diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx index f425d8c6..c2b5ff1e 100644 --- a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx +++ b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/index.jsx @@ -6,35 +6,16 @@ import { type Transaction } from '~/routes/safe/store/models/transaction' import Bold from '~/components/layout/Bold' import Paragraph from '~/components/layout/Paragraph' import Block from '~/components/layout/Block' -import { getEtherScanLink, getWeb3 } from '~/logic/wallets/getWeb3' +import { getEtherScanLink } from '~/logic/wallets/getWeb3' import { shortVersionOf } from '~/logic/wallets/ethAddresses' import { md, lg, secondary } from '~/theme/variables' - -const web3 = getWeb3() -const { toBN, fromWei } = web3.utils +import { getTxData } from './utils' const openIconStyle = { height: '13px', color: secondary, } -const getTxData = (tx: Transaction) => { - const txData = {} - - if (tx.isTokenTransfer && tx.decodedParams) { - txData.recipient = tx.decodedParams.recipient - txData.value = fromWei(toBN(tx.decodedParams.value), 'ether') - } else if (Number(tx.value) > 0) { - txData.recipient = tx.recipient - txData.value = fromWei(toBN(tx.value), 'ether') - } else if (tx.modifySettingsTx) { - txData.recipient = tx.recipient - txData.modifySettingsTx = true - } - - return txData -} - export const styles = () => ({ txDataContainer: { padding: `${lg} ${md}`, @@ -47,7 +28,9 @@ type Props = { } const TxDescription = ({ tx, classes }: Props) => { - const { recipient, value, modifySettingsTx } = getTxData(tx) + const { + recipient, value, modifySettingsTx, replacedOwner, removedOwner, addedOwner, newThreshold, + } = getTxData(tx) return ( diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/utils.js b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/utils.js new file mode 100644 index 00000000..1c311098 --- /dev/null +++ b/src/routes/safe/components/TransactionsNew/TxsTable/ExpandedTx/TxDescription/utils.js @@ -0,0 +1,41 @@ +// @flow +import { type Transaction } from '~/routes/safe/store/models/transaction' +import { getWeb3 } from '~/logic/wallets/getWeb3' + +const web3 = getWeb3() +const { toBN, fromWei } = web3.utils + +export const getTxData = (tx: Transaction) => { + const txData = {} + + if (tx.isTokenTransfer && tx.decodedParams) { + txData.recipient = tx.decodedParams.recipient + txData.value = fromWei(toBN(tx.decodedParams.value), 'ether') + } else if (Number(tx.value) > 0) { + txData.recipient = tx.recipient + txData.value = fromWei(toBN(tx.value), 'ether') + } else if (tx.modifySettingsTx) { + txData.recipient = tx.recipient + txData.modifySettingsTx = true + + if (tx.decodedParams) { + /* eslint-disable */ + if (tx.decodedParams.methodName === 'removeOwner') { + txData.removedOwner = tx.decodedParams.args[1] + txData.newThreshold = tx.decodedParams.args[2] + } else if (tx.decodedParams.methodName === 'changeThreshold') { + txData.newThreshold = tx.decodedParams.args[0] + } else if (tx.decodedParams.methodName === 'addOWnerWithThreshold') { + txData.addedOwner = tx.decodedParams.args[1] + txData.newThreshold = tx.decodedParams.args[1] + } else if (tx.decodedParams.methodName === 'swapOwner') { + txData.replacedOwner = tx.decodedParams.args[0] + txData.removedOwner = tx.decodedParams.args[1] + txData.newThreshold = tx.decodedParams.args[2] + } + /* eslint-enable */ + } + } + + return txData +}