@metamask/transaction-pay-controller 16.3.0 → 16.4.1
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.
- package/CHANGELOG.md +20 -1
- package/dist/TransactionPayController.cjs +9 -0
- package/dist/TransactionPayController.cjs.map +1 -1
- package/dist/TransactionPayController.d.cts +2 -1
- package/dist/TransactionPayController.d.cts.map +1 -1
- package/dist/TransactionPayController.d.mts +2 -1
- package/dist/TransactionPayController.d.mts.map +1 -1
- package/dist/TransactionPayController.mjs +9 -0
- package/dist/TransactionPayController.mjs.map +1 -1
- package/dist/actions/update-fiat-payment.cjs +29 -0
- package/dist/actions/update-fiat-payment.cjs.map +1 -0
- package/dist/actions/update-fiat-payment.d.cts +14 -0
- package/dist/actions/update-fiat-payment.d.cts.map +1 -0
- package/dist/actions/update-fiat-payment.d.mts +14 -0
- package/dist/actions/update-fiat-payment.d.mts.map +1 -0
- package/dist/actions/update-fiat-payment.mjs +25 -0
- package/dist/actions/update-fiat-payment.mjs.map +1 -0
- package/dist/actions/update-payment-token.cjs +1 -0
- package/dist/actions/update-payment-token.cjs.map +1 -1
- package/dist/actions/update-payment-token.d.cts.map +1 -1
- package/dist/actions/update-payment-token.d.mts.map +1 -1
- package/dist/actions/update-payment-token.mjs +1 -0
- package/dist/actions/update-payment-token.mjs.map +1 -1
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +1 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +1 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/strategy/across/AcrossStrategy.cjs +28 -0
- package/dist/strategy/across/AcrossStrategy.cjs.map +1 -0
- package/dist/strategy/across/AcrossStrategy.d.cts +8 -0
- package/dist/strategy/across/AcrossStrategy.d.cts.map +1 -0
- package/dist/strategy/across/AcrossStrategy.d.mts +8 -0
- package/dist/strategy/across/AcrossStrategy.d.mts.map +1 -0
- package/dist/strategy/across/AcrossStrategy.mjs +24 -0
- package/dist/strategy/across/AcrossStrategy.mjs.map +1 -0
- package/dist/strategy/across/across-quotes.cjs +356 -0
- package/dist/strategy/across/across-quotes.cjs.map +1 -0
- package/dist/strategy/across/across-quotes.d.cts +10 -0
- package/dist/strategy/across/across-quotes.d.cts.map +1 -0
- package/dist/strategy/across/across-quotes.d.mts +10 -0
- package/dist/strategy/across/across-quotes.d.mts.map +1 -0
- package/dist/strategy/across/across-quotes.mjs +352 -0
- package/dist/strategy/across/across-quotes.mjs.map +1 -0
- package/dist/strategy/across/across-submit.cjs +241 -0
- package/dist/strategy/across/across-submit.cjs.map +1 -0
- package/dist/strategy/across/across-submit.d.cts +13 -0
- package/dist/strategy/across/across-submit.d.cts.map +1 -0
- package/dist/strategy/across/across-submit.d.mts +13 -0
- package/dist/strategy/across/across-submit.d.mts.map +1 -0
- package/dist/strategy/across/across-submit.mjs +237 -0
- package/dist/strategy/across/across-submit.mjs.map +1 -0
- package/dist/strategy/across/types.cjs +3 -0
- package/dist/strategy/across/types.cjs.map +1 -0
- package/dist/strategy/across/types.d.cts +89 -0
- package/dist/strategy/across/types.d.cts.map +1 -0
- package/dist/strategy/across/types.d.mts +89 -0
- package/dist/strategy/across/types.d.mts.map +1 -0
- package/dist/strategy/across/types.mjs +2 -0
- package/dist/strategy/across/types.mjs.map +1 -0
- package/dist/strategy/relay/RelayStrategy.cjs +5 -0
- package/dist/strategy/relay/RelayStrategy.cjs.map +1 -1
- package/dist/strategy/relay/RelayStrategy.d.cts +1 -0
- package/dist/strategy/relay/RelayStrategy.d.cts.map +1 -1
- package/dist/strategy/relay/RelayStrategy.d.mts +1 -0
- package/dist/strategy/relay/RelayStrategy.d.mts.map +1 -1
- package/dist/strategy/relay/RelayStrategy.mjs +5 -0
- package/dist/strategy/relay/RelayStrategy.mjs.map +1 -1
- package/dist/strategy/relay/gas-station.cjs +92 -0
- package/dist/strategy/relay/gas-station.cjs.map +1 -0
- package/dist/strategy/relay/gas-station.d.cts +22 -0
- package/dist/strategy/relay/gas-station.d.cts.map +1 -0
- package/dist/strategy/relay/gas-station.d.mts +22 -0
- package/dist/strategy/relay/gas-station.d.mts.map +1 -0
- package/dist/strategy/relay/gas-station.mjs +87 -0
- package/dist/strategy/relay/gas-station.mjs.map +1 -0
- package/dist/strategy/relay/relay-max-gas-station.cjs +242 -0
- package/dist/strategy/relay/relay-max-gas-station.cjs.map +1 -0
- package/dist/strategy/relay/relay-max-gas-station.d.cts +22 -0
- package/dist/strategy/relay/relay-max-gas-station.d.cts.map +1 -0
- package/dist/strategy/relay/relay-max-gas-station.d.mts +22 -0
- package/dist/strategy/relay/relay-max-gas-station.d.mts.map +1 -0
- package/dist/strategy/relay/relay-max-gas-station.mjs +238 -0
- package/dist/strategy/relay/relay-max-gas-station.mjs.map +1 -0
- package/dist/strategy/relay/relay-quotes.cjs +32 -59
- package/dist/strategy/relay/relay-quotes.cjs.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.cts.map +1 -1
- package/dist/strategy/relay/relay-quotes.d.mts.map +1 -1
- package/dist/strategy/relay/relay-quotes.mjs +29 -56
- package/dist/strategy/relay/relay-quotes.mjs.map +1 -1
- package/dist/strategy/relay/types.cjs.map +1 -1
- package/dist/strategy/relay/types.d.cts +1 -0
- package/dist/strategy/relay/types.d.cts.map +1 -1
- package/dist/strategy/relay/types.d.mts +1 -0
- package/dist/strategy/relay/types.d.mts.map +1 -1
- package/dist/strategy/relay/types.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +24 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +24 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/amounts.cjs +40 -0
- package/dist/utils/amounts.cjs.map +1 -0
- package/dist/utils/amounts.d.cts +18 -0
- package/dist/utils/amounts.d.cts.map +1 -0
- package/dist/utils/amounts.d.mts +18 -0
- package/dist/utils/amounts.d.mts.map +1 -0
- package/dist/utils/amounts.mjs +35 -0
- package/dist/utils/amounts.mjs.map +1 -0
- package/dist/utils/feature-flags.cjs +45 -6
- package/dist/utils/feature-flags.cjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +45 -2
- package/dist/utils/feature-flags.d.cts.map +1 -1
- package/dist/utils/feature-flags.d.mts +45 -2
- package/dist/utils/feature-flags.d.mts.map +1 -1
- package/dist/utils/feature-flags.mjs +42 -5
- package/dist/utils/feature-flags.mjs.map +1 -1
- package/dist/utils/gas.cjs +46 -1
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +18 -0
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +18 -0
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +44 -0
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/strategy.cjs +3 -0
- package/dist/utils/strategy.cjs.map +1 -1
- package/dist/utils/strategy.d.cts.map +1 -1
- package/dist/utils/strategy.d.mts.map +1 -1
- package/dist/utils/strategy.mjs +3 -0
- package/dist/utils/strategy.mjs.map +1 -1
- package/dist/utils/totals.cjs +4 -19
- package/dist/utils/totals.cjs.map +1 -1
- package/dist/utils/totals.d.cts.map +1 -1
- package/dist/utils/totals.d.mts.map +1 -1
- package/dist/utils/totals.mjs +1 -16
- package/dist/utils/totals.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"across-submit.cjs","sourceRoot":"","sources":["../../../src/strategy/across/across-submit.ts"],"names":[],"mappings":";;;AAAA,iEAIoC;AACpC,6EAAmE;AAOnE,2CAAqD;AAGrD,6CAA6C;AAM7C,iEAAmE;AACnE,6DAKi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C,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE5B,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI;QACJ,GAAG,EAAE,IAAA,wBAAK,EAAC,GAAG,CAAC;QACf,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,YAAY,CAAC;QACvD,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,CAAC,oBAAoB,CAAC;QACvE,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,KAAK;KACN,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAA,wBAAK,EAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,wBAAwB,CAC/B,MAAyB;IAEzB,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAuB;QACpC,GAAG,EAAE,MAAM,CAAC,GAAsB;QAClC,YAAY,EAAE,MAAM,CAAC,YAA+B;QACpD,oBAAoB,EAAE,MAAM,CAAC,oBAAuC;QACpE,EAAE,EAAE,MAAM,CAAC,EAAqB;QAChC,KAAK,EAAE,MAAM,CAAC,KAAwB;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import {\n ORIGIN_METAMASK,\n successfulFetch,\n toHex,\n} from '@metamask/controller-utils';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n TransactionMeta,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport type { AcrossQuote } from './types';\nimport { projectLogger } from '../../logger';\nimport type {\n PayStrategyExecuteRequest,\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n} from '../../types';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags';\nimport {\n collectTransactionIds,\n getTransaction,\n updateTransaction,\n waitForTransactionConfirmed,\n} from '../../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'across-strategy');\nconst ACROSS_STATUS_POLL_INTERVAL = 1000;\n\ntype PreparedAcrossTransaction = {\n params: TransactionParams;\n type: TransactionType;\n};\n\n/**\n * Submit Across quotes.\n *\n * @param request - Request object.\n * @returns An object containing the transaction hash if available.\n */\nexport async function submitAcrossQuotes(\n request: PayStrategyExecuteRequest<AcrossQuote>,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing quotes', request);\n\n const { quotes, messenger, transaction } = request;\n let transactionHash: Hex | undefined;\n\n for (const quote of quotes) {\n ({ transactionHash } = await executeSingleQuote(\n quote,\n messenger,\n transaction,\n ));\n }\n\n return { transactionHash };\n}\n\nasync function executeSingleQuote(\n quote: TransactionPayQuote<AcrossQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing single 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 acrossDepositType = getAcrossDepositType(transaction.type);\n const transactionHash = await submitTransactions(\n quote,\n transaction.id,\n acrossDepositType,\n messenger,\n );\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Intent complete after Across submission',\n },\n (tx) => {\n tx.isIntentComplete = true;\n },\n );\n\n return { transactionHash };\n}\n\n/**\n * Submit transactions for an Across quote.\n *\n * @param quote - Across quote.\n * @param parentTransactionId - ID of the parent transaction.\n * @param acrossDepositType - Transaction type used for the swap/deposit step.\n * @param messenger - Controller messenger.\n * @returns Hash of the last submitted transaction, if available.\n */\nasync function submitTransactions(\n quote: TransactionPayQuote<AcrossQuote>,\n parentTransactionId: string,\n acrossDepositType: TransactionType,\n messenger: TransactionPayControllerMessenger,\n): Promise<Hex | undefined> {\n const { approvalTxns, swapTx } = quote.original.quote;\n const { gasLimits: quoteGasLimits } = quote.original.metamask;\n const { from } = quote.request;\n const chainId = toHex(swapTx.chainId);\n\n const networkClientId = messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n\n const transactions: PreparedAcrossTransaction[] = [];\n\n if (approvalTxns?.length) {\n for (const [index, approval] of approvalTxns.entries()) {\n const approvalGasLimit = quoteGasLimits?.approval[index]?.max;\n if (approvalGasLimit === undefined) {\n throw new Error(\n `Missing quote gas limit for Across approval transaction at index ${index}`,\n );\n }\n\n transactions.push({\n params: buildTransactionParams(from, {\n chainId: approval.chainId,\n data: approval.data,\n gasLimit: approvalGasLimit,\n to: approval.to,\n value: approval.value,\n }),\n type: TransactionType.tokenMethodApprove,\n });\n }\n }\n\n const swapGasLimit = quoteGasLimits?.swap?.max;\n if (swapGasLimit === undefined) {\n throw new Error('Missing quote gas limit for Across swap transaction');\n }\n\n transactions.push({\n params: buildTransactionParams(from, {\n chainId: swapTx.chainId,\n data: swapTx.data,\n gasLimit: swapGasLimit,\n to: swapTx.to,\n value: swapTx.value,\n maxFeePerGas: swapTx.maxFeePerGas,\n maxPriorityFeePerGas: swapTx.maxPriorityFeePerGas,\n }),\n type: acrossDepositType,\n });\n\n const transactionIds: string[] = [];\n\n const { end } = collectTransactionIds(\n chainId,\n from,\n messenger,\n (transactionId) => {\n transactionIds.push(transactionId);\n\n updateTransaction(\n {\n transactionId: parentTransactionId,\n messenger,\n note: 'Add required transaction ID from Across submission',\n },\n (tx) => {\n tx.requiredTransactionIds ??= [];\n tx.requiredTransactionIds.push(transactionId);\n },\n );\n },\n );\n\n let result: { result: Promise<string> } | undefined;\n\n try {\n if (transactions.length === 1) {\n result = await messenger.call(\n 'TransactionController:addTransaction',\n transactions[0].params,\n {\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n type: transactions[0].type,\n },\n );\n } else {\n const batchTransactions = transactions.map(({ params, type }) => ({\n params: toBatchTransactionParams(params),\n type,\n }));\n\n await messenger.call('TransactionController:addTransactionBatch', {\n from,\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n transactions: batchTransactions,\n });\n }\n } finally {\n end();\n }\n\n if (result) {\n const txHash = await result.result;\n log('Submitted transaction', txHash);\n }\n\n await Promise.all(\n transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)),\n );\n\n const hash = transactionIds.length\n ? getTransaction(transactionIds.slice(-1)[0], messenger)?.hash\n : undefined;\n\n return await waitForAcrossCompletion(\n quote.original,\n hash as Hex | undefined,\n messenger,\n );\n}\n\ntype AcrossStatusResponse = {\n status?: string;\n destinationTxHash?: Hex;\n fillTxHash?: Hex;\n txHash?: Hex;\n};\n\nasync function waitForAcrossCompletion(\n quote: AcrossQuote,\n transactionHash: Hex | undefined,\n messenger: TransactionPayControllerMessenger,\n): Promise<Hex | undefined> {\n if (!transactionHash || !quote.quote.id) {\n return transactionHash;\n }\n\n const config = getPayStrategiesConfig(messenger);\n const params = new URLSearchParams({\n depositId: quote.quote.id,\n originChainId: String(quote.quote.swapTx.chainId),\n txHash: transactionHash,\n });\n const url = `${config.across.apiBase}/deposit/status?${params.toString()}`;\n\n let attempt = 0;\n\n while (true) {\n attempt += 1;\n let status: AcrossStatusResponse;\n\n try {\n const response = await successfulFetch(url, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n },\n });\n status = (await response.json()) as AcrossStatusResponse;\n } catch (error) {\n log('Across status polling request failed', {\n attempt,\n error: String(error),\n transactionHash,\n });\n\n await new Promise((resolve) =>\n setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL),\n );\n continue;\n }\n\n const normalizedStatus = status.status?.toLowerCase();\n\n log('Polled Across status', {\n attempt,\n status: normalizedStatus,\n transactionHash,\n });\n\n if (\n normalizedStatus &&\n ['completed', 'filled', 'success'].includes(normalizedStatus)\n ) {\n return (\n status.destinationTxHash ??\n status.fillTxHash ??\n status.txHash ??\n transactionHash\n );\n }\n\n if (\n normalizedStatus &&\n ['error', 'failed', 'refund', 'refunded'].includes(normalizedStatus)\n ) {\n throw new Error(`Across request failed with status: ${normalizedStatus}`);\n }\n\n await new Promise((resolve) =>\n setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL),\n );\n }\n}\n\nfunction getAcrossDepositType(\n transactionType?: TransactionType,\n): TransactionType {\n switch (transactionType) {\n case TransactionType.perpsDeposit:\n return TransactionType.perpsAcrossDeposit;\n case TransactionType.predictDeposit:\n return TransactionType.predictAcrossDeposit;\n case undefined:\n return TransactionType.perpsAcrossDeposit;\n default:\n return transactionType;\n }\n}\n\nfunction buildTransactionParams(\n from: Hex,\n params: {\n chainId: number;\n data: Hex;\n gasLimit: number;\n to: Hex;\n value?: Hex;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n },\n): TransactionParams {\n const value = toHex(params.value ?? '0x0');\n const gas = params.gasLimit;\n\n return {\n data: params.data,\n from,\n gas: toHex(gas),\n maxFeePerGas: normalizeOptionalHex(params.maxFeePerGas),\n maxPriorityFeePerGas: normalizeOptionalHex(params.maxPriorityFeePerGas),\n to: params.to,\n value,\n };\n}\n\nfunction normalizeOptionalHex(value?: string): Hex | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n return toHex(value);\n}\n\nfunction toBatchTransactionParams(\n params: TransactionParams,\n): BatchTransactionParams {\n return {\n data: params.data as Hex | undefined,\n gas: params.gas as Hex | undefined,\n maxFeePerGas: params.maxFeePerGas as Hex | undefined,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas as Hex | undefined,\n to: params.to as Hex | undefined,\n value: params.value as Hex | undefined,\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { AcrossQuote } from "./types.cjs";
|
|
3
|
+
import type { PayStrategyExecuteRequest } from "../../types.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Submit Across quotes.
|
|
6
|
+
*
|
|
7
|
+
* @param request - Request object.
|
|
8
|
+
* @returns An object containing the transaction hash if available.
|
|
9
|
+
*/
|
|
10
|
+
export declare function submitAcrossQuotes(request: PayStrategyExecuteRequest<AcrossQuote>): Promise<{
|
|
11
|
+
transactionHash?: Hex;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=across-submit.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"across-submit.d.cts","sourceRoot":"","sources":["../../../src/strategy/across/across-submit.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAgB;AAE3C,OAAO,KAAK,EACV,yBAAyB,EAG1B,wBAAoB;AAiBrB;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,CAAC,WAAW,CAAC,GAC9C,OAAO,CAAC;IAAE,eAAe,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,CAepC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { AcrossQuote } from "./types.mjs";
|
|
3
|
+
import type { PayStrategyExecuteRequest } from "../../types.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Submit Across quotes.
|
|
6
|
+
*
|
|
7
|
+
* @param request - Request object.
|
|
8
|
+
* @returns An object containing the transaction hash if available.
|
|
9
|
+
*/
|
|
10
|
+
export declare function submitAcrossQuotes(request: PayStrategyExecuteRequest<AcrossQuote>): Promise<{
|
|
11
|
+
transactionHash?: Hex;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=across-submit.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"across-submit.d.mts","sourceRoot":"","sources":["../../../src/strategy/across/across-submit.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAgB;AAE3C,OAAO,KAAK,EACV,yBAAyB,EAG1B,wBAAoB;AAiBrB;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,CAAC,WAAW,CAAC,GAC9C,OAAO,CAAC;IAAE,eAAe,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC,CAepC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { ORIGIN_METAMASK, successfulFetch, toHex } from "@metamask/controller-utils";
|
|
2
|
+
import { TransactionType } from "@metamask/transaction-controller";
|
|
3
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
4
|
+
import { projectLogger } from "../../logger.mjs";
|
|
5
|
+
import { getPayStrategiesConfig } from "../../utils/feature-flags.mjs";
|
|
6
|
+
import { collectTransactionIds, getTransaction, updateTransaction, waitForTransactionConfirmed } from "../../utils/transaction.mjs";
|
|
7
|
+
const log = createModuleLogger(projectLogger, 'across-strategy');
|
|
8
|
+
const ACROSS_STATUS_POLL_INTERVAL = 1000;
|
|
9
|
+
/**
|
|
10
|
+
* Submit Across quotes.
|
|
11
|
+
*
|
|
12
|
+
* @param request - Request object.
|
|
13
|
+
* @returns An object containing the transaction hash if available.
|
|
14
|
+
*/
|
|
15
|
+
export async function submitAcrossQuotes(request) {
|
|
16
|
+
log('Executing quotes', request);
|
|
17
|
+
const { quotes, messenger, transaction } = request;
|
|
18
|
+
let transactionHash;
|
|
19
|
+
for (const quote of quotes) {
|
|
20
|
+
({ transactionHash } = await executeSingleQuote(quote, messenger, transaction));
|
|
21
|
+
}
|
|
22
|
+
return { transactionHash };
|
|
23
|
+
}
|
|
24
|
+
async function executeSingleQuote(quote, messenger, transaction) {
|
|
25
|
+
log('Executing single quote', quote);
|
|
26
|
+
updateTransaction({
|
|
27
|
+
transactionId: transaction.id,
|
|
28
|
+
messenger,
|
|
29
|
+
note: 'Remove nonce from skipped transaction',
|
|
30
|
+
}, (tx) => {
|
|
31
|
+
tx.txParams.nonce = undefined;
|
|
32
|
+
});
|
|
33
|
+
const acrossDepositType = getAcrossDepositType(transaction.type);
|
|
34
|
+
const transactionHash = await submitTransactions(quote, transaction.id, acrossDepositType, messenger);
|
|
35
|
+
updateTransaction({
|
|
36
|
+
transactionId: transaction.id,
|
|
37
|
+
messenger,
|
|
38
|
+
note: 'Intent complete after Across submission',
|
|
39
|
+
}, (tx) => {
|
|
40
|
+
tx.isIntentComplete = true;
|
|
41
|
+
});
|
|
42
|
+
return { transactionHash };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Submit transactions for an Across quote.
|
|
46
|
+
*
|
|
47
|
+
* @param quote - Across quote.
|
|
48
|
+
* @param parentTransactionId - ID of the parent transaction.
|
|
49
|
+
* @param acrossDepositType - Transaction type used for the swap/deposit step.
|
|
50
|
+
* @param messenger - Controller messenger.
|
|
51
|
+
* @returns Hash of the last submitted transaction, if available.
|
|
52
|
+
*/
|
|
53
|
+
async function submitTransactions(quote, parentTransactionId, acrossDepositType, messenger) {
|
|
54
|
+
const { approvalTxns, swapTx } = quote.original.quote;
|
|
55
|
+
const { gasLimits: quoteGasLimits } = quote.original.metamask;
|
|
56
|
+
const { from } = quote.request;
|
|
57
|
+
const chainId = toHex(swapTx.chainId);
|
|
58
|
+
const networkClientId = messenger.call('NetworkController:findNetworkClientIdByChainId', chainId);
|
|
59
|
+
const transactions = [];
|
|
60
|
+
if (approvalTxns?.length) {
|
|
61
|
+
for (const [index, approval] of approvalTxns.entries()) {
|
|
62
|
+
const approvalGasLimit = quoteGasLimits?.approval[index]?.max;
|
|
63
|
+
if (approvalGasLimit === undefined) {
|
|
64
|
+
throw new Error(`Missing quote gas limit for Across approval transaction at index ${index}`);
|
|
65
|
+
}
|
|
66
|
+
transactions.push({
|
|
67
|
+
params: buildTransactionParams(from, {
|
|
68
|
+
chainId: approval.chainId,
|
|
69
|
+
data: approval.data,
|
|
70
|
+
gasLimit: approvalGasLimit,
|
|
71
|
+
to: approval.to,
|
|
72
|
+
value: approval.value,
|
|
73
|
+
}),
|
|
74
|
+
type: TransactionType.tokenMethodApprove,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const swapGasLimit = quoteGasLimits?.swap?.max;
|
|
79
|
+
if (swapGasLimit === undefined) {
|
|
80
|
+
throw new Error('Missing quote gas limit for Across swap transaction');
|
|
81
|
+
}
|
|
82
|
+
transactions.push({
|
|
83
|
+
params: buildTransactionParams(from, {
|
|
84
|
+
chainId: swapTx.chainId,
|
|
85
|
+
data: swapTx.data,
|
|
86
|
+
gasLimit: swapGasLimit,
|
|
87
|
+
to: swapTx.to,
|
|
88
|
+
value: swapTx.value,
|
|
89
|
+
maxFeePerGas: swapTx.maxFeePerGas,
|
|
90
|
+
maxPriorityFeePerGas: swapTx.maxPriorityFeePerGas,
|
|
91
|
+
}),
|
|
92
|
+
type: acrossDepositType,
|
|
93
|
+
});
|
|
94
|
+
const transactionIds = [];
|
|
95
|
+
const { end } = collectTransactionIds(chainId, from, messenger, (transactionId) => {
|
|
96
|
+
transactionIds.push(transactionId);
|
|
97
|
+
updateTransaction({
|
|
98
|
+
transactionId: parentTransactionId,
|
|
99
|
+
messenger,
|
|
100
|
+
note: 'Add required transaction ID from Across submission',
|
|
101
|
+
}, (tx) => {
|
|
102
|
+
tx.requiredTransactionIds ?? (tx.requiredTransactionIds = []);
|
|
103
|
+
tx.requiredTransactionIds.push(transactionId);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
let result;
|
|
107
|
+
try {
|
|
108
|
+
if (transactions.length === 1) {
|
|
109
|
+
result = await messenger.call('TransactionController:addTransaction', transactions[0].params, {
|
|
110
|
+
networkClientId,
|
|
111
|
+
origin: ORIGIN_METAMASK,
|
|
112
|
+
requireApproval: false,
|
|
113
|
+
type: transactions[0].type,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const batchTransactions = transactions.map(({ params, type }) => ({
|
|
118
|
+
params: toBatchTransactionParams(params),
|
|
119
|
+
type,
|
|
120
|
+
}));
|
|
121
|
+
await messenger.call('TransactionController:addTransactionBatch', {
|
|
122
|
+
from,
|
|
123
|
+
networkClientId,
|
|
124
|
+
origin: ORIGIN_METAMASK,
|
|
125
|
+
requireApproval: false,
|
|
126
|
+
transactions: batchTransactions,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
end();
|
|
132
|
+
}
|
|
133
|
+
if (result) {
|
|
134
|
+
const txHash = await result.result;
|
|
135
|
+
log('Submitted transaction', txHash);
|
|
136
|
+
}
|
|
137
|
+
await Promise.all(transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)));
|
|
138
|
+
const hash = transactionIds.length
|
|
139
|
+
? getTransaction(transactionIds.slice(-1)[0], messenger)?.hash
|
|
140
|
+
: undefined;
|
|
141
|
+
return await waitForAcrossCompletion(quote.original, hash, messenger);
|
|
142
|
+
}
|
|
143
|
+
async function waitForAcrossCompletion(quote, transactionHash, messenger) {
|
|
144
|
+
if (!transactionHash || !quote.quote.id) {
|
|
145
|
+
return transactionHash;
|
|
146
|
+
}
|
|
147
|
+
const config = getPayStrategiesConfig(messenger);
|
|
148
|
+
const params = new URLSearchParams({
|
|
149
|
+
depositId: quote.quote.id,
|
|
150
|
+
originChainId: String(quote.quote.swapTx.chainId),
|
|
151
|
+
txHash: transactionHash,
|
|
152
|
+
});
|
|
153
|
+
const url = `${config.across.apiBase}/deposit/status?${params.toString()}`;
|
|
154
|
+
let attempt = 0;
|
|
155
|
+
while (true) {
|
|
156
|
+
attempt += 1;
|
|
157
|
+
let status;
|
|
158
|
+
try {
|
|
159
|
+
const response = await successfulFetch(url, {
|
|
160
|
+
method: 'GET',
|
|
161
|
+
headers: {
|
|
162
|
+
Accept: 'application/json',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
status = (await response.json());
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
log('Across status polling request failed', {
|
|
169
|
+
attempt,
|
|
170
|
+
error: String(error),
|
|
171
|
+
transactionHash,
|
|
172
|
+
});
|
|
173
|
+
await new Promise((resolve) => setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const normalizedStatus = status.status?.toLowerCase();
|
|
177
|
+
log('Polled Across status', {
|
|
178
|
+
attempt,
|
|
179
|
+
status: normalizedStatus,
|
|
180
|
+
transactionHash,
|
|
181
|
+
});
|
|
182
|
+
if (normalizedStatus &&
|
|
183
|
+
['completed', 'filled', 'success'].includes(normalizedStatus)) {
|
|
184
|
+
return (status.destinationTxHash ??
|
|
185
|
+
status.fillTxHash ??
|
|
186
|
+
status.txHash ??
|
|
187
|
+
transactionHash);
|
|
188
|
+
}
|
|
189
|
+
if (normalizedStatus &&
|
|
190
|
+
['error', 'failed', 'refund', 'refunded'].includes(normalizedStatus)) {
|
|
191
|
+
throw new Error(`Across request failed with status: ${normalizedStatus}`);
|
|
192
|
+
}
|
|
193
|
+
await new Promise((resolve) => setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function getAcrossDepositType(transactionType) {
|
|
197
|
+
switch (transactionType) {
|
|
198
|
+
case TransactionType.perpsDeposit:
|
|
199
|
+
return TransactionType.perpsAcrossDeposit;
|
|
200
|
+
case TransactionType.predictDeposit:
|
|
201
|
+
return TransactionType.predictAcrossDeposit;
|
|
202
|
+
case undefined:
|
|
203
|
+
return TransactionType.perpsAcrossDeposit;
|
|
204
|
+
default:
|
|
205
|
+
return transactionType;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function buildTransactionParams(from, params) {
|
|
209
|
+
const value = toHex(params.value ?? '0x0');
|
|
210
|
+
const gas = params.gasLimit;
|
|
211
|
+
return {
|
|
212
|
+
data: params.data,
|
|
213
|
+
from,
|
|
214
|
+
gas: toHex(gas),
|
|
215
|
+
maxFeePerGas: normalizeOptionalHex(params.maxFeePerGas),
|
|
216
|
+
maxPriorityFeePerGas: normalizeOptionalHex(params.maxPriorityFeePerGas),
|
|
217
|
+
to: params.to,
|
|
218
|
+
value,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function normalizeOptionalHex(value) {
|
|
222
|
+
if (value === undefined) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
return toHex(value);
|
|
226
|
+
}
|
|
227
|
+
function toBatchTransactionParams(params) {
|
|
228
|
+
return {
|
|
229
|
+
data: params.data,
|
|
230
|
+
gas: params.gas,
|
|
231
|
+
maxFeePerGas: params.maxFeePerGas,
|
|
232
|
+
maxPriorityFeePerGas: params.maxPriorityFeePerGas,
|
|
233
|
+
to: params.to,
|
|
234
|
+
value: params.value,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=across-submit.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"across-submit.mjs","sourceRoot":"","sources":["../../../src/strategy/across/across-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,KAAK,EACN,mCAAmC;AACpC,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAOnE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAGrD,OAAO,EAAE,aAAa,EAAE,yBAAqB;AAM7C,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AACnE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC5B,oCAAgC;AAEjC,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AACjE,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAOzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA+C;IAE/C,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAEjC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACnD,IAAI,eAAgC,CA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,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,wBAAwB,CAC/B,MAAyB;IAEzB,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAuB;QACpC,GAAG,EAAE,MAAM,CAAC,GAAsB;QAClC,YAAY,EAAE,MAAM,CAAC,YAA+B;QACpD,oBAAoB,EAAE,MAAM,CAAC,oBAAuC;QACpE,EAAE,EAAE,MAAM,CAAC,EAAqB;QAChC,KAAK,EAAE,MAAM,CAAC,KAAwB;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import {\n ORIGIN_METAMASK,\n successfulFetch,\n toHex,\n} from '@metamask/controller-utils';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport type {\n BatchTransactionParams,\n TransactionMeta,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport type { AcrossQuote } from './types';\nimport { projectLogger } from '../../logger';\nimport type {\n PayStrategyExecuteRequest,\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n} from '../../types';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags';\nimport {\n collectTransactionIds,\n getTransaction,\n updateTransaction,\n waitForTransactionConfirmed,\n} from '../../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'across-strategy');\nconst ACROSS_STATUS_POLL_INTERVAL = 1000;\n\ntype PreparedAcrossTransaction = {\n params: TransactionParams;\n type: TransactionType;\n};\n\n/**\n * Submit Across quotes.\n *\n * @param request - Request object.\n * @returns An object containing the transaction hash if available.\n */\nexport async function submitAcrossQuotes(\n request: PayStrategyExecuteRequest<AcrossQuote>,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing quotes', request);\n\n const { quotes, messenger, transaction } = request;\n let transactionHash: Hex | undefined;\n\n for (const quote of quotes) {\n ({ transactionHash } = await executeSingleQuote(\n quote,\n messenger,\n transaction,\n ));\n }\n\n return { transactionHash };\n}\n\nasync function executeSingleQuote(\n quote: TransactionPayQuote<AcrossQuote>,\n messenger: TransactionPayControllerMessenger,\n transaction: TransactionMeta,\n): Promise<{ transactionHash?: Hex }> {\n log('Executing single 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 acrossDepositType = getAcrossDepositType(transaction.type);\n const transactionHash = await submitTransactions(\n quote,\n transaction.id,\n acrossDepositType,\n messenger,\n );\n\n updateTransaction(\n {\n transactionId: transaction.id,\n messenger,\n note: 'Intent complete after Across submission',\n },\n (tx) => {\n tx.isIntentComplete = true;\n },\n );\n\n return { transactionHash };\n}\n\n/**\n * Submit transactions for an Across quote.\n *\n * @param quote - Across quote.\n * @param parentTransactionId - ID of the parent transaction.\n * @param acrossDepositType - Transaction type used for the swap/deposit step.\n * @param messenger - Controller messenger.\n * @returns Hash of the last submitted transaction, if available.\n */\nasync function submitTransactions(\n quote: TransactionPayQuote<AcrossQuote>,\n parentTransactionId: string,\n acrossDepositType: TransactionType,\n messenger: TransactionPayControllerMessenger,\n): Promise<Hex | undefined> {\n const { approvalTxns, swapTx } = quote.original.quote;\n const { gasLimits: quoteGasLimits } = quote.original.metamask;\n const { from } = quote.request;\n const chainId = toHex(swapTx.chainId);\n\n const networkClientId = messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n\n const transactions: PreparedAcrossTransaction[] = [];\n\n if (approvalTxns?.length) {\n for (const [index, approval] of approvalTxns.entries()) {\n const approvalGasLimit = quoteGasLimits?.approval[index]?.max;\n if (approvalGasLimit === undefined) {\n throw new Error(\n `Missing quote gas limit for Across approval transaction at index ${index}`,\n );\n }\n\n transactions.push({\n params: buildTransactionParams(from, {\n chainId: approval.chainId,\n data: approval.data,\n gasLimit: approvalGasLimit,\n to: approval.to,\n value: approval.value,\n }),\n type: TransactionType.tokenMethodApprove,\n });\n }\n }\n\n const swapGasLimit = quoteGasLimits?.swap?.max;\n if (swapGasLimit === undefined) {\n throw new Error('Missing quote gas limit for Across swap transaction');\n }\n\n transactions.push({\n params: buildTransactionParams(from, {\n chainId: swapTx.chainId,\n data: swapTx.data,\n gasLimit: swapGasLimit,\n to: swapTx.to,\n value: swapTx.value,\n maxFeePerGas: swapTx.maxFeePerGas,\n maxPriorityFeePerGas: swapTx.maxPriorityFeePerGas,\n }),\n type: acrossDepositType,\n });\n\n const transactionIds: string[] = [];\n\n const { end } = collectTransactionIds(\n chainId,\n from,\n messenger,\n (transactionId) => {\n transactionIds.push(transactionId);\n\n updateTransaction(\n {\n transactionId: parentTransactionId,\n messenger,\n note: 'Add required transaction ID from Across submission',\n },\n (tx) => {\n tx.requiredTransactionIds ??= [];\n tx.requiredTransactionIds.push(transactionId);\n },\n );\n },\n );\n\n let result: { result: Promise<string> } | undefined;\n\n try {\n if (transactions.length === 1) {\n result = await messenger.call(\n 'TransactionController:addTransaction',\n transactions[0].params,\n {\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n type: transactions[0].type,\n },\n );\n } else {\n const batchTransactions = transactions.map(({ params, type }) => ({\n params: toBatchTransactionParams(params),\n type,\n }));\n\n await messenger.call('TransactionController:addTransactionBatch', {\n from,\n networkClientId,\n origin: ORIGIN_METAMASK,\n requireApproval: false,\n transactions: batchTransactions,\n });\n }\n } finally {\n end();\n }\n\n if (result) {\n const txHash = await result.result;\n log('Submitted transaction', txHash);\n }\n\n await Promise.all(\n transactionIds.map((txId) => waitForTransactionConfirmed(txId, messenger)),\n );\n\n const hash = transactionIds.length\n ? getTransaction(transactionIds.slice(-1)[0], messenger)?.hash\n : undefined;\n\n return await waitForAcrossCompletion(\n quote.original,\n hash as Hex | undefined,\n messenger,\n );\n}\n\ntype AcrossStatusResponse = {\n status?: string;\n destinationTxHash?: Hex;\n fillTxHash?: Hex;\n txHash?: Hex;\n};\n\nasync function waitForAcrossCompletion(\n quote: AcrossQuote,\n transactionHash: Hex | undefined,\n messenger: TransactionPayControllerMessenger,\n): Promise<Hex | undefined> {\n if (!transactionHash || !quote.quote.id) {\n return transactionHash;\n }\n\n const config = getPayStrategiesConfig(messenger);\n const params = new URLSearchParams({\n depositId: quote.quote.id,\n originChainId: String(quote.quote.swapTx.chainId),\n txHash: transactionHash,\n });\n const url = `${config.across.apiBase}/deposit/status?${params.toString()}`;\n\n let attempt = 0;\n\n while (true) {\n attempt += 1;\n let status: AcrossStatusResponse;\n\n try {\n const response = await successfulFetch(url, {\n method: 'GET',\n headers: {\n Accept: 'application/json',\n },\n });\n status = (await response.json()) as AcrossStatusResponse;\n } catch (error) {\n log('Across status polling request failed', {\n attempt,\n error: String(error),\n transactionHash,\n });\n\n await new Promise((resolve) =>\n setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL),\n );\n continue;\n }\n\n const normalizedStatus = status.status?.toLowerCase();\n\n log('Polled Across status', {\n attempt,\n status: normalizedStatus,\n transactionHash,\n });\n\n if (\n normalizedStatus &&\n ['completed', 'filled', 'success'].includes(normalizedStatus)\n ) {\n return (\n status.destinationTxHash ??\n status.fillTxHash ??\n status.txHash ??\n transactionHash\n );\n }\n\n if (\n normalizedStatus &&\n ['error', 'failed', 'refund', 'refunded'].includes(normalizedStatus)\n ) {\n throw new Error(`Across request failed with status: ${normalizedStatus}`);\n }\n\n await new Promise((resolve) =>\n setTimeout(resolve, ACROSS_STATUS_POLL_INTERVAL),\n );\n }\n}\n\nfunction getAcrossDepositType(\n transactionType?: TransactionType,\n): TransactionType {\n switch (transactionType) {\n case TransactionType.perpsDeposit:\n return TransactionType.perpsAcrossDeposit;\n case TransactionType.predictDeposit:\n return TransactionType.predictAcrossDeposit;\n case undefined:\n return TransactionType.perpsAcrossDeposit;\n default:\n return transactionType;\n }\n}\n\nfunction buildTransactionParams(\n from: Hex,\n params: {\n chainId: number;\n data: Hex;\n gasLimit: number;\n to: Hex;\n value?: Hex;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n },\n): TransactionParams {\n const value = toHex(params.value ?? '0x0');\n const gas = params.gasLimit;\n\n return {\n data: params.data,\n from,\n gas: toHex(gas),\n maxFeePerGas: normalizeOptionalHex(params.maxFeePerGas),\n maxPriorityFeePerGas: normalizeOptionalHex(params.maxPriorityFeePerGas),\n to: params.to,\n value,\n };\n}\n\nfunction normalizeOptionalHex(value?: string): Hex | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n return toHex(value);\n}\n\nfunction toBatchTransactionParams(\n params: TransactionParams,\n): BatchTransactionParams {\n return {\n data: params.data as Hex | undefined,\n gas: params.gas as Hex | undefined,\n maxFeePerGas: params.maxFeePerGas as Hex | undefined,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas as Hex | undefined,\n to: params.to as Hex | undefined,\n value: params.value as Hex | undefined,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/strategy/across/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/** Structured destination action for Across quote APIs. */\nexport type AcrossActionArg = {\n balanceSourceToken?: string;\n populateDynamically: boolean;\n value: string | string[] | string[][];\n};\n\nexport type AcrossAction = {\n args: AcrossActionArg[];\n functionSignature: string;\n isNativeTransfer: boolean;\n populateCallValueDynamically?: boolean;\n target: Hex;\n value: string;\n};\n\nexport type AcrossActionRequestBody = {\n actions: AcrossAction[];\n};\n\nexport type AcrossToken = {\n address: Hex;\n chainId: number;\n decimals: number;\n name?: string;\n symbol?: string;\n};\n\nexport type AcrossFeeComponent = {\n amount?: string;\n amountUsd?: string;\n pct?: string | null;\n token?: AcrossToken;\n};\n\nexport type AcrossFees = {\n total?: AcrossFeeComponent;\n originGas?: AcrossFeeComponent;\n destinationGas?: AcrossFeeComponent;\n relayerCapital?: AcrossFeeComponent;\n relayerTotal?: AcrossFeeComponent;\n lpFee?: AcrossFeeComponent;\n app?: AcrossFeeComponent;\n swapImpact?: AcrossFeeComponent;\n};\n\nexport type AcrossApprovalTransaction = {\n chainId: number;\n to: Hex;\n data: Hex;\n value?: Hex;\n};\n\nexport type AcrossSwapTransaction = {\n chainId: number;\n to: Hex;\n data: Hex;\n gas?: string;\n value?: Hex;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n};\n\nexport type AcrossSwapApprovalResponse = {\n approvalTxns?: AcrossApprovalTransaction[];\n expectedFillTime?: number;\n expectedOutputAmount?: string;\n fees?: AcrossFees;\n id?: string;\n inputAmount?: string;\n inputToken: AcrossToken;\n minOutputAmount?: string;\n outputToken: AcrossToken;\n swapTx: AcrossSwapTransaction;\n};\n\nexport type AcrossGasLimits = {\n approval: {\n estimate: number;\n max: number;\n }[];\n swap: {\n estimate: number;\n max: number;\n };\n};\n\nexport type AcrossQuote = {\n metamask: {\n gasLimits: AcrossGasLimits;\n };\n quote: AcrossSwapApprovalResponse;\n request: {\n amount: string;\n tradeType: 'exactOutput' | 'exactInput';\n };\n};\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/** Structured destination action for Across quote APIs. */
|
|
3
|
+
export type AcrossActionArg = {
|
|
4
|
+
balanceSourceToken?: string;
|
|
5
|
+
populateDynamically: boolean;
|
|
6
|
+
value: string | string[] | string[][];
|
|
7
|
+
};
|
|
8
|
+
export type AcrossAction = {
|
|
9
|
+
args: AcrossActionArg[];
|
|
10
|
+
functionSignature: string;
|
|
11
|
+
isNativeTransfer: boolean;
|
|
12
|
+
populateCallValueDynamically?: boolean;
|
|
13
|
+
target: Hex;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
export type AcrossActionRequestBody = {
|
|
17
|
+
actions: AcrossAction[];
|
|
18
|
+
};
|
|
19
|
+
export type AcrossToken = {
|
|
20
|
+
address: Hex;
|
|
21
|
+
chainId: number;
|
|
22
|
+
decimals: number;
|
|
23
|
+
name?: string;
|
|
24
|
+
symbol?: string;
|
|
25
|
+
};
|
|
26
|
+
export type AcrossFeeComponent = {
|
|
27
|
+
amount?: string;
|
|
28
|
+
amountUsd?: string;
|
|
29
|
+
pct?: string | null;
|
|
30
|
+
token?: AcrossToken;
|
|
31
|
+
};
|
|
32
|
+
export type AcrossFees = {
|
|
33
|
+
total?: AcrossFeeComponent;
|
|
34
|
+
originGas?: AcrossFeeComponent;
|
|
35
|
+
destinationGas?: AcrossFeeComponent;
|
|
36
|
+
relayerCapital?: AcrossFeeComponent;
|
|
37
|
+
relayerTotal?: AcrossFeeComponent;
|
|
38
|
+
lpFee?: AcrossFeeComponent;
|
|
39
|
+
app?: AcrossFeeComponent;
|
|
40
|
+
swapImpact?: AcrossFeeComponent;
|
|
41
|
+
};
|
|
42
|
+
export type AcrossApprovalTransaction = {
|
|
43
|
+
chainId: number;
|
|
44
|
+
to: Hex;
|
|
45
|
+
data: Hex;
|
|
46
|
+
value?: Hex;
|
|
47
|
+
};
|
|
48
|
+
export type AcrossSwapTransaction = {
|
|
49
|
+
chainId: number;
|
|
50
|
+
to: Hex;
|
|
51
|
+
data: Hex;
|
|
52
|
+
gas?: string;
|
|
53
|
+
value?: Hex;
|
|
54
|
+
maxFeePerGas?: string;
|
|
55
|
+
maxPriorityFeePerGas?: string;
|
|
56
|
+
};
|
|
57
|
+
export type AcrossSwapApprovalResponse = {
|
|
58
|
+
approvalTxns?: AcrossApprovalTransaction[];
|
|
59
|
+
expectedFillTime?: number;
|
|
60
|
+
expectedOutputAmount?: string;
|
|
61
|
+
fees?: AcrossFees;
|
|
62
|
+
id?: string;
|
|
63
|
+
inputAmount?: string;
|
|
64
|
+
inputToken: AcrossToken;
|
|
65
|
+
minOutputAmount?: string;
|
|
66
|
+
outputToken: AcrossToken;
|
|
67
|
+
swapTx: AcrossSwapTransaction;
|
|
68
|
+
};
|
|
69
|
+
export type AcrossGasLimits = {
|
|
70
|
+
approval: {
|
|
71
|
+
estimate: number;
|
|
72
|
+
max: number;
|
|
73
|
+
}[];
|
|
74
|
+
swap: {
|
|
75
|
+
estimate: number;
|
|
76
|
+
max: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type AcrossQuote = {
|
|
80
|
+
metamask: {
|
|
81
|
+
gasLimits: AcrossGasLimits;
|
|
82
|
+
};
|
|
83
|
+
quote: AcrossSwapApprovalResponse;
|
|
84
|
+
request: {
|
|
85
|
+
amount: string;
|
|
86
|
+
tradeType: 'exactOutput' | 'exactInput';
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/strategy/across/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CA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AC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,SAAS,EAAE,eAAe,CAAC;KAC5B,CAAC;IACF,KAAK,EAAE,0BAA0B,CAAC;IAClC,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,aAAa,GAAG,YAAY,CAAC;KACzC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
/** Structured destination action for Across quote APIs. */
|
|
3
|
+
export type AcrossActionArg = {
|
|
4
|
+
balanceSourceToken?: string;
|
|
5
|
+
populateDynamically: boolean;
|
|
6
|
+
value: string | string[] | string[][];
|
|
7
|
+
};
|
|
8
|
+
export type AcrossAction = {
|
|
9
|
+
args: AcrossActionArg[];
|
|
10
|
+
functionSignature: string;
|
|
11
|
+
isNativeTransfer: boolean;
|
|
12
|
+
populateCallValueDynamically?: boolean;
|
|
13
|
+
target: Hex;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
export type AcrossActionRequestBody = {
|
|
17
|
+
actions: AcrossAction[];
|
|
18
|
+
};
|
|
19
|
+
export type AcrossToken = {
|
|
20
|
+
address: Hex;
|
|
21
|
+
chainId: number;
|
|
22
|
+
decimals: number;
|
|
23
|
+
name?: string;
|
|
24
|
+
symbol?: string;
|
|
25
|
+
};
|
|
26
|
+
export type AcrossFeeComponent = {
|
|
27
|
+
amount?: string;
|
|
28
|
+
amountUsd?: string;
|
|
29
|
+
pct?: string | null;
|
|
30
|
+
token?: AcrossToken;
|
|
31
|
+
};
|
|
32
|
+
export type AcrossFees = {
|
|
33
|
+
total?: AcrossFeeComponent;
|
|
34
|
+
originGas?: AcrossFeeComponent;
|
|
35
|
+
destinationGas?: AcrossFeeComponent;
|
|
36
|
+
relayerCapital?: AcrossFeeComponent;
|
|
37
|
+
relayerTotal?: AcrossFeeComponent;
|
|
38
|
+
lpFee?: AcrossFeeComponent;
|
|
39
|
+
app?: AcrossFeeComponent;
|
|
40
|
+
swapImpact?: AcrossFeeComponent;
|
|
41
|
+
};
|
|
42
|
+
export type AcrossApprovalTransaction = {
|
|
43
|
+
chainId: number;
|
|
44
|
+
to: Hex;
|
|
45
|
+
data: Hex;
|
|
46
|
+
value?: Hex;
|
|
47
|
+
};
|
|
48
|
+
export type AcrossSwapTransaction = {
|
|
49
|
+
chainId: number;
|
|
50
|
+
to: Hex;
|
|
51
|
+
data: Hex;
|
|
52
|
+
gas?: string;
|
|
53
|
+
value?: Hex;
|
|
54
|
+
maxFeePerGas?: string;
|
|
55
|
+
maxPriorityFeePerGas?: string;
|
|
56
|
+
};
|
|
57
|
+
export type AcrossSwapApprovalResponse = {
|
|
58
|
+
approvalTxns?: AcrossApprovalTransaction[];
|
|
59
|
+
expectedFillTime?: number;
|
|
60
|
+
expectedOutputAmount?: string;
|
|
61
|
+
fees?: AcrossFees;
|
|
62
|
+
id?: string;
|
|
63
|
+
inputAmount?: string;
|
|
64
|
+
inputToken: AcrossToken;
|
|
65
|
+
minOutputAmount?: string;
|
|
66
|
+
outputToken: AcrossToken;
|
|
67
|
+
swapTx: AcrossSwapTransaction;
|
|
68
|
+
};
|
|
69
|
+
export type AcrossGasLimits = {
|
|
70
|
+
approval: {
|
|
71
|
+
estimate: number;
|
|
72
|
+
max: number;
|
|
73
|
+
}[];
|
|
74
|
+
swap: {
|
|
75
|
+
estimate: number;
|
|
76
|
+
max: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export type AcrossQuote = {
|
|
80
|
+
metamask: {
|
|
81
|
+
gasLimits: AcrossGasLimits;
|
|
82
|
+
};
|
|
83
|
+
quote: AcrossSwapApprovalResponse;
|
|
84
|
+
request: {
|
|
85
|
+
amount: string;
|
|
86
|
+
tradeType: 'exactOutput' | 'exactInput';
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/strategy/across/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE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,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;IACJ,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,SAAS,EAAE,eAAe,CAAC;KAC5B,CAAC;IACF,KAAK,EAAE,0BAA0B,CAAC;IAClC,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,aAAa,GAAG,YAAY,CAAC;KACzC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/strategy/across/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/** Structured destination action for Across quote APIs. */\nexport type AcrossActionArg = {\n balanceSourceToken?: string;\n populateDynamically: boolean;\n value: string | string[] | string[][];\n};\n\nexport type AcrossAction = {\n args: AcrossActionArg[];\n functionSignature: string;\n isNativeTransfer: boolean;\n populateCallValueDynamically?: boolean;\n target: Hex;\n value: string;\n};\n\nexport type AcrossActionRequestBody = {\n actions: AcrossAction[];\n};\n\nexport type AcrossToken = {\n address: Hex;\n chainId: number;\n decimals: number;\n name?: string;\n symbol?: string;\n};\n\nexport type AcrossFeeComponent = {\n amount?: string;\n amountUsd?: string;\n pct?: string | null;\n token?: AcrossToken;\n};\n\nexport type AcrossFees = {\n total?: AcrossFeeComponent;\n originGas?: AcrossFeeComponent;\n destinationGas?: AcrossFeeComponent;\n relayerCapital?: AcrossFeeComponent;\n relayerTotal?: AcrossFeeComponent;\n lpFee?: AcrossFeeComponent;\n app?: AcrossFeeComponent;\n swapImpact?: AcrossFeeComponent;\n};\n\nexport type AcrossApprovalTransaction = {\n chainId: number;\n to: Hex;\n data: Hex;\n value?: Hex;\n};\n\nexport type AcrossSwapTransaction = {\n chainId: number;\n to: Hex;\n data: Hex;\n gas?: string;\n value?: Hex;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n};\n\nexport type AcrossSwapApprovalResponse = {\n approvalTxns?: AcrossApprovalTransaction[];\n expectedFillTime?: number;\n expectedOutputAmount?: string;\n fees?: AcrossFees;\n id?: string;\n inputAmount?: string;\n inputToken: AcrossToken;\n minOutputAmount?: string;\n outputToken: AcrossToken;\n swapTx: AcrossSwapTransaction;\n};\n\nexport type AcrossGasLimits = {\n approval: {\n estimate: number;\n max: number;\n }[];\n swap: {\n estimate: number;\n max: number;\n };\n};\n\nexport type AcrossQuote = {\n metamask: {\n gasLimits: AcrossGasLimits;\n };\n quote: AcrossSwapApprovalResponse;\n request: {\n amount: string;\n tradeType: 'exactOutput' | 'exactInput';\n };\n};\n"]}
|
|
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RelayStrategy = void 0;
|
|
4
4
|
const relay_quotes_1 = require("./relay-quotes.cjs");
|
|
5
5
|
const relay_submit_1 = require("./relay-submit.cjs");
|
|
6
|
+
const feature_flags_1 = require("../../utils/feature-flags.cjs");
|
|
6
7
|
class RelayStrategy {
|
|
8
|
+
supports(request) {
|
|
9
|
+
const config = (0, feature_flags_1.getPayStrategiesConfig)(request.messenger);
|
|
10
|
+
return config.relay.enabled;
|
|
11
|
+
}
|
|
7
12
|
async getQuotes(request) {
|
|
8
13
|
return (0, relay_quotes_1.getRelayQuotes)(request);
|
|
9
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelayStrategy.cjs","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAChD,qDAAmD;
|
|
1
|
+
{"version":3,"file":"RelayStrategy.cjs","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAChD,qDAAmD;AAQnD,iEAAmE;AAEnE,MAAa,aAAa;IACxB,QAAQ,CAAC,OAAoC;QAC3C,MAAM,MAAM,GAAG,IAAA,sCAAsB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,SAAS,CACb,OAAoC;QAEpC,OAAO,IAAA,6BAAc,EAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,OAAO,CACX,OAA8C;QAE9C,OAAO,MAAM,IAAA,gCAAiB,EAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF;AAjBD,sCAiBC","sourcesContent":["import { getRelayQuotes } from './relay-quotes';\nimport { submitRelayQuotes } from './relay-submit';\nimport type { RelayQuote } from './types';\nimport type {\n PayStrategy,\n PayStrategyExecuteRequest,\n PayStrategyGetQuotesRequest,\n TransactionPayQuote,\n} from '../../types';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags';\n\nexport class RelayStrategy implements PayStrategy<RelayQuote> {\n supports(request: PayStrategyGetQuotesRequest): boolean {\n const config = getPayStrategiesConfig(request.messenger);\n return config.relay.enabled;\n }\n\n async getQuotes(\n request: PayStrategyGetQuotesRequest,\n ): Promise<TransactionPayQuote<RelayQuote>[]> {\n return getRelayQuotes(request);\n }\n\n async execute(\n request: PayStrategyExecuteRequest<RelayQuote>,\n ): ReturnType<PayStrategy<RelayQuote>['execute']> {\n return await submitRelayQuotes(request);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RelayQuote } from "./types.cjs";
|
|
2
2
|
import type { PayStrategy, PayStrategyExecuteRequest, PayStrategyGetQuotesRequest, TransactionPayQuote } from "../../types.cjs";
|
|
3
3
|
export declare class RelayStrategy implements PayStrategy<RelayQuote> {
|
|
4
|
+
supports(request: PayStrategyGetQuotesRequest): boolean;
|
|
4
5
|
getQuotes(request: PayStrategyGetQuotesRequest): Promise<TransactionPayQuote<RelayQuote>[]>;
|
|
5
6
|
execute(request: PayStrategyExecuteRequest<RelayQuote>): ReturnType<PayStrategy<RelayQuote>['execute']>;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelayStrategy.d.cts","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAC1C,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACpB,wBAAoB;
|
|
1
|
+
{"version":3,"file":"RelayStrategy.d.cts","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAC1C,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACpB,wBAAoB;AAGrB,qBAAa,aAAc,YAAW,WAAW,CAAC,UAAU,CAAC;IAC3D,QAAQ,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO;IAKjD,SAAS,CACb,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;IAIvC,OAAO,CACX,OAAO,EAAE,yBAAyB,CAAC,UAAU,CAAC,GAC7C,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAGlD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RelayQuote } from "./types.mjs";
|
|
2
2
|
import type { PayStrategy, PayStrategyExecuteRequest, PayStrategyGetQuotesRequest, TransactionPayQuote } from "../../types.mjs";
|
|
3
3
|
export declare class RelayStrategy implements PayStrategy<RelayQuote> {
|
|
4
|
+
supports(request: PayStrategyGetQuotesRequest): boolean;
|
|
4
5
|
getQuotes(request: PayStrategyGetQuotesRequest): Promise<TransactionPayQuote<RelayQuote>[]>;
|
|
5
6
|
execute(request: PayStrategyExecuteRequest<RelayQuote>): ReturnType<PayStrategy<RelayQuote>['execute']>;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelayStrategy.d.mts","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAC1C,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACpB,wBAAoB;
|
|
1
|
+
{"version":3,"file":"RelayStrategy.d.mts","sourceRoot":"","sources":["../../../src/strategy/relay/RelayStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAC1C,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACpB,wBAAoB;AAGrB,qBAAa,aAAc,YAAW,WAAW,CAAC,UAAU,CAAC;IAC3D,QAAQ,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO;IAKjD,SAAS,CACb,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;IAIvC,OAAO,CACX,OAAO,EAAE,yBAAyB,CAAC,UAAU,CAAC,GAC7C,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAGlD"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getRelayQuotes } from "./relay-quotes.mjs";
|
|
2
2
|
import { submitRelayQuotes } from "./relay-submit.mjs";
|
|
3
|
+
import { getPayStrategiesConfig } from "../../utils/feature-flags.mjs";
|
|
3
4
|
export class RelayStrategy {
|
|
5
|
+
supports(request) {
|
|
6
|
+
const config = getPayStrategiesConfig(request.messenger);
|
|
7
|
+
return config.relay.enabled;
|
|
8
|
+
}
|
|
4
9
|
async getQuotes(request) {
|
|
5
10
|
return getRelayQuotes(request);
|
|
6
11
|
}
|