@metamask/transaction-pay-controller 17.1.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/strategy/across/across-quotes.cjs +64 -93
  3. package/dist/strategy/across/across-quotes.cjs.map +1 -1
  4. package/dist/strategy/across/across-quotes.d.cts.map +1 -1
  5. package/dist/strategy/across/across-quotes.d.mts.map +1 -1
  6. package/dist/strategy/across/across-quotes.mjs +65 -94
  7. package/dist/strategy/across/across-quotes.mjs.map +1 -1
  8. package/dist/strategy/across/across-submit.cjs +38 -37
  9. package/dist/strategy/across/across-submit.cjs.map +1 -1
  10. package/dist/strategy/across/across-submit.d.cts.map +1 -1
  11. package/dist/strategy/across/across-submit.d.mts.map +1 -1
  12. package/dist/strategy/across/across-submit.mjs +38 -37
  13. package/dist/strategy/across/across-submit.mjs.map +1 -1
  14. package/dist/strategy/across/transactions.cjs +23 -0
  15. package/dist/strategy/across/transactions.cjs.map +1 -0
  16. package/dist/strategy/across/transactions.d.cts +18 -0
  17. package/dist/strategy/across/transactions.d.cts.map +1 -0
  18. package/dist/strategy/across/transactions.d.mts +18 -0
  19. package/dist/strategy/across/transactions.d.mts.map +1 -0
  20. package/dist/strategy/across/transactions.mjs +19 -0
  21. package/dist/strategy/across/transactions.mjs.map +1 -0
  22. package/dist/strategy/across/types.cjs.map +1 -1
  23. package/dist/strategy/across/types.d.cts +6 -10
  24. package/dist/strategy/across/types.d.cts.map +1 -1
  25. package/dist/strategy/across/types.d.mts +6 -10
  26. package/dist/strategy/across/types.d.mts.map +1 -1
  27. package/dist/strategy/across/types.mjs.map +1 -1
  28. package/dist/strategy/relay/relay-quotes.cjs +49 -135
  29. package/dist/strategy/relay/relay-quotes.cjs.map +1 -1
  30. package/dist/strategy/relay/relay-quotes.d.cts.map +1 -1
  31. package/dist/strategy/relay/relay-quotes.d.mts.map +1 -1
  32. package/dist/strategy/relay/relay-quotes.mjs +51 -137
  33. package/dist/strategy/relay/relay-quotes.mjs.map +1 -1
  34. package/dist/strategy/relay/relay-submit.cjs +4 -3
  35. package/dist/strategy/relay/relay-submit.cjs.map +1 -1
  36. package/dist/strategy/relay/relay-submit.mjs +4 -3
  37. package/dist/strategy/relay/relay-submit.mjs.map +1 -1
  38. package/dist/strategy/relay/types.cjs.map +1 -1
  39. package/dist/strategy/relay/types.d.cts +10 -5
  40. package/dist/strategy/relay/types.d.cts.map +1 -1
  41. package/dist/strategy/relay/types.d.mts +10 -5
  42. package/dist/strategy/relay/types.d.mts.map +1 -1
  43. package/dist/strategy/relay/types.mjs.map +1 -1
  44. package/dist/utils/quote-gas.cjs +143 -0
  45. package/dist/utils/quote-gas.cjs.map +1 -0
  46. package/dist/utils/quote-gas.d.cts +31 -0
  47. package/dist/utils/quote-gas.d.cts.map +1 -0
  48. package/dist/utils/quote-gas.d.mts +31 -0
  49. package/dist/utils/quote-gas.d.mts.map +1 -0
  50. package/dist/utils/quote-gas.mjs +139 -0
  51. package/dist/utils/quote-gas.mjs.map +1 -0
  52. package/package.json +4 -4
@@ -0,0 +1,18 @@
1
+ import { TransactionType } from "@metamask/transaction-controller";
2
+ import type { AcrossSwapApprovalResponse } from "./types.mjs";
3
+ export type AcrossOrderedTransaction = {
4
+ chainId: number;
5
+ data: `0x${string}`;
6
+ gas?: string;
7
+ kind: 'approval' | 'swap';
8
+ maxFeePerGas?: string;
9
+ maxPriorityFeePerGas?: string;
10
+ to: `0x${string}`;
11
+ type?: TransactionType;
12
+ value?: `0x${string}`;
13
+ };
14
+ export declare function getAcrossOrderedTransactions({ quote, swapType, }: {
15
+ quote: AcrossSwapApprovalResponse;
16
+ swapType?: TransactionType;
17
+ }): AcrossOrderedTransaction[];
18
+ //# sourceMappingURL=transactions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.d.mts","sourceRoot":"","sources":["../../../src/strategy/across/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAEnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAgB;AAE1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,EAC3C,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,0BAA0B,CAAC;IAClC,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,GAAG,wBAAwB,EAAE,CAiB7B"}
@@ -0,0 +1,19 @@
1
+ import { TransactionType } from "@metamask/transaction-controller";
2
+ export function getAcrossOrderedTransactions({ quote, swapType, }) {
3
+ const swapChainId = quote.swapTx.chainId;
4
+ const approvalTransactions = (quote.approvalTxns ?? []).map((approval) => ({
5
+ ...approval,
6
+ chainId: approval.chainId ?? swapChainId,
7
+ kind: 'approval',
8
+ type: TransactionType.tokenMethodApprove,
9
+ }));
10
+ return [
11
+ ...approvalTransactions,
12
+ {
13
+ ...quote.swapTx,
14
+ kind: 'swap',
15
+ type: swapType,
16
+ },
17
+ ];
18
+ }
19
+ //# sourceMappingURL=transactions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.mjs","sourceRoot":"","sources":["../../../src/strategy/across/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,yCAAyC;AAgBnE,MAAM,UAAU,4BAA4B,CAAC,EAC3C,KAAK,EACL,QAAQ,GAIT;IACC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;IACzC,MAAM,oBAAoB,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACzE,GAAG,QAAQ;QACX,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,WAAW;QACxC,IAAI,EAAE,UAAmB;QACzB,IAAI,EAAE,eAAe,CAAC,kBAAkB;KACzC,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,GAAG,oBAAoB;QACvB;YACE,GAAG,KAAK,CAAC,MAAM;YACf,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;SACf;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\n\nimport type { AcrossSwapApprovalResponse } from './types';\n\nexport type AcrossOrderedTransaction = {\n chainId: number;\n data: `0x${string}`;\n gas?: string;\n kind: 'approval' | 'swap';\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n to: `0x${string}`;\n type?: TransactionType;\n value?: `0x${string}`;\n};\n\nexport function getAcrossOrderedTransactions({\n quote,\n swapType,\n}: {\n quote: AcrossSwapApprovalResponse;\n swapType?: TransactionType;\n}): AcrossOrderedTransaction[] {\n const swapChainId = quote.swapTx.chainId;\n const approvalTransactions = (quote.approvalTxns ?? []).map((approval) => ({\n ...approval,\n chainId: approval.chainId ?? swapChainId,\n kind: 'approval' as const,\n type: TransactionType.tokenMethodApprove,\n }));\n\n return [\n ...approvalTransactions,\n {\n ...quote.swapTx,\n kind: 'swap',\n type: swapType,\n },\n ];\n}\n"]}
@@ -1 +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"]}
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 AcrossGasLimit = {\n estimate: number;\n max: number;\n};\n\nexport type AcrossGasLimits = AcrossGasLimit[];\n\nexport type AcrossQuote = {\n metamask: {\n gasLimits: AcrossGasLimits;\n is7702?: boolean;\n };\n quote: AcrossSwapApprovalResponse;\n request: {\n amount: string;\n tradeType: 'exactOutput' | 'exactInput';\n };\n};\n"]}
@@ -40,7 +40,7 @@ export type AcrossFees = {
40
40
  swapImpact?: AcrossFeeComponent;
41
41
  };
42
42
  export type AcrossApprovalTransaction = {
43
- chainId: number;
43
+ chainId?: number;
44
44
  to: Hex;
45
45
  data: Hex;
46
46
  value?: Hex;
@@ -66,19 +66,15 @@ export type AcrossSwapApprovalResponse = {
66
66
  outputToken: AcrossToken;
67
67
  swapTx: AcrossSwapTransaction;
68
68
  };
69
- export type AcrossGasLimits = {
70
- approval: {
71
- estimate: number;
72
- max: number;
73
- }[];
74
- swap: {
75
- estimate: number;
76
- max: number;
77
- };
69
+ export type AcrossGasLimit = {
70
+ estimate: number;
71
+ max: number;
78
72
  };
73
+ export type AcrossGasLimits = AcrossGasLimit[];
79
74
  export type AcrossQuote = {
80
75
  metamask: {
81
76
  gasLimits: AcrossGasLimits;
77
+ is7702?: boolean;
82
78
  };
83
79
  quote: AcrossSwapApprovalResponse;
84
80
  request: {
@@ -1 +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;AA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AAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,GAAG,CAAC;IACR,IAAI,EAAE,GAAG,CAAC;IACV,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,EAAE,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,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,EAAE,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,SAAS,EAAE,eAAe,CAAC;QAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,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"}
@@ -40,7 +40,7 @@ export type AcrossFees = {
40
40
  swapImpact?: AcrossFeeComponent;
41
41
  };
42
42
  export type AcrossApprovalTransaction = {
43
- chainId: number;
43
+ chainId?: number;
44
44
  to: Hex;
45
45
  data: Hex;
46
46
  value?: Hex;
@@ -66,19 +66,15 @@ export type AcrossSwapApprovalResponse = {
66
66
  outputToken: AcrossToken;
67
67
  swapTx: AcrossSwapTransaction;
68
68
  };
69
- export type AcrossGasLimits = {
70
- approval: {
71
- estimate: number;
72
- max: number;
73
- }[];
74
- swap: {
75
- estimate: number;
76
- max: number;
77
- };
69
+ export type AcrossGasLimit = {
70
+ estimate: number;
71
+ max: number;
78
72
  };
73
+ export type AcrossGasLimits = AcrossGasLimit[];
79
74
  export type AcrossQuote = {
80
75
  metamask: {
81
76
  gasLimits: AcrossGasLimits;
77
+ is7702?: boolean;
82
78
  };
83
79
  quote: AcrossSwapApprovalResponse;
84
80
  request: {
@@ -1 +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,CA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;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,EAAE,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,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,EAAE,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE;QACR,SAAS,EAAE,eAAe,CAAC;QAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,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"}
@@ -1 +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"]}
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 AcrossGasLimit = {\n estimate: number;\n max: number;\n};\n\nexport type AcrossGasLimits = AcrossGasLimit[];\n\nexport type AcrossQuote = {\n metamask: {\n gasLimits: AcrossGasLimits;\n is7702?: boolean;\n };\n quote: AcrossSwapApprovalResponse;\n request: {\n amount: string;\n tradeType: 'exactOutput' | 'exactInput';\n };\n};\n"]}
@@ -16,6 +16,7 @@ const logger_1 = require("../../logger.cjs");
16
16
  const amounts_1 = require("../../utils/amounts.cjs");
17
17
  const feature_flags_1 = require("../../utils/feature-flags.cjs");
18
18
  const gas_1 = require("../../utils/gas.cjs");
19
+ const quote_gas_1 = require("../../utils/quote-gas.cjs");
19
20
  const token_1 = require("../../utils/token.cjs");
20
21
  const transaction_1 = require("../../utils/transaction.cjs");
21
22
  const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'relay-strategy');
@@ -262,7 +263,7 @@ async function normalizeQuote(quote, request, fullRequest) {
262
263
  const provider = subsidizedFeeUsd.gt(0)
263
264
  ? { usd: '0', fiat: '0' }
264
265
  : (0, amounts_1.getFiatValueFromUsd)(providerFeeUsd, usdToFiatRate);
265
- const { gasLimits, isGasFeeToken: isSourceGasFeeToken, ...sourceNetwork } = await calculateSourceNetworkCost(quote, messenger, request, fullRequest.transaction);
266
+ const { gasLimits, is7702, isGasFeeToken: isSourceGasFeeToken, ...sourceNetwork } = await calculateSourceNetworkCost(quote, messenger, request, fullRequest.transaction);
266
267
  const targetNetwork = {
267
268
  usd: '0',
268
269
  fiat: '0',
@@ -286,7 +287,8 @@ async function normalizeQuote(quote, request, fullRequest) {
286
287
  const targetAmount = (0, amounts_1.getFiatValueFromUsd)(targetAmountUsd, usdToFiatRate);
287
288
  const metamask = {
288
289
  ...quote.metamask,
289
- gasLimits,
290
+ gasLimits: is7702 ? [gasLimits[0]] : gasLimits,
291
+ is7702,
290
292
  };
291
293
  return {
292
294
  dust,
@@ -366,7 +368,12 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
366
368
  if (quote.metamask?.isExecute) {
367
369
  log('Zeroing network fees for execute flow');
368
370
  const zeroAmount = { fiat: '0', human: '0', raw: '0', usd: '0' };
369
- return { estimate: zeroAmount, max: zeroAmount, gasLimits: [] };
371
+ return {
372
+ estimate: zeroAmount,
373
+ max: zeroAmount,
374
+ gasLimits: [],
375
+ is7702: false,
376
+ };
370
377
  }
371
378
  const relayParams = quote.steps
372
379
  .flatMap((step) => step.items)
@@ -375,10 +382,11 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
375
382
  const isPredictWithdraw = request.isPostQuote && (0, transaction_1.isPredictWithdrawTransaction)(transaction);
376
383
  const fromOverride = isPredictWithdraw ? request.refundTo : undefined;
377
384
  const relayOnlyGas = await calculateSourceNetworkGasLimit(relayParams, messenger, fromOverride);
378
- const { totalGasEstimate, totalGasLimit, gasLimits } = request.isPostQuote
385
+ const { gasLimits, is7702, totalGasEstimate, totalGasLimit } = request.isPostQuote
379
386
  ? combinePostQuoteGas(relayOnlyGas, transaction)
380
387
  : relayOnlyGas;
381
388
  log('Gas limit', {
389
+ is7702,
382
390
  totalGasEstimate,
383
391
  totalGasLimit,
384
392
  gasLimits,
@@ -399,7 +407,7 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
399
407
  isMax: true,
400
408
  });
401
409
  const nativeBalance = (0, token_1.getTokenBalance)(messenger, from, sourceChainId, (0, token_1.getNativeToken)(sourceChainId));
402
- const result = { estimate, max, gasLimits };
410
+ const result = { estimate, max, gasLimits, is7702 };
403
411
  if (new bignumber_js_1.BigNumber(nativeBalance).isGreaterThanOrEqualTo(max.raw)) {
404
412
  return result;
405
413
  }
@@ -450,6 +458,7 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
450
458
  estimate: gasFeeTokenCost,
451
459
  max: gasFeeTokenCost,
452
460
  gasLimits,
461
+ is7702,
453
462
  };
454
463
  }
455
464
  return result;
@@ -480,6 +489,7 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
480
489
  estimate: gasFeeTokenCost,
481
490
  max: gasFeeTokenCost,
482
491
  gasLimits,
492
+ is7702,
483
493
  };
484
494
  }
485
495
  /**
@@ -493,9 +503,29 @@ async function calculateSourceNetworkCost(quote, messenger, request, transaction
493
503
  * @returns Total gas estimates and per-transaction gas limits.
494
504
  */
495
505
  async function calculateSourceNetworkGasLimit(params, messenger, fromOverride) {
496
- return params.length === 1
497
- ? calculateSourceNetworkGasLimitSingle(params[0], messenger, fromOverride)
498
- : calculateSourceNetworkGasLimitBatch(params, messenger, fromOverride);
506
+ const transactions = params.map((singleParams) => toRelayQuoteGasTransaction(singleParams, fromOverride));
507
+ const relayGasResult = await (0, quote_gas_1.estimateQuoteGasLimits)({
508
+ fallbackGas: (0, feature_flags_1.getFeatureFlags)(messenger).relayFallbackGas,
509
+ fallbackOnSimulationFailure: true,
510
+ messenger,
511
+ transactions,
512
+ });
513
+ return {
514
+ gasLimits: relayGasResult.gasLimits.map((gasLimit) => gasLimit.max),
515
+ is7702: relayGasResult.is7702,
516
+ totalGasEstimate: relayGasResult.totalGasEstimate,
517
+ totalGasLimit: relayGasResult.totalGasLimit,
518
+ };
519
+ }
520
+ function toRelayQuoteGasTransaction(singleParams, fromOverride) {
521
+ return {
522
+ chainId: (0, controller_utils_1.toHex)(singleParams.chainId),
523
+ data: singleParams.data,
524
+ from: fromOverride ?? singleParams.from,
525
+ gas: fromOverride ? undefined : singleParams.gas,
526
+ to: singleParams.to,
527
+ value: singleParams.value ?? '0',
528
+ };
499
529
  }
500
530
  /**
501
531
  * Combine the original transaction's gas with relay gas for post-quote flows.
@@ -508,6 +538,7 @@ async function calculateSourceNetworkGasLimit(params, messenger, fromOverride) {
508
538
  * @param relayGas.totalGasEstimate - Estimated gas total.
509
539
  * @param relayGas.totalGasLimit - Maximum gas total.
510
540
  * @param relayGas.gasLimits - Per-transaction gas limits.
541
+ * @param relayGas.is7702 - Whether the relay gas came from a combined 7702 batch estimate.
511
542
  * @param transaction - Original transaction metadata.
512
543
  * @returns Combined gas estimates including the original transaction.
513
544
  */
@@ -519,11 +550,9 @@ function combinePostQuoteGas(relayGas, transaction) {
519
550
  return relayGas;
520
551
  }
521
552
  let { gasLimits } = relayGas;
522
- // TODO: Test EIP-7702 support on the chain as well before assuming single gas limit.
523
- const isEIP7702 = gasLimits.length === 1;
524
- if (isEIP7702) {
525
- // Single gas limit (either one relay param or 7702 combined) —
526
- // add the original tx gas so the batch uses a single 7702 limit.
553
+ if (relayGas.is7702) {
554
+ // Combined 7702 gas limit — add the original tx gas so the batch
555
+ // keeps using a single 7702 limit.
527
556
  gasLimits = [gasLimits[0] + originalTxGas];
528
557
  }
529
558
  else {
@@ -535,11 +564,16 @@ function combinePostQuoteGas(relayGas, transaction) {
535
564
  const totalGasLimit = relayGas.totalGasLimit + originalTxGas;
536
565
  log('Combined original tx gas with relay gas', {
537
566
  originalTxGas,
538
- isEIP7702,
567
+ is7702: relayGas.is7702,
539
568
  gasLimits,
540
569
  totalGasLimit,
541
570
  });
542
- return { totalGasEstimate, totalGasLimit, gasLimits };
571
+ return {
572
+ totalGasEstimate,
573
+ totalGasLimit,
574
+ gasLimits,
575
+ is7702: relayGas.is7702,
576
+ };
543
577
  }
544
578
  /**
545
579
  * Calculate the provider fee for a Relay quote.
@@ -573,126 +607,6 @@ function getTransferRecipient(data) {
573
607
  .decodeFunctionData('transfer', data)
574
608
  .to.toLowerCase();
575
609
  }
576
- async function calculateSourceNetworkGasLimitSingle(params, messenger, fromOverride) {
577
- const paramGasLimit = params.gas
578
- ? new bignumber_js_1.BigNumber(params.gas).toNumber()
579
- : undefined;
580
- if (paramGasLimit && !fromOverride) {
581
- log('Using single gas limit from params', { paramGasLimit });
582
- return {
583
- totalGasEstimate: paramGasLimit,
584
- totalGasLimit: paramGasLimit,
585
- gasLimits: [paramGasLimit],
586
- };
587
- }
588
- try {
589
- const { chainId: chainIdNumber, data, from: paramsFrom, to, value: valueString, } = params;
590
- const from = fromOverride ?? paramsFrom;
591
- const chainId = (0, controller_utils_1.toHex)(chainIdNumber);
592
- const value = (0, controller_utils_1.toHex)(valueString ?? '0');
593
- const gasBuffer = (0, feature_flags_1.getGasBuffer)(messenger, chainId);
594
- const networkClientId = messenger.call('NetworkController:findNetworkClientIdByChainId', chainId);
595
- const { gas: gasHex, simulationFails } = await messenger.call('TransactionController:estimateGas', { from, data, to, value }, networkClientId);
596
- const estimatedGas = new bignumber_js_1.BigNumber(gasHex).toNumber();
597
- const bufferedGas = Math.ceil(estimatedGas * gasBuffer);
598
- if (!simulationFails) {
599
- log('Estimated gas limit for single transaction', {
600
- chainId,
601
- estimatedGas,
602
- bufferedGas,
603
- gasBuffer,
604
- });
605
- return {
606
- totalGasEstimate: bufferedGas,
607
- totalGasLimit: bufferedGas,
608
- gasLimits: [bufferedGas],
609
- };
610
- }
611
- }
612
- catch (error) {
613
- log('Failed to estimate gas limit for single transaction', error);
614
- }
615
- const fallbackGas = (0, feature_flags_1.getFeatureFlags)(messenger).relayFallbackGas;
616
- log('Using fallback gas for single transaction', { fallbackGas });
617
- return {
618
- totalGasEstimate: fallbackGas.estimate,
619
- totalGasLimit: fallbackGas.max,
620
- gasLimits: [fallbackGas.max],
621
- };
622
- }
623
- /**
624
- * Calculate the gas limits for a batch of transactions.
625
- *
626
- * @param params - Array of transaction parameters.
627
- * @param messenger - Controller messenger.
628
- * @param fromOverride - Optional address to use as `from` in gas estimation.
629
- * @returns - Gas limits.
630
- */
631
- async function calculateSourceNetworkGasLimitBatch(params, messenger, fromOverride) {
632
- try {
633
- const { chainId: chainIdNumber, from: paramsFrom } = params[0];
634
- const from = fromOverride ?? paramsFrom;
635
- const chainId = (0, controller_utils_1.toHex)(chainIdNumber);
636
- const gasBuffer = (0, feature_flags_1.getGasBuffer)(messenger, chainId);
637
- const transactions = params.map((singleParams) => ({
638
- ...singleParams,
639
- gas: !fromOverride && singleParams.gas
640
- ? (0, controller_utils_1.toHex)(singleParams.gas)
641
- : undefined,
642
- maxFeePerGas: undefined,
643
- maxPriorityFeePerGas: undefined,
644
- value: (0, controller_utils_1.toHex)(singleParams.value ?? '0'),
645
- }));
646
- const paramGasLimits = params.map((singleParams) => singleParams.gas ? new bignumber_js_1.BigNumber(singleParams.gas).toNumber() : undefined);
647
- const { totalGasLimit, gasLimits } = await messenger.call('TransactionController:estimateGasBatch', {
648
- chainId,
649
- from,
650
- transactions,
651
- });
652
- const bufferedGasLimits = gasLimits.map((limit, index) => {
653
- const useBuffer = gasLimits.length === 1 || paramGasLimits[index] !== gasLimits[index];
654
- const buffer = useBuffer ? gasBuffer : 1;
655
- return Math.ceil(limit * buffer);
656
- });
657
- const bufferedTotalGasLimit = bufferedGasLimits.reduce((acc, limit) => acc + limit, 0);
658
- log('Estimated gas limit for batch', {
659
- chainId,
660
- totalGasLimit,
661
- gasLimits,
662
- bufferedTotalGasLimit,
663
- bufferedGasLimits,
664
- gasBuffer,
665
- });
666
- return {
667
- totalGasEstimate: bufferedTotalGasLimit,
668
- totalGasLimit: bufferedTotalGasLimit,
669
- gasLimits: bufferedGasLimits,
670
- };
671
- }
672
- catch (error) {
673
- log('Failed to estimate gas limit for batch', error);
674
- }
675
- const fallbackGas = (0, feature_flags_1.getFeatureFlags)(messenger).relayFallbackGas;
676
- const totalGasEstimate = params.reduce((acc, singleParams) => {
677
- const gas = singleParams.gas ?? fallbackGas.estimate;
678
- return acc + new bignumber_js_1.BigNumber(gas).toNumber();
679
- }, 0);
680
- const gasLimits = params.map((singleParams) => {
681
- const gas = singleParams.gas ?? fallbackGas.max;
682
- return new bignumber_js_1.BigNumber(gas).toNumber();
683
- });
684
- const totalGasLimit = gasLimits.reduce((acc, singleGasLimit) => acc + singleGasLimit, 0);
685
- log('Using fallback gas for batch', {
686
- totalGasEstimate,
687
- totalGasLimit,
688
- gasLimits,
689
- });
690
- return {
691
- totalGasEstimate,
692
- totalGasLimit,
693
- gasLimits,
694
- };
695
- }
696
610
  function getSubsidizedFeeAmountUsd(quote) {
697
611
  const subsidizedFee = quote.fees?.subsidized;
698
612
  const amountUsd = new bignumber_js_1.BigNumber(subsidizedFee?.amountUsd ?? '0');