diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8c9956f26..d416c6aea 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1819,9 +1819,6 @@ export default class MetamaskController extends EventEmitter { fetchSmartTransactionFees: smartTransactionsController.getFees.bind( smartTransactionsController, ), - estimateSmartTransactionsGas: smartTransactionsController.estimateGas.bind( - smartTransactionsController, - ), submitSignedTransactions: smartTransactionsController.submitSignedTransactions.bind( smartTransactionsController, ), diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 88685c3a7..ce2bde5e4 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -3216,6 +3216,10 @@ } }, "@metamask/rpc-methods": { + "globals": { + "caveats": true, + "params": true + }, "packages": { "@metamask/controllers": true, "@metamask/rpc-methods>@metamask/key-tree": true, @@ -3275,207 +3279,17 @@ "console.error": true, "console.log": true, "fetch": true, - "setInterval": true, - "setTimeout": true + "setInterval": true }, "packages": { + "@metamask/controllers": true, "@metamask/controllers>isomorphic-fetch": true, - "@metamask/smart-transactions-controller>@metamask/controllers": true, "@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>fast-json-patch": true, "ethers": 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": { "globals": { "crypto.getRandomValues": true @@ -3504,11 +3318,17 @@ "console.info": true, "console.log": true, "console.warn": true, + "dist": true, "document.body.appendChild": true, "document.createElement": true, "document.getElementById": true, "fetch": true, - "setTimeout": true + "location": true, + "npm": true, + "remove": true, + "setTimeout": true, + "tarball": true, + "versions": true }, "packages": { "@metamask/controllers": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 88685c3a7..ce2bde5e4 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -3216,6 +3216,10 @@ } }, "@metamask/rpc-methods": { + "globals": { + "caveats": true, + "params": true + }, "packages": { "@metamask/controllers": true, "@metamask/rpc-methods>@metamask/key-tree": true, @@ -3275,207 +3279,17 @@ "console.error": true, "console.log": true, "fetch": true, - "setInterval": true, - "setTimeout": true + "setInterval": true }, "packages": { + "@metamask/controllers": true, "@metamask/controllers>isomorphic-fetch": true, - "@metamask/smart-transactions-controller>@metamask/controllers": true, "@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>fast-json-patch": true, "ethers": 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": { "globals": { "crypto.getRandomValues": true @@ -3504,11 +3318,17 @@ "console.info": true, "console.log": true, "console.warn": true, + "dist": true, "document.body.appendChild": true, "document.createElement": true, "document.getElementById": true, "fetch": true, - "setTimeout": true + "location": true, + "npm": true, + "remove": true, + "setTimeout": true, + "tarball": true, + "versions": true }, "packages": { "@metamask/controllers": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index bc3e11725..ce2bde5e4 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -3216,6 +3216,10 @@ } }, "@metamask/rpc-methods": { + "globals": { + "caveats": true, + "params": true + }, "packages": { "@metamask/controllers": true, "@metamask/rpc-methods>@metamask/key-tree": true, @@ -3275,207 +3279,17 @@ "console.error": true, "console.log": true, "fetch": true, - "setInterval": true, - "setTimeout": true + "setInterval": true }, "packages": { + "@metamask/controllers": true, "@metamask/controllers>isomorphic-fetch": true, - "@metamask/smart-transactions-controller>@metamask/controllers": true, "@metamask/smart-transactions-controller>bignumber.js": true, "@metamask/smart-transactions-controller>fast-json-patch": true, "ethers": 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": { "globals": { "crypto.getRandomValues": true @@ -3504,14 +3318,19 @@ "console.info": true, "console.log": true, "console.warn": true, + "dist": true, "document.body.appendChild": true, "document.createElement": true, "document.getElementById": true, "fetch": true, - "setTimeout": true + "location": true, + "npm": true, + "remove": true, + "setTimeout": true, + "tarball": true, + "versions": true }, "packages": { - "@metamask/snap-controllers>@metamask/controllers": true, "@metamask/controllers": true, "@metamask/post-message-stream": true, "@metamask/providers>@metamask/object-multiplex": true, @@ -3534,43 +3353,6 @@ "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": { "packages": { "@metamask/snap-controllers>@metamask/obs-store>through2": true, diff --git a/package.json b/package.json index 2a6666b9d..ce039664d 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "@metamask/providers": "^8.1.1", "@metamask/rpc-methods": "^0.14.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", "@ngraveio/bc-ur": "^1.1.6", "@popperjs/core": "^2.4.0", diff --git a/test/jest/mock-store.js b/test/jest/mock-store.js index 73f4892b3..2595746c0 100644 --- a/test/jest/mock-store.js +++ b/test/jest/mock-store.js @@ -2,51 +2,102 @@ import { MAINNET_CHAIN_ID } from '../../shared/constants/network'; const createGetSmartTransactionFeesApiResponse = () => { return { - 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, + tradeTxFees: { + // Approval 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, + }, + 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: { diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index fc75375ba..a2fe1b53c 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -31,7 +31,6 @@ import { updateSmartTransaction, setSmartTransactionsRefreshInterval, fetchSmartTransactionFees, - estimateSmartTransactionsGas, cancelSmartTransaction, getTransactions, } from '../../store/actions'; @@ -923,36 +922,44 @@ export const signAndSendSwapsSmartTransaction = ({ const approveTxParams = getApproveTxParams(state); let approvalTxUuid; + let updatedApproveTxParams; try { if (approveTxParams) { - const updatedApproveTxParams = { + updatedApproveTxParams = { ...approveTxParams, 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( - smartTransactionApprovalFees?.gasLimit || 0, + fees.approvalTxFees?.gasLimit || 0, )}`; approvalTxUuid = await dispatch( signAndSendSmartTransaction({ unsignedTransaction: updatedApproveTxParams, - smartTransactionFees: smartTransactionApprovalFees, + smartTransactionFees: fees.approvalTxFees, }), ); } - - const smartTransactionFees = await dispatch( - fetchSwapsSmartTransactionFees(unsignedTransaction), - ); unsignedTransaction.gas = `0x${decimalToHex( - smartTransactionFees?.gasLimit || 0, + fees.tradeTxFees?.gasLimit || 0, )}`; const uuid = await dispatch( signAndSendSmartTransaction({ unsignedTransaction, - smartTransactionFees, + smartTransactionFees: fees.tradeTxFees, }), ); @@ -1304,37 +1311,17 @@ export function fetchMetaSwapsGasPriceEstimates() { }; } -export function fetchSwapsSmartTransactionFees(unsignedTransaction) { - 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( +export function fetchSwapsSmartTransactionFees( unsignedTransaction, approveTxParams, ) { return async (dispatch, getState) => { const { - swaps: { isFeatureFlagLoaded, swapsSTXLoading }, + swaps: { isFeatureFlagLoaded }, } = getState(); - if (swapsSTXLoading) { - return; - } try { - await dispatch( - estimateSmartTransactionsGas(unsignedTransaction, approveTxParams), + return await dispatch( + fetchSmartTransactionFees(unsignedTransaction, approveTxParams), ); } catch (e) { if (e.message.startsWith('Fetch error:') && isFeatureFlagLoaded) { @@ -1342,6 +1329,7 @@ export function estimateSwapsSmartTransactionsGas( dispatch(setCurrentSmartTransactionsError(errorObj?.type)); } } + return null; }; } diff --git a/ui/pages/swaps/view-quote/view-quote.js b/ui/pages/swaps/view-quote/view-quote.js index e1a098b2b..3e42fb9e8 100644 --- a/ui/pages/swaps/view-quote/view-quote.js +++ b/ui/pages/swaps/view-quote/view-quote.js @@ -47,8 +47,8 @@ import { getCurrentSmartTransactionsError, getCurrentSmartTransactionsErrorMessageDismissed, getSwapsSTXLoading, - estimateSwapsSmartTransactionsGas, - getSmartTransactionEstimatedGas, + fetchSwapsSmartTransactionFees, + getSmartTransactionFees, } from '../../../ducks/swaps/swaps'; import { conversionRateSelector, @@ -202,9 +202,7 @@ export default function ViewQuote() { (currentSmartTransactionsError !== 'not_enough_funds' || currentSmartTransactionsErrorMessageDismissed) ); - const smartTransactionEstimatedGas = useSelector( - getSmartTransactionEstimatedGas, - ); + const smartTransactionFees = useSelector(getSmartTransactionFees); const swapsNetworkConfig = useSelector(getSwapsNetworkConfig); const unsignedTransaction = usedQuote.trade; @@ -308,7 +306,7 @@ export default function ViewQuote() { chainId, smartTransactionsEnabled && smartTransactionsOptInStatus && - smartTransactionEstimatedGas?.txData, + smartTransactionFees?.tradeTxFees, nativeCurrencySymbol, ); }, [ @@ -321,7 +319,7 @@ export default function ViewQuote() { approveGas, memoizedTokenConversionRates, chainId, - smartTransactionEstimatedGas?.txData, + smartTransactionFees?.tradeTxFees, nativeCurrencySymbol, smartTransactionsEnabled, smartTransactionsOptInStatus, @@ -391,11 +389,11 @@ export default function ViewQuote() { if ( currentSmartTransactionsEnabled && smartTransactionsOptInStatus && - smartTransactionEstimatedGas?.txData + smartTransactionFees?.tradeTxFees ) { const stxEstimatedFeeInWeiDec = - smartTransactionEstimatedGas.txData.feeEstimate + - (smartTransactionEstimatedGas.approvalTxData?.feeEstimate || 0); + smartTransactionFees?.tradeTxFees.feeEstimate + + (smartTransactionFees?.approvalTxFees?.feeEstimate || 0); const stxMaxFeeInWeiDec = stxEstimatedFeeInWeiDec * swapsNetworkConfig.stxMaxFeeMultiplier; ({ feeInFiat, feeInEth, rawEthFee, feeInUsd } = getFeeForSmartTransaction({ @@ -409,7 +407,7 @@ export default function ViewQuote() { additionalTrackingParams.stx_fee_in_usd = Number(feeInUsd); additionalTrackingParams.stx_fee_in_eth = Number(rawEthFee); additionalTrackingParams.estimated_gas = - smartTransactionEstimatedGas.txData.gasLimit; + smartTransactionFees?.tradeTxFees.gasLimit; ({ feeInFiat: maxFeeInFiat, feeInEth: maxFeeInEth, @@ -785,11 +783,11 @@ export default function ViewQuote() { chainId, }; intervalId = setInterval(() => { - dispatch( - estimateSwapsSmartTransactionsGas(unsignedTx, approveTxParams), - ); + if (!swapsSTXLoading) { + dispatch(fetchSwapsSmartTransactionFees(unsignedTx, approveTxParams)); + } }, swapsNetworkConfig.stxGetTransactionsRefreshTime); - dispatch(estimateSwapsSmartTransactionsGas(unsignedTx, approveTxParams)); + dispatch(fetchSwapsSmartTransactionFees(unsignedTx, approveTxParams)); } else if (intervalId) { clearInterval(intervalId); } @@ -908,14 +906,14 @@ export default function ViewQuote() { /> {currentSmartTransactionsEnabled && smartTransactionsOptInStatus && - !smartTransactionEstimatedGas?.txData && ( + !smartTransactionFees?.tradeTxFees && ( )} {(!currentSmartTransactionsEnabled || !smartTransactionsOptInStatus || - smartTransactionEstimatedGas?.txData) && ( + smartTransactionFees?.tradeTxFees) && (
{ getByTestId('main-quote-summary__exchange-rate-container'), ).toMatchSnapshot(); expect(getByText('Estimated gas fee')).toBeInTheDocument(); + expect(getByText('0.00008 ETH')).toBeInTheDocument(); expect(getByText('Max fee')).toBeInTheDocument(); expect(getByText('Swap')).toBeInTheDocument(); }); @@ -87,7 +88,7 @@ describe('ViewQuote', () => { getByTestId('main-quote-summary__exchange-rate-container'), ).toMatchSnapshot(); 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('Swap')).toBeInTheDocument(); }); diff --git a/ui/store/actions.js b/ui/store/actions.js index 262b715d6..95243f081 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -3512,36 +3512,16 @@ export async function setSmartTransactionsOptInStatus( await promisifiedBackground.setSmartTransactionsOptInStatus(optInState); } -export function fetchSmartTransactionFees(unsignedTransaction) { - 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( +export function fetchSmartTransactionFees( unsignedTransaction, approveTxParams, ) { - if (approveTxParams) { - approveTxParams.value = '0x0'; - } return async (dispatch) => { + if (approveTxParams) { + approveTxParams.value = '0x0'; + } try { - await promisifiedBackground.estimateSmartTransactionsGas( + return await promisifiedBackground.fetchSmartTransactionFees( unsignedTransaction, approveTxParams, ); diff --git a/yarn.lock b/yarn.lock index 47bf62ae8..60ee82ea4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2807,47 +2807,6 @@ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.33.0.tgz#3f0501d5c6d9119ce09c1edb075fc0a8fed7d09c" 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": version "29.0.1" 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" integrity sha512-wkFDdY4XtpF+XCqbgwhsrLRgEM/bYfIt47927JTQZQ2QxQYRbSZ6u0QygnVjIR1eqMteRGx2jtUUZ+bxYQTo/w== -"@metamask/smart-transactions-controller@^1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@metamask/smart-transactions-controller/-/smart-transactions-controller-1.10.0.tgz#230f611eaf9eefc41bac0e7af78101a215c6acba" - integrity sha512-Bx2zT7UJJF2f11yANpC3OYCXYt2gpdqXj+RC4hnf18CELeF9Sp52xwQEkO6ig+3isrj6NsyVVmoo5PRcrU++cA== +"@metamask/smart-transactions-controller@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@metamask/smart-transactions-controller/-/smart-transactions-controller-2.0.1.tgz#64bdce4368d2f33e6a2c044efe8b1a87cb20af1c" + integrity sha512-W0RmziH9HswBbchD2a97j/2sMO2qCYwcpynIJkDVLTmXJ/a6j5cECSr+vMs207bJJDExFlEOXvL+/21oINVZvA== dependencies: - "@metamask/controllers" "^27.1.1" + "@metamask/controllers" "^29.0.1" "@types/lodash" "^4.14.176" bignumber.js "^9.0.1" ethers "^5.5.1" @@ -6777,17 +6736,6 @@ bip32@^2.0.4: typeforce "^1.11.5" 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: version "1.1.5" 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" 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" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== @@ -11061,17 +11009,6 @@ eth-ens-namehash@^2.0.8: idna-uts46-hx "^2.3.1" 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: version "4.2.1" 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" 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: version "7.0.2" 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: chalk "^4.0.0" -loglevel@^1.4.1, loglevel@^1.5.0: +loglevel@^1.4.1: version "1.6.0" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.0.tgz#ae0caa561111498c5ba13723d6fb631d24003934" integrity sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ= @@ -26759,11 +26681,6 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" 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: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"