From 54cb38b864ad0ce3463f6b7f99649a561d440c16 Mon Sep 17 00:00:00 2001 From: apane Date: Thu, 14 Nov 2019 12:19:48 -0300 Subject: [PATCH 01/13] Adds update owner's list to the polling function --- src/routes/safe/components/Layout.jsx | 1 + .../ManageOwners/RemoveOwnerModal/index.jsx | 7 +++- .../Settings/ManageOwners/index.jsx | 4 +++ src/routes/safe/components/Settings/index.jsx | 4 +++ src/routes/safe/container/actions.js | 3 +- src/routes/safe/container/index.jsx | 4 +-- src/routes/safe/store/actions/fetchSafe.js | 33 ++++++++++++++++++- 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/routes/safe/components/Layout.jsx b/src/routes/safe/components/Layout.jsx index 9eaa3d2d..9063c619 100644 --- a/src/routes/safe/components/Layout.jsx +++ b/src/routes/safe/components/Layout.jsx @@ -196,6 +196,7 @@ const Layout = (props: Props) => { network={network} userAddress={userAddress} createTransaction={createTransaction} + safe={safe} /> )} /> diff --git a/src/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/index.jsx b/src/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/index.jsx index 027e1ba2..0358f6bf 100644 --- a/src/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/index.jsx +++ b/src/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/index.jsx @@ -10,6 +10,7 @@ import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions' import CheckOwner from './screens/CheckOwner' import ThresholdForm from './screens/ThresholdForm' import ReviewRemoveOwner from './screens/Review' +import type { Safe } from '~/routes/safe/store/models/safe' const styles = () => ({ biggerModalWindow: { @@ -34,6 +35,7 @@ type Props = { removeSafeOwner: Function, enqueueSnackbar: Function, closeSnackbar: Function, + safe: Safe } type ActiveScreen = 'checkOwner' | 'selectThreshold' | 'reviewRemoveOwner' @@ -48,6 +50,7 @@ export const sendRemoveOwner = async ( closeSnackbar: Function, createTransaction: Function, removeSafeOwner: Function, + safe: Safe, ) => { const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const safeOwners = await gnosisSafe.getOwners() @@ -69,7 +72,7 @@ export const sendRemoveOwner = async ( closeSnackbar, ) - if (txHash) { + if (txHash && safe.threshold === 1) { removeSafeOwner({ safeAddress, ownerAddress: ownerAddressToRemove }) } } @@ -88,6 +91,7 @@ const RemoveOwner = ({ removeSafeOwner, enqueueSnackbar, closeSnackbar, + safe, }: Props) => { const [activeScreen, setActiveScreen] = useState('checkOwner') const [values, setValues] = useState({}) @@ -130,6 +134,7 @@ const RemoveOwner = ({ closeSnackbar, createTransaction, removeSafeOwner, + safe, ) } diff --git a/src/routes/safe/components/Settings/ManageOwners/index.jsx b/src/routes/safe/components/Settings/ManageOwners/index.jsx index 436788f0..df40790d 100644 --- a/src/routes/safe/components/Settings/ManageOwners/index.jsx +++ b/src/routes/safe/components/Settings/ManageOwners/index.jsx @@ -32,6 +32,7 @@ import ReplaceOwnerIcon from './assets/icons/replace-owner.svg' import RenameOwnerIcon from './assets/icons/rename-owner.svg' import RemoveOwnerIcon from '../assets/icons/bin.svg' import Paragraph from '~/components/layout/Paragraph/index' +import type { Safe } from '~/routes/safe/store/models/safe' export const RENAME_OWNER_BTN_TEST_ID = 'rename-owner-btn' export const REMOVE_OWNER_BTN_TEST_ID = 'remove-owner-btn' @@ -53,6 +54,7 @@ type Props = { replaceSafeOwner: Function, editSafeOwner: Function, granted: boolean, + safe: Safe } type State = { @@ -111,6 +113,7 @@ class ManageOwners extends React.Component { replaceSafeOwner, editSafeOwner, granted, + safe, } = this.props const { showAddOwner, @@ -235,6 +238,7 @@ class ManageOwners extends React.Component { userAddress={userAddress} createTransaction={createTransaction} removeSafeOwner={removeSafeOwner} + safe={safe} /> { removeSafeOwner, replaceSafeOwner, editSafeOwner, + safe, } = this.props return ( @@ -152,6 +155,7 @@ class Settings extends React.Component { replaceSafeOwner={replaceSafeOwner} editSafeOwner={editSafeOwner} granted={granted} + safe={safe} /> )} {menuOptionIndex === 3 && ( diff --git a/src/routes/safe/container/actions.js b/src/routes/safe/container/actions.js index 2dc0c895..03c49de9 100644 --- a/src/routes/safe/container/actions.js +++ b/src/routes/safe/container/actions.js @@ -1,5 +1,5 @@ // @flow -import fetchSafe from '~/routes/safe/store/actions/fetchSafe' +import fetchSafe, { checkAndUpdateSafeOwners } from '~/routes/safe/store/actions/fetchSafe' import fetchTokenBalances from '~/routes/safe/store/actions/fetchTokenBalances' import fetchEtherBalance from '~/routes/safe/store/actions/fetchEtherBalance' import createTransaction from '~/routes/safe/store/actions/createTransaction' @@ -28,4 +28,5 @@ export default { fetchTransactions, updateSafe, fetchEtherBalance, + checkAndUpdateSafeOwners, } diff --git a/src/routes/safe/container/index.jsx b/src/routes/safe/container/index.jsx index fa6b170e..7104ad3c 100644 --- a/src/routes/safe/container/index.jsx +++ b/src/routes/safe/container/index.jsx @@ -89,9 +89,9 @@ class SafeView extends React.Component { checkForUpdates() { const { - safeUrl, activeTokens, fetchTokenBalances, fetchEtherBalance, + safeUrl, activeTokens, fetchTokenBalances, fetchEtherBalance, checkAndUpdateSafeOwners, } = this.props - + checkAndUpdateSafeOwners(safeUrl) fetchTokenBalances(safeUrl, activeTokens) fetchEtherBalance(safeUrl) } diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index 84c1eb63..c4f0eaf6 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -5,9 +5,11 @@ import { type GlobalState } from '~/store/index' import { makeOwner } from '~/routes/safe/store/models/owner' import type { SafeProps } from '~/routes/safe/store/models/safe' import addSafe from '~/routes/safe/store/actions/addSafe' -import { getOwners, getSafeName } from '~/logic/safe/utils' +import { getOwners, getSafeName, SAFES_KEY } from '~/logic/safe/utils' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' import { getBalanceInEtherOf } from '~/logic/wallets/getWeb3' +import { loadFromStorage } from '~/utils/storage' +import updateSafe from '~/routes/safe/store/actions/updateSafe' const buildOwnersFrom = ( safeOwners: string[], @@ -35,6 +37,35 @@ export const buildSafe = async (safeAddress: string, safeName: string) => { return safe } +const getLocalSafe = async (safeAddress: string) => { + const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} + return storedSafes[safeAddress] +} + +export const checkAndUpdateSafeOwners = (safeAddress: string) => async ( + dispatch: ReduxDispatch, +) => { + // Check if the owner's safe did change and update them + const [gnosisSafe, localSafe] = await Promise.all([getGnosisSafeInstanceAt(safeAddress), getLocalSafe(safeAddress)]) + const remoteOwners = await gnosisSafe.getOwners() + const localOwners = localSafe.owners.map((localOwner) => localOwner.address) + + if (remoteOwners.length !== localOwners.length) { + dispatch(updateSafe({ address: safeAddress, owners: remoteOwners })) + return + } + + // eslint-disable-next-line no-restricted-syntax + for (const remoteIterator of remoteOwners) { + if (!localOwners.includes(remoteIterator)) { + dispatch(updateSafe({ address: safeAddress, owners: remoteOwners })) + + return + } + } +} + +// eslint-disable-next-line consistent-return export default (safeAddress: string) => async (dispatch: ReduxDispatch) => { try { const safeName = (await getSafeName(safeAddress)) || 'LOADED SAFE' From 1c8f6b42c50ed7be56ba5e7c6f6c1dac8b276283 Mon Sep 17 00:00:00 2001 From: apane Date: Thu, 14 Nov 2019 13:46:35 -0300 Subject: [PATCH 02/13] Adds update owner's list to the polling function --- src/routes/safe/store/actions/fetchSafe.js | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index c4f0eaf6..bf54d7c8 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -9,7 +9,8 @@ import { getOwners, getSafeName, SAFES_KEY } from '~/logic/safe/utils' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' import { getBalanceInEtherOf } from '~/logic/wallets/getWeb3' import { loadFromStorage } from '~/utils/storage' -import updateSafe from '~/routes/safe/store/actions/updateSafe' +import removeSafeOwner from '~/routes/safe/store/actions/removeSafeOwner' +import addSafeOwner from '~/routes/safe/store/actions/addSafeOwner' const buildOwnersFrom = ( safeOwners: string[], @@ -48,21 +49,22 @@ export const checkAndUpdateSafeOwners = (safeAddress: string) => async ( // Check if the owner's safe did change and update them const [gnosisSafe, localSafe] = await Promise.all([getGnosisSafeInstanceAt(safeAddress), getLocalSafe(safeAddress)]) const remoteOwners = await gnosisSafe.getOwners() + // Converts from [ { address, ownerName} ] to address array const localOwners = localSafe.owners.map((localOwner) => localOwner.address) - if (remoteOwners.length !== localOwners.length) { - dispatch(updateSafe({ address: safeAddress, owners: remoteOwners })) - return - } - - // eslint-disable-next-line no-restricted-syntax - for (const remoteIterator of remoteOwners) { - if (!localOwners.includes(remoteIterator)) { - dispatch(updateSafe({ address: safeAddress, owners: remoteOwners })) - - return + // If the remote owners does not contain a local address, we remove that local owner + localOwners.forEach((localAddress) => { + if (!remoteOwners.includes(localAddress)) { + dispatch(removeSafeOwner({ safeAddress, ownerAddress: localAddress })) } - } + }) + + // If the remote has an owner that we don't have locally, we add it + remoteOwners.forEach((remoteAddress) => { + if (!localOwners.includes(remoteAddress)) { + dispatch(addSafeOwner({ safeAddress, ownerAddress: remoteAddress, ownerName: 'UNKNOWN' })) + } + }) } // eslint-disable-next-line consistent-return From 94b89b0ad0ae22984e7226e43c2986704f63fde8 Mon Sep 17 00:00:00 2001 From: apane Date: Thu, 14 Nov 2019 15:16:15 -0300 Subject: [PATCH 03/13] In order to replace the owner, first checks that the threshold is 1 --- .../Settings/ManageOwners/ReplaceOwnerModal/index.jsx | 7 ++++++- src/routes/safe/components/Settings/ManageOwners/index.jsx | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/index.jsx b/src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/index.jsx index c18f9e47..1a930be2 100644 --- a/src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/index.jsx +++ b/src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/index.jsx @@ -9,6 +9,7 @@ import { TX_NOTIFICATION_TYPES } from '~/logic/safe/transactions' import { getGnosisSafeInstanceAt, SENTINEL_ADDRESS } from '~/logic/contracts/safeContracts' import OwnerForm from './screens/OwnerForm' import ReviewReplaceOwner from './screens/Review' +import type { Safe } from '~/routes/safe/store/models/safe' const styles = () => ({ biggerModalWindow: { @@ -33,6 +34,7 @@ type Props = { replaceSafeOwner: Function, enqueueSnackbar: Function, closeSnackbar: Function, + safe: Safe, } type ActiveScreen = 'checkOwner' | 'reviewReplaceOwner' @@ -44,6 +46,7 @@ export const sendReplaceOwner = async ( closeSnackbar: Function, createTransaction: Function, replaceSafeOwner: Function, + safe: Safe, ) => { const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const safeOwners = await gnosisSafe.getOwners() @@ -65,7 +68,7 @@ export const sendReplaceOwner = async ( closeSnackbar, ) - if (txHash) { + if (txHash && safe.threshold === 1) { replaceSafeOwner({ safeAddress, oldOwnerAddress: ownerAddressToRemove, @@ -89,6 +92,7 @@ const ReplaceOwner = ({ replaceSafeOwner, enqueueSnackbar, closeSnackbar, + safe, }: Props) => { const [activeScreen, setActiveScreen] = useState('checkOwner') const [values, setValues] = useState({}) @@ -121,6 +125,7 @@ const ReplaceOwner = ({ closeSnackbar, createTransaction, replaceSafeOwner, + safe, ) } catch (error) { console.error('Error while removing an owner', error) diff --git a/src/routes/safe/components/Settings/ManageOwners/index.jsx b/src/routes/safe/components/Settings/ManageOwners/index.jsx index df40790d..10a664c4 100644 --- a/src/routes/safe/components/Settings/ManageOwners/index.jsx +++ b/src/routes/safe/components/Settings/ManageOwners/index.jsx @@ -253,6 +253,7 @@ class ManageOwners extends React.Component { userAddress={userAddress} createTransaction={createTransaction} replaceSafeOwner={replaceSafeOwner} + safe={safe} /> Date: Tue, 19 Nov 2019 19:27:41 +0400 Subject: [PATCH 04/13] Restore lost refactor for new tx history service --- src/routes/safe/store/actions/fetchTransactions.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index cbbdb2d7..4eee62fc 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -14,7 +14,6 @@ import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { addTransactions } from './addTransactions' import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens' import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers' -import { TX_TYPE_EXECUTION } from '~/logic/safe/transactions' import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds' import { ALTERNATIVE_TOKEN_ABI } from '~/logic/tokens/utils/alternativeAbi' @@ -38,6 +37,7 @@ type TxServiceModel = { executionDate: string, confirmations: ConfirmationServiceModel[], isExecuted: boolean, + transactionHash: string, } export const buildTransactionFrom = async ( @@ -63,13 +63,6 @@ export const buildTransactionFrom = async ( const isSendTokenTx = await isTokenTransfer(tx.data, tx.value) const customTx = tx.to !== safeAddress && !!tx.data && !isSendTokenTx - let executionTxHash - const executionTx = confirmations.find((conf) => conf.type === TX_TYPE_EXECUTION) - - if (executionTx) { - executionTxHash = executionTx.hash - } - let symbol = 'ETH' let decimals = 18 let decodedParams @@ -112,7 +105,7 @@ export const buildTransactionFrom = async ( isExecuted: tx.isExecuted, submissionDate: tx.submissionDate, executionDate: tx.executionDate, - executionTxHash, + executionTxHash: tx.transactionHash, safeTxHash: tx.safeTxHash, isTokenTransfer: isSendTokenTx, decodedParams, From dffb531a45b5b68237fca2e311ef3c00c7004f7b Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Wed, 20 Nov 2019 11:15:39 +0400 Subject: [PATCH 05/13] Set max-width for owner name, show '...' if it doesn't fit into table cell --- package.json | 2 +- src/components/Table/TableHead.jsx | 2 +- src/theme/mui.js | 3 +++ yarn.lock | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ea52704d..7421627f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "qrcode.react": "1.0.0", "react": "16.12.0", "react-dom": "16.12.0", - "react-final-form": "6.3.2", + "react-final-form": "6.3.3", "react-final-form-listeners": "^1.0.2", "react-hot-loader": "4.12.18", "react-qr-reader": "^2.2.1", diff --git a/src/components/Table/TableHead.jsx b/src/components/Table/TableHead.jsx index 07e38c78..428d7515 100644 --- a/src/components/Table/TableHead.jsx +++ b/src/components/Table/TableHead.jsx @@ -24,7 +24,7 @@ export const cellWidth = (width: number | typeof undefined) => { } return { - width: `${width}px`, + maxWidth: `${width}px`, } } diff --git a/src/theme/mui.js b/src/theme/mui.js index 3d88cd59..44188038 100644 --- a/src/theme/mui.js +++ b/src/theme/mui.js @@ -285,6 +285,9 @@ export default createMuiTheme({ fontWeight: 'normal', paddingTop: xs, paddingBottom: xs, + overflow: 'hidden', + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', }, }, MuiBackdrop: { diff --git a/yarn.lock b/yarn.lock index 585cfcdd..d5da1ee0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14901,10 +14901,10 @@ react-final-form-listeners@^1.0.2: dependencies: "@babel/runtime" "^7.1.5" -react-final-form@6.3.2: - version "6.3.2" - resolved "https://registry.yarnpkg.com/react-final-form/-/react-final-form-6.3.2.tgz#2c331540c8f5cbf6fbe75ecd98849a03b34dba6e" - integrity sha512-3eXCd9ScouKbf7GJubhUP0s8+aYCsltjjWZtvOKV+E0AeRjXmzQZfUAsKM+395+v1dLIyenB3x22ZQms2tWFRQ== +react-final-form@6.3.3: + version "6.3.3" + resolved "https://registry.yarnpkg.com/react-final-form/-/react-final-form-6.3.3.tgz#8856a92278de2733f83e88c75d9ef347294a66a0" + integrity sha512-hFLwLpLasywky46SovNEGlym7+N+3RKge1/cg+/fVec/YY0l4g0ihgjRof6PbkiYe4qGjKbwbrvlgfZ9/Uf8vw== dependencies: "@babel/runtime" "^7.4.5" ts-essentials "^3.0.2" From 36fec0f62dcbcf67ead4ddb5154162b852e4b2b8 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Wed, 20 Nov 2019 11:43:16 +0400 Subject: [PATCH 06/13] Allow scrolling modal view if its outside the screen --- src/components/Modal/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Modal/index.jsx b/src/components/Modal/index.jsx index def43bd7..b10ee819 100644 --- a/src/components/Modal/index.jsx +++ b/src/components/Modal/index.jsx @@ -20,6 +20,7 @@ const styles = () => ({ alignItems: 'center', justifyContent: 'center', display: 'flex', + overflowY: 'scroll', }, paper: { position: 'absolute', From 3183e3b62695dc020955ce6aecf6400c2b6a64d4 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Wed, 20 Nov 2019 14:01:49 +0400 Subject: [PATCH 07/13] Show newly created tx as pending one --- .../Transactions/TxsTable/Status/index.jsx | 29 ++++++++++++++----- .../Transactions/TxsTable/Status/style.js | 4 +++ src/routes/safe/container/selector.js | 2 ++ .../safe/store/actions/createTransaction.js | 1 + .../safe/store/actions/processTransaction.js | 1 + src/routes/safe/store/models/transaction.js | 4 +-- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx b/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx index 84f48f86..e5ccd96a 100644 --- a/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx @@ -1,6 +1,7 @@ // @flow import * as React from 'react' import { withStyles } from '@material-ui/core/styles' +import CircularProgress from '@material-ui/core/CircularProgress' import Block from '~/components/layout/Block' import Paragraph from '~/components/layout/Paragraph/' import Img from '~/components/layout/Img' @@ -12,14 +13,15 @@ import { styles } from './style' type Props = { classes: Object, - status: TransactionStatus, -} + status: TransactionStatus +}; const statusToIcon = { success: OkIcon, cancelled: ErrorIcon, awaiting_confirmations: AwaitingIcon, awaiting_execution: AwaitingIcon, + pending: , } const statusToLabel = { @@ -27,6 +29,7 @@ const statusToLabel = { cancelled: 'Cancelled', awaiting_confirmations: 'Awaiting', awaiting_execution: 'Awaiting', + pending: 'Pending', } const statusIconStyle = { @@ -34,11 +37,21 @@ const statusIconStyle = { width: '14px', } -const Status = ({ classes, status }: Props) => ( - - OK Icon - {statusToLabel[status]} - -) +const Status = ({ classes, status }: Props) => { + const Icon = statusToIcon[status] + + return ( + + {typeof Icon === 'object' ? ( + Icon + ) : ( + OK Icon + )} + + {statusToLabel[status]} + + + ) +} export default withStyles(styles)(Status) diff --git a/src/routes/safe/components/Transactions/TxsTable/Status/style.js b/src/routes/safe/components/Transactions/TxsTable/Status/style.js index 10ffb27b..8de70a09 100644 --- a/src/routes/safe/components/Transactions/TxsTable/Status/style.js +++ b/src/routes/safe/components/Transactions/TxsTable/Status/style.js @@ -29,6 +29,10 @@ export const styles = () => ({ backgroundColor: '#dfebff', color: disabled, }, + pending: { + backgroundColor: '#fff3e2', + color: '#e8673c', + }, statusText: { marginLeft: 'auto', textTransform: 'uppercase', diff --git a/src/routes/safe/container/selector.js b/src/routes/safe/container/selector.js index 259035d0..33ba0af4 100644 --- a/src/routes/safe/container/selector.js +++ b/src/routes/safe/container/selector.js @@ -41,6 +41,8 @@ const getTxStatus = (tx: Transaction, safe: Safe): TransactionStatus => { txStatus = 'cancelled' } else if (tx.confirmations.size === safe.threshold) { txStatus = 'awaiting_execution' + } else if (!tx.confirmations.size) { + txStatus = 'pending' } return txStatus diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index 04ff30d1..b62c9432 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -85,6 +85,7 @@ const createTransaction = ( from, isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, ) + dispatch(fetchTransactions(safeAddress)) } catch (err) { console.error(err) } diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index e3425387..2d1c038d 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -121,6 +121,7 @@ const processTransaction = ( from, shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, ) + dispatch(fetchTransactions(safeAddress)) } catch (err) { console.error(err) } diff --git a/src/routes/safe/store/models/transaction.js b/src/routes/safe/store/models/transaction.js index c0b598da..ca2493a0 100644 --- a/src/routes/safe/store/models/transaction.js +++ b/src/routes/safe/store/models/transaction.js @@ -3,10 +3,9 @@ import { List, Record } from 'immutable' import type { RecordFactory, RecordOf } from 'immutable' import { type Confirmation } from '~/routes/safe/store/models/confirmation' -export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' +export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' | 'pending' export type TransactionProps = { - name: string, nonce: number, value: string, confirmations: List, @@ -29,7 +28,6 @@ export type TransactionProps = { } export const makeTransaction: RecordFactory = Record({ - name: '', nonce: 0, value: 0, confirmations: List([]), From 30980ed747d0afae77843737a74fe972e2ad961b Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Wed, 20 Nov 2019 14:08:21 +0400 Subject: [PATCH 08/13] eslint fix --- .../safe/components/Transactions/TxsTable/Status/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx b/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx index e5ccd96a..3592f655 100644 --- a/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/Status/index.jsx @@ -13,8 +13,8 @@ import { styles } from './style' type Props = { classes: Object, - status: TransactionStatus -}; + status: TransactionStatus, +} const statusToIcon = { success: OkIcon, From 04540790ea2174822b03168c8fbe7e749d5027b6 Mon Sep 17 00:00:00 2001 From: Richard Meissner Date: Mon, 16 Sep 2019 20:16:03 +0200 Subject: [PATCH 09/13] Support off chain signatures Support transactions with refund Display refund in UI --- src/logic/safe/transactions/send.js | 23 +++++--- src/logic/safe/transactions/txHistory.js | 48 +++++++++++---- src/logic/wallets/ethAddresses.js | 2 + .../ExpandedTx/TxDescription/utils.js | 3 + .../TxsTable/ExpandedTx/index.jsx | 10 ++++ src/routes/safe/container/selector.js | 5 +- .../safe/store/actions/createTransaction.js | 16 ++++- .../safe/store/actions/fetchTransactions.js | 35 +++++++++++ .../safe/store/actions/processTransaction.js | 58 ++++++++++++++----- src/routes/safe/store/models/confirmation.js | 2 + src/routes/safe/store/models/transaction.js | 19 +++++- 11 files changed, 179 insertions(+), 42 deletions(-) diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index ba1044a3..a82fc6e3 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -15,6 +15,11 @@ export const getApprovalTransaction = async ( data: string, operation: Operation, nonce: number, + safeTxGas: number, + baseGas: number, + gasPrice: number, + gasToken: string, + refundReceiver: string, sender: string, ) => { const txHash = await safeInstance.getTransactionHash( @@ -22,11 +27,11 @@ export const getApprovalTransaction = async ( valueInWei, data, operation, - 0, - 0, - 0, - ZERO_ADDRESS, - ZERO_ADDRESS, + safeTxGas, + baseGas, + gasPrice, + gasToken, + refundReceiver, nonce, { from: sender, @@ -40,7 +45,6 @@ export const getApprovalTransaction = async ( return contract.methods.approveHash(txHash) } catch (err) { console.error(`Error while approving transaction: ${err}`) - throw err } } @@ -52,6 +56,11 @@ export const getExecutionTransaction = async ( data: string, operation: Operation, nonce: string | number, + safeTxGas: string | number, + baseGas: string | number, + gasPrice: string | number, + gasToken: string, + refundReceiver: string, sender: string, sigs: string, ) => { @@ -59,7 +68,7 @@ export const getExecutionTransaction = async ( const web3 = getWeb3() const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address) - return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs) + return contract.methods.execTransaction(to, valueInWei, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, sigs) } catch (err) { console.error(`Error while creating transaction: ${err}`) diff --git a/src/logic/safe/transactions/txHistory.js b/src/logic/safe/transactions/txHistory.js index d29e69c4..5e6c0a1d 100644 --- a/src/logic/safe/transactions/txHistory.js +++ b/src/logic/safe/transactions/txHistory.js @@ -2,7 +2,6 @@ import axios from 'axios' import { getWeb3 } from '~/logic/wallets/getWeb3' import { getTxServiceUriFrom, getTxServiceHost } from '~/config' -import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' export type TxServiceType = 'confirmation' | 'execution' | 'initialised' export type Operation = 0 | 1 | 2 @@ -14,6 +13,11 @@ const calculateBodyFrom = async ( data: string, operation: Operation, nonce: string | number, + safeTxGas: string | number, + baseGas: string | number, + gasPrice: string | number, + gasToken: string, + refundReceiver: string, transactionHash: string, sender: string, confirmationType: TxServiceType, @@ -23,11 +27,11 @@ const calculateBodyFrom = async ( valueInWei, data, operation, - 0, - 0, - 0, - ZERO_ADDRESS, - ZERO_ADDRESS, + safeTxGas, + baseGas, + gasPrice, + gasToken, + refundReceiver, nonce, ) @@ -37,11 +41,11 @@ const calculateBodyFrom = async ( data, operation, nonce, - safeTxGas: 0, - baseGas: 0, - gasPrice: 0, - gasToken: ZERO_ADDRESS, - refundReceiver: ZERO_ADDRESS, + safeTxGas, + baseGas, + gasPrice, + gasToken, + refundReceiver, contractTransactionHash, transactionHash, sender: getWeb3().utils.toChecksumAddress(sender), @@ -63,12 +67,32 @@ export const saveTxToHistory = async ( data: string, operation: Operation, nonce: number | string, + safeTxGas: string | number, + baseGas: string | number, + gasPrice: string | number, + gasToken: string, + refundReceiver: string, txHash: string, sender: string, type: TxServiceType, ) => { const url = buildTxServiceUrl(safeInstance.address) - const body = await calculateBodyFrom(safeInstance, to, valueInWei, data, operation, nonce, txHash, sender, type) + const body = await calculateBodyFrom( + safeInstance, + to, + valueInWei, + data, + operation, + nonce, + safeTxGas, + baseGas, + gasPrice, + gasToken, + refundReceiver, + txHash, + sender, + type, + ) const response = await axios.post(url, body) if (response.status !== 202) { diff --git a/src/logic/wallets/ethAddresses.js b/src/logic/wallets/ethAddresses.js index 34c0a9bc..6bb7d2f2 100644 --- a/src/logic/wallets/ethAddresses.js +++ b/src/logic/wallets/ethAddresses.js @@ -16,5 +16,7 @@ export const sameAddress = (firstAddress: string, secondAddress: string): boolea export const shortVersionOf = (address: string, cut: number) => { const final = 42 - cut + if (!address) return 'Unknown address' + if (address.length < final) return address return `${address.substring(0, cut)}...${address.substring(final)}` } diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/utils.js b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/utils.js index a55c986a..632cf927 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/utils.js +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/TxDescription/utils.js @@ -54,6 +54,9 @@ export const getTxData = (tx: Transaction): DecodedTxData => { } } else if (tx.cancellationTx) { txData.cancellationTx = true + } else { + txData.recipient = tx.recipient + txData.value = 0 } return txData diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx index fa484b03..e4c47510 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx @@ -98,6 +98,16 @@ const ExpandedTx = ({ {formatDate(tx.executionDate)} )} + {tx.refundParams && ( + + TX refund: + max. + {' '} + {tx.refundParams.fee} + {' '} + {tx.refundParams.symbol} + + )} diff --git a/src/routes/safe/container/selector.js b/src/routes/safe/container/selector.js index 259035d0..bcc02853 100644 --- a/src/routes/safe/container/selector.js +++ b/src/routes/safe/container/selector.js @@ -1,7 +1,6 @@ // @flow import { List, Map } from 'immutable' import { createSelector, createStructuredSelector, type Selector } from 'reselect' -import { isAfter, parseISO } from 'date-fns' import { safeSelector, safeActiveTokensSelector, @@ -115,9 +114,7 @@ const extendedTransactionsSelector: Selector (transaction.nonce === tx.nonce - && isAfter(parseISO(transaction.submissionDate), parseISO(tx.submissionDate))) - || transaction.nonce > tx.nonce, + (transaction) => transaction.isExecuted && transaction.nonce >= tx.nonce, ) if (replacementTransaction) { extendedTx = tx.set('cancelled', true) diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index 04ff30d1..437d92c2 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -54,9 +54,15 @@ const createTransaction = ( let tx try { if (isExecution) { - tx = await getExecutionTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from, sigs) + tx = await getExecutionTransaction( + safeInstance, to, valueInWei, txData, CALL, nonce, + 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, from, sigs + ) } else { - tx = await getApprovalTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from) + tx = await getApprovalTransaction( + safeInstance, to, valueInWei, txData, CALL, nonce, + 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, from, sigs + ) } const sendParams = { from, value: 0 } @@ -81,6 +87,11 @@ const createTransaction = ( txData, CALL, nonce, + 0, + 0, + 0, + ZERO_ADDRESS, + ZERO_ADDRESS, txHash, from, isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, @@ -94,7 +105,6 @@ const createTransaction = ( }) .then((receipt) => { closeSnackbar(pendingExecutionKey) - showSnackbar( isExecution ? notificationsQueue.afterExecution.noMoreConfirmationsNeeded diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index 4eee62fc..c5c334a3 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -16,6 +16,7 @@ import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens' import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers' import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds' import { ALTERNATIVE_TOKEN_ABI } from '~/logic/tokens/utils/alternativeAbi' +import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' let web3 @@ -32,6 +33,11 @@ type TxServiceModel = { data: string, operation: number, nonce: number, + safeTxGas: number, + baseGas: number, + gasPrice: number, + gasToken: string, + refundReceiver: string, safeTxHash: string, submissionDate: string, executionDate: string, @@ -55,6 +61,7 @@ export const buildTransactionFrom = async ( owner: makeOwner({ address: conf.owner, name: ownerName }), type: ((conf.confirmationType.toLowerCase(): any): TxServiceType), hash: conf.transactionHash, + signature: conf.signature, }) }), ) @@ -63,6 +70,27 @@ export const buildTransactionFrom = async ( const isSendTokenTx = await isTokenTransfer(tx.data, tx.value) const customTx = tx.to !== safeAddress && !!tx.data && !isSendTokenTx + let refundParams = null + if (tx.gasPrice > 0) { + let refundSymbol = 'ETH' + let decimals = 18 + if (tx.gasToken !== ZERO_ADDRESS) { + const gasToken = await (await getHumanFriendlyToken()).at(tx.gasToken) + refundSymbol = await gasToken.symbol() + decimals = await gasToken.decimals() + } + + const feeString = (tx.gasPrice * (tx.baseGas + tx.safeTxGas)).toString().padStart(decimals, 0) + const whole = feeString.slice(0, feeString.length - decimals) || '0' + const fraction = feeString.slice(feeString.length - decimals) + + const formattedFee = `${whole}.${fraction}` + refundParams = { + fee: formattedFee, + symbol: refundSymbol, + } + } + let symbol = 'ETH' let decimals = 18 let decodedParams @@ -102,6 +130,13 @@ export const buildTransactionFrom = async ( decimals, recipient: tx.to, data: tx.data ? tx.data : EMPTY_DATA, + operation: tx.operation, + safeTxGas: tx.safeTxGas, + baseGas: tx.baseGas, + gasPrice: tx.gasPrice, + gasToken: tx.gasToken, + refundReceiver: tx.refundReceiver, + refundParams, isExecuted: tx.isExecuted, submissionDate: tx.submissionDate, executionDate: tx.executionDate, diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index e3425387..78d03a50 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -11,7 +11,6 @@ import { type NotifiedTransaction, getApprovalTransaction, getExecutionTransaction, - CALL, saveTxToHistory, TX_TYPE_EXECUTION, TX_TYPE_CONFIRMATION, @@ -31,18 +30,27 @@ export const generateSignaturesFromTxConfirmations = ( ) => { // The constant parts need to be sorted so that the recovered signers are sorted ascending // (natural order) by address (not checksummed). - let confirmedAdresses = confirmations.map((conf) => conf.owner.address) + const confirmationsMap = confirmations.reduce((map, obj) => { + map[obj.owner.address] = obj // eslint-disable-line no-param-reassign + return map + }, {}) if (preApprovingOwner) { - confirmedAdresses = confirmedAdresses.push(preApprovingOwner) + confirmationsMap[preApprovingOwner] = { owner: preApprovingOwner } } let sigs = '0x' - confirmedAdresses.sort().forEach((addr) => { - sigs += `000000000000000000000000${addr.replace( - '0x', - '', - )}000000000000000000000000000000000000000000000000000000000000000001` + Object.keys(confirmationsMap).sort().forEach((addr) => { + const conf = confirmationsMap[addr] + if (conf.signature) { + sigs += conf.signature.slice(2) + } else { + // https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures + sigs += `000000000000000000000000${addr.replace( + '0x', + '', + )}000000000000000000000000000000000000000000000000000000000000000001` + } }) return sigs } @@ -60,7 +68,6 @@ const processTransaction = ( const safeInstance = await getGnosisSafeInstanceAt(safeAddress) const from = userAccountSelector(state) - const nonce = (await safeInstance.nonce()).toString() const threshold = (await safeInstance.getThreshold()).toNumber() const shouldExecute = threshold === tx.confirmations.size || approveAndExecute @@ -86,13 +93,31 @@ const processTransaction = ( tx.recipient, tx.value, tx.data, - CALL, - nonce, + tx.operation, + tx.nonce, + tx.safeTxGas, + tx.baseGas, + tx.gasPrice, + tx.gasToken, + tx.refundReceiver, from, sigs, ) } else { - transaction = await getApprovalTransaction(safeInstance, tx.recipient, tx.value, tx.data, CALL, nonce, from) + transaction = await getApprovalTransaction( + safeInstance, + tx.recipient, + tx.value, + tx.data, + tx.operation, + tx.nonce, + tx.safeTxGas, + tx.baseGas, + tx.gasPrice, + tx.gasToken, + tx.refundReceiver, + from, + ) } const sendParams = { from, value: 0 } @@ -115,8 +140,13 @@ const processTransaction = ( tx.recipient, tx.value, tx.data, - CALL, - nonce, + tx.operation, + tx.nonce, + tx.safeTxGas, + tx.baseGas, + tx.gasPrice, + tx.gasToken, + tx.refundReceiver, txHash, from, shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, diff --git a/src/routes/safe/store/models/confirmation.js b/src/routes/safe/store/models/confirmation.js index 49c2f01d..120ab48f 100644 --- a/src/routes/safe/store/models/confirmation.js +++ b/src/routes/safe/store/models/confirmation.js @@ -8,12 +8,14 @@ export type ConfirmationProps = { owner: Owner, type: TxServiceType, hash: string, + signature?: string, } export const makeConfirmation: RecordFactory = Record({ owner: makeOwner(), type: 'initialised', hash: '', + signature: null, }) export type Confirmation = RecordOf diff --git a/src/routes/safe/store/models/transaction.js b/src/routes/safe/store/models/transaction.js index c0b598da..c7b64c68 100644 --- a/src/routes/safe/store/models/transaction.js +++ b/src/routes/safe/store/models/transaction.js @@ -2,6 +2,7 @@ import { List, Record } from 'immutable' import type { RecordFactory, RecordOf } from 'immutable' import { type Confirmation } from '~/routes/safe/store/models/confirmation' +import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' @@ -11,7 +12,13 @@ export type TransactionProps = { value: string, confirmations: List, recipient: string, - data: string, + data?: string, + operation: number, + safeTxGas: number, + baseGas: number, + gasPrice: number, + gasToken: string, + refundReceiver: string, isExecuted: boolean, submissionDate: string, executionDate: string, @@ -26,6 +33,7 @@ export type TransactionProps = { status?: TransactionStatus, isTokenTransfer: boolean, decodedParams?: Object, + refundParams?: Object, } export const makeTransaction: RecordFactory = Record({ @@ -34,7 +42,13 @@ export const makeTransaction: RecordFactory = Record({ value: 0, confirmations: List([]), recipient: '', - data: '', + data: null, + operation: 0, + safeTxGas: 0, + baseGas: 0, + gasPrice: 0, + gasToken: ZERO_ADDRESS, + refundReceiver: ZERO_ADDRESS, isExecuted: false, submissionDate: '', executionDate: '', @@ -49,6 +63,7 @@ export const makeTransaction: RecordFactory = Record({ decimals: 18, isTokenTransfer: false, decodedParams: {}, + refundParams: null, }) export type Transaction = RecordOf From 8ec6bcf2935162f3b9ff575c4c2f914b99b08d26 Mon Sep 17 00:00:00 2001 From: Richard Meissner Date: Wed, 20 Nov 2019 23:28:59 +0100 Subject: [PATCH 10/13] Show call type in UI if not call --- .../Transactions/TxsTable/ExpandedTx/index.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx index e4c47510..81f3bdc4 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/index.jsx @@ -108,6 +108,16 @@ const ExpandedTx = ({ {tx.refundParams.symbol} )} + {tx.operation === 1 && ( + + Delegate Call + + )} + {tx.operation === 2 && ( + + Contract Creation + + )} From 88d04531682ebbbdf731eb50f500fc84e9cf8799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Thu, 21 Nov 2019 13:09:31 +0100 Subject: [PATCH 11/13] Fix generation of signatures from tx confirmations --- .../safe/store/actions/processTransaction.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index e3425387..7953e531 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -31,18 +31,27 @@ export const generateSignaturesFromTxConfirmations = ( ) => { // The constant parts need to be sorted so that the recovered signers are sorted ascending // (natural order) by address (not checksummed). - let confirmedAdresses = confirmations.map((conf) => conf.owner.address) + const confirmationsMap = confirmations.reduce((map, obj) => { + map[obj.owner.address] = obj // eslint-disable-line no-param-reassign + return map + }, {}) if (preApprovingOwner) { - confirmedAdresses = confirmedAdresses.push(preApprovingOwner) + confirmationsMap[preApprovingOwner] = { owner: preApprovingOwner } } let sigs = '0x' - confirmedAdresses.sort().forEach((addr) => { - sigs += `000000000000000000000000${addr.replace( - '0x', - '', - )}000000000000000000000000000000000000000000000000000000000000000001` + Object.keys(confirmationsMap).sort().forEach((addr) => { + const conf = confirmationsMap[addr] + if (conf.signature) { + sigs += conf.signature.slice(2) + } else { + // https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures + sigs += `000000000000000000000000${addr.replace( + '0x', + '', + )}000000000000000000000000000000000000000000000000000000000000000001` + } }) return sigs } From 0bd9353e603506b974cb87ea89c248f2c1b3a582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Fri, 22 Nov 2019 12:24:23 +0100 Subject: [PATCH 12/13] Fix confirmation+execution check --- .../TxsTable/ExpandedTx/ApproveTxModal/index.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx index a8dadc3f..55414fda 100644 --- a/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx +++ b/src/routes/safe/components/Transactions/TxsTable/ExpandedTx/ApproveTxModal/index.jsx @@ -64,10 +64,10 @@ const ApproveTxModal = ({ enqueueSnackbar, closeSnackbar, }: Props) => { - const [approveAndExecute, setApproveAndExecute] = useState(true) + const oneConfirmationLeft = !thresholdReached && tx.confirmations.size + 1 === threshold + const [approveAndExecute, setApproveAndExecute] = useState(oneConfirmationLeft || thresholdReached) const [gasCosts, setGasCosts] = useState('< 0.001') const { title, description } = getModalTitleAndDescription(thresholdReached) - const oneConfirmationLeft = tx.confirmations.size + 1 === threshold useEffect(() => { let isCurrent = true @@ -107,7 +107,7 @@ const ApproveTxModal = ({ TX_NOTIFICATION_TYPES.CONFIRMATION_TX, enqueueSnackbar, closeSnackbar, - approveAndExecute, + approveAndExecute && oneConfirmationLeft, ) onClose() } @@ -131,7 +131,7 @@ const ApproveTxModal = ({
{tx.nonce} - {!thresholdReached && oneConfirmationLeft && ( + {oneConfirmationLeft && ( <> Approving this transaction executes it right away. If you want approve but execute the transaction From 970e57a1713d25db04d271e5e01a77db6ca4315e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Fri, 22 Nov 2019 14:22:44 +0100 Subject: [PATCH 13/13] 1.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7421627f..4862c2c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safe-react", - "version": "1.0.1", + "version": "1.4.3", "description": "Allowing crypto users manage funds in a safer way", "homepage": "https://github.com/gnosis/safe-react#readme", "bugs": {