1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Migrate the "estimateGas" API call to "getFees" for STX (#14767)

This commit is contained in:
Daniel 2022-05-26 19:56:28 +02:00 committed by GitHub
parent 0d595df635
commit 6dbb2c4ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 191 additions and 842 deletions

View File

@ -1819,9 +1819,6 @@ export default class MetamaskController extends EventEmitter {
fetchSmartTransactionFees: smartTransactionsController.getFees.bind( fetchSmartTransactionFees: smartTransactionsController.getFees.bind(
smartTransactionsController, smartTransactionsController,
), ),
estimateSmartTransactionsGas: smartTransactionsController.estimateGas.bind(
smartTransactionsController,
),
submitSignedTransactions: smartTransactionsController.submitSignedTransactions.bind( submitSignedTransactions: smartTransactionsController.submitSignedTransactions.bind(
smartTransactionsController, smartTransactionsController,
), ),

View File

@ -3216,6 +3216,10 @@
} }
}, },
"@metamask/rpc-methods": { "@metamask/rpc-methods": {
"globals": {
"caveats": true,
"params": true
},
"packages": { "packages": {
"@metamask/controllers": true, "@metamask/controllers": true,
"@metamask/rpc-methods>@metamask/key-tree": true, "@metamask/rpc-methods>@metamask/key-tree": true,
@ -3275,207 +3279,17 @@
"console.error": true, "console.error": true,
"console.log": true, "console.log": true,
"fetch": true, "fetch": true,
"setInterval": true, "setInterval": true
"setTimeout": true
}, },
"packages": { "packages": {
"@metamask/controllers": true,
"@metamask/controllers>isomorphic-fetch": true, "@metamask/controllers>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>@metamask/controllers": true,
"@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>bignumber.js": true,
"@metamask/smart-transactions-controller>fast-json-patch": true, "@metamask/smart-transactions-controller>fast-json-patch": true,
"ethers": true, "ethers": true,
"lodash": true "lodash": true
} }
}, },
"@metamask/smart-transactions-controller>@metamask/controllers": {
"globals": {
"Headers": true,
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.log": true,
"fetch": true,
"setInterval": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/common": true,
"@ethereumjs/tx": true,
"@metamask/contract-metadata": true,
"@metamask/controllers>abort-controller": true,
"@metamask/controllers>async-mutex": true,
"@metamask/controllers>eth-phishing-detect": true,
"@metamask/controllers>isomorphic-fetch": true,
"@metamask/controllers>multiformats": true,
"@metamask/controllers>web3-provider-engine": true,
"@metamask/metamask-eth-abis": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": true,
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": true,
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": true,
"@storybook/api>fast-deep-equal": true,
"browserify>buffer": true,
"browserify>events": true,
"deep-freeze-strict": true,
"eth-ens-namehash": true,
"eth-json-rpc-infura": true,
"eth-query": true,
"eth-rpc-errors": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"ethers": true,
"ethjs>ethjs-unit": true,
"immer": true,
"json-rpc-engine": true,
"jsonschema": true,
"punycode": true,
"single-call-balance-checker-abi": true,
"uuid": true,
"web3": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": true,
"browserify>events": true,
"eth-keyring-controller>browser-passworder": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-keyring-controller>obs-store": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"loglevel": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": true,
"browserify>crypto-browserify>pbkdf2": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>randombytes": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": {
"globals": {
"define": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-sig-util": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": {
"globals": {
"clearInterval": true,
"setInterval": true
},
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-provider-http": true,
"ethjs>ethjs-unit": true,
"ethjs>ethjs-util": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"ethjs-query>babel-runtime": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-util": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": {
"globals": {
"console": true
},
"packages": {
"ethjs-query>babel-runtime": true,
"ethjs-query>ethjs-format": true,
"ethjs-query>ethjs-rpc": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": {
"packages": {
"browserify>process": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": {
"globals": { "globals": {
"crypto.getRandomValues": true "crypto.getRandomValues": true
@ -3504,11 +3318,17 @@
"console.info": true, "console.info": true,
"console.log": true, "console.log": true,
"console.warn": true, "console.warn": true,
"dist": true,
"document.body.appendChild": true, "document.body.appendChild": true,
"document.createElement": true, "document.createElement": true,
"document.getElementById": true, "document.getElementById": true,
"fetch": true, "fetch": true,
"setTimeout": true "location": true,
"npm": true,
"remove": true,
"setTimeout": true,
"tarball": true,
"versions": true
}, },
"packages": { "packages": {
"@metamask/controllers": true, "@metamask/controllers": true,

View File

@ -3216,6 +3216,10 @@
} }
}, },
"@metamask/rpc-methods": { "@metamask/rpc-methods": {
"globals": {
"caveats": true,
"params": true
},
"packages": { "packages": {
"@metamask/controllers": true, "@metamask/controllers": true,
"@metamask/rpc-methods>@metamask/key-tree": true, "@metamask/rpc-methods>@metamask/key-tree": true,
@ -3275,207 +3279,17 @@
"console.error": true, "console.error": true,
"console.log": true, "console.log": true,
"fetch": true, "fetch": true,
"setInterval": true, "setInterval": true
"setTimeout": true
}, },
"packages": { "packages": {
"@metamask/controllers": true,
"@metamask/controllers>isomorphic-fetch": true, "@metamask/controllers>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>@metamask/controllers": true,
"@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>bignumber.js": true,
"@metamask/smart-transactions-controller>fast-json-patch": true, "@metamask/smart-transactions-controller>fast-json-patch": true,
"ethers": true, "ethers": true,
"lodash": true "lodash": true
} }
}, },
"@metamask/smart-transactions-controller>@metamask/controllers": {
"globals": {
"Headers": true,
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.log": true,
"fetch": true,
"setInterval": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/common": true,
"@ethereumjs/tx": true,
"@metamask/contract-metadata": true,
"@metamask/controllers>abort-controller": true,
"@metamask/controllers>async-mutex": true,
"@metamask/controllers>eth-phishing-detect": true,
"@metamask/controllers>isomorphic-fetch": true,
"@metamask/controllers>multiformats": true,
"@metamask/controllers>web3-provider-engine": true,
"@metamask/metamask-eth-abis": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": true,
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": true,
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": true,
"@storybook/api>fast-deep-equal": true,
"browserify>buffer": true,
"browserify>events": true,
"deep-freeze-strict": true,
"eth-ens-namehash": true,
"eth-json-rpc-infura": true,
"eth-query": true,
"eth-rpc-errors": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"ethers": true,
"ethjs>ethjs-unit": true,
"immer": true,
"json-rpc-engine": true,
"jsonschema": true,
"punycode": true,
"single-call-balance-checker-abi": true,
"uuid": true,
"web3": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": true,
"browserify>events": true,
"eth-keyring-controller>browser-passworder": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-keyring-controller>obs-store": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"loglevel": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": true,
"browserify>crypto-browserify>pbkdf2": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>randombytes": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": {
"globals": {
"define": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-sig-util": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": {
"globals": {
"clearInterval": true,
"setInterval": true
},
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-provider-http": true,
"ethjs>ethjs-unit": true,
"ethjs>ethjs-util": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"ethjs-query>babel-runtime": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-util": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": {
"globals": {
"console": true
},
"packages": {
"ethjs-query>babel-runtime": true,
"ethjs-query>ethjs-format": true,
"ethjs-query>ethjs-rpc": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": {
"packages": {
"browserify>process": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": {
"globals": { "globals": {
"crypto.getRandomValues": true "crypto.getRandomValues": true
@ -3504,11 +3318,17 @@
"console.info": true, "console.info": true,
"console.log": true, "console.log": true,
"console.warn": true, "console.warn": true,
"dist": true,
"document.body.appendChild": true, "document.body.appendChild": true,
"document.createElement": true, "document.createElement": true,
"document.getElementById": true, "document.getElementById": true,
"fetch": true, "fetch": true,
"setTimeout": true "location": true,
"npm": true,
"remove": true,
"setTimeout": true,
"tarball": true,
"versions": true
}, },
"packages": { "packages": {
"@metamask/controllers": true, "@metamask/controllers": true,

View File

@ -3216,6 +3216,10 @@
} }
}, },
"@metamask/rpc-methods": { "@metamask/rpc-methods": {
"globals": {
"caveats": true,
"params": true
},
"packages": { "packages": {
"@metamask/controllers": true, "@metamask/controllers": true,
"@metamask/rpc-methods>@metamask/key-tree": true, "@metamask/rpc-methods>@metamask/key-tree": true,
@ -3275,207 +3279,17 @@
"console.error": true, "console.error": true,
"console.log": true, "console.log": true,
"fetch": true, "fetch": true,
"setInterval": true, "setInterval": true
"setTimeout": true
}, },
"packages": { "packages": {
"@metamask/controllers": true,
"@metamask/controllers>isomorphic-fetch": true, "@metamask/controllers>isomorphic-fetch": true,
"@metamask/smart-transactions-controller>@metamask/controllers": true,
"@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>bignumber.js": true,
"@metamask/smart-transactions-controller>fast-json-patch": true, "@metamask/smart-transactions-controller>fast-json-patch": true,
"ethers": true, "ethers": true,
"lodash": true "lodash": true
} }
}, },
"@metamask/smart-transactions-controller>@metamask/controllers": {
"globals": {
"Headers": true,
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.log": true,
"fetch": true,
"setInterval": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/common": true,
"@ethereumjs/tx": true,
"@metamask/contract-metadata": true,
"@metamask/controllers>abort-controller": true,
"@metamask/controllers>async-mutex": true,
"@metamask/controllers>eth-phishing-detect": true,
"@metamask/controllers>isomorphic-fetch": true,
"@metamask/controllers>multiformats": true,
"@metamask/controllers>web3-provider-engine": true,
"@metamask/metamask-eth-abis": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": true,
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": true,
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": true,
"@storybook/api>fast-deep-equal": true,
"browserify>buffer": true,
"browserify>events": true,
"deep-freeze-strict": true,
"eth-ens-namehash": true,
"eth-json-rpc-infura": true,
"eth-query": true,
"eth-rpc-errors": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"ethers": true,
"ethjs>ethjs-unit": true,
"immer": true,
"json-rpc-engine": true,
"jsonschema": true,
"punycode": true,
"single-call-balance-checker-abi": true,
"uuid": true,
"web3": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": true,
"browserify>events": true,
"eth-keyring-controller>browser-passworder": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-keyring-controller>obs-store": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"loglevel": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": true,
"browserify>crypto-browserify>pbkdf2": true,
"ethereumjs-util>create-hash": true,
"ethereumjs-wallet>randombytes": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39>unorm": {
"globals": {
"define": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>bip39": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": true,
"eth-keyring-controller>eth-simple-keyring": true,
"eth-sig-util": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-keyring-controller>eth-hd-keyring>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs": {
"globals": {
"clearInterval": true,
"setInterval": true
},
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-provider-http": true,
"ethjs>ethjs-unit": true,
"ethjs>ethjs-util": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"ethjs-query>babel-runtime": true,
"ethjs>ethjs-filter": true,
"ethjs>ethjs-util": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-contract>ethjs-abi": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>bn.js": true,
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": true,
"browserify>buffer": true,
"ethjs>number-to-bn": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>ethjs-query": {
"globals": {
"console": true
},
"packages": {
"ethjs-query>babel-runtime": true,
"ethjs-query>ethjs-format": true,
"ethjs-query>ethjs-rpc": true,
"promise-to-callback": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>eth-method-registry>ethjs>js-sha3": {
"packages": {
"browserify>process": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet": {
"packages": {
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": true,
"@truffle/codec>utf8": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"ethereumjs-util": true,
"ethereumjs-util>ethereum-cryptography": true,
"ethereumjs-wallet>aes-js": true,
"ethereumjs-wallet>bs58check": true,
"ethereumjs-wallet>randombytes": true,
"ethers>@ethersproject/json-wallets>scrypt-js": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>ethereumjs-wallet>uuid": {
"globals": {
"crypto": true,
"msCrypto": true
}
},
"@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": {
"globals": { "globals": {
"crypto.getRandomValues": true "crypto.getRandomValues": true
@ -3504,14 +3318,19 @@
"console.info": true, "console.info": true,
"console.log": true, "console.log": true,
"console.warn": true, "console.warn": true,
"dist": true,
"document.body.appendChild": true, "document.body.appendChild": true,
"document.createElement": true, "document.createElement": true,
"document.getElementById": true, "document.getElementById": true,
"fetch": true, "fetch": true,
"setTimeout": true "location": true,
"npm": true,
"remove": true,
"setTimeout": true,
"tarball": true,
"versions": true
}, },
"packages": { "packages": {
"@metamask/snap-controllers>@metamask/controllers": true,
"@metamask/controllers": true, "@metamask/controllers": true,
"@metamask/post-message-stream": true, "@metamask/post-message-stream": true,
"@metamask/providers>@metamask/object-multiplex": true, "@metamask/providers>@metamask/object-multiplex": true,
@ -3534,43 +3353,6 @@
"semver": true "semver": true
} }
}, },
"@metamask/snap-controllers>@metamask/controllers": {
"packages": {
"@metamask/controllers>isomorphic-fetch": true,
"browserify>buffer": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"eth-rpc-errors": true,
"eth-ens-namehash": true,
"eth-sig-util": true,
"jsonschema": true,
"@metamask/controllers>multiformats": true,
"@storybook/api>fast-deep-equal": true,
"eth-query": true,
"@metamask/controllers>async-mutex": true,
"@metamask/snap-controllers>nanoid": true,
"immer": true,
"web3": true,
"single-call-balance-checker-abi": true,
"@metamask/metamask-eth-abis": true,
"ethereumjs-wallet": true,
"eth-keyring-controller": true,
"uuid": true,
"browserify>events": true,
"@metamask/controllers>web3-provider-engine": true,
"eth-json-rpc-infura": true,
"punycode": true,
"@metamask/controllers>eth-phishing-detect": true,
"eth-method-registry": true,
"@ethereumjs/common": true,
"@ethereumjs/tx": true,
"@metamask/contract-metadata": true,
"@metamask/controllers>abort-controller": true,
"ethers": true,
"deep-freeze-strict": true,
"json-rpc-engine": true
}
},
"@metamask/snap-controllers>@metamask/obs-store": { "@metamask/snap-controllers>@metamask/obs-store": {
"packages": { "packages": {
"@metamask/snap-controllers>@metamask/obs-store>through2": true, "@metamask/snap-controllers>@metamask/obs-store>through2": true,

View File

@ -129,7 +129,7 @@
"@metamask/providers": "^8.1.1", "@metamask/providers": "^8.1.1",
"@metamask/rpc-methods": "^0.14.0", "@metamask/rpc-methods": "^0.14.0",
"@metamask/slip44": "^2.1.0", "@metamask/slip44": "^2.1.0",
"@metamask/smart-transactions-controller": "^1.10.0", "@metamask/smart-transactions-controller": "^2.0.1",
"@metamask/snap-controllers": "^0.14.0", "@metamask/snap-controllers": "^0.14.0",
"@ngraveio/bc-ur": "^1.1.6", "@ngraveio/bc-ur": "^1.1.6",
"@popperjs/core": "^2.4.0", "@popperjs/core": "^2.4.0",

View File

@ -2,51 +2,102 @@ import { MAINNET_CHAIN_ID } from '../../shared/constants/network';
const createGetSmartTransactionFeesApiResponse = () => { const createGetSmartTransactionFeesApiResponse = () => {
return { return {
cancelFees: [ tradeTxFees: {
{ maxFeePerGas: 2100001000, maxPriorityFeePerGas: 466503987 }, // Approval tx.
{ maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 }, cancelFees: [
{ maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470851 }, { maxFeePerGas: 2100001000, maxPriorityFeePerGas: 466503987 },
{ maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 }, { maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 },
{ maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010971 }, { maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470851 },
{ maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 }, { maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 },
{ maxFeePerGas: 3720300164, maxPriorityFeePerGas: 826444778 }, { maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010971 },
{ maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 }, { maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 },
{ maxFeePerGas: 4501571383, maxPriorityFeePerGas: 1000000000 }, { maxFeePerGas: 3720300164, maxPriorityFeePerGas: 826444778 },
{ maxFeePerGas: 4951733023, maxPriorityFeePerGas: 1100001000 }, { maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 },
{ maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 }, { maxFeePerGas: 4501571383, maxPriorityFeePerGas: 1000000000 },
{ maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 }, { maxFeePerGas: 4951733023, maxPriorityFeePerGas: 1100001000 },
{ maxFeePerGas: 6590774628, maxPriorityFeePerGas: 1464105324 }, { maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 },
{ maxFeePerGas: 7249858682, maxPriorityFeePerGas: 1610517320 }, { maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 },
{ maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570663 }, { maxFeePerGas: 6590774628, maxPriorityFeePerGas: 1464105324 },
{ maxFeePerGas: 8772344955, maxPriorityFeePerGas: 1948729500 }, { maxFeePerGas: 7249858682, maxPriorityFeePerGas: 1610517320 },
{ maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604399 }, { maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570663 },
{ maxFeePerGas: 10614556694, maxPriorityFeePerGas: 2357966983 }, { maxFeePerGas: 8772344955, maxPriorityFeePerGas: 1948729500 },
{ maxFeePerGas: 11676022978, maxPriorityFeePerGas: 2593766039 }, { maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604399 },
], { maxFeePerGas: 10614556694, maxPriorityFeePerGas: 2357966983 },
feeEstimate: 42000000000000, { maxFeePerGas: 11676022978, maxPriorityFeePerGas: 2593766039 },
fees: [ ],
{ maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 }, feeEstimate: 42000000000000,
{ maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470850 }, fees: [
{ maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 }, { maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 },
{ maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010970 }, { maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470850 },
{ maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 }, { maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 },
{ maxFeePerGas: 3720300163, maxPriorityFeePerGas: 826444777 }, { maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010970 },
{ maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 }, { maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 },
{ maxFeePerGas: 4501571382, maxPriorityFeePerGas: 999999999 }, { maxFeePerGas: 3720300163, maxPriorityFeePerGas: 826444777 },
{ maxFeePerGas: 4951733022, maxPriorityFeePerGas: 1100001000 }, { maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 },
{ maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 }, { maxFeePerGas: 4501571382, maxPriorityFeePerGas: 999999999 },
{ maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 }, { maxFeePerGas: 4951733022, maxPriorityFeePerGas: 1100001000 },
{ maxFeePerGas: 6590774627, maxPriorityFeePerGas: 1464105324 }, { maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 },
{ maxFeePerGas: 7249858681, maxPriorityFeePerGas: 1610517320 }, { maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 },
{ maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570662 }, { maxFeePerGas: 6590774627, maxPriorityFeePerGas: 1464105324 },
{ maxFeePerGas: 8772344954, maxPriorityFeePerGas: 1948729500 }, { maxFeePerGas: 7249858681, maxPriorityFeePerGas: 1610517320 },
{ maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604398 }, { maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570662 },
{ maxFeePerGas: 10614556693, maxPriorityFeePerGas: 2357966982 }, { maxFeePerGas: 8772344954, maxPriorityFeePerGas: 1948729500 },
{ maxFeePerGas: 11676022977, maxPriorityFeePerGas: 2593766039 }, { maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604398 },
{ maxFeePerGas: 12843636951, maxPriorityFeePerGas: 2853145236 }, { maxFeePerGas: 10614556693, maxPriorityFeePerGas: 2357966982 },
], { maxFeePerGas: 11676022977, maxPriorityFeePerGas: 2593766039 },
gasLimit: 21000, { maxFeePerGas: 12843636951, maxPriorityFeePerGas: 2853145236 },
gasUsed: 21000, ],
gasLimit: 21000,
gasUsed: 21000,
},
approvalTxFees: {
// Trade tx.
cancelFees: [
{ maxFeePerGas: 2100001000, maxPriorityFeePerGas: 466503987 },
{ maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 },
{ maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470851 },
{ maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 },
{ maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010971 },
{ maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 },
{ maxFeePerGas: 3720300164, maxPriorityFeePerGas: 826444778 },
{ maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 },
{ maxFeePerGas: 4501571383, maxPriorityFeePerGas: 1000000000 },
{ maxFeePerGas: 4951733023, maxPriorityFeePerGas: 1100001000 },
{ maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 },
{ maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 },
{ maxFeePerGas: 6590774628, maxPriorityFeePerGas: 1464105324 },
{ maxFeePerGas: 7249858682, maxPriorityFeePerGas: 1610517320 },
{ maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570663 },
{ maxFeePerGas: 8772344955, maxPriorityFeePerGas: 1948729500 },
{ maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604399 },
{ maxFeePerGas: 10614556694, maxPriorityFeePerGas: 2357966983 },
{ maxFeePerGas: 11676022978, maxPriorityFeePerGas: 2593766039 },
],
feeEstimate: 42000000000000,
fees: [
{ maxFeePerGas: 2310003200, maxPriorityFeePerGas: 513154852 },
{ maxFeePerGas: 2541005830, maxPriorityFeePerGas: 564470850 },
{ maxFeePerGas: 2795108954, maxPriorityFeePerGas: 620918500 },
{ maxFeePerGas: 3074622644, maxPriorityFeePerGas: 683010970 },
{ maxFeePerGas: 3382087983, maxPriorityFeePerGas: 751312751 },
{ maxFeePerGas: 3720300163, maxPriorityFeePerGas: 826444777 },
{ maxFeePerGas: 4092333900, maxPriorityFeePerGas: 909090082 },
{ maxFeePerGas: 4501571382, maxPriorityFeePerGas: 999999999 },
{ maxFeePerGas: 4951733022, maxPriorityFeePerGas: 1100001000 },
{ maxFeePerGas: 5446911277, maxPriorityFeePerGas: 1210002200 },
{ maxFeePerGas: 5991607851, maxPriorityFeePerGas: 1331003630 },
{ maxFeePerGas: 6590774627, maxPriorityFeePerGas: 1464105324 },
{ maxFeePerGas: 7249858681, maxPriorityFeePerGas: 1610517320 },
{ maxFeePerGas: 7974851800, maxPriorityFeePerGas: 1771570662 },
{ maxFeePerGas: 8772344954, maxPriorityFeePerGas: 1948729500 },
{ maxFeePerGas: 9649588222, maxPriorityFeePerGas: 2143604398 },
{ maxFeePerGas: 10614556693, maxPriorityFeePerGas: 2357966982 },
{ maxFeePerGas: 11676022977, maxPriorityFeePerGas: 2593766039 },
{ maxFeePerGas: 12843636951, maxPriorityFeePerGas: 2853145236 },
],
gasLimit: 21000,
gasUsed: 21000,
},
}; };
}; };
@ -384,11 +435,6 @@ export const createSwapsMockStore = () => {
}, },
], ],
}, },
estimatedGas: {
txData: {
feeEstimate: 5435000587128155,
},
},
}, },
}, },
appState: { appState: {

View File

@ -31,7 +31,6 @@ import {
updateSmartTransaction, updateSmartTransaction,
setSmartTransactionsRefreshInterval, setSmartTransactionsRefreshInterval,
fetchSmartTransactionFees, fetchSmartTransactionFees,
estimateSmartTransactionsGas,
cancelSmartTransaction, cancelSmartTransaction,
getTransactions, getTransactions,
} from '../../store/actions'; } from '../../store/actions';
@ -923,36 +922,44 @@ export const signAndSendSwapsSmartTransaction = ({
const approveTxParams = getApproveTxParams(state); const approveTxParams = getApproveTxParams(state);
let approvalTxUuid; let approvalTxUuid;
let updatedApproveTxParams;
try { try {
if (approveTxParams) { if (approveTxParams) {
const updatedApproveTxParams = { updatedApproveTxParams = {
...approveTxParams, ...approveTxParams,
value: '0x0', value: '0x0',
}; };
const smartTransactionApprovalFees = await dispatch( }
fetchSwapsSmartTransactionFees(updatedApproveTxParams), const fees = await dispatch(
); fetchSwapsSmartTransactionFees(
unsignedTransaction,
updatedApproveTxParams,
),
);
if (!fees) {
log.error('"fetchSwapsSmartTransactionFees" failed');
dispatch(setSwapsSTXSubmitLoading(false));
dispatch(setCurrentSmartTransactionsError(stxErrorTypes.UNAVAILABLE));
return;
}
if (approveTxParams) {
updatedApproveTxParams.gas = `0x${decimalToHex( updatedApproveTxParams.gas = `0x${decimalToHex(
smartTransactionApprovalFees?.gasLimit || 0, fees.approvalTxFees?.gasLimit || 0,
)}`; )}`;
approvalTxUuid = await dispatch( approvalTxUuid = await dispatch(
signAndSendSmartTransaction({ signAndSendSmartTransaction({
unsignedTransaction: updatedApproveTxParams, unsignedTransaction: updatedApproveTxParams,
smartTransactionFees: smartTransactionApprovalFees, smartTransactionFees: fees.approvalTxFees,
}), }),
); );
} }
const smartTransactionFees = await dispatch(
fetchSwapsSmartTransactionFees(unsignedTransaction),
);
unsignedTransaction.gas = `0x${decimalToHex( unsignedTransaction.gas = `0x${decimalToHex(
smartTransactionFees?.gasLimit || 0, fees.tradeTxFees?.gasLimit || 0,
)}`; )}`;
const uuid = await dispatch( const uuid = await dispatch(
signAndSendSmartTransaction({ signAndSendSmartTransaction({
unsignedTransaction, unsignedTransaction,
smartTransactionFees, smartTransactionFees: fees.tradeTxFees,
}), }),
); );
@ -1304,37 +1311,17 @@ export function fetchMetaSwapsGasPriceEstimates() {
}; };
} }
export function fetchSwapsSmartTransactionFees(unsignedTransaction) { export function fetchSwapsSmartTransactionFees(
return async (dispatch, getState) => {
const {
swaps: { isFeatureFlagLoaded },
} = getState();
try {
return await dispatch(fetchSmartTransactionFees(unsignedTransaction));
} catch (e) {
if (e.message.startsWith('Fetch error:') && isFeatureFlagLoaded) {
const errorObj = parseSmartTransactionsError(e.message);
dispatch(setCurrentSmartTransactionsError(errorObj?.type));
}
}
return null;
};
}
export function estimateSwapsSmartTransactionsGas(
unsignedTransaction, unsignedTransaction,
approveTxParams, approveTxParams,
) { ) {
return async (dispatch, getState) => { return async (dispatch, getState) => {
const { const {
swaps: { isFeatureFlagLoaded, swapsSTXLoading }, swaps: { isFeatureFlagLoaded },
} = getState(); } = getState();
if (swapsSTXLoading) {
return;
}
try { try {
await dispatch( return await dispatch(
estimateSmartTransactionsGas(unsignedTransaction, approveTxParams), fetchSmartTransactionFees(unsignedTransaction, approveTxParams),
); );
} catch (e) { } catch (e) {
if (e.message.startsWith('Fetch error:') && isFeatureFlagLoaded) { if (e.message.startsWith('Fetch error:') && isFeatureFlagLoaded) {
@ -1342,6 +1329,7 @@ export function estimateSwapsSmartTransactionsGas(
dispatch(setCurrentSmartTransactionsError(errorObj?.type)); dispatch(setCurrentSmartTransactionsError(errorObj?.type));
} }
} }
return null;
}; };
} }

View File

@ -47,8 +47,8 @@ import {
getCurrentSmartTransactionsError, getCurrentSmartTransactionsError,
getCurrentSmartTransactionsErrorMessageDismissed, getCurrentSmartTransactionsErrorMessageDismissed,
getSwapsSTXLoading, getSwapsSTXLoading,
estimateSwapsSmartTransactionsGas, fetchSwapsSmartTransactionFees,
getSmartTransactionEstimatedGas, getSmartTransactionFees,
} from '../../../ducks/swaps/swaps'; } from '../../../ducks/swaps/swaps';
import { import {
conversionRateSelector, conversionRateSelector,
@ -202,9 +202,7 @@ export default function ViewQuote() {
(currentSmartTransactionsError !== 'not_enough_funds' || (currentSmartTransactionsError !== 'not_enough_funds' ||
currentSmartTransactionsErrorMessageDismissed) currentSmartTransactionsErrorMessageDismissed)
); );
const smartTransactionEstimatedGas = useSelector( const smartTransactionFees = useSelector(getSmartTransactionFees);
getSmartTransactionEstimatedGas,
);
const swapsNetworkConfig = useSelector(getSwapsNetworkConfig); const swapsNetworkConfig = useSelector(getSwapsNetworkConfig);
const unsignedTransaction = usedQuote.trade; const unsignedTransaction = usedQuote.trade;
@ -308,7 +306,7 @@ export default function ViewQuote() {
chainId, chainId,
smartTransactionsEnabled && smartTransactionsEnabled &&
smartTransactionsOptInStatus && smartTransactionsOptInStatus &&
smartTransactionEstimatedGas?.txData, smartTransactionFees?.tradeTxFees,
nativeCurrencySymbol, nativeCurrencySymbol,
); );
}, [ }, [
@ -321,7 +319,7 @@ export default function ViewQuote() {
approveGas, approveGas,
memoizedTokenConversionRates, memoizedTokenConversionRates,
chainId, chainId,
smartTransactionEstimatedGas?.txData, smartTransactionFees?.tradeTxFees,
nativeCurrencySymbol, nativeCurrencySymbol,
smartTransactionsEnabled, smartTransactionsEnabled,
smartTransactionsOptInStatus, smartTransactionsOptInStatus,
@ -391,11 +389,11 @@ export default function ViewQuote() {
if ( if (
currentSmartTransactionsEnabled && currentSmartTransactionsEnabled &&
smartTransactionsOptInStatus && smartTransactionsOptInStatus &&
smartTransactionEstimatedGas?.txData smartTransactionFees?.tradeTxFees
) { ) {
const stxEstimatedFeeInWeiDec = const stxEstimatedFeeInWeiDec =
smartTransactionEstimatedGas.txData.feeEstimate + smartTransactionFees?.tradeTxFees.feeEstimate +
(smartTransactionEstimatedGas.approvalTxData?.feeEstimate || 0); (smartTransactionFees?.approvalTxFees?.feeEstimate || 0);
const stxMaxFeeInWeiDec = const stxMaxFeeInWeiDec =
stxEstimatedFeeInWeiDec * swapsNetworkConfig.stxMaxFeeMultiplier; stxEstimatedFeeInWeiDec * swapsNetworkConfig.stxMaxFeeMultiplier;
({ feeInFiat, feeInEth, rawEthFee, feeInUsd } = getFeeForSmartTransaction({ ({ feeInFiat, feeInEth, rawEthFee, feeInUsd } = getFeeForSmartTransaction({
@ -409,7 +407,7 @@ export default function ViewQuote() {
additionalTrackingParams.stx_fee_in_usd = Number(feeInUsd); additionalTrackingParams.stx_fee_in_usd = Number(feeInUsd);
additionalTrackingParams.stx_fee_in_eth = Number(rawEthFee); additionalTrackingParams.stx_fee_in_eth = Number(rawEthFee);
additionalTrackingParams.estimated_gas = additionalTrackingParams.estimated_gas =
smartTransactionEstimatedGas.txData.gasLimit; smartTransactionFees?.tradeTxFees.gasLimit;
({ ({
feeInFiat: maxFeeInFiat, feeInFiat: maxFeeInFiat,
feeInEth: maxFeeInEth, feeInEth: maxFeeInEth,
@ -785,11 +783,11 @@ export default function ViewQuote() {
chainId, chainId,
}; };
intervalId = setInterval(() => { intervalId = setInterval(() => {
dispatch( if (!swapsSTXLoading) {
estimateSwapsSmartTransactionsGas(unsignedTx, approveTxParams), dispatch(fetchSwapsSmartTransactionFees(unsignedTx, approveTxParams));
); }
}, swapsNetworkConfig.stxGetTransactionsRefreshTime); }, swapsNetworkConfig.stxGetTransactionsRefreshTime);
dispatch(estimateSwapsSmartTransactionsGas(unsignedTx, approveTxParams)); dispatch(fetchSwapsSmartTransactionFees(unsignedTx, approveTxParams));
} else if (intervalId) { } else if (intervalId) {
clearInterval(intervalId); clearInterval(intervalId);
} }
@ -908,14 +906,14 @@ export default function ViewQuote() {
/> />
{currentSmartTransactionsEnabled && {currentSmartTransactionsEnabled &&
smartTransactionsOptInStatus && smartTransactionsOptInStatus &&
!smartTransactionEstimatedGas?.txData && ( !smartTransactionFees?.tradeTxFees && (
<Box marginTop={0} marginBottom={10}> <Box marginTop={0} marginBottom={10}>
<PulseLoader /> <PulseLoader />
</Box> </Box>
)} )}
{(!currentSmartTransactionsEnabled || {(!currentSmartTransactionsEnabled ||
!smartTransactionsOptInStatus || !smartTransactionsOptInStatus ||
smartTransactionEstimatedGas?.txData) && ( smartTransactionFees?.tradeTxFees) && (
<div <div
className={classnames('view-quote__fee-card-container', { className={classnames('view-quote__fee-card-container', {
'view-quote__fee-card-container--three-rows': 'view-quote__fee-card-container--three-rows':
@ -963,7 +961,7 @@ export default function ViewQuote() {
if ( if (
currentSmartTransactionsEnabled && currentSmartTransactionsEnabled &&
smartTransactionsOptInStatus && smartTransactionsOptInStatus &&
smartTransactionEstimatedGas?.txData smartTransactionFees?.tradeTxFees
) { ) {
dispatch( dispatch(
signAndSendSwapsSmartTransaction({ signAndSendSwapsSmartTransaction({

View File

@ -64,6 +64,7 @@ describe('ViewQuote', () => {
getByTestId('main-quote-summary__exchange-rate-container'), getByTestId('main-quote-summary__exchange-rate-container'),
).toMatchSnapshot(); ).toMatchSnapshot();
expect(getByText('Estimated gas fee')).toBeInTheDocument(); expect(getByText('Estimated gas fee')).toBeInTheDocument();
expect(getByText('0.00008 ETH')).toBeInTheDocument();
expect(getByText('Max fee')).toBeInTheDocument(); expect(getByText('Max fee')).toBeInTheDocument();
expect(getByText('Swap')).toBeInTheDocument(); expect(getByText('Swap')).toBeInTheDocument();
}); });
@ -87,7 +88,7 @@ describe('ViewQuote', () => {
getByTestId('main-quote-summary__exchange-rate-container'), getByTestId('main-quote-summary__exchange-rate-container'),
).toMatchSnapshot(); ).toMatchSnapshot();
expect(getByText('Estimated gas fee')).toBeInTheDocument(); expect(getByText('Estimated gas fee')).toBeInTheDocument();
expect(getByText('0.00544 ETH')).toBeInTheDocument(); expect(getByText('0.00008 ETH')).toBeInTheDocument();
expect(getByText('Max fee')).toBeInTheDocument(); expect(getByText('Max fee')).toBeInTheDocument();
expect(getByText('Swap')).toBeInTheDocument(); expect(getByText('Swap')).toBeInTheDocument();
}); });

View File

@ -3512,36 +3512,16 @@ export async function setSmartTransactionsOptInStatus(
await promisifiedBackground.setSmartTransactionsOptInStatus(optInState); await promisifiedBackground.setSmartTransactionsOptInStatus(optInState);
} }
export function fetchSmartTransactionFees(unsignedTransaction) { export function fetchSmartTransactionFees(
return async (dispatch) => {
try {
return await promisifiedBackground.fetchSmartTransactionFees(
unsignedTransaction,
);
} catch (e) {
log.error(e);
if (e.message.startsWith('Fetch error:')) {
const errorObj = parseSmartTransactionsError(e.message);
dispatch({
type: actionConstants.SET_SMART_TRANSACTIONS_ERROR,
payload: errorObj.type,
});
}
throw e;
}
};
}
export function estimateSmartTransactionsGas(
unsignedTransaction, unsignedTransaction,
approveTxParams, approveTxParams,
) { ) {
if (approveTxParams) {
approveTxParams.value = '0x0';
}
return async (dispatch) => { return async (dispatch) => {
if (approveTxParams) {
approveTxParams.value = '0x0';
}
try { try {
await promisifiedBackground.estimateSmartTransactionsGas( return await promisifiedBackground.fetchSmartTransactionFees(
unsignedTransaction, unsignedTransaction,
approveTxParams, approveTxParams,
); );

View File

@ -2807,47 +2807,6 @@
resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.33.0.tgz#3f0501d5c6d9119ce09c1edb075fc0a8fed7d09c" resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.33.0.tgz#3f0501d5c6d9119ce09c1edb075fc0a8fed7d09c"
integrity sha512-sWfzsUe59UH2Y1A7czRjhPmYrWlg4UQDOUPdf+lY7kbXwYrlF/ZUvhQYajdgJVchv2yDzr+cFhWF7DmNb5NyTQ== integrity sha512-sWfzsUe59UH2Y1A7czRjhPmYrWlg4UQDOUPdf+lY7kbXwYrlF/ZUvhQYajdgJVchv2yDzr+cFhWF7DmNb5NyTQ==
"@metamask/controllers@^27.1.1":
version "27.1.1"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-27.1.1.tgz#b3288bfd05e381e9e32ed60b68a09b2855db1140"
integrity sha512-RzQ4zKsqmieYqAiVsIIazLTo9GYMcm9fDhYPJklP1M+bzm1k49GRFnZEfru3w/dPVY+wWgcDo/0ZWlOILbu3hg==
dependencies:
"@ethereumjs/common" "^2.3.1"
"@ethereumjs/tx" "^3.2.1"
"@keystonehq/metamask-airgapped-keyring" "^0.3.0"
"@metamask/contract-metadata" "^1.33.0"
"@metamask/metamask-eth-abis" "3.0.0"
"@metamask/types" "^1.1.0"
"@types/uuid" "^8.3.0"
abort-controller "^3.0.0"
async-mutex "^0.2.6"
babel-runtime "^6.26.0"
deep-freeze-strict "^1.1.1"
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.16"
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"
fast-deep-equal "^3.1.3"
immer "^9.0.6"
isomorphic-fetch "^3.0.0"
json-rpc-engine "^6.1.0"
jsonschema "^1.2.4"
multiformats "^9.5.2"
nanoid "^3.1.31"
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/controllers@^29.0.1": "@metamask/controllers@^29.0.1":
version "29.0.1" version "29.0.1"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-29.0.1.tgz#8b6d066a23877c82de005ce566b7fd6bbaa7cc13" resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-29.0.1.tgz#8b6d066a23877c82de005ce566b7fd6bbaa7cc13"
@ -3092,12 +3051,12 @@
resolved "https://registry.yarnpkg.com/@metamask/slip44/-/slip44-2.1.0.tgz#f76764ca54afc162fbfe563f1994b79ed4711bba" resolved "https://registry.yarnpkg.com/@metamask/slip44/-/slip44-2.1.0.tgz#f76764ca54afc162fbfe563f1994b79ed4711bba"
integrity sha512-wkFDdY4XtpF+XCqbgwhsrLRgEM/bYfIt47927JTQZQ2QxQYRbSZ6u0QygnVjIR1eqMteRGx2jtUUZ+bxYQTo/w== integrity sha512-wkFDdY4XtpF+XCqbgwhsrLRgEM/bYfIt47927JTQZQ2QxQYRbSZ6u0QygnVjIR1eqMteRGx2jtUUZ+bxYQTo/w==
"@metamask/smart-transactions-controller@^1.10.0": "@metamask/smart-transactions-controller@^2.0.1":
version "1.10.0" version "2.0.1"
resolved "https://registry.yarnpkg.com/@metamask/smart-transactions-controller/-/smart-transactions-controller-1.10.0.tgz#230f611eaf9eefc41bac0e7af78101a215c6acba" resolved "https://registry.yarnpkg.com/@metamask/smart-transactions-controller/-/smart-transactions-controller-2.0.1.tgz#64bdce4368d2f33e6a2c044efe8b1a87cb20af1c"
integrity sha512-Bx2zT7UJJF2f11yANpC3OYCXYt2gpdqXj+RC4hnf18CELeF9Sp52xwQEkO6ig+3isrj6NsyVVmoo5PRcrU++cA== integrity sha512-W0RmziH9HswBbchD2a97j/2sMO2qCYwcpynIJkDVLTmXJ/a6j5cECSr+vMs207bJJDExFlEOXvL+/21oINVZvA==
dependencies: dependencies:
"@metamask/controllers" "^27.1.1" "@metamask/controllers" "^29.0.1"
"@types/lodash" "^4.14.176" "@types/lodash" "^4.14.176"
bignumber.js "^9.0.1" bignumber.js "^9.0.1"
ethers "^5.5.1" ethers "^5.5.1"
@ -6777,17 +6736,6 @@ bip32@^2.0.4:
typeforce "^1.11.5" typeforce "^1.11.5"
wif "^2.0.6" wif "^2.0.6"
bip39@^2.2.0, bip39@^2.4.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235"
integrity sha512-xwIx/8JKoT2+IPJpFEfXoWdYwP7UVAoUxxLNfGCfVowaJE7yg1Y5B1BVPqlUNsBq5/nGwmFkwRJ8xDW4sX8OdA==
dependencies:
create-hash "^1.1.0"
pbkdf2 "^3.0.9"
randombytes "^2.0.1"
safe-buffer "^5.0.1"
unorm "^1.3.3"
bip66@^1.1.0, bip66@^1.1.5: bip66@^1.1.0, bip66@^1.1.5:
version "1.1.5" version "1.1.5"
resolved "https://registry.yarnpkg.com/bip66/-/bip66-1.1.5.tgz#01fa8748785ca70955d5011217d1b3139969ca22" resolved "https://registry.yarnpkg.com/bip66/-/bip66-1.1.5.tgz#01fa8748785ca70955d5011217d1b3139969ca22"
@ -6870,7 +6818,7 @@ blob@0.0.5:
resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683"
integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig== integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==
bluebird@3.7.2, bluebird@^3.3.5, bluebird@^3.5.0, bluebird@^3.5.5, bluebird@^3.7.2: bluebird@3.7.2, bluebird@^3.3.5, bluebird@^3.5.5, bluebird@^3.7.2:
version "3.7.2" version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
@ -11061,17 +11009,6 @@ eth-ens-namehash@^2.0.8:
idna-uts46-hx "^2.3.1" idna-uts46-hx "^2.3.1"
js-sha3 "^0.5.7" js-sha3 "^0.5.7"
eth-hd-keyring@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/eth-hd-keyring/-/eth-hd-keyring-3.6.0.tgz#6835d30aa411b8d3ef098e82f6427b5325082abb"
integrity sha512-n2CwE9VNXsxLrXQa6suv0Umt4NT6+HtoahKgWx3YviXx4rQFwVT5nDwZfjhwrT31ESuoXYNIeJgz5hKLD96QeQ==
dependencies:
bip39 "^2.2.0"
eth-sig-util "^3.0.1"
eth-simple-keyring "^4.2.0"
ethereumjs-util "^7.0.9"
ethereumjs-wallet "^1.0.1"
eth-json-rpc-filters@^4.2.1: eth-json-rpc-filters@^4.2.1:
version "4.2.1" version "4.2.1"
resolved "https://registry.yarnpkg.com/eth-json-rpc-filters/-/eth-json-rpc-filters-4.2.1.tgz#82204a13c99927dbf42cbb3962846650c6281f33" resolved "https://registry.yarnpkg.com/eth-json-rpc-filters/-/eth-json-rpc-filters-4.2.1.tgz#82204a13c99927dbf42cbb3962846650c6281f33"
@ -11126,21 +11063,6 @@ eth-json-rpc-middleware@^8.0.0:
node-fetch "^2.6.7" node-fetch "^2.6.7"
pify "^3.0.0" pify "^3.0.0"
eth-keyring-controller@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-6.2.1.tgz#61901071fc74059ed37cb5ae93870fdcae6e3781"
integrity sha512-x2gTM1iHp2Kbvdtd9Eslysw0qzVZiqOzpVB3AU/ni2Xiit+rlcv2H80zYKjrEwlfWFDj4YILD3bOqlnEMmRJOA==
dependencies:
bip39 "^2.4.0"
bluebird "^3.5.0"
browser-passworder "^2.0.3"
eth-hd-keyring "^3.6.0"
eth-sig-util "^3.0.1"
eth-simple-keyring "^4.2.0"
ethereumjs-util "^7.0.9"
loglevel "^1.5.0"
obs-store "^4.0.3"
eth-keyring-controller@^7.0.2: eth-keyring-controller@^7.0.2:
version "7.0.2" version "7.0.2"
resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-7.0.2.tgz#c4d7f9be179f08b3bb18410066bc4c8e91f50552" resolved "https://registry.yarnpkg.com/eth-keyring-controller/-/eth-keyring-controller-7.0.2.tgz#c4d7f9be179f08b3bb18410066bc4c8e91f50552"
@ -18123,7 +18045,7 @@ log-symbols@^4.0.0:
dependencies: dependencies:
chalk "^4.0.0" chalk "^4.0.0"
loglevel@^1.4.1, loglevel@^1.5.0: loglevel@^1.4.1:
version "1.6.0" version "1.6.0"
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.0.tgz#ae0caa561111498c5ba13723d6fb631d24003934" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.0.tgz#ae0caa561111498c5ba13723d6fb631d24003934"
integrity sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ= integrity sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ=
@ -26759,11 +26681,6 @@ universalify@^2.0.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
unorm@^1.3.3:
version "1.5.0"
resolved "https://registry.yarnpkg.com/unorm/-/unorm-1.5.0.tgz#01fa9b76f1c60f7916834605c032aa8962c3f00a"
integrity sha512-sMfSWoiRaXXeDZSXC+YRZ23H4xchQpwxjpw1tmfR+kgbBCaOgln4NI0LXejJIhnBuKINrB3WRn+ZI8IWssirVw==
unpipe@1.0.0, unpipe@~1.0.0: unpipe@1.0.0, unpipe@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"