diff --git a/jest_config/__fixtures__/approveErc20TxResponse.json b/jest_config/__fixtures__/approveErc20TxResponse.json index 92ad388b54d..38bbcac6a97 100644 --- a/jest_config/__fixtures__/approveErc20TxResponse.json +++ b/jest_config/__fixtures__/approveErc20TxResponse.json @@ -1,15 +1,9 @@ { "nonce": 1, - "gasPrice": { - "_hex": "0x4a817c800" - }, - "gasLimit": { - "_hex": "0x0249f0" - }, + "gasPrice": "0x4a817c80", + "gasLimit": "0x0249f0", "to": "0xfE5443FaC29fA621cFc33D41D1927fd0f5E0bB7c", - "value": { - "_hex": "0x0" - }, + "value": "0x00", "data": "0x095ea7b3000000000000000000000000221657776846890989a759ba2973e427dff5c9bb0000000000000000000000000000000000000000000000003782dace9d900000", "chainId": 1, "v": 41, diff --git a/jest_config/__fixtures__/repMigrationTxResponse.json b/jest_config/__fixtures__/repMigrationTxResponse.json index eda3709bf20..ee1cc086e88 100644 --- a/jest_config/__fixtures__/repMigrationTxResponse.json +++ b/jest_config/__fixtures__/repMigrationTxResponse.json @@ -1,15 +1,9 @@ { "nonce": 2, - "gasPrice": { - "_hex": "0x4a817c800" - }, - "gasLimit": { - "_hex": "0x07a120" - }, + "gasPrice": "0x4a817c800", + "gasLimit": "0x07a120", "to": "0x221657776846890989a759BA2973e427DfF5C9bB", - "value": { - "_hex": "0x0" - }, + "value": "0x00", "data": "0x75d9aa1a", "chainId": 1, "v": 41, diff --git a/jest_config/__fixtures__/txParcels.ts b/jest_config/__fixtures__/txParcels.ts index 832cd5f39a4..5994e059a65 100644 --- a/jest_config/__fixtures__/txParcels.ts +++ b/jest_config/__fixtures__/txParcels.ts @@ -16,6 +16,28 @@ export default ([ _uuid: '908acd15-f870-5652-9104-6a97b0cb98dd', status: 'CONFIRMED', txHash: '0x15f1a20e5ad8fdf50abaffaa09114d90e011406c8c888140da9595685d9de5e6', + txResponse: { + hash: '0x15f1a20e5ad8fdf50abaffaa09114d90e011406c8c888140da9595685d9de5e6', + type: 0, + accessList: null, + blockHash: '0x954aea9cd92c9d167a033bc94af2c95192e8a80b81c9856f529db45fd3264c00', + blockNumber: 9717420, + transactionIndex: 53, + confirmations: 2759837, + from: '0xfEAC75A09662396283f4bB50F0a9249576A81866', + gasPrice: '0x01dcd65000', + gasLimit: '0x0a2e36', + to: '0x3d7b19C37d422B43c07C7Ba6353ED2D1689540FD', + value: '0x038d7ea4c68000', + nonce: 139, + data: + '0x5d46ec34000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000d8775f648430679a709e98d2b0cb6250d2887ef00000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000d5704e2379762bd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000bd19f30adde367fe06c0076d690d434bf945a8fc000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124f0843ba9000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000005000000000000000000000000c0829421c1d260bd3cb3e0f06cfe2d52db2ce315000000000000000000000000b1cd6e4153b2a390cf00a6556b0fc1458c4a55330000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c000000000000000000000000131da075a2832549128e93acc2b54174045232cf0000000000000000000000000d8775f648430679a709e98d2b0cb6250d2887ef00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000038d7ea4c68000', + r: '0x3000efc622faf7d1ca11a954f6e37f80186c129a8ea16e33f58667930d5a381d', + s: '0x4e931f0efe6d400b56bff23fabac6616fc80f0bf85bb6edf7e3e0a688c46e197', + v: 37, + creates: null, + chainId: 1 + }, txReceipt: { to: '0x3d7b19C37d422B43c07C7Ba6353ED2D1689540FD', from: '0xfEAC75A09662396283f4bB50F0a9249576A81866', diff --git a/src/components/TokenMigration/components/TokenMigrationReceipt.tsx b/src/components/TokenMigration/components/TokenMigrationReceipt.tsx index e113f2cdb3a..d156aee6562 100644 --- a/src/components/TokenMigration/components/TokenMigrationReceipt.tsx +++ b/src/components/TokenMigration/components/TokenMigrationReceipt.tsx @@ -2,9 +2,9 @@ import React from 'react'; import { MultiTxReceipt } from '@components/TransactionFlow'; import { getFiat } from '@config/fiats'; -import { makeTxItem } from '@helpers'; +import { makeTxConfigFromTxResponse, makeTxItem } from '@helpers'; import { useAssets, useRates, useSettings } from '@services'; -import { ITokenMigrationConfig, StoreAccount, TxParcel } from '@types'; +import { ITokenMigrationConfig, ITxType, StoreAccount, TxParcel } from '@types'; import { makeTokenMigrationTxConfig } from '../helpers'; @@ -24,11 +24,14 @@ export default function TokenMigrationReceipt({ onComplete }: TokenMigrationReceiptProps) { const { settings } = useSettings(); - const { getAssetByUUID } = useAssets(); + const { getAssetByUUID, assets } = useAssets(); const { getAssetRate } = useRates(); const txItems = transactions.map((tx, idx) => { - const txConfig = makeTokenMigrationTxConfig(tx.txRaw, account, amount)(flowConfig); const txType = flowConfig.txConstructionConfigs[idx].txType; + const txConfig = + txType === ITxType.APPROVAL + ? makeTxConfigFromTxResponse(tx.txResponse!, assets, account.network, [account]) + : makeTokenMigrationTxConfig(tx.txRaw, account, amount)(flowConfig); return makeTxItem(txType, txConfig, tx.txHash!, tx.txReceipt); }); diff --git a/src/features/SendAssets/helpers.ts b/src/features/SendAssets/helpers.ts index c7d4fcc9358..0cecbea802d 100644 --- a/src/features/SendAssets/helpers.ts +++ b/src/features/SendAssets/helpers.ts @@ -151,7 +151,7 @@ export const parseTransactionQueryParams = (queryParams: any) => ( // This is labeled as "guess" because we can only identify simple erc20 transfers for now. If this is incorrect, It only affects displayed amounts - not the actual tx. const ercType = guessERC20Type(i.data); - const isERC20 = ercType !== ERCType.NONE; + const isERC20 = ercType === ERCType.TRANSFER; const { to, amount, receiverAddress } = deriveTxRecipientsAndAmount( ercType, diff --git a/src/features/SwapAssets/components/SwapTransactionReceipt.tsx b/src/features/SwapAssets/components/SwapTransactionReceipt.tsx index 93eae368351..617235f579a 100644 --- a/src/features/SwapAssets/components/SwapTransactionReceipt.tsx +++ b/src/features/SwapAssets/components/SwapTransactionReceipt.tsx @@ -5,7 +5,7 @@ import pick from 'ramda/src/pick'; import { MultiTxReceipt, TxReceipt } from '@components/TransactionFlow'; import { SwapFromToDiagram } from '@components/TransactionFlow/displays'; import { getFiat } from '@config/fiats'; -import { makeTxItem } from '@helpers'; +import { makeTxConfigFromTxResponse, makeTxItem } from '@helpers'; import { StoreContext, useAssets, useRates, useSettings } from '@services'; import { translateRaw } from '@translations'; import { ITxType, StoreAccount, TxParcel } from '@types'; @@ -28,7 +28,7 @@ export default function SwapTransactionReceipt({ onSuccess }: Props) { const { assets: getAssets } = useContext(StoreContext); - const { getAssetByUUID } = useAssets(); + const { getAssetByUUID, assets } = useAssets(); const { settings } = useSettings(); const { getAssetRate } = useRates(); const swapDisplay: SwapDisplayData = pick( @@ -38,13 +38,16 @@ export default function SwapTransactionReceipt({ const currentAssets = getAssets(); // @todo: refactor this to be based on status of tx from StoreProvider const txItems = transactions.map((tx, idx) => { - const txConfig = makeSwapTxConfig(currentAssets)( - tx.txRaw, - account, - assetPair.fromAsset, - assetPair.fromAmount.toString() - ); const txType = idx === transactions.length - 1 ? ITxType.SWAP : ITxType.APPROVAL; + const txConfig = + txType === ITxType.SWAP + ? makeSwapTxConfig(currentAssets)( + tx.txRaw, + account, + assetPair.fromAsset, + assetPair.fromAmount.toString() + ) + : makeTxConfigFromTxResponse(tx.txResponse!, assets, account.network, [account]); return makeTxItem(txType, txConfig, tx.txHash!, tx.txReceipt); }); diff --git a/src/helpers/transaction.spec.ts b/src/helpers/transaction.spec.ts index 4e6bddaf898..cd5496be19f 100644 --- a/src/helpers/transaction.spec.ts +++ b/src/helpers/transaction.spec.ts @@ -260,8 +260,8 @@ describe('deriveTxFields', () => { expect(result).toStrictEqual({ to: toAddress, receiverAddress: toAddress, - amount: '0', - asset: fRopDAI + amount: '0.0', + asset: fAssets[1] }); }); it("interprets an eth tx's fields correctly", () => { diff --git a/src/helpers/transaction.ts b/src/helpers/transaction.ts index 784783e9667..f1e35f7d316 100644 --- a/src/helpers/transaction.ts +++ b/src/helpers/transaction.ts @@ -328,7 +328,7 @@ export const deriveTxFields = ( baseAsset: Asset, contractAsset?: Asset ) => { - const isERC20 = ercType !== ERCType.NONE; + const isERC20 = ercType === ERCType.TRANSFER; const { to, amount: rawAmount, receiverAddress } = deriveTxRecipientsAndAmount( ercType, data,