@metamask/transaction-pay-controller 18.0.0 → 18.1.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 (112) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/TransactionPayController-method-action-types.cjs +1 -1
  3. package/dist/TransactionPayController-method-action-types.cjs.map +1 -1
  4. package/dist/TransactionPayController-method-action-types.d.cts +1 -1
  5. package/dist/TransactionPayController-method-action-types.d.mts +1 -1
  6. package/dist/TransactionPayController-method-action-types.mjs +1 -1
  7. package/dist/TransactionPayController-method-action-types.mjs.map +1 -1
  8. package/dist/constants.cjs +1 -0
  9. package/dist/constants.cjs.map +1 -1
  10. package/dist/constants.d.cts +1 -0
  11. package/dist/constants.d.cts.map +1 -1
  12. package/dist/constants.d.mts +1 -0
  13. package/dist/constants.d.mts.map +1 -1
  14. package/dist/constants.mjs +1 -0
  15. package/dist/constants.mjs.map +1 -1
  16. package/dist/strategy/across/across-actions.cjs +185 -0
  17. package/dist/strategy/across/across-actions.cjs.map +1 -0
  18. package/dist/strategy/across/across-actions.d.cts +21 -0
  19. package/dist/strategy/across/across-actions.d.cts.map +1 -0
  20. package/dist/strategy/across/across-actions.d.mts +21 -0
  21. package/dist/strategy/across/across-actions.d.mts.map +1 -0
  22. package/dist/strategy/across/across-actions.mjs +178 -0
  23. package/dist/strategy/across/across-actions.mjs.map +1 -0
  24. package/dist/strategy/across/across-quotes.cjs +2 -72
  25. package/dist/strategy/across/across-quotes.cjs.map +1 -1
  26. package/dist/strategy/across/across-quotes.d.cts.map +1 -1
  27. package/dist/strategy/across/across-quotes.d.mts.map +1 -1
  28. package/dist/strategy/across/across-quotes.mjs +1 -71
  29. package/dist/strategy/across/across-quotes.mjs.map +1 -1
  30. package/dist/strategy/fiat/FiatStrategy.cjs +15 -0
  31. package/dist/strategy/fiat/FiatStrategy.cjs.map +1 -0
  32. package/dist/strategy/fiat/FiatStrategy.d.cts +7 -0
  33. package/dist/strategy/fiat/FiatStrategy.d.cts.map +1 -0
  34. package/dist/strategy/fiat/FiatStrategy.d.mts +7 -0
  35. package/dist/strategy/fiat/FiatStrategy.d.mts.map +1 -0
  36. package/dist/strategy/fiat/FiatStrategy.mjs +11 -0
  37. package/dist/strategy/fiat/FiatStrategy.mjs.map +1 -0
  38. package/dist/strategy/fiat/constants.cjs +24 -0
  39. package/dist/strategy/fiat/constants.cjs.map +1 -0
  40. package/dist/strategy/fiat/constants.d.cts +10 -0
  41. package/dist/strategy/fiat/constants.d.cts.map +1 -0
  42. package/dist/strategy/fiat/constants.d.mts +10 -0
  43. package/dist/strategy/fiat/constants.d.mts.map +1 -0
  44. package/dist/strategy/fiat/constants.mjs +21 -0
  45. package/dist/strategy/fiat/constants.mjs.map +1 -0
  46. package/dist/strategy/fiat/fiat-quotes.cjs +214 -0
  47. package/dist/strategy/fiat/fiat-quotes.cjs.map +1 -0
  48. package/dist/strategy/fiat/fiat-quotes.d.cts +17 -0
  49. package/dist/strategy/fiat/fiat-quotes.d.cts.map +1 -0
  50. package/dist/strategy/fiat/fiat-quotes.d.mts +17 -0
  51. package/dist/strategy/fiat/fiat-quotes.d.mts.map +1 -0
  52. package/dist/strategy/fiat/fiat-quotes.mjs +210 -0
  53. package/dist/strategy/fiat/fiat-quotes.mjs.map +1 -0
  54. package/dist/strategy/fiat/fiat-submit.cjs +14 -0
  55. package/dist/strategy/fiat/fiat-submit.cjs.map +1 -0
  56. package/dist/strategy/fiat/fiat-submit.d.cts +10 -0
  57. package/dist/strategy/fiat/fiat-submit.d.cts.map +1 -0
  58. package/dist/strategy/fiat/fiat-submit.d.mts +10 -0
  59. package/dist/strategy/fiat/fiat-submit.d.mts.map +1 -0
  60. package/dist/strategy/fiat/fiat-submit.mjs +10 -0
  61. package/dist/strategy/fiat/fiat-submit.mjs.map +1 -0
  62. package/dist/strategy/fiat/types.cjs +3 -0
  63. package/dist/strategy/fiat/types.cjs.map +1 -0
  64. package/dist/strategy/fiat/types.d.cts +8 -0
  65. package/dist/strategy/fiat/types.d.cts.map +1 -0
  66. package/dist/strategy/fiat/types.d.mts +8 -0
  67. package/dist/strategy/fiat/types.d.mts.map +1 -0
  68. package/dist/strategy/fiat/types.mjs +2 -0
  69. package/dist/strategy/fiat/types.mjs.map +1 -0
  70. package/dist/strategy/fiat/utils.cjs +23 -0
  71. package/dist/strategy/fiat/utils.cjs.map +1 -0
  72. package/dist/strategy/fiat/utils.d.cts +6 -0
  73. package/dist/strategy/fiat/utils.d.cts.map +1 -0
  74. package/dist/strategy/fiat/utils.d.mts +6 -0
  75. package/dist/strategy/fiat/utils.d.mts.map +1 -0
  76. package/dist/strategy/fiat/utils.mjs +18 -0
  77. package/dist/strategy/fiat/utils.mjs.map +1 -0
  78. package/dist/tests/messenger-mock.d.cts +1 -1
  79. package/dist/tests/messenger-mock.d.mts +1 -1
  80. package/dist/types.cjs.map +1 -1
  81. package/dist/types.d.cts +6 -1
  82. package/dist/types.d.cts.map +1 -1
  83. package/dist/types.d.mts +6 -1
  84. package/dist/types.d.mts.map +1 -1
  85. package/dist/types.mjs.map +1 -1
  86. package/dist/utils/quotes.cjs +4 -2
  87. package/dist/utils/quotes.cjs.map +1 -1
  88. package/dist/utils/quotes.d.cts.map +1 -1
  89. package/dist/utils/quotes.d.mts.map +1 -1
  90. package/dist/utils/quotes.mjs +4 -2
  91. package/dist/utils/quotes.mjs.map +1 -1
  92. package/dist/utils/strategy.cjs +3 -0
  93. package/dist/utils/strategy.cjs.map +1 -1
  94. package/dist/utils/strategy.d.cts.map +1 -1
  95. package/dist/utils/strategy.d.mts.map +1 -1
  96. package/dist/utils/strategy.mjs +3 -0
  97. package/dist/utils/strategy.mjs.map +1 -1
  98. package/dist/utils/token.cjs +26 -1
  99. package/dist/utils/token.cjs.map +1 -1
  100. package/dist/utils/token.d.cts +10 -0
  101. package/dist/utils/token.d.cts.map +1 -1
  102. package/dist/utils/token.d.mts +10 -0
  103. package/dist/utils/token.d.mts.map +1 -1
  104. package/dist/utils/token.mjs +24 -0
  105. package/dist/utils/token.mjs.map +1 -1
  106. package/dist/utils/totals.cjs +2 -0
  107. package/dist/utils/totals.cjs.map +1 -1
  108. package/dist/utils/totals.d.cts.map +1 -1
  109. package/dist/utils/totals.d.mts.map +1 -1
  110. package/dist/utils/totals.mjs +2 -0
  111. package/dist/utils/totals.mjs.map +1 -1
  112. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [18.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add `FiatStrategy` to retrieve quotes via `RampsController` ([#8121](https://github.com/MetaMask/core/pull/8121))
15
+
16
+ ### Changed
17
+
18
+ - Bump `@metamask/bridge-controller` from `^69.1.1` to `^69.2.1` ([#8265](https://github.com/MetaMask/core/pull/8265), [#8288](https://github.com/MetaMask/core/pull/8288))
19
+ - Bump `@metamask/bridge-status-controller` from `^70.0.0` to `^70.0.1` ([#8288](https://github.com/MetaMask/core/pull/8288))
20
+ - Bump `@metamask/transaction-controller` from `^63.0.0` to `^63.1.0` ([#8272](https://github.com/MetaMask/core/pull/8272))
21
+ - Bump `@metamask/assets-controller` from `^3.0.0` to `^3.1.0` ([#8276](https://github.com/MetaMask/core/pull/8276))
22
+
10
23
  ## [18.0.0]
11
24
 
12
25
  ### Changed
@@ -15,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
28
  - Bump `@metamask/assets-controller` from `^2.4.0` to `^3.0.0` ([#8232](https://github.com/MetaMask/core/pull/8232))
16
29
  - Bump `@metamask/assets-controllers` from `^101.0.0` to `^101.0.1` ([#8232](https://github.com/MetaMask/core/pull/8232))
17
30
  - Remove duplication in gas estimation for Relay and Across strategies ([#8145](https://github.com/MetaMask/core/pull/8145))
31
+ - Improve Across quote handling to decode supported destination calls into post-swap actions while sending transfer-only destinations directly to the destination recipient ([#8208](https://github.com/MetaMask/core/pull/8208))
18
32
 
19
33
  ## [17.1.0]
20
34
 
@@ -550,7 +564,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
550
564
 
551
565
  - Initial release ([#6820](https://github.com/MetaMask/core/pull/6820))
552
566
 
553
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@18.0.0...HEAD
567
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@18.1.0...HEAD
568
+ [18.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@18.0.0...@metamask/transaction-pay-controller@18.1.0
554
569
  [18.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@17.1.0...@metamask/transaction-pay-controller@18.0.0
555
570
  [17.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@17.0.0...@metamask/transaction-pay-controller@17.1.0
556
571
  [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.5.0...@metamask/transaction-pay-controller@17.0.0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * This file is auto generated.
4
4
  * Do not edit manually.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionPayController-method-action-types.cjs","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { TransactionPayController } from './TransactionPayController';\n\n/**\n * Sets the transaction configuration.\n *\n * The callback receives the current configuration properties and can mutate\n * them in place. Updated values are written back to the transaction data.\n *\n * @param transactionId - The ID of the transaction to configure.\n * @param callback - A callback that receives a mutable {@link TransactionConfig} object.\n */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `TransactionPayController:setTransactionConfig`;\n handler: TransactionPayController['setTransactionConfig'];\n};\n\n/**\n * Updates the payment token for a transaction.\n *\n * Resolves token metadata and balances, then stores the new payment token\n * in the transaction data. This triggers recalculation of source amounts\n * and quote retrieval.\n *\n * @param request - The payment token update request containing the\n * transaction ID, token address, and chain ID.\n */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `TransactionPayController:updatePaymentToken`;\n handler: TransactionPayController['updatePaymentToken'];\n};\n\n/**\n * Updates the fiat payment state for a transaction.\n *\n * The request callback receives the current fiat payment state and can\n * mutate it to update properties such as the selected payment method or\n * fiat amount.\n *\n * @param request - The fiat payment update request containing the\n * transaction ID and a callback to mutate fiat payment state.\n */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `TransactionPayController:updateFiatPayment`;\n handler: TransactionPayController['updateFiatPayment'];\n};\n\n/**\n * Gets the delegation transaction for a given transaction.\n *\n * Converts the provided transaction into a redeem delegation by delegating\n * to the configured callback. Returns the delegation transaction data\n * including the encoded call data, target address, value, and an optional\n * authorization list.\n *\n * @param args - The arguments forwarded to the {@link GetDelegationTransactionCallback},\n * containing the transaction metadata.\n * @returns A promise resolving to the delegation transaction data.\n */\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `TransactionPayController:getDelegationTransaction`;\n handler: TransactionPayController['getDelegationTransaction'];\n};\n\n/**\n * Gets the preferred strategy for a transaction.\n *\n * Returns the first strategy from the ordered list of strategies applicable\n * to the given transaction. Falls back to the default strategy order derived\n * from feature flags when no custom strategy callback is configured.\n *\n * @param transaction - The transaction metadata to determine the strategy for.\n * @returns The preferred {@link TransactionPayStrategy} for the transaction.\n */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `TransactionPayController:getStrategy`;\n handler: TransactionPayController['getStrategy'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStrategyAction;\n"]}
1
+ {"version":3,"file":"TransactionPayController-method-action-types.cjs","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { TransactionPayController } from './TransactionPayController';\n\n/**\n * Sets the transaction configuration.\n *\n * The callback receives the current configuration properties and can mutate\n * them in place. Updated values are written back to the transaction data.\n *\n * @param transactionId - The ID of the transaction to configure.\n * @param callback - A callback that receives a mutable {@link TransactionConfig} object.\n */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `TransactionPayController:setTransactionConfig`;\n handler: TransactionPayController['setTransactionConfig'];\n};\n\n/**\n * Updates the payment token for a transaction.\n *\n * Resolves token metadata and balances, then stores the new payment token\n * in the transaction data. This triggers recalculation of source amounts\n * and quote retrieval.\n *\n * @param request - The payment token update request containing the\n * transaction ID, token address, and chain ID.\n */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `TransactionPayController:updatePaymentToken`;\n handler: TransactionPayController['updatePaymentToken'];\n};\n\n/**\n * Updates the fiat payment state for a transaction.\n *\n * The request callback receives the current fiat payment state and can\n * mutate it to update properties such as the selected payment method or\n * fiat amount.\n *\n * @param request - The fiat payment update request containing the\n * transaction ID and a callback to mutate fiat payment state.\n */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `TransactionPayController:updateFiatPayment`;\n handler: TransactionPayController['updateFiatPayment'];\n};\n\n/**\n * Gets the delegation transaction for a given transaction.\n *\n * Converts the provided transaction into a redeem delegation by delegating\n * to the configured callback. Returns the delegation transaction data\n * including the encoded call data, target address, value, and an optional\n * authorization list.\n *\n * @param args - The arguments forwarded to the {@link GetDelegationTransactionCallback},\n * containing the transaction metadata.\n * @returns A promise resolving to the delegation transaction data.\n */\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `TransactionPayController:getDelegationTransaction`;\n handler: TransactionPayController['getDelegationTransaction'];\n};\n\n/**\n * Gets the preferred strategy for a transaction.\n *\n * Returns the first strategy from the ordered list of strategies applicable\n * to the given transaction. Falls back to the default strategy order derived\n * from feature flags when no custom strategy callback is configured.\n *\n * @param transaction - The transaction metadata to determine the strategy for.\n * @returns The preferred {@link TransactionPayStrategy} for the transaction.\n */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `TransactionPayController:getStrategy`;\n handler: TransactionPayController['getStrategy'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStrategyAction;\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This file is auto generated by `scripts/generate-method-action-types.ts`.
2
+ * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
5
  import type { TransactionPayController } from "./TransactionPayController.cjs";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This file is auto generated by `scripts/generate-method-action-types.ts`.
2
+ * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
5
  import type { TransactionPayController } from "./TransactionPayController.mjs";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * This file is auto generated by `scripts/generate-method-action-types.ts`.
2
+ * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionPayController-method-action-types.mjs","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { TransactionPayController } from './TransactionPayController';\n\n/**\n * Sets the transaction configuration.\n *\n * The callback receives the current configuration properties and can mutate\n * them in place. Updated values are written back to the transaction data.\n *\n * @param transactionId - The ID of the transaction to configure.\n * @param callback - A callback that receives a mutable {@link TransactionConfig} object.\n */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `TransactionPayController:setTransactionConfig`;\n handler: TransactionPayController['setTransactionConfig'];\n};\n\n/**\n * Updates the payment token for a transaction.\n *\n * Resolves token metadata and balances, then stores the new payment token\n * in the transaction data. This triggers recalculation of source amounts\n * and quote retrieval.\n *\n * @param request - The payment token update request containing the\n * transaction ID, token address, and chain ID.\n */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `TransactionPayController:updatePaymentToken`;\n handler: TransactionPayController['updatePaymentToken'];\n};\n\n/**\n * Updates the fiat payment state for a transaction.\n *\n * The request callback receives the current fiat payment state and can\n * mutate it to update properties such as the selected payment method or\n * fiat amount.\n *\n * @param request - The fiat payment update request containing the\n * transaction ID and a callback to mutate fiat payment state.\n */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `TransactionPayController:updateFiatPayment`;\n handler: TransactionPayController['updateFiatPayment'];\n};\n\n/**\n * Gets the delegation transaction for a given transaction.\n *\n * Converts the provided transaction into a redeem delegation by delegating\n * to the configured callback. Returns the delegation transaction data\n * including the encoded call data, target address, value, and an optional\n * authorization list.\n *\n * @param args - The arguments forwarded to the {@link GetDelegationTransactionCallback},\n * containing the transaction metadata.\n * @returns A promise resolving to the delegation transaction data.\n */\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `TransactionPayController:getDelegationTransaction`;\n handler: TransactionPayController['getDelegationTransaction'];\n};\n\n/**\n * Gets the preferred strategy for a transaction.\n *\n * Returns the first strategy from the ordered list of strategies applicable\n * to the given transaction. Falls back to the default strategy order derived\n * from feature flags when no custom strategy callback is configured.\n *\n * @param transaction - The transaction metadata to determine the strategy for.\n * @returns The preferred {@link TransactionPayStrategy} for the transaction.\n */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `TransactionPayController:getStrategy`;\n handler: TransactionPayController['getStrategy'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStrategyAction;\n"]}
1
+ {"version":3,"file":"TransactionPayController-method-action-types.mjs","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { TransactionPayController } from './TransactionPayController';\n\n/**\n * Sets the transaction configuration.\n *\n * The callback receives the current configuration properties and can mutate\n * them in place. Updated values are written back to the transaction data.\n *\n * @param transactionId - The ID of the transaction to configure.\n * @param callback - A callback that receives a mutable {@link TransactionConfig} object.\n */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `TransactionPayController:setTransactionConfig`;\n handler: TransactionPayController['setTransactionConfig'];\n};\n\n/**\n * Updates the payment token for a transaction.\n *\n * Resolves token metadata and balances, then stores the new payment token\n * in the transaction data. This triggers recalculation of source amounts\n * and quote retrieval.\n *\n * @param request - The payment token update request containing the\n * transaction ID, token address, and chain ID.\n */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `TransactionPayController:updatePaymentToken`;\n handler: TransactionPayController['updatePaymentToken'];\n};\n\n/**\n * Updates the fiat payment state for a transaction.\n *\n * The request callback receives the current fiat payment state and can\n * mutate it to update properties such as the selected payment method or\n * fiat amount.\n *\n * @param request - The fiat payment update request containing the\n * transaction ID and a callback to mutate fiat payment state.\n */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `TransactionPayController:updateFiatPayment`;\n handler: TransactionPayController['updateFiatPayment'];\n};\n\n/**\n * Gets the delegation transaction for a given transaction.\n *\n * Converts the provided transaction into a redeem delegation by delegating\n * to the configured callback. Returns the delegation transaction data\n * including the encoded call data, target address, value, and an optional\n * authorization list.\n *\n * @param args - The arguments forwarded to the {@link GetDelegationTransactionCallback},\n * containing the transaction metadata.\n * @returns A promise resolving to the delegation transaction data.\n */\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `TransactionPayController:getDelegationTransaction`;\n handler: TransactionPayController['getDelegationTransaction'];\n};\n\n/**\n * Gets the preferred strategy for a transaction.\n *\n * Returns the first strategy from the ordered list of strategies applicable\n * to the given transaction. Falls back to the default strategy order derived\n * from feature flags when no custom strategy callback is configured.\n *\n * @param transaction - The transaction metadata to determine the strategy for.\n * @returns The preferred {@link TransactionPayStrategy} for the transaction.\n */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `TransactionPayController:getStrategy`;\n handler: TransactionPayController['getStrategy'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStrategyAction;\n"]}
@@ -29,6 +29,7 @@ var TransactionPayStrategy;
29
29
  (function (TransactionPayStrategy) {
30
30
  TransactionPayStrategy["Across"] = "across";
31
31
  TransactionPayStrategy["Bridge"] = "bridge";
32
+ TransactionPayStrategy["Fiat"] = "fiat";
32
33
  TransactionPayStrategy["Relay"] = "relay";
33
34
  TransactionPayStrategy["Test"] = "test";
34
35
  })(TransactionPayStrategy || (exports.TransactionPayStrategy = TransactionPayStrategy = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAC7C,QAAA,iBAAiB,GAAG,QAAe,CAAC;AACpC,QAAA,gBAAgB,GAAG,MAAa,CAAC;AACjC,QAAA,kBAAkB,GAAG,OAAc,CAAC;AAEpC,QAAA,oBAAoB,GAC/B,4CAAmD,CAAC;AAEzC,QAAA,qBAAqB,GAChC,4CAAmD,CAAC;AAEzC,QAAA,qBAAqB,GAChC,4CAAmD,CAAC;AAEzC,QAAA,WAAW,GAAuB;IAC7C,UAAU;IACV,KAAK,EAAE;QACL,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,yBAAiB,CAAC,EAAE,CAAC,6BAAqB,CAAC,WAAW,EAAS,CAAC;IACjE,QAAQ;IACR,QAAQ,EAAE;QACR,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,wBAAgB,CAAC,EAAE,CAAC,6BAAqB,CAAC,WAAW,EAAS,CAAC;IAChE,CAAC,0BAAkB,CAAC,EAAE,CAAC,oCAAoC,CAAC,EAAE,OAAO;CACtE,CAAC;AAEF,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,yCAAe,CAAA;IACf,uCAAa,CAAA;AACf,CAAC,EALW,sBAAsB,sCAAtB,sBAAsB,QAKjC;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAExE;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC;AAJD,4DAIC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\n\nexport const NATIVE_TOKEN_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Hex;\n\nexport const ARBITRUM_USDC_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' as Hex;\n\nexport const POLYGON_USDCE_ADDRESS =\n '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as Hex;\n\nexport const STABLECOINS: Record<Hex, Hex[]> = {\n // Mainnet\n '0x1': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC\n '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT\n ],\n [CHAIN_ID_ARBITRUM]: [ARBITRUM_USDC_ADDRESS.toLowerCase() as Hex],\n // Linea\n '0xe708': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0x176211869ca2b568f2a7d4ee941e073a821ee1ff', // USDC\n '0xa219439258ca9da29e9cc4ce5596924745e12b93', // USDT\n ],\n [CHAIN_ID_POLYGON]: [POLYGON_USDCE_ADDRESS.toLowerCase() as Hex],\n [CHAIN_ID_HYPERCORE]: ['0x00000000000000000000000000000000'], // USDC\n};\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Bridge = 'bridge',\n Relay = 'relay',\n Test = 'test',\n}\n\nconst VALID_STRATEGIES = new Set(Object.values(TransactionPayStrategy));\n\n/**\n * Checks if a value is a valid transaction pay strategy.\n *\n * @param strategy - Candidate strategy value.\n * @returns True if the value is a valid strategy.\n */\nexport function isTransactionPayStrategy(\n strategy: unknown,\n): strategy is TransactionPayStrategy {\n return VALID_STRATEGIES.has(strategy as TransactionPayStrategy);\n}\n"]}
1
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAC7C,QAAA,iBAAiB,GAAG,QAAe,CAAC;AACpC,QAAA,gBAAgB,GAAG,MAAa,CAAC;AACjC,QAAA,kBAAkB,GAAG,OAAc,CAAC;AAEpC,QAAA,oBAAoB,GAC/B,4CAAmD,CAAC;AAEzC,QAAA,qBAAqB,GAChC,4CAAmD,CAAC;AAEzC,QAAA,qBAAqB,GAChC,4CAAmD,CAAC;AAEzC,QAAA,WAAW,GAAuB;IAC7C,UAAU;IACV,KAAK,EAAE;QACL,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,yBAAiB,CAAC,EAAE,CAAC,6BAAqB,CAAC,WAAW,EAAS,CAAC;IACjE,QAAQ;IACR,QAAQ,EAAE;QACR,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,wBAAgB,CAAC,EAAE,CAAC,6BAAqB,CAAC,WAAW,EAAS,CAAC;IAChE,CAAC,0BAAkB,CAAC,EAAE,CAAC,oCAAoC,CAAC,EAAE,OAAO;CACtE,CAAC;AAEF,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,uCAAa,CAAA;AACf,CAAC,EANW,sBAAsB,sCAAtB,sBAAsB,QAMjC;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAExE;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC;AAJD,4DAIC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\n\nexport const NATIVE_TOKEN_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Hex;\n\nexport const ARBITRUM_USDC_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' as Hex;\n\nexport const POLYGON_USDCE_ADDRESS =\n '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as Hex;\n\nexport const STABLECOINS: Record<Hex, Hex[]> = {\n // Mainnet\n '0x1': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC\n '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT\n ],\n [CHAIN_ID_ARBITRUM]: [ARBITRUM_USDC_ADDRESS.toLowerCase() as Hex],\n // Linea\n '0xe708': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0x176211869ca2b568f2a7d4ee941e073a821ee1ff', // USDC\n '0xa219439258ca9da29e9cc4ce5596924745e12b93', // USDT\n ],\n [CHAIN_ID_POLYGON]: [POLYGON_USDCE_ADDRESS.toLowerCase() as Hex],\n [CHAIN_ID_HYPERCORE]: ['0x00000000000000000000000000000000'], // USDC\n};\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Bridge = 'bridge',\n Fiat = 'fiat',\n Relay = 'relay',\n Test = 'test',\n}\n\nconst VALID_STRATEGIES = new Set(Object.values(TransactionPayStrategy));\n\n/**\n * Checks if a value is a valid transaction pay strategy.\n *\n * @param strategy - Candidate strategy value.\n * @returns True if the value is a valid strategy.\n */\nexport function isTransactionPayStrategy(\n strategy: unknown,\n): strategy is TransactionPayStrategy {\n return VALID_STRATEGIES.has(strategy as TransactionPayStrategy);\n}\n"]}
@@ -10,6 +10,7 @@ export declare const STABLECOINS: Record<Hex, Hex[]>;
10
10
  export declare enum TransactionPayStrategy {
11
11
  Across = "across",
12
12
  Bridge = "bridge",
13
+ Fiat = "fiat",
13
14
  Relay = "relay",
14
15
  Test = "test"
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,eAAO,MAA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@ -10,6 +10,7 @@ export declare const STABLECOINS: Record<Hex, Hex[]>;
10
10
  export declare enum TransactionPayStrategy {
11
11
  Across = "across",
12
12
  Bridge = "bridge",
13
+ Fiat = "fiat",
13
14
  Relay = "relay",
14
15
  Test = "test"
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,iBAAiB,eAAkB,CAAC;AACjD,eAAO,MAAM,gBAAgB,eAAgB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,eAAiB,CAAC;AAEjD,eAAO,MAAM,oBAAoB,eACoB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,eACmB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,eACmB,CAAC;AAEtD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAgB1C,CAAC;AAEF,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAID;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAEpC"}
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAC1D,eAAO,MAAM,iBAAiB,eAAkB,CAAC;AACjD,eAAO,MAAM,gBAAgB,eAAgB,CAAC;AAC9C,eAAO,MAAM,kBAAkB,eAAiB,CAAC;AAEjD,eAAO,MAAM,oBAAoB,eACoB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,eACmB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,eACmB,CAAC;AAEtD,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAgB1C,CAAC;AAEF,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAID;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAEpC"}
@@ -26,6 +26,7 @@ export var TransactionPayStrategy;
26
26
  (function (TransactionPayStrategy) {
27
27
  TransactionPayStrategy["Across"] = "across";
28
28
  TransactionPayStrategy["Bridge"] = "bridge";
29
+ TransactionPayStrategy["Fiat"] = "fiat";
29
30
  TransactionPayStrategy["Relay"] = "relay";
30
31
  TransactionPayStrategy["Test"] = "test";
31
32
  })(TransactionPayStrategy || (TransactionPayStrategy = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAe,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAc,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,UAAU;IACV,KAAK,EAAE;QACL,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,iBAAiB,CAAC,EAAE,CAAC,qBAAqB,CAAC,WAAW,EAAS,CAAC;IACjE,QAAQ;IACR,QAAQ,EAAE;QACR,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,gBAAgB,CAAC,EAAE,CAAC,qBAAqB,CAAC,WAAW,EAAS,CAAC;IAChE,CAAC,kBAAkB,CAAC,EAAE,CAAC,oCAAoC,CAAC,EAAE,OAAO;CACtE,CAAC;AAEF,MAAM,CAAN,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,yCAAe,CAAA;IACf,uCAAa,CAAA;AACf,CAAC,EALW,sBAAsB,KAAtB,sBAAsB,QAKjC;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\n\nexport const NATIVE_TOKEN_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Hex;\n\nexport const ARBITRUM_USDC_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' as Hex;\n\nexport const POLYGON_USDCE_ADDRESS =\n '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as Hex;\n\nexport const STABLECOINS: Record<Hex, Hex[]> = {\n // Mainnet\n '0x1': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC\n '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT\n ],\n [CHAIN_ID_ARBITRUM]: [ARBITRUM_USDC_ADDRESS.toLowerCase() as Hex],\n // Linea\n '0xe708': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0x176211869ca2b568f2a7d4ee941e073a821ee1ff', // USDC\n '0xa219439258ca9da29e9cc4ce5596924745e12b93', // USDT\n ],\n [CHAIN_ID_POLYGON]: [POLYGON_USDCE_ADDRESS.toLowerCase() as Hex],\n [CHAIN_ID_HYPERCORE]: ['0x00000000000000000000000000000000'], // USDC\n};\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Bridge = 'bridge',\n Relay = 'relay',\n Test = 'test',\n}\n\nconst VALID_STRATEGIES = new Set(Object.values(TransactionPayStrategy));\n\n/**\n * Checks if a value is a valid transaction pay strategy.\n *\n * @param strategy - Candidate strategy value.\n * @returns True if the value is a valid strategy.\n */\nexport function isTransactionPayStrategy(\n strategy: unknown,\n): strategy is TransactionPayStrategy {\n return VALID_STRATEGIES.has(strategy as TransactionPayStrategy);\n}\n"]}
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAe,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAc,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,UAAU;IACV,KAAK,EAAE;QACL,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,iBAAiB,CAAC,EAAE,CAAC,qBAAqB,CAAC,WAAW,EAAS,CAAC;IACjE,QAAQ;IACR,QAAQ,EAAE;QACR,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,gBAAgB,CAAC,EAAE,CAAC,qBAAqB,CAAC,WAAW,EAAS,CAAC;IAChE,CAAC,kBAAkB,CAAC,EAAE,CAAC,oCAAoC,CAAC,EAAE,OAAO;CACtE,CAAC;AAEF,MAAM,CAAN,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,uCAAa,CAAA;AACf,CAAC,EANW,sBAAsB,KAAtB,sBAAsB,QAMjC;AAED,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\n\nexport const NATIVE_TOKEN_ADDRESS =\n '0x0000000000000000000000000000000000000000' as Hex;\n\nexport const ARBITRUM_USDC_ADDRESS =\n '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' as Hex;\n\nexport const POLYGON_USDCE_ADDRESS =\n '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as Hex;\n\nexport const STABLECOINS: Record<Hex, Hex[]> = {\n // Mainnet\n '0x1': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC\n '0xdac17f958d2ee523a2206206994597c13d831ec7', // USDT\n ],\n [CHAIN_ID_ARBITRUM]: [ARBITRUM_USDC_ADDRESS.toLowerCase() as Hex],\n // Linea\n '0xe708': [\n '0xaca92e438df0b2401ff60da7e4337b687a2435da', // MUSD\n '0x176211869ca2b568f2a7d4ee941e073a821ee1ff', // USDC\n '0xa219439258ca9da29e9cc4ce5596924745e12b93', // USDT\n ],\n [CHAIN_ID_POLYGON]: [POLYGON_USDCE_ADDRESS.toLowerCase() as Hex],\n [CHAIN_ID_HYPERCORE]: ['0x00000000000000000000000000000000'], // USDC\n};\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Bridge = 'bridge',\n Fiat = 'fiat',\n Relay = 'relay',\n Test = 'test',\n}\n\nconst VALID_STRATEGIES = new Set(Object.values(TransactionPayStrategy));\n\n/**\n * Checks if a value is a valid transaction pay strategy.\n *\n * @param strategy - Candidate strategy value.\n * @returns True if the value is a valid strategy.\n */\nexport function isTransactionPayStrategy(\n strategy: unknown,\n): strategy is TransactionPayStrategy {\n return VALID_STRATEGIES.has(strategy as TransactionPayStrategy);\n}\n"]}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExtractableOutputTokenTransferCall = exports.getAcrossDestination = exports.getTransferRecipient = exports.buildAcrossActionFromCall = exports.UNSUPPORTED_DESTINATION_ERROR = exports.SAFE_EXEC_TRANSACTION_SIGNATURE = exports.CREATE_PROXY_SIGNATURE = exports.TOKEN_TRANSFER_SIGNATURE = void 0;
4
+ const abi_1 = require("@ethersproject/abi");
5
+ exports.TOKEN_TRANSFER_SIGNATURE = 'function transfer(address to, uint256 value)';
6
+ exports.CREATE_PROXY_SIGNATURE = 'function createProxy(address paymentToken, uint256 payment, address payable paymentReceiver, (uint8 v, bytes32 r, bytes32 s) createSig)';
7
+ exports.SAFE_EXEC_TRANSACTION_SIGNATURE = 'function execTransaction(address to, uint256 value, bytes data, uint8 operation, uint256 safeTxGas, uint256 baseGas, uint256 gasPrice, address gasToken, address refundReceiver, bytes signatures)';
8
+ exports.UNSUPPORTED_DESTINATION_ERROR = 'Across only supports direct token transfers and a limited set of post-swap destination actions at the moment';
9
+ const ACROSS_ACTION_SIGNATURES = [
10
+ exports.CREATE_PROXY_SIGNATURE,
11
+ exports.SAFE_EXEC_TRANSACTION_SIGNATURE,
12
+ ];
13
+ function buildAcrossActionFromCall(call, request) {
14
+ if (isTransferCall(call.data)) {
15
+ return buildAcrossTransferAction(call, request);
16
+ }
17
+ const parsedCall = parseAcrossActionCall(call.data);
18
+ return {
19
+ args: Array.from(parsedCall.transaction.args).map((arg) => ({
20
+ populateDynamically: false,
21
+ value: serializeAcrossActionValue(arg),
22
+ })),
23
+ functionSignature: parsedCall.functionSignature,
24
+ isNativeTransfer: false,
25
+ target: getRequiredTarget(call),
26
+ value: '0',
27
+ };
28
+ }
29
+ exports.buildAcrossActionFromCall = buildAcrossActionFromCall;
30
+ function getTransferRecipient(data) {
31
+ const parsedCall = tryParseTransferCall(data);
32
+ if (!parsedCall) {
33
+ throw new Error(getUnsupportedDestinationErrorMessage(data));
34
+ }
35
+ return normalizeHexString(String(parsedCall.args[0]));
36
+ }
37
+ exports.getTransferRecipient = getTransferRecipient;
38
+ function getAcrossDestination(transaction, request) {
39
+ const { from } = request;
40
+ const destinationCalls = getDestinationCalls(transaction);
41
+ const swapRecipientTransferCallIndex = destinationCalls.findIndex((call) => isExtractableOutputTokenTransferCall(call, request));
42
+ const callsForActions = [...destinationCalls];
43
+ let recipient = from;
44
+ if (swapRecipientTransferCallIndex !== -1) {
45
+ const [swapRecipientTransferCall] = callsForActions.splice(swapRecipientTransferCallIndex, 1);
46
+ recipient = getTransferRecipient(swapRecipientTransferCall.data);
47
+ }
48
+ return {
49
+ actions: callsForActions.map((call) => buildAcrossActionFromCall(call, request)),
50
+ recipient,
51
+ };
52
+ }
53
+ exports.getAcrossDestination = getAcrossDestination;
54
+ function isExtractableOutputTokenTransferCall(call, request) {
55
+ return (isTransferCall(call.data) &&
56
+ (call.target === undefined ||
57
+ normalizeHexString(call.target) ===
58
+ normalizeHexString(request.targetTokenAddress)));
59
+ }
60
+ exports.isExtractableOutputTokenTransferCall = isExtractableOutputTokenTransferCall;
61
+ function getRequiredTarget(call) {
62
+ if (!call.target) {
63
+ throw new Error(exports.UNSUPPORTED_DESTINATION_ERROR);
64
+ }
65
+ return call.target;
66
+ }
67
+ function normalizeHexString(value) {
68
+ /* istanbul ignore next: current supported Across action signatures only emit hex strings here. */
69
+ if (!value.startsWith('0x')) {
70
+ return value;
71
+ }
72
+ return value.toLowerCase();
73
+ }
74
+ function parseAcrossActionCall(data) {
75
+ const parsedCall = tryParseAcrossActionCall(data);
76
+ if (!parsedCall) {
77
+ throw new Error(getUnsupportedDestinationErrorMessage(data));
78
+ }
79
+ return parsedCall;
80
+ }
81
+ function serializeAcrossActionValue(value) {
82
+ if (Array.isArray(value)) {
83
+ return value.map((entry) => serializeAcrossActionScalar(entry));
84
+ }
85
+ return serializeAcrossActionScalar(value);
86
+ }
87
+ function buildAcrossTransferAction(call, request) {
88
+ return {
89
+ args: [
90
+ {
91
+ populateDynamically: false,
92
+ value: getTransferRecipient(call.data),
93
+ },
94
+ {
95
+ balanceSourceToken: request.targetTokenAddress,
96
+ populateDynamically: true,
97
+ value: '0',
98
+ },
99
+ ],
100
+ functionSignature: exports.TOKEN_TRANSFER_SIGNATURE,
101
+ isNativeTransfer: false,
102
+ target: call.target ?? request.targetTokenAddress,
103
+ value: '0',
104
+ };
105
+ }
106
+ function getDestinationCalls(transaction) {
107
+ const nestedCalls = (transaction.nestedTransactions ?? []).flatMap((nestedTx) => nestedTx.data !== undefined && nestedTx.data !== '0x'
108
+ ? [{ data: nestedTx.data, target: nestedTx.to }]
109
+ : []);
110
+ if (nestedCalls.length > 0) {
111
+ return nestedCalls;
112
+ }
113
+ const data = transaction.txParams?.data;
114
+ if (data === undefined || data === '0x') {
115
+ return [];
116
+ }
117
+ return [
118
+ {
119
+ data,
120
+ target: transaction.txParams?.to,
121
+ },
122
+ ];
123
+ }
124
+ function getUnsupportedDestinationErrorMessage(data) {
125
+ const selector = getDestinationSelector(data);
126
+ return selector
127
+ ? `${exports.UNSUPPORTED_DESTINATION_ERROR}. Destination selector: ${selector}`
128
+ : exports.UNSUPPORTED_DESTINATION_ERROR;
129
+ }
130
+ function getDestinationSelector(data) {
131
+ if (!data || data.length < 10) {
132
+ return undefined;
133
+ }
134
+ return data.slice(0, 10).toLowerCase();
135
+ }
136
+ function serializeAcrossActionScalar(value) {
137
+ if (typeof value === 'string') {
138
+ return normalizeHexString(value);
139
+ }
140
+ if (typeof value === 'number' ||
141
+ typeof value === 'bigint' ||
142
+ typeof value === 'boolean') {
143
+ return String(value);
144
+ }
145
+ if (isBigNumberLike(value)) {
146
+ return value.toString();
147
+ }
148
+ /* istanbul ignore next: supported Across action ABIs only decode scalars and tuples of scalars. */
149
+ throw new Error(exports.UNSUPPORTED_DESTINATION_ERROR);
150
+ }
151
+ function isBigNumberLike(value) {
152
+ return (typeof value === 'object' &&
153
+ value !== null &&
154
+ '_isBigNumber' in value &&
155
+ value._isBigNumber === true &&
156
+ 'toString' in value &&
157
+ typeof value.toString === 'function');
158
+ }
159
+ function isTransferCall(data) {
160
+ return tryParseTransferCall(data) !== undefined;
161
+ }
162
+ function tryParseAcrossActionCall(data) {
163
+ for (const functionSignature of ACROSS_ACTION_SIGNATURES) {
164
+ try {
165
+ const actionInterface = new abi_1.Interface([functionSignature]);
166
+ return {
167
+ functionSignature,
168
+ transaction: actionInterface.parseTransaction({ data }),
169
+ };
170
+ }
171
+ catch {
172
+ // Intentionally empty.
173
+ }
174
+ }
175
+ return undefined;
176
+ }
177
+ function tryParseTransferCall(data) {
178
+ try {
179
+ return new abi_1.Interface([exports.TOKEN_TRANSFER_SIGNATURE]).parseTransaction({ data });
180
+ }
181
+ catch {
182
+ return undefined;
183
+ }
184
+ }
185
+ //# sourceMappingURL=across-actions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"across-actions.cjs","sourceRoot":"","sources":["../../../src/strategy/across/across-actions.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAQlC,QAAA,wBAAwB,GACnC,8CAA8C,CAAC;AACpC,QAAA,sBAAsB,GACjC,yIAAyI,CAAC;AAC/H,QAAA,+BAA+B,GAC1C,oMAAoM,CAAC;AAE1L,QAAA,6BAA6B,GACxC,8GAA8G,CAAC;AAsBjH,MAAM,wBAAwB,GAAG;IAC/B,8BAAsB;IACtB,uCAA+B;CAChC,CAAC;AAEF,SAAgB,yBAAyB,CACvC,IAA2B,EAC3B,OAAqB;IAErB,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,yBAAyB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC1D,mBAAmB,EAAE,KAAK;YAC1B,KAAK,EAAE,0BAA0B,CAAC,GAAG,CAAC;SACvC,CAAC,CAAC;QACH,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;QAC/C,gBAAgB,EAAE,KAAK;QACvB,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC;QAC/B,KAAK,EAAE,GAAG;KACX,CAAC;AACJ,CAAC;AApBD,8DAoBC;AAED,SAAgB,oBAAoB,CAAC,IAAS;IAC5C,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,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AAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAS;IACrC,IAAI,CAAC;QACH,OAAO,IAAI,eAAS,CAAC,CAAC,gCAAwB,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport type { TransactionDescription } from '@ethersproject/abi';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nimport type { AcrossAction, AcrossActionArg } from './types';\nimport type { QuoteRequest } from '../../types';\n\nexport const TOKEN_TRANSFER_SIGNATURE =\n 'function transfer(address to, uint256 value)';\nexport const CREATE_PROXY_SIGNATURE =\n 'function createProxy(address paymentToken, uint256 payment, address payable paymentReceiver, (uint8 v, bytes32 r, bytes32 s) createSig)';\nexport const SAFE_EXEC_TRANSACTION_SIGNATURE =\n 'function execTransaction(address to, uint256 value, bytes data, uint8 operation, uint256 safeTxGas, uint256 baseGas, uint256 gasPrice, address gasToken, address refundReceiver, bytes signatures)';\n\nexport const UNSUPPORTED_DESTINATION_ERROR =\n 'Across only supports direct token transfers and a limited set of post-swap destination actions at the moment';\n\nexport type AcrossDestinationCall = {\n data: Hex;\n target?: Hex;\n};\n\nexport type AcrossDestination = {\n actions: AcrossAction[];\n recipient: Hex;\n};\n\ntype ParsedAcrossActionCall = {\n functionSignature: string;\n transaction: TransactionDescription;\n};\n\ntype BigNumberLike = {\n _isBigNumber: true;\n toString: () => string;\n};\n\nconst ACROSS_ACTION_SIGNATURES = [\n CREATE_PROXY_SIGNATURE,\n SAFE_EXEC_TRANSACTION_SIGNATURE,\n];\n\nexport function buildAcrossActionFromCall(\n call: AcrossDestinationCall,\n request: QuoteRequest,\n): AcrossAction {\n if (isTransferCall(call.data)) {\n return buildAcrossTransferAction(call, request);\n }\n\n const parsedCall = parseAcrossActionCall(call.data);\n\n return {\n args: Array.from(parsedCall.transaction.args).map((arg) => ({\n populateDynamically: false,\n value: serializeAcrossActionValue(arg),\n })),\n functionSignature: parsedCall.functionSignature,\n isNativeTransfer: false,\n target: getRequiredTarget(call),\n value: '0',\n };\n}\n\nexport function getTransferRecipient(data: Hex): Hex {\n const parsedCall = tryParseTransferCall(data);\n\n if (!parsedCall) {\n throw new Error(getUnsupportedDestinationErrorMessage(data));\n }\n\n return normalizeHexString(String(parsedCall.args[0])) as Hex;\n}\n\nexport function getAcrossDestination(\n transaction: TransactionMeta,\n request: QuoteRequest,\n): AcrossDestination {\n const { from } = request;\n const destinationCalls = getDestinationCalls(transaction);\n const swapRecipientTransferCallIndex = destinationCalls.findIndex((call) =>\n isExtractableOutputTokenTransferCall(call, request),\n );\n const callsForActions = [...destinationCalls];\n let recipient = from;\n\n if (swapRecipientTransferCallIndex !== -1) {\n const [swapRecipientTransferCall] = callsForActions.splice(\n swapRecipientTransferCallIndex,\n 1,\n );\n\n recipient = getTransferRecipient(swapRecipientTransferCall.data);\n }\n\n return {\n actions: callsForActions.map((call) =>\n buildAcrossActionFromCall(call, request),\n ),\n recipient,\n };\n}\n\nexport function isExtractableOutputTokenTransferCall(\n call: AcrossDestinationCall,\n request: QuoteRequest,\n): boolean {\n return (\n isTransferCall(call.data) &&\n (call.target === undefined ||\n normalizeHexString(call.target) ===\n normalizeHexString(request.targetTokenAddress))\n );\n}\n\nfunction getRequiredTarget(call: AcrossDestinationCall): Hex {\n if (!call.target) {\n throw new Error(UNSUPPORTED_DESTINATION_ERROR);\n }\n\n return call.target;\n}\n\nfunction normalizeHexString(value: string): string {\n /* istanbul ignore next: current supported Across action signatures only emit hex strings here. */\n if (!value.startsWith('0x')) {\n return value;\n }\n\n return value.toLowerCase();\n}\n\nfunction parseAcrossActionCall(data: Hex): ParsedAcrossActionCall {\n const parsedCall = tryParseAcrossActionCall(data);\n\n if (!parsedCall) {\n throw new Error(getUnsupportedDestinationErrorMessage(data));\n }\n\n return parsedCall;\n}\n\nfunction serializeAcrossActionValue(value: unknown): AcrossActionArg['value'] {\n if (Array.isArray(value)) {\n return value.map((entry) =>\n serializeAcrossActionScalar(entry),\n ) as AcrossActionArg['value'];\n }\n\n return serializeAcrossActionScalar(value);\n}\n\nfunction buildAcrossTransferAction(\n call: AcrossDestinationCall,\n request: QuoteRequest,\n): AcrossAction {\n return {\n args: [\n {\n populateDynamically: false,\n value: getTransferRecipient(call.data),\n },\n {\n balanceSourceToken: request.targetTokenAddress,\n populateDynamically: true,\n value: '0',\n },\n ],\n functionSignature: TOKEN_TRANSFER_SIGNATURE,\n isNativeTransfer: false,\n target: call.target ?? request.targetTokenAddress,\n value: '0',\n };\n}\n\nfunction getDestinationCalls(\n transaction: TransactionMeta,\n): AcrossDestinationCall[] {\n const nestedCalls = (\n transaction.nestedTransactions ?? []\n ).flatMap<AcrossDestinationCall>((nestedTx: { data?: Hex; to?: Hex }) =>\n nestedTx.data !== undefined && nestedTx.data !== '0x'\n ? [{ data: nestedTx.data, target: nestedTx.to }]\n : [],\n );\n\n if (nestedCalls.length > 0) {\n return nestedCalls;\n }\n\n const data = transaction.txParams?.data as Hex | undefined;\n\n if (data === undefined || data === '0x') {\n return [];\n }\n\n return [\n {\n data,\n target: transaction.txParams?.to as Hex | undefined,\n },\n ];\n}\n\nfunction getUnsupportedDestinationErrorMessage(data?: Hex): string {\n const selector = getDestinationSelector(data);\n\n return selector\n ? `${UNSUPPORTED_DESTINATION_ERROR}. Destination selector: ${selector}`\n : UNSUPPORTED_DESTINATION_ERROR;\n}\n\nfunction getDestinationSelector(data?: Hex): Hex | undefined {\n if (!data || data.length < 10) {\n return undefined;\n }\n\n return data.slice(0, 10).toLowerCase() as Hex;\n}\n\nfunction serializeAcrossActionScalar(value: unknown): string {\n if (typeof value === 'string') {\n return normalizeHexString(value);\n }\n\n if (\n typeof value === 'number' ||\n typeof value === 'bigint' ||\n typeof value === 'boolean'\n ) {\n return String(value);\n }\n\n if (isBigNumberLike(value)) {\n return value.toString();\n }\n\n /* istanbul ignore next: supported Across action ABIs only decode scalars and tuples of scalars. */\n throw new Error(UNSUPPORTED_DESTINATION_ERROR);\n}\n\nfunction isBigNumberLike(value: unknown): value is BigNumberLike {\n return (\n typeof value === 'object' &&\n value !== null &&\n '_isBigNumber' in value &&\n value._isBigNumber === true &&\n 'toString' in value &&\n typeof value.toString === 'function'\n );\n}\n\nfunction isTransferCall(data: Hex): boolean {\n return tryParseTransferCall(data) !== undefined;\n}\n\nfunction tryParseAcrossActionCall(\n data: Hex,\n): ParsedAcrossActionCall | undefined {\n for (const functionSignature of ACROSS_ACTION_SIGNATURES) {\n try {\n const actionInterface = new Interface([functionSignature]);\n\n return {\n functionSignature,\n transaction: actionInterface.parseTransaction({ data }),\n };\n } catch {\n // Intentionally empty.\n }\n }\n\n return undefined;\n}\n\nfunction tryParseTransferCall(data: Hex): TransactionDescription | undefined {\n try {\n return new Interface([TOKEN_TRANSFER_SIGNATURE]).parseTransaction({ data });\n } catch {\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { TransactionMeta } from "@metamask/transaction-controller";
2
+ import type { Hex } from "@metamask/utils";
3
+ import type { AcrossAction } from "./types.cjs";
4
+ import type { QuoteRequest } from "../../types.cjs";
5
+ export declare const TOKEN_TRANSFER_SIGNATURE = "function transfer(address to, uint256 value)";
6
+ export declare const CREATE_PROXY_SIGNATURE = "function createProxy(address paymentToken, uint256 payment, address payable paymentReceiver, (uint8 v, bytes32 r, bytes32 s) createSig)";
7
+ export declare const SAFE_EXEC_TRANSACTION_SIGNATURE = "function execTransaction(address to, uint256 value, bytes data, uint8 operation, uint256 safeTxGas, uint256 baseGas, uint256 gasPrice, address gasToken, address refundReceiver, bytes signatures)";
8
+ export declare const UNSUPPORTED_DESTINATION_ERROR = "Across only supports direct token transfers and a limited set of post-swap destination actions at the moment";
9
+ export type AcrossDestinationCall = {
10
+ data: Hex;
11
+ target?: Hex;
12
+ };
13
+ export type AcrossDestination = {
14
+ actions: AcrossAction[];
15
+ recipient: Hex;
16
+ };
17
+ export declare function buildAcrossActionFromCall(call: AcrossDestinationCall, request: QuoteRequest): AcrossAction;
18
+ export declare function getTransferRecipient(data: Hex): Hex;
19
+ export declare function getAcrossDestination(transaction: TransactionMeta, request: QuoteRequest): AcrossDestination;
20
+ export declare function isExtractableOutputTokenTransferCall(call: AcrossDestinationCall, request: QuoteRequest): boolean;
21
+ //# sourceMappingURL=across-actions.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"across-actions.d.cts","sourceRoot":"","sources":["../../../src/strategy/across/across-actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAmB,oBAAgB;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAoB;AAEhD,eAAO,MAAM,wBAAwB,iDACW,CAAC;AACjD,eAAO,MAAM,sBAAsB,4IACwG,CAAC;AAC5I,eAAO,MAAM,+BAA+B,uMAC0J,CAAC;AAEvM,eAAO,MAAM,6BAA6B,iHACsE,CAAC;AAEjH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC;CAChB,CAAC;AAiBF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,YAAY,GACpB,YAAY,CAiBd;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAQnD;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,YAAY,GACpB,iBAAiB,CAwBnB;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,YAAY,GACpB,OAAO,CAOT"}
@@ -0,0 +1,21 @@
1
+ import type { TransactionMeta } from "@metamask/transaction-controller";
2
+ import type { Hex } from "@metamask/utils";
3
+ import type { AcrossAction } from "./types.mjs";
4
+ import type { QuoteRequest } from "../../types.mjs";
5
+ export declare const TOKEN_TRANSFER_SIGNATURE = "function transfer(address to, uint256 value)";
6
+ export declare const CREATE_PROXY_SIGNATURE = "function createProxy(address paymentToken, uint256 payment, address payable paymentReceiver, (uint8 v, bytes32 r, bytes32 s) createSig)";
7
+ export declare const SAFE_EXEC_TRANSACTION_SIGNATURE = "function execTransaction(address to, uint256 value, bytes data, uint8 operation, uint256 safeTxGas, uint256 baseGas, uint256 gasPrice, address gasToken, address refundReceiver, bytes signatures)";
8
+ export declare const UNSUPPORTED_DESTINATION_ERROR = "Across only supports direct token transfers and a limited set of post-swap destination actions at the moment";
9
+ export type AcrossDestinationCall = {
10
+ data: Hex;
11
+ target?: Hex;
12
+ };
13
+ export type AcrossDestination = {
14
+ actions: AcrossAction[];
15
+ recipient: Hex;
16
+ };
17
+ export declare function buildAcrossActionFromCall(call: AcrossDestinationCall, request: QuoteRequest): AcrossAction;
18
+ export declare function getTransferRecipient(data: Hex): Hex;
19
+ export declare function getAcrossDestination(transaction: TransactionMeta, request: QuoteRequest): AcrossDestination;
20
+ export declare function isExtractableOutputTokenTransferCall(call: AcrossDestinationCall, request: QuoteRequest): boolean;
21
+ //# sourceMappingURL=across-actions.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"across-actions.d.mts","sourceRoot":"","sources":["../../../src/strategy/across/across-actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAmB,oBAAgB;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAoB;AAEhD,eAAO,MAAM,wBAAwB,iDACW,CAAC;AACjD,eAAO,MAAM,sBAAsB,4IACwG,CAAC;AAC5I,eAAO,MAAM,+BAA+B,uMAC0J,CAAC;AAEvM,eAAO,MAAM,6BAA6B,iHACsE,CAAC;AAEjH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC;CAChB,CAAC;AAiBF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,YAAY,GACpB,YAAY,CAiBd;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAQnD;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,YAAY,GACpB,iBAAiB,CAwBnB;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,YAAY,GACpB,OAAO,CAOT"}