@metamask-previews/transaction-pay-controller 30.4.1-preview-c3d36da85 → 30.4.1-preview-d44afa95d

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server-submit.js","sourceRoot":"","sources":["../../../src/strategy/server/server-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,KAAK,GACN,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAQpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAA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cAAc,CAAC,MAAM,CAAC;YACnC,GAAG,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;YAE5D,IAAI,CAAC,iBAAiB,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;gBACpD,iBAAiB,GAAG,IAAI,CAAC;gBACzB,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;gBAEtC,iBAAiB,CACf;oBACE,aAAa;oBACb,SAAS;oBACT,IAAI,EAAE,oCAAoC;iBAC3C,EACD,CAAC,EAAE,EAAE,EAAE;oBACL,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC;oBACtB,EAAE,CAAC,WAAW,CAAC,UAAU,GAAG,UAAU,CAAC;gBACzC,CAAC,CACF,CAAC;YACJ,CAAC;YAED,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;YAE9C,IACE,MAAM,KAAK,YAAY,CAAC,SAAS;gBACjC,MAAM,KAAK,YAAY,CAAC,MAAM;gBAC9B,MAAM,KAAK,YAAY,CAAC,QAAQ,EAChC,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,cAAc,EAAE,CAAC;YAC3D,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,kBAAkB,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,2BAA2B,YAAY,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC","sourcesContent":["import {\n ORIGIN_METAMASK,\n successfulFetch,\n toHex,\n} from '@metamask/controller-utils';\nimport { SignTypedDataVersion } from '@metamask/keyring-controller';\nimport type {\n BatchTransactionParams,\n TransactionMeta,\n TransactionParams,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { projectLogger } from '../../logger.js';\nimport type {\n PayStrategyExecuteRequest,\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n} from '../../types.js';\nimport { accountSupports7702 } from '../../utils/7702.js';\nimport {\n getServerPollingInterval,\n getServerPollingTimeout,\n} from '../../utils/feature-flags.js';\nimport type { GasPayment } from '../../utils/gas-payment.js';\nimport {\n GasPaymentMode,\n logGasPaymentOutcome,\n resolveGasPayment,\n} from '../../utils/gas-payment.js';\nimport {\n submitPolymarketWithdraw,\n sweepPolymarketDepositWallet,\n} from '../../utils/polymarket/withdraw.js';\nimport { getNetworkClientId } from '../../utils/provider.js';\nimport { submitSecondLeg } from '../../utils/second-leg.js';\nimport {\n getLiveTokenBalance,\n normalizeTokenAddress,\n TokenAddressTarget,\n} from '../../utils/token.js';\nimport {\n collectTransactionIds,\n getTransaction,\n updateTransaction,\n waitForTransactionConfirmed,\n} from '../../utils/transaction.js';\nimport { RELAY_DEPOSIT_TYPES } from '../relay/constants.js';\nimport { getServerDepositData } from './deposit-step.js';\nimport { getServerStatus, submitServerIntent } from './server-api.js';\nimport type {\n ServerQuote,\n ServerSignatureStep,\n ServerTransactionStep,\n ServerStatusResponse,\n ServerSubmitRequest,\n} from './types.js';\nimport { ServerStatus } from './types.js';\n\nconst log = createModuleLogger(projectLogger, 'server-strategy');\n\n/**\n * Placeholder returned when an intent confirms without reporting a\n * target-chain transaction hash, so there is no settlement to read amounts\n * from.\n */\nconst MISSING_TARGET_HASH = '0x' as Hex;\n\nconst DOMAIN_FIELD_MAP: Record<string, { name: string; type: string }> = {\n name: { name: 'name', type: 'string' },\n version: { name: 'version', type: 'string' },\n chainId: { name: 'chainId', type: 'uint256' },\n verifyingContract: { name: 'verifyingContract', type: 'address' },\n salt: { name: 'salt', type: 'bytes32' },\n};\n\n/**\n * A transaction to submit for a single quote step.\n *\n * The semantic transaction type is held alongside `params` rather than within\n * it, since `TransactionParams.type` is the EVM envelope type (`0x0` - `0x4`)\n * and is rejected by the transaction controller if given anything else.\n */\ntype StepTransaction = {\n params: TransactionParams;\n type?: TransactionType;\n};\n\n/** Terminal outcome of a server intent. */\ntype ServerCompletion = {\n status: ServerStatus.Confirmed | ServerStatus.Failed | ServerStatus.Refunded;\n targetHash?: Hex;\n};\n\nfunction isSignatureStep(\n step: ServerQuote['steps'][number],\n): step is ServerSignatureStep {\n return step.type === 'signature';\n}\n\nfunction isTransactionStep(\n step: ServerQuote['steps'][number],\n): step is ServerTransactionStep {\n return step.type === 'transaction';\n}\n\n/**\n * Submits server intent quotes.\n *\n * @param request - Request object.\n * @returns An object containing the transaction hash if available.\n */\nexport async function submitServerQuotes(\n request: PayStrategyExecuteRequest<ServerQuote>,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing server quotes', request);\n\n const { quotes, messenger, transaction } = request;\n\n let transactionHash: Hex | undefined;\n\n for (const quote of quotes) {\n ({ transactionHash } = await executeSingleServerQuote(\n quote,\n messenger,\n transaction,\n ));\n }\n\n return { transactionHash };\n}\n\nasync function executeSingleServerQuote(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing single server quote', quote);\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Remove nonce from skipped transaction',\n },\n (tx) => {\n tx.txParams.nonce = undefined;\n },\n );\n\n const isDepositWallet = Boolean(quote.request.isPolymarketDepositWallet);\n\n // Phase 1: off-chain signature steps (e.g. Relay authorize, HyperLiquid deposit).\n // Use quote.request.from (resolved accountOverride) not transaction.txParams.from.\n const signatureSteps = quote.original.steps.filter(isSignatureStep);\n\n for (const step of signatureSteps) {\n await submitSignatureStep(step, quote.request.from, messenger);\n }\n\n // Phase 2: on-chain transaction steps (if any). A deposit wallet withdraw\n // replaces them with an unwrap straight to the provider deposit address.\n let preSubmitUsdceBalance: bigint | undefined;\n\n if (isDepositWallet) {\n preSubmitUsdceBalance = await submitDepositWalletWithdraw(\n quote,\n messenger,\n transaction,\n );\n } else {\n await submitTransactionSteps(quote, messenger, transaction);\n }\n\n // Phase 3: poll until the intent settles on the target chain.\n const completion = await waitForServerCompletion(\n quote.original,\n messenger,\n transaction.id,\n );\n\n log('Server request completed', completion);\n\n // A deposit wallet sweeps leftover USDC.e back into pUSD whatever the\n // outcome, so a refund is restored before the failure is reported.\n if (preSubmitUsdceBalance !== undefined) {\n await sweepPolymarketDepositWallet({\n from: quote.request.from,\n isRefund: completion.status === ServerStatus.Refunded,\n messenger,\n preSubmitUsdceBalance,\n });\n }\n\n if (completion.status !== ServerStatus.Confirmed) {\n throw new Error(`Server intent ${completion.status.toLowerCase()}`);\n }\n\n const targetHash = completion.targetHash ?? MISSING_TARGET_HASH;\n\n // Phase 4: submit the calls the quote could not execute itself, now that the\n // funds have settled on the target chain.\n const secondLegHash = quote.requiresSecondLeg\n ? await submitServerSecondLeg(quote, messenger, transaction, targetHash)\n : undefined;\n\n // Only complete once every leg has landed, so a failed second leg does not\n // leave the parent transaction flagged as achieved.\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Intent complete after Server completion',\n },\n (tx) => {\n tx.isIntentComplete = true;\n },\n );\n\n return { transactionHash: secondLegHash ?? targetHash };\n}\n\n/**\n * Submit the calls a server quote could not execute itself, from the account\n * the funds settled on.\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n * @param targetHash - Hash of the settlement on the target chain.\n * @returns Hash of the second-leg transaction, if available.\n */\nasync function submitServerSecondLeg(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n targetHash: Hex | undefined,\n): Promise<Hex | undefined> {\n const { from, isPostQuote, recipient, targetChainId, targetTokenAddress } =\n quote.request;\n\n const { transactionHash } = await submitSecondLeg({\n chainId: targetChainId,\n from: recipient ?? from,\n // Post-quote flows carry no calls of their own, so the payment override\n // builds the batch for the settled amount.\n getCalls: isPostQuote\n ? async (sourceAmountRaw): Promise<BatchTransactionParams[]> =>\n await buildPaymentOverrideCalls({\n messenger,\n quote,\n sourceAmountRaw,\n transaction,\n })\n : undefined,\n messenger,\n settlementHash: targetHash === MISSING_TARGET_HASH ? undefined : targetHash,\n tokenAddress: targetTokenAddress,\n transaction,\n });\n\n return transactionHash;\n}\n\n/**\n * Build the second-leg batch from the payment override for the settled amount.\n *\n * @param options - Build options.\n * @param options.messenger - Controller messenger.\n * @param options.quote - Server quote that settled.\n * @param options.sourceAmountRaw - Settled amount in raw units.\n * @param options.transaction - Original transaction meta.\n * @returns The batch calls.\n */\nasync function buildPaymentOverrideCalls({\n messenger,\n quote,\n sourceAmountRaw,\n transaction,\n}: {\n messenger: TransactionPayControllerMessenger;\n quote: TransactionPayQuote<ServerQuote>;\n sourceAmountRaw: string;\n transaction: TransactionMeta;\n}): Promise<BatchTransactionParams[]> {\n const { transactionData } = messenger.call(\n 'TransactionPayController:getState',\n );\n\n const amount = new BigNumber(sourceAmountRaw)\n .shiftedBy(-quote.original.output.decimals)\n .toFixed();\n\n const { calls } = await messenger.call(\n 'TransactionPayController:getPaymentOverrideData',\n {\n amount,\n transaction,\n transactionData: transactionData[transaction.id],\n },\n );\n\n return calls;\n}\n\n/**\n * Unwrap the deposit wallet's pUSD straight to the provider deposit address.\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n * @returns The deposit wallet's USDC.e balance before submission, so the sweep\n * can detect a refund.\n */\nasync function submitDepositWalletWithdraw(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<bigint> {\n const { preSubmitUsdceBalance, sourceHash } = await submitPolymarketWithdraw({\n depositData: getServerDepositData(quote.original),\n from: quote.request.from,\n messenger,\n sourceAmountRaw: quote.sourceAmount.raw,\n });\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add source hash from deposit wallet withdraw',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash;\n },\n );\n\n return preSubmitUsdceBalance;\n}\n\n/**\n * Submit the on-chain transaction steps for a server quote.\n *\n * Validates the source balance, builds the complete set of transactions (including\n * any post-quote or payment-override prepends), then dispatches to the\n * gasless execute path or TransactionController depending on the quote.\n *\n * No-ops when the quote has no transaction steps (signature-only flows).\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n */\nasync function submitTransactionSteps(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<void> {\n const transactionSteps = quote.original.steps.filter(isTransactionStep);\n\n if (transactionSteps.length === 0) {\n // Signature-only quotes (all steps are signature steps, no transaction\n // steps) have nothing to submit on-chain even when gasless is false.\n const hasSignatureSteps = quote.original.steps.some(isSignatureStep);\n if (!quote.original.gasless && !hasSignatureSteps) {\n throw new Error('Server quote has no steps to submit');\n }\n return;\n }\n\n const { isHyperliquidSource, isPostQuote, paymentOverride } = quote.request;\n\n // Skip balance check for HyperLiquid source flows (no on-chain debit),\n // post-quote flows (funds come from the Safe after the original tx executes),\n // and payment-override flows (funds are supplied by the override account).\n if (!isHyperliquidSource && !isPostQuote && !paymentOverride) {\n await validateSourceBalance(quote, messenger);\n }\n\n const stepTransactions = await buildStepTransactions(\n quote,\n transactionSteps,\n transaction,\n messenger,\n );\n\n const gasPayment = resolveGasPayment({\n isDelegated: quote.original.gasless,\n isSourceGasFeeToken: quote.fees.isSourceGasFeeToken,\n sourceTokenAddress: quote.request.sourceTokenAddress,\n sponsorship: {\n accountSupports7702: accountSupports7702(messenger, quote.request.from),\n request: quote.request,\n transaction,\n },\n });\n\n if (gasPayment.mode === GasPaymentMode.Delegation) {\n await submitViaServerExecute(\n quote,\n stepTransactions,\n messenger,\n transaction,\n );\n } else {\n await submitViaTransactionController(\n quote,\n stepTransactions,\n messenger,\n transaction,\n gasPayment,\n );\n }\n}\n\n/**\n * Build the complete flat array of transactions for on-chain submission.\n *\n * Converts server transaction steps to transactions, then prepends any\n * additional calls required by the payment override or post-quote flow. The\n * returned array is ready to pass directly to submitViaServerExecute or\n * submitViaTransactionController.\n *\n * @param quote - Server quote.\n * @param transactionSteps - Transaction steps from the quote (pre-filtered).\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Complete ordered array of transactions for submission.\n */\nasync function buildStepTransactions(\n quote: TransactionPayQuote<ServerQuote>,\n transactionSteps: ServerTransactionStep[],\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const { atomic, from, isPostQuote, paymentOverride } = quote.request;\n const { gasLimits, maxFeePerGas, maxPriorityFeePerGas } =\n quote.original.client;\n const originalType = getEffectiveTransactionType(transaction);\n\n // Client gas limits are estimated in submission order, so any prepended\n // transactions come first and the quote steps take the trailing limits.\n const stepGasLimits = gasLimits.slice(\n Math.max(gasLimits.length - transactionSteps.length, 0),\n );\n\n const quoteStepTransactions = transactionSteps.map((step, i) =>\n buildStepTransaction(\n step,\n i,\n transactionSteps.length,\n from,\n stepGasLimits,\n maxFeePerGas,\n maxPriorityFeePerGas,\n originalType,\n ),\n );\n\n // Non-atomic flows run the override calls as a second leg once the funds\n // settle, so prepending them here would run them twice.\n if (paymentOverride && atomic !== false) {\n return prependPaymentOverrideTransactions(\n quoteStepTransactions,\n quote,\n transaction,\n messenger,\n );\n }\n\n if (isPostQuote && transaction.txParams.to) {\n return prependPostQuoteTransactions(\n quoteStepTransactions,\n quote,\n transaction,\n messenger,\n );\n }\n\n return quoteStepTransactions;\n}\n\n/**\n * Converts a single server transaction step to a transaction.\n *\n * @param step - The transaction step.\n * @param index - Zero-based position within the transaction steps array.\n * @param totalSteps - Total number of transaction steps (for type mapping).\n * @param from - Sender address.\n * @param gasLimits - Per-step gas limits from client-side estimation.\n * @param clientMaxFeePerGas - Client-side max fee per gas fallback.\n * @param clientMaxPriorityFeePerGas - Client-side max priority fee per gas fallback.\n * @param originalType - Effective type of the parent transaction.\n * @returns Normalized transaction for this step.\n */\nfunction buildStepTransaction(\n step: ServerTransactionStep,\n index: number,\n totalSteps: number,\n from: Hex,\n gasLimits: number[],\n clientMaxFeePerGas: string | undefined,\n clientMaxPriorityFeePerGas: string | undefined,\n originalType: TransactionMeta['type'],\n): StepTransaction {\n let gas: Hex | undefined;\n const gasLimit = gasLimits[index];\n\n if (gasLimit) {\n gas = toHex(gasLimit);\n } else if (step.gasLimit) {\n gas = toHex(step.gasLimit);\n }\n\n const resolvedMaxFeePerGas = step.maxFeePerGas ?? clientMaxFeePerGas;\n const resolvedMaxPriorityFeePerGas =\n step.maxPriorityFeePerGas ?? clientMaxPriorityFeePerGas;\n\n const params: TransactionParams = {\n data: step.data,\n from,\n gas,\n maxFeePerGas: resolvedMaxFeePerGas\n ? toHex(resolvedMaxFeePerGas)\n : undefined,\n maxPriorityFeePerGas: resolvedMaxPriorityFeePerGas\n ? toHex(resolvedMaxPriorityFeePerGas)\n : undefined,\n to: step.to,\n value: toHex(step.value),\n };\n\n const type = getTransactionType(index, totalSteps, originalType);\n\n log('Built transaction for step', {\n index,\n step: {\n gasLimit: step.gasLimit,\n maxFeePerGas: step.maxFeePerGas,\n maxPriorityFeePerGas: step.maxPriorityFeePerGas,\n value: step.value,\n },\n params: {\n gas: params.gas,\n maxFeePerGas: params.maxFeePerGas,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas,\n type,\n value: params.value,\n },\n });\n\n return { params, type };\n}\n\n/**\n * Determine the relay deposit transaction type for a step at the given index.\n *\n * Single-step quotes always use the deposit type. In multi-step quotes the\n * first step is an approval and subsequent steps are deposits — matching the\n * Relay strategy's convention.\n *\n * @param index - Zero-based index of the step within the transaction step array.\n * @param totalSteps - Total number of transaction steps.\n * @param originalType - Effective type of the parent transaction.\n * @returns The mapped TransactionType for this step.\n */\nfunction getTransactionType(\n index: number,\n totalSteps: number,\n originalType: TransactionMeta['type'],\n): TransactionType {\n const depositType = getRelayDepositType(originalType);\n\n if (totalSteps === 1) {\n return depositType;\n }\n\n return index === 0 ? ('tokenMethodApprove' as TransactionType) : depositType;\n}\n\n/**\n * Get the relay deposit transaction type based on the parent transaction type.\n *\n * @param originalType - Type of the parent transaction.\n * @returns The mapped relay deposit type, or `relayDeposit` as a fallback.\n */\nfunction getRelayDepositType(\n originalType: TransactionMeta['type'],\n): TransactionType {\n return (\n (originalType && RELAY_DEPOSIT_TYPES[originalType]) ??\n ('relayDeposit' as TransactionType)\n );\n}\n\n/**\n * Get the effective transaction type, resolving through batch-type parent\n * transactions to find the nested perps/predict type.\n *\n * @param transaction - The transaction metadata.\n * @returns The resolved type from nested transactions, or the top-level type.\n */\nfunction getEffectiveTransactionType(\n transaction: TransactionMeta,\n): TransactionMeta['type'] {\n if (transaction.type !== ('batch' as TransactionType)) {\n return transaction.type;\n }\n\n const nestedType = transaction.nestedTransactions?.find(\n (tx) => tx.type && RELAY_DEPOSIT_TYPES[tx.type] !== undefined,\n )?.type;\n\n return nestedType ?? transaction.type;\n}\n\n/**\n * Prepend payment override calls before the quote transaction steps.\n *\n * For money-account payment override flows the override account supplies\n * the source funds. The override transactions must be batched ahead of the\n * deposit steps.\n *\n * @param quoteStepTransactions - Transactions already built from the quote steps.\n * @param quote - Server quote.\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Combined transactions with override calls prepended.\n */\nasync function prependPaymentOverrideTransactions(\n quoteStepTransactions: StepTransaction[],\n quote: TransactionPayQuote<ServerQuote>,\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const { transactionData } = messenger.call(\n 'TransactionPayController:getState',\n );\n\n const { calls: overrideCalls } = await messenger.call(\n 'TransactionPayController:getPaymentOverrideData',\n {\n amount: quote.sourceAmount.human,\n transaction,\n transactionData: transactionData[transaction.id],\n },\n );\n\n if (!overrideCalls.length) {\n log('No payment override calls to prepend');\n return quoteStepTransactions;\n }\n\n log('Prepending payment override calls', { count: overrideCalls.length });\n\n const overrideTransactions = (overrideCalls as TransactionParams[]).map(\n (params) => ({\n params,\n }),\n );\n\n return [...overrideTransactions, ...quoteStepTransactions];\n}\n\n/**\n * Prepend the original transaction (or a delegation-wrapped version) before\n * the deposit steps for post-quote flows.\n *\n * In post-quote flows the source tokens are held in the Safe and only become\n * available after the original transaction executes as part of the batch.\n * When an accountOverride is active the override account cannot directly\n * execute the original call, so it is wrapped in a delegation transaction.\n *\n * @param quoteStepTransactions - Transactions already built from the quote steps.\n * @param quote - Server quote.\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Combined transactions with the original tx prepended.\n */\nasync function prependPostQuoteTransactions(\n quoteStepTransactions: StepTransaction[],\n quote: TransactionPayQuote<ServerQuote>,\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const hasAccountOverride =\n quote.request.from.toLowerCase() !==\n (transaction.txParams.from as Hex).toLowerCase();\n\n const { gasLimits, maxFeePerGas, maxPriorityFeePerGas } =\n quote.original.client;\n\n let prependedParams: TransactionParams;\n\n if (hasAccountOverride) {\n prependedParams = await buildDelegatedOriginalParams(\n transaction,\n messenger,\n );\n } else {\n prependedParams = {\n data: transaction.txParams.data,\n from: transaction.txParams.from,\n to: transaction.txParams.to,\n value: transaction.txParams.value,\n };\n }\n\n // Ensure the prepended tx carries the same fee caps as the quote steps so\n // it isn't submitted with undefined maxFeePerGas in a non-7702 batch.\n prependedParams.maxFeePerGas = maxFeePerGas ? toHex(maxFeePerGas) : undefined;\n prependedParams.maxPriorityFeePerGas = maxPriorityFeePerGas\n ? toHex(maxPriorityFeePerGas)\n : undefined;\n\n // The original transaction is estimated ahead of the quote steps, so it owns\n // the leading limit when each transaction has its own.\n if (gasLimits.length > quoteStepTransactions.length) {\n prependedParams.gas = toHex(gasLimits[0]);\n }\n\n log('Prepending post-quote original tx', { hasAccountOverride });\n\n return [{ params: prependedParams }, ...quoteStepTransactions];\n}\n\n/**\n * Build TransactionParams for a delegation that redeems the original\n * post-quote transaction on behalf of the override account.\n *\n * @param transaction - Original transaction meta to be redeemed.\n * @param messenger - Controller messenger.\n * @returns Transaction params for the delegation tx.\n */\nasync function buildDelegatedOriginalParams(\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<TransactionParams> {\n const delegation = await messenger.call(\n 'TransactionPayController:getDelegationTransaction',\n { transaction },\n );\n\n log('Delegation result for post-quote original tx', delegation);\n\n return {\n data: delegation.data,\n from: transaction.txParams.from,\n to: delegation.to,\n value: delegation.value,\n };\n}\n\n/**\n * Validate that the user's source token balance covers the quote's required\n * source amount before submitting on-chain.\n *\n * Reads the live balance via RPC rather than the cached state so it reflects\n * any concurrent spends. Throws fast with a clear error instead of letting\n * the on-chain transaction revert.\n *\n * @param quote - Server quote containing the required source amount.\n * @param messenger - Controller messenger.\n */\nasync function validateSourceBalance(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n): Promise<void> {\n const { from, sourceChainId, sourceTokenAddress } = quote.request;\n\n const normalizedSourceTokenAddress = normalizeTokenAddress(\n sourceTokenAddress,\n sourceChainId,\n TokenAddressTarget.MetaMask,\n );\n\n let currentBalance: string;\n\n try {\n currentBalance = await getLiveTokenBalance(\n messenger,\n from,\n sourceChainId,\n normalizedSourceTokenAddress,\n );\n } catch (error) {\n throw new Error(\n `Cannot validate payment token balance - ${(error as Error).message}`,\n );\n }\n\n const requiredAmount = new BigNumber(quote.sourceAmount.raw);\n const balance = new BigNumber(currentBalance);\n\n log('Validating source balance', {\n from,\n sourceChainId,\n sourceTokenAddress,\n currentBalance,\n requiredAmount: requiredAmount.toString(10),\n });\n\n if (balance.isLessThan(requiredAmount)) {\n throw new Error(\n `Insufficient source token balance for server deposit. ` +\n `Required: ${requiredAmount.toString(10)}, ` +\n `Available: ${balance.toString(10)}`,\n );\n }\n}\n\nasync function submitViaServerExecute(\n quote: TransactionPayQuote<ServerQuote>,\n stepTransactions: StepTransaction[],\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<void> {\n const { from, sourceChainId } = quote.request;\n const networkClientId = getNetworkClientId(messenger, sourceChainId);\n\n const nestedTransactions = stepTransactions.map(({ params }) => ({\n data: (params.data ?? '0x') as Hex,\n to: params.to as Hex,\n value: (params.value ?? '0x0') as Hex,\n }));\n\n const sourceCallTransaction = {\n ...transaction,\n chainId: sourceChainId,\n networkClientId,\n nestedTransactions,\n txParams: {\n ...transaction.txParams,\n from,\n },\n } as TransactionMeta;\n\n const delegation = await messenger.call(\n 'TransactionPayController:getDelegationTransaction',\n { transaction: sourceCallTransaction },\n );\n\n log('Delegation result for server source calls', delegation);\n\n const submitBody: ServerSubmitRequest = {\n provider: quote.original.provider,\n id: quote.original.id,\n chainId: Number(sourceChainId),\n to: delegation.to,\n data: delegation.data,\n value: new BigNumber(delegation.value).toFixed(),\n ...(delegation.authorizationList?.length\n ? {\n authorizationList: delegation.authorizationList.map((auth) => ({\n chainId: Number(auth.chainId),\n address: auth.address,\n nonce: Number(auth.nonce),\n yParity: Number(auth.yParity),\n r: auth.r as Hex,\n s: auth.s as Hex,\n })),\n }\n : {}),\n };\n\n const submitResponse = await submitServerIntent(messenger, submitBody);\n\n if (!submitResponse.success) {\n throw new Error(\n `Server submit failed: ${submitResponse.error ?? 'unknown'}`,\n );\n }\n}\n\nasync function submitViaTransactionController(\n quote: TransactionPayQuote<ServerQuote>,\n stepTransactions: StepTransaction[],\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n gasPayment: GasPayment,\n): Promise<void> {\n const { from, sourceChainId } = quote.request;\n const { gasLimits, is7702 } = quote.original.client;\n const { excludeNativeTokenForFee, gasFeeToken } = gasPayment;\n\n const networkClientId = getNetworkClientId(messenger, sourceChainId);\n\n log('Submitting via TransactionController', {\n from,\n gasFeeToken,\n is7702,\n networkClientId,\n transactionCount: stepTransactions.length,\n sourceChainId,\n });\n\n const transactionIds: string[] = [];\n const { end } = collectTransactionIds(\n sourceChainId,\n from,\n messenger,\n (transactionId) => {\n transactionIds.push(transactionId);\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add required transaction ID from server submission',\n },\n (tx) => {\n tx.requiredTransactionIds ??= [];\n tx.requiredTransactionIds.push(transactionId);\n },\n );\n },\n );\n\n try {\n if (stepTransactions.length === 1) {\n const { params, type } = stepTransactions[0];\n\n const addTransactionOptions = {\n excludeNativeTokenForFee,\n gasFeeToken,\n isGasFeeSponsored: gasPayment.isGasFeeSponsored,\n isInternal: true,\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n type,\n };\n\n log('Calling addTransaction', {\n params,\n options: addTransactionOptions,\n });\n\n await messenger.call(\n 'TransactionController:addTransaction',\n params,\n addTransactionOptions,\n );\n } else {\n const gasLimit7702 = is7702 ? toHex(gasLimits[0]) : undefined;\n\n const batchTransactions = stepTransactions.map(({ params, type }) => {\n // params.gas was already resolved correctly by buildStepTransaction\n // (indexed by quote-step position), so use it directly. Indexing\n // the step position into gasLimits would be wrong when payment-\n // override or post-quote transactions are prepended. In an EIP-7702\n // batch, the outer limit is passed as gasLimit7702 and nested gas is\n // not supported, so it is omitted.\n const gas =\n gasLimit7702 === undefined\n ? (params.gas as Hex | undefined)\n : undefined;\n\n return {\n params: {\n data: params.data as Hex,\n gas,\n maxFeePerGas: params.maxFeePerGas as Hex,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas as Hex,\n to: params.to as Hex,\n value: params.value as Hex,\n },\n type,\n };\n });\n\n const addTransactionBatchOptions = {\n from,\n ...(gasLimit7702 === undefined\n ? { disable7702: true }\n : {\n disable7702: false,\n disableHook: true,\n disableSequential: true,\n gasLimit7702,\n }),\n excludeNativeTokenForFee,\n gasFeeToken,\n isGasFeeSponsored: gasPayment.isGasFeeSponsored,\n isInternal: true,\n networkClientId,\n origin: ORIGIN_METAMASK,\n overwriteUpgrade: true,\n requireApproval: false,\n transactions: batchTransactions,\n };\n\n log('Calling addTransactionBatch', addTransactionBatchOptions);\n\n await messenger.call(\n 'TransactionController:addTransactionBatch',\n addTransactionBatchOptions,\n );\n }\n } finally {\n end();\n }\n\n log('Server transactions added', transactionIds);\n\n await Promise.all(\n transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)),\n );\n\n log('Server transactions confirmed', transactionIds);\n\n logGasPaymentOutcome(\n gasPayment,\n transactionIds.map((txId) => getTransaction(txId, messenger)),\n );\n\n const lastId = transactionIds.at(-1);\n const sourceHash = lastId\n ? getTransaction(lastId, messenger)?.hash\n : undefined;\n\n if (sourceHash) {\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add source hash from server transaction submission',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash as Hex;\n },\n );\n }\n}\n\nasync function submitSignatureStep(\n step: ServerSignatureStep,\n from: Hex,\n messenger: TransactionPayControllerMessenger,\n): Promise<void> {\n const { sign, post } = step;\n\n const typedData = {\n domain: sign.domain,\n types: {\n ...sign.types,\n EIP712Domain: deriveEIP712DomainType(sign.domain),\n },\n primaryType: sign.primaryType,\n message: sign.value,\n };\n\n log('Signing typed data for signature step', {\n primaryType: sign.primaryType,\n });\n\n const signature = await messenger.call(\n 'KeyringController:signTypedMessage',\n { from, data: JSON.stringify(typedData) },\n SignTypedDataVersion.V4,\n );\n\n await postSignatureStepResult(\n post.endpoint,\n post.method,\n post.body,\n signature,\n post.signatureFormat,\n );\n}\n\nasync function postSignatureStepResult(\n endpoint: string,\n method: string,\n body: Record<string, unknown>,\n signature: string,\n signatureFormat: 'queryParam' | 'rsv',\n): Promise<void> {\n let url = endpoint;\n let postBody: Record<string, unknown>;\n\n if (signatureFormat === 'queryParam') {\n url = `${endpoint}?signature=${signature}`;\n postBody = body;\n } else {\n // eslint-disable-next-line id-length\n const r = signature.slice(0, 66);\n // eslint-disable-next-line id-length\n const s = `0x${signature.slice(66, 130)}`;\n // eslint-disable-next-line id-length\n const v = parseInt(signature.slice(130, 132), 16);\n postBody = { ...body, signature: { r, s, v } };\n }\n\n log('Posting signature step result', { url, signatureFormat });\n\n let result: unknown;\n\n try {\n const response = await successfulFetch(url, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(postBody),\n });\n\n result = await response.json();\n } catch (error) {\n throw new Error(`Signature step POST failed: ${(error as Error).message}`);\n }\n\n log('Signature step POST response', result);\n\n // For rsv-format steps (HyperLiquid exchange endpoint) the response body\n // carries an explicit status field. Validate it here so a failed deposit\n // throws immediately rather than silently proceeding to the polling phase.\n if (signatureFormat === 'rsv') {\n const status = (result as { status?: string })?.status;\n\n if (status !== 'ok') {\n throw new Error(\n `Signature step rejected by server: ${JSON.stringify(result)}`,\n );\n }\n }\n}\n\nfunction deriveEIP712DomainType(\n domain: Record<string, unknown>,\n): { name: string; type: string }[] {\n return Object.keys(DOMAIN_FIELD_MAP)\n .filter((key) => Object.prototype.hasOwnProperty.call(domain, key))\n .map((key) => DOMAIN_FIELD_MAP[key]);\n}\n\n/**\n * Poll the server until the intent reaches a terminal status.\n *\n * Failures are returned rather than thrown so callers can clean up first, such\n * as sweeping a deposit wallet refund. Timeouts still throw.\n *\n * @param quote - Server quote being polled.\n * @param messenger - Controller messenger.\n * @param transactionId - ID of the parent transaction.\n * @returns The terminal status and the target-chain hash when reported.\n */\nasync function waitForServerCompletion(\n quote: ServerQuote,\n messenger: TransactionPayControllerMessenger,\n transactionId: string,\n): Promise<ServerCompletion> {\n const pollingInterval = getServerPollingInterval(messenger);\n const pollingTimeout = getServerPollingTimeout(messenger);\n const hasTimeout = pollingTimeout !== undefined && pollingTimeout > 0;\n\n log('Server polling config', { pollingInterval, pollingTimeout });\n\n const startTime = Date.now();\n\n let lastStatus: string | undefined;\n let sourceHashEmitted = false;\n\n while (true) {\n let statusResponse: ServerStatusResponse | undefined;\n\n try {\n const tx = getTransaction(transactionId, messenger);\n\n statusResponse = await getServerStatus(messenger, {\n provider: quote.provider,\n id: quote.id,\n hash: tx?.metamaskPay?.sourceHash ?? tx?.hash,\n });\n } catch (error) {\n log('Polling network error', error);\n }\n\n if (statusResponse) {\n lastStatus = statusResponse.status;\n log('Polled status', statusResponse.status, statusResponse);\n\n if (!sourceHashEmitted && statusResponse.sourceHash) {\n sourceHashEmitted = true;\n const { sourceHash } = statusResponse;\n\n updateTransaction(\n {\n transactionId,\n messenger,\n note: 'Add source hash from server status',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash;\n },\n );\n }\n\n const { status, targetHash } = statusResponse;\n\n if (\n status === ServerStatus.Confirmed ||\n status === ServerStatus.Failed ||\n status === ServerStatus.Refunded\n ) {\n return { status, targetHash };\n }\n }\n\n if (hasTimeout && Date.now() - startTime >= pollingTimeout) {\n const statusDetail = lastStatus ? ` (last status: ${lastStatus})` : '';\n throw new Error(`Server polling timed out${statusDetail}`);\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n }\n}\n"]}
1
+ {"version":3,"file":"server-submit.js","sourceRoot":"","sources":["../../../src/strategy/server/server-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,KAAK,GACN,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAQpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MA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C,MAAM,KAAK,YAAY,CAAC,MAAM;gBAC9B,MAAM,KAAK,YAAY,CAAC,QAAQ,EAChC,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,IAAI,cAAc,EAAE,CAAC;YAC3D,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,kBAAkB,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,2BAA2B,YAAY,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC","sourcesContent":["import {\n ORIGIN_METAMASK,\n successfulFetch,\n toHex,\n} from '@metamask/controller-utils';\nimport { SignTypedDataVersion } from '@metamask/keyring-controller';\nimport type {\n BatchTransactionParams,\n TransactionMeta,\n TransactionParams,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport { projectLogger } from '../../logger.js';\nimport type {\n PayStrategyExecuteRequest,\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n} from '../../types.js';\nimport { accountSupports7702 } from '../../utils/7702.js';\nimport {\n getServerPollingInterval,\n getServerPollingTimeout,\n} from '../../utils/feature-flags.js';\nimport type { GasPayment } from '../../utils/gas-payment.js';\nimport {\n GasPaymentMode,\n logGasPaymentOutcome,\n resolveGasPayment,\n} from '../../utils/gas-payment.js';\nimport {\n submitPolymarketWithdraw,\n sweepPolymarketDepositWallet,\n} from '../../utils/polymarket/withdraw.js';\nimport { getNetworkClientId } from '../../utils/provider.js';\nimport { submitSecondLeg } from '../../utils/second-leg.js';\nimport {\n getLiveTokenBalanceOrUndefined,\n normalizeTokenAddress,\n TokenAddressTarget,\n} from '../../utils/token.js';\nimport {\n collectTransactionIds,\n getTransaction,\n updateTransaction,\n waitForTransactionConfirmed,\n} from '../../utils/transaction.js';\nimport { RELAY_DEPOSIT_TYPES } from '../relay/constants.js';\nimport { getServerDepositData } from './deposit-step.js';\nimport { getServerStatus, submitServerIntent } from './server-api.js';\nimport type {\n ServerQuote,\n ServerSignatureStep,\n ServerTransactionStep,\n ServerStatusResponse,\n ServerSubmitRequest,\n} from './types.js';\nimport { ServerStatus } from './types.js';\n\nconst log = createModuleLogger(projectLogger, 'server-strategy');\n\n/**\n * Placeholder returned when an intent confirms without reporting a\n * target-chain transaction hash, so there is no settlement to read amounts\n * from.\n */\nconst MISSING_TARGET_HASH = '0x' as Hex;\n\nconst DOMAIN_FIELD_MAP: Record<string, { name: string; type: string }> = {\n name: { name: 'name', type: 'string' },\n version: { name: 'version', type: 'string' },\n chainId: { name: 'chainId', type: 'uint256' },\n verifyingContract: { name: 'verifyingContract', type: 'address' },\n salt: { name: 'salt', type: 'bytes32' },\n};\n\n/**\n * A transaction to submit for a single quote step.\n *\n * The semantic transaction type is held alongside `params` rather than within\n * it, since `TransactionParams.type` is the EVM envelope type (`0x0` - `0x4`)\n * and is rejected by the transaction controller if given anything else.\n */\ntype StepTransaction = {\n params: TransactionParams;\n type?: TransactionType;\n};\n\n/** Terminal outcome of a server intent. */\ntype ServerCompletion = {\n status: ServerStatus.Confirmed | ServerStatus.Failed | ServerStatus.Refunded;\n targetHash?: Hex;\n};\n\nfunction isSignatureStep(\n step: ServerQuote['steps'][number],\n): step is ServerSignatureStep {\n return step.type === 'signature';\n}\n\nfunction isTransactionStep(\n step: ServerQuote['steps'][number],\n): step is ServerTransactionStep {\n return step.type === 'transaction';\n}\n\n/**\n * Submits server intent quotes.\n *\n * @param request - Request object.\n * @returns An object containing the transaction hash if available.\n */\nexport async function submitServerQuotes(\n request: PayStrategyExecuteRequest<ServerQuote>,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing server quotes', request);\n\n const { quotes, messenger, transaction } = request;\n\n let transactionHash: Hex | undefined;\n\n for (const quote of quotes) {\n ({ transactionHash } = await executeSingleServerQuote(\n quote,\n messenger,\n transaction,\n ));\n }\n\n return { transactionHash };\n}\n\nasync function executeSingleServerQuote(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing single server quote', quote);\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Remove nonce from skipped transaction',\n },\n (tx) => {\n tx.txParams.nonce = undefined;\n },\n );\n\n const isDepositWallet = Boolean(quote.request.isPolymarketDepositWallet);\n\n // Phase 1: off-chain signature steps (e.g. Relay authorize, HyperLiquid deposit).\n // Use quote.request.from (resolved accountOverride) not transaction.txParams.from.\n const signatureSteps = quote.original.steps.filter(isSignatureStep);\n\n for (const step of signatureSteps) {\n await submitSignatureStep(step, quote.request.from, messenger);\n }\n\n // Phase 2: on-chain transaction steps (if any). A deposit wallet withdraw\n // replaces them with an unwrap straight to the provider deposit address.\n let preSubmitUsdceBalance: bigint | undefined;\n\n if (isDepositWallet) {\n preSubmitUsdceBalance = await submitDepositWalletWithdraw(\n quote,\n messenger,\n transaction,\n );\n } else {\n await submitTransactionSteps(quote, messenger, transaction);\n }\n\n // Phase 3: poll until the intent settles on the target chain.\n const completion = await waitForServerCompletion(\n quote.original,\n messenger,\n transaction.id,\n );\n\n log('Server request completed', completion);\n\n // A deposit wallet sweeps leftover USDC.e back into pUSD whatever the\n // outcome, so a refund is restored before the failure is reported.\n if (preSubmitUsdceBalance !== undefined) {\n await sweepPolymarketDepositWallet({\n from: quote.request.from,\n isRefund: completion.status === ServerStatus.Refunded,\n messenger,\n preSubmitUsdceBalance,\n });\n }\n\n if (completion.status !== ServerStatus.Confirmed) {\n throw new Error(`Server intent ${completion.status.toLowerCase()}`);\n }\n\n const targetHash = completion.targetHash ?? MISSING_TARGET_HASH;\n\n // Phase 4: submit the calls the quote could not execute itself, now that the\n // funds have settled on the target chain.\n const secondLegHash = quote.requiresSecondLeg\n ? await submitServerSecondLeg(quote, messenger, transaction, targetHash)\n : undefined;\n\n // Only complete once every leg has landed, so a failed second leg does not\n // leave the parent transaction flagged as achieved.\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Intent complete after Server completion',\n },\n (tx) => {\n tx.isIntentComplete = true;\n },\n );\n\n return { transactionHash: secondLegHash ?? targetHash };\n}\n\n/**\n * Submit the calls a server quote could not execute itself, from the account\n * the funds settled on.\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n * @param targetHash - Hash of the settlement on the target chain.\n * @returns Hash of the second-leg transaction, if available.\n */\nasync function submitServerSecondLeg(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n targetHash: Hex | undefined,\n): Promise<Hex | undefined> {\n const { from, isPostQuote, recipient, targetChainId, targetTokenAddress } =\n quote.request;\n\n const { transactionHash } = await submitSecondLeg({\n chainId: targetChainId,\n from: recipient ?? from,\n // Post-quote flows carry no calls of their own, so the payment override\n // builds the batch for the settled amount.\n getCalls: isPostQuote\n ? async (sourceAmountRaw): Promise<BatchTransactionParams[]> =>\n await buildPaymentOverrideCalls({\n messenger,\n quote,\n sourceAmountRaw,\n transaction,\n })\n : undefined,\n messenger,\n settlementHash: targetHash === MISSING_TARGET_HASH ? undefined : targetHash,\n tokenAddress: targetTokenAddress,\n transaction,\n });\n\n return transactionHash;\n}\n\n/**\n * Build the second-leg batch from the payment override for the settled amount.\n *\n * @param options - Build options.\n * @param options.messenger - Controller messenger.\n * @param options.quote - Server quote that settled.\n * @param options.sourceAmountRaw - Settled amount in raw units.\n * @param options.transaction - Original transaction meta.\n * @returns The batch calls.\n */\nasync function buildPaymentOverrideCalls({\n messenger,\n quote,\n sourceAmountRaw,\n transaction,\n}: {\n messenger: TransactionPayControllerMessenger;\n quote: TransactionPayQuote<ServerQuote>;\n sourceAmountRaw: string;\n transaction: TransactionMeta;\n}): Promise<BatchTransactionParams[]> {\n const { transactionData } = messenger.call(\n 'TransactionPayController:getState',\n );\n\n const amount = new BigNumber(sourceAmountRaw)\n .shiftedBy(-quote.original.output.decimals)\n .toFixed();\n\n const { calls } = await messenger.call(\n 'TransactionPayController:getPaymentOverrideData',\n {\n amount,\n transaction,\n transactionData: transactionData[transaction.id],\n },\n );\n\n return calls;\n}\n\n/**\n * Unwrap the deposit wallet's pUSD straight to the provider deposit address.\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n * @returns The deposit wallet's USDC.e balance before submission, so the sweep\n * can detect a refund.\n */\nasync function submitDepositWalletWithdraw(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<bigint> {\n const { preSubmitUsdceBalance, sourceHash } = await submitPolymarketWithdraw({\n depositData: getServerDepositData(quote.original),\n from: quote.request.from,\n messenger,\n sourceAmountRaw: quote.sourceAmount.raw,\n });\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add source hash from deposit wallet withdraw',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash;\n },\n );\n\n return preSubmitUsdceBalance;\n}\n\n/**\n * Submit the on-chain transaction steps for a server quote.\n *\n * Validates the source balance, builds the complete set of transactions (including\n * any post-quote or payment-override prepends), then dispatches to the\n * gasless execute path or TransactionController depending on the quote.\n *\n * No-ops when the quote has no transaction steps (signature-only flows).\n *\n * @param quote - Server quote.\n * @param messenger - Controller messenger.\n * @param transaction - Original transaction meta.\n */\nasync function submitTransactionSteps(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<void> {\n const transactionSteps = quote.original.steps.filter(isTransactionStep);\n\n if (transactionSteps.length === 0) {\n // Signature-only quotes (all steps are signature steps, no transaction\n // steps) have nothing to submit on-chain even when gasless is false.\n const hasSignatureSteps = quote.original.steps.some(isSignatureStep);\n if (!quote.original.gasless && !hasSignatureSteps) {\n throw new Error('Server quote has no steps to submit');\n }\n return;\n }\n\n const { isHyperliquidSource, isPostQuote, paymentOverride } = quote.request;\n\n // Skip balance check for HyperLiquid source flows (no on-chain debit),\n // post-quote flows (funds come from the Safe after the original tx executes),\n // and payment-override flows (funds are supplied by the override account).\n if (!isHyperliquidSource && !isPostQuote && !paymentOverride) {\n await validateSourceBalance(quote, messenger);\n }\n\n const stepTransactions = await buildStepTransactions(\n quote,\n transactionSteps,\n transaction,\n messenger,\n );\n\n const gasPayment = resolveGasPayment({\n isDelegated: quote.original.gasless,\n isSourceGasFeeToken: quote.fees.isSourceGasFeeToken,\n sourceTokenAddress: quote.request.sourceTokenAddress,\n sponsorship: {\n accountSupports7702: accountSupports7702(messenger, quote.request.from),\n request: quote.request,\n transaction,\n },\n });\n\n if (gasPayment.mode === GasPaymentMode.Delegation) {\n await submitViaServerExecute(\n quote,\n stepTransactions,\n messenger,\n transaction,\n );\n } else {\n await submitViaTransactionController(\n quote,\n stepTransactions,\n messenger,\n transaction,\n gasPayment,\n );\n }\n}\n\n/**\n * Build the complete flat array of transactions for on-chain submission.\n *\n * Converts server transaction steps to transactions, then prepends any\n * additional calls required by the payment override or post-quote flow. The\n * returned array is ready to pass directly to submitViaServerExecute or\n * submitViaTransactionController.\n *\n * @param quote - Server quote.\n * @param transactionSteps - Transaction steps from the quote (pre-filtered).\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Complete ordered array of transactions for submission.\n */\nasync function buildStepTransactions(\n quote: TransactionPayQuote<ServerQuote>,\n transactionSteps: ServerTransactionStep[],\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const { atomic, from, isPostQuote, paymentOverride } = quote.request;\n const { gasLimits, maxFeePerGas, maxPriorityFeePerGas } =\n quote.original.client;\n const originalType = getEffectiveTransactionType(transaction);\n\n // Client gas limits are estimated in submission order, so any prepended\n // transactions come first and the quote steps take the trailing limits.\n const stepGasLimits = gasLimits.slice(\n Math.max(gasLimits.length - transactionSteps.length, 0),\n );\n\n const quoteStepTransactions = transactionSteps.map((step, i) =>\n buildStepTransaction(\n step,\n i,\n transactionSteps.length,\n from,\n stepGasLimits,\n maxFeePerGas,\n maxPriorityFeePerGas,\n originalType,\n ),\n );\n\n // Non-atomic flows run the override calls as a second leg once the funds\n // settle, so prepending them here would run them twice.\n if (paymentOverride && atomic !== false) {\n return prependPaymentOverrideTransactions(\n quoteStepTransactions,\n quote,\n transaction,\n messenger,\n );\n }\n\n if (isPostQuote && transaction.txParams.to) {\n return prependPostQuoteTransactions(\n quoteStepTransactions,\n quote,\n transaction,\n messenger,\n );\n }\n\n return quoteStepTransactions;\n}\n\n/**\n * Converts a single server transaction step to a transaction.\n *\n * @param step - The transaction step.\n * @param index - Zero-based position within the transaction steps array.\n * @param totalSteps - Total number of transaction steps (for type mapping).\n * @param from - Sender address.\n * @param gasLimits - Per-step gas limits from client-side estimation.\n * @param clientMaxFeePerGas - Client-side max fee per gas fallback.\n * @param clientMaxPriorityFeePerGas - Client-side max priority fee per gas fallback.\n * @param originalType - Effective type of the parent transaction.\n * @returns Normalized transaction for this step.\n */\nfunction buildStepTransaction(\n step: ServerTransactionStep,\n index: number,\n totalSteps: number,\n from: Hex,\n gasLimits: number[],\n clientMaxFeePerGas: string | undefined,\n clientMaxPriorityFeePerGas: string | undefined,\n originalType: TransactionMeta['type'],\n): StepTransaction {\n let gas: Hex | undefined;\n const gasLimit = gasLimits[index];\n\n if (gasLimit) {\n gas = toHex(gasLimit);\n } else if (step.gasLimit) {\n gas = toHex(step.gasLimit);\n }\n\n const resolvedMaxFeePerGas = step.maxFeePerGas ?? clientMaxFeePerGas;\n const resolvedMaxPriorityFeePerGas =\n step.maxPriorityFeePerGas ?? clientMaxPriorityFeePerGas;\n\n const params: TransactionParams = {\n data: step.data,\n from,\n gas,\n maxFeePerGas: resolvedMaxFeePerGas\n ? toHex(resolvedMaxFeePerGas)\n : undefined,\n maxPriorityFeePerGas: resolvedMaxPriorityFeePerGas\n ? toHex(resolvedMaxPriorityFeePerGas)\n : undefined,\n to: step.to,\n value: toHex(step.value),\n };\n\n const type = getTransactionType(index, totalSteps, originalType);\n\n log('Built transaction for step', {\n index,\n step: {\n gasLimit: step.gasLimit,\n maxFeePerGas: step.maxFeePerGas,\n maxPriorityFeePerGas: step.maxPriorityFeePerGas,\n value: step.value,\n },\n params: {\n gas: params.gas,\n maxFeePerGas: params.maxFeePerGas,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas,\n type,\n value: params.value,\n },\n });\n\n return { params, type };\n}\n\n/**\n * Determine the relay deposit transaction type for a step at the given index.\n *\n * Single-step quotes always use the deposit type. In multi-step quotes the\n * first step is an approval and subsequent steps are deposits — matching the\n * Relay strategy's convention.\n *\n * @param index - Zero-based index of the step within the transaction step array.\n * @param totalSteps - Total number of transaction steps.\n * @param originalType - Effective type of the parent transaction.\n * @returns The mapped TransactionType for this step.\n */\nfunction getTransactionType(\n index: number,\n totalSteps: number,\n originalType: TransactionMeta['type'],\n): TransactionType {\n const depositType = getRelayDepositType(originalType);\n\n if (totalSteps === 1) {\n return depositType;\n }\n\n return index === 0 ? ('tokenMethodApprove' as TransactionType) : depositType;\n}\n\n/**\n * Get the relay deposit transaction type based on the parent transaction type.\n *\n * @param originalType - Type of the parent transaction.\n * @returns The mapped relay deposit type, or `relayDeposit` as a fallback.\n */\nfunction getRelayDepositType(\n originalType: TransactionMeta['type'],\n): TransactionType {\n return (\n (originalType && RELAY_DEPOSIT_TYPES[originalType]) ??\n ('relayDeposit' as TransactionType)\n );\n}\n\n/**\n * Get the effective transaction type, resolving through batch-type parent\n * transactions to find the nested perps/predict type.\n *\n * @param transaction - The transaction metadata.\n * @returns The resolved type from nested transactions, or the top-level type.\n */\nfunction getEffectiveTransactionType(\n transaction: TransactionMeta,\n): TransactionMeta['type'] {\n if (transaction.type !== ('batch' as TransactionType)) {\n return transaction.type;\n }\n\n const nestedType = transaction.nestedTransactions?.find(\n (tx) => tx.type && RELAY_DEPOSIT_TYPES[tx.type] !== undefined,\n )?.type;\n\n return nestedType ?? transaction.type;\n}\n\n/**\n * Prepend payment override calls before the quote transaction steps.\n *\n * For money-account payment override flows the override account supplies\n * the source funds. The override transactions must be batched ahead of the\n * deposit steps.\n *\n * @param quoteStepTransactions - Transactions already built from the quote steps.\n * @param quote - Server quote.\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Combined transactions with override calls prepended.\n */\nasync function prependPaymentOverrideTransactions(\n quoteStepTransactions: StepTransaction[],\n quote: TransactionPayQuote<ServerQuote>,\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const { transactionData } = messenger.call(\n 'TransactionPayController:getState',\n );\n\n const { calls: overrideCalls } = await messenger.call(\n 'TransactionPayController:getPaymentOverrideData',\n {\n amount: quote.sourceAmount.human,\n transaction,\n transactionData: transactionData[transaction.id],\n },\n );\n\n if (!overrideCalls.length) {\n log('No payment override calls to prepend');\n return quoteStepTransactions;\n }\n\n log('Prepending payment override calls', { count: overrideCalls.length });\n\n const overrideTransactions = (overrideCalls as TransactionParams[]).map(\n (params) => ({\n params,\n }),\n );\n\n return [...overrideTransactions, ...quoteStepTransactions];\n}\n\n/**\n * Prepend the original transaction (or a delegation-wrapped version) before\n * the deposit steps for post-quote flows.\n *\n * In post-quote flows the source tokens are held in the Safe and only become\n * available after the original transaction executes as part of the batch.\n * When an accountOverride is active the override account cannot directly\n * execute the original call, so it is wrapped in a delegation transaction.\n *\n * @param quoteStepTransactions - Transactions already built from the quote steps.\n * @param quote - Server quote.\n * @param transaction - Original transaction meta.\n * @param messenger - Controller messenger.\n * @returns Combined transactions with the original tx prepended.\n */\nasync function prependPostQuoteTransactions(\n quoteStepTransactions: StepTransaction[],\n quote: TransactionPayQuote<ServerQuote>,\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<StepTransaction[]> {\n const hasAccountOverride =\n quote.request.from.toLowerCase() !==\n (transaction.txParams.from as Hex).toLowerCase();\n\n const { gasLimits, maxFeePerGas, maxPriorityFeePerGas } =\n quote.original.client;\n\n let prependedParams: TransactionParams;\n\n if (hasAccountOverride) {\n prependedParams = await buildDelegatedOriginalParams(\n transaction,\n messenger,\n );\n } else {\n prependedParams = {\n data: transaction.txParams.data,\n from: transaction.txParams.from,\n to: transaction.txParams.to,\n value: transaction.txParams.value,\n };\n }\n\n // Ensure the prepended tx carries the same fee caps as the quote steps so\n // it isn't submitted with undefined maxFeePerGas in a non-7702 batch.\n prependedParams.maxFeePerGas = maxFeePerGas ? toHex(maxFeePerGas) : undefined;\n prependedParams.maxPriorityFeePerGas = maxPriorityFeePerGas\n ? toHex(maxPriorityFeePerGas)\n : undefined;\n\n // The original transaction is estimated ahead of the quote steps, so it owns\n // the leading limit when each transaction has its own.\n if (gasLimits.length > quoteStepTransactions.length) {\n prependedParams.gas = toHex(gasLimits[0]);\n }\n\n log('Prepending post-quote original tx', { hasAccountOverride });\n\n return [{ params: prependedParams }, ...quoteStepTransactions];\n}\n\n/**\n * Build TransactionParams for a delegation that redeems the original\n * post-quote transaction on behalf of the override account.\n *\n * @param transaction - Original transaction meta to be redeemed.\n * @param messenger - Controller messenger.\n * @returns Transaction params for the delegation tx.\n */\nasync function buildDelegatedOriginalParams(\n transaction: TransactionMeta,\n messenger: TransactionPayControllerMessenger,\n): Promise<TransactionParams> {\n const delegation = await messenger.call(\n 'TransactionPayController:getDelegationTransaction',\n { transaction },\n );\n\n log('Delegation result for post-quote original tx', delegation);\n\n return {\n data: delegation.data,\n from: transaction.txParams.from,\n to: delegation.to,\n value: delegation.value,\n };\n}\n\n/**\n * Validate that the user's source token balance covers the quote's required\n * source amount before submitting on-chain.\n *\n * Reads the live balance via RPC rather than the cached state so it reflects\n * any concurrent spends. Throws fast with a clear error instead of letting\n * the on-chain transaction revert.\n *\n * This is a fast-fail optimisation, not a safety net: if the balance cannot be\n * read the check is skipped and submission proceeds, since the server and the\n * chain still reject an underfunded transaction.\n *\n * @param quote - Server quote containing the required source amount.\n * @param messenger - Controller messenger.\n */\nasync function validateSourceBalance(\n quote: TransactionPayQuote<ServerQuote>,\n messenger: TransactionPayControllerMessenger,\n): Promise<void> {\n const { from, sourceChainId, sourceTokenAddress } = quote.request;\n\n const normalizedSourceTokenAddress = normalizeTokenAddress(\n sourceTokenAddress,\n sourceChainId,\n TokenAddressTarget.MetaMask,\n );\n\n const currentBalance = await getLiveTokenBalanceOrUndefined(\n messenger,\n from,\n sourceChainId,\n normalizedSourceTokenAddress,\n );\n\n // An unreadable balance is unknown, not insufficient. Submit anyway and let\n // the server and the chain reject a genuinely underfunded transaction.\n if (currentBalance === undefined) {\n log('Skipping source balance check: live balance unavailable', {\n from,\n sourceChainId,\n sourceTokenAddress,\n });\n return;\n }\n\n const requiredAmount = new BigNumber(quote.sourceAmount.raw);\n const balance = new BigNumber(currentBalance);\n\n log('Validating source balance', {\n from,\n sourceChainId,\n sourceTokenAddress,\n currentBalance,\n requiredAmount: requiredAmount.toString(10),\n });\n\n if (balance.isLessThan(requiredAmount)) {\n throw new Error(\n `Insufficient source token balance for server deposit. ` +\n `Required: ${requiredAmount.toString(10)}, ` +\n `Available: ${balance.toString(10)}`,\n );\n }\n}\n\nasync function submitViaServerExecute(\n quote: TransactionPayQuote<ServerQuote>,\n stepTransactions: StepTransaction[],\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<void> {\n const { from, sourceChainId } = quote.request;\n const networkClientId = getNetworkClientId(messenger, sourceChainId);\n\n const nestedTransactions = stepTransactions.map(({ params }) => ({\n data: (params.data ?? '0x') as Hex,\n to: params.to as Hex,\n value: (params.value ?? '0x0') as Hex,\n }));\n\n const sourceCallTransaction = {\n ...transaction,\n chainId: sourceChainId,\n networkClientId,\n nestedTransactions,\n txParams: {\n ...transaction.txParams,\n from,\n },\n } as TransactionMeta;\n\n const delegation = await messenger.call(\n 'TransactionPayController:getDelegationTransaction',\n { transaction: sourceCallTransaction },\n );\n\n log('Delegation result for server source calls', delegation);\n\n const submitBody: ServerSubmitRequest = {\n provider: quote.original.provider,\n id: quote.original.id,\n chainId: Number(sourceChainId),\n to: delegation.to,\n data: delegation.data,\n value: new BigNumber(delegation.value).toFixed(),\n ...(delegation.authorizationList?.length\n ? {\n authorizationList: delegation.authorizationList.map((auth) => ({\n chainId: Number(auth.chainId),\n address: auth.address,\n nonce: Number(auth.nonce),\n yParity: Number(auth.yParity),\n r: auth.r as Hex,\n s: auth.s as Hex,\n })),\n }\n : {}),\n };\n\n const submitResponse = await submitServerIntent(messenger, submitBody);\n\n if (!submitResponse.success) {\n throw new Error(\n `Server submit failed: ${submitResponse.error ?? 'unknown'}`,\n );\n }\n}\n\nasync function submitViaTransactionController(\n quote: TransactionPayQuote<ServerQuote>,\n stepTransactions: StepTransaction[],\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n gasPayment: GasPayment,\n): Promise<void> {\n const { from, sourceChainId } = quote.request;\n const { gasLimits, is7702 } = quote.original.client;\n const { excludeNativeTokenForFee, gasFeeToken } = gasPayment;\n\n const networkClientId = getNetworkClientId(messenger, sourceChainId);\n\n log('Submitting via TransactionController', {\n from,\n gasFeeToken,\n is7702,\n networkClientId,\n transactionCount: stepTransactions.length,\n sourceChainId,\n });\n\n const transactionIds: string[] = [];\n const { end } = collectTransactionIds(\n sourceChainId,\n from,\n messenger,\n (transactionId) => {\n transactionIds.push(transactionId);\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add required transaction ID from server submission',\n },\n (tx) => {\n tx.requiredTransactionIds ??= [];\n tx.requiredTransactionIds.push(transactionId);\n },\n );\n },\n );\n\n try {\n if (stepTransactions.length === 1) {\n const { params, type } = stepTransactions[0];\n\n const addTransactionOptions = {\n excludeNativeTokenForFee,\n gasFeeToken,\n isGasFeeSponsored: gasPayment.isGasFeeSponsored,\n isInternal: true,\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n type,\n };\n\n log('Calling addTransaction', {\n params,\n options: addTransactionOptions,\n });\n\n await messenger.call(\n 'TransactionController:addTransaction',\n params,\n addTransactionOptions,\n );\n } else {\n const gasLimit7702 = is7702 ? toHex(gasLimits[0]) : undefined;\n\n const batchTransactions = stepTransactions.map(({ params, type }) => {\n // params.gas was already resolved correctly by buildStepTransaction\n // (indexed by quote-step position), so use it directly. Indexing\n // the step position into gasLimits would be wrong when payment-\n // override or post-quote transactions are prepended. In an EIP-7702\n // batch, the outer limit is passed as gasLimit7702 and nested gas is\n // not supported, so it is omitted.\n const gas =\n gasLimit7702 === undefined\n ? (params.gas as Hex | undefined)\n : undefined;\n\n return {\n params: {\n data: params.data as Hex,\n gas,\n maxFeePerGas: params.maxFeePerGas as Hex,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas as Hex,\n to: params.to as Hex,\n value: params.value as Hex,\n },\n type,\n };\n });\n\n const addTransactionBatchOptions = {\n from,\n ...(gasLimit7702 === undefined\n ? { disable7702: true }\n : {\n disable7702: false,\n disableHook: true,\n disableSequential: true,\n gasLimit7702,\n }),\n excludeNativeTokenForFee,\n gasFeeToken,\n isGasFeeSponsored: gasPayment.isGasFeeSponsored,\n isInternal: true,\n networkClientId,\n origin: ORIGIN_METAMASK,\n overwriteUpgrade: true,\n requireApproval: false,\n transactions: batchTransactions,\n };\n\n log('Calling addTransactionBatch', addTransactionBatchOptions);\n\n await messenger.call(\n 'TransactionController:addTransactionBatch',\n addTransactionBatchOptions,\n );\n }\n } finally {\n end();\n }\n\n log('Server transactions added', transactionIds);\n\n await Promise.all(\n transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)),\n );\n\n log('Server transactions confirmed', transactionIds);\n\n logGasPaymentOutcome(\n gasPayment,\n transactionIds.map((txId) => getTransaction(txId, messenger)),\n );\n\n const lastId = transactionIds.at(-1);\n const sourceHash = lastId\n ? getTransaction(lastId, messenger)?.hash\n : undefined;\n\n if (sourceHash) {\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Add source hash from server transaction submission',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash as Hex;\n },\n );\n }\n}\n\nasync function submitSignatureStep(\n step: ServerSignatureStep,\n from: Hex,\n messenger: TransactionPayControllerMessenger,\n): Promise<void> {\n const { sign, post } = step;\n\n const typedData = {\n domain: sign.domain,\n types: {\n ...sign.types,\n EIP712Domain: deriveEIP712DomainType(sign.domain),\n },\n primaryType: sign.primaryType,\n message: sign.value,\n };\n\n log('Signing typed data for signature step', {\n primaryType: sign.primaryType,\n });\n\n const signature = await messenger.call(\n 'KeyringController:signTypedMessage',\n { from, data: JSON.stringify(typedData) },\n SignTypedDataVersion.V4,\n );\n\n await postSignatureStepResult(\n post.endpoint,\n post.method,\n post.body,\n signature,\n post.signatureFormat,\n );\n}\n\nasync function postSignatureStepResult(\n endpoint: string,\n method: string,\n body: Record<string, unknown>,\n signature: string,\n signatureFormat: 'queryParam' | 'rsv',\n): Promise<void> {\n let url = endpoint;\n let postBody: Record<string, unknown>;\n\n if (signatureFormat === 'queryParam') {\n url = `${endpoint}?signature=${signature}`;\n postBody = body;\n } else {\n // eslint-disable-next-line id-length\n const r = signature.slice(0, 66);\n // eslint-disable-next-line id-length\n const s = `0x${signature.slice(66, 130)}`;\n // eslint-disable-next-line id-length\n const v = parseInt(signature.slice(130, 132), 16);\n postBody = { ...body, signature: { r, s, v } };\n }\n\n log('Posting signature step result', { url, signatureFormat });\n\n let result: unknown;\n\n try {\n const response = await successfulFetch(url, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(postBody),\n });\n\n result = await response.json();\n } catch (error) {\n throw new Error(`Signature step POST failed: ${(error as Error).message}`);\n }\n\n log('Signature step POST response', result);\n\n // For rsv-format steps (HyperLiquid exchange endpoint) the response body\n // carries an explicit status field. Validate it here so a failed deposit\n // throws immediately rather than silently proceeding to the polling phase.\n if (signatureFormat === 'rsv') {\n const status = (result as { status?: string })?.status;\n\n if (status !== 'ok') {\n throw new Error(\n `Signature step rejected by server: ${JSON.stringify(result)}`,\n );\n }\n }\n}\n\nfunction deriveEIP712DomainType(\n domain: Record<string, unknown>,\n): { name: string; type: string }[] {\n return Object.keys(DOMAIN_FIELD_MAP)\n .filter((key) => Object.prototype.hasOwnProperty.call(domain, key))\n .map((key) => DOMAIN_FIELD_MAP[key]);\n}\n\n/**\n * Poll the server until the intent reaches a terminal status.\n *\n * Failures are returned rather than thrown so callers can clean up first, such\n * as sweeping a deposit wallet refund. Timeouts still throw.\n *\n * @param quote - Server quote being polled.\n * @param messenger - Controller messenger.\n * @param transactionId - ID of the parent transaction.\n * @returns The terminal status and the target-chain hash when reported.\n */\nasync function waitForServerCompletion(\n quote: ServerQuote,\n messenger: TransactionPayControllerMessenger,\n transactionId: string,\n): Promise<ServerCompletion> {\n const pollingInterval = getServerPollingInterval(messenger);\n const pollingTimeout = getServerPollingTimeout(messenger);\n const hasTimeout = pollingTimeout !== undefined && pollingTimeout > 0;\n\n log('Server polling config', { pollingInterval, pollingTimeout });\n\n const startTime = Date.now();\n\n let lastStatus: string | undefined;\n let sourceHashEmitted = false;\n\n while (true) {\n let statusResponse: ServerStatusResponse | undefined;\n\n try {\n const tx = getTransaction(transactionId, messenger);\n\n statusResponse = await getServerStatus(messenger, {\n provider: quote.provider,\n id: quote.id,\n hash: tx?.metamaskPay?.sourceHash ?? tx?.hash,\n });\n } catch (error) {\n log('Polling network error', error);\n }\n\n if (statusResponse) {\n lastStatus = statusResponse.status;\n log('Polled status', statusResponse.status, statusResponse);\n\n if (!sourceHashEmitted && statusResponse.sourceHash) {\n sourceHashEmitted = true;\n const { sourceHash } = statusResponse;\n\n updateTransaction(\n {\n transactionId,\n messenger,\n note: 'Add source hash from server status',\n },\n (tx) => {\n tx.metamaskPay ??= {};\n tx.metamaskPay.sourceHash = sourceHash;\n },\n );\n }\n\n const { status, targetHash } = statusResponse;\n\n if (\n status === ServerStatus.Confirmed ||\n status === ServerStatus.Failed ||\n status === ServerStatus.Refunded\n ) {\n return { status, targetHash };\n }\n }\n\n if (hasTimeout && Date.now() - startTime >= pollingTimeout) {\n const statusDetail = lastStatus ? ` (last status: ${lastStatus})` : '';\n throw new Error(`Server polling timed out${statusDetail}`);\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n }\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -319,7 +319,13 @@ export type TransactionPaySourceAmount = {
319
319
  * Used for analytics and tests. Human-readable copy is carried by `message`
320
320
  * and `detail` on {@link QuoteErrorInfo}.
321
321
  */
322
- export type QuoteErrorReason = 'balance-unavailable' | 'insufficient-source-balance' | 'insufficient-transfer-balance' | 'no-quotes' | 'simulation-failed';
322
+ export type QuoteErrorReason =
323
+ /**
324
+ * @deprecated No longer emitted. An unreadable live balance is treated as
325
+ * unknown rather than insufficient, so it no longer blocks the quote. Kept
326
+ * so existing consumers and historical analytics still type-check.
327
+ */
328
+ 'balance-unavailable' | 'insufficient-source-balance' | 'insufficient-transfer-balance' | 'no-quotes' | 'simulation-failed';
323
329
  /**
324
330
  * Structured description of why a quote failed validation.
325
331
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,KAAK,EACV,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;A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AAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhE,4EAA4E;IAC5E,wBAAwB,EAAE,CAAC,MAAM,EAAE;QACjC,GAAG,EAAE,GAAG,CAAC;QACT,aAAa,EAAE,GAAG,CAAC;QACnB,KAAK,EAAE;YAAE,MAAM,EAAE,GAAG,CAAC;YAAC,IAAI,EAAE,GAAG,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACpD,KAAK,OAAO,CAAC;QAAE,UAAU,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CACpC,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG;IAC/B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IAEd,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8PA;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,aAAa;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC","sourcesContent":["import type { AccountsControllerGetStateAction } from '@metamask/accounts-controller';\nimport type {\n AssetsControllerGetStateAction,\n AssetsControllerStateChangeEvent,\n} from '@metamask/assets-controller';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerUnlockEvent,\n KeyringTypes,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkConfigurationByChainIdAction } from '@metamask/network-controller';\nimport type { Quote as RampsQuote } from '@metamask/ramps-controller';\nimport type {\n RampsControllerGetOrderAction,\n RampsControllerGetQuoteWithFeesAction,\n} from '@metamask/ramps-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SentinelApiServiceActions } from '@metamask/sentinel-api-service';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\n BatchTransactionParams,\n TransactionControllerAddTransactionAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetStateAction,\n TransactionControllerStateChangeEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport type {\n CONTROLLER_NAME,\n PaymentOverride,\n TransactionPayClientId,\n TransactionPayStrategy,\n} from './constants.js';\nimport type { TransactionPayControllerMethodActions } from './TransactionPayController-method-action-types.js';\n\nexport type AllowedActions =\n | AccountsControllerGetStateAction\n | AssetsControllerGetStateAction\n | GetGasFeeState\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | RampsControllerGetOrderAction\n | RampsControllerGetQuoteWithFeesAction\n | RemoteFeatureFlagControllerGetStateAction\n | SentinelApiServiceActions\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | AssetsControllerStateChangeEvent\n | KeyringControllerUnlockEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction (or `paymentOverride` batch) is executed\n * atomically with the Relay quote. Defaults to `true` (embedded in the quote\n * and executed by the Relay solver). When `false`, Pay does not embed the\n * target/override calls in the quote; the quote only bridges the required\n * asset to `recipient`, and the calls are submitted separately after Relay\n * completion. Used by flows whose second-leg amount is only known after\n * Relay settles (EXACT_INPUT max flows) or that require the second leg to\n * originate from a different signer than the Relay solver.\n * For max deposits enabled by `payStrategies.relay.atomicMaxEnabled`, this\n * is a subsidy hint: atomic quotes are retried non-atomically if not\n * subsidized, and subsidized non-atomic quotes are upgraded to atomic.\n */\n atomic?: boolean;\n\n /**\n * Whether the source of funds is HyperLiquid (HyperCore).\n * When true, the Relay strategy uses the HyperLiquid 2-step withdrawal\n * flow: (1) authorize nonce-mapping, (2) sendAsset to Relay solver.\n */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n */\n isPostQuote?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request. Use this for post-quote flows where the user's funds originate\n * from a smart contract account (e.g. Predict Safe proxy) so that refunds\n * go back to that account rather than the EOA.\n */\n refundTo?: Hex;\n};\n\n/** Callback to update transaction config. */\nexport type TransactionConfigCallback = (config: TransactionConfig) => void;\n\n/** Request passed to {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataRequest = {\n /** Amount of the source token in human-readable format. */\n amount: string;\n\n /** Metadata of the original transaction. */\n transaction: TransactionMeta;\n\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Response returned by {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataResponse = {\n /** Batch transaction params to prepend to the submit batch. */\n calls: BatchTransactionParams[];\n\n /** Optional recipient address for the funding token transfer. */\n recipient?: Hex;\n\n /** Optional EIP-7702 authorization list from delegation. */\n authorizationList?: AuthorizationList;\n};\n\n/**\n * Callback invoked during submit when `paymentOverride` is defined.\n * Returns batch transaction params to prepend to the submit batch.\n */\nexport type GetPaymentOverrideDataCallback = (\n request: GetPaymentOverrideDataRequest,\n) => Promise<GetPaymentOverrideDataResponse>;\n\nexport type GetAmountDataRequest = {\n /** Raw token amount (atomic units) to encode into calldata. */\n amount: string;\n\n /** Metadata of the transaction whose nested calls need updating. */\n transaction: TransactionMeta;\n};\n\nexport type GetAmountDataResponse = {\n /** Per-nested-call data updates; empty when no update is needed. */\n updates: { nestedTransactionIndex: number; data: Hex }[];\n};\n\n/**\n * Optional callback that re-encodes nested transaction calldata for a given\n * token amount. Used by transaction types with non-standard nested data\n * (e.g. vault approve + deposit) that cannot be derived from the amount alone\n * without client-side context (vault config, RPC providers, etc.).\n */\nexport type GetAmountDataCallback = (\n request: GetAmountDataRequest,\n) => Promise<GetAmountDataResponse>;\n\n/** Request passed to {@link GetBalanceCallback}. */\nexport type GetBalanceRequest = {\n /** Metadata of the transaction whose source balance is being resolved. */\n transaction: TransactionMeta;\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Balance override returned by {@link GetBalanceCallback}. */\nexport type GetBalanceResponse = {\n /** Balance in atomic format without factoring token decimals. */\n balanceRaw: string;\n};\n\n/**\n * Optional client-supplied callback that overrides the built-in\n * pay-token / required-token balance lookup used for `isMaxAmount`\n * source-amount calculation. Enables alternate balance sources\n * (perps, predict, money-account, post-quote, etc.) without adding\n * conditional branches inside the controller. MUST be synchronous:\n * it runs inside the controller state-update block.\n * Return `undefined` to fall back to the built-in token balance.\n */\nexport type GetBalanceCallback = (\n request: GetBalanceRequest,\n) => GetBalanceResponse | undefined;\n\n/** Callback to update fiat payment state. */\nexport type TransactionFiatPaymentCallback = (\n fiatPayment: TransactionFiatPayment,\n) => void;\n\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerMethodActions;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/**\n * Keyring types that support EIP-7702 authorization signing.\n * Hardware wallets, snap keyrings, and custody keyrings are excluded.\n */\nexport const KEYRING_TYPES_SUPPORTING_7702: `${KeyringTypes}`[] = [\n 'HD Key Tree',\n 'Simple Key Pair',\n 'Money Keyring',\n];\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /**\n * Identifies the MetaMask client, sent as the `X-Client-Id` header on\n * requests to the intents API so the server can distinguish Mobile from\n * Extension traffic.\n */\n clientId?: TransactionPayClientId;\n\n /** Optional callback to re-encode nested transaction calldata for a given amount. */\n getAmountData?: GetAmountDataCallback;\n\n /** Optional callback to override the source balance used for max-amount calculation. */\n getBalance?: GetBalanceCallback;\n\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\n\n /** Optional fiat execution configuration. */\n fiatOptions?: TransactionPayFiatOptions;\n\n /**\n * Optional callback invoked during quote execution when `paymentOverride` is defined.\n * Returns additional transactions to be submitted alongside the quote batch.\n */\n getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n /** Callback to select the PayStrategy for a transaction. */\n getStrategy?: (transaction: TransactionMeta) => TransactionPayStrategy;\n\n /** Callback to select ordered PayStrategies for a transaction. */\n getStrategies?: (transaction: TransactionMeta) => TransactionPayStrategy[];\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Callbacks for the Polymarket relayer; required only for the Polymarket deposit-wallet flow. */\n polymarket?: PolymarketCallbacks;\n\n /** Initial state of the controller. */\n state?: Partial<TransactionPayControllerState>;\n};\n\n/** State of the TransactionPayController. */\nexport type TransactionPayControllerState = {\n /** State relating to each transaction, keyed by transaction ID. */\n transactionData: Record<string, TransactionData>;\n};\n\n/** Optional fiat execution configuration. */\nexport type TransactionPayFiatOptions = {\n /** Test funding source used to bypass fiat on-ramp execution during local QA. */\n testFundingSource?: Hex;\n\n /** Optional human amount to transfer from the test funding source. */\n testAmountOverride?: string;\n};\n\n/** State relating to a single transaction. */\nexport type TransactionData = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Fiat payment method state. */\n fiatPayment?: TransactionFiatPayment;\n\n /** Whether quotes are currently being retrieved. */\n isLoading: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n * Used when funds need to be moved after a transaction completes\n * (e.g., bridging output to a different token/chain).\n */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /**\n * Token selected for the transaction.\n * - For standard flows (isPostQuote=false): This is the SOURCE/payment token\n * - For post-quote flows (isPostQuote=true): This is the DESTINATION token\n */\n paymentToken?: TransactionPaymentToken;\n\n /** Quotes retrieved for the transaction. */\n quotes?: TransactionPayQuote<Json>[];\n\n /** Most relevant structured validation error from the latest quote attempt. */\n quoteError?: QuoteErrorInfo;\n\n /** Timestamp of when quotes were last updated. */\n quotesLastUpdated?: number;\n\n /** Amounts of payment token required for each required token. */\n sourceAmounts?: TransactionPaySourceAmount[];\n\n /** Tokens required by the transaction. */\n tokens: TransactionPayRequiredToken[];\n\n /** Calculated totals for the transaction. */\n totals?: TransactionPayTotals;\n};\n\n/** Fiat payment state stored per transaction. */\nexport type TransactionFiatPayment = {\n /** Entered fiat amount for the selected payment method. */\n amountFiat?: string;\n\n /** CAIP-19 asset id derived from the transaction type for the fiat on-ramp. */\n caipAssetId?: string;\n\n /** Order identifier in normalized format (/providers/{provider}/orders/{id}). */\n orderId?: string;\n\n /** The ramps quote received from the ramps provider. */\n rampsQuote?: RampsQuote;\n\n /** Selected fiat payment method ID. */\n selectedPaymentMethodId?: string;\n};\n\n/** A token required by a transaction. */\nexport type TransactionPayRequiredToken = {\n /** Address of the required token. */\n address: Hex;\n\n /** Whether to allow quotes that return less than the minimum amount requested. */\n allowUnderMinimum: boolean;\n\n /** Amount required in the selected currency. */\n amountFiat: string;\n\n /** Amount required in a human-readable format factoring token decimals. */\n amountHuman: string;\n\n /** Amount required in atomic format without factoring token decimals. */\n amountRaw: string;\n\n /** Amount required in USD. */\n amountUsd: string;\n\n /** Balance of the required token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the required token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the required token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the required token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the required token. */\n chainId: Hex;\n\n /** Decimals of the required token. */\n decimals: number;\n\n /** Whether to skip transfer of this token if balance is already sufficient. */\n skipIfBalance: boolean;\n\n /** Symbol of the required token. */\n symbol: string;\n};\n\n/** Amount of payment token required by a required token. */\nexport type TransactionPaySourceAmount = {\n /** Amount of payment token required in the selected currency. */\n sourceAmountHuman: string;\n\n /** Amount of payment token required in atomic format without factoring token decimals. */\n sourceAmountRaw: string;\n\n /** Balance of the source token in atomic format (for post-quote flows). */\n sourceBalanceRaw?: string;\n\n /** Chain ID of the source token (for post-quote flows). */\n sourceChainId?: Hex;\n\n /** Address of the source token (for post-quote flows). */\n sourceTokenAddress?: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n};\n\n/**\n * Machine-readable discriminator for a quote validation failure.\n *\n * Used for analytics and tests. Human-readable copy is carried by `message`\n * and `detail` on {@link QuoteErrorInfo}.\n */\nexport type QuoteErrorReason =\n | 'balance-unavailable'\n | 'insufficient-source-balance'\n | 'insufficient-transfer-balance'\n | 'no-quotes'\n | 'simulation-failed';\n\n/**\n * Structured description of why a quote failed validation.\n *\n * `message` and `detail` are formatted (English) copy ready to display; `reason`\n * is a machine-readable discriminator for analytics and tests.\n */\nexport type QuoteErrorInfo = {\n /** Short, display-ready summary of the failure. */\n message: string;\n\n /** Machine-readable discriminator for the failure. */\n reason: QuoteErrorReason;\n\n /** Optional display-ready detail rows (e.g. Required / Current / Missing). */\n detail?: string[];\n};\n\n/** Source token used to pay for required tokens. */\nexport type TransactionPaymentToken = {\n /** Address of the payment token. */\n address: Hex;\n\n /** Balance of the payment token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the payment token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the payment token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the payment token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the payment token. */\n chainId: Hex;\n\n /** Decimals of the payment token. */\n decimals: number;\n\n /** Symbol of the payment token. */\n symbol: string;\n};\n\n/** Callback to update state for a single transaction. */\nexport type UpdateTransactionDataCallback = (\n /** ID of the transaction to update. */\n transactionId: string,\n /** Function that receives a draft of the transaction data to update. */\n fn: (data: Draft<TransactionData>) => void,\n) => void;\n\n/** Conversion rates from the native currency to other currencies. */\nexport type FiatRates = {\n /** Conversion rate for the native currency to the selected fiat currency. */\n fiatRate: string;\n\n /** Conversion rate for the native currency to USD. */\n usdRate: string;\n};\n\n/** Request for a quote to retrieve a required token. */\nexport type QuoteRequest = {\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Address of the user's account. */\n from: Hex;\n\n /** Whether the transaction is a maximum amount transaction. */\n isMaxAmount?: boolean;\n\n /** Whether this is a post-quote flow. */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether this quote is the direct mUSD-to-Money-Account fiat flow. */\n isDirectMusdMoneyAccount?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** Optional recipient address for Relay requests. When set, overrides the default `from` address. */\n recipient?: Hex;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /** Whether to skip processTransactions in relay-quotes. Defaults to `isPostQuote`. */\n skipProcessTransactions?: boolean;\n\n /** Balance of the source token in atomic format without factoring token decimals. */\n sourceBalanceRaw: string;\n\n /** Chain ID of the source token. */\n sourceChainId: Hex;\n\n /** Address of the source token. */\n sourceTokenAddress: Hex;\n\n /** Amount of the required token in atomic format without factoring token decimals. */\n sourceTokenAmount: string;\n\n /** Minimum amount required of the target token in atomic format without factoring token decimals. */\n targetAmountMinimum: string;\n\n /** Chain ID of the target token. */\n targetChainId: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n\n /**\n * One-time HyperLiquid activation fee (USD) reserved from the source amount\n * for an unactivated HyperCore account. The source amount sent to the\n * provider is reduced by this amount so HyperLiquid retains enough balance\n * for the fee, and the amount is surfaced as part of the provider fee.\n */\n hyperliquidActivationFeeUsd?: string;\n};\n\n/** Fees associated with a transaction pay quote. */\nexport type TransactionPayFees = {\n /** Whether a gas fee token is used to pay source network fees. */\n isSourceGasFeeToken?: boolean;\n\n /** Whether a gas fee token is used to pay target network fees. */\n isTargetGasFeeToken?: boolean;\n\n /** Fee charged by MetaMask. */\n metaMask: FiatValue;\n\n /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Fee charged by fiat on-ramp provider (breakdown of the provider total). */\n providerFiat?: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: {\n estimate: Amount;\n max: Amount;\n };\n\n /** Network fee for transactions on the target network. */\n targetNetwork: FiatValue;\n};\n\n/** Quote returned to retrieve a required token using the payment token. */\nexport type TransactionPayQuote<OriginalQuote> = {\n /** Additional amount provided by the quote beyond the minimum requested. */\n dust: FiatValue;\n\n /** Duration estimated for the transaction to complete in seconds. */\n estimatedDuration: number;\n\n /** Fees associated with the transaction pay quote. */\n fees: TransactionPayFees;\n\n /** Whether fees are subtracted from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Whether the reported fees are already included in the source amount. */\n areFeesIncludedInSourceAmount?: boolean;\n\n /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\n\n /**\n * Whether the target calls could not be embedded in the quote and must be\n * submitted separately, on the target chain, once the quote settles.\n *\n * Set by the strategy at quote time, since only it knows whether the provider\n * accepted the calls. {@link TransactionConfig.atomic} is a hint rather than\n * a guarantee: a quote requested atomically still falls back to a second leg\n * when the provider cannot execute the calls itself.\n */\n requiresSecondLeg?: boolean;\n\n /** Amount of source token required. */\n sourceAmount: Amount;\n\n /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\n\n /** Amount of target token provided. */\n targetAmount: FiatValue;\n};\n\n/** Request to get quotes for a transaction. */\nexport type PayStrategyGetQuotesRequest = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Selected fiat payment method ID, if applicable. */\n fiatPaymentMethod?: string;\n\n /**\n * Resolved wallet address for the transaction.\n * This is `accountOverride ?? txParams.from`, pre-computed by the quote\n * orchestrator so that individual strategies do not need to re-derive it.\n */\n from: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\n\n /**\n * Signal that aborts when a newer quote request supersedes this one.\n * Strategies that perform their own network IO should forward this to\n * their fetch calls so cancelled requests release network resources.\n */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to submit quotes for a transaction. */\nexport type PayStrategyExecuteRequest<OriginalRequest> = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Callback to determine if the transaction is a smart transaction. */\n isSmartTransaction: (chainId: Hex) => boolean;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes to be submitted. */\n quotes: TransactionPayQuote<OriginalRequest>[];\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get batch transactions for quotes. */\nexport type PayStrategyGetBatchRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes for required tokens. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n};\n\n/** Request to check whether retrieved quotes can be executed by a strategy. */\nexport type PayStrategyCheckQuoteSupportRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes returned by the strategy. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get refresh interval for a specific strategy. */\nexport type PayStrategyGetRefreshIntervalRequest = {\n /** Chain ID of the source or payment token. */\n chainId: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n};\n\n/** Strategy used to obtain required tokens for a transaction. */\nexport type PayStrategy<OriginalQuote> = {\n /**\n * Check if the strategy supports the given request.\n * Defaults to true if not implemented.\n */\n supports?: (\n request: PayStrategyGetQuotesRequest,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\n\n /**\n * Check if the returned quotes are supported after provider quote\n * construction and gas planning.\n *\n * Use this for limitations that are only knowable once quote metadata is\n * available, such as whether execution will require an EIP-7702\n * authorization list.\n */\n checkQuoteSupport?: (\n request: PayStrategyCheckQuoteSupportRequest<OriginalQuote>,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve batch transactions for quotes, if supported by the strategy. */\n getBatchTransactions?: (\n request: PayStrategyGetBatchRequest<OriginalQuote>,\n ) => Promise<BatchTransaction[]>;\n\n /**\n * Retrieve refresh interval for the strategy, if applicable.\n * Defaults to 30 seconds.\n */\n getRefreshInterval?: (\n request: PayStrategyGetRefreshIntervalRequest,\n ) => Promise<number | undefined>;\n\n /** Execute or submit the quotes to obtain required tokens. */\n execute: (request: PayStrategyExecuteRequest<OriginalQuote>) => Promise<{\n transactionHash?: Hex;\n }>;\n};\n\n/** Single fiat value in alternate currencies. */\nexport type FiatValue = {\n /** Value in the selected fiat currency. */\n fiat: string;\n\n /** Value in USD. */\n usd: string;\n};\n\n/** Calculated totals for a target transaction and all quotes. */\nexport type TransactionPayTotals = {\n /** Total estimated duration for the target transaction and all quotes. */\n estimatedDuration: number;\n\n /** Total fees for the target transaction and all quotes. */\n fees: TransactionPayFees;\n\n /** Whether the selected quotes subtract fees from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Total amount of source token required. */\n sourceAmount: Amount;\n\n /** Total amount of target token provided. */\n targetAmount: FiatValue;\n\n /** Overall total cost for the target transaction and all quotes. */\n total: FiatValue;\n};\n\n/** Request to update the payment token for a transaction. */\nexport type UpdatePaymentTokenRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Address of the new payment token. */\n tokenAddress: Hex;\n\n /** Chain ID of the new payment token. */\n chainId: Hex;\n};\n\n/** Request to update fiat payment state for a transaction. */\nexport type UpdateFiatPaymentRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Callback to mutate fiat payment state. */\n callback: TransactionFiatPaymentCallback;\n};\n\n/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n isSubsidized,\n}: {\n transaction: TransactionMeta;\n isSubsidized?: boolean;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: Hex;\n}>;\n\n/** Client-supplied callbacks for the Polymarket relayer protocol. */\nexport type PolymarketCallbacks = {\n /** Derive the deposit-wallet address (CREATE2) for the given EOA. */\n getDepositWalletAddress: (params: { eoa: Hex }) => Promise<Hex>;\n\n /** Sign and broadcast a deposit-wallet batch, returning the source hash. */\n submitDepositWalletBatch: (params: {\n eoa: Hex;\n depositWallet: Hex;\n calls: { target: Hex; data: Hex; value: string }[];\n }) => Promise<{ sourceHash: Hex }>;\n};\n\n/** Single amount in alternate formats. */\nexport type Amount = FiatValue & {\n /** Amount in human-readable format factoring token decimals. */\n human: string;\n\n /** Amount in atomic format without factoring token decimals. */\n raw: string;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8PA;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,aAAa;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC","sourcesContent":["import type { AccountsControllerGetStateAction } from '@metamask/accounts-controller';\nimport type {\n AssetsControllerGetStateAction,\n AssetsControllerStateChangeEvent,\n} from '@metamask/assets-controller';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerUnlockEvent,\n KeyringTypes,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkConfigurationByChainIdAction } from '@metamask/network-controller';\nimport type { Quote as RampsQuote } from '@metamask/ramps-controller';\nimport type {\n RampsControllerGetOrderAction,\n RampsControllerGetQuoteWithFeesAction,\n} from '@metamask/ramps-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SentinelApiServiceActions } from '@metamask/sentinel-api-service';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\n BatchTransactionParams,\n TransactionControllerAddTransactionAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetStateAction,\n TransactionControllerStateChangeEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport type {\n CONTROLLER_NAME,\n PaymentOverride,\n TransactionPayClientId,\n TransactionPayStrategy,\n} from './constants.js';\nimport type { TransactionPayControllerMethodActions } from './TransactionPayController-method-action-types.js';\n\nexport type AllowedActions =\n | AccountsControllerGetStateAction\n | AssetsControllerGetStateAction\n | GetGasFeeState\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | RampsControllerGetOrderAction\n | RampsControllerGetQuoteWithFeesAction\n | RemoteFeatureFlagControllerGetStateAction\n | SentinelApiServiceActions\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | AssetsControllerStateChangeEvent\n | KeyringControllerUnlockEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction (or `paymentOverride` batch) is executed\n * atomically with the Relay quote. Defaults to `true` (embedded in the quote\n * and executed by the Relay solver). When `false`, Pay does not embed the\n * target/override calls in the quote; the quote only bridges the required\n * asset to `recipient`, and the calls are submitted separately after Relay\n * completion. Used by flows whose second-leg amount is only known after\n * Relay settles (EXACT_INPUT max flows) or that require the second leg to\n * originate from a different signer than the Relay solver.\n * For max deposits enabled by `payStrategies.relay.atomicMaxEnabled`, this\n * is a subsidy hint: atomic quotes are retried non-atomically if not\n * subsidized, and subsidized non-atomic quotes are upgraded to atomic.\n */\n atomic?: boolean;\n\n /**\n * Whether the source of funds is HyperLiquid (HyperCore).\n * When true, the Relay strategy uses the HyperLiquid 2-step withdrawal\n * flow: (1) authorize nonce-mapping, (2) sendAsset to Relay solver.\n */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n */\n isPostQuote?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request. Use this for post-quote flows where the user's funds originate\n * from a smart contract account (e.g. Predict Safe proxy) so that refunds\n * go back to that account rather than the EOA.\n */\n refundTo?: Hex;\n};\n\n/** Callback to update transaction config. */\nexport type TransactionConfigCallback = (config: TransactionConfig) => void;\n\n/** Request passed to {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataRequest = {\n /** Amount of the source token in human-readable format. */\n amount: string;\n\n /** Metadata of the original transaction. */\n transaction: TransactionMeta;\n\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Response returned by {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataResponse = {\n /** Batch transaction params to prepend to the submit batch. */\n calls: BatchTransactionParams[];\n\n /** Optional recipient address for the funding token transfer. */\n recipient?: Hex;\n\n /** Optional EIP-7702 authorization list from delegation. */\n authorizationList?: AuthorizationList;\n};\n\n/**\n * Callback invoked during submit when `paymentOverride` is defined.\n * Returns batch transaction params to prepend to the submit batch.\n */\nexport type GetPaymentOverrideDataCallback = (\n request: GetPaymentOverrideDataRequest,\n) => Promise<GetPaymentOverrideDataResponse>;\n\nexport type GetAmountDataRequest = {\n /** Raw token amount (atomic units) to encode into calldata. */\n amount: string;\n\n /** Metadata of the transaction whose nested calls need updating. */\n transaction: TransactionMeta;\n};\n\nexport type GetAmountDataResponse = {\n /** Per-nested-call data updates; empty when no update is needed. */\n updates: { nestedTransactionIndex: number; data: Hex }[];\n};\n\n/**\n * Optional callback that re-encodes nested transaction calldata for a given\n * token amount. Used by transaction types with non-standard nested data\n * (e.g. vault approve + deposit) that cannot be derived from the amount alone\n * without client-side context (vault config, RPC providers, etc.).\n */\nexport type GetAmountDataCallback = (\n request: GetAmountDataRequest,\n) => Promise<GetAmountDataResponse>;\n\n/** Request passed to {@link GetBalanceCallback}. */\nexport type GetBalanceRequest = {\n /** Metadata of the transaction whose source balance is being resolved. */\n transaction: TransactionMeta;\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Balance override returned by {@link GetBalanceCallback}. */\nexport type GetBalanceResponse = {\n /** Balance in atomic format without factoring token decimals. */\n balanceRaw: string;\n};\n\n/**\n * Optional client-supplied callback that overrides the built-in\n * pay-token / required-token balance lookup used for `isMaxAmount`\n * source-amount calculation. Enables alternate balance sources\n * (perps, predict, money-account, post-quote, etc.) without adding\n * conditional branches inside the controller. MUST be synchronous:\n * it runs inside the controller state-update block.\n * Return `undefined` to fall back to the built-in token balance.\n */\nexport type GetBalanceCallback = (\n request: GetBalanceRequest,\n) => GetBalanceResponse | undefined;\n\n/** Callback to update fiat payment state. */\nexport type TransactionFiatPaymentCallback = (\n fiatPayment: TransactionFiatPayment,\n) => void;\n\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerMethodActions;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/**\n * Keyring types that support EIP-7702 authorization signing.\n * Hardware wallets, snap keyrings, and custody keyrings are excluded.\n */\nexport const KEYRING_TYPES_SUPPORTING_7702: `${KeyringTypes}`[] = [\n 'HD Key Tree',\n 'Simple Key Pair',\n 'Money Keyring',\n];\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /**\n * Identifies the MetaMask client, sent as the `X-Client-Id` header on\n * requests to the intents API so the server can distinguish Mobile from\n * Extension traffic.\n */\n clientId?: TransactionPayClientId;\n\n /** Optional callback to re-encode nested transaction calldata for a given amount. */\n getAmountData?: GetAmountDataCallback;\n\n /** Optional callback to override the source balance used for max-amount calculation. */\n getBalance?: GetBalanceCallback;\n\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\n\n /** Optional fiat execution configuration. */\n fiatOptions?: TransactionPayFiatOptions;\n\n /**\n * Optional callback invoked during quote execution when `paymentOverride` is defined.\n * Returns additional transactions to be submitted alongside the quote batch.\n */\n getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n /** Callback to select the PayStrategy for a transaction. */\n getStrategy?: (transaction: TransactionMeta) => TransactionPayStrategy;\n\n /** Callback to select ordered PayStrategies for a transaction. */\n getStrategies?: (transaction: TransactionMeta) => TransactionPayStrategy[];\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Callbacks for the Polymarket relayer; required only for the Polymarket deposit-wallet flow. */\n polymarket?: PolymarketCallbacks;\n\n /** Initial state of the controller. */\n state?: Partial<TransactionPayControllerState>;\n};\n\n/** State of the TransactionPayController. */\nexport type TransactionPayControllerState = {\n /** State relating to each transaction, keyed by transaction ID. */\n transactionData: Record<string, TransactionData>;\n};\n\n/** Optional fiat execution configuration. */\nexport type TransactionPayFiatOptions = {\n /** Test funding source used to bypass fiat on-ramp execution during local QA. */\n testFundingSource?: Hex;\n\n /** Optional human amount to transfer from the test funding source. */\n testAmountOverride?: string;\n};\n\n/** State relating to a single transaction. */\nexport type TransactionData = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Fiat payment method state. */\n fiatPayment?: TransactionFiatPayment;\n\n /** Whether quotes are currently being retrieved. */\n isLoading: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n * Used when funds need to be moved after a transaction completes\n * (e.g., bridging output to a different token/chain).\n */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /**\n * Token selected for the transaction.\n * - For standard flows (isPostQuote=false): This is the SOURCE/payment token\n * - For post-quote flows (isPostQuote=true): This is the DESTINATION token\n */\n paymentToken?: TransactionPaymentToken;\n\n /** Quotes retrieved for the transaction. */\n quotes?: TransactionPayQuote<Json>[];\n\n /** Most relevant structured validation error from the latest quote attempt. */\n quoteError?: QuoteErrorInfo;\n\n /** Timestamp of when quotes were last updated. */\n quotesLastUpdated?: number;\n\n /** Amounts of payment token required for each required token. */\n sourceAmounts?: TransactionPaySourceAmount[];\n\n /** Tokens required by the transaction. */\n tokens: TransactionPayRequiredToken[];\n\n /** Calculated totals for the transaction. */\n totals?: TransactionPayTotals;\n};\n\n/** Fiat payment state stored per transaction. */\nexport type TransactionFiatPayment = {\n /** Entered fiat amount for the selected payment method. */\n amountFiat?: string;\n\n /** CAIP-19 asset id derived from the transaction type for the fiat on-ramp. */\n caipAssetId?: string;\n\n /** Order identifier in normalized format (/providers/{provider}/orders/{id}). */\n orderId?: string;\n\n /** The ramps quote received from the ramps provider. */\n rampsQuote?: RampsQuote;\n\n /** Selected fiat payment method ID. */\n selectedPaymentMethodId?: string;\n};\n\n/** A token required by a transaction. */\nexport type TransactionPayRequiredToken = {\n /** Address of the required token. */\n address: Hex;\n\n /** Whether to allow quotes that return less than the minimum amount requested. */\n allowUnderMinimum: boolean;\n\n /** Amount required in the selected currency. */\n amountFiat: string;\n\n /** Amount required in a human-readable format factoring token decimals. */\n amountHuman: string;\n\n /** Amount required in atomic format without factoring token decimals. */\n amountRaw: string;\n\n /** Amount required in USD. */\n amountUsd: string;\n\n /** Balance of the required token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the required token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the required token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the required token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the required token. */\n chainId: Hex;\n\n /** Decimals of the required token. */\n decimals: number;\n\n /** Whether to skip transfer of this token if balance is already sufficient. */\n skipIfBalance: boolean;\n\n /** Symbol of the required token. */\n symbol: string;\n};\n\n/** Amount of payment token required by a required token. */\nexport type TransactionPaySourceAmount = {\n /** Amount of payment token required in the selected currency. */\n sourceAmountHuman: string;\n\n /** Amount of payment token required in atomic format without factoring token decimals. */\n sourceAmountRaw: string;\n\n /** Balance of the source token in atomic format (for post-quote flows). */\n sourceBalanceRaw?: string;\n\n /** Chain ID of the source token (for post-quote flows). */\n sourceChainId?: Hex;\n\n /** Address of the source token (for post-quote flows). */\n sourceTokenAddress?: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n};\n\n/**\n * Machine-readable discriminator for a quote validation failure.\n *\n * Used for analytics and tests. Human-readable copy is carried by `message`\n * and `detail` on {@link QuoteErrorInfo}.\n */\nexport type QuoteErrorReason =\n /**\n * @deprecated No longer emitted. An unreadable live balance is treated as\n * unknown rather than insufficient, so it no longer blocks the quote. Kept\n * so existing consumers and historical analytics still type-check.\n */\n | 'balance-unavailable'\n | 'insufficient-source-balance'\n | 'insufficient-transfer-balance'\n | 'no-quotes'\n | 'simulation-failed';\n\n/**\n * Structured description of why a quote failed validation.\n *\n * `message` and `detail` are formatted (English) copy ready to display; `reason`\n * is a machine-readable discriminator for analytics and tests.\n */\nexport type QuoteErrorInfo = {\n /** Short, display-ready summary of the failure. */\n message: string;\n\n /** Machine-readable discriminator for the failure. */\n reason: QuoteErrorReason;\n\n /** Optional display-ready detail rows (e.g. Required / Current / Missing). */\n detail?: string[];\n};\n\n/** Source token used to pay for required tokens. */\nexport type TransactionPaymentToken = {\n /** Address of the payment token. */\n address: Hex;\n\n /** Balance of the payment token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the payment token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the payment token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the payment token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the payment token. */\n chainId: Hex;\n\n /** Decimals of the payment token. */\n decimals: number;\n\n /** Symbol of the payment token. */\n symbol: string;\n};\n\n/** Callback to update state for a single transaction. */\nexport type UpdateTransactionDataCallback = (\n /** ID of the transaction to update. */\n transactionId: string,\n /** Function that receives a draft of the transaction data to update. */\n fn: (data: Draft<TransactionData>) => void,\n) => void;\n\n/** Conversion rates from the native currency to other currencies. */\nexport type FiatRates = {\n /** Conversion rate for the native currency to the selected fiat currency. */\n fiatRate: string;\n\n /** Conversion rate for the native currency to USD. */\n usdRate: string;\n};\n\n/** Request for a quote to retrieve a required token. */\nexport type QuoteRequest = {\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Address of the user's account. */\n from: Hex;\n\n /** Whether the transaction is a maximum amount transaction. */\n isMaxAmount?: boolean;\n\n /** Whether this is a post-quote flow. */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether this quote is the direct mUSD-to-Money-Account fiat flow. */\n isDirectMusdMoneyAccount?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** Optional recipient address for Relay requests. When set, overrides the default `from` address. */\n recipient?: Hex;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /** Whether to skip processTransactions in relay-quotes. Defaults to `isPostQuote`. */\n skipProcessTransactions?: boolean;\n\n /** Balance of the source token in atomic format without factoring token decimals. */\n sourceBalanceRaw: string;\n\n /** Chain ID of the source token. */\n sourceChainId: Hex;\n\n /** Address of the source token. */\n sourceTokenAddress: Hex;\n\n /** Amount of the required token in atomic format without factoring token decimals. */\n sourceTokenAmount: string;\n\n /** Minimum amount required of the target token in atomic format without factoring token decimals. */\n targetAmountMinimum: string;\n\n /** Chain ID of the target token. */\n targetChainId: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n\n /**\n * One-time HyperLiquid activation fee (USD) reserved from the source amount\n * for an unactivated HyperCore account. The source amount sent to the\n * provider is reduced by this amount so HyperLiquid retains enough balance\n * for the fee, and the amount is surfaced as part of the provider fee.\n */\n hyperliquidActivationFeeUsd?: string;\n};\n\n/** Fees associated with a transaction pay quote. */\nexport type TransactionPayFees = {\n /** Whether a gas fee token is used to pay source network fees. */\n isSourceGasFeeToken?: boolean;\n\n /** Whether a gas fee token is used to pay target network fees. */\n isTargetGasFeeToken?: boolean;\n\n /** Fee charged by MetaMask. */\n metaMask: FiatValue;\n\n /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Fee charged by fiat on-ramp provider (breakdown of the provider total). */\n providerFiat?: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: {\n estimate: Amount;\n max: Amount;\n };\n\n /** Network fee for transactions on the target network. */\n targetNetwork: FiatValue;\n};\n\n/** Quote returned to retrieve a required token using the payment token. */\nexport type TransactionPayQuote<OriginalQuote> = {\n /** Additional amount provided by the quote beyond the minimum requested. */\n dust: FiatValue;\n\n /** Duration estimated for the transaction to complete in seconds. */\n estimatedDuration: number;\n\n /** Fees associated with the transaction pay quote. */\n fees: TransactionPayFees;\n\n /** Whether fees are subtracted from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Whether the reported fees are already included in the source amount. */\n areFeesIncludedInSourceAmount?: boolean;\n\n /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\n\n /**\n * Whether the target calls could not be embedded in the quote and must be\n * submitted separately, on the target chain, once the quote settles.\n *\n * Set by the strategy at quote time, since only it knows whether the provider\n * accepted the calls. {@link TransactionConfig.atomic} is a hint rather than\n * a guarantee: a quote requested atomically still falls back to a second leg\n * when the provider cannot execute the calls itself.\n */\n requiresSecondLeg?: boolean;\n\n /** Amount of source token required. */\n sourceAmount: Amount;\n\n /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\n\n /** Amount of target token provided. */\n targetAmount: FiatValue;\n};\n\n/** Request to get quotes for a transaction. */\nexport type PayStrategyGetQuotesRequest = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Selected fiat payment method ID, if applicable. */\n fiatPaymentMethod?: string;\n\n /**\n * Resolved wallet address for the transaction.\n * This is `accountOverride ?? txParams.from`, pre-computed by the quote\n * orchestrator so that individual strategies do not need to re-derive it.\n */\n from: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\n\n /**\n * Signal that aborts when a newer quote request supersedes this one.\n * Strategies that perform their own network IO should forward this to\n * their fetch calls so cancelled requests release network resources.\n */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to submit quotes for a transaction. */\nexport type PayStrategyExecuteRequest<OriginalRequest> = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Callback to determine if the transaction is a smart transaction. */\n isSmartTransaction: (chainId: Hex) => boolean;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes to be submitted. */\n quotes: TransactionPayQuote<OriginalRequest>[];\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get batch transactions for quotes. */\nexport type PayStrategyGetBatchRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes for required tokens. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n};\n\n/** Request to check whether retrieved quotes can be executed by a strategy. */\nexport type PayStrategyCheckQuoteSupportRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes returned by the strategy. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get refresh interval for a specific strategy. */\nexport type PayStrategyGetRefreshIntervalRequest = {\n /** Chain ID of the source or payment token. */\n chainId: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n};\n\n/** Strategy used to obtain required tokens for a transaction. */\nexport type PayStrategy<OriginalQuote> = {\n /**\n * Check if the strategy supports the given request.\n * Defaults to true if not implemented.\n */\n supports?: (\n request: PayStrategyGetQuotesRequest,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\n\n /**\n * Check if the returned quotes are supported after provider quote\n * construction and gas planning.\n *\n * Use this for limitations that are only knowable once quote metadata is\n * available, such as whether execution will require an EIP-7702\n * authorization list.\n */\n checkQuoteSupport?: (\n request: PayStrategyCheckQuoteSupportRequest<OriginalQuote>,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve batch transactions for quotes, if supported by the strategy. */\n getBatchTransactions?: (\n request: PayStrategyGetBatchRequest<OriginalQuote>,\n ) => Promise<BatchTransaction[]>;\n\n /**\n * Retrieve refresh interval for the strategy, if applicable.\n * Defaults to 30 seconds.\n */\n getRefreshInterval?: (\n request: PayStrategyGetRefreshIntervalRequest,\n ) => Promise<number | undefined>;\n\n /** Execute or submit the quotes to obtain required tokens. */\n execute: (request: PayStrategyExecuteRequest<OriginalQuote>) => Promise<{\n transactionHash?: Hex;\n }>;\n};\n\n/** Single fiat value in alternate currencies. */\nexport type FiatValue = {\n /** Value in the selected fiat currency. */\n fiat: string;\n\n /** Value in USD. */\n usd: string;\n};\n\n/** Calculated totals for a target transaction and all quotes. */\nexport type TransactionPayTotals = {\n /** Total estimated duration for the target transaction and all quotes. */\n estimatedDuration: number;\n\n /** Total fees for the target transaction and all quotes. */\n fees: TransactionPayFees;\n\n /** Whether the selected quotes subtract fees from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Total amount of source token required. */\n sourceAmount: Amount;\n\n /** Total amount of target token provided. */\n targetAmount: FiatValue;\n\n /** Overall total cost for the target transaction and all quotes. */\n total: FiatValue;\n};\n\n/** Request to update the payment token for a transaction. */\nexport type UpdatePaymentTokenRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Address of the new payment token. */\n tokenAddress: Hex;\n\n /** Chain ID of the new payment token. */\n chainId: Hex;\n};\n\n/** Request to update fiat payment state for a transaction. */\nexport type UpdateFiatPaymentRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Callback to mutate fiat payment state. */\n callback: TransactionFiatPaymentCallback;\n};\n\n/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n isSubsidized,\n}: {\n transaction: TransactionMeta;\n isSubsidized?: boolean;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: Hex;\n}>;\n\n/** Client-supplied callbacks for the Polymarket relayer protocol. */\nexport type PolymarketCallbacks = {\n /** Derive the deposit-wallet address (CREATE2) for the given EOA. */\n getDepositWalletAddress: (params: { eoa: Hex }) => Promise<Hex>;\n\n /** Sign and broadcast a deposit-wallet batch, returning the source hash. */\n submitDepositWalletBatch: (params: {\n eoa: Hex;\n depositWallet: Hex;\n calls: { target: Hex; data: Hex; value: string }[];\n }) => Promise<{ sourceHash: Hex }>;\n};\n\n/** Single amount in alternate formats. */\nexport type Amount = FiatValue & {\n /** Amount in human-readable format factoring token decimals. */\n human: string;\n\n /** Amount in atomic format without factoring token decimals. */\n raw: string;\n};\n"]}
@@ -104,6 +104,24 @@ export declare function getNativeToken(chainId: Hex): Hex;
104
104
  * @returns Raw token balance as a decimal string.
105
105
  */
106
106
  export declare function getLiveTokenBalance(messenger: TransactionPayControllerMessenger, account: Hex, chainId: Hex, tokenAddress: Hex): Promise<string>;
107
+ /**
108
+ * Read the live on-chain token balance, returning `undefined` instead of
109
+ * throwing when the RPC request fails.
110
+ *
111
+ * An RPC failure means the balance is *unknown*, which is not the same as the
112
+ * balance being *insufficient*. Callers use the balance to fail fast before
113
+ * simulation and submission; when it cannot be read they should skip that
114
+ * optimisation rather than block the user, since simulation and the on-chain
115
+ * transaction still catch a genuine shortfall.
116
+ *
117
+ * @param messenger - Controller messenger.
118
+ * @param account - Address of the account.
119
+ * @param chainId - Chain ID.
120
+ * @param tokenAddress - Address of the token contract.
121
+ * @returns Raw token balance as a decimal string, or `undefined` if the
122
+ * balance could not be read.
123
+ */
124
+ export declare function getLiveTokenBalanceOrUndefined(messenger: TransactionPayControllerMessenger, account: Hex, chainId: Hex, tokenAddress: Hex): Promise<string | undefined>;
107
125
  /**
108
126
  * Build a CAIP-19 asset type identifier for an EVM token.
109
127
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/utils/token.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC,OAAO,KAAK,EAAE,SAAS,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAchF;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,EACtC,MAAM,EAAE;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,GACrC,OAAO,CAKT;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,iCAAiC,EAC5C,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,GAAG,GAChB,MAAM,CAqCR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,iCAAiC,EAC5C,YAAY,EAAE,GAAG,EACjB,OAAO,EAAE,GAAG,GACX;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAUlD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,iCAAiC,EAC5C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