add decodedParams to transaction model

This commit is contained in:
mmv 2019-07-10 16:29:59 +04:00
parent d7ef87b0bf
commit ff49f3c6c2
2 changed files with 14 additions and 9 deletions

View File

@ -62,33 +62,34 @@ const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, saf
}
let symbol = 'ETH'
let recipient = tx.to
let value = tx.value.toString()
let decodedParams
if (isToken) {
const tokenContract = await getHumanFriendlyToken()
const tokenInstance = await tokenContract.at(tx.to)
symbol = await tokenInstance.symbol()
const decodedParams = web3.eth.abi.decodeParameters(['address', 'uint256'], tx.data.slice(10))
/* eslint-disable */
recipient = decodedParams[0]
value = decodedParams[1]
/* eslint-enable */
const params = web3.eth.abi.decodeParameters(['address', 'uint256'], tx.data.slice(10))
decodedParams = {
recipient: params[0],
value: params[1],
}
}
return makeTransaction({
name,
symbol,
nonce: tx.nonce,
value,
value: tx.value.toString(),
confirmations,
recipient,
recipient: tx.to,
data: tx.data ? tx.data : EMPTY_DATA,
isExecuted: tx.isExecuted,
submissionDate: tx.submissionDate,
executionDate: tx.executionDate,
executionTxHash,
creationTxHash,
isToken,
decodedParams,
})
}

View File

@ -20,6 +20,8 @@ export type TransactionProps = {
executionTxHash?: string,
cancelled?: boolean,
status?: TransactionStatus,
isToken: boolean,
decodedParams?: Object,
}
export const makeTransaction: RecordFactory<TransactionProps> = Record({
@ -37,6 +39,8 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
creationTxHash: '',
cancelled: false,
status: 'awaiting',
isToken: false,
decodedParams: {},
})
export type Transaction = RecordOf<TransactionProps>