Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Transaction state #3099

Merged
merged 9 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/components/UI/TransactionElement/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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) {
Expand Down
Binary file added metamask-controllers-v14.2.0-tx-state-v3.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "./metamask-controllers-v14.2.0-tx-state-v3.tgz",
"@metamask/etherscan-link": "^2.0.0",
"@metamask/swaps-controller": "^6.2.0",
"@react-native-community/async-storage": "1.12.1",
Expand Down