(args)
| 96 | } |
| 97 | |
| 98 | function getTokenTransfer(args) { |
| 99 | const { |
| 100 | tx: { |
| 101 | txParams: { from, to, data, nonce }, |
| 102 | }, |
| 103 | conversionRate, |
| 104 | currentCurrency, |
| 105 | tokens, |
| 106 | contractExchangeRates, |
| 107 | totalGas, |
| 108 | actionKey, |
| 109 | primaryCurrency, |
| 110 | selectedAddress, |
| 111 | } = args; |
| 112 | |
| 113 | const [, , encodedAmount] = decodeTransferData('transfer', data); |
| 114 | const amount = hexToBN(encodedAmount); |
| 115 | const userHasToken = safeToChecksumAddress(to) in tokens; |
| 116 | const token = userHasToken ? tokens[safeToChecksumAddress(to)] : null; |
| 117 | const renderActionKey = token |
| 118 | ? `${strings('transactions.sent')} ${token.symbol}` |
| 119 | : actionKey; |
| 120 | const renderTokenAmount = token |
| 121 | ? `${renderFromTokenMinimalUnit(amount, token.decimals)} ${token.symbol}` |
| 122 | : undefined; |
| 123 | const exchangeRate = token ? contractExchangeRates[token.address] : undefined; |
| 124 | let renderTokenFiatAmount, renderTokenFiatNumber; |
| 125 | if (exchangeRate) { |
| 126 | renderTokenFiatAmount = balanceToFiat( |
| 127 | fromTokenMinimalUnit(amount, token.decimals) || 0, |
| 128 | conversionRate, |
| 129 | exchangeRate, |
| 130 | currentCurrency, |
| 131 | ); |
| 132 | renderTokenFiatNumber = balanceToFiatNumber( |
| 133 | fromTokenMinimalUnit(amount, token.decimals) || 0, |
| 134 | conversionRate, |
| 135 | exchangeRate, |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | const renderToken = token |
| 140 | ? `${renderFromTokenMinimalUnit(amount, token.decimals)} ${token.symbol}` |
| 141 | : strings('transaction.value_not_available'); |
| 142 | const totalFiatNumber = renderTokenFiatNumber |
| 143 | ? weiToFiatNumber(totalGas, conversionRate) + renderTokenFiatNumber |
| 144 | : weiToFiatNumber(totalGas, conversionRate); |
| 145 | |
| 146 | const ticker = getTicker(args.ticker); |
| 147 | |
| 148 | let transactionDetails = { |
| 149 | renderTotalGas: `${renderFromWei(totalGas)} ${ticker}`, |
| 150 | renderValue: renderToken, |
| 151 | }; |
| 152 | if (primaryCurrency === 'ETH') { |
| 153 | transactionDetails = { |
| 154 | ...transactionDetails, |
| 155 | summaryAmount: renderToken, |
no test coverage detected