diff --git a/app/components/UI/TransactionElement/utils.js b/app/components/UI/TransactionElement/utils.js index 68ed389c34f..3c55e2f4251 100644 --- a/app/components/UI/TransactionElement/utils.js +++ b/app/components/UI/TransactionElement/utils.js @@ -33,7 +33,7 @@ const { isEIP1559Transaction } = util; const { getSwapsContractAddress } = swapsUtils; function calculateTotalGas(transaction) { - const { gas, gasPrice, estimatedBaseFee, maxPriorityFeePerGas, maxFeePerGas } = transaction; + const { gas, gasPrice, gasUsed, estimatedBaseFee, maxPriorityFeePerGas, maxFeePerGas } = transaction; if (isEIP1559Transaction(transaction)) { const eip1559GasHex = calculateEIP1559GasFeeHexes({ @@ -46,8 +46,17 @@ function calculateTotalGas(transaction) { } const gasBN = hexToBN(gas); const gasPriceBN = hexToBN(gasPrice); + const gasUsedBN = gasUsed ? hexToBN(gasUsed) : null; - return isBN(gasBN) && isBN(gasPriceBN) ? gasBN.mul(gasPriceBN) : toBN('0x0'); + if (gasUsedBN && isBN(gasUsedBN) && isBN(gasPriceBN)) { + return gasUsedBN.mul(gasPriceBN); + } + + if (isBN(gasBN) && isBN(gasPriceBN)) { + return gasBN.mul(gasPriceBN); + } + + return toBN('0x0'); } function renderGwei(transaction) { diff --git a/package.json b/package.json index 3cf3507f9e6..60688e3d435 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "dependencies": { "@exodus/react-native-payments": "https://github.com/wachunei/react-native-payments.git#package-json-hack", "@metamask/contract-metadata": "^1.23.0", - "@metamask/controllers": "^15.0.2", + "@metamask/controllers": "^15.1.0", "@metamask/etherscan-link": "^2.0.0", "@metamask/swaps-controller": "^6.3.0", "@react-native-community/async-storage": "1.12.1", diff --git a/yarn.lock b/yarn.lock index 37e98f298e3..c22c6a0c01a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1557,7 +1557,7 @@ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.29.0.tgz#4ca86a2f03d4dad4350d09216a7fe92f9dd21c8e" integrity sha512-wxsC0ZCyhPKqThvmsL8+2zVWGWPqofSo8HNtOuOnQM9oGbXX9294imJ3T+A/Lov8fkX4jAWZOeNV0uR80zkNtA== -"@metamask/controllers@^15.0.1", "@metamask/controllers@^15.0.2": +"@metamask/controllers@^15.0.1": version "15.0.2" resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-15.0.2.tgz#b4012a8bf28bd2c8dbb3c96f4d934d6cf1bb778c" integrity sha512-MPxfZ2OOTzEa5lUzDsSkINtlTDU4q4udjpBNM5Dq1yCnLKIuPKzYC5nl/rA88Ssr9Hs6babCtMbnUpbbjQjLOg== @@ -1594,6 +1594,43 @@ web3 "^0.20.7" web3-provider-engine "^16.0.3" +"@metamask/controllers@^15.1.0": + version "15.1.0" + resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-15.1.0.tgz#f480e7bdfb8c4a31ea8b21214b919478df507cab" + integrity sha512-LCz23ZsJRD9SYWPYdSthP5SLKI40XJaVflUOF4VxDnaEA9DKmCVI3Y9TzjJITT3cRIQXD6Z5fEIGBRrZHXkufQ== + dependencies: + "@ethereumjs/common" "^2.3.1" + "@ethereumjs/tx" "^3.2.1" + "@metamask/contract-metadata" "^1.29.0" + "@types/uuid" "^8.3.0" + abort-controller "^3.0.0" + async-mutex "^0.2.6" + babel-runtime "^6.26.0" + eth-ens-namehash "^2.0.8" + eth-json-rpc-infura "^5.1.0" + eth-keyring-controller "^6.2.1" + eth-method-registry "1.1.0" + eth-phishing-detect "^1.1.14" + eth-query "^2.1.2" + eth-rpc-errors "^4.0.0" + eth-sig-util "^3.0.0" + ethereumjs-util "^7.0.10" + ethereumjs-wallet "^1.0.1" + ethers "^5.4.1" + ethjs-unit "^0.1.6" + ethjs-util "^0.1.6" + human-standard-collectible-abi "^1.0.2" + human-standard-token-abi "^2.0.0" + immer "^9.0.6" + isomorphic-fetch "^3.0.0" + jsonschema "^1.2.4" + nanoid "^3.1.12" + punycode "^2.1.1" + single-call-balance-checker-abi "^1.0.0" + uuid "^8.3.2" + web3 "^0.20.7" + web3-provider-engine "^16.0.3" + "@metamask/eslint-config-typescript@^7.0.0": version "7.0.1" resolved "https://registry.yarnpkg.com/@metamask/eslint-config-typescript/-/eslint-config-typescript-7.0.1.tgz#e013f7f0505741b9321cab21351136f651abbba6" @@ -7584,6 +7621,11 @@ immer@^8.0.1: resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.4.tgz#3a21605a4e2dded852fb2afd208ad50969737b7a" integrity sha512-jMfL18P+/6P6epANRvRk6q8t+3gGhqsJ9EuJ25AXE+9bNTYtssvzeYbEd0mXRYWCmmXSIbnlpz6vd6iJlmGGGQ== +immer@^9.0.6: + version "9.0.6" + resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.6.tgz#7a96bf2674d06c8143e327cbf73539388ddf1a73" + integrity sha512-G95ivKpy+EvVAnAab4fVa4YGYn24J1SpEktnJX7JJ45Bd7xqME/SCplFzYFmTbrkwZbQ4xJK1xMTUYBkN6pWsQ== + import-fresh@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546"