add case in useTransactionDisplayData to handle transaction type safeTransferFrom (#14678)

* add case in useTransactionDisplayData to handle transaction type safeTransferFrom

* add test
feature/default_network_editable
Alex Donesky 3 years ago committed by GitHub
parent 02d374fde0
commit 5e55cf2cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      shared/constants/transaction.js
  2. 352
      test/data/transaction-data.json
  3. 3
      ui/hooks/useTransactionDisplayData.js
  4. 12
      ui/hooks/useTransactionDisplayData.test.js

@ -9,6 +9,10 @@ import { MESSAGE_TYPE } from './app';
* @property {'transferfrom'} TOKEN_METHOD_TRANSFER_FROM - A token transaction * @property {'transferfrom'} TOKEN_METHOD_TRANSFER_FROM - A token transaction
* transferring tokens from an account that the sender has an allowance of. * transferring tokens from an account that the sender has an allowance of.
* For more information on allowances, see the approve type. * For more information on allowances, see the approve type.
* @property {'safetransferfrom'} TOKEN_METHOD_SAFE_TRANSFER_FROM - A token transaction
* transferring tokens from an account that the sender has an allowance of.
* The method is prefixed with safe because when calling this method the contract checks
* to ensure that the receiver is an address capable of handling with the token being sent.
* @property {'approve'} TOKEN_METHOD_APPROVE - A token transaction requesting an * @property {'approve'} TOKEN_METHOD_APPROVE - A token transaction requesting an
* allowance of the token to spend on behalf of the user * allowance of the token to spend on behalf of the user
* @property {'incoming'} INCOMING - An incoming (deposit) transaction * @property {'incoming'} INCOMING - An incoming (deposit) transaction

@ -856,5 +856,357 @@
}, },
"hasRetried": false, "hasRetried": false,
"hasCancelled": false "hasCancelled": false
},
{
"nonce": "0x57",
"transactions": [
{
"id": 1441203963845330,
"time": 1652206763566,
"status": "confirmed",
"metamaskNetworkId": "4",
"originalGasEstimate": "0x118e0",
"userEditedGasLimit": false,
"chainId": "0x4",
"loadingDefaults": false,
"dappSuggestedGasFees": {
"maxPriorityFeePerGas": "0x3B9ACA00",
"maxFeePerGas": "0x7be830aec"
},
"sendFlowHistory": [],
"txParams": {
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"nonce": "0x57",
"value": "0x0",
"data": "0x42842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7cc",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"origin": "https://rinkeby.etherscan.io",
"type": "safetransferfrom",
"userFeeLevel": "dappSuggested",
"defaultGasEstimates": {
"estimateType": "dappSuggested",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"estimatedBaseFee": "3ba182755",
"nonceDetails": {
"params": {
"highestLocallyConfirmed": 87,
"highestSuggested": 87,
"nextNetworkNonce": 87
},
"local": {
"name": "local",
"nonce": 87,
"details": {
"startPoint": 87,
"highest": 87
}
},
"network": {
"name": "network",
"nonce": 87,
"details": {
"blockNumber": "0xa28e38",
"baseCount": 87
}
}
},
"r": "0xd13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791c",
"s": "0x7a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"v": "0x00",
"rawTx": "0x02f8d10457843b9aca008507be830aec830118e094f5de760f2e916647fd766b4ad9e85ff943ce3a2b80b86442842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7ccc080a0d13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791ca07a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"hash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"submittedTime": 1652206777046,
"txReceipt": {
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"contractAddress": null,
"cumulativeGasUsed": "fd5dee",
"effectiveGasPrice": "0x4028dcaf1",
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"gasUsed": "bb40",
"logs": [
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "45",
"removed": false,
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
},
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "46",
"removed": false,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
}
],
"logsBloom": "0x00000000000000001000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000008000200000000000000000000000000008000000000000000000008000000000000000000000000000020800000000000000000800000000000000000000000010000000000000000000000000000080000010000000000000000000000000000000000000020000000000000000000001000000000000000000000000000000000000000000000202000000000000000000000800000000000000000000000000000020000010000000000002008000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23",
"type": "0x2"
},
"baseFeePerGas": "0x3c6f300f1",
"blockTimestamp": "627aacc2"
}
],
"initialTransaction": {
"id": 1441203963845330,
"time": 1652206763566,
"status": "confirmed",
"metamaskNetworkId": "4",
"originalGasEstimate": "0x118e0",
"userEditedGasLimit": false,
"chainId": "0x4",
"loadingDefaults": false,
"dappSuggestedGasFees": {
"maxPriorityFeePerGas": "0x3B9ACA00",
"maxFeePerGas": "0x7be830aec"
},
"sendFlowHistory": [],
"txParams": {
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"nonce": "0x57",
"value": "0x0",
"data": "0x42842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7cc",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"origin": "https://rinkeby.etherscan.io",
"type": "safetransferfrom",
"userFeeLevel": "dappSuggested",
"defaultGasEstimates": {
"estimateType": "dappSuggested",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"estimatedBaseFee": "3ba182755",
"nonceDetails": {
"params": {
"highestLocallyConfirmed": 87,
"highestSuggested": 87,
"nextNetworkNonce": 87
},
"local": {
"name": "local",
"nonce": 87,
"details": {
"startPoint": 87,
"highest": 87
}
},
"network": {
"name": "network",
"nonce": 87,
"details": {
"blockNumber": "0xa28e38",
"baseCount": 87
}
}
},
"r": "0xd13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791c",
"s": "0x7a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"v": "0x00",
"rawTx": "0x02f8d10457843b9aca008507be830aec830118e094f5de760f2e916647fd766b4ad9e85ff943ce3a2b80b86442842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7ccc080a0d13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791ca07a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"hash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"submittedTime": 1652206777046,
"txReceipt": {
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"contractAddress": null,
"cumulativeGasUsed": "fd5dee",
"effectiveGasPrice": "0x4028dcaf1",
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"gasUsed": "bb40",
"logs": [
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "45",
"removed": false,
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
},
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "46",
"removed": false,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
}
],
"logsBloom": "0x00000000000000001000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000008000200000000000000000000000000008000000000000000000008000000000000000000000000000020800000000000000000800000000000000000000000010000000000000000000000000000080000010000000000000000000000000000000000000020000000000000000000001000000000000000000000000000000000000000000000202000000000000000000000800000000000000000000000000000020000010000000000002008000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23",
"type": "0x2"
},
"baseFeePerGas": "0x3c6f300f1",
"blockTimestamp": "627aacc2"
},
"primaryTransaction": {
"id": 1441203963845330,
"time": 1652206763566,
"status": "confirmed",
"metamaskNetworkId": "4",
"originalGasEstimate": "0x118e0",
"userEditedGasLimit": false,
"chainId": "0x4",
"loadingDefaults": false,
"dappSuggestedGasFees": {
"maxPriorityFeePerGas": "0x3B9ACA00",
"maxFeePerGas": "0x7be830aec"
},
"sendFlowHistory": [],
"txParams": {
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"nonce": "0x57",
"value": "0x0",
"data": "0x42842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7cc",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"origin": "https://rinkeby.etherscan.io",
"type": "safetransferfrom",
"userFeeLevel": "dappSuggested",
"defaultGasEstimates": {
"estimateType": "dappSuggested",
"gas": "0x118e0",
"maxFeePerGas": "0x7be830aec",
"maxPriorityFeePerGas": "0x3B9ACA00"
},
"estimatedBaseFee": "3ba182755",
"nonceDetails": {
"params": {
"highestLocallyConfirmed": 87,
"highestSuggested": 87,
"nextNetworkNonce": 87
},
"local": {
"name": "local",
"nonce": 87,
"details": {
"startPoint": 87,
"highest": 87
}
},
"network": {
"name": "network",
"nonce": 87,
"details": {
"blockNumber": "0xa28e38",
"baseCount": 87
}
}
},
"r": "0xd13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791c",
"s": "0x7a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"v": "0x00",
"rawTx": "0x02f8d10457843b9aca008507be830aec830118e094f5de760f2e916647fd766b4ad9e85ff943ce3a2b80b86442842e0e000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98000000000000000000000000000000000000000000000000000000000009a7ccc080a0d13310569a8d5876e37788183034bfe4bc3b49c0663c5fd9b2bf13adf9b4791ca07a83d8840e7edcdf4fdedfd2bc1ce19775e54fd17f29ede5165591a1cf3febea",
"hash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"submittedTime": 1652206777046,
"txReceipt": {
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"contractAddress": null,
"cumulativeGasUsed": "fd5dee",
"effectiveGasPrice": "0x4028dcaf1",
"from": "0x806627172af48bd5b0765d3449a7def80d6576ff",
"gasUsed": "bb40",
"logs": [
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "45",
"removed": false,
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
},
{
"address": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"blockHash": "0x75eb415f79d24f62821b979e3a5f0d4904b2381e973da5fadbddc046c701e3d1",
"blockNumber": "a28e39",
"data": "0x",
"logIndex": "46",
"removed": false,
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000806627172af48bd5b0765d3449a7def80d6576ff",
"0x000000000000000000000000e7d522230eff653bb0a9b4385f0be0815420dd98",
"0x000000000000000000000000000000000000000000000000000000000009a7cc"
],
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23"
}
],
"logsBloom": "0x00000000000000001000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000008000200000000000000000000000000008000000000000000000008000000000000000000000000000020800000000000000000800000000000000000000000010000000000000000000000000000080000010000000000000000000000000000000000000020000000000000000000001000000000000000000000000000000000000000000000202000000000000000000000800000000000000000000000000000020000010000000000002008000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b",
"transactionHash": "0xe8717d7b075f8bb555cd4bb9846659a7dfba70dc017a84782a2d23d21f948ee3",
"transactionIndex": "23",
"type": "0x2"
},
"baseFeePerGas": "0x3c6f300f1",
"blockTimestamp": "627aacc2"
},
"hasRetried": false,
"hasCancelled": false
} }
] ]

@ -238,7 +238,8 @@ export function useTransactionDisplayData(transactionGroup) {
subtitle = t('fromAddress', [shortenAddress(senderAddress)]); subtitle = t('fromAddress', [shortenAddress(senderAddress)]);
} else if ( } else if (
type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM || type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM ||
type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER ||
type === TRANSACTION_TYPES.TOKEN_METHOD_SAFE_TRANSFER_FROM
) { ) {
category = TRANSACTION_GROUP_CATEGORIES.SEND; category = TRANSACTION_GROUP_CATEGORIES.SEND;
title = t('sendSpecifiedTokens', [ title = t('sendSpecifiedTokens', [

@ -130,6 +130,18 @@ const expectedResults = [
isPending: false, isPending: false,
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED, displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
}, },
{
title: 'Send Token',
category: TRANSACTION_GROUP_CATEGORIES.SEND,
subtitle: 'To: 0xe7d...dd98',
subtitleContainsOrigin: true,
primaryCurrency: '-0 ETH',
senderAddress: '0x806627172af48bd5b0765d3449a7def80d6576ff',
recipientAddress: '0xe7d522230eff653bb0a9b4385f0be0815420dd98',
secondaryCurrency: '-0 ETH',
isPending: false,
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
},
]; ];
let useSelector, useI18nContext, useTokenFiatAmount; let useSelector, useI18nContext, useTokenFiatAmount;

Loading…
Cancel
Save