@metamask-previews/bridge-status-controller 76.4.0-preview-686aaf7 → 76.4.0-preview-51ecba2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bridge-status-controller.d.ts.map +1 -1
  3. package/dist/bridge-status-controller.js +78 -40
  4. package/dist/bridge-status-controller.js.map +1 -1
  5. package/dist/strategy/batch-sell-strategy.d.ts.map +1 -1
  6. package/dist/strategy/batch-sell-strategy.js +62 -34
  7. package/dist/strategy/batch-sell-strategy.js.map +1 -1
  8. package/dist/strategy/batch-strategy.d.ts.map +1 -1
  9. package/dist/strategy/batch-strategy.js +38 -13
  10. package/dist/strategy/batch-strategy.js.map +1 -1
  11. package/dist/strategy/evm-strategy.d.ts +2 -28
  12. package/dist/strategy/evm-strategy.d.ts.map +1 -1
  13. package/dist/strategy/evm-strategy.js +62 -39
  14. package/dist/strategy/evm-strategy.js.map +1 -1
  15. package/dist/strategy/intent-strategy.d.ts.map +1 -1
  16. package/dist/strategy/intent-strategy.js +2 -1
  17. package/dist/strategy/intent-strategy.js.map +1 -1
  18. package/dist/strategy/types.d.ts +3 -2
  19. package/dist/strategy/types.d.ts.map +1 -1
  20. package/dist/strategy/types.js.map +1 -1
  21. package/dist/types.d.ts +1 -2
  22. package/dist/types.d.ts.map +1 -1
  23. package/dist/types.js.map +1 -1
  24. package/dist/utils/history.d.ts +2 -2
  25. package/dist/utils/history.d.ts.map +1 -1
  26. package/dist/utils/history.js +64 -25
  27. package/dist/utils/history.js.map +1 -1
  28. package/dist/utils/metrics.d.ts +2 -33
  29. package/dist/utils/metrics.d.ts.map +1 -1
  30. package/dist/utils/metrics.js.map +1 -1
  31. package/dist/utils/transaction.d.ts +2 -0
  32. package/dist/utils/transaction.d.ts.map +1 -1
  33. package/dist/utils/transaction.js +16 -4
  34. package/dist/utils/transaction.js.map +1 -1
  35. package/package.json +1 -1
@@ -1 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QAChC,iBAAiB,EAAE,EAAE;QACrB,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE,KAAK;QACnB,iBAAiB,EAAE,KAAK;QACxB,mBAAmB,EAAE,CAAC;QACtB,iBAAiB,EAAE,CAAC;QACpB,QAAQ,EAAE,EAA2B;QACrC,mBAAmB,EAAE,CAAC;QACtB,wBAAwB,EAAE,CAAC;QAC3B,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,CAAC;QACjB,WAAW,EAAE,iBAAiB,CAAC,aAAa;QAC5C,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,GAAG,yBAAyB,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC;QAC7D,aAAa,EAAE,eAAe,CAAC,IAAI;YACjC,CAAC,CAAC,YAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,YAAY,CAAC,SAAS;QAC1B,UAAU,EAAE,eAAe,CAAC,KAAK;YAC/B,CAAC,CAAC,mBAAmB,CAAC,OAAO;YAC7B,CAAC,CAAC,mBAAmB,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable camelcase */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport {\n StatusTypes,\n getAccountHardwareType,\n formatChainIdToHex,\n isEthUsdt,\n formatChainIdToCaip,\n formatProviderLabel,\n isCustomSlippage,\n getSwapType,\n formatAddressToAssetId,\n MetricsActionType,\n MetricsSwapType,\n MetaMetricsSwapsEventSource,\n FeatureId,\n UnifiedSwapBridgeEventName,\n FailurePhase,\n SwapBridgeErrorCode,\n} from '@metamask/bridge-controller';\nimport type {\n AccountHardwareType,\n QuoteFetchData,\n QuoteMetadata,\n QuoteResponseV1,\n TxStatusData,\n RequestParams,\n TradeData,\n RequestMetadata,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types.js';\nimport { calcActualGasUsed } from './gas.js';\nimport {\n getActualBridgeReceivedAmount,\n getActualSwapReceivedAmount,\n} from './swap-received-amount.js';\n\n/**\n * Classify a thrown value from submit (sign/broadcast) catch paths.\n *\n * @param error - The thrown value from submit.\n * @returns The Mixpanel `error_code`.\n */\nexport const getSubmitErrorCode = (error: unknown): SwapBridgeErrorCode => {\n if (error === undefined || error === null) {\n return SwapBridgeErrorCode.MissingErrorObject;\n }\n if (error instanceof Error) {\n return SwapBridgeErrorCode.Unknown;\n }\n return SwapBridgeErrorCode.NonErrorRejection;\n};\n\n/**\n * @param sourceHash - Source tx hash if known at emit time.\n * @param destinationHash - Destination tx hash if known at emit time.\n * @returns Boolean hash-presence properties.\n */\nexport const getHashPresenceProperties = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): HashPresenceProperties => {\n return {\n source_hash_present: Boolean(sourceHash),\n destination_hash_present: Boolean(destinationHash),\n };\n};\n\n/**\n * Prefer destination_execution over source_execution over poll.\n *\n * @param hashPresence - Hash presence at emit time.\n * @returns The Mixpanel `failure_phase` for a status/polling Failed event.\n */\nexport const getStatusFailurePhase = (\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (hashPresence.source_hash_present) {\n return FailurePhase.SourceExecution;\n }\n return FailurePhase.Poll;\n};\n\n/**\n * Align `failure_phase` with combined hash presence without turning a\n * no-hash `broadcast` failure into `poll`.\n *\n * @param phase - Phase from the emitting path.\n * @param hashPresence - Combined history + caller hash flags.\n * @returns The Mixpanel `failure_phase`.\n */\nexport const promoteFailurePhase = (\n phase: FailurePhase,\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (\n hashPresence.source_hash_present &&\n (phase === FailurePhase.Broadcast ||\n phase === FailurePhase.Poll ||\n phase === FailurePhase.Unknown)\n ) {\n return FailurePhase.SourceExecution;\n }\n return phase;\n};\n\n/**\n * Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).\n *\n * @param error - The thrown value from the submit/broadcast catch.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getBroadcastFailureProperties = (\n error: unknown,\n): FailureTelemetryProperties => {\n return {\n failure_phase: FailurePhase.Broadcast,\n error_code: getSubmitErrorCode(error),\n source_hash_present: false,\n destination_hash_present: false,\n };\n};\n\n/**\n * Mixpanel properties for Failed events derived from history hashes.\n *\n * Used for poll Failed and TransactionController Failed once a history\n * item exists. Not poll-only.\n *\n * @param sourceHash - Source tx hash from history if known.\n * @param destinationHash - Destination tx hash from history if known.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getFailurePropertiesFromHistory = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): FailureTelemetryProperties => {\n const hashPresence = getHashPresenceProperties(sourceHash, destinationHash);\n return {\n ...hashPresence,\n failure_phase: getStatusFailurePhase(hashPresence),\n error_code: SwapBridgeErrorCode.StatusFailedWithoutReason,\n };\n};\n\nexport const getTxStatusesFromHistory = ({\n status,\n hasApprovalTx,\n approvalTxId,\n quote,\n}: BridgeHistoryItem): TxStatusData => {\n const source_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n const destination_transaction = status.destChain?.txHash\n ? status.status\n : StatusTypes.PENDING;\n\n const hexChainId = formatChainIdToHex(quote.srcChainId);\n const isEthUsdtTx = isEthUsdt(hexChainId, quote.srcAsset.address);\n const allowance_reset_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : undefined;\n const approval_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n\n return {\n allowance_reset_transaction: isEthUsdtTx\n ? allowance_reset_transaction\n : undefined,\n approval_transaction:\n hasApprovalTx || approvalTxId ? approval_transaction : undefined,\n source_transaction,\n destination_transaction:\n status.status === StatusTypes.FAILED\n ? StatusTypes.FAILED\n : destination_transaction,\n };\n};\n\n/**\n * Calculate the properties for a finalized transaction event based on the txHistory\n * and txMeta\n *\n * @param historyItem - The bridge history item\n * @param txMeta - The transaction meta from the TransactionController\n * @param approvalTxMeta - The approval transaction meta from the TransactionController\n * @returns The properties for the finalized transaction\n */\nexport const getFinalizedTxProperties = (\n historyItem: BridgeHistoryItem,\n txMeta?: TransactionMeta,\n approvalTxMeta?: TransactionMeta,\n) => {\n const startTime =\n approvalTxMeta?.submittedTime ??\n txMeta?.submittedTime ??\n historyItem.startTime;\n const completionTime =\n txMeta?.type === TransactionType.swap\n ? txMeta?.time\n : historyItem.completionTime;\n\n const actualGas = calcActualGasUsed(\n historyItem,\n txMeta?.txReceipt,\n approvalTxMeta?.txReceipt,\n );\n\n const actualReturn =\n txMeta?.type === TransactionType.swap\n ? getActualSwapReceivedAmount(historyItem, actualGas, txMeta)\n : getActualBridgeReceivedAmount(historyItem);\n\n const quotedVsUsedGasRatio =\n historyItem.pricingData?.quotedGasAmount && actualGas?.amount\n ? new BigNumber(historyItem.pricingData.quotedGasAmount)\n .multipliedBy(new BigNumber(10).pow(18))\n .div(actualGas.amount)\n .toNumber()\n : 0;\n\n const quoteVsExecutionRatio =\n historyItem.pricingData?.quotedReturnInUsd && actualReturn?.usd\n ? new BigNumber(historyItem.pricingData.quotedReturnInUsd)\n .div(actualReturn.usd)\n .toNumber()\n : 0;\n\n return {\n actual_time_minutes:\n completionTime && startTime ? (completionTime - startTime) / 60000 : 0,\n usd_actual_return: Number(actualReturn?.usd ?? 0),\n usd_actual_gas: actualGas?.usd ?? 0,\n quote_vs_execution_ratio: quoteVsExecutionRatio,\n quoted_vs_used_gas_ratio: quotedVsUsedGasRatio,\n };\n};\n\nexport const getRequestParamFromHistory = (\n historyItem: BridgeHistoryItem,\n): RequestParams => {\n return {\n chain_id_source: formatChainIdToCaip(historyItem.quote.srcChainId),\n token_symbol_source: historyItem.quote.srcAsset.symbol,\n token_address_source: historyItem.quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(historyItem.quote.destChainId),\n token_symbol_destination: historyItem.quote.destAsset.symbol,\n token_address_destination: historyItem.quote.destAsset.assetId,\n token_security_type_destination:\n historyItem.tokenSecurityTypeDestination ?? null,\n };\n};\n\nexport const getTradeDataFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n batchSellTrades?: BatchSellTradesResponse | null,\n): TradeData => {\n return {\n usd_quoted_gas: Number(quoteResponse.gasFee?.total?.usd ?? 0),\n gas_included:\n quoteResponse.quote.gasIncluded ?? batchSellTrades?.gasIncluded ?? false,\n gas_included_7702:\n quoteResponse.quote.gasIncluded7702 ??\n batchSellTrades?.gasIncluded7702 ??\n false,\n provider: formatProviderLabel(quoteResponse.quote),\n quoted_time_minutes: Number(\n quoteResponse.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(quoteResponse?.adjustedReturn?.usd ?? 0),\n };\n};\n\nexport const getPriceImpactFromQuote = (\n quote: QuoteResponseV1['quote'],\n): Pick<QuoteFetchData, 'price_impact'> => {\n return { price_impact: Number(quote.priceData?.priceImpact ?? '0') };\n};\n\n/**\n * Before the tx is confirmed, its data is not available in txHistory\n * The quote is used to populate event properties before confirmation\n *\n * @param quoteResponse - The quote response\n * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension\n * @param accountHardwareType - The hardware wallet type used to submit the tx, or null if not a hardware wallet\n * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)\n * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)\n * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target)\n * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.\n * @param batchSellTrades - The batch sell trades response\n * @param batchId - The batch ID of the transaction batch.\n * @param quotesReceivedContext - The client context captured when quotes were received.\n * @returns The properties for the pre-confirmation event\n */\nexport const getPreConfirmationPropertiesFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n isStxEnabled: boolean,\n accountHardwareType: AccountHardwareType,\n location?: MetaMetricsSwapsEventSource,\n abTests?: Record<string, string>,\n activeAbTests?: { key: string; value: string }[],\n tokenSecurityTypeDestination?: string | null,\n batchSellTrades?: BatchSellTradesResponse | null,\n batchId?: Hex,\n quotesReceivedContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n) => {\n const { quote } = quoteResponse;\n return {\n ...getPriceImpactFromQuote(quote),\n ...getTradeDataFromQuote(quoteResponse, batchSellTrades),\n chain_id_source: formatChainIdToCaip(quote.srcChainId),\n token_symbol_source: quote.srcAsset.symbol,\n token_address_source: quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(quote.destChainId),\n token_symbol_destination: quote.destAsset.symbol,\n token_address_destination: quote.destAsset.assetId,\n token_security_type_destination: tokenSecurityTypeDestination ?? null,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type: getSwapType(\n quoteResponse.quote.srcChainId,\n quoteResponse.quote.destChainId,\n ),\n usd_amount_source: Number(quoteResponse?.sentAmount?.usd ?? 0),\n stx_enabled: isStxEnabled,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n slippage_limit:\n quotesReceivedContext?.slippage_limit ?? quote.slippage ?? 0,\n custom_slippage: quotesReceivedContext?.custom_slippage ?? false,\n location,\n ...(abTests &&\n Object.keys(abTests).length > 0 && {\n ab_tests: abTests,\n }),\n ...(activeAbTests &&\n activeAbTests.length > 0 && {\n active_ab_tests: activeAbTests,\n }),\n ...(batchId ? { batch_id: batchId } : {}),\n feature_id: quoteResponse.featureId ?? FeatureId.UNIFIED_SWAP_BRIDGE,\n };\n};\n\nexport const getTradeDataFromHistory = (\n historyItem: BridgeHistoryItem,\n): TradeData => {\n return {\n usd_quoted_gas: Number(historyItem.pricingData?.quotedGasInUsd ?? 0),\n gas_included: historyItem.quote.gasIncluded ?? false,\n gas_included_7702: historyItem.quote.gasIncluded7702 ?? false,\n provider: formatProviderLabel(historyItem.quote),\n quoted_time_minutes: Number(\n historyItem.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(historyItem.pricingData?.quotedReturnInUsd ?? 0),\n };\n};\n\nexport const getRequestMetadataFromHistory = (\n historyItem: BridgeHistoryItem,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n): RequestMetadata => {\n const {\n quote,\n slippagePercentage,\n isStxEnabled,\n customSlippage,\n batchSellData,\n featureId,\n } = historyItem;\n const accountHardwareType = getAccountHardwareType(account);\n const isBatchSell =\n Boolean(batchSellData) || featureId === FeatureId.BATCH_SELL;\n const isUnifiedSwapBridge =\n featureId === undefined || featureId === FeatureId.UNIFIED_SWAP_BRIDGE;\n let inferredCustomSlippage = false;\n if (isBatchSell) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage ?? 0);\n } else if (!isUnifiedSwapBridge) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage);\n }\n\n return {\n slippage_limit: slippagePercentage ?? 0,\n custom_slippage: customSlippage ?? inferredCustomSlippage,\n usd_amount_source: Number(historyItem.pricingData?.amountSentInUsd ?? 0),\n swap_type: getSwapType(quote.srcChainId, quote.destChainId),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n stx_enabled: isStxEnabled ?? false,\n security_warnings: [],\n };\n};\n\n/**\n * Get the properties for a swap transaction that is not in the txHistory\n *\n * @param transactionMeta - The transaction meta\n * @param account - The account that submitted the transaction\n * @returns The properties for the swap transaction\n */\nexport const getEVMTxPropertiesFromTransactionMeta = (\n transactionMeta: TransactionMeta,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const accountHardwareType = getAccountHardwareType(account);\n\n return {\n source_transaction: [\n TransactionStatus.failed,\n TransactionStatus.dropped,\n TransactionStatus.rejected,\n ].includes(transactionMeta.status)\n ? StatusTypes.FAILED\n : StatusTypes.COMPLETE,\n error_message: [\n `Transaction ${transactionMeta.status}`,\n transactionMeta.error?.message,\n ]\n .filter(Boolean)\n .join('. '),\n chain_id_source: formatChainIdToCaip(transactionMeta.chainId),\n chain_id_destination: formatChainIdToCaip(transactionMeta.chainId),\n token_symbol_source: transactionMeta.sourceTokenSymbol ?? '',\n token_symbol_destination: transactionMeta.destinationTokenSymbol ?? '',\n usd_amount_source: 0,\n slippage_limit: 0,\n stx_enabled: false,\n token_address_source:\n formatAddressToAssetId(\n transactionMeta.sourceTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_address_destination:\n formatAddressToAssetId(\n transactionMeta.destinationTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_security_type_destination: null,\n custom_slippage: false,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type:\n transactionMeta.type &&\n [TransactionType.swap, TransactionType.swapApproval].includes(\n transactionMeta.type,\n )\n ? MetricsSwapType.SINGLE\n : MetricsSwapType.CROSSCHAIN,\n security_warnings: [],\n price_impact: 0,\n usd_quoted_gas: 0,\n gas_included: false,\n gas_included_7702: false,\n quoted_time_minutes: 0,\n usd_quoted_return: 0,\n provider: '' as `${string}_${string}`,\n actual_time_minutes: 0,\n quote_vs_execution_ratio: 0,\n quoted_vs_used_gas_ratio: 0,\n usd_actual_return: 0,\n usd_actual_gas: 0,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n ...(transactionMeta.batchId ? { batch_id: transactionMeta.batchId } : {}),\n ...getHashPresenceProperties(transactionMeta.hash, undefined),\n failure_phase: transactionMeta.hash\n ? FailurePhase.SourceExecution\n : FailurePhase.Broadcast,\n error_code: transactionMeta.error\n ? SwapBridgeErrorCode.Unknown\n : SwapBridgeErrorCode.MissingErrorObject,\n };\n};\n"]}
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EAEf,SAAS,EAET,YAAY,EACZ,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAerC,OAAO,EACL,iBAAiB,EACjB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAuB,EAAE;IACxE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,mBAAmB,CAAC,kBAAkB,CAAC;IAChD,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,mBAAmB,CAAC,OAAO,CAAC;IACrC,CAAC;IACD,OAAO,mBAAmB,CAAC,iBAAiB,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAA0B,EAC1B,eAA+B,EACP,EAAE;IAC1B,OAAO;QACL,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC;QACx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EACP,eAAe,CAAC,IAAI;YACpB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC,QAAQ,CAC3D,eAAe,CAAC,IAAI,CACrB;YACC,CAAC,CAAC,eAAe,CAAC,MAAM;YACxB,CAAC,CAAC,eAAe,CAAC,UAAU;QAChC,iBAAiB,EAAE,EAAE;QACrB,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE,KAAK;QACnB,iBAAiB,EAAE,KAAK;QACxB,mBAAmB,EAAE,CAAC;QACtB,iBAAiB,EAAE,CAAC;QACpB,QAAQ,EAAE,EAA2B;QACrC,mBAAmB,EAAE,CAAC;QACtB,wBAAwB,EAAE,CAAC;QAC3B,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,CAAC;QACjB,WAAW,EAAE,iBAAiB,CAAC,aAAa;QAC5C,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,GAAG,yBAAyB,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC;QAC7D,aAAa,EAAE,eAAe,CAAC,IAAI;YACjC,CAAC,CAAC,YAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,YAAY,CAAC,SAAS;QAC1B,UAAU,EAAE,eAAe,CAAC,KAAK;YAC/B,CAAC,CAAC,mBAAmB,CAAC,OAAO;YAC7B,CAAC,CAAC,mBAAmB,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable camelcase */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport {\n StatusTypes,\n getAccountHardwareType,\n formatChainIdToHex,\n isEthUsdt,\n formatChainIdToCaip,\n formatProviderLabel,\n isCustomSlippage,\n getSwapType,\n formatAddressToAssetId,\n MetricsActionType,\n MetricsSwapType,\n MetaMetricsSwapsEventSource,\n FeatureId,\n UnifiedSwapBridgeEventName,\n FailurePhase,\n SwapBridgeErrorCode,\n} from '@metamask/bridge-controller';\nimport type {\n AccountHardwareType,\n QuoteFetchData,\n QuoteMetadata,\n QuoteResponseV1,\n TxStatusData,\n RequestParams,\n TradeData,\n RequestMetadata,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types.js';\nimport { calcActualGasUsed } from './gas.js';\nimport {\n getActualBridgeReceivedAmount,\n getActualSwapReceivedAmount,\n} from './swap-received-amount.js';\n\n/**\n * Classify a thrown value from submit (sign/broadcast) catch paths.\n *\n * @param error - The thrown value from submit.\n * @returns The Mixpanel `error_code`.\n */\nexport const getSubmitErrorCode = (error: unknown): SwapBridgeErrorCode => {\n if (error === undefined || error === null) {\n return SwapBridgeErrorCode.MissingErrorObject;\n }\n if (error instanceof Error) {\n return SwapBridgeErrorCode.Unknown;\n }\n return SwapBridgeErrorCode.NonErrorRejection;\n};\n\n/**\n * @param sourceHash - Source tx hash if known at emit time.\n * @param destinationHash - Destination tx hash if known at emit time.\n * @returns Boolean hash-presence properties.\n */\nexport const getHashPresenceProperties = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): HashPresenceProperties => {\n return {\n source_hash_present: Boolean(sourceHash),\n destination_hash_present: Boolean(destinationHash),\n };\n};\n\n/**\n * Prefer destination_execution over source_execution over poll.\n *\n * @param hashPresence - Hash presence at emit time.\n * @returns The Mixpanel `failure_phase` for a status/polling Failed event.\n */\nexport const getStatusFailurePhase = (\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (hashPresence.source_hash_present) {\n return FailurePhase.SourceExecution;\n }\n return FailurePhase.Poll;\n};\n\n/**\n * Align `failure_phase` with combined hash presence without turning a\n * no-hash `broadcast` failure into `poll`.\n *\n * @param phase - Phase from the emitting path.\n * @param hashPresence - Combined history + caller hash flags.\n * @returns The Mixpanel `failure_phase`.\n */\nexport const promoteFailurePhase = (\n phase: FailurePhase,\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (\n hashPresence.source_hash_present &&\n (phase === FailurePhase.Broadcast ||\n phase === FailurePhase.Poll ||\n phase === FailurePhase.Unknown)\n ) {\n return FailurePhase.SourceExecution;\n }\n return phase;\n};\n\n/**\n * Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).\n *\n * @param error - The thrown value from the submit/broadcast catch.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getBroadcastFailureProperties = (\n error: unknown,\n): FailureTelemetryProperties => {\n return {\n failure_phase: FailurePhase.Broadcast,\n error_code: getSubmitErrorCode(error),\n source_hash_present: false,\n destination_hash_present: false,\n };\n};\n\n/**\n * Mixpanel properties for Failed events derived from history hashes.\n *\n * Used for poll Failed and TransactionController Failed once a history\n * item exists. Not poll-only.\n *\n * @param sourceHash - Source tx hash from history if known.\n * @param destinationHash - Destination tx hash from history if known.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getFailurePropertiesFromHistory = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): FailureTelemetryProperties => {\n const hashPresence = getHashPresenceProperties(sourceHash, destinationHash);\n return {\n ...hashPresence,\n failure_phase: getStatusFailurePhase(hashPresence),\n error_code: SwapBridgeErrorCode.StatusFailedWithoutReason,\n };\n};\n\nexport const getTxStatusesFromHistory = ({\n status,\n hasApprovalTx,\n approvalTxId,\n quote,\n}: BridgeHistoryItem): TxStatusData => {\n const source_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n const destination_transaction = status.destChain?.txHash\n ? status.status\n : StatusTypes.PENDING;\n\n const hexChainId = formatChainIdToHex(quote.srcChainId);\n const isEthUsdtTx = isEthUsdt(hexChainId, quote.srcAsset.address);\n const allowance_reset_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : undefined;\n const approval_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n\n return {\n allowance_reset_transaction: isEthUsdtTx\n ? allowance_reset_transaction\n : undefined,\n approval_transaction:\n hasApprovalTx || approvalTxId ? approval_transaction : undefined,\n source_transaction,\n destination_transaction:\n status.status === StatusTypes.FAILED\n ? StatusTypes.FAILED\n : destination_transaction,\n };\n};\n\n/**\n * Calculate the properties for a finalized transaction event based on the txHistory\n * and txMeta\n *\n * @param historyItem - The bridge history item\n * @param txMeta - The transaction meta from the TransactionController\n * @param approvalTxMeta - The approval transaction meta from the TransactionController\n * @returns The properties for the finalized transaction\n */\nexport const getFinalizedTxProperties = (\n historyItem: BridgeHistoryItem,\n txMeta?: TransactionMeta,\n approvalTxMeta?: TransactionMeta,\n) => {\n const startTime =\n approvalTxMeta?.submittedTime ??\n txMeta?.submittedTime ??\n historyItem.startTime;\n const completionTime =\n txMeta?.type === TransactionType.swap\n ? txMeta?.time\n : historyItem.completionTime;\n\n const actualGas = calcActualGasUsed(\n historyItem,\n txMeta?.txReceipt,\n approvalTxMeta?.txReceipt,\n );\n\n const actualReturn =\n txMeta?.type === TransactionType.swap\n ? getActualSwapReceivedAmount(historyItem, actualGas, txMeta)\n : getActualBridgeReceivedAmount(historyItem);\n\n const quotedVsUsedGasRatio =\n historyItem.pricingData?.quotedGasAmount && actualGas?.amount\n ? new BigNumber(historyItem.pricingData.quotedGasAmount)\n .multipliedBy(new BigNumber(10).pow(18))\n .div(actualGas.amount)\n .toNumber()\n : 0;\n\n const quoteVsExecutionRatio =\n historyItem.pricingData?.quotedReturnInUsd && actualReturn?.usd\n ? new BigNumber(historyItem.pricingData.quotedReturnInUsd)\n .div(actualReturn.usd)\n .toNumber()\n : 0;\n\n return {\n actual_time_minutes:\n completionTime && startTime ? (completionTime - startTime) / 60000 : 0,\n usd_actual_return: Number(actualReturn?.usd ?? 0),\n usd_actual_gas: actualGas?.usd ?? 0,\n quote_vs_execution_ratio: quoteVsExecutionRatio,\n quoted_vs_used_gas_ratio: quotedVsUsedGasRatio,\n };\n};\n\nexport const getRequestParamFromHistory = (\n historyItem: BridgeHistoryItem,\n): RequestParams => {\n return {\n chain_id_source: formatChainIdToCaip(historyItem.quote.srcChainId),\n token_symbol_source: historyItem.quote.srcAsset.symbol,\n token_address_source: historyItem.quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(historyItem.quote.destChainId),\n token_symbol_destination: historyItem.quote.destAsset.symbol,\n token_address_destination: historyItem.quote.destAsset.assetId,\n token_security_type_destination:\n historyItem.tokenSecurityTypeDestination ?? null,\n };\n};\n\nexport const getTradeDataFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n batchSellTrades?: BatchSellTradesResponse | null,\n): TradeData => {\n return {\n usd_quoted_gas: Number(quoteResponse.gasFee?.total?.usd ?? 0),\n gas_included:\n quoteResponse.quote.gasIncluded ?? batchSellTrades?.gasIncluded ?? false,\n gas_included_7702:\n quoteResponse.quote.gasIncluded7702 ??\n batchSellTrades?.gasIncluded7702 ??\n false,\n provider: formatProviderLabel(quoteResponse.quote),\n quoted_time_minutes: Number(\n quoteResponse.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(quoteResponse?.adjustedReturn?.usd ?? 0),\n };\n};\n\nexport const getPriceImpactFromQuote = (\n quote: QuoteResponseV1['quote'],\n): Pick<QuoteFetchData, 'price_impact'> => {\n return { price_impact: Number(quote.priceData?.priceImpact ?? '0') };\n};\n\n/**\n * Before the tx is confirmed, its data is not available in txHistory\n * The quote is used to populate event properties before confirmation\n *\n * @param quoteResponse - The quote response\n * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension\n * @param accountHardwareType - The hardware wallet type used to submit the tx, or null if not a hardware wallet\n * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)\n * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)\n * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target)\n * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.\n * @param batchSellTrades - The batch sell trades response\n * @param batchId - The batch ID of the transaction batch.\n * @param quotesReceivedContext - The client context captured when quotes were received.\n * @returns The properties for the pre-confirmation event\n */\nexport const getPreConfirmationPropertiesFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n isStxEnabled: boolean,\n accountHardwareType: AccountHardwareType,\n location?: MetaMetricsSwapsEventSource,\n abTests?: Record<string, string>,\n activeAbTests?: { key: string; value: string }[],\n tokenSecurityTypeDestination?: string | null,\n batchSellTrades?: BatchSellTradesResponse | null,\n batchId?: Hex,\n quotesReceivedContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n): RequiredEventContextFromClient[UnifiedSwapBridgeEventName.Submitted] => {\n const { quote } = quoteResponse;\n return {\n ...getPriceImpactFromQuote(quote),\n ...getTradeDataFromQuote(quoteResponse, batchSellTrades),\n chain_id_source: formatChainIdToCaip(quote.srcChainId),\n token_symbol_source: quote.srcAsset.symbol,\n token_address_source: quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(quote.destChainId),\n token_symbol_destination: quote.destAsset.symbol,\n token_address_destination: quote.destAsset.assetId,\n token_security_type_destination: tokenSecurityTypeDestination ?? null,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type: getSwapType(\n quoteResponse.quote.srcChainId,\n quoteResponse.quote.destChainId,\n ),\n usd_amount_source: Number(quoteResponse?.sentAmount?.usd ?? 0),\n stx_enabled: isStxEnabled,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n slippage_limit:\n quotesReceivedContext?.slippage_limit ?? quote.slippage ?? 0,\n custom_slippage: quotesReceivedContext?.custom_slippage ?? false,\n location,\n ...(abTests &&\n Object.keys(abTests).length > 0 && {\n ab_tests: abTests,\n }),\n ...(activeAbTests &&\n activeAbTests.length > 0 && {\n active_ab_tests: activeAbTests,\n }),\n ...(batchId ? { batch_id: batchId } : {}),\n feature_id: quoteResponse.featureId ?? FeatureId.UNIFIED_SWAP_BRIDGE,\n };\n};\n\nexport const getTradeDataFromHistory = (\n historyItem: BridgeHistoryItem,\n): TradeData => {\n return {\n usd_quoted_gas: Number(historyItem.pricingData?.quotedGasInUsd ?? 0),\n gas_included: historyItem.quote.gasIncluded ?? false,\n gas_included_7702: historyItem.quote.gasIncluded7702 ?? false,\n provider: formatProviderLabel(historyItem.quote),\n quoted_time_minutes: Number(\n historyItem.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(historyItem.pricingData?.quotedReturnInUsd ?? 0),\n };\n};\n\nexport const getRequestMetadataFromHistory = (\n historyItem: BridgeHistoryItem,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n): RequestMetadata => {\n const {\n quote,\n slippagePercentage,\n isStxEnabled,\n customSlippage,\n batchSellData,\n featureId,\n } = historyItem;\n const accountHardwareType = getAccountHardwareType(account);\n const isBatchSell =\n Boolean(batchSellData) || featureId === FeatureId.BATCH_SELL;\n const isUnifiedSwapBridge =\n featureId === undefined || featureId === FeatureId.UNIFIED_SWAP_BRIDGE;\n let inferredCustomSlippage = false;\n if (isBatchSell) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage ?? 0);\n } else if (!isUnifiedSwapBridge) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage);\n }\n\n return {\n slippage_limit: slippagePercentage ?? 0,\n custom_slippage: customSlippage ?? inferredCustomSlippage,\n usd_amount_source: Number(historyItem.pricingData?.amountSentInUsd ?? 0),\n swap_type: getSwapType(quote.srcChainId, quote.destChainId),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n stx_enabled: isStxEnabled ?? false,\n security_warnings: [],\n };\n};\n\n/**\n * Get the properties for a swap transaction that is not in the txHistory\n *\n * @param transactionMeta - The transaction meta\n * @param account - The account that submitted the transaction\n * @returns The properties for the swap transaction\n */\nexport const getEVMTxPropertiesFromTransactionMeta = (\n transactionMeta: TransactionMeta,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const accountHardwareType = getAccountHardwareType(account);\n\n return {\n source_transaction: [\n TransactionStatus.failed,\n TransactionStatus.dropped,\n TransactionStatus.rejected,\n ].includes(transactionMeta.status)\n ? StatusTypes.FAILED\n : StatusTypes.COMPLETE,\n error_message: [\n `Transaction ${transactionMeta.status}`,\n transactionMeta.error?.message,\n ]\n .filter(Boolean)\n .join('. '),\n chain_id_source: formatChainIdToCaip(transactionMeta.chainId),\n chain_id_destination: formatChainIdToCaip(transactionMeta.chainId),\n token_symbol_source: transactionMeta.sourceTokenSymbol ?? '',\n token_symbol_destination: transactionMeta.destinationTokenSymbol ?? '',\n usd_amount_source: 0,\n slippage_limit: 0,\n stx_enabled: false,\n token_address_source:\n formatAddressToAssetId(\n transactionMeta.sourceTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_address_destination:\n formatAddressToAssetId(\n transactionMeta.destinationTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_security_type_destination: null,\n custom_slippage: false,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type:\n transactionMeta.type &&\n [TransactionType.swap, TransactionType.swapApproval].includes(\n transactionMeta.type,\n )\n ? MetricsSwapType.SINGLE\n : MetricsSwapType.CROSSCHAIN,\n security_warnings: [],\n price_impact: 0,\n usd_quoted_gas: 0,\n gas_included: false,\n gas_included_7702: false,\n quoted_time_minutes: 0,\n usd_quoted_return: 0,\n provider: '' as `${string}_${string}`,\n actual_time_minutes: 0,\n quote_vs_execution_ratio: 0,\n quoted_vs_used_gas_ratio: 0,\n usd_actual_return: 0,\n usd_actual_gas: 0,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n ...(transactionMeta.batchId ? { batch_id: transactionMeta.batchId } : {}),\n ...getHashPresenceProperties(transactionMeta.hash, undefined),\n failure_phase: transactionMeta.hash\n ? FailurePhase.SourceExecution\n : FailurePhase.Broadcast,\n error_code: transactionMeta.error\n ? SwapBridgeErrorCode.Unknown\n : SwapBridgeErrorCode.MissingErrorObject,\n };\n};\n"]}
@@ -17,9 +17,11 @@ export declare const isCrossChainTx: (type: TransactionType) => type is Transact
17
17
  export declare const is7702Tx: (tx: TransactionMeta) => boolean;
18
18
  export declare const shouldDisable7702: (gasIncluded7702?: boolean, gasIncluded?: boolean, isDelegatedAccount?: boolean) => boolean;
19
19
  export declare const hasNestedSwapTransactions: (txMeta: TransactionMeta) => boolean;
20
+ export declare const isAtomic7702BatchTx: (txMeta: TransactionMeta) => boolean;
20
21
  export declare const getGasFeeEstimates: (messenger: BridgeStatusControllerMessenger, args: Parameters<TransactionController['estimateGasFee']>[0]) => Promise<import("@metamask/transaction-controller").FeeMarketGasFeeEstimateForLevel | undefined>;
21
22
  export declare const getTransactions: (messenger: BridgeStatusControllerMessenger) => TransactionMeta[];
22
23
  export declare const getTransactionMetaById: (messenger: BridgeStatusControllerMessenger, txId?: string) => TransactionMeta | undefined;
24
+ export declare const getTransactionMetaByActionId: (messenger: BridgeStatusControllerMessenger, actionId?: string) => TransactionMeta | undefined;
23
25
  export declare const getTransactionMetaByHash: (messenger: BridgeStatusControllerMessenger, txHash?: string) => TransactionMeta | undefined;
24
26
  export declare const updateTransaction: (messenger: BridgeStatusControllerMessenger, txMeta: TransactionMeta, txMetaUpdates: Partial<TransactionMeta>, note: string) => void;
25
27
  export declare const checkIsDelegatedAccount: (messenger: BridgeStatusControllerMessenger, fromAddress: Hex, chainIds: Hex[]) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,KAAK,EACL,MAAM,EACN,cAAc,EACf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAEV,qBAAqB,EACrB,eAAe,EAEf,sBAAsB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAItD,eAAO,MAAM,YAAY,SAAU,eAAe,0EAEX,CAAC;AACxC,eAAO,MAAM,SAAS,SAAU,eAAe,0DACmB,CAAC;AACnE,eAAO,MAAM,cAAc,SAAU,eAAe,0HACb,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,OAAQ,eAAe,YAM3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,qBACX,OAAO,gBACX,OAAO,uBACA,OAAO,KAC1B,OAcF,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAAY,eAAe,YAIhE,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,+BAA+B,QACpC,UAAU,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,oGAY7D,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,+BAA+B,sBAEzE,CAAC;AAEF,eAAO,MAAM,sBAAsB,cACtB,+BAA+B,SACnC,MAAM,gCAKd,CAAC;AAEF,eAAO,MAAM,wBAAwB,cACxB,+BAA+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CAAC,sBAAsB,CAsChC,CAAC;AAEF,eAAO,MAAM,4BAA4B,gGAMtC,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;IACxE,SAAS,EAAE,+BAA+B,CAAC;IAC3C,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,KAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAkCtE,CAAC;AAEF,eAAO,MAAM,0BAA0B,uCAIpC;IACD,SAAS,EAAE,+BAA+B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,kBAAkB,EAAE,CAAC;CACjC,KAAG,kBAAkB,EA8BrB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,0CAGnC;IACD,SAAS,EAAE,+BAA+B,CAAC;IAC3C,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;CAC7C,yBAuBA,CAAC"}
@@ -40,6 +40,9 @@ export const shouldDisable7702 = (gasIncluded7702 = false, gasIncluded = false,
40
40
  export const hasNestedSwapTransactions = (txMeta) => {
41
41
  return Boolean(txMeta?.nestedTransactions?.some((tx) => tx.type === TransactionType.swap));
42
42
  };
43
+ export const isAtomic7702BatchTx = (txMeta) => txMeta.type === TransactionType.batch ||
44
+ hasNestedSwapTransactions(txMeta) ||
45
+ Boolean(txMeta.txParams?.authorizationList?.length);
43
46
  export const getGasFeeEstimates = async (messenger, args) => {
44
47
  const { estimates } = await messenger.call('TransactionController:estimateGasFee', args);
45
48
  if (estimates?.type === GasFeeEstimateType.FeeMarket) {
@@ -53,6 +56,9 @@ export const getTransactions = (messenger) => {
53
56
  export const getTransactionMetaById = (messenger, txId) => {
54
57
  return getTransactions(messenger).find((tx) => tx.id === txId);
55
58
  };
59
+ export const getTransactionMetaByActionId = (messenger, actionId) => {
60
+ return getTransactions(messenger).find((tx) => tx.actionId === actionId);
61
+ };
56
62
  export const getTransactionMetaByHash = (messenger, txHash) => {
57
63
  return getTransactions(messenger).find((tx) => tx.hash?.toLowerCase() === txHash?.toLowerCase());
58
64
  };
@@ -357,10 +363,16 @@ export const updateTransactionsInBatch = ({ messenger, allTradesWithMetadata, })
357
363
  return allTradesWithMetadata.map((tradeWithMetadata) => {
358
364
  const { txMeta, type } = tradeWithMetadata;
359
365
  if (txMeta) {
360
- // Update the tx type from batch to swap/bridge
361
- updateTransaction(messenger, txMeta, { type }, `Update tx type to ${type}`);
362
- const updatedTx = { ...txMeta, type };
363
- return { ...tradeWithMetadata, txMeta: updatedTx, type };
366
+ try {
367
+ // Update the tx type from batch to swap/bridge
368
+ updateTransaction(messenger, txMeta, { type }, `Update tx type to ${type}`);
369
+ const updatedTx = { ...txMeta, type };
370
+ return { ...tradeWithMetadata, txMeta: updatedTx, type };
371
+ }
372
+ catch (error) {
373
+ console.warn(`Failed to update transaction type to ${type}`, error);
374
+ return tradeWithMetadata;
375
+ }
364
376
  }
365
377
  return tradeWithMetadata;
366
378
  });
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,6BAA6B,EAC7B,WAAW,EACX,OAAO,EACP,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OA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qBAAqB,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;QACrD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC;QAE3C,IAAI,MAAM,EAAE,CAAC;YACX,+CAA+C;YAC/C,iBAAiB,CACf,SAAS,EACT,MAAM,EACN,EAAE,IAAI,EAAE,EACR,qBAAqB,IAAI,EAAE,CAC5B,CAAC;YACF,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;YACtC,OAAO,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC3D,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n isEvmTxData,\n FeeType,\n BatchSellTransactionType,\n} from '@metamask/bridge-controller';\nimport type {\n BatchSellTradesResponse,\n QuoteMetadata,\n QuoteResponseV1,\n SimulatedGasFeeLimits,\n Trade,\n TxData,\n TxFeeGasLimits,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n GasFeeEstimateType,\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n BatchTransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, isStrictHexString } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { APPROVAL_DELAY_MS } from '../constants.js';\nimport type { BridgeStatusControllerMessenger } from '../types.js';\nimport type { QuoteAndTxMetadata } from '../types.js';\nimport { getAccountByAddress } from './accounts.js';\nimport { getNetworkClientIdByChainId } from './network.js';\n\nexport const isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nexport const isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\n/**\n * For 7702 delegated transactions, check for delegation-specific fields\n * These transactions might have authorizationList or delegationAddress\n *\n * @param tx - The transaction meta\n * @returns Whether the transaction is a 7702 transaction\n */\nexport const is7702Tx = (tx: TransactionMeta) => {\n return (\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress)\n );\n};\n\nexport const shouldDisable7702 = (\n gasIncluded7702: boolean = false,\n gasIncluded: boolean = false,\n isDelegatedAccount: boolean = false,\n): boolean => {\n // Enable 7702 batching when the quote includes gasless 7702 support\n if (gasIncluded7702) {\n return false;\n }\n // Enable batching when the account is already delegated (to avoid the in-flight transaction limit for delegated accounts)\n // For gasless transactions with STX/sendBundle we keep disabling 7702\n if (isDelegatedAccount && !gasIncluded) {\n return false;\n }\n /**\n * Explicitly return default instead of falsy value (see TransactionBatchRequest.disable7702)\n */\n return true;\n};\n\nexport const hasNestedSwapTransactions = (txMeta: TransactionMeta) => {\n return Boolean(\n txMeta?.nestedTransactions?.some((tx) => tx.type === TransactionType.swap),\n );\n};\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n\n if (estimates?.type === GasFeeEstimateType.FeeMarket) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n\n return;\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n isInternal: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponseV1['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toQuoteAndTxMetadata = ({\n quoteResponse,\n isBridgeTx,\n}: {\n quoteResponse: QuoteResponseV1<Trade, Trade> & QuoteMetadata;\n isBridgeTx: boolean;\n}): Omit<QuoteAndTxMetadata, 'txMeta'>[] => {\n const tradeData: QuoteAndTxMetadata[] = [];\n\n const approvalTxType = isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval;\n\n if (quoteResponse.resetApproval) {\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.resetApproval,\n type: approvalTxType,\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n }\n if (quoteResponse.approval && isEvmTxData(quoteResponse.approval)) {\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.approval,\n type: approvalTxType,\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n }\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.trade as TxData,\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n assetsFiatValues: {\n sending: quoteResponse.sentAmount?.valueInCurrency?.toString(),\n receiving: quoteResponse.toTokenAmount?.valueInCurrency?.toString(),\n },\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n\n return tradeData;\n};\n\n/**\n * Build the trade+quote metadata array for the batch sell transaction\n * This ties together the quote, the tx params and the txMeta after submission\n *\n * @param options - The options for the batch sell transaction\n * @param options.quoteResponses - The quote responses for the batch sell transaction\n * @param options.batchSellTrades - The batch sell trades for the batch sell transaction\n * @returns The trade+quote metadata array for the batch sell transaction\n */\nexport const toQuoteAndTxMetadataBatch = ({\n quoteResponses,\n batchSellTrades,\n}: {\n quoteResponses: (QuoteResponseV1<TxData, TxData> & QuoteMetadata)[];\n batchSellTrades: BatchSellTradesResponse;\n}): Omit<QuoteAndTxMetadata, 'txMeta'>[] => {\n const tradeData: QuoteAndTxMetadata[] = [];\n\n const {\n transactions,\n gasIncluded7702,\n gasIncluded,\n gasSponsored = false,\n } = batchSellTrades;\n\n for (const transaction of transactions) {\n const { type, maxFeePerGas, maxPriorityFeePerGas, ...tx } = transaction;\n // Match the trade or approval tx data with the quote response\n const matchingQuoteResponse =\n quoteResponses.find(\n ({ approval, trade }) =>\n trade?.data.toLowerCase() === tx.data.toLowerCase() ||\n approval?.data.toLowerCase() === tx.data.toLowerCase(),\n ) ?? quoteResponses[0];\n\n // Include gasIncluded and gasIncluded7702 from the gasless batch\n const normalizedQuote = {\n ...matchingQuoteResponse,\n quote: {\n ...matchingQuoteResponse.quote,\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n };\n\n const commonTradeData = {\n tx,\n quoteResponse: normalizedQuote,\n txFee: { maxFeePerGas, maxPriorityFeePerGas },\n };\n\n if (type === BatchSellTransactionType.TRADE) {\n tradeData.push({\n ...commonTradeData,\n type: TransactionType.swap,\n assetsFiatValues: {\n sending:\n matchingQuoteResponse.sentAmount?.valueInCurrency?.toString(),\n receiving:\n matchingQuoteResponse.toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n } else {\n tradeData.push({\n ...commonTradeData,\n type:\n type === BatchSellTransactionType.APPROVAL\n ? TransactionType.swapApproval\n : TransactionType.tokenMethodTransfer,\n });\n }\n }\n\n return tradeData;\n};\n\n/**\n * Appends the gas fee estimates for a transaction and normalizes the trade data\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param trade - the trade data to append gas fees to\n * @param trade.chainId - ignored, use chainId instead\n * @param trade.gasLimit - the gas limit to use for the gas fee estimates\n * @param networkClientId - the network client ID to use for the gas fee estimates\n * @param chainId - the chain ID to use for the gas fee estimates\n * @param simulatedGasFeeLimits - either the txFee from the quote or the simulated gas fee limits for the batch sell\n * @returns The gas fee estimates for the transaction\n */\nexport const toTransactionParams = async (\n messenger: BridgeStatusControllerMessenger,\n { chainId: tradeChainId, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n simulatedGasFeeLimits?: SimulatedGasFeeLimits | TxFeeGasLimits,\n): Promise<BatchTransactionParams> => {\n const transactionParams = {\n data: trade.data,\n to: trade.to,\n from: trade.from,\n value: trade.value,\n // Only add gas if it's truthy\n gas: gasLimit ? toHex(gasLimit) : undefined,\n };\n\n // Use bridge-api's provided gas fee estimates\n if (simulatedGasFeeLimits) {\n return {\n ...transactionParams,\n // Sometimes estimates are hex, somethings numeric strings\n maxFeePerGas: isStrictHexString(simulatedGasFeeLimits.maxFeePerGas)\n ? simulatedGasFeeLimits.maxFeePerGas\n : toHex(simulatedGasFeeLimits.maxFeePerGas),\n maxPriorityFeePerGas: isStrictHexString(\n simulatedGasFeeLimits.maxPriorityFeePerGas,\n )\n ? simulatedGasFeeLimits.maxPriorityFeePerGas\n : toHex(simulatedGasFeeLimits.maxPriorityFeePerGas),\n };\n }\n\n // Get transaction's 1559 gas fee estimates\n const gasFeeEstimates = await getGasFeeEstimates(messenger, {\n transactionParams,\n networkClientId,\n chainId,\n });\n\n return {\n ...transactionParams,\n maxFeePerGas: gasFeeEstimates?.maxFeePerGas,\n maxPriorityFeePerGas: gasFeeEstimates?.maxPriorityFeePerGas,\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n tradeData,\n requireApproval = false,\n isDelegatedAccount,\n ...addTransactionBatchParams\n}: Partial<Parameters<TransactionController['addTransactionBatch']>[0]> & {\n messenger: BridgeStatusControllerMessenger;\n tradeData: QuoteAndTxMetadata[];\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}): Promise<Parameters<TransactionController['addTransactionBatch']>[0]> => {\n const trade = tradeData[0].tx;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const transactions: TransactionBatchSingleRequest[] = await Promise.all(\n tradeData.map(async ({ tx, txFee, assetsFiatValues, type }) => ({\n params: await toTransactionParams(\n messenger,\n tx,\n networkClientId,\n hexChainId,\n txFee,\n ),\n assetsFiatValues,\n type,\n })),\n );\n\n return {\n networkClientId,\n requireApproval,\n origin: 'metamask',\n from: selectedAccount.address as Hex,\n isInternal: true,\n transactions,\n ...addTransactionBatchParams,\n };\n};\n\nexport const findAllTransactionsInBatch = ({\n messenger,\n batchId,\n tradeData,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n tradeData: QuoteAndTxMetadata[];\n}): QuoteAndTxMetadata[] => {\n // Filter for transactions with batchId\n const txs = getTransactions(messenger).filter(\n (tx: TransactionMeta) => tx.batchId === batchId,\n );\n\n return tradeData.map((tradeWithMetadata) => {\n const { tx, type } = tradeWithMetadata;\n return {\n ...tradeWithMetadata,\n txMeta: txs.find((txMeta: TransactionMeta) => {\n if (is7702Tx(txMeta)) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(type) && txMeta.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(type) && txMeta.txParams.data === tx.data) {\n return true;\n }\n }\n // Default matching logic for non-7702 transactions\n if (txMeta.txParams.data === tx.data) {\n return true;\n }\n return false;\n }),\n };\n });\n};\n\n/**\n * This is a workaround to update the tx type after submission. Batch txs are submitted with\n * the \"batch\" type, but we need to update to swap/bridge for display purposes.\n *\n * @param params - The parameters for the transaction search\n * @param params.messenger - The messenger to use for the transaction\n * @param params.allTradesWithMetadata - The quote, tx data and type for each transaction in the batch\n * @returns A list of transaction metas for each trade in the batch]\n *\n * @example\n * [\n * {...tradeData[0], tradeMeta: TransactionMeta}\n * {...tradeData[1], tradeMeta: TransactionMeta}\n * {...tradeData[2], tradeMeta: TransactionMeta}\n * {...tradeData[3], tradeMeta: TransactionMeta}\n * ]\n */\nexport const updateTransactionsInBatch = ({\n messenger,\n allTradesWithMetadata,\n}: {\n messenger: BridgeStatusControllerMessenger;\n allTradesWithMetadata: QuoteAndTxMetadata[];\n}) => {\n return allTradesWithMetadata.map((tradeWithMetadata) => {\n const { txMeta, type } = tradeWithMetadata;\n\n if (txMeta) {\n // Update the tx type from batch to swap/bridge\n updateTransaction(\n messenger,\n txMeta,\n { type },\n `Update tx type to ${type}`,\n );\n const updatedTx = { ...txMeta, type };\n return { ...tradeWithMetadata, txMeta: updatedTx, type };\n }\n\n return tradeWithMetadata;\n });\n};\n"]}
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,6BAA6B,EAC7B,WAAW,EACX,OAAO,EACP,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,EAAE,CACpD,IAAI,KAAK,eAAe,CAAC,cAAc;IACvC,IAAI,KAAK,eAAe,CAAC,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE,CACjD,IAAI,KAAK,eAAe,CAAC,MAAM,IAAI,IAAI,KAAK,eAAe,CAAC,IAAI,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IA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,GAItB,EAAE,EAAE;IACH,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE;QACrD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC;QAE3C,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC;gBACH,+CAA+C;gBAC/C,iBAAiB,CACf,SAAS,EACT,MAAM,EACN,EAAE,IAAI,EAAE,EACR,qBAAqB,IAAI,EAAE,CAC5B,CAAC;gBACF,MAAM,SAAS,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;gBACtC,OAAO,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YAC3D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CAAC,wCAAwC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpE,OAAO,iBAAiB,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport {\n ChainId,\n formatChainIdToHex,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n isEvmTxData,\n FeeType,\n BatchSellTransactionType,\n} from '@metamask/bridge-controller';\nimport type {\n BatchSellTradesResponse,\n QuoteMetadata,\n QuoteResponseV1,\n SimulatedGasFeeLimits,\n Trade,\n TxData,\n TxFeeGasLimits,\n} from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport {\n GasFeeEstimateType,\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type {\n IsAtomicBatchSupportedResultEntry,\n TransactionController,\n TransactionMeta,\n TransactionBatchSingleRequest,\n BatchTransactionParams,\n} from '@metamask/transaction-controller';\nimport { createProjectLogger, isStrictHexString } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { APPROVAL_DELAY_MS } from '../constants.js';\nimport type { BridgeStatusControllerMessenger } from '../types.js';\nimport type { QuoteAndTxMetadata } from '../types.js';\nimport { getAccountByAddress } from './accounts.js';\nimport { getNetworkClientIdByChainId } from './network.js';\n\nexport const isApprovalTx = (type: TransactionType) =>\n type === TransactionType.bridgeApproval ||\n type === TransactionType.swapApproval;\nexport const isTradeTx = (type: TransactionType) =>\n type === TransactionType.bridge || type === TransactionType.swap;\nexport const isCrossChainTx = (type: TransactionType) =>\n isTradeTx(type) || isApprovalTx(type);\n\n/**\n * For 7702 delegated transactions, check for delegation-specific fields\n * These transactions might have authorizationList or delegationAddress\n *\n * @param tx - The transaction meta\n * @returns Whether the transaction is a 7702 transaction\n */\nexport const is7702Tx = (tx: TransactionMeta) => {\n return (\n (Array.isArray(tx.txParams.authorizationList) &&\n tx.txParams.authorizationList.length > 0) ||\n Boolean(tx.delegationAddress)\n );\n};\n\nexport const shouldDisable7702 = (\n gasIncluded7702: boolean = false,\n gasIncluded: boolean = false,\n isDelegatedAccount: boolean = false,\n): boolean => {\n // Enable 7702 batching when the quote includes gasless 7702 support\n if (gasIncluded7702) {\n return false;\n }\n // Enable batching when the account is already delegated (to avoid the in-flight transaction limit for delegated accounts)\n // For gasless transactions with STX/sendBundle we keep disabling 7702\n if (isDelegatedAccount && !gasIncluded) {\n return false;\n }\n /**\n * Explicitly return default instead of falsy value (see TransactionBatchRequest.disable7702)\n */\n return true;\n};\n\nexport const hasNestedSwapTransactions = (txMeta: TransactionMeta) => {\n return Boolean(\n txMeta?.nestedTransactions?.some((tx) => tx.type === TransactionType.swap),\n );\n};\n\nexport const isAtomic7702BatchTx = (txMeta: TransactionMeta): boolean =>\n txMeta.type === TransactionType.batch ||\n hasNestedSwapTransactions(txMeta) ||\n Boolean(txMeta.txParams?.authorizationList?.length);\n\nexport const getGasFeeEstimates = async (\n messenger: BridgeStatusControllerMessenger,\n args: Parameters<TransactionController['estimateGasFee']>[0],\n) => {\n const { estimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n args,\n );\n\n if (estimates?.type === GasFeeEstimateType.FeeMarket) {\n return estimates[BRIDGE_PREFERRED_GAS_ESTIMATE];\n }\n\n return;\n};\n\nexport const getTransactions = (messenger: BridgeStatusControllerMessenger) => {\n return messenger.call('TransactionController:getState').transactions ?? [];\n};\n\nexport const getTransactionMetaById = (\n messenger: BridgeStatusControllerMessenger,\n txId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.id === txId,\n );\n};\n\nexport const getTransactionMetaByActionId = (\n messenger: BridgeStatusControllerMessenger,\n actionId?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.actionId === actionId,\n );\n};\n\nexport const getTransactionMetaByHash = (\n messenger: BridgeStatusControllerMessenger,\n txHash?: string,\n) => {\n return getTransactions(messenger).find(\n (tx: TransactionMeta) => tx.hash?.toLowerCase() === txHash?.toLowerCase(),\n );\n};\n\nexport const updateTransaction = (\n messenger: BridgeStatusControllerMessenger,\n txMeta: TransactionMeta,\n txMetaUpdates: Partial<TransactionMeta>,\n note: string,\n) => {\n return messenger.call(\n 'TransactionController:updateTransaction',\n { ...txMeta, ...txMetaUpdates },\n note,\n );\n};\n\nexport const checkIsDelegatedAccount = async (\n messenger: BridgeStatusControllerMessenger,\n fromAddress: Hex,\n chainIds: Hex[],\n): Promise<boolean> => {\n try {\n const atomicBatchSupport = await messenger.call(\n 'TransactionController:isAtomicBatchSupported',\n {\n address: fromAddress,\n chainIds,\n },\n );\n return atomicBatchSupport.some(\n (entry: IsAtomicBatchSupportedResultEntry) =>\n entry.isSupported && entry.delegationAddress,\n );\n } catch {\n return false;\n }\n};\n\nconst waitForHashAndReturnFinalTxMeta = async (\n messenger: BridgeStatusControllerMessenger,\n hashPromise?: Awaited<\n ReturnType<TransactionController['addTransaction']>\n >['result'],\n): Promise<TransactionMeta> => {\n const txHash = await hashPromise;\n const finalTransactionMeta = getTransactionMetaByHash(messenger, txHash);\n if (!finalTransactionMeta) {\n throw new Error(\n 'Failed to submit cross-chain swap tx: txMeta for txHash was not found',\n );\n }\n return finalTransactionMeta;\n};\n\nexport const addTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { result } = await messenger.call(\n 'TransactionController:addTransaction',\n ...args,\n );\n return await waitForHashAndReturnFinalTxMeta(messenger, result);\n};\n\nexport const generateActionId = () => (Date.now() + Math.random()).toString();\n\n/**\n * Adds a synthetic transaction to the TransactionController to display pending intent orders in the UI\n *\n * @param messenger - The messenger to use for the transaction\n * @param args - The arguments for the transaction\n * @returns The transaction meta\n */\nexport const addSyntheticTransaction = async (\n messenger: BridgeStatusControllerMessenger,\n ...args: Parameters<TransactionController['addTransaction']>\n) => {\n const { transactionMeta } = await messenger.call(\n 'TransactionController:addTransaction',\n args[0],\n {\n origin: 'metamask',\n actionId: generateActionId(),\n isStateOnly: true,\n isInternal: true,\n ...args[1],\n },\n );\n return transactionMeta;\n};\n\nexport const handleApprovalDelay = async (\n srcChainId: QuoteResponseV1['quote']['srcChainId'],\n) => {\n if ([ChainId.LINEA, ChainId.BASE].includes(srcChainId)) {\n const debugLog = createProjectLogger('bridge');\n debugLog(\n 'Delaying submitting bridge tx to make Linea and Base confirmation more likely',\n );\n const waitPromise = new Promise((resolve) =>\n setTimeout(resolve, APPROVAL_DELAY_MS),\n );\n await waitPromise;\n }\n};\n\n/**\n * Adds a delay for hardware wallet transactions on mobile to fix an issue\n * where the Ledger does not get prompted for the 2nd approval.\n * Extension does not have this issue.\n *\n * @param requireApproval - Whether the delay should be applied\n */\nexport const handleMobileHardwareWalletDelay = async (\n requireApproval: boolean,\n) => {\n if (requireApproval) {\n const mobileHardwareWalletDelay = new Promise((resolve) =>\n setTimeout(resolve, 1000),\n );\n await mobileHardwareWalletDelay;\n }\n};\n\n/**\n * Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.\n *\n * @deprecated use addTransaction util\n * @param messenger - the BridgeStatusControllerMessenger\n * @param txId - the transaction ID\n * @param options - the options for the timeout and poll\n * @param options.timeoutMs - the timeout in milliseconds\n * @param options.pollMs - the poll interval in milliseconds\n * @returns the transaction meta\n */\nexport const waitForTxConfirmation = async (\n messenger: BridgeStatusControllerMessenger,\n txId: string,\n {\n timeoutMs = 5 * 60_000,\n pollMs = 3_000,\n }: { timeoutMs?: number; pollMs?: number } = {},\n): Promise<TransactionMeta> => {\n const start = Date.now();\n while (true) {\n const meta = getTransactionMetaById(messenger, txId);\n\n if (meta) {\n if (meta.status === TransactionStatus.confirmed) {\n return meta;\n }\n if (\n meta.status === TransactionStatus.failed ||\n meta.status === TransactionStatus.dropped ||\n meta.status === TransactionStatus.rejected\n ) {\n throw new Error('Approval transaction did not confirm');\n }\n }\n\n if (Date.now() - start > timeoutMs) {\n throw new Error('Timed out waiting for approval confirmation');\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollMs));\n }\n};\n\nexport const toQuoteAndTxMetadata = ({\n quoteResponse,\n isBridgeTx,\n}: {\n quoteResponse: QuoteResponseV1<Trade, Trade> & QuoteMetadata;\n isBridgeTx: boolean;\n}): Omit<QuoteAndTxMetadata, 'txMeta'>[] => {\n const tradeData: QuoteAndTxMetadata[] = [];\n\n const approvalTxType = isBridgeTx\n ? TransactionType.bridgeApproval\n : TransactionType.swapApproval;\n\n if (quoteResponse.resetApproval) {\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.resetApproval,\n type: approvalTxType,\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n }\n if (quoteResponse.approval && isEvmTxData(quoteResponse.approval)) {\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.approval,\n type: approvalTxType,\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n }\n tradeData.push({\n quoteResponse,\n tx: quoteResponse.trade as TxData,\n type: isBridgeTx ? TransactionType.bridge : TransactionType.swap,\n assetsFiatValues: {\n sending: quoteResponse.sentAmount?.valueInCurrency?.toString(),\n receiving: quoteResponse.toTokenAmount?.valueInCurrency?.toString(),\n },\n txFee: quoteResponse.quote.feeData[FeeType.TX_FEE],\n });\n\n return tradeData;\n};\n\n/**\n * Build the trade+quote metadata array for the batch sell transaction\n * This ties together the quote, the tx params and the txMeta after submission\n *\n * @param options - The options for the batch sell transaction\n * @param options.quoteResponses - The quote responses for the batch sell transaction\n * @param options.batchSellTrades - The batch sell trades for the batch sell transaction\n * @returns The trade+quote metadata array for the batch sell transaction\n */\nexport const toQuoteAndTxMetadataBatch = ({\n quoteResponses,\n batchSellTrades,\n}: {\n quoteResponses: (QuoteResponseV1<TxData, TxData> & QuoteMetadata)[];\n batchSellTrades: BatchSellTradesResponse;\n}): Omit<QuoteAndTxMetadata, 'txMeta'>[] => {\n const tradeData: QuoteAndTxMetadata[] = [];\n\n const {\n transactions,\n gasIncluded7702,\n gasIncluded,\n gasSponsored = false,\n } = batchSellTrades;\n\n for (const transaction of transactions) {\n const { type, maxFeePerGas, maxPriorityFeePerGas, ...tx } = transaction;\n // Match the trade or approval tx data with the quote response\n const matchingQuoteResponse =\n quoteResponses.find(\n ({ approval, trade }) =>\n trade?.data.toLowerCase() === tx.data.toLowerCase() ||\n approval?.data.toLowerCase() === tx.data.toLowerCase(),\n ) ?? quoteResponses[0];\n\n // Include gasIncluded and gasIncluded7702 from the gasless batch\n const normalizedQuote = {\n ...matchingQuoteResponse,\n quote: {\n ...matchingQuoteResponse.quote,\n gasIncluded,\n gasIncluded7702,\n gasSponsored,\n },\n };\n\n const commonTradeData = {\n tx,\n quoteResponse: normalizedQuote,\n txFee: { maxFeePerGas, maxPriorityFeePerGas },\n };\n\n if (type === BatchSellTransactionType.TRADE) {\n tradeData.push({\n ...commonTradeData,\n type: TransactionType.swap,\n assetsFiatValues: {\n sending:\n matchingQuoteResponse.sentAmount?.valueInCurrency?.toString(),\n receiving:\n matchingQuoteResponse.toTokenAmount?.valueInCurrency?.toString(),\n },\n });\n } else {\n tradeData.push({\n ...commonTradeData,\n type:\n type === BatchSellTransactionType.APPROVAL\n ? TransactionType.swapApproval\n : TransactionType.tokenMethodTransfer,\n });\n }\n }\n\n return tradeData;\n};\n\n/**\n * Appends the gas fee estimates for a transaction and normalizes the trade data\n *\n * @param messenger - The messenger for the gas fee estimates\n * @param trade - the trade data to append gas fees to\n * @param trade.chainId - ignored, use chainId instead\n * @param trade.gasLimit - the gas limit to use for the gas fee estimates\n * @param networkClientId - the network client ID to use for the gas fee estimates\n * @param chainId - the chain ID to use for the gas fee estimates\n * @param simulatedGasFeeLimits - either the txFee from the quote or the simulated gas fee limits for the batch sell\n * @returns The gas fee estimates for the transaction\n */\nexport const toTransactionParams = async (\n messenger: BridgeStatusControllerMessenger,\n { chainId: tradeChainId, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n simulatedGasFeeLimits?: SimulatedGasFeeLimits | TxFeeGasLimits,\n): Promise<BatchTransactionParams> => {\n const transactionParams = {\n data: trade.data,\n to: trade.to,\n from: trade.from,\n value: trade.value,\n // Only add gas if it's truthy\n gas: gasLimit ? toHex(gasLimit) : undefined,\n };\n\n // Use bridge-api's provided gas fee estimates\n if (simulatedGasFeeLimits) {\n return {\n ...transactionParams,\n // Sometimes estimates are hex, somethings numeric strings\n maxFeePerGas: isStrictHexString(simulatedGasFeeLimits.maxFeePerGas)\n ? simulatedGasFeeLimits.maxFeePerGas\n : toHex(simulatedGasFeeLimits.maxFeePerGas),\n maxPriorityFeePerGas: isStrictHexString(\n simulatedGasFeeLimits.maxPriorityFeePerGas,\n )\n ? simulatedGasFeeLimits.maxPriorityFeePerGas\n : toHex(simulatedGasFeeLimits.maxPriorityFeePerGas),\n };\n }\n\n // Get transaction's 1559 gas fee estimates\n const gasFeeEstimates = await getGasFeeEstimates(messenger, {\n transactionParams,\n networkClientId,\n chainId,\n });\n\n return {\n ...transactionParams,\n maxFeePerGas: gasFeeEstimates?.maxFeePerGas,\n maxPriorityFeePerGas: gasFeeEstimates?.maxPriorityFeePerGas,\n };\n};\n\nexport const getAddTransactionBatchParams = async ({\n messenger,\n tradeData,\n requireApproval = false,\n isDelegatedAccount,\n ...addTransactionBatchParams\n}: Partial<Parameters<TransactionController['addTransactionBatch']>[0]> & {\n messenger: BridgeStatusControllerMessenger;\n tradeData: QuoteAndTxMetadata[];\n requireApproval?: boolean;\n isDelegatedAccount?: boolean;\n}): Promise<Parameters<TransactionController['addTransactionBatch']>[0]> => {\n const trade = tradeData[0].tx;\n const selectedAccount = getAccountByAddress(messenger, trade.from);\n if (!selectedAccount) {\n throw new Error(\n 'Failed to submit cross-chain swap batch transaction: unknown account in trade data',\n );\n }\n const hexChainId = formatChainIdToHex(trade.chainId);\n const networkClientId = getNetworkClientIdByChainId(messenger, hexChainId);\n\n const transactions: TransactionBatchSingleRequest[] = await Promise.all(\n tradeData.map(async ({ tx, txFee, assetsFiatValues, type }) => ({\n params: await toTransactionParams(\n messenger,\n tx,\n networkClientId,\n hexChainId,\n txFee,\n ),\n assetsFiatValues,\n type,\n })),\n );\n\n return {\n networkClientId,\n requireApproval,\n origin: 'metamask',\n from: selectedAccount.address as Hex,\n isInternal: true,\n transactions,\n ...addTransactionBatchParams,\n };\n};\n\nexport const findAllTransactionsInBatch = ({\n messenger,\n batchId,\n tradeData,\n}: {\n messenger: BridgeStatusControllerMessenger;\n batchId: string;\n tradeData: QuoteAndTxMetadata[];\n}): QuoteAndTxMetadata[] => {\n // Filter for transactions with batchId\n const txs = getTransactions(messenger).filter(\n (tx: TransactionMeta) => tx.batchId === batchId,\n );\n\n return tradeData.map((tradeWithMetadata) => {\n const { tx, type } = tradeWithMetadata;\n return {\n ...tradeWithMetadata,\n txMeta: txs.find((txMeta: TransactionMeta) => {\n if (is7702Tx(txMeta)) {\n // For 7702 transactions, we need to match based on transaction type\n // since the data field might be different (batch execute call)\n if (isTradeTx(type) && txMeta.type === TransactionType.batch) {\n return true;\n }\n // Also check if it's an approval transaction for 7702\n if (isApprovalTx(type) && txMeta.txParams.data === tx.data) {\n return true;\n }\n }\n // Default matching logic for non-7702 transactions\n if (txMeta.txParams.data === tx.data) {\n return true;\n }\n return false;\n }),\n };\n });\n};\n\n/**\n * This is a workaround to update the tx type after submission. Batch txs are submitted with\n * the \"batch\" type, but we need to update to swap/bridge for display purposes.\n *\n * @param params - The parameters for the transaction search\n * @param params.messenger - The messenger to use for the transaction\n * @param params.allTradesWithMetadata - The quote, tx data and type for each transaction in the batch\n * @returns A list of transaction metas for each trade in the batch]\n *\n * @example\n * [\n * {...tradeData[0], tradeMeta: TransactionMeta}\n * {...tradeData[1], tradeMeta: TransactionMeta}\n * {...tradeData[2], tradeMeta: TransactionMeta}\n * {...tradeData[3], tradeMeta: TransactionMeta}\n * ]\n */\nexport const updateTransactionsInBatch = ({\n messenger,\n allTradesWithMetadata,\n}: {\n messenger: BridgeStatusControllerMessenger;\n allTradesWithMetadata: QuoteAndTxMetadata[];\n}) => {\n return allTradesWithMetadata.map((tradeWithMetadata) => {\n const { txMeta, type } = tradeWithMetadata;\n\n if (txMeta) {\n try {\n // Update the tx type from batch to swap/bridge\n updateTransaction(\n messenger,\n txMeta,\n { type },\n `Update tx type to ${type}`,\n );\n const updatedTx = { ...txMeta, type };\n return { ...tradeWithMetadata, txMeta: updatedTx, type };\n } catch (error) {\n console.warn(`Failed to update transaction type to ${type}`, error);\n return tradeWithMetadata;\n }\n }\n\n return tradeWithMetadata;\n });\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/bridge-status-controller",
3
- "version": "76.4.0-preview-686aaf7",
3
+ "version": "76.4.0-preview-51ecba2",
4
4
  "description": "Manages bridge-related status fetching functionality for MetaMask",
5
5
  "keywords": [
6
6
  "Ethereum",