diff --git a/.js.env.example b/.js.env.example index ff60d5739df..a9c923b361b 100644 --- a/.js.env.example +++ b/.js.env.example @@ -50,10 +50,10 @@ export MM_BLOCKAID_UI_ENABLED="" export WATCHER_PORT=8081 # Environment: "production", "pre-release" or "local" -export METAMASK_ENVIRONMENT="" +export METAMASK_ENVIRONMENT="local" # Build type: "main" or "flask" -export METAMASK_BUILD_TYPE="" +export METAMASK_BUILD_TYPE="main" # Segment SDK proxy endpoint and write key export SEGMENT_WRITE_KEY="" diff --git a/README.md b/README.md index 89cb782993f..9794cab8c73 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ To learn how to develop MetaMask-compatible applications, visit our [Developer D ### Environment setup -Before running the app, make sure your development environment has all the required tools. +Before running the app, make sure your development environment has all the required tools. Several of these tools (ie Node and Ruby) may require specific versions in order to successfully build the app. [Setup your development environment](./docs/readme/environment.md) @@ -65,4 +65,4 @@ yarn start:ios **Run on an Android device** ```bash yarn start:android -``` \ No newline at end of file +``` diff --git a/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.test.tsx b/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.test.tsx index 7f8d13ca8cf..e32fbe12f3d 100644 --- a/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.test.tsx +++ b/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.test.tsx @@ -378,6 +378,7 @@ describe('SendTransaction View', () => { "fiat_out": 0, "order_id": "test-id-1", "payment_method_id": "/payments/instant-bank-transfer", + "provider_offramp": "Test (Staging)", }, ] `); @@ -432,6 +433,7 @@ describe('SendTransaction View', () => { "fiat_out": 0, "order_id": "test-id-1", "payment_method_id": "/payments/instant-bank-transfer", + "provider_offramp": "Test (Staging)", }, ] `); @@ -479,6 +481,7 @@ describe('SendTransaction View', () => { "fiat_out": 0, "order_id": "test-id-1", "payment_method_id": "/payments/instant-bank-transfer", + "provider_offramp": "Test (Staging)", }, ] `); @@ -529,6 +532,7 @@ describe('SendTransaction View', () => { "fiat_out": 0, "order_id": "test-id-1", "payment_method_id": "/payments/instant-bank-transfer", + "provider_offramp": "Test (Staging)", }, ] `); diff --git a/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.tsx b/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.tsx index 7db84663a0e..4bf46677aba 100644 --- a/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.tsx +++ b/app/components/UI/Ramp/Views/SendTransaction/SendTransaction.tsx @@ -92,13 +92,14 @@ function SendTransaction() { const transactionAnalyticsPayload = useMemo( () => ({ - crypto_amount: orderData?.cryptoAmount, + crypto_amount: orderData?.cryptoAmount as string, chain_id_source: orderData?.cryptoCurrency.network.chainId, fiat_out: orderData?.fiatAmount, payment_method_id: orderData?.paymentMethod.id, currency_source: orderData?.cryptoCurrency.symbol, currency_destination: orderData?.fiatCurrency.symbol, order_id: order?.id, + provider_offramp: orderData?.provider.name, }), [order?.id, orderData], ); diff --git a/app/components/UI/Ramp/types/analytics.ts b/app/components/UI/Ramp/types/analytics.ts index 951e79afbb5..f7eb4bba4f2 100644 --- a/app/components/UI/Ramp/types/analytics.ts +++ b/app/components/UI/Ramp/types/analytics.ts @@ -278,6 +278,7 @@ interface RampTransaction { currency_source: string; currency_destination: string; order_id?: string; + provider_offramp: string; } interface RampQuotesExpanded { diff --git a/app/components/Views/Settings/NetworksSettings/index.js b/app/components/Views/Settings/NetworksSettings/index.js index e3d0fc7f0d8..6419bcac3cc 100644 --- a/app/components/Views/Settings/NetworksSettings/index.js +++ b/app/components/Views/Settings/NetworksSettings/index.js @@ -155,7 +155,11 @@ class NetworksSettings extends PureComponent { this.updateNavBar(); }; - componentDidUpdate = () => { + componentDidUpdate = (prevProps) => { + if (this.props.networkConfigurations !== prevProps.networkConfigurations) { + this.handleSearchTextChange(this.state.searchString); + } + this.updateNavBar(); }; diff --git a/app/store/migrations/025.test.js b/app/store/migrations/025.test.js index c4622a6e618..54d055f1314 100644 --- a/app/store/migrations/025.test.js +++ b/app/store/migrations/025.test.js @@ -14,7 +14,7 @@ describe('Migration #25', () => { '0x61': true, '0xa': true, '0xa869': true, - '0x1a4': true, + '0xaa37dc': true, '0x89': true, '0x13881': true, '0xa86a': true, @@ -46,7 +46,7 @@ describe('Migration #25', () => { '0x61': false, '0xa': false, '0xa869': false, - '0x1a4': false, + '0xaa37dc': false, '0x89': false, '0x13881': false, '0xa86a': false, diff --git a/app/util/test/initial-background-state.json b/app/util/test/initial-background-state.json index 3411e941c18..63a35c52b99 100644 --- a/app/util/test/initial-background-state.json +++ b/app/util/test/initial-background-state.json @@ -113,7 +113,7 @@ "0x61": true, "0xa": true, "0xa869": true, - "0x1a4": true, + "0xaa37dc": true, "0x89": true, "0x13881": true, "0xa86a": true, diff --git a/package.json b/package.json index 897d3e0891e..05463042058 100644 --- a/package.json +++ b/package.json @@ -116,9 +116,7 @@ "@metamask/contract-metadata": "^2.1.0", "@metamask/approval-controller": "3.4.0", "@exodus/react-native-payments/validator": "^13.7.0", - "**/plist": "3.0.5", "**/minimist": "1.2.6", - "@metamask/**/cross-fetch": "2.2.6", "react-native-svg-asset-plugin/sharp": "^0.30.5", "d3-color": "3.1.0", "tough-cookie": "4.1.3", diff --git a/patches/@metamask+preferences-controller+4.4.3.patch b/patches/@metamask+preferences-controller+4.4.3.patch index d806f0606c7..e9d0e20d3e2 100644 --- a/patches/@metamask+preferences-controller+4.4.3.patch +++ b/patches/@metamask+preferences-controller+4.4.3.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/@metamask/preferences-controller/dist/PreferencesController.d.ts b/node_modules/@metamask/preferences-controller/dist/PreferencesController.d.ts -index 323a8e8..8fa1856 100644 +index 323a8e8..0c5ed1b 100644 --- a/node_modules/@metamask/preferences-controller/dist/PreferencesController.d.ts +++ b/node_modules/@metamask/preferences-controller/dist/PreferencesController.d.ts @@ -35,7 +35,8 @@ export interface PreferencesState extends BaseState { @@ -54,8 +54,9 @@ index 323a8e8..8fa1856 100644 } export default PreferencesController; //# sourceMappingURL=PreferencesController.d.ts.map +\ No newline at end of file diff --git a/node_modules/@metamask/preferences-controller/dist/PreferencesController.js b/node_modules/@metamask/preferences-controller/dist/PreferencesController.js -index 1a98ab0..a31d967 100644 +index 1a98ab0..4ce2400 100644 --- a/node_modules/@metamask/preferences-controller/dist/PreferencesController.js +++ b/node_modules/@metamask/preferences-controller/dist/PreferencesController.js @@ -3,6 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true }); @@ -69,7 +70,7 @@ index 1a98ab0..a31d967 100644 + BSC: '0x38', + BSC_TESTNET: '0x61', + OPTIMISM: '0xa', -+ OPTIMISM_TESTNET: '0x1a4', ++ OPTIMISM_SEPOLIA: '0xaa37dc', + POLYGON: '0x89', + POLYGON_TESTNET: '0x13881', + AVALANCHE: '0xa86a', @@ -108,7 +109,7 @@ index 1a98ab0..a31d967 100644 + [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true, -+ [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_TESTNET]: true, ++ [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true, @@ -193,3 +194,4 @@ index 1a98ab0..a31d967 100644 exports.PreferencesController = PreferencesController; exports.default = PreferencesController; //# sourceMappingURL=PreferencesController.js.map +\ No newline at end of file diff --git a/patches/@metamask+transaction-controller+6.1.0.patch b/patches/@metamask+transaction-controller+6.1.0.patch index c10253dacd5..faf1553d52d 100644 --- a/patches/@metamask+transaction-controller+6.1.0.patch +++ b/patches/@metamask+transaction-controller+6.1.0.patch @@ -1798,7 +1798,7 @@ index e356498..0000000 \ 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..c7de118 +index 0000000..5010b5b --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/constants.d.ts @@ -0,0 +1,119 @@ @@ -1808,7 +1808,7 @@ index 0000000..c7de118 + readonly BSC: "0x38"; + readonly BSC_TESTNET: "0x61"; + readonly OPTIMISM: "0xa"; -+ readonly OPTIMISM_TESTNET: "0x1a4"; ++ readonly OPTIMISM_SEPOLIA: "0xaa37dc"; + readonly POLYGON: "0x89"; + readonly POLYGON_TESTNET: "0x13881"; + readonly AVALANCHE: "0xa86a"; @@ -1864,7 +1864,7 @@ index 0000000..c7de118 + subdomain: string; + networkId: string; + }; -+ "0x1a4": { ++ "0xaa37dc": { + domain: string; + subdomain: string; + networkId: string; @@ -1924,7 +1924,7 @@ index 0000000..c7de118 \ 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 +index 0000000..5f7644a --- /dev/null +++ b/node_modules/@metamask/transaction-controller/dist/constants.js @@ -0,0 +1,124 @@ @@ -1937,7 +1937,7 @@ index 0000000..a19d2ca + BSC: '0x38', + BSC_TESTNET: '0x61', + OPTIMISM: '0xa', -+ OPTIMISM_TESTNET: '0x1a4', ++ OPTIMISM_SEPOLIA: '0xaa37dc', + POLYGON: '0x89', + POLYGON_TESTNET: '0x13881', + AVALANCHE: '0xa86a', @@ -1995,10 +1995,10 @@ index 0000000..a19d2ca + subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`, + networkId: parseInt(exports.CHAIN_IDS.OPTIMISM, 16).toString(), + }, -+ [exports.CHAIN_IDS.OPTIMISM_TESTNET]: { ++ [exports.CHAIN_IDS.OPTIMISM_SEPOLIA]: { + domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`, -+ networkId: parseInt(exports.CHAIN_IDS.OPTIMISM_TESTNET, 16).toString(), ++ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`, ++ networkId: parseInt(exports.CHAIN_IDS.OPTIMISM_SEPOLIA, 16).toString(), + }, + [exports.CHAIN_IDS.POLYGON]: { + domain: 'polygonscan.com', @@ -2521,6 +2521,174 @@ index 0000000..4742145 @@ -0,0 +1 @@ +{"version":3,"file":"LineaGasFeeFlow.js","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAA4E;AAC5E,2CAA+D;AAG/D,sCAA0C;AAQ1C,oCAA+C;AAC/C,2DAAwD;AAWxD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,eAAe,GAAU;IAC7B,0BAAO,CAAC,eAAe,CAAC;IACxB,0BAAO,CAAC,cAAc,CAAC;CACxB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF;;;;GAIG;AACH,MAAa,eAAe;IAA5B;;IA0GA,CAAC;IAzGC,kBAAkB,CAAC,eAAgC;QACjD,OAAO,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAc,CAAC,CAAC;IAClE,CAAC;IAEK,UAAU,CAAC,OAA0B;;YACzC,IAAI;gBACF,OAAO,MAAM,uBAAA,IAAI,oEAAiB,MAArB,IAAI,EAAkB,OAAO,CAAC,CAAC;aAC7C;YAAC,OAAO,KAAK,EAAE;gBACd,GAAG,CAAC,6CAA6C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AAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { ChainId, hexToBN, query, toHex } from '@metamask/controller-utils';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\nimport type { BN } from 'ethereumjs-util';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\n\ntype LineaEstimateGasResponse = {\n baseFeePerGas: Hex;\n priorityFeePerGas: Hex;\n};\n\ntype FeesByLevel = {\n [key in GasFeeEstimateLevel]: BN;\n};\n\nconst log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');\n\nconst LINEA_CHAIN_IDS: Hex[] = [\n ChainId['linea-mainnet'],\n ChainId['linea-goerli'],\n];\n\nconst BASE_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.35,\n high: 1.7,\n};\n\nconst PRIORITY_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.05,\n high: 1.1,\n};\n\n/**\n * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:\n * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.\n * - Static multipliers to increase the base and priority fees.\n */\nexport class LineaGasFeeFlow implements GasFeeFlow {\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return LINEA_CHAIN_IDS.includes(transactionMeta.chainId as Hex);\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise {\n try {\n return await this.#getLineaGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n }\n\n async #getLineaGasFees(\n request: GasFeeFlowRequest,\n ): Promise {\n const { ethQuery, transactionMeta } = request;\n\n const lineaResponse = await this.#getLineaResponse(\n transactionMeta,\n ethQuery,\n );\n\n log('Received Linea response', lineaResponse);\n\n const baseFees = this.#getValuesFromMultipliers(\n lineaResponse.baseFeePerGas,\n BASE_FEE_MULTIPLIERS,\n );\n\n log('Generated base fees', this.#feesToString(baseFees));\n\n const priorityFees = this.#getValuesFromMultipliers(\n lineaResponse.priorityFeePerGas,\n PRIORITY_FEE_MULTIPLIERS,\n );\n\n log('Generated priority fees', this.#feesToString(priorityFees));\n\n const maxFees = this.#getMaxFees(baseFees, priorityFees);\n\n log('Generated max fees', this.#feesToString(maxFees));\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: {\n maxFeePerGas: toHex(maxFees[level]),\n maxPriorityFeePerGas: toHex(priorityFees[level]),\n },\n }),\n {} as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getLineaResponse(\n transactionMeta: TransactionMeta,\n ethQuery: any,\n ): Promise {\n return query(ethQuery, 'linea_estimateGas', [\n {\n from: transactionMeta.transaction.from,\n to: transactionMeta.transaction.to,\n value: transactionMeta.transaction.value,\n input: transactionMeta.transaction.data,\n // Required in request but no impact on response.\n gasPrice: '0x100000000',\n },\n ]);\n }\n\n #getValuesFromMultipliers(\n value: Hex,\n multipliers: { low: number; medium: number; high: number },\n ): FeesByLevel {\n const base = hexToBN(value);\n const low = base.muln(multipliers.low);\n const medium = base.muln(multipliers.medium);\n const high = base.muln(multipliers.high);\n\n return {\n low,\n medium,\n high,\n };\n }\n\n #getMaxFees(\n baseFees: Record,\n priorityFees: Record,\n ): FeesByLevel {\n return {\n low: baseFees.low.add(priorityFees.low),\n medium: baseFees.medium.add(priorityFees.medium),\n high: baseFees.high.add(priorityFees.high),\n };\n }\n\n #feesToString(fees: FeesByLevel) {\n return Object.values(GasFeeEstimateLevel).map((level) =>\n fees[level].toString(10),\n );\n }\n}\n"]} \ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts +new file mode 100644 +index 0000000..77cbad1 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts +@@ -0,0 +1,15 @@ ++import type { Hex } from '@metamask/utils'; ++import type { RemoteTransactionSource, RemoteTransactionSourceRequest, TransactionMeta } from '../types'; ++/** ++ * A RemoteTransactionSource that fetches transaction data from Etherscan. ++ */ ++export declare class EtherscanRemoteTransactionSource implements RemoteTransactionSource { ++ #private; ++ constructor({ includeTokenTransfers, }?: { ++ includeTokenTransfers?: boolean; ++ }); ++ isSupportedNetwork(chainId: Hex): boolean; ++ getLastBlockVariations(): string[]; ++ fetchTransactions(request: RemoteTransactionSourceRequest): Promise; ++} ++//# sourceMappingURL=EtherscanRemoteTransactionSource.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +new file mode 100644 +index 0000000..e802a34 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"EtherscanRemoteTransactionSource.d.ts","sourceRoot":"","sources":["../../src/helpers/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAM3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,MAAM,UAAU,CAAC;AAclB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;gBAMtB,EACV,qBAAqB,GACtB,GAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAO;IAK3C,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAIzC,sBAAsB,IAAI,MAAM,EAAE;IAI5B,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CAmI9B"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js +new file mode 100644 +index 0000000..22a00a2 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js +@@ -0,0 +1,123 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { ++ if (kind === "m") throw new TypeError("Private method is not writable"); ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); ++ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; ++}; ++var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); ++ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); ++}; ++var _EtherscanRemoteTransactionSource_instances, _EtherscanRemoteTransactionSource_includeTokenTransfers, _EtherscanRemoteTransactionSource_isTokenRequestPending, _EtherscanRemoteTransactionSource_fetchNormalTransactions, _EtherscanRemoteTransactionSource_fetchTokenTransactions, _EtherscanRemoteTransactionSource_getResponseTransactions, _EtherscanRemoteTransactionSource_normalizeTransaction, _EtherscanRemoteTransactionSource_normalizeTokenTransaction, _EtherscanRemoteTransactionSource_normalizeTransactionBase; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.EtherscanRemoteTransactionSource = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const ethereumjs_util_1 = require("ethereumjs-util"); ++const uuid_1 = require("uuid"); ++const constants_1 = require("../constants"); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const etherscan_1 = require("../utils/etherscan"); ++/** ++ * A RemoteTransactionSource that fetches transaction data from Etherscan. ++ */ ++class EtherscanRemoteTransactionSource { ++ constructor({ includeTokenTransfers, } = {}) { ++ _EtherscanRemoteTransactionSource_instances.add(this); ++ _EtherscanRemoteTransactionSource_includeTokenTransfers.set(this, void 0); ++ _EtherscanRemoteTransactionSource_isTokenRequestPending.set(this, void 0); ++ _EtherscanRemoteTransactionSource_fetchNormalTransactions.set(this, (request, etherscanRequest) => __awaiter(this, void 0, void 0, function* () { ++ const { currentChainId } = request; ++ const etherscanTransactions = yield (0, etherscan_1.fetchEtherscanTransactions)(etherscanRequest); ++ return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransaction).call(this, tx, currentChainId)); ++ })); ++ _EtherscanRemoteTransactionSource_fetchTokenTransactions.set(this, (request, etherscanRequest) => __awaiter(this, void 0, void 0, function* () { ++ const { currentChainId } = request; ++ const etherscanTransactions = yield (0, etherscan_1.fetchEtherscanTokenTransactions)(etherscanRequest); ++ return __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_getResponseTransactions).call(this, etherscanTransactions).map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTokenTransaction).call(this, tx, currentChainId)); ++ })); ++ __classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, includeTokenTransfers !== null && includeTokenTransfers !== void 0 ? includeTokenTransfers : true, "f"); ++ __classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, false, "f"); ++ } ++ isSupportedNetwork(chainId) { ++ return Object.keys(constants_1.ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId); ++ } ++ getLastBlockVariations() { ++ return [__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal']; ++ } ++ fetchTransactions(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const etherscanRequest = Object.assign(Object.assign({}, request), { chainId: request.currentChainId }); ++ const transactions = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ++ ? yield __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchTokenTransactions, "f").call(this, request, etherscanRequest) ++ : yield __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_fetchNormalTransactions, "f").call(this, request, etherscanRequest); ++ if (__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, "f")) { ++ __classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, !__classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f"), "f"); ++ } ++ return transactions; ++ }); ++ } ++} ++exports.EtherscanRemoteTransactionSource = EtherscanRemoteTransactionSource; ++_EtherscanRemoteTransactionSource_includeTokenTransfers = new WeakMap(), _EtherscanRemoteTransactionSource_isTokenRequestPending = new WeakMap(), _EtherscanRemoteTransactionSource_fetchNormalTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_fetchTokenTransactions = new WeakMap(), _EtherscanRemoteTransactionSource_instances = new WeakSet(), _EtherscanRemoteTransactionSource_getResponseTransactions = function _EtherscanRemoteTransactionSource_getResponseTransactions(response) { ++ let result = response.result; ++ if (response.status === '0') { ++ result = []; ++ if (response.result.length) { ++ (0, logger_1.incomingTransactionsLogger)('Ignored Etherscan request error', { ++ message: response.result, ++ type: __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_isTokenRequestPending, "f") ? 'token' : 'normal', ++ }); ++ } ++ } ++ return result; ++}, _EtherscanRemoteTransactionSource_normalizeTransaction = function _EtherscanRemoteTransactionSource_normalizeTransaction(txMeta, currentChainId) { ++ const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, currentChainId); ++ return Object.assign(Object.assign(Object.assign({}, base), { txParams: Object.assign(Object.assign({}, base.txParams), { data: txMeta.input }) }), (txMeta.isError === '0' ++ ? { status: types_1.TransactionStatus.confirmed } ++ : { ++ error: new Error('Transaction failed'), ++ status: types_1.TransactionStatus.failed, ++ })); ++}, _EtherscanRemoteTransactionSource_normalizeTokenTransaction = function _EtherscanRemoteTransactionSource_normalizeTokenTransaction(txMeta, currentChainId) { ++ const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, currentChainId); ++ return Object.assign(Object.assign({}, base), { isTransfer: true, transferInformation: { ++ contractAddress: txMeta.contractAddress, ++ decimals: Number(txMeta.tokenDecimal), ++ symbol: txMeta.tokenSymbol, ++ } }); ++}, _EtherscanRemoteTransactionSource_normalizeTransactionBase = function _EtherscanRemoteTransactionSource_normalizeTransactionBase(txMeta, currentChainId) { ++ const time = parseInt(txMeta.timeStamp, 10) * 1000; ++ return { ++ blockNumber: txMeta.blockNumber, ++ chainId: currentChainId, ++ hash: txMeta.hash, ++ id: (0, uuid_1.v1)({ msecs: time }), ++ status: types_1.TransactionStatus.confirmed, ++ time, ++ txParams: { ++ chainId: currentChainId, ++ from: txMeta.from, ++ gas: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gas)), ++ gasPrice: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gasPrice)), ++ gasUsed: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.gasUsed)), ++ nonce: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.nonce)), ++ to: txMeta.to, ++ value: (0, controller_utils_1.BNToHex)(new ethereumjs_util_1.BN(txMeta.value)), ++ }, ++ type: types_1.TransactionType.incoming, ++ verifiedOnBlockchain: false, ++ }; ++}; ++//# sourceMappingURL=EtherscanRemoteTransactionSource.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js.map +new file mode 100644 +index 0000000..121a92d +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/EtherscanRemoteTransactionSource.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"EtherscanRemoteTransactionSource.js","sourceRoot":"","sources":["../../src/helpers/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAErD,qDAAqC;AACrC,+BAAoC;AAEpC,4CAA4D;AAC5D,sCAA8D;AAM9D,oCAA8D;AAC9D,kDAG4B;AAS5B;;GAEG;AACH,MAAa,gCAAgC;IAO3C,YAAY,EACV,qBAAqB,MACkB,EAAE;;QAN3C,0EAAgC;QAEhC,0EAAgC;QAoChC,oEAA2B,CACzB,OAAuC,EACvC,gBAA6C,EAC7C,EAAE;YACF,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;YAEnC,MAAM,qBAAqB,GAAG,M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CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,EAAE,uBAAe,CAAC,QAAQ;QAC9B,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import { BNToHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { BN } from 'ethereumjs-util';\nimport { v1 as random } from 'uuid';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from '../types';\nimport { TransactionStatus, TransactionType } from '../types';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from '../utils/etherscan';\nimport type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from '../utils/etherscan';\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n #includeTokenTransfers: boolean;\n\n #isTokenRequestPending: boolean;\n\n constructor({\n includeTokenTransfers,\n }: { includeTokenTransfers?: boolean } = {}) {\n this.#includeTokenTransfers = includeTokenTransfers ?? true;\n this.#isTokenRequestPending = false;\n }\n\n isSupportedNetwork(chainId: Hex): boolean {\n return Object.keys(ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId);\n }\n\n getLastBlockVariations(): string[] {\n return [this.#isTokenRequestPending ? 'token' : 'normal'];\n }\n\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise {\n const etherscanRequest: EtherscanTransactionRequest = {\n ...request,\n chainId: request.currentChainId,\n };\n\n const transactions = this.#isTokenRequestPending\n ? await this.#fetchTokenTransactions(request, etherscanRequest)\n : await this.#fetchNormalTransactions(request, etherscanRequest);\n\n if (this.#includeTokenTransfers) {\n this.#isTokenRequestPending = !this.#isTokenRequestPending;\n }\n\n return transactions;\n }\n\n #fetchNormalTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { currentChainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTransaction(tx, currentChainId),\n );\n };\n\n #fetchTokenTransactions = async (\n request: RemoteTransactionSourceRequest,\n etherscanRequest: EtherscanTransactionRequest,\n ) => {\n const { currentChainId } = request;\n\n const etherscanTransactions = await fetchEtherscanTokenTransactions(\n etherscanRequest,\n );\n\n return this.#getResponseTransactions(etherscanTransactions).map((tx) =>\n this.#normalizeTokenTransaction(tx, currentChainId),\n );\n };\n\n #getResponseTransactions(\n response: EtherscanTransactionResponse,\n ): T[] {\n let result = response.result as T[];\n\n if (response.status === '0') {\n result = [];\n\n if (response.result.length) {\n log('Ignored Etherscan request error', {\n message: response.result,\n type: this.#isTokenRequestPending ? 'token' : 'normal',\n });\n }\n }\n\n return result;\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n txParams: {\n ...base.txParams,\n data: txMeta.input,\n },\n ...(txMeta.isError === '0'\n ? { status: TransactionStatus.confirmed }\n : {\n error: new Error('Transaction failed'),\n status: TransactionStatus.failed,\n }),\n };\n }\n\n #normalizeTokenTransaction(\n txMeta: EtherscanTokenTransactionMeta,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(txMeta, currentChainId);\n\n return {\n ...base,\n isTransfer: true,\n transferInformation: {\n contractAddress: txMeta.contractAddress,\n decimals: Number(txMeta.tokenDecimal),\n symbol: txMeta.tokenSymbol,\n },\n };\n }\n\n #normalizeTransactionBase(\n txMeta: EtherscanTransactionMetaBase,\n currentChainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId: currentChainId,\n hash: txMeta.hash,\n id: random({ msecs: time }),\n status: TransactionStatus.confirmed,\n time,\n txParams: {\n chainId: currentChainId,\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 type: TransactionType.incoming,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]} +\ No newline at end of file diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts new file mode 100644 index 0000000..dfaddc5 @@ -2730,233 +2898,1292 @@ index 0000000..08b3514 @@ -0,0 +1 @@ +{"version":3,"file":"GasFeePoller.js","sourceRoot":"","sources":["../../src/helpers/GasFeePoller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAElC,2CAAqD;AAErD,sCAA0C;AAE1C,oCAAmE;AACnE,gDAAkD;AAElD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,gBAAgB,CAAC,CAAC;AAEhE,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC;;GAEG;AACH,MAAa,YAAY;IAiBvB;;;;;;;;;;OAUG;IACH,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,4BAA4B,EAC5B,eAAe,EACf,aAAa,GAQd;;QAzCD,QAAG,GAAiB,IAAI,gBAAY,EAAE,CAAC;QAEvC,4CAA2B;QAE3B,4CAA6B;QAE7B,4CAAwB;QAExB,6DAA0D;QAE1D,gDAA0C;QAE1C,wCAAc;QAEd,gCAAW,KAAK,EAAC;QA4Bf,uBAAA,IAAI,6BAAgB,WAAW,MAAA,CAAC;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AI,CAAC,GAAG,CAAC,IAAI,CACX,qBAAqB,EACrB,eAAe,EACf,2CAA2C,CAC5C,CAAC;QAEF,GAAG,CAAC,4BAA4B,EAAE;YAChC,eAAe,EAAE,eAAe,CAAC,eAAe;YAChD,WAAW,EAAE,eAAe,CAAC,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;;IAGC,MAAM,QAAQ,GAAG,uBAAA,IAAI,iCAAa,MAAjB,IAAI,CAAe,CAAC;IAErC,OAAO,uBAAA,IAAI,qCAAiB,MAArB,IAAI,CAAmB,CAAC,MAAM,CACnC,CAAC,EAAE,EAAE,EAAE,CACL,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAiB,CAAC;QACvC,EAAE,CAAC,MAAM,KAAK,yBAAiB,CAAC,UAAU,CAC7C,CAAC;AACJ,CAAC","sourcesContent":["import EventEmitter from 'events';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type { GasFeeFlow, GasFeeFlowRequest } from '../types';\nimport { TransactionStatus, type TransactionMeta } from '../types';\nimport { getGasFeeFlow } from '../utils/gas-flow';\n\nconst log = createModuleLogger(projectLogger, 'gas-fee-poller');\n\nconst INTERVAL_MILLISECONDS = 10000;\n\n/**\n * Automatically polls and updates suggested gas fees on unapproved transactions.\n */\nexport class GasFeePoller {\n hub: EventEmitter = new EventEmitter();\n\n #gasFeeFlows: GasFeeFlow[];\n\n #getChainIds: () => string[];\n\n #getEthQuery: () => any;\n\n #getGasFeeControllerEstimates: () => Promise;\n\n #getTransactions: () => TransactionMeta[];\n\n #timeout: any;\n\n #running = false;\n\n /**\n * Constructs a new instance of the GasFeePoller.\n *\n * @param options - The options for this instance.\n * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees.\n * @param options.getChainIds - Callback to specify the chain IDs to monitor.\n * @param options.getEthQuery - Callback to obtain an EthQuery instance.\n * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.\n * @param options.getTransactions - Callback to obtain the transaction data.\n * @param options.onStateChange - Callback to register a listener for controller state changes.\n */\n constructor({\n gasFeeFlows,\n getChainIds,\n getEthQuery,\n getGasFeeControllerEstimates,\n getTransactions,\n onStateChange,\n }: {\n gasFeeFlows: GasFeeFlow[];\n getChainIds: () => string[];\n getEthQuery: () => any;\n getGasFeeControllerEstimates: () => Promise;\n getTransactions: () => TransactionMeta[];\n onStateChange: (listener: () => void) => void;\n }) {\n this.#gasFeeFlows = gasFeeFlows;\n this.#getChainIds = getChainIds;\n this.#getEthQuery = getEthQuery;\n this.#getGasFeeControllerEstimates = getGasFeeControllerEstimates;\n this.#getTransactions = getTransactions;\n\n onStateChange(() => {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n if (unapprovedTransactions.length) {\n this.#start();\n } else {\n this.#stop();\n }\n });\n }\n\n #start() {\n if (this.#running) {\n return;\n }\n\n // Intentionally not awaiting since this starts the timeout chain.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#onTimeout();\n\n this.#running = true;\n\n log('Started polling');\n }\n\n #stop() {\n if (!this.#running) {\n return;\n }\n\n clearTimeout(this.#timeout);\n\n this.#timeout = undefined;\n this.#running = false;\n\n log('Stopped polling');\n }\n\n async #onTimeout() {\n await this.#updateUnapprovedTransactions();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#timeout = setTimeout(() => this.#onTimeout(), INTERVAL_MILLISECONDS);\n }\n\n async #updateUnapprovedTransactions() {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n log('Found unapproved transactions', {\n count: unapprovedTransactions.length,\n });\n\n const ethQuery = this.#getEthQuery();\n\n await Promise.all(\n unapprovedTransactions.map((tx) =>\n this.#updateTransactionSuggestedFees(tx, ethQuery),\n ),\n );\n }\n\n async #updateTransactionSuggestedFees(\n transactionMeta: TransactionMeta,\n ethQuery: any,\n ) {\n const gasFeeFlow = getGasFeeFlow(transactionMeta, this.#gasFeeFlows);\n\n if (!gasFeeFlow) {\n log('No gas fee flow found', transactionMeta.id);\n } else {\n log(\n 'Found gas fee flow',\n gasFeeFlow.constructor.name,\n transactionMeta.id,\n );\n }\n\n const request: GasFeeFlowRequest = {\n ethQuery,\n getGasFeeControllerEstimates: this.#getGasFeeControllerEstimates,\n transactionMeta,\n };\n\n if (gasFeeFlow) {\n try {\n const response = await gasFeeFlow.getGasFees(request);\n\n transactionMeta.gasFeeEstimates = response.estimates;\n } catch (error) {\n log('Failed to get suggested gas fees', transactionMeta.id, error);\n }\n }\n\n if (!gasFeeFlow && transactionMeta.gasFeeEstimatesLoaded) {\n return;\n }\n\n transactionMeta.gasFeeEstimatesLoaded = true;\n\n this.hub.emit(\n 'transaction-updated',\n transactionMeta,\n 'GasFeePoller - Suggested gas fees updated',\n );\n\n log('Updated suggested gas fees', {\n gasFeeEstimates: transactionMeta.gasFeeEstimates,\n transaction: transactionMeta.id,\n });\n }\n\n #getUnapprovedTransactions() {\n const chainIds = this.#getChainIds();\n\n return this.#getTransactions().filter(\n (tx) =>\n chainIds.includes(tx.chainId as string) &&\n tx.status === TransactionStatus.unapproved,\n );\n }\n}\n"]} \ 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 fc7f49b..b7c9355 100644 ---- a/node_modules/@metamask/transaction-controller/dist/index.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/index.d.ts -@@ -1,3 +1,5 @@ - export * from './TransactionController'; --export { isEIP1559Transaction } from './utils'; -+export { isEIP1559Transaction, normalizeTransactionParams } from './utils'; -+export * from './types'; -+export { mergeGasFeeEstimates, getGasFeeFlow } from './utils/gas-flow'; - //# 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..0818eb8 100644 ---- a/node_modules/@metamask/transaction-controller/dist/index.js -+++ b/node_modules/@metamask/transaction-controller/dist/index.js -@@ -14,8 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); - }; - Object.defineProperty(exports, "__esModule", { value: true }); --exports.isEIP1559Transaction = void 0; -+exports.getGasFeeFlow = exports.mergeGasFeeEstimates = exports.normalizeTransactionParams = exports.isEIP1559Transaction = void 0; - __exportStar(require("./TransactionController"), exports); - var utils_1 = require("./utils"); - Object.defineProperty(exports, "isEIP1559Transaction", { enumerable: true, get: function () { return utils_1.isEIP1559Transaction; } }); -+Object.defineProperty(exports, "normalizeTransactionParams", { enumerable: true, get: function () { return utils_1.normalizeTransactionParams; } }); -+__exportStar(require("./types"), exports); -+var gas_flow_1 = require("./utils/gas-flow"); -+Object.defineProperty(exports, "mergeGasFeeEstimates", { enumerable: true, get: function () { return gas_flow_1.mergeGasFeeEstimates; } }); -+Object.defineProperty(exports, "getGasFeeFlow", { enumerable: true, get: function () { return gas_flow_1.getGasFeeFlow; } }); - //# sourceMappingURL=index.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/index.js.map b/node_modules/@metamask/transaction-controller/dist/index.js.map -deleted file mode 100644 -index a4460fa..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/index.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA","sourcesContent":["export * from './TransactionController';\nexport { isEIP1559Transaction } from './utils';\n"]} +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts +new file mode 100644 +index 0000000..3716ebf +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts +@@ -0,0 +1,25 @@ ++/// ++import type { BlockTracker, NetworkState } from '@metamask/network-controller'; ++import type { Hex } from '@metamask/utils'; ++import EventEmitter from 'events'; ++import type { RemoteTransactionSource, TransactionMeta } from '../types'; ++export declare class IncomingTransactionHelper { ++ #private; ++ hub: EventEmitter; ++ constructor({ blockTracker, getCurrentAccount, getLastFetchedBlockNumbers, getLocalTransactions, getNetworkState, isEnabled, queryEntireHistory, remoteTransactionSource, transactionLimit, updateTransactions, }: { ++ blockTracker: BlockTracker; ++ getCurrentAccount: () => string; ++ getLastFetchedBlockNumbers: () => Record; ++ getLocalTransactions?: () => TransactionMeta[]; ++ getNetworkState: () => NetworkState; ++ isEnabled?: () => boolean; ++ queryEntireHistory?: boolean; ++ remoteTransactionSource: RemoteTransactionSource; ++ transactionLimit?: number; ++ updateTransactions?: boolean; ++ }); ++ start(): void; ++ stop(): void; ++ update(latestBlockNumberHex?: Hex): Promise; ++} ++//# sourceMappingURL=IncomingTransactionHelper.d.ts.map \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/logger.d.ts b/node_modules/@metamask/transaction-controller/dist/logger.d.ts +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts.map new file mode 100644 -index 0000000..43ad63f +index 0000000..ba41d04 --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/logger.d.ts -@@ -0,0 +1,6 @@ -+/// -+import { createModuleLogger } from '@metamask/utils'; -+export declare const projectLogger: import("debug").Debugger; -+export declare const incomingTransactionsLogger: import("debug").Debugger; -+export { createModuleLogger }; -+//# sourceMappingURL=logger.d.ts.map ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"IncomingTransactionHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/IncomingTransactionHelper.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,YAAY,MAAM,QAAQ,CAAC;AAGlC,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAWzE,qBAAa,yBAAyB;;IACpC,GAAG,EAAE,YAAY,CAAC;gBA4BN,EACV,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,GACnB,EAAE;QACD,YAAY,EAAE,YAAY,CAAC;QAC3B,iBAAiB,EAAE,MAAM,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzD,oBAAoB,CAAC,EAAE,MAAM,eAAe,EAAE,CAAC;QAC/C,eAAe,EAAE,MAAM,YAAY,CAAC;QACpC,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC;QAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,uBAAuB,EAAE,uBAAuB,CAAC;QACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B;IA0BD,KAAK;IAaL,IAAI;IAKE,MAAM,CAAC,oBAAoB,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAqMxD"} \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/logger.js b/node_modules/@metamask/transaction-controller/dist/logger.js +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js new file mode 100644 -index 0000000..bb55b17 +index 0000000..68b3070 --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/logger.js -@@ -0,0 +1,9 @@ ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js +@@ -0,0 +1,202 @@ +"use strict"; -+/* istanbul ignore file */ ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { ++ if (kind === "m") throw new TypeError("Private method is not writable"); ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); ++ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; ++}; ++var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); ++ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); ++}; ++var __importDefault = (this && this.__importDefault) || function (mod) { ++ return (mod && mod.__esModule) ? mod : { "default": mod }; ++}; ++var _IncomingTransactionHelper_instances, _IncomingTransactionHelper_blockTracker, _IncomingTransactionHelper_getCurrentAccount, _IncomingTransactionHelper_getLastFetchedBlockNumbers, _IncomingTransactionHelper_getLocalTransactions, _IncomingTransactionHelper_getNetworkState, _IncomingTransactionHelper_isEnabled, _IncomingTransactionHelper_isRunning, _IncomingTransactionHelper_mutex, _IncomingTransactionHelper_onLatestBlock, _IncomingTransactionHelper_queryEntireHistory, _IncomingTransactionHelper_remoteTransactionSource, _IncomingTransactionHelper_transactionLimit, _IncomingTransactionHelper_updateTransactions, _IncomingTransactionHelper_sortTransactionsByTime, _IncomingTransactionHelper_getNewTransactions, _IncomingTransactionHelper_getUpdatedTransactions, _IncomingTransactionHelper_isTransactionOutdated, _IncomingTransactionHelper_getFromBlock, _IncomingTransactionHelper_updateLastFetchedBlockNumber, _IncomingTransactionHelper_getBlockNumberKey, _IncomingTransactionHelper_canStart, _IncomingTransactionHelper_getCurrentChainId; +Object.defineProperty(exports, "__esModule", { value: true }); -+exports.createModuleLogger = exports.incomingTransactionsLogger = exports.projectLogger = void 0; -+const utils_1 = require("@metamask/utils"); -+Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } }); -+exports.projectLogger = (0, utils_1.createProjectLogger)('transaction-controller'); -+exports.incomingTransactionsLogger = (0, utils_1.createModuleLogger)(exports.projectLogger, 'incoming-transactions'); -+//# sourceMappingURL=logger.js.map -\ 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 688af82..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts -+++ /dev/null -@@ -1,64 +0,0 @@ --import { TransactionMeta } from '../TransactionController'; --export declare const ethTxsMock: (ethTxHash: string) => ({ -- blockNumber: string; -- confirmations: string; -- contractAddress: string; -- cumulativeGasUsed: string; -- from: string; -- gas: string; -- gasPrice: string; -- gasUsed: string; -- hash: string; -- input: string; -- isError: string; -- nonce: string; -- timeStamp: string; -- to: string; -- transactionIndex: string; -- txreceipt_status: string; -- value: string; --} | { -- blockNumber: string; -- confirmations: string; -- contractAddress: string; -- cumulativeGasUsed: string; -- from: string; -- gas: string; -- gasPrice: string; -- gasUsed: string; -- hash: string; -- input: string; -- isError: string; -- nonce: string; -- timeStamp: string; -- transactionIndex: string; -- txreceipt_status: string; -- value: string; -- to?: undefined; --})[]; --export declare const tokenTxsMock: (tokenTxHash: string) => { -- blockNumber: string; -- timeStamp: string; -- hash: string; -- nonce: string; -- blockHash: string; -- from: string; -- contractAddress: string; -- to: string; -- value: string; -- tokenName: string; -- tokenSymbol: string; -- tokenDecimal: string; -- transactionIndex: string; -- gas: string; -- gasPrice: string; -- gasUsed: string; -- cumulativeGasUsed: string; -- input: string; -- confirmations: string; --}[]; --export declare const txsInStateMock: (ethTxHash: string, tokenTxHash: string) => TransactionMeta[]; --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 ++exports.IncomingTransactionHelper = void 0; ++const async_mutex_1 = require("async-mutex"); ++const events_1 = __importDefault(require("events")); ++const logger_1 = require("../logger"); ++const RECENT_HISTORY_BLOCK_RANGE = 10; ++// TODO: Replace `any` with type ++// eslint-disable-next-line @typescript-eslint/no-explicit-any ++const UPDATE_CHECKS = [ ++ (txMeta) => txMeta.status, ++ (txMeta) => txMeta.txParams.gasUsed, ++]; ++class IncomingTransactionHelper { ++ constructor({ blockTracker, getCurrentAccount, getLastFetchedBlockNumbers, getLocalTransactions, getNetworkState, isEnabled, queryEntireHistory, remoteTransactionSource, transactionLimit, updateTransactions, }) { ++ _IncomingTransactionHelper_instances.add(this); ++ _IncomingTransactionHelper_blockTracker.set(this, void 0); ++ _IncomingTransactionHelper_getCurrentAccount.set(this, void 0); ++ _IncomingTransactionHelper_getLastFetchedBlockNumbers.set(this, void 0); ++ _IncomingTransactionHelper_getLocalTransactions.set(this, void 0); ++ _IncomingTransactionHelper_getNetworkState.set(this, void 0); ++ _IncomingTransactionHelper_isEnabled.set(this, void 0); ++ _IncomingTransactionHelper_isRunning.set(this, void 0); ++ _IncomingTransactionHelper_mutex.set(this, new async_mutex_1.Mutex()); ++ _IncomingTransactionHelper_onLatestBlock.set(this, void 0); ++ _IncomingTransactionHelper_queryEntireHistory.set(this, void 0); ++ _IncomingTransactionHelper_remoteTransactionSource.set(this, void 0); ++ _IncomingTransactionHelper_transactionLimit.set(this, void 0); ++ _IncomingTransactionHelper_updateTransactions.set(this, void 0); ++ this.hub = new events_1.default(); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_blockTracker, blockTracker, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_getCurrentAccount, getCurrentAccount, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_getLastFetchedBlockNumbers, getLastFetchedBlockNumbers, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_getLocalTransactions, getLocalTransactions || (() => []), "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_getNetworkState, getNetworkState, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_isEnabled, isEnabled !== null && isEnabled !== void 0 ? isEnabled : (() => true), "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_isRunning, false, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_queryEntireHistory, queryEntireHistory !== null && queryEntireHistory !== void 0 ? queryEntireHistory : true, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_remoteTransactionSource, remoteTransactionSource, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_transactionLimit, transactionLimit, "f"); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_updateTransactions, updateTransactions !== null && updateTransactions !== void 0 ? updateTransactions : false, "f"); ++ // Using a property instead of a method to provide a listener reference ++ // with the correct scope that we can remove later if stopped. ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_onLatestBlock, (blockNumberHex) => __awaiter(this, void 0, void 0, function* () { ++ try { ++ yield this.update(blockNumberHex); ++ } ++ catch (error) { ++ console.error('Error while checking incoming transactions', error); ++ } ++ }), "f"); ++ } ++ start() { ++ if (__classPrivateFieldGet(this, _IncomingTransactionHelper_isRunning, "f")) { ++ return; ++ } ++ if (!__classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_canStart).call(this)) { ++ return; ++ } ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_blockTracker, "f").addListener('latest', __classPrivateFieldGet(this, _IncomingTransactionHelper_onLatestBlock, "f")); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_isRunning, true, "f"); ++ } ++ stop() { ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_blockTracker, "f").removeListener('latest', __classPrivateFieldGet(this, _IncomingTransactionHelper_onLatestBlock, "f")); ++ __classPrivateFieldSet(this, _IncomingTransactionHelper_isRunning, false, "f"); ++ } ++ update(latestBlockNumberHex) { ++ var _a, _b, _c; ++ return __awaiter(this, void 0, void 0, function* () { ++ const releaseLock = yield __classPrivateFieldGet(this, _IncomingTransactionHelper_mutex, "f").acquire(); ++ (0, logger_1.incomingTransactionsLogger)('Checking for incoming transactions'); ++ try { ++ if (!__classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_canStart).call(this)) { ++ return; ++ } ++ const latestBlockNumber = parseInt(latestBlockNumberHex || (yield __classPrivateFieldGet(this, _IncomingTransactionHelper_blockTracker, "f").getLatestBlock()), 16); ++ const additionalLastFetchedKeys = (_c = (_b = (_a = __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f")).getLastBlockVariations) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : []; ++ const fromBlock = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getFromBlock).call(this, latestBlockNumber, additionalLastFetchedKeys); ++ const address = __classPrivateFieldGet(this, _IncomingTransactionHelper_getCurrentAccount, "f").call(this); ++ const currentChainId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentChainId).call(this); ++ let remoteTransactions = []; ++ try { ++ remoteTransactions = ++ yield __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f").fetchTransactions({ ++ address, ++ currentChainId, ++ fromBlock, ++ limit: __classPrivateFieldGet(this, _IncomingTransactionHelper_transactionLimit, "f"), ++ }); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ } ++ catch (error) { ++ (0, logger_1.incomingTransactionsLogger)('Error while fetching remote transactions', error); ++ return; ++ } ++ if (!__classPrivateFieldGet(this, _IncomingTransactionHelper_updateTransactions, "f")) { ++ remoteTransactions = remoteTransactions.filter((tx) => { var _a; return ((_a = tx.txParams.to) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === address.toLowerCase(); }); ++ } ++ const localTransactions = !__classPrivateFieldGet(this, _IncomingTransactionHelper_updateTransactions, "f") ++ ? [] ++ : __classPrivateFieldGet(this, _IncomingTransactionHelper_getLocalTransactions, "f").call(this); ++ const newTransactions = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getNewTransactions).call(this, remoteTransactions, localTransactions); ++ const updatedTransactions = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getUpdatedTransactions).call(this, remoteTransactions, localTransactions); ++ if (newTransactions.length > 0 || updatedTransactions.length > 0) { ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_sortTransactionsByTime).call(this, newTransactions); ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_sortTransactionsByTime).call(this, updatedTransactions); ++ (0, logger_1.incomingTransactionsLogger)('Found incoming transactions', { ++ new: newTransactions, ++ updated: updatedTransactions, ++ }); ++ this.hub.emit('transactions', { ++ added: newTransactions, ++ updated: updatedTransactions, ++ }); ++ } ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_updateLastFetchedBlockNumber).call(this, remoteTransactions, additionalLastFetchedKeys); ++ } ++ finally { ++ releaseLock(); ++ } ++ }); ++ } ++} ++exports.IncomingTransactionHelper = IncomingTransactionHelper; ++_IncomingTransactionHelper_blockTracker = new WeakMap(), _IncomingTransactionHelper_getCurrentAccount = new WeakMap(), _IncomingTransactionHelper_getLastFetchedBlockNumbers = new WeakMap(), _IncomingTransactionHelper_getLocalTransactions = new WeakMap(), _IncomingTransactionHelper_getNetworkState = new WeakMap(), _IncomingTransactionHelper_isEnabled = new WeakMap(), _IncomingTransactionHelper_isRunning = new WeakMap(), _IncomingTransactionHelper_mutex = new WeakMap(), _IncomingTransactionHelper_onLatestBlock = new WeakMap(), _IncomingTransactionHelper_queryEntireHistory = new WeakMap(), _IncomingTransactionHelper_remoteTransactionSource = new WeakMap(), _IncomingTransactionHelper_transactionLimit = new WeakMap(), _IncomingTransactionHelper_updateTransactions = new WeakMap(), _IncomingTransactionHelper_instances = new WeakSet(), _IncomingTransactionHelper_sortTransactionsByTime = function _IncomingTransactionHelper_sortTransactionsByTime(transactions) { ++ transactions.sort((a, b) => (a.time < b.time ? -1 : 1)); ++}, _IncomingTransactionHelper_getNewTransactions = function _IncomingTransactionHelper_getNewTransactions(remoteTxs, localTxs) { ++ return remoteTxs.filter((tx) => !localTxs.some(({ hash }) => hash === tx.hash)); ++}, _IncomingTransactionHelper_getUpdatedTransactions = function _IncomingTransactionHelper_getUpdatedTransactions(remoteTxs, localTxs) { ++ return remoteTxs.filter((remoteTx) => localTxs.some((localTx) => remoteTx.hash === localTx.hash && ++ __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_isTransactionOutdated).call(this, remoteTx, localTx))); ++}, _IncomingTransactionHelper_isTransactionOutdated = function _IncomingTransactionHelper_isTransactionOutdated(remoteTx, localTx) { ++ return UPDATE_CHECKS.some((getValue) => getValue(remoteTx) !== getValue(localTx)); ++}, _IncomingTransactionHelper_getFromBlock = function _IncomingTransactionHelper_getFromBlock(latestBlockNumber, additionalKeys) { ++ const lastFetchedKey = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getBlockNumberKey).call(this, additionalKeys); ++ const lastFetchedBlockNumber = __classPrivateFieldGet(this, _IncomingTransactionHelper_getLastFetchedBlockNumbers, "f").call(this)[lastFetchedKey]; ++ if (lastFetchedBlockNumber) { ++ return lastFetchedBlockNumber + 1; ++ } ++ return __classPrivateFieldGet(this, _IncomingTransactionHelper_queryEntireHistory, "f") ++ ? undefined ++ : latestBlockNumber - RECENT_HISTORY_BLOCK_RANGE; ++}, _IncomingTransactionHelper_updateLastFetchedBlockNumber = function _IncomingTransactionHelper_updateLastFetchedBlockNumber(remoteTxs, additionalKeys) { ++ let lastFetchedBlockNumber = -1; ++ for (const tx of remoteTxs) { ++ const currentBlockNumberValue = tx.blockNumber ++ ? parseInt(tx.blockNumber, 10) ++ : -1; ++ lastFetchedBlockNumber = Math.max(lastFetchedBlockNumber, currentBlockNumberValue); ++ } ++ if (lastFetchedBlockNumber === -1) { ++ return; ++ } ++ const lastFetchedKey = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getBlockNumberKey).call(this, additionalKeys); ++ const lastFetchedBlockNumbers = __classPrivateFieldGet(this, _IncomingTransactionHelper_getLastFetchedBlockNumbers, "f").call(this); ++ const previousValue = lastFetchedBlockNumbers[lastFetchedKey]; ++ if (previousValue >= lastFetchedBlockNumber) { ++ return; ++ } ++ lastFetchedBlockNumbers[lastFetchedKey] = lastFetchedBlockNumber; ++ this.hub.emit('updatedLastFetchedBlockNumbers', { ++ lastFetchedBlockNumbers, ++ blockNumber: lastFetchedBlockNumber, ++ }); ++}, _IncomingTransactionHelper_getBlockNumberKey = function _IncomingTransactionHelper_getBlockNumberKey(additionalKeys) { ++ const currentChainId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentChainId).call(this); ++ const currentAccount = __classPrivateFieldGet(this, _IncomingTransactionHelper_getCurrentAccount, "f").call(this).toLowerCase(); ++ return [currentChainId, currentAccount, ...additionalKeys].join('#'); ++}, _IncomingTransactionHelper_canStart = function _IncomingTransactionHelper_canStart() { ++ const isEnabled = __classPrivateFieldGet(this, _IncomingTransactionHelper_isEnabled, "f").call(this); ++ const currentChainId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentChainId).call(this); ++ const isSupportedNetwork = __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f").isSupportedNetwork(currentChainId); ++ return isEnabled && isSupportedNetwork; ++}, _IncomingTransactionHelper_getCurrentChainId = function _IncomingTransactionHelper_getCurrentChainId() { ++ return __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).providerConfig.chainId; ++}; ++//# sourceMappingURL=IncomingTransactionHelper.js.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 c9350fa..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":"AACA,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"} +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js.map +new file mode 100644 +index 0000000..b7780b4 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/IncomingTransactionHelper.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"IncomingTransactionHelper.js","sourceRoot":"","sources":["../../src/helpers/IncomingTransactionHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAAoC;AACpC,oDAAkC;AAElC,sCAA8D;AAG9D,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAEtC,gCAAgC;AAChC,8DAA8D;AAC9D,MAAM,aAAa,GAAyC;IAC1D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM;IACzB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO;CACpC,CAAC;AAEF,MAAa,yBAAyB;IA6BpC,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B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B,EAAE;QAC3C,OAAO;KACR;IAED,uBAAuB,CAAC,cAAc,CAAC,GAAG,sBAAsB,CAAC;IAEjE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE;QAC9C,uBAAuB;QACvB,WAAW,EAAE,sBAAsB;KACpC,CAAC,CAAC;AACL,CAAC,uGAEkB,cAAwB;IACzC,MAAM,cAAc,GAAG,uBAAA,IAAI,0FAAmB,MAAvB,IAAI,CAAqB,CAAC;IACjD,MAAM,cAAc,GAAG,uBAAA,IAAI,oDAAmB,MAAvB,IAAI,CAAqB,CAAC,WAAW,EAAE,CAAC;IAE/D,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvE,CAAC;IAGC,MAAM,SAAS,GAAG,uBAAA,IAAI,4CAAW,MAAf,IAAI,CAAa,CAAC;IACpC,MAAM,cAAc,GAAG,uBAAA,IAAI,0FAAmB,MAAvB,IAAI,CAAqB,CAAC;IAEjD,MAAM,kBAAkB,GACtB,uBAAA,IAAI,0DAAyB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAEnE,OAAO,SAAS,IAAI,kBAAkB,CAAC;AACzC,CAAC;IAGC,OAAO,uBAAA,IAAI,kDAAiB,MAArB,IAAI,CAAmB,CAAC,cAAc,CAAC,OAAO,CAAC;AACxD,CAAC","sourcesContent":["import type { BlockTracker, NetworkState } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport EventEmitter from 'events';\n\nimport { incomingTransactionsLogger as log } from '../logger';\nimport type { RemoteTransactionSource, TransactionMeta } from '../types';\n\nconst RECENT_HISTORY_BLOCK_RANGE = 10;\n\n// TODO: Replace `any` with type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst UPDATE_CHECKS: ((txMeta: TransactionMeta) => any)[] = [\n (txMeta) => txMeta.status,\n (txMeta) => txMeta.txParams.gasUsed,\n];\n\nexport class IncomingTransactionHelper {\n hub: EventEmitter;\n\n #blockTracker: BlockTracker;\n\n #getCurrentAccount: () => string;\n\n #getLastFetchedBlockNumbers: () => Record;\n\n #getLocalTransactions: () => TransactionMeta[];\n\n #getNetworkState: () => NetworkState;\n\n #isEnabled: () => boolean;\n\n #isRunning: boolean;\n\n #mutex = new Mutex();\n\n #onLatestBlock: (blockNumberHex: Hex) => Promise;\n\n #queryEntireHistory: boolean;\n\n #remoteTransactionSource: RemoteTransactionSource;\n\n #transactionLimit?: number;\n\n #updateTransactions: boolean;\n\n constructor({\n blockTracker,\n getCurrentAccount,\n getLastFetchedBlockNumbers,\n getLocalTransactions,\n getNetworkState,\n isEnabled,\n queryEntireHistory,\n remoteTransactionSource,\n transactionLimit,\n updateTransactions,\n }: {\n blockTracker: BlockTracker;\n getCurrentAccount: () => string;\n getLastFetchedBlockNumbers: () => Record;\n getLocalTransactions?: () => TransactionMeta[];\n getNetworkState: () => NetworkState;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n remoteTransactionSource: RemoteTransactionSource;\n transactionLimit?: number;\n updateTransactions?: boolean;\n }) {\n this.hub = new EventEmitter();\n\n this.#blockTracker = blockTracker;\n this.#getCurrentAccount = getCurrentAccount;\n this.#getLastFetchedBlockNumbers = getLastFetchedBlockNumbers;\n this.#getLocalTransactions = getLocalTransactions || (() => []);\n this.#getNetworkState = getNetworkState;\n this.#isEnabled = isEnabled ?? (() => true);\n this.#isRunning = false;\n this.#queryEntireHistory = queryEntireHistory ?? true;\n this.#remoteTransactionSource = remoteTransactionSource;\n this.#transactionLimit = transactionLimit;\n this.#updateTransactions = updateTransactions ?? false;\n\n // Using a property instead of a method to provide a listener reference\n // with the correct scope that we can remove later if stopped.\n this.#onLatestBlock = async (blockNumberHex: Hex) => {\n try {\n await this.update(blockNumberHex);\n } catch (error) {\n console.error('Error while checking incoming transactions', error);\n }\n };\n }\n\n start() {\n if (this.#isRunning) {\n return;\n }\n\n if (!this.#canStart()) {\n return;\n }\n\n this.#blockTracker.addListener('latest', this.#onLatestBlock);\n this.#isRunning = true;\n }\n\n stop() {\n this.#blockTracker.removeListener('latest', this.#onLatestBlock);\n this.#isRunning = false;\n }\n\n async update(latestBlockNumberHex?: Hex): Promise {\n const releaseLock = await this.#mutex.acquire();\n\n log('Checking for incoming transactions');\n\n try {\n if (!this.#canStart()) {\n return;\n }\n\n const latestBlockNumber = parseInt(\n latestBlockNumberHex || (await this.#blockTracker.getLatestBlock()),\n 16,\n );\n\n const additionalLastFetchedKeys =\n this.#remoteTransactionSource.getLastBlockVariations?.() ?? [];\n\n const fromBlock = this.#getFromBlock(\n latestBlockNumber,\n additionalLastFetchedKeys,\n );\n\n const address = this.#getCurrentAccount();\n const currentChainId = this.#getCurrentChainId();\n\n let remoteTransactions = [];\n\n try {\n remoteTransactions =\n await this.#remoteTransactionSource.fetchTransactions({\n address,\n currentChainId,\n fromBlock,\n limit: this.#transactionLimit,\n });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n log('Error while fetching remote transactions', error);\n return;\n }\n\n if (!this.#updateTransactions) {\n remoteTransactions = remoteTransactions.filter(\n (tx) => tx.txParams.to?.toLowerCase() === address.toLowerCase(),\n );\n }\n\n const localTransactions = !this.#updateTransactions\n ? []\n : this.#getLocalTransactions();\n\n const newTransactions = this.#getNewTransactions(\n remoteTransactions,\n localTransactions,\n );\n\n const updatedTransactions = this.#getUpdatedTransactions(\n remoteTransactions,\n localTransactions,\n );\n\n if (newTransactions.length > 0 || updatedTransactions.length > 0) {\n this.#sortTransactionsByTime(newTransactions);\n this.#sortTransactionsByTime(updatedTransactions);\n\n log('Found incoming transactions', {\n new: newTransactions,\n updated: updatedTransactions,\n });\n\n this.hub.emit('transactions', {\n added: newTransactions,\n updated: updatedTransactions,\n });\n }\n\n this.#updateLastFetchedBlockNumber(\n remoteTransactions,\n additionalLastFetchedKeys,\n );\n } finally {\n releaseLock();\n }\n }\n\n #sortTransactionsByTime(transactions: TransactionMeta[]) {\n transactions.sort((a, b) => (a.time < b.time ? -1 : 1));\n }\n\n #getNewTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter(\n (tx) => !localTxs.some(({ hash }) => hash === tx.hash),\n );\n }\n\n #getUpdatedTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((remoteTx) =>\n localTxs.some(\n (localTx) =>\n remoteTx.hash === localTx.hash &&\n this.#isTransactionOutdated(remoteTx, localTx),\n ),\n );\n }\n\n #isTransactionOutdated(\n remoteTx: TransactionMeta,\n localTx: TransactionMeta,\n ): boolean {\n return UPDATE_CHECKS.some(\n (getValue) => getValue(remoteTx) !== getValue(localTx),\n );\n }\n\n #getFromBlock(\n latestBlockNumber: number,\n additionalKeys: string[],\n ): number | undefined {\n const lastFetchedKey = this.#getBlockNumberKey(additionalKeys);\n\n const lastFetchedBlockNumber =\n this.#getLastFetchedBlockNumbers()[lastFetchedKey];\n\n if (lastFetchedBlockNumber) {\n return lastFetchedBlockNumber + 1;\n }\n\n return this.#queryEntireHistory\n ? undefined\n : latestBlockNumber - RECENT_HISTORY_BLOCK_RANGE;\n }\n\n #updateLastFetchedBlockNumber(\n remoteTxs: TransactionMeta[],\n additionalKeys: string[],\n ) {\n let lastFetchedBlockNumber = -1;\n\n for (const tx of remoteTxs) {\n const currentBlockNumberValue = tx.blockNumber\n ? parseInt(tx.blockNumber, 10)\n : -1;\n\n lastFetchedBlockNumber = Math.max(\n lastFetchedBlockNumber,\n currentBlockNumberValue,\n );\n }\n\n if (lastFetchedBlockNumber === -1) {\n return;\n }\n\n const lastFetchedKey = this.#getBlockNumberKey(additionalKeys);\n const lastFetchedBlockNumbers = this.#getLastFetchedBlockNumbers();\n const previousValue = lastFetchedBlockNumbers[lastFetchedKey];\n\n if (previousValue >= lastFetchedBlockNumber) {\n return;\n }\n\n lastFetchedBlockNumbers[lastFetchedKey] = lastFetchedBlockNumber;\n\n this.hub.emit('updatedLastFetchedBlockNumbers', {\n lastFetchedBlockNumbers,\n blockNumber: lastFetchedBlockNumber,\n });\n }\n\n #getBlockNumberKey(additionalKeys: string[]): string {\n const currentChainId = this.#getCurrentChainId();\n const currentAccount = this.#getCurrentAccount().toLowerCase();\n\n return [currentChainId, currentAccount, ...additionalKeys].join('#');\n }\n\n #canStart(): boolean {\n const isEnabled = this.#isEnabled();\n const currentChainId = this.#getCurrentChainId();\n\n const isSupportedNetwork =\n this.#remoteTransactionSource.isSupportedNetwork(currentChainId);\n\n return isEnabled && isSupportedNetwork;\n }\n\n #getCurrentChainId(): Hex {\n return this.#getNetworkState().providerConfig.chainId;\n }\n}\n"]} \ 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 d17aabf..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js -+++ /dev/null -@@ -1,516 +0,0 @@ --"use strict"; --Object.defineProperty(exports, "__esModule", { value: true }); --exports.txsInStateWithOutdatedStatusAndGasDataMock = exports.txsInStateWithOutdatedGasDataMock = exports.txsInStateWithOutdatedStatusMock = exports.txsInStateMock = exports.tokenTxsMock = exports.ethTxsMock = void 0; --const controller_utils_1 = require("@metamask/controller-utils"); --const TransactionController_1 = require("../TransactionController"); --const ethTxsMock = (ethTxHash) => [ -- { -- blockNumber: '4535101', -- confirmations: '10', -- contractAddress: '', -- cumulativeGasUsed: '120607', -- from: '0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1', -- gas: '335208', -- gasPrice: '10000000000', -- gasUsed: '21000', -- hash: ethTxHash, -- input: '0x', -- isError: '0', -- nonce: '9', -- timeStamp: '1543596286', -- to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', -- transactionIndex: '2', -- txreceipt_status: '1', -- value: '100000000000000000', -- }, -- { -- blockNumber: '4535108', -- confirmations: '3', -- contractAddress: '', -- cumulativeGasUsed: '693910', -- from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', -- gas: '335208', -- gasPrice: '20000000000', -- gasUsed: '21000', -- hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff92', -- input: '0x', -- isError: '0', -- nonce: '0', -- timeStamp: '1543596378', -- to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23', -- transactionIndex: '12', -- txreceipt_status: '1', -- value: '50000000000000000', -- }, -- { -- blockNumber: '4535105', -- confirmations: '4', -- contractAddress: '', -- cumulativeGasUsed: '693910', -- from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', -- gas: '335208', -- gasPrice: '20000000000', -- gasUsed: '21000', -- hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff91', -- input: '0x', -- isError: '0', -- nonce: '1', -- timeStamp: '1543596356', -- transactionIndex: '13', -- txreceipt_status: '1', -- value: '50000000000000000', -- }, -- { -- blockNumber: '4535106', -- confirmations: '4', +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts +new file mode 100644 +index 0000000..0541964 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts +@@ -0,0 +1,72 @@ ++import EthQuery from '@metamask/eth-query'; ++import type { NetworkClientId, NetworkController, BlockTracker, Provider, NetworkControllerStateChangeEvent } from '@metamask/network-controller'; ++import type { Hex } from '@metamask/utils'; ++import type { NonceLock, NonceTracker } from 'nonce-tracker'; ++import { EtherscanRemoteTransactionSource } from './EtherscanRemoteTransactionSource'; ++import type { IncomingTransactionHelper, IncomingTransactionOptions } from './IncomingTransactionHelper'; ++import type { PendingTransactionTracker } from './PendingTransactionTracker'; ++export declare type MultichainTrackingHelperOptions = { ++ isMultichainEnabled: boolean; ++ provider: Provider; ++ nonceTracker: NonceTracker; ++ incomingTransactionOptions: IncomingTransactionOptions; ++ findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId']; ++ getNetworkClientById: NetworkController['getNetworkClientById']; ++ getNetworkClientRegistry: NetworkController['getNetworkClientRegistry']; ++ removeIncomingTransactionHelperListeners: (IncomingTransactionHelper: IncomingTransactionHelper) => void; ++ removePendingTransactionTrackerListeners: (pendingTransactionTracker: PendingTransactionTracker) => void; ++ createNonceTracker: (opts: { ++ provider: Provider; ++ blockTracker: BlockTracker; ++ chainId?: Hex; ++ }) => NonceTracker; ++ createIncomingTransactionHelper: (opts: { ++ blockTracker: BlockTracker; ++ etherscanRemoteTransactionSource: EtherscanRemoteTransactionSource; ++ chainId?: Hex; ++ }) => IncomingTransactionHelper; ++ createPendingTransactionTracker: (opts: { ++ provider: Provider; ++ blockTracker: BlockTracker; ++ chainId?: Hex; ++ }) => PendingTransactionTracker; ++ onNetworkStateChange: (listener: (...payload: NetworkControllerStateChangeEvent['payload']) => void) => void; ++}; ++export declare class MultichainTrackingHelper { ++ #private; ++ constructor({ isMultichainEnabled, provider, nonceTracker, incomingTransactionOptions, findNetworkClientIdByChainId, getNetworkClientById, getNetworkClientRegistry, removeIncomingTransactionHelperListeners, removePendingTransactionTrackerListeners, createNonceTracker, createIncomingTransactionHelper, createPendingTransactionTracker, onNetworkStateChange, }: MultichainTrackingHelperOptions); ++ initialize(): void; ++ has(networkClientId: NetworkClientId): boolean; ++ getEthQuery({ networkClientId, chainId, }?: { ++ networkClientId?: NetworkClientId; ++ chainId?: Hex; ++ }): EthQuery; ++ /** ++ * Gets the mutex intended to guard the nonceTracker for a particular chainId and key . ++ * ++ * @param opts - The options object. ++ * @param opts.chainId - The hex chainId. ++ * @param opts.key - The hex address (or constant) pertaining to the chainId ++ * @returns Mutex instance for the given chainId and key pair ++ */ ++ acquireNonceLockForChainIdKey({ chainId, key, }: { ++ chainId: Hex; ++ key?: string; ++ }): Promise<() => void>; ++ /** ++ * Gets the next nonce according to the nonce-tracker. ++ * Ensure `releaseLock` is called once processing of the `nonce` value is complete. ++ * ++ * @param address - The hex string address for the transaction. ++ * @param networkClientId - The network client ID for the transaction, used to fetch the correct nonce tracker. ++ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock. ++ */ ++ getNonceLock(address: string, networkClientId?: NetworkClientId): Promise; ++ startIncomingTransactionPolling(networkClientIds?: NetworkClientId[]): void; ++ stopIncomingTransactionPolling(networkClientIds?: NetworkClientId[]): void; ++ stopAllIncomingTransactionPolling(): void; ++ updateIncomingTransactions(networkClientIds?: NetworkClientId[]): Promise; ++ checkForPendingTransactionAndStartPolling: () => void; ++ stopAllTracking(): void; ++} ++//# sourceMappingURL=MultichainTrackingHelper.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts.map +new file mode 100644 +index 0000000..3cb1f3c +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"MultichainTrackingHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/MultichainTrackingHelper.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAEjB,YAAY,EACZ,QAAQ,EACR,iCAAiC,EAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAA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oBAAoB,EACpB,wBAAwB,EACxB,wCAAwC,EACxC,wCAAwC,EACxC,kBAAkB,EAClB,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,GACrB,EAAE,+BAA+B;IAiClC,UAAU;IAQV,GAAG,CAAC,eAAe,EAAE,eAAe;IAIpC,WAAW,CAAC,EACV,eAAe,EACf,OAAO,GACR,GAAE;QACD,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,OAAO,CAAC,EAAE,GAAG,CAAC;KACV,GAAG,QAAQ;IAgCjB;;;;;;;OAOG;IACG,6BAA6B,CAAC,EAClC,OAAO,EACP,GAAc,GACf,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAevB;;;;;;;OAOG;IACG,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,SAAS,CAAC;IAmCrB,+BAA+B,CAAC,gBAAgB,GAAE,eAAe,EAAO;IAMxE,8BAA8B,CAAC,gBAAgB,GAAE,eAAe,EAAO;IAMvE,iCAAiC;IAM3B,0BAA0B,CAAC,gBAAgB,GAAE,eAAe,EAAO;IAmBzE,yCAAyC,aAIvC;IAEF,eAAe;CAmHhB"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js +new file mode 100644 +index 0000000..237e8a0 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js +@@ -0,0 +1,292 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { ++ if (kind === "m") throw new TypeError("Private method is not writable"); ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); ++ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; ++}; ++var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); ++ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); ++}; ++var __importDefault = (this && this.__importDefault) || function (mod) { ++ return (mod && mod.__esModule) ? mod : { "default": mod }; ++}; ++var _MultichainTrackingHelper_instances, _MultichainTrackingHelper_isMultichainEnabled, _MultichainTrackingHelper_provider, _MultichainTrackingHelper_nonceTracker, _MultichainTrackingHelper_incomingTransactionOptions, _MultichainTrackingHelper_findNetworkClientIdByChainId, _MultichainTrackingHelper_getNetworkClientById, _MultichainTrackingHelper_getNetworkClientRegistry, _MultichainTrackingHelper_removeIncomingTransactionHelperListeners, _MultichainTrackingHelper_removePendingTransactionTrackerListeners, _MultichainTrackingHelper_createNonceTracker, _MultichainTrackingHelper_createIncomingTransactionHelper, _MultichainTrackingHelper_createPendingTransactionTracker, _MultichainTrackingHelper_nonceMutexesByChainId, _MultichainTrackingHelper_trackingMap, _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap, _MultichainTrackingHelper_refreshTrackingMap, _MultichainTrackingHelper_stopTrackingByNetworkClientId, _MultichainTrackingHelper_startTrackingByNetworkClientId, _MultichainTrackingHelper_refreshEtherscanRemoteTransactionSources; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.MultichainTrackingHelper = void 0; ++const eth_query_1 = __importDefault(require("@metamask/eth-query")); ++const async_mutex_1 = require("async-mutex"); ++const logger_1 = require("../logger"); ++const EtherscanRemoteTransactionSource_1 = require("./EtherscanRemoteTransactionSource"); ++class MultichainTrackingHelper { ++ constructor({ isMultichainEnabled, provider, nonceTracker, incomingTransactionOptions, findNetworkClientIdByChainId, getNetworkClientById, getNetworkClientRegistry, removeIncomingTransactionHelperListeners, removePendingTransactionTrackerListeners, createNonceTracker, createIncomingTransactionHelper, createPendingTransactionTracker, onNetworkStateChange, }) { ++ _MultichainTrackingHelper_instances.add(this); ++ _MultichainTrackingHelper_isMultichainEnabled.set(this, void 0); ++ _MultichainTrackingHelper_provider.set(this, void 0); ++ _MultichainTrackingHelper_nonceTracker.set(this, void 0); ++ _MultichainTrackingHelper_incomingTransactionOptions.set(this, void 0); ++ _MultichainTrackingHelper_findNetworkClientIdByChainId.set(this, void 0); ++ _MultichainTrackingHelper_getNetworkClientById.set(this, void 0); ++ _MultichainTrackingHelper_getNetworkClientRegistry.set(this, void 0); ++ _MultichainTrackingHelper_removeIncomingTransactionHelperListeners.set(this, void 0); ++ _MultichainTrackingHelper_removePendingTransactionTrackerListeners.set(this, void 0); ++ _MultichainTrackingHelper_createNonceTracker.set(this, void 0); ++ _MultichainTrackingHelper_createIncomingTransactionHelper.set(this, void 0); ++ _MultichainTrackingHelper_createPendingTransactionTracker.set(this, void 0); ++ _MultichainTrackingHelper_nonceMutexesByChainId.set(this, new Map()); ++ _MultichainTrackingHelper_trackingMap.set(this, new Map()); ++ _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap.set(this, new Map()); ++ this.checkForPendingTransactionAndStartPolling = () => { ++ for (const [, trackers] of __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f")) { ++ trackers.pendingTransactionTracker.startIfPendingTransactions(); ++ } ++ }; ++ _MultichainTrackingHelper_refreshTrackingMap.set(this, (networkClients) => { ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_refreshEtherscanRemoteTransactionSources, "f").call(this, networkClients); ++ const networkClientIds = Object.keys(networkClients); ++ const existingNetworkClientIds = Array.from(__classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").keys()); ++ // Remove tracking for NetworkClientIds that no longer exist ++ const networkClientIdsToRemove = existingNetworkClientIds.filter((id) => !networkClientIds.includes(id)); ++ networkClientIdsToRemove.forEach((id) => { ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_instances, "m", _MultichainTrackingHelper_stopTrackingByNetworkClientId).call(this, id); ++ }); ++ // Start tracking new NetworkClientIds from the registry ++ const networkClientIdsToAdd = networkClientIds.filter((id) => !existingNetworkClientIds.includes(id)); ++ networkClientIdsToAdd.forEach((id) => { ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_instances, "m", _MultichainTrackingHelper_startTrackingByNetworkClientId).call(this, id); ++ }); ++ }); ++ _MultichainTrackingHelper_refreshEtherscanRemoteTransactionSources.set(this, (networkClients) => { ++ // this will be prettier when we have consolidated network clients with a single chainId: ++ // check if there are still other network clients using the same chainId ++ // if not remove the etherscanRemoteTransaction source from the map ++ const chainIdsInRegistry = new Set(); ++ Object.values(networkClients).forEach((networkClient) => chainIdsInRegistry.add(networkClient.configuration.chainId)); ++ const existingChainIds = Array.from(__classPrivateFieldGet(this, _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap, "f").keys()); ++ const chainIdsToRemove = existingChainIds.filter((chainId) => !chainIdsInRegistry.has(chainId)); ++ chainIdsToRemove.forEach((chainId) => { ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap, "f").delete(chainId); ++ }); ++ }); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_isMultichainEnabled, isMultichainEnabled, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_provider, provider, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_nonceTracker, nonceTracker, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_incomingTransactionOptions, incomingTransactionOptions, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_findNetworkClientIdByChainId, findNetworkClientIdByChainId, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_getNetworkClientById, getNetworkClientById, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_getNetworkClientRegistry, getNetworkClientRegistry, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_createNonceTracker, createNonceTracker, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_createIncomingTransactionHelper, createIncomingTransactionHelper, "f"); ++ __classPrivateFieldSet(this, _MultichainTrackingHelper_createPendingTransactionTracker, createPendingTransactionTracker, "f"); ++ onNetworkStateChange((_, patches) => { ++ if (__classPrivateFieldGet(this, _MultichainTrackingHelper_isMultichainEnabled, "f")) { ++ const networkClients = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientRegistry, "f").call(this); ++ patches.forEach(({ op, path }) => { ++ if (op === 'remove' && path[0] === 'networkConfigurations') { ++ const networkClientId = path[1]; ++ delete networkClients[networkClientId]; ++ } ++ }); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_refreshTrackingMap, "f").call(this, networkClients); ++ } ++ }); ++ } ++ initialize() { ++ if (!__classPrivateFieldGet(this, _MultichainTrackingHelper_isMultichainEnabled, "f")) { ++ return; ++ } ++ const networkClients = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientRegistry, "f").call(this); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_refreshTrackingMap, "f").call(this, networkClients); ++ } ++ has(networkClientId) { ++ return __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").has(networkClientId); ++ } ++ getEthQuery({ networkClientId, chainId, } = {}) { ++ if (!__classPrivateFieldGet(this, _MultichainTrackingHelper_isMultichainEnabled, "f")) { ++ return new eth_query_1.default(__classPrivateFieldGet(this, _MultichainTrackingHelper_provider, "f")); ++ } ++ let networkClient; ++ if (networkClientId) { ++ try { ++ networkClient = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientById, "f").call(this, networkClientId); ++ } ++ catch (err) { ++ (0, logger_1.incomingTransactionsLogger)('failed to get network client by networkClientId'); ++ } ++ } ++ if (!networkClient && chainId) { ++ try { ++ networkClientId = __classPrivateFieldGet(this, _MultichainTrackingHelper_findNetworkClientIdByChainId, "f").call(this, chainId); ++ networkClient = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientById, "f").call(this, networkClientId); ++ } ++ catch (err) { ++ (0, logger_1.incomingTransactionsLogger)('failed to get network client by chainId'); ++ } ++ } ++ if (networkClient) { ++ return new eth_query_1.default(networkClient.provider); ++ } ++ // NOTE(JL): we're not ready to drop globally selected ethQuery yet. ++ // Some calls to getEthQuery only have access to optional networkClientId ++ // throw new Error('failed to get eth query instance'); ++ return new eth_query_1.default(__classPrivateFieldGet(this, _MultichainTrackingHelper_provider, "f")); ++ } ++ /** ++ * Gets the mutex intended to guard the nonceTracker for a particular chainId and key . ++ * ++ * @param opts - The options object. ++ * @param opts.chainId - The hex chainId. ++ * @param opts.key - The hex address (or constant) pertaining to the chainId ++ * @returns Mutex instance for the given chainId and key pair ++ */ ++ acquireNonceLockForChainIdKey({ chainId, key = 'global', }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ let nonceMutexesForChainId = __classPrivateFieldGet(this, _MultichainTrackingHelper_nonceMutexesByChainId, "f").get(chainId); ++ if (!nonceMutexesForChainId) { ++ nonceMutexesForChainId = new Map(); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_nonceMutexesByChainId, "f").set(chainId, nonceMutexesForChainId); ++ } ++ let nonceMutexForKey = nonceMutexesForChainId.get(key); ++ if (!nonceMutexForKey) { ++ nonceMutexForKey = new async_mutex_1.Mutex(); ++ nonceMutexesForChainId.set(key, nonceMutexForKey); ++ } ++ return yield nonceMutexForKey.acquire(); ++ }); ++ } ++ /** ++ * Gets the next nonce according to the nonce-tracker. ++ * Ensure `releaseLock` is called once processing of the `nonce` value is complete. ++ * ++ * @param address - The hex string address for the transaction. ++ * @param networkClientId - The network client ID for the transaction, used to fetch the correct nonce tracker. ++ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock. ++ */ ++ getNonceLock(address, networkClientId) { ++ return __awaiter(this, void 0, void 0, function* () { ++ let releaseLockForChainIdKey; ++ let nonceTracker = __classPrivateFieldGet(this, _MultichainTrackingHelper_nonceTracker, "f"); ++ if (networkClientId && __classPrivateFieldGet(this, _MultichainTrackingHelper_isMultichainEnabled, "f")) { ++ const networkClient = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientById, "f").call(this, networkClientId); ++ releaseLockForChainIdKey = yield this.acquireNonceLockForChainIdKey({ ++ chainId: networkClient.configuration.chainId, ++ key: address, ++ }); ++ const trackers = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").get(networkClientId); ++ if (!trackers) { ++ throw new Error('missing nonceTracker for networkClientId'); ++ } ++ nonceTracker = trackers.nonceTracker; ++ } ++ // Acquires the lock for the chainId + address and the nonceLock from the nonceTracker, then ++ // couples them together by replacing the nonceLock's releaseLock method with ++ // an anonymous function that calls releases both the original nonceLock and the ++ // lock for the chainId. ++ try { ++ const nonceLock = yield nonceTracker.getNonceLock(address); ++ return Object.assign(Object.assign({}, nonceLock), { releaseLock: () => { ++ nonceLock.releaseLock(); ++ releaseLockForChainIdKey === null || releaseLockForChainIdKey === void 0 ? void 0 : releaseLockForChainIdKey(); ++ } }); ++ } ++ catch (err) { ++ releaseLockForChainIdKey === null || releaseLockForChainIdKey === void 0 ? void 0 : releaseLockForChainIdKey(); ++ throw err; ++ } ++ }); ++ } ++ startIncomingTransactionPolling(networkClientIds = []) { ++ networkClientIds.forEach((networkClientId) => { ++ var _a; ++ (_a = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").get(networkClientId)) === null || _a === void 0 ? void 0 : _a.incomingTransactionHelper.start(); ++ }); ++ } ++ stopIncomingTransactionPolling(networkClientIds = []) { ++ networkClientIds.forEach((networkClientId) => { ++ var _a; ++ (_a = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").get(networkClientId)) === null || _a === void 0 ? void 0 : _a.incomingTransactionHelper.stop(); ++ }); ++ } ++ stopAllIncomingTransactionPolling() { ++ for (const [, trackers] of __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f")) { ++ trackers.incomingTransactionHelper.stop(); ++ } ++ } ++ updateIncomingTransactions(networkClientIds = []) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const promises = yield Promise.allSettled(networkClientIds.map((networkClientId) => __awaiter(this, void 0, void 0, function* () { ++ var _a; ++ return yield ((_a = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f") ++ .get(networkClientId)) === null || _a === void 0 ? void 0 : _a.incomingTransactionHelper.update()); ++ }))); ++ promises ++ .filter((result) => result.status === 'rejected') ++ .forEach((result) => { ++ (0, logger_1.incomingTransactionsLogger)('failed to update incoming transactions', result.reason); ++ }); ++ }); ++ } ++ stopAllTracking() { ++ for (const [networkClientId] of __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f")) { ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_instances, "m", _MultichainTrackingHelper_stopTrackingByNetworkClientId).call(this, networkClientId); ++ } ++ } ++} ++exports.MultichainTrackingHelper = MultichainTrackingHelper; ++_MultichainTrackingHelper_isMultichainEnabled = new WeakMap(), _MultichainTrackingHelper_provider = new WeakMap(), _MultichainTrackingHelper_nonceTracker = new WeakMap(), _MultichainTrackingHelper_incomingTransactionOptions = new WeakMap(), _MultichainTrackingHelper_findNetworkClientIdByChainId = new WeakMap(), _MultichainTrackingHelper_getNetworkClientById = new WeakMap(), _MultichainTrackingHelper_getNetworkClientRegistry = new WeakMap(), _MultichainTrackingHelper_removeIncomingTransactionHelperListeners = new WeakMap(), _MultichainTrackingHelper_removePendingTransactionTrackerListeners = new WeakMap(), _MultichainTrackingHelper_createNonceTracker = new WeakMap(), _MultichainTrackingHelper_createIncomingTransactionHelper = new WeakMap(), _MultichainTrackingHelper_createPendingTransactionTracker = new WeakMap(), _MultichainTrackingHelper_nonceMutexesByChainId = new WeakMap(), _MultichainTrackingHelper_trackingMap = new WeakMap(), _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap = new WeakMap(), _MultichainTrackingHelper_refreshTrackingMap = new WeakMap(), _MultichainTrackingHelper_refreshEtherscanRemoteTransactionSources = new WeakMap(), _MultichainTrackingHelper_instances = new WeakSet(), _MultichainTrackingHelper_stopTrackingByNetworkClientId = function _MultichainTrackingHelper_stopTrackingByNetworkClientId(networkClientId) { ++ const trackers = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").get(networkClientId); ++ if (trackers) { ++ trackers.pendingTransactionTracker.stop(); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_removePendingTransactionTrackerListeners, "f").call(this, trackers.pendingTransactionTracker); ++ trackers.incomingTransactionHelper.stop(); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_removeIncomingTransactionHelperListeners, "f").call(this, trackers.incomingTransactionHelper); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").delete(networkClientId); ++ } ++}, _MultichainTrackingHelper_startTrackingByNetworkClientId = function _MultichainTrackingHelper_startTrackingByNetworkClientId(networkClientId) { ++ const trackers = __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").get(networkClientId); ++ if (trackers) { ++ return; ++ } ++ const { provider, blockTracker, configuration: { chainId }, } = __classPrivateFieldGet(this, _MultichainTrackingHelper_getNetworkClientById, "f").call(this, networkClientId); ++ let etherscanRemoteTransactionSource = __classPrivateFieldGet(this, _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap, "f").get(chainId); ++ if (!etherscanRemoteTransactionSource) { ++ etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({ ++ includeTokenTransfers: __classPrivateFieldGet(this, _MultichainTrackingHelper_incomingTransactionOptions, "f").includeTokenTransfers, ++ }); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_etherscanRemoteTransactionSourcesMap, "f").set(chainId, etherscanRemoteTransactionSource); ++ } ++ const nonceTracker = __classPrivateFieldGet(this, _MultichainTrackingHelper_createNonceTracker, "f").call(this, { ++ provider, ++ blockTracker, ++ chainId, ++ }); ++ const incomingTransactionHelper = __classPrivateFieldGet(this, _MultichainTrackingHelper_createIncomingTransactionHelper, "f").call(this, { ++ blockTracker, ++ etherscanRemoteTransactionSource, ++ chainId, ++ }); ++ const pendingTransactionTracker = __classPrivateFieldGet(this, _MultichainTrackingHelper_createPendingTransactionTracker, "f").call(this, { ++ provider, ++ blockTracker, ++ chainId, ++ }); ++ __classPrivateFieldGet(this, _MultichainTrackingHelper_trackingMap, "f").set(networkClientId, { ++ nonceTracker, ++ incomingTransactionHelper, ++ pendingTransactionTracker, ++ }); ++}; ++//# sourceMappingURL=MultichainTrackingHelper.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js.map +new file mode 100644 +index 0000000..1f96700 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/MultichainTrackingHelper.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"MultichainTrackingHelper.js","sourceRoot":"","sources":["../../src/helpers/MultichainTrackingHelper.ts"],"names":[],"mappings":";;;;;;;;;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AC,CAAC;IAEhD,IAAI,gCAAgC,GAClC,uBAAA,IAAI,sEAAsC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1D,IAAI,CAAC,gCAAgC,EAAE;QACrC,gCAAgC,GAAG,IAAI,mEAAgC,CAAC;YACtE,qBAAqB,EACnB,uBAAA,IAAI,4DAA4B,CAAC,qBAAqB;SACzD,CAAC,CAAC;QACH,uBAAA,IAAI,sEAAsC,CAAC,GAAG,CAC5C,OAAO,EACP,gCAAgC,CACjC,CAAC;KACH;IAED,MAAM,YAAY,GAAG,uBAAA,IAAI,oDAAoB,MAAxB,IAAI,EAAqB;QAC5C,QAAQ;QACR,YAAY;QACZ,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,yBAAyB,GAAG,uBAAA,IAAI,iEAAiC,MAArC,IAAI,EAAkC;QACtE,YAAY;QACZ,gCAAgC;QAChC,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,yBAAyB,GAAG,uBAAA,IAAI,iEAAiC,MAArC,IAAI,EAAkC;QACtE,QAAQ;QACR,YAAY;QACZ,OAAO;KACR,CAAC,CAAC;IAEH,uBAAA,IAAI,6CAAa,CAAC,GAAG,CAAC,eAAe,EAAE;QACrC,YAAY;QACZ,yBAAyB;QACzB,yBAAyB;KAC1B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import EthQuery from '@metamask/eth-query';\nimport type {\n NetworkClientId,\n NetworkController,\n NetworkClient,\n BlockTracker,\n Provider,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport type { NonceLock, NonceTracker } from 'nonce-tracker';\n\nimport { incomingTransactionsLogger as log } from '../logger';\nimport { EtherscanRemoteTransactionSource } from './EtherscanRemoteTransactionSource';\nimport type {\n IncomingTransactionHelper,\n IncomingTransactionOptions,\n} from './IncomingTransactionHelper';\nimport type { PendingTransactionTracker } from './PendingTransactionTracker';\n\n/**\n * Registry of network clients provided by the NetworkController\n */\ntype NetworkClientRegistry = ReturnType<\n NetworkController['getNetworkClientRegistry']\n>;\n\nexport type MultichainTrackingHelperOptions = {\n isMultichainEnabled: boolean;\n provider: Provider;\n nonceTracker: NonceTracker;\n incomingTransactionOptions: IncomingTransactionOptions;\n\n findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n getNetworkClientById: NetworkController['getNetworkClientById'];\n getNetworkClientRegistry: NetworkController['getNetworkClientRegistry'];\n\n removeIncomingTransactionHelperListeners: (\n IncomingTransactionHelper: IncomingTransactionHelper,\n ) => void;\n removePendingTransactionTrackerListeners: (\n pendingTransactionTracker: PendingTransactionTracker,\n ) => void;\n createNonceTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => NonceTracker;\n createIncomingTransactionHelper: (opts: {\n blockTracker: BlockTracker;\n etherscanRemoteTransactionSource: EtherscanRemoteTransactionSource;\n chainId?: Hex;\n }) => IncomingTransactionHelper;\n createPendingTransactionTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => PendingTransactionTracker;\n onNetworkStateChange: (\n listener: (\n ...payload: NetworkControllerStateChangeEvent['payload']\n ) => void,\n ) => void;\n};\n\nexport class MultichainTrackingHelper {\n #isMultichainEnabled: boolean;\n\n readonly #provider: Provider;\n\n readonly #nonceTracker: NonceTracker;\n\n readonly #incomingTransactionOptions: IncomingTransactionOptions;\n\n readonly #findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n\n readonly #getNetworkClientById: NetworkController['getNetworkClientById'];\n\n readonly #getNetworkClientRegistry: NetworkController['getNetworkClientRegistry'];\n\n readonly #removeIncomingTransactionHelperListeners: (\n IncomingTransactionHelper: IncomingTransactionHelper,\n ) => void;\n\n readonly #removePendingTransactionTrackerListeners: (\n pendingTransactionTracker: PendingTransactionTracker,\n ) => void;\n\n readonly #createNonceTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => NonceTracker;\n\n readonly #createIncomingTransactionHelper: (opts: {\n blockTracker: BlockTracker;\n chainId?: Hex;\n etherscanRemoteTransactionSource: EtherscanRemoteTransactionSource;\n }) => IncomingTransactionHelper;\n\n readonly #createPendingTransactionTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => PendingTransactionTracker;\n\n readonly #nonceMutexesByChainId = new Map>();\n\n readonly #trackingMap: Map<\n NetworkClientId,\n {\n nonceTracker: NonceTracker;\n pendingTransactionTracker: PendingTransactionTracker;\n incomingTransactionHelper: IncomingTransactionHelper;\n }\n > = new Map();\n\n readonly #etherscanRemoteTransactionSourcesMap: Map<\n Hex,\n EtherscanRemoteTransactionSource\n > = new Map();\n\n constructor({\n isMultichainEnabled,\n provider,\n nonceTracker,\n incomingTransactionOptions,\n findNetworkClientIdByChainId,\n getNetworkClientById,\n getNetworkClientRegistry,\n removeIncomingTransactionHelperListeners,\n removePendingTransactionTrackerListeners,\n createNonceTracker,\n createIncomingTransactionHelper,\n createPendingTransactionTracker,\n onNetworkStateChange,\n }: MultichainTrackingHelperOptions) {\n this.#isMultichainEnabled = isMultichainEnabled;\n this.#provider = provider;\n this.#nonceTracker = nonceTracker;\n this.#incomingTransactionOptions = incomingTransactionOptions;\n\n this.#findNetworkClientIdByChainId = findNetworkClientIdByChainId;\n this.#getNetworkClientById = getNetworkClientById;\n this.#getNetworkClientRegistry = getNetworkClientRegistry;\n\n this.#removeIncomingTransactionHelperListeners =\n removeIncomingTransactionHelperListeners;\n this.#removePendingTransactionTrackerListeners =\n removePendingTransactionTrackerListeners;\n this.#createNonceTracker = createNonceTracker;\n this.#createIncomingTransactionHelper = createIncomingTransactionHelper;\n this.#createPendingTransactionTracker = createPendingTransactionTracker;\n\n onNetworkStateChange((_, patches) => {\n if (this.#isMultichainEnabled) {\n const networkClients = this.#getNetworkClientRegistry();\n patches.forEach(({ op, path }) => {\n if (op === 'remove' && path[0] === 'networkConfigurations') {\n const networkClientId = path[1] as NetworkClientId;\n delete networkClients[networkClientId];\n }\n });\n\n this.#refreshTrackingMap(networkClients);\n }\n });\n }\n\n initialize() {\n if (!this.#isMultichainEnabled) {\n return;\n }\n const networkClients = this.#getNetworkClientRegistry();\n this.#refreshTrackingMap(networkClients);\n }\n\n has(networkClientId: NetworkClientId) {\n return this.#trackingMap.has(networkClientId);\n }\n\n getEthQuery({\n networkClientId,\n chainId,\n }: {\n networkClientId?: NetworkClientId;\n chainId?: Hex;\n } = {}): EthQuery {\n if (!this.#isMultichainEnabled) {\n return new EthQuery(this.#provider);\n }\n let networkClient: NetworkClient | undefined;\n\n if (networkClientId) {\n try {\n networkClient = this.#getNetworkClientById(networkClientId);\n } catch (err) {\n log('failed to get network client by networkClientId');\n }\n }\n if (!networkClient && chainId) {\n try {\n networkClientId = this.#findNetworkClientIdByChainId(chainId);\n networkClient = this.#getNetworkClientById(networkClientId);\n } catch (err) {\n log('failed to get network client by chainId');\n }\n }\n\n if (networkClient) {\n return new EthQuery(networkClient.provider);\n }\n\n // NOTE(JL): we're not ready to drop globally selected ethQuery yet.\n // Some calls to getEthQuery only have access to optional networkClientId\n // throw new Error('failed to get eth query instance');\n return new EthQuery(this.#provider);\n }\n\n /**\n * Gets the mutex intended to guard the nonceTracker for a particular chainId and key .\n *\n * @param opts - The options object.\n * @param opts.chainId - The hex chainId.\n * @param opts.key - The hex address (or constant) pertaining to the chainId\n * @returns Mutex instance for the given chainId and key pair\n */\n async acquireNonceLockForChainIdKey({\n chainId,\n key = 'global',\n }: {\n chainId: Hex;\n key?: string;\n }): Promise<() => void> {\n let nonceMutexesForChainId = this.#nonceMutexesByChainId.get(chainId);\n if (!nonceMutexesForChainId) {\n nonceMutexesForChainId = new Map();\n this.#nonceMutexesByChainId.set(chainId, nonceMutexesForChainId);\n }\n let nonceMutexForKey = nonceMutexesForChainId.get(key);\n if (!nonceMutexForKey) {\n nonceMutexForKey = new Mutex();\n nonceMutexesForChainId.set(key, nonceMutexForKey);\n }\n\n return await nonceMutexForKey.acquire();\n }\n\n /**\n * Gets the next nonce according to the nonce-tracker.\n * Ensure `releaseLock` is called once processing of the `nonce` value is complete.\n *\n * @param address - The hex string address for the transaction.\n * @param networkClientId - The network client ID for the transaction, used to fetch the correct nonce tracker.\n * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.\n */\n async getNonceLock(\n address: string,\n networkClientId?: NetworkClientId,\n ): Promise {\n let releaseLockForChainIdKey: (() => void) | undefined;\n let nonceTracker = this.#nonceTracker;\n if (networkClientId && this.#isMultichainEnabled) {\n const networkClient = this.#getNetworkClientById(networkClientId);\n releaseLockForChainIdKey = await this.acquireNonceLockForChainIdKey({\n chainId: networkClient.configuration.chainId,\n key: address,\n });\n const trackers = this.#trackingMap.get(networkClientId);\n if (!trackers) {\n throw new Error('missing nonceTracker for networkClientId');\n }\n nonceTracker = trackers.nonceTracker;\n }\n\n // Acquires the lock for the chainId + address and the nonceLock from the nonceTracker, then\n // couples them together by replacing the nonceLock's releaseLock method with\n // an anonymous function that calls releases both the original nonceLock and the\n // lock for the chainId.\n try {\n const nonceLock = await nonceTracker.getNonceLock(address);\n return {\n ...nonceLock,\n releaseLock: () => {\n nonceLock.releaseLock();\n releaseLockForChainIdKey?.();\n },\n };\n } catch (err) {\n releaseLockForChainIdKey?.();\n throw err;\n }\n }\n\n startIncomingTransactionPolling(networkClientIds: NetworkClientId[] = []) {\n networkClientIds.forEach((networkClientId) => {\n this.#trackingMap.get(networkClientId)?.incomingTransactionHelper.start();\n });\n }\n\n stopIncomingTransactionPolling(networkClientIds: NetworkClientId[] = []) {\n networkClientIds.forEach((networkClientId) => {\n this.#trackingMap.get(networkClientId)?.incomingTransactionHelper.stop();\n });\n }\n\n stopAllIncomingTransactionPolling() {\n for (const [, trackers] of this.#trackingMap) {\n trackers.incomingTransactionHelper.stop();\n }\n }\n\n async updateIncomingTransactions(networkClientIds: NetworkClientId[] = []) {\n const promises = await Promise.allSettled(\n networkClientIds.map(async (networkClientId) => {\n return await this.#trackingMap\n .get(networkClientId)\n ?.incomingTransactionHelper.update();\n }),\n );\n\n promises\n .filter((result) => result.status === 'rejected')\n .forEach((result) => {\n log(\n 'failed to update incoming transactions',\n (result as PromiseRejectedResult).reason,\n );\n });\n }\n\n checkForPendingTransactionAndStartPolling = () => {\n for (const [, trackers] of this.#trackingMap) {\n trackers.pendingTransactionTracker.startIfPendingTransactions();\n }\n };\n\n stopAllTracking() {\n for (const [networkClientId] of this.#trackingMap) {\n this.#stopTrackingByNetworkClientId(networkClientId);\n }\n }\n\n #refreshTrackingMap = (networkClients: NetworkClientRegistry) => {\n this.#refreshEtherscanRemoteTransactionSources(networkClients);\n\n const networkClientIds = Object.keys(networkClients);\n const existingNetworkClientIds = Array.from(this.#trackingMap.keys());\n\n // Remove tracking for NetworkClientIds that no longer exist\n const networkClientIdsToRemove = existingNetworkClientIds.filter(\n (id) => !networkClientIds.includes(id),\n );\n networkClientIdsToRemove.forEach((id) => {\n this.#stopTrackingByNetworkClientId(id);\n });\n\n // Start tracking new NetworkClientIds from the registry\n const networkClientIdsToAdd = networkClientIds.filter(\n (id) => !existingNetworkClientIds.includes(id),\n );\n networkClientIdsToAdd.forEach((id) => {\n this.#startTrackingByNetworkClientId(id);\n });\n };\n\n #stopTrackingByNetworkClientId(networkClientId: NetworkClientId) {\n const trackers = this.#trackingMap.get(networkClientId);\n if (trackers) {\n trackers.pendingTransactionTracker.stop();\n this.#removePendingTransactionTrackerListeners(\n trackers.pendingTransactionTracker,\n );\n trackers.incomingTransactionHelper.stop();\n this.#removeIncomingTransactionHelperListeners(\n trackers.incomingTransactionHelper,\n );\n this.#trackingMap.delete(networkClientId);\n }\n }\n\n #startTrackingByNetworkClientId(networkClientId: NetworkClientId) {\n const trackers = this.#trackingMap.get(networkClientId);\n if (trackers) {\n return;\n }\n\n const {\n provider,\n blockTracker,\n configuration: { chainId },\n } = this.#getNetworkClientById(networkClientId);\n\n let etherscanRemoteTransactionSource =\n this.#etherscanRemoteTransactionSourcesMap.get(chainId);\n if (!etherscanRemoteTransactionSource) {\n etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource({\n includeTokenTransfers:\n this.#incomingTransactionOptions.includeTokenTransfers,\n });\n this.#etherscanRemoteTransactionSourcesMap.set(\n chainId,\n etherscanRemoteTransactionSource,\n );\n }\n\n const nonceTracker = this.#createNonceTracker({\n provider,\n blockTracker,\n chainId,\n });\n\n const incomingTransactionHelper = this.#createIncomingTransactionHelper({\n blockTracker,\n etherscanRemoteTransactionSource,\n chainId,\n });\n\n const pendingTransactionTracker = this.#createPendingTransactionTracker({\n provider,\n blockTracker,\n chainId,\n });\n\n this.#trackingMap.set(networkClientId, {\n nonceTracker,\n incomingTransactionHelper,\n pendingTransactionTracker,\n });\n }\n\n #refreshEtherscanRemoteTransactionSources = (\n networkClients: NetworkClientRegistry,\n ) => {\n // this will be prettier when we have consolidated network clients with a single chainId:\n // check if there are still other network clients using the same chainId\n // if not remove the etherscanRemoteTransaction source from the map\n const chainIdsInRegistry = new Set();\n Object.values(networkClients).forEach((networkClient) =>\n chainIdsInRegistry.add(networkClient.configuration.chainId),\n );\n const existingChainIds = Array.from(\n this.#etherscanRemoteTransactionSourcesMap.keys(),\n );\n const chainIdsToRemove = existingChainIds.filter(\n (chainId) => !chainIdsInRegistry.has(chainId),\n );\n\n chainIdsToRemove.forEach((chainId) => {\n this.#etherscanRemoteTransactionSourcesMap.delete(chainId);\n });\n };\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts +new file mode 100644 +index 0000000..cf31577 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts +@@ -0,0 +1,37 @@ ++/// ++import type EthQuery from '@metamask/eth-query'; ++import type { BlockTracker } from '@metamask/network-controller'; ++import EventEmitter from 'events'; ++import type { NonceTracker } from 'nonce-tracker'; ++import type { TransactionMeta } from '../types'; ++declare type Events = { ++ 'transaction-confirmed': [txMeta: TransactionMeta]; ++ 'transaction-dropped': [txMeta: TransactionMeta]; ++ 'transaction-failed': [txMeta: TransactionMeta, error: Error]; ++ 'transaction-updated': [txMeta: TransactionMeta, note: string]; ++}; ++export interface PendingTransactionTrackerEventEmitter extends EventEmitter { ++ on(eventName: T, listener: (...args: Events[T]) => void): this; ++ emit(eventName: T, ...args: Events[T]): boolean; ++} ++export declare class PendingTransactionTracker { ++ #private; ++ hub: PendingTransactionTrackerEventEmitter; ++ constructor({ approveTransaction, blockTracker, getChainId, getEthQuery, getTransactions, isResubmitEnabled, nonceTracker, onStateChange, publishTransaction, hooks, }: { ++ approveTransaction: (transactionId: string) => Promise; ++ blockTracker: BlockTracker; ++ getChainId: () => string; ++ getEthQuery: () => EthQuery; ++ getTransactions: () => TransactionMeta[]; ++ isResubmitEnabled?: boolean; ++ nonceTracker: NonceTracker; ++ onStateChange: (listener: () => void) => void; ++ publishTransaction: (rawTx: string) => Promise; ++ hooks?: { ++ beforeCheckPendingTransaction?: (transactionMeta: TransactionMeta) => boolean; ++ beforePublish?: (transactionMeta: TransactionMeta) => boolean; ++ }; ++ }); ++} ++export {}; ++//# sourceMappingURL=PendingTransactionTracker.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts.map +new file mode 100644 +index 0000000..aba0260 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"PendingTransactionTracker.d.ts","sourceRoot":"","sources":["../../src/helpers/PendingTransactionTracker.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,YA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,EAAE,OAAO,CAAC;QAC5B,YAAY,EAAE,YAAY,CAAC;QAC3B,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;QAC9C,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QACvD,KAAK,CAAC,EAAE;YACN,6BAA6B,CAAC,EAAE,CAC9B,eAAe,EAAE,eAAe,KAC7B,OAAO,CAAC;YACb,aAAa,CAAC,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC;SAC/D,CAAC;KACH;CA4ZF"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js +new file mode 100644 +index 0000000..06963b7 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js +@@ -0,0 +1,341 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { ++ if (kind === "m") throw new TypeError("Private method is not writable"); ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); ++ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; ++}; ++var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { ++ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); ++ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); ++ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); ++}; ++var __importDefault = (this && this.__importDefault) || function (mod) { ++ return (mod && mod.__esModule) ? mod : { "default": mod }; ++}; ++var _PendingTransactionTracker_instances, _PendingTransactionTracker_approveTransaction, _PendingTransactionTracker_blockTracker, _PendingTransactionTracker_droppedBlockCountByHash, _PendingTransactionTracker_getChainId, _PendingTransactionTracker_getEthQuery, _PendingTransactionTracker_getTransactions, _PendingTransactionTracker_isResubmitEnabled, _PendingTransactionTracker_listener, _PendingTransactionTracker_nonceTracker, _PendingTransactionTracker_onStateChange, _PendingTransactionTracker_publishTransaction, _PendingTransactionTracker_running, _PendingTransactionTracker_beforeCheckPendingTransaction, _PendingTransactionTracker_beforePublish, _PendingTransactionTracker_start, _PendingTransactionTracker_stop, _PendingTransactionTracker_onLatestBlock, _PendingTransactionTracker_checkTransactions, _PendingTransactionTracker_resubmitTransactions, _PendingTransactionTracker_isKnownTransactionError, _PendingTransactionTracker_resubmitTransaction, _PendingTransactionTracker_isResubmitDue, _PendingTransactionTracker_checkTransaction, _PendingTransactionTracker_onTransactionConfirmed, _PendingTransactionTracker_isTransactionDropped, _PendingTransactionTracker_isNonceTaken, _PendingTransactionTracker_getPendingTransactions, _PendingTransactionTracker_warnTransaction, _PendingTransactionTracker_failTransaction, _PendingTransactionTracker_dropTransaction, _PendingTransactionTracker_updateTransaction, _PendingTransactionTracker_getTransactionReceipt, _PendingTransactionTracker_getBlockByHash, _PendingTransactionTracker_getNetworkTransactionCount, _PendingTransactionTracker_getCurrentChainTransactions; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.PendingTransactionTracker = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const utils_1 = require("@metamask/utils"); ++const events_1 = __importDefault(require("events")); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++/** ++ * We wait this many blocks before emitting a 'transaction-dropped' event ++ * This is because we could be talking to a node that is out of sync ++ */ ++const DROPPED_BLOCK_COUNT = 3; ++const RECEIPT_STATUS_SUCCESS = '0x1'; ++const RECEIPT_STATUS_FAILURE = '0x0'; ++const MAX_RETRY_BLOCK_DISTANCE = 50; ++const KNOWN_TRANSACTION_ERRORS = [ ++ 'replacement transaction underpriced', ++ 'known transaction', ++ 'gas price too low to replace', ++ 'transaction with the same hash was already imported', ++ 'gateway timeout', ++ 'nonce too low', ++]; ++const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'pending-transactions'); ++class PendingTransactionTracker { ++ constructor({ approveTransaction, blockTracker, getChainId, getEthQuery, getTransactions, isResubmitEnabled, nonceTracker, onStateChange, publishTransaction, hooks, }) { ++ var _a, _b; ++ _PendingTransactionTracker_instances.add(this); ++ _PendingTransactionTracker_approveTransaction.set(this, void 0); ++ _PendingTransactionTracker_blockTracker.set(this, void 0); ++ _PendingTransactionTracker_droppedBlockCountByHash.set(this, void 0); ++ _PendingTransactionTracker_getChainId.set(this, void 0); ++ _PendingTransactionTracker_getEthQuery.set(this, void 0); ++ _PendingTransactionTracker_getTransactions.set(this, void 0); ++ _PendingTransactionTracker_isResubmitEnabled.set(this, void 0); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ _PendingTransactionTracker_listener.set(this, void 0); ++ _PendingTransactionTracker_nonceTracker.set(this, void 0); ++ _PendingTransactionTracker_onStateChange.set(this, void 0); ++ _PendingTransactionTracker_publishTransaction.set(this, void 0); ++ _PendingTransactionTracker_running.set(this, void 0); ++ _PendingTransactionTracker_beforeCheckPendingTransaction.set(this, void 0); ++ _PendingTransactionTracker_beforePublish.set(this, void 0); ++ this.hub = new events_1.default(); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_approveTransaction, approveTransaction, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_blockTracker, blockTracker, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_droppedBlockCountByHash, new Map(), "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_getChainId, getChainId, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_getEthQuery, getEthQuery, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_getTransactions, getTransactions, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_isResubmitEnabled, isResubmitEnabled !== null && isResubmitEnabled !== void 0 ? isResubmitEnabled : true, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_listener, __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_onLatestBlock).bind(this), "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_nonceTracker, nonceTracker, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_onStateChange, onStateChange, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_publishTransaction, publishTransaction, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_running, false, "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_beforePublish, (_a = hooks === null || hooks === void 0 ? void 0 : hooks.beforePublish) !== null && _a !== void 0 ? _a : (() => true), "f"); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_beforeCheckPendingTransaction, (_b = hooks === null || hooks === void 0 ? void 0 : hooks.beforeCheckPendingTransaction) !== null && _b !== void 0 ? _b : (() => true), "f"); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_onStateChange, "f").call(this, () => { ++ const pendingTransactions = __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getPendingTransactions).call(this); ++ if (pendingTransactions.length) { ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_start).call(this); ++ } ++ else { ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_stop).call(this); ++ } ++ }); ++ } ++} ++exports.PendingTransactionTracker = PendingTransactionTracker; ++_PendingTransactionTracker_approveTransaction = new WeakMap(), _PendingTransactionTracker_blockTracker = new WeakMap(), _PendingTransactionTracker_droppedBlockCountByHash = new WeakMap(), _PendingTransactionTracker_getChainId = new WeakMap(), _PendingTransactionTracker_getEthQuery = new WeakMap(), _PendingTransactionTracker_getTransactions = new WeakMap(), _PendingTransactionTracker_isResubmitEnabled = new WeakMap(), _PendingTransactionTracker_listener = new WeakMap(), _PendingTransactionTracker_nonceTracker = new WeakMap(), _PendingTransactionTracker_onStateChange = new WeakMap(), _PendingTransactionTracker_publishTransaction = new WeakMap(), _PendingTransactionTracker_running = new WeakMap(), _PendingTransactionTracker_beforeCheckPendingTransaction = new WeakMap(), _PendingTransactionTracker_beforePublish = new WeakMap(), _PendingTransactionTracker_instances = new WeakSet(), _PendingTransactionTracker_start = function _PendingTransactionTracker_start() { ++ if (__classPrivateFieldGet(this, _PendingTransactionTracker_running, "f")) { ++ return; ++ } ++ __classPrivateFieldGet(this, _PendingTransactionTracker_blockTracker, "f").on('latest', __classPrivateFieldGet(this, _PendingTransactionTracker_listener, "f")); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_running, true, "f"); ++ log('Started polling'); ++}, _PendingTransactionTracker_stop = function _PendingTransactionTracker_stop() { ++ if (!__classPrivateFieldGet(this, _PendingTransactionTracker_running, "f")) { ++ return; ++ } ++ __classPrivateFieldGet(this, _PendingTransactionTracker_blockTracker, "f").removeListener('latest', __classPrivateFieldGet(this, _PendingTransactionTracker_listener, "f")); ++ __classPrivateFieldSet(this, _PendingTransactionTracker_running, false, "f"); ++ log('Stopped polling'); ++}, _PendingTransactionTracker_onLatestBlock = function _PendingTransactionTracker_onLatestBlock(latestBlockNumber) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const nonceGlobalLock = yield __classPrivateFieldGet(this, _PendingTransactionTracker_nonceTracker, "f").getGlobalLock(); ++ try { ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_checkTransactions).call(this); ++ } ++ catch (error) { ++ /* istanbul ignore next */ ++ log('Failed to check transactions', error); ++ } ++ finally { ++ nonceGlobalLock.releaseLock(); ++ } ++ try { ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_resubmitTransactions).call(this, latestBlockNumber); ++ } ++ catch (error) { ++ /* istanbul ignore next */ ++ log('Failed to resubmit transactions', error); ++ } ++ }); ++}, _PendingTransactionTracker_checkTransactions = function _PendingTransactionTracker_checkTransactions() { ++ return __awaiter(this, void 0, void 0, function* () { ++ log('Checking transactions'); ++ const pendingTransactions = __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getPendingTransactions).call(this); ++ if (!pendingTransactions.length) { ++ log('No pending transactions to check'); ++ return; ++ } ++ log('Found pending transactions to check', { ++ count: pendingTransactions.length, ++ ids: pendingTransactions.map((tx) => tx.id), ++ }); ++ yield Promise.all(pendingTransactions.map((tx) => __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_checkTransaction).call(this, tx))); ++ }); ++}, _PendingTransactionTracker_resubmitTransactions = function _PendingTransactionTracker_resubmitTransactions(latestBlockNumber) { ++ var _a, _b; ++ return __awaiter(this, void 0, void 0, function* () { ++ if (!__classPrivateFieldGet(this, _PendingTransactionTracker_isResubmitEnabled, "f") || !__classPrivateFieldGet(this, _PendingTransactionTracker_running, "f")) { ++ return; ++ } ++ log('Resubmitting transactions'); ++ const pendingTransactions = __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getPendingTransactions).call(this); ++ if (!pendingTransactions.length) { ++ log('No pending transactions to resubmit'); ++ return; ++ } ++ log('Found pending transactions to resubmit', { ++ count: pendingTransactions.length, ++ ids: pendingTransactions.map((tx) => tx.id), ++ }); ++ for (const txMeta of pendingTransactions) { ++ try { ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_resubmitTransaction).call(this, txMeta, latestBlockNumber); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ } ++ catch (error) { ++ /* istanbul ignore next */ ++ const errorMessage = ((_b = (_a = error.value) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || error.message.toLowerCase(); ++ if (__classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_isKnownTransactionError).call(this, errorMessage)) { ++ log('Ignoring known transaction error', errorMessage); ++ return; ++ } ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_warnTransaction).call(this, txMeta, error.message, 'There was an error when resubmitting this transaction.'); ++ } ++ } ++ }); ++}, _PendingTransactionTracker_isKnownTransactionError = function _PendingTransactionTracker_isKnownTransactionError(errorMessage) { ++ return KNOWN_TRANSACTION_ERRORS.some((knownError) => errorMessage.includes(knownError)); ++}, _PendingTransactionTracker_resubmitTransaction = function _PendingTransactionTracker_resubmitTransaction(txMeta, latestBlockNumber) { ++ var _a; ++ return __awaiter(this, void 0, void 0, function* () { ++ if (!__classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_isResubmitDue).call(this, txMeta, latestBlockNumber)) { ++ return; ++ } ++ log('Resubmitting transaction', txMeta.id); ++ const { rawTx } = txMeta; ++ if (!__classPrivateFieldGet(this, _PendingTransactionTracker_beforePublish, "f").call(this, txMeta)) { ++ return; ++ } ++ if (!(rawTx === null || rawTx === void 0 ? void 0 : rawTx.length)) { ++ log('Approving transaction as no raw value'); ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_approveTransaction, "f").call(this, txMeta.id); ++ return; ++ } ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_publishTransaction, "f").call(this, rawTx); ++ txMeta.retryCount = ((_a = txMeta.retryCount) !== null && _a !== void 0 ? _a : 0) + 1; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_updateTransaction).call(this, txMeta, 'PendingTransactionTracker:transaction-retry - Retry count increased'); ++ }); ++}, _PendingTransactionTracker_isResubmitDue = function _PendingTransactionTracker_isResubmitDue(txMeta, latestBlockNumber) { ++ if (!txMeta.firstRetryBlockNumber) { ++ txMeta.firstRetryBlockNumber = latestBlockNumber; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_updateTransaction).call(this, txMeta, 'PendingTransactionTracker:#isResubmitDue - First retry block number set'); ++ } ++ const firstRetryBlockNumber = txMeta.firstRetryBlockNumber || latestBlockNumber; ++ const blocksSinceFirstRetry = Number.parseInt(latestBlockNumber, 16) - ++ Number.parseInt(firstRetryBlockNumber, 16); ++ const retryCount = txMeta.retryCount || 0; ++ // Exponential backoff to limit retries at publishing ++ // Capped at ~15 minutes between retries ++ const requiredBlocksSinceFirstRetry = Math.min(MAX_RETRY_BLOCK_DISTANCE, Math.pow(2, retryCount)); ++ return blocksSinceFirstRetry >= requiredBlocksSinceFirstRetry; ++}, _PendingTransactionTracker_checkTransaction = function _PendingTransactionTracker_checkTransaction(txMeta) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { hash, id } = txMeta; ++ if (!hash && __classPrivateFieldGet(this, _PendingTransactionTracker_beforeCheckPendingTransaction, "f").call(this, txMeta)) { ++ const error = new Error('We had an error while submitting this transaction, please try again.'); ++ error.name = 'NoTxHashError'; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_failTransaction).call(this, txMeta, error); ++ return; ++ } ++ if (__classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_isNonceTaken).call(this, txMeta)) { ++ log('Nonce already taken', id); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_dropTransaction).call(this, txMeta); ++ return; ++ } ++ try { ++ const receipt = yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getTransactionReceipt).call(this, hash); ++ const isSuccess = (receipt === null || receipt === void 0 ? void 0 : receipt.status) === RECEIPT_STATUS_SUCCESS; ++ const isFailure = (receipt === null || receipt === void 0 ? void 0 : receipt.status) === RECEIPT_STATUS_FAILURE; ++ if (isFailure) { ++ log('Transaction receipt has failed status'); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_failTransaction).call(this, txMeta, new Error('Transaction dropped or replaced')); ++ return; ++ } ++ const { blockNumber, blockHash } = receipt || {}; ++ if (isSuccess && blockNumber && blockHash) { ++ yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_onTransactionConfirmed).call(this, txMeta, Object.assign(Object.assign({}, receipt), { blockNumber, ++ blockHash })); ++ return; ++ } ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ } ++ catch (error) { ++ log('Failed to check transaction', id, error); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_warnTransaction).call(this, txMeta, error.message, 'There was a problem loading this transaction.'); ++ return; ++ } ++ if (yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_isTransactionDropped).call(this, txMeta)) { ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_dropTransaction).call(this, txMeta); ++ } ++ }); ++}, _PendingTransactionTracker_onTransactionConfirmed = function _PendingTransactionTracker_onTransactionConfirmed(txMeta, receipt) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { id } = txMeta; ++ const { blockHash } = receipt; ++ log('Transaction confirmed', id); ++ const { baseFeePerGas, timestamp: blockTimestamp } = yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getBlockByHash).call(this, blockHash, false); ++ txMeta.baseFeePerGas = baseFeePerGas; ++ txMeta.blockTimestamp = blockTimestamp; ++ txMeta.status = types_1.TransactionStatus.confirmed; ++ txMeta.txParams.gasUsed = receipt.gasUsed; ++ txMeta.txReceipt = receipt; ++ txMeta.verifiedOnBlockchain = true; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_updateTransaction).call(this, txMeta, 'PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed'); ++ this.hub.emit('transaction-confirmed', txMeta); ++ }); ++}, _PendingTransactionTracker_isTransactionDropped = function _PendingTransactionTracker_isTransactionDropped(txMeta) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { hash, id, txParams: { nonce, from }, } = txMeta; ++ /* istanbul ignore next */ ++ if (!nonce || !hash) { ++ return false; ++ } ++ const networkNextNonceHex = yield __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getNetworkTransactionCount).call(this, from); ++ const networkNextNonceNumber = parseInt(networkNextNonceHex, 16); ++ const nonceNumber = parseInt(nonce, 16); ++ if (nonceNumber >= networkNextNonceNumber) { ++ return false; ++ } ++ let droppedBlockCount = __classPrivateFieldGet(this, _PendingTransactionTracker_droppedBlockCountByHash, "f").get(hash); ++ if (droppedBlockCount === undefined) { ++ droppedBlockCount = 0; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_droppedBlockCountByHash, "f").set(hash, droppedBlockCount); ++ } ++ if (droppedBlockCount < DROPPED_BLOCK_COUNT) { ++ log('Incrementing dropped block count', { id, droppedBlockCount }); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_droppedBlockCountByHash, "f").set(hash, droppedBlockCount + 1); ++ return false; ++ } ++ log('Hit dropped block count', id); ++ __classPrivateFieldGet(this, _PendingTransactionTracker_droppedBlockCountByHash, "f").delete(hash); ++ return true; ++ }); ++}, _PendingTransactionTracker_isNonceTaken = function _PendingTransactionTracker_isNonceTaken(txMeta) { ++ const { id, txParams } = txMeta; ++ return __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getCurrentChainTransactions).call(this).some((tx) => tx.id !== id && ++ tx.txParams.from === txParams.from && ++ tx.status === types_1.TransactionStatus.confirmed && ++ tx.txParams.nonce === txParams.nonce && ++ tx.type !== types_1.TransactionType.incoming); ++}, _PendingTransactionTracker_getPendingTransactions = function _PendingTransactionTracker_getPendingTransactions() { ++ return __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_getCurrentChainTransactions).call(this).filter((tx) => tx.status === types_1.TransactionStatus.submitted && ++ !tx.verifiedOnBlockchain && ++ !tx.isUserOperation); ++}, _PendingTransactionTracker_warnTransaction = function _PendingTransactionTracker_warnTransaction(txMeta, error, message) { ++ txMeta.warning = { ++ error, ++ message, ++ }; ++ __classPrivateFieldGet(this, _PendingTransactionTracker_instances, "m", _PendingTransactionTracker_updateTransaction).call(this, txMeta, 'PendingTransactionTracker:#warnTransaction - Warning added'); ++}, _PendingTransactionTracker_failTransaction = function _PendingTransactionTracker_failTransaction(txMeta, error) { ++ log('Transaction failed', txMeta.id, error); ++ this.hub.emit('transaction-failed', txMeta, error); ++}, _PendingTransactionTracker_dropTransaction = function _PendingTransactionTracker_dropTransaction(txMeta) { ++ log('Transaction dropped', txMeta.id); ++ this.hub.emit('transaction-dropped', txMeta); ++}, _PendingTransactionTracker_updateTransaction = function _PendingTransactionTracker_updateTransaction(txMeta, note) { ++ this.hub.emit('transaction-updated', txMeta, note); ++}, _PendingTransactionTracker_getTransactionReceipt = function _PendingTransactionTracker_getTransactionReceipt(txHash) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield (0, controller_utils_1.query)(__classPrivateFieldGet(this, _PendingTransactionTracker_getEthQuery, "f").call(this), 'getTransactionReceipt', [txHash]); ++ }); ++}, _PendingTransactionTracker_getBlockByHash = function _PendingTransactionTracker_getBlockByHash(blockHash, includeTransactionDetails) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield (0, controller_utils_1.query)(__classPrivateFieldGet(this, _PendingTransactionTracker_getEthQuery, "f").call(this), 'getBlockByHash', [ ++ blockHash, ++ includeTransactionDetails, ++ ]); ++ }); ++}, _PendingTransactionTracker_getNetworkTransactionCount = function _PendingTransactionTracker_getNetworkTransactionCount(address) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield (0, controller_utils_1.query)(__classPrivateFieldGet(this, _PendingTransactionTracker_getEthQuery, "f").call(this), 'getTransactionCount', [address]); ++ }); ++}, _PendingTransactionTracker_getCurrentChainTransactions = function _PendingTransactionTracker_getCurrentChainTransactions() { ++ const currentChainId = __classPrivateFieldGet(this, _PendingTransactionTracker_getChainId, "f").call(this); ++ return __classPrivateFieldGet(this, _PendingTransactionTracker_getTransactions, "f").call(this).filter((tx) => tx.chainId === currentChainId); ++}; ++//# sourceMappingURL=PendingTransactionTracker.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js.map +new file mode 100644 +index 0000000..a28fb95 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/PendingTransactionTracker.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"PendingTransactionTracker.js","sourceRoot":"","sources":["../../src/helpers/PendingTransactionTracker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AAGnD,2CAAqD;AACrD,oDAAkC;AAGlC,sCAA0C;AAE1C,oCAA8D;AAE9D;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,MAAM,wBAAwB,GAAG;IAC/B,qCAAqC;IACrC,mBAAmB;IACnB,8BAA8B;IAC9B,qDAAqD;IACrD,iBAAiB;IACjB,eAAe;CAChB,CAAC;AAEF,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBA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,IAAI,CAAC,qBAAqB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC,+GAGC,MAAe;;QAEf,OAAO,MAAM,IAAA,wBAAK,EAAC,uBAAA,IAAI,8CAAa,MAAjB,IAAI,CAAe,EAAE,uBAAuB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7E,CAAC;kGAGC,SAAiB,EACjB,yBAAkC;;QAIlC,OAAO,MAAM,IAAA,wBAAK,EAAC,uBAAA,IAAI,8CAAa,MAAjB,IAAI,CAAe,EAAE,gBAAgB,EAAE;YACxD,SAAS;YACT,yBAAyB;SAC1B,CAAC,CAAC;IACL,CAAC;0HAEiC,OAAe;;QAC/C,OAAO,MAAM,IAAA,wBAAK,EAAC,uBAAA,IAAI,8CAAa,MAAjB,IAAI,CAAe,EAAE,qBAAqB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC;;IAGC,MAAM,cAAc,GAAG,uBAAA,IAAI,6CAAY,MAAhB,IAAI,CAAc,CAAC;IAE1C,OAAO,uBAAA,IAAI,kDAAiB,MAArB,IAAI,CAAmB,CAAC,MAAM,CACnC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,KAAK,cAAc,CACtC,CAAC;AACJ,CAAC","sourcesContent":["import { query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { BlockTracker } from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport EventEmitter from 'events';\nimport type { NonceTracker } from 'nonce-tracker';\n\nimport { projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionReceipt } from '../types';\nimport { TransactionStatus, TransactionType } from '../types';\n\n/**\n * We wait this many blocks before emitting a 'transaction-dropped' event\n * This is because we could be talking to a node that is out of sync\n */\nconst DROPPED_BLOCK_COUNT = 3;\n\nconst RECEIPT_STATUS_SUCCESS = '0x1';\nconst RECEIPT_STATUS_FAILURE = '0x0';\nconst MAX_RETRY_BLOCK_DISTANCE = 50;\n\nconst KNOWN_TRANSACTION_ERRORS = [\n 'replacement transaction underpriced',\n 'known transaction',\n 'gas price too low to replace',\n 'transaction with the same hash was already imported',\n 'gateway timeout',\n 'nonce too low',\n];\n\nconst log = createModuleLogger(projectLogger, 'pending-transactions');\n\ntype SuccessfulTransactionReceipt = TransactionReceipt & {\n blockNumber: string;\n blockHash: string;\n};\n\ntype Events = {\n 'transaction-confirmed': [txMeta: TransactionMeta];\n 'transaction-dropped': [txMeta: TransactionMeta];\n 'transaction-failed': [txMeta: TransactionMeta, error: Error];\n 'transaction-updated': [txMeta: TransactionMeta, note: string];\n};\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface PendingTransactionTrackerEventEmitter extends EventEmitter {\n on(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): this;\n\n emit(eventName: T, ...args: Events[T]): boolean;\n}\n\nexport class PendingTransactionTracker {\n hub: PendingTransactionTrackerEventEmitter;\n\n #approveTransaction: (transactionId: string) => Promise;\n\n #blockTracker: BlockTracker;\n\n #droppedBlockCountByHash: Map;\n\n #getChainId: () => string;\n\n #getEthQuery: () => EthQuery;\n\n #getTransactions: () => TransactionMeta[];\n\n #isResubmitEnabled: boolean;\n\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #listener: any;\n\n #nonceTracker: NonceTracker;\n\n #onStateChange: (listener: () => void) => void;\n\n #publishTransaction: (rawTx: string) => Promise;\n\n #running: boolean;\n\n #beforeCheckPendingTransaction: (transactionMeta: TransactionMeta) => boolean;\n\n #beforePublish: (transactionMeta: TransactionMeta) => boolean;\n\n constructor({\n approveTransaction,\n blockTracker,\n getChainId,\n getEthQuery,\n getTransactions,\n isResubmitEnabled,\n nonceTracker,\n onStateChange,\n publishTransaction,\n hooks,\n }: {\n approveTransaction: (transactionId: string) => Promise;\n blockTracker: BlockTracker;\n getChainId: () => string;\n getEthQuery: () => EthQuery;\n getTransactions: () => TransactionMeta[];\n isResubmitEnabled?: boolean;\n nonceTracker: NonceTracker;\n onStateChange: (listener: () => void) => void;\n publishTransaction: (rawTx: string) => Promise;\n hooks?: {\n beforeCheckPendingTransaction?: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n beforePublish?: (transactionMeta: TransactionMeta) => boolean;\n };\n }) {\n this.hub = new EventEmitter() as PendingTransactionTrackerEventEmitter;\n\n this.#approveTransaction = approveTransaction;\n this.#blockTracker = blockTracker;\n this.#droppedBlockCountByHash = new Map();\n this.#getChainId = getChainId;\n this.#getEthQuery = getEthQuery;\n this.#getTransactions = getTransactions;\n this.#isResubmitEnabled = isResubmitEnabled ?? true;\n this.#listener = this.#onLatestBlock.bind(this);\n this.#nonceTracker = nonceTracker;\n this.#onStateChange = onStateChange;\n this.#publishTransaction = publishTransaction;\n this.#running = false;\n this.#beforePublish = hooks?.beforePublish ?? (() => true);\n this.#beforeCheckPendingTransaction =\n hooks?.beforeCheckPendingTransaction ?? (() => true);\n\n this.#onStateChange(() => {\n const pendingTransactions = this.#getPendingTransactions();\n\n if (pendingTransactions.length) {\n this.#start();\n } else {\n this.#stop();\n }\n });\n }\n\n #start() {\n if (this.#running) {\n return;\n }\n\n this.#blockTracker.on('latest', this.#listener);\n this.#running = true;\n\n log('Started polling');\n }\n\n #stop() {\n if (!this.#running) {\n return;\n }\n\n this.#blockTracker.removeListener('latest', this.#listener);\n this.#running = false;\n\n log('Stopped polling');\n }\n\n async #onLatestBlock(latestBlockNumber: string) {\n const nonceGlobalLock = await this.#nonceTracker.getGlobalLock();\n\n try {\n await this.#checkTransactions();\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check transactions', error);\n } finally {\n nonceGlobalLock.releaseLock();\n }\n\n try {\n await this.#resubmitTransactions(latestBlockNumber);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to resubmit transactions', error);\n }\n }\n\n async #checkTransactions() {\n log('Checking transactions');\n\n const pendingTransactions = this.#getPendingTransactions();\n\n if (!pendingTransactions.length) {\n log('No pending transactions to check');\n return;\n }\n\n log('Found pending transactions to check', {\n count: pendingTransactions.length,\n ids: pendingTransactions.map((tx) => tx.id),\n });\n\n await Promise.all(\n pendingTransactions.map((tx) => this.#checkTransaction(tx)),\n );\n }\n\n async #resubmitTransactions(latestBlockNumber: string) {\n if (!this.#isResubmitEnabled || !this.#running) {\n return;\n }\n\n log('Resubmitting transactions');\n\n const pendingTransactions = this.#getPendingTransactions();\n\n if (!pendingTransactions.length) {\n log('No pending transactions to resubmit');\n return;\n }\n\n log('Found pending transactions to resubmit', {\n count: pendingTransactions.length,\n ids: pendingTransactions.map((tx) => tx.id),\n });\n\n for (const txMeta of pendingTransactions) {\n try {\n await this.#resubmitTransaction(txMeta, latestBlockNumber);\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n /* istanbul ignore next */\n const errorMessage =\n error.value?.message?.toLowerCase() || error.message.toLowerCase();\n\n if (this.#isKnownTransactionError(errorMessage)) {\n log('Ignoring known transaction error', errorMessage);\n return;\n }\n\n this.#warnTransaction(\n txMeta,\n error.message,\n 'There was an error when resubmitting this transaction.',\n );\n }\n }\n }\n\n #isKnownTransactionError(errorMessage: string) {\n return KNOWN_TRANSACTION_ERRORS.some((knownError) =>\n errorMessage.includes(knownError),\n );\n }\n\n async #resubmitTransaction(\n txMeta: TransactionMeta,\n latestBlockNumber: string,\n ) {\n if (!this.#isResubmitDue(txMeta, latestBlockNumber)) {\n return;\n }\n\n log('Resubmitting transaction', txMeta.id);\n\n const { rawTx } = txMeta;\n\n if (!this.#beforePublish(txMeta)) {\n return;\n }\n\n if (!rawTx?.length) {\n log('Approving transaction as no raw value');\n await this.#approveTransaction(txMeta.id);\n return;\n }\n\n await this.#publishTransaction(rawTx);\n\n txMeta.retryCount = (txMeta.retryCount ?? 0) + 1;\n\n this.#updateTransaction(\n txMeta,\n 'PendingTransactionTracker:transaction-retry - Retry count increased',\n );\n }\n\n #isResubmitDue(txMeta: TransactionMeta, latestBlockNumber: string): boolean {\n if (!txMeta.firstRetryBlockNumber) {\n txMeta.firstRetryBlockNumber = latestBlockNumber;\n\n this.#updateTransaction(\n txMeta,\n 'PendingTransactionTracker:#isResubmitDue - First retry block number set',\n );\n }\n\n const firstRetryBlockNumber =\n txMeta.firstRetryBlockNumber || latestBlockNumber;\n\n const blocksSinceFirstRetry =\n Number.parseInt(latestBlockNumber, 16) -\n Number.parseInt(firstRetryBlockNumber, 16);\n\n const retryCount = txMeta.retryCount || 0;\n\n // Exponential backoff to limit retries at publishing\n // Capped at ~15 minutes between retries\n const requiredBlocksSinceFirstRetry = Math.min(\n MAX_RETRY_BLOCK_DISTANCE,\n Math.pow(2, retryCount),\n );\n\n return blocksSinceFirstRetry >= requiredBlocksSinceFirstRetry;\n }\n\n async #checkTransaction(txMeta: TransactionMeta) {\n const { hash, id } = txMeta;\n\n if (!hash && this.#beforeCheckPendingTransaction(txMeta)) {\n const error = new Error(\n 'We had an error while submitting this transaction, please try again.',\n );\n\n error.name = 'NoTxHashError';\n\n this.#failTransaction(txMeta, error);\n\n return;\n }\n\n if (this.#isNonceTaken(txMeta)) {\n log('Nonce already taken', id);\n this.#dropTransaction(txMeta);\n return;\n }\n\n try {\n const receipt = await this.#getTransactionReceipt(hash);\n const isSuccess = receipt?.status === RECEIPT_STATUS_SUCCESS;\n const isFailure = receipt?.status === RECEIPT_STATUS_FAILURE;\n\n if (isFailure) {\n log('Transaction receipt has failed status');\n\n this.#failTransaction(\n txMeta,\n new Error('Transaction dropped or replaced'),\n );\n\n return;\n }\n\n const { blockNumber, blockHash } = receipt || {};\n\n if (isSuccess && blockNumber && blockHash) {\n await this.#onTransactionConfirmed(txMeta, {\n ...receipt,\n blockNumber,\n blockHash,\n });\n\n return;\n }\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n log('Failed to check transaction', id, error);\n\n this.#warnTransaction(\n txMeta,\n error.message,\n 'There was a problem loading this transaction.',\n );\n\n return;\n }\n\n if (await this.#isTransactionDropped(txMeta)) {\n this.#dropTransaction(txMeta);\n }\n }\n\n async #onTransactionConfirmed(\n txMeta: TransactionMeta,\n receipt: SuccessfulTransactionReceipt,\n ) {\n const { id } = txMeta;\n const { blockHash } = receipt;\n\n log('Transaction confirmed', id);\n\n const { baseFeePerGas, timestamp: blockTimestamp } =\n await this.#getBlockByHash(blockHash, false);\n\n txMeta.baseFeePerGas = baseFeePerGas;\n txMeta.blockTimestamp = blockTimestamp;\n txMeta.status = TransactionStatus.confirmed;\n txMeta.txParams.gasUsed = receipt.gasUsed;\n txMeta.txReceipt = receipt;\n txMeta.verifiedOnBlockchain = true;\n\n this.#updateTransaction(\n txMeta,\n 'PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed',\n );\n\n this.hub.emit('transaction-confirmed', txMeta);\n }\n\n async #isTransactionDropped(txMeta: TransactionMeta) {\n const {\n hash,\n id,\n txParams: { nonce, from },\n } = txMeta;\n\n /* istanbul ignore next */\n if (!nonce || !hash) {\n return false;\n }\n\n const networkNextNonceHex = await this.#getNetworkTransactionCount(from);\n const networkNextNonceNumber = parseInt(networkNextNonceHex, 16);\n const nonceNumber = parseInt(nonce, 16);\n\n if (nonceNumber >= networkNextNonceNumber) {\n return false;\n }\n\n let droppedBlockCount = this.#droppedBlockCountByHash.get(hash);\n\n if (droppedBlockCount === undefined) {\n droppedBlockCount = 0;\n this.#droppedBlockCountByHash.set(hash, droppedBlockCount);\n }\n\n if (droppedBlockCount < DROPPED_BLOCK_COUNT) {\n log('Incrementing dropped block count', { id, droppedBlockCount });\n this.#droppedBlockCountByHash.set(hash, droppedBlockCount + 1);\n return false;\n }\n\n log('Hit dropped block count', id);\n\n this.#droppedBlockCountByHash.delete(hash);\n return true;\n }\n\n #isNonceTaken(txMeta: TransactionMeta): boolean {\n const { id, txParams } = txMeta;\n\n return this.#getCurrentChainTransactions().some(\n (tx) =>\n tx.id !== id &&\n tx.txParams.from === txParams.from &&\n tx.status === TransactionStatus.confirmed &&\n tx.txParams.nonce === txParams.nonce &&\n tx.type !== TransactionType.incoming,\n );\n }\n\n #getPendingTransactions(): TransactionMeta[] {\n return this.#getCurrentChainTransactions().filter(\n (tx) =>\n tx.status === TransactionStatus.submitted &&\n !tx.verifiedOnBlockchain &&\n !tx.isUserOperation,\n );\n }\n\n #warnTransaction(txMeta: TransactionMeta, error: string, message: string) {\n txMeta.warning = {\n error,\n message,\n };\n\n this.#updateTransaction(\n txMeta,\n 'PendingTransactionTracker:#warnTransaction - Warning added',\n );\n }\n\n #failTransaction(txMeta: TransactionMeta, error: Error) {\n log('Transaction failed', txMeta.id, error);\n this.hub.emit('transaction-failed', txMeta, error);\n }\n\n #dropTransaction(txMeta: TransactionMeta) {\n log('Transaction dropped', txMeta.id);\n this.hub.emit('transaction-dropped', txMeta);\n }\n\n #updateTransaction(txMeta: TransactionMeta, note: string) {\n this.hub.emit('transaction-updated', txMeta, note);\n }\n\n async #getTransactionReceipt(\n txHash?: string,\n ): Promise {\n return await query(this.#getEthQuery(), 'getTransactionReceipt', [txHash]);\n }\n\n async #getBlockByHash(\n blockHash: string,\n includeTransactionDetails: boolean,\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise {\n return await query(this.#getEthQuery(), 'getBlockByHash', [\n blockHash,\n includeTransactionDetails,\n ]);\n }\n\n async #getNetworkTransactionCount(address: string): Promise {\n return await query(this.#getEthQuery(), 'getTransactionCount', [address]);\n }\n\n #getCurrentChainTransactions(): TransactionMeta[] {\n const currentChainId = this.#getChainId();\n\n return this.#getTransactions().filter(\n (tx) => tx.chainId === currentChainId,\n );\n }\n}\n"]} +\ 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 fc7f49b..b7c9355 100644 +--- a/node_modules/@metamask/transaction-controller/dist/index.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/index.d.ts +@@ -1,3 +1,5 @@ + export * from './TransactionController'; +-export { isEIP1559Transaction } from './utils'; ++export { isEIP1559Transaction, normalizeTransactionParams } from './utils'; ++export * from './types'; ++export { mergeGasFeeEstimates, getGasFeeFlow } from './utils/gas-flow'; + //# 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..0818eb8 100644 +--- a/node_modules/@metamask/transaction-controller/dist/index.js ++++ b/node_modules/@metamask/transaction-controller/dist/index.js +@@ -14,8 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.isEIP1559Transaction = void 0; ++exports.getGasFeeFlow = exports.mergeGasFeeEstimates = exports.normalizeTransactionParams = exports.isEIP1559Transaction = void 0; + __exportStar(require("./TransactionController"), exports); + var utils_1 = require("./utils"); + Object.defineProperty(exports, "isEIP1559Transaction", { enumerable: true, get: function () { return utils_1.isEIP1559Transaction; } }); ++Object.defineProperty(exports, "normalizeTransactionParams", { enumerable: true, get: function () { return utils_1.normalizeTransactionParams; } }); ++__exportStar(require("./types"), exports); ++var gas_flow_1 = require("./utils/gas-flow"); ++Object.defineProperty(exports, "mergeGasFeeEstimates", { enumerable: true, get: function () { return gas_flow_1.mergeGasFeeEstimates; } }); ++Object.defineProperty(exports, "getGasFeeFlow", { enumerable: true, get: function () { return gas_flow_1.getGasFeeFlow; } }); + //# sourceMappingURL=index.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/index.js.map b/node_modules/@metamask/transaction-controller/dist/index.js.map +deleted file mode 100644 +index a4460fa..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/index.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA","sourcesContent":["export * from './TransactionController';\nexport { isEIP1559Transaction } from './utils';\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/logger.d.ts b/node_modules/@metamask/transaction-controller/dist/logger.d.ts +new file mode 100644 +index 0000000..43ad63f +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/logger.d.ts +@@ -0,0 +1,6 @@ ++/// ++import { createModuleLogger } from '@metamask/utils'; ++export declare const projectLogger: import("debug").Debugger; ++export declare const incomingTransactionsLogger: import("debug").Debugger; ++export { createModuleLogger }; ++//# sourceMappingURL=logger.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/logger.js b/node_modules/@metamask/transaction-controller/dist/logger.js +new file mode 100644 +index 0000000..bb55b17 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/logger.js +@@ -0,0 +1,9 @@ ++"use strict"; ++/* istanbul ignore file */ ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.createModuleLogger = exports.incomingTransactionsLogger = exports.projectLogger = void 0; ++const utils_1 = require("@metamask/utils"); ++Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } }); ++exports.projectLogger = (0, utils_1.createProjectLogger)('transaction-controller'); ++exports.incomingTransactionsLogger = (0, utils_1.createModuleLogger)(exports.projectLogger, 'incoming-transactions'); ++//# sourceMappingURL=logger.js.map +\ 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 688af82..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.d.ts ++++ /dev/null +@@ -1,64 +0,0 @@ +-import { TransactionMeta } from '../TransactionController'; +-export declare const ethTxsMock: (ethTxHash: string) => ({ +- blockNumber: string; +- confirmations: string; +- contractAddress: string; +- cumulativeGasUsed: string; +- from: string; +- gas: string; +- gasPrice: string; +- gasUsed: string; +- hash: string; +- input: string; +- isError: string; +- nonce: string; +- timeStamp: string; +- to: string; +- transactionIndex: string; +- txreceipt_status: string; +- value: string; +-} | { +- blockNumber: string; +- confirmations: string; +- contractAddress: string; +- cumulativeGasUsed: string; +- from: string; +- gas: string; +- gasPrice: string; +- gasUsed: string; +- hash: string; +- input: string; +- isError: string; +- nonce: string; +- timeStamp: string; +- transactionIndex: string; +- txreceipt_status: string; +- value: string; +- to?: undefined; +-})[]; +-export declare const tokenTxsMock: (tokenTxHash: string) => { +- blockNumber: string; +- timeStamp: string; +- hash: string; +- nonce: string; +- blockHash: string; +- from: string; +- contractAddress: string; +- to: string; +- value: string; +- tokenName: string; +- tokenSymbol: string; +- tokenDecimal: string; +- transactionIndex: string; +- gas: string; +- gasPrice: string; +- gasUsed: string; +- cumulativeGasUsed: string; +- input: string; +- confirmations: string; +-}[]; +-export declare const txsInStateMock: (ethTxHash: string, tokenTxHash: string) => TransactionMeta[]; +-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 c9350fa..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":"AACA,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 d17aabf..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js ++++ /dev/null +@@ -1,516 +0,0 @@ +-"use strict"; +-Object.defineProperty(exports, "__esModule", { value: true }); +-exports.txsInStateWithOutdatedStatusAndGasDataMock = exports.txsInStateWithOutdatedGasDataMock = exports.txsInStateWithOutdatedStatusMock = exports.txsInStateMock = exports.tokenTxsMock = exports.ethTxsMock = void 0; +-const controller_utils_1 = require("@metamask/controller-utils"); +-const TransactionController_1 = require("../TransactionController"); +-const ethTxsMock = (ethTxHash) => [ +- { +- blockNumber: '4535101', +- confirmations: '10', +- contractAddress: '', +- cumulativeGasUsed: '120607', +- from: '0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1', +- gas: '335208', +- gasPrice: '10000000000', +- gasUsed: '21000', +- hash: ethTxHash, +- input: '0x', +- isError: '0', +- nonce: '9', +- timeStamp: '1543596286', +- to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', +- transactionIndex: '2', +- txreceipt_status: '1', +- value: '100000000000000000', +- }, +- { +- blockNumber: '4535108', +- confirmations: '3', +- contractAddress: '', +- cumulativeGasUsed: '693910', +- from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', +- gas: '335208', +- gasPrice: '20000000000', +- gasUsed: '21000', +- hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff92', +- input: '0x', +- isError: '0', +- nonce: '0', +- timeStamp: '1543596378', +- to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23', +- transactionIndex: '12', +- txreceipt_status: '1', +- value: '50000000000000000', +- }, +- { +- blockNumber: '4535105', +- confirmations: '4', +- contractAddress: '', +- cumulativeGasUsed: '693910', +- from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', +- gas: '335208', +- gasPrice: '20000000000', +- gasUsed: '21000', +- hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff91', +- input: '0x', +- isError: '0', +- nonce: '1', +- timeStamp: '1543596356', +- transactionIndex: '13', +- txreceipt_status: '1', +- value: '50000000000000000', +- }, +- { +- blockNumber: '4535106', +- confirmations: '4', - contractAddress: '', - cumulativeGasUsed: '693910', - from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207', @@ -3409,637 +4636,2716 @@ index d17aabf..0000000 -exports.txsInStateWithOutdatedStatusAndGasDataMock = txsInStateWithOutdatedStatusAndGasDataMock; -//# sourceMappingURL=txsMock.js.map \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map b/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map -deleted file mode 100644 -index 99e8f02..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"txsMock.js","sourceRoot":"","sources":["../../src/mocks/txsMock.ts"],"names":[],"mappings":";;;AAAA,iEAAmD;AACnD,oEAA8E;AAEvE,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC;IAC/C;QACE,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,EAAE;QACnB,iBAAiB,EAAE,QAAQ;QAC3B,IAAI,EAAE,4CAA4C;QAClD,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,aAAa;QACvB,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,YAAY;QACvB,EAAE,EAAE,4CAA4C;QAChD,gBAAgB,EAAE,GAAG;QACrB,gBAAgB,EAAE,GAAG;QACrB,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,GAAG;QAClB,eAAe,EAAE,EAAE;QACnB,iBAAiB,EAAE,QAAQ;QAC3B,IAAI,EAAE,4CAA4C;QAClD,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,aAAa;QACvB,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,oEAAoE;QAC1E,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,YAAY;QACvB,EAAE,EAAE,4CAA4C;QAChD,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,GAAG;QACrB,KAAK,EAAE,mBAA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,KAAK;KACvB;CACF,CAAC;AAxCW,QAAA,0CAA0C,8CAwCrD","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport { TransactionMeta, TransactionStatus } from '../TransactionController';\n\nexport const ethTxsMock = (ethTxHash: string) => [\n {\n blockNumber: '4535101',\n confirmations: '10',\n contractAddress: '',\n cumulativeGasUsed: '120607',\n from: '0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1',\n gas: '335208',\n gasPrice: '10000000000',\n gasUsed: '21000',\n hash: ethTxHash,\n input: '0x',\n isError: '0',\n nonce: '9',\n timeStamp: '1543596286',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n transactionIndex: '2',\n txreceipt_status: '1',\n value: '100000000000000000',\n },\n {\n blockNumber: '4535108',\n confirmations: '3',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff92',\n input: '0x',\n isError: '0',\n nonce: '0',\n timeStamp: '1543596378',\n to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23',\n transactionIndex: '12',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n {\n blockNumber: '4535105',\n confirmations: '4',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff91',\n input: '0x',\n isError: '0',\n nonce: '1',\n timeStamp: '1543596356',\n transactionIndex: '13',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n {\n blockNumber: '4535106',\n confirmations: '4',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973139fc7219dbadcbb5629730cfe65e9f9cb15ff91',\n input: '0x11',\n isError: '0',\n nonce: '3',\n timeStamp: '1543596356',\n to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23',\n transactionIndex: '13',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n];\n\nexport const tokenTxsMock = (tokenTxHash: string) => [\n {\n blockNumber: '8222239',\n timeStamp: '1564091067',\n hash: tokenTxHash,\n nonce: '2329',\n blockHash:\n '0x3c30a9be9aea7be13caad419444140c11839d72e70479ec7e9c6d8bd08c533bc',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '69',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n cumulativeGasUsed: '3203881',\n input: 'deprecated',\n confirmations: '3659676',\n },\n {\n blockNumber: '8222250',\n timeStamp: '1564091247',\n hash: '0xdcd1c8bee545d3f76d80b20a23ad44276ba2e376681228eb4570cf3518491279',\n nonce: '2330',\n blockHash:\n '0x16986dd66bedb20a5b846ec2b6c0ecaa62f1c4b51fac58c1326101fd9126dd82',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '40',\n gas: '594268',\n gasPrice: '20000000000',\n gasUsed: '579268',\n cumulativeGasUsed: '2009011',\n input: 'deprecated',\n confirmations: '3659665',\n },\n {\n blockNumber: '8223771',\n timeStamp: '1564111652',\n hash: '0x070369e6f560b0deca52e050ff1a961fa7b688bbec5cea08435921c9d9b0f52e',\n nonce: '2333',\n blockHash:\n '0x0aff8b36881be99df6d176d7c64c2171672c0483684a10c112d2c90fefe30a0a',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '132',\n gas: '583810',\n gasPrice: '6000000000',\n gasUsed: '568810',\n cumulativeGasUsed: '6956245',\n input: 'deprecated',\n confirmations: '3658144',\n },\n {\n blockNumber: '8224850',\n timeStamp: '1564126442',\n hash: '0x8ef20ec9597c8c2e945bcc76d2668e5d3bb088b081fe8c5b5af2e1cbd315a20f',\n nonce: '31',\n blockHash:\n '0xb80d4d861ecb7a3cb14e591c0aaeb226842d0267772affa2acc1a590c7535647',\n from: '0x6c70e3563cef0c6835703bb2664c9f59a92353e4',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '10000000000000000000',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '169',\n gas: '78447',\n gasPrice: '2000000000',\n gasUsed: '52298',\n cumulativeGasUsed: '7047823',\n input: 'deprecated',\n confirmations: '3657065',\n },\n {\n blockNumber: '8228053',\n timeStamp: '1564168901',\n hash: '0xa0f2d7b558bb3cc28fa568f6feb8ed30eb28a01a674d7c0d4ae603fc691e6020',\n nonce: '2368',\n blockHash:\n '0x62c515ea049842c968ca67499f47a32a11394364d319d9c9cc0a0211652a7294',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '43',\n gas: '567156',\n gasPrice: '3000000000',\n gasUsed: '552156',\n cumulativeGasUsed: '3048261',\n input: 'deprecated',\n confirmations: '3653862',\n },\n {\n blockNumber: '8315335',\n timeStamp: '1565339223',\n hash: '0x464df60fe00b6dd04c9e8ab341d02af9b10a619d2fcd60fd2971f10edf12118f',\n nonce: '206760',\n blockHash:\n '0x98275388ef6708debe35ac7bf2e30143c9b1fd9e0e457ca03598fc1f4209e273',\n from: '0x00cfbbaf7ddb3a1476767101c12a0162e241fbad',\n contractAddress: '0x4dc3643dbc642b72c158e7f3d2ff232df61cb6ce',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n tokenName: 'Amber',\n tokenSymbol: 'AMB',\n tokenDecimal: '18',\n transactionIndex: '186',\n gas: '60000',\n gasPrice: '2000000000',\n gasUsed: '52108',\n cumulativeGasUsed: '7490707',\n input: 'deprecated',\n confirmations: '3566580',\n },\n {\n blockNumber: '8350846',\n timeStamp: '1565815049',\n hash: '0xc0682327ad3efd56dfa33e8206b4e09efad4e419a6191076069d217e3ee2341f',\n nonce: '2506',\n blockHash:\n '0xd0aa3c0e319fdfeb21b0192cf77b9760b8668060a5977a5f10f8413531083afa',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '4',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '48',\n gas: '578737',\n gasPrice: '3000000000',\n gasUsed: '518737',\n cumulativeGasUsed: '2848015',\n input: 'deprecated',\n confirmations: '3531069',\n },\n {\n blockNumber: '8350859',\n timeStamp: '1565815221',\n hash: '0x989ea9f3ee576fa43957f44363e839adf1a4a397c3d8392a4f7cbbf7949fd0ae',\n nonce: '2',\n blockHash:\n '0xb9cf1d29c665c052e3831b5754903e539c5b0b1d33b8bcab6cd2d450764d601f',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x09cabec1ead1c0ba254b09efb3ee13841712be14',\n value: '10000000000000000000',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '31',\n gas: '60734',\n gasPrice: '1000000000',\n gasUsed: '54745',\n cumulativeGasUsed: '7833857',\n input: 'deprecated',\n confirmations: '3531056',\n },\n {\n blockNumber: '8679548',\n timeStamp: '1570244087',\n hash: '0xc0016b89b3b525b30d73f242653b0d80ec3ebf285376dff5bb52cef3261498b2',\n nonce: '3',\n blockHash:\n '0x1ceb2f8b83087f010773e2acf63d1526633c8a884bd1980f118a1bba576be69f',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '56',\n gas: '993379',\n gasPrice: '1440000000',\n gasUsed: '647253',\n cumulativeGasUsed: '3562204',\n input: 'deprecated',\n confirmations: '3202367',\n },\n {\n blockNumber: '8679548',\n timeStamp: '1570244087',\n hash: '0xc0016b89b3b525b30d73f242653b0d80ec3ebf285376dff5bb52cef3261498b2',\n nonce: '3',\n blockHash:\n '0x1ceb2f8b83087f010773e2acf63d1526633c8a884bd1980f118a1bba576be69f',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '56',\n gas: '993379',\n gasPrice: '1440000000',\n gasUsed: '647253',\n cumulativeGasUsed: '3562204',\n input: 'deprecated',\n confirmations: '3202367',\n },\n {\n blockNumber: '8694142',\n timeStamp: '1570440625',\n hash: '0xd8397138bb93d56e50d01e92a9eae99ebd3ae28844acdaa4663976a5501116cf',\n nonce: '2837',\n blockHash:\n '0xba45dd64e71e146066af9b6d2dd3bc5d72f4a3399148c155dced74c139fc3c51',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '217',\n gas: '600632',\n gasPrice: '9000000000',\n gasUsed: '570632',\n cumulativeGasUsed: '9023725',\n input: 'deprecated',\n confirmations: '3187773',\n },\n {\n blockNumber: '10877041',\n timeStamp: '1600310867',\n hash: '0xc8bd16b6b41b4c24849eb6869702e1489c808cb5b125b01f084e38fefcb5ea77',\n nonce: '4',\n blockHash:\n '0x7fa16a022bcf1f69c2d7adf6bd7d3f058e808eec5c66aaa910dfa8016a5333d1',\n from: '0x090d4613473dee047c3f2706764f49e0821d256e',\n contractAddress: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '400000000000000000000',\n tokenName: 'Uniswap',\n tokenSymbol: 'UNI',\n tokenDecimal: '18',\n transactionIndex: '42',\n gas: '90038',\n gasPrice: '550000000000',\n gasUsed: '81853',\n cumulativeGasUsed: '3163540',\n input: 'deprecated',\n confirmations: '1004874',\n },\n {\n blockNumber: '10877897',\n timeStamp: '1600321973',\n hash: '0xa7162489faef826ee77862ed5210b01726524f09428f69842118dad394842d62',\n nonce: '6',\n blockHash:\n '0xa74eb9d16f65f307dde4ce58c813c981b28f242edf1090ee2ac42caac9dccaca',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',\n to: '0x5e736f1f25992b2cad20ded179a52823d3d24b26',\n value: '400000000000000000000',\n tokenName: 'Uniswap',\n tokenSymbol: 'UNI',\n tokenDecimal: '18',\n transactionIndex: '86',\n gas: '60759',\n gasPrice: '640000000000',\n gasUsed: '25506',\n cumulativeGasUsed: '4408393',\n input: 'deprecated',\n confirmations: '1004018',\n },\n];\n\nexport const txsInStateMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: '0x5208',\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedStatusMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: '0x5208',\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedGasDataMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedStatusAndGasDataMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n"]} +diff --git a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map b/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map +deleted file mode 100644 +index 99e8f02..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/mocks/txsMock.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"txsMock.js","sourceRoot":"","sources":["../../src/mocks/txsMock.ts"],"names":[],"mappings":";;;AAAA,iEAAmD;AACnD,oEAA8E;AAEvE,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC;IAC/C;QACE,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,EAAE;QACnB,iBAAiB,EAAE,QAAQ;QAC3B,IAAI,EAAE,4CAA4C;QAClD,GAAG,EAAE,QAAQ;QACb,QAAQ,EAAE,aAAa;QACvB,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,GAAG;QACZ,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,YAAY;QACvB,EAAE,EAAE,4CAA4C;QAChD,gBAAgB,EAAE,GAAG;QACrB,gBAAgB,EAAE,GAAG;QACrB,KAAK,EAAE,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,WAAW;QAC5B,eAAe,EAAE,IAAI;KACtB;IACD;QACE,EAAE,EAAE,oBAAoB;QACxB,OAAO,EAAE,IAAA,wBAAK,EAAC,CAAC,CAAC;QACjB,MAAM,EAAE,yCAAiB,CAAC,QAAQ;QAClC,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;YACX,IAAI,EAAE,4CAA4C;YAClD,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,SAAS;YACd,QAAQ,EAAE,aAAa;YACvB,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,MAAM;YACb,EAAE,EAAE,4CAA4C;YAChD,KAAK,EAAE,oBAAoB;SAC5B;QACD,eAAe,EAAE,SAAS;QAC1B,eAAe,EAAE,KAAK;KACvB;CACF,CAAC;AAxCW,QAAA,0CAA0C,8CAwCrD","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport { TransactionMeta, TransactionStatus } from '../TransactionController';\n\nexport const ethTxsMock = (ethTxHash: string) => [\n {\n blockNumber: '4535101',\n confirmations: '10',\n contractAddress: '',\n cumulativeGasUsed: '120607',\n from: '0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1',\n gas: '335208',\n gasPrice: '10000000000',\n gasUsed: '21000',\n hash: ethTxHash,\n input: '0x',\n isError: '0',\n nonce: '9',\n timeStamp: '1543596286',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n transactionIndex: '2',\n txreceipt_status: '1',\n value: '100000000000000000',\n },\n {\n blockNumber: '4535108',\n confirmations: '3',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff92',\n input: '0x',\n isError: '0',\n nonce: '0',\n timeStamp: '1543596378',\n to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23',\n transactionIndex: '12',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n {\n blockNumber: '4535105',\n confirmations: '4',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973339fc7219dbadcbb5629730cfe65e9f9cb15ff91',\n input: '0x',\n isError: '0',\n nonce: '1',\n timeStamp: '1543596356',\n transactionIndex: '13',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n {\n blockNumber: '4535106',\n confirmations: '4',\n contractAddress: '',\n cumulativeGasUsed: '693910',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n gas: '335208',\n gasPrice: '20000000000',\n gasUsed: '21000',\n hash: '0x342e9d73e10004af41d04973139fc7219dbadcbb5629730cfe65e9f9cb15ff91',\n input: '0x11',\n isError: '0',\n nonce: '3',\n timeStamp: '1543596356',\n to: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23',\n transactionIndex: '13',\n txreceipt_status: '1',\n value: '50000000000000000',\n },\n];\n\nexport const tokenTxsMock = (tokenTxHash: string) => [\n {\n blockNumber: '8222239',\n timeStamp: '1564091067',\n hash: tokenTxHash,\n nonce: '2329',\n blockHash:\n '0x3c30a9be9aea7be13caad419444140c11839d72e70479ec7e9c6d8bd08c533bc',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '69',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n cumulativeGasUsed: '3203881',\n input: 'deprecated',\n confirmations: '3659676',\n },\n {\n blockNumber: '8222250',\n timeStamp: '1564091247',\n hash: '0xdcd1c8bee545d3f76d80b20a23ad44276ba2e376681228eb4570cf3518491279',\n nonce: '2330',\n blockHash:\n '0x16986dd66bedb20a5b846ec2b6c0ecaa62f1c4b51fac58c1326101fd9126dd82',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '40',\n gas: '594268',\n gasPrice: '20000000000',\n gasUsed: '579268',\n cumulativeGasUsed: '2009011',\n input: 'deprecated',\n confirmations: '3659665',\n },\n {\n blockNumber: '8223771',\n timeStamp: '1564111652',\n hash: '0x070369e6f560b0deca52e050ff1a961fa7b688bbec5cea08435921c9d9b0f52e',\n nonce: '2333',\n blockHash:\n '0x0aff8b36881be99df6d176d7c64c2171672c0483684a10c112d2c90fefe30a0a',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '132',\n gas: '583810',\n gasPrice: '6000000000',\n gasUsed: '568810',\n cumulativeGasUsed: '6956245',\n input: 'deprecated',\n confirmations: '3658144',\n },\n {\n blockNumber: '8224850',\n timeStamp: '1564126442',\n hash: '0x8ef20ec9597c8c2e945bcc76d2668e5d3bb088b081fe8c5b5af2e1cbd315a20f',\n nonce: '31',\n blockHash:\n '0xb80d4d861ecb7a3cb14e591c0aaeb226842d0267772affa2acc1a590c7535647',\n from: '0x6c70e3563cef0c6835703bb2664c9f59a92353e4',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '10000000000000000000',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '169',\n gas: '78447',\n gasPrice: '2000000000',\n gasUsed: '52298',\n cumulativeGasUsed: '7047823',\n input: 'deprecated',\n confirmations: '3657065',\n },\n {\n blockNumber: '8228053',\n timeStamp: '1564168901',\n hash: '0xa0f2d7b558bb3cc28fa568f6feb8ed30eb28a01a674d7c0d4ae603fc691e6020',\n nonce: '2368',\n blockHash:\n '0x62c515ea049842c968ca67499f47a32a11394364d319d9c9cc0a0211652a7294',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '43',\n gas: '567156',\n gasPrice: '3000000000',\n gasUsed: '552156',\n cumulativeGasUsed: '3048261',\n input: 'deprecated',\n confirmations: '3653862',\n },\n {\n blockNumber: '8315335',\n timeStamp: '1565339223',\n hash: '0x464df60fe00b6dd04c9e8ab341d02af9b10a619d2fcd60fd2971f10edf12118f',\n nonce: '206760',\n blockHash:\n '0x98275388ef6708debe35ac7bf2e30143c9b1fd9e0e457ca03598fc1f4209e273',\n from: '0x00cfbbaf7ddb3a1476767101c12a0162e241fbad',\n contractAddress: '0x4dc3643dbc642b72c158e7f3d2ff232df61cb6ce',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n tokenName: 'Amber',\n tokenSymbol: 'AMB',\n tokenDecimal: '18',\n transactionIndex: '186',\n gas: '60000',\n gasPrice: '2000000000',\n gasUsed: '52108',\n cumulativeGasUsed: '7490707',\n input: 'deprecated',\n confirmations: '3566580',\n },\n {\n blockNumber: '8350846',\n timeStamp: '1565815049',\n hash: '0xc0682327ad3efd56dfa33e8206b4e09efad4e419a6191076069d217e3ee2341f',\n nonce: '2506',\n blockHash:\n '0xd0aa3c0e319fdfeb21b0192cf77b9760b8668060a5977a5f10f8413531083afa',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '4',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '48',\n gas: '578737',\n gasPrice: '3000000000',\n gasUsed: '518737',\n cumulativeGasUsed: '2848015',\n input: 'deprecated',\n confirmations: '3531069',\n },\n {\n blockNumber: '8350859',\n timeStamp: '1565815221',\n hash: '0x989ea9f3ee576fa43957f44363e839adf1a4a397c3d8392a4f7cbbf7949fd0ae',\n nonce: '2',\n blockHash:\n '0xb9cf1d29c665c052e3831b5754903e539c5b0b1d33b8bcab6cd2d450764d601f',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x09cabec1ead1c0ba254b09efb3ee13841712be14',\n value: '10000000000000000000',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '31',\n gas: '60734',\n gasPrice: '1000000000',\n gasUsed: '54745',\n cumulativeGasUsed: '7833857',\n input: 'deprecated',\n confirmations: '3531056',\n },\n {\n blockNumber: '8679548',\n timeStamp: '1570244087',\n hash: '0xc0016b89b3b525b30d73f242653b0d80ec3ebf285376dff5bb52cef3261498b2',\n nonce: '3',\n blockHash:\n '0x1ceb2f8b83087f010773e2acf63d1526633c8a884bd1980f118a1bba576be69f',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '56',\n gas: '993379',\n gasPrice: '1440000000',\n gasUsed: '647253',\n cumulativeGasUsed: '3562204',\n input: 'deprecated',\n confirmations: '3202367',\n },\n {\n blockNumber: '8679548',\n timeStamp: '1570244087',\n hash: '0xc0016b89b3b525b30d73f242653b0d80ec3ebf285376dff5bb52cef3261498b2',\n nonce: '3',\n blockHash:\n '0x1ceb2f8b83087f010773e2acf63d1526633c8a884bd1980f118a1bba576be69f',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '56',\n gas: '993379',\n gasPrice: '1440000000',\n gasUsed: '647253',\n cumulativeGasUsed: '3562204',\n input: 'deprecated',\n confirmations: '3202367',\n },\n {\n blockNumber: '8694142',\n timeStamp: '1570440625',\n hash: '0xd8397138bb93d56e50d01e92a9eae99ebd3ae28844acdaa4663976a5501116cf',\n nonce: '2837',\n blockHash:\n '0xba45dd64e71e146066af9b6d2dd3bc5d72f4a3399148c155dced74c139fc3c51',\n from: '0xdfa6edae2ec0cf1d4a60542422724a48195a5071',\n contractAddress: '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '0',\n tokenName: 'Sai Stablecoin v1.0',\n tokenSymbol: 'SAI',\n tokenDecimal: '18',\n transactionIndex: '217',\n gas: '600632',\n gasPrice: '9000000000',\n gasUsed: '570632',\n cumulativeGasUsed: '9023725',\n input: 'deprecated',\n confirmations: '3187773',\n },\n {\n blockNumber: '10877041',\n timeStamp: '1600310867',\n hash: '0xc8bd16b6b41b4c24849eb6869702e1489c808cb5b125b01f084e38fefcb5ea77',\n nonce: '4',\n blockHash:\n '0x7fa16a022bcf1f69c2d7adf6bd7d3f058e808eec5c66aaa910dfa8016a5333d1',\n from: '0x090d4613473dee047c3f2706764f49e0821d256e',\n contractAddress: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '400000000000000000000',\n tokenName: 'Uniswap',\n tokenSymbol: 'UNI',\n tokenDecimal: '18',\n transactionIndex: '42',\n gas: '90038',\n gasPrice: '550000000000',\n gasUsed: '81853',\n cumulativeGasUsed: '3163540',\n input: 'deprecated',\n confirmations: '1004874',\n },\n {\n blockNumber: '10877897',\n timeStamp: '1600321973',\n hash: '0xa7162489faef826ee77862ed5210b01726524f09428f69842118dad394842d62',\n nonce: '6',\n blockHash:\n '0xa74eb9d16f65f307dde4ce58c813c981b28f242edf1090ee2ac42caac9dccaca',\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n contractAddress: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',\n to: '0x5e736f1f25992b2cad20ded179a52823d3d24b26',\n value: '400000000000000000000',\n tokenName: 'Uniswap',\n tokenSymbol: 'UNI',\n tokenDecimal: '18',\n transactionIndex: '86',\n gas: '60759',\n gasPrice: '640000000000',\n gasUsed: '25506',\n cumulativeGasUsed: '4408393',\n input: 'deprecated',\n confirmations: '1004018',\n },\n];\n\nexport const txsInStateMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: '0x5208',\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedStatusMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: '21000',\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: '0x5208',\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedGasDataMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.confirmed,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n\nexport const txsInStateWithOutdatedStatusAndGasDataMock = (\n ethTxHash: string,\n tokenTxHash: string,\n): TransactionMeta[] => [\n {\n id: 'token-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '624874',\n gasPrice: '20000000000',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x881d40237659c251811cec9c364ef91dc08d300c',\n value: '0x0',\n },\n transactionHash: tokenTxHash,\n toSmartContract: true,\n },\n {\n id: 'eth-transaction-id',\n chainId: toHex(1),\n status: TransactionStatus.rejected,\n time: 1615497996125,\n transaction: {\n from: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n data: '0x',\n gas: '0x51d68',\n gasPrice: '0x2540be400',\n gasUsed: undefined,\n nonce: '0x12',\n to: '0x6bf137f335ea1b8f193b8f6ea92561a60d23a207',\n value: '100000000000000000',\n },\n transactionHash: ethTxHash,\n toSmartContract: false,\n },\n];\n"]} +\ 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..39cc136 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/types.d.ts +@@ -0,0 +1,232 @@ ++import { Hex } from '@metamask/utils'; ++import { GasFeeState } from '@metamask/gas-fee-controller'; ++/** ++ * @type TransactionMeta ++ * ++ * TransactionMeta representation ++ * @property error - Synthesized error information for failed transactions ++ * @property id - Generated UUID associated with this transaction ++ * @property networkID - Network code as per EIP-155 for this transaction ++ * @property origin - Origin this transaction was sent from ++ * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed ++ * @property rawTransaction - Hex representation of the underlying transaction ++ * @property status - String status of this transaction ++ * @property time - Timestamp associated with this transaction ++ * @property toSmartContract - Whether transaction recipient is a smart contract ++ * @property transaction - Underlying Transaction object ++ * @property transactionHash - Hash of a successful transaction ++ * @property blockNumber - Number of the block where the transaction has been included ++ */ ++export declare type TransactionMeta = ({ ++ status: Exclude; ++} & TransactionMetaBase) | ({ ++ status: TransactionStatus.failed; ++ error: Error; ++} & TransactionMetaBase); ++declare type TransactionMetaBase = { ++ isTransfer?: boolean; ++ transferInformation?: { ++ symbol: string; ++ contractAddress: string; ++ decimals: number; ++ }; ++ id: string; ++ networkID?: string; ++ chainId?: Hex; ++ origin?: string; ++ rawTransaction?: string; ++ time: number; ++ toSmartContract?: boolean; ++ transaction: Transaction; ++ transactionHash?: string; ++ blockNumber?: string; ++ deviceConfirmedOn?: WalletDevice; ++ verifiedOnBlockchain?: boolean; ++ /** Alternate EIP-1559 gas fee estimates for multiple priority levels. */ ++ gasFeeEstimates?: GasFeeEstimates; ++ /** Whether the gas fee estimates have been checked at least once. */ ++ gasFeeEstimatesLoaded?: boolean; ++ /** ++ * Response from security validator. ++ */ ++ securityAlertResponse?: SecurityAlertResponse; ++}; ++/** ++ * The status of the transaction. Each status represents the state of the transaction internally ++ * in the wallet. Some of these correspond with the state of the transaction on the network, but ++ * some are wallet-specific. ++ */ ++export declare enum TransactionStatus { ++ approved = "approved", ++ cancelled = "cancelled", ++ confirmed = "confirmed", ++ failed = "failed", ++ rejected = "rejected", ++ signed = "signed", ++ submitted = "submitted", ++ unapproved = "unapproved" ++} ++/** ++ * Options for wallet device. ++ */ ++export declare enum WalletDevice { ++ MM_MOBILE = "metamask_mobile", ++ MM_EXTENSION = "metamask_extension", ++ OTHER = "other_device" ++} ++/** ++ * @type Transaction ++ * ++ * Transaction representation ++ * @property chainId - Network ID as per EIP-155 ++ * @property data - Data to pass with this transaction ++ * @property from - Address to send this transaction from ++ * @property gas - Gas to send with this transaction ++ * @property gasPrice - Price of gas with this transaction ++ * @property gasUsed - Gas used in the transaction ++ * @property nonce - Unique number to prevent replay attacks ++ * @property to - Address to send this transaction to ++ * @property value - Value associated with this transaction ++ */ ++export interface Transaction { ++ chainId?: Hex; ++ data?: string; ++ from: string; ++ gas?: string; ++ gasPrice?: string; ++ gasUsed?: string; ++ nonce?: string; ++ to?: string; ++ value?: string; ++ maxFeePerGas?: string; ++ maxPriorityFeePerGas?: string; ++ estimatedBaseFee?: string; ++ estimateGasError?: string; ++ type?: string; ++} ++/** ++ * The configuration required to fetch transaction data from a RemoteTransactionSource. ++ */ ++export interface RemoteTransactionSourceRequest { ++ /** ++ * The address of the account to fetch transactions for. ++ */ ++ address: string; ++ /** ++ * API key if required by the remote source. ++ */ ++ apiKey?: string; ++ /** ++ * The chainId of the current network. ++ */ ++ currentChainId: Hex; ++ /** ++ * The networkId of the current network. ++ */ ++ currentNetworkId: string; ++ /** ++ * Block number to start fetching transactions from. ++ */ ++ fromBlock?: number; ++ /** ++ * Maximum number of transactions to retrieve. ++ */ ++ limit?: number; ++} ++/** ++ * An object capable of fetching transaction data from a remote source. ++ * Used by the IncomingTransactionHelper to retrieve remote transaction data. ++ */ ++export interface RemoteTransactionSource { ++ isSupportedNetwork: (chainId: string, networkId: string) => boolean; ++ fetchTransactions: (request: RemoteTransactionSourceRequest) => Promise; ++} ++export declare type SecurityAlertResponse = { ++ reason: string; ++ features?: string[]; ++ result_type: string; ++ providerRequestsCount?: Record; ++}; ++/** ++ * Data concerning a successfully submitted transaction. ++ * Used for debugging purposes. ++ */ ++export declare type SubmitHistoryEntry = { ++ /** The chain ID of the transaction as a hexadecimal string. */ ++ chainId?: Hex; ++ /** The hash of the transaction returned from the RPC provider. */ ++ hash: string; ++ /** True if the entry was generated using the migration and existing transaction metadata. */ ++ migration?: boolean; ++ /** The type of the network where the transaction was submitted. */ ++ networkType?: string; ++ /** ++ * The URL of the network the transaction was submitted to. ++ * A single network URL if it was recorded when submitted. ++ * An array of potential network URLs if it cannot be confirmed since the migration was used. ++ */ ++ networkUrl?: string | string[]; ++ /** The origin of the transaction. */ ++ origin?: string; ++ /** The raw transaction data that was submitted. */ ++ rawTransaction: string; ++ /** When the transaction was submitted. */ ++ time: number; ++ /** The transaction parameters that were submitted. */ ++ transaction: Record; ++}; ++/** Gas fee estimates for a specific priority level. */ ++export declare type GasFeeEstimatesForLevel = { ++ /** Maximum amount to pay per gas. */ ++ maxFeePerGas: Hex; ++ /** Maximum amount per gas to give to the validator as an incentive. */ ++ maxPriorityFeePerGas: Hex; ++}; ++/** Alternate priority levels for which values are provided in gas fee estimates. */ ++export declare enum GasFeeEstimateLevel { ++ low = "low", ++ medium = "medium", ++ high = "high" ++} ++/** Gas fee estimates for a transaction. */ ++export declare type GasFeeEstimates = { ++ /** The gas fee estimate for a low priority transaction. */ ++ [GasFeeEstimateLevel.low]: GasFeeEstimatesForLevel; ++ /** The gas fee estimate for a medium priority transaction. */ ++ [GasFeeEstimateLevel.medium]: GasFeeEstimatesForLevel; ++ /** The gas fee estimate for a high priority transaction. */ ++ [GasFeeEstimateLevel.high]: GasFeeEstimatesForLevel; ++}; ++/** Request to a gas fee flow to obtain gas fee estimates. */ ++export declare type GasFeeFlowRequest = { ++ /** An EthQuery instance to enable queries to the associated RPC provider. */ ++ ethQuery: any; ++ /** Callback to get the GasFeeController estimates. */ ++ getGasFeeControllerEstimates: () => Promise; ++ /** The metadata of the transaction to obtain estimates for. */ ++ transactionMeta: TransactionMeta; ++}; ++/** Response from a gas fee flow containing gas fee estimates. */ ++export declare type GasFeeFlowResponse = { ++ /** The gas fee estimates for the transaction. */ ++ estimates: GasFeeEstimates; ++}; ++/** A method of obtaining gas fee estimates for a specific transaction. */ ++export declare type GasFeeFlow = { ++ /** ++ * Determine if the gas fee flow supports the specified transaction. ++ * ++ * @param transactionMeta - The transaction metadata. ++ * @returns Whether the gas fee flow supports the transaction. ++ */ ++ matchesTransaction(transactionMeta: TransactionMeta): boolean; ++ /** ++ * Get gas fee estimates for a specific transaction. ++ * ++ * @param request - The gas fee flow request. ++ * @returns The gas fee flow response containing the gas fee estimates. ++ */ ++ getGasFees: (request: GasFeeFlowRequest) => 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..2cc85ee +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/types.js +@@ -0,0 +1,36 @@ ++"use strict"; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.GasFeeEstimateLevel = exports.WalletDevice = exports.TransactionStatus = void 0; ++/** ++ * The status of the transaction. Each status represents the state of the transaction internally ++ * in the wallet. Some of these correspond with the state of the transaction on the network, but ++ * some are wallet-specific. ++ */ ++var TransactionStatus; ++(function (TransactionStatus) { ++ TransactionStatus["approved"] = "approved"; ++ TransactionStatus["cancelled"] = "cancelled"; ++ TransactionStatus["confirmed"] = "confirmed"; ++ TransactionStatus["failed"] = "failed"; ++ TransactionStatus["rejected"] = "rejected"; ++ TransactionStatus["signed"] = "signed"; ++ TransactionStatus["submitted"] = "submitted"; ++ TransactionStatus["unapproved"] = "unapproved"; ++})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {})); ++/** ++ * Options for wallet device. ++ */ ++var WalletDevice; ++(function (WalletDevice) { ++ WalletDevice["MM_MOBILE"] = "metamask_mobile"; ++ WalletDevice["MM_EXTENSION"] = "metamask_extension"; ++ WalletDevice["OTHER"] = "other_device"; ++})(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {})); ++/** Alternate priority levels for which values are provided in gas fee estimates. */ ++var GasFeeEstimateLevel; ++(function (GasFeeEstimateLevel) { ++ GasFeeEstimateLevel["low"] = "low"; ++ GasFeeEstimateLevel["medium"] = "medium"; ++ GasFeeEstimateLevel["high"] = "high"; ++})(GasFeeEstimateLevel = exports.GasFeeEstimateLevel || (exports.GasFeeEstimateLevel = {})); ++//# 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 ccf3362..6521edf 100644 +--- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/utils.d.ts +@@ -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, 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. +@@ -16,7 +16,7 @@ export declare function getEtherscanApiUrl(networkType: string, urlParams: any): + * @param transaction - Transaction object to normalize. + * @returns Normalized Transaction object. + */ +-export declare function normalizeTransaction(transaction: Transaction): Transaction; ++export declare function normalizeTransactionParams(transaction: Transaction): Transaction; + /** + * Validates a Transaction object for required properties and throws in + * the event of any validation error. +@@ -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; +-/** +- * Handles the fetch of incoming transactions. +- * +- * @param networkType - Network type of desired network. +- * @param address - Address to get the transactions from. +- * @param txHistoryLimit - The maximum number of transactions to fetch. +- * @param opt - Object that can contain fromBlock and Etherscan service API key. +- * @returns Responses for both ETH and ERC20 token transactions. +- */ +-export declare function handleTransactionFetch(networkType: string, address: string, txHistoryLimit: number, opt?: FetchAllOptions): Promise<[{ +- [result: string]: []; +-}, { +- [result: string]: []; +-}]>; + 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; +@@ -63,10 +49,19 @@ export declare function validateMinimumIncrease(proposed: string, min: string): + /** + * Helper function to filter and format transactions for the nonce tracker. + * ++ * @param currentChainId - Chain ID of the current network. + * @param fromAddress - Address of the account from which the transactions to filter from are sent. + * @param transactionStatus - Status of the transactions for which to filter. + * @param transactions - Array of transactionMeta objects that have been prefiltered. + * @returns Array of transactions formatted for the nonce tracker. + */ +-export declare function getAndFormatTransactionsForNonceTracker(fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; ++export declare function getAndFormatTransactionsForNonceTracker(currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; ++/** ++ * Ensure a hex string is of even length by adding a leading 0 if necessary. ++ * Any existing `0x` prefix is preserved but is not added if missing. ++ * ++ * @param hex - The hex string to ensure is even. ++ * @returns The hex string with an even length. ++ */ ++export declare function padHexToEvenLength(hex: string): string; + //# sourceMappingURL=utils.d.ts.map +\ No newline at end of file +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,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B,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 179a564..0bbba70 100644 +--- a/node_modules/@metamask/transaction-controller/dist/utils.js ++++ b/node_modules/@metamask/transaction-controller/dist/utils.js +@@ -1,20 +1,11 @@ + "use strict"; +-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { +- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } +- return new (P || (P = Promise))(function (resolve, reject) { +- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } +- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } +- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } +- step((generator = generator.apply(thisArg, _arguments || [])).next()); +- }); +-}; + Object.defineProperty(exports, "__esModule", { value: true }); +-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.padHexToEvenLength = exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransactionParams = 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'; + const NORMALIZERS = { +- data: (data) => (0, ethereumjs_util_1.addHexPrefix)(data), ++ data: (data) => (0, ethereumjs_util_1.addHexPrefix)(padHexToEvenLength(data)), + from: (from) => (0, ethereumjs_util_1.addHexPrefix)(from).toLowerCase(), + gas: (gas) => (0, ethereumjs_util_1.addHexPrefix)(gas), + gasPrice: (gasPrice) => (0, ethereumjs_util_1.addHexPrefix)(gasPrice), +@@ -24,6 +15,7 @@ const NORMALIZERS = { + maxFeePerGas: (maxFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxFeePerGas), + maxPriorityFeePerGas: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), + estimatedBaseFee: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), ++ type: (type) => (type === '0x0' ? '0x0' : undefined), + }; + /** + * Return a URL that can be used to fetch ETH transactions. +@@ -54,7 +46,7 @@ exports.getEtherscanApiUrl = getEtherscanApiUrl; + * @param transaction - Transaction object to normalize. + * @returns Normalized Transaction object. + */ +-function normalizeTransaction(transaction) { ++function normalizeTransactionParams(transaction) { + const normalizedTransaction = { from: '' }; + let key; + for (key in NORMALIZERS) { +@@ -64,7 +56,7 @@ function normalizeTransaction(transaction) { + } + return normalizedTransaction; + } +-exports.normalizeTransaction = normalizeTransaction; ++exports.normalizeTransactionParams = normalizeTransactionParams; + /** + * Validates a Transaction object for required properties and throws in + * the event of any validation error. +@@ -121,50 +113,6 @@ const isEIP1559Transaction = (transaction) => { + hasOwnProp(transaction, 'maxPriorityFeePerGas')); + }; + exports.isEIP1559Transaction = isEIP1559Transaction; +-/** +- * Handles the fetch of incoming transactions. +- * +- * @param networkType - Network type of desired network. +- * @param address - Address to get the transactions from. +- * @param txHistoryLimit - The maximum number of transactions to fetch. +- * @param opt - Object that can contain fromBlock and Etherscan service API key. +- * @returns Responses for both ETH and ERC20 token transactions. +- */ +-function handleTransactionFetch(networkType, address, txHistoryLimit, opt) { +- return __awaiter(this, void 0, void 0, function* () { +- // transactions +- const urlParams = { +- module: 'account', +- address, +- startBlock: opt === null || opt === void 0 ? void 0 : opt.fromBlock, +- apikey: opt === null || opt === void 0 ? void 0 : opt.etherscanApiKey, +- offset: txHistoryLimit.toString(), +- order: 'desc', +- }; +- const etherscanTxUrl = getEtherscanApiUrl(networkType, Object.assign(Object.assign({}, urlParams), { action: 'txlist' })); +- const etherscanTxResponsePromise = (0, controller_utils_1.handleFetch)(etherscanTxUrl); +- // tokens +- const etherscanTokenUrl = getEtherscanApiUrl(networkType, Object.assign(Object.assign({}, urlParams), { action: 'tokentx' })); +- const etherscanTokenResponsePromise = (0, controller_utils_1.handleFetch)(etherscanTokenUrl); +- let [etherscanTxResponse, etherscanTokenResponse] = yield Promise.all([ +- etherscanTxResponsePromise, +- etherscanTokenResponsePromise, +- ]); +- if (etherscanTxResponse.status === '0' || +- etherscanTxResponse.result.length <= 0) { +- etherscanTxResponse = { status: etherscanTxResponse.status, result: [] }; +- } +- if (etherscanTokenResponse.status === '0' || +- etherscanTokenResponse.result.length <= 0) { +- etherscanTokenResponse = { +- status: etherscanTokenResponse.status, +- result: [], +- }; +- } +- return [etherscanTxResponse, etherscanTokenResponse]; +- }); +-} +-exports.handleTransactionFetch = handleTransactionFetch; + const validateGasValues = (gasValues) => { + Object.keys(gasValues).forEach((key) => { + const value = gasValues[key]; +@@ -206,14 +154,17 @@ exports.validateMinimumIncrease = validateMinimumIncrease; + /** + * Helper function to filter and format transactions for the nonce tracker. + * ++ * @param currentChainId - Chain ID of the current network. + * @param fromAddress - Address of the account from which the transactions to filter from are sent. + * @param transactionStatus - Status of the transactions for which to filter. + * @param transactions - Array of transactionMeta objects that have been prefiltered. + * @returns Array of transactions formatted for the nonce tracker. + */ +-function getAndFormatTransactionsForNonceTracker(fromAddress, transactionStatus, transactions) { ++function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) { + return transactions +- .filter(({ status, transaction: { from } }) => status === transactionStatus && ++ .filter(({ chainId, isTransfer, status, transaction: { from } }) => !isTransfer && ++ chainId === currentChainId && ++ status === transactionStatus && + from.toLowerCase() === fromAddress.toLowerCase()) + .map(({ status, transaction: { from, gas, value, nonce } }) => { + // the only value we care about is the nonce +@@ -232,4 +183,18 @@ function getAndFormatTransactionsForNonceTracker(fromAddress, transactionStatus, + }); + } + exports.getAndFormatTransactionsForNonceTracker = getAndFormatTransactionsForNonceTracker; ++/** ++ * Ensure a hex string is of even length by adding a leading 0 if necessary. ++ * Any existing `0x` prefix is preserved but is not added if missing. ++ * ++ * @param hex - The hex string to ensure is even. ++ * @returns The hex string with an even length. ++ */ ++function padHexToEvenLength(hex) { ++ const prefix = hex.toLowerCase().startsWith('0x') ? hex.slice(0, 2) : ''; ++ const data = prefix ? hex.slice(2) : hex; ++ const evenData = data.length % 2 === 0 ? data : `0${data}`; ++ return prefix + evenData; ++} ++exports.padHexToEvenLength = padHexToEvenLength; + //# sourceMappingURL=utils.js.map +\ No newline at end of file +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 8f2f6e3..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/utils.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"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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AC5C,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;AAED;;;;;;;GAOG;AACH,SAAgB,uCAAuC,CACrD,WAAmB,EACnB,iBAAoC,EACpC,YAA+B;IAE/B,OAAO,YAAY;SAChB,MAAM,CACL,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CACpC,MAAM,KAAK,iBAAiB;QAC5B,IAAI,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CACnD;SACA,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC5D,4CAA4C;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/node_modules/@metamask/transaction-controller/dist/utils/etherscan.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.d.ts +new file mode 100644 +index 0000000..4a63542 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.d.ts +@@ -0,0 +1,64 @@ ++import type { Hex } from '@metamask/utils'; ++export interface EtherscanTransactionMetaBase { ++ blockNumber: string; ++ blockHash: string; ++ confirmations: string; ++ contractAddress: string; ++ cumulativeGasUsed: string; ++ from: string; ++ gas: string; ++ gasPrice: string; ++ gasUsed: string; ++ hash: string; ++ nonce: string; ++ timeStamp: string; ++ to: string; ++ transactionIndex: string; ++ value: string; ++} ++export interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase { ++ functionName: string; ++ input: string; ++ isError: string; ++ methodId: string; ++ txreceipt_status: string; ++} ++export interface EtherscanTokenTransactionMeta extends EtherscanTransactionMetaBase { ++ tokenDecimal: string; ++ tokenName: string; ++ tokenSymbol: string; ++} ++export interface EtherscanTransactionResponse { ++ status: '0' | '1'; ++ message?: string; ++ result: string | T[]; ++} ++export interface EtherscanTransactionRequest { ++ address: string; ++ chainId: Hex; ++ fromBlock?: number; ++ limit?: number; ++} ++/** ++ * Retrieves transaction data from Etherscan. ++ * ++ * @param request - Configuration required to fetch transactions. ++ * @param request.address - Address to retrieve transactions for. ++ * @param request.chainId - Current chain ID used to determine subdomain and domain. ++ * @param request.fromBlock - Block number to start fetching transactions from. ++ * @param request.limit - Number of transactions to retrieve. ++ * @returns An Etherscan response object containing the request status and an array of token transaction data. ++ */ ++export declare function fetchEtherscanTransactions({ address, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise>; ++/** ++ * Retrieves token transaction data from Etherscan. ++ * ++ * @param request - Configuration required to fetch token transactions. ++ * @param request.address - Address to retrieve token transactions for. ++ * @param request.chainId - Current chain ID used to determine subdomain and domain. ++ * @param request.fromBlock - Block number to start fetching token transactions from. ++ * @param request.limit - Number of token transactions to retrieve. ++ * @returns An Etherscan response object containing the request status and an array of token transaction data. ++ */ ++export declare function fetchEtherscanTokenTransactions({ address, 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/utils/etherscan.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.d.ts.map +new file mode 100644 +index 0000000..bde0ec8 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"etherscan.d.ts","sourceRoot":"","sources":["../../src/utils/etherscan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAQ3C,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAKD,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAKD,MAAM,WAAW,6BACf,SAAQ,4BAA4B;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,MAAM,WAAW,4BAA4B,CAC3C,CAAC,SAAS,4BAA4B;IAEtC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;CACtB;AAKD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACN,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,wBAAwB,CAAC,CACvD,CAOA;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACN,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,6BAA6B,CAAC,CAC5D,CAOA"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js +new file mode 100644 +index 0000000..7932542 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js +@@ -0,0 +1,108 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.fetchEtherscanTokenTransactions = exports.fetchEtherscanTransactions = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const constants_1 = require("../constants"); ++const logger_1 = require("../logger"); ++/** ++ * Retrieves transaction data from Etherscan. ++ * ++ * @param request - Configuration required to fetch transactions. ++ * @param request.address - Address to retrieve transactions for. ++ * @param request.chainId - Current chain ID used to determine subdomain and domain. ++ * @param request.fromBlock - Block number to start fetching transactions from. ++ * @param request.limit - Number of transactions to retrieve. ++ * @returns An Etherscan response object containing the request status and an array of token transaction data. ++ */ ++function fetchEtherscanTransactions({ address, chainId, fromBlock, limit, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield fetchTransactions('txlist', { ++ address, ++ chainId, ++ fromBlock, ++ limit, ++ }); ++ }); ++} ++exports.fetchEtherscanTransactions = fetchEtherscanTransactions; ++/** ++ * Retrieves token transaction data from Etherscan. ++ * ++ * @param request - Configuration required to fetch token transactions. ++ * @param request.address - Address to retrieve token transactions for. ++ * @param request.chainId - Current chain ID used to determine subdomain and domain. ++ * @param request.fromBlock - Block number to start fetching token transactions from. ++ * @param request.limit - Number of token transactions to retrieve. ++ * @returns An Etherscan response object containing the request status and an array of token transaction data. ++ */ ++function fetchEtherscanTokenTransactions({ address, chainId, fromBlock, limit, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield fetchTransactions('tokentx', { ++ address, ++ chainId, ++ fromBlock, ++ limit, ++ }); ++ }); ++} ++exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions; ++/** ++ * Retrieves transaction data from Etherscan from a specific endpoint. ++ * ++ * @param action - The Etherscan endpoint to use. ++ * @param options - Options bag. ++ * @param options.address - Address to retrieve transactions for. ++ * @param options.chainId - Current chain ID used to determine subdomain and domain. ++ * @param options.fromBlock - Block number to start fetching transactions from. ++ * @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, chainId, fromBlock, limit, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const urlParams = { ++ module: 'account', ++ address, ++ startBlock: fromBlock === null || fromBlock === void 0 ? void 0 : fromBlock.toString(), ++ offset: limit === null || limit === void 0 ? void 0 : limit.toString(), ++ sort: 'desc', ++ }; ++ const etherscanTxUrl = getEtherscanApiUrl(chainId, Object.assign(Object.assign({}, urlParams), { action })); ++ (0, logger_1.incomingTransactionsLogger)('Sending Etherscan request', etherscanTxUrl); ++ const response = (yield (0, controller_utils_1.handleFetch)(etherscanTxUrl)); ++ return response; ++ }); ++} ++/** ++ * Return a URL that can be used to fetch data from Etherscan. ++ * ++ * @param chainId - Current chain ID used to determine subdomain and domain. ++ * @param urlParams - The parameters used to construct the URL. ++ * @returns URL to access Etherscan data. ++ */ ++function getEtherscanApiUrl(chainId, urlParams) { ++ const networkInfo = constants_1.ETHERSCAN_SUPPORTED_NETWORKS[chainId]; ++ if (!networkInfo) { ++ throw new Error(`Etherscan does not support chain with ID: ${chainId}`); ++ } ++ const apiUrl = `https://${networkInfo.subdomain}.${networkInfo.domain}`; ++ let url = `${apiUrl}/api?`; ++ for (const paramKey of Object.keys(urlParams)) { ++ const value = urlParams[paramKey]; ++ if (!value) { ++ continue; ++ } ++ url += `${paramKey}=${value}&`; ++ } ++ url += 'tag=latest&page=1'; ++ return url; ++} ++//# sourceMappingURL=etherscan.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js.map b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js.map +new file mode 100644 +index 0000000..b38f825 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/etherscan.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"etherscan.js","sourceRoot":"","sources":["../../src/utils/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AAGzD,4CAA4D;AAC5D,sCAA8D;AAiE9D;;;;;;;;;GASG;AACH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AC,6CAA6C,OAAO,EAAE,CAAC,CAAC;KACzE;IAED,MAAM,MAAM,GAAG,WAAW,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;IACxE,IAAI,GAAG,GAAG,GAAG,MAAM,OAAO,CAAC;IAE3B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE;YACV,SAAS;SACV;QAED,GAAG,IAAI,GAAG,QAAQ,IAAI,KAAK,GAAG,CAAC;KAChC;IAED,GAAG,IAAI,mBAAmB,CAAC;IAE3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionMetaBase {\n blockNumber: string;\n blockHash: string;\n confirmations: string;\n contractAddress: string;\n cumulativeGasUsed: string;\n from: string;\n gas: string;\n gasPrice: string;\n gasUsed: string;\n hash: string;\n nonce: string;\n timeStamp: string;\n to: string;\n transactionIndex: string;\n value: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n txreceipt_status: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionResponse<\n T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n message?: string;\n result: string | T[];\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionRequest {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n}\n\n/**\n * Retrieves transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch transactions.\n * @param request.address - Address to retrieve transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching transactions from.\n * @param request.limit - Number of transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse\n> {\n return await fetchTransactions('txlist', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves token transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch token transactions.\n * @param request.address - Address to retrieve token transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching token transactions from.\n * @param request.limit - Number of token transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTokenTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse\n> {\n return await fetchTransactions('tokentx', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves transaction data from Etherscan from a specific endpoint.\n *\n * @param action - The Etherscan endpoint to use.\n * @param options - Options bag.\n * @param options.address - Address to retrieve transactions for.\n * @param options.chainId - Current chain ID used to determine subdomain and domain.\n * @param options.fromBlock - Block number to start fetching transactions from.\n * @param options.limit - Number of transactions to retrieve.\n * @returns An object containing the request status and an array of transaction data.\n */\nasync function fetchTransactions(\n action: string,\n {\n address,\n chainId,\n fromBlock,\n limit,\n }: {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n },\n): Promise> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock?.toString(),\n offset: limit?.toString(),\n sort: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(chainId, {\n ...urlParams,\n action,\n });\n\n log('Sending Etherscan request', etherscanTxUrl);\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as EtherscanTransactionResponse;\n\n return response;\n}\n\n/**\n * Return a URL that can be used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to access Etherscan data.\n */\nfunction getEtherscanApiUrl(\n chainId: Hex,\n urlParams: Record,\n): string {\n type SupportedChainId = keyof typeof ETHERSCAN_SUPPORTED_NETWORKS;\n\n const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId as SupportedChainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n const apiUrl = `https://${networkInfo.subdomain}.${networkInfo.domain}`;\n let url = `${apiUrl}/api?`;\n\n for (const paramKey of Object.keys(urlParams)) {\n const value = urlParams[paramKey];\n\n if (!value) {\n continue;\n }\n\n url += `${paramKey}=${value}&`;\n }\n\n url += 'tag=latest&page=1';\n\n return url;\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts +new file mode 100644 +index 0000000..04efc8e +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts +@@ -0,0 +1,10 @@ ++import type { TransactionMeta } from '../types'; ++/** ++ * Validates the external provided transaction meta. ++ * ++ * @param transactionMeta - The transaction meta to validate. ++ * @param confirmedTxs - The confirmed transactions in controller state. ++ * @param pendingTxs - The submitted transactions in controller state. ++ */ ++export declare function validateConfirmedExternalTransaction(transactionMeta?: TransactionMeta, confirmedTxs?: TransactionMeta[], pendingTxs?: TransactionMeta[]): void; ++//# sourceMappingURL=external-transactions.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts.map +new file mode 100644 +index 0000000..fe57dc6 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"external-transactions.d.ts","sourceRoot":"","sources":["../../src/utils/external-transactions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,CAAC,EAAE,eAAe,EACjC,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,UAAU,CAAC,EAAE,eAAe,EAAE,QAoC/B"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js +new file mode 100644 +index 0000000..415eaf9 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js +@@ -0,0 +1,36 @@ ++"use strict"; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.validateConfirmedExternalTransaction = void 0; ++// These utility functions are exclusively used by `confirmExternalTransaction` method in controller ++const rpc_errors_1 = require("@metamask/rpc-errors"); ++const types_1 = require("../types"); ++/** ++ * Validates the external provided transaction meta. ++ * ++ * @param transactionMeta - The transaction meta to validate. ++ * @param confirmedTxs - The confirmed transactions in controller state. ++ * @param pendingTxs - The submitted transactions in controller state. ++ */ ++function validateConfirmedExternalTransaction(transactionMeta, confirmedTxs, pendingTxs) { ++ if (!transactionMeta || !transactionMeta.txParams) { ++ throw rpc_errors_1.rpcErrors.invalidParams('"transactionMeta" or "transactionMeta.txParams" is missing'); ++ } ++ if (transactionMeta.status !== types_1.TransactionStatus.confirmed) { ++ throw rpc_errors_1.rpcErrors.invalidParams('External transaction status should be "confirmed"'); ++ } ++ const externalTxNonce = transactionMeta.txParams.nonce; ++ if (pendingTxs && pendingTxs.length > 0) { ++ const foundPendingTxByNonce = pendingTxs.find((tx) => { var _a; return ((_a = tx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === externalTxNonce; }); ++ if (foundPendingTxByNonce) { ++ throw rpc_errors_1.rpcErrors.invalidParams('External transaction nonce should not be in pending txs'); ++ } ++ } ++ if (confirmedTxs && confirmedTxs.length > 0) { ++ const foundConfirmedTxByNonce = confirmedTxs.find((tx) => { var _a; return ((_a = tx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === externalTxNonce; }); ++ if (foundConfirmedTxByNonce) { ++ throw rpc_errors_1.rpcErrors.invalidParams('External transaction nonce should not be in confirmed txs'); ++ } ++ } ++} ++exports.validateConfirmedExternalTransaction = validateConfirmedExternalTransaction; ++//# sourceMappingURL=external-transactions.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js.map b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js.map +new file mode 100644 +index 0000000..c0d7d83 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/external-transactions.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"external-transactions.js","sourceRoot":"","sources":["../../src/utils/external-transactions.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,qDAAiD;AAEjD,oCAA6C;AAG7C;;;;;;GAMG;AACH,SAAgB,oCAAoC,CAClD,eAAiC,EACjC,YAAgC,EAChC,UAA8B;IAE9B,IAAI,CAAC,eAAe,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;QACjD,MAAM,sBAAS,CAAC,aAAa,CAC3B,4DAA4D,CAC7D,CAAC;KACH;IAED,IAAI,eAAe,CAAC,MAAM,KAAK,yBAAiB,CAAC,SAAS,EAAE;QAC1D,MAAM,sBAAS,CAAC,aAAa,CAC3B,mDAAmD,CACpD,CAAC;KACH;IAED,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC;IACvD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACvC,MAAM,qBAAqB,GAAG,UAAU,CAAC,IAAI,CAC3C,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,EAAE,CAAC,QAAQ,0CAAE,KAAK,MAAK,eAAe,CAAA,EAAA,CAC/C,CAAC;QACF,IAAI,qBAAqB,EAAE;YACzB,MAAM,sBAAS,CAAC,aAAa,CAC3B,yDAAyD,CAC1D,CAAC;SACH;KACF;IAED,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,uBAAuB,GAAG,YAAY,CAAC,IAAI,CAC/C,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,EAAE,CAAC,QAAQ,0CAAE,KAAK,MAAK,eAAe,CAAA,EAAA,CAC/C,CAAC;QACF,IAAI,uBAAuB,EAAE;YAC3B,MAAM,sBAAS,CAAC,aAAa,CAC3B,2DAA2D,CAC5D,CAAC;SACH;KACF;AACH,CAAC;AAvCD,oFAuCC","sourcesContent":["// These utility functions are exclusively used by `confirmExternalTransaction` method in controller\nimport { rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionStatus } from '../types';\nimport type { TransactionMeta } from '../types';\n\n/**\n * Validates the external provided transaction meta.\n *\n * @param transactionMeta - The transaction meta to validate.\n * @param confirmedTxs - The confirmed transactions in controller state.\n * @param pendingTxs - The submitted transactions in controller state.\n */\nexport function validateConfirmedExternalTransaction(\n transactionMeta?: TransactionMeta,\n confirmedTxs?: TransactionMeta[],\n pendingTxs?: TransactionMeta[],\n) {\n if (!transactionMeta || !transactionMeta.txParams) {\n throw rpcErrors.invalidParams(\n '\"transactionMeta\" or \"transactionMeta.txParams\" is missing',\n );\n }\n\n if (transactionMeta.status !== TransactionStatus.confirmed) {\n throw rpcErrors.invalidParams(\n 'External transaction status should be \"confirmed\"',\n );\n }\n\n const externalTxNonce = transactionMeta.txParams.nonce;\n if (pendingTxs && pendingTxs.length > 0) {\n const foundPendingTxByNonce = pendingTxs.find(\n (tx) => tx.txParams?.nonce === externalTxNonce,\n );\n if (foundPendingTxByNonce) {\n throw rpcErrors.invalidParams(\n 'External transaction nonce should not be in pending txs',\n );\n }\n }\n\n if (confirmedTxs && confirmedTxs.length > 0) {\n const foundConfirmedTxByNonce = confirmedTxs.find(\n (tx) => tx.txParams?.nonce === externalTxNonce,\n );\n if (foundConfirmedTxByNonce) {\n throw rpcErrors.invalidParams(\n 'External transaction nonce should not be in confirmed txs',\n );\n }\n }\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts +new file mode 100644 +index 0000000..9ed9fdd +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts +@@ -0,0 +1,31 @@ ++import type EthQuery from '@metamask/eth-query'; ++import type { GasFeeState } from '@metamask/gas-fee-controller'; ++import type { SavedGasFees, TransactionParams, TransactionMeta } from '../types'; ++export declare type UpdateGasFeesRequest = { ++ eip1559: boolean; ++ ethQuery: EthQuery; ++ getSavedGasFees: () => SavedGasFees | undefined; ++ getGasFeeEstimates: () => Promise; ++ txMeta: TransactionMeta; ++}; ++export declare type GetGasFeeRequest = UpdateGasFeesRequest & { ++ savedGasFees?: SavedGasFees; ++ initialParams: TransactionParams; ++ suggestedGasFees: Awaited>; ++}; ++export declare function updateGasFees(request: UpdateGasFeesRequest): Promise; ++declare function getSuggestedGasFees(request: UpdateGasFeesRequest): Promise<{ ++ maxFeePerGas?: undefined; ++ maxPriorityFeePerGas?: undefined; ++ gasPrice?: undefined; ++} | { ++ maxFeePerGas: `0x${string}`; ++ maxPriorityFeePerGas: `0x${string}`; ++ gasPrice?: undefined; ++} | { ++ gasPrice: string | undefined; ++ maxFeePerGas?: undefined; ++ maxPriorityFeePerGas?: undefined; ++}>; ++export {}; ++//# sourceMappingURL=gas-fees.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts.map +new file mode 100644 +index 0000000..6b56c63 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas-fees.d.ts","sourceRoot":"","sources":["../../src/utils/gas-fees.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EAEhB,MAAM,UAAU,CAAC;AAIlB,oBAAY,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,YAAY,GAAG,SAAS,CAAC;IAChD,kBAAkB,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,oBAAoB,GAAG;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC;CACnE,CAAC;AAIF,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,iBA4ChE;AA6KD,iBAAe,mBAAmB,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;GAwD/D"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js +new file mode 100644 +index 0000000..823fa99 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js +@@ -0,0 +1,212 @@ ++"use strict"; ++/* eslint-disable jsdoc/require-jsdoc */ ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.updateGasFees = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const gas_fee_controller_1 = require("@metamask/gas-fee-controller"); ++const utils_1 = require("@metamask/utils"); ++const ethereumjs_util_1 = require("ethereumjs-util"); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const swaps_1 = require("./swaps"); ++const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas-fees'); ++function updateGasFees(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { txMeta } = request; ++ const initialParams = Object.assign({}, txMeta.txParams); ++ const isSwap = swaps_1.SWAP_TRANSACTION_TYPES.includes(txMeta.type); ++ const savedGasFees = isSwap ? undefined : request.getSavedGasFees(); ++ const suggestedGasFees = yield getSuggestedGasFees(request); ++ log('Suggested gas fees', suggestedGasFees); ++ const getGasFeeRequest = Object.assign(Object.assign({}, request), { savedGasFees, ++ initialParams, ++ suggestedGasFees }); ++ txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest); ++ txMeta.txParams.maxPriorityFeePerGas = ++ getMaxPriorityFeePerGas(getGasFeeRequest); ++ txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest); ++ txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest); ++ log('Updated gas fee properties', { ++ maxFeePerGas: txMeta.txParams.maxFeePerGas, ++ maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas, ++ gasPrice: txMeta.txParams.gasPrice, ++ }); ++ if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) { ++ delete txMeta.txParams.gasPrice; ++ } ++ if (txMeta.txParams.gasPrice) { ++ delete txMeta.txParams.maxFeePerGas; ++ delete txMeta.txParams.maxPriorityFeePerGas; ++ } ++ updateDefaultGasEstimates(txMeta); ++ }); ++} ++exports.updateGasFees = updateGasFees; ++function getMaxFeePerGas(request) { ++ const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request; ++ if (!eip1559) { ++ return undefined; ++ } ++ if (savedGasFees) { ++ const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee); ++ log('Using maxFeePerGas from savedGasFees', maxFeePerGas); ++ return maxFeePerGas; ++ } ++ if (initialParams.maxFeePerGas) { ++ log('Using maxFeePerGas from request', initialParams.maxFeePerGas); ++ return initialParams.maxFeePerGas; ++ } ++ if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) { ++ log('Setting maxFeePerGas to gasPrice from request', initialParams.gasPrice); ++ return initialParams.gasPrice; ++ } ++ if (suggestedGasFees.maxFeePerGas) { ++ log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas); ++ return suggestedGasFees.maxFeePerGas; ++ } ++ if (suggestedGasFees.gasPrice) { ++ log('Setting maxFeePerGas to suggested gasPrice', suggestedGasFees.gasPrice); ++ return suggestedGasFees.gasPrice; ++ } ++ log('maxFeePerGas not set'); ++ return undefined; ++} ++function getMaxPriorityFeePerGas(request) { ++ const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request; ++ if (!eip1559) { ++ return undefined; ++ } ++ if (savedGasFees) { ++ const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee); ++ log('Using maxPriorityFeePerGas from savedGasFees.priorityFee', maxPriorityFeePerGas); ++ return maxPriorityFeePerGas; ++ } ++ if (initialParams.maxPriorityFeePerGas) { ++ log('Using maxPriorityFeePerGas from request', initialParams.maxPriorityFeePerGas); ++ return initialParams.maxPriorityFeePerGas; ++ } ++ if (initialParams.gasPrice && !initialParams.maxFeePerGas) { ++ log('Setting maxPriorityFeePerGas to gasPrice from request', initialParams.gasPrice); ++ return initialParams.gasPrice; ++ } ++ if (suggestedGasFees.maxPriorityFeePerGas) { ++ log('Using suggested maxPriorityFeePerGas', suggestedGasFees.maxPriorityFeePerGas); ++ return suggestedGasFees.maxPriorityFeePerGas; ++ } ++ if (txMeta.txParams.maxFeePerGas) { ++ log('Setting maxPriorityFeePerGas to maxFeePerGas', txMeta.txParams.maxFeePerGas); ++ return txMeta.txParams.maxFeePerGas; ++ } ++ log('maxPriorityFeePerGas not set'); ++ return undefined; ++} ++function getGasPrice(request) { ++ const { eip1559, initialParams, suggestedGasFees } = request; ++ if (eip1559) { ++ return undefined; ++ } ++ if (initialParams.gasPrice) { ++ log('Using gasPrice from request', initialParams.gasPrice); ++ return initialParams.gasPrice; ++ } ++ if (suggestedGasFees.gasPrice) { ++ log('Using suggested gasPrice', suggestedGasFees.gasPrice); ++ return suggestedGasFees.gasPrice; ++ } ++ log('gasPrice not set'); ++ return undefined; ++} ++function getUserFeeLevel(request) { ++ const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request; ++ if (!eip1559) { ++ return undefined; ++ } ++ if (savedGasFees) { ++ return types_1.UserFeeLevel.CUSTOM; ++ } ++ if (!initialParams.maxFeePerGas && ++ !initialParams.maxPriorityFeePerGas && ++ initialParams.gasPrice) { ++ return txMeta.origin === controller_utils_1.ORIGIN_METAMASK ++ ? types_1.UserFeeLevel.CUSTOM ++ : types_1.UserFeeLevel.DAPP_SUGGESTED; ++ } ++ if (!initialParams.maxFeePerGas && ++ !initialParams.maxPriorityFeePerGas && ++ suggestedGasFees.maxFeePerGas && ++ suggestedGasFees.maxPriorityFeePerGas) { ++ return types_1.UserFeeLevel.MEDIUM; ++ } ++ if (txMeta.origin === controller_utils_1.ORIGIN_METAMASK) { ++ return types_1.UserFeeLevel.MEDIUM; ++ } ++ return types_1.UserFeeLevel.DAPP_SUGGESTED; ++} ++function updateDefaultGasEstimates(txMeta) { ++ if (!txMeta.defaultGasEstimates) { ++ txMeta.defaultGasEstimates = {}; ++ } ++ txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas; ++ txMeta.defaultGasEstimates.maxPriorityFeePerGas = ++ txMeta.txParams.maxPriorityFeePerGas; ++ txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice; ++ txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel; ++} ++function getSuggestedGasFees(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { eip1559, ethQuery, getGasFeeEstimates, txMeta } = request; ++ if ((!eip1559 && txMeta.txParams.gasPrice) || ++ (eip1559 && ++ txMeta.txParams.maxFeePerGas && ++ txMeta.txParams.maxPriorityFeePerGas)) { ++ return {}; ++ } ++ try { ++ const { gasFeeEstimates, gasEstimateType } = yield getGasFeeEstimates(); ++ if (eip1559 && gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { ++ const { medium: { suggestedMaxPriorityFeePerGas, suggestedMaxFeePerGas } = {}, } = gasFeeEstimates; ++ if (suggestedMaxPriorityFeePerGas && suggestedMaxFeePerGas) { ++ return { ++ maxFeePerGas: gweiDecimalToWeiHex(suggestedMaxFeePerGas), ++ maxPriorityFeePerGas: gweiDecimalToWeiHex(suggestedMaxPriorityFeePerGas), ++ }; ++ } ++ } ++ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) { ++ // The LEGACY type includes low, medium and high estimates of ++ // gas price values. ++ return { ++ gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.medium), ++ }; ++ } ++ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.ETH_GASPRICE) { ++ // The ETH_GASPRICE type just includes a single gas price property, ++ // which we can assume was retrieved from eth_gasPrice ++ return { ++ gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice), ++ }; ++ } ++ } ++ catch (error) { ++ log('Failed to get suggested gas fees', error); ++ } ++ const gasPriceDecimal = (yield (0, controller_utils_1.query)(ethQuery, 'gasPrice')); ++ const gasPrice = gasPriceDecimal ++ ? (0, ethereumjs_util_1.addHexPrefix)(gasPriceDecimal.toString(16)) ++ : undefined; ++ return { gasPrice }; ++ }); ++} ++function gweiDecimalToWeiHex(value) { ++ return (0, controller_utils_1.toHex)((0, controller_utils_1.gweiDecToWEIBN)(value)); ++} ++//# sourceMappingURL=gas-fees.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js.map +new file mode 100644 +index 0000000..464cc3d +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-fees.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas-fees.js","sourceRoot":"","sources":["../../src/utils/gas-fees.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;;;;;;;;;;AAExC,iEAKoC;AAGpC,qEAAkE;AAClE,2CAAqD;AACrD,qDAA+C;AAE/C,sCAA0C;AAO1C,oCAAwC;AACxC,mCAAiD;AAgBjD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,UAAU,CAAC,CAAC;AAE1D,SAAsB,aAAa,CAAC,OAA6B;;QAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,MAAM,aAAa,qBAAQ,MAAM,CAAC,QAAQ,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AAI,eAAe,KAAK,uCAAkB,CAAC,YAAY,EAAE;gBACvD,mEAAmE;gBACnE,sDAAsD;gBACtD,OAAO;oBACL,QAAQ,EAAE,mBAAmB,CAAC,eAAe,CAAC,QAAQ,CAAC;iBACxD,CAAC;aACH;SACF;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;SAChD;QAED,MAAM,eAAe,GAAG,CAAC,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAW,CAAC;QAEtE,MAAM,QAAQ,GAAG,eAAe;YAC9B,CAAC,CAAC,IAAA,8BAAY,EAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC5C,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO,EAAE,QAAQ,EAAE,CAAC;IACtB,CAAC;CAAA;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,IAAA,wBAAK,EAAC,IAAA,iCAAc,EAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport {\n ORIGIN_METAMASK,\n gweiDecToWEIBN,\n query,\n toHex,\n} from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport { addHexPrefix } from 'ethereumjs-util';\n\nimport { projectLogger } from '../logger';\nimport type {\n SavedGasFees,\n TransactionParams,\n TransactionMeta,\n TransactionType,\n} from '../types';\nimport { UserFeeLevel } from '../types';\nimport { SWAP_TRANSACTION_TYPES } from './swaps';\n\nexport type UpdateGasFeesRequest = {\n eip1559: boolean;\n ethQuery: EthQuery;\n getSavedGasFees: () => SavedGasFees | undefined;\n getGasFeeEstimates: () => Promise;\n txMeta: TransactionMeta;\n};\n\nexport type GetGasFeeRequest = UpdateGasFeesRequest & {\n savedGasFees?: SavedGasFees;\n initialParams: TransactionParams;\n suggestedGasFees: Awaited>;\n};\n\nconst log = createModuleLogger(projectLogger, 'gas-fees');\n\nexport async function updateGasFees(request: UpdateGasFeesRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const isSwap = SWAP_TRANSACTION_TYPES.includes(\n txMeta.type as TransactionType,\n );\n const savedGasFees = isSwap ? undefined : request.getSavedGasFees();\n\n const suggestedGasFees = await getSuggestedGasFees(request);\n\n log('Suggested gas fees', suggestedGasFees);\n\n const getGasFeeRequest = {\n ...request,\n savedGasFees,\n initialParams,\n suggestedGasFees,\n };\n\n txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.maxPriorityFeePerGas =\n getMaxPriorityFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest);\n txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest);\n\n log('Updated gas fee properties', {\n maxFeePerGas: txMeta.txParams.maxFeePerGas,\n maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas,\n gasPrice: txMeta.txParams.gasPrice,\n });\n\n if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) {\n delete txMeta.txParams.gasPrice;\n }\n\n if (txMeta.txParams.gasPrice) {\n delete txMeta.txParams.maxFeePerGas;\n delete txMeta.txParams.maxPriorityFeePerGas;\n }\n\n updateDefaultGasEstimates(txMeta);\n}\n\nfunction getMaxFeePerGas(request: GetGasFeeRequest): string | undefined {\n const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee as string);\n log('Using maxFeePerGas from savedGasFees', maxFeePerGas);\n return maxFeePerGas;\n }\n\n if (initialParams.maxFeePerGas) {\n log('Using maxFeePerGas from request', initialParams.maxFeePerGas);\n return initialParams.maxFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) {\n log(\n 'Setting maxFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log(\n 'Setting maxFeePerGas to suggested gasPrice',\n suggestedGasFees.gasPrice,\n );\n return suggestedGasFees.gasPrice;\n }\n\n log('maxFeePerGas not set');\n return undefined;\n}\n\nfunction getMaxPriorityFeePerGas(\n request: GetGasFeeRequest,\n): string | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);\n log(\n 'Using maxPriorityFeePerGas from savedGasFees.priorityFee',\n maxPriorityFeePerGas,\n );\n return maxPriorityFeePerGas;\n }\n\n if (initialParams.maxPriorityFeePerGas) {\n log(\n 'Using maxPriorityFeePerGas from request',\n initialParams.maxPriorityFeePerGas,\n );\n return initialParams.maxPriorityFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxPriorityFeePerGas) {\n log(\n 'Using suggested maxPriorityFeePerGas',\n suggestedGasFees.maxPriorityFeePerGas,\n );\n return suggestedGasFees.maxPriorityFeePerGas;\n }\n\n if (txMeta.txParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to maxFeePerGas',\n txMeta.txParams.maxFeePerGas,\n );\n return txMeta.txParams.maxFeePerGas;\n }\n\n log('maxPriorityFeePerGas not set');\n return undefined;\n}\n\nfunction getGasPrice(request: GetGasFeeRequest): string | undefined {\n const { eip1559, initialParams, suggestedGasFees } = request;\n\n if (eip1559) {\n return undefined;\n }\n\n if (initialParams.gasPrice) {\n log('Using gasPrice from request', initialParams.gasPrice);\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.gasPrice) {\n log('Using suggested gasPrice', suggestedGasFees.gasPrice);\n return suggestedGasFees.gasPrice;\n }\n\n log('gasPrice not set');\n return undefined;\n}\n\nfunction getUserFeeLevel(request: GetGasFeeRequest): UserFeeLevel | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n return UserFeeLevel.CUSTOM;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n initialParams.gasPrice\n ) {\n return txMeta.origin === ORIGIN_METAMASK\n ? UserFeeLevel.CUSTOM\n : UserFeeLevel.DAPP_SUGGESTED;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n suggestedGasFees.maxFeePerGas &&\n suggestedGasFees.maxPriorityFeePerGas\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (txMeta.origin === ORIGIN_METAMASK) {\n return UserFeeLevel.MEDIUM;\n }\n\n return UserFeeLevel.DAPP_SUGGESTED;\n}\n\nfunction updateDefaultGasEstimates(txMeta: TransactionMeta) {\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;\n\n txMeta.defaultGasEstimates.maxPriorityFeePerGas =\n txMeta.txParams.maxPriorityFeePerGas;\n\n txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;\n txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;\n}\n\nasync function getSuggestedGasFees(request: UpdateGasFeesRequest) {\n const { eip1559, ethQuery, getGasFeeEstimates, txMeta } = request;\n\n if (\n (!eip1559 && txMeta.txParams.gasPrice) ||\n (eip1559 &&\n txMeta.txParams.maxFeePerGas &&\n txMeta.txParams.maxPriorityFeePerGas)\n ) {\n return {};\n }\n\n try {\n const { gasFeeEstimates, gasEstimateType } = await getGasFeeEstimates();\n\n if (eip1559 && gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n const {\n medium: { suggestedMaxPriorityFeePerGas, suggestedMaxFeePerGas } = {},\n } = gasFeeEstimates;\n\n if (suggestedMaxPriorityFeePerGas && suggestedMaxFeePerGas) {\n return {\n maxFeePerGas: gweiDecimalToWeiHex(suggestedMaxFeePerGas),\n maxPriorityFeePerGas: gweiDecimalToWeiHex(\n suggestedMaxPriorityFeePerGas,\n ),\n };\n }\n }\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n // The LEGACY type includes low, medium and high estimates of\n // gas price values.\n return {\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.medium),\n };\n }\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.ETH_GASPRICE) {\n // The ETH_GASPRICE type just includes a single gas price property,\n // which we can assume was retrieved from eth_gasPrice\n return {\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n } catch (error) {\n log('Failed to get suggested gas fees', error);\n }\n\n const gasPriceDecimal = (await query(ethQuery, 'gasPrice')) as number;\n\n const gasPrice = gasPriceDecimal\n ? addHexPrefix(gasPriceDecimal.toString(16))\n : undefined;\n\n return { gasPrice };\n}\n\nfunction gweiDecimalToWeiHex(value: string) {\n return toHex(gweiDecToWEIBN(value));\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts +new file mode 100644 +index 0000000..59837f9 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts +@@ -0,0 +1,33 @@ ++import type { GasFeeEstimates, LegacyGasPriceEstimate } from '@metamask/gas-fee-controller'; ++import { type GasFeeState } from '@metamask/gas-fee-controller'; ++import { type GasFeeEstimates as TransactionGasFeeEstimates, type GasFeeFlow, type TransactionMeta } from '../types'; ++/** ++ * Returns the first gas fee flow that matches the transaction. ++ * ++ * @param transactionMeta - The transaction metadata to find a gas fee flow for. ++ * @param gasFeeFlows - The gas fee flows to search. ++ * @returns The first gas fee flow that matches the transaction, or undefined if none match. ++ */ ++export declare function getGasFeeFlow(transactionMeta: TransactionMeta, gasFeeFlows: GasFeeFlow[]): GasFeeFlow | undefined; ++declare type FeeMarketMergeGasFeeEstimatesRequest = { ++ gasFeeControllerEstimateType: 'fee-market'; ++ gasFeeControllerEstimates: GasFeeEstimates; ++ transactionGasFeeEstimates: TransactionGasFeeEstimates; ++}; ++declare type LegacyMergeGasFeeEstimatesRequest = { ++ gasFeeControllerEstimateType: 'legacy'; ++ gasFeeControllerEstimates: LegacyGasPriceEstimate; ++ transactionGasFeeEstimates: TransactionGasFeeEstimates; ++}; ++/** ++ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction. ++ * ++ * @param request - Data required to merge gas fee estimates. ++ * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller. ++ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController. ++ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction. ++ * @returns The merged gas fee estimates. ++ */ ++export declare function mergeGasFeeEstimates({ gasFeeControllerEstimateType, gasFeeControllerEstimates, transactionGasFeeEstimates, }: FeeMarketMergeGasFeeEstimatesRequest | LegacyMergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates']; ++export {}; ++//# sourceMappingURL=gas-flow.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map +new file mode 100644 +index 0000000..46c3e5a +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas-flow.d.ts","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,eAAe,EACf,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,KAAK,eAAe,IAAI,0BAA0B,EAClD,KAAK,UAAU,EACf,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AAElB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,UAAU,EAAE,GACxB,UAAU,GAAG,SAAS,CAIxB;AAED,aAAK,oCAAoC,GAAG;IAC1C,4BAA4B,EAAE,YAAY,CAAC;IAC3C,yBAAyB,EAAE,eAAe,CAAC;IAC3C,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF,aAAK,iCAAiC,GAAG;IACvC,4BAA4B,EAAE,QAAQ,CAAC;IACvC,yBAAyB,EAAE,sBAAsB,CAAC;IAClD,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAC3B,EACG,oCAAoC,GACpC,iCAAiC,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAyBrE"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js +new file mode 100644 +index 0000000..7f4e8a9 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js +@@ -0,0 +1,56 @@ ++"use strict"; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.mergeGasFeeEstimates = exports.getGasFeeFlow = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const gas_fee_controller_1 = require("@metamask/gas-fee-controller"); ++const types_1 = require("../types"); ++/** ++ * Returns the first gas fee flow that matches the transaction. ++ * ++ * @param transactionMeta - The transaction metadata to find a gas fee flow for. ++ * @param gasFeeFlows - The gas fee flows to search. ++ * @returns The first gas fee flow that matches the transaction, or undefined if none match. ++ */ ++function getGasFeeFlow(transactionMeta, gasFeeFlows) { ++ return gasFeeFlows.find((gasFeeFlow) => gasFeeFlow.matchesTransaction(transactionMeta)); ++} ++exports.getGasFeeFlow = getGasFeeFlow; ++/** ++ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction. ++ * ++ * @param request - Data required to merge gas fee estimates. ++ * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller. ++ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController. ++ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction. ++ * @returns The merged gas fee estimates. ++ */ ++function mergeGasFeeEstimates({ gasFeeControllerEstimateType, gasFeeControllerEstimates, transactionGasFeeEstimates, }) { ++ if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { ++ return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: mergeFeeMarketEstimate(gasFeeControllerEstimates[level], transactionGasFeeEstimates[level]) })), Object.assign({}, gasFeeControllerEstimates)); ++ } ++ if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) { ++ return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: getLegacyEstimate(transactionGasFeeEstimates[level]) })), {}); ++ } ++ return gasFeeControllerEstimates; ++} ++exports.mergeGasFeeEstimates = mergeGasFeeEstimates; ++/** ++ * Merge a specific priority level of EIP-1559 gas fee estimates. ++ * ++ * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller. ++ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction. ++ * @returns The merged gas fee estimate. ++ */ ++function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) { ++ return Object.assign(Object.assign({}, gasFeeControllerEstimate), { suggestedMaxFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas), suggestedMaxPriorityFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxPriorityFeePerGas) }); ++} ++/** ++ * Generate a specific priority level for a legacy gas fee estimate. ++ * ++ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction. ++ * @returns The legacy gas fee estimate. ++ */ ++function getLegacyEstimate(transactionGasFeeEstimate) { ++ return (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas); ++} ++//# sourceMappingURL=gas-flow.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map +new file mode 100644 +index 0000000..fe93a4a +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas-flow.js","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAM7D,qEAGsC;AAEtC,oCAMkB;AAElB;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,eAAgC,EAChC,WAAyB;IAEzB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrC,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAC/C,CAAC;AACJ,CAAC;AAPD,sCAOC;AAcD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAAC,EACnC,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAGS;IACnC,IAAI,4BAA4B,KAAK,uCAAkB,CAAC,UAAU,EAAE;QAClE,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,iCACd,MAAM,KACT,CAAC,KAAK,CAAC,EAAE,sBAAsB,CAC7B,yBAAyB,CAAC,KAAK,CAAC,EAChC,0BAA0B,CAAC,KAAK,CAAC,CAClC,IACD,EACF,kBAAK,yBAAyB,CAAqB,CACpD,CAAC;KACH;IAED,IAAI,4BAA4B,KAAK,uCAAkB,CAAC,MAAM,EAAE;QAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,iCACd,MAAM,KACT,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,IAC7D,EACF,EAA4B,CAC7B,CAAC;KACH;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC;AA/BD,oDA+BC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAC7B,wBAAuC,EACvC,yBAAkD;IAElD,uCACK,wBAAwB,KAC3B,qBAAqB,EAAE,IAAA,kCAAe,EACpC,yBAAyB,CAAC,YAAY,CACvC,EACD,6BAA6B,EAAE,IAAA,kCAAe,EAC5C,yBAAyB,CAAC,oBAAoB,CAC/C,IACD;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,yBAAkD;IAElD,OAAO,IAAA,kCAAe,EAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport type {\n Eip1559GasFee,\n GasFeeEstimates,\n LegacyGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport {\n GAS_ESTIMATE_TYPES,\n type GasFeeState,\n} from '@metamask/gas-fee-controller';\n\nimport {\n type GasFeeEstimates as TransactionGasFeeEstimates,\n type GasFeeFlow,\n type TransactionMeta,\n type GasFeeEstimatesForLevel,\n GasFeeEstimateLevel,\n} from '../types';\n\n/**\n * Returns the first gas fee flow that matches the transaction.\n *\n * @param transactionMeta - The transaction metadata to find a gas fee flow for.\n * @param gasFeeFlows - The gas fee flows to search.\n * @returns The first gas fee flow that matches the transaction, or undefined if none match.\n */\nexport function getGasFeeFlow(\n transactionMeta: TransactionMeta,\n gasFeeFlows: GasFeeFlow[],\n): GasFeeFlow | undefined {\n return gasFeeFlows.find((gasFeeFlow) =>\n gasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\ntype FeeMarketMergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimateType: 'fee-market';\n gasFeeControllerEstimates: GasFeeEstimates;\n transactionGasFeeEstimates: TransactionGasFeeEstimates;\n};\n\ntype LegacyMergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimateType: 'legacy';\n gasFeeControllerEstimates: LegacyGasPriceEstimate;\n transactionGasFeeEstimates: TransactionGasFeeEstimates;\n};\n\n/**\n * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.\n *\n * @param request - Data required to merge gas fee estimates.\n * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller.\n * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.\n * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.\n * @returns The merged gas fee estimates.\n */\nexport function mergeGasFeeEstimates({\n gasFeeControllerEstimateType,\n gasFeeControllerEstimates,\n transactionGasFeeEstimates,\n}:\n | FeeMarketMergeGasFeeEstimatesRequest\n | LegacyMergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'] {\n if (gasFeeControllerEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: mergeFeeMarketEstimate(\n gasFeeControllerEstimates[level],\n transactionGasFeeEstimates[level],\n ),\n }),\n { ...gasFeeControllerEstimates } as GasFeeEstimates,\n );\n }\n\n if (gasFeeControllerEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: getLegacyEstimate(transactionGasFeeEstimates[level]),\n }),\n {} as LegacyGasPriceEstimate,\n );\n }\n\n return gasFeeControllerEstimates;\n}\n\n/**\n * Merge a specific priority level of EIP-1559 gas fee estimates.\n *\n * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The merged gas fee estimate.\n */\nfunction mergeFeeMarketEstimate(\n gasFeeControllerEstimate: Eip1559GasFee,\n transactionGasFeeEstimate: GasFeeEstimatesForLevel,\n): Eip1559GasFee {\n return {\n ...gasFeeControllerEstimate,\n suggestedMaxFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxFeePerGas,\n ),\n suggestedMaxPriorityFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxPriorityFeePerGas,\n ),\n };\n}\n\n/**\n * Generate a specific priority level for a legacy gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The legacy gas fee estimate.\n */\nfunction getLegacyEstimate(\n transactionGasFeeEstimate: GasFeeEstimatesForLevel,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate.maxFeePerGas);\n}\n"]} \ 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 +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts new file mode 100644 -index 0000000..39cc136 +index 0000000..a3abd31 --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/types.d.ts -@@ -0,0 +1,232 @@ -+import { Hex } from '@metamask/utils'; -+import { GasFeeState } from '@metamask/gas-fee-controller'; ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts +@@ -0,0 +1,27 @@ ++/// ++import type EthQuery from '@metamask/eth-query'; ++import type { ProviderConfig } from '@metamask/network-controller'; ++import type { TransactionMeta, TransactionParams } from '../types'; ++export declare type UpdateGasRequest = { ++ ethQuery: EthQuery; ++ providerConfig: ProviderConfig; ++ txMeta: TransactionMeta; ++}; ++export declare const log: import("debug").Debugger; ++export declare const FIXED_GAS = "0x5208"; ++export declare const DEFAULT_GAS_MULTIPLIER = 1.5; ++export declare function updateGas(request: UpdateGasRequest): Promise; ++export declare function estimateGas(txParams: TransactionParams, ethQuery: EthQuery): Promise<{ ++ blockGasLimit: string; ++ estimatedGas: string; ++ simulationFails: { ++ reason: any; ++ errorKey: any; ++ debug: { ++ blockNumber: string; ++ blockGasLimit: string; ++ }; ++ } | undefined; ++}>; ++export declare function addGasBuffer(estimatedGas: string, blockGasLimit: string, multiplier: number): string; ++//# sourceMappingURL=gas.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts.map +new file mode 100644 +index 0000000..0875df2 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";AASA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnE,oBAAY,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,GAAG,0BAA2C,CAAC;AAE5D,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,iBAkBxD;AAED,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ;;;;;;;;;;;GAwCnB;AAED,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,UAqBnB"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas.js b/node_modules/@metamask/transaction-controller/dist/utils/gas.js +new file mode 100644 +index 0000000..072b0e6 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas.js +@@ -0,0 +1,136 @@ ++"use strict"; ++/* eslint-disable jsdoc/require-jsdoc */ ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.addGasBuffer = exports.estimateGas = exports.updateGas = exports.DEFAULT_GAS_MULTIPLIER = exports.FIXED_GAS = exports.log = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const utils_1 = require("@metamask/utils"); ++const ethereumjs_util_1 = require("ethereumjs-util"); ++const constants_1 = require("../constants"); ++const logger_1 = require("../logger"); ++exports.log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas'); ++exports.FIXED_GAS = '0x5208'; ++exports.DEFAULT_GAS_MULTIPLIER = 1.5; ++function updateGas(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { txMeta } = request; ++ const initialParams = Object.assign({}, txMeta.txParams); ++ const [gas, simulationFails] = yield getGas(request); ++ txMeta.txParams.gas = gas; ++ txMeta.simulationFails = simulationFails; ++ if (!initialParams.gas) { ++ txMeta.originalGasEstimate = txMeta.txParams.gas; ++ } ++ if (!txMeta.defaultGasEstimates) { ++ txMeta.defaultGasEstimates = {}; ++ } ++ txMeta.defaultGasEstimates.gas = txMeta.txParams.gas; ++ }); ++} ++exports.updateGas = updateGas; ++function estimateGas(txParams, ethQuery) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const request = Object.assign({}, txParams); ++ const { data, value } = request; ++ const { gasLimit: gasLimitHex, number: blockNumber } = yield getLatestBlock(ethQuery); ++ const gasLimitBN = (0, controller_utils_1.hexToBN)(gasLimitHex); ++ request.data = data ? (0, ethereumjs_util_1.addHexPrefix)(data) : data; ++ request.gas = (0, controller_utils_1.BNToHex)((0, controller_utils_1.fractionBN)(gasLimitBN, 19, 20)); ++ request.value = value || '0x0'; ++ let estimatedGas = request.gas; ++ let simulationFails; ++ try { ++ estimatedGas = yield (0, controller_utils_1.query)(ethQuery, 'estimateGas', [request]); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ } ++ catch (error) { ++ simulationFails = { ++ reason: error.message, ++ errorKey: error.errorKey, ++ debug: { ++ blockNumber, ++ blockGasLimit: gasLimitHex, ++ }, ++ }; ++ (0, exports.log)('Estimation failed', Object.assign(Object.assign({}, simulationFails), { fallback: estimateGas })); ++ } ++ return { ++ blockGasLimit: gasLimitHex, ++ estimatedGas, ++ simulationFails, ++ }; ++ }); ++} ++exports.estimateGas = estimateGas; ++function addGasBuffer(estimatedGas, blockGasLimit, multiplier) { ++ const estimatedGasBN = (0, controller_utils_1.hexToBN)(estimatedGas); ++ const maxGasBN = (0, controller_utils_1.hexToBN)(blockGasLimit).muln(0.9); ++ const paddedGasBN = estimatedGasBN.muln(multiplier); ++ if (estimatedGasBN.gt(maxGasBN)) { ++ const estimatedGasHex = (0, ethereumjs_util_1.addHexPrefix)(estimatedGas); ++ (0, exports.log)('Using estimated value', estimatedGasHex); ++ return estimatedGasHex; ++ } ++ if (paddedGasBN.lt(maxGasBN)) { ++ const paddedHex = (0, ethereumjs_util_1.addHexPrefix)((0, controller_utils_1.BNToHex)(paddedGasBN)); ++ (0, exports.log)('Using padded estimate', paddedHex, multiplier); ++ return paddedHex; ++ } ++ const maxHex = (0, ethereumjs_util_1.addHexPrefix)((0, controller_utils_1.BNToHex)(maxGasBN)); ++ (0, exports.log)('Using 90% of block gas limit', maxHex); ++ return maxHex; ++} ++exports.addGasBuffer = addGasBuffer; ++function getGas(request) { ++ var _a; ++ return __awaiter(this, void 0, void 0, function* () { ++ const { providerConfig, txMeta } = request; ++ if (txMeta.txParams.gas) { ++ (0, exports.log)('Using value from request', txMeta.txParams.gas); ++ return [txMeta.txParams.gas]; ++ } ++ if (yield requiresFixedGas(request)) { ++ (0, exports.log)('Using fixed value', exports.FIXED_GAS); ++ return [exports.FIXED_GAS]; ++ } ++ const { blockGasLimit, estimatedGas, simulationFails } = yield estimateGas(txMeta.txParams, request.ethQuery); ++ if (providerConfig.type === controller_utils_1.NetworkType.rpc) { ++ (0, exports.log)('Using original estimate as custom network'); ++ return [estimatedGas, simulationFails]; ++ } ++ const bufferMultiplier = (_a = constants_1.GAS_BUFFER_CHAIN_OVERRIDES[providerConfig.chainId]) !== null && _a !== void 0 ? _a : exports.DEFAULT_GAS_MULTIPLIER; ++ const bufferedGas = addGasBuffer(estimatedGas, blockGasLimit, bufferMultiplier); ++ return [bufferedGas, simulationFails]; ++ }); ++} ++function requiresFixedGas({ ethQuery, txMeta, providerConfig, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const isCustomNetwork = providerConfig.type === controller_utils_1.NetworkType.rpc; ++ const { txParams: { to, data }, } = txMeta; ++ if (isCustomNetwork || !to || data) { ++ return false; ++ } ++ const code = yield getCode(ethQuery, to); ++ return !code || code === '0x'; ++ }); ++} ++function getCode(ethQuery, address) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield (0, controller_utils_1.query)(ethQuery, 'getCode', [address]); ++ }); ++} ++function getLatestBlock(ethQuery) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return yield (0, controller_utils_1.query)(ethQuery, 'getBlockByNumber', ['latest', false]); ++ }); ++} ++//# sourceMappingURL=gas.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas.js.map b/node_modules/@metamask/transaction-controller/dist/utils/gas.js.map +new file mode 100644 +index 0000000..d705124 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;;;;;;;;;;AAExC,iEAMoC;AAGpC,2CAAqD;AACrD,qDAA+C;AAE/C,4CAA0D;AAC1D,sCAA0C;AAS7B,QAAA,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,KAAK,CAAC,CAAC;AAE/C,QAAA,SAAS,GAAG,QAAQ,CAAC;AACrB,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAE1C,SAAsB,SAAS,CAAC,OAAyB;;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,MAAM,aAAa,qBAAQ,MAAM,CAAC,QAAQ,CAAE,CAAC;QAE7C,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QAErD,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;YACtB,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;SAClD;QAED,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE;YAC/B,MAAM,CAAC,mBAAmB,GAA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AAC;CAAA;AAED,SAAe,OAAO,CACpB,QAAkB,EAClB,OAAe;;QAEf,OAAO,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC;CAAA;AAED,SAAe,cAAc,CAC3B,QAAkB;;QAElB,OAAO,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,kBAAkB,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IACtE,CAAC;CAAA","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport {\n BNToHex,\n NetworkType,\n fractionBN,\n hexToBN,\n query,\n} from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { ProviderConfig } from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport { addHexPrefix } from 'ethereumjs-util';\n\nimport { GAS_BUFFER_CHAIN_OVERRIDES } from '../constants';\nimport { projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionParams } from '../types';\n\nexport type UpdateGasRequest = {\n ethQuery: EthQuery;\n providerConfig: ProviderConfig;\n txMeta: TransactionMeta;\n};\n\nexport const log = createModuleLogger(projectLogger, 'gas');\n\nexport const FIXED_GAS = '0x5208';\nexport const DEFAULT_GAS_MULTIPLIER = 1.5;\n\nexport async function updateGas(request: UpdateGasRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const [gas, simulationFails] = await getGas(request);\n\n txMeta.txParams.gas = gas;\n txMeta.simulationFails = simulationFails;\n\n if (!initialParams.gas) {\n txMeta.originalGasEstimate = txMeta.txParams.gas;\n }\n\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.gas = txMeta.txParams.gas;\n}\n\nexport async function estimateGas(\n txParams: TransactionParams,\n ethQuery: EthQuery,\n) {\n const request = { ...txParams };\n const { data, value } = request;\n\n const { gasLimit: gasLimitHex, number: blockNumber } = await getLatestBlock(\n ethQuery,\n );\n\n const gasLimitBN = hexToBN(gasLimitHex);\n\n request.data = data ? addHexPrefix(data) : data;\n request.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n request.value = value || '0x0';\n\n let estimatedGas = request.gas;\n let simulationFails;\n\n try {\n estimatedGas = await query(ethQuery, 'estimateGas', [request]);\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n simulationFails = {\n reason: error.message,\n errorKey: error.errorKey,\n debug: {\n blockNumber,\n blockGasLimit: gasLimitHex,\n },\n };\n\n log('Estimation failed', { ...simulationFails, fallback: estimateGas });\n }\n\n return {\n blockGasLimit: gasLimitHex,\n estimatedGas,\n simulationFails,\n };\n}\n\nexport function addGasBuffer(\n estimatedGas: string,\n blockGasLimit: string,\n multiplier: number,\n) {\n const estimatedGasBN = hexToBN(estimatedGas);\n const maxGasBN = hexToBN(blockGasLimit).muln(0.9);\n const paddedGasBN = estimatedGasBN.muln(multiplier);\n\n if (estimatedGasBN.gt(maxGasBN)) {\n const estimatedGasHex = addHexPrefix(estimatedGas);\n log('Using estimated value', estimatedGasHex);\n return estimatedGasHex;\n }\n\n if (paddedGasBN.lt(maxGasBN)) {\n const paddedHex = addHexPrefix(BNToHex(paddedGasBN));\n log('Using padded estimate', paddedHex, multiplier);\n return paddedHex;\n }\n\n const maxHex = addHexPrefix(BNToHex(maxGasBN));\n log('Using 90% of block gas limit', maxHex);\n return maxHex;\n}\n\nasync function getGas(\n request: UpdateGasRequest,\n): Promise<[string, TransactionMeta['simulationFails']?]> {\n const { providerConfig, txMeta } = request;\n\n if (txMeta.txParams.gas) {\n log('Using value from request', txMeta.txParams.gas);\n return [txMeta.txParams.gas];\n }\n\n if (await requiresFixedGas(request)) {\n log('Using fixed value', FIXED_GAS);\n return [FIXED_GAS];\n }\n\n const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(\n txMeta.txParams,\n request.ethQuery,\n );\n\n if (providerConfig.type === NetworkType.rpc) {\n log('Using original estimate as custom network');\n return [estimatedGas, simulationFails];\n }\n\n const bufferMultiplier =\n GAS_BUFFER_CHAIN_OVERRIDES[\n providerConfig.chainId as keyof typeof GAS_BUFFER_CHAIN_OVERRIDES\n ] ?? DEFAULT_GAS_MULTIPLIER;\n\n const bufferedGas = addGasBuffer(\n estimatedGas,\n blockGasLimit,\n bufferMultiplier,\n );\n\n return [bufferedGas, simulationFails];\n}\n\nasync function requiresFixedGas({\n ethQuery,\n txMeta,\n providerConfig,\n}: UpdateGasRequest): Promise {\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n\n const {\n txParams: { to, data },\n } = txMeta;\n\n if (isCustomNetwork || !to || data) {\n return false;\n }\n\n const code = await getCode(ethQuery, to);\n\n return !code || code === '0x';\n}\n\nasync function getCode(\n ethQuery: EthQuery,\n address: string,\n): Promise {\n return await query(ethQuery, 'getCode', [address]);\n}\n\nasync function getLatestBlock(\n ethQuery: EthQuery,\n): Promise<{ gasLimit: string; number: string }> {\n return await query(ethQuery, 'getBlockByNumber', ['latest', false]);\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts +new file mode 100644 +index 0000000..bafbf48 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts +@@ -0,0 +1,15 @@ ++import type { TransactionMeta } from '../types'; +/** -+ * @type TransactionMeta ++ * Add initial history snapshot to the provided transactionMeta history. + * -+ * TransactionMeta representation -+ * @property error - Synthesized error information for failed transactions -+ * @property id - Generated UUID associated with this transaction -+ * @property networkID - Network code as per EIP-155 for this transaction -+ * @property origin - Origin this transaction was sent from -+ * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed -+ * @property rawTransaction - Hex representation of the underlying transaction -+ * @property status - String status of this transaction -+ * @property time - Timestamp associated with this transaction -+ * @property toSmartContract - Whether transaction recipient is a smart contract -+ * @property transaction - Underlying Transaction object -+ * @property transactionHash - Hash of a successful transaction -+ * @property blockNumber - Number of the block where the transaction has been included ++ * @param transactionMeta - TransactionMeta to add initial history snapshot to. + */ -+export declare type TransactionMeta = ({ -+ status: Exclude; -+} & TransactionMetaBase) | ({ -+ status: TransactionStatus.failed; -+ error: Error; -+} & TransactionMetaBase); -+declare type TransactionMetaBase = { -+ isTransfer?: boolean; -+ transferInformation?: { -+ symbol: string; -+ contractAddress: string; -+ decimals: number; -+ }; -+ id: string; -+ networkID?: string; -+ chainId?: Hex; -+ origin?: string; -+ rawTransaction?: string; -+ time: number; -+ toSmartContract?: boolean; -+ transaction: Transaction; -+ transactionHash?: string; -+ blockNumber?: string; -+ deviceConfirmedOn?: WalletDevice; -+ verifiedOnBlockchain?: boolean; -+ /** Alternate EIP-1559 gas fee estimates for multiple priority levels. */ -+ gasFeeEstimates?: GasFeeEstimates; -+ /** Whether the gas fee estimates have been checked at least once. */ -+ gasFeeEstimatesLoaded?: boolean; -+ /** -+ * Response from security validator. -+ */ -+ securityAlertResponse?: SecurityAlertResponse; ++export declare function addInitialHistorySnapshot(transactionMeta: TransactionMeta): void; ++/** ++ * Compares and adds history entry to the provided transactionMeta history. ++ * ++ * @param transactionMeta - TransactionMeta to add history entry to. ++ * @param note - Note to add to history entry. ++ */ ++export declare function updateTransactionHistory(transactionMeta: TransactionMeta, note: string): void; ++//# sourceMappingURL=history.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts.map +new file mode 100644 +index 0000000..61f35cd +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/history.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/utils/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,eAAe,QAGzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,MAAM,GACX,IAAI,CAeN"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/history.js b/node_modules/@metamask/transaction-controller/dist/utils/history.js +new file mode 100644 +index 0000000..c2eb6d7 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/history.js +@@ -0,0 +1,84 @@ ++"use strict"; ++var __importDefault = (this && this.__importDefault) || function (mod) { ++ return (mod && mod.__esModule) ? mod : { "default": mod }; +}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.updateTransactionHistory = exports.addInitialHistorySnapshot = void 0; ++const fast_json_patch_1 = __importDefault(require("fast-json-patch")); ++const lodash_1 = require("lodash"); +/** -+ * The status of the transaction. Each status represents the state of the transaction internally -+ * in the wallet. Some of these correspond with the state of the transaction on the network, but -+ * some are wallet-specific. ++ * Add initial history snapshot to the provided transactionMeta history. ++ * ++ * @param transactionMeta - TransactionMeta to add initial history snapshot to. + */ -+export declare enum TransactionStatus { -+ approved = "approved", -+ cancelled = "cancelled", -+ confirmed = "confirmed", -+ failed = "failed", -+ rejected = "rejected", -+ signed = "signed", -+ submitted = "submitted", -+ unapproved = "unapproved" ++function addInitialHistorySnapshot(transactionMeta) { ++ const snapshot = snapshotFromTransactionMeta(transactionMeta); ++ transactionMeta.history = [snapshot]; ++} ++exports.addInitialHistorySnapshot = addInitialHistorySnapshot; ++/** ++ * Compares and adds history entry to the provided transactionMeta history. ++ * ++ * @param transactionMeta - TransactionMeta to add history entry to. ++ * @param note - Note to add to history entry. ++ */ ++function updateTransactionHistory(transactionMeta, note) { ++ var _a; ++ if (!transactionMeta.history) { ++ return; ++ } ++ const currentState = snapshotFromTransactionMeta(transactionMeta); ++ const previousState = replayHistory(transactionMeta.history); ++ const historyEntry = generateHistoryEntry(previousState, currentState, note); ++ if (historyEntry.length) { ++ (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.history) === null || _a === void 0 ? void 0 : _a.push(historyEntry); ++ } ++} ++exports.updateTransactionHistory = updateTransactionHistory; ++/** ++ * Generates a history entry from the previous and new transaction metadata. ++ * ++ * @param previousState - The previous transaction metadata. ++ * @param currentState - The new transaction metadata. ++ * @param note - A note for the transaction metada update. ++ * @returns An array of history operation. ++ */ ++function generateHistoryEntry( ++// TODO: Replace `any` with type ++// eslint-disable-next-line @typescript-eslint/no-explicit-any ++previousState, currentState, note) { ++ const historyOperationsEntry = fast_json_patch_1.default.compare(previousState, currentState); ++ // Add a note to the first operation, since it breaks if we append it to the entry ++ if (historyOperationsEntry[0]) { ++ if (note) { ++ historyOperationsEntry[0].note = note; ++ } ++ historyOperationsEntry[0].timestamp = Date.now(); ++ } ++ return historyOperationsEntry; ++} ++/** ++ * Recovers previous transactionMeta from passed history array. ++ * ++ * @param transactionHistory - The transaction metadata to replay. ++ * @returns The transaction metadata. ++ */ ++function replayHistory(transactionHistory) { ++ const shortHistory = (0, lodash_1.cloneDeep)(transactionHistory); ++ return shortHistory.reduce( ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ (val, entry) => fast_json_patch_1.default.applyPatch(val, entry).newDocument); ++} ++/** ++ * Clone the transaction meta data without the history property. ++ * ++ * @param transactionMeta - The transaction metadata to snapshot. ++ * @returns A deep clone of transaction metadata without history property. ++ */ ++function snapshotFromTransactionMeta(transactionMeta) { ++ const snapshot = Object.assign({}, transactionMeta); ++ delete snapshot.history; ++ return (0, lodash_1.cloneDeep)(snapshot); +} ++//# sourceMappingURL=history.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/history.js.map b/node_modules/@metamask/transaction-controller/dist/utils/history.js.map +new file mode 100644 +index 0000000..fdaa643 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/history.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"history.js","sourceR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GAKG;AACH,SAAS,aAAa,CACpB,kBAAsC;IAEtC,MAAM,YAAY,GAAG,IAAA,kBAAS,EAAC,kBAAkB,CAAC,CAAC;IACnD,OAAO,YAAY,CAAC,MAAM;IACxB,gCAAgC;IAChC,8DAA8D;IAC9D,CAAC,GAAG,EAAE,KAAU,EAAE,EAAE,CAAC,yBAAU,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,WAAW,CAChD,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAClC,eAAgC;IAEhC,MAAM,QAAQ,qBAAQ,eAAe,CAAE,CAAC;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC;IACxB,OAAO,IAAA,kBAAS,EAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import jsonDiffer from 'fast-json-patch';\nimport { cloneDeep } from 'lodash';\n\nimport type {\n TransactionHistory,\n TransactionHistoryEntry,\n TransactionMeta,\n} from '../types';\n\n/**\n * Add initial history snapshot to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add initial history snapshot to.\n */\nexport function addInitialHistorySnapshot(transactionMeta: TransactionMeta) {\n const snapshot = snapshotFromTransactionMeta(transactionMeta);\n transactionMeta.history = [snapshot];\n}\n\n/**\n * Compares and adds history entry to the provided transactionMeta history.\n *\n * @param transactionMeta - TransactionMeta to add history entry to.\n * @param note - Note to add to history entry.\n */\nexport function updateTransactionHistory(\n transactionMeta: TransactionMeta,\n note: string,\n): void {\n if (!transactionMeta.history) {\n return;\n }\n\n const currentState = snapshotFromTransactionMeta(transactionMeta);\n const previousState = replayHistory(\n transactionMeta.history as TransactionHistory,\n );\n\n const historyEntry = generateHistoryEntry(previousState, currentState, note);\n\n if (historyEntry.length) {\n transactionMeta?.history?.push(historyEntry);\n }\n}\n\n/**\n * Generates a history entry from the previous and new transaction metadata.\n *\n * @param previousState - The previous transaction metadata.\n * @param currentState - The new transaction metadata.\n * @param note - A note for the transaction metada update.\n * @returns An array of history operation.\n */\nfunction generateHistoryEntry(\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n previousState: any,\n currentState: TransactionMeta,\n note: string,\n): TransactionHistoryEntry {\n const historyOperationsEntry = jsonDiffer.compare(\n previousState,\n currentState,\n ) as TransactionHistoryEntry;\n // Add a note to the first operation, since it breaks if we append it to the entry\n if (historyOperationsEntry[0]) {\n if (note) {\n historyOperationsEntry[0].note = note;\n }\n historyOperationsEntry[0].timestamp = Date.now();\n }\n return historyOperationsEntry;\n}\n\n/**\n * Recovers previous transactionMeta from passed history array.\n *\n * @param transactionHistory - The transaction metadata to replay.\n * @returns The transaction metadata.\n */\nfunction replayHistory(\n transactionHistory: TransactionHistory,\n): TransactionMeta {\n const shortHistory = cloneDeep(transactionHistory);\n return shortHistory.reduce(\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (val, entry: any) => jsonDiffer.applyPatch(val, entry).newDocument,\n ) as TransactionMeta;\n}\n\n/**\n * Clone the transaction meta data without the history property.\n *\n * @param transactionMeta - The transaction metadata to snapshot.\n * @returns A deep clone of transaction metadata without history property.\n */\nfunction snapshotFromTransactionMeta(\n transactionMeta: TransactionMeta,\n): TransactionMeta {\n const snapshot = { ...transactionMeta };\n delete snapshot.history;\n return cloneDeep(snapshot);\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts +new file mode 100644 +index 0000000..04b9b52 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts +@@ -0,0 +1,21 @@ ++import type { NonceTracker, Transaction as NonceTrackerTransaction } from 'nonce-tracker'; ++import type { TransactionMeta, TransactionStatus } from '../types'; ++/** ++ * Determine the next nonce to be used for a transaction. ++ * ++ * @param txMeta - The transaction metadata. ++ * @param nonceTracker - An instance of a nonce tracker. ++ * @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock. ++ */ ++export declare function getNextNonce(txMeta: TransactionMeta, nonceTracker: NonceTracker): Promise<[string, (() => void) | undefined]>; ++/** ++ * Filter and format transactions for the nonce tracker. ++ * ++ * @param currentChainId - Chain ID of the current network. ++ * @param fromAddress - Address of the account from which the transactions to filter from are sent. ++ * @param transactionStatus - Status of the transactions for which to filter. ++ * @param transactions - Array of transactionMeta objects that have been prefiltered. ++ * @returns Array of transactions formatted for the nonce tracker. ++ */ ++export declare function getAndFormatTransactionsForNonceTracker(currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; ++//# sourceMappingURL=nonce.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts.map +new file mode 100644 +index 0000000..0914c21 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/nonce.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"nonce.d.ts","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,IAAI,uBAAuB,EACvC,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAInE;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAyB7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,uCAAuC,CACrD,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,eAAe,EAAE,GAC9B,uBAAuB,EAAE,CA0B3B"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/nonce.js b/node_modules/@metamask/transaction-controller/dist/utils/nonce.js +new file mode 100644 +index 0000000..686d398 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/nonce.js +@@ -0,0 +1,77 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.getAndFormatTransactionsForNonceTracker = exports.getNextNonce = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const logger_1 = require("../logger"); ++const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'nonce'); +/** -+ * Options for wallet device. ++ * Determine the next nonce to be used for a transaction. ++ * ++ * @param txMeta - The transaction metadata. ++ * @param nonceTracker - An instance of a nonce tracker. ++ * @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock. + */ -+export declare enum WalletDevice { -+ MM_MOBILE = "metamask_mobile", -+ MM_EXTENSION = "metamask_extension", -+ OTHER = "other_device" ++function getNextNonce(txMeta, nonceTracker) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { customNonceValue, txParams: { from, nonce: existingNonce }, } = txMeta; ++ const customNonce = customNonceValue ? (0, controller_utils_1.toHex)(customNonceValue) : undefined; ++ if (customNonce) { ++ log('Using custom nonce', customNonce); ++ return [customNonce, undefined]; ++ } ++ if (existingNonce) { ++ log('Using existing nonce', existingNonce); ++ return [existingNonce, undefined]; ++ } ++ const nonceLock = yield nonceTracker.getNonceLock(from); ++ const nonce = (0, controller_utils_1.toHex)(nonceLock.nextNonce); ++ const releaseLock = nonceLock.releaseLock.bind(nonceLock); ++ log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails); ++ return [nonce, releaseLock]; ++ }); +} ++exports.getNextNonce = getNextNonce; +/** -+ * @type Transaction ++ * Filter and format transactions for the nonce tracker. + * -+ * Transaction representation -+ * @property chainId - Network ID as per EIP-155 -+ * @property data - Data to pass with this transaction -+ * @property from - Address to send this transaction from -+ * @property gas - Gas to send with this transaction -+ * @property gasPrice - Price of gas with this transaction -+ * @property gasUsed - Gas used in the transaction -+ * @property nonce - Unique number to prevent replay attacks -+ * @property to - Address to send this transaction to -+ * @property value - Value associated with this transaction ++ * @param currentChainId - Chain ID of the current network. ++ * @param fromAddress - Address of the account from which the transactions to filter from are sent. ++ * @param transactionStatus - Status of the transactions for which to filter. ++ * @param transactions - Array of transactionMeta objects that have been prefiltered. ++ * @returns Array of transactions formatted for the nonce tracker. + */ -+export interface Transaction { -+ chainId?: Hex; -+ data?: string; -+ from: string; -+ gas?: string; -+ gasPrice?: string; -+ gasUsed?: string; -+ nonce?: string; -+ to?: string; -+ value?: string; -+ maxFeePerGas?: string; -+ maxPriorityFeePerGas?: string; -+ estimatedBaseFee?: string; -+ estimateGasError?: string; -+ type?: string; ++function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) { ++ return transactions ++ .filter(({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) => !isTransfer && ++ !isUserOperation && ++ chainId === currentChainId && ++ status === transactionStatus && ++ from.toLowerCase() === fromAddress.toLowerCase()) ++ .map(({ status, txParams: { from, gas, value, nonce } }) => { ++ // the only value we care about is the nonce ++ // but we need to return the other values to satisfy the type ++ // TODO: refactor nonceTracker to not require this ++ /* istanbul ignore next */ ++ return { ++ status, ++ history: [{}], ++ txParams: { ++ from: from !== null && from !== void 0 ? from : '', ++ gas: gas !== null && gas !== void 0 ? gas : '', ++ value: value !== null && value !== void 0 ? value : '', ++ nonce: nonce !== null && nonce !== void 0 ? nonce : '', ++ }, ++ }; ++ }); +} ++exports.getAndFormatTransactionsForNonceTracker = getAndFormatTransactionsForNonceTracker; ++//# sourceMappingURL=nonce.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/nonce.js.map b/node_modules/@metamask/transaction-controller/dist/utils/nonce.js.map +new file mode 100644 +index 0000000..21a35c3 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/nonce.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"nonce.js","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAmD;AAMnD,sCAA8D;AAG9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,OAAO,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,SAAsB,YAAY,CAChC,MAAuB,EACvB,YAA0B;;QAE1B,MAAM,EACJ,gBAAgB,EAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GACzC,GAAG,MAAM,CAAC;QAEX,MAAM,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAA,wBAAK,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3E,IAAI,WAAW,EAAE;YACf,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;YACvC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;SACjC;QAED,IAAI,aAAa,EAAE;YACjB,GAAG,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;YAC3C,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;SACnC;QAED,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxD,MAAM,KAAK,GAAG,IAAA,wBAAK,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,WAAW,GAA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racker,\n Transaction as NonceTrackerTransaction,\n} from 'nonce-tracker';\n\nimport { createModuleLogger, projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionStatus } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'nonce');\n\n/**\n * Determine the next nonce to be used for a transaction.\n *\n * @param txMeta - The transaction metadata.\n * @param nonceTracker - An instance of a nonce tracker.\n * @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.\n */\nexport async function getNextNonce(\n txMeta: TransactionMeta,\n nonceTracker: NonceTracker,\n): Promise<[string, (() => void) | undefined]> {\n const {\n customNonceValue,\n txParams: { from, nonce: existingNonce },\n } = txMeta;\n\n const customNonce = customNonceValue ? toHex(customNonceValue) : undefined;\n\n if (customNonce) {\n log('Using custom nonce', customNonce);\n return [customNonce, undefined];\n }\n\n if (existingNonce) {\n log('Using existing nonce', existingNonce);\n return [existingNonce, undefined];\n }\n\n const nonceLock = await nonceTracker.getNonceLock(from);\n const nonce = toHex(nonceLock.nextNonce);\n const releaseLock = nonceLock.releaseLock.bind(nonceLock);\n\n log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);\n\n return [nonce, releaseLock];\n}\n\n/**\n * Filter and format transactions for the nonce tracker.\n *\n * @param currentChainId - Chain ID of the current network.\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 currentChainId: string,\n fromAddress: string,\n transactionStatus: TransactionStatus,\n transactions: TransactionMeta[],\n): NonceTrackerTransaction[] {\n return transactions\n .filter(\n ({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) =>\n !isTransfer &&\n !isUserOperation &&\n chainId === currentChainId &&\n status === transactionStatus &&\n from.toLowerCase() === fromAddress.toLowerCase(),\n )\n .map(({ status, txParams: { 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 /* istanbul ignore next */\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/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts +new file mode 100644 +index 0000000..c2eb3a1 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts +@@ -0,0 +1,81 @@ ++import type EthQuery from '@metamask/eth-query'; ++import type { Events, TransactionMeta } from '../types'; ++import { TransactionType } from '../types'; +/** -+ * The configuration required to fetch transaction data from a RemoteTransactionSource. ++ * Interval in milliseconds between checks of post transaction balance + */ -+export interface RemoteTransactionSourceRequest { -+ /** -+ * The address of the account to fetch transactions for. -+ */ -+ address: string; -+ /** -+ * API key if required by the remote source. -+ */ -+ apiKey?: string; -+ /** -+ * The chainId of the current network. -+ */ -+ currentChainId: Hex; ++export declare const UPDATE_POST_TX_BALANCE_TIMEOUT = 5000; ++/** ++ * Retry attempts for checking post transaction balance ++ */ ++export declare const UPDATE_POST_TX_BALANCE_ATTEMPTS = 6; ++/** ++ * An address that the metaswap-api recognizes as the default token for the current network, in place of the token address that ERC-20 tokens have ++ */ ++export declare const DEFAULT_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000"; ++interface SwapsTokenObject { + /** -+ * The networkId of the current network. ++ * The name for the network + */ -+ currentNetworkId: string; ++ name: string; + /** -+ * Block number to start fetching transactions from. ++ * An address that the metaswap-api recognizes as the default token + */ -+ fromBlock?: number; ++ address: string; + /** -+ * Maximum number of transactions to retrieve. ++ * Number of digits after decimal point + */ -+ limit?: number; ++ decimals: number; +} ++export declare const SWAPS_CHAINID_DEFAULT_TOKEN_MAP: { ++ readonly "0x1": SwapsTokenObject; ++ readonly "0x539": SwapsTokenObject; ++ readonly "0x38": SwapsTokenObject; ++ readonly "0x89": SwapsTokenObject; ++ readonly "0x5": SwapsTokenObject; ++ readonly "0xa86a": SwapsTokenObject; ++ readonly "0xa": SwapsTokenObject; ++ readonly "0xa4b1": SwapsTokenObject; ++ readonly "0x144": SwapsTokenObject; ++}; ++export declare const SWAP_TRANSACTION_TYPES: TransactionType[]; +/** -+ * An object capable of fetching transaction data from a remote source. -+ * Used by the IncomingTransactionHelper to retrieve remote transaction data. ++ * Updates the transaction meta object with the swap information ++ * ++ * @param transactionMeta - The transaction meta object to update ++ * @param transactionType - The type of the transaction ++ * @param swaps - The swaps object ++ * @param swaps.hasApproveTx - Whether the swap has an approval transaction ++ * @param swaps.meta - The swap meta object ++ * @param updateSwapsTransactionRequest - Dependency bag ++ * @param updateSwapsTransactionRequest.isSwapsDisabled - Whether swaps are disabled ++ * @param updateSwapsTransactionRequest.cancelTransaction - Function to cancel a transaction ++ * @param updateSwapsTransactionRequest.controllerHubEmitter - Function to emit an event to the controller hub + */ -+export interface RemoteTransactionSource { -+ isSupportedNetwork: (chainId: string, networkId: string) => boolean; -+ fetchTransactions: (request: RemoteTransactionSourceRequest) => Promise; -+} -+export declare type SecurityAlertResponse = { -+ reason: string; -+ features?: string[]; -+ result_type: string; -+ providerRequestsCount?: Record; ++export declare function updateSwapsTransaction(transactionMeta: TransactionMeta, transactionType: TransactionType, swaps: { ++ hasApproveTx?: boolean; ++ meta?: Partial; ++}, { isSwapsDisabled, cancelTransaction, controllerHubEmitter, }: { ++ isSwapsDisabled: boolean; ++ cancelTransaction: (transactionId: string) => void; ++ controllerHubEmitter: (eventName: T, ...args: Events[T]) => boolean; ++}): Promise; ++/** ++ * Attempts to update the post transaction balance of the provided transaction ++ * ++ * @param transactionMeta - Transaction meta object to update ++ * @param updatePostTransactionBalanceRequest - Dependency bag ++ * @param updatePostTransactionBalanceRequest.ethQuery - EthQuery object ++ * @param updatePostTransactionBalanceRequest.getTransaction - Reading function for the latest transaction state ++ * @param updatePostTransactionBalanceRequest.updateTransaction - Updating transaction function ++ */ ++export declare function updatePostTransactionBalance(transactionMeta: TransactionMeta, { ethQuery, getTransaction, updateTransaction, }: { ++ ethQuery: EthQuery; ++ getTransaction: (transactionId: string) => TransactionMeta | undefined; ++ updateTransaction: (transactionMeta: TransactionMeta, note: string) => void; ++}): Promise<{ ++ updatedTransactionMeta: TransactionMeta; ++ approvalTransactionMeta?: TransactionMeta; ++}>; ++export {}; ++//# sourceMappingURL=swaps.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts.map +new file mode 100644 +index 0000000..a1312b7 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/swaps.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"swaps.d.ts","sourceRoot":"","sources":["../../src/utils/swaps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAKhD,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAK3C;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAIjD;;GAEG;AACH,eAAO,MAAM,qBAAqB,+CACY,CAAC;AAI/C,UAAU,gBAAgB;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkDD,eAAO,MAAM,+BAA+B;;;;;;;;;;CAUlC,CAAC;AAEX,eAAO,MAAM,sBAAsB,mBAGlC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE;IACL,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACjC,EACD,EACE,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACrB,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,oBAAoB,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EAC3C,SAAS,EAAE,CAAC,EACZ,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KACf,OAAO,CAAC;CACd,iBAyCF;AAED;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,CAChD,eAAe,EAAE,eAAe,EAChC,EACE,QAAQ,EACR,cAAc,EACd,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;IACvE,iBAAiB,EAAE,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7E,GACA,OAAO,CAAC;IACT,sBAAsB,EAAE,eAAe,CAAC;IACxC,uBAAuB,CAAC,EAAE,eAAe,CAAC;CAC3C,CAAC,CAyDD"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/swaps.js b/node_modules/@metamask/transaction-controller/dist/utils/swaps.js +new file mode 100644 +index 0000000..ecf4c46 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/swaps.js +@@ -0,0 +1,257 @@ ++"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); +}; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.updatePostTransactionBalance = exports.updateSwapsTransaction = exports.SWAP_TRANSACTION_TYPES = exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = exports.DEFAULT_TOKEN_ADDRESS = exports.UPDATE_POST_TX_BALANCE_ATTEMPTS = exports.UPDATE_POST_TX_BALANCE_TIMEOUT = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const lodash_1 = require("lodash"); ++const constants_1 = require("../constants"); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const utils_1 = require("./utils"); ++const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'swaps'); +/** -+ * Data concerning a successfully submitted transaction. -+ * Used for debugging purposes. ++ * Interval in milliseconds between checks of post transaction balance + */ -+export declare type SubmitHistoryEntry = { -+ /** The chain ID of the transaction as a hexadecimal string. */ -+ chainId?: Hex; -+ /** The hash of the transaction returned from the RPC provider. */ -+ hash: string; -+ /** True if the entry was generated using the migration and existing transaction metadata. */ -+ migration?: boolean; -+ /** The type of the network where the transaction was submitted. */ -+ networkType?: string; -+ /** -+ * The URL of the network the transaction was submitted to. -+ * A single network URL if it was recorded when submitted. -+ * An array of potential network URLs if it cannot be confirmed since the migration was used. -+ */ -+ networkUrl?: string | string[]; -+ /** The origin of the transaction. */ -+ origin?: string; -+ /** The raw transaction data that was submitted. */ -+ rawTransaction: string; -+ /** When the transaction was submitted. */ -+ time: number; -+ /** The transaction parameters that were submitted. */ -+ transaction: Record; ++exports.UPDATE_POST_TX_BALANCE_TIMEOUT = 5000; ++/** ++ * Retry attempts for checking post transaction balance ++ */ ++exports.UPDATE_POST_TX_BALANCE_ATTEMPTS = 6; ++const SWAPS_TESTNET_CHAIN_ID = '0x539'; ++/** ++ * An address that the metaswap-api recognizes as the default token for the current network, in place of the token address that ERC-20 tokens have ++ */ ++exports.DEFAULT_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000'; ++const ETH_SWAPS_TOKEN_OBJECT = { ++ name: 'Ether', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+/** Gas fee estimates for a specific priority level. */ -+export declare type GasFeeEstimatesForLevel = { -+ /** Maximum amount to pay per gas. */ -+ maxFeePerGas: Hex; -+ /** Maximum amount per gas to give to the validator as an incentive. */ -+ maxPriorityFeePerGas: Hex; ++const BNB_SWAPS_TOKEN_OBJECT = { ++ name: 'Binance Coin', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+/** Alternate priority levels for which values are provided in gas fee estimates. */ -+export declare enum GasFeeEstimateLevel { -+ low = "low", -+ medium = "medium", -+ high = "high" -+} -+/** Gas fee estimates for a transaction. */ -+export declare type GasFeeEstimates = { -+ /** The gas fee estimate for a low priority transaction. */ -+ [GasFeeEstimateLevel.low]: GasFeeEstimatesForLevel; -+ /** The gas fee estimate for a medium priority transaction. */ -+ [GasFeeEstimateLevel.medium]: GasFeeEstimatesForLevel; -+ /** The gas fee estimate for a high priority transaction. */ -+ [GasFeeEstimateLevel.high]: GasFeeEstimatesForLevel; ++const MATIC_SWAPS_TOKEN_OBJECT = { ++ name: 'Matic', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+/** Request to a gas fee flow to obtain gas fee estimates. */ -+export declare type GasFeeFlowRequest = { -+ /** An EthQuery instance to enable queries to the associated RPC provider. */ -+ ethQuery: any; -+ /** Callback to get the GasFeeController estimates. */ -+ getGasFeeControllerEstimates: () => Promise; -+ /** The metadata of the transaction to obtain estimates for. */ -+ transactionMeta: TransactionMeta; ++const AVAX_SWAPS_TOKEN_OBJECT = { ++ name: 'Avalanche', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+/** Response from a gas fee flow containing gas fee estimates. */ -+export declare type GasFeeFlowResponse = { -+ /** The gas fee estimates for the transaction. */ -+ estimates: GasFeeEstimates; ++const TEST_ETH_SWAPS_TOKEN_OBJECT = { ++ name: 'Test Ether', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+/** A method of obtaining gas fee estimates for a specific transaction. */ -+export declare type GasFeeFlow = { -+ /** -+ * Determine if the gas fee flow supports the specified transaction. -+ * -+ * @param transactionMeta - The transaction metadata. -+ * @returns Whether the gas fee flow supports the transaction. -+ */ -+ matchesTransaction(transactionMeta: TransactionMeta): boolean; -+ /** -+ * Get gas fee estimates for a specific transaction. -+ * -+ * @param request - The gas fee flow request. -+ * @returns The gas fee flow response containing the gas fee estimates. -+ */ -+ getGasFees: (request: GasFeeFlowRequest) => Promise; ++const GOERLI_SWAPS_TOKEN_OBJECT = { ++ name: 'Ether', ++ address: exports.DEFAULT_TOKEN_ADDRESS, ++ decimals: 18, +}; -+export {}; -+//# sourceMappingURL=types.d.ts.map ++const ARBITRUM_SWAPS_TOKEN_OBJECT = Object.assign({}, ETH_SWAPS_TOKEN_OBJECT); ++const OPTIMISM_SWAPS_TOKEN_OBJECT = Object.assign({}, ETH_SWAPS_TOKEN_OBJECT); ++const ZKSYNC_ERA_SWAPS_TOKEN_OBJECT = Object.assign({}, ETH_SWAPS_TOKEN_OBJECT); ++exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = { ++ [constants_1.CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT, ++ [SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.BSC]: BNB_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.POLYGON]: MATIC_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.GOERLI]: GOERLI_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT, ++ [constants_1.CHAIN_IDS.ZKSYNC_ERA]: ZKSYNC_ERA_SWAPS_TOKEN_OBJECT, ++}; ++exports.SWAP_TRANSACTION_TYPES = [ ++ types_1.TransactionType.swap, ++ types_1.TransactionType.swapApproval, ++]; ++/** ++ * Updates the transaction meta object with the swap information ++ * ++ * @param transactionMeta - The transaction meta object to update ++ * @param transactionType - The type of the transaction ++ * @param swaps - The swaps object ++ * @param swaps.hasApproveTx - Whether the swap has an approval transaction ++ * @param swaps.meta - The swap meta object ++ * @param updateSwapsTransactionRequest - Dependency bag ++ * @param updateSwapsTransactionRequest.isSwapsDisabled - Whether swaps are disabled ++ * @param updateSwapsTransactionRequest.cancelTransaction - Function to cancel a transaction ++ * @param updateSwapsTransactionRequest.controllerHubEmitter - Function to emit an event to the controller hub ++ */ ++function updateSwapsTransaction(transactionMeta, transactionType, swaps, { isSwapsDisabled, cancelTransaction, controllerHubEmitter, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ if (isSwapsDisabled || !exports.SWAP_TRANSACTION_TYPES.includes(transactionType)) { ++ return; ++ } ++ // The simulationFails property is added if the estimateGas call fails. In cases ++ // when no swaps approval tx is required, this indicates that the swap will likely ++ // fail. There was an earlier estimateGas call made by the swaps controller, ++ // but it is possible that external conditions have change since then, and ++ // a previously succeeding estimate gas call could now fail. By checking for ++ // the `simulationFails` property here, we can reduce the number of swap ++ // transactions that get published to the blockchain only to fail and thereby ++ // waste the user's funds on gas. ++ if (transactionType === types_1.TransactionType.swap && ++ (swaps === null || swaps === void 0 ? void 0 : swaps.hasApproveTx) === false && ++ transactionMeta.simulationFails) { ++ yield cancelTransaction(transactionMeta.id); ++ throw new Error('Simulation failed'); ++ } ++ const swapsMeta = swaps === null || swaps === void 0 ? void 0 : swaps.meta; ++ if (!swapsMeta) { ++ return; ++ } ++ if (transactionType === types_1.TransactionType.swapApproval) { ++ updateSwapApprovalTransaction(transactionMeta, swapsMeta); ++ controllerHubEmitter('transaction-new-swap-approval', { ++ transactionMeta, ++ }); ++ } ++ if (transactionType === types_1.TransactionType.swap) { ++ updateSwapTransaction(transactionMeta, swapsMeta); ++ controllerHubEmitter('transaction-new-swap', { ++ transactionMeta, ++ }); ++ } ++ }); ++} ++exports.updateSwapsTransaction = updateSwapsTransaction; ++/** ++ * Attempts to update the post transaction balance of the provided transaction ++ * ++ * @param transactionMeta - Transaction meta object to update ++ * @param updatePostTransactionBalanceRequest - Dependency bag ++ * @param updatePostTransactionBalanceRequest.ethQuery - EthQuery object ++ * @param updatePostTransactionBalanceRequest.getTransaction - Reading function for the latest transaction state ++ * @param updatePostTransactionBalanceRequest.updateTransaction - Updating transaction function ++ */ ++function updatePostTransactionBalance(transactionMeta, { ethQuery, getTransaction, updateTransaction, }) { ++ return __awaiter(this, void 0, void 0, function* () { ++ log('Updating post transaction balance', transactionMeta.id); ++ const transactionId = transactionMeta.id; ++ let latestTransactionMeta, approvalTransactionMeta; ++ for (let i = 0; i < exports.UPDATE_POST_TX_BALANCE_ATTEMPTS; i++) { ++ log('Querying balance', { attempt: i }); ++ const postTransactionBalance = yield (0, controller_utils_1.query)(ethQuery, 'getBalance', [ ++ transactionMeta.txParams.from, ++ ]); ++ latestTransactionMeta = getTransaction(transactionId); ++ approvalTransactionMeta = latestTransactionMeta.approvalTxId ++ ? getTransaction(latestTransactionMeta.approvalTxId) ++ : undefined; ++ latestTransactionMeta.postTxBalance = postTransactionBalance.toString(16); ++ const isDefaultTokenAddress = isSwapsDefaultTokenAddress(transactionMeta.destinationTokenAddress, transactionMeta.chainId); ++ if (!isDefaultTokenAddress || ++ transactionMeta.preTxBalance !== latestTransactionMeta.postTxBalance) { ++ log('Finishing post balance update', { ++ isDefaultTokenAddress, ++ preTxBalance: transactionMeta.preTxBalance, ++ postTxBalance: latestTransactionMeta.postTxBalance, ++ }); ++ break; ++ } ++ log('Waiting for balance to update', { ++ delay: exports.UPDATE_POST_TX_BALANCE_TIMEOUT, ++ }); ++ yield sleep(exports.UPDATE_POST_TX_BALANCE_TIMEOUT); ++ } ++ updateTransaction(latestTransactionMeta, 'TransactionController#updatePostTransactionBalance - Add post transaction balance'); ++ log('Completed post balance update', latestTransactionMeta === null || latestTransactionMeta === void 0 ? void 0 : latestTransactionMeta.postTxBalance); ++ return { ++ updatedTransactionMeta: latestTransactionMeta, ++ approvalTransactionMeta, ++ }; ++ }); ++} ++exports.updatePostTransactionBalance = updatePostTransactionBalance; ++/** ++ * Updates the transaction meta object with the swap information ++ * ++ * @param transactionMeta - Transaction meta object to update ++ * @param propsToUpdate - Properties to update ++ * @param propsToUpdate.sourceTokenSymbol - Symbol of the token to be swapped ++ * @param propsToUpdate.destinationTokenSymbol - Symbol of the token to be received ++ * @param propsToUpdate.type - Type of the transaction ++ * @param propsToUpdate.destinationTokenDecimals - Decimals of the token to be received ++ * @param propsToUpdate.destinationTokenAddress - Address of the token to be received ++ * @param propsToUpdate.swapMetaData - Metadata of the swap ++ * @param propsToUpdate.swapTokenValue - Value of the token to be swapped ++ * @param propsToUpdate.estimatedBaseFee - Estimated base fee of the transaction ++ * @param propsToUpdate.approvalTxId - Transaction id of the approval transaction ++ */ ++function updateSwapTransaction(transactionMeta, { sourceTokenSymbol, destinationTokenSymbol, type, destinationTokenDecimals, destinationTokenAddress, swapMetaData, swapTokenValue, estimatedBaseFee, approvalTxId, }) { ++ (0, utils_1.validateIfTransactionUnapproved)(transactionMeta, 'updateSwapTransaction'); ++ let swapTransaction = { ++ sourceTokenSymbol, ++ destinationTokenSymbol, ++ type, ++ destinationTokenDecimals, ++ destinationTokenAddress, ++ swapMetaData, ++ swapTokenValue, ++ estimatedBaseFee, ++ approvalTxId, ++ }; ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ swapTransaction = (0, lodash_1.pickBy)(swapTransaction); ++ (0, lodash_1.merge)(transactionMeta, swapTransaction); ++} ++/** ++ * Updates the transaction meta object with the swap approval information ++ * ++ * @param transactionMeta - Transaction meta object to update ++ * @param propsToUpdate - Properties to update ++ * @param propsToUpdate.type - Type of the transaction ++ * @param propsToUpdate.sourceTokenSymbol - Symbol of the token to be swapped ++ */ ++function updateSwapApprovalTransaction(transactionMeta, { type, sourceTokenSymbol }) { ++ (0, utils_1.validateIfTransactionUnapproved)(transactionMeta, 'updateSwapApprovalTransaction'); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ let swapApprovalTransaction = { type, sourceTokenSymbol }; ++ swapApprovalTransaction = (0, lodash_1.pickBy)({ ++ type, ++ sourceTokenSymbol, ++ }); ++ (0, lodash_1.merge)(transactionMeta, swapApprovalTransaction); ++} ++/** ++ * Checks whether the provided address is strictly equal to the address for ++ * the default swaps token of the provided chain. ++ * ++ * @param address - The string to compare to the default token address ++ * @param chainId - The hex encoded chain ID of the default swaps token to check ++ * @returns Whether the address is the provided chain's default token address ++ */ ++function isSwapsDefaultTokenAddress(address, chainId) { ++ var _a; ++ if (!address || !chainId) { ++ return false; ++ } ++ return (address === ++ ((_a = exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP[chainId]) === null || _a === void 0 ? void 0 : _a.address)); ++} ++/** ++ * Sleeps for the provided number of milliseconds ++ * ++ * @param ms - Number of milliseconds to sleep ++ * @returns Promise that resolves after the provided number of milliseconds ++ */ ++function sleep(ms) { ++ return new Promise((resolve) => setTimeout(resolve, ms)); ++} ++//# sourceMappingURL=swaps.js.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 +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/swaps.js.map b/node_modules/@metamask/transaction-controller/dist/utils/swaps.js.map +new file mode 100644 +index 0000000..773cba5 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/swaps.js.map +@@ -0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,gBAAgB;QAChB,YAAY;KACb,CAAC;IACF,gCAAgC;IAChC,8DAA8D;IAC9D,eAAe,GAAG,IAAA,eAAM,EAAC,eAAe,CAAQ,CAAC;IACjD,IAAA,cAAK,EAAC,eAAe,EAAE,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,6BAA6B,CACpC,eAAgC,EAChC,EAAE,IAAI,EAAE,iBAAiB,EAA4B;IAErD,IAAA,uCAA+B,EAC7B,eAAe,EACf,+BAA+B,CAChC,CAAC;IAEF,gCAAgC;IAChC,8DAA8D;IAC9D,IAAI,uBAAuB,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAS,CAAC;IACjE,uBAAuB,GAAG,IAAA,eAAM,EAAC;QAC/B,IAAI;QACJ,iBAAiB;KAClB,CAA6B,CAAC;IAC/B,IAAA,cAAK,EAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,0BAA0B,CAAC,OAAe,EAAE,OAAe;;IAClE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IAED,OAAO,CACL,OAAO;SACP,MAAA,uCAA+B,CAC7B,OAAuD,CACxD,0CAAE,OAAO,CAAA,CACX,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { merge, pickBy } from 'lodash';\n\nimport { CHAIN_IDS } from '../constants';\nimport { createModuleLogger, projectLogger } from '../logger';\nimport type { Events, TransactionMeta } from '../types';\nimport { TransactionType } from '../types';\nimport { validateIfTransactionUnapproved } from './utils';\n\nconst log = createModuleLogger(projectLogger, 'swaps');\n\n/**\n * Interval in milliseconds between checks of post transaction balance\n */\nexport const UPDATE_POST_TX_BALANCE_TIMEOUT = 5000;\n\n/**\n * Retry attempts for checking post transaction balance\n */\nexport const UPDATE_POST_TX_BALANCE_ATTEMPTS = 6;\n\nconst SWAPS_TESTNET_CHAIN_ID = '0x539';\n\n/**\n * An address that the metaswap-api recognizes as the default token for the current network, in place of the token address that ERC-20 tokens have\n */\nexport const DEFAULT_TOKEN_ADDRESS =\n '0x0000000000000000000000000000000000000000';\n\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\ninterface SwapsTokenObject {\n /**\n * The name for the network\n */\n name: string;\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string;\n /**\n * Number of digits after decimal point\n */\n decimals: number;\n}\n\nconst ETH_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Ether',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n};\n\nconst BNB_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Binance Coin',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n} as const;\n\nconst MATIC_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Matic',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n} as const;\n\nconst AVAX_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Avalanche',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n} as const;\n\nconst TEST_ETH_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Test Ether',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n} as const;\n\nconst GOERLI_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n name: 'Ether',\n address: DEFAULT_TOKEN_ADDRESS,\n decimals: 18,\n} as const;\n\nconst ARBITRUM_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n ...ETH_SWAPS_TOKEN_OBJECT,\n} as const;\n\nconst OPTIMISM_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n ...ETH_SWAPS_TOKEN_OBJECT,\n} as const;\n\nconst ZKSYNC_ERA_SWAPS_TOKEN_OBJECT: SwapsTokenObject = {\n ...ETH_SWAPS_TOKEN_OBJECT,\n} as const;\n\nexport const SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {\n [CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT,\n [SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.BSC]: BNB_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.POLYGON]: MATIC_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.GOERLI]: GOERLI_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT,\n [CHAIN_IDS.ZKSYNC_ERA]: ZKSYNC_ERA_SWAPS_TOKEN_OBJECT,\n} as const;\n\nexport const SWAP_TRANSACTION_TYPES = [\n TransactionType.swap,\n TransactionType.swapApproval,\n];\n\n/**\n * Updates the transaction meta object with the swap information\n *\n * @param transactionMeta - The transaction meta object to update\n * @param transactionType - The type of the transaction\n * @param swaps - The swaps object\n * @param swaps.hasApproveTx - Whether the swap has an approval transaction\n * @param swaps.meta - The swap meta object\n * @param updateSwapsTransactionRequest - Dependency bag\n * @param updateSwapsTransactionRequest.isSwapsDisabled - Whether swaps are disabled\n * @param updateSwapsTransactionRequest.cancelTransaction - Function to cancel a transaction\n * @param updateSwapsTransactionRequest.controllerHubEmitter - Function to emit an event to the controller hub\n */\nexport async function updateSwapsTransaction(\n transactionMeta: TransactionMeta,\n transactionType: TransactionType,\n swaps: {\n hasApproveTx?: boolean;\n meta?: Partial;\n },\n {\n isSwapsDisabled,\n cancelTransaction,\n controllerHubEmitter,\n }: {\n isSwapsDisabled: boolean;\n cancelTransaction: (transactionId: string) => void;\n controllerHubEmitter: (\n eventName: T,\n ...args: Events[T]\n ) => boolean;\n },\n) {\n if (isSwapsDisabled || !SWAP_TRANSACTION_TYPES.includes(transactionType)) {\n return;\n }\n // The simulationFails property is added if the estimateGas call fails. In cases\n // when no swaps approval tx is required, this indicates that the swap will likely\n // fail. There was an earlier estimateGas call made by the swaps controller,\n // but it is possible that external conditions have change since then, and\n // a previously succeeding estimate gas call could now fail. By checking for\n // the `simulationFails` property here, we can reduce the number of swap\n // transactions that get published to the blockchain only to fail and thereby\n // waste the user's funds on gas.\n if (\n transactionType === TransactionType.swap &&\n swaps?.hasApproveTx === false &&\n transactionMeta.simulationFails\n ) {\n await cancelTransaction(transactionMeta.id);\n throw new Error('Simulation failed');\n }\n\n const swapsMeta = swaps?.meta as Partial;\n\n if (!swapsMeta) {\n return;\n }\n\n if (transactionType === TransactionType.swapApproval) {\n updateSwapApprovalTransaction(transactionMeta, swapsMeta);\n controllerHubEmitter('transaction-new-swap-approval', {\n transactionMeta,\n });\n }\n\n if (transactionType === TransactionType.swap) {\n updateSwapTransaction(transactionMeta, swapsMeta);\n controllerHubEmitter('transaction-new-swap', {\n transactionMeta,\n });\n }\n}\n\n/**\n * Attempts to update the post transaction balance of the provided transaction\n *\n * @param transactionMeta - Transaction meta object to update\n * @param updatePostTransactionBalanceRequest - Dependency bag\n * @param updatePostTransactionBalanceRequest.ethQuery - EthQuery object\n * @param updatePostTransactionBalanceRequest.getTransaction - Reading function for the latest transaction state\n * @param updatePostTransactionBalanceRequest.updateTransaction - Updating transaction function\n */\nexport async function updatePostTransactionBalance(\n transactionMeta: TransactionMeta,\n {\n ethQuery,\n getTransaction,\n updateTransaction,\n }: {\n ethQuery: EthQuery;\n getTransaction: (transactionId: string) => TransactionMeta | undefined;\n updateTransaction: (transactionMeta: TransactionMeta, note: string) => void;\n },\n): Promise<{\n updatedTransactionMeta: TransactionMeta;\n approvalTransactionMeta?: TransactionMeta;\n}> {\n log('Updating post transaction balance', transactionMeta.id);\n\n const transactionId = transactionMeta.id;\n let latestTransactionMeta, approvalTransactionMeta;\n\n for (let i = 0; i < UPDATE_POST_TX_BALANCE_ATTEMPTS; i++) {\n log('Querying balance', { attempt: i });\n\n const postTransactionBalance = await query(ethQuery, 'getBalance', [\n transactionMeta.txParams.from,\n ]);\n\n latestTransactionMeta = getTransaction(transactionId) as TransactionMeta;\n\n approvalTransactionMeta = latestTransactionMeta.approvalTxId\n ? getTransaction(latestTransactionMeta.approvalTxId)\n : undefined;\n\n latestTransactionMeta.postTxBalance = postTransactionBalance.toString(16);\n\n const isDefaultTokenAddress = isSwapsDefaultTokenAddress(\n transactionMeta.destinationTokenAddress as string,\n transactionMeta.chainId,\n );\n\n if (\n !isDefaultTokenAddress ||\n transactionMeta.preTxBalance !== latestTransactionMeta.postTxBalance\n ) {\n log('Finishing post balance update', {\n isDefaultTokenAddress,\n preTxBalance: transactionMeta.preTxBalance,\n postTxBalance: latestTransactionMeta.postTxBalance,\n });\n\n break;\n }\n\n log('Waiting for balance to update', {\n delay: UPDATE_POST_TX_BALANCE_TIMEOUT,\n });\n\n await sleep(UPDATE_POST_TX_BALANCE_TIMEOUT);\n }\n\n updateTransaction(\n latestTransactionMeta as TransactionMeta,\n 'TransactionController#updatePostTransactionBalance - Add post transaction balance',\n );\n\n log('Completed post balance update', latestTransactionMeta?.postTxBalance);\n\n return {\n updatedTransactionMeta: latestTransactionMeta as TransactionMeta,\n approvalTransactionMeta,\n };\n}\n\n/**\n * Updates the transaction meta object with the swap information\n *\n * @param transactionMeta - Transaction meta object to update\n * @param propsToUpdate - Properties to update\n * @param propsToUpdate.sourceTokenSymbol - Symbol of the token to be swapped\n * @param propsToUpdate.destinationTokenSymbol - Symbol of the token to be received\n * @param propsToUpdate.type - Type of the transaction\n * @param propsToUpdate.destinationTokenDecimals - Decimals of the token to be received\n * @param propsToUpdate.destinationTokenAddress - Address of the token to be received\n * @param propsToUpdate.swapMetaData - Metadata of the swap\n * @param propsToUpdate.swapTokenValue - Value of the token to be swapped\n * @param propsToUpdate.estimatedBaseFee - Estimated base fee of the transaction\n * @param propsToUpdate.approvalTxId - Transaction id of the approval transaction\n */\nfunction updateSwapTransaction(\n transactionMeta: TransactionMeta,\n {\n sourceTokenSymbol,\n destinationTokenSymbol,\n type,\n destinationTokenDecimals,\n destinationTokenAddress,\n swapMetaData,\n swapTokenValue,\n estimatedBaseFee,\n approvalTxId,\n }: Partial,\n) {\n validateIfTransactionUnapproved(transactionMeta, 'updateSwapTransaction');\n\n let swapTransaction = {\n sourceTokenSymbol,\n destinationTokenSymbol,\n type,\n destinationTokenDecimals,\n destinationTokenAddress,\n swapMetaData,\n swapTokenValue,\n estimatedBaseFee,\n approvalTxId,\n };\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swapTransaction = pickBy(swapTransaction) as any;\n merge(transactionMeta, swapTransaction);\n}\n\n/**\n * Updates the transaction meta object with the swap approval information\n *\n * @param transactionMeta - Transaction meta object to update\n * @param propsToUpdate - Properties to update\n * @param propsToUpdate.type - Type of the transaction\n * @param propsToUpdate.sourceTokenSymbol - Symbol of the token to be swapped\n */\nfunction updateSwapApprovalTransaction(\n transactionMeta: TransactionMeta,\n { type, sourceTokenSymbol }: Partial,\n) {\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateSwapApprovalTransaction',\n );\n\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let swapApprovalTransaction = { type, sourceTokenSymbol } as any;\n swapApprovalTransaction = pickBy({\n type,\n sourceTokenSymbol,\n }) as Partial;\n merge(transactionMeta, swapApprovalTransaction);\n}\n\n/**\n * Checks whether the provided address is strictly equal to the address for\n * the default swaps token of the provided chain.\n *\n * @param address - The string to compare to the default token address\n * @param chainId - The hex encoded chain ID of the default swaps token to check\n * @returns Whether the address is the provided chain's default token address\n */\nfunction isSwapsDefaultTokenAddress(address: string, chainId: string) {\n if (!address || !chainId) {\n return false;\n }\n\n return (\n address ===\n SWAPS_CHAINID_DEFAULT_TOKEN_MAP[\n chainId as keyof typeof SWAPS_CHAINID_DEFAULT_TOKEN_MAP\n ]?.address\n );\n}\n\n/**\n * Sleeps for the provided number of milliseconds\n *\n * @param ms - Number of milliseconds to sleep\n * @returns Promise that resolves after the provided number of milliseconds\n */\nfunction sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts +new file mode 100644 +index 0000000..8528ffc +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts +@@ -0,0 +1,14 @@ ++import type EthQuery from '@metamask/eth-query'; ++import type { InferTransactionTypeResult, TransactionParams } from '../types'; ++export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; ++/** ++ * Determines the type of the transaction by analyzing the txParams. ++ * It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these ++ * represent specific events that we specify manually at transaction creation. ++ * ++ * @param txParams - Parameters for the transaction. ++ * @param ethQuery - EthQuery instance. ++ * @returns A object with the transaction type and the contract code response in Hex. ++ */ ++export declare function determineTransactionType(txParams: TransactionParams, ethQuery: EthQuery): Promise; ++//# sourceMappingURL=transaction-type.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts.map +new file mode 100644 +index 0000000..ee20d3e +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"transaction-type.d.ts","sourceRoot":"","sources":["../../src/utils/transaction-type.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAGhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG9E,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAMrE;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,0BAA0B,CAAC,CA4CrC"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js new file mode 100644 -index 0000000..2cc85ee +index 0000000..b04f5d5 --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/types.js -@@ -0,0 +1,36 @@ ++++ b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js +@@ -0,0 +1,121 @@ +"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; +Object.defineProperty(exports, "__esModule", { value: true }); -+exports.GasFeeEstimateLevel = exports.WalletDevice = exports.TransactionStatus = void 0; -+/** -+ * The status of the transaction. Each status represents the state of the transaction internally -+ * in the wallet. Some of these correspond with the state of the transaction on the network, but -+ * some are wallet-specific. -+ */ -+var TransactionStatus; -+(function (TransactionStatus) { -+ TransactionStatus["approved"] = "approved"; -+ TransactionStatus["cancelled"] = "cancelled"; -+ TransactionStatus["confirmed"] = "confirmed"; -+ TransactionStatus["failed"] = "failed"; -+ TransactionStatus["rejected"] = "rejected"; -+ TransactionStatus["signed"] = "signed"; -+ TransactionStatus["submitted"] = "submitted"; -+ TransactionStatus["unapproved"] = "unapproved"; -+})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {})); ++exports.determineTransactionType = exports.ESTIMATE_GAS_ERROR = void 0; ++const abi_1 = require("@ethersproject/abi"); ++const controller_utils_1 = require("@metamask/controller-utils"); ++const metamask_eth_abis_1 = require("@metamask/metamask-eth-abis"); ++const types_1 = require("../types"); ++exports.ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error'; ++const ERC20Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC20); ++const ERC721Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC721); ++const ERC1155Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC1155); +/** -+ * Options for wallet device. ++ * Determines the type of the transaction by analyzing the txParams. ++ * It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these ++ * represent specific events that we specify manually at transaction creation. ++ * ++ * @param txParams - Parameters for the transaction. ++ * @param ethQuery - EthQuery instance. ++ * @returns A object with the transaction type and the contract code response in Hex. + */ -+var WalletDevice; -+(function (WalletDevice) { -+ WalletDevice["MM_MOBILE"] = "metamask_mobile"; -+ WalletDevice["MM_EXTENSION"] = "metamask_extension"; -+ WalletDevice["OTHER"] = "other_device"; -+})(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {})); -+/** Alternate priority levels for which values are provided in gas fee estimates. */ -+var GasFeeEstimateLevel; -+(function (GasFeeEstimateLevel) { -+ GasFeeEstimateLevel["low"] = "low"; -+ GasFeeEstimateLevel["medium"] = "medium"; -+ GasFeeEstimateLevel["high"] = "high"; -+})(GasFeeEstimateLevel = exports.GasFeeEstimateLevel || (exports.GasFeeEstimateLevel = {})); -+//# 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 ccf3362..6521edf 100644 ---- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/utils.d.ts -@@ -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, 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. -@@ -16,7 +16,7 @@ export declare function getEtherscanApiUrl(networkType: string, urlParams: any): - * @param transaction - Transaction object to normalize. - * @returns Normalized Transaction object. - */ --export declare function normalizeTransaction(transaction: Transaction): Transaction; -+export declare function normalizeTransactionParams(transaction: Transaction): Transaction; - /** - * Validates a Transaction object for required properties and throws in - * the event of any validation error. -@@ -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; --/** -- * Handles the fetch of incoming transactions. -- * -- * @param networkType - Network type of desired network. -- * @param address - Address to get the transactions from. -- * @param txHistoryLimit - The maximum number of transactions to fetch. -- * @param opt - Object that can contain fromBlock and Etherscan service API key. -- * @returns Responses for both ETH and ERC20 token transactions. -- */ --export declare function handleTransactionFetch(networkType: string, address: string, txHistoryLimit: number, opt?: FetchAllOptions): Promise<[{ -- [result: string]: []; --}, { -- [result: string]: []; --}]>; - 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; -@@ -63,10 +49,19 @@ export declare function validateMinimumIncrease(proposed: string, min: string): - /** - * Helper function to filter and format transactions for the nonce tracker. - * -+ * @param currentChainId - Chain ID of the current network. - * @param fromAddress - Address of the account from which the transactions to filter from are sent. - * @param transactionStatus - Status of the transactions for which to filter. - * @param transactions - Array of transactionMeta objects that have been prefiltered. - * @returns Array of transactions formatted for the nonce tracker. - */ --export declare function getAndFormatTransactionsForNonceTracker(fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; -+export declare function getAndFormatTransactionsForNonceTracker(currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; ++function determineTransactionType(txParams, ethQuery) { ++ var _a, _b; ++ return __awaiter(this, void 0, void 0, function* () { ++ const { data, to } = txParams; ++ if (data && !to) { ++ return { type: types_1.TransactionType.deployContract, getCodeResponse: undefined }; ++ } ++ const { contractCode: getCodeResponse, isContractAddress } = yield readAddressAsContract(ethQuery, to); ++ if (!isContractAddress) { ++ return { type: types_1.TransactionType.simpleSend, getCodeResponse }; ++ } ++ const hasValue = Number((_a = txParams.value) !== null && _a !== void 0 ? _a : '0') !== 0; ++ const contractInteractionResult = { ++ type: types_1.TransactionType.contractInteraction, ++ getCodeResponse, ++ }; ++ if (!data || hasValue) { ++ return contractInteractionResult; ++ } ++ const name = (_b = parseStandardTokenTransactionData(data)) === null || _b === void 0 ? void 0 : _b.name; ++ if (!name) { ++ return contractInteractionResult; ++ } ++ const tokenMethodName = [ ++ types_1.TransactionType.tokenMethodApprove, ++ types_1.TransactionType.tokenMethodSetApprovalForAll, ++ types_1.TransactionType.tokenMethodTransfer, ++ types_1.TransactionType.tokenMethodTransferFrom, ++ types_1.TransactionType.tokenMethodSafeTransferFrom, ++ ].find((methodName) => methodName.toLowerCase() === name.toLowerCase()); ++ if (tokenMethodName) { ++ return { type: tokenMethodName, getCodeResponse }; ++ } ++ return contractInteractionResult; ++ }); ++} ++exports.determineTransactionType = determineTransactionType; +/** -+ * Ensure a hex string is of even length by adding a leading 0 if necessary. -+ * Any existing `0x` prefix is preserved but is not added if missing. ++ * Attempts to decode transaction data using ABIs for three different token standards: ERC20, ERC721, ERC1155. ++ * The data will decode correctly if the transaction is an interaction with a contract that matches one of these ++ * contract standards + * -+ * @param hex - The hex string to ensure is even. -+ * @returns The hex string with an even length. ++ * @param data - Encoded transaction data. ++ * @returns A representation of an ethereum contract call. + */ -+export declare function padHexToEvenLength(hex: string): string; - //# sourceMappingURL=utils.d.ts.map -\ No newline at end of file -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 179a564..0bbba70 100644 ---- a/node_modules/@metamask/transaction-controller/dist/utils.js -+++ b/node_modules/@metamask/transaction-controller/dist/utils.js -@@ -1,20 +1,11 @@ - "use strict"; --var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { -- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } -- return new (P || (P = Promise))(function (resolve, reject) { -- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } -- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } -- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } -- step((generator = generator.apply(thisArg, _arguments || [])).next()); -- }); --}; - Object.defineProperty(exports, "__esModule", { value: true }); --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.padHexToEvenLength = exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransactionParams = 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'; - const NORMALIZERS = { -- data: (data) => (0, ethereumjs_util_1.addHexPrefix)(data), -+ data: (data) => (0, ethereumjs_util_1.addHexPrefix)(padHexToEvenLength(data)), - from: (from) => (0, ethereumjs_util_1.addHexPrefix)(from).toLowerCase(), - gas: (gas) => (0, ethereumjs_util_1.addHexPrefix)(gas), - gasPrice: (gasPrice) => (0, ethereumjs_util_1.addHexPrefix)(gasPrice), -@@ -24,6 +15,7 @@ const NORMALIZERS = { - maxFeePerGas: (maxFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxFeePerGas), - maxPriorityFeePerGas: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), - estimatedBaseFee: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), -+ type: (type) => (type === '0x0' ? '0x0' : undefined), - }; - /** - * Return a URL that can be used to fetch ETH transactions. -@@ -54,7 +46,7 @@ exports.getEtherscanApiUrl = getEtherscanApiUrl; - * @param transaction - Transaction object to normalize. - * @returns Normalized Transaction object. - */ --function normalizeTransaction(transaction) { -+function normalizeTransactionParams(transaction) { - const normalizedTransaction = { from: '' }; - let key; - for (key in NORMALIZERS) { -@@ -64,7 +56,7 @@ function normalizeTransaction(transaction) { - } - return normalizedTransaction; - } --exports.normalizeTransaction = normalizeTransaction; -+exports.normalizeTransactionParams = normalizeTransactionParams; - /** - * Validates a Transaction object for required properties and throws in - * the event of any validation error. -@@ -121,50 +113,6 @@ const isEIP1559Transaction = (transaction) => { - hasOwnProp(transaction, 'maxPriorityFeePerGas')); - }; - exports.isEIP1559Transaction = isEIP1559Transaction; --/** -- * Handles the fetch of incoming transactions. -- * -- * @param networkType - Network type of desired network. -- * @param address - Address to get the transactions from. -- * @param txHistoryLimit - The maximum number of transactions to fetch. -- * @param opt - Object that can contain fromBlock and Etherscan service API key. -- * @returns Responses for both ETH and ERC20 token transactions. -- */ --function handleTransactionFetch(networkType, address, txHistoryLimit, opt) { -- return __awaiter(this, void 0, void 0, function* () { -- // transactions -- const urlParams = { -- module: 'account', -- address, -- startBlock: opt === null || opt === void 0 ? void 0 : opt.fromBlock, -- apikey: opt === null || opt === void 0 ? void 0 : opt.etherscanApiKey, -- offset: txHistoryLimit.toString(), -- order: 'desc', -- }; -- const etherscanTxUrl = getEtherscanApiUrl(networkType, Object.assign(Object.assign({}, urlParams), { action: 'txlist' })); -- const etherscanTxResponsePromise = (0, controller_utils_1.handleFetch)(etherscanTxUrl); -- // tokens -- const etherscanTokenUrl = getEtherscanApiUrl(networkType, Object.assign(Object.assign({}, urlParams), { action: 'tokentx' })); -- const etherscanTokenResponsePromise = (0, controller_utils_1.handleFetch)(etherscanTokenUrl); -- let [etherscanTxResponse, etherscanTokenResponse] = yield Promise.all([ -- etherscanTxResponsePromise, -- etherscanTokenResponsePromise, -- ]); -- if (etherscanTxResponse.status === '0' || -- etherscanTxResponse.result.length <= 0) { -- etherscanTxResponse = { status: etherscanTxResponse.status, result: [] }; -- } -- if (etherscanTokenResponse.status === '0' || -- etherscanTokenResponse.result.length <= 0) { -- etherscanTokenResponse = { -- status: etherscanTokenResponse.status, -- result: [], -- }; -- } -- return [etherscanTxResponse, etherscanTokenResponse]; -- }); --} --exports.handleTransactionFetch = handleTransactionFetch; - const validateGasValues = (gasValues) => { - Object.keys(gasValues).forEach((key) => { - const value = gasValues[key]; -@@ -206,14 +154,17 @@ exports.validateMinimumIncrease = validateMinimumIncrease; - /** - * Helper function to filter and format transactions for the nonce tracker. - * -+ * @param currentChainId - Chain ID of the current network. - * @param fromAddress - Address of the account from which the transactions to filter from are sent. - * @param transactionStatus - Status of the transactions for which to filter. - * @param transactions - Array of transactionMeta objects that have been prefiltered. - * @returns Array of transactions formatted for the nonce tracker. - */ --function getAndFormatTransactionsForNonceTracker(fromAddress, transactionStatus, transactions) { -+function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) { - return transactions -- .filter(({ status, transaction: { from } }) => status === transactionStatus && -+ .filter(({ chainId, isTransfer, status, transaction: { from } }) => !isTransfer && -+ chainId === currentChainId && -+ status === transactionStatus && - from.toLowerCase() === fromAddress.toLowerCase()) - .map(({ status, transaction: { from, gas, value, nonce } }) => { - // the only value we care about is the nonce -@@ -232,4 +183,18 @@ function getAndFormatTransactionsForNonceTracker(fromAddress, transactionStatus, - }); - } - exports.getAndFormatTransactionsForNonceTracker = getAndFormatTransactionsForNonceTracker; ++function parseStandardTokenTransactionData(data) { ++ if (!data) { ++ return undefined; ++ } ++ try { ++ return ERC20Interface.parseTransaction({ data }); ++ } ++ catch (_a) { ++ // ignore and next try to parse with erc721 ABI ++ } ++ try { ++ return ERC721Interface.parseTransaction({ data }); ++ } ++ catch (_b) { ++ // ignore and next try to parse with erc1155 ABI ++ } ++ try { ++ return ERC1155Interface.parseTransaction({ data }); ++ } ++ catch (_c) { ++ // ignore and return undefined ++ } ++ return undefined; ++} +/** -+ * Ensure a hex string is of even length by adding a leading 0 if necessary. -+ * Any existing `0x` prefix is preserved but is not added if missing. ++ * Reads an Ethereum address and determines if it is a contract address. + * -+ * @param hex - The hex string to ensure is even. -+ * @returns The hex string with an even length. ++ * @param ethQuery - The Ethereum query object used to interact with the Ethereum blockchain. ++ * @param address - The Ethereum address. ++ * @returns An object containing the contract code and a boolean indicating if it is a contract address. + */ -+function padHexToEvenLength(hex) { -+ const prefix = hex.toLowerCase().startsWith('0x') ? hex.slice(0, 2) : ''; -+ const data = prefix ? hex.slice(2) : hex; -+ const evenData = data.length % 2 === 0 ? data : `0${data}`; -+ return prefix + evenData; ++function readAddressAsContract(ethQuery, address) { ++ return __awaiter(this, void 0, void 0, function* () { ++ let contractCode; ++ try { ++ contractCode = yield (0, controller_utils_1.query)(ethQuery, 'getCode', [address]); ++ } ++ catch (e) { ++ contractCode = null; ++ } ++ const isContractAddress = contractCode ++ ? contractCode !== '0x' && contractCode !== '0x0' ++ : false; ++ return { contractCode, isContractAddress }; ++ }); +} -+exports.padHexToEvenLength = padHexToEvenLength; - //# sourceMappingURL=utils.js.map ++//# sourceMappingURL=transaction-type.js.map \ No newline at end of file -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 8f2f6e3..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/utils.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"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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refix, 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"]} +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js.map b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js.map +new file mode 100644 +index 0000000..198f519 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/transaction-type.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"transaction-type.js","sourceRoot":"","sources":["../../src/utils/transaction-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4CAA+C;AAC/C,iEAAmD;AAEnD,mEAA8E;AAG9E,oCAA2C;AAE9B,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,cAAc,GAAG,IAAI,eAAS,CAAC,4BAAQ,CAAC,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAI,eAAS,CAAC,6BAAS,CAAC,CAAC;AACjD,MAAM,gBAAgB,GAAG,IAAI,eAAS,CAAC,8BAAU,CAAC,CAAC;AAEnD;;;;;;;;GAQG;AACH,SAAsB,wBAAwB,CAC5C,QAA2B,EAC3B,QAAkB;;;QAElB,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC;QAE9B,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;YACf,OAAO,EAAE,IAAI,EAAE,uBAAe,CAAC,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;SAC7E;QAED,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,GACxD,MAAM,qBAAqB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE5C,IAAI,CAAC,iBAAiB,EAAE;YACtB,OAAO,EAAE,IAAI,EAAE,uBAAe,CAAC,UAAU,EAAE,eAAe,EAAE,CAAC;SAC9D;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAA,QAAQ,CAA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ED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAe,qBAAqB,CAClC,QAAkB,EAClB,OAAgB;;QAKhB,IAAI,YAAY,CAAC;QACjB,IAAI;YACF,YAAY,GAAG,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;SAC5D;QAAC,OAAO,CAAC,EAAE;YACV,YAAY,GAAG,IAAI,CAAC;SACrB;QAED,MAAM,iBAAiB,GAAG,YAAY;YACpC,CAAC,CAAC,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,KAAK;YACjD,CAAC,CAAC,KAAK,CAAC;QACV,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAC7C,CAAC;CAAA","sourcesContent":["import type { TransactionDescription } from '@ethersproject/abi';\nimport { Interface } from '@ethersproject/abi';\nimport { query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { abiERC721, abiERC20, abiERC1155 } from '@metamask/metamask-eth-abis';\n\nimport type { InferTransactionTypeResult, TransactionParams } from '../types';\nimport { TransactionType } from '../types';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\nconst ERC20Interface = new Interface(abiERC20);\nconst ERC721Interface = new Interface(abiERC721);\nconst ERC1155Interface = new Interface(abiERC1155);\n\n/**\n * Determines the type of the transaction by analyzing the txParams.\n * It will never return TRANSACTION_TYPE_CANCEL or TRANSACTION_TYPE_RETRY as these\n * represent specific events that we specify manually at transaction creation.\n *\n * @param txParams - Parameters for the transaction.\n * @param ethQuery - EthQuery instance.\n * @returns A object with the transaction type and the contract code response in Hex.\n */\nexport async function determineTransactionType(\n txParams: TransactionParams,\n ethQuery: EthQuery,\n): Promise {\n const { data, to } = txParams;\n\n if (data && !to) {\n return { type: TransactionType.deployContract, getCodeResponse: undefined };\n }\n\n const { contractCode: getCodeResponse, isContractAddress } =\n await readAddressAsContract(ethQuery, to);\n\n if (!isContractAddress) {\n return { type: TransactionType.simpleSend, getCodeResponse };\n }\n\n const hasValue = Number(txParams.value ?? '0') !== 0;\n\n const contractInteractionResult = {\n type: TransactionType.contractInteraction,\n getCodeResponse,\n };\n\n if (!data || hasValue) {\n return contractInteractionResult;\n }\n\n const name = parseStandardTokenTransactionData(data)?.name;\n\n if (!name) {\n return contractInteractionResult;\n }\n\n const tokenMethodName = [\n TransactionType.tokenMethodApprove,\n TransactionType.tokenMethodSetApprovalForAll,\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.tokenMethodSafeTransferFrom,\n ].find((methodName) => methodName.toLowerCase() === name.toLowerCase());\n\n if (tokenMethodName) {\n return { type: tokenMethodName, getCodeResponse };\n }\n\n return contractInteractionResult;\n}\n\n/**\n * Attempts to decode transaction data using ABIs for three different token standards: ERC20, ERC721, ERC1155.\n * The data will decode correctly if the transaction is an interaction with a contract that matches one of these\n * contract standards\n *\n * @param data - Encoded transaction data.\n * @returns A representation of an ethereum contract call.\n */\nfunction parseStandardTokenTransactionData(\n data?: string,\n): TransactionDescription | undefined {\n if (!data) {\n return undefined;\n }\n\n try {\n return ERC20Interface.parseTransaction({ data });\n } catch {\n // ignore and next try to parse with erc721 ABI\n }\n\n try {\n return ERC721Interface.parseTransaction({ data });\n } catch {\n // ignore and next try to parse with erc1155 ABI\n }\n\n try {\n return ERC1155Interface.parseTransaction({ data });\n } catch {\n // ignore and return undefined\n }\n\n return undefined;\n}\n\n/**\n * Reads an Ethereum address and determines if it is a contract address.\n *\n * @param ethQuery - The Ethereum query object used to interact with the Ethereum blockchain.\n * @param address - The Ethereum address.\n * @returns An object containing the contract code and a boolean indicating if it is a contract address.\n */\nasync function readAddressAsContract(\n ethQuery: EthQuery,\n address?: string,\n): Promise<{\n contractCode: string | null;\n isContractAddress: boolean;\n}> {\n let contractCode;\n try {\n contractCode = await query(ethQuery, 'getCode', [address]);\n } catch (e) {\n contractCode = null;\n }\n\n const isContractAddress = contractCode\n ? contractCode !== '0x' && contractCode !== '0x0'\n : false;\n return { contractCode, isContractAddress };\n}\n"]} \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts new file mode 100644 -index 0000000..59837f9 +index 0000000..b2ab104 --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts -@@ -0,0 +1,33 @@ -+import type { GasFeeEstimates, LegacyGasPriceEstimate } from '@metamask/gas-fee-controller'; -+import { type GasFeeState } from '@metamask/gas-fee-controller'; -+import { type GasFeeEstimates as TransactionGasFeeEstimates, type GasFeeFlow, type TransactionMeta } from '../types'; ++++ b/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts +@@ -0,0 +1,58 @@ ++import type { GasPriceValue, FeeMarketEIP1559Values } from '../TransactionController'; ++import type { TransactionParams, TransactionMeta, TransactionError } from '../types'; ++export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; +/** -+ * Returns the first gas fee flow that matches the transaction. ++ * Normalizes properties on transaction params. + * -+ * @param transactionMeta - The transaction metadata to find a gas fee flow for. -+ * @param gasFeeFlows - The gas fee flows to search. -+ * @returns The first gas fee flow that matches the transaction, or undefined if none match. ++ * @param txParams - The transaction params to normalize. ++ * @returns Normalized transaction params. + */ -+export declare function getGasFeeFlow(transactionMeta: TransactionMeta, gasFeeFlows: GasFeeFlow[]): GasFeeFlow | undefined; -+declare type FeeMarketMergeGasFeeEstimatesRequest = { -+ gasFeeControllerEstimateType: 'fee-market'; -+ gasFeeControllerEstimates: GasFeeEstimates; -+ transactionGasFeeEstimates: TransactionGasFeeEstimates; ++export declare function normalizeTxParams(txParams: TransactionParams): TransactionParams; ++/** ++ * Checks if a transaction is EIP-1559 by checking for the existence of ++ * maxFeePerGas and maxPriorityFeePerGas within its parameters. ++ * ++ * @param txParams - Transaction params object to add. ++ * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false. ++ */ ++export declare function isEIP1559Transaction(txParams: TransactionParams): boolean; ++export declare const validateGasValues: (gasValues: GasPriceValue | FeeMarketEIP1559Values) => void; ++export declare const isFeeMarketEIP1559Values: (gasValues?: GasPriceValue | FeeMarketEIP1559Values) => gasValues is FeeMarketEIP1559Values; ++export declare const isGasPriceValue: (gasValues?: GasPriceValue | FeeMarketEIP1559Values) => gasValues is GasPriceValue; ++export declare const getIncreasedPriceHex: (value: number, rate: number) => string; ++export declare const getIncreasedPriceFromExisting: (value: string | undefined, rate: number) => string; ++/** ++ * Validates that the proposed value is greater than or equal to the minimum value. ++ * ++ * @param proposed - The proposed value. ++ * @param min - The minimum value. ++ * @returns The proposed value. ++ * @throws Will throw if the proposed value is too low. ++ */ ++export declare function validateMinimumIncrease(proposed: string, min: string): string; ++/** ++ * Validates that a transaction is unapproved. ++ * Throws if the transaction is not unapproved. ++ * ++ * @param transactionMeta - The transaction metadata to check. ++ * @param fnName - The name of the function calling this helper. ++ */ ++export declare function validateIfTransactionUnapproved(transactionMeta: TransactionMeta | undefined, fnName: string): void; ++/** ++ * Normalizes properties on transaction params. ++ * ++ * @param error - The error to be normalize. ++ * @returns Normalized transaction error. ++ */ ++export declare function normalizeTxError(error: Error & { ++ code?: string; ++ value?: unknown; ++}): TransactionError; ++/** ++ * Normalize an object containing gas fee values. ++ * ++ * @param gasFeeValues - An object containing gas fee values. ++ * @returns An object containing normalized gas fee values. ++ */ ++export declare function normalizeGasFeeValues(gasFeeValues: GasPriceValue | FeeMarketEIP1559Values): GasPriceValue | FeeMarketEIP1559Values; ++//# sourceMappingURL=utils.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts.map +new file mode 100644 +index 0000000..f455211 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/utils.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAqBrE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,qBAc5D;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAOzE;AAED,eAAO,MAAM,iBAAiB,cACjB,aAAa,GAAG,sBAAsB,SAYlD,CAAC;AAEF,eAAO,MAAM,wBAAwB,eACvB,aAAa,GAAG,sBAAsB,wCAGuB,CAAC;AAE5E,eAAO,MAAM,eAAe,eACd,aAAa,GAAG,sBAAsB,+BAEE,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;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,eAAe,GAAG,SAAS,EAC5C,MAAM,EAAE,MAAM,QAQf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAChD,gBAAgB,CAQlB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,aAAa,GAAG,sBAAsB,GACnD,aAAa,GAAG,sBAAsB,CAgBxC"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/utils.js b/node_modules/@metamask/transaction-controller/dist/utils/utils.js +new file mode 100644 +index 0000000..13f878e +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/utils.js +@@ -0,0 +1,148 @@ ++"use strict"; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.normalizeGasFeeValues = exports.normalizeTxError = exports.validateIfTransactionUnapproved = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.normalizeTxParams = exports.ESTIMATE_GAS_ERROR = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const utils_1 = require("@metamask/utils"); ++const ethereumjs_util_1 = require("ethereumjs-util"); ++const types_1 = require("../types"); ++exports.ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error'; ++// TODO: Replace `any` with type ++// eslint-disable-next-line @typescript-eslint/no-explicit-any ++const NORMALIZERS = { ++ data: (data) => (0, ethereumjs_util_1.addHexPrefix)(data), ++ from: (from) => (0, ethereumjs_util_1.addHexPrefix)(from).toLowerCase(), ++ gas: (gas) => (0, ethereumjs_util_1.addHexPrefix)(gas), ++ gasLimit: (gas) => (0, ethereumjs_util_1.addHexPrefix)(gas), ++ gasPrice: (gasPrice) => (0, ethereumjs_util_1.addHexPrefix)(gasPrice), ++ nonce: (nonce) => (0, ethereumjs_util_1.addHexPrefix)(nonce), ++ to: (to) => (0, ethereumjs_util_1.addHexPrefix)(to).toLowerCase(), ++ value: (value) => (0, ethereumjs_util_1.addHexPrefix)(value), ++ maxFeePerGas: (maxFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxFeePerGas), ++ maxPriorityFeePerGas: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), ++ estimatedBaseFee: (maxPriorityFeePerGas) => (0, ethereumjs_util_1.addHexPrefix)(maxPriorityFeePerGas), ++ type: (type) => (type === '0x0' ? '0x0' : undefined), +}; -+declare type LegacyMergeGasFeeEstimatesRequest = { -+ gasFeeControllerEstimateType: 'legacy'; -+ gasFeeControllerEstimates: LegacyGasPriceEstimate; -+ transactionGasFeeEstimates: TransactionGasFeeEstimates; ++/** ++ * Normalizes properties on transaction params. ++ * ++ * @param txParams - The transaction params to normalize. ++ * @returns Normalized transaction params. ++ */ ++function normalizeTxParams(txParams) { ++ const normalizedTxParams = { from: '' }; ++ for (const key of (0, utils_1.getKnownPropertyNames)(NORMALIZERS)) { ++ if (txParams[key]) { ++ normalizedTxParams[key] = NORMALIZERS[key](txParams[key]); ++ } ++ } ++ if (!normalizedTxParams.value) { ++ normalizedTxParams.value = '0x0'; ++ } ++ return normalizedTxParams; ++} ++exports.normalizeTxParams = normalizeTxParams; ++/** ++ * Checks if a transaction is EIP-1559 by checking for the existence of ++ * maxFeePerGas and maxPriorityFeePerGas within its parameters. ++ * ++ * @param txParams - Transaction params object to add. ++ * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false. ++ */ ++function isEIP1559Transaction(txParams) { ++ const hasOwnProp = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key); ++ return (hasOwnProp(txParams, 'maxFeePerGas') && ++ hasOwnProp(txParams, 'maxPriorityFeePerGas')); ++} ++exports.isEIP1559Transaction = isEIP1559Transaction; ++const validateGasValues = (gasValues) => { ++ Object.keys(gasValues).forEach((key) => { ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ const value = gasValues[key]; ++ if (typeof value !== 'string' || !(0, ethereumjs_util_1.isHexString)(value)) { ++ throw new TypeError(`expected hex string for ${key} but received: ${value}`); ++ } ++ }); ++}; ++exports.validateGasValues = validateGasValues; ++const isFeeMarketEIP1559Values = (gasValues) => (gasValues === null || gasValues === void 0 ? void 0 : gasValues.maxFeePerGas) !== undefined || ++ (gasValues === null || gasValues === void 0 ? void 0 : gasValues.maxPriorityFeePerGas) !== undefined; ++exports.isFeeMarketEIP1559Values = isFeeMarketEIP1559Values; ++const isGasPriceValue = (gasValues) => (gasValues === null || gasValues === void 0 ? void 0 : gasValues.gasPrice) !== undefined; ++exports.isGasPriceValue = isGasPriceValue; ++const getIncreasedPriceHex = (value, rate) => (0, ethereumjs_util_1.addHexPrefix)(`${parseInt(`${value * rate}`, 10).toString(16)}`); ++exports.getIncreasedPriceHex = getIncreasedPriceHex; ++const getIncreasedPriceFromExisting = (value, rate) => { ++ return (0, exports.getIncreasedPriceHex)((0, controller_utils_1.convertHexToDecimal)(value), rate); +}; ++exports.getIncreasedPriceFromExisting = getIncreasedPriceFromExisting; +/** -+ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction. ++ * Validates that the proposed value is greater than or equal to the minimum value. + * -+ * @param request - Data required to merge gas fee estimates. -+ * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller. -+ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController. -+ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction. -+ * @returns The merged gas fee estimates. ++ * @param proposed - The proposed value. ++ * @param min - The minimum value. ++ * @returns The proposed value. ++ * @throws Will throw if the proposed value is too low. + */ -+export declare function mergeGasFeeEstimates({ gasFeeControllerEstimateType, gasFeeControllerEstimates, transactionGasFeeEstimates, }: FeeMarketMergeGasFeeEstimatesRequest | LegacyMergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates']; -+export {}; -+//# sourceMappingURL=gas-flow.d.ts.map ++function validateMinimumIncrease(proposed, min) { ++ const proposedDecimal = (0, controller_utils_1.convertHexToDecimal)(proposed); ++ const minDecimal = (0, controller_utils_1.convertHexToDecimal)(min); ++ if (proposedDecimal >= minDecimal) { ++ return proposed; ++ } ++ const errorMsg = `The proposed value: ${proposedDecimal} should meet or exceed the minimum value: ${minDecimal}`; ++ throw new Error(errorMsg); ++} ++exports.validateMinimumIncrease = validateMinimumIncrease; ++/** ++ * Validates that a transaction is unapproved. ++ * Throws if the transaction is not unapproved. ++ * ++ * @param transactionMeta - The transaction metadata to check. ++ * @param fnName - The name of the function calling this helper. ++ */ ++function validateIfTransactionUnapproved(transactionMeta, fnName) { ++ if ((transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.status) !== types_1.TransactionStatus.unapproved) { ++ throw new Error(`TransactionsController: Can only call ${fnName} on an unapproved transaction. ++ Current tx status: ${transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.status}`); ++ } ++} ++exports.validateIfTransactionUnapproved = validateIfTransactionUnapproved; ++/** ++ * Normalizes properties on transaction params. ++ * ++ * @param error - The error to be normalize. ++ * @returns Normalized transaction error. ++ */ ++function normalizeTxError(error) { ++ return { ++ name: error.name, ++ message: error.message, ++ stack: error.stack, ++ code: error === null || error === void 0 ? void 0 : error.code, ++ rpc: error === null || error === void 0 ? void 0 : error.value, ++ }; ++} ++exports.normalizeTxError = normalizeTxError; ++/** ++ * Normalize an object containing gas fee values. ++ * ++ * @param gasFeeValues - An object containing gas fee values. ++ * @returns An object containing normalized gas fee values. ++ */ ++function normalizeGasFeeValues(gasFeeValues) { ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ const normalize = (value) => typeof value === 'string' ? (0, ethereumjs_util_1.addHexPrefix)(value) : value; ++ if ('gasPrice' in gasFeeValues) { ++ return { ++ gasPrice: normalize(gasFeeValues.gasPrice), ++ }; ++ } ++ return { ++ maxFeePerGas: normalize(gasFeeValues.maxFeePerGas), ++ maxPriorityFeePerGas: normalize(gasFeeValues.maxPriorityFeePerGas), ++ }; ++} ++exports.normalizeGasFeeValues = normalizeGasFeeValues; ++//# sourceMappingURL=utils.js.map \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/utils.js.map b/node_modules/@metamask/transaction-controller/dist/utils/utils.js.map new file mode 100644 -index 0000000..46c3e5a +index 0000000..bbba8bd --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts.map ++++ b/node_modules/@metamask/transaction-controller/dist/utils/utils.js.map @@ -0,0 +1 @@ -+{"version":3,"file":"gas-flow.d.ts","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,eAAe,EACf,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,KAAK,eAAe,IAAI,0BAA0B,EAClD,KAAK,UAAU,EACf,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AAElB;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,UAAU,EAAE,GACxB,UAAU,GAAG,SAAS,CAIxB;AAED,aAAK,oCAAoC,GAAG;IAC1C,4BAA4B,EAAE,YAAY,CAAC;IAC3C,yBAAyB,EAAE,eAAe,CAAC;IAC3C,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF,aAAK,iCAAiC,GAAG;IACvC,4BAA4B,EAAE,QAAQ,CAAC;IACvC,yBAAyB,EAAE,sBAAsB,CAAC;IAClD,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAC3B,EACG,oCAAoC,GACpC,iCAAiC,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAyBrE"} ++{"version":3,"file":"utils.js","sourceRoot":"","sources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sDAkBC","sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport { getKnownPropertyNames } from '@metamask/utils';\nimport { addHexPrefix, isHexString } from 'ethereumjs-util';\n\nimport type {\n GasPriceValue,\n FeeMarketEIP1559Values,\n} from '../TransactionController';\nimport { TransactionStatus } from '../types';\nimport type {\n TransactionParams,\n TransactionMeta,\n TransactionError,\n} from '../types';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\n// TODO: Replace `any` with type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst NORMALIZERS: { [param in keyof TransactionParams]: any } = {\n data: (data: string) => addHexPrefix(data),\n from: (from: string) => addHexPrefix(from).toLowerCase(),\n gas: (gas: string) => addHexPrefix(gas),\n gasLimit: (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 type: (type: string) => (type === '0x0' ? '0x0' : undefined),\n};\n\n/**\n * Normalizes properties on transaction params.\n *\n * @param txParams - The transaction params to normalize.\n * @returns Normalized transaction params.\n */\nexport function normalizeTxParams(txParams: TransactionParams) {\n const normalizedTxParams: TransactionParams = { from: '' };\n\n for (const key of getKnownPropertyNames(NORMALIZERS)) {\n if (txParams[key]) {\n normalizedTxParams[key] = NORMALIZERS[key](txParams[key]);\n }\n }\n\n if (!normalizedTxParams.value) {\n normalizedTxParams.value = '0x0';\n }\n\n return normalizedTxParams;\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 txParams - Transaction params object to add.\n * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false.\n */\nexport function isEIP1559Transaction(txParams: TransactionParams): boolean {\n const hasOwnProp = (obj: TransactionParams, key: string) =>\n Object.prototype.hasOwnProperty.call(obj, key);\n return (\n hasOwnProp(txParams, 'maxFeePerGas') &&\n hasOwnProp(txParams, 'maxPriorityFeePerGas')\n );\n}\n\nexport const validateGasValues = (\n gasValues: GasPriceValue | FeeMarketEIP1559Values,\n) => {\n Object.keys(gasValues).forEach((key) => {\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 * Validates that a transaction is unapproved.\n * Throws if the transaction is not unapproved.\n *\n * @param transactionMeta - The transaction metadata to check.\n * @param fnName - The name of the function calling this helper.\n */\nexport function validateIfTransactionUnapproved(\n transactionMeta: TransactionMeta | undefined,\n fnName: string,\n) {\n if (transactionMeta?.status !== TransactionStatus.unapproved) {\n throw new Error(\n `TransactionsController: Can only call ${fnName} on an unapproved transaction.\n Current tx status: ${transactionMeta?.status}`,\n );\n }\n}\n\n/**\n * Normalizes properties on transaction params.\n *\n * @param error - The error to be normalize.\n * @returns Normalized transaction error.\n */\nexport function normalizeTxError(\n error: Error & { code?: string; value?: unknown },\n): TransactionError {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n code: error?.code,\n rpc: error?.value,\n };\n}\n\n/**\n * Normalize an object containing gas fee values.\n *\n * @param gasFeeValues - An object containing gas fee values.\n * @returns An object containing normalized gas fee values.\n */\nexport function normalizeGasFeeValues(\n gasFeeValues: GasPriceValue | FeeMarketEIP1559Values,\n): GasPriceValue | FeeMarketEIP1559Values {\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const normalize = (value: any) =>\n typeof value === 'string' ? addHexPrefix(value) : value;\n\n if ('gasPrice' in gasFeeValues) {\n return {\n gasPrice: normalize(gasFeeValues.gasPrice),\n };\n }\n\n return {\n maxFeePerGas: normalize(gasFeeValues.maxFeePerGas),\n maxPriorityFeePerGas: normalize(gasFeeValues.maxPriorityFeePerGas),\n };\n}\n"]} \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts new file mode 100644 -index 0000000..7f4e8a9 +index 0000000..6c1d8bc --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js -@@ -0,0 +1,56 @@ ++++ b/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts +@@ -0,0 +1,20 @@ ++import { type TransactionParams } from '../types'; ++/** ++ * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin. ++ * ++ * @param permittedAddresses - The permitted accounts for the given origin. ++ * @param selectedAddress - The currently selected Ethereum address in the wallet. ++ * @param from - The address from which the transaction is initiated. ++ * @param origin - The origin or source of the transaction. ++ * @throws Throws an error if the transaction is not permitted. ++ */ ++export declare function validateTransactionOrigin(permittedAddresses: string[], selectedAddress: string, from: string, origin: string): Promise; ++/** ++ * Validates the transaction params for required properties and throws in ++ * the event of any validation error. ++ * ++ * @param txParams - Transaction params object to validate. ++ * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions. ++ */ ++export declare function validateTxParams(txParams: TransactionParams, isEIP1559Compatible?: boolean): void; ++//# sourceMappingURL=validation.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts.map b/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts.map +new file mode 100644 +index 0000000..ca49683 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/validation.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK3E;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,kBAAkB,EAAE,MAAM,EAAE,EAC5B,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,iBAqBf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,mBAAmB,UAAO,QAS3B"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/validation.js b/node_modules/@metamask/transaction-controller/dist/utils/validation.js +new file mode 100644 +index 0000000..6bd709c +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/validation.js +@@ -0,0 +1,259 @@ +"use strict"; ++var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { ++ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } ++ return new (P || (P = Promise))(function (resolve, reject) { ++ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } ++ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } ++ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } ++ step((generator = generator.apply(thisArg, _arguments || [])).next()); ++ }); ++}; +Object.defineProperty(exports, "__esModule", { value: true }); -+exports.mergeGasFeeEstimates = exports.getGasFeeFlow = void 0; ++exports.validateTxParams = exports.validateTransactionOrigin = void 0; ++const abi_1 = require("@ethersproject/abi"); +const controller_utils_1 = require("@metamask/controller-utils"); -+const gas_fee_controller_1 = require("@metamask/gas-fee-controller"); ++const metamask_eth_abis_1 = require("@metamask/metamask-eth-abis"); ++const rpc_errors_1 = require("@metamask/rpc-errors"); +const types_1 = require("../types"); ++const utils_1 = require("./utils"); +/** -+ * Returns the first gas fee flow that matches the transaction. ++ * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin. + * -+ * @param transactionMeta - The transaction metadata to find a gas fee flow for. -+ * @param gasFeeFlows - The gas fee flows to search. -+ * @returns The first gas fee flow that matches the transaction, or undefined if none match. ++ * @param permittedAddresses - The permitted accounts for the given origin. ++ * @param selectedAddress - The currently selected Ethereum address in the wallet. ++ * @param from - The address from which the transaction is initiated. ++ * @param origin - The origin or source of the transaction. ++ * @throws Throws an error if the transaction is not permitted. + */ -+function getGasFeeFlow(transactionMeta, gasFeeFlows) { -+ return gasFeeFlows.find((gasFeeFlow) => gasFeeFlow.matchesTransaction(transactionMeta)); ++function validateTransactionOrigin(permittedAddresses, selectedAddress, from, origin) { ++ return __awaiter(this, void 0, void 0, function* () { ++ if (origin === controller_utils_1.ORIGIN_METAMASK) { ++ // Ensure the 'from' address matches the currently selected address ++ if (from !== selectedAddress) { ++ throw rpc_errors_1.rpcErrors.internal({ ++ message: `Internally initiated transaction is using invalid account.`, ++ data: { ++ origin, ++ fromAddress: from, ++ selectedAddress, ++ }, ++ }); ++ } ++ return; ++ } ++ // Check if the origin has permissions to initiate transactions from the specified address ++ if (!permittedAddresses.includes(from)) { ++ throw rpc_errors_1.providerErrors.unauthorized({ data: { origin } }); ++ } ++ }); +} -+exports.getGasFeeFlow = getGasFeeFlow; ++exports.validateTransactionOrigin = validateTransactionOrigin; +/** -+ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction. ++ * Validates the transaction params for required properties and throws in ++ * the event of any validation error. + * -+ * @param request - Data required to merge gas fee estimates. -+ * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller. -+ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController. -+ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction. -+ * @returns The merged gas fee estimates. ++ * @param txParams - Transaction params object to validate. ++ * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions. + */ -+function mergeGasFeeEstimates({ gasFeeControllerEstimateType, gasFeeControllerEstimates, transactionGasFeeEstimates, }) { -+ if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { -+ return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: mergeFeeMarketEstimate(gasFeeControllerEstimates[level], transactionGasFeeEstimates[level]) })), Object.assign({}, gasFeeControllerEstimates)); ++function validateTxParams(txParams, isEIP1559Compatible = true) { ++ validateEIP1559Compatibility(txParams, isEIP1559Compatible); ++ validateParamFrom(txParams.from); ++ validateParamRecipient(txParams); ++ validateParamValue(txParams.value); ++ validateParamData(txParams.data); ++ validateParamChainId(txParams.chainId); ++ validateGasFeeParams(txParams); ++} ++exports.validateTxParams = validateTxParams; ++/** ++ * Validates EIP-1559 compatibility for transaction creation. ++ * ++ * @param txParams - The transaction parameters to validate. ++ * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559. ++ * @throws Throws invalid params if the transaction specifies EIP-1559 but the network does not support it. ++ */ ++function validateEIP1559Compatibility(txParams, isEIP1559Compatible) { ++ if ((0, utils_1.isEIP1559Transaction)(txParams) && !isEIP1559Compatible) { ++ throw rpc_errors_1.rpcErrors.invalidParams('Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559'); + } -+ if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) { -+ return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: getLegacyEstimate(transactionGasFeeEstimates[level]) })), {}); ++} ++/** ++ * Validates value property, ensuring it is a valid positive integer number ++ * denominated in wei. ++ * ++ * @param value - The value to validate, expressed as a string. ++ * @throws Throws an error if the value is not a valid positive integer ++ * number denominated in wei. ++ * - If the value contains a hyphen (-), it is considered invalid. ++ * - If the value contains a decimal point (.), it is considered invalid. ++ * - If the value is not a finite number, is NaN, or is not a safe integer, it is considered invalid. ++ */ ++function validateParamValue(value) { ++ if (value !== undefined) { ++ if (value.includes('-')) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction value "${value}": not a positive number.`); ++ } ++ if (value.includes('.')) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction value "${value}": number must be in wei.`); ++ } ++ const intValue = parseInt(value, 10); ++ const isValid = Number.isFinite(intValue) && ++ !Number.isNaN(intValue) && ++ !isNaN(Number(value)) && ++ Number.isSafeInteger(intValue); ++ if (!isValid) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction value ${value}: number must be a valid number.`); ++ } + } -+ return gasFeeControllerEstimates; +} -+exports.mergeGasFeeEstimates = mergeGasFeeEstimates; +/** -+ * Merge a specific priority level of EIP-1559 gas fee estimates. ++ * Validates the recipient address in a transaction's parameters. + * -+ * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller. -+ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction. -+ * @returns The merged gas fee estimate. ++ * @param txParams - The transaction parameters object to validate. ++ * @throws Throws an error if the recipient address is invalid: ++ * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data, ++ * the "to" field is removed from the transaction parameters. ++ * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown. + */ -+function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) { -+ return Object.assign(Object.assign({}, gasFeeControllerEstimate), { suggestedMaxFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas), suggestedMaxPriorityFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxPriorityFeePerGas) }); ++function validateParamRecipient(txParams) { ++ if (txParams.to === '0x' || txParams.to === undefined) { ++ if (txParams.data) { ++ delete txParams.to; ++ } ++ else { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid "to" address.`); ++ } ++ } ++ else if (txParams.to !== undefined && !(0, controller_utils_1.isValidHexAddress)(txParams.to)) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid "to" address.`); ++ } +} +/** -+ * Generate a specific priority level for a legacy gas fee estimate. ++ * Validates the recipient address in a transaction's parameters. + * -+ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction. -+ * @returns The legacy gas fee estimate. ++ * @param from - The from property to validate. ++ * @throws Throws an error if the recipient address is invalid: ++ * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data, ++ * the "to" field is removed from the transaction parameters. ++ * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown. + */ -+function getLegacyEstimate(transactionGasFeeEstimate) { -+ return (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas); ++function validateParamFrom(from) { ++ if (!from || typeof from !== 'string') { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid "from" address ${from}: not a string.`); ++ } ++ if (!(0, controller_utils_1.isValidHexAddress)(from)) { ++ throw rpc_errors_1.rpcErrors.invalidParams('Invalid "from" address.'); ++ } +} -+//# sourceMappingURL=gas-flow.js.map ++/** ++ * Validates input data for transactions. ++ * ++ * @param value - The input data to validate. ++ * @throws Throws invalid params if the input data is invalid. ++ */ ++function validateParamData(value) { ++ if (value) { ++ const ERC20Interface = new abi_1.Interface(metamask_eth_abis_1.abiERC20); ++ try { ++ ERC20Interface.parseTransaction({ data: value }); ++ // TODO: Replace `any` with type ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ } ++ catch (error) { ++ if (error.message.match(/BUFFER_OVERRUN/u)) { ++ throw rpc_errors_1.rpcErrors.invalidParams('Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.'); ++ } ++ } ++ } ++} ++/** ++ * Validates chainId type. ++ * ++ * @param chainId - The chainId to validate. ++ */ ++function validateParamChainId(chainId) { ++ if (chainId !== undefined && ++ typeof chainId !== 'number' && ++ typeof chainId !== 'string') { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`); ++ } ++} ++/** ++ * Validates gas values. ++ * ++ * @param txParams - The transaction parameters to validate. ++ */ ++function validateGasFeeParams(txParams) { ++ if (txParams.gasPrice) { ++ ensureProperTransactionEnvelopeTypeProvided(txParams, 'gasPrice'); ++ ensureMutuallyExclusiveFieldsNotProvided(txParams, 'gasPrice', 'maxFeePerGas'); ++ ensureMutuallyExclusiveFieldsNotProvided(txParams, 'gasPrice', 'maxPriorityFeePerGas'); ++ ensureFieldIsString(txParams, 'gasPrice'); ++ } ++ if (txParams.maxFeePerGas) { ++ ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxFeePerGas'); ++ ensureMutuallyExclusiveFieldsNotProvided(txParams, 'maxFeePerGas', 'gasPrice'); ++ ensureFieldIsString(txParams, 'maxFeePerGas'); ++ } ++ if (txParams.maxPriorityFeePerGas) { ++ ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxPriorityFeePerGas'); ++ ensureMutuallyExclusiveFieldsNotProvided(txParams, 'maxPriorityFeePerGas', 'gasPrice'); ++ ensureFieldIsString(txParams, 'maxPriorityFeePerGas'); ++ } ++} ++/** ++ * Ensures that the provided txParams has the proper 'type' specified for the ++ * given field, if it is provided. If types do not match throws an ++ * invalidParams error. ++ * ++ * @param txParams - The transaction parameters object ++ * @param field - The current field being validated ++ * @throws {ethErrors.rpc.invalidParams} Throws if type does not match the ++ * expectations for provided field. ++ */ ++function ensureProperTransactionEnvelopeTypeProvided(txParams, field) { ++ switch (field) { ++ case 'maxFeePerGas': ++ case 'maxPriorityFeePerGas': ++ if (txParams.type && ++ txParams.type !== types_1.TransactionEnvelopeType.feeMarket) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but including maxFeePerGas and maxPriorityFeePerGas requires type: "${types_1.TransactionEnvelopeType.feeMarket}"`); ++ } ++ break; ++ case 'gasPrice': ++ default: ++ if (txParams.type && ++ txParams.type === types_1.TransactionEnvelopeType.feeMarket) { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction envelope type: specified type "${txParams.type}" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`); ++ } ++ } ++} ++/** ++ * Given two fields, ensure that the second field is not included in txParams, ++ * and if it is throw an invalidParams error. ++ * ++ * @param txParams - The transaction parameters object ++ * @param fieldBeingValidated - The current field being validated ++ * @param mutuallyExclusiveField - The field to ensure is not provided ++ * @throws {ethErrors.rpc.invalidParams} Throws if mutuallyExclusiveField is ++ * present in txParams. ++ */ ++function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated, mutuallyExclusiveField) { ++ if (typeof txParams[mutuallyExclusiveField] !== 'undefined') { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`); ++ } ++} ++/** ++ * Ensures that the provided value for field is a string, throws an ++ * invalidParams error if field is not a string. ++ * ++ * @param txParams - The transaction parameters object ++ * @param field - The current field being validated ++ * @throws {rpcErrors.invalidParams} Throws if field is not a string ++ */ ++function ensureFieldIsString(txParams, field) { ++ if (typeof txParams[field] !== 'string') { ++ throw rpc_errors_1.rpcErrors.invalidParams(`Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`); ++ } ++} ++//# sourceMappingURL=validation.js.map \ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map +diff --git a/node_modules/@metamask/transaction-controller/dist/utils/validation.js.map b/node_modules/@metamask/transaction-controller/dist/utils/validation.js.map new file mode 100644 -index 0000000..fe93a4a +index 0000000..1167caa --- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.js.map ++++ b/node_modules/@metamask/transaction-controller/dist/utils/validation.js.map @@ -0,0 +1 @@ -+{"version":3,"file":"gas-flow.js","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAM7D,qEAGsC;AAEtC,oCAMkB;AAElB;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,eAAgC,EAChC,WAAyB;IAEzB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrC,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAC/C,CAAC;AACJ,CAAC;AAPD,sCAOC;AAcD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAAC,EACnC,4BAA4B,EAC5B,yBAAyB,EACzB,0BAA0B,GAGS;IACnC,IAAI,4BAA4B,KAAK,uCAAkB,CAAC,UAAU,EAAE;QAClE,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,iCACd,MAAM,KACT,CAAC,KAAK,CAAC,EAAE,sBAAsB,CAC7B,yBAAyB,CAAC,KAAK,CAAC,EAChC,0BAA0B,CAAC,KAAK,CAAC,CAClC,IACD,EACF,kBAAK,yBAAyB,CAAqB,CACpD,CAAC;KACH;IAED,IAAI,4BAA4B,KAAK,uCAAkB,CAAC,MAAM,EAAE;QAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,iCACd,MAAM,KACT,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,IAC7D,EACF,EAA4B,CAC7B,CAAC;KACH;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC;AA/BD,oDA+BC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAC7B,wBAAuC,EACvC,yBAAkD;IAElD,uCACK,wBAAwB,KAC3B,qBAAqB,EAAE,IAAA,kCAAe,EACpC,yBAAyB,CAAC,YAAY,CACvC,EACD,6BAA6B,EAAE,IAAA,kCAAe,EAC5C,yBAAyB,CAAC,oBAAoB,CAC/C,IACD;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,yBAAkD;IAElD,OAAO,IAAA,kCAAe,EAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport type {\n Eip1559GasFee,\n GasFeeEstimates,\n LegacyGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport {\n GAS_ESTIMATE_TYPES,\n type GasFeeState,\n} from '@metamask/gas-fee-controller';\n\nimport {\n type GasFeeEstimates as TransactionGasFeeEstimates,\n type GasFeeFlow,\n type TransactionMeta,\n type GasFeeEstimatesForLevel,\n GasFeeEstimateLevel,\n} from '../types';\n\n/**\n * Returns the first gas fee flow that matches the transaction.\n *\n * @param transactionMeta - The transaction metadata to find a gas fee flow for.\n * @param gasFeeFlows - The gas fee flows to search.\n * @returns The first gas fee flow that matches the transaction, or undefined if none match.\n */\nexport function getGasFeeFlow(\n transactionMeta: TransactionMeta,\n gasFeeFlows: GasFeeFlow[],\n): GasFeeFlow | undefined {\n return gasFeeFlows.find((gasFeeFlow) =>\n gasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\ntype FeeMarketMergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimateType: 'fee-market';\n gasFeeControllerEstimates: GasFeeEstimates;\n transactionGasFeeEstimates: TransactionGasFeeEstimates;\n};\n\ntype LegacyMergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimateType: 'legacy';\n gasFeeControllerEstimates: LegacyGasPriceEstimate;\n transactionGasFeeEstimates: TransactionGasFeeEstimates;\n};\n\n/**\n * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.\n *\n * @param request - Data required to merge gas fee estimates.\n * @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller.\n * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.\n * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.\n * @returns The merged gas fee estimates.\n */\nexport function mergeGasFeeEstimates({\n gasFeeControllerEstimateType,\n gasFeeControllerEstimates,\n transactionGasFeeEstimates,\n}:\n | FeeMarketMergeGasFeeEstimatesRequest\n | LegacyMergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'] {\n if (gasFeeControllerEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: mergeFeeMarketEstimate(\n gasFeeControllerEstimates[level],\n transactionGasFeeEstimates[level],\n ),\n }),\n { ...gasFeeControllerEstimates } as GasFeeEstimates,\n );\n }\n\n if (gasFeeControllerEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: getLegacyEstimate(transactionGasFeeEstimates[level]),\n }),\n {} as LegacyGasPriceEstimate,\n );\n }\n\n return gasFeeControllerEstimates;\n}\n\n/**\n * Merge a specific priority level of EIP-1559 gas fee estimates.\n *\n * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The merged gas fee estimate.\n */\nfunction mergeFeeMarketEstimate(\n gasFeeControllerEstimate: Eip1559GasFee,\n transactionGasFeeEstimate: GasFeeEstimatesForLevel,\n): Eip1559GasFee {\n return {\n ...gasFeeControllerEstimate,\n suggestedMaxFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxFeePerGas,\n ),\n suggestedMaxPriorityFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxPriorityFeePerGas,\n ),\n };\n}\n\n/**\n * Generate a specific priority level for a legacy gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The legacy gas fee estimate.\n */\nfunction getLegacyEstimate(\n transactionGasFeeEstimate: GasFeeEstimatesForLevel,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate.maxFeePerGas);\n}\n"]} ++{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA+C;AAC/C,iEAAgF;AAChF,mEAAuD;AACvD,qDAAiE;AAEjE,oCAA2E;AAC3E,mCAA+C;AAI/C;;;;;;;;GAQG;AACH,SAAsB,yBAAyB,CAC7C,kBAA4B,EAC5B,eAAuB,EACvB,IAAY,EACZ,MAAc;;QAEd,IAAI,MAAM,KAAK,kCAAe,EAAE;YAC9B,mEAAmE;YACnE,IAAI,IAAI,KAAK,eAAe,EAAE;gBAC5B,MAAM,sBAAS,CAAC,QAAQ,CAAC;oBACvB,OAAO,EAAE,4DAA4D;oBACrE,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,sBAAS,CAAC,aAAa,CAC3B,+BAA+B,KAAK,2BAA2B,QAAQ,CAAC,KAAK,CAAC,GAAG,CAClF,CAAC;KACH;AACH,CAAC","sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport { ORIGIN_METAMASK, isValidHexAddress } from '@metamask/controller-utils';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionEnvelopeType, type TransactionParams } from '../types';\nimport { isEIP1559Transaction } from './utils';\n\ntype GasFieldsToValidate = 'gasPrice' | 'maxFeePerGas' | 'maxPriorityFeePerGas';\n\n/**\n * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin.\n *\n * @param permittedAddresses - The permitted accounts for the given origin.\n * @param selectedAddress - The currently selected Ethereum address in the wallet.\n * @param from - The address from which the transaction is initiated.\n * @param origin - The origin or source of the transaction.\n * @throws Throws an error if the transaction is not permitted.\n */\nexport async function validateTransactionOrigin(\n permittedAddresses: string[],\n selectedAddress: string,\n from: string,\n origin: string,\n) {\n if (origin === ORIGIN_METAMASK) {\n // Ensure the 'from' address matches the currently selected address\n if (from !== selectedAddress) {\n throw rpcErrors.internal({\n message: `Internally initiated transaction is using invalid account.`,\n data: {\n origin,\n fromAddress: from,\n selectedAddress,\n },\n });\n }\n return;\n }\n\n // Check if the origin has permissions to initiate transactions from the specified address\n if (!permittedAddresses.includes(from)) {\n throw providerErrors.unauthorized({ data: { origin } });\n }\n}\n\n/**\n * Validates the transaction params for required properties and throws in\n * the event of any validation error.\n *\n * @param txParams - Transaction params object to validate.\n * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions.\n */\nexport function validateTxParams(\n txParams: TransactionParams,\n isEIP1559Compatible = true,\n) {\n validateEIP1559Compatibility(txParams, isEIP1559Compatible);\n validateParamFrom(txParams.from);\n validateParamRecipient(txParams);\n validateParamValue(txParams.value);\n validateParamData(txParams.data);\n validateParamChainId(txParams.chainId);\n validateGasFeeParams(txParams);\n}\n\n/**\n * Validates EIP-1559 compatibility for transaction creation.\n *\n * @param txParams - The transaction parameters to validate.\n * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559.\n * @throws Throws invalid params if the transaction specifies EIP-1559 but the network does not support it.\n */\nfunction validateEIP1559Compatibility(\n txParams: TransactionParams,\n isEIP1559Compatible: boolean,\n) {\n if (isEIP1559Transaction(txParams) && !isEIP1559Compatible) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559',\n );\n }\n}\n\n/**\n * Validates value property, ensuring it is a valid positive integer number\n * denominated in wei.\n *\n * @param value - The value to validate, expressed as a string.\n * @throws Throws an error if the value is not a valid positive integer\n * number denominated in wei.\n * - If the value contains a hyphen (-), it is considered invalid.\n * - If the value contains a decimal point (.), it is considered invalid.\n * - If the value is not a finite number, is NaN, or is not a safe integer, it is considered invalid.\n */\nfunction validateParamValue(value?: string) {\n if (value !== undefined) {\n if (value.includes('-')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": not a positive number.`,\n );\n }\n\n if (value.includes('.')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": number must be in wei.`,\n );\n }\n const intValue = parseInt(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 rpcErrors.invalidParams(\n `Invalid transaction value ${value}: number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param txParams - The transaction parameters object to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamRecipient(txParams: TransactionParams) {\n if (txParams.to === '0x' || txParams.to === undefined) {\n if (txParams.data) {\n delete txParams.to;\n } else {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n } else if (txParams.to !== undefined && !isValidHexAddress(txParams.to)) {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param from - The from property to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamFrom(from: string) {\n if (!from || typeof from !== 'string') {\n throw rpcErrors.invalidParams(\n `Invalid \"from\" address ${from}: not a string.`,\n );\n }\n if (!isValidHexAddress(from)) {\n throw rpcErrors.invalidParams('Invalid \"from\" address.');\n }\n}\n\n/**\n * Validates input data for transactions.\n *\n * @param value - The input data to validate.\n * @throws Throws invalid params if the input data is invalid.\n */\nfunction validateParamData(value?: string) {\n if (value) {\n const ERC20Interface = new Interface(abiERC20);\n try {\n ERC20Interface.parseTransaction({ data: value });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message.match(/BUFFER_OVERRUN/u)) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.',\n );\n }\n }\n }\n}\n\n/**\n * Validates chainId type.\n *\n * @param chainId - The chainId to validate.\n */\nfunction validateParamChainId(chainId: number | string | undefined) {\n if (\n chainId !== undefined &&\n typeof chainId !== 'number' &&\n typeof chainId !== 'string'\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`,\n );\n }\n}\n\n/**\n * Validates gas values.\n *\n * @param txParams - The transaction parameters to validate.\n */\nfunction validateGasFeeParams(txParams: TransactionParams) {\n if (txParams.gasPrice) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'gasPrice');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxPriorityFeePerGas',\n );\n ensureFieldIsString(txParams, 'gasPrice');\n }\n\n if (txParams.maxFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxFeePerGas');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxFeePerGas');\n }\n\n if (txParams.maxPriorityFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(\n txParams,\n 'maxPriorityFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxPriorityFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxPriorityFeePerGas');\n }\n}\n\n/**\n * Ensures that the provided txParams has the proper 'type' specified for the\n * given field, if it is provided. If types do not match throws an\n * invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {ethErrors.rpc.invalidParams} Throws if type does not match the\n * expectations for provided field.\n */\nfunction ensureProperTransactionEnvelopeTypeProvided(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n switch (field) {\n case 'maxFeePerGas':\n case 'maxPriorityFeePerGas':\n if (\n txParams.type &&\n txParams.type !== TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but including maxFeePerGas and maxPriorityFeePerGas requires type: \"${TransactionEnvelopeType.feeMarket}\"`,\n );\n }\n break;\n case 'gasPrice':\n default:\n if (\n txParams.type &&\n txParams.type === TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`,\n );\n }\n }\n}\n\n/**\n * Given two fields, ensure that the second field is not included in txParams,\n * and if it is throw an invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param fieldBeingValidated - The current field being validated\n * @param mutuallyExclusiveField - The field to ensure is not provided\n * @throws {ethErrors.rpc.invalidParams} Throws if mutuallyExclusiveField is\n * present in txParams.\n */\nfunction ensureMutuallyExclusiveFieldsNotProvided(\n txParams: TransactionParams,\n fieldBeingValidated: GasFieldsToValidate,\n mutuallyExclusiveField: GasFieldsToValidate,\n) {\n if (typeof txParams[mutuallyExclusiveField] !== 'undefined') {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`,\n );\n }\n}\n\n/**\n * Ensures that the provided value for field is a string, throws an\n * invalidParams error if field is not a string.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {rpcErrors.invalidParams} Throws if field is not a string\n */\nfunction ensureFieldIsString(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n if (typeof txParams[field] !== 'string') {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`,\n );\n }\n}\n"]} \ No newline at end of file diff --git a/patches/react-native-webview+11.13.0.patch b/patches/react-native-webview+11.13.0.patch index 81140f13f02..d613485d404 100644 --- a/patches/react-native-webview+11.13.0.patch +++ b/patches/react-native-webview+11.13.0.patch @@ -83,7 +83,7 @@ index 0000000..f4a6af9 + } +} diff --git a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java -index f743bbc..06d172f 100644 +index f743bbc..b520532 100644 --- a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -5,6 +5,7 @@ import android.annotation.TargetApi; @@ -1022,7 +1022,31 @@ index f743bbc..06d172f 100644 @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { -@@ -1402,6 +1756,15 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1266,7 +1620,22 @@ public class RNCWebViewManager extends SimpleViewManager { + requestPermissions(Collections.singletonList(Manifest.permission.ACCESS_FINE_LOCATION)); + + } else { +- callback.invoke(origin, true, false); ++ String alertMessage = String.format("Allow this app to use your location?"); ++ AlertDialog.Builder builder = new AlertDialog.Builder(this.mWebView.getContext()); ++ builder.setMessage(alertMessage); ++ builder.setCancelable(false); ++ builder.setPositiveButton("Allow", (dialog, which) -> { ++ callback.invoke(origin, true, false); ++ }); ++ builder.setNegativeButton("Don't allow", (dialog, which) -> { ++ callback.invoke(origin, false, false); ++ }); ++ AlertDialog alertDialog = builder.create(); ++ alertDialog.show(); ++ //Delay making `allow` clickable for 500ms to avoid unwanted presses. ++ Button posButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); ++ posButton.setEnabled(false); ++ this.runDelayed(() -> posButton.setEnabled(true), 500); + } + } + +@@ -1402,6 +1771,15 @@ public class RNCWebViewManager extends SimpleViewManager { } } @@ -1038,7 +1062,7 @@ index f743bbc..06d172f 100644 @Override public void onHostPause() { } -@@ -1447,6 +1810,13 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1447,6 +1825,13 @@ public class RNCWebViewManager extends SimpleViewManager { protected boolean nestedScrollEnabled = false; protected ProgressChangedFilter progressChangedFilter; @@ -1052,7 +1076,7 @@ index f743bbc..06d172f 100644 /** * WebView must be created with an context of the current activity *

-@@ -1475,6 +1845,42 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1475,6 +1860,42 @@ public class RNCWebViewManager extends SimpleViewManager { this.nestedScrollEnabled = nestedScrollEnabled; } @@ -1095,7 +1119,7 @@ index f743bbc..06d172f 100644 @Override public void onHostResume() { // do nothing -@@ -1533,6 +1939,8 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1533,6 +1954,8 @@ public class RNCWebViewManager extends SimpleViewManager { } } @@ -1104,7 +1128,7 @@ index f743bbc..06d172f 100644 public @Nullable RNCWebViewClient getRNCWebViewClient() { return mRNCWebViewClient; -@@ -1609,8 +2017,8 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1609,8 +2032,8 @@ public class RNCWebViewManager extends SimpleViewManager { public void callInjectedJavaScriptBeforeContentLoaded() { if (getSettings().getJavaScriptEnabled() && @@ -1115,7 +1139,7 @@ index f743bbc..06d172f 100644 evaluateJavascriptWithFallback("(function() {\n" + injectedJSBeforeContentLoaded + ";\n})();"); } } -@@ -1672,16 +2080,16 @@ public class RNCWebViewManager extends SimpleViewManager { +@@ -1672,16 +2095,16 @@ public class RNCWebViewManager extends SimpleViewManager { if (mOnScrollDispatchHelper.onScrollChanged(x, y)) { ScrollEvent event = ScrollEvent.obtain( @@ -1174,7 +1198,7 @@ diff --git a/node_modules/react-native-webview/apple/RNCWebView.m b/node_modules index 28c078a..9bb5368 100644 --- a/node_modules/react-native-webview/apple/RNCWebView.m +++ b/node_modules/react-native-webview/apple/RNCWebView.m -@@ -105,6 +105,7 @@ @implementation RNCWebView +@@ -105,6 +105,7 @@ static NSDictionary* customCertificatesForHost; UIStatusBarStyle _savedStatusBarStyle; #endif // !TARGET_OS_OSX BOOL _savedStatusBarHidden; @@ -1182,7 +1206,7 @@ index 28c078a..9bb5368 100644 #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */ UIScrollViewContentInsetAdjustmentBehavior _savedContentInsetAdjustmentBehavior; -@@ -139,6 +140,7 @@ - (instancetype)initWithFrame:(CGRect)frame +@@ -139,6 +140,7 @@ static NSDictionary* customCertificatesForHost; _injectedJavaScriptForMainFrameOnly = YES; _injectedJavaScriptBeforeContentLoaded = nil; _injectedJavaScriptBeforeContentLoadedForMainFrameOnly = YES; @@ -1190,7 +1214,7 @@ index 28c078a..9bb5368 100644 #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */ _savedContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; -@@ -417,6 +419,7 @@ -(void)keyboardDisplacementFix +@@ -417,6 +419,7 @@ static NSDictionary* customCertificatesForHost; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ if ([keyPath isEqual:@"estimatedProgress"] && object == self.webView) { if(_onLoadingProgress){ @@ -1198,7 +1222,7 @@ index 28c078a..9bb5368 100644 NSMutableDictionary *event = [self baseEvent]; [event addEntriesFromDictionary:@{@"progress":[NSNumber numberWithDouble:self.webView.estimatedProgress]}]; _onLoadingProgress(event); -@@ -492,6 +495,7 @@ - (void)userContentController:(WKUserContentController *)userContentController +@@ -492,6 +495,7 @@ static NSDictionary* customCertificatesForHost; NSMutableDictionary *event = [self baseEvent]; [event addEntriesFromDictionary: @{@"navigationType": message.body}]; _onLoadingFinish(event); @@ -1206,7 +1230,7 @@ index 28c078a..9bb5368 100644 } } else if ([message.name isEqualToString:MessageHandlerName]) { if (_onMessage) { -@@ -851,11 +855,13 @@ - (void) webView:(WKWebView *)webView +@@ -851,11 +855,13 @@ static NSDictionary* customCertificatesForHost; - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler { #if !TARGET_OS_OSX @@ -1225,7 +1249,7 @@ index 28c078a..9bb5368 100644 #else NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:message]; -@@ -868,6 +874,51 @@ - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSStrin +@@ -868,6 +874,51 @@ static NSDictionary* customCertificatesForHost; /** * confirm */ @@ -1277,7 +1301,7 @@ index 28c078a..9bb5368 100644 - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{ #if !TARGET_OS_OSX UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert]; -@@ -894,44 +945,49 @@ - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSStr +@@ -894,44 +945,49 @@ static NSDictionary* customCertificatesForHost; * prompt */ - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{ @@ -1362,7 +1386,7 @@ index 28c078a..9bb5368 100644 } #if !TARGET_OS_OSX -@@ -1157,6 +1213,7 @@ - (void)webView:(WKWebView *)webView +@@ -1157,6 +1213,7 @@ static NSDictionary* customCertificatesForHost; } if (_onLoadingFinish) { @@ -1370,7 +1394,7 @@ index 28c078a..9bb5368 100644 _onLoadingFinish([self baseEvent]); } } -@@ -1446,3 +1503,4 @@ - (void)userContentController:(WKUserContentController *)userContentController d +@@ -1446,3 +1503,4 @@ static NSDictionary* customCertificatesForHost; } @end diff --git a/yarn.lock b/yarn.lock index ed8168e74b9..8f308ccb4d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9941,7 +9941,7 @@ resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e" integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ== -"@xmldom/xmldom@^0.8.10", "@xmldom/xmldom@^0.x": +"@xmldom/xmldom@^0.8.10", "@xmldom/xmldom@^0.8.8", "@xmldom/xmldom@^0.x": version "0.8.10" resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.10.tgz#a1337ca426aa61cef9fe15b5b28e340a72f6fa99" integrity sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw== @@ -13362,15 +13362,7 @@ cron-parser@^4.5.0: dependencies: luxon "^3.2.1" -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== - dependencies: - node-fetch "^2.6.7" - whatwg-fetch "^2.0.4" - -cross-fetch@3.1.5, cross-fetch@^3.0.4: +cross-fetch@3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== @@ -13384,6 +13376,13 @@ cross-fetch@4.0.0: dependencies: node-fetch "^2.6.12" +cross-fetch@^3.0.4, cross-fetch@^3.1.5: + version "3.1.8" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" + integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== + dependencies: + node-fetch "^2.6.12" + cross-spawn@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" @@ -22619,13 +22618,14 @@ please-upgrade-node@^3.1.1, please-upgrade-node@^3.2.0: dependencies: semver-compare "^1.0.0" -plist@3.0.5, plist@3.1.0, plist@^3.0.1, plist@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.5.tgz#2cbeb52d10e3cdccccf0c11a63a85d830970a987" - integrity sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA== +plist@3.1.0, plist@^3.0.1, plist@^3.0.5: + version "3.1.0" + resolved "https://registry.yarnpkg.com/plist/-/plist-3.1.0.tgz#797a516a93e62f5bde55e0b9cc9c967f860893c9" + integrity sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ== dependencies: + "@xmldom/xmldom" "^0.8.8" base64-js "^1.5.1" - xmlbuilder "^9.0.7" + xmlbuilder "^15.1.1" plugin-error@^0.1.2: version "0.1.2" @@ -27901,11 +27901,6 @@ webpack@5, webpack@^5.88.2: watchpack "^2.4.0" webpack-sources "^3.2.3" -whatwg-fetch@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" - integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== - whatwg-fetch@^3.0.0, whatwg-fetch@^3.4.1: version "3.6.2" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c" @@ -28249,7 +28244,7 @@ xmlbuilder@^15.1.1: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-15.1.1.tgz#9dcdce49eea66d8d10b42cae94a79c3c8d0c2ec5" integrity sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg== -xmlbuilder@^9.0.1, xmlbuilder@^9.0.7: +xmlbuilder@^9.0.1: version "9.0.7" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" integrity sha512-7YXTQc3P2l9+0rjaUbLwMKRhtmwg1M1eDf6nag7urC7pIPYLD9W/jmzQ4ptRSUbodw5S0jfoGTflLemQibSpeQ==