diff --git a/app/components/Nav/Main/RootRPCMethodsUI.js b/app/components/Nav/Main/RootRPCMethodsUI.js index ca6007d86bc6..631ed527cc86 100644 --- a/app/components/Nav/Main/RootRPCMethodsUI.js +++ b/app/components/Nav/Main/RootRPCMethodsUI.js @@ -106,7 +106,7 @@ const RootRPCMethodsUI = (props) => { const receipt = await query( TransactionController.ethQuery, 'getTransactionReceipt', - [transactionMeta.transactionHash], + [transactionMeta.hash], ); const currentBlock = await query( @@ -115,18 +115,18 @@ const RootRPCMethodsUI = (props) => { [receipt.blockHash, false], ); let approvalReceipt; - if (approvalTransaction?.transactionHash) { + if (approvalTransaction?.hash) { approvalReceipt = await query( TransactionController.ethQuery, 'getTransactionReceipt', - [approvalTransaction.transactionHash], + [approvalTransaction.hash], ); } const tokensReceived = swapsUtils.getSwapsTokensReceived( receipt, approvalReceipt, - transactionMeta?.transaction, - approvalTransaction?.transaction, + transactionMeta?.txParams, + approvalTransaction?.txParams, swapTransaction.destinationToken, ethAccountBalance, ethBalance, @@ -161,7 +161,7 @@ const RootRPCMethodsUI = (props) => { const analyticsParams = { ...swapTransaction.analytics, - account_type: getAddressAccountType(transactionMeta.transaction.from), + account_type: getAddressAccountType(transactionMeta.txParams.from), }; delete newSwapsTransactions[transactionMeta.id].analytics; delete newSwapsTransactions[transactionMeta.id].paramsForAnalytics; @@ -200,7 +200,7 @@ const RootRPCMethodsUI = (props) => { if (transactionMeta.status === 'submitted') { NotificationManager.watchSubmittedTransaction({ ...transactionMeta, - assetType: transactionMeta.transaction.assetType, + assetType: transactionMeta.txParams.assetType, }); } else { if (props.swapsTransactions[transactionMeta.id]?.analytics) { @@ -221,7 +221,7 @@ const RootRPCMethodsUI = (props) => { await KeyringController.resetQRKeyringState(); const isLedgerAccount = isHardwareAccount( - transactionMeta.transaction.from, + transactionMeta.txParams.from, [ExtendedKeyringTypes.ledger], ); @@ -261,18 +261,18 @@ const RootRPCMethodsUI = (props) => { async (transactionMeta) => { if (transactionMeta.origin === TransactionTypes.MMM) return; - const to = transactionMeta.transaction.to?.toLowerCase(); - const { data } = transactionMeta.transaction; + const to = transactionMeta.txParams.to?.toLowerCase(); + const { data } = transactionMeta.txParams; if (isSwapTransaction(data, transactionMeta.origin, to, props.chainId)) { autoSign(transactionMeta); } else { const { - transaction: { value, gas, gasPrice, data }, + txParams: { value, gas, gasPrice, data }, } = transactionMeta; const { AssetsContractController } = Engine.context; - transactionMeta.transaction.gas = hexToBN(gas); - transactionMeta.transaction.gasPrice = gasPrice && hexToBN(gasPrice); + transactionMeta.txParams.gas = hexToBN(gas); + transactionMeta.txParams.gasPrice = gasPrice && hexToBN(gasPrice); if ( (value === '0x0' || !value) && @@ -311,11 +311,11 @@ const RootRPCMethodsUI = (props) => { const tokenAmount = tokenData && calcTokenAmount(tokenValue, asset.decimals).toFixed(); - transactionMeta.transaction.value = hexToBN( + transactionMeta.txParams.value = hexToBN( getTokenValueParamAsHex(tokenData), ); - transactionMeta.transaction.readableValue = tokenAmount; - transactionMeta.transaction.to = toAddress; + transactionMeta.txParams.readableValue = tokenAmount; + transactionMeta.txParams.to = toAddress; setTransactionObject({ type: 'INDIVIDUAL_TOKEN_TRANSACTION', @@ -323,19 +323,19 @@ const RootRPCMethodsUI = (props) => { id: transactionMeta.id, origin: transactionMeta.origin, securityAlertResponse: transactionMeta.securityAlertResponse, - ...transactionMeta.transaction, + ...transactionMeta.txParams, }); } else { - transactionMeta.transaction.value = hexToBN(value); - transactionMeta.transaction.readableValue = fromWei( - transactionMeta.transaction.value, + transactionMeta.txParams.value = hexToBN(value); + transactionMeta.txParams.readableValue = fromWei( + transactionMeta.txParams.value, ); setEtherTransaction({ id: transactionMeta.id, origin: transactionMeta.origin, securityAlertResponse: transactionMeta.securityAlertResponse, - ...transactionMeta.transaction, + ...transactionMeta.txParams, }); } diff --git a/app/components/UI/Notification/TransactionNotification/index.js b/app/components/UI/Notification/TransactionNotification/index.js index 6543347eea52..1eb7693fc38b 100644 --- a/app/components/UI/Notification/TransactionNotification/index.js +++ b/app/components/UI/Notification/TransactionNotification/index.js @@ -249,9 +249,7 @@ function TransactionNotification(props) { swapsTransactions, swapsTokens, }); - const existingGasPrice = new BigNumber( - tx?.transaction?.gasPrice || '0x0', - ); + const existingGasPrice = new BigNumber(tx?.txParams?.gasPrice || '0x0'); const gasFeeValue = fastSplit( existingGasPrice .times( @@ -289,7 +287,7 @@ function TransactionNotification(props) { { const { chainId, - transactionObject: { status, time, transaction }, + transactionObject: { status, time, txParams }, } = this.props; const { updatedTransactionDetails } = this.state; const styles = this.getStyles(); @@ -332,7 +331,7 @@ class TransactionDetails extends PureComponent { - + {strings('transactions.from')} @@ -361,9 +360,9 @@ class TransactionDetails extends PureComponent { {strings('transactions.nonce')} - {!!transaction?.nonce && ( + {!!txParams?.nonce && ( {`#${parseInt( - transaction.nonce.replace(regex.transactionNonce, ''), + txParams.nonce.replace(regex.transactionNonce, ''), 16, )}`} )} @@ -372,7 +371,7 @@ class TransactionDetails extends PureComponent { - {updatedTransactionDetails.transactionHash && + {updatedTransactionDetails.hash && status !== 'cancelled' && rpcBlockExplorer !== NO_RPC_BLOCK_EXPLORER && ( { const { tx, selectedAddress } = this.props; - const incoming = - safeToChecksumAddress(tx.transaction.to) === selectedAddress; + const incoming = safeToChecksumAddress(tx.txParams.to) === selectedAddress; const selfSent = - incoming && - safeToChecksumAddress(tx.transaction.from) === selectedAddress; + incoming && safeToChecksumAddress(tx.txParams.from) === selectedAddress; return `${ (!incoming || selfSent) && tx.deviceConfirmedOn === WalletDevice.MM_MOBILE - ? `#${parseInt(tx.transaction.nonce, 16)} - ${toDateFormat( + ? `#${parseInt(tx.txParams.nonce, 16)} - ${toDateFormat( tx.time, )} ${strings( 'transactions.from_device_label', @@ -402,7 +400,7 @@ class TransactionElement extends PureComponent { const { tx } = this.props; let existingGas = {}; - const transaction = tx?.transaction; + const transaction = tx?.txParams; if (transaction) { if (isEIP1559Transaction(transaction)) { existingGas = { @@ -413,9 +411,7 @@ class TransactionElement extends PureComponent { ), }; } else { - const existingGasPrice = tx.transaction - ? tx.transaction.gasPrice - : '0x0'; + const existingGasPrice = tx.txParams ? tx.txParams.gasPrice : '0x0'; const existingGasPriceDecimal = parseInt( existingGasPrice === undefined ? '0x0' : existingGasPrice, 16, diff --git a/app/components/UI/TransactionElement/utils.js b/app/components/UI/TransactionElement/utils.js index c09cff46d735..cf9a091e686d 100644 --- a/app/components/UI/TransactionElement/utils.js +++ b/app/components/UI/TransactionElement/utils.js @@ -98,7 +98,7 @@ function renderGwei(transaction) { function getTokenTransfer(args) { const { tx: { - transaction: { from, to, data, nonce }, + txParams: { from, to, data, nonce }, }, conversionRate, currentCurrency, @@ -196,7 +196,7 @@ function getTokenTransfer(args) { function getCollectibleTransfer(args) { const { tx: { - transaction: { from, to, data }, + txParams: { from, to, data }, }, collectibleContracts, totalGas, @@ -267,9 +267,9 @@ function getCollectibleTransfer(args) { export function decodeIncomingTransfer(args) { const { tx: { - transaction: { to, from, value }, + txParams: { to, from, value }, transferInformation: { symbol, decimals, contractAddress }, - transactionHash, + hash, }, conversionRate, currentCurrency, @@ -324,7 +324,7 @@ export function decodeIncomingTransfer(args) { renderValue: renderToken, renderFrom: renderFullAddress(from), renderTo: renderFullAddress(to), - transactionHash, + hash, transactionType, }; if (primaryCurrency === 'ETH') { @@ -375,9 +375,9 @@ export function decodeIncomingTransfer(args) { async function decodeTransferTx(args) { const { tx: { - transaction, - transaction: { from, gas, data, to }, - transactionHash, + txParams, + txParams: { from, gas, data, to }, + hash, }, } = args; @@ -390,9 +390,9 @@ async function decodeTransferTx(args) { // } - const totalGas = calculateTotalGas(transaction); + const totalGas = calculateTotalGas(txParams); const renderGas = parseInt(gas, 16).toString(); - const renderGasPrice = renderGwei(transaction); + const renderGasPrice = renderGwei(txParams); let [transactionElement, transactionDetails] = isCollectible ? getCollectibleTransfer({ ...args, totalGas }) : getTokenTransfer({ ...args, totalGas }); @@ -402,7 +402,7 @@ async function decodeTransferTx(args) { ...{ renderFrom: renderFullAddress(from), renderTo: renderFullAddress(addressTo), - transactionHash, + hash, renderGas, renderGasPrice, }, @@ -413,9 +413,9 @@ async function decodeTransferTx(args) { function decodeTransferFromTx(args) { const { tx: { - transaction, - transaction: { gas, data, to }, - transactionHash, + txParams, + txParams: { gas, data, to }, + hash, }, collectibleContracts, conversionRate, @@ -435,7 +435,7 @@ function decodeTransferFromTx(args) { actionKey = `${strings('transactions.sent')} ${collectible.name}`; } - const totalGas = calculateTotalGas(transaction); + const totalGas = calculateTotalGas(txParams); const renderCollectible = collectible?.symbol ? `${strings('unit.token_id')}${tokenId} ${collectible?.symbol}` : `${strings('unit.token_id')}${tokenId}`; @@ -451,10 +451,10 @@ function decodeTransferFromTx(args) { let transactionDetails = { renderFrom, renderTo, - transactionHash, + hash, renderValue: renderCollectible, renderGas: parseInt(gas, 16).toString(), - renderGasPrice: renderGwei(transaction), + renderGasPrice: renderGwei(txParams), renderTotalGas: `${renderFromWei(totalGas)} ${ticker}`, }; @@ -501,9 +501,9 @@ function decodeTransferFromTx(args) { function decodeDeploymentTx(args) { const { tx: { - transaction, - transaction: { value, gas, from }, - transactionHash, + txParams, + txParams: { value, gas, from }, + hash, }, conversionRate, currentCurrency, @@ -512,7 +512,7 @@ function decodeDeploymentTx(args) { } = args; const ticker = getTicker(args.ticker); - const totalGas = calculateTotalGas(transaction); + const totalGas = calculateTotalGas(txParams); const renderTotalEth = `${renderFromWei(totalGas)} ${ticker}`; const renderTotalEthFiat = weiToFiat( totalGas, @@ -536,10 +536,10 @@ function decodeDeploymentTx(args) { let transactionDetails = { renderFrom, renderTo, - transactionHash, + hash, renderValue: `${renderFromWei(value)} ${ticker}`, renderGas: parseInt(gas, 16).toString(), - renderGasPrice: renderGwei(transaction), + renderGasPrice: renderGwei(txParams), renderTotalGas: `${renderFromWei(totalGas)} ${ticker}`, }; @@ -571,9 +571,9 @@ function decodeDeploymentTx(args) { function decodeConfirmTx(args) { const { tx: { - transaction, - transaction: { value, gas, from, to }, - transactionHash, + txParams, + txParams: { value, gas, from, to }, + hash, }, conversionRate, currentCurrency, @@ -591,7 +591,7 @@ function decodeConfirmTx(args) { currentCurrency, ); - const totalGas = calculateTotalGas(transaction); + const totalGas = calculateTotalGas(txParams); const totalValue = isBN(totalEth) ? totalEth.add(totalGas) : totalGas; const renderFrom = renderFullAddress(from); @@ -628,10 +628,10 @@ function decodeConfirmTx(args) { let transactionDetails = { renderFrom, renderTo, - transactionHash, + hash, renderValue: `${renderFromWei(value)} ${ticker}`, renderGas: parseInt(gas, 16).toString(), - renderGasPrice: renderGwei(transaction), + renderGasPrice: renderGwei(txParams), renderTotalGas: `${renderFromWei(totalGas)} ${ticker}`, transactionType, }; @@ -673,9 +673,9 @@ function decodeSwapsTx(args) { primaryCurrency, tx: { id, - transaction, - transaction: { gas, from, to }, - transactionHash, + txParams, + txParams: { gas, from, to }, + hash, }, tx, contractExchangeRates, @@ -683,7 +683,7 @@ function decodeSwapsTx(args) { } = args; const swapTransaction = (swapsTransactions && swapsTransactions[id]) || {}; const totalGas = calculateTotalGas({ - ...transaction, + ...txParams, gas: swapTransaction.gasUsed || gas, }); const sourceToken = swapsTokens?.find( @@ -811,12 +811,12 @@ function decodeSwapsTx(args) { let transactionDetails = { renderFrom, renderTo, - transactionHash, + hash, renderValue: decimalSourceAmount ? `${decimalSourceAmount} ${sourceToken.symbol}` : `0 ${ticker}`, renderGas: parseInt(gas, 16), - renderGasPrice: renderGwei(transaction), + renderGasPrice: renderGwei(txParams), renderTotalGas: `${totalEthGas} ${ticker}`, }; @@ -865,7 +865,7 @@ export default async function decodeTransaction(args) { let transactionElement, transactionDetails; if ( - tx.transaction.to?.toLowerCase() === getSwapsContractAddress(chainId) || + tx.txParams.to?.toLowerCase() === getSwapsContractAddress(chainId) || swapsTransactions[tx.id] ) { const [transactionElement, transactionDetails] = decodeSwapsTx({ diff --git a/app/components/UI/TransactionElement/utils.test.js b/app/components/UI/TransactionElement/utils.test.js index 480582eb7d7a..d4a251629d3f 100644 --- a/app/components/UI/TransactionElement/utils.test.js +++ b/app/components/UI/TransactionElement/utils.test.js @@ -4,7 +4,7 @@ describe('decodeIncomingTransfer', () => { // Arrange const args = { tx: { - transaction: { + txParams: { to: '0x77648f1407986479fb1fa5cc3597084b5dbdb057', from: '0x1440ec793ae50fa046b95bfeca5af475b6003f9e', value: '52daf0', @@ -14,8 +14,7 @@ describe('decodeIncomingTransfer', () => { decimals: 6, contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', }, - transactionHash: - '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', + hash: '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', }, currentCurrency: 'usd', contractExchangeRates: {}, @@ -45,8 +44,7 @@ describe('decodeIncomingTransfer', () => { renderValue: '5.43 USDT', renderFrom: '0x1440ec793aE50fA046B95bFeCa5aF475b6003f9e', renderTo: '0x77648F1407986479fb1fA5Cc3597084B5dbDB057', - transactionHash: - '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', + hash: '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', transactionType: 'transaction_received_token', summaryAmount: '5.43 USDT', summaryFee: '< 0.00001 ETH', @@ -59,7 +57,7 @@ describe('decodeIncomingTransfer', () => { // Arrange const args = { tx: { - transaction: { + txParams: { to: '0x77648f1407986479fb1fa5cc3597084b5dbdb057', from: '0x1440ec793ae50fa046b95bfeca5af475b6003f9e', value: '3B9ACA00', // 1000000000 in decimal @@ -69,8 +67,7 @@ describe('decodeIncomingTransfer', () => { decimals: 6, contractAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', }, - transactionHash: - '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', + hash: '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', }, currentCurrency: 'usd', contractExchangeRates: {}, @@ -100,8 +97,7 @@ describe('decodeIncomingTransfer', () => { renderValue: '1000 USDT', renderFrom: '0x1440ec793aE50fA046B95bFeCa5aF475b6003f9e', renderTo: '0x77648F1407986479fb1fA5Cc3597084B5dbDB057', - transactionHash: - '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', + hash: '0x942d7843454266b81bf631022aa5f3f944691731b62d67c4e80c4bb5740058bb', transactionType: 'transaction_received_token', summaryAmount: '1000 USDT', summaryFee: '< 0.00001 ETH', diff --git a/app/components/UI/Transactions/__snapshots__/index.test.tsx.snap b/app/components/UI/Transactions/__snapshots__/index.test.tsx.snap index ad5c7d060f27..af217f5255f7 100644 --- a/app/components/UI/Transactions/__snapshots__/index.test.tsx.snap +++ b/app/components/UI/Transactions/__snapshots__/index.test.tsx.snap @@ -38,11 +38,12 @@ exports[`Transactions should render correctly 1`] = ` [ { "blockNumber": "5108051", + "hash": "0x79ce2d56aaa4735b2bb602ae3a501d9055350a6ec3fb3bd457ba18e8fa4aa2ae", "id": "95305900-3b10-11e9-af59-6f4c0e36ce5f", "networkID": "3", "status": "confirmed", "time": 1551327802000, - "transaction": { + "txParams": { "data": "0x", "from": "0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23", "gas": "0x5208", @@ -51,7 +52,6 @@ exports[`Transactions should render correctly 1`] = ` "to": "0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1", "value": "0xfa1c6d5030000", }, - "transactionHash": "0x79ce2d56aaa4735b2bb602ae3a501d9055350a6ec3fb3bd457ba18e8fa4aa2ae", }, ] } diff --git a/app/components/UI/Transactions/index.js b/app/components/UI/Transactions/index.js index 45f2cc0d2068..97f6ed5829d6 100644 --- a/app/components/UI/Transactions/index.js +++ b/app/components/UI/Transactions/index.js @@ -697,7 +697,7 @@ class Transactions extends PureComponent { contentContainerStyle={styles.keyboardAwareWrapper} > { networkID: '3', status: 'confirmed', time: 1551327802000, - transaction: { + txParams: { data: '0x', from: '0xb2d191b6fe03c5b8a1ab249cfe88c37553357a23', gas: '0x5208', @@ -37,8 +37,7 @@ describe('Transactions', () => { to: '0xe46abaf75cfbff815c0b7ffed6f02b0760ea27f1', value: '0xfa1c6d5030000', }, - transactionHash: - '0x79ce2d56aaa4735b2bb602ae3a501d9055350a6ec3fb3bd457ba18e8fa4aa2ae', + hash: '0x79ce2d56aaa4735b2bb602ae3a501d9055350a6ec3fb3bd457ba18e8fa4aa2ae', }, ]} loading={false} diff --git a/app/components/Views/Asset/index.js b/app/components/Views/Asset/index.js index 20c8a172d99e..8db88541c212 100644 --- a/app/components/Views/Asset/index.js +++ b/app/components/Views/Asset/index.js @@ -278,7 +278,7 @@ class Asset extends PureComponent { const { networkId } = store.getState().inpageProvider; const { selectedAddress, chainId } = this.props; const { - transaction: { from, to }, + txParams: { from, to }, isTransfer, transferInformation, } = tx; @@ -303,7 +303,7 @@ class Asset extends PureComponent { const { chainId, swapsTransactions, selectedAddress } = this.props; const { - transaction: { to, from }, + txParams: { to, from }, isTransfer, transferInformation, } = tx; @@ -377,7 +377,7 @@ class Asset extends PureComponent { return filterResult; }); - submittedTxs = submittedTxs.filter(({ transaction: { from, nonce } }) => { + submittedTxs = submittedTxs.filter(({ txParams: { from, nonce } }) => { if (!toLowerCaseEquals(from, selectedAddress)) { return false; } @@ -385,9 +385,9 @@ class Asset extends PureComponent { const alreadyConfirmed = confirmedTxs.find( (confirmedTransaction) => toLowerCaseEquals( - safeToChecksumAddress(confirmedTransaction.transaction.from), + safeToChecksumAddress(confirmedTransaction.txParams.from), selectedAddress, - ) && confirmedTransaction.transaction.nonce === nonce, + ) && confirmedTransaction.txParams.nonce === nonce, ); if (alreadyConfirmed) { return false; diff --git a/app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx b/app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx index 416868684cfe..12c925eb0633 100644 --- a/app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx +++ b/app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx @@ -902,7 +902,7 @@ const Settings: React.FC = () => { key={chainId} variant={CellVariant.Display} title={name} - secondaryText={myNetworks[chainId].domain} + secondaryText={myNetworks[chainId]?.domain} avatarProps={{ variant: AvatarVariant.Network, name, diff --git a/app/components/Views/TransactionsView/index.js b/app/components/Views/TransactionsView/index.js index a304952da703..5c31b2d9bf71 100644 --- a/app/components/Views/TransactionsView/index.js +++ b/app/components/Views/TransactionsView/index.js @@ -110,8 +110,8 @@ const TransactionsView = ({ return filter; }); - const submittedTxsFiltered = submittedTxs.filter(({ transaction }) => { - const { from, nonce } = transaction; + const submittedTxsFiltered = submittedTxs.filter(({ txParams }) => { + const { from, nonce } = txParams; if (!toLowerCaseEquals(from, selectedAddress)) { return false; } @@ -119,9 +119,9 @@ const TransactionsView = ({ const alreadyConfirmed = confirmedTxs.find( (tx) => toLowerCaseEquals( - safeToChecksumAddress(tx.transaction.from), + safeToChecksumAddress(tx.txParams.from), selectedAddress, - ) && tx.transaction.nonce === nonce, + ) && tx.txParams.nonce === nonce, ); if (alreadyConfirmed) { return false; diff --git a/app/components/Views/confirmations/Approval/index.js b/app/components/Views/confirmations/Approval/index.js index 7df6611a41fa..88051521fd0f 100644 --- a/app/components/Views/confirmations/Approval/index.js +++ b/app/components/Views/confirmations/Approval/index.js @@ -399,6 +399,7 @@ class Approval extends PureComponent { transactions, transaction: { assetType, selectedAsset }, showCustomNonce, + chainId, } = this.props; let { transaction } = this.props; const { nonce } = transaction; @@ -453,7 +454,16 @@ class Approval extends PureComponent { ); const fullTx = transactions.find(({ id }) => id === transaction.id); - const updatedTx = { ...fullTx, transaction }; + + const updatedTx = { + ...fullTx, + txParams: { + ...fullTx.txParams, + ...transaction, + chainId, + }, + }; + await updateTransaction(updatedTx); await KeyringController.resetQRKeyringState(); diff --git a/app/components/Views/confirmations/ApproveView/Approve/index.js b/app/components/Views/confirmations/ApproveView/Approve/index.js index 7b380aef049d..7d4f5a9008fa 100644 --- a/app/components/Views/confirmations/ApproveView/Approve/index.js +++ b/app/components/Views/confirmations/ApproveView/Approve/index.js @@ -500,7 +500,7 @@ class Approve extends PureComponent { onConfirm = async () => { const { TransactionController, KeyringController, ApprovalController } = Engine.context; - const { transactions, gasEstimateType, metrics } = this.props; + const { transactions, gasEstimateType, metrics, chainId } = this.props; const { legacyGasTransaction, transactionConfirmed, @@ -539,7 +539,15 @@ class Approve extends PureComponent { ); const fullTx = transactions.find(({ id }) => id === transaction.id); - const updatedTx = { ...fullTx, transaction }; + + const updatedTx = { + ...fullTx, + txParams: { + ...fullTx.txParams, + ...transaction, + chainId, + }, + }; await updateTransaction(updatedTx); await KeyringController.resetQRKeyringState(); diff --git a/app/components/Views/confirmations/SendFlow/Confirm/index.js b/app/components/Views/confirmations/SendFlow/Confirm/index.js index ceaa7b045876..9a0cc5f0a888 100644 --- a/app/components/Views/confirmations/SendFlow/Confirm/index.js +++ b/app/components/Views/confirmations/SendFlow/Confirm/index.js @@ -842,8 +842,6 @@ class Confirm extends PureComponent { ExtendedKeyringTypes.ledger, ]); - await this.persistTransactionParameters(transaction); - if (isLedgerAccount) { const ledgerKeyring = await getLedgerKeyring(); this.setState({ transactionConfirmed: false }); @@ -1150,9 +1148,14 @@ class Confirm extends PureComponent { (tx) => tx.id === transactionId, ); - controllerTransactionMeta.transaction = transactionParams; - - await updateTransaction(controllerTransactionMeta); + const updatedTx = { + ...controllerTransactionMeta, + txParams: { + ...transactionParams, + chainId: controllerTransactionMeta.chainId, + }, + }; + await updateTransaction(updatedTx); } render = () => { diff --git a/app/core/Engine.ts b/app/core/Engine.ts index ce41845b67a5..f88ca8215e29 100644 --- a/app/core/Engine.ts +++ b/app/core/Engine.ts @@ -1093,13 +1093,15 @@ class Engine { // @ts-expect-error at this point in time the provider will be defined by the `networkController.initializeProvider` blockTracker: networkController.getProviderAndBlockTracker().blockTracker, + disableSendFlowHistory: true, + disableHistory: true, getGasFeeEstimates: () => gasFeeController.fetchGasFeeEstimates(), - //@ts-expect-error TransactionController needs to be updated to v13 for this error disappears + getCurrentNetworkEIP1559Compatibility: + networkController.getEIP1559Compatibility.bind(networkController), getNetworkState: () => networkController.state, getSelectedAddress: () => accountsController.getSelectedAccount().address, incomingTransactions: { - apiKey: process.env.MM_ETHERSCAN_KEY, isEnabled: () => { const currentHexChainId = networkController.state.providerConfig.chainId; @@ -1126,7 +1128,6 @@ class Engine { onNetworkStateChange: (listener) => this.controllerMessenger.subscribe( AppConstants.NETWORK_STATE_CHANGE_EVENT, - //@ts-expect-error TransactionController needs to be updated to v13 for this error disappears listener, ), // @ts-expect-error at this point in time the provider will be defined by the `networkController.initializeProvider` diff --git a/app/core/NotificationManager.js b/app/core/NotificationManager.js index 1cdcbd67587a..bf29f74f4cb5 100644 --- a/app/core/NotificationManager.js +++ b/app/core/NotificationManager.js @@ -169,7 +169,7 @@ class NotificationManager { // If it fails we hide the pending tx notification this._removeNotificationById(transactionMeta.id); const transaction = - this._transactionsWatchTable[transactionMeta.transaction.nonce]; + this._transactionsWatchTable[transactionMeta.txParams.nonce]; transaction && transaction.length && setTimeout(() => { @@ -182,14 +182,14 @@ class NotificationManager { }); // Clean up this._removeListeners(transactionMeta.id); - delete this._transactionsWatchTable[transactionMeta.transaction.nonce]; + delete this._transactionsWatchTable[transactionMeta.txParams.nonce]; }, 2000); }; _confirmedCallback = (transactionMeta, originalTransaction) => { // Once it's confirmed we hide the pending tx notification this._removeNotificationById(transactionMeta.id); - this._transactionsWatchTable[transactionMeta.transaction.nonce].length && + this._transactionsWatchTable[transactionMeta.txParams.nonce].length && setTimeout(() => { // Then we show the success notification this._showNotification({ @@ -197,7 +197,7 @@ class NotificationManager { autoHide: true, transaction: { id: transactionMeta.id, - nonce: `${hexToBN(transactionMeta.transaction.nonce).toString()}`, + nonce: `${hexToBN(transactionMeta.txParams.nonce).toString()}`, }, duration: 5000, }); @@ -240,7 +240,7 @@ class NotificationManager { ReviewManager.promptReview(); this._removeListeners(transactionMeta.id); - delete this._transactionsWatchTable[transactionMeta.transaction.nonce]; + delete this._transactionsWatchTable[transactionMeta.txParams.nonce]; }, 2000); }; @@ -252,7 +252,7 @@ class NotificationManager { type: 'speedup', transaction: { id: transactionMeta.id, - nonce: `${hexToBN(transactionMeta.transaction.nonce).toString()}`, + nonce: `${hexToBN(transactionMeta.txParams.nonce).toString()}`, }, }); }, 2000); @@ -331,20 +331,24 @@ class NotificationManager { watchSubmittedTransaction(transaction, speedUp = false) { if (transaction.silent) return false; const { TransactionController } = Engine.context; - const nonce = transaction.transaction.nonce; + const transactionMeta = TransactionController.state.transactions.find( + ({ id }) => id === transaction.id, + ); + + const nonce = transactionMeta.txParams.nonce; // First we show the pending tx notification if is not an speed up tx !speedUp && this._showNotification({ type: 'pending', autoHide: false, transaction: { - id: transaction.id, + id: transactionMeta.id, }, }); this._transactionsWatchTable[nonce] - ? this._transactionsWatchTable[nonce].push(transaction.id) - : (this._transactionsWatchTable[nonce] = [transaction.id]); + ? this._transactionsWatchTable[nonce].push(transactionMeta.id) + : (this._transactionsWatchTable[nonce] = [transactionMeta.id]); TransactionController.hub.once( `${transaction.id}:confirmed`, @@ -389,8 +393,8 @@ class NotificationManager { .reverse() .filter( (tx) => - safeToChecksumAddress(tx.transaction?.to) === selectedAddress && - safeToChecksumAddress(tx.transaction?.from) !== selectedAddress && + safeToChecksumAddress(tx.txParams?.to) === selectedAddress && + safeToChecksumAddress(tx.txParams?.from) !== selectedAddress && tx.chainId === chainId && tx.status === 'confirmed' && lastBlock <= parseInt(tx.blockNumber, 10) && @@ -400,8 +404,8 @@ class NotificationManager { this._showNotification({ type: 'received', transaction: { - nonce: `${hexToBN(txs[0].transaction.nonce).toString()}`, - amount: `${renderFromWei(hexToBN(txs[0].transaction.value))}`, + nonce: `${hexToBN(txs[0].txParams.nonce).toString()}`, + amount: `${renderFromWei(hexToBN(txs[0].txParams.value))}`, id: txs[0]?.id, assetType: strings('unit.eth'), }, diff --git a/app/core/RPCMethods/RPCMethodMiddleware.test.ts b/app/core/RPCMethods/RPCMethodMiddleware.test.ts index 70480f0f7ca2..0d18945def55 100644 --- a/app/core/RPCMethods/RPCMethodMiddleware.test.ts +++ b/app/core/RPCMethods/RPCMethodMiddleware.test.ts @@ -6,7 +6,7 @@ import { JsonRpcResponse, JsonRpcSuccess, } from 'json-rpc-engine'; -import type { Transaction } from '@metamask/transaction-controller'; +import type { TransactionParams } from '@metamask/transaction-controller'; import type { ProviderConfig } from '@metamask/network-controller'; import { providerErrors, rpcErrors } from '@metamask/rpc-errors'; import Engine from '../Engine'; @@ -830,7 +830,7 @@ describe('getRpcMethodMiddleware', () => { it('returns a JSON-RPC error if an error is thrown when adding this transaction', async () => { // Omit `from` and `chainId` here to skip validation for simplicity // Downcast needed here because `from` is required by this type - const mockTransactionParameters = {} as Transaction; + const mockTransactionParameters = {} as TransactionParams; // Transaction fails before returning a result mockAddTransaction.mockImplementation(async () => { throw new Error('Failed to add transaction'); @@ -858,7 +858,7 @@ describe('getRpcMethodMiddleware', () => { it('returns a JSON-RPC error if an error is thrown after approval', async () => { // Omit `from` and `chainId` here to skip validation for simplicity // Downcast needed here because `from` is required by this type - const mockTransactionParameters = {} as Transaction; + const mockTransactionParameters = {} as TransactionParams; setupGlobalState({ addTransactionResult: Promise.reject( new Error('Failed to process transaction'), diff --git a/app/core/RPCMethods/eth_sendTransaction.test.ts b/app/core/RPCMethods/eth_sendTransaction.test.ts index 60d652109b06..c1f064ffdba5 100644 --- a/app/core/RPCMethods/eth_sendTransaction.test.ts +++ b/app/core/RPCMethods/eth_sendTransaction.test.ts @@ -2,7 +2,7 @@ import { inspect } from 'util'; import type { JsonRpcRequest, PendingJsonRpcResponse } from 'json-rpc-engine'; import type { - Transaction, + TransactionParams, TransactionController, WalletDevice, } from '@metamask/transaction-controller'; @@ -99,7 +99,7 @@ function getMockAddTransaction({ return jest.fn().mockImplementation( async ( - transaction: Transaction, + transaction: TransactionParams, { origin, deviceConfirmedOn, diff --git a/app/store/migrations/029.ts b/app/store/migrations/029.ts index 7c0fe7aa3c81..e0b8041a8c19 100644 --- a/app/store/migrations/029.ts +++ b/app/store/migrations/029.ts @@ -5,7 +5,7 @@ import { regex } from '../../../app/util/regex'; //@ts-expect-error - This error is expected, but ethereumjs-util exports this function import { isHexString } from 'ethereumjs-util'; import { NetworkState } from '@metamask/network-controller'; -import { Transaction } from '@metamask/transaction-controller'; +import { TransactionParams } from '@metamask/transaction-controller'; import { captureException } from '@sentry/react-native'; import { AddressBookEntry, @@ -449,7 +449,7 @@ export default async function migrate(stateAsync: unknown) { // Transaction Controller transactions object chain id property to hexadecimal if (Array.isArray(transactionControllerState.transactions)) { transactionControllerState.transactions.forEach( - (transaction: Transaction, index: number) => { + (transaction: TransactionParams, index: number) => { if (transaction && !isHexString(transaction.chainId)) { if ( Array.isArray(transactionControllerState.transactions) && diff --git a/app/store/migrations/040.test.ts b/app/store/migrations/040.test.ts new file mode 100644 index 000000000000..96edf1802054 --- /dev/null +++ b/app/store/migrations/040.test.ts @@ -0,0 +1,160 @@ +import migrate from './040'; +import { merge } from 'lodash'; +import { captureException } from '@sentry/react-native'; +import initialRootState from '../../util/test/initial-root-state'; + +const expectedState = { + engine: { + backgroundState: { + TransactionController: { + transactions: [ + { + chainId: '0x5', + id: '1', + origin: 'test.com', + status: 'confirmed', + time: 1631714312, + txParams: { + from: '0x1', + }, + hash: '0x2', + rawTx: '0x3', + }, + { + chainId: '0x5', + id: '2', + origin: 'test.com', + status: 'confirmed', + time: 1631714312, + txParams: { + from: '0x1', + }, + hash: '0x2', + }, + { + chainId: '0x1', + id: '3', + origin: 'test2.com', + status: 'submitted', + time: 1631714313, + txParams: { + from: '0x6', + }, + hash: '0x4', + rawTx: '0x5', + }, + ], + }, + }, + }, +}; + +jest.mock('@sentry/react-native', () => ({ + captureException: jest.fn(), +})); +const mockedCaptureException = jest.mocked(captureException); + +describe('Migration #40', () => { + beforeEach(() => { + jest.restoreAllMocks(); + jest.resetAllMocks(); + }); + + const invalidStates = [ + { + state: null, + errorMessage: "Migration 40: Invalid state error: 'object'", + scenario: 'state is invalid', + }, + { + state: merge({}, initialRootState, { + engine: null, + }), + errorMessage: "Migration 40: Invalid engine state error: 'object'", + scenario: 'engine state is invalid', + }, + { + state: merge({}, initialRootState, { + engine: { + backgroundState: null, + }, + }), + errorMessage: + "Migration 40: Invalid engine backgroundState error: 'object'", + scenario: 'backgroundState is invalid', + }, + { + state: merge({}, initialRootState, { + engine: { + backgroundState: { TransactionController: null }, + }, + }), + errorMessage: "Migration 40: Invalid TransactionController state: 'null'", + scenario: 'transactionController is invalid', + }, + ]; + it.each(invalidStates)( + 'should capture exception if $scenario', + ({ errorMessage, state }) => { + const newState = migrate(state); + + expect(newState).toStrictEqual(state); + expect(mockedCaptureException).toHaveBeenCalledWith(expect.any(Error)); + expect(mockedCaptureException.mock.calls[0][0].message).toBe( + errorMessage, + ); + }, + ); + + it('apply migration, change property transaction, transactionHash and rawTransaction', () => { + const oldState = { + engine: { + backgroundState: { + TransactionController: { + transactions: [ + { + chainId: '0x5', + id: '1', + origin: 'test.com', + status: 'confirmed', + time: 1631714312, + transaction: { + from: '0x1', + }, + transactionHash: '0x2', + rawTransaction: '0x3', + }, + { + chainId: '0x5', + id: '2', + origin: 'test.com', + status: 'confirmed', + time: 1631714312, + transaction: { + from: '0x1', + }, + transactionHash: '0x2', + }, + { + chainId: '0x1', + id: '3', + origin: 'test2.com', + status: 'submitted', + time: 1631714313, + transaction: { + from: '0x6', + }, + transactionHash: '0x4', + rawTransaction: '0x5', + }, + ], + }, + }, + }, + }; + + const newState = migrate(oldState); + + expect(newState).toStrictEqual(expectedState); + }); +}); diff --git a/app/store/migrations/040.ts b/app/store/migrations/040.ts new file mode 100644 index 000000000000..7ff92b9f2d6e --- /dev/null +++ b/app/store/migrations/040.ts @@ -0,0 +1,47 @@ +import { isObject } from '@metamask/utils'; +import { captureException } from '@sentry/react-native'; +import { ensureValidState } from './util'; + +export default function migrate(state: unknown) { + if (!ensureValidState(state, 40)) { + return state; + } + + if (!isObject(state.engine.backgroundState.TransactionController)) { + captureException( + new Error( + `Migration 40: Invalid TransactionController state: '${state.engine.backgroundState.TransactionController}'`, + ), + ); + return state; + } + + const transactionControllerState = + state.engine.backgroundState.TransactionController; + + if (!Array.isArray(transactionControllerState.transactions)) { + captureException( + new Error( + `Migration 40: Missing transactions property from TransactionController: '${typeof state + .engine.backgroundState.TransactionController}'`, + ), + ); + return state; + } + transactionControllerState.transactions.forEach((transaction: any) => { + if (transaction.rawTransaction) { + transaction.rawTx = transaction.rawTransaction; + delete transaction.rawTransaction; + } + if (transaction.transactionHash) { + transaction.hash = transaction.transactionHash; + delete transaction.transactionHash; + } + if (transaction.transaction) { + transaction.txParams = transaction.transaction; + delete transaction.transaction; + } + }); + + return state; +} diff --git a/app/store/migrations/index.ts b/app/store/migrations/index.ts index 084dde7f56c9..c6811fb13388 100644 --- a/app/store/migrations/index.ts +++ b/app/store/migrations/index.ts @@ -40,6 +40,7 @@ import migration36 from './036'; import migration37 from './037'; import migration38 from './038'; import migration39 from './039'; +import migration40 from './040'; type MigrationFunction = (state: unknown) => unknown; type AsyncMigrationFunction = (state: unknown) => Promise; @@ -92,6 +93,7 @@ export const migrationList: MigrationsList = { 37: migration37, 38: migration38, 39: migration39, + 40: migration40, }; // Enable both synchronous and asynchronous migrations diff --git a/app/util/activity/index.test.ts b/app/util/activity/index.test.ts index 4a30805ffe95..773aee170287 100644 --- a/app/util/activity/index.test.ts +++ b/app/util/activity/index.test.ts @@ -14,14 +14,14 @@ const MAKER_ADDRESS = '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2'; describe('Activity utils :: isFromOrToSelectedAddress', () => { const tx = { - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, }; it('should return true if the transaction is from the selected address', () => { const { - transaction: { from, to }, + txParams: { from, to }, } = tx; const selectedAddress = TEST_ADDRESS_ONE; const result = isFromOrToSelectedAddress(from, to, selectedAddress); @@ -29,7 +29,7 @@ describe('Activity utils :: isFromOrToSelectedAddress', () => { }); it('should return true if the transaction is to the selected address', () => { const { - transaction: { from, to }, + txParams: { from, to }, } = tx; const selectedAddress = TEST_ADDRESS_TWO; const result = isFromOrToSelectedAddress(from, to, selectedAddress); @@ -37,7 +37,7 @@ describe('Activity utils :: isFromOrToSelectedAddress', () => { }); it('should return false if the transaction is not from nor to the selected address', () => { const { - transaction: { from, to }, + txParams: { from, to }, } = tx; const selectedAddress = TEST_ADDRESS_THREE; const result = isFromOrToSelectedAddress(from, to, selectedAddress); @@ -45,7 +45,7 @@ describe('Activity utils :: isFromOrToSelectedAddress', () => { }); it('should return false if no address is provided', () => { const { - transaction: { from, to }, + txParams: { from, to }, } = tx; const selectedAddress = ''; const result = isFromOrToSelectedAddress(from, to, selectedAddress); @@ -103,7 +103,7 @@ describe('Activity utils :: filterByAddressAndNetwork', () => { const transaction = { chainId, status: TX_SUBMITTED, - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, @@ -126,7 +126,7 @@ describe('Activity utils :: filterByAddressAndNetwork', () => { const transaction = { chainId, status: TX_SUBMITTED, - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, @@ -151,7 +151,7 @@ describe('Activity utils :: filterByAddressAndNetwork', () => { const transaction = { chainId, status: TX_SUBMITTED, - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, @@ -174,7 +174,7 @@ describe('Activity utils :: filterByAddressAndNetwork', () => { const transaction = { chainId: '4', status: TX_SUBMITTED, - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, @@ -197,7 +197,7 @@ describe('Activity utils :: filterByAddressAndNetwork', () => { const transaction = { chainId: '4', status: TX_SUBMITTED, - transaction: { + txParams: { from: TEST_ADDRESS_ONE, to: TEST_ADDRESS_TWO, }, diff --git a/app/util/activity/index.ts b/app/util/activity/index.ts index 6df4d83db88a..97fc39b0cf92 100644 --- a/app/util/activity/index.ts +++ b/app/util/activity/index.ts @@ -60,7 +60,7 @@ export const filterByAddressAndNetwork = ( chainId: string, ): boolean => { const { - transaction: { from, to }, + txParams: { from, to }, isTransfer, transferInformation, } = tx; diff --git a/app/util/transaction-controller/index.ts b/app/util/transaction-controller/index.ts index 810c4bd6e9da..34d52c607761 100644 --- a/app/util/transaction-controller/index.ts +++ b/app/util/transaction-controller/index.ts @@ -1,5 +1,5 @@ import { - Transaction, + TransactionParams, TransactionController as BaseTransactionController, } from '@metamask/transaction-controller'; @@ -7,7 +7,7 @@ import Engine from '../../core/Engine'; // Keeping this export as function to put more logic in the future export async function addTransaction( - transaction: Transaction, + transaction: TransactionParams, opts: Parameters[1], ) { const { TransactionController } = Engine.context; @@ -16,7 +16,7 @@ export async function addTransaction( } // Keeping this export as function to put more logic in the future -export async function estimateGas(transaction: Transaction) { +export async function estimateGas(transaction: TransactionParams) { const { TransactionController } = Engine.context; return await TransactionController.estimateGas(transaction); diff --git a/app/util/transactions/index.js b/app/util/transactions/index.js index 8f8afb612389..a3ca0333c6a8 100644 --- a/app/util/transactions/index.js +++ b/app/util/transactions/index.js @@ -337,7 +337,11 @@ export async function isCollectibleAddress(address, tokenId) { * @returns {string} - Corresponding transaction action key */ export async function getTransactionActionKey(transaction, chainId) { - const { transaction: { data, to } = {} } = transaction; + // This condition is needed until the transaction reducer be refactored + if (!transaction.txParams) { + transaction.txParams = transaction.transaction; + } + const { txParams: { data, to } = {} } = transaction; if (!to) return CONTRACT_METHOD_DEPLOY; if (to === getSwapsContractAddress(chainId)) return SWAPS_TRANSACTION_ACTION_KEY; @@ -384,11 +388,9 @@ export async function getActionKey(tx, selectedAddress, ticker, chainId) { currencySymbol = tx.transferInformation.symbol; } - const incoming = - safeToChecksumAddress(tx.transaction.to) === selectedAddress; + const incoming = safeToChecksumAddress(tx.txParams.to) === selectedAddress; const selfSent = - incoming && - safeToChecksumAddress(tx.transaction.from) === selectedAddress; + incoming && safeToChecksumAddress(tx.txParams.from) === selectedAddress; return incoming ? selfSent ? currencySymbol @@ -503,6 +505,7 @@ export function addAccountTimeFlagFilter( ); } +//Leaving here a comment to re-visit this function since it's probably be possible to deprecate export function getNormalizedTxState(state) { return state.transaction ? { ...state.transaction, ...state.transaction.transaction } diff --git a/app/util/transactions/index.test.ts b/app/util/transactions/index.test.ts index 92e7f35ca480..fe9206c2e424 100644 --- a/app/util/transactions/index.test.ts +++ b/app/util/transactions/index.test.ts @@ -302,7 +302,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be "Sent Yourself Ether"', async () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS1, }, @@ -319,7 +319,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Sent Yourself UNI"', async () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS1, }, @@ -338,7 +338,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Sent Ether"', async () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS2, }, @@ -356,7 +356,7 @@ describe('Transactions utils :: getActionKey', () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS2, }, @@ -376,7 +376,7 @@ describe('Transactions utils :: getActionKey', () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS2, }, @@ -393,7 +393,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Received UNI"', async () => { spyOnQueryMethod(undefined); const tx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS2, }, @@ -412,7 +412,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Smart Contract Interaction" if the receiver is a smart contract', async () => { spyOnQueryMethod(UNI_ADDRESS); const tx = { - transaction: { + txParams: { to: UNI_ADDRESS, }, }; @@ -428,7 +428,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Smart Contract Interaction" if the tx is to a smart contract', async () => { spyOnQueryMethod(UNI_ADDRESS); const tx = { - transaction: { + txParams: { to: UNI_ADDRESS, }, toSmartContract: true, @@ -445,7 +445,7 @@ describe('Transactions utils :: getActionKey', () => { it('should be labeled as "Contract Deployment" if the tx has no receiver', async () => { spyOnQueryMethod(UNI_ADDRESS); const tx = { - transaction: {}, + txParams: {}, toSmartContract: true, }; const result = await getActionKey( @@ -461,7 +461,7 @@ describe('Transactions utils :: getActionKey', () => { describe('Transactions utils :: generateTxWithNewTokenAllowance', () => { const mockDecimal = 18; const mockTx = { - transaction: { + txParams: { from: MOCK_ADDRESS1, to: MOCK_ADDRESS3, }, diff --git a/package.json b/package.json index c6afebe7cd4a..c48bd2d14c38 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "check-template-and-add-labels": "ts-node ./.github/scripts/check-template-and-add-labels.ts", "patch:tx": "./scripts/patch-transaction-controller.sh", "patch:assets": "./scripts/patch-assets-controllers.sh", + "patch:approval": "./scripts/patch-approval-controller.sh", "storybook-generate": "sb-rn-get-stories", "storybook-watch": "sb-rn-watcher" }, @@ -137,7 +138,7 @@ "@ledgerhq/react-native-hw-transport-ble": "^6.32.3", "@metamask/accounts-controller": "^11.0.0", "@metamask/address-book-controller": "^3.0.0", - "@metamask/approval-controller": "3.5.0", + "@metamask/approval-controller": "^3.5.2", "@metamask/assets-controllers": "^18.0.0", "@metamask/base-controller": "^4.1.1", "@metamask/composable-controller": "^3.0.0", @@ -173,7 +174,7 @@ "@metamask/snaps-utils": "^6.0.0", "@metamask/swappable-obj-proxy": "^2.1.0", "@metamask/swaps-controller": "^6.9.3", - "@metamask/transaction-controller": "8.0.1", + "@metamask/transaction-controller": "^13.0.0", "@metamask/utils": "^8.1.0", "@ngraveio/bc-ur": "^1.1.6", "@notifee/react-native": "^7.8.2", diff --git a/patches/@metamask+approval-controller+3.5.0.patch b/patches/@metamask+approval-controller+3.5.0.patch deleted file mode 100644 index a8e1eb9f1861..000000000000 --- a/patches/@metamask+approval-controller+3.5.0.patch +++ /dev/null @@ -1,94 +0,0 @@ -diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts -index 32f61cb..4e4d7a1 100644 ---- a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts -+++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts -@@ -99,6 +99,12 @@ export declare type AcceptOptions = { - * If false or unspecified, the promise will resolve immediately. - */ - waitForResult?: boolean; -+ /** -+ * Whether to delete the approval request after a result callback is called. -+ * If false or unspecified, the approval request will be deleted immediately. -+ * Ignored if `waitForResult` is false or unspecified. -+ */ -+ deleteAfterResult?: boolean; - }; - export declare type StartFlowOptions = OptionalField; - export declare type EndFlowOptions = Pick; -diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.js b/node_modules/@metamask/approval-controller/dist/ApprovalController.js -index 3709ab3..43c8bb9 100644 ---- a/node_modules/@metamask/approval-controller/dist/ApprovalController.js -+++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.js -@@ -19,7 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( - 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 _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_deleteApprovalAndGetCallbacks, _ApprovalController_result; -+var _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_getCallbacks, _ApprovalController_result; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.ApprovalController = exports.APPROVAL_TYPE_RESULT_SUCCESS = exports.APPROVAL_TYPE_RESULT_ERROR = exports.ORIGIN_METAMASK = void 0; - const base_controller_1 = require("@metamask/base-controller"); -@@ -227,7 +227,12 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { - accept(id, value, options) { - // Safe to cast as the delete method below will throw if the ID is not found - const approval = this.get(id); -- const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id); -+ const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); -+ let requestDeleted = false; -+ if (!(options === null || options === void 0 ? void 0 : options.deleteAfterResult) || !options.waitForResult) { -+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); -+ requestDeleted = true; -+ } - return new Promise((resolve, reject) => { - const resultCallbacks = { - success: (acceptValue) => resolve({ value: acceptValue }), -@@ -245,6 +250,10 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { - if (!(options === null || options === void 0 ? void 0 : options.waitForResult)) { - resolve({ value: undefined }); - } -+ }).finally(() => { -+ if (!requestDeleted) { -+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); -+ } - }); - } - /** -@@ -255,7 +264,9 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { - * @param error - The error to reject the approval promise with. - */ - reject(id, error) { -- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id).reject(error); -+ const callbacks = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); -+ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); -+ callbacks.reject(error); - } - /** - * Rejects and deletes all approval requests. -@@ -441,10 +452,10 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new - draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; - }); - }, _ApprovalController_delete = function _ApprovalController_delete(id) { -+ if (!__classPrivateFieldGet(this, _ApprovalController_approvals, "f").has(id)) { -+ throw new errors_1.ApprovalRequestNotFoundError(id); -+ } - __classPrivateFieldGet(this, _ApprovalController_approvals, "f").delete(id); -- // This method is only called after verifying that the approval with the -- // specified id exists. -- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const { origin, type } = this.state.pendingApprovals[id]; - const originMap = __classPrivateFieldGet(this, _ApprovalController_origins, "f").get(origin); - const originTotalCount = this.getApprovalCount({ origin }); -@@ -459,12 +470,11 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new - delete draftState.pendingApprovals[id]; - draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; - }); --}, _ApprovalController_deleteApprovalAndGetCallbacks = function _ApprovalController_deleteApprovalAndGetCallbacks(id) { -+ }, _ApprovalController_getCallbacks = function _ApprovalController_getCallbacks(id) { - const callbacks = __classPrivateFieldGet(this, _ApprovalController_approvals, "f").get(id); - if (!callbacks) { - throw new errors_1.ApprovalRequestNotFoundError(id); - } -- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); - return callbacks; - }, _ApprovalController_result = function _ApprovalController_result(type, opts, requestData) { - return __awaiter(this, void 0, void 0, function* () { diff --git a/patches/@metamask+approval-controller+3.5.2.patch b/patches/@metamask+approval-controller+3.5.2.patch new file mode 100644 index 000000000000..65ea2e95d027 --- /dev/null +++ b/patches/@metamask+approval-controller+3.5.2.patch @@ -0,0 +1,155 @@ +diff --git a/node_modules/@metamask/approval-controller/dist/.patch.txt b/node_modules/@metamask/approval-controller/dist/.patch.txt +new file mode 100644 +index 0000000..550de56 +--- /dev/null ++++ b/node_modules/@metamask/approval-controller/dist/.patch.txt +@@ -0,0 +1,7 @@ ++PATCH GENERATED FROM MetaMask/core branch: patch/mobile-approval-controller-3-5-2 ++This patch backports various transaction controller features from the main branch of MetaMask/core ++Steps to update patch: ++* Create a new core branch from: patch/mobile-approval-controller-3-5-2 ++* Run "yarn build" in the core monorepo ++* Run "yarn patch:approval " in the mobile repo ++* Once the new patch is merged, add your changes to: patch/mobile-approval-controller-3-5-2 +diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts +index 32f61cb..4e4d7a1 100644 +--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts ++++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts +@@ -99,6 +99,12 @@ export declare type AcceptOptions = { + * If false or unspecified, the promise will resolve immediately. + */ + waitForResult?: boolean; ++ /** ++ * Whether to delete the approval request after a result callback is called. ++ * If false or unspecified, the approval request will be deleted immediately. ++ * Ignored if `waitForResult` is false or unspecified. ++ */ ++ deleteAfterResult?: boolean; + }; + export declare type StartFlowOptions = OptionalField; + export declare type EndFlowOptions = Pick; +diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts.map b/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts.map +deleted file mode 100644 +index 1c9cfb4..0000000 +--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"ApprovalController.d.ts","sourceRoot":"","sources":["../src/ApprovalController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,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EAAE,EAAE,cAAc;IAmB9B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,yBAAyB;IAcjE;;;;;;;;OAQG;IACG,OAAO,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQhE;;;;;;;;OAQG;IACG,KAAK,CAAC,IAAI,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;CAoO3D;AAED,eAAe,kBAAkB,CAAC"} +\ No newline at end of file +diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.js b/node_modules/@metamask/approval-controller/dist/ApprovalController.js +index 3709ab3..89f57c3 100644 +--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.js ++++ b/node_modules/@metamask/approval-controller/dist/ApprovalController.js +@@ -19,7 +19,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( + 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 _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_deleteApprovalAndGetCallbacks, _ApprovalController_result; ++var _ApprovalController_instances, _ApprovalController_approvals, _ApprovalController_origins, _ApprovalController_showApprovalRequest, _ApprovalController_typesExcludedFromRateLimiting, _ApprovalController_add, _ApprovalController_validateAddParams, _ApprovalController_addPendingApprovalOrigin, _ApprovalController_addToStore, _ApprovalController_delete, _ApprovalController_getCallbacks, _ApprovalController_result; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ApprovalController = exports.APPROVAL_TYPE_RESULT_SUCCESS = exports.APPROVAL_TYPE_RESULT_ERROR = exports.ORIGIN_METAMASK = void 0; + const base_controller_1 = require("@metamask/base-controller"); +@@ -227,7 +227,12 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { + accept(id, value, options) { + // Safe to cast as the delete method below will throw if the ID is not found + const approval = this.get(id); +- const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id); ++ const requestPromise = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); ++ let requestDeleted = false; ++ if (!(options === null || options === void 0 ? void 0 : options.deleteAfterResult) || !options.waitForResult) { ++ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); ++ requestDeleted = true; ++ } + return new Promise((resolve, reject) => { + const resultCallbacks = { + success: (acceptValue) => resolve({ value: acceptValue }), +@@ -245,6 +250,10 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { + if (!(options === null || options === void 0 ? void 0 : options.waitForResult)) { + resolve({ value: undefined }); + } ++ }).finally(() => { ++ if (!requestDeleted) { ++ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); ++ } + }); + } + /** +@@ -255,7 +264,9 @@ class ApprovalController extends base_controller_1.BaseControllerV2 { + * @param error - The error to reject the approval promise with. + */ + reject(id, error) { +- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_deleteApprovalAndGetCallbacks).call(this, id).reject(error); ++ const callbacks = __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_getCallbacks).call(this, id); ++ __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); ++ callbacks.reject(error); + } + /** + * Rejects and deletes all approval requests. +@@ -441,10 +452,10 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new + draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; + }); + }, _ApprovalController_delete = function _ApprovalController_delete(id) { ++ if (!__classPrivateFieldGet(this, _ApprovalController_approvals, "f").has(id)) { ++ throw new errors_1.ApprovalRequestNotFoundError(id); ++ } + __classPrivateFieldGet(this, _ApprovalController_approvals, "f").delete(id); +- // This method is only called after verifying that the approval with the +- // specified id exists. +- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const { origin, type } = this.state.pendingApprovals[id]; + const originMap = __classPrivateFieldGet(this, _ApprovalController_origins, "f").get(origin); + const originTotalCount = this.getApprovalCount({ origin }); +@@ -459,12 +470,11 @@ _ApprovalController_approvals = new WeakMap(), _ApprovalController_origins = new + delete draftState.pendingApprovals[id]; + draftState.pendingApprovalCount = Object.keys(draftState.pendingApprovals).length; + }); +-}, _ApprovalController_deleteApprovalAndGetCallbacks = function _ApprovalController_deleteApprovalAndGetCallbacks(id) { ++}, _ApprovalController_getCallbacks = function _ApprovalController_getCallbacks(id) { + const callbacks = __classPrivateFieldGet(this, _ApprovalController_approvals, "f").get(id); + if (!callbacks) { + throw new errors_1.ApprovalRequestNotFoundError(id); + } +- __classPrivateFieldGet(this, _ApprovalController_instances, "m", _ApprovalController_delete).call(this, id); + return callbacks; + }, _ApprovalController_result = function _ApprovalController_result(type, opts, requestData) { + return __awaiter(this, void 0, void 0, function* () { +diff --git a/node_modules/@metamask/approval-controller/dist/ApprovalController.js.map b/node_modules/@metamask/approval-controller/dist/ApprovalController.js.map +deleted file mode 100644 +index 6235ddf..0000000 +--- a/node_modules/@metamask/approval-controller/dist/ApprovalController.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"ApprovalController.js","sourceRoot":"","sources":["../src/ApprovalController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,+DAA6D;AAG7D,mDAA2C;AAE3C,mCAAgC;AAEhC,qCAMkB;AAElB,YAAY;AAEZ,0CAA0C;AAC7B,QAAA,eAAe,GAAG,UAAU,CAAC;AAC7B,QAAA,0BAA0B,GAAG,cAAc,CAAC;AAC5C,QAAA,4BAA4B,GAAG,gBAAgB,CAAC;AAE7D,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,CAAC,gBAAgB,CAC5B,CAAC,MAAM,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC,iHAU8B,EAAU;IACvC,MAAM,SAAS,GAAG,uBAAA,IAAI,qCAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,qCAA4B,CAAC,EAAE,CAAC,CAAC;KAC5C;IAED,uBAAA,IAAI,iEAAQ,MAAZ,IAAI,EAAS,EAAE,CAAC,CAAC;IACjB,OAAO,SAAS,CAAC;AACnB,CAAC,mEAGC,IAAY,EACZ,IAAmB,EACnB,WAAiC;;QAEjC,IAAI;YACF,MAAM,IAAI,CAAC,yBAAyB,CAAC;gBACnC,MAAM,EAAE,uBAAe;gBACvB,IAAI;gBACJ,WAAW;aACZ,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;SACtD;gBAAS;YACR,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IAAI;oBACF,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;iBACtC;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;iBACnE;aACF;SACF;IACH,CAAC;;AAGH,kBAAe,kBAAkB,CAAC","sourcesContent":["import type { RestrictedControllerMessenger } from '@metamask/base-controller';\nimport { BaseControllerV2 } from '@metamask/base-controller';\nimport type { Json, OptionalField } from '@metamask/utils';\nimport type { EthereumRpcError } from 'eth-rpc-errors';\nimport { ethErrors } from 'eth-rpc-errors';\nimport type { Patch } from 'immer';\nimport { nanoid } from 'nanoid';\n\nimport {\n ApprovalRequestNotFoundError,\n ApprovalRequestNoResultSupportError,\n EndInvalidFlowError,\n NoApprovalFlowsError,\n MissingApprovalFlowError,\n} from './errors';\n\n// Constants\n\n// Avoiding dependency on controller-utils\nexport const ORIGIN_METAMASK = 'metamask';\nexport const APPROVAL_TYPE_RESULT_ERROR = 'result_error';\nexport const APPROVAL_TYPE_RESULT_SUCCESS = 'result_success';\n\nconst controllerName = 'ApprovalController';\n\nconst stateMetadata = {\n pendingApprovals: { persist: false, anonymous: true },\n pendingApprovalCount: { persist: false, anonymous: false },\n approvalFlows: { persist: false, anonymous: false },\n};\n\nconst getAlreadyPendingMessage = (origin: string, type: string) =>\n `Request of type '${type}' already pending for origin ${origin}. Please wait.`;\n\nconst getDefaultState = (): ApprovalControllerState => {\n return {\n pendingApprovals: {},\n pendingApprovalCount: 0,\n approvalFlows: [],\n };\n};\n\n// Internal Types\n\ntype ApprovalPromiseResolve = (value?: unknown | AddResult) => void;\n\ntype ApprovalPromiseReject = (error?: unknown) => void;\n\ntype ApprovalRequestData = Record | null;\n\ntype ApprovalRequestState = Record | null;\n\ntype ApprovalCallbacks = {\n resolve: ApprovalPromiseResolve;\n reject: ApprovalPromiseReject;\n};\n\ntype ApprovalFlow = {\n id: string;\n loadingText: string | null;\n};\n\ntype ResultOptions = {\n flowToEnd?: string;\n header?: (string | ResultComponent)[];\n};\n\n// Miscellaneous Types\n\nexport type ApprovalRequest = {\n /**\n * The ID of the approval request.\n */\n id: string;\n\n /**\n * The origin of the approval request.\n */\n origin: string;\n\n /**\n * The time that the request was received, per Date.now().\n */\n time: number;\n\n /**\n * The type of the approval request.\n */\n type: string;\n\n /**\n * Additional data associated with the request.\n * TODO:TS4.4 make optional\n */\n requestData: RequestData;\n\n /**\n * Additional mutable state associated with the request\n */\n requestState: ApprovalRequestState;\n\n /**\n * Whether the request expects a result object to be returned instead of just the approval value.\n */\n expectsResult: boolean;\n};\n\nexport type ApprovalFlowState = ApprovalFlow;\n\nexport type ApprovalControllerState = {\n pendingApprovals: Record>>;\n pendingApprovalCount: number;\n approvalFlows: ApprovalFlowState[];\n};\n\nexport type ApprovalControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n ApprovalControllerActions,\n ApprovalControllerEvents,\n string,\n string\n>;\n\n// Option Types\n\nexport type ShowApprovalRequest = () => void | Promise;\n\nexport type ResultComponent = {\n /**\n * A unique identifier for this instance of the component.\n */\n key: string;\n\n /**\n * The name of the component to render.\n */\n name: string;\n\n /**\n * Any properties required by the component.\n */\n properties?: Record;\n\n /**\n * Any child components to render inside the component.\n */\n children?: string | ResultComponent | (string | ResultComponent)[];\n};\n\nexport type ApprovalControllerOptions = {\n messenger: ApprovalControllerMessenger;\n showApprovalRequest: ShowApprovalRequest;\n state?: Partial;\n typesExcludedFromRateLimiting?: string[];\n};\n\nexport type AddApprovalOptions = {\n id?: string;\n origin: string;\n type: string;\n requestData?: Record;\n requestState?: Record;\n expectsResult?: boolean;\n};\n\nexport type UpdateRequestStateOptions = {\n id: string;\n requestState: Record;\n};\n\nexport type AcceptOptions = {\n /**\n * Whether to resolve the returned promise only when the request creator indicates the success of the\n * post-approval logic using the result callbacks.\n * If false or unspecified, the promise will resolve immediately.\n */\n waitForResult?: boolean;\n};\n\nexport type StartFlowOptions = OptionalField<\n ApprovalFlow,\n 'id' | 'loadingText'\n>;\n\nexport type EndFlowOptions = Pick;\n\nexport type SetFlowLoadingTextOptions = ApprovalFlow;\n\nexport type SuccessOptions = ResultOptions & {\n message?: string | ResultComponent | (string | ResultComponent)[];\n};\n\nexport type ErrorOptions = ResultOptions & {\n error?: string | ResultComponent | (string | ResultComponent)[];\n};\n\n// Result Types\n\nexport type AcceptResultCallbacks = {\n /**\n * Inform the request acceptor that the post-approval logic was successful.\n *\n * @param value - An optional value generated by the post-approval logic.\n */\n success: (value?: unknown) => void;\n\n /**\n * Inform the request acceptor that the post-approval logic failed.\n *\n * @param error - The reason for the failure.\n */\n error: (error: Error) => void;\n};\n\nexport type AddResult = {\n /**\n * An optional value provided by the request acceptor.\n */\n value?: unknown;\n\n /**\n * Callback functions that must be used to indicate to the request acceptor whether the post-approval logic was successful or not.\n * Will be undefined if the request acceptor did not specify that they want to wait for a result.\n */\n resultCallbacks?: AcceptResultCallbacks;\n};\n\nexport type AcceptResult = {\n /**\n * An optional value provided by the request creator when indicating a successful result.\n */\n value?: unknown;\n};\n\nexport type ApprovalFlowStartResult = ApprovalFlow;\n\nexport type SuccessResult = Record;\n\nexport type ErrorResult = Record;\n\n// Event Types\n\nexport type ApprovalStateChange = {\n type: `${typeof controllerName}:stateChange`;\n payload: [ApprovalControllerState, Patch[]];\n};\n\nexport type ApprovalControllerEvents = ApprovalStateChange;\n\n// Action Types\n\nexport type GetApprovalsState = {\n type: `${typeof controllerName}:getState`;\n handler: () => ApprovalControllerState;\n};\n\nexport type ClearApprovalRequests = {\n type: `${typeof controllerName}:clearRequests`;\n handler: (error: EthereumRpcError) => void;\n};\n\nexport type AddApprovalRequest = {\n type: `${typeof controllerName}:addRequest`;\n handler: (\n opts: AddApprovalOptions,\n shouldShowRequest: boolean,\n ) => ReturnType;\n};\n\nexport type HasApprovalRequest = {\n type: `${typeof controllerName}:hasRequest`;\n handler: ApprovalController['has'];\n};\n\nexport type AcceptRequest = {\n type: `${typeof controllerName}:acceptRequest`;\n handler: ApprovalController['accept'];\n};\n\nexport type RejectRequest = {\n type: `${typeof controllerName}:rejectRequest`;\n handler: ApprovalController['reject'];\n};\n\nexport type UpdateRequestState = {\n type: `${typeof controllerName}:updateRequestState`;\n handler: ApprovalController['updateRequestState'];\n};\n\nexport type StartFlow = {\n type: `${typeof controllerName}:startFlow`;\n handler: ApprovalController['startFlow'];\n};\n\nexport type EndFlow = {\n type: `${typeof controllerName}:endFlow`;\n handler: ApprovalController['endFlow'];\n};\n\nexport type SetFlowLoadingText = {\n type: `${typeof controllerName}:setFlowLoadingText`;\n handler: ApprovalController['setFlowLoadingText'];\n};\n\nexport type ShowSuccess = {\n type: `${typeof controllerName}:showSuccess`;\n handler: ApprovalController['success'];\n};\n\nexport type ShowError = {\n type: `${typeof controllerName}:showError`;\n handler: ApprovalController['error'];\n};\n\nexport type ApprovalControllerActions =\n | GetApprovalsState\n | ClearApprovalRequests\n | AddApprovalRequest\n | HasApprovalRequest\n | AcceptRequest\n | RejectRequest\n | UpdateRequestState\n | StartFlow\n | EndFlow\n | SetFlowLoadingText\n | ShowSuccess\n | ShowError;\n\n/**\n * Controller for managing requests that require user approval.\n *\n * Enables limiting the number of pending requests by origin and type, counting\n * pending requests, and more.\n *\n * Adding a request returns a promise that resolves or rejects when the request\n * is approved or denied, respectively.\n */\nexport class ApprovalController extends BaseControllerV2<\n typeof controllerName,\n ApprovalControllerState,\n ApprovalControllerMessenger\n> {\n #approvals: Map;\n\n #origins: Map>;\n\n #showApprovalRequest: () => void;\n\n #typesExcludedFromRateLimiting: string[];\n\n /**\n * Construct an Approval controller.\n *\n * @param options - The controller options.\n * @param options.showApprovalRequest - Function for opening the UI such that\n * the request can be displayed to the user.\n * @param options.messenger - The restricted controller messenger for the Approval controller.\n * @param options.state - The initial controller state.\n * @param options.typesExcludedFromRateLimiting - Array of aproval types which allow multiple pending approval requests from the same origin.\n */\n constructor({\n messenger,\n showApprovalRequest,\n state = {},\n typesExcludedFromRateLimiting = [],\n }: ApprovalControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#approvals = new Map();\n this.#origins = new Map();\n this.#showApprovalRequest = showApprovalRequest;\n this.#typesExcludedFromRateLimiting = typesExcludedFromRateLimiting;\n this.registerMessageHandlers();\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n private registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n `${controllerName}:clearRequests` as const,\n this.clear.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:addRequest` as const,\n (opts: AddApprovalOptions, shouldShowRequest: boolean) => {\n if (shouldShowRequest) {\n return this.addAndShowApprovalRequest(opts);\n }\n return this.add(opts);\n },\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:hasRequest` as const,\n this.has.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:acceptRequest` as const,\n this.accept.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:rejectRequest` as const,\n this.reject.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:updateRequestState` as const,\n this.updateRequestState.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:startFlow` as const,\n this.startFlow.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:endFlow` as const,\n this.endFlow.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:setFlowLoadingText` as const,\n this.setFlowLoadingText.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:showSuccess` as const,\n this.success.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n `${controllerName}:showError` as const,\n this.error.bind(this),\n );\n }\n\n /**\n * Adds an approval request per the given arguments, calls the show approval\n * request function, and returns the associated approval promise resolving to\n * an AddResult object.\n *\n * There can only be one approval per origin and type. An error is thrown if\n * attempting to add an invalid or duplicate request.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval request. A random id will be\n * generated if none is provided.\n * @param opts.origin - The origin of the approval request.\n * @param opts.type - The type associated with the approval request.\n * @param opts.requestData - Additional data associated with the request,\n * @param opts.requestState - Additional state associated with the request,\n * if any.\n * @returns The approval promise resolving to an AddResult object.\n */\n addAndShowApprovalRequest(\n opts: AddApprovalOptions & { expectsResult: true },\n ): Promise;\n\n /**\n * Adds an approval request per the given arguments, calls the show approval\n * request function, and returns the associated approval promise resolving\n * to a value provided during acceptance.\n *\n * There can only be one approval per origin and type. An error is thrown if\n * attempting to add an invalid or duplicate request.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval request. A random id will be\n * generated if none is provided.\n * @param opts.origin - The origin of the approval request.\n * @param opts.type - The type associated with the approval request.\n * @param opts.requestData - Additional data associated with the request,\n * @param opts.requestState - Additional state associated with the request,\n * if any.\n * @returns The approval promise resolving to a value provided during acceptance.\n */\n addAndShowApprovalRequest(opts: AddApprovalOptions): Promise;\n\n addAndShowApprovalRequest(opts: AddApprovalOptions): Promise {\n const promise = this.#add(\n opts.origin,\n opts.type,\n opts.id,\n opts.requestData,\n opts.requestState,\n opts.expectsResult,\n );\n this.#showApprovalRequest();\n return promise;\n }\n\n /**\n * Adds an approval request per the given arguments and returns the approval\n * promise resolving to an AddResult object.\n *\n * There can only be one approval per origin and type. An error is thrown if\n * attempting to add an invalid or duplicate request.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval request. A random id will be\n * generated if none is provided.\n * @param opts.origin - The origin of the approval request.\n * @param opts.type - The type associated with the approval request.\n * @param opts.requestData - Additional data associated with the request,\n * if any.\n * @returns The approval promise resolving to an AddResult object.\n */\n add(opts: AddApprovalOptions & { expectsResult: true }): Promise;\n\n /**\n * Adds an approval request per the given arguments and returns the approval\n * promise resolving to a value provided during acceptance.\n *\n * There can only be one approval per origin and type. An error is thrown if\n * attempting to add an invalid or duplicate request.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval request. A random id will be\n * generated if none is provided.\n * @param opts.origin - The origin of the approval request.\n * @param opts.type - The type associated with the approval request.\n * @param opts.requestData - Additional data associated with the request,\n * if any.\n * @returns The approval promise resolving to a value provided during acceptance.\n */\n add(opts: AddApprovalOptions): Promise;\n\n add(opts: AddApprovalOptions): Promise {\n return this.#add(\n opts.origin,\n opts.type,\n opts.id,\n opts.requestData,\n opts.requestState,\n opts.expectsResult,\n );\n }\n\n /**\n * Gets the info for the approval request with the given id.\n *\n * @param id - The id of the approval request.\n * @returns The approval request data associated with the id.\n */\n get(id: string): ApprovalRequest | undefined {\n return this.state.pendingApprovals[id];\n }\n\n /**\n * Gets the number of pending approvals, by origin and/or type.\n *\n * If only `origin` is specified, all approvals for that origin will be\n * counted, regardless of type.\n * If only `type` is specified, all approvals for that type will be counted,\n * regardless of origin.\n * If both `origin` and `type` are specified, 0 or 1 will be returned.\n *\n * @param opts - The approval count options.\n * @param opts.origin - An approval origin.\n * @param opts.type - The type of the approval request.\n * @returns The current approval request count for the given origin and/or\n * type.\n */\n getApprovalCount(opts: { origin?: string; type?: string } = {}): number {\n if (!opts.origin && !opts.type) {\n throw new Error('Must specify origin, type, or both.');\n }\n const { origin, type: _type } = opts;\n\n if (origin && _type) {\n return this.#origins.get(origin)?.get(_type) || 0;\n }\n\n if (origin) {\n return Array.from(\n (this.#origins.get(origin) || new Map()).values(),\n ).reduce((total, value) => total + value, 0);\n }\n\n // Only \"type\" was specified\n let count = 0;\n for (const approval of Object.values(this.state.pendingApprovals)) {\n if (approval.type === _type) {\n count += 1;\n }\n }\n return count;\n }\n\n /**\n * Get the total count of all pending approval requests for all origins.\n *\n * @returns The total pending approval request count.\n */\n getTotalApprovalCount(): number {\n return this.state.pendingApprovalCount;\n }\n\n /**\n * Checks if there's a pending approval request per the given parameters.\n * At least one parameter must be specified. An error will be thrown if the\n * parameters are invalid.\n *\n * If `id` is specified, all other parameters will be ignored.\n * If `id` is not specified, the method will check for requests that match\n * all of the specified parameters.\n *\n * @param opts - Options bag.\n * @param opts.id - The ID to check for.\n * @param opts.origin - The origin to check for.\n * @param opts.type - The type to check for.\n * @returns `true` if a matching approval is found, and `false` otherwise.\n */\n has(opts: { id?: string; origin?: string; type?: string } = {}): boolean {\n const { id, origin, type: _type } = opts;\n\n if (id) {\n if (typeof id !== 'string') {\n throw new Error('May not specify non-string id.');\n }\n return this.#approvals.has(id);\n }\n\n if (_type && typeof _type !== 'string') {\n throw new Error('May not specify non-string type.');\n }\n\n if (origin) {\n if (typeof origin !== 'string') {\n throw new Error('May not specify non-string origin.');\n }\n\n // Check origin and type pair if type also specified\n if (_type) {\n return Boolean(this.#origins.get(origin)?.get(_type));\n }\n return this.#origins.has(origin);\n }\n\n if (_type) {\n for (const approval of Object.values(this.state.pendingApprovals)) {\n if (approval.type === _type) {\n return true;\n }\n }\n return false;\n }\n throw new Error(\n 'Must specify a valid combination of id, origin, and type.',\n );\n }\n\n /**\n * Resolves the promise of the approval with the given id, and deletes the\n * approval. Throws an error if no such approval exists.\n *\n * @param id - The id of the approval request.\n * @param value - The value to resolve the approval promise with.\n * @param options - Options bag.\n * @returns A promise that either resolves once a result is provided by\n * the creator of the approval request, or immediately if `options.waitForResult`\n * is `false` or `undefined`.\n */\n accept(\n id: string,\n value?: unknown,\n options?: AcceptOptions,\n ): Promise {\n // Safe to cast as the delete method below will throw if the ID is not found\n const approval = this.get(id) as ApprovalRequest;\n const requestPromise = this.#deleteApprovalAndGetCallbacks(id);\n\n return new Promise((resolve, reject) => {\n const resultCallbacks: AcceptResultCallbacks = {\n success: (acceptValue?: unknown) => resolve({ value: acceptValue }),\n error: reject,\n };\n\n if (options?.waitForResult && !approval.expectsResult) {\n reject(new ApprovalRequestNoResultSupportError(id));\n return;\n }\n\n const resultValue = options?.waitForResult ? resultCallbacks : undefined;\n\n const resolveValue = approval.expectsResult\n ? { value, resultCallbacks: resultValue }\n : value;\n\n requestPromise.resolve(resolveValue);\n\n if (!options?.waitForResult) {\n resolve({ value: undefined });\n }\n });\n }\n\n /**\n * Rejects the promise of the approval with the given id, and deletes the\n * approval. Throws an error if no such approval exists.\n *\n * @param id - The id of the approval request.\n * @param error - The error to reject the approval promise with.\n */\n reject(id: string, error: unknown): void {\n this.#deleteApprovalAndGetCallbacks(id).reject(error);\n }\n\n /**\n * Rejects and deletes all approval requests.\n *\n * @param rejectionError - The EthereumRpcError to reject the approval\n * requests with.\n */\n clear(rejectionError: EthereumRpcError): void {\n for (const id of this.#approvals.keys()) {\n this.reject(id, rejectionError);\n }\n this.#origins.clear();\n this.update((draftState) => {\n draftState.pendingApprovals = {};\n draftState.pendingApprovalCount = 0;\n });\n }\n\n /**\n * Updates the request state of the approval with the given id.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval request.\n * @param opts.requestState - Additional data associated with the request\n */\n updateRequestState(opts: UpdateRequestStateOptions): void {\n if (!this.state.pendingApprovals[opts.id]) {\n throw new ApprovalRequestNotFoundError(opts.id);\n }\n\n this.update((draftState) => {\n // Typecast: ts(2589)\n draftState.pendingApprovals[opts.id].requestState =\n opts.requestState as any;\n });\n }\n\n /**\n * Starts a new approval flow.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval flow.\n * @param opts.loadingText - The loading text that will be associated to the approval flow.\n * @returns The object containing the approval flow id.\n */\n startFlow(opts: StartFlowOptions = {}): ApprovalFlowStartResult {\n const id = opts.id ?? nanoid();\n const loadingText = opts.loadingText ?? null;\n\n this.update((draftState) => {\n draftState.approvalFlows.push({ id, loadingText });\n });\n\n this.#showApprovalRequest();\n\n return { id, loadingText };\n }\n\n /**\n * Ends the current approval flow.\n *\n * @param opts - Options bag.\n * @param opts.id - The id of the approval flow that will be finished.\n */\n endFlow({ id }: EndFlowOptions) {\n if (!this.state.approvalFlows.length) {\n throw new NoApprovalFlowsError();\n }\n\n const currentFlow = this.state.approvalFlows.slice(-1)[0];\n\n if (id !== currentFlow.id) {\n throw new EndInvalidFlowError(\n id,\n this.state.approvalFlows.map((flow) => flow.id),\n );\n }\n\n this.update((draftState) => {\n draftState.approvalFlows.pop();\n });\n }\n\n /**\n * Sets the loading text for the approval flow.\n *\n * @param opts - Options bag.\n * @param opts.id - The approval flow loading text that will be displayed.\n * @param opts.loadingText - The loading text that will be associated to the approval flow.\n */\n setFlowLoadingText({ id, loadingText }: SetFlowLoadingTextOptions) {\n const flowIndex = this.state.approvalFlows.findIndex(\n (flow) => flow.id === id,\n );\n\n if (flowIndex === -1) {\n throw new MissingApprovalFlowError(id);\n }\n\n this.update((draftState) => {\n draftState.approvalFlows[flowIndex].loadingText = loadingText;\n });\n }\n\n /**\n * Show a success page.\n *\n * @param opts - Options bag.\n * @param opts.message - The message text or components to display in the page.\n * @param opts.header - The text or components to display in the header of the page.\n * @param opts.flowToEnd - The ID of the approval flow to end once the success page is approved.\n * @returns Empty object to support future additions.\n */\n async success(opts: SuccessOptions = {}): Promise {\n await this.#result(APPROVAL_TYPE_RESULT_SUCCESS, opts, {\n message: opts.message,\n header: opts.header,\n } as any);\n return {};\n }\n\n /**\n * Show an error page.\n *\n * @param opts - Options bag.\n * @param opts.message - The message text or components to display in the page.\n * @param opts.header - The text or components to display in the header of the page.\n * @param opts.flowToEnd - The ID of the approval flow to end once the error page is approved.\n * @returns Empty object to support future additions.\n */\n async error(opts: ErrorOptions = {}): Promise {\n await this.#result(APPROVAL_TYPE_RESULT_ERROR, opts, {\n error: opts.error,\n header: opts.header,\n } as any);\n return {};\n }\n\n /**\n * Implementation of add operation.\n *\n * @param origin - The origin of the approval request.\n * @param type - The type associated with the approval request.\n * @param id - The id of the approval request.\n * @param requestData - The request data associated with the approval request.\n * @param requestState - The request state associated with the approval request.\n * @param expectsResult - Whether the approval request expects a result object to be returned.\n * @returns The approval promise.\n */\n #add(\n origin: string,\n type: string,\n id: string = nanoid(),\n requestData?: Record,\n requestState?: Record,\n expectsResult?: boolean,\n ): Promise {\n this.#validateAddParams(id, origin, type, requestData, requestState);\n\n if (\n !this.#typesExcludedFromRateLimiting.includes(type) &&\n this.has({ origin, type })\n ) {\n throw ethErrors.rpc.resourceUnavailable(\n getAlreadyPendingMessage(origin, type),\n );\n }\n\n // add pending approval\n return new Promise((resolve, reject) => {\n this.#approvals.set(id, { resolve, reject });\n this.#addPendingApprovalOrigin(origin, type);\n\n this.#addToStore(\n id,\n origin,\n type,\n requestData,\n requestState,\n expectsResult,\n );\n });\n }\n\n /**\n * Validates parameters to the add method.\n *\n * @param id - The id of the approval request.\n * @param origin - The origin of the approval request.\n * @param type - The type associated with the approval request.\n * @param requestData - The request data associated with the approval request.\n * @param requestState - The request state associated with the approval request.\n */\n #validateAddParams(\n id: string,\n origin: string,\n type: string,\n requestData?: Record,\n requestState?: Record,\n ): void {\n let errorMessage = null;\n if (!id || typeof id !== 'string') {\n errorMessage = 'Must specify non-empty string id.';\n } else if (this.#approvals.has(id)) {\n errorMessage = `Approval request with id '${id}' already exists.`;\n } else if (!origin || typeof origin !== 'string') {\n errorMessage = 'Must specify non-empty string origin.';\n } else if (!type || typeof type !== 'string') {\n errorMessage = 'Must specify non-empty string type.';\n } else if (\n requestData &&\n (typeof requestData !== 'object' || Array.isArray(requestData))\n ) {\n errorMessage = 'Request data must be a plain object if specified.';\n } else if (\n requestState &&\n (typeof requestState !== 'object' || Array.isArray(requestState))\n ) {\n errorMessage = 'Request state must be a plain object if specified.';\n }\n\n if (errorMessage) {\n throw ethErrors.rpc.internal(errorMessage);\n }\n }\n\n /**\n * Adds an entry to _origins.\n * Performs no validation.\n *\n * @param origin - The origin of the approval request.\n * @param type - The type associated with the approval request.\n */\n #addPendingApprovalOrigin(origin: string, type: string): void {\n let originMap = this.#origins.get(origin);\n\n if (!originMap) {\n originMap = new Map();\n this.#origins.set(origin, originMap);\n }\n\n const currentValue = originMap.get(type) || 0;\n originMap.set(type, currentValue + 1);\n }\n\n /**\n * Adds an entry to the store.\n * Performs no validation.\n *\n * @param id - The id of the approval request.\n * @param origin - The origin of the approval request.\n * @param type - The type associated with the approval request.\n * @param requestData - The request data associated with the approval request.\n * @param requestState - The request state associated with the approval request.\n * @param expectsResult - Whether the request expects a result object to be returned.\n */\n #addToStore(\n id: string,\n origin: string,\n type: string,\n requestData?: Record,\n requestState?: Record,\n expectsResult?: boolean,\n ): void {\n const approval: ApprovalRequest | null> = {\n id,\n origin,\n type,\n time: Date.now(),\n requestData: requestData || null,\n requestState: requestState || null,\n expectsResult: expectsResult || false,\n };\n\n this.update((draftState) => {\n // Typecast: ts(2589)\n draftState.pendingApprovals[id] = approval as any;\n draftState.pendingApprovalCount = Object.keys(\n draftState.pendingApprovals,\n ).length;\n });\n }\n\n /**\n * Deletes the approval with the given id. The approval promise must be\n * resolved or reject before this method is called.\n * Deletion is an internal operation because approval state is solely\n * managed by this controller.\n *\n * @param id - The id of the approval request to be deleted.\n */\n #delete(id: string): void {\n this.#approvals.delete(id);\n\n // This method is only called after verifying that the approval with the\n // specified id exists.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { origin, type } = this.state.pendingApprovals[id]!;\n\n const originMap = this.#origins.get(origin) as Map;\n const originTotalCount = this.getApprovalCount({ origin });\n const originTypeCount = originMap.get(type) as number;\n\n if (originTotalCount === 1) {\n this.#origins.delete(origin);\n } else {\n originMap.set(type, originTypeCount - 1);\n }\n\n this.update((draftState) => {\n delete draftState.pendingApprovals[id];\n draftState.pendingApprovalCount = Object.keys(\n draftState.pendingApprovals,\n ).length;\n });\n }\n\n /**\n * Gets the approval callbacks for the given id, deletes the entry, and then\n * returns the callbacks for promise resolution.\n * Throws an error if no approval is found for the given id.\n *\n * @param id - The id of the approval request.\n * @returns The promise callbacks associated with the approval request.\n */\n #deleteApprovalAndGetCallbacks(id: string): ApprovalCallbacks {\n const callbacks = this.#approvals.get(id);\n if (!callbacks) {\n throw new ApprovalRequestNotFoundError(id);\n }\n\n this.#delete(id);\n return callbacks;\n }\n\n async #result(\n type: string,\n opts: ResultOptions,\n requestData: Record,\n ) {\n try {\n await this.addAndShowApprovalRequest({\n origin: ORIGIN_METAMASK,\n type,\n requestData,\n });\n } catch (error) {\n console.info('Failed to display result page', error);\n } finally {\n if (opts.flowToEnd) {\n try {\n this.endFlow({ id: opts.flowToEnd });\n } catch (error) {\n console.info('Failed to end flow', { id: opts.flowToEnd, error });\n }\n }\n }\n }\n}\n\nexport default ApprovalController;\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/approval-controller/dist/errors.d.ts.map b/node_modules/@metamask/approval-controller/dist/errors.d.ts.map +deleted file mode 100644 +index 43e92d5..0000000 +--- a/node_modules/@metamask/approval-controller/dist/errors.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,EAAE,EAAE,MAAM;CAGvB;AAED,qBAAa,mCAAoC,SAAQ,KAAK;gBAChD,EAAE,EAAE,MAAM;CAKvB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;;CAI9C;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;CAO1C;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,EAAE,EAAE,MAAM;CAGvB"} +\ No newline at end of file +diff --git a/node_modules/@metamask/approval-controller/dist/errors.js.map b/node_modules/@metamask/approval-controller/dist/errors.js.map +deleted file mode 100644 +index c709895..0000000 +--- a/node_modules/@metamask/approval-controller/dist/errors.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,EAAU;QACpB,KAAK,CAAC,6BAA6B,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;CACF;AAJD,oEAIC;AAED,MAAa,mCAAoC,SAAQ,KAAK;IAC5D,YAAY,EAAU;QACpB,KAAK,CACH,6DAA6D,EAAE,wBAAwB,CACxF,CAAC;IACJ,CAAC;CACF;AAND,kFAMC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACpC,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,EAAU,EAAE,OAAiB;QACvC,KAAK,CACH,kCAAkC,EAAE,gDAClC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,iBAAiB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtC,CAAC;IACJ,CAAC;CACF;AARD,kDAQC;AAED,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,EAAU;QACpB,KAAK,CAAC,oCAAoC,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAJD,4DAIC","sourcesContent":["export class ApprovalRequestNotFoundError extends Error {\n constructor(id: string) {\n super(`Approval request with id '${id}' not found.`);\n }\n}\n\nexport class ApprovalRequestNoResultSupportError extends Error {\n constructor(id: string) {\n super(\n `Approval acceptance requested result but request with id '${id}' does not support it.`,\n );\n }\n}\n\nexport class NoApprovalFlowsError extends Error {\n constructor() {\n super(`No approval flows found.`);\n }\n}\n\nexport class EndInvalidFlowError extends Error {\n constructor(id: string, flowIds: string[]) {\n super(\n `Attempted to end flow with id '${id}' which does not match current flow with id '${\n flowIds.slice(-1)[0]\n }'. All Flows: ${flowIds.join(', ')}`,\n );\n }\n}\n\nexport class MissingApprovalFlowError extends Error {\n constructor(id: string) {\n super(`No approval flows found with id '${id}'.`);\n }\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/approval-controller/dist/index.d.ts.map b/node_modules/@metamask/approval-controller/dist/index.d.ts.map +deleted file mode 100644 +index ae4b431..0000000 +--- a/node_modules/@metamask/approval-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,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"} +\ No newline at end of file +diff --git a/node_modules/@metamask/approval-controller/dist/index.js.map b/node_modules/@metamask/approval-controller/dist/index.js.map +deleted file mode 100644 +index af114e6..0000000 +--- a/node_modules/@metamask/approval-controller/dist/index.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2CAAyB","sourcesContent":["export * from './ApprovalController';\nexport * from './errors';\n"]} +\ No newline at end of file diff --git a/patches/@metamask+transaction-controller+13.0.0.patch b/patches/@metamask+transaction-controller+13.0.0.patch new file mode 100644 index 000000000000..73085b70210c --- /dev/null +++ b/patches/@metamask+transaction-controller+13.0.0.patch @@ -0,0 +1,1649 @@ +diff --git a/node_modules/@metamask/transaction-controller/dist/.patch.txt b/node_modules/@metamask/transaction-controller/dist/.patch.txt +new file mode 100644 +index 0000000..550de56 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/.patch.txt +@@ -0,0 +1,7 @@ ++PATCH GENERATED FROM MetaMask/core branch: patch/mobile-transaction-controller-13-0-0 ++This patch backports various transaction controller features from the main branch of MetaMask/core ++Steps to update patch: ++* Create a new core branch from: patch/mobile-transaction-controller-13-0-0 ++* Run "yarn build" in the core monorepo ++* Run "yarn patch:tx " in the mobile repo ++* Once the new patch is merged, add your changes to: patch/mobile-transaction-controller-13-0-0 +diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map +deleted file mode 100644 +index 9a28bf5..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"EtherscanRemoteTransactionSource.d.ts","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAiB3C,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;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;CAkI9B"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map +deleted file mode 100644 +index 4b10444..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"EtherscanRemoteTransactionSource.js","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAErD,qDAAqC;AACrC,+BAAoC;AAEpC,2CAA2D;AAQ3D,2CAGqB;AACrB,qCAA6D;AAM7D,mCAA4C;AAE5C;;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,MAAM,IAAA,sCAA0B,EAC5D,gBAAgB,CACjB,CAAC;YAEF,OAAO,uBAAA,IAAI,8GAAyB,MAA7B,IAAI,EAA0B,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACrE,uBAAA,IAAI,2GAAsB,MAA1B,IAAI,EAAuB,EAAE,EAAE,cAAc,CAAC,CAC/C,CAAC;QACJ,CAAC,CAAA,EAAC;QAEF,mEAA0B,CACxB,OAAuC,EACvC,gBAA6C,EAC7C,EAAE;YACF,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;YAEnC,MAAM,qBAAqB,GAAG,MAAM,IAAA,2CAA+B,EACjE,gBAAgB,CACjB,CAAC;YAEF,OAAO,uBAAA,IAAI,8GAAyB,MAA7B,IAAI,EAA0B,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EA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,cAAc;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,EAAE,EAAE,IAAA,SAAM,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC3B,MAAM,EAAE,yBAAiB,CAAC,SAAS;QACnC,IAAI;QACJ,QAAQ,EAAE;YACR,OAAO,EAAE,cAAc;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,GAAG,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,QAAQ,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,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 type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n EtherscanTransactionRequest,\n EtherscanTransactionResponse,\n} from './etherscan';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from './etherscan';\nimport { incomingTransactionsLogger as log } from './logger';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from './types';\nimport { TransactionStatus } from './types';\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 verifiedOnBlockchain: false,\n };\n }\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map +deleted file mode 100644 +index 5d3ae50..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"IncomingTransactionHelper.d.ts","sourceRoot":"","sources":["../src/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,SAAS,CAAC;AASxE,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;CAmMxD"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js.map b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js.map +deleted file mode 100644 +index a45b30c..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.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A,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\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 } 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/TransactionController.d.ts b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts +index d8fa996..e5e97bc 100644 +--- a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts +@@ -1,15 +1,15 @@ + /// +-import { Hardfork } from '@ethereumjs/common'; + import type { TypedTransaction } from '@ethereumjs/tx'; + import type { AddApprovalRequest } from '@metamask/approval-controller'; + import type { BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller'; + import { BaseController } from '@metamask/base-controller'; ++import type { GasFeeState } from '@metamask/gas-fee-controller'; + import type { BlockTracker, NetworkState, Provider } from '@metamask/network-controller'; + import type { Hex } from '@metamask/utils'; + import { EventEmitter } from 'events'; +-import type { TransactionParams, TransactionMeta, TransactionReceipt, SendFlowHistoryEntry, WalletDevice } from './types'; ++import type { NonceLock } from 'nonce-tracker/dist/NonceTracker'; ++import type { TransactionParams, TransactionMeta, TransactionReceipt, SecurityAlertResponse, SendFlowHistoryEntry, WalletDevice, SubmitHistoryEntry } from './types'; + import { TransactionType } from './types'; +-export declare const HARDFORK = Hardfork.London; + /** + * @type Result + * @property result - Promise resolving to a new transaction hash +@@ -65,11 +65,12 @@ export interface TransactionState extends BaseState { + lastFetchedBlockNumbers: { + [key: string]: number; + }; ++ submitHistory: SubmitHistoryEntry[]; + } + /** + * Multiplier used to determine a transaction's increased gas fee during cancellation + */ +-export declare const CANCEL_RATE = 1.5; ++export declare const CANCEL_RATE = 1.1; + /** + * Multiplier used to determine a transaction's increased gas fee during speed up + */ +@@ -101,6 +102,8 @@ export declare class TransactionController extends BaseController Promise; +- getCurrentNetworkEIP1559Compatibility: () => Promise; ++ getCurrentNetworkEIP1559Compatibility: () => Promise; ++ getGasFeeEstimates: () => Promise; + getNetworkState: () => NetworkState; + getSelectedAddress: () => string; + incomingTransactions: { +@@ -191,7 +196,7 @@ export declare class TransactionController extends BaseController; ++ securityAlertResponse?: SecurityAlertResponse; + sendFlowHistory?: SendFlowHistoryEntry[]; + type?: TransactionType; + }): Promise; +@@ -254,6 +259,13 @@ export declare class TransactionController extends BaseController; + /** + * Trim the amount of transactions that are set on the state. Checks + * if the length of the tx history is longer then desired persistence +@@ -431,6 +451,10 @@ export declare class TransactionController extends BaseController (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.submitted, this.state.transactions), +- getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.confirmed, this.state.transactions), ++ getPendingTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.submitted), ++ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed), + }); + this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({ + blockTracker, + getCurrentAccount: getSelectedAddress, + getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers, ++ getLocalTransactions: () => this.state.transactions, + getNetworkState, + isEnabled: incomingTransactions.isEnabled, + queryEntireHistory: incomingTransactions.queryEntireHistory, +@@ -125,6 +132,18 @@ class TransactionController extends base_controller_1.BaseController { + }); + this.incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this)); + this.incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this)); ++ this.gasFeeFlows = this.getGasFeeFlows(); ++ const gasFeePoller = new GasFeePoller_1.GasFeePoller({ ++ gasFeeFlows: this.gasFeeFlows, ++ getChainIds: () => [this.getNetworkState().providerConfig.chainId], ++ getEthQuery: () => this.ethQuery, ++ getGasFeeControllerEstimates: this.getGasFeeEstimates, ++ getTransactions: () => this.state.transactions, ++ onStateChange: (listener) => { ++ this.subscribe(listener); ++ }, ++ }); ++ gasFeePoller.hub.on('transaction-updated', this.updateTransaction.bind(this)); + onNetworkStateChange(() => { + this.ethQuery = new eth_query_1.default(this.provider); + this.registry = new eth_method_registry_1.default({ provider: this.provider }); +@@ -204,7 +223,7 @@ class TransactionController extends base_controller_1.BaseController { + return __awaiter(this, void 0, void 0, function* () { + const chainId = this.getChainId(); + const { transactions } = this.state; +- txParams = (0, utils_1.normalizeTxParams)(txParams); ++ txParams = (0, utils_1.normalizeTransactionParams)(txParams); + const isEIP1559Compatible = yield this.getEIP1559Compatibility(); + (0, utils_1.validateTxParams)(txParams, isEIP1559Compatible); + const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin); +@@ -353,7 +372,7 @@ class TransactionController extends base_controller_1.BaseController { + const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from); + yield this.updateTransactionMetaRSV(transactionMeta, signedTx); + const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); +- yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]); ++ yield this.publishTransaction(rawTx, txParams, transactionMeta.chainId, 'cancel'); + transactionMeta.estimatedBaseFee = estimatedBaseFee; + transactionMeta.status = types_1.TransactionStatus.cancelled; + this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); +@@ -414,7 +433,7 @@ class TransactionController extends base_controller_1.BaseController { + const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from); + yield this.updateTransactionMetaRSV(transactionMeta, signedTx); + const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); +- const hash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]); ++ const hash = yield this.publishTransaction(rawTx, txParams, transactionMeta.chainId, controller_utils_1.ORIGIN_METAMASK); + const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { estimatedBaseFee, id: (0, uuid_1.v1)(), time: Date.now(), hash, + actionId, originalGasEstimate: transactionMeta.txParams.gas, type: types_1.TransactionType.retry }); + const newTransactionMeta = newMaxFeePerGas && newMaxPriorityFeePerGas +@@ -474,6 +493,8 @@ class TransactionController extends base_controller_1.BaseController { + } + catch (error) { + estimateGasError = utils_1.ESTIMATE_GAS_ERROR; ++ // Fallback to 95% of the block gasLimit. ++ gasHex = estimatedTransaction.gas; + } + // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a + // a custom network then return the eth_estimateGas value. +@@ -529,7 +550,7 @@ class TransactionController extends base_controller_1.BaseController { + */ + updateTransaction(transactionMeta, note) { + const { transactions } = this.state; +- transactionMeta.txParams = (0, utils_1.normalizeTxParams)(transactionMeta.txParams); ++ transactionMeta.txParams = (0, utils_1.normalizeTransactionParams)(transactionMeta.txParams); + (0, utils_1.validateTxParams)(transactionMeta.txParams); + if (!this.isHistoryDisabled) { + (0, history_1.updateTransactionHistory)(transactionMeta, note); +@@ -538,6 +559,23 @@ class TransactionController extends base_controller_1.BaseController { + transactions[index] = transactionMeta; + this.update({ transactions: this.trimTransactionsForState(transactions) }); + } ++ /** ++ * Update the security alert response for a transaction. ++ * ++ * @param transactionId - ID of the transaction. ++ * @param securityAlertResponse - The new security alert response for the transaction. ++ */ ++ updateSecurityAlertResponse(transactionId, securityAlertResponse) { ++ if (!securityAlertResponse) { ++ throw new Error('updateSecurityAlertResponse: securityAlertResponse should not be null'); ++ } ++ const transactionMeta = this.getTransaction(transactionId); ++ if (!transactionMeta) { ++ throw new Error(`Cannot update security alert response as no transaction metadata found`); ++ } ++ const updatedMeta = (0, lodash_1.merge)(transactionMeta, { securityAlertResponse }); ++ this.updateTransaction(updatedMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`); ++ } + /** + * Removes all transactions from state, optionally based on the current network. + * +@@ -762,7 +800,7 @@ class TransactionController extends base_controller_1.BaseController { + // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction + // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce + if (!nonceToUse) { +- nonceLock = yield this.nonceTracker.getNonceLock(from); ++ nonceLock = yield this.getNonceLock(from); + nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16)); + } + transactionMeta.status = status; +@@ -786,7 +824,7 @@ class TransactionController extends base_controller_1.BaseController { + const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); + transactionMeta.rawTx = rawTx; + this.updateTransaction(transactionMeta, 'TransactionController#approveTransaction - RawTransaction added'); +- const hash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]); ++ const hash = yield this.publishTransaction(rawTx, txParams, chainId, transactionMeta.origin); + transactionMeta.hash = hash; + transactionMeta.status = types_1.TransactionStatus.submitted; + transactionMeta.submittedTime = new Date().getTime(); +@@ -797,11 +835,10 @@ class TransactionController extends base_controller_1.BaseController { + this.failTransaction(transactionMeta, error); + } + finally { +- // must set transaction to submitted/failed before releasing lock ++ releaseLock(); + if (nonceLock) { + nonceLock.releaseLock(); + } +- releaseLock(); + } + }); + } +@@ -821,6 +858,18 @@ class TransactionController extends base_controller_1.BaseController { + const transactions = this.state.transactions.filter(({ id }) => id !== transactionId); + this.update({ transactions: this.trimTransactionsForState(transactions) }); + } ++ /** ++ * 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. ++ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock. ++ */ ++ getNonceLock(address) { ++ return __awaiter(this, void 0, void 0, function* () { ++ return this.nonceTracker.getNonceLock(address); ++ }); ++ } + /** + * Trim the amount of transactions that are set on the state. Checks + * if the length of the tx history is longer then desired persistence +@@ -932,9 +981,17 @@ class TransactionController extends base_controller_1.BaseController { + } + /* istanbul ignore next */ + if (txObj === null || txObj === void 0 ? void 0 : txObj.blockNumber) { +- meta.status = types_1.TransactionStatus.confirmed; +- this.hub.emit(`${meta.id}:confirmed`, meta); +- return [meta, true]; ++ // transactions can be added to a block and still fail, so we need to check the transaction status before emitting the confirmed event ++ const txStatusFailed = yield this.checkTxReceiptStatusIsFailed(hash); ++ if (txStatusFailed) { ++ const error = new Error('Transaction failed. The transaction was reversed'); ++ this.failTransaction(meta, error); ++ } ++ else { ++ meta.status = types_1.TransactionStatus.confirmed; ++ this.hub.emit(`${meta.id}:confirmed`, meta); ++ return [meta, true]; ++ } + } + return [meta, false]; + default: +@@ -1016,13 +1073,14 @@ class TransactionController extends base_controller_1.BaseController { + const { providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState(); + if (chain !== controller_utils_1.RPC && + chain !== controller_utils_1.NetworkType['linea-goerli'] && ++ chain !== controller_utils_1.NetworkType['linea-sepolia'] && + chain !== controller_utils_1.NetworkType['linea-mainnet']) { +- return new common_1.Common({ chain, hardfork: exports.HARDFORK }); ++ return new common_1.Common({ chain, hardfork: HARDFORK }); + } + const customChainParams = { + name, + chainId: parseInt(chainId, 16), +- defaultHardfork: exports.HARDFORK, ++ defaultHardfork: HARDFORK, + }; + return common_1.Common.custom(customChainParams); + } +@@ -1182,6 +1240,40 @@ class TransactionController extends base_controller_1.BaseController { + return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible); + }); + } ++ getNonceTrackerTransactions(status, address) { ++ const currentChainId = this.getChainId(); ++ return (0, utils_1.getAndFormatTransactionsForNonceTracker)(currentChainId, address, status, this.state.transactions); ++ } ++ publishTransaction(rawTransaction, transaction, chainId, origin) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const transactionHash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [ ++ rawTransaction, ++ ]); ++ this.updateSubmitHistory(rawTransaction, transactionHash, transaction, chainId, origin); ++ return transactionHash; ++ }); ++ } ++ updateSubmitHistory(rawTransaction, hash, transaction, chainId, origin) { ++ const { rpcUrl: networkUrl, type: networkType } = this.getNetworkState().providerConfig; ++ const submitHistoryEntry = { ++ chainId, ++ hash, ++ networkType, ++ networkUrl, ++ origin, ++ time: Date.now(), ++ transaction, ++ rawTransaction, ++ }; ++ const submitHistory = [submitHistoryEntry, ...this.state.submitHistory]; ++ if (submitHistory.length > SUBMIT_HISTORY_LIMIT) { ++ submitHistory.pop(); ++ } ++ this.update({ submitHistory }); ++ } ++ getGasFeeFlows() { ++ return [new LineaGasFeeFlow_1.LineaGasFeeFlow()]; ++ } + } + exports.TransactionController = TransactionController; + exports.default = TransactionController; +diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map b/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map +deleted file mode 100644 +index b4ead51..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;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C,aAAqB;;YAErB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,aAAa,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE;oBACpD,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;;;;;OAMG;IACW,wBAAwB,CACpC,eAAgC,EAChC,QAA0B;;YAE1B,IAAI,QAAQ,CAAC,CAAC,EAAE;gBACd,eAAe,CAAC,CAAC,GAAG,IAAA,8BAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;aAC3D;YAED,IAAI,QAAQ,CAAC,CAAC,EAAE;gBACd,eAAe,CAAC,CAAC,GAAG,IAAA,8BAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;aAC3D;YAED,IAAI,QAAQ,CAAC,CAAC,EAAE;gBACd,eAAe,CAAC,CAAC,GAAG,IAAA,8BAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;aAC3D;QACH,CAAC;KAAA;IAEa,uBAAuB;;;YACnC,MAAM,iCAAiC,GACrC,MAAM,IAAI,CAAC,qCAAqC,EAAE,CAAC;YACrD,MAAM,iCAAiC,GACrC,MAAA,MAAA,IAAI,CAAC,qCAAqC,oDAAI,mCAAI,IAAI,CAAC;YAEzD,OAAO,CACL,iCAAiC,IAAI,iCAAiC,CACvE,CAAC;;KACH;CACF;AAhoDD,sDAgoDC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["import { Hardfork, Common, type ChainConfig } from '@ethereumjs/common';\nimport type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type {\n AcceptResultCallbacks,\n AddApprovalRequest,\n AddResult,\n} from '@metamask/approval-controller';\nimport type {\n BaseConfig,\n BaseState,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport {\n BNToHex,\n fractionBN,\n hexToBN,\n safelyExecute,\n query,\n NetworkType,\n RPC,\n ApprovalType,\n ORIGIN_METAMASK,\n convertHexToDecimal,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type {\n BlockTracker,\n NetworkState,\n Provider,\n} from '@metamask/network-controller';\nimport { errorCodes, rpcErrors, providerErrors } from '@metamask/rpc-errors';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport MethodRegistry from 'eth-method-registry';\nimport { addHexPrefix, bufferToHex } from 'ethereumjs-util';\nimport { EventEmitter } from 'events';\nimport { merge, pickBy } from 'lodash';\nimport NonceTracker from 'nonce-tracker';\nimport { v1 as random } from 'uuid';\n\nimport { EtherscanRemoteTransactionSource } from './EtherscanRemoteTransactionSource';\nimport { validateConfirmedExternalTransaction } from './external-transactions';\nimport { addInitialHistorySnapshot, updateTransactionHistory } from './history';\nimport { IncomingTransactionHelper } from './IncomingTransactionHelper';\nimport { determineTransactionType } from './transaction-type';\nimport type {\n DappSuggestedGasFees,\n TransactionParams,\n TransactionMeta,\n TransactionReceipt,\n SendFlowHistoryEntry,\n WalletDevice,\n} from './types';\nimport { TransactionType, TransactionStatus } from './types';\nimport {\n getAndFormatTransactionsForNonceTracker,\n getIncreasedPriceFromExisting,\n normalizeTxParams,\n isEIP1559Transaction,\n isFeeMarketEIP1559Values,\n isGasPriceValue,\n validateGasValues,\n validateIfTransactionUnapproved,\n validateMinimumIncrease,\n validateTxParams,\n ESTIMATE_GAS_ERROR,\n} from './utils';\n\nexport const HARDFORK = Hardfork.London;\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\nexport interface Result {\n result: Promise;\n transactionMeta: TransactionMeta;\n}\n\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property interval - Polling interval used to fetch new currency rate\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\nexport interface TransactionConfig extends BaseConfig {\n interval: number;\n sign?: (txParams: TransactionParams, from: string) => Promise;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n lastFetchedBlockNumbers: { [key: string]: number };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * The name of the {@link TransactionController}.\n */\nconst controllerName = 'TransactionController';\n\n/**\n * The external actions available to the {@link TransactionController}.\n */\ntype AllowedActions = AddApprovalRequest;\n\n/**\n * The messenger of the {@link TransactionController}.\n */\nexport type TransactionControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseController<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: EthQuery;\n\n private readonly isHistoryDisabled: boolean;\n\n private readonly isSendFlowHistoryDisabled: boolean;\n\n private readonly nonceTracker: NonceTracker;\n\n private registry: any;\n\n private readonly provider: Provider;\n\n private handle?: ReturnType;\n\n private readonly mutex = new Mutex();\n\n private readonly getNetworkState: () => NetworkState;\n\n private readonly getCurrentAccountEIP1559Compatibility: () => Promise;\n\n private readonly getCurrentNetworkEIP1559Compatibility: () => Promise;\n\n private readonly messagingSystem: TransactionControllerMessenger;\n\n private readonly incomingTransactionHelper: IncomingTransactionHelper;\n\n private failTransaction(transactionMeta: TransactionMeta, error: Error) {\n const newTransactionMeta = {\n ...transactionMeta,\n error,\n status: TransactionStatus.failed,\n };\n this.updateTransaction(\n newTransactionMeta,\n 'TransactionController#failTransaction - Add error message and set status to failed',\n );\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter();\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n ) => Promise;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.blockTracker - The block tracker used to poll for new blocks data.\n * @param options.disableHistory - Whether to disable storing history in transaction metadata.\n * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.\n * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.\n * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.getSelectedAddress - Gets the address of the currently selected account.\n * @param options.incomingTransactions - Configuration options for incoming transaction support.\n * @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.\n * @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled.\n * @param options.incomingTransactions.queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.\n * @param options.incomingTransactions.updateTransactions - Whether to update local transactions using remote transaction data.\n * @param options.messenger - The controller messenger.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.provider - The provider used to create the underlying EthQuery instance.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n blockTracker,\n disableHistory,\n disableSendFlowHistory,\n getCurrentAccountEIP1559Compatibility,\n getCurrentNetworkEIP1559Compatibility,\n getNetworkState,\n getSelectedAddress,\n incomingTransactions = {},\n messenger,\n onNetworkStateChange,\n provider,\n }: {\n blockTracker: BlockTracker;\n disableHistory: boolean;\n disableSendFlowHistory: boolean;\n getCurrentAccountEIP1559Compatibility: () => Promise;\n getCurrentNetworkEIP1559Compatibility: () => Promise;\n getNetworkState: () => NetworkState;\n getSelectedAddress: () => string;\n incomingTransactions: {\n includeTokenTransfers?: boolean;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n updateTransactions?: boolean;\n };\n messenger: TransactionControllerMessenger;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n provider: Provider;\n },\n config?: Partial,\n state?: Partial,\n ) {\n super(config, state);\n\n this.defaultConfig = {\n interval: 15000,\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n lastFetchedBlockNumbers: {},\n };\n\n this.initialize();\n\n this.provider = provider;\n this.messagingSystem = messenger;\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;\n this.isHistoryDisabled = disableHistory ?? false;\n this.registry = new MethodRegistry({ provider });\n this.getCurrentAccountEIP1559Compatibility =\n getCurrentAccountEIP1559Compatibility;\n this.getCurrentNetworkEIP1559Compatibility =\n getCurrentNetworkEIP1559Compatibility;\n\n this.nonceTracker = new NonceTracker({\n provider,\n blockTracker,\n getPendingTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.submitted,\n this.state.transactions,\n ),\n getConfirmedTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.confirmed,\n this.state.transactions,\n ),\n });\n\n this.incomingTransactionHelper = new IncomingTransactionHelper({\n blockTracker,\n getCurrentAccount: getSelectedAddress,\n getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,\n getNetworkState,\n isEnabled: incomingTransactions.isEnabled,\n queryEntireHistory: incomingTransactions.queryEntireHistory,\n remoteTransactionSource: new EtherscanRemoteTransactionSource({\n includeTokenTransfers: incomingTransactions.includeTokenTransfers,\n }),\n transactionLimit: this.config.txHistoryLimit,\n updateTransactions: incomingTransactions.updateTransactions,\n });\n\n this.incomingTransactionHelper.hub.on(\n 'transactions',\n this.onIncomingTransactions.bind(this),\n );\n\n this.incomingTransactionHelper.hub.on(\n 'updatedLastFetchedBlockNumbers',\n this.onUpdatedLastFetchedBlockNumbers.bind(this),\n );\n\n onNetworkStateChange(() => {\n this.ethQuery = new EthQuery(this.provider);\n this.registry = new MethodRegistry({ provider: this.provider });\n });\n\n this.poll();\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - The polling interval used to fetch new transaction statuses.\n */\n async poll(interval?: number): Promise {\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await safelyExecute(() => this.queryTransactionStatuses());\n this.handle = setTimeout(() => {\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `:unapproved` hub event will be emitted once added.\n *\n * @param txParams - Standard parameters for an Ethereum transaction.\n * @param opts - Additional options to control how the transaction is added.\n * @param opts.actionId - Unique ID to prevent duplicate requests.\n * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.\n * @param opts.origin - The origin of the transaction request, such as a dApp hostname.\n * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.\n * @param opts.securityAlertResponse - Response from security validator.\n * @param opts.sendFlowHistory - The sendFlowHistory entries to add.\n * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n txParams: TransactionParams,\n {\n actionId,\n deviceConfirmedOn,\n origin,\n requireApproval,\n securityAlertResponse,\n sendFlowHistory,\n type,\n }: {\n actionId?: string;\n deviceConfirmedOn?: WalletDevice;\n origin?: string;\n requireApproval?: boolean | undefined;\n securityAlertResponse?: Record;\n sendFlowHistory?: SendFlowHistoryEntry[];\n type?: TransactionType;\n } = {},\n ): Promise {\n const chainId = this.getChainId();\n const { transactions } = this.state;\n txParams = normalizeTxParams(txParams);\n const isEIP1559Compatible = await this.getEIP1559Compatibility();\n validateTxParams(txParams, isEIP1559Compatible);\n\n const dappSuggestedGasFees = this.generateDappSuggestedGasFees(\n txParams,\n origin,\n );\n\n const transactionType =\n type ?? (await determineTransactionType(txParams, this.ethQuery)).type;\n\n const existingTransactionMeta = this.getTransactionWithActionId(actionId);\n // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.\n const transactionMeta: TransactionMeta = existingTransactionMeta || {\n // Add actionId to txMeta to check if same actionId is seen again\n actionId,\n chainId,\n dappSuggestedGasFees,\n deviceConfirmedOn,\n id: random(),\n origin,\n securityAlertResponse,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n txParams,\n userEditedGasLimit: false,\n verifiedOnBlockchain: false,\n type: transactionType,\n };\n\n try {\n const { gas, estimateGasError } = await this.estimateGas(txParams);\n txParams.gas = gas;\n txParams.estimateGasError = estimateGasError;\n transactionMeta.originalGasEstimate = gas;\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n return Promise.reject(error);\n }\n\n // Checks if a transaction already exists with a given actionId\n if (!existingTransactionMeta) {\n if (!this.isSendFlowHistoryDisabled) {\n transactionMeta.sendFlowHistory = sendFlowHistory ?? [];\n }\n // Initial history push\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n transactions.push(transactionMeta);\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n }\n\n return {\n result: this.processApproval(transactionMeta, {\n isExisting: Boolean(existingTransactionMeta),\n requireApproval,\n }),\n transactionMeta,\n };\n }\n\n startIncomingTransactionPolling() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionPolling() {\n this.incomingTransactionHelper.stop();\n }\n\n async updateIncomingTransactions() {\n await this.incomingTransactionHelper.update();\n }\n\n /**\n * Creates approvals for all unapproved transactions persisted.\n */\n initApprovals() {\n const chainId = this.getChainId();\n const unapprovedTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.status === TransactionStatus.unapproved &&\n transaction.chainId === chainId,\n );\n\n for (const txMeta of unapprovedTxs) {\n this.processApproval(txMeta, {\n shouldShowRequest: false,\n }).catch((error) => {\n /* istanbul ignore next */\n console.error('Error during persisted transaction approval', error);\n });\n }\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transaction.\n * @param options - The options for the cancellation transaction.\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async stopTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n { estimatedBaseFee }: { estimatedBaseFee?: string } = {},\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n CANCEL_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n CANCEL_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n CANCEL_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.txParams.from,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.txParams.nonce,\n to: transactionMeta.txParams.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n const rawTx = bufferToHex(signedTx.serialize());\n await query(this.ethQuery, 'sendRawTransaction', [rawTx]);\n transactionMeta.estimatedBaseFee = estimatedBaseFee;\n transactionMeta.status = TransactionStatus.cancelled;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionId - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transaction.\n * @param options - The options for the speed up transaction.\n * @param options.actionId - Unique ID to prevent duplicate requests\n * @param options.estimatedBaseFee - The estimated base fee of the transaction.\n */\n async speedUpTransaction(\n transactionId: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n {\n actionId,\n estimatedBaseFee,\n }: { actionId?: string; estimatedBaseFee?: string } = {},\n ) {\n // If transaction is found for same action id, do not create a new speed up transaction.\n if (this.getTransactionWithActionId(actionId)) {\n return;\n }\n\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const { transactions } = this.state;\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.txParams.gasPrice,\n SPEED_UP_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.txParams?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n SPEED_UP_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.txParams?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n SPEED_UP_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n }\n : {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.txParams.from,\n );\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n const rawTx = bufferToHex(signedTx.serialize());\n const hash = await query(this.ethQuery, 'sendRawTransaction', [rawTx]);\n const baseTransactionMeta = {\n ...transactionMeta,\n estimatedBaseFee,\n id: random(),\n time: Date.now(),\n hash,\n actionId,\n originalGasEstimate: transactionMeta.txParams.gas,\n type: TransactionType.retry,\n };\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n txParams: {\n ...transactionMeta.txParams,\n gasPrice: newGasPrice,\n },\n };\n transactions.push(newTransactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: TransactionParams) {\n const estimatedTransaction = { ...transaction };\n const {\n gas,\n gasPrice: providedGasPrice,\n to,\n value,\n data,\n } = estimatedTransaction;\n const gasPrice =\n typeof providedGasPrice === 'undefined'\n ? await query(this.ethQuery, 'gasPrice')\n : providedGasPrice;\n const { providerConfig } = this.getNetworkState();\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n // 1. If gas is already defined on the transaction, use it\n if (typeof gas !== 'undefined') {\n return { gas, gasPrice };\n }\n const { gasLimit } = await query(this.ethQuery, 'getBlockByNumber', [\n 'latest',\n false,\n ]);\n\n // 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.\n // If the network is a custom network then bypass this check and fetch 'estimateGas'.\n /* istanbul ignore next */\n const code = to ? await query(this.ethQuery, 'getCode', [to]) : undefined;\n /* istanbul ignore next */\n if (\n !isCustomNetwork &&\n (!to || (to && !data && (!code || code === '0x')))\n ) {\n return { gas: '0x5208', gasPrice };\n }\n\n // if data, should be hex string format\n estimatedTransaction.data = !data\n ? data\n : /* istanbul ignore next */ addHexPrefix(data);\n\n // 3. If this is a contract address, safely estimate gas using RPC\n estimatedTransaction.value =\n typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;\n const gasLimitBN = hexToBN(gasLimit);\n estimatedTransaction.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n\n let gasHex;\n let estimateGasError;\n try {\n gasHex = await query(this.ethQuery, 'estimateGas', [\n estimatedTransaction,\n ]);\n } catch (error) {\n estimateGasError = ESTIMATE_GAS_ERROR;\n }\n // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a\n // a custom network then return the eth_estimateGas value.\n const gasBN = hexToBN(gasHex);\n const maxGasBN = gasLimitBN.muln(0.9);\n const paddedGasBN = gasBN.muln(1.5);\n /* istanbul ignore next */\n if (gasBN.gt(maxGasBN) || isCustomNetwork) {\n return { gas: addHexPrefix(gasHex), gasPrice, estimateGasError };\n }\n\n /* istanbul ignore next */\n if (paddedGasBN.lt(maxGasBN)) {\n return {\n gas: addHexPrefix(BNToHex(paddedGasBN)),\n gasPrice,\n estimateGasError,\n };\n }\n return { gas: addHexPrefix(BNToHex(maxGasBN)), gasPrice, estimateGasError };\n }\n\n /**\n * Check the status of submitted transactions on the network to determine whether they have\n * been included in a block. Any that have been included in a block are marked as confirmed.\n */\n async queryTransactionStatuses() {\n const { transactions } = this.state;\n const currentChainId = this.getChainId();\n let gotUpdates = false;\n await safelyExecute(() =>\n Promise.all(\n transactions.map(async (meta, index) => {\n if (!meta.verifiedOnBlockchain && meta.chainId === currentChainId) {\n const [reconciledTx, updateRequired] =\n await this.blockchainTransactionStateReconciler(meta);\n if (updateRequired) {\n transactions[index] = reconciledTx;\n gotUpdates = updateRequired;\n }\n }\n }),\n ),\n );\n\n /* istanbul ignore else */\n if (gotUpdates) {\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n }\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n * @param note - A note or update reason to include in the transaction history.\n */\n updateTransaction(transactionMeta: TransactionMeta, note: string) {\n const { transactions } = this.state;\n transactionMeta.txParams = normalizeTxParams(transactionMeta.txParams);\n validateTxParams(transactionMeta.txParams);\n if (!this.isHistoryDisabled) {\n updateTransactionHistory(transactionMeta, note);\n }\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n * @param address - If specified, only transactions originating from this address will be\n * wiped on current network.\n */\n wipeTransactions(ignoreNetwork?: boolean, address?: string) {\n /* istanbul ignore next */\n if (ignoreNetwork && !address) {\n this.update({ transactions: [] });\n return;\n }\n const currentChainId = this.getChainId();\n const newTransactions = this.state.transactions.filter(\n ({ chainId, txParams }) => {\n const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;\n\n if (!isMatchingNetwork) {\n return true;\n }\n\n const isMatchingAddress =\n !address || txParams.from?.toLowerCase() === address.toLowerCase();\n\n return !isMatchingAddress;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n startIncomingTransactionProcessing() {\n this.incomingTransactionHelper.start();\n }\n\n stopIncomingTransactionProcessing() {\n this.incomingTransactionHelper.stop();\n }\n\n /**\n * Adds external provided transaction to state as confirmed transaction.\n *\n * @param transactionMeta - TransactionMeta to add transactions.\n * @param transactionReceipt - TransactionReceipt of the external transaction.\n * @param baseFeePerGas - Base fee per gas of the external transaction.\n */\n async confirmExternalTransaction(\n transactionMeta: TransactionMeta,\n transactionReceipt: TransactionReceipt,\n baseFeePerGas: Hex,\n ) {\n // Run validation and add external transaction to state.\n this.addExternalTransaction(transactionMeta);\n\n try {\n const transactionId = transactionMeta.id;\n\n // Make sure status is confirmed and define gasUsed as in receipt.\n transactionMeta.status = TransactionStatus.confirmed;\n transactionMeta.txReceipt = transactionReceipt;\n if (baseFeePerGas) {\n transactionMeta.baseFeePerGas = baseFeePerGas;\n }\n\n // Update same nonce local transactions as dropped and define replacedBy properties.\n this.markNonceDuplicatesDropped(transactionId);\n\n // Update external provided transaction with updated gas values and confirmed status.\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:confirmExternalTransaction - Add external transaction',\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n /**\n * Append new send flow history to a transaction.\n *\n * @param transactionID - The ID of the transaction to update.\n * @param currentSendFlowHistoryLength - The length of the current sendFlowHistory array.\n * @param sendFlowHistoryToAdd - The sendFlowHistory entries to add.\n * @returns The updated transactionMeta.\n */\n updateTransactionSendFlowHistory(\n transactionID: string,\n currentSendFlowHistoryLength: number,\n sendFlowHistoryToAdd: SendFlowHistoryEntry[],\n ): TransactionMeta {\n if (this.isSendFlowHistoryDisabled) {\n throw new Error(\n 'Send flow history is disabled for the current transaction controller',\n );\n }\n\n const transactionMeta = this.getTransaction(transactionID);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update send flow history as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionSendFlowHistory',\n );\n\n if (\n currentSendFlowHistoryLength ===\n (transactionMeta?.sendFlowHistory?.length || 0)\n ) {\n transactionMeta.sendFlowHistory = [\n ...(transactionMeta?.sendFlowHistory ?? []),\n ...sendFlowHistoryToAdd,\n ];\n this.updateTransaction(\n transactionMeta,\n 'TransactionController:updateTransactionSendFlowHistory - sendFlowHistory updated',\n );\n }\n\n return this.getTransaction(transactionID) as TransactionMeta;\n }\n\n /**\n * Update the gas values of a transaction.\n *\n * @param transactionId - The ID of the transaction to update.\n * @param gasValues - Gas values to update.\n * @param gasValues.gas - Same as transaction.gasLimit.\n * @param gasValues.gasLimit - Maxmimum number of units of gas to use for this transaction.\n * @param gasValues.gasPrice - Price per gas for legacy transactions.\n * @param gasValues.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.\n * @param gasValues.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.\n * @param gasValues.estimateUsed - Which estimate level was used.\n * @param gasValues.estimateSuggested - Which estimate level that the API suggested.\n * @param gasValues.defaultGasEstimates - The default estimate for gas.\n * @param gasValues.originalGasEstimate - Original estimate for gas.\n * @param gasValues.userEditedGasLimit - The gas limit supplied by user.\n * @param gasValues.userFeeLevel - Estimate level user selected.\n * @returns The updated transactionMeta.\n */\n updateTransactionGasFees(\n transactionId: string,\n {\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n }: {\n defaultGasEstimates?: string;\n estimateUsed?: string;\n estimateSuggested?: string;\n gas?: string;\n gasLimit?: string;\n gasPrice?: string;\n maxPriorityFeePerGas?: string;\n maxFeePerGas?: string;\n originalGasEstimate?: string;\n userEditedGasLimit?: boolean;\n userFeeLevel?: string;\n },\n ): TransactionMeta {\n const transactionMeta = this.getTransaction(transactionId);\n\n if (!transactionMeta) {\n throw new Error(\n `Cannot update transaction as no transaction metadata found`,\n );\n }\n\n validateIfTransactionUnapproved(\n transactionMeta,\n 'updateTransactionGasFees',\n );\n\n let transactionGasFees = {\n txParams: {\n gas,\n gasLimit,\n gasPrice,\n maxPriorityFeePerGas,\n maxFeePerGas,\n },\n defaultGasEstimates,\n estimateUsed,\n estimateSuggested,\n originalGasEstimate,\n userEditedGasLimit,\n userFeeLevel,\n } as any;\n\n // only update what is defined\n transactionGasFees.txParams = pickBy(transactionGasFees.txParams);\n transactionGasFees = pickBy(transactionGasFees);\n\n // merge updated gas values with existing transaction meta\n const updatedMeta = merge(transactionMeta, transactionGasFees);\n\n this.updateTransaction(\n updatedMeta,\n 'TransactionController:updateTransactionGasFees - gas values updated',\n );\n\n return this.getTransaction(transactionId) as TransactionMeta;\n }\n\n private async processApproval(\n transactionMeta: TransactionMeta,\n {\n isExisting = false,\n requireApproval,\n shouldShowRequest = true,\n }: {\n isExisting?: boolean;\n requireApproval?: boolean | undefined;\n shouldShowRequest?: boolean;\n },\n ): Promise {\n const transactionId = transactionMeta.id;\n let resultCallbacks: AcceptResultCallbacks | undefined;\n const { meta, isCompleted } = this.isTransactionCompleted(transactionId);\n const finishedPromise = isCompleted\n ? Promise.resolve(meta)\n : this.waitForTransactionFinished(transactionId);\n\n if (meta && !isExisting && !isCompleted) {\n try {\n if (requireApproval !== false) {\n const acceptResult = await this.requestApproval(transactionMeta, {\n shouldShowRequest,\n });\n resultCallbacks = acceptResult.resultCallbacks;\n }\n\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n\n if (!isTxCompleted) {\n await this.approveTransaction(transactionId);\n }\n } catch (error: any) {\n const { isCompleted: isTxCompleted } =\n this.isTransactionCompleted(transactionId);\n if (!isTxCompleted) {\n if (error.code === errorCodes.provider.userRejectedRequest) {\n this.cancelTransaction(transactionId);\n\n throw providerErrors.userRejectedRequest(\n 'User rejected the transaction',\n );\n } else {\n this.failTransaction(meta, error);\n }\n }\n }\n }\n\n const finalMeta = await finishedPromise;\n\n switch (finalMeta?.status) {\n case TransactionStatus.failed:\n resultCallbacks?.error(finalMeta.error);\n throw rpcErrors.internal(finalMeta.error.message);\n\n case TransactionStatus.cancelled:\n const cancelError = rpcErrors.internal(\n 'User cancelled the transaction',\n );\n\n resultCallbacks?.error(cancelError);\n throw cancelError;\n\n case TransactionStatus.submitted:\n resultCallbacks?.success();\n return finalMeta.hash as string;\n\n default:\n const internalError = rpcErrors.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n finalMeta || transactionId,\n )}`,\n );\n\n resultCallbacks?.error(internalError);\n throw internalError;\n }\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `:finished` hub event is fired after success or failure.\n *\n * @param transactionId - The ID of the transaction to approve.\n */\n private async approveTransaction(transactionId: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const chainId = this.getChainId();\n const index = transactions.findIndex(({ id }) => transactionId === id);\n const transactionMeta = transactions[index];\n const {\n txParams: { nonce, from },\n } = transactionMeta;\n let nonceLock;\n try {\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!chainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n const { approved: status } = TransactionStatus;\n let nonceToUse = nonce;\n // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction\n // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce\n if (!nonceToUse) {\n nonceLock = await this.nonceTracker.getNonceLock(from);\n nonceToUse = addHexPrefix(nonceLock.nextNonce.toString(16));\n }\n\n transactionMeta.status = status;\n transactionMeta.txParams.nonce = nonceToUse;\n transactionMeta.txParams.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.txParams);\n\n const txParams = isEIP1559\n ? {\n ...baseTxParams,\n maxFeePerGas: transactionMeta.txParams.maxFeePerGas,\n maxPriorityFeePerGas: transactionMeta.txParams.maxPriorityFeePerGas,\n estimatedBaseFee: transactionMeta.txParams.estimatedBaseFee,\n // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set\n type: 2,\n }\n : baseTxParams;\n\n // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set\n if (isEIP1559) {\n delete txParams.gasPrice;\n }\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n const signedTx = await this.sign(unsignedEthTx, from);\n await this.updateTransactionMetaRSV(transactionMeta, signedTx);\n transactionMeta.status = TransactionStatus.signed;\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction signed',\n );\n\n const rawTx = bufferToHex(signedTx.serialize());\n transactionMeta.rawTx = rawTx;\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - RawTransaction added',\n );\n const hash = await query(this.ethQuery, 'sendRawTransaction', [rawTx]);\n transactionMeta.hash = hash;\n transactionMeta.status = TransactionStatus.submitted;\n transactionMeta.submittedTime = new Date().getTime();\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#approveTransaction - Transaction submitted',\n );\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n // must set transaction to submitted/failed before releasing lock\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n releaseLock();\n }\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionId - The ID of the transaction to cancel.\n */\n private cancelTransaction(transactionId: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionId,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionId,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseController update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n\n const txsToKeep = transactions\n .sort((a, b) => (a.time > b.time ? -1 : 1)) // Descending time order\n .filter((tx) => {\n const { chainId, status, txParams, time } = tx;\n\n if (txParams) {\n const key = `${txParams.nonce}-${convertHexToDecimal(\n chainId,\n )}-${new Date(time).toDateString()}`;\n\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n\n return false;\n });\n\n txsToKeep.reverse(); // Ascending time order\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed ||\n status === TransactionStatus.cancelled\n );\n }\n\n /**\n * Whether the transaction has at least completed all local processing.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isLocalFinalState(status: TransactionStatus): boolean {\n return [\n TransactionStatus.cancelled,\n TransactionStatus.confirmed,\n TransactionStatus.failed,\n TransactionStatus.rejected,\n TransactionStatus.submitted,\n ].includes(status);\n }\n\n /**\n * Method to verify the state of a transaction using the Blockchain as a source of truth.\n *\n * @param meta - The local transaction to verify on the blockchain.\n * @returns A tuple containing the updated transaction, and whether or not an update was required.\n */\n private async blockchainTransactionStateReconciler(\n meta: TransactionMeta,\n ): Promise<[TransactionMeta, boolean]> {\n const { status, hash } = meta;\n switch (status) {\n case TransactionStatus.confirmed:\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n hash,\n ]);\n\n if (!txReceipt) {\n return [meta, false];\n }\n\n const txBlock = await query(this.ethQuery, 'getBlockByHash', [\n txReceipt.blockHash,\n ]);\n\n meta.verifiedOnBlockchain = true;\n meta.txParams.gasUsed = txReceipt.gasUsed;\n meta.txReceipt = txReceipt;\n meta.baseFeePerGas = txBlock?.baseFeePerGas;\n meta.blockTimestamp = txBlock?.timestamp;\n\n // According to the Web3 docs:\n // TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n if (Number(txReceipt.status) === 0) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was reversed',\n );\n this.failTransaction(meta, error);\n return [meta, false];\n }\n\n return [meta, true];\n case TransactionStatus.submitted:\n const txObj = await query(this.ethQuery, 'getTransactionByHash', [\n hash,\n ]);\n\n if (!txObj) {\n const receiptShowsFailedStatus =\n await this.checkTxReceiptStatusIsFailed(hash);\n\n // Case the txObj is evaluated as false, a second check will\n // determine if the tx failed or it is pending or confirmed\n if (receiptShowsFailedStatus) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was dropped or replaced by a new one',\n );\n this.failTransaction(meta, error);\n }\n }\n\n /* istanbul ignore next */\n if (txObj?.blockNumber) {\n meta.status = TransactionStatus.confirmed;\n this.hub.emit(`${meta.id}:confirmed`, meta);\n return [meta, true];\n }\n\n return [meta, false];\n default:\n return [meta, false];\n }\n }\n\n /**\n * Method to check if a tx has failed according to their receipt\n * According to the Web3 docs:\n * TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n * The receipt is not available for pending transactions and returns null.\n *\n * @param txHash - The transaction hash.\n * @returns Whether the transaction has failed.\n */\n private async checkTxReceiptStatusIsFailed(\n txHash: string | undefined,\n ): Promise {\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n txHash,\n ]);\n if (!txReceipt) {\n // Transaction is pending\n return false;\n }\n return Number(txReceipt.status) === 0;\n }\n\n private async requestApproval(\n txMeta: TransactionMeta,\n { shouldShowRequest }: { shouldShowRequest: boolean },\n ): Promise {\n const id = this.getApprovalId(txMeta);\n const { origin } = txMeta;\n const type = ApprovalType.Transaction;\n const requestData = { txId: txMeta.id };\n\n return (await this.messagingSystem.call(\n 'ApprovalController:addRequest',\n {\n id,\n origin: origin || ORIGIN_METAMASK,\n type,\n requestData,\n expectsResult: true,\n },\n shouldShowRequest,\n )) as Promise;\n }\n\n private getTransaction(transactionId: string): TransactionMeta | undefined {\n const { transactions } = this.state;\n return transactions.find(({ id }) => id === transactionId);\n }\n\n private getApprovalId(txMeta: TransactionMeta) {\n return String(txMeta.id);\n }\n\n private isTransactionCompleted(transactionId: string): {\n meta?: TransactionMeta;\n isCompleted: boolean;\n } {\n const transaction = this.getTransaction(transactionId);\n\n if (!transaction) {\n return { meta: undefined, isCompleted: false };\n }\n\n const isCompleted = this.isLocalFinalState(transaction.status);\n\n return { meta: transaction, isCompleted };\n }\n\n private getChainId(): Hex {\n const { providerConfig } = this.getNetworkState();\n return providerConfig.chainId;\n }\n\n private prepareUnsignedEthTx(\n txParams: Record,\n ): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns common configuration object\n */\n private getCommonConfiguration(): Common {\n const {\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (\n chain !== RPC &&\n chain !== NetworkType['linea-goerli'] &&\n chain !== NetworkType['linea-mainnet']\n ) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams: Partial = {\n name,\n chainId: parseInt(chainId, 16),\n defaultHardfork: HARDFORK,\n };\n\n return Common.custom(customChainParams);\n }\n\n private onIncomingTransactions({\n added,\n updated,\n }: {\n added: TransactionMeta[];\n updated: TransactionMeta[];\n }) {\n const { transactions: currentTransactions } = this.state;\n\n const updatedTransactions = [\n ...added,\n ...currentTransactions.map((originalTransaction) => {\n const updatedTransaction = updated.find(\n ({ hash }) => hash === originalTransaction.hash,\n );\n\n return updatedTransaction ?? originalTransaction;\n }),\n ];\n\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n private onUpdatedLastFetchedBlockNumbers({\n lastFetchedBlockNumbers,\n blockNumber,\n }: {\n lastFetchedBlockNumbers: {\n [key: string]: number;\n };\n blockNumber: number;\n }) {\n this.update({ lastFetchedBlockNumbers });\n this.hub.emit('incomingTransactionBlock', blockNumber);\n }\n\n private generateDappSuggestedGasFees(\n txParams: TransactionParams,\n origin?: string,\n ): DappSuggestedGasFees | undefined {\n if (!origin || origin === ORIGIN_METAMASK) {\n return undefined;\n }\n\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;\n\n if (\n gasPrice === undefined &&\n maxFeePerGas === undefined &&\n maxPriorityFeePerGas === undefined &&\n gas === undefined\n ) {\n return undefined;\n }\n\n const dappSuggestedGasFees: DappSuggestedGasFees = {};\n\n if (gasPrice !== undefined) {\n dappSuggestedGasFees.gasPrice = gasPrice;\n } else if (\n maxFeePerGas !== undefined ||\n maxPriorityFeePerGas !== undefined\n ) {\n dappSuggestedGasFees.maxFeePerGas = maxFeePerGas;\n dappSuggestedGasFees.maxPriorityFeePerGas = maxPriorityFeePerGas;\n }\n\n if (gas !== undefined) {\n dappSuggestedGasFees.gas = gas;\n }\n\n return dappSuggestedGasFees;\n }\n\n /**\n * Validates and adds external provided transaction to state.\n *\n * @param transactionMeta - Nominated external transaction to be added to state.\n */\n private async addExternalTransaction(transactionMeta: TransactionMeta) {\n const chainId = this.getChainId();\n const { transactions } = this.state;\n const fromAddress = transactionMeta?.txParams?.from;\n const sameFromAndNetworkTransactions = transactions.filter(\n (transaction) =>\n transaction.txParams.from === fromAddress &&\n transaction.chainId === chainId,\n );\n const confirmedTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.confirmed,\n );\n const pendingTxs = sameFromAndNetworkTransactions.filter(\n (transaction) => transaction.status === TransactionStatus.submitted,\n );\n\n validateConfirmedExternalTransaction(\n transactionMeta,\n confirmedTxs,\n pendingTxs,\n );\n\n // Make sure provided external transaction has non empty history array\n if (!(transactionMeta.history ?? []).length) {\n if (!this.isHistoryDisabled) {\n addInitialHistorySnapshot(transactionMeta);\n }\n }\n\n const updatedTransactions = [...transactions, transactionMeta];\n this.update({\n transactions: this.trimTransactionsForState(updatedTransactions),\n });\n }\n\n /**\n * Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions\n * in the transactions have the same nonce.\n *\n * @param transactionId - Used to identify original transaction.\n */\n private markNonceDuplicatesDropped(transactionId: string) {\n const chainId = this.getChainId();\n const transactionMeta = this.getTransaction(transactionId);\n const nonce = transactionMeta?.txParams?.nonce;\n const from = transactionMeta?.txParams?.from;\n const sameNonceTxs = this.state.transactions.filter(\n (transaction) =>\n transaction.txParams.from === from &&\n transaction.txParams.nonce === nonce &&\n transaction.chainId === chainId,\n );\n\n if (!sameNonceTxs.length) {\n return;\n }\n\n // Mark all same nonce transactions as dropped and give it a replacedBy hash\n for (const transaction of sameNonceTxs) {\n if (transaction.id === transactionId) {\n continue;\n }\n transaction.replacedBy = transactionMeta?.hash;\n transaction.replacedById = transactionMeta?.id;\n // Drop any transaction that wasn't previously failed (off chain failure)\n if (transaction.status !== TransactionStatus.failed) {\n this.setTransactionStatusDropped(transaction);\n }\n }\n }\n\n /**\n * Method to set transaction status to dropped.\n *\n * @param transactionMeta - TransactionMeta of transaction to be marked as dropped.\n */\n private setTransactionStatusDropped(transactionMeta: TransactionMeta) {\n transactionMeta.status = TransactionStatus.dropped;\n this.updateTransaction(\n transactionMeta,\n 'TransactionController#setTransactionStatusDropped - Transaction dropped',\n );\n }\n\n /**\n * Get transaction with provided actionId.\n *\n * @param actionId - Unique ID to prevent duplicate requests\n * @returns the filtered transaction\n */\n private getTransactionWithActionId(actionId?: string) {\n return this.state.transactions.find(\n (transaction) => actionId && transaction.actionId === actionId,\n );\n }\n\n private async waitForTransactionFinished(\n transactionId: string,\n ): Promise {\n return new Promise((resolve) => {\n this.hub.once(`${transactionId}:finished`, (txMeta) => {\n resolve(txMeta);\n });\n });\n }\n\n /**\n * Updates the r, s, and v properties of a TransactionMeta object\n * with values from a signed transaction.\n *\n * @param transactionMeta - The TransactionMeta object to update.\n * @param signedTx - The encompassing type for all transaction types containing r, s, and v values.\n */\n private async updateTransactionMetaRSV(\n transactionMeta: TransactionMeta,\n signedTx: TypedTransaction,\n ): Promise {\n if (signedTx.r) {\n transactionMeta.r = addHexPrefix(signedTx.r.toString(16));\n }\n\n if (signedTx.s) {\n transactionMeta.s = addHexPrefix(signedTx.s.toString(16));\n }\n\n if (signedTx.v) {\n transactionMeta.v = addHexPrefix(signedTx.v.toString(16));\n }\n }\n\n private async getEIP1559Compatibility() {\n const currentNetworkIsEIP1559Compatible =\n await this.getCurrentNetworkEIP1559Compatibility();\n const currentAccountIsEIP1559Compatible =\n this.getCurrentAccountEIP1559Compatibility?.() ?? true;\n\n return (\n currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible\n );\n }\n}\n\nexport default TransactionController;\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/constants.d.ts b/node_modules/@metamask/transaction-controller/dist/constants.d.ts +index fff2c5c..e809bd0 100644 +--- a/node_modules/@metamask/transaction-controller/dist/constants.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/constants.d.ts +@@ -5,7 +5,7 @@ export declare const CHAIN_IDS: { + 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"; +@@ -14,6 +14,7 @@ export declare const CHAIN_IDS: { + readonly FANTOM_TESTNET: "0xfa2"; + readonly SEPOLIA: "0xaa36a7"; + readonly LINEA_GOERLI: "0xe704"; ++ readonly LINEA_SEPOLIA: "0xe705"; + readonly LINEA_MAINNET: "0xe708"; + readonly MOONBEAM: "0x504"; + readonly MOONBEAM_TESTNET: "0x507"; +@@ -39,6 +40,10 @@ export declare const ETHERSCAN_SUPPORTED_NETWORKS: { + domain: string; + subdomain: string; + }; ++ "0xe705": { ++ domain: string; ++ subdomain: string; ++ }; + "0xe708": { + domain: string; + subdomain: string; +@@ -55,7 +60,7 @@ export declare const ETHERSCAN_SUPPORTED_NETWORKS: { + domain: string; + subdomain: string; + }; +- "0x1a4": { ++ "0xaa37dc": { + domain: string; + subdomain: string; + }; +diff --git a/node_modules/@metamask/transaction-controller/dist/constants.d.ts.map b/node_modules/@metamask/transaction-controller/dist/constants.d.ts.map +deleted file mode 100644 +index 7fe8678..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/constants.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAC;AAEX,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,kCAAkC,QAAQ,CAAC;AAExD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ExC,CAAC;AAEF,eAAO,MAAM,sBAAsB,mBAGlC,CAAC;AAIF,eAAO,MAAM,kCAAkC,mBAM9C,CAAC"} +\ 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 +index 3a2ead9..9d95f79 100644 +--- a/node_modules/@metamask/transaction-controller/dist/constants.js ++++ b/node_modules/@metamask/transaction-controller/dist/constants.js +@@ -8,7 +8,7 @@ exports.CHAIN_IDS = { + BSC: '0x38', + BSC_TESTNET: '0x61', + OPTIMISM: '0xa', +- OPTIMISM_TESTNET: '0x1a4', ++ OPTIMISM_SEPOLIA: '0xaa37dc', + POLYGON: '0x89', + POLYGON_TESTNET: '0x13881', + AVALANCHE: '0xa86a', +@@ -17,6 +17,7 @@ exports.CHAIN_IDS = { + FANTOM_TESTNET: '0xfa2', + SEPOLIA: '0xaa36a7', + LINEA_GOERLI: '0xe704', ++ LINEA_SEPOLIA: '0xe705', + LINEA_MAINNET: '0xe708', + MOONBEAM: '0x504', + MOONBEAM_TESTNET: '0x507', +@@ -42,6 +43,10 @@ exports.ETHERSCAN_SUPPORTED_NETWORKS = { + domain: 'lineascan.build', + subdomain: 'goerli', + }, ++ [exports.CHAIN_IDS.LINEA_SEPOLIA]: { ++ domain: 'lineascan.build', ++ subdomain: 'sepolia', ++ }, + [exports.CHAIN_IDS.LINEA_MAINNET]: { + domain: 'lineascan.build', + subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, +@@ -58,9 +63,9 @@ exports.ETHERSCAN_SUPPORTED_NETWORKS = { + domain: exports.DEFAULT_ETHERSCAN_DOMAIN, + subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`, + }, +- [exports.CHAIN_IDS.OPTIMISM_TESTNET]: { ++ [exports.CHAIN_IDS.OPTIMISM_SEPOLIA]: { + domain: exports.DEFAULT_ETHERSCAN_DOMAIN, +- subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`, ++ subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`, + }, + [exports.CHAIN_IDS.POLYGON]: { + domain: 'polygonscan.com', +diff --git a/node_modules/@metamask/transaction-controller/dist/constants.js.map b/node_modules/@metamask/transaction-controller/dist/constants.js.map +deleted file mode 100644 +index 8e7d444..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/constants.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAE7B,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,MAAM;IACX,W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AY;KAC7D;IACD,CAAC,iBAAS,CAAC,MAAM,CAAC,EAAE;QAClB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,GAAG,0CAAkC,SAAS;KAC1D;CACF,CAAC;AAEW,QAAA,sBAAsB,GAAG;IACpC,uBAAe,CAAC,IAAI;IACpB,uBAAe,CAAC,YAAY;CAC7B,CAAC;AAEF,4EAA4E;AAC5E,uCAAuC;AAC1B,QAAA,kCAAkC,GAAG;IAChD,GAAG,8BAAsB;IACzB,uBAAe,CAAC,UAAU;IAC1B,uBAAe,CAAC,mBAAmB;IACnC,uBAAe,CAAC,uBAAuB;IACvC,uBAAe,CAAC,mBAAmB;CACpC,CAAC","sourcesContent":["import { TransactionType } from './types';\n\nexport const CHAIN_IDS = {\n MAINNET: '0x1',\n GOERLI: '0x5',\n BSC: '0x38',\n BSC_TESTNET: '0x61',\n OPTIMISM: '0xa',\n OPTIMISM_TESTNET: '0x1a4',\n POLYGON: '0x89',\n POLYGON_TESTNET: '0x13881',\n AVALANCHE: '0xa86a',\n AVALANCHE_TESTNET: '0xa869',\n FANTOM: '0xfa',\n FANTOM_TESTNET: '0xfa2',\n SEPOLIA: '0xaa36a7',\n LINEA_GOERLI: '0xe704',\n LINEA_MAINNET: '0xe708',\n MOONBEAM: '0x504',\n MOONBEAM_TESTNET: '0x507',\n MOONRIVER: '0x505',\n GNOSIS: '0x64',\n} as const;\n\nexport const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';\nexport const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';\n\nexport const ETHERSCAN_SUPPORTED_NETWORKS = {\n [CHAIN_IDS.GOERLI]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,\n },\n [CHAIN_IDS.MAINNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.SEPOLIA]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,\n },\n [CHAIN_IDS.LINEA_GOERLI]: {\n domain: 'lineascan.build',\n subdomain: 'goerli',\n },\n [CHAIN_IDS.LINEA_MAINNET]: {\n domain: 'lineascan.build',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC]: {\n domain: 'bscscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.BSC_TESTNET]: {\n domain: 'bscscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.OPTIMISM]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,\n },\n [CHAIN_IDS.OPTIMISM_TESTNET]: {\n domain: DEFAULT_ETHERSCAN_DOMAIN,\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,\n },\n [CHAIN_IDS.POLYGON]: {\n domain: 'polygonscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.POLYGON_TESTNET]: {\n domain: 'polygonscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,\n },\n [CHAIN_IDS.AVALANCHE]: {\n domain: 'snowtrace.io',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.AVALANCHE_TESTNET]: {\n domain: 'snowtrace.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.FANTOM]: {\n domain: 'ftmscan.com',\n subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,\n },\n [CHAIN_IDS.FANTOM_TESTNET]: {\n domain: 'ftmscan.com',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,\n },\n [CHAIN_IDS.MOONBEAM]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,\n },\n [CHAIN_IDS.MOONBEAM_TESTNET]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,\n },\n [CHAIN_IDS.MOONRIVER]: {\n domain: 'moonscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,\n },\n [CHAIN_IDS.GNOSIS]: {\n domain: 'gnosisscan.io',\n subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,\n },\n};\n\nexport const SWAP_TRANSACTION_TYPES = [\n TransactionType.swap,\n TransactionType.swapApproval,\n];\n\n// Only certain types of transactions should be allowed to be specified when\n// adding a new unapproved transaction.\nexport const VALID_UNAPPROVED_TRANSACTION_TYPES = [\n ...SWAP_TRANSACTION_TYPES,\n TransactionType.simpleSend,\n TransactionType.tokenMethodTransfer,\n TransactionType.tokenMethodTransferFrom,\n TransactionType.contractInteraction,\n];\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map +deleted file mode 100644 +index 089ab8f..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"etherscan.d.ts","sourceRoot":"","sources":["../src/etherscan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAK3C,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,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4B,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/etherscan.js.map b/node_modules/@metamask/transaction-controller/dist/etherscan.js.map +deleted file mode 100644 +index 070ac33..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/etherscan.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"etherscan.js","sourceRoot":"","sources":["../src/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AAGzD,2CAA2D;AAC3D,qCAA6D;AAkD7D;;;;;;;;;GASG;AACH,SAAsB,0BAA0B,CAAC,EAC/C,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,QAAQ,EAAE;YACvC,OAAO;YACP,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAdD,gEAcC;AAED;;;;;;;;;GASG;AACH,SAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,SAAS,EAAE;YACxC,OAAO;YACP,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAdD,0EAcC;AAED;;;;;;;;;;GAUG;AACH,SAAe,iBAAiB,CAC9B,MAAc,EACd,EACE,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GAMN;;QAED,MAAM,SAAS,GAAG;YAChB,MAAM,EAAE,SAAS;YACjB,OAAO;YACP,UAAU,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE;YACjC,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE;YACzB,IAAI,EAAE,MAAM;SACb,CAAC;QAEF,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,kCAC5C,SAAS,KACZ,MAAM,IACN,CAAC;QAEH,IAAA,mCAAG,EAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,8BAAW,EACjC,cAAc,CACf,CAAoC,CAAC;QAEtC,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,OAAY,EACZ,SAA6C;IAI7C,MAAM,WAAW,GAAG,wCAA4B,CAAC,OAA2B,CAAC,CAAC;IAE9E,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,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,wCAAwC;IACxC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,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\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\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n txreceipt_status: string;\n}\n\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\nexport interface EtherscanTransactionResponse<\n T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n message?: string;\n result: string | T[];\n}\n\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 // eslint-disable-next-line guard-for-in\n for (const paramKey in 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/external-transactions.d.ts.map b/node_modules/@metamask/transaction-controller/dist/external-transactions.d.ts.map +deleted file mode 100644 +index 4a72b53..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/external-transactions.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"external-transactions.d.ts","sourceRoot":"","sources":["../src/external-transactions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;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/external-transactions.js.map b/node_modules/@metamask/transaction-controller/dist/external-transactions.js.map +deleted file mode 100644 +index d92c9fc..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/external-transactions.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"external-transactions.js","sourceRoot":"","sources":["../src/external-transactions.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,qDAAiD;AAEjD,mCAA4C;AAG5C;;;;;;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/gas-flows/DefaultGasFeeFlow.d.ts b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts +new file mode 100644 +index 0000000..325802b +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts +@@ -0,0 +1,10 @@ ++import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types'; ++/** ++ * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController. ++ */ ++export declare class DefaultGasFeeFlow implements GasFeeFlow { ++ #private; ++ matchesTransaction(_transactionMeta: TransactionMeta): boolean; ++ getGasFees(request: GasFeeFlowRequest): Promise; ++} ++//# sourceMappingURL=DefaultGasFeeFlow.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +new file mode 100644 +index 0000000..7ed6d78 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"DefaultGasFeeFlow.d.ts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAGV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAC;AAiBlB;;GAEG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAClD,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4E1E"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js +new file mode 100644 +index 0000000..24ecb29 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js +@@ -0,0 +1,79 @@ ++"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 __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 _DefaultGasFeeFlow_instances, _DefaultGasFeeFlow_getEstimateLevel, _DefaultGasFeeFlow_getFeeMarketLevel, _DefaultGasFeeFlow_getLegacyLevel, _DefaultGasFeeFlow_gweiDecimalToWeiHex; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.DefaultGasFeeFlow = 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 logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'default-gas-fee-flow'); ++/** ++ * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController. ++ */ ++class DefaultGasFeeFlow { ++ constructor() { ++ _DefaultGasFeeFlow_instances.add(this); ++ } ++ matchesTransaction(_transactionMeta) { ++ return true; ++ } ++ getGasFees(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { getGasFeeControllerEstimates } = request; ++ const { gasEstimateType, gasFeeEstimates } = yield getGasFeeControllerEstimates(); ++ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { ++ log('Using fee market estimates', gasFeeEstimates); ++ } ++ else if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) { ++ log('Using legacy estimates', gasFeeEstimates); ++ } ++ else { ++ throw new Error(`'No gas fee estimates available`); ++ } ++ const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getEstimateLevel).call(this, { ++ gasEstimateType, ++ gasFeeEstimates, ++ level, ++ }) })), {}); ++ return { estimates }; ++ }); ++ } ++} ++exports.DefaultGasFeeFlow = DefaultGasFeeFlow; ++_DefaultGasFeeFlow_instances = new WeakSet(), _DefaultGasFeeFlow_getEstimateLevel = function _DefaultGasFeeFlow_getEstimateLevel({ gasEstimateType, gasFeeEstimates, level, }) { ++ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { ++ return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getFeeMarketLevel).call(this, gasFeeEstimates, level); ++ } ++ return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getLegacyLevel).call(this, gasFeeEstimates, level); ++}, _DefaultGasFeeFlow_getFeeMarketLevel = function _DefaultGasFeeFlow_getFeeMarketLevel(gasFeeEstimates, level) { ++ const maxFeePerGas = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level].suggestedMaxFeePerGas); ++ const maxPriorityFeePerGas = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level].suggestedMaxPriorityFeePerGas); ++ return { ++ maxFeePerGas, ++ maxPriorityFeePerGas, ++ }; ++}, _DefaultGasFeeFlow_getLegacyLevel = function _DefaultGasFeeFlow_getLegacyLevel(gasFeeEstimates, level) { ++ const gasPrice = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level]); ++ return { ++ maxFeePerGas: gasPrice, ++ maxPriorityFeePerGas: gasPrice, ++ }; ++}, _DefaultGasFeeFlow_gweiDecimalToWeiHex = function _DefaultGasFeeFlow_gweiDecimalToWeiHex(gweiDecimal) { ++ return (0, controller_utils_1.toHex)((0, controller_utils_1.gweiDecToWEIBN)(gweiDecimal)); ++}; ++//# sourceMappingURL=DefaultGasFeeFlow.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map +new file mode 100644 +index 0000000..436f84f +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"DefaultGasFeeFlow.js","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAAmE;AAKnE,qEAAkE;AAElE,2CAAqD;AAErD,sCAA0C;AAS1C,oCAA+C;AAE/C,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa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uFAGC,eAA0C,EAC1C,KAA0B;IAE1B,MAAM,YAAY,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EACvB,eAAe,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAC7C,CAAC;IAEF,MAAM,oBAAoB,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAC/B,eAAe,CAAC,KAAK,CAAC,CAAC,6BAA6B,CACrD,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,iFAGC,eAAuC,EACvC,KAA0B;IAE1B,MAAM,QAAQ,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAAsB,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAEnE,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,oBAAoB,EAAE,QAAQ;KAC/B,CAAC;AACJ,CAAC,2FAEoB,WAAmB;IACtC,OAAO,IAAA,wBAAK,EAAC,IAAA,iCAAc,EAAC,WAAW,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { gweiDecToWEIBN, toHex } from '@metamask/controller-utils';\nimport type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeEstimatesForLevel,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\ntype FeeMarketGetEstimateLevelRequest = {\n gasEstimateType: 'fee-market';\n gasFeeEstimates: FeeMarketGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\n\ntype LegacyGetEstimateLevelRequest = {\n gasEstimateType: 'legacy';\n gasFeeEstimates: LegacyGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise {\n const { getGasFeeControllerEstimates } = request;\n\n const { gasEstimateType, gasFeeEstimates } =\n await getGasFeeControllerEstimates();\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n log('Using fee market estimates', gasFeeEstimates);\n } else if (gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n log('Using legacy estimates', gasFeeEstimates);\n } else {\n throw new Error(`'No gas fee estimates available`);\n }\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n } as FeeMarketGetEstimateLevelRequest | LegacyGetEstimateLevelRequest),\n }),\n {} as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n }:\n | FeeMarketGetEstimateLevelRequest\n | LegacyGetEstimateLevelRequest): GasFeeEstimatesForLevel {\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n return this.#getFeeMarketLevel(gasFeeEstimates, level);\n }\n\n return this.#getLegacyLevel(gasFeeEstimates, level);\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): GasFeeEstimatesForLevel {\n const maxFeePerGas = this.#gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = this.#gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): GasFeeEstimatesForLevel {\n const gasPrice = this.#gweiDecimalToWeiHex(gasFeeEstimates[level]);\n\n return {\n maxFeePerGas: gasPrice,\n maxPriorityFeePerGas: gasPrice,\n };\n }\n\n #gweiDecimalToWeiHex(gweiDecimal: string): Hex {\n return toHex(gweiDecToWEIBN(gweiDecimal));\n }\n}\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts +new file mode 100644 +index 0000000..ce728db +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts +@@ -0,0 +1,12 @@ ++import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types'; ++/** ++ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using: ++ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee. ++ * - Static multipliers to increase the base and priority fees. ++ */ ++export declare class LineaGasFeeFlow implements GasFeeFlow { ++ #private; ++ matchesTransaction(transactionMeta: TransactionMeta): boolean; ++ getGasFees(request: GasFeeFlowRequest): Promise; ++} ++//# sourceMappingURL=LineaGasFeeFlow.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map +new file mode 100644 +index 0000000..dec2fb5 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"LineaGasFeeFlow.d.ts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAC;AAgClB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js +new file mode 100644 +index 0000000..0f7f764 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js +@@ -0,0 +1,112 @@ ++"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 __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 _LineaGasFeeFlow_instances, _LineaGasFeeFlow_getLineaGasFees, _LineaGasFeeFlow_getLineaResponse, _LineaGasFeeFlow_getValuesFromMultipliers, _LineaGasFeeFlow_getMaxFees, _LineaGasFeeFlow_feesToString; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.LineaGasFeeFlow = void 0; ++const controller_utils_1 = require("@metamask/controller-utils"); ++const utils_1 = require("@metamask/utils"); ++const DefaultGasFeeFlow_1 = require("./DefaultGasFeeFlow"); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'linea-gas-fee-flow'); ++const LINEA_CHAIN_IDS = [ ++ controller_utils_1.ChainId['linea-mainnet'], ++ controller_utils_1.ChainId['linea-goerli'], ++ controller_utils_1.ChainId['linea-sepolia'], ++]; ++const BASE_FEE_MULTIPLIERS = { ++ low: 1, ++ medium: 1.35, ++ high: 1.7, ++}; ++const PRIORITY_FEE_MULTIPLIERS = { ++ low: 1, ++ medium: 1.05, ++ high: 1.1, ++}; ++/** ++ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using: ++ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee. ++ * - Static multipliers to increase the base and priority fees. ++ */ ++class LineaGasFeeFlow { ++ constructor() { ++ _LineaGasFeeFlow_instances.add(this); ++ } ++ matchesTransaction(transactionMeta) { ++ return LINEA_CHAIN_IDS.includes(transactionMeta.chainId); ++ } ++ getGasFees(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ try { ++ return yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaGasFees).call(this, request); ++ } ++ catch (error) { ++ log('Using default flow as fallback due to error', error); ++ return new DefaultGasFeeFlow_1.DefaultGasFeeFlow().getGasFees(request); ++ } ++ }); ++ } ++} ++exports.LineaGasFeeFlow = LineaGasFeeFlow; ++_LineaGasFeeFlow_instances = new WeakSet(), _LineaGasFeeFlow_getLineaGasFees = function _LineaGasFeeFlow_getLineaGasFees(request) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const { ethQuery, transactionMeta } = request; ++ const lineaResponse = yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaResponse).call(this, transactionMeta, ethQuery); ++ log('Received Linea response', lineaResponse); ++ const baseFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.baseFeePerGas, BASE_FEE_MULTIPLIERS); ++ log('Generated base fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, baseFees)); ++ const priorityFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.priorityFeePerGas, PRIORITY_FEE_MULTIPLIERS); ++ log('Generated priority fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, priorityFees)); ++ const maxFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getMaxFees).call(this, baseFees, priorityFees); ++ log('Generated max fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, maxFees)); ++ const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: { ++ maxFeePerGas: (0, controller_utils_1.toHex)(maxFees[level]), ++ maxPriorityFeePerGas: (0, controller_utils_1.toHex)(priorityFees[level]), ++ } })), {}); ++ return { estimates }; ++ }); ++}, _LineaGasFeeFlow_getLineaResponse = function _LineaGasFeeFlow_getLineaResponse(transactionMeta, ethQuery) { ++ return (0, controller_utils_1.query)(ethQuery, 'linea_estimateGas', [ ++ { ++ from: transactionMeta.txParams.from, ++ to: transactionMeta.txParams.to, ++ value: transactionMeta.txParams.value, ++ input: transactionMeta.txParams.data, ++ // Required in request but no impact on response. ++ gasPrice: '0x100000000', ++ }, ++ ]); ++}, _LineaGasFeeFlow_getValuesFromMultipliers = function _LineaGasFeeFlow_getValuesFromMultipliers(value, multipliers) { ++ const base = (0, controller_utils_1.hexToBN)(value); ++ const low = base.muln(multipliers.low); ++ const medium = base.muln(multipliers.medium); ++ const high = base.muln(multipliers.high); ++ return { ++ low, ++ medium, ++ high, ++ }; ++}, _LineaGasFeeFlow_getMaxFees = function _LineaGasFeeFlow_getMaxFees(baseFees, priorityFees) { ++ return { ++ low: baseFees.low.add(priorityFees.low), ++ medium: baseFees.medium.add(priorityFees.medium), ++ high: baseFees.high.add(priorityFees.high), ++ }; ++}, _LineaGasFeeFlow_feesToString = function _LineaGasFeeFlow_feesToString(fees) { ++ return Object.values(types_1.GasFeeEstimateLevel).map((level) => fees[level].toString(10)); ++}; ++//# sourceMappingURL=LineaGasFeeFlow.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map +new file mode 100644 +index 0000000..7efd818 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"LineaGasFeeFlow.js","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAA4E;AAC5E,2CAA+D;AAG/D,2DAAwD;AACxD,sCAA0C;AAQ1C,oCAA+C;AAW/C,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;IACvB,0BAAO,CAAC,eAAe,CAAC;CACzB,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;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C,qEAGC,QAAyC,EACzC,YAA6C;IAE7C,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,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 { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\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 ChainId['linea-sepolia'],\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.txParams.from,\n to: transactionMeta.txParams.to,\n value: transactionMeta.txParams.value,\n input: transactionMeta.txParams.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/GasFeePoller.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts +new file mode 100644 +index 0000000..e7eb32d +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts +@@ -0,0 +1,31 @@ ++/// ++import type { GasFeeState } from '@metamask/gas-fee-controller'; ++import EventEmitter from 'events'; ++import type { GasFeeFlow, TransactionMeta } from '../types'; ++/** ++ * Automatically polls and updates suggested gas fees on unapproved transactions. ++ */ ++export declare class GasFeePoller { ++ #private; ++ hub: EventEmitter; ++ /** ++ * Constructs a new instance of the GasFeePoller. ++ * ++ * @param options - The options for this instance. ++ * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees. ++ * @param options.getChainIds - Callback to specify the chain IDs to monitor. ++ * @param options.getEthQuery - Callback to obtain an EthQuery instance. ++ * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates. ++ * @param options.getTransactions - Callback to obtain the transaction data. ++ * @param options.onStateChange - Callback to register a listener for controller state changes. ++ */ ++ constructor({ gasFeeFlows, getChainIds, getEthQuery, getGasFeeControllerEstimates, getTransactions, onStateChange, }: { ++ gasFeeFlows: GasFeeFlow[]; ++ getChainIds: () => string[]; ++ getEthQuery: () => any; ++ getGasFeeControllerEstimates: () => Promise; ++ getTransactions: () => TransactionMeta[]; ++ onStateChange: (listener: () => void) => void; ++ }); ++} ++//# sourceMappingURL=GasFeePoller.d.ts.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map +new file mode 100644 +index 0000000..f6a5ea5 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map +@@ -0,0 +1 @@ ++{"version":3,"file":"GasFeePoller.d.ts","sourceRoot":"","sources":["../../src/helpers/GasFeePoller.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAIlC,OAAO,KAAK,EAAE,UAAU,EAAqB,eAAe,EAAE,MAAM,UAAU,CAAC;AAO/E;;GAEG;AACH,qBAAa,YAAY;;IACvB,GAAG,EAAE,YAAY,CAAsB;IAgBvC;;;;;;;;;;OAUG;gBACS,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,4BAA4B,EAC5B,eAAe,EACf,aAAa,GACd,EAAE;QACD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,WAAW,EAAE,MAAM,MAAM,EAAE,CAAC;QAC5B,WAAW,EAAE,MAAM,GAAG,CAAC;QACvB,4BAA4B,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD,eAAe,EAAE,MAAM,eAAe,EAAE,CAAC;QACzC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;KAC/C;CA+HF"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js +new file mode 100644 +index 0000000..6f287b5 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js +@@ -0,0 +1,147 @@ ++"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 _GasFeePoller_instances, _GasFeePoller_gasFeeFlows, _GasFeePoller_getChainIds, _GasFeePoller_getEthQuery, _GasFeePoller_getGasFeeControllerEstimates, _GasFeePoller_getTransactions, _GasFeePoller_timeout, _GasFeePoller_running, _GasFeePoller_start, _GasFeePoller_stop, _GasFeePoller_onTimeout, _GasFeePoller_updateUnapprovedTransactions, _GasFeePoller_updateTransactionSuggestedFees, _GasFeePoller_getUnapprovedTransactions; ++Object.defineProperty(exports, "__esModule", { value: true }); ++exports.GasFeePoller = void 0; ++const utils_1 = require("@metamask/utils"); ++const events_1 = __importDefault(require("events")); ++const logger_1 = require("../logger"); ++const types_1 = require("../types"); ++const gas_flow_1 = require("../utils/gas-flow"); ++const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas-fee-poller'); ++const INTERVAL_MILLISECONDS = 10000; ++/** ++ * Automatically polls and updates suggested gas fees on unapproved transactions. ++ */ ++class GasFeePoller { ++ /** ++ * Constructs a new instance of the GasFeePoller. ++ * ++ * @param options - The options for this instance. ++ * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees. ++ * @param options.getChainIds - Callback to specify the chain IDs to monitor. ++ * @param options.getEthQuery - Callback to obtain an EthQuery instance. ++ * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates. ++ * @param options.getTransactions - Callback to obtain the transaction data. ++ * @param options.onStateChange - Callback to register a listener for controller state changes. ++ */ ++ constructor({ gasFeeFlows, getChainIds, getEthQuery, getGasFeeControllerEstimates, getTransactions, onStateChange, }) { ++ _GasFeePoller_instances.add(this); ++ this.hub = new events_1.default(); ++ _GasFeePoller_gasFeeFlows.set(this, void 0); ++ _GasFeePoller_getChainIds.set(this, void 0); ++ _GasFeePoller_getEthQuery.set(this, void 0); ++ _GasFeePoller_getGasFeeControllerEstimates.set(this, void 0); ++ _GasFeePoller_getTransactions.set(this, void 0); ++ _GasFeePoller_timeout.set(this, void 0); ++ _GasFeePoller_running.set(this, false); ++ __classPrivateFieldSet(this, _GasFeePoller_gasFeeFlows, gasFeeFlows, "f"); ++ __classPrivateFieldSet(this, _GasFeePoller_getChainIds, getChainIds, "f"); ++ __classPrivateFieldSet(this, _GasFeePoller_getEthQuery, getEthQuery, "f"); ++ __classPrivateFieldSet(this, _GasFeePoller_getGasFeeControllerEstimates, getGasFeeControllerEstimates, "f"); ++ __classPrivateFieldSet(this, _GasFeePoller_getTransactions, getTransactions, "f"); ++ onStateChange(() => { ++ const unapprovedTransactions = __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_getUnapprovedTransactions).call(this); ++ if (unapprovedTransactions.length) { ++ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_start).call(this); ++ } ++ else { ++ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_stop).call(this); ++ } ++ }); ++ } ++} ++exports.GasFeePoller = GasFeePoller; ++_GasFeePoller_gasFeeFlows = new WeakMap(), _GasFeePoller_getChainIds = new WeakMap(), _GasFeePoller_getEthQuery = new WeakMap(), _GasFeePoller_getGasFeeControllerEstimates = new WeakMap(), _GasFeePoller_getTransactions = new WeakMap(), _GasFeePoller_timeout = new WeakMap(), _GasFeePoller_running = new WeakMap(), _GasFeePoller_instances = new WeakSet(), _GasFeePoller_start = function _GasFeePoller_start() { ++ if (__classPrivateFieldGet(this, _GasFeePoller_running, "f")) { ++ return; ++ } ++ // Intentionally not awaiting since this starts the timeout chain. ++ // eslint-disable-next-line @typescript-eslint/no-floating-promises ++ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_onTimeout).call(this); ++ __classPrivateFieldSet(this, _GasFeePoller_running, true, "f"); ++ log('Started polling'); ++}, _GasFeePoller_stop = function _GasFeePoller_stop() { ++ if (!__classPrivateFieldGet(this, _GasFeePoller_running, "f")) { ++ return; ++ } ++ clearTimeout(__classPrivateFieldGet(this, _GasFeePoller_timeout, "f")); ++ __classPrivateFieldSet(this, _GasFeePoller_timeout, undefined, "f"); ++ __classPrivateFieldSet(this, _GasFeePoller_running, false, "f"); ++ log('Stopped polling'); ++}, _GasFeePoller_onTimeout = function _GasFeePoller_onTimeout() { ++ return __awaiter(this, void 0, void 0, function* () { ++ yield __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_updateUnapprovedTransactions).call(this); ++ // eslint-disable-next-line @typescript-eslint/no-misused-promises ++ __classPrivateFieldSet(this, _GasFeePoller_timeout, setTimeout(() => __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_onTimeout).call(this), INTERVAL_MILLISECONDS), "f"); ++ }); ++}, _GasFeePoller_updateUnapprovedTransactions = function _GasFeePoller_updateUnapprovedTransactions() { ++ return __awaiter(this, void 0, void 0, function* () { ++ const unapprovedTransactions = __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_getUnapprovedTransactions).call(this); ++ log('Found unapproved transactions', { ++ count: unapprovedTransactions.length, ++ }); ++ const ethQuery = __classPrivateFieldGet(this, _GasFeePoller_getEthQuery, "f").call(this); ++ yield Promise.all(unapprovedTransactions.map((tx) => __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_updateTransactionSuggestedFees).call(this, tx, ethQuery))); ++ }); ++}, _GasFeePoller_updateTransactionSuggestedFees = function _GasFeePoller_updateTransactionSuggestedFees(transactionMeta, ethQuery) { ++ return __awaiter(this, void 0, void 0, function* () { ++ const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, __classPrivateFieldGet(this, _GasFeePoller_gasFeeFlows, "f")); ++ if (!gasFeeFlow) { ++ log('No gas fee flow found', transactionMeta.id); ++ } ++ else { ++ log('Found gas fee flow', gasFeeFlow.constructor.name, transactionMeta.id); ++ } ++ const request = { ++ ethQuery, ++ getGasFeeControllerEstimates: __classPrivateFieldGet(this, _GasFeePoller_getGasFeeControllerEstimates, "f"), ++ transactionMeta, ++ }; ++ if (gasFeeFlow) { ++ try { ++ const response = yield gasFeeFlow.getGasFees(request); ++ transactionMeta.gasFeeEstimates = response.estimates; ++ } ++ catch (error) { ++ log('Failed to get suggested gas fees', transactionMeta.id, error); ++ } ++ } ++ if (!gasFeeFlow && transactionMeta.gasFeeEstimatesLoaded) { ++ return; ++ } ++ transactionMeta.gasFeeEstimatesLoaded = true; ++ this.hub.emit('transaction-updated', transactionMeta, 'GasFeePoller - Suggested gas fees updated'); ++ log('Updated suggested gas fees', { ++ gasFeeEstimates: transactionMeta.gasFeeEstimates, ++ transaction: transactionMeta.id, ++ }); ++ }); ++}, _GasFeePoller_getUnapprovedTransactions = function _GasFeePoller_getUnapprovedTransactions() { ++ const chainIds = __classPrivateFieldGet(this, _GasFeePoller_getChainIds, "f").call(this); ++ return __classPrivateFieldGet(this, _GasFeePoller_getTransactions, "f").call(this).filter((tx) => chainIds.includes(tx.chainId) && ++ tx.status === types_1.TransactionStatus.unapproved); ++}; ++//# sourceMappingURL=GasFeePoller.js.map +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map +new file mode 100644 +index 0000000..1b85190 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map +@@ -0,0 +1 @@ ++{"version":3,"file":"GasFeePoller.js","sourceRoot":"","sources":["../../src/helpers/GasFeePoller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAqD;AACrD,oDAAkC;AAElC,sCAA0C;AAC1C,oCAA6C;AAE7C,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;QAChC,uBAAA,IAAI,6BAAgB,WAAW,MAAA,CAAC;QAChC,uBAAA,IAAI,6BAAgB,WAAW,MAAA,CAAC;QAChC,uBAAA,IAAI,8CAAiC,4BAA4B,MAAA,CAAC;QAClE,uBAAA,IAAI,i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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 type { GasFeeState } from '@metamask/gas-fee-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport EventEmitter from 'events';\n\nimport { projectLogger } from '../logger';\nimport { TransactionStatus } from '../types';\nimport type { GasFeeFlow, GasFeeFlowRequest, 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/history.d.ts.map b/node_modules/@metamask/transaction-controller/dist/history.d.ts.map +deleted file mode 100644 +index 7a423a8..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/history.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,eAAe,QAGzE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,MAAM,GACX,IAAI,CAWN"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/history.js.map b/node_modules/@metamask/transaction-controller/dist/history.js.map +deleted file mode 100644 +index 09322be..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/history.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"history.js","sourceRoot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AC;IACnD,OAAO,YAAY,CAAC,MAAM,CACxB,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 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 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 (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/index.d.ts b/node_modules/@metamask/transaction-controller/dist/index.d.ts +index 9998101..b7c9355 100644 +--- a/node_modules/@metamask/transaction-controller/dist/index.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/index.d.ts +@@ -1,5 +1,5 @@ + export * from './TransactionController'; +-export type { EtherscanTransactionMeta } from './etherscan'; +-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 6b85676..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,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,cAAc,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 602f51c..0818eb8 100644 +--- a/node_modules/@metamask/transaction-controller/dist/index.js ++++ b/node_modules/@metamask/transaction-controller/dist/index.js +@@ -14,9 +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 c4fa911..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;AAExC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAC7B,0CAAwB","sourcesContent":["export * from './TransactionController';\nexport type { EtherscanTransactionMeta } from './etherscan';\nexport { isEIP1559Transaction } from './utils';\nexport * from './types';\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/logger.d.ts.map b/node_modules/@metamask/transaction-controller/dist/logger.d.ts.map +deleted file mode 100644 +index bb648ef..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/logger.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,aAAa,0BAAgD,CAAC;AAE3E,eAAO,MAAM,0BAA0B,0BAGtC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"} +\ 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 +index 69ce8ec..bb55b17 100644 +--- a/node_modules/@metamask/transaction-controller/dist/logger.js ++++ b/node_modules/@metamask/transaction-controller/dist/logger.js +@@ -1,4 +1,5 @@ + "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"); +diff --git a/node_modules/@metamask/transaction-controller/dist/logger.js.map b/node_modules/@metamask/transaction-controller/dist/logger.js.map +deleted file mode 100644 +index 616e0cd..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/logger.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AASjE,mGATqB,0BAAkB,OASrB;AAPd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,wBAAwB,CAAC,CAAC;AAE9D,QAAA,0BAA0B,GAAG,IAAA,0BAAkB,EAC1D,qBAAa,EACb,uBAAuB,CACxB,CAAC","sourcesContent":["import { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('transaction-controller');\n\nexport const incomingTransactionsLogger = createModuleLogger(\n projectLogger,\n 'incoming-transactions',\n);\n\nexport { createModuleLogger };\n"]} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/transaction-type.d.ts.map b/node_modules/@metamask/transaction-controller/dist/transaction-type.d.ts.map +deleted file mode 100644 +index 0721a72..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/transaction-type.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"transaction-type.d.ts","sourceRoot":"","sources":["../src/transaction-type.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAGhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAMrE;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,0BAA0B,CAAC,CAiCrC"} +\ No newline at end of file +diff --git a/node_modules/@metamask/transaction-controller/dist/transaction-type.js.map b/node_modules/@metamask/transaction-controller/dist/transaction-type.js.map +deleted file mode 100644 +index fc7d668..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/transaction-type.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"transaction-type.js","sourceRoot":"","sources":["../src/transaction-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4CAA+C;AAC/C,iEAAmD;AAEnD,mEAA8E;AAG9E,mCAA0C;AAE7B,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,cAAc,GAAG,I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ACxC,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;SAC/D;QAED,OAAO;YACL,IAAI,EAAE,uBAAe,CAAC,mBAAmB;YACzC,eAAe,EAAE,UAAU;SAC5B,CAAC;;CACH;AApCD,4DAoCC;AAED;;;;;;;GAOG;AACH,SAAS,iCAAiC,CACxC,IAAa;IAEb,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,SAAS,CAAC;KAClB;IAED,IAAI;QACF,OAAO,cAAc,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KAClD;IAAC,WAAM;QACN,+CAA+C;KAChD;IAED,IAAI;QACF,OAAO,eAAe,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACnD;IAAC,WAAM;QACN,gDAAgD;KACjD;IAED,IAAI;QACF,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACpD;IAAC,WAAM;QACN,8BAA8B;KAC/B;IAED,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 const name = parseStandardTokenTransactionData(data)?.name;\n\n if (data && !to) {\n return { type: TransactionType.deployContract, getCodeResponse: undefined };\n }\n\n const { contractCode: resultCode, isContractAddress } =\n await readAddressAsContract(ethQuery, to);\n\n if (!isContractAddress) {\n return { type: TransactionType.simpleSend, getCodeResponse: resultCode };\n }\n\n const hasValue = txParams.value && Number(txParams.value) !== 0;\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 (data && tokenMethodName && !hasValue) {\n return { type: tokenMethodName, getCodeResponse: resultCode };\n }\n\n return {\n type: TransactionType.contractInteraction,\n getCodeResponse: resultCode,\n };\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/types.d.ts b/node_modules/@metamask/transaction-controller/dist/types.d.ts +index fb94e7b..0914962 100644 +--- a/node_modules/@metamask/transaction-controller/dist/types.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/types.d.ts +@@ -1,3 +1,4 @@ ++import type { GasFeeState } from '@metamask/gas-fee-controller'; + import type { Hex } from '@metamask/utils'; + import type { Operation } from 'fast-json-patch'; + /** +@@ -107,10 +108,14 @@ declare type TransactionMetaBase = { + * The transaction's 's' value as a hex string. + */ + s?: string; ++ /** 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?: Record; ++ securityAlertResponse?: SecurityAlertResponse; + /** + * An array of entries that describe the user's journey through the send flow. + * This is purely attached to state logs for troubleshooting and support. +@@ -353,15 +358,15 @@ export interface TransactionParams { + * Address to send this transaction to. + */ + to?: string; +- /** +- * Value associated with this transaction. +- */ +- value?: string; + /** + * Type of transaction. + * 0x0 indicates a legacy transaction. + */ + type?: string; ++ /** ++ * Value associated with this transaction. ++ */ ++ value?: string; + } + /** + * Standard data concerning a transaction processed by the blockchain. +@@ -499,5 +504,92 @@ export declare type InferTransactionTypeResult = { + */ + type: TransactionType; + }; ++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.d.ts.map b/node_modules/@metamask/transaction-controller/dist/types.d.ts.map +deleted file mode 100644 +index 2dc9ab6..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/types.d.ts.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;GAEG;AACH,oBAAY,eAAe,GACvB,CAAC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AAuB;IACtC;;;OAGG;IACH,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;IAE9C;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC;IAExC;;;OAGG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,aAAK,wBAAwB,GAAG,SAAS,GAAG;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,oBAAY,uBAAuB,GAAG;IACpC,wBAAwB;IACxB,GAAG,SAAS,EAAE;CACf,CAAC;AAEF;;;GAGG;AACH,oBAAY,kBAAkB,GAAG;IAC/B,eAAe;IACf,GAAG,uBAAuB,EAAE;CAC7B,CAAC;AAEF;;GAEG;AACH,oBAAY,0BAA0B,GAAG;IACvC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC"} +\ 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 +index 6bbf145..7b3c99c 100644 +--- a/node_modules/@metamask/transaction-controller/dist/types.js ++++ b/node_modules/@metamask/transaction-controller/dist/types.js +@@ -1,6 +1,6 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.TransactionType = exports.WalletDevice = exports.TransactionStatus = void 0; ++exports.GasFeeEstimateLevel = exports.TransactionType = 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 +@@ -125,4 +125,11 @@ var TransactionType; + */ + TransactionType["tokenMethodSetApprovalForAll"] = "setapprovalforall"; + })(TransactionType = exports.TransactionType || (exports.TransactionType = {})); ++/** 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/types.js.map b/node_modules/@metamask/transaction-controller/dist/types.js.map +deleted file mode 100644 +index 7bca630..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/types.js.map ++++ /dev/null +@@ -1 +0,0 @@ +-{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAwNA;;;;GAIG;AACH,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;AAC3B,CAAC,EAVW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAU5B;AAED;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,sCAAsB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED;;GAEG;AACH,IAAY,eA+GX;AA/GD,WAAY,eAAe;IACzB;;OAEG;IACH,oCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8DAA2C,CAAA;IAE3C;;OAEG;IACH,wDAAqC,CAAA;IAErC;;OAEG;IACH,6CAA0B,CAAA;IAE1B;;OAEG;IACH,2EAAwD,CAAA;IAExD;;OAEG;IACH,wCAAqB,CAAA;IAErB;;OAEG;IACH,iDAA8B,CAAA;IAE9B;;;;;OAKG;IACH,kCAAe,CAAA;IAEf;;OAEG;IACH,4CAAyB,CAAA;IAEzB;;OAEG;IACH,oCAAiB,CAAA;IAEjB;;OAEG;IACH,sDAAmC,CAAA;IAEnC;;OAEG;IACH,kCAAe,CAAA;IAEf;;OAEG;IACH,gCAAa,CAAA;IAEb;;;;;OAKG;IACH,gDAA6B,CAAA;IAE7B;;;OAGG;IACH,iDAA8B,CAAA;IAE9B;;;;;OAKG;IACH,mEAAgD,CAAA;IAEhD;;;OAGG;IACH,mDAAgC,CAAA;IAEhC;;;;OAIG;IACH,2DAAwC,CAAA;IAExC;;;OAGG;IACH,qEAAkD,CAAA;AACpD,CAAC,EA/GW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA+G1B","sourcesContent":["import type { Hex } from '@metamask/utils';\nimport type { Operation } from 'fast-json-patch';\n\n/**\n * Representation of transaction metadata.\n */\nexport type TransactionMeta =\n | ({\n status: Exclude;\n } & TransactionMetaBase)\n | ({ status: TransactionStatus.failed; error: Error } & TransactionMetaBase);\n\n/**\n * Information about a single transaction such as status and block number.\n */\ntype TransactionMetaBase = {\n /**\n * Unique ID to prevent duplicate requests.\n */\n actionId?: string;\n\n /**\n * Base fee of the block as a hex value, introduced in EIP-1559.\n */\n baseFeePerGas?: Hex;\n\n /**\n * Number of the block where the transaction has been included.\n */\n blockNumber?: string;\n\n /**\n * The timestamp for when the block was collated.\n */\n blockTimestamp?: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * Gas values provided by the dApp.\n */\n dappSuggestedGasFees?: DappSuggestedGasFees;\n\n /**\n * The default estimate for gas.\n */\n defaultGasEstimates?: string;\n\n /**\n * String to indicate what device the transaction was confirmed on.\n */\n deviceConfirmedOn?: WalletDevice;\n\n /**\n * The estimated base fee of the transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * A hex string of the transaction hash, used to identify the transaction on the network.\n */\n hash?: string;\n\n /**\n * A history of mutations to TransactionMeta.\n */\n history?: TransactionHistory;\n\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Whether the transaction is a transfer.\n */\n isTransfer?: boolean;\n\n /**\n * Network code as per EIP-155 for this transaction\n *\n * @deprecated Use `chainId` instead.\n */\n readonly networkID?: string;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * The original gas estimation of the transaction.\n */\n originalGasEstimate?: string;\n\n /**\n * The transaction's 'r' value as a hex string.\n */\n r?: string;\n\n /**\n * Hex representation of the underlying transaction.\n */\n rawTx?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction hash.\n */\n replacedBy?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction ID.\n */\n replacedById?: string;\n\n /**\n * The transaction's 's' value as a hex string.\n */\n s?: string;\n\n /**\n * Response from security validator.\n */\n securityAlertResponse?: Record;\n\n /**\n * An array of entries that describe the user's journey through the send flow.\n * This is purely attached to state logs for troubleshooting and support.\n */\n sendFlowHistory?: SendFlowHistoryEntry[];\n\n /**\n * The time the transaction was submitted to the network, in Unix epoch time (ms).\n */\n submittedTime?: number;\n\n /**\n * Timestamp associated with this transaction.\n */\n time: number;\n\n /**\n * Whether transaction recipient is a smart contract.\n */\n toSmartContract?: boolean;\n\n /**\n * Additional transfer information.\n */\n transferInformation?: {\n contractAddress: string;\n decimals: number;\n symbol: string;\n };\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * Transaction receipt.\n */\n txReceipt?: TransactionReceipt;\n\n /**\n * The type of transaction such as `cancel` or `swap`.\n */\n type?: TransactionType;\n\n /**\n * The gas limit supplied by user.\n */\n userEditedGasLimit?: boolean;\n\n /**\n * Estimate level user selected.\n */\n userFeeLevel?: string;\n\n /**\n * The transaction's 'v' value as a hex string.\n */\n v?: string;\n\n /**\n * Whether the transaction is verified on the blockchain.\n */\n verifiedOnBlockchain?: boolean;\n};\n\nexport type SendFlowHistoryEntry = {\n /**\n * String to indicate user interaction information.\n */\n entry: string;\n\n /**\n * Timestamp associated with this entry.\n */\n timestamp: number;\n};\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n dropped = 'dropped',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\n/**\n * The type of the transaction.\n */\nexport enum TransactionType {\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n cancel = 'cancel',\n\n /**\n * A transaction that is interacting with a smart contract's methods that we\n * have not treated as a special case, such as approve, transfer, and\n * transferfrom.\n */\n contractInteraction = 'contractInteraction',\n\n /**\n * A transaction that deployed a smart contract.\n */\n deployContract = 'contractDeployment',\n\n /**\n * A transaction for Ethereum decryption.\n */\n ethDecrypt = 'eth_decrypt',\n\n /**\n * A transaction for getting an encryption public key.\n */\n ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n\n /**\n * An incoming (deposit) transaction.\n */\n incoming = 'incoming',\n\n /**\n * A transaction for personal sign.\n */\n personalSign = 'personal_sign',\n\n /**\n * When a transaction is failed it can be retried by\n * resubmitting the same transaction with a higher gas fee. This type is also used\n * to speed up pending transactions. This is accomplished by creating a new tx with\n * the same nonce and higher gas fees.\n */\n retry = 'retry',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n simpleSend = 'simpleSend',\n\n /**\n * A transaction that is signing a message.\n */\n sign = 'eth_sign',\n\n /**\n * A transaction that is signing typed data.\n */\n signTypedData = 'eth_signTypedData',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n smart = 'smart',\n\n /**\n * A transaction swapping one token for another through MetaMask Swaps.\n */\n swap = 'swap',\n\n /**\n * Similar to the approve type, a swap approval is a special case of ERC20\n * approve method that requests an allowance of the token to spend on behalf\n * of the user for the MetaMask Swaps contract. The first swap for any token\n * will have an accompanying swapApproval transaction.\n */\n swapApproval = 'swapApproval',\n\n /**\n * A token transaction requesting an allowance of the token to spend on\n * behalf of the user.\n */\n tokenMethodApprove = 'approve',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. The method is prefixed with safe because when calling\n * this method the contract checks to ensure that the receiver is an address\n * capable of handling the token being sent.\n */\n tokenMethodSafeTransferFrom = 'safetransferfrom',\n\n /**\n * A token transaction where the user is sending tokens that they own to\n * another address.\n */\n tokenMethodTransfer = 'transfer',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. For more information on allowances, see the approve\n * type.\n */\n tokenMethodTransferFrom = 'transferfrom',\n\n /**\n * A token transaction requesting an allowance of all of a user's tokens to\n * spend on behalf of the user.\n */\n tokenMethodSetApprovalForAll = 'setapprovalforall',\n}\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport interface TransactionParams {\n /**\n * Network ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n}\n\n/**\n * Standard data concerning a transaction processed by the blockchain.\n */\nexport interface TransactionReceipt {\n /**\n * The block hash of the block that this transaction was included in.\n */\n blockHash?: string;\n\n /**\n * The block number of the block that this transaction was included in.\n */\n blockNumber?: string;\n\n /**\n * Effective gas price the transaction was charged at.\n */\n effectiveGasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Total used gas in hex.\n */\n l1Fee?: string;\n\n /**\n * All the logs emitted by this transaction.\n */\n logs?: Log[];\n\n /**\n * The status of the transaction.\n */\n status?: string;\n\n /**\n * The index of this transaction in the list of transactions included in the block this transaction was mined in.\n */\n transactionIndex?: number;\n}\n\n/**\n * Represents an event that has been included in a transaction using the EVM `LOG` opcode.\n */\nexport interface Log {\n /**\n * Address of the contract that generated log.\n */\n address?: string;\n /**\n * List of topics for log.\n */\n topics?: string;\n}\n\n/**\n * The configuration required to fetch transaction data from a RemoteTransactionSource.\n */\nexport interface RemoteTransactionSourceRequest {\n /**\n * The address of the account to fetch transactions for.\n */\n address: string;\n\n /**\n * The chainId of the current network.\n */\n currentChainId: Hex;\n\n /**\n * Block number to start fetching transactions from.\n */\n fromBlock?: number;\n\n /**\n * Maximum number of transactions to retrieve.\n */\n limit?: number;\n}\n\n/**\n * An object capable of fetching transaction data from a remote source.\n * Used by the IncomingTransactionHelper to retrieve remote transaction data.\n */\nexport interface RemoteTransactionSource {\n /**\n * @param chainId - The chainId of the current network.\n * @returns Whether the remote transaction source supports the specified network.\n */\n isSupportedNetwork: (chainId: Hex) => boolean;\n\n /**\n * @returns An array of additional keys to use when caching the last fetched block number.\n */\n getLastBlockVariations?: () => string[];\n\n /**\n * @param request - A request object containing data such as the address and chain ID.\n * @returns An array of transaction metadata for the retrieved transactions.\n */\n fetchTransactions: (\n request: RemoteTransactionSourceRequest,\n ) => Promise;\n}\n\n/**\n * Gas values initially suggested by the dApp.\n */\nexport interface DappSuggestedGasFees {\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n}\n\n/**\n * A transaction history operation that includes a note and timestamp.\n */\ntype ExtendedHistoryOperation = Operation & {\n note?: string;\n timestamp?: number;\n};\n\n/**\n * A transaction history entry that includes the ExtendedHistoryOperation as the first element.\n */\nexport type TransactionHistoryEntry = [\n ExtendedHistoryOperation,\n ...Operation[],\n];\n\n/**\n * A transaction history that includes the transaction meta as the first element.\n * And the rest of the elements are the operation arrays that were applied to the transaction meta.\n */\nexport type TransactionHistory = [\n TransactionMeta,\n ...TransactionHistoryEntry[],\n];\n\n/**\n * Result of inferring the transaction type.\n */\nexport type InferTransactionTypeResult = {\n /**\n * The contract code, in hex format if it exists. '0x0' or\n * '0x' are also indicators of non-existent contract code.\n */\n getCodeResponse?: string | null;\n\n /**\n * The type of transaction\n */\n type: TransactionType;\n};\n"]} +\ 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 1049d83..83b5ca9 100644 +--- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts ++++ b/node_modules/@metamask/transaction-controller/dist/utils.d.ts +@@ -1,3 +1,4 @@ ++import type { Hex } from '@metamask/utils'; + import type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker'; + import type { GasPriceValue, FeeMarketEIP1559Values } from './TransactionController'; + import { TransactionStatus } from './types'; +@@ -9,7 +10,7 @@ export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; + * @param txParams - The transaction params to normalize. + * @returns Normalized transaction params. + */ +-export declare function normalizeTxParams(txParams: TransactionParams): TransactionParams; ++export declare function normalizeTransactionParams(txParams: TransactionParams): TransactionParams; + /** + * Validates the transaction params for required properties and throws in + * the event of any validation error. +@@ -43,12 +44,13 @@ 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: Hex, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[]; + /** + * Validates that a transaction is unapproved. + * Throws if the transaction is not unapproved. +@@ -57,4 +59,12 @@ export declare function getAndFormatTransactionsForNonceTracker(fromAddress: str + * @param fnName - The name of the function calling this helper. + */ + export declare function validateIfTransactionUnapproved(transactionMeta: TransactionMeta | undefined, fnName: string): void; ++/** ++ * 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 01c0c66..0000000 +--- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts.map ++++ /dev/null +@@ -1 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AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,eAAe,GAAG,SAAS,EAC5C,MAAM,EAAE,MAAM,QAQf"} +\ 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 835d1e4..0eab5db 100644 +--- a/node_modules/@metamask/transaction-controller/dist/utils.js ++++ b/node_modules/@metamask/transaction-controller/dist/utils.js +@@ -1,13 +1,13 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +-exports.validateIfTransactionUnapproved = exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTxParams = exports.normalizeTxParams = exports.ESTIMATE_GAS_ERROR = void 0; ++exports.padHexToEvenLength = exports.validateIfTransactionUnapproved = exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTxParams = exports.normalizeTransactionParams = exports.ESTIMATE_GAS_ERROR = void 0; + const controller_utils_1 = require("@metamask/controller-utils"); + const rpc_errors_1 = require("@metamask/rpc-errors"); + const ethereumjs_util_1 = require("ethereumjs-util"); + const types_1 = require("./types"); + 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), + gasLimit: (gas) => (0, ethereumjs_util_1.addHexPrefix)(gas), +@@ -26,7 +26,7 @@ const NORMALIZERS = { + * @param txParams - The transaction params to normalize. + * @returns Normalized transaction params. + */ +-function normalizeTxParams(txParams) { ++function normalizeTransactionParams(txParams) { + const normalizedTxParams = { from: '' }; + let key; + for (key in NORMALIZERS) { +@@ -36,7 +36,7 @@ function normalizeTxParams(txParams) { + } + return normalizedTxParams; + } +-exports.normalizeTxParams = normalizeTxParams; ++exports.normalizeTransactionParams = normalizeTransactionParams; + /** + * Validates the transaction params for required properties and throws in + * the event of any validation error. +@@ -137,14 +137,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, txParams: { from } }) => status === transactionStatus && ++ .filter(({ chainId, isTransfer, status, txParams: { from } }) => !isTransfer && ++ chainId === currentChainId && ++ status === transactionStatus && + from.toLowerCase() === fromAddress.toLowerCase()) + .map(({ status, txParams: { from, gas, value, nonce } }) => { + // the only value we care about is the nonce +@@ -177,4 +180,18 @@ function validateIfTransactionUnapproved(transactionMeta, fnName) { + } + } + exports.validateIfTransactionUnapproved = validateIfTransactionUnapproved; ++/** ++ * 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 013009a..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,iEAGoC;AACpC,qDAAiD;AACjD,qDAA4D;AAO5D,mCAA4C;AAG/B,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAAgD;IAC/D,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE;IACxD,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,GAAG,CAAC;IACvC,QAAQ,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,GAAG,CAAC;IAC5C,QAAQ,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,QAAQ,CAAC;IACtD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,KAAK,CAAC;IAC7C,EAAE,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,EAAE,CAAC,CAAC,WAAW,EAAE;IAClD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,KAAK,CAAC;IAC7C,YAAY,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,YAAY,CAAC;IAClE,oBAAoB,EAAE,CAAC,oBAA4B,EAAE,EAAE,CACrD,IAAA,8BAAY,EA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AAI,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;AAED;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAC7C,eAA4C,EAC5C,MAAc;IAEd,IAAI,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,MAAK,yBAAiB,CAAC,UAAU,EAAE;QAC5D,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM;2BACF,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,EAAE,CAC/C,CAAC;KACH;AACH,CAAC;AAVD,0EAUC","sourcesContent":["import {\n convertHexToDecimal,\n isValidHexAddress,\n} from '@metamask/controller-utils';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { addHexPrefix, isHexString } from 'ethereumjs-util';\nimport type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker';\n\nimport type {\n GasPriceValue,\n FeeMarketEIP1559Values,\n} from './TransactionController';\nimport { TransactionStatus } from './types';\nimport type { TransactionParams, TransactionMeta } from './types';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\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 let key: keyof TransactionParams;\n for (key in NORMALIZERS) {\n if (txParams[key as keyof TransactionParams]) {\n normalizedTxParams[key] = NORMALIZERS[key](txParams[key]) as never;\n }\n }\n return normalizedTxParams;\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 if (\n !txParams.from ||\n typeof txParams.from !== 'string' ||\n !isValidHexAddress(txParams.from)\n ) {\n throw rpcErrors.invalidParams(\n `Invalid \"from\" address: ${txParams.from} must be a valid string.`,\n );\n }\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 if (txParams.to === '0x' || txParams.to === undefined) {\n if (txParams.data) {\n delete txParams.to;\n } else {\n throw rpcErrors.invalidParams(\n `Invalid \"to\" address: ${txParams.to} must be a valid string.`,\n );\n }\n } else if (txParams.to !== undefined && !isValidHexAddress(txParams.to)) {\n throw rpcErrors.invalidParams(\n `Invalid \"to\" address: ${txParams.to} must be a valid string.`,\n );\n }\n\n if (txParams.value !== undefined) {\n const value = txParams.value.toString();\n if (value.includes('-')) {\n throw rpcErrors.invalidParams(\n `Invalid \"value\": ${value} is not a positive number.`,\n );\n }\n\n if (value.includes('.')) {\n throw rpcErrors.invalidParams(\n `Invalid \"value\": ${value} number must be denominated in wei.`,\n );\n }\n const intValue = parseInt(txParams.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 \"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 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 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, txParams: { from } }) =>\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 return {\n status,\n history: [{}],\n txParams: {\n from: from ?? '',\n gas: gas ?? '',\n value: value ?? '',\n nonce: nonce ?? '',\n },\n };\n });\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 `Can only call ${fnName} on an unapproved transaction.\n Current tx status: ${transactionMeta?.status}`,\n );\n }\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..02539b9 +--- /dev/null ++++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts +@@ -0,0 +1,32 @@ ++import { type GasFeeEstimates, type GasFeeState, type LegacyGasPriceEstimate } 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..1eee187 +--- /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,EAGL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC5B,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..461ba2c +--- /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;AAC7D,qEAMsC;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 {\n GAS_ESTIMATE_TYPES,\n type Eip1559GasFee,\n type GasFeeEstimates,\n type GasFeeState,\n type LegacyGasPriceEstimate,\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/patches/@metamask+transaction-controller+8.0.1.patch b/patches/@metamask+transaction-controller+8.0.1.patch deleted file mode 100644 index bbdf5e2adb1b..000000000000 --- a/patches/@metamask+transaction-controller+8.0.1.patch +++ /dev/null @@ -1,2762 +0,0 @@ -diff --git a/node_modules/@metamask/transaction-controller/dist/.patch.txt b/node_modules/@metamask/transaction-controller/dist/.patch.txt -new file mode 100644 -index 0000000..a36a87d ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/.patch.txt -@@ -0,0 +1,7 @@ -+PATCH GENERATED FROM MetaMask/core branch: patch/mobile-transaction-controller-8-0-1 -+This patch backports various transaction controller features from the main branch of MetaMask/core -+Steps to update patch: -+* Create a new core branch from: patch/mobile-transaction-controller-8-0-1 -+* Run "yarn build" in the core monorepo -+* Run "yarn patch:tx " in the mobile repo -+* Once the new patch is merged, add your changes to: patch/mobile-transaction-controller-8-0-1 -diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts -index d89ef46..7637754 100644 ---- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts -@@ -4,12 +4,11 @@ import type { RemoteTransactionSource, RemoteTransactionSourceRequest, Transacti - */ - export declare class EtherscanRemoteTransactionSource implements RemoteTransactionSource { - #private; -- /** -- * Retrieve transaction data from Etherscan. -- * -- * @param request - The configuration required to fetch Etherscan transaction data. -- * @returns An array of transaction metadata. -- */ -+ constructor({ apiKey, includeTokenTransfers, }?: { -+ apiKey?: string; -+ includeTokenTransfers?: boolean; -+ }); -+ isSupportedNetwork(chainId: string, _networkId: string): boolean; - fetchTransactions(request: RemoteTransactionSourceRequest): Promise; - } - //# sourceMappingURL=EtherscanRemoteTransactionSource.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map -deleted file mode 100644 -index 4f8dae0..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.d.ts.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"EtherscanRemoteTransactionSource.d.ts","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,uBAAuB,EACvB,8BAA8B,EAC9B,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,qBAAa,gCACX,YAAW,uBAAuB;;IAElC;;;;;OAKG;IACG,iBAAiB,CACrB,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,eAAe,EAAE,CAAC;CAqG9B"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js -index 63fdb89..0902b41 100644 ---- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js -+++ b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js -@@ -8,38 +8,50 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge - 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_normalizeTransaction, _EtherscanRemoteTransactionSource_normalizeTokenTransaction, _EtherscanRemoteTransactionSource_normalizeTransactionBase; -+var _EtherscanRemoteTransactionSource_instances, _EtherscanRemoteTransactionSource_apiKey, _EtherscanRemoteTransactionSource_includeTokenTransfers, _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 etherscan_1 = require("./etherscan"); - const types_1 = require("./types"); - /** - * A RemoteTransactionSource that fetches transaction data from Etherscan. - */ - class EtherscanRemoteTransactionSource { -- constructor() { -+ constructor({ apiKey, includeTokenTransfers, } = {}) { - _EtherscanRemoteTransactionSource_instances.add(this); -+ _EtherscanRemoteTransactionSource_apiKey.set(this, void 0); -+ _EtherscanRemoteTransactionSource_includeTokenTransfers.set(this, void 0); -+ __classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_apiKey, apiKey, "f"); -+ __classPrivateFieldSet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, includeTokenTransfers !== null && includeTokenTransfers !== void 0 ? includeTokenTransfers : true, "f"); -+ } -+ isSupportedNetwork(chainId, _networkId) { -+ return Object.keys(constants_1.ETHERSCAN_SUPPORTED_NETWORKS).includes(chainId); - } -- /** -- * Retrieve transaction data from Etherscan. -- * -- * @param request - The configuration required to fetch Etherscan transaction data. -- * @returns An array of transaction metadata. -- */ - fetchTransactions(request) { - return __awaiter(this, void 0, void 0, function* () { -- const [etherscanTransactions, etherscanTokenTransactions] = yield Promise.all([ -- (0, etherscan_1.fetchEtherscanTransactions)(request), -- (0, etherscan_1.fetchEtherscanTokenTransactions)(request), -- ]); -+ const etherscanRequest = Object.assign(Object.assign({}, request), { apiKey: __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_apiKey, "f"), chainId: request.currentChainId }); -+ const transactionPromise = (0, etherscan_1.fetchEtherscanTransactions)(etherscanRequest); -+ const tokenTransactionPromise = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_includeTokenTransfers, "f") -+ ? (0, etherscan_1.fetchEtherscanTokenTransactions)(etherscanRequest) -+ : Promise.resolve({ -+ result: [], -+ }); -+ const [etherscanTransactions, etherscanTokenTransactions] = yield Promise.all([transactionPromise, tokenTransactionPromise]); - const transactions = etherscanTransactions.result.map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransaction).call(this, tx, request.currentNetworkId, request.currentChainId)); - const tokenTransactions = etherscanTokenTransactions.result.map((tx) => __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTokenTransaction).call(this, tx, request.currentNetworkId, request.currentChainId)); - return [...transactions, ...tokenTransactions]; -@@ -47,7 +59,7 @@ class EtherscanRemoteTransactionSource { - } - } - exports.EtherscanRemoteTransactionSource = EtherscanRemoteTransactionSource; --_EtherscanRemoteTransactionSource_instances = new WeakSet(), _EtherscanRemoteTransactionSource_normalizeTransaction = function _EtherscanRemoteTransactionSource_normalizeTransaction(txMeta, currentNetworkId, currentChainId) { -+_EtherscanRemoteTransactionSource_apiKey = new WeakMap(), _EtherscanRemoteTransactionSource_includeTokenTransfers = new WeakMap(), _EtherscanRemoteTransactionSource_instances = new WeakSet(), _EtherscanRemoteTransactionSource_normalizeTransaction = function _EtherscanRemoteTransactionSource_normalizeTransaction(txMeta, currentNetworkId, currentChainId) { - const base = __classPrivateFieldGet(this, _EtherscanRemoteTransactionSource_instances, "m", _EtherscanRemoteTransactionSource_normalizeTransactionBase).call(this, txMeta, currentNetworkId, currentChainId); - return Object.assign(Object.assign(Object.assign({}, base), { transaction: Object.assign(Object.assign({}, base.transaction), { data: txMeta.input }) }), (txMeta.isError === '0' - ? { status: types_1.TransactionStatus.confirmed } -diff --git a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map b/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map -deleted file mode 100644 -index ade75c0..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/EtherscanRemoteTransactionSource.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"EtherscanRemoteTransactionSource.js","sourceRoot":"","sources":["../src/EtherscanRemoteTransactionSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAAqD;AAErD,qDAAqC;AACrC,+BAAoC;AAOpC,2CAGqB;AAMrB,mCAA4C;AAE5C;;GAEG;AACH,MAAa,gCAAgC;IAA7C;;IAgHA,CAAC;IA7GC;;;;;OAKG;IACG,iBAAiB,CACrB,OAAuC;;YAEvC,MAAM,CAAC,qBAAqB,EAAE,0BAA0B,CAAC,GACvD,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChB,IAAA,sCAA0B,EAAC,OAAO,CAAC;gBACnC,IAAA,2CAA+B,EAAC,OAAO,CAAC;aACzC,CAAC,CAAC;YAEL,MAAM,YAAY,GAAG,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAC3D,uBAAA,IAAI,2GAAsB,MAA1B,IAAI,EACF,EAAE,EACF,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC,cAAc,CACvB,CACF,CAAC;YAEF,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACrE,uBAAA,IAAI,gHAA2B,MAA/B,IAAI,EACF,EAAE,EACF,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC,cAAc,CACvB,CACF,CAAC;YAEF,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,iBAAiB,CAAC,CAAC;QACjD,CAAC;KAAA;CA6EF;AAhHD,4EAgHC;sLA1EG,MAAgC,EAChC,gBAAwB,EACxB,cAAmB;IAEnB,MAAM,IAAI,GAAG,uBAAA,IAAI,+GAA0B,MAA9B,IAAI,EACf,MAA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ChC,QAAQ,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,IAAA,0BAAO,EAAC,IAAI,oBAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,eAAe,EAAE,MAAM,CAAC,IAAI;QAC5B,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 type {\n EtherscanTokenTransactionMeta,\n EtherscanTransactionMeta,\n EtherscanTransactionMetaBase,\n} from './etherscan';\nimport {\n fetchEtherscanTokenTransactions,\n fetchEtherscanTransactions,\n} from './etherscan';\nimport type {\n RemoteTransactionSource,\n RemoteTransactionSourceRequest,\n TransactionMeta,\n} from './types';\nimport { TransactionStatus } from './types';\n\n/**\n * A RemoteTransactionSource that fetches transaction data from Etherscan.\n */\nexport class EtherscanRemoteTransactionSource\n implements RemoteTransactionSource\n{\n /**\n * Retrieve transaction data from Etherscan.\n *\n * @param request - The configuration required to fetch Etherscan transaction data.\n * @returns An array of transaction metadata.\n */\n async fetchTransactions(\n request: RemoteTransactionSourceRequest,\n ): Promise {\n const [etherscanTransactions, etherscanTokenTransactions] =\n await Promise.all([\n fetchEtherscanTransactions(request),\n fetchEtherscanTokenTransactions(request),\n ]);\n\n const transactions = etherscanTransactions.result.map((tx) =>\n this.#normalizeTransaction(\n tx,\n request.currentNetworkId,\n request.currentChainId,\n ),\n );\n\n const tokenTransactions = etherscanTokenTransactions.result.map((tx) =>\n this.#normalizeTokenTransaction(\n tx,\n request.currentNetworkId,\n request.currentChainId,\n ),\n );\n\n return [...transactions, ...tokenTransactions];\n }\n\n #normalizeTransaction(\n txMeta: EtherscanTransactionMeta,\n currentNetworkId: string,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(\n txMeta,\n currentNetworkId,\n currentChainId,\n );\n\n return {\n ...base,\n transaction: {\n ...base.transaction,\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 currentNetworkId: string,\n currentChainId: Hex,\n ): TransactionMeta {\n const base = this.#normalizeTransactionBase(\n txMeta,\n currentNetworkId,\n currentChainId,\n );\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 currentNetworkId: string,\n currentChainId: Hex,\n ): TransactionMeta {\n const time = parseInt(txMeta.timeStamp, 10) * 1000;\n\n return {\n blockNumber: txMeta.blockNumber,\n chainId: currentChainId,\n id: random({ msecs: time }),\n networkID: currentNetworkId,\n status: TransactionStatus.confirmed,\n time,\n transaction: {\n from: txMeta.from,\n gas: BNToHex(new BN(txMeta.gas)),\n gasPrice: BNToHex(new BN(txMeta.gasPrice)),\n gasUsed: BNToHex(new BN(txMeta.gasUsed)),\n nonce: BNToHex(new BN(txMeta.nonce)),\n to: txMeta.to,\n value: BNToHex(new BN(txMeta.value)),\n },\n transactionHash: txMeta.hash,\n verifiedOnBlockchain: false,\n };\n }\n}\n"]} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts -index 37a01c8..7ee2061 100644 ---- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts -@@ -1,23 +1,23 @@ --import type EthQuery from '@metamask/eth-query'; --import type { NetworkState } from '@metamask/network-controller'; -+/// -+import type { BlockTracker, NetworkState } from '@metamask/network-controller'; -+import EventEmitter from 'events'; - import type { RemoteTransactionSource, TransactionMeta } from './types'; - export declare class IncomingTransactionHelper { - #private; -- constructor({ getNetworkState, getEthQuery, transactionLimit, remoteTransactionSource, }: { -+ hub: EventEmitter; -+ constructor({ blockTracker, getCurrentAccount, getLastFetchedBlockNumbers, getLocalTransactions, getNetworkState, isEnabled, remoteTransactionSource, transactionLimit, updateTransactions, }: { -+ blockTracker: BlockTracker; -+ getCurrentAccount: () => string; - getNetworkState: () => NetworkState; -- getEthQuery: () => EthQuery; -- transactionLimit: number; -+ getLastFetchedBlockNumbers: () => Record; -+ getLocalTransactions?: () => TransactionMeta[]; -+ isEnabled?: () => boolean; - remoteTransactionSource: RemoteTransactionSource; -+ transactionLimit?: number; -+ updateTransactions?: boolean; - }); -- reconcile({ address, localTransactions, fromBlock, apiKey, }: { -- address: string; -- localTransactions: TransactionMeta[]; -- fromBlock?: string; -- apiKey?: string; -- }): Promise<{ -- updateRequired: boolean; -- transactions: TransactionMeta[]; -- latestBlockNumber?: string; -- }>; -+ start(): void; -+ stop(): void; -+ update(latestBlockNumberHex?: string): Promise; - } - //# sourceMappingURL=IncomingTransactionHelper.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map -deleted file mode 100644 -index 048e002..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.d.ts.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"IncomingTransactionHelper.d.ts","sourceRoot":"","sources":["../src/IncomingTransactionHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,KAAK,EACV,uBAAuB,EAEvB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAQjB,qBAAa,yBAAyB;;gBASxB,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,uBAAuB,GACxB,EAAE;QACD,eAAe,EAAE,MAAM,YAAY,CAAC;QACpC,WAAW,EAAE,MAAM,QAAQ,CAAC;QAC5B,gBAAgB,EAAE,MAAM,CAAC;QACzB,uBAAuB,EAAE,uBAAuB,CAAC;KAClD;IAOK,SAAS,CAAC,EACd,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,MAAM,GACP,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,eAAe,EAAE,CAAC;QACrC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,eAAe,EAAE,CAAC;QAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CAmMH"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js -index 6a27aeb..5f34686 100644 ---- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js -+++ b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js -@@ -19,126 +19,173 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( - 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 _IncomingTransactionHelper_instances, _IncomingTransactionHelper_getNetworkState, _IncomingTransactionHelper_getEthQuery, _IncomingTransactionHelper_transactionLimit, _IncomingTransactionHelper_remoteTransactionSource, _IncomingTransactionHelper_updateSmartContractProperty, _IncomingTransactionHelper_getLatestBlockNumber, _IncomingTransactionHelper_isToSmartContract, _IncomingTransactionHelper_sortTransactionsByTime, _IncomingTransactionHelper_reconcileTransactions, _IncomingTransactionHelper_getNewTransactions, _IncomingTransactionHelper_getUpdatedTransactions, _IncomingTransactionHelper_isTransactionOutdated, _IncomingTransactionHelper_isStatusOutdated, _IncomingTransactionHelper_isGasDataOutdated; -+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_remoteTransactionSource, _IncomingTransactionHelper_transactionLimit, _IncomingTransactionHelper_updateTransactions, _IncomingTransactionHelper_sortTransactionsByTime, _IncomingTransactionHelper_getNewTransactions, _IncomingTransactionHelper_getUpdatedTransactions, _IncomingTransactionHelper_isTransactionOutdated, _IncomingTransactionHelper_getFromBlock, _IncomingTransactionHelper_updateLastFetchedBlockNumber, _IncomingTransactionHelper_getBlockNumberKey, _IncomingTransactionHelper_canStart, _IncomingTransactionHelper_getCurrentChainId, _IncomingTransactionHelper_getCurrentNetworkId; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.IncomingTransactionHelper = void 0; --const controller_utils_1 = require("@metamask/controller-utils"); --const SUPPORTED_NETWORK_IDS = [ -- '1', -- '5', -- '11155111', // Sepolia -+const async_mutex_1 = require("async-mutex"); -+const events_1 = __importDefault(require("events")); -+const UPDATE_CHECKS = [ -+ (txMeta) => txMeta.status, -+ (txMeta) => txMeta.transaction.gasUsed, - ]; - class IncomingTransactionHelper { -- constructor({ getNetworkState, getEthQuery, transactionLimit, remoteTransactionSource, }) { -+ constructor({ blockTracker, getCurrentAccount, getLastFetchedBlockNumbers, getLocalTransactions, getNetworkState, isEnabled, 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_getEthQuery.set(this, void 0); -- _IncomingTransactionHelper_transactionLimit.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_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_getEthQuery, getEthQuery, "f"); -- __classPrivateFieldSet(this, _IncomingTransactionHelper_transactionLimit, transactionLimit, "f"); -+ __classPrivateFieldSet(this, _IncomingTransactionHelper_isEnabled, isEnabled !== null && isEnabled !== void 0 ? isEnabled : (() => true), "f"); -+ __classPrivateFieldSet(this, _IncomingTransactionHelper_isRunning, false, "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"); - } -- reconcile({ address, localTransactions, fromBlock, apiKey, }) { -+ 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) { - return __awaiter(this, void 0, void 0, function* () { -- const { providerConfig, networkId: currentNetworkId } = __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this); -- const { chainId: currentChainId, type: networkType } = providerConfig; -- if (currentNetworkId === null || -- !SUPPORTED_NETWORK_IDS.includes(currentNetworkId)) { -- return { updateRequired: false, transactions: [] }; -+ const releaseLock = yield __classPrivateFieldGet(this, _IncomingTransactionHelper_mutex, "f").acquire(); -+ 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 fromBlock = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getFromBlock).call(this, latestBlockNumber); -+ const address = __classPrivateFieldGet(this, _IncomingTransactionHelper_getCurrentAccount, "f").call(this); -+ const currentChainId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentChainId).call(this); -+ const currentNetworkId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentNetworkId).call(this); -+ let remoteTransactions = []; -+ try { -+ remoteTransactions = -+ yield __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f").fetchTransactions({ -+ address, -+ currentChainId, -+ currentNetworkId, -+ fromBlock, -+ limit: __classPrivateFieldGet(this, _IncomingTransactionHelper_transactionLimit, "f"), -+ }); -+ } -+ catch (error) { -+ return; -+ } -+ if (!__classPrivateFieldGet(this, _IncomingTransactionHelper_updateTransactions, "f")) { -+ remoteTransactions = remoteTransactions.filter((tx) => { var _a; return ((_a = tx.transaction.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); -+ this.hub.emit('transactions', { -+ added: newTransactions, -+ updated: updatedTransactions, -+ }); -+ } -+ __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_updateLastFetchedBlockNumber).call(this, remoteTransactions); -+ } -+ finally { -+ releaseLock(); - } -- const remoteTransactions = yield __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f").fetchTransactions({ -- address, -- networkType, -- limit: __classPrivateFieldGet(this, _IncomingTransactionHelper_transactionLimit, "f"), -- currentChainId, -- currentNetworkId, -- fromBlock, -- apiKey, -- }); -- const [updateRequired, transactions] = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_reconcileTransactions).call(this, localTransactions, remoteTransactions); -- __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_sortTransactionsByTime).call(this, transactions); -- const latestBlockNumber = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getLatestBlockNumber).call(this, transactions, address, currentChainId, currentNetworkId); -- yield __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_updateSmartContractProperty).call(this, transactions); -- return { updateRequired, transactions, latestBlockNumber }; - }); - } - } - exports.IncomingTransactionHelper = IncomingTransactionHelper; --_IncomingTransactionHelper_getNetworkState = new WeakMap(), _IncomingTransactionHelper_getEthQuery = new WeakMap(), _IncomingTransactionHelper_transactionLimit = new WeakMap(), _IncomingTransactionHelper_remoteTransactionSource = new WeakMap(), _IncomingTransactionHelper_instances = new WeakSet(), _IncomingTransactionHelper_updateSmartContractProperty = function _IncomingTransactionHelper_updateSmartContractProperty(transactions) { -- return __awaiter(this, void 0, void 0, function* () { -- yield Promise.all(transactions.map((tx) => __awaiter(this, void 0, void 0, function* () { -- var _a; -- (_a = tx.toSmartContract) !== null && _a !== void 0 ? _a : (tx.toSmartContract = yield __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_isToSmartContract).call(this, tx.transaction)); -- }))); -- }); --}, _IncomingTransactionHelper_getLatestBlockNumber = function _IncomingTransactionHelper_getLatestBlockNumber(transactions, address, currentChainId, currentNetworkId) { -- var _a; -- let latestBlockNumber; -- for (const tx of transactions) { -- const onCurrentChain = tx.chainId === currentChainId || -- (!tx.chainId && tx.networkID === currentNetworkId); -- const toCurrentAccount = ((_a = tx.transaction.to) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === address.toLowerCase(); -+_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_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(({ transactionHash }) => transactionHash === tx.transactionHash)); -+}, _IncomingTransactionHelper_getUpdatedTransactions = function _IncomingTransactionHelper_getUpdatedTransactions(remoteTxs, localTxs) { -+ return remoteTxs.filter((remoteTx) => localTxs.some((localTx) => remoteTx.transactionHash === localTx.transactionHash && -+ __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) { -+ const lastFetchedKey = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getBlockNumberKey).call(this); -+ const lastFetchedBlockNumber = __classPrivateFieldGet(this, _IncomingTransactionHelper_getLastFetchedBlockNumbers, "f").call(this)[lastFetchedKey]; -+ if (lastFetchedBlockNumber) { -+ return lastFetchedBlockNumber + 1; -+ } -+ // Query entire transaction history -+ return undefined; -+}, _IncomingTransactionHelper_updateLastFetchedBlockNumber = function _IncomingTransactionHelper_updateLastFetchedBlockNumber(remoteTxs) { -+ let lastFetchedBlockNumber = -1; -+ for (const tx of remoteTxs) { - const currentBlockNumberValue = tx.blockNumber - ? parseInt(tx.blockNumber, 10) - : -1; -- const latestBlockNumberValue = latestBlockNumber -- ? parseInt(latestBlockNumber, 10) -- : -1; -- if (onCurrentChain && -- toCurrentAccount && -- latestBlockNumberValue < currentBlockNumberValue) { -- latestBlockNumber = tx.blockNumber; -- } -+ lastFetchedBlockNumber = Math.max(lastFetchedBlockNumber, currentBlockNumberValue); - } -- return latestBlockNumber; --}, _IncomingTransactionHelper_isToSmartContract = function _IncomingTransactionHelper_isToSmartContract(transaction) { -- return __awaiter(this, void 0, void 0, function* () { -- // Contract Deploy -- if (!transaction.to) { -- return false; -- } -- // Send -- if (transaction.data === '0x') { -- return false; -- } -- const ethQuery = __classPrivateFieldGet(this, _IncomingTransactionHelper_getEthQuery, "f").call(this); -- const code = yield (0, controller_utils_1.query)(ethQuery, 'getCode', [transaction.to]); -- return (0, controller_utils_1.isSmartContractCode)(code); -- }); --}, _IncomingTransactionHelper_sortTransactionsByTime = function _IncomingTransactionHelper_sortTransactionsByTime(transactions) { -- transactions.sort((a, b) => (a.time < b.time ? -1 : 1)); --}, _IncomingTransactionHelper_reconcileTransactions = function _IncomingTransactionHelper_reconcileTransactions(localTxs, remoteTxs) { -- const updatedTxs = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getUpdatedTransactions).call(this, remoteTxs, localTxs); -- const newTxs = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getNewTransactions).call(this, remoteTxs, localTxs); -- const updatedLocalTxs = localTxs.map((tx) => { -- const txIdx = updatedTxs.findIndex(({ transactionHash }) => transactionHash === tx.transactionHash); -- return txIdx === -1 ? tx : updatedTxs[txIdx]; -- }); -- const updateRequired = newTxs.length > 0 || updatedTxs.length > 0; -- const transactions = [...newTxs, ...updatedLocalTxs]; -- return [updateRequired, transactions]; --}, _IncomingTransactionHelper_getNewTransactions = function _IncomingTransactionHelper_getNewTransactions(remoteTxs, localTxs) { -- return remoteTxs.filter((tx) => { -- const alreadyInTransactions = localTxs.find(({ transactionHash }) => transactionHash === tx.transactionHash); -- return !alreadyInTransactions; -- }); --}, _IncomingTransactionHelper_getUpdatedTransactions = function _IncomingTransactionHelper_getUpdatedTransactions(remoteTxs, localTxs) { -- return remoteTxs.filter((remoteTx) => { -- const isTxOutdated = localTxs.find((localTx) => { -- return (remoteTx.transactionHash === localTx.transactionHash && -- __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_isTransactionOutdated).call(this, remoteTx, localTx)); -- }); -- return isTxOutdated; -+ if (lastFetchedBlockNumber === -1) { -+ return; -+ } -+ const lastFetchedKey = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getBlockNumberKey).call(this); -+ 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_isTransactionOutdated = function _IncomingTransactionHelper_isTransactionOutdated(remoteTx, localTx) { -- const statusOutdated = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_isStatusOutdated).call(this, remoteTx.transactionHash, localTx.transactionHash, remoteTx.status, localTx.status); -- const gasDataOutdated = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_isGasDataOutdated).call(this, remoteTx.transaction.gasUsed, localTx.transaction.gasUsed); -- return statusOutdated || gasDataOutdated; --}, _IncomingTransactionHelper_isStatusOutdated = function _IncomingTransactionHelper_isStatusOutdated(remoteTxHash, localTxHash, remoteTxStatus, localTxStatus) { -- return remoteTxHash === localTxHash && remoteTxStatus !== localTxStatus; --}, _IncomingTransactionHelper_isGasDataOutdated = function _IncomingTransactionHelper_isGasDataOutdated(remoteGasUsed, localGasUsed) { -- return remoteGasUsed !== localGasUsed; -+}, _IncomingTransactionHelper_getBlockNumberKey = function _IncomingTransactionHelper_getBlockNumberKey() { -+ var _a; -+ const currentChainId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentChainId).call(this); -+ const currentAccount = (_a = __classPrivateFieldGet(this, _IncomingTransactionHelper_getCurrentAccount, "f").call(this)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); -+ return [currentChainId, currentAccount].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 currentNetworkId = __classPrivateFieldGet(this, _IncomingTransactionHelper_instances, "m", _IncomingTransactionHelper_getCurrentNetworkId).call(this); -+ const isSupportedNetwork = __classPrivateFieldGet(this, _IncomingTransactionHelper_remoteTransactionSource, "f").isSupportedNetwork(currentChainId, currentNetworkId); -+ return isEnabled && isSupportedNetwork; -+}, _IncomingTransactionHelper_getCurrentChainId = function _IncomingTransactionHelper_getCurrentChainId() { -+ return __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).providerConfig.chainId; -+}, _IncomingTransactionHelper_getCurrentNetworkId = function _IncomingTransactionHelper_getCurrentNetworkId() { -+ return __classPrivateFieldGet(this, _IncomingTransactionHelper_getNetworkState, "f").call(this).networkId; - }; - //# sourceMappingURL=IncomingTransactionHelper.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js.map b/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js.map -deleted file mode 100644 -index 2fc96c7..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/IncomingTransactionHelper.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"IncomingTransactionHelper.js","sourceRoot":"","sources":["../src/IncomingTransactionHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAwE;AAYxE,MAAM,qBAAqB,GAAG;IAC5B,GA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AO,CAAC,eAAe,EACvB,QAAQ,CAAC,MAAM,EACf,OAAO,CAAC,MAAM,CACf,CAAC;IAEF,MAAM,eAAe,GAAG,uBAAA,IAAI,0FAAmB,MAAvB,IAAI,EAC1B,QAAQ,CAAC,WAAW,CAAC,OAAO,EAC5B,OAAO,CAAC,WAAW,CAAC,OAAO,CAC5B,CAAC;IAEF,OAAO,cAAc,IAAI,eAAe,CAAC;AAC3C,CAAC,qGAGC,YAAgC,EAChC,WAA+B,EAC/B,cAAiC,EACjC,aAAgC;IAEhC,OAAO,YAAY,KAAK,WAAW,IAAI,cAAc,KAAK,aAAa,CAAC;AAC1E,CAAC,uGAGC,aAAiC,EACjC,YAAgC;IAEhC,OAAO,aAAa,KAAK,YAAY,CAAC;AACxC,CAAC","sourcesContent":["import { isSmartContractCode, query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type { NetworkState } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type {\n RemoteTransactionSource,\n Transaction,\n TransactionMeta,\n TransactionStatus,\n} from './types';\n\nconst SUPPORTED_NETWORK_IDS = [\n '1', // Mainnet\n '5', // Goerli\n '11155111', // Sepolia\n];\n\nexport class IncomingTransactionHelper {\n #getNetworkState: () => NetworkState;\n\n #getEthQuery: () => EthQuery;\n\n #transactionLimit: number;\n\n #remoteTransactionSource: RemoteTransactionSource;\n\n constructor({\n getNetworkState,\n getEthQuery,\n transactionLimit,\n remoteTransactionSource,\n }: {\n getNetworkState: () => NetworkState;\n getEthQuery: () => EthQuery;\n transactionLimit: number;\n remoteTransactionSource: RemoteTransactionSource;\n }) {\n this.#getNetworkState = getNetworkState;\n this.#getEthQuery = getEthQuery;\n this.#transactionLimit = transactionLimit;\n this.#remoteTransactionSource = remoteTransactionSource;\n }\n\n async reconcile({\n address,\n localTransactions,\n fromBlock,\n apiKey,\n }: {\n address: string;\n localTransactions: TransactionMeta[];\n fromBlock?: string;\n apiKey?: string;\n }): Promise<{\n updateRequired: boolean;\n transactions: TransactionMeta[];\n latestBlockNumber?: string;\n }> {\n const { providerConfig, networkId: currentNetworkId } =\n this.#getNetworkState();\n const { chainId: currentChainId, type: networkType } = providerConfig;\n\n if (\n currentNetworkId === null ||\n !SUPPORTED_NETWORK_IDS.includes(currentNetworkId)\n ) {\n return { updateRequired: false, transactions: [] };\n }\n\n const remoteTransactions =\n await this.#remoteTransactionSource.fetchTransactions({\n address,\n networkType,\n limit: this.#transactionLimit,\n currentChainId,\n currentNetworkId,\n fromBlock,\n apiKey,\n });\n\n const [updateRequired, transactions] = this.#reconcileTransactions(\n localTransactions,\n remoteTransactions,\n );\n\n this.#sortTransactionsByTime(transactions);\n\n const latestBlockNumber = this.#getLatestBlockNumber(\n transactions,\n address,\n currentChainId,\n currentNetworkId,\n );\n\n await this.#updateSmartContractProperty(transactions);\n\n return { updateRequired, transactions, latestBlockNumber };\n }\n\n async #updateSmartContractProperty(transactions: TransactionMeta[]) {\n await Promise.all(\n transactions.map(async (tx) => {\n tx.toSmartContract ??= await this.#isToSmartContract(tx.transaction);\n }),\n );\n }\n\n #getLatestBlockNumber(\n transactions: TransactionMeta[],\n address: string,\n currentChainId: Hex,\n currentNetworkId: string,\n ): string | undefined {\n let latestBlockNumber: string | undefined;\n\n for (const tx of transactions) {\n const onCurrentChain =\n tx.chainId === currentChainId ||\n (!tx.chainId && tx.networkID === currentNetworkId);\n\n const toCurrentAccount =\n tx.transaction.to?.toLowerCase() === address.toLowerCase();\n\n const currentBlockNumberValue = tx.blockNumber\n ? parseInt(tx.blockNumber, 10)\n : -1;\n\n const latestBlockNumberValue = latestBlockNumber\n ? parseInt(latestBlockNumber, 10)\n : -1;\n\n if (\n onCurrentChain &&\n toCurrentAccount &&\n latestBlockNumberValue < currentBlockNumberValue\n ) {\n latestBlockNumber = tx.blockNumber;\n }\n }\n\n return latestBlockNumber;\n }\n\n async #isToSmartContract(transaction: Transaction): Promise {\n // Contract Deploy\n if (!transaction.to) {\n return false;\n }\n\n // Send\n if (transaction.data === '0x') {\n return false;\n }\n\n const ethQuery = this.#getEthQuery();\n const code = await query(ethQuery, 'getCode', [transaction.to]);\n\n return isSmartContractCode(code);\n }\n\n #sortTransactionsByTime(transactions: TransactionMeta[]) {\n transactions.sort((a, b) => (a.time < b.time ? -1 : 1));\n }\n\n #reconcileTransactions(\n localTxs: TransactionMeta[],\n remoteTxs: TransactionMeta[],\n ): [boolean, TransactionMeta[]] {\n const updatedTxs: TransactionMeta[] = this.#getUpdatedTransactions(\n remoteTxs,\n localTxs,\n );\n\n const newTxs: TransactionMeta[] = this.#getNewTransactions(\n remoteTxs,\n localTxs,\n );\n\n const updatedLocalTxs = localTxs.map((tx: TransactionMeta) => {\n const txIdx = updatedTxs.findIndex(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return txIdx === -1 ? tx : updatedTxs[txIdx];\n });\n\n const updateRequired = newTxs.length > 0 || updatedTxs.length > 0;\n const transactions = [...newTxs, ...updatedLocalTxs];\n\n return [updateRequired, transactions];\n }\n\n #getNewTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((tx) => {\n const alreadyInTransactions = localTxs.find(\n ({ transactionHash }) => transactionHash === tx.transactionHash,\n );\n return !alreadyInTransactions;\n });\n }\n\n #getUpdatedTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((remoteTx) => {\n const isTxOutdated = localTxs.find((localTx) => {\n return (\n remoteTx.transactionHash === localTx.transactionHash &&\n this.#isTransactionOutdated(remoteTx, localTx)\n );\n });\n return isTxOutdated;\n });\n }\n\n #isTransactionOutdated(\n remoteTx: TransactionMeta,\n localTx: TransactionMeta,\n ): boolean {\n const statusOutdated = this.#isStatusOutdated(\n remoteTx.transactionHash,\n localTx.transactionHash,\n remoteTx.status,\n localTx.status,\n );\n\n const gasDataOutdated = this.#isGasDataOutdated(\n remoteTx.transaction.gasUsed,\n localTx.transaction.gasUsed,\n );\n\n return statusOutdated || gasDataOutdated;\n }\n\n #isStatusOutdated(\n remoteTxHash: string | undefined,\n localTxHash: string | undefined,\n remoteTxStatus: TransactionStatus,\n localTxStatus: TransactionStatus,\n ): boolean {\n return remoteTxHash === localTxHash && remoteTxStatus !== localTxStatus;\n }\n\n #isGasDataOutdated(\n remoteGasUsed: string | undefined,\n localGasUsed: string | undefined,\n ): boolean {\n return remoteGasUsed !== localGasUsed;\n }\n}\n"]} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts -index 4e3d5e0..5c96964 100644 ---- a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts -@@ -1,13 +1,14 @@ - /// --import { Hardfork, Common } from '@ethereumjs/common'; -+import { Common } from '@ethereumjs/common'; - import type { TypedTransaction } from '@ethereumjs/tx'; - import type { AddApprovalRequest } from '@metamask/approval-controller'; - import type { BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller'; - import { BaseController } from '@metamask/base-controller'; -+import type { GasFeeState } from '@metamask/gas-fee-controller'; - import type { BlockTracker, NetworkState, Provider } from '@metamask/network-controller'; - import { EventEmitter } from 'events'; --import type { Transaction, TransactionMeta, WalletDevice } from './types'; --export declare const HARDFORK = Hardfork.London; -+import type { NonceLock } from 'nonce-tracker/dist/NonceTracker'; -+import type { SecurityAlertResponse, Transaction, TransactionMeta, WalletDevice, SubmitHistoryEntry } from './types'; - /** - * @type Result - * @property result - Promise resolving to a new transaction hash -@@ -17,15 +18,6 @@ export interface Result { - result: Promise; - transactionMeta: TransactionMeta; - } --/** -- * @type Fetch All Options -- * @property fromBlock - String containing a specific block decimal number -- * @property etherscanApiKey - API key to be used to fetch token transactions -- */ --export interface FetchAllOptions { -- fromBlock?: string; -- etherscanApiKey?: string; --} - export interface GasPriceValue { - gasPrice: string; - } -@@ -69,11 +61,15 @@ export interface TransactionState extends BaseState { - methodData: { - [key: string]: MethodData; - }; -+ lastFetchedBlockNumbers: { -+ [key: string]: number; -+ }; -+ submitHistory: SubmitHistoryEntry[]; - } - /** - * Multiplier used to determine a transaction's increased gas fee during cancellation - */ --export declare const CANCEL_RATE = 1.5; -+export declare const CANCEL_RATE = 1.1; - /** - * Multiplier used to determine a transaction's increased gas fee during speed up - */ -@@ -101,6 +97,8 @@ export declare class TransactionController extends BaseController Promise; - getNetworkState: () => NetworkState; -+ getSelectedAddress: () => string; -+ incomingTransactions: { -+ apiKey?: string; -+ includeTokenTransfers?: boolean; -+ isEnabled?: () => boolean; -+ updateTransactions?: boolean; -+ }; -+ messenger: TransactionControllerMessenger; - onNetworkStateChange: (listener: (state: NetworkState) => void) => void; - provider: Provider; -- blockTracker: BlockTracker; -- messenger: TransactionControllerMessenger; - }, config?: Partial, state?: Partial); - /** - * Starts a new polling interval. -@@ -155,11 +168,20 @@ export declare class TransactionController extends BaseController:unapproved` hub event will be emitted once added. - * - * @param transaction - The transaction object to add. -- * @param origin - The domain origin to append to the generated TransactionMeta. -- * @param deviceConfirmedOn - An enum to indicate what device the transaction was confirmed to append to the generated TransactionMeta. -+ * @param opts - Additional options to control how the transaction is added. -+ * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction. -+ * @param opts.origin - The origin of the transaction request, such as a dApp hostname. -+ * @param opts.securityAlertResponse - Response from security validator. - * @returns Object containing a promise resolving to the transaction hash if approved. - */ -- addTransaction(transaction: Transaction, origin?: string, deviceConfirmedOn?: WalletDevice): Promise; -+ addTransaction(transaction: Transaction, { deviceConfirmedOn, origin, securityAlertResponse, }?: { -+ deviceConfirmedOn?: WalletDevice; -+ origin?: string; -+ securityAlertResponse?: SecurityAlertResponse; -+ }): Promise; -+ startIncomingTransactionPolling(): void; -+ stopIncomingTransactionPolling(): void; -+ updateIncomingTransactions(): Promise; - prepareUnsignedEthTx(txParams: Record): TypedTransaction; - /** - * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for -@@ -212,6 +234,13 @@ export declare class TransactionController extends BaseController; - private processApproval; - /** -- * Approves a transaction and updates it's status in state. If this is not a -- * retry transaction, a nonce will be generated. The transaction is signed -- * using the sign configuration property, then published to the blockchain. -- * A `:finished` hub event is fired after success or failure. -+ * Gets the next nonce according to the nonce-tracker. -+ * Ensure `releaseLock` is called once processing of the `nonce` value is complete. - * -- * @param transactionID - The ID of the transaction to approve. -+ * @param address - The hex string address for the transaction. -+ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock. - */ -- private approveTransaction; -- /** -- * Cancels a transaction based on its ID by setting its status to "rejected" -- * and emitting a `:finished` hub event. -- * -- * @param transactionID - The ID of the transaction to cancel. -- */ -- private cancelTransaction; -+ getNonceLock(address: string): Promise; - /** - * Trim the amount of transactions that are set on the state. Checks - * if the length of the tx history is longer then desired persistence -@@ -293,9 +304,31 @@ export declare class TransactionController extends BaseController:finished` hub event is fired after success or failure. -+ * -+ * @param transactionID - The ID of the transaction to approve. -+ */ -+ private approveTransaction; -+ private publishTransaction; -+ /** -+ * Cancels a transaction based on its ID by setting its status to "rejected" -+ * and emitting a `:finished` hub event. -+ * -+ * @param transactionID - The ID of the transaction to cancel. -+ */ -+ private cancelTransaction; -+ private getTransaction; - private isTransactionCompleted; -+ private onIncomingTransactions; -+ private onUpdatedLastFetchedBlockNumbers; -+ private getNonceTrackerTransactions; -+ private updateSubmitHistory; -+ private getGasFeeFlows; - } - export default TransactionController; - //# sourceMappingURL=TransactionController.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts.map b/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts.map -deleted file mode 100644 -index 61bec0a..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/TransactionController.d.ts.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"TransactionController.d.ts","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[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;;;;;;IA6E1C;;;OAGG;IACG,wBAAwB;IAmC9B;;;;OAIG;IACH,iBAAiB,CAAC,eAAe,EAAE,eAAe;IAWlD;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,CAAC,EAAE,OAAO;IAwBxC;;;;;;;;OAQG;IACG,QAAQ,CACZ,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAoBX,eAAe;IA8D7B;;;;;;;OAOG;YACW,kBAAkB;IAwFhC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,wBAAwB;IA0BhC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;;OAKG;YACW,oCAAoC;IA4DlD;;;;;;;;OAQG;YACW,4BAA4B;YAa5B,eAAe;IAmB7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;CAc/B;AAED,eAAe,qBAAqB,CAAC"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.js b/node_modules/@metamask/transaction-controller/dist/TransactionController.js -index b67387e..a6dd5da 100644 ---- a/node_modules/@metamask/transaction-controller/dist/TransactionController.js -+++ b/node_modules/@metamask/transaction-controller/dist/TransactionController.js -@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - Object.defineProperty(exports, "__esModule", { value: true }); --exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0; -+exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0; - const common_1 = require("@ethereumjs/common"); - const tx_1 = require("@ethereumjs/tx"); - const base_controller_1 = require("@metamask/base-controller"); -@@ -23,17 +23,21 @@ const eth_method_registry_1 = __importDefault(require("eth-method-registry")); - const eth_rpc_errors_1 = require("eth-rpc-errors"); - const ethereumjs_util_1 = require("ethereumjs-util"); - const events_1 = require("events"); --const nonce_tracker_1 = __importDefault(require("nonce-tracker")); -+const lodash_1 = require("lodash"); -+const NonceTracker_1 = require("nonce-tracker/dist/NonceTracker"); - const uuid_1 = require("uuid"); - const EtherscanRemoteTransactionSource_1 = require("./EtherscanRemoteTransactionSource"); -+const LineaGasFeeFlow_1 = require("./gas-flows/LineaGasFeeFlow"); -+const GasFeePoller_1 = require("./helpers/GasFeePoller"); - const IncomingTransactionHelper_1 = require("./IncomingTransactionHelper"); - const types_1 = require("./types"); - const utils_1 = require("./utils"); --exports.HARDFORK = common_1.Hardfork.London; -+const HARDFORK = 'london'; -+const SUBMIT_HISTORY_LIMIT = 100; - /** - * Multiplier used to determine a transaction's increased gas fee during cancellation - */ --exports.CANCEL_RATE = 1.5; -+exports.CANCEL_RATE = 1.1; - /** - * Multiplier used to determine a transaction's increased gas fee during speed up - */ -@@ -50,15 +54,22 @@ class TransactionController extends base_controller_1.BaseController { - * Creates a TransactionController instance. - * - * @param options - The controller options. -+ * @param options.blockTracker - The block tracker used to poll for new blocks data. -+ * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates. - * @param options.getNetworkState - Gets the state of the network controller. -+ * @param options.getSelectedAddress - Gets the address of the currently selected account. -+ * @param options.incomingTransactions - Configuration options for incoming transaction support. -+ * @param options.incomingTransactions.apiKey - An optional API key to use when fetching remote transaction data. -+ * @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers. -+ * @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled. -+ * @param options.incomingTransactions.updateTransactions - Whether or not to update local transactions using remote transaction data. -+ * @param options.messenger - The controller messenger. - * @param options.onNetworkStateChange - Allows subscribing to network controller state changes. - * @param options.provider - The provider used to create the underlying EthQuery instance. -- * @param options.blockTracker - The block tracker used to poll for new blocks data. -- * @param options.messenger - The controller messenger. - * @param config - Initial options used to configure this controller. - * @param state - Initial state to set on this controller. - */ -- constructor({ getNetworkState, onNetworkStateChange, provider, blockTracker, messenger, }, config, state) { -+ constructor({ blockTracker, getGasFeeEstimates, getNetworkState, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, provider, }, config, state) { - super(config, state); - this.mutex = new async_mutex_1.Mutex(); - /** -@@ -76,25 +87,50 @@ class TransactionController extends base_controller_1.BaseController { - this.defaultState = { - methodData: {}, - transactions: [], -+ lastFetchedBlockNumbers: {}, -+ submitHistory: [], - }; - this.initialize(); - this.provider = provider; - this.messagingSystem = messenger; -+ this.getGasFeeEstimates = getGasFeeEstimates; - this.getNetworkState = getNetworkState; - this.ethQuery = new eth_query_1.default(provider); - this.registry = new eth_method_registry_1.default({ provider }); -- this.nonceTracker = new nonce_tracker_1.default({ -+ this.nonceTracker = new NonceTracker_1.NonceTracker({ - provider, - blockTracker, -- getPendingTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.submitted, this.state.transactions), -- getConfirmedTransactions: (address) => (0, utils_1.getAndFormatTransactionsForNonceTracker)(address, types_1.TransactionStatus.confirmed, this.state.transactions), -+ getPendingTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.submitted), -+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed), - }); - this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({ -+ blockTracker, -+ getCurrentAccount: getSelectedAddress, -+ getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers, -+ getLocalTransactions: () => this.state.transactions, - getNetworkState, -- getEthQuery: () => this.ethQuery, -+ isEnabled: incomingTransactions.isEnabled, -+ remoteTransactionSource: new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({ -+ apiKey: incomingTransactions.apiKey, -+ includeTokenTransfers: incomingTransactions.includeTokenTransfers, -+ }), - transactionLimit: this.config.txHistoryLimit, -- remoteTransactionSource: new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource(), -+ updateTransactions: incomingTransactions.updateTransactions, -+ }); -+ this.incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this)); -+ this.incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this)); -+ this.gasFeeFlows = this.getGasFeeFlows(); -+ const gasFeePoller = new GasFeePoller_1.GasFeePoller({ -+ gasFeeFlows: this.gasFeeFlows, -+ getChainIds: () => [this.getNetworkState().providerConfig.chainId], -+ getEthQuery: () => this.ethQuery, -+ getGasFeeControllerEstimates: this.getGasFeeEstimates, -+ getTransactions: () => this.state.transactions, -+ onStateChange: (listener) => { -+ this.subscribe(listener); -+ }, - }); -+ gasFeePoller.hub.on('transaction-updated', this.updateTransaction.bind(this)); - onNetworkStateChange(() => { - this.ethQuery = new eth_query_1.default(this.provider); - this.registry = new eth_method_registry_1.default({ provider: this.provider }); -@@ -160,15 +196,17 @@ class TransactionController extends base_controller_1.BaseController { - * if not provided. If A `:unapproved` hub event will be emitted once added. - * - * @param transaction - The transaction object to add. -- * @param origin - The domain origin to append to the generated TransactionMeta. -- * @param deviceConfirmedOn - An enum to indicate what device the transaction was confirmed to append to the generated TransactionMeta. -+ * @param opts - Additional options to control how the transaction is added. -+ * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction. -+ * @param opts.origin - The origin of the transaction request, such as a dApp hostname. -+ * @param opts.securityAlertResponse - Response from security validator. - * @returns Object containing a promise resolving to the transaction hash if approved. - */ -- addTransaction(transaction, origin, deviceConfirmedOn) { -+ addTransaction(transaction, { deviceConfirmedOn, origin, securityAlertResponse, } = {}) { - return __awaiter(this, void 0, void 0, function* () { - const { providerConfig, networkId } = this.getNetworkState(); - const { transactions } = this.state; -- transaction = (0, utils_1.normalizeTransaction)(transaction); -+ transaction = (0, utils_1.normalizeTransactionParams)(transaction); - (0, utils_1.validateTransaction)(transaction); - const transactionMeta = { - id: (0, uuid_1.v1)(), -@@ -180,6 +218,7 @@ class TransactionController extends base_controller_1.BaseController { - transaction, - deviceConfirmedOn, - verifiedOnBlockchain: false, -+ securityAlertResponse, - }; - try { - const { gas, estimateGasError } = yield this.estimateGas(transaction); -@@ -199,6 +238,17 @@ class TransactionController extends base_controller_1.BaseController { - }; - }); - } -+ startIncomingTransactionPolling() { -+ this.incomingTransactionHelper.start(); -+ } -+ stopIncomingTransactionPolling() { -+ this.incomingTransactionHelper.stop(); -+ } -+ updateIncomingTransactions() { -+ return __awaiter(this, void 0, void 0, function* () { -+ yield this.incomingTransactionHelper.update(); -+ }); -+ } - prepareUnsignedEthTx(txParams) { - return tx_1.TransactionFactory.fromTxData(txParams, { - common: this.getCommonConfiguration(), -@@ -218,14 +268,15 @@ class TransactionController extends base_controller_1.BaseController { - const { networkId, providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState(); - if (chain !== controller_utils_1.RPC && - chain !== controller_utils_1.NetworkType['linea-goerli'] && -+ chain !== controller_utils_1.NetworkType['linea-sepolia'] && - chain !== controller_utils_1.NetworkType['linea-mainnet']) { -- return new common_1.Common({ chain, hardfork: exports.HARDFORK }); -+ return new common_1.Common({ chain, hardfork: HARDFORK }); - } - const customChainParams = { - name, - chainId: parseInt(chainId, 16), - networkId: networkId === null ? NaN : parseInt(networkId, undefined), -- defaultHardfork: exports.HARDFORK, -+ defaultHardfork: HARDFORK, - }; - return common_1.Common.custom(customChainParams); - } -@@ -291,7 +342,7 @@ class TransactionController extends base_controller_1.BaseController { - const unsignedEthTx = this.prepareUnsignedEthTx(txParams); - const signedTx = yield this.sign(unsignedEthTx, transactionMeta.transaction.from); - const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); -- yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]); -+ yield this.publishTransaction(rawTransaction, txParams, transactionMeta.chainId, 'cancel'); - transactionMeta.status = types_1.TransactionStatus.cancelled; - this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); - }); -@@ -343,9 +394,7 @@ class TransactionController extends base_controller_1.BaseController { - const unsignedEthTx = this.prepareUnsignedEthTx(txParams); - const signedTx = yield this.sign(unsignedEthTx, transactionMeta.transaction.from); - const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); -- const transactionHash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [ -- rawTransaction, -- ]); -+ const transactionHash = yield this.publishTransaction(rawTransaction, txParams, transactionMeta.chainId, controller_utils_1.ORIGIN_METAMASK); - const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { id: (0, uuid_1.v1)(), time: Date.now(), transactionHash }); - const newTransactionMeta = newMaxFeePerGas && newMaxPriorityFeePerGas - ? Object.assign(Object.assign({}, baseTransactionMeta), { transaction: Object.assign(Object.assign({}, transactionMeta.transaction), { maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas }) }) : Object.assign(Object.assign({}, baseTransactionMeta), { transaction: Object.assign(Object.assign({}, transactionMeta.transaction), { gasPrice: newGasPrice }) }); -@@ -404,6 +453,8 @@ class TransactionController extends base_controller_1.BaseController { - } - catch (error) { - estimateGasError = utils_1.ESTIMATE_GAS_ERROR; -+ // Fallback to 95% of the block gasLimit. -+ gasHex = estimatedTransaction.gas; - } - // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a - // a custom network then return the eth_estimateGas value. -@@ -463,12 +514,29 @@ class TransactionController extends base_controller_1.BaseController { - */ - updateTransaction(transactionMeta) { - const { transactions } = this.state; -- transactionMeta.transaction = (0, utils_1.normalizeTransaction)(transactionMeta.transaction); -+ transactionMeta.transaction = (0, utils_1.normalizeTransactionParams)(transactionMeta.transaction); - (0, utils_1.validateTransaction)(transactionMeta.transaction); - const index = transactions.findIndex(({ id }) => transactionMeta.id === id); - transactions[index] = transactionMeta; - this.update({ transactions: this.trimTransactionsForState(transactions) }); - } -+ /** -+ * Update the security alert response for a transaction. -+ * -+ * @param transactionId - ID of the transaction. -+ * @param securityAlertResponse - The new security alert response for the transaction. -+ */ -+ updateSecurityAlertResponse(transactionId, securityAlertResponse) { -+ if (!securityAlertResponse) { -+ throw new Error('updateSecurityAlertResponse: securityAlertResponse should not be null'); -+ } -+ const transactionMeta = this.getTransaction(transactionId); -+ if (!transactionMeta) { -+ throw new Error(`Cannot update security alert response as no transaction metadata found`); -+ } -+ const updatedMeta = (0, lodash_1.merge)(transactionMeta, { securityAlertResponse }); -+ this.updateTransaction(updatedMeta); -+ } - /** - * Removes all transactions from state, optionally based on the current network. - * -@@ -493,32 +561,6 @@ class TransactionController extends base_controller_1.BaseController { - transactions: this.trimTransactionsForState(newTransactions), - }); - } -- /** -- * Get transactions from Etherscan for the given address. By default all transactions are -- * returned, but the `fromBlock` option can be given to filter just for transactions from a -- * specific block onward. -- * -- * @param address - The address to fetch the transactions for. -- * @param opt - Object containing optional data, fromBlock and Etherscan API key. -- * @returns The block number of the latest incoming transaction. -- */ -- fetchAll(address, opt) { -- return __awaiter(this, void 0, void 0, function* () { -- const { transactions: localTransactions } = this.state; -- const { updateRequired, transactions, latestBlockNumber } = yield this.incomingTransactionHelper.reconcile({ -- address, -- localTransactions, -- fromBlock: opt === null || opt === void 0 ? void 0 : opt.fromBlock, -- apiKey: opt === null || opt === void 0 ? void 0 : opt.etherscanApiKey, -- }); -- if (updateRequired) { -- this.update({ -- transactions: this.trimTransactionsForState(transactions), -- }); -- } -- return latestBlockNumber; -- }); -- } - processApproval(transactionMeta) { - return __awaiter(this, void 0, void 0, function* () { - const transactionId = transactionMeta.id; -@@ -563,98 +605,17 @@ class TransactionController extends base_controller_1.BaseController { - }); - } - /** -- * Approves a transaction and updates it's status in state. If this is not a -- * retry transaction, a nonce will be generated. The transaction is signed -- * using the sign configuration property, then published to the blockchain. -- * A `:finished` hub event is fired after success or failure. -+ * Gets the next nonce according to the nonce-tracker. -+ * Ensure `releaseLock` is called once processing of the `nonce` value is complete. - * -- * @param transactionID - The ID of the transaction to approve. -+ * @param address - The hex string address for the transaction. -+ * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock. - */ -- approveTransaction(transactionID) { -+ getNonceLock(address) { - return __awaiter(this, void 0, void 0, function* () { -- const { transactions } = this.state; -- const releaseLock = yield this.mutex.acquire(); -- const { providerConfig } = this.getNetworkState(); -- const { chainId } = providerConfig; -- const index = transactions.findIndex(({ id }) => transactionID === id); -- const transactionMeta = transactions[index]; -- const { transaction: { nonce, from }, } = transactionMeta; -- let nonceLock; -- try { -- if (!this.sign) { -- releaseLock(); -- this.failTransaction(transactionMeta, new Error('No sign method defined.')); -- return; -- } -- else if (!chainId) { -- releaseLock(); -- this.failTransaction(transactionMeta, new Error('No chainId defined.')); -- return; -- } -- const { approved: status } = types_1.TransactionStatus; -- let nonceToUse = nonce; -- // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction -- // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce -- if (!nonceToUse) { -- nonceLock = yield this.nonceTracker.getNonceLock(from); -- nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16)); -- } -- transactionMeta.status = status; -- transactionMeta.transaction.nonce = nonceToUse; -- transactionMeta.transaction.chainId = chainId; -- const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas }); -- const isEIP1559 = (0, utils_1.isEIP1559Transaction)(transactionMeta.transaction); -- const txParams = isEIP1559 -- ? Object.assign(Object.assign({}, baseTxParams), { maxFeePerGas: transactionMeta.transaction.maxFeePerGas, maxPriorityFeePerGas: transactionMeta.transaction.maxPriorityFeePerGas, estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee, -- // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set -- type: 2 }) : baseTxParams; -- // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set -- if (isEIP1559) { -- delete txParams.gasPrice; -- } -- const unsignedEthTx = this.prepareUnsignedEthTx(txParams); -- const signedTx = yield this.sign(unsignedEthTx, from); -- transactionMeta.status = types_1.TransactionStatus.signed; -- this.updateTransaction(transactionMeta); -- const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); -- transactionMeta.rawTransaction = rawTransaction; -- this.updateTransaction(transactionMeta); -- const transactionHash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [ -- rawTransaction, -- ]); -- transactionMeta.transactionHash = transactionHash; -- transactionMeta.status = types_1.TransactionStatus.submitted; -- this.updateTransaction(transactionMeta); -- this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); -- } -- catch (error) { -- this.failTransaction(transactionMeta, error); -- } -- finally { -- // must set transaction to submitted/failed before releasing lock -- if (nonceLock) { -- nonceLock.releaseLock(); -- } -- releaseLock(); -- } -+ return this.nonceTracker.getNonceLock(address); - }); - } -- /** -- * Cancels a transaction based on its ID by setting its status to "rejected" -- * and emitting a `:finished` hub event. -- * -- * @param transactionID - The ID of the transaction to cancel. -- */ -- cancelTransaction(transactionID) { -- const transactionMeta = this.state.transactions.find(({ id }) => id === transactionID); -- if (!transactionMeta) { -- return; -- } -- transactionMeta.status = types_1.TransactionStatus.rejected; -- this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); -- const transactions = this.state.transactions.filter(({ id }) => id !== transactionID); -- this.update({ transactions: this.trimTransactionsForState(transactions) }); -- } - /** - * Trim the amount of transactions that are set on the state. Checks - * if the length of the tx history is longer then desired persistence -@@ -671,7 +632,9 @@ class TransactionController extends base_controller_1.BaseController { - */ - trimTransactionsForState(transactions) { - const nonceNetworkSet = new Set(); -- const txsToKeep = transactions.reverse().filter((tx) => { -+ const txsToKeep = transactions -+ .sort((a, b) => (a.time > b.time ? -1 : 1)) // Descending time order -+ .filter((tx) => { - const { chainId, networkID, status, transaction, time } = tx; - if (transaction) { - const key = `${transaction.nonce}-${chainId ? (0, controller_utils_1.convertHexToDecimal)(chainId) : networkID}-${new Date(time).toDateString()}`; -@@ -686,7 +649,7 @@ class TransactionController extends base_controller_1.BaseController { - } - return false; - }); -- txsToKeep.reverse(); -+ txsToKeep.reverse(); // Ascending time order - return txsToKeep; - } - /** -@@ -758,9 +721,17 @@ class TransactionController extends base_controller_1.BaseController { - } - /* istanbul ignore next */ - if (txObj === null || txObj === void 0 ? void 0 : txObj.blockNumber) { -- meta.status = types_1.TransactionStatus.confirmed; -- this.hub.emit(`${meta.id}:confirmed`, meta); -- return [meta, true]; -+ // transactions can be added to a block and still fail, so we need to check the transaction status before emitting the confirmed event -+ const txStatusFailed = yield this.checkTxReceiptStatusIsFailed(transactionHash); -+ if (txStatusFailed) { -+ const error = new Error('Transaction failed. The transaction was reversed'); -+ this.failTransaction(meta, error); -+ } -+ else { -+ meta.status = types_1.TransactionStatus.confirmed; -+ this.hub.emit(`${meta.id}:confirmed`, meta); -+ return [meta, true]; -+ } - } - return [meta, false]; - default: -@@ -804,13 +775,113 @@ class TransactionController extends base_controller_1.BaseController { - }, true)); - }); - } -+ getApprovalId(txMeta) { -+ return String(txMeta.id); -+ } -+ /** -+ * Approves a transaction and updates it's status in state. If this is not a -+ * retry transaction, a nonce will be generated. The transaction is signed -+ * using the sign configuration property, then published to the blockchain. -+ * A `:finished` hub event is fired after success or failure. -+ * -+ * @param transactionID - The ID of the transaction to approve. -+ */ -+ approveTransaction(transactionID) { -+ return __awaiter(this, void 0, void 0, function* () { -+ const { transactions } = this.state; -+ const releaseLock = yield this.mutex.acquire(); -+ const { providerConfig } = this.getNetworkState(); -+ const { chainId: currentChainId } = providerConfig; -+ const index = transactions.findIndex(({ id }) => transactionID === id); -+ const transactionMeta = transactions[index]; -+ const { transaction: { nonce, from }, } = transactionMeta; -+ let nonceLock; -+ try { -+ if (!this.sign) { -+ releaseLock(); -+ this.failTransaction(transactionMeta, new Error('No sign method defined.')); -+ return; -+ } -+ else if (!currentChainId) { -+ releaseLock(); -+ this.failTransaction(transactionMeta, new Error('No chainId defined.')); -+ return; -+ } -+ const { approved: status } = types_1.TransactionStatus; -+ let nonceToUse = nonce; -+ // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction -+ // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce -+ if (!nonceToUse) { -+ nonceLock = yield this.nonceTracker.getNonceLock(from); -+ nonceToUse = (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16)); -+ } -+ transactionMeta.status = status; -+ transactionMeta.transaction.nonce = nonceToUse; -+ transactionMeta.transaction.chainId = currentChainId; -+ const baseTxParams = Object.assign(Object.assign({}, transactionMeta.transaction), { gasLimit: transactionMeta.transaction.gas }); -+ const isEIP1559 = (0, utils_1.isEIP1559Transaction)(transactionMeta.transaction); -+ const txParams = isEIP1559 -+ ? Object.assign(Object.assign({}, baseTxParams), { maxFeePerGas: transactionMeta.transaction.maxFeePerGas, maxPriorityFeePerGas: transactionMeta.transaction.maxPriorityFeePerGas, estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee, -+ // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set -+ type: 2 }) : baseTxParams; -+ // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set -+ if (isEIP1559) { -+ delete txParams.gasPrice; -+ } -+ const unsignedEthTx = this.prepareUnsignedEthTx(txParams); -+ const signedTx = yield this.sign(unsignedEthTx, from); -+ transactionMeta.status = types_1.TransactionStatus.signed; -+ this.updateTransaction(transactionMeta); -+ const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize()); -+ transactionMeta.rawTransaction = rawTransaction; -+ this.updateTransaction(transactionMeta); -+ const transactionHash = yield this.publishTransaction(rawTransaction, txParams, currentChainId, transactionMeta.origin); -+ transactionMeta.transactionHash = transactionHash; -+ transactionMeta.status = types_1.TransactionStatus.submitted; -+ this.updateTransaction(transactionMeta); -+ this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); -+ } -+ catch (error) { -+ this.failTransaction(transactionMeta, error); -+ } -+ finally { -+ // must set transaction to submitted/failed before releasing lock -+ if (nonceLock) { -+ nonceLock.releaseLock(); -+ } -+ releaseLock(); -+ } -+ }); -+ } -+ publishTransaction(rawTransaction, transaction, chainId, origin) { -+ return __awaiter(this, void 0, void 0, function* () { -+ const transactionHash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [ -+ rawTransaction, -+ ]); -+ this.updateSubmitHistory(rawTransaction, transactionHash, transaction, chainId, origin); -+ return transactionHash; -+ }); -+ } -+ /** -+ * Cancels a transaction based on its ID by setting its status to "rejected" -+ * and emitting a `:finished` hub event. -+ * -+ * @param transactionID - The ID of the transaction to cancel. -+ */ -+ cancelTransaction(transactionID) { -+ const transactionMeta = this.state.transactions.find(({ id }) => id === transactionID); -+ if (!transactionMeta) { -+ return; -+ } -+ transactionMeta.status = types_1.TransactionStatus.rejected; -+ this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta); -+ const transactions = this.state.transactions.filter(({ id }) => id !== transactionID); -+ this.update({ transactions: this.trimTransactionsForState(transactions) }); -+ } - getTransaction(transactionID) { - const { transactions } = this.state; - return transactions.find(({ id }) => id === transactionID); - } -- getApprovalId(txMeta) { -- return String(txMeta.id); -- } - isTransactionCompleted(transactionid) { - const transaction = this.getTransaction(transactionid); - if (!transaction) { -@@ -819,6 +890,49 @@ class TransactionController extends base_controller_1.BaseController { - const isCompleted = this.isLocalFinalState(transaction.status); - return { meta: transaction, isCompleted }; - } -+ onIncomingTransactions({ added, updated, }) { -+ const { transactions: currentTransactions } = this.state; -+ const updatedTransactions = [ -+ ...added, -+ ...currentTransactions.map((originalTransaction) => { -+ const updatedTransaction = updated.find(({ transactionHash }) => transactionHash === originalTransaction.transactionHash); -+ return updatedTransaction !== null && updatedTransaction !== void 0 ? updatedTransaction : originalTransaction; -+ }), -+ ]; -+ this.update({ -+ transactions: this.trimTransactionsForState(updatedTransactions), -+ }); -+ this.hub.emit('incomingTransactions', { added, updated }); -+ } -+ onUpdatedLastFetchedBlockNumbers({ lastFetchedBlockNumbers, blockNumber, }) { -+ this.update({ lastFetchedBlockNumbers }); -+ this.hub.emit('incomingTransactionBlock', blockNumber); -+ } -+ getNonceTrackerTransactions(status, address) { -+ const { chainId: currentChainId } = this.getNetworkState().providerConfig; -+ return (0, utils_1.getAndFormatTransactionsForNonceTracker)(currentChainId, address, status, this.state.transactions); -+ } -+ updateSubmitHistory(rawTransaction, hash, transaction, chainId, origin) { -+ const { rpcUrl: networkUrl, type: networkType } = this.getNetworkState().providerConfig; -+ const submitHistoryEntry = { -+ chainId, -+ hash, -+ networkType, -+ networkUrl, -+ origin, -+ time: Date.now(), -+ transaction, -+ rawTransaction, -+ }; -+ const submitHistory = [submitHistoryEntry, ...this.state.submitHistory]; -+ if (submitHistory.length > SUBMIT_HISTORY_LIMIT) { -+ submitHistory.pop(); -+ } -+ this.update({ submitHistory }); -+ } -+ getGasFeeFlows() { -+ return [new LineaGasFeeFlow_1.LineaGasFeeFlow()]; -+ } - } - exports.TransactionController = TransactionController; - exports.default = TransactionController; -diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map b/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map -deleted file mode 100644 -index 73c9b24..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/TransactionController.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"TransactionController.js","sourceRoot":"","sources":["../src/TransactionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAwE;AAExE,uCAAoD;AAWpD,+DAA2D;AAC3D,iEAWoC;AACpC,oEAA2C;AAM3C,6CAAoC;AACpC,8EAAiD;AACjD,mDAAuD;AACvD,qDAA4D;AAC5D,mCAAsC;AACtC,kEAAyC;AACzC,+BAAoC;AAEpC,yFAAsF;AACtF,2EAAwE;AAExE,mCAA4C;AAC5C,mCAWiB;AAEJ,QAAA,QAAQ,GAAG,iBAAQ,CAAC,MAAM,CAAC;AAqExC;;GAEG;AACU,QAAA,WAAW,GAAG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AC;IAEO,sBAAsB,CAAC,aAAqB;QAIlD,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAEvD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;SAChD;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE/D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;IAC5C,CAAC;CACF;AA5iCD,sDA4iCC;AAED,kBAAe,qBAAqB,CAAC","sourcesContent":["import { Hardfork, Common, type ChainConfig } from '@ethereumjs/common';\nimport type { TypedTransaction } from '@ethereumjs/tx';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport type {\n AcceptResultCallbacks,\n AddApprovalRequest,\n AddResult,\n} from '@metamask/approval-controller';\nimport type {\n BaseConfig,\n BaseState,\n RestrictedControllerMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport {\n BNToHex,\n fractionBN,\n hexToBN,\n safelyExecute,\n query,\n NetworkType,\n RPC,\n ApprovalType,\n ORIGIN_METAMASK,\n convertHexToDecimal,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport type {\n BlockTracker,\n NetworkState,\n Provider,\n} from '@metamask/network-controller';\nimport { Mutex } from 'async-mutex';\nimport MethodRegistry from 'eth-method-registry';\nimport { errorCodes, ethErrors } from 'eth-rpc-errors';\nimport { addHexPrefix, bufferToHex } from 'ethereumjs-util';\nimport { EventEmitter } from 'events';\nimport NonceTracker from 'nonce-tracker';\nimport { v1 as random } from 'uuid';\n\nimport { EtherscanRemoteTransactionSource } from './EtherscanRemoteTransactionSource';\nimport { IncomingTransactionHelper } from './IncomingTransactionHelper';\nimport type { Transaction, TransactionMeta, WalletDevice } from './types';\nimport { TransactionStatus } from './types';\nimport {\n getAndFormatTransactionsForNonceTracker,\n normalizeTransaction,\n validateTransaction,\n getIncreasedPriceFromExisting,\n isEIP1559Transaction,\n isGasPriceValue,\n isFeeMarketEIP1559Values,\n validateGasValues,\n validateMinimumIncrease,\n ESTIMATE_GAS_ERROR,\n} from './utils';\n\nexport const HARDFORK = Hardfork.London;\n\n/**\n * @type Result\n * @property result - Promise resolving to a new transaction hash\n * @property transactionMeta - Meta information about this new transaction\n */\nexport interface Result {\n result: Promise;\n transactionMeta: TransactionMeta;\n}\n\n/**\n * @type Fetch All Options\n * @property fromBlock - String containing a specific block decimal number\n * @property etherscanApiKey - API key to be used to fetch token transactions\n */\nexport interface FetchAllOptions {\n fromBlock?: string;\n etherscanApiKey?: string;\n}\n\nexport interface GasPriceValue {\n gasPrice: string;\n}\n\nexport interface FeeMarketEIP1559Values {\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n}\n\n/**\n * @type TransactionConfig\n *\n * Transaction controller configuration\n * @property interval - Polling interval used to fetch new currency rate\n * @property provider - Provider used to create a new underlying EthQuery instance\n * @property sign - Method used to sign transactions\n */\nexport interface TransactionConfig extends BaseConfig {\n interval: number;\n sign?: (transaction: Transaction, from: string) => Promise;\n txHistoryLimit: number;\n}\n\n/**\n * @type MethodData\n *\n * Method data registry object\n * @property registryMethod - Registry method raw string\n * @property parsedRegistryMethod - Registry method object, containing name and method arguments\n */\nexport interface MethodData {\n registryMethod: string;\n parsedRegistryMethod: Record;\n}\n\n/**\n * @type TransactionState\n *\n * Transaction controller state\n * @property transactions - A list of TransactionMeta objects\n * @property methodData - Object containing all known method data information\n */\nexport interface TransactionState extends BaseState {\n transactions: TransactionMeta[];\n methodData: { [key: string]: MethodData };\n}\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during cancellation\n */\nexport const CANCEL_RATE = 1.5;\n\n/**\n * Multiplier used to determine a transaction's increased gas fee during speed up\n */\nexport const SPEED_UP_RATE = 1.1;\n\n/**\n * The name of the {@link TransactionController}.\n */\nconst controllerName = 'TransactionController';\n\n/**\n * The external actions available to the {@link TransactionController}.\n */\ntype AllowedActions = AddApprovalRequest;\n\n/**\n * The messenger of the {@link TransactionController}.\n */\nexport type TransactionControllerMessenger = RestrictedControllerMessenger<\n typeof controllerName,\n AllowedActions,\n never,\n AllowedActions['type'],\n never\n>;\n\n/**\n * Controller responsible for submitting and managing transactions.\n */\nexport class TransactionController extends BaseController<\n TransactionConfig,\n TransactionState\n> {\n private ethQuery: EthQuery;\n\n private readonly nonceTracker: NonceTracker;\n\n private registry: any;\n\n private readonly provider: Provider;\n\n private handle?: ReturnType;\n\n private readonly mutex = new Mutex();\n\n private readonly getNetworkState: () => NetworkState;\n\n private readonly messagingSystem: TransactionControllerMessenger;\n\n private readonly incomingTransactionHelper: IncomingTransactionHelper;\n\n private failTransaction(transactionMeta: TransactionMeta, error: Error) {\n const newTransactionMeta = {\n ...transactionMeta,\n error,\n status: TransactionStatus.failed,\n };\n this.updateTransaction(newTransactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, newTransactionMeta);\n }\n\n private async registryLookup(fourBytePrefix: string): Promise {\n const registryMethod = await this.registry.lookup(fourBytePrefix);\n const parsedRegistryMethod = this.registry.parse(registryMethod);\n return { registryMethod, parsedRegistryMethod };\n }\n\n /**\n * EventEmitter instance used to listen to specific transactional events\n */\n hub = new EventEmitter();\n\n /**\n * Name of this controller used during composition\n */\n override name = 'TransactionController';\n\n /**\n * Method used to sign transactions\n */\n sign?: (\n transaction: TypedTransaction,\n from: string,\n ) => Promise;\n\n /**\n * Creates a TransactionController instance.\n *\n * @param options - The controller options.\n * @param options.getNetworkState - Gets the state of the network controller.\n * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.\n * @param options.provider - The provider used to create the underlying EthQuery instance.\n * @param options.blockTracker - The block tracker used to poll for new blocks data.\n * @param options.messenger - The controller messenger.\n * @param config - Initial options used to configure this controller.\n * @param state - Initial state to set on this controller.\n */\n constructor(\n {\n getNetworkState,\n onNetworkStateChange,\n provider,\n blockTracker,\n messenger,\n }: {\n getNetworkState: () => NetworkState;\n onNetworkStateChange: (listener: (state: NetworkState) => void) => void;\n provider: Provider;\n blockTracker: BlockTracker;\n messenger: TransactionControllerMessenger;\n },\n config?: Partial,\n state?: Partial,\n ) {\n super(config, state);\n this.defaultConfig = {\n interval: 15000,\n txHistoryLimit: 40,\n };\n\n this.defaultState = {\n methodData: {},\n transactions: [],\n };\n this.initialize();\n this.provider = provider;\n this.messagingSystem = messenger;\n this.getNetworkState = getNetworkState;\n this.ethQuery = new EthQuery(provider);\n this.registry = new MethodRegistry({ provider });\n this.nonceTracker = new NonceTracker({\n provider,\n blockTracker,\n getPendingTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.submitted,\n this.state.transactions,\n ),\n getConfirmedTransactions: (address) =>\n getAndFormatTransactionsForNonceTracker(\n address,\n TransactionStatus.confirmed,\n this.state.transactions,\n ),\n });\n this.incomingTransactionHelper = new IncomingTransactionHelper({\n getNetworkState,\n getEthQuery: () => this.ethQuery,\n transactionLimit: this.config.txHistoryLimit,\n remoteTransactionSource: new EtherscanRemoteTransactionSource(),\n });\n\n onNetworkStateChange(() => {\n this.ethQuery = new EthQuery(this.provider);\n this.registry = new MethodRegistry({ provider: this.provider });\n });\n this.poll();\n }\n\n /**\n * Starts a new polling interval.\n *\n * @param interval - The polling interval used to fetch new transaction statuses.\n */\n async poll(interval?: number): Promise {\n interval && this.configure({ interval }, false, false);\n this.handle && clearTimeout(this.handle);\n await safelyExecute(() => this.queryTransactionStatuses());\n this.handle = setTimeout(() => {\n this.poll(this.config.interval);\n }, this.config.interval);\n }\n\n /**\n * Handle new method data request.\n *\n * @param fourBytePrefix - The method prefix.\n * @returns The method data object corresponding to the given signature prefix.\n */\n async handleMethodData(fourBytePrefix: string): Promise {\n const releaseLock = await this.mutex.acquire();\n try {\n const { methodData } = this.state;\n const knownMethod = Object.keys(methodData).find(\n (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix,\n );\n if (knownMethod) {\n return methodData[fourBytePrefix];\n }\n const registry = await this.registryLookup(fourBytePrefix);\n this.update({\n methodData: { ...methodData, ...{ [fourBytePrefix]: registry } },\n });\n return registry;\n } finally {\n releaseLock();\n }\n }\n\n /**\n * Add a new unapproved transaction to state. Parameters will be validated, a\n * unique transaction id will be generated, and gas and gasPrice will be calculated\n * if not provided. If A `:unapproved` hub event will be emitted once added.\n *\n * @param transaction - The transaction object to add.\n * @param origin - The domain origin to append to the generated TransactionMeta.\n * @param deviceConfirmedOn - An enum to indicate what device the transaction was confirmed to append to the generated TransactionMeta.\n * @returns Object containing a promise resolving to the transaction hash if approved.\n */\n async addTransaction(\n transaction: Transaction,\n origin?: string,\n deviceConfirmedOn?: WalletDevice,\n ): Promise {\n const { providerConfig, networkId } = this.getNetworkState();\n const { transactions } = this.state;\n transaction = normalizeTransaction(transaction);\n validateTransaction(transaction);\n\n const transactionMeta: TransactionMeta = {\n id: random(),\n networkID: networkId ?? undefined,\n chainId: providerConfig.chainId,\n origin,\n status: TransactionStatus.unapproved as TransactionStatus.unapproved,\n time: Date.now(),\n transaction,\n deviceConfirmedOn,\n verifiedOnBlockchain: false,\n };\n\n try {\n const { gas, estimateGasError } = await this.estimateGas(transaction);\n transaction.gas = gas;\n transaction.estimateGasError = estimateGasError;\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n return Promise.reject(error);\n }\n\n transactions.push(transactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`unapprovedTransaction`, transactionMeta);\n\n return {\n result: this.processApproval(transactionMeta),\n transactionMeta,\n };\n }\n\n prepareUnsignedEthTx(txParams: Record): TypedTransaction {\n return TransactionFactory.fromTxData(txParams, {\n common: this.getCommonConfiguration(),\n freeze: false,\n });\n }\n\n /**\n * `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for\n * specifying which chain, network, hardfork and EIPs to support for\n * a transaction. By referencing this configuration, and analyzing the fields\n * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718\n * transaction type to use.\n *\n * @returns {Common} common configuration object\n */\n\n getCommonConfiguration(): Common {\n const {\n networkId,\n providerConfig: { type: chain, chainId, nickname: name },\n } = this.getNetworkState();\n\n if (\n chain !== RPC &&\n chain !== NetworkType['linea-goerli'] &&\n chain !== NetworkType['linea-mainnet']\n ) {\n return new Common({ chain, hardfork: HARDFORK });\n }\n\n const customChainParams: Partial = {\n name,\n chainId: parseInt(chainId, 16),\n networkId: networkId === null ? NaN : parseInt(networkId, undefined),\n defaultHardfork: HARDFORK,\n };\n\n return Common.custom(customChainParams);\n }\n\n /**\n * Attempts to cancel a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n * @param gasValues - The gas values to use for the cancellation transaction.\n */\n async stopTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n CANCEL_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n CANCEL_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n CANCEL_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n }\n : {\n from: transactionMeta.transaction.from,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n nonce: transactionMeta.transaction.nonce,\n to: transactionMeta.transaction.from,\n value: '0x0',\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n await query(this.ethQuery, 'sendRawTransaction', [rawTransaction]);\n transactionMeta.status = TransactionStatus.cancelled;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n }\n\n /**\n * Attempts to speed up a transaction increasing transaction gasPrice by ten percent.\n *\n * @param transactionID - The ID of the transaction to speed up.\n * @param gasValues - The gas values to use for the speed up transation.\n */\n async speedUpTransaction(\n transactionID: string,\n gasValues?: GasPriceValue | FeeMarketEIP1559Values,\n ) {\n if (gasValues) {\n validateGasValues(gasValues);\n }\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n /* istanbul ignore next */\n if (!transactionMeta) {\n return;\n }\n\n /* istanbul ignore next */\n if (!this.sign) {\n throw new Error('No sign method defined.');\n }\n\n const { transactions } = this.state;\n\n // gasPrice (legacy non EIP1559)\n const minGasPrice = getIncreasedPriceFromExisting(\n transactionMeta.transaction.gasPrice,\n SPEED_UP_RATE,\n );\n\n const gasPriceFromValues = isGasPriceValue(gasValues) && gasValues.gasPrice;\n\n const newGasPrice =\n (gasPriceFromValues &&\n validateMinimumIncrease(gasPriceFromValues, minGasPrice)) ||\n minGasPrice;\n\n // maxFeePerGas (EIP1559)\n const existingMaxFeePerGas = transactionMeta.transaction?.maxFeePerGas;\n const minMaxFeePerGas = getIncreasedPriceFromExisting(\n existingMaxFeePerGas,\n SPEED_UP_RATE,\n );\n const maxFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxFeePerGas;\n const newMaxFeePerGas =\n (maxFeePerGasValues &&\n validateMinimumIncrease(maxFeePerGasValues, minMaxFeePerGas)) ||\n (existingMaxFeePerGas && minMaxFeePerGas);\n\n // maxPriorityFeePerGas (EIP1559)\n const existingMaxPriorityFeePerGas =\n transactionMeta.transaction?.maxPriorityFeePerGas;\n const minMaxPriorityFeePerGas = getIncreasedPriceFromExisting(\n existingMaxPriorityFeePerGas,\n SPEED_UP_RATE,\n );\n const maxPriorityFeePerGasValues =\n isFeeMarketEIP1559Values(gasValues) && gasValues.maxPriorityFeePerGas;\n const newMaxPriorityFeePerGas =\n (maxPriorityFeePerGasValues &&\n validateMinimumIncrease(\n maxPriorityFeePerGasValues,\n minMaxPriorityFeePerGas,\n )) ||\n (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);\n\n const txParams =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n type: 2,\n }\n : {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n gasPrice: newGasPrice,\n };\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n\n const signedTx = await this.sign(\n unsignedEthTx,\n transactionMeta.transaction.from,\n );\n const rawTransaction = bufferToHex(signedTx.serialize());\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n const baseTransactionMeta = {\n ...transactionMeta,\n id: random(),\n time: Date.now(),\n transactionHash,\n };\n const newTransactionMeta =\n newMaxFeePerGas && newMaxPriorityFeePerGas\n ? {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n maxFeePerGas: newMaxFeePerGas,\n maxPriorityFeePerGas: newMaxPriorityFeePerGas,\n },\n }\n : {\n ...baseTransactionMeta,\n transaction: {\n ...transactionMeta.transaction,\n gasPrice: newGasPrice,\n },\n };\n transactions.push(newTransactionMeta);\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n this.hub.emit(`${transactionMeta.id}:speedup`, newTransactionMeta);\n }\n\n /**\n * Estimates required gas for a given transaction.\n *\n * @param transaction - The transaction to estimate gas for.\n * @returns The gas and gas price.\n */\n async estimateGas(transaction: Transaction) {\n const estimatedTransaction = { ...transaction };\n const {\n gas,\n gasPrice: providedGasPrice,\n to,\n value,\n data,\n } = estimatedTransaction;\n const gasPrice =\n typeof providedGasPrice === 'undefined'\n ? await query(this.ethQuery, 'gasPrice')\n : providedGasPrice;\n const { providerConfig } = this.getNetworkState();\n const isCustomNetwork = providerConfig.type === NetworkType.rpc;\n // 1. If gas is already defined on the transaction, use it\n if (typeof gas !== 'undefined') {\n return { gas, gasPrice };\n }\n const { gasLimit } = await query(this.ethQuery, 'getBlockByNumber', [\n 'latest',\n false,\n ]);\n\n // 2. If to is not defined or this is not a contract address, and there is no data use 0x5208 / 21000.\n // If the newtwork is a custom network then bypass this check and fetch 'estimateGas'.\n /* istanbul ignore next */\n const code = to ? await query(this.ethQuery, 'getCode', [to]) : undefined;\n /* istanbul ignore next */\n if (\n !isCustomNetwork &&\n (!to || (to && !data && (!code || code === '0x')))\n ) {\n return { gas: '0x5208', gasPrice };\n }\n\n // if data, should be hex string format\n estimatedTransaction.data = !data\n ? data\n : /* istanbul ignore next */ addHexPrefix(data);\n\n // 3. If this is a contract address, safely estimate gas using RPC\n estimatedTransaction.value =\n typeof value === 'undefined' ? '0x0' : /* istanbul ignore next */ value;\n const gasLimitBN = hexToBN(gasLimit);\n estimatedTransaction.gas = BNToHex(fractionBN(gasLimitBN, 19, 20));\n\n let gasHex;\n let estimateGasError;\n try {\n gasHex = await query(this.ethQuery, 'estimateGas', [\n estimatedTransaction,\n ]);\n } catch (error) {\n estimateGasError = ESTIMATE_GAS_ERROR;\n }\n // 4. Pad estimated gas without exceeding the most recent block gasLimit. If the network is a\n // a custom network then return the eth_estimateGas value.\n const gasBN = hexToBN(gasHex);\n const maxGasBN = gasLimitBN.muln(0.9);\n const paddedGasBN = gasBN.muln(1.5);\n /* istanbul ignore next */\n if (gasBN.gt(maxGasBN) || isCustomNetwork) {\n return { gas: addHexPrefix(gasHex), gasPrice, estimateGasError };\n }\n\n /* istanbul ignore next */\n if (paddedGasBN.lt(maxGasBN)) {\n return {\n gas: addHexPrefix(BNToHex(paddedGasBN)),\n gasPrice,\n estimateGasError,\n };\n }\n return { gas: addHexPrefix(BNToHex(maxGasBN)), gasPrice, estimateGasError };\n }\n\n /**\n * Check the status of submitted transactions on the network to determine whether they have\n * been included in a block. Any that have been included in a block are marked as confirmed.\n */\n async queryTransactionStatuses() {\n const { transactions } = this.state;\n const { providerConfig, networkId: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n let gotUpdates = false;\n await safelyExecute(() =>\n Promise.all(\n transactions.map(async (meta, index) => {\n // Using fallback to networkID only when there is no chainId present.\n // Should be removed when networkID is completely removed.\n const txBelongsToCurrentChain =\n meta.chainId === currentChainId ||\n (!meta.chainId && meta.networkID === currentNetworkID);\n\n if (!meta.verifiedOnBlockchain && txBelongsToCurrentChain) {\n const [reconciledTx, updateRequired] =\n await this.blockchainTransactionStateReconciler(meta);\n if (updateRequired) {\n transactions[index] = reconciledTx;\n gotUpdates = updateRequired;\n }\n }\n }),\n ),\n );\n\n /* istanbul ignore else */\n if (gotUpdates) {\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n }\n }\n\n /**\n * Updates an existing transaction in state.\n *\n * @param transactionMeta - The new transaction to store in state.\n */\n updateTransaction(transactionMeta: TransactionMeta) {\n const { transactions } = this.state;\n transactionMeta.transaction = normalizeTransaction(\n transactionMeta.transaction,\n );\n validateTransaction(transactionMeta.transaction);\n const index = transactions.findIndex(({ id }) => transactionMeta.id === id);\n transactions[index] = transactionMeta;\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Removes all transactions from state, optionally based on the current network.\n *\n * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the\n * current network. If `true`, all transactions are wiped.\n */\n wipeTransactions(ignoreNetwork?: boolean) {\n /* istanbul ignore next */\n if (ignoreNetwork) {\n this.update({ transactions: [] });\n return;\n }\n const { providerConfig, networkId: currentNetworkID } =\n this.getNetworkState();\n const { chainId: currentChainId } = providerConfig;\n const newTransactions = this.state.transactions.filter(\n ({ networkID, chainId }) => {\n // Using fallback to networkID only when there is no chainId present. Should be removed when networkID is completely removed.\n const isCurrentNetwork =\n chainId === currentChainId ||\n (!chainId && networkID === currentNetworkID);\n return !isCurrentNetwork;\n },\n );\n\n this.update({\n transactions: this.trimTransactionsForState(newTransactions),\n });\n }\n\n /**\n * Get transactions from Etherscan for the given address. By default all transactions are\n * returned, but the `fromBlock` option can be given to filter just for transactions from a\n * specific block onward.\n *\n * @param address - The address to fetch the transactions for.\n * @param opt - Object containing optional data, fromBlock and Etherscan API key.\n * @returns The block number of the latest incoming transaction.\n */\n async fetchAll(\n address: string,\n opt?: FetchAllOptions,\n ): Promise {\n const { transactions: localTransactions } = this.state;\n\n const { updateRequired, transactions, latestBlockNumber } =\n await this.incomingTransactionHelper.reconcile({\n address,\n localTransactions,\n fromBlock: opt?.fromBlock,\n apiKey: opt?.etherscanApiKey,\n });\n\n if (updateRequired) {\n this.update({\n transactions: this.trimTransactionsForState(transactions),\n });\n }\n\n return latestBlockNumber;\n }\n\n private async processApproval(\n transactionMeta: TransactionMeta,\n ): Promise {\n const transactionId = transactionMeta.id;\n let resultCallbacks: AcceptResultCallbacks | undefined;\n\n try {\n const acceptResult = await this.requestApproval(transactionMeta);\n resultCallbacks = acceptResult.resultCallbacks;\n\n const { meta, isCompleted } = this.isTransactionCompleted(transactionId);\n\n if (meta && !isCompleted) {\n await this.approveTransaction(transactionId);\n }\n } catch (error: any) {\n const { meta, isCompleted } = this.isTransactionCompleted(transactionId);\n\n if (meta && !isCompleted) {\n if (error.code === errorCodes.provider.userRejectedRequest) {\n this.cancelTransaction(transactionId);\n\n throw ethErrors.provider.userRejectedRequest(\n 'User rejected the transaction',\n );\n } else {\n this.failTransaction(meta, error);\n }\n }\n }\n\n const finalMeta = this.getTransaction(transactionId);\n\n switch (finalMeta?.status) {\n case TransactionStatus.failed:\n resultCallbacks?.error(finalMeta.error);\n throw ethErrors.rpc.internal(finalMeta.error.message);\n\n case TransactionStatus.cancelled:\n const cancelError = ethErrors.rpc.internal(\n 'User cancelled the transaction',\n );\n\n resultCallbacks?.error(cancelError);\n throw cancelError;\n\n case TransactionStatus.submitted:\n resultCallbacks?.success();\n return finalMeta.transactionHash as string;\n\n default:\n const internalError = ethErrors.rpc.internal(\n `MetaMask Tx Signature: Unknown problem: ${JSON.stringify(\n finalMeta || transactionId,\n )}`,\n );\n\n resultCallbacks?.error(internalError);\n throw internalError;\n }\n }\n\n /**\n * Approves a transaction and updates it's status in state. If this is not a\n * retry transaction, a nonce will be generated. The transaction is signed\n * using the sign configuration property, then published to the blockchain.\n * A `:finished` hub event is fired after success or failure.\n *\n * @param transactionID - The ID of the transaction to approve.\n */\n private async approveTransaction(transactionID: string) {\n const { transactions } = this.state;\n const releaseLock = await this.mutex.acquire();\n const { providerConfig } = this.getNetworkState();\n const { chainId } = providerConfig;\n const index = transactions.findIndex(({ id }) => transactionID === id);\n const transactionMeta = transactions[index];\n const {\n transaction: { nonce, from },\n } = transactionMeta;\n let nonceLock;\n try {\n if (!this.sign) {\n releaseLock();\n this.failTransaction(\n transactionMeta,\n new Error('No sign method defined.'),\n );\n return;\n } else if (!chainId) {\n releaseLock();\n this.failTransaction(transactionMeta, new Error('No chainId defined.'));\n return;\n }\n\n const { approved: status } = TransactionStatus;\n let nonceToUse = nonce;\n // if a nonce already exists on the transactionMeta it means this is a speedup or cancel transaction\n // so we want to reuse that nonce and hope that it beats the previous attempt to chain. Otherwise use a new locked nonce\n if (!nonceToUse) {\n nonceLock = await this.nonceTracker.getNonceLock(from);\n nonceToUse = addHexPrefix(nonceLock.nextNonce.toString(16));\n }\n\n transactionMeta.status = status;\n transactionMeta.transaction.nonce = nonceToUse;\n transactionMeta.transaction.chainId = chainId;\n\n const baseTxParams = {\n ...transactionMeta.transaction,\n gasLimit: transactionMeta.transaction.gas,\n };\n\n const isEIP1559 = isEIP1559Transaction(transactionMeta.transaction);\n\n const txParams = isEIP1559\n ? {\n ...baseTxParams,\n maxFeePerGas: transactionMeta.transaction.maxFeePerGas,\n maxPriorityFeePerGas:\n transactionMeta.transaction.maxPriorityFeePerGas,\n estimatedBaseFee: transactionMeta.transaction.estimatedBaseFee,\n // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set\n type: 2,\n }\n : baseTxParams;\n\n // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set\n if (isEIP1559) {\n delete txParams.gasPrice;\n }\n\n const unsignedEthTx = this.prepareUnsignedEthTx(txParams);\n const signedTx = await this.sign(unsignedEthTx, from);\n transactionMeta.status = TransactionStatus.signed;\n this.updateTransaction(transactionMeta);\n const rawTransaction = bufferToHex(signedTx.serialize());\n\n transactionMeta.rawTransaction = rawTransaction;\n this.updateTransaction(transactionMeta);\n const transactionHash = await query(this.ethQuery, 'sendRawTransaction', [\n rawTransaction,\n ]);\n transactionMeta.transactionHash = transactionHash;\n transactionMeta.status = TransactionStatus.submitted;\n this.updateTransaction(transactionMeta);\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n } catch (error: any) {\n this.failTransaction(transactionMeta, error);\n } finally {\n // must set transaction to submitted/failed before releasing lock\n if (nonceLock) {\n nonceLock.releaseLock();\n }\n releaseLock();\n }\n }\n\n /**\n * Cancels a transaction based on its ID by setting its status to \"rejected\"\n * and emitting a `:finished` hub event.\n *\n * @param transactionID - The ID of the transaction to cancel.\n */\n private cancelTransaction(transactionID: string) {\n const transactionMeta = this.state.transactions.find(\n ({ id }) => id === transactionID,\n );\n if (!transactionMeta) {\n return;\n }\n transactionMeta.status = TransactionStatus.rejected;\n this.hub.emit(`${transactionMeta.id}:finished`, transactionMeta);\n const transactions = this.state.transactions.filter(\n ({ id }) => id !== transactionID,\n );\n this.update({ transactions: this.trimTransactionsForState(transactions) });\n }\n\n /**\n * Trim the amount of transactions that are set on the state. Checks\n * if the length of the tx history is longer then desired persistence\n * limit and then if it is removes the oldest confirmed or rejected tx.\n * Pending or unapproved transactions will not be removed by this\n * operation. For safety of presenting a fully functional transaction UI\n * representation, this function will not break apart transactions with the\n * same nonce, created on the same day, per network. Not accounting for transactions of the same\n * nonce, same day and network combo can result in confusing or broken experiences\n * in the UI. The transactions are then updated using the BaseController update.\n *\n * @param transactions - The transactions to be applied to the state.\n * @returns The trimmed list of transactions.\n */\n private trimTransactionsForState(\n transactions: TransactionMeta[],\n ): TransactionMeta[] {\n const nonceNetworkSet = new Set();\n const txsToKeep = transactions.reverse().filter((tx) => {\n const { chainId, networkID, status, transaction, time } = tx;\n if (transaction) {\n const key = `${transaction.nonce}-${\n chainId ? convertHexToDecimal(chainId) : networkID\n }-${new Date(time).toDateString()}`;\n if (nonceNetworkSet.has(key)) {\n return true;\n } else if (\n nonceNetworkSet.size < this.config.txHistoryLimit ||\n !this.isFinalState(status)\n ) {\n nonceNetworkSet.add(key);\n return true;\n }\n }\n return false;\n });\n txsToKeep.reverse();\n return txsToKeep;\n }\n\n /**\n * Determines if the transaction is in a final state.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isFinalState(status: TransactionStatus): boolean {\n return (\n status === TransactionStatus.rejected ||\n status === TransactionStatus.confirmed ||\n status === TransactionStatus.failed ||\n status === TransactionStatus.cancelled\n );\n }\n\n /**\n * Whether the transaction has at least completed all local processing.\n *\n * @param status - The transaction status.\n * @returns Whether the transaction is in a final state.\n */\n private isLocalFinalState(status: TransactionStatus): boolean {\n return [\n TransactionStatus.cancelled,\n TransactionStatus.confirmed,\n TransactionStatus.failed,\n TransactionStatus.rejected,\n TransactionStatus.submitted,\n ].includes(status);\n }\n\n /**\n * Method to verify the state of a transaction using the Blockchain as a source of truth.\n *\n * @param meta - The local transaction to verify on the blockchain.\n * @returns A tuple containing the updated transaction, and whether or not an update was required.\n */\n private async blockchainTransactionStateReconciler(\n meta: TransactionMeta,\n ): Promise<[TransactionMeta, boolean]> {\n const { status, transactionHash } = meta;\n switch (status) {\n case TransactionStatus.confirmed:\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n transactionHash,\n ]);\n\n if (!txReceipt) {\n return [meta, false];\n }\n\n meta.verifiedOnBlockchain = true;\n meta.transaction.gasUsed = txReceipt.gasUsed;\n\n // According to the Web3 docs:\n // TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n if (Number(txReceipt.status) === 0) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was reversed',\n );\n this.failTransaction(meta, error);\n return [meta, false];\n }\n\n return [meta, true];\n case TransactionStatus.submitted:\n const txObj = await query(this.ethQuery, 'getTransactionByHash', [\n transactionHash,\n ]);\n\n if (!txObj) {\n const receiptShowsFailedStatus =\n await this.checkTxReceiptStatusIsFailed(transactionHash);\n\n // Case the txObj is evaluated as false, a second check will\n // determine if the tx failed or it is pending or confirmed\n if (receiptShowsFailedStatus) {\n const error: Error = new Error(\n 'Transaction failed. The transaction was dropped or replaced by a new one',\n );\n this.failTransaction(meta, error);\n }\n }\n\n /* istanbul ignore next */\n if (txObj?.blockNumber) {\n meta.status = TransactionStatus.confirmed;\n this.hub.emit(`${meta.id}:confirmed`, meta);\n return [meta, true];\n }\n\n return [meta, false];\n default:\n return [meta, false];\n }\n }\n\n /**\n * Method to check if a tx has failed according to their receipt\n * According to the Web3 docs:\n * TRUE if the transaction was successful, FALSE if the EVM reverted the transaction.\n * The receipt is not available for pending transactions and returns null.\n *\n * @param txHash - The transaction hash.\n * @returns Whether the transaction has failed.\n */\n private async checkTxReceiptStatusIsFailed(\n txHash: string | undefined,\n ): Promise {\n const txReceipt = await query(this.ethQuery, 'getTransactionReceipt', [\n txHash,\n ]);\n if (!txReceipt) {\n // Transaction is pending\n return false;\n }\n return Number(txReceipt.status) === 0;\n }\n\n private async requestApproval(txMeta: TransactionMeta): Promise {\n const id = this.getApprovalId(txMeta);\n const { origin } = txMeta;\n const type = ApprovalType.Transaction;\n const requestData = { txId: txMeta.id };\n\n return (await this.messagingSystem.call(\n 'ApprovalController:addRequest',\n {\n id,\n origin: origin || ORIGIN_METAMASK,\n type,\n requestData,\n expectsResult: true,\n },\n true,\n )) as Promise;\n }\n\n private getTransaction(transactionID: string): TransactionMeta | undefined {\n const { transactions } = this.state;\n return transactions.find(({ id }) => id === transactionID);\n }\n\n private getApprovalId(txMeta: TransactionMeta) {\n return String(txMeta.id);\n }\n\n private isTransactionCompleted(transactionid: string): {\n meta?: TransactionMeta;\n isCompleted: boolean;\n } {\n const transaction = this.getTransaction(transactionid);\n\n if (!transaction) {\n return { meta: undefined, isCompleted: false };\n }\n\n const isCompleted = this.isLocalFinalState(transaction.status);\n\n return { meta: transaction, isCompleted };\n }\n}\n\nexport default TransactionController;\n"]} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/constants.d.ts b/node_modules/@metamask/transaction-controller/dist/constants.d.ts -new file mode 100644 -index 0000000..66a2d93 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/constants.d.ts -@@ -0,0 +1,125 @@ -+export declare const CHAIN_IDS: { -+ readonly MAINNET: "0x1"; -+ readonly GOERLI: "0x5"; -+ readonly BSC: "0x38"; -+ readonly BSC_TESTNET: "0x61"; -+ readonly OPTIMISM: "0xa"; -+ readonly OPTIMISM_SEPOLIA: "0xaa37dc"; -+ readonly POLYGON: "0x89"; -+ readonly POLYGON_TESTNET: "0x13881"; -+ readonly AVALANCHE: "0xa86a"; -+ readonly AVALANCHE_TESTNET: "0xa869"; -+ readonly FANTOM: "0xfa"; -+ readonly FANTOM_TESTNET: "0xfa2"; -+ readonly SEPOLIA: "0xaa36a7"; -+ readonly LINEA_GOERLI: "0xe704"; -+ readonly LINEA_SEPOLIA: "0xe705"; -+ readonly LINEA_MAINNET: "0xe708"; -+ readonly MOONBEAM: "0x504"; -+ readonly MOONBEAM_TESTNET: "0x507"; -+ readonly MOONRIVER: "0x505"; -+ readonly GNOSIS: "0x64"; -+}; -+export declare const ETHERSCAN_SUPPORTED_NETWORKS: { -+ "0x5": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x1": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xaa36a7": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xe704": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xe705": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xe708": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x38": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x61": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xa": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xaa37dc": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x89": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x13881": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xa86a": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xa869": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xfa": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0xfa2": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x504": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x507": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x505": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+ "0x64": { -+ domain: string; -+ subdomain: string; -+ networkId: string; -+ }; -+}; -+//# sourceMappingURL=constants.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/constants.js b/node_modules/@metamask/transaction-controller/dist/constants.js -new file mode 100644 -index 0000000..b190c92 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/constants.js -@@ -0,0 +1,130 @@ -+"use strict"; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.ETHERSCAN_SUPPORTED_NETWORKS = exports.CHAIN_IDS = void 0; -+exports.CHAIN_IDS = { -+ MAINNET: '0x1', -+ GOERLI: '0x5', -+ BSC: '0x38', -+ BSC_TESTNET: '0x61', -+ OPTIMISM: '0xa', -+ OPTIMISM_SEPOLIA: '0xaa37dc', -+ POLYGON: '0x89', -+ POLYGON_TESTNET: '0x13881', -+ AVALANCHE: '0xa86a', -+ AVALANCHE_TESTNET: '0xa869', -+ FANTOM: '0xfa', -+ FANTOM_TESTNET: '0xfa2', -+ SEPOLIA: '0xaa36a7', -+ LINEA_GOERLI: '0xe704', -+ LINEA_SEPOLIA: '0xe705', -+ LINEA_MAINNET: '0xe708', -+ MOONBEAM: '0x504', -+ MOONBEAM_TESTNET: '0x507', -+ MOONRIVER: '0x505', -+ GNOSIS: '0x64', -+}; -+const DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io'; -+const DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api'; -+exports.ETHERSCAN_SUPPORTED_NETWORKS = { -+ [exports.CHAIN_IDS.GOERLI]: { -+ domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`, -+ networkId: parseInt(exports.CHAIN_IDS.GOERLI, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.MAINNET]: { -+ domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.MAINNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.SEPOLIA]: { -+ domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`, -+ networkId: parseInt(exports.CHAIN_IDS.SEPOLIA, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.LINEA_GOERLI]: { -+ domain: 'lineascan.build', -+ subdomain: 'goerli', -+ networkId: parseInt(exports.CHAIN_IDS.LINEA_GOERLI, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.LINEA_SEPOLIA]: { -+ domain: 'lineascan.build', -+ subdomain: 'sepolia', -+ networkId: parseInt(exports.CHAIN_IDS.LINEA_SEPOLIA, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.LINEA_MAINNET]: { -+ domain: 'lineascan.build', -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.LINEA_MAINNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.BSC]: { -+ domain: 'bscscan.com', -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.BSC, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.BSC_TESTNET]: { -+ domain: 'bscscan.com', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`, -+ networkId: parseInt(exports.CHAIN_IDS.BSC_TESTNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.OPTIMISM]: { -+ domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`, -+ networkId: parseInt(exports.CHAIN_IDS.OPTIMISM, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.OPTIMISM_SEPOLIA]: { -+ domain: DEFAULT_ETHERSCAN_DOMAIN, -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`, -+ networkId: parseInt(exports.CHAIN_IDS.OPTIMISM_SEPOLIA, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.POLYGON]: { -+ domain: 'polygonscan.com', -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.POLYGON, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.POLYGON_TESTNET]: { -+ domain: 'polygonscan.com', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`, -+ networkId: parseInt(exports.CHAIN_IDS.POLYGON_TESTNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.AVALANCHE]: { -+ domain: 'snowtrace.io', -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.AVALANCHE, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.AVALANCHE_TESTNET]: { -+ domain: 'snowtrace.io', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`, -+ networkId: parseInt(exports.CHAIN_IDS.AVALANCHE_TESTNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.FANTOM]: { -+ domain: 'ftmscan.com', -+ subdomain: DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX, -+ networkId: parseInt(exports.CHAIN_IDS.FANTOM, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.FANTOM_TESTNET]: { -+ domain: 'ftmscan.com', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`, -+ networkId: parseInt(exports.CHAIN_IDS.FANTOM_TESTNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.MOONBEAM]: { -+ domain: 'moonscan.io', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`, -+ networkId: parseInt(exports.CHAIN_IDS.MOONBEAM, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.MOONBEAM_TESTNET]: { -+ domain: 'moonscan.io', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`, -+ networkId: parseInt(exports.CHAIN_IDS.MOONBEAM_TESTNET, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.MOONRIVER]: { -+ domain: 'moonscan.io', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`, -+ networkId: parseInt(exports.CHAIN_IDS.MOONRIVER, 16).toString(), -+ }, -+ [exports.CHAIN_IDS.GNOSIS]: { -+ domain: 'gnosisscan.io', -+ subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`, -+ networkId: parseInt(exports.CHAIN_IDS.GNOSIS, 16).toString(), -+ }, -+}; -+//# sourceMappingURL=constants.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts -index 3605f99..a49d68f 100644 ---- a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts -@@ -1,4 +1,3 @@ --import { NetworkType } from '@metamask/controller-utils'; - export interface EtherscanTransactionMetaBase { - blockNumber: string; - blockHash: string; -@@ -29,38 +28,37 @@ export interface EtherscanTokenTransactionMeta extends EtherscanTransactionMetaB - tokenSymbol: string; - } - export interface EtherscanTransactionResponse { -- status: '0' | '1'; - result: T[]; - } - export interface EtherscanTransactionRequest { - address: string; -- networkType: NetworkType; -- limit: number; -- fromBlock?: string; - apiKey?: string; -+ chainId: string; -+ 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.networkType - Current network type used to determine the Etherscan subdomain. -- * @param request.limit - Maximum number of transactions to retrieve. - * @param request.apiKey - Etherscan API key. -+ * @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, networkType, limit, apiKey, fromBlock, }: EtherscanTransactionRequest): Promise>; -+export declare function fetchEtherscanTransactions({ address, apiKey, 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.networkType - Current network type used to determine the Etherscan subdomain. -- * @param request.limit - Maximum number of token transactions to retrieve. - * @param request.apiKey - Etherscan API key. -+ * @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, networkType, limit, apiKey, fromBlock, }: EtherscanTransactionRequest): Promise>; -+export declare function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }: EtherscanTransactionRequest): Promise>; - //# sourceMappingURL=etherscan.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map b/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map -deleted file mode 100644 -index b947cbc..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/etherscan.d.ts.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"etherscan.d.ts","sourceRoot":"","sources":["../src/etherscan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,4BAA4B,CAAC;AAEtE,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;AAED,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;AAED,MAAM,WAAW,6BACf,SAAQ,4BAA4B;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B,CAC3C,CAAC,SAAS,4BAA4B;IAEtC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,MAAM,EAAE,CAAC,EAAE,CAAC;CACb;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,OAAO,EACP,WAAW,EACX,KAAK,EACL,MAAM,EACN,SAAS,GACV,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,wBAAwB,CAAC,CACvD,CAQA;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,WAAW,EACX,KAAK,EACL,MAAM,EACN,SAAS,GACV,EAAE,2BAA2B,GAAG,OAAO,CACtC,4BAA4B,CAAC,6BAA6B,CAAC,CAC5D,CAQA"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.js b/node_modules/@metamask/transaction-controller/dist/etherscan.js -index 4e1cade..0757847 100644 ---- a/node_modules/@metamask/transaction-controller/dist/etherscan.js -+++ b/node_modules/@metamask/transaction-controller/dist/etherscan.js -@@ -11,25 +11,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge - 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"); - /** - * Retrieves transaction data from Etherscan. - * - * @param request - Configuration required to fetch transactions. - * @param request.address - Address to retrieve transactions for. -- * @param request.networkType - Current network type used to determine the Etherscan subdomain. -- * @param request.limit - Maximum number of transactions to retrieve. - * @param request.apiKey - Etherscan API key. -+ * @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, networkType, limit, apiKey, fromBlock, }) { -+function fetchEtherscanTransactions({ address, apiKey, chainId, fromBlock, limit, }) { - return __awaiter(this, void 0, void 0, function* () { - return yield fetchTransactions('txlist', { - address, -- networkType, -- limit, -- fromBlock, - apiKey, -+ chainId, -+ fromBlock, -+ limit, - }); - }); - } -@@ -39,20 +40,20 @@ exports.fetchEtherscanTransactions = fetchEtherscanTransactions; - * - * @param request - Configuration required to fetch token transactions. - * @param request.address - Address to retrieve token transactions for. -- * @param request.networkType - Current network type used to determine the Etherscan subdomain. -- * @param request.limit - Maximum number of token transactions to retrieve. - * @param request.apiKey - Etherscan API key. -+ * @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, networkType, limit, apiKey, fromBlock, }) { -+function fetchEtherscanTokenTransactions({ address, apiKey, chainId, fromBlock, limit, }) { - return __awaiter(this, void 0, void 0, function* () { - return yield fetchTransactions('tokentx', { - address, -- networkType, -- limit, -- fromBlock, - apiKey, -+ chainId, -+ fromBlock, -+ limit, - }); - }); - } -@@ -63,44 +64,47 @@ exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions; - * @param action - The Etherscan endpoint to use. - * @param options - Options bag. - * @param options.address - Address to retrieve transactions for. -- * @param options.networkType - Current network type used to determine the Etherscan subdomain. -- * @param options.limit - Maximum number of transactions to retrieve. - * @param options.apiKey - Etherscan API key. -+ * @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, networkType, limit, apiKey, fromBlock, }) { -+function fetchTransactions(action, { address, apiKey, chainId, limit, }) { - return __awaiter(this, void 0, void 0, function* () { - const urlParams = { - module: 'account', - address, -- startBlock: fromBlock, -+ // Not previously used in mobile due to bug, temporarily disabled to match existing behaviour. -+ startBlock: undefined, - apikey: apiKey, -- offset: limit.toString(), -- order: 'desc', -+ offset: limit === null || limit === void 0 ? void 0 : limit.toString(), -+ sort: 'desc', - }; -- const etherscanTxUrl = getEtherscanApiUrl(networkType, Object.assign(Object.assign({}, urlParams), { action })); -+ const etherscanTxUrl = getEtherscanApiUrl(chainId, Object.assign(Object.assign({}, urlParams), { action })); - const response = (yield (0, controller_utils_1.handleFetch)(etherscanTxUrl)); -- if (response.status === '0' || response.result.length <= 0) { -- return { status: response.status, result: [] }; -+ let result = response.result; -+ if (response.status === '0') { -+ result = []; - } -- return response; -+ return { result }; - }); - } - /** - * Return a URL that can be used to fetch data from Etherscan. - * -- * @param networkType - Network type of desired network. -+ * @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(networkType, urlParams) { -- let etherscanSubdomain = 'api'; -- if (networkType !== controller_utils_1.NetworkType.mainnet) { -- etherscanSubdomain = `api-${networkType}`; -+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://${etherscanSubdomain}.etherscan.io`; -+ const apiUrl = `https://${networkInfo.subdomain}.${networkInfo.domain}`; - let url = `${apiUrl}/api?`; -+ // eslint-disable-next-line guard-for-in - for (const paramKey in urlParams) { - const value = urlParams[paramKey]; - if (!value) { -diff --git a/node_modules/@metamask/transaction-controller/dist/etherscan.js.map b/node_modules/@metamask/transaction-controller/dist/etherscan.js.map -deleted file mode 100644 -index a9710c0..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/etherscan.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"etherscan.js","sourceRoot":"","sources":["../src/etherscan.ts"],"names":[],"m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AQ,CAAC;IAClB,CAAC;CAAA;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,WAAmB,EACnB,SAA6C;IAE7C,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,IAAI,WAAW,KAAK,8BAAW,CAAC,OAAO,EAAE;QACvC,kBAAkB,GAAG,OAAO,WAAW,EAAE,CAAC;KAC3C;IAED,MAAM,MAAM,GAAG,WAAW,kBAAkB,eAAe,CAAC;IAC5D,IAAI,GAAG,GAAG,GAAG,MAAM,OAAO,CAAC;IAE3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,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 { NetworkType, handleFetch } from '@metamask/controller-utils';\n\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\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n txreceipt_status: string;\n}\n\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\nexport interface EtherscanTransactionResponse<\n T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n result: T[];\n}\n\nexport interface EtherscanTransactionRequest {\n address: string;\n networkType: NetworkType;\n limit: number;\n fromBlock?: string;\n apiKey?: string;\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.networkType - Current network type used to determine the Etherscan subdomain.\n * @param request.limit - Maximum number of transactions to retrieve.\n * @param request.apiKey - Etherscan API key.\n * @param request.fromBlock - Block number to start fetching transactions from.\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 networkType,\n limit,\n apiKey,\n fromBlock,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse\n> {\n return await fetchTransactions('txlist', {\n address,\n networkType,\n limit,\n fromBlock,\n apiKey,\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.networkType - Current network type used to determine the Etherscan subdomain.\n * @param request.limit - Maximum number of token transactions to retrieve.\n * @param request.apiKey - Etherscan API key.\n * @param request.fromBlock - Block number to start fetching token transactions from.\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 networkType,\n limit,\n apiKey,\n fromBlock,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse\n> {\n return await fetchTransactions('tokentx', {\n address,\n networkType,\n limit,\n fromBlock,\n apiKey,\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.networkType - Current network type used to determine the Etherscan subdomain.\n * @param options.limit - Maximum number of transactions to retrieve.\n * @param options.apiKey - Etherscan API key.\n * @param options.fromBlock - Block number to start fetching transactions from.\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 networkType,\n limit,\n apiKey,\n fromBlock,\n }: {\n address: string;\n networkType: NetworkType;\n limit: number;\n fromBlock?: string;\n apiKey?: string;\n },\n): Promise> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock,\n apikey: apiKey,\n offset: limit.toString(),\n order: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(networkType, {\n ...urlParams,\n action,\n });\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as EtherscanTransactionResponse;\n\n if (response.status === '0' || response.result.length <= 0) {\n return { status: response.status, result: [] };\n }\n\n return response;\n}\n\n/**\n * Return a URL that can be used to fetch data from Etherscan.\n *\n * @param networkType - Network type of desired network.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to access Etherscan data.\n */\nfunction getEtherscanApiUrl(\n networkType: string,\n urlParams: Record,\n): string {\n let etherscanSubdomain = 'api';\n\n if (networkType !== NetworkType.mainnet) {\n etherscanSubdomain = `api-${networkType}`;\n }\n\n const apiUrl = `https://${etherscanSubdomain}.etherscan.io`;\n let url = `${apiUrl}/api?`;\n\n for (const paramKey in 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/gas-flows/DefaultGasFeeFlow.d.ts b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts -new file mode 100644 -index 0000000..325802b ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts -@@ -0,0 +1,10 @@ -+import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types'; -+/** -+ * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController. -+ */ -+export declare class DefaultGasFeeFlow implements GasFeeFlow { -+ #private; -+ matchesTransaction(_transactionMeta: TransactionMeta): boolean; -+ getGasFees(request: GasFeeFlowRequest): Promise; -+} -+//# sourceMappingURL=DefaultGasFeeFlow.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map -new file mode 100644 -index 0000000..7ed6d78 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.d.ts.map -@@ -0,0 +1 @@ -+{"version":3,"file":"DefaultGasFeeFlow.d.ts","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAGV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAC;AAiBlB;;GAEG;AACH,qBAAa,iBAAkB,YAAW,UAAU;;IAClD,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4E1E"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js -new file mode 100644 -index 0000000..24ecb29 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js -@@ -0,0 +1,79 @@ -+"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 __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 _DefaultGasFeeFlow_instances, _DefaultGasFeeFlow_getEstimateLevel, _DefaultGasFeeFlow_getFeeMarketLevel, _DefaultGasFeeFlow_getLegacyLevel, _DefaultGasFeeFlow_gweiDecimalToWeiHex; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.DefaultGasFeeFlow = 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 logger_1 = require("../logger"); -+const types_1 = require("../types"); -+const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'default-gas-fee-flow'); -+/** -+ * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController. -+ */ -+class DefaultGasFeeFlow { -+ constructor() { -+ _DefaultGasFeeFlow_instances.add(this); -+ } -+ matchesTransaction(_transactionMeta) { -+ return true; -+ } -+ getGasFees(request) { -+ return __awaiter(this, void 0, void 0, function* () { -+ const { getGasFeeControllerEstimates } = request; -+ const { gasEstimateType, gasFeeEstimates } = yield getGasFeeControllerEstimates(); -+ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { -+ log('Using fee market estimates', gasFeeEstimates); -+ } -+ else if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) { -+ log('Using legacy estimates', gasFeeEstimates); -+ } -+ else { -+ throw new Error(`'No gas fee estimates available`); -+ } -+ const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getEstimateLevel).call(this, { -+ gasEstimateType, -+ gasFeeEstimates, -+ level, -+ }) })), {}); -+ return { estimates }; -+ }); -+ } -+} -+exports.DefaultGasFeeFlow = DefaultGasFeeFlow; -+_DefaultGasFeeFlow_instances = new WeakSet(), _DefaultGasFeeFlow_getEstimateLevel = function _DefaultGasFeeFlow_getEstimateLevel({ gasEstimateType, gasFeeEstimates, level, }) { -+ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) { -+ return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getFeeMarketLevel).call(this, gasFeeEstimates, level); -+ } -+ return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getLegacyLevel).call(this, gasFeeEstimates, level); -+}, _DefaultGasFeeFlow_getFeeMarketLevel = function _DefaultGasFeeFlow_getFeeMarketLevel(gasFeeEstimates, level) { -+ const maxFeePerGas = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level].suggestedMaxFeePerGas); -+ const maxPriorityFeePerGas = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level].suggestedMaxPriorityFeePerGas); -+ return { -+ maxFeePerGas, -+ maxPriorityFeePerGas, -+ }; -+}, _DefaultGasFeeFlow_getLegacyLevel = function _DefaultGasFeeFlow_getLegacyLevel(gasFeeEstimates, level) { -+ const gasPrice = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_gweiDecimalToWeiHex).call(this, gasFeeEstimates[level]); -+ return { -+ maxFeePerGas: gasPrice, -+ maxPriorityFeePerGas: gasPrice, -+ }; -+}, _DefaultGasFeeFlow_gweiDecimalToWeiHex = function _DefaultGasFeeFlow_gweiDecimalToWeiHex(gweiDecimal) { -+ return (0, controller_utils_1.toHex)((0, controller_utils_1.gweiDecToWEIBN)(gweiDecimal)); -+}; -+//# sourceMappingURL=DefaultGasFeeFlow.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map -new file mode 100644 -index 0000000..436f84f ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/DefaultGasFeeFlow.js.map -@@ -0,0 +1 @@ -+{"version":3,"file":"DefaultGasFeeFlow.js","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAAmE;AAKnE,qEAAkE;AAElE,2CAAqD;AAErD,sCAA0C;AAS1C,oCAA+C;AAE/C,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,sBAAsB,CAAC,CAAC;AActE;;GAEG;AACH,MAAa,iBAAiB;IAA9B;;IAiFA,CAAC;IAhFC,kBAAkB,CAAC,gBAAiC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAEK,UAAU,CAAC,OAA0B;;YACzC,MAAM,EAAE,4BAA4B,EAAE,GAAG,OAAO,CAAC;YAEjD,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GACxC,MAAM,4BAA4B,EAAE,CAAC;YAEvC,IAAI,eAAe,KAAK,uCAAkB,CAAC,UAAU,EAAE;gBACrD,GAAG,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;aACpD;iBAAM,IAAI,eAAe,KAAK,uCAAkB,CAAC,MAAM,EAAE;gBACxD,GAAG,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;aAChD;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;aACpD;YAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,MAAM,CACzD,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,iCACd,MAAM,KACT,CAAC,KAAK,CAAC,EAAE,uBAAA,IAAI,yEAAkB,MAAtB,IAAI,EAAmB;oBAC9B,eAAe;oBACf,eAAe;oBACf,KAAK;iBAC8D,CAAC,IACtE,EACF,EAAqB,CACtB,CAAC;YAEF,OAAO,EAAE,SAAS,EAAE,CAAC;QACvB,CAAC;KAAA;CAiDF;AAjFD,8CAiFC;iIA/CmB,EAChB,eAAe,EACf,eAAe,EACf,KAAK,GAG0B;IAC/B,IAAI,eAAe,KAAK,uCAAkB,CAAC,UAAU,EAAE;QACrD,OAAO,uBAAA,IAAI,0EAAmB,MAAvB,IAAI,EAAoB,eAAe,EAAE,KAAK,CAAC,CAAC;KACxD;IAED,OAAO,uBAAA,IAAI,uEAAgB,MAApB,IAAI,EAAiB,eAAe,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,uFAGC,eAA0C,EAC1C,KAA0B;IAE1B,MAAM,YAAY,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EACvB,eAAe,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAC7C,CAAC;IAEF,MAAM,oBAAoB,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAC/B,eAAe,CAAC,KAAK,CAAC,CAAC,6BAA6B,CACrD,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,iFAGC,eAAuC,EACvC,KAA0B;IAE1B,MAAM,QAAQ,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAAsB,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAEnE,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,oBAAoB,EAAE,QAAQ;KAC/B,CAAC;AACJ,CAAC,2FAEoB,WAAmB;IACtC,OAAO,IAAA,wBAAK,EAAC,IAAA,iCAAc,EAAC,WAAW,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { gweiDecToWEIBN, toHex } from '@metamask/controller-utils';\nimport type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeEstimatesForLevel,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\ntype FeeMarketGetEstimateLevelRequest = {\n gasEstimateType: 'fee-market';\n gasFeeEstimates: FeeMarketGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\n\ntype LegacyGetEstimateLevelRequest = {\n gasEstimateType: 'legacy';\n gasFeeEstimates: LegacyGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise {\n const { getGasFeeControllerEstimates } = request;\n\n const { gasEstimateType, gasFeeEstimates } =\n await getGasFeeControllerEstimates();\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n log('Using fee market estimates', gasFeeEstimates);\n } else if (gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n log('Using legacy estimates', gasFeeEstimates);\n } else {\n throw new Error(`'No gas fee estimates available`);\n }\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n } as FeeMarketGetEstimateLevelRequest | LegacyGetEstimateLevelRequest),\n }),\n {} as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n }:\n | FeeMarketGetEstimateLevelRequest\n | LegacyGetEstimateLevelRequest): GasFeeEstimatesForLevel {\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n return this.#getFeeMarketLevel(gasFeeEstimates, level);\n }\n\n return this.#getLegacyLevel(gasFeeEstimates, level);\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): GasFeeEstimatesForLevel {\n const maxFeePerGas = this.#gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = this.#gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): GasFeeEstimatesForLevel {\n const gasPrice = this.#gweiDecimalToWeiHex(gasFeeEstimates[level]);\n\n return {\n maxFeePerGas: gasPrice,\n maxPriorityFeePerGas: gasPrice,\n };\n }\n\n #gweiDecimalToWeiHex(gweiDecimal: string): Hex {\n return toHex(gweiDecToWEIBN(gweiDecimal));\n }\n}\n"]} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts -new file mode 100644 -index 0000000..ce728db ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts -@@ -0,0 +1,12 @@ -+import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types'; -+/** -+ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using: -+ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee. -+ * - Static multipliers to increase the base and priority fees. -+ */ -+export declare class LineaGasFeeFlow implements GasFeeFlow { -+ #private; -+ matchesTransaction(transactionMeta: TransactionMeta): boolean; -+ getGasFees(request: GasFeeFlowRequest): Promise; -+} -+//# sourceMappingURL=LineaGasFeeFlow.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map -new file mode 100644 -index 0000000..3bc92f3 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.d.ts.map -@@ -0,0 +1 @@ -+{"version":3,"file":"LineaGasFeeFlow.d.ts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAC;AA+BlB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js -new file mode 100644 -index 0000000..4b3ad42 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js -@@ -0,0 +1,112 @@ -+"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 __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 _LineaGasFeeFlow_instances, _LineaGasFeeFlow_getLineaGasFees, _LineaGasFeeFlow_getLineaResponse, _LineaGasFeeFlow_getValuesFromMultipliers, _LineaGasFeeFlow_getMaxFees, _LineaGasFeeFlow_feesToString; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.LineaGasFeeFlow = void 0; -+const controller_utils_1 = require("@metamask/controller-utils"); -+const utils_1 = require("@metamask/utils"); -+const DefaultGasFeeFlow_1 = require("./DefaultGasFeeFlow"); -+const logger_1 = require("../logger"); -+const types_1 = require("../types"); -+const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'linea-gas-fee-flow'); -+const LINEA_CHAIN_IDS = [ -+ controller_utils_1.ChainId['linea-mainnet'], -+ controller_utils_1.ChainId['linea-goerli'], -+ controller_utils_1.ChainId['linea-sepolia'], -+]; -+const BASE_FEE_MULTIPLIERS = { -+ low: 1, -+ medium: 1.35, -+ high: 1.7, -+}; -+const PRIORITY_FEE_MULTIPLIERS = { -+ low: 1, -+ medium: 1.05, -+ high: 1.1, -+}; -+/** -+ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using: -+ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee. -+ * - Static multipliers to increase the base and priority fees. -+ */ -+class LineaGasFeeFlow { -+ constructor() { -+ _LineaGasFeeFlow_instances.add(this); -+ } -+ matchesTransaction(transactionMeta) { -+ return LINEA_CHAIN_IDS.includes(transactionMeta.chainId); -+ } -+ getGasFees(request) { -+ return __awaiter(this, void 0, void 0, function* () { -+ try { -+ return yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaGasFees).call(this, request); -+ } -+ catch (error) { -+ log('Using default flow as fallback due to error', error); -+ return new DefaultGasFeeFlow_1.DefaultGasFeeFlow().getGasFees(request); -+ } -+ }); -+ } -+} -+exports.LineaGasFeeFlow = LineaGasFeeFlow; -+_LineaGasFeeFlow_instances = new WeakSet(), _LineaGasFeeFlow_getLineaGasFees = function _LineaGasFeeFlow_getLineaGasFees(request) { -+ return __awaiter(this, void 0, void 0, function* () { -+ const { ethQuery, transactionMeta } = request; -+ const lineaResponse = yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaResponse).call(this, transactionMeta, ethQuery); -+ log('Received Linea response', lineaResponse); -+ const baseFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.baseFeePerGas, BASE_FEE_MULTIPLIERS); -+ log('Generated base fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, baseFees)); -+ const priorityFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.priorityFeePerGas, PRIORITY_FEE_MULTIPLIERS); -+ log('Generated priority fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, priorityFees)); -+ const maxFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getMaxFees).call(this, baseFees, priorityFees); -+ log('Generated max fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, maxFees)); -+ const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: { -+ maxFeePerGas: (0, controller_utils_1.toHex)(maxFees[level]), -+ maxPriorityFeePerGas: (0, controller_utils_1.toHex)(priorityFees[level]), -+ } })), {}); -+ return { estimates }; -+ }); -+}, _LineaGasFeeFlow_getLineaResponse = function _LineaGasFeeFlow_getLineaResponse(transactionMeta, ethQuery) { -+ return (0, controller_utils_1.query)(ethQuery, 'linea_estimateGas', [ -+ { -+ from: transactionMeta.transaction.from, -+ to: transactionMeta.transaction.to, -+ value: transactionMeta.transaction.value, -+ input: transactionMeta.transaction.data, -+ // Required in request but no impact on response. -+ gasPrice: '0x100000000', -+ }, -+ ]); -+}, _LineaGasFeeFlow_getValuesFromMultipliers = function _LineaGasFeeFlow_getValuesFromMultipliers(value, multipliers) { -+ const base = (0, controller_utils_1.hexToBN)(value); -+ const low = base.muln(multipliers.low); -+ const medium = base.muln(multipliers.medium); -+ const high = base.muln(multipliers.high); -+ return { -+ low, -+ medium, -+ high, -+ }; -+}, _LineaGasFeeFlow_getMaxFees = function _LineaGasFeeFlow_getMaxFees(baseFees, priorityFees) { -+ return { -+ low: baseFees.low.add(priorityFees.low), -+ medium: baseFees.medium.add(priorityFees.medium), -+ high: baseFees.high.add(priorityFees.high), -+ }; -+}, _LineaGasFeeFlow_feesToString = function _LineaGasFeeFlow_feesToString(fees) { -+ return Object.values(types_1.GasFeeEstimateLevel).map((level) => fees[level].toString(10)); -+}; -+//# sourceMappingURL=LineaGasFeeFlow.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map -new file mode 100644 -index 0000000..145abc5 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/gas-flows/LineaGasFeeFlow.js.map -@@ -0,0 +1 @@ -+{"version":3,"file":"LineaGasFeeFlow.js","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iEAA4E;AAC5E,2CAA+D;AAG/D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AE,aAAa;SACxB;KACF,CAAC,CAAC;AACL,CAAC,iGAGC,KAAU,EACV,WAA0D;IAE1D,MAAM,IAAI,GAAG,IAAA,0BAAO,EAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;QACL,GAAG;QACH,MAAM;QACN,IAAI;KACL,CAAC;AACJ,CAAC,qEAGC,QAAyC,EACzC,YAA6C;IAE7C,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,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 { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\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 ChainId['linea-sepolia'],\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/GasFeePoller.d.ts b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts -new file mode 100644 -index 0000000..e7eb32d ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts -@@ -0,0 +1,31 @@ -+/// -+import type { GasFeeState } from '@metamask/gas-fee-controller'; -+import EventEmitter from 'events'; -+import type { GasFeeFlow, TransactionMeta } from '../types'; -+/** -+ * Automatically polls and updates suggested gas fees on unapproved transactions. -+ */ -+export declare class GasFeePoller { -+ #private; -+ hub: EventEmitter; -+ /** -+ * Constructs a new instance of the GasFeePoller. -+ * -+ * @param options - The options for this instance. -+ * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees. -+ * @param options.getChainIds - Callback to specify the chain IDs to monitor. -+ * @param options.getEthQuery - Callback to obtain an EthQuery instance. -+ * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates. -+ * @param options.getTransactions - Callback to obtain the transaction data. -+ * @param options.onStateChange - Callback to register a listener for controller state changes. -+ */ -+ constructor({ gasFeeFlows, getChainIds, getEthQuery, getGasFeeControllerEstimates, getTransactions, onStateChange, }: { -+ gasFeeFlows: GasFeeFlow[]; -+ getChainIds: () => string[]; -+ getEthQuery: () => any; -+ getGasFeeControllerEstimates: () => Promise; -+ getTransactions: () => TransactionMeta[]; -+ onStateChange: (listener: () => void) => void; -+ }); -+} -+//# sourceMappingURL=GasFeePoller.d.ts.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map -new file mode 100644 -index 0000000..f6a5ea5 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.d.ts.map -@@ -0,0 +1 @@ -+{"version":3,"file":"GasFeePoller.d.ts","sourceRoot":"","sources":["../../src/helpers/GasFeePoller.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAIlC,OAAO,KAAK,EAAE,UAAU,EAAqB,eAAe,EAAE,MAAM,UAAU,CAAC;AAO/E;;GAEG;AACH,qBAAa,YAAY;;IACvB,GAAG,EAAE,YAAY,CAAsB;IAgBvC;;;;;;;;;;OAUG;gBACS,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,4BAA4B,EAC5B,eAAe,EACf,aAAa,GACd,EAAE;QACD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,WAAW,EAAE,MAAM,MAAM,EAAE,CAAC;QAC5B,WAAW,EAAE,MAAM,GAAG,CAAC;QACvB,4BAA4B,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD,eAAe,EAAE,MAAM,eAAe,EAAE,CAAC;QACzC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;KAC/C;CA+HF"} -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js -new file mode 100644 -index 0000000..6f287b5 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js -@@ -0,0 +1,147 @@ -+"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 _GasFeePoller_instances, _GasFeePoller_gasFeeFlows, _GasFeePoller_getChainIds, _GasFeePoller_getEthQuery, _GasFeePoller_getGasFeeControllerEstimates, _GasFeePoller_getTransactions, _GasFeePoller_timeout, _GasFeePoller_running, _GasFeePoller_start, _GasFeePoller_stop, _GasFeePoller_onTimeout, _GasFeePoller_updateUnapprovedTransactions, _GasFeePoller_updateTransactionSuggestedFees, _GasFeePoller_getUnapprovedTransactions; -+Object.defineProperty(exports, "__esModule", { value: true }); -+exports.GasFeePoller = void 0; -+const utils_1 = require("@metamask/utils"); -+const events_1 = __importDefault(require("events")); -+const logger_1 = require("../logger"); -+const types_1 = require("../types"); -+const gas_flow_1 = require("../utils/gas-flow"); -+const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas-fee-poller'); -+const INTERVAL_MILLISECONDS = 10000; -+/** -+ * Automatically polls and updates suggested gas fees on unapproved transactions. -+ */ -+class GasFeePoller { -+ /** -+ * Constructs a new instance of the GasFeePoller. -+ * -+ * @param options - The options for this instance. -+ * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees. -+ * @param options.getChainIds - Callback to specify the chain IDs to monitor. -+ * @param options.getEthQuery - Callback to obtain an EthQuery instance. -+ * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates. -+ * @param options.getTransactions - Callback to obtain the transaction data. -+ * @param options.onStateChange - Callback to register a listener for controller state changes. -+ */ -+ constructor({ gasFeeFlows, getChainIds, getEthQuery, getGasFeeControllerEstimates, getTransactions, onStateChange, }) { -+ _GasFeePoller_instances.add(this); -+ this.hub = new events_1.default(); -+ _GasFeePoller_gasFeeFlows.set(this, void 0); -+ _GasFeePoller_getChainIds.set(this, void 0); -+ _GasFeePoller_getEthQuery.set(this, void 0); -+ _GasFeePoller_getGasFeeControllerEstimates.set(this, void 0); -+ _GasFeePoller_getTransactions.set(this, void 0); -+ _GasFeePoller_timeout.set(this, void 0); -+ _GasFeePoller_running.set(this, false); -+ __classPrivateFieldSet(this, _GasFeePoller_gasFeeFlows, gasFeeFlows, "f"); -+ __classPrivateFieldSet(this, _GasFeePoller_getChainIds, getChainIds, "f"); -+ __classPrivateFieldSet(this, _GasFeePoller_getEthQuery, getEthQuery, "f"); -+ __classPrivateFieldSet(this, _GasFeePoller_getGasFeeControllerEstimates, getGasFeeControllerEstimates, "f"); -+ __classPrivateFieldSet(this, _GasFeePoller_getTransactions, getTransactions, "f"); -+ onStateChange(() => { -+ const unapprovedTransactions = __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_getUnapprovedTransactions).call(this); -+ if (unapprovedTransactions.length) { -+ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_start).call(this); -+ } -+ else { -+ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_stop).call(this); -+ } -+ }); -+ } -+} -+exports.GasFeePoller = GasFeePoller; -+_GasFeePoller_gasFeeFlows = new WeakMap(), _GasFeePoller_getChainIds = new WeakMap(), _GasFeePoller_getEthQuery = new WeakMap(), _GasFeePoller_getGasFeeControllerEstimates = new WeakMap(), _GasFeePoller_getTransactions = new WeakMap(), _GasFeePoller_timeout = new WeakMap(), _GasFeePoller_running = new WeakMap(), _GasFeePoller_instances = new WeakSet(), _GasFeePoller_start = function _GasFeePoller_start() { -+ if (__classPrivateFieldGet(this, _GasFeePoller_running, "f")) { -+ return; -+ } -+ // Intentionally not awaiting since this starts the timeout chain. -+ // eslint-disable-next-line @typescript-eslint/no-floating-promises -+ __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_onTimeout).call(this); -+ __classPrivateFieldSet(this, _GasFeePoller_running, true, "f"); -+ log('Started polling'); -+}, _GasFeePoller_stop = function _GasFeePoller_stop() { -+ if (!__classPrivateFieldGet(this, _GasFeePoller_running, "f")) { -+ return; -+ } -+ clearTimeout(__classPrivateFieldGet(this, _GasFeePoller_timeout, "f")); -+ __classPrivateFieldSet(this, _GasFeePoller_timeout, undefined, "f"); -+ __classPrivateFieldSet(this, _GasFeePoller_running, false, "f"); -+ log('Stopped polling'); -+}, _GasFeePoller_onTimeout = function _GasFeePoller_onTimeout() { -+ return __awaiter(this, void 0, void 0, function* () { -+ yield __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_updateUnapprovedTransactions).call(this); -+ // eslint-disable-next-line @typescript-eslint/no-misused-promises -+ __classPrivateFieldSet(this, _GasFeePoller_timeout, setTimeout(() => __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_onTimeout).call(this), INTERVAL_MILLISECONDS), "f"); -+ }); -+}, _GasFeePoller_updateUnapprovedTransactions = function _GasFeePoller_updateUnapprovedTransactions() { -+ return __awaiter(this, void 0, void 0, function* () { -+ const unapprovedTransactions = __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_getUnapprovedTransactions).call(this); -+ log('Found unapproved transactions', { -+ count: unapprovedTransactions.length, -+ }); -+ const ethQuery = __classPrivateFieldGet(this, _GasFeePoller_getEthQuery, "f").call(this); -+ yield Promise.all(unapprovedTransactions.map((tx) => __classPrivateFieldGet(this, _GasFeePoller_instances, "m", _GasFeePoller_updateTransactionSuggestedFees).call(this, tx, ethQuery))); -+ }); -+}, _GasFeePoller_updateTransactionSuggestedFees = function _GasFeePoller_updateTransactionSuggestedFees(transactionMeta, ethQuery) { -+ return __awaiter(this, void 0, void 0, function* () { -+ const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, __classPrivateFieldGet(this, _GasFeePoller_gasFeeFlows, "f")); -+ if (!gasFeeFlow) { -+ log('No gas fee flow found', transactionMeta.id); -+ } -+ else { -+ log('Found gas fee flow', gasFeeFlow.constructor.name, transactionMeta.id); -+ } -+ const request = { -+ ethQuery, -+ getGasFeeControllerEstimates: __classPrivateFieldGet(this, _GasFeePoller_getGasFeeControllerEstimates, "f"), -+ transactionMeta, -+ }; -+ if (gasFeeFlow) { -+ try { -+ const response = yield gasFeeFlow.getGasFees(request); -+ transactionMeta.gasFeeEstimates = response.estimates; -+ } -+ catch (error) { -+ log('Failed to get suggested gas fees', transactionMeta.id, error); -+ } -+ } -+ if (!gasFeeFlow && transactionMeta.gasFeeEstimatesLoaded) { -+ return; -+ } -+ transactionMeta.gasFeeEstimatesLoaded = true; -+ this.hub.emit('transaction-updated', transactionMeta, 'GasFeePoller - Suggested gas fees updated'); -+ log('Updated suggested gas fees', { -+ gasFeeEstimates: transactionMeta.gasFeeEstimates, -+ transaction: transactionMeta.id, -+ }); -+ }); -+}, _GasFeePoller_getUnapprovedTransactions = function _GasFeePoller_getUnapprovedTransactions() { -+ const chainIds = __classPrivateFieldGet(this, _GasFeePoller_getChainIds, "f").call(this); -+ return __classPrivateFieldGet(this, _GasFeePoller_getTransactions, "f").call(this).filter((tx) => chainIds.includes(tx.chainId) && -+ tx.status === types_1.TransactionStatus.unapproved); -+}; -+//# sourceMappingURL=GasFeePoller.js.map -\ No newline at end of file -diff --git a/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map -new file mode 100644 -index 0000000..1b85190 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/helpers/GasFeePoller.js.map -@@ -0,0 +1 @@ -+{"version":3,"file":"GasFeePoller.js","sourceRoot":"","sources":["../../src/helpers/GasFeePoller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAqD;AACrD,oDAAkC;AAElC,sCAA0C;AAC1C,oCAA6C;AAE7C,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,EAC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e,GAAG,QAAQ,CAAC,SAAS,CAAC;aACtD;YAAC,OAAO,KAAK,EAAE;gBACd,GAAG,CAAC,kCAAkC,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;aACpE;SACF;QAED,IAAI,CAAC,UAAU,IAAI,eAAe,CAAC,qBAAqB,EAAE;YACxD,OAAO;SACR;QAED,eAAe,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAE7C,IAAI,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 type { GasFeeState } from '@metamask/gas-fee-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport EventEmitter from 'events';\n\nimport { projectLogger } from '../logger';\nimport { TransactionStatus } from '../types';\nimport type { GasFeeFlow, GasFeeFlowRequest, 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 9998101..b7c9355 100644 ---- a/node_modules/@metamask/transaction-controller/dist/index.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/index.d.ts -@@ -1,5 +1,5 @@ - export * from './TransactionController'; --export type { EtherscanTransactionMeta } from './etherscan'; --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 6b85676..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,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,cAAc,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 602f51c..0818eb8 100644 ---- a/node_modules/@metamask/transaction-controller/dist/index.js -+++ b/node_modules/@metamask/transaction-controller/dist/index.js -@@ -14,9 +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 c4fa911..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;AAExC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAC7B,0CAAwB","sourcesContent":["export * from './TransactionController';\nexport type { EtherscanTransactionMeta } from './etherscan';\nexport { isEIP1559Transaction } from './utils';\nexport * from './types';\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/types.d.ts b/node_modules/@metamask/transaction-controller/dist/types.d.ts -index 924bc33..7fb25a4 100644 ---- a/node_modules/@metamask/transaction-controller/dist/types.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/types.d.ts -@@ -1,4 +1,4 @@ --import type { NetworkType } from '@metamask/controller-utils'; -+import type { GasFeeState } from '@metamask/gas-fee-controller'; - import type { Hex } from '@metamask/utils'; - /** - * @type TransactionMeta -@@ -42,6 +42,14 @@ declare type TransactionMetaBase = { - 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 -@@ -94,6 +102,7 @@ export interface Transaction { - maxPriorityFeePerGas?: string; - estimatedBaseFee?: string; - estimateGasError?: string; -+ type?: string; - } - /** - * The configuration required to fetch transaction data from a RemoteTransactionSource. -@@ -118,22 +127,106 @@ export interface RemoteTransactionSourceRequest { - /** - * Block number to start fetching transactions from. - */ -- fromBlock?: string; -+ fromBlock?: number; - /** - * Maximum number of transactions to retrieve. - */ -- limit: number; -- /** -- * The type of the current network. -- */ -- networkType: NetworkType; -+ 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.d.ts.map b/node_modules/@metamask/transaction-controller/dist/types.d.ts.map -deleted file mode 100644 -index 19ac8ab..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/types.d.ts.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,oBAAY,eAAe,GACvB,CAAC;IACC,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAC9D,GAAG,mBAAmB,CAAC,GACxB,CAAC;IAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG,mBAAmB,CAAC,CAAC;AAE/E,aAAK,mBAAmB,GAAG;IACzB,UA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CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,cAAc,EAAE,GAAG,CAAC;IAEpB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,CACjB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACjC"} -\ 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 -index 1cddb49..2cc85ee 100644 ---- a/node_modules/@metamask/transaction-controller/dist/types.js -+++ b/node_modules/@metamask/transaction-controller/dist/types.js -@@ -1,6 +1,6 @@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --exports.WalletDevice = exports.TransactionStatus = void 0; -+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 -@@ -26,4 +26,11 @@ var WalletDevice; - 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/types.js.map b/node_modules/@metamask/transaction-controller/dist/types.js.map -deleted file mode 100644 -index 83f50bc..0000000 ---- a/node_modules/@metamask/transaction-controller/dist/types.js.map -+++ /dev/null -@@ -1 +0,0 @@ --{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA+CA;;;;GAIG;AACH,IAAY,iBASX;AATD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;AAC3B,CAAC,EATW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAS5B;AAED;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,sCAAsB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB","sourcesContent":["import type { NetworkType } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * @type TransactionMeta\n *\n * TransactionMeta representation\n * @property error - Synthesized error information for failed transactions\n * @property id - Generated UUID associated with this transaction\n * @property networkID - Network code as per EIP-155 for this transaction\n * @property origin - Origin this transaction was sent from\n * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed\n * @property rawTransaction - Hex representation of the underlying transaction\n * @property status - String status of this transaction\n * @property time - Timestamp associated with this transaction\n * @property toSmartContract - Whether transaction recipient is a smart contract\n * @property transaction - Underlying Transaction object\n * @property transactionHash - Hash of a successful transaction\n * @property blockNumber - Number of the block where the transaction has been included\n */\nexport type TransactionMeta =\n | ({\n status: Exclude;\n } & TransactionMetaBase)\n | ({ status: TransactionStatus.failed; error: Error } & TransactionMetaBase);\n\ntype TransactionMetaBase = {\n isTransfer?: boolean;\n transferInformation?: {\n symbol: string;\n contractAddress: string;\n decimals: number;\n };\n id: string;\n networkID?: string;\n chainId?: Hex;\n origin?: string;\n rawTransaction?: string;\n time: number;\n toSmartContract?: boolean;\n transaction: Transaction;\n transactionHash?: string;\n blockNumber?: string;\n deviceConfirmedOn?: WalletDevice;\n verifiedOnBlockchain?: boolean;\n};\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\n/**\n * @type Transaction\n *\n * Transaction representation\n * @property chainId - Network ID as per EIP-155\n * @property data - Data to pass with this transaction\n * @property from - Address to send this transaction from\n * @property gas - Gas to send with this transaction\n * @property gasPrice - Price of gas with this transaction\n * @property gasUsed - Gas used in the transaction\n * @property nonce - Unique number to prevent replay attacks\n * @property to - Address to send this transaction to\n * @property value - Value associated with this transaction\n */\nexport interface Transaction {\n chainId?: Hex;\n data?: string;\n from: string;\n gas?: string;\n gasPrice?: string;\n gasUsed?: string;\n nonce?: string;\n to?: string;\n value?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n estimatedBaseFee?: string;\n estimateGasError?: string;\n}\n\n/**\n * The configuration required to fetch transaction data from a RemoteTransactionSource.\n */\nexport interface RemoteTransactionSourceRequest {\n /**\n * The address of the account to fetch transactions for.\n */\n address: string;\n\n /**\n * API key if required by the remote source.\n */\n apiKey?: string;\n\n /**\n * The chainId of the current network.\n */\n currentChainId: Hex;\n\n /**\n * The networkId of the current network.\n */\n currentNetworkId: string;\n\n /**\n * Block number to start fetching transactions from.\n */\n fromBlock?: string;\n\n /**\n * Maximum number of transactions to retrieve.\n */\n limit: number;\n\n /**\n * The type of the current network.\n */\n networkType: NetworkType;\n}\n\n/**\n * An object capable of fetching transaction data from a remote source.\n * Used by the IncomingTransactionHelper to retrieve remote transaction data.\n */\nexport interface RemoteTransactionSource {\n fetchTransactions: (\n request: RemoteTransactionSourceRequest,\n ) => Promise;\n}\n"]} -\ 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 f9a1c07..15b0901 100644 ---- a/node_modules/@metamask/transaction-controller/dist/utils.d.ts -+++ b/node_modules/@metamask/transaction-controller/dist/utils.d.ts -@@ -8,7 +8,7 @@ export declare const ESTIMATE_GAS_ERROR = "eth_estimateGas rpc method error"; - * @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. -@@ -41,10 +41,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 2c9dc99..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":"AAKA,OAAO,KAAK,EAAE,WAAW,IAAI,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE9F,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE/E,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAiBrE;;;;;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,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 387a364..9d71811 100644 ---- a/node_modules/@metamask/transaction-controller/dist/utils.js -+++ b/node_modules/@metamask/transaction-controller/dist/utils.js -@@ -1,11 +1,11 @@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); --exports.getAndFormatTransactionsForNonceTracker = exports.validateMinimumIncrease = exports.getIncreasedPriceFromExisting = exports.getIncreasedPriceHex = exports.isGasPriceValue = exports.isFeeMarketEIP1559Values = exports.validateGasValues = exports.isEIP1559Transaction = exports.validateTransaction = exports.normalizeTransaction = 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.ESTIMATE_GAS_ERROR = void 0; - const controller_utils_1 = require("@metamask/controller-utils"); - const ethereumjs_util_1 = require("ethereumjs-util"); - 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), -@@ -15,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), - }; - /** - * Normalizes properties on a Transaction object. -@@ -22,7 +23,7 @@ const NORMALIZERS = { - * @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) { -@@ -32,7 +33,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. -@@ -130,14 +131,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 -@@ -156,4 +160,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 a1f7e90..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,iEAGoC;AACpC,qDAA4D;AAS/C,QAAA,kBAAkB,GAAG,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAA0C;IACzD,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE;IACxD,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,GAAG,CAAC;IACvC,QAAQ,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,QAAQ,CAAC;IACtD,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,8BAAY,EAAC,KAAK,CAAC;IAC7C,EAAE,EAAE,CAAC,EAAU,EAA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AG,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 {\n convertHexToDecimal,\n isValidHexAddress,\n} from '@metamask/controller-utils';\nimport { addHexPrefix, isHexString } from 'ethereumjs-util';\nimport type { Transaction as NonceTrackerTransaction } from 'nonce-tracker/dist/NonceTracker';\n\nimport type {\n GasPriceValue,\n FeeMarketEIP1559Values,\n} from './TransactionController';\nimport type { Transaction, TransactionMeta, TransactionStatus } from './types';\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 * 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\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/gas-flow.d.ts b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts -new file mode 100644 -index 0000000..02539b9 ---- /dev/null -+++ b/node_modules/@metamask/transaction-controller/dist/utils/gas-flow.d.ts -@@ -0,0 +1,32 @@ -+import { type GasFeeEstimates, type GasFeeState, type LegacyGasPriceEstimate } 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..1eee187 ---- /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,EAGL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC5B,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..461ba2c ---- /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;AAC7D,qEAMsC;AAEtC,oCAMkB;AAElB;;;;;;GA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AAS,iBAAiB,CACxB,yBAAkD;IAElD,OAAO,IAAA,kCAAe,EAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport {\n GAS_ESTIMATE_TYPES,\n type Eip1559GasFee,\n type GasFeeEstimates,\n type GasFeeState,\n type LegacyGasPriceEstimate,\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/scripts/patch-approval-controller.sh b/scripts/patch-approval-controller.sh new file mode 100755 index 000000000000..1912940ee769 --- /dev/null +++ b/scripts/patch-approval-controller.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# ! IMPORTANT ! - Do not forget to give permission to this script: `chmod +x ./scripts/patch-approval-controller.sh`` + +# Generates the patch for the @metamask/approval-controller package +# given only the path to a local core repository. + +# Applies standardisation including: +# - Adding a comment to the top of the patch which is added to a `.patch.txt` file. +# - Removing all sourcemaps. +# - Removing the mocks directory. + +# Requires the approval-controller package to have already been built +# in the core repository. + +set -e +set -o pipefail + +PACKAGE="@metamask/approval-controller" +PACKAGE_DIR_MOBILE="node_modules/$PACKAGE" +DIST_DIR_MOBILE="$PACKAGE_DIR_MOBILE/dist" +PATCH_FILE="patches/@metamask+approval-controller+*.patch" +COMMENT_LINE_COUNT=7 + +COMMENT='+PATCH GENERATED FROM MetaMask/core branch: patch/mobile-approval-controller-3-5-2\ ++This patch backports various transaction controller features from the main branch of MetaMask/core\ ++Steps to update patch:\ ++* Create a new core branch from: patch/mobile-approval-controller-3-5-2\ ++* Run "yarn build" in the core monorepo\ ++* Run "yarn patch:approval " in the mobile repo\ ++* Once the new patch is merged, add your changes to: patch/mobile-approval-controller-3-5-2' + +COMMENT_DIFF='diff --git a/node_modules/@metamask/approval-controller/dist/.patch.txt b/node_modules/@metamask/approval-controller/dist/.patch.txt\ +new file mode 100644\ +index 0000000..550de56\ +--- /dev/null\ ++++ b/node_modules/@metamask/approval-controller/dist/.patch.txt\ +@@ -0,0 +1,'"$COMMENT_LINE_COUNT"' @@\ +'"$COMMENT" + +CORE_DIR="$1" + +if [ -z "$CORE_DIR" ] ; then + echo "Usage: yarn patch:approval " + echo "" + echo "Example: yarn patch:approval ../core" + exit 1 +fi + +DIST_DIR_CORE="$CORE_DIR/packages/approval-controller/dist" + +rm -rf "$DIST_DIR_MOBILE" +cp -r "$DIST_DIR_CORE" "$PACKAGE_DIR_MOBILE" + +rm -f "$DIST_DIR_MOBILE"/*.map +rm -rf "$DIST_DIR_MOBILE/mocks" + +yarn patch-package "$PACKAGE" + +NEW_LINE=$'\n' + +# ShellCheck disabled as intentionally not using quotes as PATCH_FILE relies on globbing + +#shellcheck disable=SC2086 +sed -i.bak "1i\\$NEW_LINE$COMMENT_DIFF$NEW_LINE" $PATCH_FILE + +#shellcheck disable=SC2086 +rm $PATCH_FILE.bak diff --git a/scripts/patch-transaction-controller.sh b/scripts/patch-transaction-controller.sh index 285929521be3..34b65be6f3a9 100755 --- a/scripts/patch-transaction-controller.sh +++ b/scripts/patch-transaction-controller.sh @@ -20,13 +20,13 @@ DIST_DIR_MOBILE="$PACKAGE_DIR_MOBILE/dist" PATCH_FILE="patches/@metamask+transaction-controller+*.patch" COMMENT_LINE_COUNT=7 -COMMENT='+PATCH GENERATED FROM MetaMask/core branch: patch/mobile-transaction-controller-8-0-1\ +COMMENT='+PATCH GENERATED FROM MetaMask/core branch: patch/mobile-transaction-controller-13-0-0\ +This patch backports various transaction controller features from the main branch of MetaMask/core\ +Steps to update patch:\ -+* Create a new core branch from: patch/mobile-transaction-controller-8-0-1\ ++* Create a new core branch from: patch/mobile-transaction-controller-13-0-0\ +* Run "yarn build" in the core monorepo\ +* Run "yarn patch:tx " in the mobile repo\ -+* Once the new patch is merged, add your changes to: patch/mobile-transaction-controller-8-0-1' ++* Once the new patch is merged, add your changes to: patch/mobile-transaction-controller-13-0-0' COMMENT_DIFF='diff --git a/node_modules/@metamask/transaction-controller/dist/.patch.txt b/node_modules/@metamask/transaction-controller/dist/.patch.txt\ new file mode 100644\ diff --git a/yarn.lock b/yarn.lock index 69517950890a..d09744901a8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3607,18 +3607,7 @@ "@metamask/controller-utils" "^6.0.0" "@metamask/utils" "^8.2.0" -"@metamask/approval-controller@3.5.0": - version "3.5.0" - resolved "https://registry.yarnpkg.com/@metamask/approval-controller/-/approval-controller-3.5.0.tgz#07295ccac0006e005db74fd734a16eec6f22f0da" - integrity sha512-qrPn0uuNgQEQ9Nk5A6tRtDjZB6PkPB5IeZRyVcvD8H1KaGswAdm7ZPp0t+jJ2wDeS6wjImYeplUNkhThDqUERA== - dependencies: - "@metamask/base-controller" "^3.2.0" - "@metamask/utils" "^6.2.0" - eth-rpc-errors "^4.0.2" - immer "^9.0.6" - nanoid "^3.1.31" - -"@metamask/approval-controller@^3.5.0", "@metamask/approval-controller@^3.5.1": +"@metamask/approval-controller@^3.5.1", "@metamask/approval-controller@^3.5.2": version "3.5.2" resolved "https://registry.yarnpkg.com/@metamask/approval-controller/-/approval-controller-3.5.2.tgz#c8ca4578f053d719bff82b0c9fa1939d21978d46" integrity sha512-5jYMtPexeeNL8m+5Mzhayr1l367MbbBs0Wf+FBeL/xLv6nSNqvvNs/CXfvkqxLDZJKIgBCBPKg7eIu1U6MJ6ag== @@ -3679,7 +3668,7 @@ single-call-balance-checker-abi "^1.0.0" uuid "^8.3.2" -"@metamask/base-controller@^3.0.0", "@metamask/base-controller@^3.2.0", "@metamask/base-controller@^3.2.1", "@metamask/base-controller@^3.2.2", "@metamask/base-controller@^3.2.3": +"@metamask/base-controller@^3.0.0", "@metamask/base-controller@^3.2.1", "@metamask/base-controller@^3.2.2", "@metamask/base-controller@^3.2.3": version "3.2.3" resolved "https://registry.yarnpkg.com/@metamask/base-controller/-/base-controller-3.2.3.tgz#7436a14f6789acf0814952dabaa70ee4fb7d473c" integrity sha512-k66oZe7BOEx0D5N5X8feE/32QlrUTmiEHHAZU/yCac2+VHllJOCEQV/cTeaAtgepnEf8O7SskvYZN+eIjgS99w== @@ -3722,29 +3711,29 @@ resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-2.2.0.tgz#277764d0d56e37180ae7644a9d11eb96295b36fc" integrity sha512-SM6A4C7vXNbVpgMTX67kfW8QWvu3eSXxMZlY5PqZBTkvri1s9zgQ0uwRkK5r2VXNEoVmXCDnnEX/tX5EzzgNUQ== -"@metamask/controller-utils@^4.3.1", "@metamask/controller-utils@^5.0.0", "@metamask/controller-utils@^5.0.2": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@metamask/controller-utils/-/controller-utils-5.0.2.tgz#f6e848d9b80aca7943e1edae927324982305d1f8" - integrity sha512-bHgyPL+Ah6OBOkjWykA1NpTZdpRhoJjCrvuFf8mFxBJLvXE9m/rw9DYp2Rw9WXonMWK17NxwQv/7bKzsGZnjVQ== +"@metamask/controller-utils@^4.3.2": + version "4.3.2" + resolved "https://registry.yarnpkg.com/@metamask/controller-utils/-/controller-utils-4.3.2.tgz#e11fda4b2d38b96925891410665b57efcf41e07d" + integrity sha512-QlBUfUbexB+7IXHtZzFVYqKUvQEvktCHoDrzkXN8pjCbjm4sZtB6Lh47O0QSyoPR3dT77mphTz3GktjmfzskbA== dependencies: "@metamask/eth-query" "^3.0.1" - "@metamask/utils" "^8.1.0" + "@metamask/utils" "^6.2.0" "@spruceid/siwe-parser" "1.1.3" eth-ens-namehash "^2.0.8" + eth-rpc-errors "^4.0.2" ethereumjs-util "^7.0.10" ethjs-unit "^0.1.6" fast-deep-equal "^3.1.3" -"@metamask/controller-utils@^4.3.2": - version "4.3.2" - resolved "https://registry.yarnpkg.com/@metamask/controller-utils/-/controller-utils-4.3.2.tgz#e11fda4b2d38b96925891410665b57efcf41e07d" - integrity sha512-QlBUfUbexB+7IXHtZzFVYqKUvQEvktCHoDrzkXN8pjCbjm4sZtB6Lh47O0QSyoPR3dT77mphTz3GktjmfzskbA== +"@metamask/controller-utils@^5.0.0", "@metamask/controller-utils@^5.0.1", "@metamask/controller-utils@^5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@metamask/controller-utils/-/controller-utils-5.0.2.tgz#f6e848d9b80aca7943e1edae927324982305d1f8" + integrity sha512-bHgyPL+Ah6OBOkjWykA1NpTZdpRhoJjCrvuFf8mFxBJLvXE9m/rw9DYp2Rw9WXonMWK17NxwQv/7bKzsGZnjVQ== dependencies: "@metamask/eth-query" "^3.0.1" - "@metamask/utils" "^6.2.0" + "@metamask/utils" "^8.1.0" "@spruceid/siwe-parser" "1.1.3" eth-ens-namehash "^2.0.8" - eth-rpc-errors "^4.0.2" ethereumjs-util "^7.0.10" ethjs-unit "^0.1.6" fast-deep-equal "^3.1.3" @@ -4129,18 +4118,23 @@ resolved "https://registry.yarnpkg.com/@metamask/metamask-eth-abis/-/metamask-eth-abis-3.0.0.tgz#eccc0746b3ab1ab63000444403819c16e88b5272" integrity sha512-YtIl4e1VzqwwHGafuLIVPqbcWWWqQ0Ezo8/Ci5m5OGllqE2oTTx9iVHdUmXNkgCVD37SBfwn/fm/S1IGkM8BQA== +"@metamask/metamask-eth-abis@^3.0.0": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@metamask/metamask-eth-abis/-/metamask-eth-abis-3.1.1.tgz#3de904511115c488809ddee25c470332c03db531" + integrity sha512-lRUyWN/GrIFQlT0wq/9gB+4wIV2i0N6yAQlJhfLCT6bVfK5GI5IUDxvCyLTDvxQxaLpNgtBFFzbuY1iVj3UWLA== + "@metamask/mobile-provider@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@metamask/mobile-provider/-/mobile-provider-3.0.0.tgz#8a6a5a0874c8cbe4b468f63dfc57117d207f9595" integrity sha512-XwFJk0rd9lAZR5xS3VC7ypEhD7DvZR2gi2Ch6PHnODIqeS9Te3OdVKK5+jHI4his8v/zs6LWdFdlRtx5/jL96w== -"@metamask/network-controller@^12.0.0": - version "12.2.0" - resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-12.2.0.tgz#679d81e009cfd2b9fdaf884267d7a11b535f1922" - integrity sha512-MBsEOy8htQtN46s/pbmEPsfe+UyOe3aUGTeswG0Iy0qGKyqu+uEx/nhydaLpMHFlOLbboPWtUmnPRLFE9pQDEA== +"@metamask/network-controller@^13.0.1": + version "13.0.1" + resolved "https://registry.yarnpkg.com/@metamask/network-controller/-/network-controller-13.0.1.tgz#b8d3cd4abe8e03a8d030409588da6f05461955c5" + integrity sha512-stoS3Dj4b3B8M6dCFs0uE7Zz1Y535yeSUJxJQ12v2t1OlB4JfV5mNL67SJR8h+efR+t336H3EujxevEiW32CVA== dependencies: - "@metamask/base-controller" "^3.2.1" - "@metamask/controller-utils" "^4.3.2" + "@metamask/base-controller" "^3.2.2" + "@metamask/controller-utils" "^5.0.1" "@metamask/eth-json-rpc-infura" "^8.1.1" "@metamask/eth-json-rpc-middleware" "^11.0.2" "@metamask/eth-json-rpc-provider" "^1.0.0" @@ -4621,23 +4615,27 @@ resolved "https://registry.yarnpkg.com/@metamask/test-dapp/-/test-dapp-8.0.0.tgz#72f64b18a6157400ef3a3901c35819883524a048" integrity sha512-yy1eZ9fZfJSEJIUjqcigBehFv6vdPGmDkVnzpBpEJqxiMPZGnbR5dypMfo0XsPdp5Lvmawx47Kamuy4Ocsy+iw== -"@metamask/transaction-controller@8.0.1": - version "8.0.1" - resolved "https://registry.yarnpkg.com/@metamask/transaction-controller/-/transaction-controller-8.0.1.tgz#fa56023d8f8ab65806343cf1cfcd8feeb0dfd6bc" - integrity sha512-vTshHPkuEGKBh9mmNSu1wadd9F2BTMIIANUAdK6IPl52f+4vtC1cJ4ele23CiJAAuLHdmnEZsVIDq7/HoCt7gA== +"@metamask/transaction-controller@^13.0.0": + version "13.0.0" + resolved "https://registry.yarnpkg.com/@metamask/transaction-controller/-/transaction-controller-13.0.0.tgz#7ad704900199f4bac4c299c6e1c2c26c5e1d0818" + integrity sha512-/ptn2605x42ysDfQcuZKhZ6pwouUOALQDlhLp4o2th8pt28ppMjPleXbbGxyu1qP8Truz49RTPFWTy2THrqiZQ== dependencies: "@ethereumjs/common" "^3.2.0" "@ethereumjs/tx" "^4.2.0" - "@metamask/approval-controller" "^3.5.0" - "@metamask/base-controller" "^3.2.0" - "@metamask/controller-utils" "^4.3.1" + "@ethersproject/abi" "^5.7.0" + "@metamask/approval-controller" "^3.5.2" + "@metamask/base-controller" "^3.2.2" + "@metamask/controller-utils" "^5.0.1" "@metamask/eth-query" "^3.0.1" - "@metamask/network-controller" "^12.0.0" + "@metamask/metamask-eth-abis" "^3.0.0" + "@metamask/network-controller" "^13.0.1" + "@metamask/rpc-errors" "^6.0.0" "@metamask/utils" "^6.2.0" async-mutex "^0.2.6" eth-method-registry "1.1.0" - eth-rpc-errors "^4.0.2" ethereumjs-util "^7.0.10" + fast-json-patch "^3.1.1" + lodash "^4.17.21" nonce-tracker "^1.1.0" uuid "^8.3.2" @@ -16566,6 +16564,11 @@ fast-glob@^3.2.11, fast-glob@^3.2.9: merge2 "^1.3.0" micromatch "^4.0.4" +fast-json-patch@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/fast-json-patch/-/fast-json-patch-3.1.1.tgz#85064ea1b1ebf97a3f7ad01e23f9337e72c66947" + integrity sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ== + fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"