(Fix) Transaction List not loading and handle DCD token (#539)
* Handle DCD token - treat DCD particularly and hardcode `symbol` and `decimal` values - for those ALTERNATIVE_TOKEN_ABI contracts, we were converting the `symbol` to ascii, and we had to convert from hex to string instead - the `incoming-transactions` endpoint is returning the `executionDate`, so no request for that value to the blockchain is required * remove condition
This commit is contained in:
parent
30f3483119
commit
b938d456c1
|
@ -204,10 +204,8 @@ export const buildIncomingTransactionFrom = async (tx: IncomingTxServiceModel) =
|
||||||
let symbol = 'ETH'
|
let symbol = 'ETH'
|
||||||
let decimals = 18
|
let decimals = 18
|
||||||
|
|
||||||
const whenExecutionDate = web3.eth.getBlock(tx.blockNumber)
|
const fee = await web3.eth.getTransaction(tx.transactionHash)
|
||||||
.then(({ timestamp }) => new Date(timestamp * 1000).toISOString())
|
.then(({ gas, gasPrice }) => bn(gas).div(gasPrice).toFixed())
|
||||||
const whenFee = web3.eth.getTransaction(tx.transactionHash).then((t) => bn(t.gas).div(t.gasPrice).toFixed())
|
|
||||||
const [executionDate, fee] = await Promise.all([whenExecutionDate, whenFee])
|
|
||||||
|
|
||||||
if (tx.tokenAddress) {
|
if (tx.tokenAddress) {
|
||||||
try {
|
try {
|
||||||
|
@ -217,10 +215,20 @@ export const buildIncomingTransactionFrom = async (tx: IncomingTxServiceModel) =
|
||||||
symbol = tokenSymbol
|
symbol = tokenSymbol
|
||||||
decimals = tokenDecimals
|
decimals = tokenDecimals
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
try {
|
||||||
const { methods } = new web3.eth.Contract(ALTERNATIVE_TOKEN_ABI, tx.tokenAddress)
|
const { methods } = new web3.eth.Contract(ALTERNATIVE_TOKEN_ABI, tx.tokenAddress)
|
||||||
const [tokenSymbol, tokenDecimals] = await Promise.all([methods.symbol, methods.decimals].map((m) => m().call()))
|
const [tokenSymbol, tokenDecimals] = await Promise.all([methods.symbol, methods.decimals].map((m) => m()
|
||||||
symbol = web3.utils.toAscii(tokenSymbol)
|
.call()))
|
||||||
|
symbol = web3.utils.hexToString(tokenSymbol)
|
||||||
decimals = tokenDecimals
|
decimals = tokenDecimals
|
||||||
|
} catch (e) {
|
||||||
|
// this is a particular treatment for the DCD token, as it seems to lack of symbol and decimal methods
|
||||||
|
if (tx.tokenAddress && tx.tokenAddress.toLowerCase() === '0xe0b7927c4af23765cb51314a0e0521a9645f0e2a') {
|
||||||
|
symbol = 'DCD'
|
||||||
|
decimals = 9
|
||||||
|
}
|
||||||
|
// if it's not DCD, then we fall to the default values
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +239,6 @@ export const buildIncomingTransactionFrom = async (tx: IncomingTxServiceModel) =
|
||||||
symbol,
|
symbol,
|
||||||
decimals,
|
decimals,
|
||||||
fee,
|
fee,
|
||||||
executionDate,
|
|
||||||
executionTxHash: transactionHash,
|
executionTxHash: transactionHash,
|
||||||
safeTxHash: transactionHash,
|
safeTxHash: transactionHash,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue