diff --git a/app/components/UI/ApproveTransactionReview/index.js b/app/components/UI/ApproveTransactionReview/index.js index 65296adab77..6b96f2deae5 100644 --- a/app/components/UI/ApproveTransactionReview/index.js +++ b/app/components/UI/ApproveTransactionReview/index.js @@ -78,7 +78,6 @@ import Routes from '../../../constants/navigation/Routes'; import createStyles from './styles'; import { selectChainId, - selectNetwork, selectNetworkConfigurations, selectProviderType, selectTicker, @@ -1226,7 +1225,6 @@ const mapStateToProps = (state) => ({ providerRpcTarget: selectRpcTarget(state), primaryCurrency: state.settings.primaryCurrency, activeTabUrl: getActiveTabUrl(state), - networkId: selectNetwork(state), chainId: selectChainId(state), tokenList: selectTokenList(state), isNativeTokenBuySupported: isNetworkBuyNativeTokenSupported( diff --git a/app/components/Views/Asset/index.js b/app/components/Views/Asset/index.js index f66e253bce4..a381802dbda 100644 --- a/app/components/Views/Asset/index.js +++ b/app/components/Views/Asset/index.js @@ -30,7 +30,7 @@ import { } from '../../../reducers/swaps'; import { selectChainId, - selectNetwork, + selectNetworkId, selectNetworkConfigurations, selectRpcTarget, } from '../../../selectors/networkController'; @@ -587,7 +587,7 @@ const mapStateToProps = (state) => ({ identities: selectIdentities(state), chainId: selectChainId(state), tokens: selectTokens(state), - networkId: selectNetwork(state), + networkId: selectNetworkId(state), transactions: state.engine.backgroundState.TransactionController.transactions, rpcTarget: selectRpcTarget(state), networkConfigurations: selectNetworkConfigurations(state), diff --git a/app/components/Views/TransactionsView/index.js b/app/components/Views/TransactionsView/index.js index c7e70d8abdf..397d7b13be3 100644 --- a/app/components/Views/TransactionsView/index.js +++ b/app/components/Views/TransactionsView/index.js @@ -21,7 +21,7 @@ import { addAccountTimeFlagFilter } from '../../../util/transactions'; import { toLowerCaseEquals } from '../../../util/general'; import { selectChainId, - selectNetwork, + selectNetworkId, selectProviderType, } from '../../../selectors/networkController'; import { @@ -55,11 +55,11 @@ const TransactionsView = ({ const [submittedTxs, setSubmittedTxs] = useState([]); const [confirmedTxs, setConfirmedTxs] = useState([]); const [loading, setLoading] = useState(); - const networkId = useSelector(selectNetwork); + const networkId = useSelector(selectNetworkId); const filterTransactions = useCallback( (networkId) => { - if (networkId === 'loading') return; + if (networkId === null) return; let accountAddedTimeInsertPointFound = false; const addedAccountTime = identities[selectedAddress]?.importTime; diff --git a/app/core/BackgroundBridge/BackgroundBridge.js b/app/core/BackgroundBridge/BackgroundBridge.js index 7ba903dc0f5..2253bd08c47 100644 --- a/app/core/BackgroundBridge/BackgroundBridge.js +++ b/app/core/BackgroundBridge/BackgroundBridge.js @@ -19,8 +19,9 @@ import WalletConnectPort from './WalletConnectPort'; import Port from './Port'; import { selectChainId, - selectNetwork, + selectNetworkId, selectProviderConfig, + selectLegacyNetwork, } from '../../selectors/networkController'; import { store } from '../../store'; @@ -70,7 +71,7 @@ export class BackgroundBridge extends EventEmitter { this.engine = null; this.chainIdSent = selectChainId(store.getState()); - this.networkVersionSent = selectNetwork(store.getState()); + this.networkVersionSent = selectNetworkId(store.getState()); // This will only be used for WalletConnect for now this.addressSent = @@ -99,7 +100,7 @@ export class BackgroundBridge extends EventEmitter { if (this.isRemoteConn) { const memState = this.getState(); - const publicState = this.getProviderNetworkState(memState); + const publicState = this.getProviderNetworkState(); const selectedAddress = memState.selectedAddress; this.notifyChainChanged(publicState); this.notifySelectedAddressChanged(selectedAddress); @@ -154,7 +155,7 @@ export class BackgroundBridge extends EventEmitter { }); } - getProviderNetworkState({ network }) { + getProviderNetworkState() { const providerConfig = selectProviderConfig(store.getState()); const networkType = providerConfig.type; @@ -173,7 +174,7 @@ export class BackgroundBridge extends EventEmitter { } const result = { - networkVersion: network, + networkVersion: selectLegacyNetwork(store.getState()), chainId, }; return result; @@ -200,7 +201,7 @@ export class BackgroundBridge extends EventEmitter { if (!memState) { memState = this.getState(); } - const publicState = this.getProviderNetworkState(memState); + const publicState = this.getProviderNetworkState(); // Check if update already sent if ( @@ -227,10 +228,9 @@ export class BackgroundBridge extends EventEmitter { } getProviderState() { - const memState = this.getState(); return { isUnlocked: this.isUnlocked(), - ...this.getProviderNetworkState(memState), + ...this.getProviderNetworkState(), }; } @@ -340,11 +340,11 @@ export class BackgroundBridge extends EventEmitter { */ getState() { const vault = Engine.context.KeyringController.state.vault; - const { network, selectedAddress } = Engine.datamodel.flatState; + const { selectedAddress } = Engine.datamodel.flatState; return { isInitialized: !!vault, isUnlocked: true, - network, + network: selectLegacyNetwork(store.getState()), selectedAddress, }; } diff --git a/app/core/Engine.ts b/app/core/Engine.ts index 149d0c36dac..7618fd71d3b 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -38,6 +38,7 @@ import { NetworkControllerActions, NetworkControllerEvents, NetworkState, + NetworkStatus, } from '@metamask/network-controller'; import { PhishingController, @@ -535,9 +536,9 @@ class Engine { }, ), new TransactionController({ + blockTracker: + networkController.getProviderAndBlockTracker().blockTracker, getNetworkState: () => networkController.state, - getProvider: () => - networkController.getProviderAndBlockTracker().provider, getSelectedAddress: () => preferencesController.state.selectedAddress, incomingTransactions: { apiKey: process.env.MM_ETHERSCAN_KEY, @@ -554,6 +555,7 @@ class Engine { AppConstants.NETWORK_STATE_CHANGE_EVENT, listener, ), + provider: networkController.getProviderAndBlockTracker().provider, }), new SwapsController( { @@ -721,9 +723,9 @@ class Engine { this.controllerMessenger.subscribe( AppConstants.NETWORK_STATE_CHANGE_EVENT, - (state: { network: string; providerConfig: { chainId: any } }) => { + (state: NetworkState) => { if ( - state.network !== 'loading' && + state.networkStatus === NetworkStatus.Available && state.providerConfig.chainId !== currentChainId ) { // We should add a state or event emitter saying the provider changed diff --git a/app/selectors/networkController.ts b/app/selectors/networkController.ts index 7275a0969d1..e21f9bd4a82 100644 --- a/app/selectors/networkController.ts +++ b/app/selectors/networkController.ts @@ -1,6 +1,10 @@ import { createSelector } from 'reselect'; import { RootState } from '../reducers'; -import { ProviderConfig, NetworkState } from '@metamask/network-controller'; +import { + ProviderConfig, + NetworkState, + NetworkStatus, +} from '@metamask/network-controller'; const selectNetworkControllerState = (state: RootState) => state?.engine?.backgroundState?.NetworkController; @@ -32,9 +36,15 @@ export const selectRpcTarget = createSelector( selectProviderConfig, (providerConfig: ProviderConfig) => providerConfig.rpcTarget, ); -export const selectNetwork = createSelector( +export const selectNetworkId = createSelector( selectNetworkControllerState, - (networkControllerState: NetworkState) => networkControllerState?.network, + (networkControllerState: NetworkState) => networkControllerState?.networkId, +); + +export const selectNetworkStatus = createSelector( + selectNetworkControllerState, + (networkControllerState: NetworkState) => + networkControllerState?.networkStatus, ); export const selectNetworkConfigurations = createSelector( @@ -42,3 +52,18 @@ export const selectNetworkConfigurations = createSelector( (networkControllerState: NetworkState) => networkControllerState.networkConfigurations, ); + +/** + * Derive a value matching the now-removed property `network` that had been + * included in the NetworkController state. It's set to "loading" if the + * network is loading, but otherwise is set to the network ID. + * + * @deprecated Use networkStatus and networkId instead + */ +export const selectLegacyNetwork = createSelector( + selectNetworkControllerState, + (networkControllerState: NetworkState) => { + const { networkId, networkStatus } = networkControllerState; + return networkStatus !== NetworkStatus.Available ? 'loading' : networkId; + }, +); diff --git a/app/store/migrations.js b/app/store/migrations.js index 1b0b40ad3cd..a338b89f058 100644 --- a/app/store/migrations.js +++ b/app/store/migrations.js @@ -19,6 +19,7 @@ import { regex } from '../../app/util/regex'; // Generated using this script: https://gist.github.com/Gudahtt/7a8a9e452bd2efdc5ceecd93610a25d3 import ambiguousNetworks from './migration-data/amibiguous-networks.json'; +import { NetworkStatus } from '@metamask/network-controller'; export const migrations = { // Needed after https://github.com/MetaMask/controllers/pull/152 @@ -695,6 +696,53 @@ export const migrations = { return state; }, + /** + * Migrate NetworkController state, splitting old `network` property into + * `networkId` and `networkStatus`. This is required to update to v8 of the + * NetworkController package. + * + * @see {@link https://github.com/MetaMask/core/blob/main/packages/network-controller/CHANGELOG.md#800} + * + * Note: the type is wrong here because it conflicts with `redux-persist` + * types, due to a bug in that package. + * See: https://github.com/rt2zz/redux-persist/issues/1065 + * TODO: Use `unknown` as the state type, and silence or work around the + * redux-persist bug somehow. + * + * @param {any} state - Redux state. + * @returns Migrated Redux state. + */ + 24: (state) => { + const networkControllerState = + state.engine.backgroundState.NetworkController; + + if (!isObject(networkControllerState)) { + captureException( + new Error( + `Migration 24: Invalid network controller state: '${typeof networkControllerState}'`, + ), + ); + return state; + } else if (typeof networkControllerState.network !== 'string') { + captureException( + new Error( + `Migration 24: Invalid network state: '${typeof networkControllerState.network}'`, + ), + ); + return state; + } + + if (networkControllerState.network === 'loading') { + networkControllerState.networkId = null; + networkControllerState.networkStatus = NetworkStatus.Unknown; + } else { + networkControllerState.networkId = networkControllerState.network; + networkControllerState.networkStatus = NetworkStatus.Available; + } + delete networkControllerState.network; + + return state; + }, // If you are implementing a migration it will break the migration tests, // please write a unit for your specific migration version }; diff --git a/app/store/migrations.test.js b/app/store/migrations.test.js index 11b89e8f7f6..dd0d840b90c 100644 --- a/app/store/migrations.test.js +++ b/app/store/migrations.test.js @@ -802,4 +802,101 @@ describe('Redux Persist Migrations', () => { ); }); }); + + describe('#24', () => { + const invalidBackgroundStates = [ + { + state: merge({}, initialRootState, { + engine: { + backgroundState: { + NetworkController: null, + }, + }, + }), + errorMessage: + "Migration 24: Invalid network controller state: 'object'", + scenario: 'network controller state is invalid', + }, + { + state: merge({}, initialRootState, { + engine: { + backgroundState: { + NetworkController: { network: null }, + }, + }, + }), + errorMessage: "Migration 24: Invalid network state: 'object'", + scenario: 'network state is invalid', + }, + ]; + + for (const { errorMessage, scenario, state } of invalidBackgroundStates) { + it(`should capture exception if ${scenario}`, () => { + const migration = migrations[24]; + const newState = migration(cloneDeep(state)); + + expect(newState).toStrictEqual(state); + expect(mockedCaptureException).toHaveBeenCalledWith(expect.any(Error)); + expect(mockedCaptureException.mock.calls[0][0].message).toBe( + errorMessage, + ); + }); + } + + it('should migrate loading network state', () => { + const state = { + engine: { + backgroundState: merge({}, initialBackgroundState, { + NetworkController: { + network: 'loading', + }, + }), + }, + }; + + const migration = migrations[24]; + const newState = migration(state); + + expect(newState.engine.backgroundState.NetworkController).toStrictEqual({ + networkConfigurations: {}, + networkDetails: { + isEIP1559Compatible: false, + }, + networkId: null, + networkStatus: 'unknown', + providerConfig: { + chainId: '1', + type: 'mainnet', + }, + }); + }); + + it('should migrate non-loading network state', () => { + const state = { + engine: { + backgroundState: merge({}, initialBackgroundState, { + NetworkController: { + network: '1', + }, + }), + }, + }; + + const migration = migrations[24]; + const newState = migration(state); + + expect(newState.engine.backgroundState.NetworkController).toStrictEqual({ + networkConfigurations: {}, + networkDetails: { + isEIP1559Compatible: false, + }, + networkId: '1', + networkStatus: 'available', + providerConfig: { + chainId: '1', + type: 'mainnet', + }, + }); + }); + }); }); diff --git a/app/util/networks/handleNetworkSwitch.test.ts b/app/util/networks/handleNetworkSwitch.test.ts index 6cf29deca33..15ad2f0515e 100644 --- a/app/util/networks/handleNetworkSwitch.test.ts +++ b/app/util/networks/handleNetworkSwitch.test.ts @@ -31,7 +31,6 @@ function setupGetStateMock() { engine: { backgroundState: { NetworkController: { - network: 'loading', isCustomNetwork: false, networkConfigurations: { networkId1: { diff --git a/app/util/test/initial-background-state.json b/app/util/test/initial-background-state.json index 50fe7ab679f..ebbcec2c3ea 100644 --- a/app/util/test/initial-background-state.json +++ b/app/util/test/initial-background-state.json @@ -54,8 +54,6 @@ "usdConversionRate": null }, "NetworkController": { - "network": "loading", - "isCustomNetwork": false, "networkConfigurations": {}, "providerConfig": { "type": "mainnet", @@ -63,7 +61,9 @@ }, "networkDetails": { "isEIP1559Compatible": false - } + }, + "networkId": null, + "networkStatus": "unknown" }, "PhishingController": { "listState": { diff --git a/package.json b/package.json index 5199c9b7b83..2c2620469a2 100644 --- a/package.json +++ b/package.json @@ -162,7 +162,7 @@ "@keystonehq/ur-decoder": "^0.6.1", "@metamask/address-book-controller": "^2.0.0", "@metamask/approval-controller": "^3.4.0", - "@metamask/assets-controllers": "^6.0.0", + "@metamask/assets-controllers": "^7.0.0", "@metamask/base-controller": "^2.0.0", "@metamask/composable-controller": "^2.0.0", "@metamask/contract-metadata": "^2.1.0", @@ -170,10 +170,10 @@ "@metamask/design-tokens": "^1.12.0", "@metamask/eth-sig-util": "^4.0.1", "@metamask/etherscan-link": "^2.0.0", - "@metamask/gas-fee-controller": "^4.0.0", + "@metamask/gas-fee-controller": "^5.0.0", "@metamask/keyring-controller": "^1.0.1", "@metamask/logging-controller": "^1.0.1", - "@metamask/network-controller": "^7.0.0", + "@metamask/network-controller": "^8.0.0", "@metamask/permission-controller": "^4.0.1", "@metamask/phishing-controller": "^3.0.0", "@metamask/ppom-validator": "^0.5.0", @@ -182,7 +182,7 @@ "@metamask/signature-controller": "4.0.1", "@metamask/swappable-obj-proxy": "^2.1.0", "@metamask/swaps-controller": "^6.8.0", - "@metamask/transaction-controller": "^4.0.1", + "@metamask/transaction-controller": "^5.0.0", "@metamask/utils": "^5.0.2", "@ngraveio/bc-ur": "^1.1.6", "@react-native-async-storage/async-storage": "1.17.10", diff --git a/patches/@metamask+assets-controllers+6.0.0.patch b/patches/@metamask+assets-controllers+7.0.0.patch similarity index 100% rename from patches/@metamask+assets-controllers+6.0.0.patch rename to patches/@metamask+assets-controllers+7.0.0.patch diff --git a/patches/@metamask+network-controller+7.0.0.patch b/patches/@metamask+network-controller+7.0.0.patch deleted file mode 100644 index 8d7f93a7147..00000000000 --- a/patches/@metamask+network-controller+7.0.0.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/node_modules/@metamask/network-controller/dist/NetworkController.js b/node_modules/@metamask/network-controller/dist/NetworkController.js -index d56e4f3..7fe27c8 100644 ---- a/node_modules/@metamask/network-controller/dist/NetworkController.js -+++ b/node_modules/@metamask/network-controller/dist/NetworkController.js -@@ -103,6 +103,8 @@ class NetworkController extends base_controller_1.BaseControllerV2 { - case controller_utils_1.NetworkType.mainnet: - case controller_utils_1.NetworkType.goerli: - case controller_utils_1.NetworkType.sepolia: -+ case controller_utils_1.NetworkType["linea-goerli"]: -+ case controller_utils_1.NetworkType["linea-mainnet"]: - this.setupInfuraProvider(type); - break; - case controller_utils_1.NetworkType.localhost: -@@ -158,6 +160,8 @@ class NetworkController extends base_controller_1.BaseControllerV2 { - return (chainId !== controller_utils_1.NetworksChainId.mainnet && - chainId !== controller_utils_1.NetworksChainId.goerli && - chainId !== controller_utils_1.NetworksChainId.sepolia && -+ chainId !== controller_utils_1.NetworksChainId["linea-goerli"] && -+ chainId !== controller_utils_1.NetworksChainId["linea-mainnet"] && - chainId !== controller_utils_1.NetworksChainId.localhost); - } - setupStandardProvider(rpcTarget, chainId, ticker, nickname) { -@@ -313,8 +317,8 @@ class NetworkController extends base_controller_1.BaseControllerV2 { - */ - upsertNetworkConfiguration({ rpcUrl, chainId, ticker, nickname, rpcPrefs }, { setActive = false, referrer, source, }) { - var _a; -- (0, utils_1.assertIsStrictHexString)(chainId); -- if (!(0, controller_utils_1.isSafeChainId)(parseInt(chainId, 16))) { -+ // Remove chain ID Hex validation (chain ID is still a decimal string for now) -+ if (!(0, controller_utils_1.isSafeChainId)(parseInt(chainId, 10))) { - throw new Error(`Invalid chain ID "${chainId}": numerical value greater than max safe value.`); - } - if (!rpcUrl) { diff --git a/patches/@metamask+network-controller+8.0.0.patch b/patches/@metamask+network-controller+8.0.0.patch new file mode 100644 index 00000000000..fa0ae48e1d2 --- /dev/null +++ b/patches/@metamask+network-controller+8.0.0.patch @@ -0,0 +1,24 @@ +diff --git a/node_modules/@metamask/network-controller/dist/NetworkController.js b/node_modules/@metamask/network-controller/dist/NetworkController.js +index 0243801..7334aa5 100644 +--- a/node_modules/@metamask/network-controller/dist/NetworkController.js ++++ b/node_modules/@metamask/network-controller/dist/NetworkController.js +@@ -276,8 +276,8 @@ class NetworkController extends base_controller_1.BaseControllerV2 { + upsertNetworkConfiguration({ rpcUrl, chainId, ticker, nickname, rpcPrefs }, { setActive = false, referrer, source, }) { + var _a; + return __awaiter(this, void 0, void 0, function* () { +- (0, utils_1.assertIsStrictHexString)(chainId); +- if (!(0, controller_utils_1.isSafeChainId)(parseInt(chainId, 16))) { ++ // Remove chain ID Hex validation (chain ID is still a decimal string for now) ++ if (!(0, controller_utils_1.isSafeChainId)(parseInt(chainId, 10))) { + throw new Error(`Invalid chain ID "${chainId}": numerical value greater than max safe value.`); + } + if (!rpcUrl) { +@@ -365,6 +365,8 @@ _NetworkController_ethQuery = new WeakMap(), _NetworkController_infuraProjectId + case controller_utils_1.NetworkType.mainnet: + case controller_utils_1.NetworkType.goerli: + case controller_utils_1.NetworkType.sepolia: ++ case controller_utils_1.NetworkType["linea-goerli"]: ++ case controller_utils_1.NetworkType["linea-mainnet"]: + __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_setupInfuraProvider).call(this, type); + break; + case controller_utils_1.NetworkType.localhost: diff --git a/patches/@metamask+transaction-controller+4.0.1.patch b/patches/@metamask+transaction-controller+5.0.0.patch similarity index 61% rename from patches/@metamask+transaction-controller+4.0.1.patch rename to patches/@metamask+transaction-controller+5.0.0.patch index ad2c3fa8fb5..dd0bed45d64 100644 --- a/patches/@metamask+transaction-controller+4.0.1.patch +++ b/patches/@metamask+transaction-controller+5.0.0.patch @@ -4,19 +4,19 @@ index 0000000..550de56 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/.patch.txt @@ -0,0 +1,7 @@ -+PATCH GENERATED FROM MetaMask/core branch: refactor/transaction-controller-patch-mobile ++PATCH GENERATED FROM MetaMask/core branch: refactor/transaction-controller-patch-mobile-5 +This patch backports various transaction controller features from the main branch of MetaMask/core +Steps to update patch: -+* Create a new core branch from: refactor/transaction-controller-patch-mobile ++* Create a new core branch from: refactor/transaction-controller-patch-mobile-5 +* Run "yarn build" in the core monorepo +* Run "yarn patch:tx " in the mobile repo -+* Once the new patch is merged, add your changes to: refactor/transaction-controller-patch-mobile ++* Once the new patch is merged, add your changes to: refactor/transaction-controller-patch-mobile-5 diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts new file mode 100644 -index 0000000..a2d484f +index 0000000..7637754 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts -@@ -0,0 +1,13 @@ +@@ -0,0 +1,14 @@ +import type { RemoteTransactionSource, RemoteTransactionSourceRequest, TransactionMeta } from './types'; +/** + * A RemoteTransactionSource that fetches transaction data from Etherscan. @@ -30,6 +30,8 @@ index 0000000..a2d484f + isSupportedNetwork(chainId: string, _networkId: string): boolean; + fetchTransactions(request: RemoteTransactionSourceRequest): Promise; +} ++//# sourceMappingURL=EtherscanRemoteTransactionSource.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js new file mode 100644 index 0000000..ef97d13 @@ -139,20 +141,19 @@ index 0000000..ef97d13 \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts new file mode 100644 -index 0000000..8cf6c64 +index 0000000..5e1b7fc --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts @@ -0,0 +1,23 @@ +/// +import EventEmitter from 'events'; -+import type { NetworkState } from '@metamask/network-controller'; -+import { PollingBlockTracker as BlockTracker } from 'eth-block-tracker'; ++import type { BlockTrackerProxy, NetworkState } from '@metamask/network-controller'; +import type { RemoteTransactionSource, TransactionMeta } from './types'; +export declare class IncomingTransactionHelper { + #private; + hub: EventEmitter; + constructor({ blockTracker, getCurrentAccount, getLastFetchedBlockNumbers, getLocalTransactions, getNetworkState, isEnabled, remoteTransactionSource, transactionLimit, updateTransactions, }: { -+ blockTracker: BlockTracker; ++ blockTracker: BlockTrackerProxy; + getCurrentAccount: () => string; + getNetworkState: () => NetworkState; + getLastFetchedBlockNumbers: () => Record; @@ -166,9 +167,11 @@ index 0000000..8cf6c64 + stop(): void; + update(latestBlockNumberHex?: string): Promise; +} ++//# sourceMappingURL=IncomingTransactionHelper.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js new file mode 100644 -index 0000000..797b372 +index 0000000..8da9369 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js @@ -0,0 +1,189 @@ @@ -358,29 +361,27 @@ index 0000000..797b372 + const chainIdDecimalString = __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).providerConfig.chainId; + return `0x${parseInt(chainIdDecimalString, 10).toString(16)}`; +}, _IncomingTransactionHelper_getCurrentNetworkId = function _IncomingTransactionHelper_getCurrentNetworkId() { -+ return __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).network; ++ return __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).networkId; +}; +//# sourceMappingURL=IncomingTransactionHelper.js.map \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts -index 56005aa..5475a63 100644 +index e242aed..d315c6c 100644 --- a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts +++ b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts -@@ -2,8 +2,12 @@ +@@ -2,8 +2,10 @@ import { EventEmitter } from 'events'; import Common from '@ethereumjs/common'; import { TypedTransaction } from '@ethereumjs/tx'; -import { BaseController, BaseConfig, BaseState } from '@metamask/base-controller'; +import { BaseController, BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller'; - import type { NetworkState, ProviderProxy } from '@metamask/network-controller'; + import type { NetworkState, ProviderProxy, BlockTrackerProxy } from '@metamask/network-controller'; +import { AddApprovalRequest } from '@metamask/approval-controller'; -+import { PollingBlockTracker as BlockTracker } from 'eth-block-tracker'; -+import type { SwappableProxy } from '@metamask/swappable-obj-proxy'; +import { Transaction, TransactionMeta, WalletDevice } from './types'; /** * @type Result * @property result - Promise resolving to a new transaction hash -@@ -13,44 +17,6 @@ export interface Result { +@@ -13,44 +15,6 @@ export interface Result { result: Promise; transactionMeta: TransactionMeta; } @@ -425,7 +426,7 @@ index 56005aa..5475a63 100644 export interface GasPriceValue { gasPrice: string; } -@@ -58,115 +24,6 @@ export interface FeeMarketEIP1559Values { +@@ -58,115 +22,6 @@ export interface FeeMarketEIP1559Values { maxFeePerGas: string; maxPriorityFeePerGas: string; } @@ -541,7 +542,7 @@ index 56005aa..5475a63 100644 /** * @type TransactionConfig * -@@ -203,7 +60,23 @@ export interface TransactionState extends BaseState { +@@ -203,7 +58,22 @@ export interface TransactionState extends BaseState { methodData: { [key: string]: MethodData; }; @@ -561,17 +562,15 @@ index 56005aa..5475a63 100644 + * The messenger of the {@link TransactionController}. + */ +export declare type TransactionControllerMessenger = RestrictedControllerMessenger; -+export declare type BlockTrackerProxy = SwappableProxy; /** * Multiplier used to determine a transaction's increased gas fee during cancellation */ -@@ -221,19 +94,11 @@ export declare class TransactionController extends BaseController NetworkState; -- onNetworkStateChange: (listener: (state: NetworkState) => void) => void; - getProvider: () => ProviderProxy; + getSelectedAddress: () => string; + incomingTransactions: { + apiKey?: string; @@ -617,11 +618,13 @@ index 56005aa..5475a63 100644 + updateTransactions?: boolean; + }; + messenger: TransactionControllerMessenger; -+ onNetworkStateChange: (listener: (state: NetworkState) => void) => void; + onNetworkStateChange: (listener: (state: NetworkState) => void) => void; + provider: ProviderProxy; +- blockTracker: BlockTrackerProxy; }, config?: Partial, state?: Partial); /** * Starts a new polling interval. -@@ -280,11 +159,20 @@ export declare class TransactionController extends BaseController:unapproved` hub event will be emitted once added. * * @param transaction - The transaction object to add. @@ -645,7 +648,7 @@ index 56005aa..5475a63 100644 prepareUnsignedEthTx(txParams: Record): TypedTransaction; /** * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for -@@ -296,22 +184,6 @@ export declare class TransactionController extends BaseController:finished` hub event. -@@ -360,16 +232,6 @@ export declare class TransactionController extends BaseController { @@ -870,21 +883,28 @@ index 318d61e..41508e0 100644 /** * EventEmitter instance used to listen to specific transactional events */ -@@ -119,21 +81,41 @@ class TransactionController extends base_controller_1.BaseController { +@@ -121,18 +82,36 @@ class TransactionController extends base_controller_1.BaseController { this.defaultState = { methodData: {}, transactions: [], + lastFetchedBlockNumbers: {}, }; this.initialize(); - const provider = getProvider(); + this.provider = provider; this.getNetworkState = getNetworkState; this.ethQuery = new eth_query_1.default(provider); this.registry = new eth_method_registry_1.default({ provider }); + this.messagingSystem = messenger; -+ this.blockTracker = (0, swappable_obj_proxy_1.createEventEmitterProxy)(new eth_block_tracker_1.PollingBlockTracker({ provider })); + this.nonceTracker = new nonce_tracker_1.default({ + provider, + blockTracker, +- getPendingTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, TransactionStatus.submitted, this.state.transactions), +- getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, TransactionStatus.confirmed, this.state.transactions), ++ getPendingTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.submitted, this.state.transactions), ++ getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.confirmed, this.state.transactions), ++ }); + this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({ -+ blockTracker: this.blockTracker, ++ blockTracker, + getCurrentAccount: getSelectedAddress, + getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers, + getLocalTransactions: () => this.state.transactions, @@ -896,15 +916,13 @@ index 318d61e..41508e0 100644 + }), + transactionLimit: this.config.txHistoryLimit, + updateTransactions: incomingTransactions.updateTransactions, -+ }); + }); + this.incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this)); + this.incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this)); onNetworkStateChange(() => { - const newProvider = getProvider(); - this.ethQuery = new eth_query_1.default(newProvider); - this.registry = new eth_method_registry_1.default({ provider: newProvider }); -+ this.blockTracker.setTarget(new eth_block_tracker_1.PollingBlockTracker({ provider: newProvider })); - }); + this.ethQuery = new eth_query_1.default(this.provider); + this.registry = new eth_method_registry_1.default({ provider: this.provider }); +@@ -140,7 +119,7 @@ class TransactionController extends base_controller_1.BaseController { this.poll(); } failTransaction(transactionMeta, error) { @@ -913,7 +931,7 @@ index 318d61e..41508e0 100644 this.updateTransaction(newTransactionMeta); this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta); } -@@ -144,43 +126,6 @@ class TransactionController extends base_controller_1.BaseController { +@@ -151,43 +130,6 @@ class TransactionController extends base_controller_1.BaseController { return { registryMethod, parsedRegistryMethod }; }); } @@ -957,7 +975,7 @@ index 318d61e..41508e0 100644 /** * Starts a new polling interval. * -@@ -228,11 +173,13 @@ class TransactionController extends base_controller_1.BaseController { +@@ -235,11 +177,13 @@ class TransactionController extends base_controller_1.BaseController { * if not provided. If A `:unapproved` hub event will be emitted once added. * * @param transaction - The transaction object to add. @@ -972,10 +990,10 @@ index 318d61e..41508e0 100644 - addTransaction(transaction, origin, deviceConfirmedOn) { + addTransaction(transaction, { deviceConfirmedOn, origin, securityAlertResponse, } = {}) { return __awaiter(this, void 0, void 0, function* () { - const { providerConfig, network } = this.getNetworkState(); + const { providerConfig, networkId } = this.getNetworkState(); const { transactions } = this.state; -@@ -243,11 +190,12 @@ class TransactionController extends base_controller_1.BaseController { - networkID: network, +@@ -250,11 +194,12 @@ class TransactionController extends base_controller_1.BaseController { + networkID: networkId !== null && networkId !== void 0 ? networkId : undefined, chainId: providerConfig.chainId, origin, - status: TransactionStatus.unapproved, @@ -988,7 +1006,7 @@ index 318d61e..41508e0 100644 }; try { const { gas, estimateGasError } = yield this.estimateGas(transaction); -@@ -258,27 +206,24 @@ class TransactionController extends base_controller_1.BaseController { +@@ -265,27 +210,24 @@ class TransactionController extends base_controller_1.BaseController { this.failTransaction(transactionMeta, error); return Promise.reject(error); } @@ -1031,10 +1049,10 @@ index 318d61e..41508e0 100644 }); } prepareUnsignedEthTx(txParams) { -@@ -298,7 +243,9 @@ class TransactionController extends base_controller_1.BaseController { +@@ -305,7 +247,9 @@ class TransactionController extends base_controller_1.BaseController { */ getCommonConfiguration() { - const { network: networkId, providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState(); + const { networkId, providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState(); - if (chain !== controller_utils_1.RPC) { + if (chain !== controller_utils_1.RPC && + chain !== 'linea-goerli' && @@ -1042,7 +1060,7 @@ index 318d61e..41508e0 100644 return new common_1.default({ chain, hardfork: HARDFORK }); } const customChainParams = { -@@ -308,91 +255,6 @@ class TransactionController extends base_controller_1.BaseController { +@@ -315,100 +259,6 @@ class TransactionController extends base_controller_1.BaseController { }; return common_1.default.forCustomChain(controller_utils_1.NetworkType.mainnet, customChainParams, HARDFORK); } @@ -1062,9 +1080,9 @@ index 318d61e..41508e0 100644 - const { chainId: currentChainId } = providerConfig; - const index = transactions.findIndex(({ id }) => transactionID === id); - const transactionMeta = transactions[index]; -- const { nonce } = transactionMeta.transaction; +- const { transaction: { nonce, from }, } = transactionMeta; +- let nonceLock; - try { -- const { from } = transactionMeta.transaction; - if (!this.sign) { - releaseLock(); - this.failTransaction(transactionMeta, new Error('No sign method defined.')); @@ -1077,12 +1095,17 @@ index 318d61e..41508e0 100644 - } - const chainId = parseInt(currentChainId, undefined); - const { approved: status } = TransactionStatus; -- const txNonce = nonce || -- (yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionCount', [from, 'pending'])); +- let nonceToUse = nonce; +- // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction +- // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce +- if (!nonceToUse) { +- nonceLock = yield this.nonceTracker.getNonceLock(from); +- nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16)); +- } - transactionMeta.status = status; -- transactionMeta.transaction.nonce = txNonce; +- transactionMeta.transaction.nonce = nonceToUse; - transactionMeta.transaction.chainId = chainId; -- const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas, chainId, nonce: txNonce, status }); +- const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas }); - const isEIP1559 = (0, utils_1.isEIP1559Transaction)(transactionMeta.transaction); - const txParams = isEIP1559 - ? Object.assign(Object.assign({}, baseTxParams), { maxFeePerGas: transactionMeta.transaction.maxFeePerGas, maxPriorityFeePerGas: transactionMeta.transaction.maxPriorityFeePerGas, estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee, @@ -1111,6 +1134,10 @@ index 318d61e..41508e0 100644 - this.failTransaction(transactionMeta, error); - } - finally { +- // must set transaction to submitted/failed before releasing lock +- if (nonceLock) { +- nonceLock.releaseLock(); +- } - releaseLock(); - } - }); @@ -1134,7 +1161,7 @@ index 318d61e..41508e0 100644 /** * Attempts to cancel a transaction based on its ID by setting its status to "rejected" * and emitting a `:finished` hub event. -@@ -456,7 +318,7 @@ class TransactionController extends base_controller_1.BaseController { +@@ -472,7 +322,7 @@ class TransactionController extends base_controller_1.BaseController { const signedTx = yield this.sign(unsignedEthTx, transactionMeta.transaction.from); const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]); @@ -1143,7 +1170,7 @@ index 318d61e..41508e0 100644 this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); }); } -@@ -656,69 +518,6 @@ class TransactionController extends base_controller_1.BaseController { +@@ -673,70 +523,6 @@ class TransactionController extends base_controller_1.BaseController { transactions: this.trimTransactionsForState(newTransactions), }); } @@ -1158,12 +1185,13 @@ index 318d61e..41508e0 100644 - */ - fetchAll(address, opt) { - return __awaiter(this, void 0, void 0, function* () { -- const { providerConfig, network: currentNetworkID } = this.getNetworkState(); +- const { providerConfig, networkId: currentNetworkID } = this.getNetworkState(); - const { chainId: currentChainId, type: networkType } = providerConfig; - const { transactions } = this.state; - const supportedNetworkIds = ['1', '5', '11155111']; - /* istanbul ignore next */ -- if (supportedNetworkIds.indexOf(currentNetworkID) === -1) { +- if (currentNetworkID === null || +- supportedNetworkIds.indexOf(currentNetworkID) === -1) { - return undefined; - } - const [etherscanTxResponse, etherscanTokenResponse] = yield (0, utils_1.handleTransactionFetch)(networkType, address, this.config.txHistoryLimit, opt); @@ -1213,7 +1241,7 @@ index 318d61e..41508e0 100644 /** * Trim the amount of transactions that are set on the state. Checks * if the length of the tx history is longer then desired persistence -@@ -735,7 +534,9 @@ class TransactionController extends base_controller_1.BaseController { +@@ -753,7 +539,9 @@ class TransactionController extends base_controller_1.BaseController { */ trimTransactionsForState(transactions) { const nonceNetworkSet = new Set(); @@ -1224,7 +1252,7 @@ index 318d61e..41508e0 100644 const { chainId, networkID, status, transaction, time } = tx; if (transaction) { const key = `${transaction.nonce}-${chainId !== null && chainId !== void 0 ? chainId : networkID}-${new Date(time).toDateString()}`; -@@ -750,7 +551,7 @@ class TransactionController extends base_controller_1.BaseController { +@@ -768,7 +556,7 @@ class TransactionController extends base_controller_1.BaseController { } return false; }); @@ -1233,7 +1261,7 @@ index 318d61e..41508e0 100644 return txsToKeep; } /** -@@ -760,10 +561,10 @@ class TransactionController extends base_controller_1.BaseController { +@@ -778,10 +566,10 @@ class TransactionController extends base_controller_1.BaseController { * @returns Whether the transaction is in a final state. */ isFinalState(status) { @@ -1248,7 +1276,7 @@ index 318d61e..41508e0 100644 } /** * Method to verify the state of a transaction using the Blockchain as a source of truth. -@@ -775,7 +576,7 @@ class TransactionController extends base_controller_1.BaseController { +@@ -793,7 +581,7 @@ class TransactionController extends base_controller_1.BaseController { return __awaiter(this, void 0, void 0, function* () { const { status, transactionHash } = meta; switch (status) { @@ -1257,7 +1285,7 @@ index 318d61e..41508e0 100644 const txReceipt = yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionReceipt', [ transactionHash, ]); -@@ -792,7 +593,7 @@ class TransactionController extends base_controller_1.BaseController { +@@ -810,7 +598,7 @@ class TransactionController extends base_controller_1.BaseController { return [meta, false]; } return [meta, true]; @@ -1266,7 +1294,7 @@ index 318d61e..41508e0 100644 const txObj = yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionByHash', [ transactionHash, ]); -@@ -807,7 +608,7 @@ class TransactionController extends base_controller_1.BaseController { +@@ -825,7 +613,7 @@ class TransactionController extends base_controller_1.BaseController { } /* istanbul ignore next */ if (txObj === null || txObj === void 0 ? void 0 : txObj.blockNumber) { @@ -1275,7 +1303,7 @@ index 318d61e..41508e0 100644 this.hub.emit(`${meta.id}:confirmed`, meta); return [meta, true]; } -@@ -838,88 +639,196 @@ class TransactionController extends base_controller_1.BaseController { +@@ -856,88 +644,205 @@ class TransactionController extends base_controller_1.BaseController { return Number(txReceipt.status) === 0; }); } @@ -1396,9 +1424,9 @@ index 318d61e..41508e0 100644 + const { chainId: currentChainId } = providerConfig; + const index = transactions.findIndex(({ id }) => transactionID === id); + const transactionMeta = transactions[index]; -+ const { nonce } = transactionMeta.transaction; ++ const { transaction: { nonce, from }, } = transactionMeta; ++ let nonceLock; + try { -+ const { from } = transactionMeta.transaction; + if (!this.sign) { + releaseLock(); + this.failTransaction(transactionMeta, new Error('No sign method defined.')); @@ -1411,12 +1439,17 @@ index 318d61e..41508e0 100644 + } + const chainId = parseInt(currentChainId, undefined); + const { approved: status } = types_1.TransactionStatus; -+ const txNonce = nonce || -+ (yield (0, controller_utils_1.query)(this.ethQuery, 'getTransactionCount', [from, 'pending'])); ++ let nonceToUse = nonce; ++ // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction ++ // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce ++ if (!nonceToUse) { ++ nonceLock = yield this.nonceTracker.getNonceLock(from); ++ nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16)); ++ } + transactionMeta.status = status; -+ transactionMeta.transaction.nonce = txNonce; ++ transactionMeta.transaction.nonce = nonceToUse; + transactionMeta.transaction.chainId = chainId; -+ const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas, chainId, nonce: txNonce, status }); ++ const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas }); + const isEIP1559 = (0, utils_1.isEIP1559Transaction)(transactionMeta.transaction); + const txParams = isEIP1559 + ? Object.assign(Object.assign({}, baseTxParams), { maxFeePerGas: transactionMeta.transaction.maxFeePerGas, maxPriorityFeePerGas: transactionMeta.transaction.maxPriorityFeePerGas, estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee, @@ -1445,6 +1478,10 @@ index 318d61e..41508e0 100644 + this.failTransaction(transactionMeta, error); + } + finally { ++ // must set transaction to submitted/failed before releasing lock ++ if (nonceLock) { ++ nonceLock.releaseLock(); ++ } + releaseLock(); + } }); @@ -1539,18 +1576,18 @@ index 318d61e..41508e0 100644 exports.TransactionController = TransactionController; diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map b/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map deleted file mode 100644 -index cf2bb49..0000000 +index e834efc..0000000 --- a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map +++ /dev/null @@ -1 +0,0 @@ --{"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAsC;AACtC,qDAAgE;AAChE,mDAA2C;AAC3C,8EAAiD;AACjD,0DAAiC;AACjC,gEAAwC;AACxC,uCAAsE;AACtE,+BAAoC;AACpC,6CAAoC;AACpC,+DAImC;AAEnC,iEASoC;AACpC,mCAWiB;AAEjB,MAAM,QAAQ,GAAG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;IACK,iBAAiB,CACvB,aAAiC,EACjC,YAAgC;QAEhC,OAAO,aAAa,KAAK,YAAY,CAAC;IACxC,CAAC;CACF;AAtsCD,sDAssCC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["import { EventEmitter } from 'events';\nimport { addHexPrefix, bufferToHex, BN } from 'ethereumjs-util';\nimport { ethErrors } from 'eth-rpc-errors';\nimport MethodRegistry from 'eth-method-registry';\nimport EthQuery from 'eth-query';\nimport Common from '@ethereumjs/common';\nimport { TransactionFactory, TypedTransaction } from '@ethereumjs/tx';\nimport { v1 as random } from 'uuid';\nimport { Mutex } from 'async-mutex';\nimport {\n BaseController,\n BaseConfig,\n BaseState,\n} from '@metamask/base-controller';\nimport type { NetworkState, ProviderProxy } from '@metamask/network-controller';\nimport {\n BNToHex,\n fractionBN,\n hexToBN,\n safelyExecute,\n isSmartContractCode,\n query,\n NetworkType,\n RPC,\n} from '@metamask/controller-utils';\nimport {\n normalizeTransaction,\n validateTransaction,\n handleTransactionFetch,\n getIncreasedPriceFromExisting,\n isEIP1559Transaction,\n isGasPriceValue,\n isFeeMarketEIP1559Values,\n validateGasValues,\n validateMinimumIncrease,\n ESTIMATE_GAS_ERROR,\n} from './utils';\n\nconst HARDFORK = 'london';\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\nexport interface Result {\n result: Promise;\n transactionMeta: TransactionMeta;\n}\n\n/**\n * @type Fetch All Options\n * @property fromBlock - String containing a specific block decimal number\n * @property etherscanApiKey - API key to be used to fetch token transactions\n */\nexport interface FetchAllOptions {\n fromBlock?: string;\n etherscanApiKey?: string;\n}\n\n/**\n * @type Transaction\n *\n * Transaction representation\n * @property chainId - Network ID as per EIP-155\n * @property data - Data to pass with this transaction\n * @property from - Address to send this transaction from\n * @property gas - Gas to send with this transaction\n * @property gasPrice - Price of gas with this transaction\n * @property gasUsed - Gas used in the transaction\n * @property nonce - Unique number to prevent replay attacks\n * @property to - Address to send this transaction to\n * @property value - Value associated with this transaction\n */\nexport interface Transaction {\n chainId?: number;\n data?: string;\n from: string;\n gas?: string;\n gasPrice?: string;\n gasUsed?: string;\n nonce?: string;\n to?: string;\n value?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n estimatedBaseFee?: string;\n estimateGasError?: string;\n}\n\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\ntype TransactionMetaBase = {\n isTransfer?: boolean;\n transferInformation?: {\n symbol: string;\n contractAddress: string;\n decimals: number;\n };\n id: string;\n networkID?: string;\n chainId?: string;\n origin?: string;\n rawTransaction?: string;\n time: number;\n toSmartContract?: boolean;\n transaction: Transaction;\n transactionHash?: string;\n blockNumber?: string;\n deviceConfirmedOn?: WalletDevice;\n verifiedOnBlockchain?: boolean;\n};\n\n/**\n * @type TransactionMeta\n *\n * TransactionMeta representation\n * @property error - Synthesized error information for failed transactions\n * @property id - Generated UUID associated with this transaction\n * @property networkID - Network code as per EIP-155 for this transaction\n * @property origin - Origin this transaction was sent from\n * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed\n * @property rawTransaction - Hex representation of the underlying transaction\n * @property status - String status of this transaction\n * @property time - Timestamp associated with this transaction\n * @property toSmartContract - Whether transaction recipient is a smart contract\n * @property transaction - Underlying Transaction object\n * @property transactionHash - Hash of a successful transaction\n * @property blockNumber - Number of the block where the transaction has been included\n */\nexport type TransactionMeta =\n | ({\n status: Exclude;\n } & TransactionMetaBase)\n | ({ status: TransactionStatus.failed; error: Error } & TransactionMetaBase);\n\n/**\n * @type EtherscanTransactionMeta\n *\n * EtherscanTransactionMeta representation\n * @property blockNumber - Number of the block where the transaction has been included\n * @property timeStamp - Timestamp associated with this transaction\n * @property hash - Hash of a successful transaction\n * @property nonce - Nonce of the transaction\n * @property blockHash - Hash of the block where the transaction has been included\n * @property transactionIndex - Etherscan internal index for this transaction\n * @property from - Address to send this transaction from\n * @property to - Address to send this transaction to\n * @property gas - Gas to send with this transaction\n * @property gasPrice - Price of gas with this transaction\n * @property isError - Synthesized error information for failed transactions\n * @property txreceipt_status - Receipt status for this transaction\n * @property input - input of the transaction\n * @property contractAddress - Address of the contract\n * @property cumulativeGasUsed - Amount of gas used\n * @property confirmations - Number of confirmations\n */\nexport interface EtherscanTransactionMeta {\n blockNumber: string;\n timeStamp: string;\n hash: string;\n nonce: string;\n blockHash: string;\n transactionIndex: string;\n from: string;\n to: string;\n value: string;\n gas: string;\n gasPrice: string;\n cumulativeGasUsed: string;\n gasUsed: string;\n isError: string;\n txreceipt_status: string;\n input: string;\n contractAddress: string;\n confirmations: string;\n tokenDecimal: string;\n tokenSymbol: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property interval - Polling interval used to fetch new currency rate\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\nexport interface TransactionConfig extends BaseConfig {\n interval: number;\n sign?: (transaction: Transaction, from: string) => Promise;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseController<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: any;\n\n private registry: any;\n\n private handle?: ReturnType;\n\n private mutex = new Mutex();\n\n private getNetworkState: () => NetworkState;\n\n private failTransaction(transactionMeta: TransactionMeta, error: Error) {\n const newTransactionMeta = {\n ...transactionMeta,\n error,\n status: TransactionStatus.failed,\n };\n this.updateTransaction(newTransactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * Normalizes the transaction information from etherscan\n * to be compatible with the TransactionMeta interface.\n *\n * @param txMeta - The transaction.\n * @param currentNetworkID - The current network ID.\n * @param currentChainId - The current chain ID.\n * @returns The normalized transaction.\n */\n private normalizeTx(\n txMeta: EtherscanTransactionMeta,\n currentNetworkID: string,\n currentChainId: string,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n const normalizedTransactionBase = {\n blockNumber: txMeta.blockNumber,\n id: random({ msecs: time }),\n networkID: currentNetworkID,\n chainId: currentChainId,\n time,\n transaction: {\n data: txMeta.input,\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n transactionHash: txMeta.hash,\n verifiedOnBlockchain: false,\n };\n\n /* istanbul ignore else */\n if (txMeta.isError === '0') {\n return {\n ...normalizedTransactionBase,\n status: TransactionStatus.confirmed,\n };\n }\n\n /* istanbul ignore next */\n return {\n ...normalizedTransactionBase,\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n };\n }\n\n private normalizeTokenTx = (\n txMeta: EtherscanTransactionMeta,\n currentNetworkID: string,\n currentChainId: string,\n ): TransactionMeta => {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n const {\n to,\n from,\n gas,\n gasPrice,\n gasUsed,\n hash,\n contractAddress,\n tokenDecimal,\n tokenSymbol,\n value,\n } = txMeta;\n return {\n id: random({ msecs: time }),\n isTransfer: true,\n networkID: currentNetworkID,\n chainId: currentChainId,\n status: TransactionStatus.confirmed,\n time,\n transaction: {\n chainId: 1,\n from,\n gas,\n gasPrice,\n gasUsed,\n to,\n value,\n },\n transactionHash: hash,\n transferInformation: {\n contractAddress,\n decimals: Number(tokenDecimal),\n symbol: tokenSymbol,\n },\n verifiedOnBlockchain: false,\n };\n };\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter();\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n ) => Promise;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.getProvider - Returns a provider for the current network.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n getNetworkState,\n onNetworkStateChange,\n getProvider,\n }: {\n getNetworkState: () => NetworkState;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n getProvider: () => ProviderProxy;\n },\n config?: Partial,\n state?: Partial,\n ) {\n super(config, state);\n this.defaultConfig = {\n interval: 15000,\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n };\n this.initialize();\n const provider = getProvider();\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.registry = new MethodRegistry({ provider });\n onNetworkStateChange(() => {\n const newProvider = getProvider();\n this.ethQuery = new EthQuery(newProvider);\n this.registry = new MethodRegistry({ provider: newProvider });\n });\n this.poll();\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - The polling interval used to fetch new transaction statuses.\n */\n async poll(interval?: number): Promise {\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await safelyExecute(() => this.queryTransactionStatuses());\n this.handle = setTimeout(() => {\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `:unapproved` hub event will be emitted once added.\n *\n * @param transaction - The transaction object to add.\n * @param origin - The domain origin to append to the generated TransactionMeta.\n * @param deviceConfirmedOn - An enum to indicate what device the transaction was confirmed to append to the generated TransactionMeta.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n transaction: Transaction,\n origin?: string,\n deviceConfirmedOn?: WalletDevice,\n ): Promise {\n const { providerConfig, network } = this.getNetworkState();\n const { transactions } = this.state;\n transaction = normalizeTransaction(transaction);\n validateTransaction(transaction);\n\n const transactionMeta: TransactionMeta = {\n id: random(),\n networkID: network,\n chainId: providerConfig.chainId,\n origin,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n transaction,\n deviceConfirmedOn,\n verifiedOnBlockchain: false,\n };\n\n try {\n const { gas, estimateGasError } = await this.estimateGas(transaction);\n transaction.gas = gas;\n transaction.estimateGasError = estimateGasError;\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n return Promise.reject(error);\n }\n\n const result: Promise = new Promise((resolve, reject) => {\n this.hub.once(\n `${transactionMeta.id}:finished`,\n (meta: TransactionMeta) => {\n switch (meta.status) {\n case TransactionStatus.submitted:\n return resolve(meta.transactionHash as string);\n case TransactionStatus.rejected:\n return reject(\n ethErrors.provider.userRejectedRequest(\n 'User rejected the transaction',\n ),\n );\n case TransactionStatus.cancelled:\n return reject(\n ethErrors.rpc.internal('User cancelled the transaction'),\n );\n case TransactionStatus.failed:\n return reject(ethErrors.rpc.internal(meta.error.message));\n /* istanbul ignore next */\n default:\n return reject(\n ethErrors.rpc.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n meta,\n )}`,\n ),\n );\n }\n },\n );\n });\n\n transactions.push(transactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n return { result, transactionMeta };\n }\n\n prepareUnsignedEthTx(txParams: Record): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns {Common} common configuration object\n */\n\n getCommonConfiguration(): Common {\n const {\n network: networkId,\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (chain !== RPC) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams = {\n name,\n chainId: parseInt(chainId, undefined),\n networkId: parseInt(networkId, undefined),\n };\n\n return Common.forCustomChain(\n NetworkType.mainnet,\n customChainParams,\n HARDFORK,\n );\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `:finished` hub event is fired after success or failure.\n *\n * @param transactionID - The ID of the transaction to approve.\n */\n async approveTransaction(transactionID: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const { providerConfig } = this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n const index = transactions.findIndex(({ id }) => transactionID === id);\n const transactionMeta = transactions[index];\n const { nonce } = transactionMeta.transaction;\n\n try {\n const { from } = transactionMeta.transaction;\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!currentChainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n const chainId = parseInt(currentChainId, undefined);\n const { approved: status } = TransactionStatus;\n\n const txNonce =\n nonce ||\n (await query(this.ethQuery, 'getTransactionCount', [from, 'pending']));\n\n transactionMeta.status = status;\n transactionMeta.transaction.nonce = txNonce;\n transactionMeta.transaction.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n chainId,\n nonce: txNonce,\n status,\n };\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.transaction);\n\n const txParams = isEIP1559\n ? {\n ...baseTxParams,\n maxFeePerGas: transactionMeta.transaction.maxFeePerGas,\n maxPriorityFeePerGas:\n transactionMeta.transaction.maxPriorityFeePerGas,\n estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee,\n // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set\n type: 2,\n }\n : baseTxParams;\n\n // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set\n if (isEIP1559) {\n delete txParams.gasPrice;\n }\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n const signedTx = await this.sign(unsignedEthTx, from);\n transactionMeta.status = TransactionStatus.signed;\n this.updateTransaction(transactionMeta);\n const rawTransaction = bufferToHex(signedTx.serialize());\n\n transactionMeta.rawTransaction = rawTransaction;\n this.updateTransaction(transactionMeta);\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n transactionMeta.transactionHash = transactionHash;\n transactionMeta.status = TransactionStatus.submitted;\n this.updateTransaction(transactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n */\n cancelTransaction(transactionID: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionID,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transation.\n */\n async stopTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n CANCEL_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n CANCEL_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n CANCEL_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n await query(this.ethQuery, 'sendRawTransaction', [rawTransaction]);\n transactionMeta.status = TransactionStatus.cancelled;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionID - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transation.\n */\n async speedUpTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const { transactions } = this.state;\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n SPEED_UP_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n SPEED_UP_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n SPEED_UP_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n }\n : {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n const baseTransactionMeta = {\n ...transactionMeta,\n id: random(),\n time: Date.now(),\n transactionHash,\n };\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n gasPrice: newGasPrice,\n },\n };\n transactions.push(newTransactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: Transaction) {\n const estimatedTransaction = { ...transaction };\n const {\n gas,\n gasPrice: providedGasPrice,\n to,\n value,\n data,\n } = estimatedTransaction;\n const gasPrice =\n typeof providedGasPrice === 'undefined'\n ? await query(this.ethQuery, 'gasPrice')\n : providedGasPrice;\n const { isCustomNetwork } = this.getNetworkState();\n // 1. If gas is already defined on the transaction, use it\n if (typeof gas !== 'undefined') {\n return { gas, gasPrice };\n }\n const { gasLimit } = await query(this.ethQuery, 'getBlockByNumber', [\n 'latest',\n false,\n ]);\n\n // 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.\n // If the newtwork is a custom network then bypass this check and fetch 'estimateGas'.\n /* istanbul ignore next */\n const code = to ? await query(this.ethQuery, 'getCode', [to]) : undefined;\n /* istanbul ignore next */\n if (\n !isCustomNetwork &&\n (!to || (to && !data && (!code || code === '0x')))\n ) {\n return { gas: '0x5208', gasPrice };\n }\n\n // if data, should be hex string format\n estimatedTransaction.data = !data\n ? data\n : /* istanbul ignore next */ addHexPrefix(data);\n\n // 3. If this is a contract address, safely estimate gas using RPC\n estimatedTransaction.value =\n typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;\n const gasLimitBN = hexToBN(gasLimit);\n estimatedTransaction.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n\n let gasHex;\n let estimateGasError;\n try {\n gasHex = await query(this.ethQuery, 'estimateGas', [\n estimatedTransaction,\n ]);\n } catch (error) {\n estimateGasError = ESTIMATE_GAS_ERROR;\n }\n // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a\n // a custom network then return the eth_estimateGas value.\n const gasBN = hexToBN(gasHex);\n const maxGasBN = gasLimitBN.muln(0.9);\n const paddedGasBN = gasBN.muln(1.5);\n /* istanbul ignore next */\n if (gasBN.gt(maxGasBN) || isCustomNetwork) {\n return { gas: addHexPrefix(gasHex), gasPrice, estimateGasError };\n }\n\n /* istanbul ignore next */\n if (paddedGasBN.lt(maxGasBN)) {\n return {\n gas: addHexPrefix(BNToHex(paddedGasBN)),\n gasPrice,\n estimateGasError,\n };\n }\n return { gas: addHexPrefix(BNToHex(maxGasBN)), gasPrice };\n }\n\n /**\n * Check the status of submitted transactions on the network to determine whether they have\n * been included in a block. Any that have been included in a block are marked as confirmed.\n */\n async queryTransactionStatuses() {\n const { transactions } = this.state;\n const { providerConfig, network: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n let gotUpdates = false;\n await safelyExecute(() =>\n Promise.all(\n transactions.map(async (meta, index) => {\n // Using fallback to networkID only when there is no chainId present.\n // Should be removed when networkID is completely removed.\n const txBelongsToCurrentChain =\n meta.chainId === currentChainId ||\n (!meta.chainId && meta.networkID === currentNetworkID);\n\n if (!meta.verifiedOnBlockchain && txBelongsToCurrentChain) {\n const [reconciledTx, updateRequired] =\n await this.blockchainTransactionStateReconciler(meta);\n if (updateRequired) {\n transactions[index] = reconciledTx;\n gotUpdates = updateRequired;\n }\n }\n }),\n ),\n );\n\n /* istanbul ignore else */\n if (gotUpdates) {\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n }\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n */\n updateTransaction(transactionMeta: TransactionMeta) {\n const { transactions } = this.state;\n transactionMeta.transaction = normalizeTransaction(\n transactionMeta.transaction,\n );\n validateTransaction(transactionMeta.transaction);\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n */\n wipeTransactions(ignoreNetwork?: boolean) {\n /* istanbul ignore next */\n if (ignoreNetwork) {\n this.update({ transactions: [] });\n return;\n }\n const { providerConfig, network: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n const newTransactions = this.state.transactions.filter(\n ({ networkID, chainId }) => {\n // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.\n const isCurrentNetwork =\n chainId === currentChainId ||\n (!chainId && networkID === currentNetworkID);\n return !isCurrentNetwork;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n /**\n * Get transactions from Etherscan for the given address. By default all transactions are\n * returned, but the `fromBlock` option can be given to filter just for transactions from a\n * specific block onward.\n *\n * @param address - The address to fetch the transactions for.\n * @param opt - Object containing optional data, fromBlock and Etherscan API key.\n * @returns The block number of the latest incoming transaction.\n */\n async fetchAll(\n address: string,\n opt?: FetchAllOptions,\n ): Promise {\n const { providerConfig, network: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId, type: networkType } = providerConfig;\n const { transactions } = this.state;\n\n const supportedNetworkIds = ['1', '5', '11155111'];\n /* istanbul ignore next */\n if (supportedNetworkIds.indexOf(currentNetworkID) === -1) {\n return undefined;\n }\n\n const [etherscanTxResponse, etherscanTokenResponse] =\n await handleTransactionFetch(\n networkType,\n address,\n this.config.txHistoryLimit,\n opt,\n );\n\n const normalizedTxs = etherscanTxResponse.result.map(\n (tx: EtherscanTransactionMeta) =>\n this.normalizeTx(tx, currentNetworkID, currentChainId),\n );\n const normalizedTokenTxs = etherscanTokenResponse.result.map(\n (tx: EtherscanTransactionMeta) =>\n this.normalizeTokenTx(tx, currentNetworkID, currentChainId),\n );\n\n const [updateRequired, allTxs] = this.etherscanTransactionStateReconciler(\n [...normalizedTxs, ...normalizedTokenTxs],\n transactions,\n );\n\n allTxs.sort((a, b) => (a.time < b.time ? -1 : 1));\n\n let latestIncomingTxBlockNumber: string | undefined;\n allTxs.forEach(async (tx) => {\n /* istanbul ignore next */\n if (\n // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.\n (tx.chainId === currentChainId ||\n (!tx.chainId && tx.networkID === currentNetworkID)) &&\n tx.transaction.to &&\n tx.transaction.to.toLowerCase() === address.toLowerCase()\n ) {\n if (\n tx.blockNumber &&\n (!latestIncomingTxBlockNumber ||\n parseInt(latestIncomingTxBlockNumber, 10) <\n parseInt(tx.blockNumber, 10))\n ) {\n latestIncomingTxBlockNumber = tx.blockNumber;\n }\n }\n\n /* istanbul ignore else */\n if (tx.toSmartContract === undefined) {\n // If not `to` is a contract deploy, if not `data` is send eth\n if (\n tx.transaction.to &&\n (!tx.transaction.data || tx.transaction.data !== '0x')\n ) {\n const code = await query(this.ethQuery, 'getCode', [\n tx.transaction.to,\n ]);\n tx.toSmartContract = isSmartContractCode(code);\n } else {\n tx.toSmartContract = false;\n }\n }\n });\n\n // Update state only if new transactions were fetched or\n // the status or gas data of a transaction has changed\n if (updateRequired) {\n this.update({ transactions: this.trimTransactionsForState(allTxs) });\n }\n return latestIncomingTxBlockNumber;\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseController update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n const txsToKeep = transactions.reverse().filter((tx) => {\n const { chainId, networkID, status, transaction, time } = tx;\n if (transaction) {\n const key = `${transaction.nonce}-${chainId ?? networkID}-${new Date(\n time,\n ).toDateString()}`;\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n return false;\n });\n txsToKeep.reverse();\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed ||\n status === TransactionStatus.cancelled\n );\n }\n\n /**\n * Method to verify the state of a transaction using the Blockchain as a source of truth.\n *\n * @param meta - The local transaction to verify on the blockchain.\n * @returns A tuple containing the updated transaction, and whether or not an update was required.\n */\n private async blockchainTransactionStateReconciler(\n meta: TransactionMeta,\n ): Promise<[TransactionMeta, boolean]> {\n const { status, transactionHash } = meta;\n switch (status) {\n case TransactionStatus.confirmed:\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n transactionHash,\n ]);\n\n if (!txReceipt) {\n return [meta, false];\n }\n\n meta.verifiedOnBlockchain = true;\n meta.transaction.gasUsed = txReceipt.gasUsed;\n\n // According to the Web3 docs:\n // TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n if (Number(txReceipt.status) === 0) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was reversed',\n );\n this.failTransaction(meta, error);\n return [meta, false];\n }\n\n return [meta, true];\n case TransactionStatus.submitted:\n const txObj = await query(this.ethQuery, 'getTransactionByHash', [\n transactionHash,\n ]);\n\n if (!txObj) {\n const receiptShowsFailedStatus =\n await this.checkTxReceiptStatusIsFailed(transactionHash);\n\n // Case the txObj is evaluated as false, a second check will\n // determine if the tx failed or it is pending or confirmed\n if (receiptShowsFailedStatus) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was dropped or replaced by a new one',\n );\n this.failTransaction(meta, error);\n }\n }\n\n /* istanbul ignore next */\n if (txObj?.blockNumber) {\n meta.status = TransactionStatus.confirmed;\n this.hub.emit(`${meta.id}:confirmed`, meta);\n return [meta, true];\n }\n\n return [meta, false];\n default:\n return [meta, false];\n }\n }\n\n /**\n * Method to check if a tx has failed according to their receipt\n * According to the Web3 docs:\n * TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n * The receipt is not available for pending transactions and returns null.\n *\n * @param txHash - The transaction hash.\n * @returns Whether the transaction has failed.\n */\n private async checkTxReceiptStatusIsFailed(\n txHash: string | undefined,\n ): Promise {\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n txHash,\n ]);\n if (!txReceipt) {\n // Transaction is pending\n return false;\n }\n return Number(txReceipt.status) === 0;\n }\n\n /**\n * Method to verify the state of transactions using Etherscan as a source of truth.\n *\n * @param remoteTxs - Transactions to reconcile that are from a remote source.\n * @param localTxs - Transactions to reconcile that are local.\n * @returns A tuple containing a boolean indicating whether or not an update was required, and the updated transaction.\n */\n private etherscanTransactionStateReconciler(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): [boolean, TransactionMeta[]] {\n const updatedTxs: TransactionMeta[] = this.getUpdatedTransactions(\n remoteTxs,\n localTxs,\n );\n\n const newTxs: TransactionMeta[] = this.getNewTransactions(\n remoteTxs,\n localTxs,\n );\n\n const updatedLocalTxs = localTxs.map((tx: TransactionMeta) => {\n const txIdx = updatedTxs.findIndex(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return txIdx === -1 ? tx : updatedTxs[txIdx];\n });\n\n const updateRequired = newTxs.length > 0 || updatedLocalTxs.length > 0;\n\n return [updateRequired, [...newTxs, ...updatedLocalTxs]];\n }\n\n /**\n * Get all transactions that are in the remote transactions array\n * but not in the local transactions array.\n *\n * @param remoteTxs - Array of transactions from remote source.\n * @param localTxs - Array of transactions stored locally.\n * @returns The new transactions.\n */\n private getNewTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((tx) => {\n const alreadyInTransactions = localTxs.find(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return !alreadyInTransactions;\n });\n }\n\n /**\n * Get all the transactions that are locally outdated with respect\n * to a remote source (etherscan or blockchain). The returned array\n * contains the transactions with the updated data.\n *\n * @param remoteTxs - Array of transactions from remote source.\n * @param localTxs - Array of transactions stored locally.\n * @returns The updated transactions.\n */\n private getUpdatedTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((remoteTx) => {\n const isTxOutdated = localTxs.find((localTx) => {\n return (\n remoteTx.transactionHash === localTx.transactionHash &&\n this.isTransactionOutdated(remoteTx, localTx)\n );\n });\n return isTxOutdated;\n });\n }\n\n /**\n * Verifies if a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteTx - The remote transaction from Etherscan.\n * @param localTx - The local transaction.\n * @returns Whether the transaction is outdated.\n */\n private isTransactionOutdated(\n remoteTx: TransactionMeta,\n localTx: TransactionMeta,\n ): boolean {\n const statusOutdated = this.isStatusOutdated(\n remoteTx.transactionHash,\n localTx.transactionHash,\n remoteTx.status,\n localTx.status,\n );\n const gasDataOutdated = this.isGasDataOutdated(\n remoteTx.transaction.gasUsed,\n localTx.transaction.gasUsed,\n );\n return statusOutdated || gasDataOutdated;\n }\n\n /**\n * Verifies if the status of a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteTxHash - Remote transaction hash.\n * @param localTxHash - Local transaction hash.\n * @param remoteTxStatus - Remote transaction status.\n * @param localTxStatus - Local transaction status.\n * @returns Whether the status is outdated.\n */\n private isStatusOutdated(\n remoteTxHash: string | undefined,\n localTxHash: string | undefined,\n remoteTxStatus: TransactionStatus,\n localTxStatus: TransactionStatus,\n ): boolean {\n return remoteTxHash === localTxHash && remoteTxStatus !== localTxStatus;\n }\n\n /**\n * Verifies if the gas data of a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteGasUsed - Remote gas used in the transaction.\n * @param localGasUsed - Local gas used in the transaction.\n * @returns Whether the gas data is outdated.\n */\n private isGasDataOutdated(\n remoteGasUsed: string | undefined,\n localGasUsed: string | undefined,\n ): boolean {\n return remoteGasUsed !== localGasUsed;\n }\n}\n\nexport default TransactionController;\n"]} +-{"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAsC;AACtC,qDAAgE;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AAM,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7C,OAAO,CACL,QAAQ,CAAC,eAAe,KAAK,OAAO,CAAC,eAAe;oBACpD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAC9C,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACK,qBAAqB,CAC3B,QAAyB,EACzB,OAAwB;QAExB,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAC1C,QAAQ,CAAC,eAAe,EACxB,OAAO,CAAC,eAAe,EACvB,QAAQ,CAAC,MAAM,EACf,OAAO,CAAC,MAAM,CACf,CAAC;QACF,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAC5C,QAAQ,CAAC,WAAW,CAAC,OAAO,EAC5B,OAAO,CAAC,WAAW,CAAC,OAAO,CAC5B,CAAC;QACF,OAAO,cAAc,IAAI,eAAe,CAAC;IAC3C,CAAC;IAED;;;;;;;;OAQG;IACK,gBAAgB,CACtB,YAAgC,EAChC,WAA+B,EAC/B,cAAiC,EACjC,aAAgC;QAEhC,OAAO,YAAY,KAAK,WAAW,IAAI,cAAc,KAAK,aAAa,CAAC;IAC1E,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CACvB,aAAiC,EACjC,YAAgC;QAEhC,OAAO,aAAa,KAAK,YAAY,CAAC;IACxC,CAAC;CACF;AAtuCD,sDAsuCC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["import { EventEmitter } from 'events';\nimport { addHexPrefix, bufferToHex, BN } from 'ethereumjs-util';\nimport { ethErrors } from 'eth-rpc-errors';\nimport MethodRegistry from 'eth-method-registry';\nimport EthQuery from 'eth-query';\nimport Common from '@ethereumjs/common';\nimport { TransactionFactory, TypedTransaction } from '@ethereumjs/tx';\nimport { v1 as random } from 'uuid';\nimport { Mutex } from 'async-mutex';\nimport {\n BaseController,\n BaseConfig,\n BaseState,\n} from '@metamask/base-controller';\nimport type {\n NetworkState,\n ProviderProxy,\n BlockTrackerProxy,\n} from '@metamask/network-controller';\nimport {\n BNToHex,\n fractionBN,\n hexToBN,\n safelyExecute,\n isSmartContractCode,\n query,\n NetworkType,\n RPC,\n} from '@metamask/controller-utils';\nimport NonceTracker from 'nonce-tracker';\nimport {\n getAndFormatTransactionsForNonceTracker,\n normalizeTransaction,\n validateTransaction,\n handleTransactionFetch,\n getIncreasedPriceFromExisting,\n isEIP1559Transaction,\n isGasPriceValue,\n isFeeMarketEIP1559Values,\n validateGasValues,\n validateMinimumIncrease,\n ESTIMATE_GAS_ERROR,\n} from './utils';\n\nconst HARDFORK = 'london';\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\nexport interface Result {\n result: Promise;\n transactionMeta: TransactionMeta;\n}\n\n/**\n * @type Fetch All Options\n * @property fromBlock - String containing a specific block decimal number\n * @property etherscanApiKey - API key to be used to fetch token transactions\n */\nexport interface FetchAllOptions {\n fromBlock?: string;\n etherscanApiKey?: string;\n}\n\n/**\n * @type Transaction\n *\n * Transaction representation\n * @property chainId - Network ID as per EIP-155\n * @property data - Data to pass with this transaction\n * @property from - Address to send this transaction from\n * @property gas - Gas to send with this transaction\n * @property gasPrice - Price of gas with this transaction\n * @property gasUsed - Gas used in the transaction\n * @property nonce - Unique number to prevent replay attacks\n * @property to - Address to send this transaction to\n * @property value - Value associated with this transaction\n */\nexport interface Transaction {\n chainId?: number;\n data?: string;\n from: string;\n gas?: string;\n gasPrice?: string;\n gasUsed?: string;\n nonce?: string;\n to?: string;\n value?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n estimatedBaseFee?: string;\n estimateGasError?: string;\n}\n\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\ntype TransactionMetaBase = {\n isTransfer?: boolean;\n transferInformation?: {\n symbol: string;\n contractAddress: string;\n decimals: number;\n };\n id: string;\n networkID?: string;\n chainId?: string;\n origin?: string;\n rawTransaction?: string;\n time: number;\n toSmartContract?: boolean;\n transaction: Transaction;\n transactionHash?: string;\n blockNumber?: string;\n deviceConfirmedOn?: WalletDevice;\n verifiedOnBlockchain?: boolean;\n};\n\n/**\n * @type TransactionMeta\n *\n * TransactionMeta representation\n * @property error - Synthesized error information for failed transactions\n * @property id - Generated UUID associated with this transaction\n * @property networkID - Network code as per EIP-155 for this transaction\n * @property origin - Origin this transaction was sent from\n * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed\n * @property rawTransaction - Hex representation of the underlying transaction\n * @property status - String status of this transaction\n * @property time - Timestamp associated with this transaction\n * @property toSmartContract - Whether transaction recipient is a smart contract\n * @property transaction - Underlying Transaction object\n * @property transactionHash - Hash of a successful transaction\n * @property blockNumber - Number of the block where the transaction has been included\n */\nexport type TransactionMeta =\n | ({\n status: Exclude;\n } & TransactionMetaBase)\n | ({ status: TransactionStatus.failed; error: Error } & TransactionMetaBase);\n\n/**\n * @type EtherscanTransactionMeta\n *\n * EtherscanTransactionMeta representation\n * @property blockNumber - Number of the block where the transaction has been included\n * @property timeStamp - Timestamp associated with this transaction\n * @property hash - Hash of a successful transaction\n * @property nonce - Nonce of the transaction\n * @property blockHash - Hash of the block where the transaction has been included\n * @property transactionIndex - Etherscan internal index for this transaction\n * @property from - Address to send this transaction from\n * @property to - Address to send this transaction to\n * @property gas - Gas to send with this transaction\n * @property gasPrice - Price of gas with this transaction\n * @property isError - Synthesized error information for failed transactions\n * @property txreceipt_status - Receipt status for this transaction\n * @property input - input of the transaction\n * @property contractAddress - Address of the contract\n * @property cumulativeGasUsed - Amount of gas used\n * @property confirmations - Number of confirmations\n */\nexport interface EtherscanTransactionMeta {\n blockNumber: string;\n timeStamp: string;\n hash: string;\n nonce: string;\n blockHash: string;\n transactionIndex: string;\n from: string;\n to: string;\n value: string;\n gas: string;\n gasPrice: string;\n cumulativeGasUsed: string;\n gasUsed: string;\n isError: string;\n txreceipt_status: string;\n input: string;\n contractAddress: string;\n confirmations: string;\n tokenDecimal: string;\n tokenSymbol: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property interval - Polling interval used to fetch new currency rate\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\nexport interface TransactionConfig extends BaseConfig {\n interval: number;\n sign?: (transaction: Transaction, from: string) => Promise;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseController<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: any;\n\n private nonceTracker: NonceTracker;\n\n private registry: any;\n\n private provider: ProviderProxy;\n\n private handle?: ReturnType;\n\n private mutex = new Mutex();\n\n private getNetworkState: () => NetworkState;\n\n private failTransaction(transactionMeta: TransactionMeta, error: Error) {\n const newTransactionMeta = {\n ...transactionMeta,\n error,\n status: TransactionStatus.failed,\n };\n this.updateTransaction(newTransactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * Normalizes the transaction information from etherscan\n * to be compatible with the TransactionMeta interface.\n *\n * @param txMeta - The transaction.\n * @param currentNetworkID - The current network ID.\n * @param currentChainId - The current chain ID.\n * @returns The normalized transaction.\n */\n private normalizeTx(\n txMeta: EtherscanTransactionMeta,\n currentNetworkID: string,\n currentChainId: string,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n const normalizedTransactionBase = {\n blockNumber: txMeta.blockNumber,\n id: random({ msecs: time }),\n networkID: currentNetworkID,\n chainId: currentChainId,\n time,\n transaction: {\n data: txMeta.input,\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n transactionHash: txMeta.hash,\n verifiedOnBlockchain: false,\n };\n\n /* istanbul ignore else */\n if (txMeta.isError === '0') {\n return {\n ...normalizedTransactionBase,\n status: TransactionStatus.confirmed,\n };\n }\n\n /* istanbul ignore next */\n return {\n ...normalizedTransactionBase,\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n };\n }\n\n private normalizeTokenTx = (\n txMeta: EtherscanTransactionMeta,\n currentNetworkID: string,\n currentChainId: string,\n ): TransactionMeta => {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n const {\n to,\n from,\n gas,\n gasPrice,\n gasUsed,\n hash,\n contractAddress,\n tokenDecimal,\n tokenSymbol,\n value,\n } = txMeta;\n return {\n id: random({ msecs: time }),\n isTransfer: true,\n networkID: currentNetworkID,\n chainId: currentChainId,\n status: TransactionStatus.confirmed,\n time,\n transaction: {\n chainId: 1,\n from,\n gas,\n gasPrice,\n gasUsed,\n to,\n value,\n },\n transactionHash: hash,\n transferInformation: {\n contractAddress,\n decimals: Number(tokenDecimal),\n symbol: tokenSymbol,\n },\n verifiedOnBlockchain: false,\n };\n };\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter();\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n ) => Promise;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.provider - The provider used to create the underlying EthQuery instance.\n * @param options.blockTracker - The block tracker used to poll for new blocks data.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n getNetworkState,\n onNetworkStateChange,\n provider,\n blockTracker,\n }: {\n getNetworkState: () => NetworkState;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n provider: ProviderProxy;\n blockTracker: BlockTrackerProxy;\n },\n config?: Partial,\n state?: Partial,\n ) {\n super(config, state);\n this.defaultConfig = {\n interval: 15000,\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n };\n this.initialize();\n this.provider = provider;\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.registry = new MethodRegistry({ provider });\n this.nonceTracker = new NonceTracker({\n provider,\n blockTracker,\n getPendingTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.submitted,\n this.state.transactions,\n ),\n getConfirmedTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.confirmed,\n this.state.transactions,\n ),\n });\n\n onNetworkStateChange(() => {\n this.ethQuery = new EthQuery(this.provider);\n this.registry = new MethodRegistry({ provider: this.provider });\n });\n this.poll();\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - The polling interval used to fetch new transaction statuses.\n */\n async poll(interval?: number): Promise {\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await safelyExecute(() => this.queryTransactionStatuses());\n this.handle = setTimeout(() => {\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `:unapproved` hub event will be emitted once added.\n *\n * @param transaction - The transaction object to add.\n * @param origin - The domain origin to append to the generated TransactionMeta.\n * @param deviceConfirmedOn - An enum to indicate what device the transaction was confirmed to append to the generated TransactionMeta.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n transaction: Transaction,\n origin?: string,\n deviceConfirmedOn?: WalletDevice,\n ): Promise {\n const { providerConfig, networkId } = this.getNetworkState();\n const { transactions } = this.state;\n transaction = normalizeTransaction(transaction);\n validateTransaction(transaction);\n\n const transactionMeta: TransactionMeta = {\n id: random(),\n networkID: networkId ?? undefined,\n chainId: providerConfig.chainId,\n origin,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n transaction,\n deviceConfirmedOn,\n verifiedOnBlockchain: false,\n };\n\n try {\n const { gas, estimateGasError } = await this.estimateGas(transaction);\n transaction.gas = gas;\n transaction.estimateGasError = estimateGasError;\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n return Promise.reject(error);\n }\n\n const result: Promise = new Promise((resolve, reject) => {\n this.hub.once(\n `${transactionMeta.id}:finished`,\n (meta: TransactionMeta) => {\n switch (meta.status) {\n case TransactionStatus.submitted:\n return resolve(meta.transactionHash as string);\n case TransactionStatus.rejected:\n return reject(\n ethErrors.provider.userRejectedRequest(\n 'User rejected the transaction',\n ),\n );\n case TransactionStatus.cancelled:\n return reject(\n ethErrors.rpc.internal('User cancelled the transaction'),\n );\n case TransactionStatus.failed:\n return reject(ethErrors.rpc.internal(meta.error.message));\n /* istanbul ignore next */\n default:\n return reject(\n ethErrors.rpc.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n meta,\n )}`,\n ),\n );\n }\n },\n );\n });\n\n transactions.push(transactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n return { result, transactionMeta };\n }\n\n prepareUnsignedEthTx(txParams: Record): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns {Common} common configuration object\n */\n\n getCommonConfiguration(): Common {\n const {\n networkId,\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (chain !== RPC) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams = {\n name,\n chainId: parseInt(chainId, undefined),\n networkId: networkId === null ? NaN : parseInt(networkId, undefined),\n };\n\n return Common.forCustomChain(\n NetworkType.mainnet,\n customChainParams,\n HARDFORK,\n );\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `:finished` hub event is fired after success or failure.\n *\n * @param transactionID - The ID of the transaction to approve.\n */\n async approveTransaction(transactionID: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const { providerConfig } = this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n const index = transactions.findIndex(({ id }) => transactionID === id);\n const transactionMeta = transactions[index];\n const {\n transaction: { nonce, from },\n } = transactionMeta;\n let nonceLock;\n try {\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!currentChainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n const chainId = parseInt(currentChainId, undefined);\n const { approved: status } = TransactionStatus;\n let nonceToUse = nonce;\n // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction\n // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce\n if (!nonceToUse) {\n nonceLock = await this.nonceTracker.getNonceLock(from);\n nonceToUse = addHexPrefix(nonceLock.nextNonce.toString(16));\n }\n\n transactionMeta.status = status;\n transactionMeta.transaction.nonce = nonceToUse;\n transactionMeta.transaction.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n };\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.transaction);\n\n const txParams = isEIP1559\n ? {\n ...baseTxParams,\n maxFeePerGas: transactionMeta.transaction.maxFeePerGas,\n maxPriorityFeePerGas:\n transactionMeta.transaction.maxPriorityFeePerGas,\n estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee,\n // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set\n type: 2,\n }\n : baseTxParams;\n\n // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set\n if (isEIP1559) {\n delete txParams.gasPrice;\n }\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n const signedTx = await this.sign(unsignedEthTx, from);\n transactionMeta.status = TransactionStatus.signed;\n this.updateTransaction(transactionMeta);\n const rawTransaction = bufferToHex(signedTx.serialize());\n\n transactionMeta.rawTransaction = rawTransaction;\n this.updateTransaction(transactionMeta);\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n transactionMeta.transactionHash = transactionHash;\n transactionMeta.status = TransactionStatus.submitted;\n this.updateTransaction(transactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n // must set transaction to submitted/failed before releasing lock\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n releaseLock();\n }\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n */\n cancelTransaction(transactionID: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionID,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transation.\n */\n async stopTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n CANCEL_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n CANCEL_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n CANCEL_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n await query(this.ethQuery, 'sendRawTransaction', [rawTransaction]);\n transactionMeta.status = TransactionStatus.cancelled;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionID - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transation.\n */\n async speedUpTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const { transactions } = this.state;\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n SPEED_UP_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n SPEED_UP_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n SPEED_UP_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n }\n : {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n const baseTransactionMeta = {\n ...transactionMeta,\n id: random(),\n time: Date.now(),\n transactionHash,\n };\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n gasPrice: newGasPrice,\n },\n };\n transactions.push(newTransactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: Transaction) {\n const estimatedTransaction = { ...transaction };\n const {\n gas,\n gasPrice: providedGasPrice,\n to,\n value,\n data,\n } = estimatedTransaction;\n const gasPrice =\n typeof providedGasPrice === 'undefined'\n ? await query(this.ethQuery, 'gasPrice')\n : providedGasPrice;\n const { providerConfig } = this.getNetworkState();\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n // 1. If gas is already defined on the transaction, use it\n if (typeof gas !== 'undefined') {\n return { gas, gasPrice };\n }\n const { gasLimit } = await query(this.ethQuery, 'getBlockByNumber', [\n 'latest',\n false,\n ]);\n\n // 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.\n // If the newtwork is a custom network then bypass this check and fetch 'estimateGas'.\n /* istanbul ignore next */\n const code = to ? await query(this.ethQuery, 'getCode', [to]) : undefined;\n /* istanbul ignore next */\n if (\n !isCustomNetwork &&\n (!to || (to && !data && (!code || code === '0x')))\n ) {\n return { gas: '0x5208', gasPrice };\n }\n\n // if data, should be hex string format\n estimatedTransaction.data = !data\n ? data\n : /* istanbul ignore next */ addHexPrefix(data);\n\n // 3. If this is a contract address, safely estimate gas using RPC\n estimatedTransaction.value =\n typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;\n const gasLimitBN = hexToBN(gasLimit);\n estimatedTransaction.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n\n let gasHex;\n let estimateGasError;\n try {\n gasHex = await query(this.ethQuery, 'estimateGas', [\n estimatedTransaction,\n ]);\n } catch (error) {\n estimateGasError = ESTIMATE_GAS_ERROR;\n }\n // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a\n // a custom network then return the eth_estimateGas value.\n const gasBN = hexToBN(gasHex);\n const maxGasBN = gasLimitBN.muln(0.9);\n const paddedGasBN = gasBN.muln(1.5);\n /* istanbul ignore next */\n if (gasBN.gt(maxGasBN) || isCustomNetwork) {\n return { gas: addHexPrefix(gasHex), gasPrice, estimateGasError };\n }\n\n /* istanbul ignore next */\n if (paddedGasBN.lt(maxGasBN)) {\n return {\n gas: addHexPrefix(BNToHex(paddedGasBN)),\n gasPrice,\n estimateGasError,\n };\n }\n return { gas: addHexPrefix(BNToHex(maxGasBN)), gasPrice };\n }\n\n /**\n * Check the status of submitted transactions on the network to determine whether they have\n * been included in a block. Any that have been included in a block are marked as confirmed.\n */\n async queryTransactionStatuses() {\n const { transactions } = this.state;\n const { providerConfig, networkId: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n let gotUpdates = false;\n await safelyExecute(() =>\n Promise.all(\n transactions.map(async (meta, index) => {\n // Using fallback to networkID only when there is no chainId present.\n // Should be removed when networkID is completely removed.\n const txBelongsToCurrentChain =\n meta.chainId === currentChainId ||\n (!meta.chainId && meta.networkID === currentNetworkID);\n\n if (!meta.verifiedOnBlockchain && txBelongsToCurrentChain) {\n const [reconciledTx, updateRequired] =\n await this.blockchainTransactionStateReconciler(meta);\n if (updateRequired) {\n transactions[index] = reconciledTx;\n gotUpdates = updateRequired;\n }\n }\n }),\n ),\n );\n\n /* istanbul ignore else */\n if (gotUpdates) {\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n }\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n */\n updateTransaction(transactionMeta: TransactionMeta) {\n const { transactions } = this.state;\n transactionMeta.transaction = normalizeTransaction(\n transactionMeta.transaction,\n );\n validateTransaction(transactionMeta.transaction);\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n */\n wipeTransactions(ignoreNetwork?: boolean) {\n /* istanbul ignore next */\n if (ignoreNetwork) {\n this.update({ transactions: [] });\n return;\n }\n const { providerConfig, networkId: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n const newTransactions = this.state.transactions.filter(\n ({ networkID, chainId }) => {\n // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.\n const isCurrentNetwork =\n chainId === currentChainId ||\n (!chainId && networkID === currentNetworkID);\n return !isCurrentNetwork;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n /**\n * Get transactions from Etherscan for the given address. By default all transactions are\n * returned, but the `fromBlock` option can be given to filter just for transactions from a\n * specific block onward.\n *\n * @param address - The address to fetch the transactions for.\n * @param opt - Object containing optional data, fromBlock and Etherscan API key.\n * @returns The block number of the latest incoming transaction.\n */\n async fetchAll(\n address: string,\n opt?: FetchAllOptions,\n ): Promise {\n const { providerConfig, networkId: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId, type: networkType } = providerConfig;\n const { transactions } = this.state;\n\n const supportedNetworkIds = ['1', '5', '11155111'];\n /* istanbul ignore next */\n if (\n currentNetworkID === null ||\n supportedNetworkIds.indexOf(currentNetworkID) === -1\n ) {\n return undefined;\n }\n\n const [etherscanTxResponse, etherscanTokenResponse] =\n await handleTransactionFetch(\n networkType,\n address,\n this.config.txHistoryLimit,\n opt,\n );\n\n const normalizedTxs = etherscanTxResponse.result.map(\n (tx: EtherscanTransactionMeta) =>\n this.normalizeTx(tx, currentNetworkID, currentChainId),\n );\n const normalizedTokenTxs = etherscanTokenResponse.result.map(\n (tx: EtherscanTransactionMeta) =>\n this.normalizeTokenTx(tx, currentNetworkID, currentChainId),\n );\n\n const [updateRequired, allTxs] = this.etherscanTransactionStateReconciler(\n [...normalizedTxs, ...normalizedTokenTxs],\n transactions,\n );\n\n allTxs.sort((a, b) => (a.time < b.time ? -1 : 1));\n\n let latestIncomingTxBlockNumber: string | undefined;\n allTxs.forEach(async (tx) => {\n /* istanbul ignore next */\n if (\n // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.\n (tx.chainId === currentChainId ||\n (!tx.chainId && tx.networkID === currentNetworkID)) &&\n tx.transaction.to &&\n tx.transaction.to.toLowerCase() === address.toLowerCase()\n ) {\n if (\n tx.blockNumber &&\n (!latestIncomingTxBlockNumber ||\n parseInt(latestIncomingTxBlockNumber, 10) <\n parseInt(tx.blockNumber, 10))\n ) {\n latestIncomingTxBlockNumber = tx.blockNumber;\n }\n }\n\n /* istanbul ignore else */\n if (tx.toSmartContract === undefined) {\n // If not `to` is a contract deploy, if not `data` is send eth\n if (\n tx.transaction.to &&\n (!tx.transaction.data || tx.transaction.data !== '0x')\n ) {\n const code = await query(this.ethQuery, 'getCode', [\n tx.transaction.to,\n ]);\n tx.toSmartContract = isSmartContractCode(code);\n } else {\n tx.toSmartContract = false;\n }\n }\n });\n\n // Update state only if new transactions were fetched or\n // the status or gas data of a transaction has changed\n if (updateRequired) {\n this.update({ transactions: this.trimTransactionsForState(allTxs) });\n }\n return latestIncomingTxBlockNumber;\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseController update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n const txsToKeep = transactions.reverse().filter((tx) => {\n const { chainId, networkID, status, transaction, time } = tx;\n if (transaction) {\n const key = `${transaction.nonce}-${chainId ?? networkID}-${new Date(\n time,\n ).toDateString()}`;\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n return false;\n });\n txsToKeep.reverse();\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed ||\n status === TransactionStatus.cancelled\n );\n }\n\n /**\n * Method to verify the state of a transaction using the Blockchain as a source of truth.\n *\n * @param meta - The local transaction to verify on the blockchain.\n * @returns A tuple containing the updated transaction, and whether or not an update was required.\n */\n private async blockchainTransactionStateReconciler(\n meta: TransactionMeta,\n ): Promise<[TransactionMeta, boolean]> {\n const { status, transactionHash } = meta;\n switch (status) {\n case TransactionStatus.confirmed:\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n transactionHash,\n ]);\n\n if (!txReceipt) {\n return [meta, false];\n }\n\n meta.verifiedOnBlockchain = true;\n meta.transaction.gasUsed = txReceipt.gasUsed;\n\n // According to the Web3 docs:\n // TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n if (Number(txReceipt.status) === 0) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was reversed',\n );\n this.failTransaction(meta, error);\n return [meta, false];\n }\n\n return [meta, true];\n case TransactionStatus.submitted:\n const txObj = await query(this.ethQuery, 'getTransactionByHash', [\n transactionHash,\n ]);\n\n if (!txObj) {\n const receiptShowsFailedStatus =\n await this.checkTxReceiptStatusIsFailed(transactionHash);\n\n // Case the txObj is evaluated as false, a second check will\n // determine if the tx failed or it is pending or confirmed\n if (receiptShowsFailedStatus) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was dropped or replaced by a new one',\n );\n this.failTransaction(meta, error);\n }\n }\n\n /* istanbul ignore next */\n if (txObj?.blockNumber) {\n meta.status = TransactionStatus.confirmed;\n this.hub.emit(`${meta.id}:confirmed`, meta);\n return [meta, true];\n }\n\n return [meta, false];\n default:\n return [meta, false];\n }\n }\n\n /**\n * Method to check if a tx has failed according to their receipt\n * According to the Web3 docs:\n * TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n * The receipt is not available for pending transactions and returns null.\n *\n * @param txHash - The transaction hash.\n * @returns Whether the transaction has failed.\n */\n private async checkTxReceiptStatusIsFailed(\n txHash: string | undefined,\n ): Promise {\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n txHash,\n ]);\n if (!txReceipt) {\n // Transaction is pending\n return false;\n }\n return Number(txReceipt.status) === 0;\n }\n\n /**\n * Method to verify the state of transactions using Etherscan as a source of truth.\n *\n * @param remoteTxs - Transactions to reconcile that are from a remote source.\n * @param localTxs - Transactions to reconcile that are local.\n * @returns A tuple containing a boolean indicating whether or not an update was required, and the updated transaction.\n */\n private etherscanTransactionStateReconciler(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): [boolean, TransactionMeta[]] {\n const updatedTxs: TransactionMeta[] = this.getUpdatedTransactions(\n remoteTxs,\n localTxs,\n );\n\n const newTxs: TransactionMeta[] = this.getNewTransactions(\n remoteTxs,\n localTxs,\n );\n\n const updatedLocalTxs = localTxs.map((tx: TransactionMeta) => {\n const txIdx = updatedTxs.findIndex(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return txIdx === -1 ? tx : updatedTxs[txIdx];\n });\n\n const updateRequired = newTxs.length > 0 || updatedLocalTxs.length > 0;\n\n return [updateRequired, [...newTxs, ...updatedLocalTxs]];\n }\n\n /**\n * Get all transactions that are in the remote transactions array\n * but not in the local transactions array.\n *\n * @param remoteTxs - Array of transactions from remote source.\n * @param localTxs - Array of transactions stored locally.\n * @returns The new transactions.\n */\n private getNewTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((tx) => {\n const alreadyInTransactions = localTxs.find(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return !alreadyInTransactions;\n });\n }\n\n /**\n * Get all the transactions that are locally outdated with respect\n * to a remote source (etherscan or blockchain). The returned array\n * contains the transactions with the updated data.\n *\n * @param remoteTxs - Array of transactions from remote source.\n * @param localTxs - Array of transactions stored locally.\n * @returns The updated transactions.\n */\n private getUpdatedTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((remoteTx) => {\n const isTxOutdated = localTxs.find((localTx) => {\n return (\n remoteTx.transactionHash === localTx.transactionHash &&\n this.isTransactionOutdated(remoteTx, localTx)\n );\n });\n return isTxOutdated;\n });\n }\n\n /**\n * Verifies if a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteTx - The remote transaction from Etherscan.\n * @param localTx - The local transaction.\n * @returns Whether the transaction is outdated.\n */\n private isTransactionOutdated(\n remoteTx: TransactionMeta,\n localTx: TransactionMeta,\n ): boolean {\n const statusOutdated = this.isStatusOutdated(\n remoteTx.transactionHash,\n localTx.transactionHash,\n remoteTx.status,\n localTx.status,\n );\n const gasDataOutdated = this.isGasDataOutdated(\n remoteTx.transaction.gasUsed,\n localTx.transaction.gasUsed,\n );\n return statusOutdated || gasDataOutdated;\n }\n\n /**\n * Verifies if the status of a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteTxHash - Remote transaction hash.\n * @param localTxHash - Local transaction hash.\n * @param remoteTxStatus - Remote transaction status.\n * @param localTxStatus - Local transaction status.\n * @returns Whether the status is outdated.\n */\n private isStatusOutdated(\n remoteTxHash: string | undefined,\n localTxHash: string | undefined,\n remoteTxStatus: TransactionStatus,\n localTxStatus: TransactionStatus,\n ): boolean {\n return remoteTxHash === localTxHash && remoteTxStatus !== localTxStatus;\n }\n\n /**\n * Verifies if the gas data of a local transaction is outdated with respect to the remote transaction.\n *\n * @param remoteGasUsed - Remote gas used in the transaction.\n * @param localGasUsed - Local gas used in the transaction.\n * @returns Whether the gas data is outdated.\n */\n private isGasDataOutdated(\n remoteGasUsed: string | undefined,\n localGasUsed: string | undefined,\n ): boolean {\n return remoteGasUsed !== localGasUsed;\n }\n}\n\nexport default TransactionController;\n"]} \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/constants.d.ts b/node_modules/@metamask/transaction-controller/dist/constants.d.ts new file mode 100644 -index 0000000..de324e0 +index 0000000..c7de118 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/constants.d.ts -@@ -0,0 +1,118 @@ +@@ -0,0 +1,119 @@ +export declare const CHAIN_IDS: { + readonly MAINNET: "0x1"; + readonly GOERLI: "0x5"; @@ -1669,6 +1706,8 @@ index 0000000..de324e0 + networkId: string; + }; +}; ++//# sourceMappingURL=constants.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/constants.js b/node_modules/@metamask/transaction-controller/dist/constants.js new file mode 100644 index 0000000..a19d2ca @@ -1802,10 +1841,10 @@ index 0000000..a19d2ca \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts new file mode 100644 -index 0000000..99e055c +index 0000000..a49d68f --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts -@@ -0,0 +1,63 @@ +@@ -0,0 +1,64 @@ +export interface EtherscanTransactionMetaBase { + blockNumber: string; + blockHash: string; @@ -1869,9 +1908,11 @@ index 0000000..99e055c + * @returns An Etherscan response object containing the request status and an array of token transaction data. + */ +export declare function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise>; ++//# sourceMappingURL=etherscan.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.js b/node_modules/@metamask/transaction-controller/dist/etherscan.js new file mode 100644 -index 0000000..79f6512 +index 0000000..0757847 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/etherscan.js @@ -0,0 +1,118 @@ @@ -1947,7 +1988,7 @@ index 0000000..79f6512 + * @param options.limit - Number of transactions to retrieve. + * @returns An object containing the request status and an array of transaction data. + */ -+function fetchTransactions(action, { address, apiKey, chainId, fromBlock, limit, }) { ++function fetchTransactions(action, { address, apiKey, chainId, limit, }) { + return __awaiter(this, void 0, void 0, function* () { + const urlParams = { + module: 'account', @@ -1995,13 +2036,23 @@ index 0000000..79f6512 +//# sourceMappingURL=etherscan.js.map \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/index.d.ts b/node_modules/@metamask/transaction-controller/dist/index.d.ts -index def5ced..1817e69 100644 +index fc7f49b..cd9486a 100644 --- a/node_modules/@metamask/transaction-controller/dist/index.d.ts +++ b/node_modules/@metamask/transaction-controller/dist/index.d.ts -@@ -1,2 +1,3 @@ +@@ -1,3 +1,4 @@ export * from './TransactionController'; export { isEIP1559Transaction } from './utils'; +export * from './types'; + //# sourceMappingURL=index.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/index.d.ts.map b/node_modules/@metamask/transaction-controller/dist/index.d.ts.map +deleted file mode 100644 +index 2175387..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/index.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"} +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/index.js b/node_modules/@metamask/transaction-controller/dist/index.js index a1c07c8..602f51c 100644 --- a/node_modules/@metamask/transaction-controller/dist/index.js @@ -2023,10 +2074,10 @@ index a4460fa..0000000 \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts b/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts deleted file mode 100644 -index 649d313..0000000 +index 688af82..0000000 --- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts +++ /dev/null -@@ -1,63 +0,0 @@ +@@ -1,64 +0,0 @@ -import { TransactionMeta } from '../TransactionController'; -export declare const ethTxsMock: (ethTxHash: string) => ({ - blockNumber: string; @@ -2090,6 +2141,16 @@ index 649d313..0000000 -export declare const txsInStateWithOutdatedStatusMock: (ethTxHash: string, tokenTxHash: string) => TransactionMeta[]; -export declare const txsInStateWithOutdatedGasDataMock: (ethTxHash: string, tokenTxHash: string) => TransactionMeta[]; -export declare const txsInStateWithOutdatedStatusAndGasDataMock: (ethTxHash: string, tokenTxHash: string) => TransactionMeta[]; +-//# sourceMappingURL=txsMock.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts.map b/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts.map +deleted file mode 100644 +index 2611b68..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"txsMock.d.ts","sourceRoot":"","sources":["../../src/mocks/txsMock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAqB,MAAM,0BAA0B,CAAC;AAE9E,eAAO,MAAM,UAAU,cAAe,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4E3C,CAAC;AAEF,eAAO,MAAM,YAAY,gBAAiB,MAAM;;;;;;;;;;;;;;;;;;;;GA+R/C,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,MAAM,eACJ,MAAM,KAClB,eAAe,EAqCjB,CAAC;AAEF,eAAO,MAAM,gCAAgC,cAChC,MAAM,eACJ,MAAM,KAClB,eAAe,EAqCjB,CAAC;AAEF,eAAO,MAAM,iCAAiC,cACjC,MAAM,eACJ,MAAM,KAClB,eAAe,EAqCjB,CAAC;AAEF,eAAO,MAAM,0CAA0C,cAC1C,MAAM,eACJ,MAAM,KAClB,eAAe,EAqCjB,CAAC"} +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js b/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js deleted file mode 100644 index 47cf349..0000000 @@ -2622,10 +2683,10 @@ index f038698..0000000 \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/types.d.ts b/node_modules/@metamask/transaction-controller/dist/types.d.ts new file mode 100644 -index 0000000..55b8a6a +index 0000000..257a6b3 --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/types.d.ts -@@ -0,0 +1,138 @@ +@@ -0,0 +1,139 @@ +/** + * @type TransactionMeta + * @@ -2764,6 +2825,8 @@ index 0000000..55b8a6a + fetchTransactions: (request: RemoteTransactionSourceRequest) => Promise; +} +export {}; ++//# sourceMappingURL=types.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/types.js b/node_modules/@metamask/transaction-controller/dist/types.js new file mode 100644 index 0000000..1cddb49 @@ -2801,17 +2864,19 @@ index 0000000..1cddb49 +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/utils.d.ts b/node_modules/@metamask/transaction-controller/dist/utils.d.ts -index e74f382..8748242 100644 +index ccf3362..895cdf1 100644 --- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts +++ b/node_modules/@metamask/transaction-controller/dist/utils.d.ts -@@ -1,4 +1,5 @@ --import { Transaction, FetchAllOptions, GasPriceValue, FeeMarketEIP1559Values } from './TransactionController'; +@@ -1,6 +1,6 @@ + import type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker'; +-import { Transaction, FetchAllOptions, GasPriceValue, FeeMarketEIP1559Values, TransactionStatus } from './TransactionController'; +-import type { TransactionMeta } from './TransactionController'; +import { GasPriceValue, FeeMarketEIP1559Values } from './TransactionController'; -+import { Transaction } from './types'; ++import { Transaction, TransactionStatus, TransactionMeta } from './types'; export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; /** * Return a URL that can be used to fetch ETH transactions. -@@ -30,20 +31,6 @@ export declare function validateTransaction(transaction: Transaction): void; +@@ -32,20 +32,6 @@ export declare function validateTransaction(transaction: Transaction): void; * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false. */ export declare const isEIP1559Transaction: (transaction: Transaction) => boolean; @@ -2832,8 +2897,16 @@ index e74f382..8748242 100644 export declare const validateGasValues: (gasValues: GasPriceValue | FeeMarketEIP1559Values) => void; export declare const isFeeMarketEIP1559Values: (gasValues?: GasPriceValue | FeeMarketEIP1559Values | undefined) => gasValues is FeeMarketEIP1559Values; export declare const isGasPriceValue: (gasValues?: GasPriceValue | FeeMarketEIP1559Values | undefined) => gasValues is GasPriceValue; +diff --git a/node_modules/@metamask/transaction-controller/dist/utils.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils.d.ts.map +deleted file mode 100644 +index 9d4045c..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAiBrE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,GAAG,GACb,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,eAS5D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,QAmD3D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,gBAAiB,WAAW,KAAG,OAO/D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAA;CAAE,EAAE;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAA;CAAE,CAAC,CAAC,CA8C/D;AAED,eAAO,MAAM,iBAAiB,cACjB,aAAa,GAAG,sBAAsB,SAUlD,CAAC;AAEF,eAAO,MAAM,wBAAwB,yGAIsC,CAAC;AAE5E,eAAO,MAAM,eAAe,gGAG0B,CAAC;AAEvD,eAAO,MAAM,oBAAoB,UAAW,MAAM,QAAQ,MAAM,KAAG,MACF,CAAC;AAElE,eAAO,MAAM,6BAA6B,UACjC,MAAM,GAAG,SAAS,QACnB,MAAM,KACX,MAEF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAQpE;AAED;;;;;;;GAOG;AACH,wBAAgB,uCAAuC,CACrD,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,eAAe,EAAE,GAC9B,uBAAuB,EAAE,CAsB3B"} +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/utils.js b/node_modules/@metamask/transaction-controller/dist/utils.js -index dc4300f..6d26ffb 100644 +index 179a564..ce955ba 100644 --- a/node_modules/@metamask/transaction-controller/dist/utils.js +++ b/node_modules/@metamask/transaction-controller/dist/utils.js @@ -1,15 +1,6 @@ @@ -2848,8 +2921,8 @@ index dc4300f..6d26ffb 100644 - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); --exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.handleTransactionFetch = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransaction = exports.getEtherscanApiUrl = exports.ESTIMATE_GAS_ERROR = void 0; -+exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransaction = exports.getEtherscanApiUrl = exports.ESTIMATE_GAS_ERROR = void 0; +-exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.handleTransactionFetch = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransaction = exports.getEtherscanApiUrl = exports.ESTIMATE_GAS_ERROR = void 0; ++exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransaction = exports.getEtherscanApiUrl = exports.ESTIMATE_GAS_ERROR = void 0; const ethereumjs_util_1 = require("ethereumjs-util"); const controller_utils_1 = require("@metamask/controller-utils"); exports.ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error'; @@ -2914,9 +2987,9 @@ index dc4300f..6d26ffb 100644 const value = gasValues[key]; diff --git a/node_modules/@metamask/transaction-controller/dist/utils.js.map b/node_modules/@metamask/transaction-controller/dist/utils.js.map deleted file mode 100644 -index 4d94b8b..0000000 +index 8f2f6e3..0000000 --- a/node_modules/@metamask/transaction-controller/dist/utils.js.map +++ /dev/null @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AAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AADrD,QAAA,oBAAoB,wBACiC;AAE3D,MAAM,6BAA6B,GAAG,CAC3C,KAAyB,EACzB,IAAY,EACJ,EAAE;IACV,OAAO,IAAA,4BAAoB,EAAC,IAAA,sCAAmB,EAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC;AALW,QAAA,6BAA6B,iCAKxC;AAEF;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,QAAgB,EAAE,GAAW;IACnE,MAAM,eAAe,GAAG,IAAA,sCAAmB,EAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,IAAA,sCAAmB,EAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,eAAe,IAAI,UAAU,EAAE;QACjC,OAAO,QAAQ,CAAC;KACjB;IACD,MAAM,QAAQ,GAAG,uBAAuB,eAAe,6CAA6C,UAAU,EAAE,CAAC;IACjH,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC;AARD,0DAQC","sourcesContent":["import { addHexPrefix, isHexString } from 'ethereumjs-util';\nimport {\n NetworkType,\n convertHexToDecimal,\n handleFetch,\n isValidHexAddress,\n} from '@metamask/controller-utils';\nimport {\n Transaction,\n FetchAllOptions,\n GasPriceValue,\n FeeMarketEIP1559Values,\n} from './TransactionController';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\nconst NORMALIZERS: { [param in keyof Transaction]: any } = {\n data: (data: string) => addHexPrefix(data),\n from: (from: string) => addHexPrefix(from).toLowerCase(),\n gas: (gas: string) => addHexPrefix(gas),\n gasPrice: (gasPrice: string) => addHexPrefix(gasPrice),\n nonce: (nonce: string) => addHexPrefix(nonce),\n to: (to: string) => addHexPrefix(to).toLowerCase(),\n value: (value: string) => addHexPrefix(value),\n maxFeePerGas: (maxFeePerGas: string) => addHexPrefix(maxFeePerGas),\n maxPriorityFeePerGas: (maxPriorityFeePerGas: string) =>\n addHexPrefix(maxPriorityFeePerGas),\n estimatedBaseFee: (maxPriorityFeePerGas: string) =>\n addHexPrefix(maxPriorityFeePerGas),\n};\n\n/**\n * Return a URL that can be used to fetch ETH transactions.\n *\n * @param networkType - Network type of desired network.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to fetch the access the endpoint.\n */\nexport function getEtherscanApiUrl(\n networkType: string,\n urlParams: any,\n): string {\n let etherscanSubdomain = 'api';\n if (networkType !== NetworkType.mainnet) {\n etherscanSubdomain = `api-${networkType}`;\n }\n const apiUrl = `https://${etherscanSubdomain}.etherscan.io`;\n let url = `${apiUrl}/api?`;\n\n for (const paramKey in urlParams) {\n if (urlParams[paramKey]) {\n url += `${paramKey}=${urlParams[paramKey]}&`;\n }\n }\n url += 'tag=latest&page=1';\n return url;\n}\n\n/**\n * Normalizes properties on a Transaction object.\n *\n * @param transaction - Transaction object to normalize.\n * @returns Normalized Transaction object.\n */\nexport function normalizeTransaction(transaction: Transaction) {\n const normalizedTransaction: Transaction = { from: '' };\n let key: keyof Transaction;\n for (key in NORMALIZERS) {\n if (transaction[key as keyof Transaction]) {\n normalizedTransaction[key] = NORMALIZERS[key](transaction[key]) as never;\n }\n }\n return normalizedTransaction;\n}\n\n/**\n * Validates a Transaction object for required properties and throws in\n * the event of any validation error.\n *\n * @param transaction - Transaction object to validate.\n */\nexport function validateTransaction(transaction: Transaction) {\n if (\n !transaction.from ||\n typeof transaction.from !== 'string' ||\n !isValidHexAddress(transaction.from)\n ) {\n throw new Error(\n `Invalid \"from\" address: ${transaction.from} must be a valid string.`,\n );\n }\n\n if (transaction.to === '0x' || transaction.to === undefined) {\n if (transaction.data) {\n delete transaction.to;\n } else {\n throw new Error(\n `Invalid \"to\" address: ${transaction.to} must be a valid string.`,\n );\n }\n } else if (\n transaction.to !== undefined &&\n !isValidHexAddress(transaction.to)\n ) {\n throw new Error(\n `Invalid \"to\" address: ${transaction.to} must be a valid string.`,\n );\n }\n\n if (transaction.value !== undefined) {\n const value = transaction.value.toString();\n if (value.includes('-')) {\n throw new Error(`Invalid \"value\": ${value} is not a positive number.`);\n }\n\n if (value.includes('.')) {\n throw new Error(\n `Invalid \"value\": ${value} number must be denominated in wei.`,\n );\n }\n const intValue = parseInt(transaction.value, 10);\n const isValid =\n Number.isFinite(intValue) &&\n !Number.isNaN(intValue) &&\n !isNaN(Number(value)) &&\n Number.isSafeInteger(intValue);\n if (!isValid) {\n throw new Error(\n `Invalid \"value\": ${value} number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Checks if a transaction is EIP-1559 by checking for the existence of\n * maxFeePerGas and maxPriorityFeePerGas within its parameters.\n *\n * @param transaction - Transaction object to add.\n * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false.\n */\nexport const isEIP1559Transaction = (transaction: Transaction): boolean => {\n const hasOwnProp = (obj: Transaction, key: string) =>\n Object.prototype.hasOwnProperty.call(obj, key);\n return (\n hasOwnProp(transaction, 'maxFeePerGas') &&\n hasOwnProp(transaction, 'maxPriorityFeePerGas')\n );\n};\n\n/**\n * Handles the fetch of incoming transactions.\n *\n * @param networkType - Network type of desired network.\n * @param address - Address to get the transactions from.\n * @param txHistoryLimit - The maximum number of transactions to fetch.\n * @param opt - Object that can contain fromBlock and Etherscan service API key.\n * @returns Responses for both ETH and ERC20 token transactions.\n */\nexport async function handleTransactionFetch(\n networkType: string,\n address: string,\n txHistoryLimit: number,\n opt?: FetchAllOptions,\n): Promise<[{ [result: string]: [] }, { [result: string]: [] }]> {\n // transactions\n const urlParams = {\n module: 'account',\n address,\n startBlock: opt?.fromBlock,\n apikey: opt?.etherscanApiKey,\n offset: txHistoryLimit.toString(),\n order: 'desc',\n };\n const etherscanTxUrl = getEtherscanApiUrl(networkType, {\n ...urlParams,\n action: 'txlist',\n });\n const etherscanTxResponsePromise = handleFetch(etherscanTxUrl);\n\n // tokens\n const etherscanTokenUrl = getEtherscanApiUrl(networkType, {\n ...urlParams,\n action: 'tokentx',\n });\n const etherscanTokenResponsePromise = handleFetch(etherscanTokenUrl);\n\n let [etherscanTxResponse, etherscanTokenResponse] = await Promise.all([\n etherscanTxResponsePromise,\n etherscanTokenResponsePromise,\n ]);\n\n if (\n etherscanTxResponse.status === '0' ||\n etherscanTxResponse.result.length <= 0\n ) {\n etherscanTxResponse = { status: etherscanTxResponse.status, result: [] };\n }\n\n if (\n etherscanTokenResponse.status === '0' ||\n etherscanTokenResponse.result.length <= 0\n ) {\n etherscanTokenResponse = {\n status: etherscanTokenResponse.status,\n result: [],\n };\n }\n\n return [etherscanTxResponse, etherscanTokenResponse];\n}\n\nexport const validateGasValues = (\n gasValues: GasPriceValue | FeeMarketEIP1559Values,\n) => {\n Object.keys(gasValues).forEach((key) => {\n const value = (gasValues as any)[key];\n if (typeof value !== 'string' || !isHexString(value)) {\n throw new TypeError(\n `expected hex string for ${key} but received: ${value}`,\n );\n }\n });\n};\n\nexport const isFeeMarketEIP1559Values = (\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): gasValues is FeeMarketEIP1559Values =>\n (gasValues as FeeMarketEIP1559Values)?.maxFeePerGas !== undefined ||\n (gasValues as FeeMarketEIP1559Values)?.maxPriorityFeePerGas !== undefined;\n\nexport const isGasPriceValue = (\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): gasValues is GasPriceValue =>\n (gasValues as GasPriceValue)?.gasPrice !== undefined;\n\nexport const getIncreasedPriceHex = (value: number, rate: number): string =>\n addHexPrefix(`${parseInt(`${value * rate}`, 10).toString(16)}`);\n\nexport const getIncreasedPriceFromExisting = (\n value: string | undefined,\n rate: number,\n): string => {\n return getIncreasedPriceHex(convertHexToDecimal(value), rate);\n};\n\n/**\n * Validates that the proposed value is greater than or equal to the minimum value.\n *\n * @param proposed - The proposed value.\n * @param min - The minimum value.\n * @returns The proposed value.\n * @throws Will throw if the proposed value is too low.\n */\nexport function validateMinimumIncrease(proposed: string, min: string) {\n const proposedDecimal = convertHexToDecimal(proposed);\n const minDecimal = convertHexToDecimal(min);\n if (proposedDecimal >= minDecimal) {\n return proposed;\n }\n const errorMsg = `The proposed value: ${proposedDecimal} should meet or exceed the minimum value: ${minDecimal}`;\n throw new Error(errorMsg);\n}\n"]} +-{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4D;AAC5D,iEAKoC;AAWvB,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAA0C;IACzD,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE;IACxD,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,GAAG,CAAC;IACvC,QAAQ,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,QAAQ,CAAC;IACtD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,KAAK,CAAC;IAC7C,EAAE,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,EAAE,CAAC,CAAC,WAAW,EAAE;IAClD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,KAAK,CAAC;IAC7C,YAAY,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,YAAY,CAAC;IAClE,oBAAoB,EAAE,CAAC,oBAA4B,EAAE,EAAE,CACrD,IAAA,8BAAY,EAAC,oBAAoB,CAAC;IACpC,gBAAgB,EAAE,CAAC,oBAA4B,EAAE,EAAE,CACjD,IAAA,8BAAY,EAAC,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,kBAA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A4C;QAC5C,6DAA6D;QAC7D,kDAAkD;QAClD,OAAO;YACL,MAAM;YACN,OAAO,EAAE,CAAC,EAAE,CAAC;YACb,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE;gBAChB,GAAG,EAAE,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE;gBACd,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE;gBAClB,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE;aACnB;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AA1BD,0FA0BC","sourcesContent":["import { addHexPrefix, isHexString } from 'ethereumjs-util';\nimport {\n NetworkType,\n convertHexToDecimal,\n handleFetch,\n isValidHexAddress,\n} from '@metamask/controller-utils';\nimport type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker';\nimport {\n Transaction,\n FetchAllOptions,\n GasPriceValue,\n FeeMarketEIP1559Values,\n TransactionStatus,\n} from './TransactionController';\nimport type { TransactionMeta } from './TransactionController';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\nconst NORMALIZERS: { [param in keyof Transaction]: any } = {\n data: (data: string) => addHexPrefix(data),\n from: (from: string) => addHexPrefix(from).toLowerCase(),\n gas: (gas: string) => addHexPrefix(gas),\n gasPrice: (gasPrice: string) => addHexPrefix(gasPrice),\n nonce: (nonce: string) => addHexPrefix(nonce),\n to: (to: string) => addHexPrefix(to).toLowerCase(),\n value: (value: string) => addHexPrefix(value),\n maxFeePerGas: (maxFeePerGas: string) => addHexPrefix(maxFeePerGas),\n maxPriorityFeePerGas: (maxPriorityFeePerGas: string) =>\n addHexPrefix(maxPriorityFeePerGas),\n estimatedBaseFee: (maxPriorityFeePerGas: string) =>\n addHexPrefix(maxPriorityFeePerGas),\n};\n\n/**\n * Return a URL that can be used to fetch ETH transactions.\n *\n * @param networkType - Network type of desired network.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to fetch the access the endpoint.\n */\nexport function getEtherscanApiUrl(\n networkType: string,\n urlParams: any,\n): string {\n let etherscanSubdomain = 'api';\n if (networkType !== NetworkType.mainnet) {\n etherscanSubdomain = `api-${networkType}`;\n }\n const apiUrl = `https://${etherscanSubdomain}.etherscan.io`;\n let url = `${apiUrl}/api?`;\n\n for (const paramKey in urlParams) {\n if (urlParams[paramKey]) {\n url += `${paramKey}=${urlParams[paramKey]}&`;\n }\n }\n url += 'tag=latest&page=1';\n return url;\n}\n\n/**\n * Normalizes properties on a Transaction object.\n *\n * @param transaction - Transaction object to normalize.\n * @returns Normalized Transaction object.\n */\nexport function normalizeTransaction(transaction: Transaction) {\n const normalizedTransaction: Transaction = { from: '' };\n let key: keyof Transaction;\n for (key in NORMALIZERS) {\n if (transaction[key as keyof Transaction]) {\n normalizedTransaction[key] = NORMALIZERS[key](transaction[key]) as never;\n }\n }\n return normalizedTransaction;\n}\n\n/**\n * Validates a Transaction object for required properties and throws in\n * the event of any validation error.\n *\n * @param transaction - Transaction object to validate.\n */\nexport function validateTransaction(transaction: Transaction) {\n if (\n !transaction.from ||\n typeof transaction.from !== 'string' ||\n !isValidHexAddress(transaction.from)\n ) {\n throw new Error(\n `Invalid \"from\" address: ${transaction.from} must be a valid string.`,\n );\n }\n\n if (transaction.to === '0x' || transaction.to === undefined) {\n if (transaction.data) {\n delete transaction.to;\n } else {\n throw new Error(\n `Invalid \"to\" address: ${transaction.to} must be a valid string.`,\n );\n }\n } else if (\n transaction.to !== undefined &&\n !isValidHexAddress(transaction.to)\n ) {\n throw new Error(\n `Invalid \"to\" address: ${transaction.to} must be a valid string.`,\n );\n }\n\n if (transaction.value !== undefined) {\n const value = transaction.value.toString();\n if (value.includes('-')) {\n throw new Error(`Invalid \"value\": ${value} is not a positive number.`);\n }\n\n if (value.includes('.')) {\n throw new Error(\n `Invalid \"value\": ${value} number must be denominated in wei.`,\n );\n }\n const intValue = parseInt(transaction.value, 10);\n const isValid =\n Number.isFinite(intValue) &&\n !Number.isNaN(intValue) &&\n !isNaN(Number(value)) &&\n Number.isSafeInteger(intValue);\n if (!isValid) {\n throw new Error(\n `Invalid \"value\": ${value} number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Checks if a transaction is EIP-1559 by checking for the existence of\n * maxFeePerGas and maxPriorityFeePerGas within its parameters.\n *\n * @param transaction - Transaction object to add.\n * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false.\n */\nexport const isEIP1559Transaction = (transaction: Transaction): boolean => {\n const hasOwnProp = (obj: Transaction, key: string) =>\n Object.prototype.hasOwnProperty.call(obj, key);\n return (\n hasOwnProp(transaction, 'maxFeePerGas') &&\n hasOwnProp(transaction, 'maxPriorityFeePerGas')\n );\n};\n\n/**\n * Handles the fetch of incoming transactions.\n *\n * @param networkType - Network type of desired network.\n * @param address - Address to get the transactions from.\n * @param txHistoryLimit - The maximum number of transactions to fetch.\n * @param opt - Object that can contain fromBlock and Etherscan service API key.\n * @returns Responses for both ETH and ERC20 token transactions.\n */\nexport async function handleTransactionFetch(\n networkType: string,\n address: string,\n txHistoryLimit: number,\n opt?: FetchAllOptions,\n): Promise<[{ [result: string]: [] }, { [result: string]: [] }]> {\n // transactions\n const urlParams = {\n module: 'account',\n address,\n startBlock: opt?.fromBlock,\n apikey: opt?.etherscanApiKey,\n offset: txHistoryLimit.toString(),\n order: 'desc',\n };\n const etherscanTxUrl = getEtherscanApiUrl(networkType, {\n ...urlParams,\n action: 'txlist',\n });\n const etherscanTxResponsePromise = handleFetch(etherscanTxUrl);\n\n // tokens\n const etherscanTokenUrl = getEtherscanApiUrl(networkType, {\n ...urlParams,\n action: 'tokentx',\n });\n const etherscanTokenResponsePromise = handleFetch(etherscanTokenUrl);\n\n let [etherscanTxResponse, etherscanTokenResponse] = await Promise.all([\n etherscanTxResponsePromise,\n etherscanTokenResponsePromise,\n ]);\n\n if (\n etherscanTxResponse.status === '0' ||\n etherscanTxResponse.result.length <= 0\n ) {\n etherscanTxResponse = { status: etherscanTxResponse.status, result: [] };\n }\n\n if (\n etherscanTokenResponse.status === '0' ||\n etherscanTokenResponse.result.length <= 0\n ) {\n etherscanTokenResponse = {\n status: etherscanTokenResponse.status,\n result: [],\n };\n }\n\n return [etherscanTxResponse, etherscanTokenResponse];\n}\n\nexport const validateGasValues = (\n gasValues: GasPriceValue | FeeMarketEIP1559Values,\n) => {\n Object.keys(gasValues).forEach((key) => {\n const value = (gasValues as any)[key];\n if (typeof value !== 'string' || !isHexString(value)) {\n throw new TypeError(\n `expected hex string for ${key} but received: ${value}`,\n );\n }\n });\n};\n\nexport const isFeeMarketEIP1559Values = (\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): gasValues is FeeMarketEIP1559Values =>\n (gasValues as FeeMarketEIP1559Values)?.maxFeePerGas !== undefined ||\n (gasValues as FeeMarketEIP1559Values)?.maxPriorityFeePerGas !== undefined;\n\nexport const isGasPriceValue = (\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): gasValues is GasPriceValue =>\n (gasValues as GasPriceValue)?.gasPrice !== undefined;\n\nexport const getIncreasedPriceHex = (value: number, rate: number): string =>\n addHexPrefix(`${parseInt(`${value * rate}`, 10).toString(16)}`);\n\nexport const getIncreasedPriceFromExisting = (\n value: string | undefined,\n rate: number,\n): string => {\n return getIncreasedPriceHex(convertHexToDecimal(value), rate);\n};\n\n/**\n * Validates that the proposed value is greater than or equal to the minimum value.\n *\n * @param proposed - The proposed value.\n * @param min - The minimum value.\n * @returns The proposed value.\n * @throws Will throw if the proposed value is too low.\n */\nexport function validateMinimumIncrease(proposed: string, min: string) {\n const proposedDecimal = convertHexToDecimal(proposed);\n const minDecimal = convertHexToDecimal(min);\n if (proposedDecimal >= minDecimal) {\n return proposed;\n }\n const errorMsg = `The proposed value: ${proposedDecimal} should meet or exceed the minimum value: ${minDecimal}`;\n throw new Error(errorMsg);\n}\n\n/**\n * Helper function to filter and format transactions for the nonce tracker.\n *\n * @param fromAddress - Address of the account from which the transactions to filter from are sent.\n * @param transactionStatus - Status of the transactions for which to filter.\n * @param transactions - Array of transactionMeta objects that have been prefiltered.\n * @returns Array of transactions formatted for the nonce tracker.\n */\nexport function getAndFormatTransactionsForNonceTracker(\n fromAddress: string,\n transactionStatus: TransactionStatus,\n transactions: TransactionMeta[],\n): NonceTrackerTransaction[] {\n return transactions\n .filter(\n ({ status, transaction: { from } }) =>\n status === transactionStatus &&\n from.toLowerCase() === fromAddress.toLowerCase(),\n )\n .map(({ status, transaction: { from, gas, value, nonce } }) => {\n // the only value we care about is the nonce\n // but we need to return the other values to satisfy the type\n // TODO: refactor nonceTracker to not require this\n return {\n status,\n history: [{}],\n txParams: {\n from: from ?? '',\n gas: gas ?? '',\n value: value ?? '',\n nonce: nonce ?? '',\n },\n };\n });\n}\n"]} \ No newline at end of file diff --git a/patches/web3-provider-engine+16.0.3.patch b/patches/web3-provider-engine+16.0.5.patch similarity index 98% rename from patches/web3-provider-engine+16.0.3.patch rename to patches/web3-provider-engine+16.0.5.patch index 25017fe98a4..4836a7d8c73 100644 --- a/patches/web3-provider-engine+16.0.3.patch +++ b/patches/web3-provider-engine+16.0.5.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/web3-provider-engine/index.js b/node_modules/web3-provider-engine/index.js -index 3a1b7d5..15560d7 100644 +index 4a22471..3173b3e 100644 --- a/node_modules/web3-provider-engine/index.js +++ b/node_modules/web3-provider-engine/index.js @@ -48,8 +48,29 @@ Web3ProviderEngine.prototype.start = function(cb = noop){ diff --git a/scripts/patch-transaction-controller.sh b/scripts/patch-transaction-controller.sh index 263e3f2280d..764fbe334a3 100755 --- a/scripts/patch-transaction-controller.sh +++ b/scripts/patch-transaction-controller.sh @@ -20,13 +20,13 @@ DIST_DIR_MOBILE="$PACKAGE_DIR_MOBILE/dist" PATCH_FILE="patches/@metamask+transaction-controller+*.patch" COMMENT_LINE_COUNT=7 -COMMENT='+PATCH GENERATED FROM MetaMask/core branch: refactor/transaction-controller-patch-mobile\ +COMMENT='+PATCH GENERATED FROM MetaMask/core branch: refactor/transaction-controller-patch-mobile-5\ +This patch backports various transaction controller features from the main branch of MetaMask/core\ +Steps to update patch:\ -+* Create a new core branch from: refactor/transaction-controller-patch-mobile\ ++* Create a new core branch from: refactor/transaction-controller-patch-mobile-5\ +* Run "yarn build" in the core monorepo\ +* Run "yarn patch:tx " in the mobile repo\ -+* Once the new patch is merged, add your changes to: refactor/transaction-controller-patch-mobile' ++* Once the new patch is merged, add your changes to: refactor/transaction-controller-patch-mobile-5' COMMENT_DIFF='diff --git a/node_modules/@metamask/transaction-controller/dist/.patch.txt b/node_modules/@metamask/transaction-controller/dist/.patch.txt\ new file mode 100644\ diff --git a/yarn.lock b/yarn.lock index 020d08970b1..9c6685aaec8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -144,16 +144,16 @@ "@babel/highlight" "^7.22.13" chalk "^2.4.2" +"@babel/compat-data@^7.13.11", "@babel/compat-data@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.20.tgz#8df6e96661209623f1975d66c35ffca66f3306d0" + integrity sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw== + "@babel/compat-data@^7.20.5", "@babel/compat-data@^7.22.6", "@babel/compat-data@^7.22.9": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.9.tgz#71cdb00a1ce3a329ce4cbec3a44f9fef35669730" integrity sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ== -"@babel/compat-data@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.20.tgz#8df6e96661209623f1975d66c35ffca66f3306d0" - integrity sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw== - "@babel/core@^7.0.0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.13.16", "@babel/core@^7.14.0", "@babel/core@^7.15.5", "@babel/core@^7.20.0", "@babel/core@^7.7.5": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.22.15.tgz#15d4fd03f478a459015a4b94cfbb3bd42c48d2f4" @@ -269,6 +269,20 @@ resolve "^1.14.2" semver "^6.1.2" +"@babel/helper-define-polyfill-provider@^0.2.2", "@babel/helper-define-polyfill-provider@^0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.2.4.tgz#8867aed79d3ea6cade40f801efb7ac5c66916b10" + integrity sha512-OrpPZ97s+aPi6h2n1OXzdhVis1SGSsMU2aMHgLcOKfsp4/v1NWpx3CWT3lBj5eeBq9cDkPkh+YCfdF7O12uNDQ== + dependencies: + "@babel/helper-compilation-targets" "^7.13.0" + "@babel/helper-module-imports" "^7.12.13" + "@babel/helper-plugin-utils" "^7.13.0" + "@babel/traverse" "^7.13.0" + debug "^4.1.1" + lodash.debounce "^4.0.8" + resolve "^1.14.2" + semver "^6.1.2" + "@babel/helper-define-polyfill-provider@^0.4.2": version "0.4.2" resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.4.2.tgz#82c825cadeeeee7aad237618ebbe8fa1710015d7" @@ -312,7 +326,7 @@ dependencies: "@babel/types" "^7.22.15" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.22.5": +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.14.5", "@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.22.5": version "7.22.15" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" integrity sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w== @@ -1121,17 +1135,17 @@ dependencies: "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-runtime@^7.0.0", "@babel/plugin-transform-runtime@^7.5.5": - version "7.22.15" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.22.15.tgz#3a625c4c05a39e932d7d34f5d4895cdd0172fdc9" - integrity sha512-tEVLhk8NRZSmwQ0DJtxxhTrCht1HVo8VaMzYT4w6lwyKBuHsgoioAUA7/6eT2fRfc5/23fuGdlwIxXhRVgWr4g== +"@babel/plugin-transform-runtime@^7.0.0": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.14.5.tgz#30491dad49c6059f8f8fa5ee8896a0089e987523" + integrity sha512-fPMBhh1AV8ZyneiCIA+wYYUH1arzlXR1UMcApjvchDhfKxhy2r2lReJv8uHEyihi4IFIGlr1Pdx7S5fkESDQsg== dependencies: - "@babel/helper-module-imports" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - babel-plugin-polyfill-corejs2 "^0.4.5" - babel-plugin-polyfill-corejs3 "^0.8.3" - babel-plugin-polyfill-regenerator "^0.5.2" - semver "^6.3.1" + "@babel/helper-module-imports" "^7.14.5" + "@babel/helper-plugin-utils" "^7.14.5" + babel-plugin-polyfill-corejs2 "^0.2.2" + babel-plugin-polyfill-corejs3 "^0.2.2" + babel-plugin-polyfill-regenerator "^0.2.2" + semver "^6.3.0" "@babel/plugin-transform-shorthand-properties@^7.0.0", "@babel/plugin-transform-shorthand-properties@^7.12.1", "@babel/plugin-transform-shorthand-properties@^7.22.5": version "7.22.5" @@ -4190,7 +4204,7 @@ "@metamask/base-controller" "^2.0.0" "@metamask/controller-utils" "^3.0.0" -"@metamask/approval-controller@3.4.0", "@metamask/approval-controller@^2.1.0", "@metamask/approval-controller@^3.3.0", "@metamask/approval-controller@^3.4.0": +"@metamask/approval-controller@3.4.0", "@metamask/approval-controller@^2.1.1", "@metamask/approval-controller@^3.3.0", "@metamask/approval-controller@^3.4.0": version "3.4.0" resolved "https://registry.yarnpkg.com/@metamask/approval-controller/-/approval-controller-3.4.0.tgz#282900361d42f785578728b45014ff8cb5e557ea" integrity sha512-DjqrhiX9+W/Fh6Crr7FPJ87Y/uhPWzBvfXGtekv1LHZNmEtUxkrA7aelddUM0fpTdURIGT4aNGBoQudFidc+Lw== @@ -4201,21 +4215,21 @@ immer "^9.0.6" nanoid "^3.1.31" -"@metamask/assets-controllers@^6.0.0": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@metamask/assets-controllers/-/assets-controllers-6.0.0.tgz#94349d35ea505479e9afa517e156e28a1facfa45" - integrity sha512-uDoR0G2NQyZy5V2QTaBn2qzfZ7jj5dmwnyGQs/7YNE+4RmUBfUE6F5+lnzXADYPOt96rZQo0W8rUJZmz62nQuw== +"@metamask/assets-controllers@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@metamask/assets-controllers/-/assets-controllers-7.0.0.tgz#3f39cbd9a8c21c9db53e42a0ec9876017a7ee190" + integrity sha512-yk0TbN/HdZHUbTmKLXu7NzxSFz3/Tf7HVBxMYAXJtmecRTLBk8zw9fGdOiolpQAQ6HIMNupQcTVGv+dGHE6i9A== dependencies: "@ethersproject/bignumber" "^5.7.0" "@ethersproject/contracts" "^5.7.0" "@ethersproject/providers" "^5.7.0" "@metamask/abi-utils" "^1.1.0" - "@metamask/approval-controller" "^2.1.0" + "@metamask/approval-controller" "^2.1.1" "@metamask/base-controller" "^2.0.0" "@metamask/contract-metadata" "^2.3.1" - "@metamask/controller-utils" "^3.2.0" + "@metamask/controller-utils" "^3.4.0" "@metamask/metamask-eth-abis" "3.0.0" - "@metamask/network-controller" "^7.0.0" + "@metamask/network-controller" "^8.0.0" "@metamask/preferences-controller" "^3.0.0" "@metamask/utils" "^5.0.1" "@types/uuid" "^8.3.0" @@ -4284,7 +4298,7 @@ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-2.2.0.tgz#277764d0d56e37180ae7644a9d11eb96295b36fc" integrity sha512-SM6A4C7vXNbVpgMTX67kfW8QWvu3eSXxMZlY5PqZBTkvri1s9zgQ0uwRkK5r2VXNEoVmXCDnnEX/tX5EzzgNUQ== -"@metamask/controller-utils@^1.0.0", "@metamask/controller-utils@^3.0.0", "@metamask/controller-utils@^3.1.0", "@metamask/controller-utils@^3.2.0", "@metamask/controller-utils@^3.4.0", "@metamask/controller-utils@^4.0.0", "@metamask/controller-utils@^4.0.1", "@metamask/controller-utils@^4.3.2": +"@metamask/controller-utils@^1.0.0", "@metamask/controller-utils@^3.0.0", "@metamask/controller-utils@^3.1.0", "@metamask/controller-utils@^3.4.0", "@metamask/controller-utils@^4.0.0", "@metamask/controller-utils@^4.0.1", "@metamask/controller-utils@^4.3.2": version "3.4.0" resolved "https://registry.yarnpkg.com/@metamask/controller-utils/-/controller-utils-3.4.0.tgz#3714799a3e2648cd758272612578238749e3e11b" integrity sha512-/++y7qXUd9+aRzOklypfzmehO87QVKndlJXsbLRk36W5L5DJo4lrR2pd/IBbwbWEhFJWHhlfbMD+T+gEBvIftw== @@ -4388,14 +4402,14 @@ resolved "https://registry.yarnpkg.com/@metamask/etherscan-link/-/etherscan-link-2.1.0.tgz#c0be8e68445b7b83cf85bcc03a56cdf8e256c973" integrity sha512-ADuWlTUkFfN2vXlz81Bg/0BA+XRor+CdK1055p6k7H6BLIPoDKn9SBOFld9haQFuR9cKh/JYHcnlSIv5R4fUEw== -"@metamask/gas-fee-controller@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@metamask/gas-fee-controller/-/gas-fee-controller-4.0.1.tgz#12ddf59e68af724c1f91a078596c34a4af7beb6c" - integrity sha512-GQxZNZr0gi93nCv1/43BDjA/2TIw4sik4w84xJA+dH3UN7Nzo5JWGnqtjG6JYzwGd1YeYLXYe1H/+3WH12GoAA== +"@metamask/gas-fee-controller@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@metamask/gas-fee-controller/-/gas-fee-controller-5.0.0.tgz#6f9e385951eadf052ecc1311d05501513cda3f4f" + integrity sha512-/F0A4tvkd2MUtfT52CgIqhMKQQv3T7+rqFdPj/GGKWJ/DVhs+TZ3hlQOhJnVUiyx1RHV2owvD0yy04+HfsajqQ== dependencies: "@metamask/base-controller" "^2.0.0" - "@metamask/controller-utils" "^3.1.0" - "@metamask/network-controller" "^6.0.0" + "@metamask/controller-utils" "^3.4.0" + "@metamask/network-controller" "^8.0.0" "@types/uuid" "^8.3.0" babel-runtime "^6.26.0" eth-query "^2.1.2" @@ -4475,39 +4489,23 @@ resolved "https://registry.yarnpkg.com/@metamask/mobile-provider/-/mobile-provider-2.1.0.tgz#685b2f6a55d24197af3f26de4dd0bb78e10ac83e" integrity sha512-VuVUIZ5jEQmLaU8SJC8692crxtNncsxyR9q5j1J6epyMHUU75WTtQdq7VSsu1ghkmP9NXNAz3inlWOGsbT8lLA== -"@metamask/network-controller@^6.0.0": - version "6.0.0" - resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-6.0.0.tgz#7b762c6461b97a301c55e9d73e87487a94f31efe" - integrity sha512-y8rTMAc1LFKBKD0RAiKv2jSl+BUFooJ5fRrqfPLfxLAlg1vrxQojE7iSn1imp3OVSSoKSZk0RPKJ/8SW78dV/Q== - dependencies: - "@metamask/base-controller" "^2.0.0" - "@metamask/controller-utils" "^3.1.0" - "@metamask/swappable-obj-proxy" "^2.1.0" - "@metamask/utils" "^3.3.1" - async-mutex "^0.2.6" - babel-runtime "^6.26.0" - eth-json-rpc-infura "^5.1.0" - eth-query "^2.1.2" - immer "^9.0.6" - uuid "^8.3.2" - web3-provider-engine "^16.0.3" - -"@metamask/network-controller@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-7.0.0.tgz#5084762ff8a5a9ced7d3cc00ebfbd00efd0bb85d" - integrity sha512-W9iowJAqfrGMYWo03wfbwksO6j3QWRGMQA6vyTfB/Nyu9NyoJUALmLk9pSC16mGXwaOO8TzbNCehlbRZkGYAoQ== +"@metamask/network-controller@^8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-8.0.0.tgz#46876af563507fd0bdc5c403fe545cbb1c460b21" + integrity sha512-GYmD9Mc38ymv1BX5LVtCkdomeA41Nxnf1YqNVjyiNMpmZHj4HYnkkTEUsJpWvGvECzV7QunF4s3zcguNIz5kEA== dependencies: "@metamask/base-controller" "^2.0.0" - "@metamask/controller-utils" "^3.1.0" + "@metamask/controller-utils" "^3.4.0" "@metamask/swappable-obj-proxy" "^2.1.0" - "@metamask/utils" "^3.3.1" + "@metamask/utils" "^5.0.1" async-mutex "^0.2.6" babel-runtime "^6.26.0" eth-json-rpc-infura "^5.1.0" eth-query "^2.1.2" + eth-rpc-errors "^4.0.2" immer "^9.0.6" uuid "^8.3.2" - web3-provider-engine "^16.0.3" + web3-provider-engine "^16.0.5" "@metamask/obs-store@^7.0.0": version "7.0.0" @@ -4640,22 +4638,23 @@ resolved "https://registry.yarnpkg.com/@metamask/test-dapp/-/test-dapp-7.1.0.tgz#e7119f12b1dc7a600b0b726e58971900c29b88a7" integrity sha512-uqnno8JmpNMuyxDqQ6rq8+T9hf6Rsuy7rJnHHQd0RFRmva02v6N8rJZpEmftM61ciAaMolSB8XbZPPRsMIdQ8w== -"@metamask/transaction-controller@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@metamask/transaction-controller/-/transaction-controller-4.0.1.tgz#52f307bfc6a438a6174fedfcc276ca392e4be971" - integrity sha512-9N0FbByZVbQsNv2nZiVFCVdKLzNcYB/kwOJ4zIfdtjVRZH9Li3Ges0aT+LdiaTf2eGkvFagTEe7KjRQptYRgng== +"@metamask/transaction-controller@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@metamask/transaction-controller/-/transaction-controller-5.0.0.tgz#5572a63a6bea752f8271143f02ac66a9f4850469" + integrity sha512-jv5famkDobQqm0OCdQidtwsMUSc0rwUS7yN47nQE1Hd7o9ry1BJDI9QN+7ufjkFXw3WWIZZyyFVsuwUtAvBY0g== dependencies: "@ethereumjs/common" "^2.6.1" "@ethereumjs/tx" "^3.5.2" "@metamask/base-controller" "^2.0.0" - "@metamask/controller-utils" "^3.1.0" - "@metamask/network-controller" "^6.0.0" + "@metamask/controller-utils" "^3.4.0" + "@metamask/network-controller" "^8.0.0" async-mutex "^0.2.6" babel-runtime "^6.26.0" eth-method-registry "1.1.0" eth-query "^2.1.2" - eth-rpc-errors "^4.0.0" + eth-rpc-errors "^4.0.2" ethereumjs-util "^7.0.10" + nonce-tracker "^1.1.0" uuid "^8.3.2" "@metamask/types@^1.1.0": @@ -4663,7 +4662,7 @@ resolved "https://registry.yarnpkg.com/@metamask/types/-/types-1.1.0.tgz#9bd14b33427932833c50c9187298804a18c2e025" integrity sha512-EEV/GjlYkOSfSPnYXfOosxa3TqYtIW3fhg6jdw+cok/OhMgNn4wCfbENFqjytrHMU2f7ZKtBAvtiP5V8H44sSw== -"@metamask/utils@^3.3.1", "@metamask/utils@^3.4.1": +"@metamask/utils@^3.4.1": version "3.6.0" resolved "https://registry.yarnpkg.com/@metamask/utils/-/utils-3.6.0.tgz#b218b969a05ca7a8093b5d1670f6625061de707d" integrity sha512-9cIRrfkWvHblSiNDVXsjivqa9Ak0RYo/1H6tqTqTbAx+oBK2Sva0lWDHxGchOqA7bySGUJKAWSNJvH6gdHZ0gQ== @@ -4721,6 +4720,11 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.0.tgz#085fd70f6d7d9d109671090ccae1d3bec62554a1" integrity sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg== +"@noble/hashes@^1.3.1": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@noble/hashes@~1.3.0": version "1.3.1" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" @@ -11023,6 +11027,14 @@ assert@^1.1.1: object.assign "^4.1.4" util "^0.10.4" +assert@^1.4.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb" + integrity sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA== + dependencies: + object-assign "^4.1.1" + util "0.10.3" + assert@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32" @@ -11366,6 +11378,15 @@ babel-plugin-named-exports-order@^0.0.2: resolved "https://registry.yarnpkg.com/babel-plugin-named-exports-order/-/babel-plugin-named-exports-order-0.0.2.tgz#ae14909521cf9606094a2048239d69847540cb09" integrity sha512-OgOYHOLoRK+/mvXU9imKHlG6GkPLYrUCvFXG/CM93R/aNNO8pOOF4aS+S8CCHMDQoNSeiOYEZb/G6RwL95Jktw== +babel-plugin-polyfill-corejs2@^0.2.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.2.3.tgz#6ed8e30981b062f8fe6aca8873a37ebcc8cc1c0f" + integrity sha512-NDZ0auNRzmAfE1oDDPW2JhzIMXUk+FFe2ICejmt5T4ocKgiQx3e0VCRx9NCAidcMtL2RUZaWtXnmjTCkx0tcbA== + dependencies: + "@babel/compat-data" "^7.13.11" + "@babel/helper-define-polyfill-provider" "^0.2.4" + semver "^6.1.1" + babel-plugin-polyfill-corejs2@^0.4.5: version "0.4.5" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.5.tgz#8097b4cb4af5b64a1d11332b6fb72ef5e64a054c" @@ -11383,6 +11404,14 @@ babel-plugin-polyfill-corejs3@^0.1.0: "@babel/helper-define-polyfill-provider" "^0.1.5" core-js-compat "^3.8.1" +babel-plugin-polyfill-corejs3@^0.2.2: + version "0.2.5" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.2.5.tgz#2779846a16a1652244ae268b1e906ada107faf92" + integrity sha512-ninF5MQNwAX9Z7c9ED+H2pGt1mXdP4TqzlHKyPIYmJIYz0N+++uwdM7RnJukklhzJ54Q84vA4ZJkgs7lu5vqcw== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.2.2" + core-js-compat "^3.16.2" + babel-plugin-polyfill-corejs3@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.3.tgz#b4f719d0ad9bb8e0c23e3e630c0c8ec6dd7a1c52" @@ -11391,6 +11420,13 @@ babel-plugin-polyfill-corejs3@^0.8.3: "@babel/helper-define-polyfill-provider" "^0.4.2" core-js-compat "^3.31.0" +babel-plugin-polyfill-regenerator@^0.2.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.2.3.tgz#2e9808f5027c4336c994992b48a4262580cb8d6d" + integrity sha512-JVE78oRZPKFIeUqFGrSORNzQnrDwZR16oiWeGM8ZyjBn2XAT5OjP+wXx5ESuo33nUsFUEJYjtklnsKbxW5L+7g== + dependencies: + "@babel/helper-define-polyfill-provider" "^0.2.4" + babel-plugin-polyfill-regenerator@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.5.2.tgz#80d0f3e1098c080c8b5a65f41e9427af692dc326" @@ -13179,6 +13215,13 @@ copyfiles@^2.3.0: untildify "^4.0.0" yargs "^16.1.0" +core-js-compat@^3.16.2, core-js-compat@^3.8.1: + version "3.32.2" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.32.2.tgz#8047d1a8b3ac4e639f0d4f66d4431aa3b16e004c" + integrity sha512-+GjlguTDINOijtVRUxrQOv3kfu9rl+qPNdX2LTbJ/ZyVTuxK+ksVSAGX1nHstu4hrv1En/uPTtWgq2gI5wt4AQ== + dependencies: + browserslist "^4.21.10" + core-js-compat@^3.31.0: version "3.31.1" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.31.1.tgz#5084ad1a46858df50ff89ace152441a63ba7aae0" @@ -13186,13 +13229,6 @@ core-js-compat@^3.31.0: dependencies: browserslist "^4.21.9" -core-js-compat@^3.8.1: - version "3.32.2" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.32.2.tgz#8047d1a8b3ac4e639f0d4f66d4431aa3b16e004c" - integrity sha512-+GjlguTDINOijtVRUxrQOv3kfu9rl+qPNdX2LTbJ/ZyVTuxK+ksVSAGX1nHstu4hrv1En/uPTtWgq2gI5wt4AQ== - dependencies: - browserslist "^4.21.10" - core-js@^2.4.0, core-js@^2.5.7, core-js@^2.6.5: version "2.6.12" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" @@ -13339,7 +13375,7 @@ create-require@^1.1.0: resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== -cross-fetch@2.2.6, cross-fetch@^2.1.0, cross-fetch@^3.1.5: +cross-fetch@2.2.6, cross-fetch@^3.1.5: version "2.2.6" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.6.tgz#2ef0bb39a24ac034787965c457368a28730e220a" integrity sha512-9JZz+vXCmfKUZ68zAptS7k4Nu8e2qcibe7WVZYps7sAgk5R8GYTc+T1WR0v1rlP9HxgARmOX1UTIJZFytajpNA== @@ -15478,17 +15514,14 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= -eth-block-tracker@^4.4.2: - version "4.4.3" - resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-4.4.3.tgz#766a0a0eb4a52c867a28328e9ae21353812cf626" - integrity sha512-A8tG4Z4iNg4mw5tP1Vung9N9IjgMNqpiMoJ/FouSFwNCGHv2X0mmOYwtQOJzki6XN7r7Tyo01S29p7b224I4jw== +eth-block-tracker@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-5.0.1.tgz#c5ad39902bd0454223b601ec0874f9fcc9f30eed" + integrity sha512-NVs+JDSux0FdmOrl3A2YDcQFkkYf9/qW9irvPmtC7bhMoPAe6oBlaqqe/m9Ixh5rkKqAox4mEyWGpsFmf/IsNw== dependencies: - "@babel/plugin-transform-runtime" "^7.5.5" - "@babel/runtime" "^7.5.5" - eth-query "^2.1.0" + "@metamask/safe-event-emitter" "^2.0.0" json-rpc-random-id "^1.0.1" pify "^3.0.0" - safe-event-emitter "^1.0.1" eth-block-tracker@^7.0.1: version "7.1.0" @@ -15649,7 +15682,7 @@ eth-phishing-detect@^1.2.0: dependencies: fast-levenshtein "^2.0.6" -eth-query@^2.1.0, eth-query@^2.1.2: +eth-query@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/eth-query/-/eth-query-2.1.2.tgz#d6741d9000106b51510c72db92d6365456a6da5e" integrity sha1-1nQdkAAQa1FRDHLbktY2VFam2l4= @@ -16118,7 +16151,7 @@ ethjs-query@0.3.7: ethjs-rpc "0.2.0" promise-to-callback "^1.0.0" -ethjs-query@0.3.8: +ethjs-query@0.3.8, ethjs-query@^0.3.8: version "0.3.8" resolved "https://registry.yarnpkg.com/ethjs-query/-/ethjs-query-0.3.8.tgz#aa5af02887bdd5f3c78b3256d0f22ffd5d357490" integrity sha512-/J5JydqrOzU8O7VBOwZKUWXxHDGr46VqNjBCJgBVNNda+tv7Xc8Y2uJc6aMHHVbeN3YOQ7YRElgIc0q1CI02lQ== @@ -22853,6 +22886,15 @@ noms@0.0.0: inherits "^2.0.1" readable-stream "~1.0.31" +nonce-tracker@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/nonce-tracker/-/nonce-tracker-1.1.0.tgz#9a102346dc5ab681e357b61091da16b068ab50ac" + integrity sha512-Cz+ZC+tsVEelWUU9T02PQBmI4o3uYnbIraGIvlpjQtLZvPVaE2DQh7o0wfUK1h7q3qyEeMup4h7giz5E1xIF4w== + dependencies: + assert "^1.4.1" + await-semaphore "^0.1.3" + ethjs-query "^0.3.8" + noop-logger@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/noop-logger/-/noop-logger-0.1.1.tgz#94a2b1633c4f1317553007d8966fd0e841b6a4c2" @@ -26914,7 +26956,7 @@ semver@^6.0.0, semver@^6.1.2, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^6.3.1: +semver@^6.1.1, semver@^6.3.1: version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== @@ -29667,17 +29709,16 @@ weak@^1.0.0: bindings "^1.2.1" nan "^2.0.5" -web3-provider-engine@^16.0.3: - version "16.0.3" - resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-16.0.3.tgz#8ff93edf3a8da2f70d7f85c5116028c06a0d9f07" - integrity sha512-Q3bKhGqLfMTdLvkd4TtkGYJHcoVQ82D1l8jTIwwuJp/sAp7VHnRYb9YJ14SW/69VMWoOhSpPLZV2tWb9V0WJoA== +web3-provider-engine@^16.0.3, web3-provider-engine@^16.0.5: + version "16.0.5" + resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-16.0.5.tgz#28a0eaf6c33bc60b3cb7de1b961bea6b5cf06b78" + integrity sha512-fvoMm8Tehf3efaqv9pSd2VKLjgzcYNsJaiby87nPrktlnIc9S3G/9udnuJQn32FAt19yzOvNk3B513jhBKOgEg== dependencies: "@ethereumjs/tx" "^3.3.0" async "^2.5.0" backoff "^2.5.0" clone "^2.0.0" - cross-fetch "^2.1.0" - eth-block-tracker "^4.4.2" + eth-block-tracker "^5.0.1" eth-json-rpc-filters "^4.2.1" eth-json-rpc-infura "^5.1.0" eth-json-rpc-middleware "^6.0.0"