@metamask-previews/transaction-pay-controller 30.3.3-preview-fbb37663c → 30.3.3-preview-eb5c879
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/TransactionPayController-method-action-types.d.ts +14 -1
- package/dist/TransactionPayController-method-action-types.d.ts.map +1 -1
- package/dist/TransactionPayController-method-action-types.js.map +1 -1
- package/dist/TransactionPayController.d.ts +12 -1
- package/dist/TransactionPayController.d.ts.map +1 -1
- package/dist/TransactionPayController.js +16 -1
- package/dist/TransactionPayController.js.map +1 -1
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +13 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/strategy/server/server-api.d.ts.map +1 -1
- package/dist/strategy/server/server-api.js +32 -5
- package/dist/strategy/server/server-api.js.map +1 -1
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add optional `clientId` constructor option to `TransactionPayController`, sent as the `X-Client-Id` header on all intents API requests so the server can distinguish Mobile from Extension traffic ([#11259](https://github.com/MetaMask/core/pull/11259))
|
|
13
|
+
- Add `TransactionPayClientId` enum with `Extension` and `Mobile` members.
|
|
14
|
+
- Add `TransactionPayController:getClientId` messenger action and the corresponding `TransactionPayControllerGetClientIdAction` type.
|
|
15
|
+
- The header is omitted when `clientId` is not provided, so existing consumers are unaffected.
|
|
16
|
+
|
|
10
17
|
### Changed
|
|
11
18
|
|
|
12
19
|
- Bump `@metamask/assets-controller` from `^20.1.0` to `^20.2.0` ([#11255](https://github.com/MetaMask/core/pull/11255))
|
|
@@ -44,6 +44,19 @@ export type TransactionPayControllerUpdateFiatPaymentAction = {
|
|
|
44
44
|
type: `TransactionPayController:updateFiatPayment`;
|
|
45
45
|
handler: TransactionPayController['updateFiatPayment'];
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Returns the configured client identifier.
|
|
49
|
+
*
|
|
50
|
+
* Used to set the `X-Client-Id` header on intents API requests so the
|
|
51
|
+
* server can distinguish Mobile from Extension traffic. This is
|
|
52
|
+
* intentionally not stored in controller state.
|
|
53
|
+
*
|
|
54
|
+
* @returns The client identifier, if configured.
|
|
55
|
+
*/
|
|
56
|
+
export type TransactionPayControllerGetClientIdAction = {
|
|
57
|
+
type: `TransactionPayController:getClientId`;
|
|
58
|
+
handler: TransactionPayController['getClientId'];
|
|
59
|
+
};
|
|
47
60
|
/**
|
|
48
61
|
* Gets the delegation transaction for a given transaction.
|
|
49
62
|
*
|
|
@@ -128,5 +141,5 @@ export type TransactionPayControllerPolymarketSubmitDepositWalletBatchAction = {
|
|
|
128
141
|
/**
|
|
129
142
|
* Union of all TransactionPayController action types.
|
|
130
143
|
*/
|
|
131
|
-
export type TransactionPayControllerMethodActions = TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdatePaymentTokenAction | TransactionPayControllerUpdateFiatPaymentAction | TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetAmountDataAction | TransactionPayControllerGetFiatOptionsAction | TransactionPayControllerGetPaymentOverrideDataAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerPolymarketGetDepositWalletAddressAction | TransactionPayControllerPolymarketSubmitDepositWalletBatchAction;
|
|
144
|
+
export type TransactionPayControllerMethodActions = TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdatePaymentTokenAction | TransactionPayControllerUpdateFiatPaymentAction | TransactionPayControllerGetClientIdAction | TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetAmountDataAction | TransactionPayControllerGetFiatOptionsAction | TransactionPayControllerGetPaymentOverrideDataAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerPolymarketGetDepositWalletAddressAction | TransactionPayControllerPolymarketSubmitDepositWalletBatchAction;
|
|
132
145
|
//# sourceMappingURL=TransactionPayController-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController-method-action-types.d.ts","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,wBAAwB,CAAC,oBAAoB,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,wBAAwB,CAAC,mBAAmB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sDAAsD,GAAG;IACnE,IAAI,EAAE,mDAAmD,CAAC;IAC1D,OAAO,EAAE,wBAAwB,CAAC,0BAA0B,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,wBAAwB,CAAC,wBAAwB,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+DAA+D,GAAG;IAC5E,IAAI,EAAE,4DAA4D,CAAC;IACnE,OAAO,EAAE,wBAAwB,CAAC,mCAAmC,CAAC,CAAC;CACxE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gEAAgE,GAAG;IAC7E,IAAI,EAAE,6DAA6D,CAAC;IACpE,OAAO,EAAE,wBAAwB,CAAC,oCAAoC,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,kDAAkD,GAClD,gDAAgD,GAChD,+CAA+C,GAC/C,sDAAsD,GACtD,2CAA2C,GAC3C,4CAA4C,GAC5C,oDAAoD,GACpD,yCAAyC,GACzC,+DAA+D,GAC/D,gEAAgE,CAAC"}
|
|
1
|
+
{"version":3,"file":"TransactionPayController-method-action-types.d.ts","sourceRoot":"","sources":["../src/TransactionPayController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;CAC3D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAA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IACnE,OAAO,EAAE,wBAAwB,CAAC,mCAAmC,CAAC,CAAC;CACxE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gEAAgE,GAAG;IAC7E,IAAI,EAAE,6DAA6D,CAAC;IACpE,OAAO,EAAE,wBAAwB,CAAC,oCAAoC,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,kDAAkD,GAClD,gDAAgD,GAChD,+CAA+C,GAC/C,yCAAyC,GACzC,sDAAsD,GACtD,2CAA2C,GAC3C,4CAA4C,GAC5C,oDAAoD,GACpD,yCAAyC,GACzC,+DAA+D,GAC/D,gEAAgE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController-method-action-types.js","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.js';\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 * Returns additional transactions for the paymentOverride flow.\n *\n * Delegates to the client-supplied {@link GetPaymentOverrideDataCallback}.\n * Called during quote execution when `paymentOverride` is defined on the transaction.\n * Returns an empty array when no callback is configured.\n *\n * @param args - The arguments forwarded to the {@link GetPaymentOverrideDataCallback}.\n * @returns A promise resolving to the additional transactions array.\n */\nexport type TransactionPayControllerGetAmountDataAction = {\n type: `TransactionPayController:getAmountData`;\n handler: TransactionPayController['getAmountData'];\n};\n\n/**\n * Returns optional fiat execution configuration.\n *\n * This is intentionally not stored in controller state.\n *\n * @returns Fiat execution options, if configured.\n */\nexport type TransactionPayControllerGetFiatOptionsAction = {\n type: `TransactionPayController:getFiatOptions`;\n handler: TransactionPayController['getFiatOptions'];\n};\n\nexport type TransactionPayControllerGetPaymentOverrideDataAction = {\n type: `TransactionPayController:getPaymentOverrideData`;\n handler: TransactionPayController['getPaymentOverrideData'];\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 * Derives the Polymarket deposit-wallet address for an EOA via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.getDepositWalletAddress}.\n * @returns A promise resolving to the deposit-wallet address.\n */\nexport type TransactionPayControllerPolymarketGetDepositWalletAddressAction = {\n type: `TransactionPayController:polymarketGetDepositWalletAddress`;\n handler: TransactionPayController['polymarketGetDepositWalletAddress'];\n};\n\n/**\n * Signs and broadcasts a Polymarket deposit-wallet batch via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.submitDepositWalletBatch}.\n * @returns A promise resolving to the relayer-issued source hash.\n */\nexport type TransactionPayControllerPolymarketSubmitDepositWalletBatchAction = {\n type: `TransactionPayController:polymarketSubmitDepositWalletBatch`;\n handler: TransactionPayController['polymarketSubmitDepositWalletBatch'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetAmountDataAction\n | TransactionPayControllerGetFiatOptionsAction\n | TransactionPayControllerGetPaymentOverrideDataAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerPolymarketGetDepositWalletAddressAction\n | TransactionPayControllerPolymarketSubmitDepositWalletBatchAction;\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionPayController-method-action-types.js","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.js';\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 * Returns the configured client identifier.\n *\n * Used to set the `X-Client-Id` header on intents API requests so the\n * server can distinguish Mobile from Extension traffic. This is\n * intentionally not stored in controller state.\n *\n * @returns The client identifier, if configured.\n */\nexport type TransactionPayControllerGetClientIdAction = {\n type: `TransactionPayController:getClientId`;\n handler: TransactionPayController['getClientId'];\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 * Returns additional transactions for the paymentOverride flow.\n *\n * Delegates to the client-supplied {@link GetPaymentOverrideDataCallback}.\n * Called during quote execution when `paymentOverride` is defined on the transaction.\n * Returns an empty array when no callback is configured.\n *\n * @param args - The arguments forwarded to the {@link GetPaymentOverrideDataCallback}.\n * @returns A promise resolving to the additional transactions array.\n */\nexport type TransactionPayControllerGetAmountDataAction = {\n type: `TransactionPayController:getAmountData`;\n handler: TransactionPayController['getAmountData'];\n};\n\n/**\n * Returns optional fiat execution configuration.\n *\n * This is intentionally not stored in controller state.\n *\n * @returns Fiat execution options, if configured.\n */\nexport type TransactionPayControllerGetFiatOptionsAction = {\n type: `TransactionPayController:getFiatOptions`;\n handler: TransactionPayController['getFiatOptions'];\n};\n\nexport type TransactionPayControllerGetPaymentOverrideDataAction = {\n type: `TransactionPayController:getPaymentOverrideData`;\n handler: TransactionPayController['getPaymentOverrideData'];\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 * Derives the Polymarket deposit-wallet address for an EOA via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.getDepositWalletAddress}.\n * @returns A promise resolving to the deposit-wallet address.\n */\nexport type TransactionPayControllerPolymarketGetDepositWalletAddressAction = {\n type: `TransactionPayController:polymarketGetDepositWalletAddress`;\n handler: TransactionPayController['polymarketGetDepositWalletAddress'];\n};\n\n/**\n * Signs and broadcasts a Polymarket deposit-wallet batch via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.submitDepositWalletBatch}.\n * @returns A promise resolving to the relayer-issued source hash.\n */\nexport type TransactionPayControllerPolymarketSubmitDepositWalletBatchAction = {\n type: `TransactionPayController:polymarketSubmitDepositWalletBatch`;\n handler: TransactionPayController['polymarketSubmitDepositWalletBatch'];\n};\n\n/**\n * Union of all TransactionPayController action types.\n */\nexport type TransactionPayControllerMethodActions =\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerGetClientIdAction\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetAmountDataAction\n | TransactionPayControllerGetFiatOptionsAction\n | TransactionPayControllerGetPaymentOverrideDataAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerPolymarketGetDepositWalletAddressAction\n | TransactionPayControllerPolymarketSubmitDepositWalletBatchAction;\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BaseController } from '@metamask/base-controller';
|
|
2
2
|
import type { TransactionMeta } from '@metamask/transaction-controller';
|
|
3
3
|
import { CONTROLLER_NAME, TransactionPayStrategy } from './constants.js';
|
|
4
|
+
import type { TransactionPayClientId } from './constants.js';
|
|
4
5
|
import type { GetAmountDataCallback, GetDelegationTransactionCallback, GetPaymentOverrideDataCallback, PolymarketCallbacks, TransactionConfigCallback, TransactionPayControllerMessenger, TransactionPayFiatOptions, TransactionPayControllerOptions, TransactionPayControllerState, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest } from './types.js';
|
|
5
6
|
export declare class TransactionPayController extends BaseController<typeof CONTROLLER_NAME, TransactionPayControllerState, TransactionPayControllerMessenger> {
|
|
6
7
|
#private;
|
|
7
|
-
constructor({ fiatOptions, getAmountData, getBalance, getDelegationTransaction, getPaymentOverrideData, getStrategy, getStrategies, messenger, polymarket, state, }: TransactionPayControllerOptions);
|
|
8
|
+
constructor({ clientId, fiatOptions, getAmountData, getBalance, getDelegationTransaction, getPaymentOverrideData, getStrategy, getStrategies, messenger, polymarket, state, }: TransactionPayControllerOptions);
|
|
8
9
|
/**
|
|
9
10
|
* Sets the transaction configuration.
|
|
10
11
|
*
|
|
@@ -37,6 +38,16 @@ export declare class TransactionPayController extends BaseController<typeof CONT
|
|
|
37
38
|
* transaction ID and a callback to mutate fiat payment state.
|
|
38
39
|
*/
|
|
39
40
|
updateFiatPayment(request: UpdateFiatPaymentRequest): void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the configured client identifier.
|
|
43
|
+
*
|
|
44
|
+
* Used to set the `X-Client-Id` header on intents API requests so the
|
|
45
|
+
* server can distinguish Mobile from Extension traffic. This is
|
|
46
|
+
* intentionally not stored in controller state.
|
|
47
|
+
*
|
|
48
|
+
* @returns The client identifier, if configured.
|
|
49
|
+
*/
|
|
50
|
+
getClientId(): TransactionPayClientId | undefined;
|
|
40
51
|
/**
|
|
41
52
|
* Gets the delegation transaction for a given transaction.
|
|
42
53
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.d.ts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EACL,eAAe,EAEf,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"TransactionPayController.d.ts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,EACL,eAAe,EAEf,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EACV,qBAAqB,EAErB,gCAAgC,EAChC,8BAA8B,EAC9B,mBAAmB,EAEnB,yBAAyB,EAEzB,iCAAiC,EACjC,yBAAyB,EACzB,+BAA+B,EAC/B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,YAAY,CA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AE5D;IAED;;;;;;OAMG;IACH,kCAAkC,CAChC,GAAG,IAAI,EAAE,UAAU,CAAC,mBAAmB,CAAC,0BAA0B,CAAC,CAAC,GACnE,UAAU,CAAC,mBAAmB,CAAC,0BAA0B,CAAC,CAAC,CAE7D;CAiJF"}
|
|
@@ -10,6 +10,7 @@ import { updateSourceAmounts } from './utils/source-amounts.js';
|
|
|
10
10
|
import { subscribeAssetChanges, subscribeTransactionChanges, } from './utils/transaction.js';
|
|
11
11
|
const MESSENGER_EXPOSED_METHODS = [
|
|
12
12
|
'getAmountData',
|
|
13
|
+
'getClientId',
|
|
13
14
|
'getDelegationTransaction',
|
|
14
15
|
'getFiatOptions',
|
|
15
16
|
'getPaymentOverrideData',
|
|
@@ -32,6 +33,7 @@ const getDefaultState = () => ({
|
|
|
32
33
|
transactionData: {},
|
|
33
34
|
});
|
|
34
35
|
export class TransactionPayController extends BaseController {
|
|
36
|
+
#clientId;
|
|
35
37
|
#fiatOptions;
|
|
36
38
|
#getAmountData;
|
|
37
39
|
#getBalance;
|
|
@@ -40,13 +42,14 @@ export class TransactionPayController extends BaseController {
|
|
|
40
42
|
#getStrategy;
|
|
41
43
|
#getStrategies;
|
|
42
44
|
#polymarket;
|
|
43
|
-
constructor({ fiatOptions, getAmountData, getBalance, getDelegationTransaction, getPaymentOverrideData, getStrategy, getStrategies, messenger, polymarket, state, }) {
|
|
45
|
+
constructor({ clientId, fiatOptions, getAmountData, getBalance, getDelegationTransaction, getPaymentOverrideData, getStrategy, getStrategies, messenger, polymarket, state, }) {
|
|
44
46
|
super({
|
|
45
47
|
name: CONTROLLER_NAME,
|
|
46
48
|
metadata: stateMetadata,
|
|
47
49
|
messenger,
|
|
48
50
|
state: { ...getDefaultState(), ...state },
|
|
49
51
|
});
|
|
52
|
+
this.#clientId = clientId;
|
|
50
53
|
this.#fiatOptions = fiatOptions;
|
|
51
54
|
this.#getAmountData = getAmountData;
|
|
52
55
|
this.#getBalance = getBalance;
|
|
@@ -128,6 +131,18 @@ export class TransactionPayController extends BaseController {
|
|
|
128
131
|
updateTransactionData: this.#updateTransactionData.bind(this),
|
|
129
132
|
});
|
|
130
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns the configured client identifier.
|
|
136
|
+
*
|
|
137
|
+
* Used to set the `X-Client-Id` header on intents API requests so the
|
|
138
|
+
* server can distinguish Mobile from Extension traffic. This is
|
|
139
|
+
* intentionally not stored in controller state.
|
|
140
|
+
*
|
|
141
|
+
* @returns The client identifier, if configured.
|
|
142
|
+
*/
|
|
143
|
+
getClientId() {
|
|
144
|
+
return this.#clientId;
|
|
145
|
+
}
|
|
131
146
|
/**
|
|
132
147
|
* Gets the delegation transaction for a given transaction.
|
|
133
148
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.js","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,eAAe,EACf,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAiB7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,yBAAyB,GAAG;IAChC,eAAe;IACf,0BAA0B;IAC1B,gBAAgB;IAChB,wBAAwB;IACxB,aAAa;IACb,mCAAmC;IACnC,oCAAoC;IACpC,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M,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,wBAAwB,CAAC,QAAQ,CAAC,CACrC,CAAC;QAEF,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,MAAM,YAAY,GAAG,eAAe,EAAE,YAAY,CAAC;QAEnD,OAAO,gBAAgB,CACrB,IAAI,CAAC,SAAS,EACd,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,EAAE,WAAW,EAAE,uBAAuB,CACtD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { StateMetadata } from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { Draft } from 'immer';\nimport { noop } from 'lodash-es';\n\nimport { updateFiatPayment } from './actions/update-fiat-payment.js';\nimport { updatePaymentToken } from './actions/update-payment-token.js';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants.js';\nimport { QuoteRefresher } from './helpers/QuoteRefresher.js';\nimport type {\n GetAmountDataCallback,\n GetBalanceCallback,\n GetDelegationTransactionCallback,\n GetPaymentOverrideDataCallback,\n PolymarketCallbacks,\n TransactionConfig,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayFiatOptions,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types.js';\nimport { getStrategyOrder } from './utils/feature-flags.js';\nimport { updateQuotes } from './utils/quotes.js';\nimport { updateSourceAmounts } from './utils/source-amounts.js';\nimport {\n subscribeAssetChanges,\n subscribeTransactionChanges,\n} from './utils/transaction.js';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getAmountData',\n 'getDelegationTransaction',\n 'getFiatOptions',\n 'getPaymentOverrideData',\n 'getStrategy',\n 'polymarketGetDepositWalletAddress',\n 'polymarketSubmitDepositWalletBatch',\n 'setTransactionConfig',\n 'updateFiatPayment',\n 'updatePaymentToken',\n] as const;\n\nconst stateMetadata: StateMetadata<TransactionPayControllerState> = {\n transactionData: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = (): TransactionPayControllerState => ({\n transactionData: {},\n});\n\nexport class TransactionPayController extends BaseController<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState,\n TransactionPayControllerMessenger\n> {\n readonly #fiatOptions?: TransactionPayFiatOptions;\n\n readonly #getAmountData?: GetAmountDataCallback;\n\n readonly #getBalance?: GetBalanceCallback;\n\n readonly #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n readonly #polymarket?: PolymarketCallbacks;\n\n constructor({\n fiatOptions,\n getAmountData,\n getBalance,\n getDelegationTransaction,\n getPaymentOverrideData,\n getStrategy,\n getStrategies,\n messenger,\n polymarket,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#fiatOptions = fiatOptions;\n this.#getAmountData = getAmountData;\n this.#getBalance = getBalance;\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getPaymentOverrideData = getPaymentOverrideData;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n this.#polymarket = polymarket;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n subscribeTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.bind(this),\n );\n\n subscribeAssetChanges(\n messenger,\n () => this.state,\n this.#updateTransactionData.bind(this),\n );\n\n // eslint-disable-next-line no-new\n new QuoteRefresher({\n getStrategies: this.#getStrategiesWithFallback.bind(this),\n messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\n }\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 */\n setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config: TransactionConfig = {\n accountOverride: transactionData.accountOverride,\n atomic: transactionData.atomic,\n isHyperliquidSource: transactionData.isHyperliquidSource,\n isMaxAmount: transactionData.isMaxAmount,\n isPolymarketDepositWallet: transactionData.isPolymarketDepositWallet,\n isPostQuote: transactionData.isPostQuote,\n isQuoteRequired: transactionData.isQuoteRequired,\n paymentOverride: transactionData.paymentOverride,\n refundTo: transactionData.refundTo,\n };\n\n const previousAccountOverride = config.accountOverride;\n\n callback(config);\n\n Object.assign(transactionData, config);\n\n if (\n !config.isPostQuote &&\n config.accountOverride !== previousAccountOverride\n ) {\n transactionData.paymentToken = undefined;\n }\n });\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 */\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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 */\n updateFiatPayment(request: UpdateFiatPaymentRequest): void {\n updateFiatPayment(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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 */\n getDelegationTransaction(\n ...args: Parameters<GetDelegationTransactionCallback>\n ): ReturnType<GetDelegationTransactionCallback> {\n return this.#getDelegationTransaction(...args);\n }\n\n /**\n * Returns additional transactions for the paymentOverride flow.\n *\n * Delegates to the client-supplied {@link GetPaymentOverrideDataCallback}.\n * Called during quote execution when `paymentOverride` is defined on the transaction.\n * Returns an empty array when no callback is configured.\n *\n * @param args - The arguments forwarded to the {@link GetPaymentOverrideDataCallback}.\n * @returns A promise resolving to the additional transactions array.\n */\n getAmountData(\n ...args: Parameters<GetAmountDataCallback>\n ): ReturnType<GetAmountDataCallback> {\n return this.#getAmountData?.(...args) ?? Promise.resolve({ updates: [] });\n }\n\n /**\n * Returns optional fiat execution configuration.\n *\n * This is intentionally not stored in controller state.\n *\n * @returns Fiat execution options, if configured.\n */\n getFiatOptions(): TransactionPayFiatOptions | undefined {\n return this.#fiatOptions;\n }\n\n getPaymentOverrideData(\n ...args: Parameters<GetPaymentOverrideDataCallback>\n ): ReturnType<GetPaymentOverrideDataCallback> {\n return (\n this.#getPaymentOverrideData?.(...args) ?? Promise.resolve({ calls: [] })\n );\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 */\n getStrategy(transaction: TransactionMeta): TransactionPayStrategy {\n return this.#getStrategiesWithFallback(transaction)[0];\n }\n\n /**\n * Derives the Polymarket deposit-wallet address for an EOA via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.getDepositWalletAddress}.\n * @returns A promise resolving to the deposit-wallet address.\n */\n polymarketGetDepositWalletAddress(\n ...args: Parameters<PolymarketCallbacks['getDepositWalletAddress']>\n ): ReturnType<PolymarketCallbacks['getDepositWalletAddress']> {\n return this.#requirePolymarket().getDepositWalletAddress(...args);\n }\n\n /**\n * Signs and broadcasts a Polymarket deposit-wallet batch via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.submitDepositWalletBatch}.\n * @returns A promise resolving to the relayer-issued source hash.\n */\n polymarketSubmitDepositWalletBatch(\n ...args: Parameters<PolymarketCallbacks['submitDepositWalletBatch']>\n ): ReturnType<PolymarketCallbacks['submitDepositWalletBatch']> {\n return this.#requirePolymarket().submitDepositWalletBatch(...args);\n }\n\n #requirePolymarket(): PolymarketCallbacks {\n if (!this.#polymarket) {\n throw new Error('TransactionPayController: Polymarket callbacks missing');\n }\n return this.#polymarket;\n }\n\n #removeTransactionData(transactionId: string): void {\n this.update((state) => {\n delete state.transactionData[transactionId];\n });\n }\n\n #updateTransactionData(\n transactionId: string,\n fn: (transactionData: Draft<TransactionData>) => void,\n ): void {\n let shouldUpdateQuotes = false;\n\n this.update((state) => {\n const { transactionData } = state;\n let current = transactionData[transactionId];\n const originalPaymentToken = current?.paymentToken;\n const originalTokens = current?.tokens;\n const originalIsMaxAmount = current?.isMaxAmount;\n const originalIsPostQuote = current?.isPostQuote;\n const originalAccountOverride = current?.accountOverride;\n const originalFiatPaymentAmount = current?.fiatPayment?.amountFiat;\n const originalFiatPaymentMethodId =\n current?.fiatPayment?.selectedPaymentMethodId;\n\n if (!current) {\n transactionData[transactionId] = {\n fiatPayment: {},\n isLoading: false,\n tokens: [],\n };\n\n current = transactionData[transactionId];\n }\n\n fn(current);\n\n const isPaymentTokenUpdated =\n current.paymentToken?.address?.toLowerCase() !==\n originalPaymentToken?.address?.toLowerCase() ||\n current.paymentToken?.chainId !== originalPaymentToken?.chainId;\n\n const isPaymentTokenBalanceUpdated =\n current.paymentToken?.balanceRaw !== originalPaymentToken?.balanceRaw;\n\n const isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n const isAccountOverrideUpdated =\n current.accountOverride !== originalAccountOverride;\n const isFiatAmountUpdated =\n current.fiatPayment?.amountFiat !== originalFiatPaymentAmount;\n const isFiatPaymentMethodUpdated =\n current.fiatPayment?.selectedPaymentMethodId !==\n originalFiatPaymentMethodId;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated ||\n isAccountOverrideUpdated\n ) {\n updateSourceAmounts(\n transactionId,\n /* oxlint-disable typescript/no-unnecessary-type-assertion */\n current as never,\n /* oxlint-enable typescript/no-unnecessary-type-assertion */\n this.messenger,\n this.#getBalance,\n );\n\n shouldUpdateQuotes = true;\n } else if (\n isPaymentTokenBalanceUpdated &&\n current.isMaxAmount &&\n !current.isPostQuote\n ) {\n // On max the source amount is the payment token balance, so a\n // refreshed balance must re-derive it, otherwise the amount stays at\n // whatever the balance was when the token was selected. Quotes are not\n // requested again here: the balance is refreshed by `updateQuotes`\n // itself, which reads the re-derived amounts before building requests.\n updateSourceAmounts(\n transactionId,\n /* oxlint-disable typescript/no-unnecessary-type-assertion */\n current as never,\n /* oxlint-enable typescript/no-unnecessary-type-assertion */\n this.messenger,\n this.#getBalance,\n );\n }\n\n if (isFiatAmountUpdated || isFiatPaymentMethodUpdated) {\n shouldUpdateQuotes = true;\n }\n });\n\n if (shouldUpdateQuotes) {\n updateQuotes({\n getStrategies: this.#getStrategiesWithFallback.bind(this),\n messenger: this.messenger,\n transactionData: this.state.transactionData[transactionId],\n transactionId,\n updateTransactionData: this.#updateTransactionData.bind(this),\n }).catch(noop);\n }\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\n const transactionData = this.state.transactionData[transaction.id];\n\n const strategyCandidates: unknown[] =\n this.#getStrategies?.(transaction) ??\n (this.#getStrategy ? [this.#getStrategy(transaction)] : []);\n\n const validStrategies = strategyCandidates.filter(\n (strategy): strategy is TransactionPayStrategy =>\n isTransactionPayStrategy(strategy),\n );\n\n if (validStrategies.length) {\n return validStrategies;\n }\n\n const paymentToken = transactionData?.paymentToken;\n\n return getStrategyOrder(\n this.messenger,\n paymentToken?.chainId,\n paymentToken?.address,\n transaction.type,\n transactionData?.fiatPayment?.selectedPaymentMethodId,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionPayController.js","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,eAAe,EACf,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAiB7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,yBAAyB,GAAG;IAChC,eAAe;IACf,aAAa;IACb,0BAA0B;IAC1B,gBAAgB;IAChB,wBAAwB;IACxB,aAAa;IACb,mCAAmC;IACnC,oCAAoC;IACpC,sBAAsB;IACtB,mBAAmB;IACnB,oBAAoB;CACZ,CAAC;AAEX,MAAM,aAAa,GAAiD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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,wBAAwB,CAAC,QAAQ,CAAC,CACrC,CAAC;QAEF,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,MAAM,YAAY,GAAG,eAAe,EAAE,YAAY,CAAC;QAEnD,OAAO,gBAAgB,CACrB,IAAI,CAAC,SAAS,EACd,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,EAAE,WAAW,EAAE,uBAAuB,CACtD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { StateMetadata } from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { Draft } from 'immer';\nimport { noop } from 'lodash-es';\n\nimport { updateFiatPayment } from './actions/update-fiat-payment.js';\nimport { updatePaymentToken } from './actions/update-payment-token.js';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants.js';\nimport type { TransactionPayClientId } from './constants.js';\nimport { QuoteRefresher } from './helpers/QuoteRefresher.js';\nimport type {\n GetAmountDataCallback,\n GetBalanceCallback,\n GetDelegationTransactionCallback,\n GetPaymentOverrideDataCallback,\n PolymarketCallbacks,\n TransactionConfig,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayFiatOptions,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types.js';\nimport { getStrategyOrder } from './utils/feature-flags.js';\nimport { updateQuotes } from './utils/quotes.js';\nimport { updateSourceAmounts } from './utils/source-amounts.js';\nimport {\n subscribeAssetChanges,\n subscribeTransactionChanges,\n} from './utils/transaction.js';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getAmountData',\n 'getClientId',\n 'getDelegationTransaction',\n 'getFiatOptions',\n 'getPaymentOverrideData',\n 'getStrategy',\n 'polymarketGetDepositWalletAddress',\n 'polymarketSubmitDepositWalletBatch',\n 'setTransactionConfig',\n 'updateFiatPayment',\n 'updatePaymentToken',\n] as const;\n\nconst stateMetadata: StateMetadata<TransactionPayControllerState> = {\n transactionData: {\n includeInDebugSnapshot: false,\n includeInStateLogs: true,\n persist: false,\n usedInUi: true,\n },\n};\n\nconst getDefaultState = (): TransactionPayControllerState => ({\n transactionData: {},\n});\n\nexport class TransactionPayController extends BaseController<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState,\n TransactionPayControllerMessenger\n> {\n readonly #clientId?: TransactionPayClientId;\n\n readonly #fiatOptions?: TransactionPayFiatOptions;\n\n readonly #getAmountData?: GetAmountDataCallback;\n\n readonly #getBalance?: GetBalanceCallback;\n\n readonly #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n readonly #polymarket?: PolymarketCallbacks;\n\n constructor({\n clientId,\n fiatOptions,\n getAmountData,\n getBalance,\n getDelegationTransaction,\n getPaymentOverrideData,\n getStrategy,\n getStrategies,\n messenger,\n polymarket,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#clientId = clientId;\n this.#fiatOptions = fiatOptions;\n this.#getAmountData = getAmountData;\n this.#getBalance = getBalance;\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getPaymentOverrideData = getPaymentOverrideData;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n this.#polymarket = polymarket;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n subscribeTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.bind(this),\n );\n\n subscribeAssetChanges(\n messenger,\n () => this.state,\n this.#updateTransactionData.bind(this),\n );\n\n // eslint-disable-next-line no-new\n new QuoteRefresher({\n getStrategies: this.#getStrategiesWithFallback.bind(this),\n messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\n }\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 */\n setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config: TransactionConfig = {\n accountOverride: transactionData.accountOverride,\n atomic: transactionData.atomic,\n isHyperliquidSource: transactionData.isHyperliquidSource,\n isMaxAmount: transactionData.isMaxAmount,\n isPolymarketDepositWallet: transactionData.isPolymarketDepositWallet,\n isPostQuote: transactionData.isPostQuote,\n isQuoteRequired: transactionData.isQuoteRequired,\n paymentOverride: transactionData.paymentOverride,\n refundTo: transactionData.refundTo,\n };\n\n const previousAccountOverride = config.accountOverride;\n\n callback(config);\n\n Object.assign(transactionData, config);\n\n if (\n !config.isPostQuote &&\n config.accountOverride !== previousAccountOverride\n ) {\n transactionData.paymentToken = undefined;\n }\n });\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 */\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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 */\n updateFiatPayment(request: UpdateFiatPaymentRequest): void {\n updateFiatPayment(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\n }\n\n /**\n * Returns the configured client identifier.\n *\n * Used to set the `X-Client-Id` header on intents API requests so the\n * server can distinguish Mobile from Extension traffic. This is\n * intentionally not stored in controller state.\n *\n * @returns The client identifier, if configured.\n */\n getClientId(): TransactionPayClientId | undefined {\n return this.#clientId;\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 */\n getDelegationTransaction(\n ...args: Parameters<GetDelegationTransactionCallback>\n ): ReturnType<GetDelegationTransactionCallback> {\n return this.#getDelegationTransaction(...args);\n }\n\n /**\n * Returns additional transactions for the paymentOverride flow.\n *\n * Delegates to the client-supplied {@link GetPaymentOverrideDataCallback}.\n * Called during quote execution when `paymentOverride` is defined on the transaction.\n * Returns an empty array when no callback is configured.\n *\n * @param args - The arguments forwarded to the {@link GetPaymentOverrideDataCallback}.\n * @returns A promise resolving to the additional transactions array.\n */\n getAmountData(\n ...args: Parameters<GetAmountDataCallback>\n ): ReturnType<GetAmountDataCallback> {\n return this.#getAmountData?.(...args) ?? Promise.resolve({ updates: [] });\n }\n\n /**\n * Returns optional fiat execution configuration.\n *\n * This is intentionally not stored in controller state.\n *\n * @returns Fiat execution options, if configured.\n */\n getFiatOptions(): TransactionPayFiatOptions | undefined {\n return this.#fiatOptions;\n }\n\n getPaymentOverrideData(\n ...args: Parameters<GetPaymentOverrideDataCallback>\n ): ReturnType<GetPaymentOverrideDataCallback> {\n return (\n this.#getPaymentOverrideData?.(...args) ?? Promise.resolve({ calls: [] })\n );\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 */\n getStrategy(transaction: TransactionMeta): TransactionPayStrategy {\n return this.#getStrategiesWithFallback(transaction)[0];\n }\n\n /**\n * Derives the Polymarket deposit-wallet address for an EOA via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.getDepositWalletAddress}.\n * @returns A promise resolving to the deposit-wallet address.\n */\n polymarketGetDepositWalletAddress(\n ...args: Parameters<PolymarketCallbacks['getDepositWalletAddress']>\n ): ReturnType<PolymarketCallbacks['getDepositWalletAddress']> {\n return this.#requirePolymarket().getDepositWalletAddress(...args);\n }\n\n /**\n * Signs and broadcasts a Polymarket deposit-wallet batch via the\n * client-supplied callback.\n *\n * @param args - The arguments forwarded to {@link PolymarketCallbacks.submitDepositWalletBatch}.\n * @returns A promise resolving to the relayer-issued source hash.\n */\n polymarketSubmitDepositWalletBatch(\n ...args: Parameters<PolymarketCallbacks['submitDepositWalletBatch']>\n ): ReturnType<PolymarketCallbacks['submitDepositWalletBatch']> {\n return this.#requirePolymarket().submitDepositWalletBatch(...args);\n }\n\n #requirePolymarket(): PolymarketCallbacks {\n if (!this.#polymarket) {\n throw new Error('TransactionPayController: Polymarket callbacks missing');\n }\n return this.#polymarket;\n }\n\n #removeTransactionData(transactionId: string): void {\n this.update((state) => {\n delete state.transactionData[transactionId];\n });\n }\n\n #updateTransactionData(\n transactionId: string,\n fn: (transactionData: Draft<TransactionData>) => void,\n ): void {\n let shouldUpdateQuotes = false;\n\n this.update((state) => {\n const { transactionData } = state;\n let current = transactionData[transactionId];\n const originalPaymentToken = current?.paymentToken;\n const originalTokens = current?.tokens;\n const originalIsMaxAmount = current?.isMaxAmount;\n const originalIsPostQuote = current?.isPostQuote;\n const originalAccountOverride = current?.accountOverride;\n const originalFiatPaymentAmount = current?.fiatPayment?.amountFiat;\n const originalFiatPaymentMethodId =\n current?.fiatPayment?.selectedPaymentMethodId;\n\n if (!current) {\n transactionData[transactionId] = {\n fiatPayment: {},\n isLoading: false,\n tokens: [],\n };\n\n current = transactionData[transactionId];\n }\n\n fn(current);\n\n const isPaymentTokenUpdated =\n current.paymentToken?.address?.toLowerCase() !==\n originalPaymentToken?.address?.toLowerCase() ||\n current.paymentToken?.chainId !== originalPaymentToken?.chainId;\n\n const isPaymentTokenBalanceUpdated =\n current.paymentToken?.balanceRaw !== originalPaymentToken?.balanceRaw;\n\n const isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n const isAccountOverrideUpdated =\n current.accountOverride !== originalAccountOverride;\n const isFiatAmountUpdated =\n current.fiatPayment?.amountFiat !== originalFiatPaymentAmount;\n const isFiatPaymentMethodUpdated =\n current.fiatPayment?.selectedPaymentMethodId !==\n originalFiatPaymentMethodId;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated ||\n isAccountOverrideUpdated\n ) {\n updateSourceAmounts(\n transactionId,\n /* oxlint-disable typescript/no-unnecessary-type-assertion */\n current as never,\n /* oxlint-enable typescript/no-unnecessary-type-assertion */\n this.messenger,\n this.#getBalance,\n );\n\n shouldUpdateQuotes = true;\n } else if (\n isPaymentTokenBalanceUpdated &&\n current.isMaxAmount &&\n !current.isPostQuote\n ) {\n // On max the source amount is the payment token balance, so a\n // refreshed balance must re-derive it, otherwise the amount stays at\n // whatever the balance was when the token was selected. Quotes are not\n // requested again here: the balance is refreshed by `updateQuotes`\n // itself, which reads the re-derived amounts before building requests.\n updateSourceAmounts(\n transactionId,\n /* oxlint-disable typescript/no-unnecessary-type-assertion */\n current as never,\n /* oxlint-enable typescript/no-unnecessary-type-assertion */\n this.messenger,\n this.#getBalance,\n );\n }\n\n if (isFiatAmountUpdated || isFiatPaymentMethodUpdated) {\n shouldUpdateQuotes = true;\n }\n });\n\n if (shouldUpdateQuotes) {\n updateQuotes({\n getStrategies: this.#getStrategiesWithFallback.bind(this),\n messenger: this.messenger,\n transactionData: this.state.transactionData[transactionId],\n transactionId,\n updateTransactionData: this.#updateTransactionData.bind(this),\n }).catch(noop);\n }\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\n const transactionData = this.state.transactionData[transaction.id];\n\n const strategyCandidates: unknown[] =\n this.#getStrategies?.(transaction) ??\n (this.#getStrategy ? [this.#getStrategy(transaction)] : []);\n\n const validStrategies = strategyCandidates.filter(\n (strategy): strategy is TransactionPayStrategy =>\n isTransactionPayStrategy(strategy),\n );\n\n if (validStrategies.length) {\n return validStrategies;\n }\n\n const paymentToken = transactionData?.paymentToken;\n\n return getStrategyOrder(\n this.messenger,\n paymentToken?.chainId,\n paymentToken?.address,\n transaction.type,\n transactionData?.fiatPayment?.selectedPaymentMethodId,\n );\n }\n}\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -26,6 +26,18 @@ export declare enum PaymentOverride {
|
|
|
26
26
|
Perps = "perps",
|
|
27
27
|
Predict = "predict"
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Identifies the MetaMask client making MM Pay requests.
|
|
31
|
+
*
|
|
32
|
+
* Sent as the `X-Client-Id` header on requests to the intents API so the
|
|
33
|
+
* server can distinguish Mobile traffic from Extension traffic.
|
|
34
|
+
*/
|
|
35
|
+
export declare enum TransactionPayClientId {
|
|
36
|
+
Extension = "extension",
|
|
37
|
+
Mobile = "mobile"
|
|
38
|
+
}
|
|
39
|
+
/** Header used to identify the calling client to the intents API. */
|
|
40
|
+
export declare const CLIENT_ID_HEADER = "X-Client-Id";
|
|
29
41
|
export declare enum TransactionPayStrategy {
|
|
30
42
|
Across = "across",
|
|
31
43
|
Fiat = "fiat",
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAAe,EAGhD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAe,GAAG,CAAC;AACjD,eAAO,MAAM,gBAAgB,EAAY,GAAG,CAAC;AAC7C,eAAO,MAAM,gBAAgB,EAAa,GAAG,CAAC;AAC9C,eAAO,MAAM,kBAAkB,EAAc,GAAG,CAAC;AACjD,eAAO,MAAM,cAAc,EAAa,GAAG,CAAC;AAE5C,eAAO,MAAM,oBAAoB,EACiB,GAAG,CAAC;AAEtD,eAAO,MAAM,qBAAqB,EACgB,GAAG,CAAC;AAEtD,eAAO,MAAM,qBAAqB,EACgB,GAAG,CAAC;AAEtD,eAAO,MAAM,oBAAoB,EACiB,GAAG,CAAC;AAEtD,eAAO,MAAM,kBAAkB,EACmB,GAAG,CAAC;AAEtD,eAAO,MAAM,sBAAsB,uCAAuC,CAAC;AAE3E,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAEzD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,CAmB1C,CAAC;AAEF,oBAAY,eAAe;IACzB,YAAY,iBAAiB;IAC7B,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IAC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,iBAAiB;IAC7B,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,oBAAY,sBAAsB;IAChC,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IACjB,IAAI,SAAS;IACb;;;OAGG;IACH,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAQD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,sBAAsB,CAEpC"}
|
package/dist/constants.js
CHANGED
|
@@ -50,6 +50,19 @@ export var PaymentOverride;
|
|
|
50
50
|
PaymentOverride["Perps"] = "perps";
|
|
51
51
|
PaymentOverride["Predict"] = "predict";
|
|
52
52
|
})(PaymentOverride || (PaymentOverride = {}));
|
|
53
|
+
/**
|
|
54
|
+
* Identifies the MetaMask client making MM Pay requests.
|
|
55
|
+
*
|
|
56
|
+
* Sent as the `X-Client-Id` header on requests to the intents API so the
|
|
57
|
+
* server can distinguish Mobile traffic from Extension traffic.
|
|
58
|
+
*/
|
|
59
|
+
export var TransactionPayClientId;
|
|
60
|
+
(function (TransactionPayClientId) {
|
|
61
|
+
TransactionPayClientId["Extension"] = "extension";
|
|
62
|
+
TransactionPayClientId["Mobile"] = "mobile";
|
|
63
|
+
})(TransactionPayClientId || (TransactionPayClientId = {}));
|
|
64
|
+
/** Header used to identify the calling client to the intents API. */
|
|
65
|
+
export const CLIENT_ID_HEADER = 'X-Client-Id';
|
|
53
66
|
export var TransactionPayStrategy;
|
|
54
67
|
(function (TransactionPayStrategy) {
|
|
55
68
|
TransactionPayStrategy["Across"] = "across";
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAA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ACR,QAAQ,EAAE;QACR,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;KACtD;IACD,CAAC,gBAAgB,CAAC,EAAE;QAClB,qBAAqB,CAAC,WAAW,EAAS;QAC1C,oBAAoB,CAAC,WAAW,EAAS;KAC1C;IACD,CAAC,kBAAkB,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,OAAO;CACxD,CAAC;AAEF,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,gDAA6B,CAAA;IAC7B,kCAAe,CAAA;IACf,sCAAmB,CAAA;AACrB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb;;;OAGG;IACH,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAC3D,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,sBAAsB,CAAC,IAAI,CACvD,CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\n\n/**\n * Parent transaction types that represent a Hyperliquid perps deposit and\n * share the same Arbitrum-USDC → Hypercore handling in pay strategies.\n */\nexport const PERPS_DEPOSIT_TYPES: TransactionType[] = [\n TransactionType.perpsDeposit,\n TransactionType.perpsDepositAndOrder,\n];\n\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_MAINNET = '0x1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\nexport const CHAIN_ID_MONAD = '0x8f' 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 POLYGON_PUSD_ADDRESS =\n '0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB' as Hex;\n\nexport const MUSD_MONAD_ADDRESS =\n '0xaca92e438df0b2401ff60da7e4337b687a2435da' as Hex;\n\nexport const HYPERCORE_USDC_ADDRESS = '0x00000000000000000000000000000000';\n\nexport const HYPERCORE_USDC_DECIMALS = 8;\nexport const USDC_DECIMALS = 6;\n\nexport const SLIP44_COIN_TYPE_BY_CHAIN: Record<Hex, number> = {\n [CHAIN_ID_POLYGON]: 966, // POL\n};\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]: [\n POLYGON_USDCE_ADDRESS.toLowerCase() as Hex,\n POLYGON_PUSD_ADDRESS.toLowerCase() as Hex,\n ],\n [CHAIN_ID_HYPERCORE]: [HYPERCORE_USDC_ADDRESS], // USDC\n};\n\nexport enum PaymentOverride {\n MoneyAccount = 'moneyAccount',\n Perps = 'perps',\n Predict = 'predict',\n}\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Fiat = 'fiat',\n /**\n * Internal marker for no-op quotes generated when the controller determines\n * that no conversion is needed. Not a routable strategy.\n */\n None = 'none',\n Relay = 'relay',\n Server = 'server',\n}\n\nconst VALID_STRATEGIES: Set<TransactionPayStrategy> = new Set(\n Object.values(TransactionPayStrategy).filter(\n (strategy) => strategy !== TransactionPayStrategy.None,\n ),\n);\n\n/**\n * Checks if a value is a valid, routable transaction pay strategy.\n * The internal no-op marker is not routable.\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.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,oBAAoB;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAe,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAc,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAC/B,4CAAmD,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAA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AC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C,MAAM,CAAN,IAAY,sBAUX;AAVD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb;;;OAGG;IACH,uCAAa,CAAA;IACb,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAVW,sBAAsB,KAAtB,sBAAsB,QAUjC;AAED,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAC3D,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAC1C,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,sBAAsB,CAAC,IAAI,CACvD,CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAiB;IAEjB,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAkC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { TransactionType } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\nexport const CONTROLLER_NAME = 'TransactionPayController';\n\n/**\n * Parent transaction types that represent a Hyperliquid perps deposit and\n * share the same Arbitrum-USDC → Hypercore handling in pay strategies.\n */\nexport const PERPS_DEPOSIT_TYPES: TransactionType[] = [\n TransactionType.perpsDeposit,\n TransactionType.perpsDepositAndOrder,\n];\n\nexport const CHAIN_ID_ARBITRUM = '0xa4b1' as Hex;\nexport const CHAIN_ID_MAINNET = '0x1' as Hex;\nexport const CHAIN_ID_POLYGON = '0x89' as Hex;\nexport const CHAIN_ID_HYPERCORE = '0x539' as Hex;\nexport const CHAIN_ID_MONAD = '0x8f' 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 POLYGON_PUSD_ADDRESS =\n '0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB' as Hex;\n\nexport const MUSD_MONAD_ADDRESS =\n '0xaca92e438df0b2401ff60da7e4337b687a2435da' as Hex;\n\nexport const HYPERCORE_USDC_ADDRESS = '0x00000000000000000000000000000000';\n\nexport const HYPERCORE_USDC_DECIMALS = 8;\nexport const USDC_DECIMALS = 6;\n\nexport const SLIP44_COIN_TYPE_BY_CHAIN: Record<Hex, number> = {\n [CHAIN_ID_POLYGON]: 966, // POL\n};\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]: [\n POLYGON_USDCE_ADDRESS.toLowerCase() as Hex,\n POLYGON_PUSD_ADDRESS.toLowerCase() as Hex,\n ],\n [CHAIN_ID_HYPERCORE]: [HYPERCORE_USDC_ADDRESS], // USDC\n};\n\nexport enum PaymentOverride {\n MoneyAccount = 'moneyAccount',\n Perps = 'perps',\n Predict = 'predict',\n}\n\n/**\n * Identifies the MetaMask client making MM Pay requests.\n *\n * Sent as the `X-Client-Id` header on requests to the intents API so the\n * server can distinguish Mobile traffic from Extension traffic.\n */\nexport enum TransactionPayClientId {\n Extension = 'extension',\n Mobile = 'mobile',\n}\n\n/** Header used to identify the calling client to the intents API. */\nexport const CLIENT_ID_HEADER = 'X-Client-Id';\n\nexport enum TransactionPayStrategy {\n Across = 'across',\n Fiat = 'fiat',\n /**\n * Internal marker for no-op quotes generated when the controller determines\n * that no conversion is needed. Not a routable strategy.\n */\n None = 'none',\n Relay = 'relay',\n Server = 'server',\n}\n\nconst VALID_STRATEGIES: Set<TransactionPayStrategy> = new Set(\n Object.values(TransactionPayStrategy).filter(\n (strategy) => strategy !== TransactionPayStrategy.None,\n ),\n);\n\n/**\n * Checks if a value is a valid, routable transaction pay strategy.\n * The internal no-op marker is not routable.\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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { GetAmountDataCallback, GetAmountDataRequest, GetAmountDataResponse, GetBalanceCallback, GetBalanceRequest, GetBalanceResponse, GetPaymentOverrideDataRequest, GetPaymentOverrideDataResponse, TransactionConfig, TransactionConfigCallback, TransactionData, TransactionFiatPayment, TransactionFiatPaymentCallback, TransactionPayFiatOptions, TransactionPayControllerActions, TransactionPayControllerEvents, TransactionPayControllerGetStateAction, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerState, PolymarketCallbacks, QuoteErrorInfo, QuoteErrorReason, TransactionPayControllerStateChangeEvent, TransactionPaymentToken, TransactionPayQuote, TransactionPayRequiredToken, TransactionPaySourceAmount, TransactionPayTotals, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest, } from './types.js';
|
|
2
|
-
export type { TransactionPayControllerGetAmountDataAction, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetFiatOptionsAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerPolymarketGetDepositWalletAddressAction, TransactionPayControllerPolymarketSubmitDepositWalletBatchAction, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerUpdatePaymentTokenAction, TransactionPayControllerUpdateFiatPaymentAction, } from './TransactionPayController-method-action-types.js';
|
|
3
|
-
export { PaymentOverride, TransactionPayStrategy } from './constants.js';
|
|
2
|
+
export type { TransactionPayControllerGetAmountDataAction, TransactionPayControllerGetClientIdAction, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetFiatOptionsAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerPolymarketGetDepositWalletAddressAction, TransactionPayControllerPolymarketSubmitDepositWalletBatchAction, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerUpdatePaymentTokenAction, TransactionPayControllerUpdateFiatPaymentAction, } from './TransactionPayController-method-action-types.js';
|
|
3
|
+
export { PaymentOverride, TransactionPayClientId, TransactionPayStrategy, } from './constants.js';
|
|
4
4
|
export { TransactionPayController } from './TransactionPayController.js';
|
|
5
5
|
export { TransactionPayPublishHook } from './helpers/TransactionPayPublishHook.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,wCAAwC,EACxC,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,2CAA2C,EAC3C,sDAAsD,EACtD,4CAA4C,EAC5C,yCAAyC,EACzC,+DAA+D,EAC/D,gEAAgE,EAChE,kDAAkD,EAClD,gDAAgD,EAChD,+CAA+C,GAChD,MAAM,mDAAmD,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,wCAAwC,EACxC,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,2CAA2C,EAC3C,yCAAyC,EACzC,sDAAsD,EACtD,4CAA4C,EAC5C,yCAAyC,EACzC,+DAA+D,EAC/D,gEAAgE,EAChE,kDAAkD,EAClD,gDAAgD,EAChD,+CAA+C,GAChD,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PaymentOverride, TransactionPayStrategy } from './constants.js';
|
|
1
|
+
export { PaymentOverride, TransactionPayClientId, TransactionPayStrategy, } from './constants.js';
|
|
2
2
|
export { TransactionPayController } from './TransactionPayController.js';
|
|
3
3
|
export { TransactionPayPublishHook } from './helpers/TransactionPayPublishHook.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6CA,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export type {\n GetAmountDataCallback,\n GetAmountDataRequest,\n GetAmountDataResponse,\n GetBalanceCallback,\n GetBalanceRequest,\n GetBalanceResponse,\n GetPaymentOverrideDataRequest,\n GetPaymentOverrideDataResponse,\n TransactionConfig,\n TransactionConfigCallback,\n TransactionData,\n TransactionFiatPayment,\n TransactionFiatPaymentCallback,\n TransactionPayFiatOptions,\n TransactionPayControllerActions,\n TransactionPayControllerEvents,\n TransactionPayControllerGetStateAction,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n PolymarketCallbacks,\n QuoteErrorInfo,\n QuoteErrorReason,\n TransactionPayControllerStateChangeEvent,\n TransactionPaymentToken,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPaySourceAmount,\n TransactionPayTotals,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types.js';\nexport type {\n TransactionPayControllerGetAmountDataAction,\n TransactionPayControllerGetClientIdAction,\n TransactionPayControllerGetDelegationTransactionAction,\n TransactionPayControllerGetFiatOptionsAction,\n TransactionPayControllerGetStrategyAction,\n TransactionPayControllerPolymarketGetDepositWalletAddressAction,\n TransactionPayControllerPolymarketSubmitDepositWalletBatchAction,\n TransactionPayControllerSetTransactionConfigAction,\n TransactionPayControllerUpdatePaymentTokenAction,\n TransactionPayControllerUpdateFiatPaymentAction,\n} from './TransactionPayController-method-action-types.js';\nexport {\n PaymentOverride,\n TransactionPayClientId,\n TransactionPayStrategy,\n} from './constants.js';\nexport { TransactionPayController } from './TransactionPayController.js';\nexport { TransactionPayPublishHook } from './helpers/TransactionPayPublishHook.js';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-api.d.ts","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-api.d.ts","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,kBAAkB,EACxB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAc9B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,iCAAiC,EAC5C,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAa/B;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,iCAAiC,EAC5C,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,oBAAoB,CAAC,CAgB/B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createModuleLogger } from '@metamask/utils';
|
|
2
|
+
import { CLIENT_ID_HEADER } from '../../constants.js';
|
|
2
3
|
import { projectLogger } from '../../logger.js';
|
|
3
4
|
import { getPayStrategiesConfig } from '../../utils/feature-flags.js';
|
|
4
5
|
const log = createModuleLogger(projectLogger, 'server-api');
|
|
@@ -14,7 +15,7 @@ export async function fetchServerQuote(messenger, body, signal) {
|
|
|
14
15
|
const { server } = getPayStrategiesConfig(messenger);
|
|
15
16
|
const quoteUrl = `${server.baseUrl}/quote`;
|
|
16
17
|
log('Fetching quote', { url: quoteUrl });
|
|
17
|
-
const response = await serverFetch(quoteUrl, {
|
|
18
|
+
const response = await serverFetch(messenger, quoteUrl, {
|
|
18
19
|
method: 'POST',
|
|
19
20
|
headers: { 'Content-Type': 'application/json' },
|
|
20
21
|
body: JSON.stringify(body),
|
|
@@ -33,7 +34,7 @@ export async function submitServerIntent(messenger, body) {
|
|
|
33
34
|
const { server } = getPayStrategiesConfig(messenger);
|
|
34
35
|
const submitUrl = `${server.baseUrl}/submit`;
|
|
35
36
|
log('Submitting intent', { url: submitUrl });
|
|
36
|
-
const response = await serverFetch(submitUrl, {
|
|
37
|
+
const response = await serverFetch(messenger, submitUrl, {
|
|
37
38
|
method: 'POST',
|
|
38
39
|
headers: { 'Content-Type': 'application/json' },
|
|
39
40
|
body: JSON.stringify(body),
|
|
@@ -61,7 +62,7 @@ export async function getServerStatus(messenger, params) {
|
|
|
61
62
|
}
|
|
62
63
|
const url = `${server.baseUrl}/status?${query.toString()}`;
|
|
63
64
|
log('Fetching status', { url });
|
|
64
|
-
const response = await serverFetch(url, { method: 'GET' });
|
|
65
|
+
const response = await serverFetch(messenger, url, { method: 'GET' });
|
|
65
66
|
return (await response.json());
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
@@ -70,12 +71,20 @@ export async function getServerStatus(messenger, params) {
|
|
|
70
71
|
* responses so the server's actual reason is preserved without leaking the
|
|
71
72
|
* request URL.
|
|
72
73
|
*
|
|
74
|
+
* Adds the `X-Client-Id` header so the intents API can distinguish Mobile
|
|
75
|
+
* from Extension traffic.
|
|
76
|
+
*
|
|
77
|
+
* @param messenger - Controller messenger.
|
|
73
78
|
* @param url - The endpoint to fetch.
|
|
74
79
|
* @param init - Fetch init options.
|
|
75
80
|
* @returns The successful response.
|
|
76
81
|
*/
|
|
77
|
-
async function serverFetch(url, init) {
|
|
78
|
-
const
|
|
82
|
+
async function serverFetch(messenger, url, init) {
|
|
83
|
+
const clientId = getClientId(messenger);
|
|
84
|
+
const headers = clientId
|
|
85
|
+
? { ...init?.headers, [CLIENT_ID_HEADER]: clientId }
|
|
86
|
+
: init?.headers;
|
|
87
|
+
const response = await fetch(url, { ...init, ...(headers && { headers }) });
|
|
79
88
|
if (!response.ok) {
|
|
80
89
|
let detail;
|
|
81
90
|
try {
|
|
@@ -89,4 +98,22 @@ async function serverFetch(url, init) {
|
|
|
89
98
|
}
|
|
90
99
|
return response;
|
|
91
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Retrieve the client identifier from the controller.
|
|
103
|
+
*
|
|
104
|
+
* Returns `undefined` if the client did not configure one, so requests are
|
|
105
|
+
* still made without the header rather than failing.
|
|
106
|
+
*
|
|
107
|
+
* @param messenger - Controller messenger.
|
|
108
|
+
* @returns The client identifier, if configured.
|
|
109
|
+
*/
|
|
110
|
+
function getClientId(messenger) {
|
|
111
|
+
try {
|
|
112
|
+
return messenger.call('TransactionPayController:getClientId');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
log('Failed to retrieve client ID', error);
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
92
119
|
//# sourceMappingURL=server-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-api.js","sourceRoot":"","sources":["../../../src/strategy/server/server-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EA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C,QAAQ,CAAC,MAAM,CAAC,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,WAAW,CAClB,SAA4C;IAE5C,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\n\nimport { CLIENT_ID_HEADER } from '../../constants.js';\nimport type { TransactionPayClientId } from '../../constants.js';\nimport { projectLogger } from '../../logger.js';\nimport type { TransactionPayControllerMessenger } from '../../types.js';\nimport { getPayStrategiesConfig } from '../../utils/feature-flags.js';\nimport type {\n ServerQuoteRequest,\n ServerQuoteResponse,\n ServerStatusResponse,\n ServerSubmitRequest,\n ServerSubmitResponse,\n} from './types.js';\n\nconst log = createModuleLogger(projectLogger, 'server-api');\n\n/**\n * Fetch a quote from the server intents API.\n *\n * @param messenger - Controller messenger.\n * @param body - Quote request parameters.\n * @param signal - Optional abort signal that cancels the underlying fetch.\n * @returns The server quote response.\n */\nexport async function fetchServerQuote(\n messenger: TransactionPayControllerMessenger,\n body: ServerQuoteRequest,\n signal?: AbortSignal,\n): Promise<ServerQuoteResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const quoteUrl = `${server.baseUrl}/quote`;\n\n log('Fetching quote', { url: quoteUrl });\n\n const response = await serverFetch(messenger, quoteUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n signal,\n });\n\n return (await response.json()) as ServerQuoteResponse;\n}\n\n/**\n * Submit a gasless intent via the server intents API.\n *\n * @param messenger - Controller messenger.\n * @param body - Submit request parameters.\n * @returns The submit response.\n */\nexport async function submitServerIntent(\n messenger: TransactionPayControllerMessenger,\n body: ServerSubmitRequest,\n): Promise<ServerSubmitResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const submitUrl = `${server.baseUrl}/submit`;\n\n log('Submitting intent', { url: submitUrl });\n\n const response = await serverFetch(messenger, submitUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n });\n\n return (await response.json()) as ServerSubmitResponse;\n}\n\n/**\n * Fetch the status of a server intent.\n *\n * @param messenger - Controller messenger.\n * @param params - Status query parameters.\n * @param params.provider - The provider that the intent was submitted to.\n * @param params.id - The intent ID.\n * @param params.hash - Optional transaction hash to include in the status query.\n * @returns The current status of the intent.\n */\nexport async function getServerStatus(\n messenger: TransactionPayControllerMessenger,\n params: { provider: string; id: string; hash?: string },\n): Promise<ServerStatusResponse> {\n const { server } = getPayStrategiesConfig(messenger);\n const query = new URLSearchParams({\n provider: params.provider,\n id: params.id,\n });\n if (params.hash) {\n query.set('hash', params.hash);\n }\n const url = `${server.baseUrl}/status?${query.toString()}`;\n\n log('Fetching status', { url });\n\n const response = await serverFetch(messenger, url, { method: 'GET' });\n\n return (await response.json()) as ServerStatusResponse;\n}\n\n/**\n * Fetch a server intents-api endpoint, throwing an error containing the\n * response body's `message` or `error` field (or status code) on non-OK\n * responses so the server's actual reason is preserved without leaking the\n * request URL.\n *\n * Adds the `X-Client-Id` header so the intents API can distinguish Mobile\n * from Extension traffic.\n *\n * @param messenger - Controller messenger.\n * @param url - The endpoint to fetch.\n * @param init - Fetch init options.\n * @returns The successful response.\n */\nasync function serverFetch(\n messenger: TransactionPayControllerMessenger,\n url: string,\n init?: RequestInit,\n): Promise<Response> {\n const clientId = getClientId(messenger);\n\n const headers = clientId\n ? { ...init?.headers, [CLIENT_ID_HEADER]: clientId }\n : init?.headers;\n\n const response = await fetch(url, { ...init, ...(headers && { headers }) });\n\n if (!response.ok) {\n let detail: string | undefined;\n try {\n const body = (await response.json()) as {\n message?: string;\n error?: string;\n };\n detail = body.message ?? body.error;\n } catch {\n // Body wasn't JSON; fall through to status-only error.\n }\n throw new Error(\n detail ? `${response.status} - ${detail}` : String(response.status),\n );\n }\n\n return response;\n}\n\n/**\n * Retrieve the client identifier from the controller.\n *\n * Returns `undefined` if the client did not configure one, so requests are\n * still made without the header rather than failing.\n *\n * @param messenger - Controller messenger.\n * @returns The client identifier, if configured.\n */\nfunction getClientId(\n messenger: TransactionPayControllerMessenger,\n): TransactionPayClientId | undefined {\n try {\n return messenger.call('TransactionPayController:getClientId');\n } catch (error) {\n log('Failed to retrieve client ID', error);\n return undefined;\n }\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { AuthorizationList, TransactionControllerAddTransactionBatchAction,
|
|
|
16
16
|
import type { BatchTransaction, BatchTransactionParams, TransactionControllerAddTransactionAction, TransactionControllerGetGasFeeTokensAction, TransactionControllerGetStateAction, TransactionControllerStateChangeEvent, TransactionControllerUpdateTransactionAction, TransactionMeta } from '@metamask/transaction-controller';
|
|
17
17
|
import type { Hex, Json } from '@metamask/utils';
|
|
18
18
|
import type { Draft } from 'immer';
|
|
19
|
-
import type { CONTROLLER_NAME, PaymentOverride, TransactionPayStrategy } from './constants.js';
|
|
19
|
+
import type { CONTROLLER_NAME, PaymentOverride, TransactionPayClientId, TransactionPayStrategy } from './constants.js';
|
|
20
20
|
import type { TransactionPayControllerMethodActions } from './TransactionPayController-method-action-types.js';
|
|
21
21
|
export type AllowedActions = AccountsControllerGetStateAction | AssetsControllerGetStateAction | GetGasFeeState | KeyringControllerGetStateAction | KeyringControllerSignTypedMessageAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetNetworkConfigurationByChainIdAction | RampsControllerGetOrderAction | RampsControllerGetQuoteWithFeesAction | RemoteFeatureFlagControllerGetStateAction | SentinelApiServiceActions | TransactionControllerAddTransactionAction | TransactionControllerAddTransactionBatchAction | TransactionControllerEstimateGasAction | TransactionControllerEstimateGasBatchAction | TransactionControllerGetGasFeeTokensAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction;
|
|
22
22
|
export type AllowedEvents = AssetsControllerStateChangeEvent | KeyringControllerUnlockEvent | TransactionControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent;
|
|
@@ -152,6 +152,12 @@ export type TransactionPayControllerMessenger = Messenger<typeof CONTROLLER_NAME
|
|
|
152
152
|
export declare const KEYRING_TYPES_SUPPORTING_7702: `${KeyringTypes}`[];
|
|
153
153
|
/** Options for the TransactionPayController. */
|
|
154
154
|
export type TransactionPayControllerOptions = {
|
|
155
|
+
/**
|
|
156
|
+
* Identifies the MetaMask client, sent as the `X-Client-Id` header on
|
|
157
|
+
* requests to the intents API so the server can distinguish Mobile from
|
|
158
|
+
* Extension traffic.
|
|
159
|
+
*/
|
|
160
|
+
clientId?: TransactionPayClientId;
|
|
155
161
|
/** Optional callback to re-encode nested transaction calldata for a given amount. */
|
|
156
162
|
getAmountData?: GetAmountDataCallback;
|
|
157
163
|
/** Optional callback to override the source balance used for max-amount calculation. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,KAAK,EACV,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EACV,+BAA+B,EAC/B,uCAAuC,EACvC,4BAA4B,EAC5B,YAAY,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAq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AE,GAAG,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACpD,KAAK,OAAO,CAAC;QAAE,UAAU,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CACpC,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG;IAC/B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IAEd,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6PA;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,aAAa;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC","sourcesContent":["import type { AccountsControllerGetStateAction } from '@metamask/accounts-controller';\nimport type {\n AssetsControllerGetStateAction,\n AssetsControllerStateChangeEvent,\n} from '@metamask/assets-controller';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerUnlockEvent,\n KeyringTypes,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkConfigurationByChainIdAction } from '@metamask/network-controller';\nimport type { Quote as RampsQuote } from '@metamask/ramps-controller';\nimport type {\n RampsControllerGetOrderAction,\n RampsControllerGetQuoteWithFeesAction,\n} from '@metamask/ramps-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SentinelApiServiceActions } from '@metamask/sentinel-api-service';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\n BatchTransactionParams,\n TransactionControllerAddTransactionAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetStateAction,\n TransactionControllerStateChangeEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport type {\n CONTROLLER_NAME,\n PaymentOverride,\n TransactionPayStrategy,\n} from './constants.js';\nimport type { TransactionPayControllerMethodActions } from './TransactionPayController-method-action-types.js';\n\nexport type AllowedActions =\n | AccountsControllerGetStateAction\n | AssetsControllerGetStateAction\n | GetGasFeeState\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | RampsControllerGetOrderAction\n | RampsControllerGetQuoteWithFeesAction\n | RemoteFeatureFlagControllerGetStateAction\n | SentinelApiServiceActions\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | AssetsControllerStateChangeEvent\n | KeyringControllerUnlockEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction (or `paymentOverride` batch) is executed\n * atomically with the Relay quote. Defaults to `true` (embedded in the quote\n * and executed by the Relay solver). When `false`, Pay does not embed the\n * target/override calls in the quote; the quote only bridges the required\n * asset to `recipient`, and the calls are submitted separately after Relay\n * completion. Used by flows whose second-leg amount is only known after\n * Relay settles (EXACT_INPUT max flows) or that require the second leg to\n * originate from a different signer than the Relay solver.\n * For max deposits enabled by `payStrategies.relay.atomicMaxEnabled`, this\n * is a subsidy hint: atomic quotes are retried non-atomically if not\n * subsidized, and subsidized non-atomic quotes are upgraded to atomic.\n */\n atomic?: boolean;\n\n /**\n * Whether the source of funds is HyperLiquid (HyperCore).\n * When true, the Relay strategy uses the HyperLiquid 2-step withdrawal\n * flow: (1) authorize nonce-mapping, (2) sendAsset to Relay solver.\n */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n */\n isPostQuote?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request. Use this for post-quote flows where the user's funds originate\n * from a smart contract account (e.g. Predict Safe proxy) so that refunds\n * go back to that account rather than the EOA.\n */\n refundTo?: Hex;\n};\n\n/** Callback to update transaction config. */\nexport type TransactionConfigCallback = (config: TransactionConfig) => void;\n\n/** Request passed to {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataRequest = {\n /** Amount of the source token in human-readable format. */\n amount: string;\n\n /** Metadata of the original transaction. */\n transaction: TransactionMeta;\n\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Response returned by {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataResponse = {\n /** Batch transaction params to prepend to the submit batch. */\n calls: BatchTransactionParams[];\n\n /** Optional recipient address for the funding token transfer. */\n recipient?: Hex;\n\n /** Optional EIP-7702 authorization list from delegation. */\n authorizationList?: AuthorizationList;\n};\n\n/**\n * Callback invoked during submit when `paymentOverride` is defined.\n * Returns batch transaction params to prepend to the submit batch.\n */\nexport type GetPaymentOverrideDataCallback = (\n request: GetPaymentOverrideDataRequest,\n) => Promise<GetPaymentOverrideDataResponse>;\n\nexport type GetAmountDataRequest = {\n /** Raw token amount (atomic units) to encode into calldata. */\n amount: string;\n\n /** Metadata of the transaction whose nested calls need updating. */\n transaction: TransactionMeta;\n};\n\nexport type GetAmountDataResponse = {\n /** Per-nested-call data updates; empty when no update is needed. */\n updates: { nestedTransactionIndex: number; data: Hex }[];\n};\n\n/**\n * Optional callback that re-encodes nested transaction calldata for a given\n * token amount. Used by transaction types with non-standard nested data\n * (e.g. vault approve + deposit) that cannot be derived from the amount alone\n * without client-side context (vault config, RPC providers, etc.).\n */\nexport type GetAmountDataCallback = (\n request: GetAmountDataRequest,\n) => Promise<GetAmountDataResponse>;\n\n/** Request passed to {@link GetBalanceCallback}. */\nexport type GetBalanceRequest = {\n /** Metadata of the transaction whose source balance is being resolved. */\n transaction: TransactionMeta;\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Balance override returned by {@link GetBalanceCallback}. */\nexport type GetBalanceResponse = {\n /** Balance in atomic format without factoring token decimals. */\n balanceRaw: string;\n};\n\n/**\n * Optional client-supplied callback that overrides the built-in\n * pay-token / required-token balance lookup used for `isMaxAmount`\n * source-amount calculation. Enables alternate balance sources\n * (perps, predict, money-account, post-quote, etc.) without adding\n * conditional branches inside the controller. MUST be synchronous:\n * it runs inside the controller state-update block.\n * Return `undefined` to fall back to the built-in token balance.\n */\nexport type GetBalanceCallback = (\n request: GetBalanceRequest,\n) => GetBalanceResponse | undefined;\n\n/** Callback to update fiat payment state. */\nexport type TransactionFiatPaymentCallback = (\n fiatPayment: TransactionFiatPayment,\n) => void;\n\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerMethodActions;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/**\n * Keyring types that support EIP-7702 authorization signing.\n * Hardware wallets, snap keyrings, and custody keyrings are excluded.\n */\nexport const KEYRING_TYPES_SUPPORTING_7702: `${KeyringTypes}`[] = [\n 'HD Key Tree',\n 'Simple Key Pair',\n 'Money Keyring',\n];\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /** Optional callback to re-encode nested transaction calldata for a given amount. */\n getAmountData?: GetAmountDataCallback;\n\n /** Optional callback to override the source balance used for max-amount calculation. */\n getBalance?: GetBalanceCallback;\n\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\n\n /** Optional fiat execution configuration. */\n fiatOptions?: TransactionPayFiatOptions;\n\n /**\n * Optional callback invoked during quote execution when `paymentOverride` is defined.\n * Returns additional transactions to be submitted alongside the quote batch.\n */\n getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n /** Callback to select the PayStrategy for a transaction. */\n getStrategy?: (transaction: TransactionMeta) => TransactionPayStrategy;\n\n /** Callback to select ordered PayStrategies for a transaction. */\n getStrategies?: (transaction: TransactionMeta) => TransactionPayStrategy[];\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Callbacks for the Polymarket relayer; required only for the Polymarket deposit-wallet flow. */\n polymarket?: PolymarketCallbacks;\n\n /** Initial state of the controller. */\n state?: Partial<TransactionPayControllerState>;\n};\n\n/** State of the TransactionPayController. */\nexport type TransactionPayControllerState = {\n /** State relating to each transaction, keyed by transaction ID. */\n transactionData: Record<string, TransactionData>;\n};\n\n/** Optional fiat execution configuration. */\nexport type TransactionPayFiatOptions = {\n /** Test funding source used to bypass fiat on-ramp execution during local QA. */\n testFundingSource?: Hex;\n\n /** Optional human amount to transfer from the test funding source. */\n testAmountOverride?: string;\n};\n\n/** State relating to a single transaction. */\nexport type TransactionData = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Fiat payment method state. */\n fiatPayment?: TransactionFiatPayment;\n\n /** Whether quotes are currently being retrieved. */\n isLoading: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n * Used when funds need to be moved after a transaction completes\n * (e.g., bridging output to a different token/chain).\n */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /**\n * Token selected for the transaction.\n * - For standard flows (isPostQuote=false): This is the SOURCE/payment token\n * - For post-quote flows (isPostQuote=true): This is the DESTINATION token\n */\n paymentToken?: TransactionPaymentToken;\n\n /** Quotes retrieved for the transaction. */\n quotes?: TransactionPayQuote<Json>[];\n\n /** Most relevant structured validation error from the latest quote attempt. */\n quoteError?: QuoteErrorInfo;\n\n /** Timestamp of when quotes were last updated. */\n quotesLastUpdated?: number;\n\n /** Amounts of payment token required for each required token. */\n sourceAmounts?: TransactionPaySourceAmount[];\n\n /** Tokens required by the transaction. */\n tokens: TransactionPayRequiredToken[];\n\n /** Calculated totals for the transaction. */\n totals?: TransactionPayTotals;\n};\n\n/** Fiat payment state stored per transaction. */\nexport type TransactionFiatPayment = {\n /** Entered fiat amount for the selected payment method. */\n amountFiat?: string;\n\n /** CAIP-19 asset id derived from the transaction type for the fiat on-ramp. */\n caipAssetId?: string;\n\n /** Order identifier in normalized format (/providers/{provider}/orders/{id}). */\n orderId?: string;\n\n /** The ramps quote received from the ramps provider. */\n rampsQuote?: RampsQuote;\n\n /** Selected fiat payment method ID. */\n selectedPaymentMethodId?: string;\n};\n\n/** A token required by a transaction. */\nexport type TransactionPayRequiredToken = {\n /** Address of the required token. */\n address: Hex;\n\n /** Whether to allow quotes that return less than the minimum amount requested. */\n allowUnderMinimum: boolean;\n\n /** Amount required in the selected currency. */\n amountFiat: string;\n\n /** Amount required in a human-readable format factoring token decimals. */\n amountHuman: string;\n\n /** Amount required in atomic format without factoring token decimals. */\n amountRaw: string;\n\n /** Amount required in USD. */\n amountUsd: string;\n\n /** Balance of the required token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the required token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the required token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the required token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the required token. */\n chainId: Hex;\n\n /** Decimals of the required token. */\n decimals: number;\n\n /** Whether to skip transfer of this token if balance is already sufficient. */\n skipIfBalance: boolean;\n\n /** Symbol of the required token. */\n symbol: string;\n};\n\n/** Amount of payment token required by a required token. */\nexport type TransactionPaySourceAmount = {\n /** Amount of payment token required in the selected currency. */\n sourceAmountHuman: string;\n\n /** Amount of payment token required in atomic format without factoring token decimals. */\n sourceAmountRaw: string;\n\n /** Balance of the source token in atomic format (for post-quote flows). */\n sourceBalanceRaw?: string;\n\n /** Chain ID of the source token (for post-quote flows). */\n sourceChainId?: Hex;\n\n /** Address of the source token (for post-quote flows). */\n sourceTokenAddress?: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n};\n\n/**\n * Machine-readable discriminator for a quote validation failure.\n *\n * Used for analytics and tests. Human-readable copy is carried by `message`\n * and `detail` on {@link QuoteErrorInfo}.\n */\nexport type QuoteErrorReason =\n | 'balance-unavailable'\n | 'insufficient-source-balance'\n | 'insufficient-transfer-balance'\n | 'no-quotes'\n | 'simulation-failed';\n\n/**\n * Structured description of why a quote failed validation.\n *\n * `message` and `detail` are formatted (English) copy ready to display; `reason`\n * is a machine-readable discriminator for analytics and tests.\n */\nexport type QuoteErrorInfo = {\n /** Short, display-ready summary of the failure. */\n message: string;\n\n /** Machine-readable discriminator for the failure. */\n reason: QuoteErrorReason;\n\n /** Optional display-ready detail rows (e.g. Required / Current / Missing). */\n detail?: string[];\n};\n\n/** Source token used to pay for required tokens. */\nexport type TransactionPaymentToken = {\n /** Address of the payment token. */\n address: Hex;\n\n /** Balance of the payment token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the payment token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the payment token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the payment token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the payment token. */\n chainId: Hex;\n\n /** Decimals of the payment token. */\n decimals: number;\n\n /** Symbol of the payment token. */\n symbol: string;\n};\n\n/** Callback to update state for a single transaction. */\nexport type UpdateTransactionDataCallback = (\n /** ID of the transaction to update. */\n transactionId: string,\n /** Function that receives a draft of the transaction data to update. */\n fn: (data: Draft<TransactionData>) => void,\n) => void;\n\n/** Conversion rates from the native currency to other currencies. */\nexport type FiatRates = {\n /** Conversion rate for the native currency to the selected fiat currency. */\n fiatRate: string;\n\n /** Conversion rate for the native currency to USD. */\n usdRate: string;\n};\n\n/** Request for a quote to retrieve a required token. */\nexport type QuoteRequest = {\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Address of the user's account. */\n from: Hex;\n\n /** Whether the transaction is a maximum amount transaction. */\n isMaxAmount?: boolean;\n\n /** Whether this is a post-quote flow. */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether this quote is the direct mUSD-to-Money-Account fiat flow. */\n isDirectMusdMoneyAccount?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** Optional recipient address for Relay requests. When set, overrides the default `from` address. */\n recipient?: Hex;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /** Whether to skip processTransactions in relay-quotes. Defaults to `isPostQuote`. */\n skipProcessTransactions?: boolean;\n\n /** Balance of the source token in atomic format without factoring token decimals. */\n sourceBalanceRaw: string;\n\n /** Chain ID of the source token. */\n sourceChainId: Hex;\n\n /** Address of the source token. */\n sourceTokenAddress: Hex;\n\n /** Amount of the required token in atomic format without factoring token decimals. */\n sourceTokenAmount: string;\n\n /** Minimum amount required of the target token in atomic format without factoring token decimals. */\n targetAmountMinimum: string;\n\n /** Chain ID of the target token. */\n targetChainId: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n\n /**\n * One-time HyperLiquid activation fee (USD) reserved from the source amount\n * for an unactivated HyperCore account. The source amount sent to the\n * provider is reduced by this amount so HyperLiquid retains enough balance\n * for the fee, and the amount is surfaced as part of the provider fee.\n */\n hyperliquidActivationFeeUsd?: string;\n};\n\n/** Fees associated with a transaction pay quote. */\nexport type TransactionPayFees = {\n /** Whether a gas fee token is used to pay source network fees. */\n isSourceGasFeeToken?: boolean;\n\n /** Whether a gas fee token is used to pay target network fees. */\n isTargetGasFeeToken?: boolean;\n\n /** Fee charged by MetaMask. */\n metaMask: FiatValue;\n\n /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Fee charged by fiat on-ramp provider (breakdown of the provider total). */\n providerFiat?: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: {\n estimate: Amount;\n max: Amount;\n };\n\n /** Network fee for transactions on the target network. */\n targetNetwork: FiatValue;\n};\n\n/** Quote returned to retrieve a required token using the payment token. */\nexport type TransactionPayQuote<OriginalQuote> = {\n /** Additional amount provided by the quote beyond the minimum requested. */\n dust: FiatValue;\n\n /** Duration estimated for the transaction to complete in seconds. */\n estimatedDuration: number;\n\n /** Fees associated with the transaction pay quote. */\n fees: TransactionPayFees;\n\n /** Whether fees are subtracted from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Whether the reported fees are already included in the source amount. */\n areFeesIncludedInSourceAmount?: boolean;\n\n /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\n\n /**\n * Whether the target calls could not be embedded in the quote and must be\n * submitted separately, on the target chain, once the quote settles.\n *\n * Set by the strategy at quote time, since only it knows whether the provider\n * accepted the calls. {@link TransactionConfig.atomic} is a hint rather than\n * a guarantee: a quote requested atomically still falls back to a second leg\n * when the provider cannot execute the calls itself.\n */\n requiresSecondLeg?: boolean;\n\n /** Amount of source token required. */\n sourceAmount: Amount;\n\n /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\n\n /** Amount of target token provided. */\n targetAmount: FiatValue;\n};\n\n/** Request to get quotes for a transaction. */\nexport type PayStrategyGetQuotesRequest = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Selected fiat payment method ID, if applicable. */\n fiatPaymentMethod?: string;\n\n /**\n * Resolved wallet address for the transaction.\n * This is `accountOverride ?? txParams.from`, pre-computed by the quote\n * orchestrator so that individual strategies do not need to re-derive it.\n */\n from: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\n\n /**\n * Signal that aborts when a newer quote request supersedes this one.\n * Strategies that perform their own network IO should forward this to\n * their fetch calls so cancelled requests release network resources.\n */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to submit quotes for a transaction. */\nexport type PayStrategyExecuteRequest<OriginalRequest> = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Callback to determine if the transaction is a smart transaction. */\n isSmartTransaction: (chainId: Hex) => boolean;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes to be submitted. */\n quotes: TransactionPayQuote<OriginalRequest>[];\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get batch transactions for quotes. */\nexport type PayStrategyGetBatchRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes for required tokens. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n};\n\n/** Request to check whether retrieved quotes can be executed by a strategy. */\nexport type PayStrategyCheckQuoteSupportRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes returned by the strategy. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get refresh interval for a specific strategy. */\nexport type PayStrategyGetRefreshIntervalRequest = {\n /** Chain ID of the source or payment token. */\n chainId: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n};\n\n/** Strategy used to obtain required tokens for a transaction. */\nexport type PayStrategy<OriginalQuote> = {\n /**\n * Check if the strategy supports the given request.\n * Defaults to true if not implemented.\n */\n supports?: (\n request: PayStrategyGetQuotesRequest,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\n\n /**\n * Check if the returned quotes are supported after provider quote\n * construction and gas planning.\n *\n * Use this for limitations that are only knowable once quote metadata is\n * available, such as whether execution will require an EIP-7702\n * authorization list.\n */\n checkQuoteSupport?: (\n request: PayStrategyCheckQuoteSupportRequest<OriginalQuote>,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve batch transactions for quotes, if supported by the strategy. */\n getBatchTransactions?: (\n request: PayStrategyGetBatchRequest<OriginalQuote>,\n ) => Promise<BatchTransaction[]>;\n\n /**\n * Retrieve refresh interval for the strategy, if applicable.\n * Defaults to 30 seconds.\n */\n getRefreshInterval?: (\n request: PayStrategyGetRefreshIntervalRequest,\n ) => Promise<number | undefined>;\n\n /** Execute or submit the quotes to obtain required tokens. */\n execute: (request: PayStrategyExecuteRequest<OriginalQuote>) => Promise<{\n transactionHash?: Hex;\n }>;\n};\n\n/** Single fiat value in alternate currencies. */\nexport type FiatValue = {\n /** Value in the selected fiat currency. */\n fiat: string;\n\n /** Value in USD. */\n usd: string;\n};\n\n/** Calculated totals for a target transaction and all quotes. */\nexport type TransactionPayTotals = {\n /** Total estimated duration for the target transaction and all quotes. */\n estimatedDuration: number;\n\n /** Total fees for the target transaction and all quotes. */\n fees: TransactionPayFees;\n\n /** Whether the selected quotes subtract fees from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Total amount of source token required. */\n sourceAmount: Amount;\n\n /** Total amount of target token provided. */\n targetAmount: FiatValue;\n\n /** Overall total cost for the target transaction and all quotes. */\n total: FiatValue;\n};\n\n/** Request to update the payment token for a transaction. */\nexport type UpdatePaymentTokenRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Address of the new payment token. */\n tokenAddress: Hex;\n\n /** Chain ID of the new payment token. */\n chainId: Hex;\n};\n\n/** Request to update fiat payment state for a transaction. */\nexport type UpdateFiatPaymentRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Callback to mutate fiat payment state. */\n callback: TransactionFiatPaymentCallback;\n};\n\n/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n isSubsidized,\n}: {\n transaction: TransactionMeta;\n isSubsidized?: boolean;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: Hex;\n}>;\n\n/** Client-supplied callbacks for the Polymarket relayer protocol. */\nexport type PolymarketCallbacks = {\n /** Derive the deposit-wallet address (CREATE2) for the given EOA. */\n getDepositWalletAddress: (params: { eoa: Hex }) => Promise<Hex>;\n\n /** Sign and broadcast a deposit-wallet batch, returning the source hash. */\n submitDepositWalletBatch: (params: {\n eoa: Hex;\n depositWallet: Hex;\n calls: { target: Hex; data: Hex; value: string }[];\n }) => Promise<{ sourceHash: Hex }>;\n};\n\n/** Single amount in alternate formats. */\nexport type Amount = FiatValue & {\n /** Amount in human-readable format factoring token decimals. */\n human: string;\n\n /** Amount in atomic format without factoring token decimals. */\n raw: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA8PA;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB;IAChE,aAAa;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC","sourcesContent":["import type { AccountsControllerGetStateAction } from '@metamask/accounts-controller';\nimport type {\n AssetsControllerGetStateAction,\n AssetsControllerStateChangeEvent,\n} from '@metamask/assets-controller';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n KeyringControllerUnlockEvent,\n KeyringTypes,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkConfigurationByChainIdAction } from '@metamask/network-controller';\nimport type { Quote as RampsQuote } from '@metamask/ramps-controller';\nimport type {\n RampsControllerGetOrderAction,\n RampsControllerGetQuoteWithFeesAction,\n} from '@metamask/ramps-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SentinelApiServiceActions } from '@metamask/sentinel-api-service';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\n BatchTransactionParams,\n TransactionControllerAddTransactionAction,\n TransactionControllerGetGasFeeTokensAction,\n TransactionControllerGetStateAction,\n TransactionControllerStateChangeEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Draft } from 'immer';\n\nimport type {\n CONTROLLER_NAME,\n PaymentOverride,\n TransactionPayClientId,\n TransactionPayStrategy,\n} from './constants.js';\nimport type { TransactionPayControllerMethodActions } from './TransactionPayController-method-action-types.js';\n\nexport type AllowedActions =\n | AccountsControllerGetStateAction\n | AssetsControllerGetStateAction\n | GetGasFeeState\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | RampsControllerGetOrderAction\n | RampsControllerGetQuoteWithFeesAction\n | RemoteFeatureFlagControllerGetStateAction\n | SentinelApiServiceActions\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | AssetsControllerStateChangeEvent\n | KeyringControllerUnlockEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction (or `paymentOverride` batch) is executed\n * atomically with the Relay quote. Defaults to `true` (embedded in the quote\n * and executed by the Relay solver). When `false`, Pay does not embed the\n * target/override calls in the quote; the quote only bridges the required\n * asset to `recipient`, and the calls are submitted separately after Relay\n * completion. Used by flows whose second-leg amount is only known after\n * Relay settles (EXACT_INPUT max flows) or that require the second leg to\n * originate from a different signer than the Relay solver.\n * For max deposits enabled by `payStrategies.relay.atomicMaxEnabled`, this\n * is a subsidy hint: atomic quotes are retried non-atomically if not\n * subsidized, and subsidized non-atomic quotes are upgraded to atomic.\n */\n atomic?: boolean;\n\n /**\n * Whether the source of funds is HyperLiquid (HyperCore).\n * When true, the Relay strategy uses the HyperLiquid 2-step withdrawal\n * flow: (1) authorize nonce-mapping, (2) sendAsset to Relay solver.\n */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n */\n isPostQuote?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request. Use this for post-quote flows where the user's funds originate\n * from a smart contract account (e.g. Predict Safe proxy) so that refunds\n * go back to that account rather than the EOA.\n */\n refundTo?: Hex;\n};\n\n/** Callback to update transaction config. */\nexport type TransactionConfigCallback = (config: TransactionConfig) => void;\n\n/** Request passed to {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataRequest = {\n /** Amount of the source token in human-readable format. */\n amount: string;\n\n /** Metadata of the original transaction. */\n transaction: TransactionMeta;\n\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Response returned by {@link GetPaymentOverrideDataCallback}. */\nexport type GetPaymentOverrideDataResponse = {\n /** Batch transaction params to prepend to the submit batch. */\n calls: BatchTransactionParams[];\n\n /** Optional recipient address for the funding token transfer. */\n recipient?: Hex;\n\n /** Optional EIP-7702 authorization list from delegation. */\n authorizationList?: AuthorizationList;\n};\n\n/**\n * Callback invoked during submit when `paymentOverride` is defined.\n * Returns batch transaction params to prepend to the submit batch.\n */\nexport type GetPaymentOverrideDataCallback = (\n request: GetPaymentOverrideDataRequest,\n) => Promise<GetPaymentOverrideDataResponse>;\n\nexport type GetAmountDataRequest = {\n /** Raw token amount (atomic units) to encode into calldata. */\n amount: string;\n\n /** Metadata of the transaction whose nested calls need updating. */\n transaction: TransactionMeta;\n};\n\nexport type GetAmountDataResponse = {\n /** Per-nested-call data updates; empty when no update is needed. */\n updates: { nestedTransactionIndex: number; data: Hex }[];\n};\n\n/**\n * Optional callback that re-encodes nested transaction calldata for a given\n * token amount. Used by transaction types with non-standard nested data\n * (e.g. vault approve + deposit) that cannot be derived from the amount alone\n * without client-side context (vault config, RPC providers, etc.).\n */\nexport type GetAmountDataCallback = (\n request: GetAmountDataRequest,\n) => Promise<GetAmountDataResponse>;\n\n/** Request passed to {@link GetBalanceCallback}. */\nexport type GetBalanceRequest = {\n /** Metadata of the transaction whose source balance is being resolved. */\n transaction: TransactionMeta;\n /** Pay-controller state for the transaction. */\n transactionData: TransactionData;\n};\n\n/** Balance override returned by {@link GetBalanceCallback}. */\nexport type GetBalanceResponse = {\n /** Balance in atomic format without factoring token decimals. */\n balanceRaw: string;\n};\n\n/**\n * Optional client-supplied callback that overrides the built-in\n * pay-token / required-token balance lookup used for `isMaxAmount`\n * source-amount calculation. Enables alternate balance sources\n * (perps, predict, money-account, post-quote, etc.) without adding\n * conditional branches inside the controller. MUST be synchronous:\n * it runs inside the controller state-update block.\n * Return `undefined` to fall back to the built-in token balance.\n */\nexport type GetBalanceCallback = (\n request: GetBalanceRequest,\n) => GetBalanceResponse | undefined;\n\n/** Callback to update fiat payment state. */\nexport type TransactionFiatPaymentCallback = (\n fiatPayment: TransactionFiatPayment,\n) => void;\n\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerMethodActions;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/**\n * Keyring types that support EIP-7702 authorization signing.\n * Hardware wallets, snap keyrings, and custody keyrings are excluded.\n */\nexport const KEYRING_TYPES_SUPPORTING_7702: `${KeyringTypes}`[] = [\n 'HD Key Tree',\n 'Simple Key Pair',\n 'Money Keyring',\n];\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /**\n * Identifies the MetaMask client, sent as the `X-Client-Id` header on\n * requests to the intents API so the server can distinguish Mobile from\n * Extension traffic.\n */\n clientId?: TransactionPayClientId;\n\n /** Optional callback to re-encode nested transaction calldata for a given amount. */\n getAmountData?: GetAmountDataCallback;\n\n /** Optional callback to override the source balance used for max-amount calculation. */\n getBalance?: GetBalanceCallback;\n\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\n\n /** Optional fiat execution configuration. */\n fiatOptions?: TransactionPayFiatOptions;\n\n /**\n * Optional callback invoked during quote execution when `paymentOverride` is defined.\n * Returns additional transactions to be submitted alongside the quote batch.\n */\n getPaymentOverrideData?: GetPaymentOverrideDataCallback;\n\n /** Callback to select the PayStrategy for a transaction. */\n getStrategy?: (transaction: TransactionMeta) => TransactionPayStrategy;\n\n /** Callback to select ordered PayStrategies for a transaction. */\n getStrategies?: (transaction: TransactionMeta) => TransactionPayStrategy[];\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Callbacks for the Polymarket relayer; required only for the Polymarket deposit-wallet flow. */\n polymarket?: PolymarketCallbacks;\n\n /** Initial state of the controller. */\n state?: Partial<TransactionPayControllerState>;\n};\n\n/** State of the TransactionPayController. */\nexport type TransactionPayControllerState = {\n /** State relating to each transaction, keyed by transaction ID. */\n transactionData: Record<string, TransactionData>;\n};\n\n/** Optional fiat execution configuration. */\nexport type TransactionPayFiatOptions = {\n /** Test funding source used to bypass fiat on-ramp execution during local QA. */\n testFundingSource?: Hex;\n\n /** Optional human amount to transfer from the test funding source. */\n testAmountOverride?: string;\n};\n\n/** State relating to a single transaction. */\nexport type TransactionData = {\n /**\n * Optional address to override the default account used by the transaction.\n * When `isPostQuote` is true, used as the recipient of the MM Pay transfer.\n * When `isPostQuote` is false, it provides the funds and pays for gas.\n */\n accountOverride?: Hex;\n\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Fiat payment method state. */\n fiatPayment?: TransactionFiatPayment;\n\n /** Whether quotes are currently being retrieved. */\n isLoading: boolean;\n\n /** Whether the user has selected the maximum amount. */\n isMaxAmount?: boolean;\n\n /**\n * Whether this is a post-quote transaction.\n * When true, the paymentToken represents the destination token,\n * and the quote source is derived from the transaction's output token.\n * Used when funds need to be moved after a transaction completes\n * (e.g., bridging output to a different token/chain).\n */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** When true, a quote is always fetched even when the source and target tokens are identical. */\n isQuoteRequired?: boolean;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /**\n * Token selected for the transaction.\n * - For standard flows (isPostQuote=false): This is the SOURCE/payment token\n * - For post-quote flows (isPostQuote=true): This is the DESTINATION token\n */\n paymentToken?: TransactionPaymentToken;\n\n /** Quotes retrieved for the transaction. */\n quotes?: TransactionPayQuote<Json>[];\n\n /** Most relevant structured validation error from the latest quote attempt. */\n quoteError?: QuoteErrorInfo;\n\n /** Timestamp of when quotes were last updated. */\n quotesLastUpdated?: number;\n\n /** Amounts of payment token required for each required token. */\n sourceAmounts?: TransactionPaySourceAmount[];\n\n /** Tokens required by the transaction. */\n tokens: TransactionPayRequiredToken[];\n\n /** Calculated totals for the transaction. */\n totals?: TransactionPayTotals;\n};\n\n/** Fiat payment state stored per transaction. */\nexport type TransactionFiatPayment = {\n /** Entered fiat amount for the selected payment method. */\n amountFiat?: string;\n\n /** CAIP-19 asset id derived from the transaction type for the fiat on-ramp. */\n caipAssetId?: string;\n\n /** Order identifier in normalized format (/providers/{provider}/orders/{id}). */\n orderId?: string;\n\n /** The ramps quote received from the ramps provider. */\n rampsQuote?: RampsQuote;\n\n /** Selected fiat payment method ID. */\n selectedPaymentMethodId?: string;\n};\n\n/** A token required by a transaction. */\nexport type TransactionPayRequiredToken = {\n /** Address of the required token. */\n address: Hex;\n\n /** Whether to allow quotes that return less than the minimum amount requested. */\n allowUnderMinimum: boolean;\n\n /** Amount required in the selected currency. */\n amountFiat: string;\n\n /** Amount required in a human-readable format factoring token decimals. */\n amountHuman: string;\n\n /** Amount required in atomic format without factoring token decimals. */\n amountRaw: string;\n\n /** Amount required in USD. */\n amountUsd: string;\n\n /** Balance of the required token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the required token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the required token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the required token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the required token. */\n chainId: Hex;\n\n /** Decimals of the required token. */\n decimals: number;\n\n /** Whether to skip transfer of this token if balance is already sufficient. */\n skipIfBalance: boolean;\n\n /** Symbol of the required token. */\n symbol: string;\n};\n\n/** Amount of payment token required by a required token. */\nexport type TransactionPaySourceAmount = {\n /** Amount of payment token required in the selected currency. */\n sourceAmountHuman: string;\n\n /** Amount of payment token required in atomic format without factoring token decimals. */\n sourceAmountRaw: string;\n\n /** Balance of the source token in atomic format (for post-quote flows). */\n sourceBalanceRaw?: string;\n\n /** Chain ID of the source token (for post-quote flows). */\n sourceChainId?: Hex;\n\n /** Address of the source token (for post-quote flows). */\n sourceTokenAddress?: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n};\n\n/**\n * Machine-readable discriminator for a quote validation failure.\n *\n * Used for analytics and tests. Human-readable copy is carried by `message`\n * and `detail` on {@link QuoteErrorInfo}.\n */\nexport type QuoteErrorReason =\n | 'balance-unavailable'\n | 'insufficient-source-balance'\n | 'insufficient-transfer-balance'\n | 'no-quotes'\n | 'simulation-failed';\n\n/**\n * Structured description of why a quote failed validation.\n *\n * `message` and `detail` are formatted (English) copy ready to display; `reason`\n * is a machine-readable discriminator for analytics and tests.\n */\nexport type QuoteErrorInfo = {\n /** Short, display-ready summary of the failure. */\n message: string;\n\n /** Machine-readable discriminator for the failure. */\n reason: QuoteErrorReason;\n\n /** Optional display-ready detail rows (e.g. Required / Current / Missing). */\n detail?: string[];\n};\n\n/** Source token used to pay for required tokens. */\nexport type TransactionPaymentToken = {\n /** Address of the payment token. */\n address: Hex;\n\n /** Balance of the payment token in the selected currency. */\n balanceFiat: string;\n\n /** Balance of the payment token in a human-readable format factoring token decimals. */\n balanceHuman: string;\n\n /** Balance of the payment token in atomic format without factoring token decimals. */\n balanceRaw: string;\n\n /** Balance of the payment token in USD. */\n balanceUsd: string;\n\n /** Chain ID of the payment token. */\n chainId: Hex;\n\n /** Decimals of the payment token. */\n decimals: number;\n\n /** Symbol of the payment token. */\n symbol: string;\n};\n\n/** Callback to update state for a single transaction. */\nexport type UpdateTransactionDataCallback = (\n /** ID of the transaction to update. */\n transactionId: string,\n /** Function that receives a draft of the transaction data to update. */\n fn: (data: Draft<TransactionData>) => void,\n) => void;\n\n/** Conversion rates from the native currency to other currencies. */\nexport type FiatRates = {\n /** Conversion rate for the native currency to the selected fiat currency. */\n fiatRate: string;\n\n /** Conversion rate for the native currency to USD. */\n usdRate: string;\n};\n\n/** Request for a quote to retrieve a required token. */\nexport type QuoteRequest = {\n /**\n * Whether the target transaction is executed atomically with the Relay\n * quote. See {@link TransactionConfig.atomic}.\n */\n atomic?: boolean;\n\n /** Address of the user's account. */\n from: Hex;\n\n /** Whether the transaction is a maximum amount transaction. */\n isMaxAmount?: boolean;\n\n /** Whether this is a post-quote flow. */\n isPostQuote?: boolean;\n\n /** Whether the source of funds is HyperLiquid (HyperCore). */\n isHyperliquidSource?: boolean;\n\n /** Whether the source of funds is a Polymarket deposit wallet. */\n isPolymarketDepositWallet?: boolean;\n\n /** Whether this quote is the direct mUSD-to-Money-Account fiat flow. */\n isDirectMusdMoneyAccount?: boolean;\n\n /** Overrides the payment source for the transaction. */\n paymentOverride?: PaymentOverride;\n\n /** Optional recipient address for Relay requests. When set, overrides the default `from` address. */\n recipient?: Hex;\n\n /**\n * Optional address to receive refunds if the quote provider transaction fails.\n * When set, overrides the default refund recipient (EOA) in the quote\n * request.\n */\n refundTo?: Hex;\n\n /** Whether to skip processTransactions in relay-quotes. Defaults to `isPostQuote`. */\n skipProcessTransactions?: boolean;\n\n /** Balance of the source token in atomic format without factoring token decimals. */\n sourceBalanceRaw: string;\n\n /** Chain ID of the source token. */\n sourceChainId: Hex;\n\n /** Address of the source token. */\n sourceTokenAddress: Hex;\n\n /** Amount of the required token in atomic format without factoring token decimals. */\n sourceTokenAmount: string;\n\n /** Minimum amount required of the target token in atomic format without factoring token decimals. */\n targetAmountMinimum: string;\n\n /** Chain ID of the target token. */\n targetChainId: Hex;\n\n /** Address of the target token. */\n targetTokenAddress: Hex;\n\n /**\n * One-time HyperLiquid activation fee (USD) reserved from the source amount\n * for an unactivated HyperCore account. The source amount sent to the\n * provider is reduced by this amount so HyperLiquid retains enough balance\n * for the fee, and the amount is surfaced as part of the provider fee.\n */\n hyperliquidActivationFeeUsd?: string;\n};\n\n/** Fees associated with a transaction pay quote. */\nexport type TransactionPayFees = {\n /** Whether a gas fee token is used to pay source network fees. */\n isSourceGasFeeToken?: boolean;\n\n /** Whether a gas fee token is used to pay target network fees. */\n isTargetGasFeeToken?: boolean;\n\n /** Fee charged by MetaMask. */\n metaMask: FiatValue;\n\n /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Fee charged by fiat on-ramp provider (breakdown of the provider total). */\n providerFiat?: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: {\n estimate: Amount;\n max: Amount;\n };\n\n /** Network fee for transactions on the target network. */\n targetNetwork: FiatValue;\n};\n\n/** Quote returned to retrieve a required token using the payment token. */\nexport type TransactionPayQuote<OriginalQuote> = {\n /** Additional amount provided by the quote beyond the minimum requested. */\n dust: FiatValue;\n\n /** Duration estimated for the transaction to complete in seconds. */\n estimatedDuration: number;\n\n /** Fees associated with the transaction pay quote. */\n fees: TransactionPayFees;\n\n /** Whether fees are subtracted from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Whether the reported fees are already included in the source amount. */\n areFeesIncludedInSourceAmount?: boolean;\n\n /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\n\n /**\n * Whether the target calls could not be embedded in the quote and must be\n * submitted separately, on the target chain, once the quote settles.\n *\n * Set by the strategy at quote time, since only it knows whether the provider\n * accepted the calls. {@link TransactionConfig.atomic} is a hint rather than\n * a guarantee: a quote requested atomically still falls back to a second leg\n * when the provider cannot execute the calls itself.\n */\n requiresSecondLeg?: boolean;\n\n /** Amount of source token required. */\n sourceAmount: Amount;\n\n /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\n\n /** Amount of target token provided. */\n targetAmount: FiatValue;\n};\n\n/** Request to get quotes for a transaction. */\nexport type PayStrategyGetQuotesRequest = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Selected fiat payment method ID, if applicable. */\n fiatPaymentMethod?: string;\n\n /**\n * Resolved wallet address for the transaction.\n * This is `accountOverride ?? txParams.from`, pre-computed by the quote\n * orchestrator so that individual strategies do not need to re-derive it.\n */\n from: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\n\n /**\n * Signal that aborts when a newer quote request supersedes this one.\n * Strategies that perform their own network IO should forward this to\n * their fetch calls so cancelled requests release network resources.\n */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to submit quotes for a transaction. */\nexport type PayStrategyExecuteRequest<OriginalRequest> = {\n /** Whether the account supports EIP-7702 authorization signing. */\n accountSupports7702: boolean;\n\n /** Callback to determine if the transaction is a smart transaction. */\n isSmartTransaction: (chainId: Hex) => boolean;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes to be submitted. */\n quotes: TransactionPayQuote<OriginalRequest>[];\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get batch transactions for quotes. */\nexport type PayStrategyGetBatchRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes for required tokens. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n};\n\n/** Request to check whether retrieved quotes can be executed by a strategy. */\nexport type PayStrategyCheckQuoteSupportRequest<OriginalQuote> = {\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quotes returned by the strategy. */\n quotes: TransactionPayQuote<OriginalQuote>[];\n\n /** Signal that aborts when a newer quote request supersedes this one. */\n signal?: AbortSignal;\n\n /** Metadata of the original target transaction. */\n transaction: TransactionMeta;\n};\n\n/** Request to get refresh interval for a specific strategy. */\nexport type PayStrategyGetRefreshIntervalRequest = {\n /** Chain ID of the source or payment token. */\n chainId: Hex;\n\n /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n};\n\n/** Strategy used to obtain required tokens for a transaction. */\nexport type PayStrategy<OriginalQuote> = {\n /**\n * Check if the strategy supports the given request.\n * Defaults to true if not implemented.\n */\n supports?: (\n request: PayStrategyGetQuotesRequest,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\n\n /**\n * Check if the returned quotes are supported after provider quote\n * construction and gas planning.\n *\n * Use this for limitations that are only knowable once quote metadata is\n * available, such as whether execution will require an EIP-7702\n * authorization list.\n */\n checkQuoteSupport?: (\n request: PayStrategyCheckQuoteSupportRequest<OriginalQuote>,\n ) => boolean | Promise<boolean>;\n\n /** Retrieve batch transactions for quotes, if supported by the strategy. */\n getBatchTransactions?: (\n request: PayStrategyGetBatchRequest<OriginalQuote>,\n ) => Promise<BatchTransaction[]>;\n\n /**\n * Retrieve refresh interval for the strategy, if applicable.\n * Defaults to 30 seconds.\n */\n getRefreshInterval?: (\n request: PayStrategyGetRefreshIntervalRequest,\n ) => Promise<number | undefined>;\n\n /** Execute or submit the quotes to obtain required tokens. */\n execute: (request: PayStrategyExecuteRequest<OriginalQuote>) => Promise<{\n transactionHash?: Hex;\n }>;\n};\n\n/** Single fiat value in alternate currencies. */\nexport type FiatValue = {\n /** Value in the selected fiat currency. */\n fiat: string;\n\n /** Value in USD. */\n usd: string;\n};\n\n/** Calculated totals for a target transaction and all quotes. */\nexport type TransactionPayTotals = {\n /** Total estimated duration for the target transaction and all quotes. */\n estimatedDuration: number;\n\n /** Total fees for the target transaction and all quotes. */\n fees: TransactionPayFees;\n\n /** Whether the selected quotes subtract fees from the destination amount, meaning the input amount is static. */\n isInputBased?: boolean;\n\n /** Total amount of source token required. */\n sourceAmount: Amount;\n\n /** Total amount of target token provided. */\n targetAmount: FiatValue;\n\n /** Overall total cost for the target transaction and all quotes. */\n total: FiatValue;\n};\n\n/** Request to update the payment token for a transaction. */\nexport type UpdatePaymentTokenRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Address of the new payment token. */\n tokenAddress: Hex;\n\n /** Chain ID of the new payment token. */\n chainId: Hex;\n};\n\n/** Request to update fiat payment state for a transaction. */\nexport type UpdateFiatPaymentRequest = {\n /** ID of the transaction to update. */\n transactionId: string;\n\n /** Callback to mutate fiat payment state. */\n callback: TransactionFiatPaymentCallback;\n};\n\n/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n isSubsidized,\n}: {\n transaction: TransactionMeta;\n isSubsidized?: boolean;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: Hex;\n}>;\n\n/** Client-supplied callbacks for the Polymarket relayer protocol. */\nexport type PolymarketCallbacks = {\n /** Derive the deposit-wallet address (CREATE2) for the given EOA. */\n getDepositWalletAddress: (params: { eoa: Hex }) => Promise<Hex>;\n\n /** Sign and broadcast a deposit-wallet batch, returning the source hash. */\n submitDepositWalletBatch: (params: {\n eoa: Hex;\n depositWallet: Hex;\n calls: { target: Hex; data: Hex; value: string }[];\n }) => Promise<{ sourceHash: Hex }>;\n};\n\n/** Single amount in alternate formats. */\nexport type Amount = FiatValue & {\n /** Amount in human-readable format factoring token decimals. */\n human: string;\n\n /** Amount in atomic format without factoring token decimals. */\n raw: string;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/transaction-pay-controller",
|
|
3
|
-
"version": "30.3.3-preview-
|
|
3
|
+
"version": "30.3.3-preview-eb5c879",
|
|
4
4
|
"description": "Manages alternate payment strategies to provide required funds for transactions in MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|