display module tx information

This commit is contained in:
fernandomg 2020-07-16 23:09:24 -03:00
parent 6442b52562
commit eab41bd314
3 changed files with 62 additions and 1 deletions

View File

@ -43,6 +43,8 @@ export const SAFE_METHODS_NAMES = {
CHANGE_THRESHOLD: 'changeThreshold',
REMOVE_OWNER: 'removeOwner',
SWAP_OWNER: 'swapOwner',
ENABLE_MODULE: 'enableModule',
DISABLE_MODULE: 'disableModule',
}
const METHOD_TO_ID = {
@ -50,6 +52,8 @@ const METHOD_TO_ID = {
'0x0d582f13': SAFE_METHODS_NAMES.ADD_OWNER_WITH_THRESHOLD,
'0xf8dc5dd9': SAFE_METHODS_NAMES.REMOVE_OWNER,
'0x694e80c3': SAFE_METHODS_NAMES.CHANGE_THRESHOLD,
'0x610b5925': SAFE_METHODS_NAMES.ENABLE_MODULE,
'0xe009cfde': SAFE_METHODS_NAMES.DISABLE_MODULE,
}
type SafeMethods = typeof SAFE_METHODS_NAMES[keyof typeof SAFE_METHODS_NAMES]
@ -127,6 +131,29 @@ export const decodeParamsFromSafeMethod = (data: string): DataDecoded | null =>
}
}
// enableModule
case '0x610b5925': {
const decodedParameters = web3.eth.abi.decodeParameters(['address'], params)
return {
method: METHOD_TO_ID[methodId],
parameters: [
{ name: 'module', type: '', value: decodedParameters[0] },
],
}
}
// disableModule
case '0xe009cfde': {
const decodedParameters = web3.eth.abi.decodeParameters(['address', 'address'], params)
return {
method: METHOD_TO_ID[methodId],
parameters: [
{ name: 'prevModule', type: '', value: decodedParameters[0] },
{ name: 'module', type: '', value: decodedParameters[1] },
],
}
}
default:
return null
}

View File

@ -23,6 +23,8 @@ export const TRANSACTIONS_DESC_CHANGE_THRESHOLD_TEST_ID = 'tx-description-change
export const TRANSACTIONS_DESC_SEND_TEST_ID = 'tx-description-send'
export const TRANSACTIONS_DESC_CUSTOM_VALUE_TEST_ID = 'tx-description-custom-value'
export const TRANSACTIONS_DESC_CUSTOM_DATA_TEST_ID = 'tx-description-custom-data'
export const TRANSACTIONS_DESC_ADD_MODULE_TEST_ID = 'tx-description-add-module'
export const TRANSACTIONS_DESC_REMOVE_MODULE_TEST_ID = 'tx-description-remove-module'
export const TRANSACTIONS_DESC_NO_DATA = 'tx-description-no-data'
export const styles = () => ({
@ -96,7 +98,21 @@ const NewThreshold = ({ newThreshold }) => (
</Block>
)
const SettingsDescription = ({ action, addedOwner, newThreshold, removedOwner }) => {
const AddModule = ({ module }) => (
<Block data-testid={TRANSACTIONS_DESC_ADD_MODULE_TEST_ID}>
<Bold>Add module:</Bold>
<EtherscanLink value={module} knownAddress={false} type="address" />
</Block>
)
const RemoveModule = ({ module }) => (
<Block data-testid={TRANSACTIONS_DESC_REMOVE_MODULE_TEST_ID}>
<Bold>Remove module:</Bold>
<EtherscanLink value={module} knownAddress={false} type="address" />
</Block>
)
const SettingsDescription = ({ action, addedOwner, newThreshold, removedOwner, module }) => {
if (action === SAFE_METHODS_NAMES.REMOVE_OWNER && removedOwner && newThreshold) {
return (
<>
@ -128,6 +144,14 @@ const SettingsDescription = ({ action, addedOwner, newThreshold, removedOwner })
)
}
if (action === SAFE_METHODS_NAMES.ENABLE_MODULE && module) {
return <AddModule module={module} />
}
if (action === SAFE_METHODS_NAMES.DISABLE_MODULE && module) {
return <RemoveModule module={module} />
}
return (
<Block data-testid={TRANSACTIONS_DESC_NO_DATA}>
<Bold>No data available for current transaction</Bold>
@ -207,6 +231,7 @@ const TxDescription = ({ classes, tx }) => {
customTx,
data,
modifySettingsTx,
module,
newThreshold,
recipient,
removedOwner,
@ -221,6 +246,7 @@ const TxDescription = ({ classes, tx }) => {
addedOwner={addedOwner}
newThreshold={newThreshold}
removedOwner={removedOwner}
module={module}
/>
)}
{!upgradeTx && customTx && (

View File

@ -47,6 +47,14 @@ export const getTxData = (tx) => {
txData.action = SAFE_METHODS_NAMES.SWAP_OWNER
txData.removedOwner = oldOwner
txData.addedOwner = newOwner
} else if (tx.decodedParams[SAFE_METHODS_NAMES.ENABLE_MODULE]) {
const { module } = tx.decodedParams[SAFE_METHODS_NAMES.ENABLE_MODULE]
txData.action = SAFE_METHODS_NAMES.ENABLE_MODULE
txData.module = module
} else if (tx.decodedParams[SAFE_METHODS_NAMES.DISABLE_MODULE]) {
const { module } = tx.decodedParams[SAFE_METHODS_NAMES.DISABLE_MODULE]
txData.action = SAFE_METHODS_NAMES.DISABLE_MODULE
txData.module = module
}
} else if (tx.multiSendTx) {
txData.recipient = tx.recipient