@metamask-previews/transaction-pay-controller 16.3.0-preview-327d86601 → 16.4.0-preview-93bf4ab29
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 +6 -2
- package/dist/TransactionPayController.cjs +9 -0
- package/dist/TransactionPayController.cjs.map +1 -1
- package/dist/TransactionPayController.d.cts +2 -1
- package/dist/TransactionPayController.d.cts.map +1 -1
- package/dist/TransactionPayController.d.mts +2 -1
- package/dist/TransactionPayController.d.mts.map +1 -1
- package/dist/TransactionPayController.mjs +9 -0
- package/dist/TransactionPayController.mjs.map +1 -1
- package/dist/actions/update-fiat-payment.cjs +29 -0
- package/dist/actions/update-fiat-payment.cjs.map +1 -0
- package/dist/actions/update-fiat-payment.d.cts +14 -0
- package/dist/actions/update-fiat-payment.d.cts.map +1 -0
- package/dist/actions/update-fiat-payment.d.mts +14 -0
- package/dist/actions/update-fiat-payment.d.mts.map +1 -0
- package/dist/actions/update-fiat-payment.mjs +25 -0
- package/dist/actions/update-fiat-payment.mjs.map +1 -0
- package/dist/actions/update-payment-token.cjs +1 -0
- package/dist/actions/update-payment-token.cjs.map +1 -1
- package/dist/actions/update-payment-token.d.cts.map +1 -1
- package/dist/actions/update-payment-token.d.mts.map +1 -1
- package/dist/actions/update-payment-token.mjs +1 -0
- package/dist/actions/update-payment-token.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +24 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +24 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [16.4.0]
|
|
11
|
+
|
|
10
12
|
### Added
|
|
11
13
|
|
|
12
|
-
-
|
|
14
|
+
- Add a dedicated max-amount gas-station fallback flow for Relay quoting ([#7927](https://github.com/MetaMask/core/pull/7927))
|
|
13
15
|
- Add Across pay strategy support ([#7886](https://github.com/MetaMask/core/pull/7886))
|
|
16
|
+
- Add `fiatPayment` transaction state into `transactionData` and `updateFiatPayment` callback action ([#8093](https://github.com/MetaMask/core/pull/8093))
|
|
14
17
|
|
|
15
18
|
## [16.3.0]
|
|
16
19
|
|
|
@@ -481,7 +484,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
481
484
|
|
|
482
485
|
- Initial release ([#6820](https://github.com/MetaMask/core/pull/6820))
|
|
483
486
|
|
|
484
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.
|
|
487
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.4.0...HEAD
|
|
488
|
+
[16.4.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.3.0...@metamask/transaction-pay-controller@16.4.0
|
|
485
489
|
[16.3.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.2.0...@metamask/transaction-pay-controller@16.3.0
|
|
486
490
|
[16.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.1.2...@metamask/transaction-pay-controller@16.2.0
|
|
487
491
|
[16.1.2]: https://github.com/MetaMask/core/compare/@metamask/transaction-pay-controller@16.1.1...@metamask/transaction-pay-controller@16.1.2
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.TransactionPayController = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
17
|
const lodash_1 = require("lodash");
|
|
18
|
+
const update_fiat_payment_1 = require("./actions/update-fiat-payment.cjs");
|
|
18
19
|
const update_payment_token_1 = require("./actions/update-payment-token.cjs");
|
|
19
20
|
const constants_1 = require("./constants.cjs");
|
|
20
21
|
const QuoteRefresher_1 = require("./helpers/QuoteRefresher.cjs");
|
|
@@ -76,6 +77,12 @@ class TransactionPayController extends base_controller_1.BaseController {
|
|
|
76
77
|
updateTransactionData: __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_updateTransactionData).bind(this),
|
|
77
78
|
});
|
|
78
79
|
}
|
|
80
|
+
updateFiatPayment(request) {
|
|
81
|
+
(0, update_fiat_payment_1.updateFiatPayment)(request, {
|
|
82
|
+
messenger: this.messenger,
|
|
83
|
+
updateTransactionData: __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_updateTransactionData).bind(this),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
exports.TransactionPayController = TransactionPayController;
|
|
81
88
|
_TransactionPayController_getDelegationTransaction = new WeakMap(), _TransactionPayController_getStrategy = new WeakMap(), _TransactionPayController_getStrategies = new WeakMap(), _TransactionPayController_instances = new WeakSet(), _TransactionPayController_removeTransactionData = function _TransactionPayController_removeTransactionData(transactionId) {
|
|
@@ -93,6 +100,7 @@ _TransactionPayController_getDelegationTransaction = new WeakMap(), _Transaction
|
|
|
93
100
|
const originalIsPostQuote = current?.isPostQuote;
|
|
94
101
|
if (!current) {
|
|
95
102
|
transactionData[transactionId] = {
|
|
103
|
+
fiatPayment: {},
|
|
96
104
|
isLoading: false,
|
|
97
105
|
tokens: [],
|
|
98
106
|
};
|
|
@@ -127,6 +135,7 @@ _TransactionPayController_getDelegationTransaction = new WeakMap(), _Transaction
|
|
|
127
135
|
this.messenger.registerActionHandler('TransactionPayController:getStrategy', (transaction) => __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_getStrategiesWithFallback).call(this, transaction)[0]);
|
|
128
136
|
this.messenger.registerActionHandler('TransactionPayController:setTransactionConfig', this.setTransactionConfig.bind(this));
|
|
129
137
|
this.messenger.registerActionHandler('TransactionPayController:updatePaymentToken', this.updatePaymentToken.bind(this));
|
|
138
|
+
this.messenger.registerActionHandler('TransactionPayController:updateFiatPayment', this.updateFiatPayment.bind(this));
|
|
130
139
|
}, _TransactionPayController_getStrategiesWithFallback = function _TransactionPayController_getStrategiesWithFallback(transaction) {
|
|
131
140
|
const strategyCandidates = __classPrivateFieldGet(this, _TransactionPayController_getStrategies, "f")?.call(this, transaction) ??
|
|
132
141
|
(__classPrivateFieldGet(this, _TransactionPayController_getStrategy, "f") ? [__classPrivateFieldGet(this, _TransactionPayController_getStrategy, "f").call(this, transaction)] : []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.cjs","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+DAA2D;AAG3D,mCAA8B;AAE9B,6EAAoE;AACpE,+CAIqB;AACrB,iEAA0D;AAU1D,6DAAyD;AACzD,+CAA8C;AAC9C,+DAA6D;AAC7D,yDAA6D;AAE7D,MAAM,aAAa,GAAiD;IAClE,eAAe,EAAE;QACf,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAkC,EAAE,CAAC,CAAC;IAC5D,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,MAAa,wBAAyB,SAAQ,gCAI7C;IAWC,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GAC2B;QAChC,KAAK,CAAC;YACJ,IAAI,EAAE,2BAAe;YACrB,QAAQ,EAAE,aAAa;YACvB,SAAS;YACT,KAAK,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE,GAAG,KAAK,EAAE;SAC1C,CAAC,CAAC;;QAtB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AC,CACnC,CAAC;AACJ,CAAC,qHAGC,WAA4B;IAE5B,MAAM,kBAAkB,GACtB,uBAAA,IAAI,+CAAe,EAAE,KAArB,IAAI,EAAkB,WAAW,CAAC;QAClC,CAAC,uBAAA,IAAI,6CAAa,CAAC,CAAC,CAAC,CAAC,uBAAA,IAAI,6CAAa,MAAjB,IAAI,EAAc,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,IAAA,oCAAwB,EAAC,QAAQ,CAAC,CACrC,CAAC;IAEF,OAAO,eAAe,CAAC,MAAM;QAC3B,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,IAAA,gCAAgB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","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';\n\nimport { updatePaymentToken } from './actions/update-payment-token';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants';\nimport { QuoteRefresher } from './helpers/QuoteRefresher';\nimport type {\n GetDelegationTransactionCallback,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdatePaymentTokenRequest,\n} from './types';\nimport { getStrategyOrder } from './utils/feature-flags';\nimport { updateQuotes } from './utils/quotes';\nimport { updateSourceAmounts } from './utils/source-amounts';\nimport { pollTransactionChanges } from './utils/transaction';\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 #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n constructor({\n getDelegationTransaction,\n getStrategy,\n getStrategies,\n messenger,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n\n this.#registerActionHandlers();\n\n pollTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.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 setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config = {\n isMaxAmount: transactionData.isMaxAmount,\n isPostQuote: transactionData.isPostQuote,\n refundTo: transactionData.refundTo,\n };\n\n callback(config);\n\n transactionData.isMaxAmount = config.isMaxAmount;\n transactionData.isPostQuote = config.isPostQuote;\n transactionData.refundTo = config.refundTo;\n });\n }\n\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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\n if (!current) {\n transactionData[transactionId] = {\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 isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated\n ) {\n updateSourceAmounts(transactionId, current as never, this.messenger);\n\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 #registerActionHandlers(): void {\n this.messenger.registerActionHandler(\n 'TransactionPayController:getDelegationTransaction',\n this.#getDelegationTransaction.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n (transaction: TransactionMeta): TransactionPayStrategy =>\n this.#getStrategiesWithFallback(transaction)[0],\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:setTransactionConfig',\n this.setTransactionConfig.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updatePaymentToken',\n this.updatePaymentToken.bind(this),\n );\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\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 return validStrategies.length\n ? validStrategies\n : getStrategyOrder(this.messenger);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionPayController.cjs","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+DAA2D;AAG3D,mCAA8B;AAE9B,2EAAkE;AAClE,6EAAoE;AACpE,+CAIqB;AACrB,iEAA0D;AAW1D,6DAAyD;AACzD,+CAA8C;AAC9C,+DAA6D;AAC7D,yDAA6D;AAE7D,MAAM,aAAa,GAAiD;IAClE,eAAe,EAAE;QACf,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAkC,EAAE,CAAC,CAAC;IAC5D,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,MAAa,wBAAyB,SAAQ,gCAI7C;IAWC,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GAC2B;QAChC,KAAK,CAAC;YACJ,IAAI,EAAE,2BAAe;YACrB,QAAQ,EAAE,aAAa;YACvB,SAAS;YACT,KAAK,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE,GAAG,KAAK,EAAE;SAC1C,CAAC,CAAC;;QAtBI,qEAA4D;QAE5D,wDAEmB;QAEnB,0DAEqB;QAgB5B,uBAAA,IAAI,sDAA6B,wBAAwB,MAAA,CAAC;QAC1D,uBAAA,IAAI,yCAAgB,WAAW,MAAA,CAAC;QAChC,uBAAA,IAAI,2CAAkB,aAAa,MAAA,CAAC;QAEpC,uBAAA,IAAI,6FAAwB,MAA5B,IAAI,CAA0B,CAAC;QAE/B,IAAA,oCAAsB,EACpB,SAAS,EACT,uBAAA,IAAI,4FAAuB,CAAC,IAAI,CAAC,IAAI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CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;AACJ,CAAC,qHAGC,WAA4B;IAE5B,MAAM,kBAAkB,GACtB,uBAAA,IAAI,+CAAe,EAAE,KAArB,IAAI,EAAkB,WAAW,CAAC;QAClC,CAAC,uBAAA,IAAI,6CAAa,CAAC,CAAC,CAAC,CAAC,uBAAA,IAAI,6CAAa,MAAjB,IAAI,EAAc,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,IAAA,oCAAwB,EAAC,QAAQ,CAAC,CACrC,CAAC;IAEF,OAAO,eAAe,CAAC,MAAM;QAC3B,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,IAAA,gCAAgB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","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';\n\nimport { updateFiatPayment } from './actions/update-fiat-payment';\nimport { updatePaymentToken } from './actions/update-payment-token';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants';\nimport { QuoteRefresher } from './helpers/QuoteRefresher';\nimport type {\n GetDelegationTransactionCallback,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types';\nimport { getStrategyOrder } from './utils/feature-flags';\nimport { updateQuotes } from './utils/quotes';\nimport { updateSourceAmounts } from './utils/source-amounts';\nimport { pollTransactionChanges } from './utils/transaction';\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 #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n constructor({\n getDelegationTransaction,\n getStrategy,\n getStrategies,\n messenger,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n\n this.#registerActionHandlers();\n\n pollTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.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 setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config = {\n isMaxAmount: transactionData.isMaxAmount,\n isPostQuote: transactionData.isPostQuote,\n refundTo: transactionData.refundTo,\n };\n\n callback(config);\n\n transactionData.isMaxAmount = config.isMaxAmount;\n transactionData.isPostQuote = config.isPostQuote;\n transactionData.refundTo = config.refundTo;\n });\n }\n\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\n }\n\n updateFiatPayment(request: UpdateFiatPaymentRequest): void {\n updateFiatPayment(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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\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 isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated\n ) {\n updateSourceAmounts(transactionId, current as never, this.messenger);\n\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 #registerActionHandlers(): void {\n this.messenger.registerActionHandler(\n 'TransactionPayController:getDelegationTransaction',\n this.#getDelegationTransaction.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n (transaction: TransactionMeta): TransactionPayStrategy =>\n this.#getStrategiesWithFallback(transaction)[0],\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:setTransactionConfig',\n this.setTransactionConfig.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updatePaymentToken',\n this.updatePaymentToken.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updateFiatPayment',\n this.updateFiatPayment.bind(this),\n );\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\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 return validStrategies.length\n ? validStrategies\n : getStrategyOrder(this.messenger);\n }\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BaseController } from "@metamask/base-controller";
|
|
2
2
|
import { CONTROLLER_NAME } from "./constants.cjs";
|
|
3
|
-
import type { TransactionConfigCallback, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerState, UpdatePaymentTokenRequest } from "./types.cjs";
|
|
3
|
+
import type { TransactionConfigCallback, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerState, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest } from "./types.cjs";
|
|
4
4
|
export declare class TransactionPayController extends BaseController<typeof CONTROLLER_NAME, TransactionPayControllerState, TransactionPayControllerMessenger> {
|
|
5
5
|
#private;
|
|
6
6
|
constructor({ getDelegationTransaction, getStrategy, getStrategies, messenger, state, }: TransactionPayControllerOptions);
|
|
7
7
|
setTransactionConfig(transactionId: string, callback: TransactionConfigCallback): void;
|
|
8
8
|
updatePaymentToken(request: UpdatePaymentTokenRequest): void;
|
|
9
|
+
updateFiatPayment(request: UpdateFiatPaymentRequest): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=TransactionPayController.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.d.cts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;
|
|
1
|
+
{"version":3,"file":"TransactionPayController.d.cts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAO3D,OAAO,EACL,eAAe,EAGhB,wBAAoB;AAErB,OAAO,KAAK,EAEV,yBAAyB,EAEzB,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,EAC1B,oBAAgB;AAmBjB,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,eAAe,EACtB,6BAA6B,EAC7B,iCAAiC,CAClC;;gBAWa,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,+BAA+B;IA4BlC,oBAAoB,CAClB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,yBAAyB,GAClC,IAAI;IAgBP,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAO5D,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAmH3D"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BaseController } from "@metamask/base-controller";
|
|
2
2
|
import { CONTROLLER_NAME } from "./constants.mjs";
|
|
3
|
-
import type { TransactionConfigCallback, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerState, UpdatePaymentTokenRequest } from "./types.mjs";
|
|
3
|
+
import type { TransactionConfigCallback, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerState, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest } from "./types.mjs";
|
|
4
4
|
export declare class TransactionPayController extends BaseController<typeof CONTROLLER_NAME, TransactionPayControllerState, TransactionPayControllerMessenger> {
|
|
5
5
|
#private;
|
|
6
6
|
constructor({ getDelegationTransaction, getStrategy, getStrategies, messenger, state, }: TransactionPayControllerOptions);
|
|
7
7
|
setTransactionConfig(transactionId: string, callback: TransactionConfigCallback): void;
|
|
8
8
|
updatePaymentToken(request: UpdatePaymentTokenRequest): void;
|
|
9
|
+
updateFiatPayment(request: UpdateFiatPaymentRequest): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=TransactionPayController.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.d.mts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;
|
|
1
|
+
{"version":3,"file":"TransactionPayController.d.mts","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAO3D,OAAO,EACL,eAAe,EAGhB,wBAAoB;AAErB,OAAO,KAAK,EAEV,yBAAyB,EAEzB,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,EAC1B,oBAAgB;AAmBjB,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,eAAe,EACtB,6BAA6B,EAC7B,iCAAiC,CAClC;;gBAWa,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,+BAA+B;IA4BlC,oBAAoB,CAClB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,yBAAyB,GAClC,IAAI;IAgBP,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAO5D,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAmH3D"}
|
|
@@ -13,6 +13,7 @@ var _TransactionPayController_instances, _TransactionPayController_getDelegation
|
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
14
|
import $lodash from "lodash";
|
|
15
15
|
const { noop } = $lodash;
|
|
16
|
+
import { updateFiatPayment } from "./actions/update-fiat-payment.mjs";
|
|
16
17
|
import { updatePaymentToken } from "./actions/update-payment-token.mjs";
|
|
17
18
|
import { CONTROLLER_NAME, isTransactionPayStrategy, TransactionPayStrategy } from "./constants.mjs";
|
|
18
19
|
import { QuoteRefresher } from "./helpers/QuoteRefresher.mjs";
|
|
@@ -74,6 +75,12 @@ export class TransactionPayController extends BaseController {
|
|
|
74
75
|
updateTransactionData: __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_updateTransactionData).bind(this),
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
updateFiatPayment(request) {
|
|
79
|
+
updateFiatPayment(request, {
|
|
80
|
+
messenger: this.messenger,
|
|
81
|
+
updateTransactionData: __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_updateTransactionData).bind(this),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
85
|
_TransactionPayController_getDelegationTransaction = new WeakMap(), _TransactionPayController_getStrategy = new WeakMap(), _TransactionPayController_getStrategies = new WeakMap(), _TransactionPayController_instances = new WeakSet(), _TransactionPayController_removeTransactionData = function _TransactionPayController_removeTransactionData(transactionId) {
|
|
79
86
|
this.update((state) => {
|
|
@@ -90,6 +97,7 @@ _TransactionPayController_getDelegationTransaction = new WeakMap(), _Transaction
|
|
|
90
97
|
const originalIsPostQuote = current?.isPostQuote;
|
|
91
98
|
if (!current) {
|
|
92
99
|
transactionData[transactionId] = {
|
|
100
|
+
fiatPayment: {},
|
|
93
101
|
isLoading: false,
|
|
94
102
|
tokens: [],
|
|
95
103
|
};
|
|
@@ -124,6 +132,7 @@ _TransactionPayController_getDelegationTransaction = new WeakMap(), _Transaction
|
|
|
124
132
|
this.messenger.registerActionHandler('TransactionPayController:getStrategy', (transaction) => __classPrivateFieldGet(this, _TransactionPayController_instances, "m", _TransactionPayController_getStrategiesWithFallback).call(this, transaction)[0]);
|
|
125
133
|
this.messenger.registerActionHandler('TransactionPayController:setTransactionConfig', this.setTransactionConfig.bind(this));
|
|
126
134
|
this.messenger.registerActionHandler('TransactionPayController:updatePaymentToken', this.updatePaymentToken.bind(this));
|
|
135
|
+
this.messenger.registerActionHandler('TransactionPayController:updateFiatPayment', this.updateFiatPayment.bind(this));
|
|
127
136
|
}, _TransactionPayController_getStrategiesWithFallback = function _TransactionPayController_getStrategiesWithFallback(transaction) {
|
|
128
137
|
const strategyCandidates = __classPrivateFieldGet(this, _TransactionPayController_getStrategies, "f")?.call(this, transaction) ??
|
|
129
138
|
(__classPrivateFieldGet(this, _TransactionPayController_getStrategy, "f") ? [__classPrivateFieldGet(this, _TransactionPayController_getStrategy, "f").call(this, transaction)] : []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionPayController.mjs","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;;;AAK3D,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACvB,wBAAoB;AACrB,OAAO,EAAE,cAAc,EAAE,qCAAiC;AAU1D,OAAO,EAAE,gBAAgB,EAAE,kCAA8B;AACzD,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAC9C,OAAO,EAAE,mBAAmB,EAAE,mCAA+B;AAC7D,OAAO,EAAE,sBAAsB,EAAE,gCAA4B;AAE7D,MAAM,aAAa,GAAiD;IAClE,eAAe,EAAE;QACf,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAkC,EAAE,CAAC,CAAC;IAC5D,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,OAAO,wBAAyB,SAAQ,cAI7C;IAWC,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GAC2B;QAChC,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,QAAQ,E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B,CAClC,6CAA6C,EAC7C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC,qHAGC,WAA4B;IAE5B,MAAM,kBAAkB,GACtB,uBAAA,IAAI,+CAAe,EAAE,KAArB,IAAI,EAAkB,WAAW,CAAC;QAClC,CAAC,uBAAA,IAAI,6CAAa,CAAC,CAAC,CAAC,CAAC,uBAAA,IAAI,6CAAa,MAAjB,IAAI,EAAc,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,wBAAwB,CAAC,QAAQ,CAAC,CACrC,CAAC;IAEF,OAAO,eAAe,CAAC,MAAM;QAC3B,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","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';\n\nimport { updatePaymentToken } from './actions/update-payment-token';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants';\nimport { QuoteRefresher } from './helpers/QuoteRefresher';\nimport type {\n GetDelegationTransactionCallback,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdatePaymentTokenRequest,\n} from './types';\nimport { getStrategyOrder } from './utils/feature-flags';\nimport { updateQuotes } from './utils/quotes';\nimport { updateSourceAmounts } from './utils/source-amounts';\nimport { pollTransactionChanges } from './utils/transaction';\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 #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n constructor({\n getDelegationTransaction,\n getStrategy,\n getStrategies,\n messenger,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n\n this.#registerActionHandlers();\n\n pollTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.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 setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config = {\n isMaxAmount: transactionData.isMaxAmount,\n isPostQuote: transactionData.isPostQuote,\n refundTo: transactionData.refundTo,\n };\n\n callback(config);\n\n transactionData.isMaxAmount = config.isMaxAmount;\n transactionData.isPostQuote = config.isPostQuote;\n transactionData.refundTo = config.refundTo;\n });\n }\n\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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\n if (!current) {\n transactionData[transactionId] = {\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 isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated\n ) {\n updateSourceAmounts(transactionId, current as never, this.messenger);\n\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 #registerActionHandlers(): void {\n this.messenger.registerActionHandler(\n 'TransactionPayController:getDelegationTransaction',\n this.#getDelegationTransaction.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n (transaction: TransactionMeta): TransactionPayStrategy =>\n this.#getStrategiesWithFallback(transaction)[0],\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:setTransactionConfig',\n this.setTransactionConfig.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updatePaymentToken',\n this.updatePaymentToken.bind(this),\n );\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\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 return validStrategies.length\n ? validStrategies\n : getStrategyOrder(this.messenger);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TransactionPayController.mjs","sourceRoot":"","sources":["../src/TransactionPayController.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,cAAc,EAAE,kCAAkC;;;AAK3D,OAAO,EAAE,iBAAiB,EAAE,0CAAsC;AAClE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACvB,wBAAoB;AACrB,OAAO,EAAE,cAAc,EAAE,qCAAiC;AAW1D,OAAO,EAAE,gBAAgB,EAAE,kCAA8B;AACzD,OAAO,EAAE,YAAY,EAAE,2BAAuB;AAC9C,OAAO,EAAE,mBAAmB,EAAE,mCAA+B;AAC7D,OAAO,EAAE,sBAAsB,EAAE,gCAA4B;AAE7D,MAAM,aAAa,GAAiD;IAClE,eAAe,EAAE;QACf,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,eAAe,GAAG,GAAkC,EAAE,CAAC,CAAC;IAC5D,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,OAAO,wBAAyB,SAAQ,cAI7C;IAWC,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,SAAS,EACT,KAAK,GAC2B;QAChC,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,aAAa;YACvB,SAAS;YACT,KAAK,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE,GAAG,KAAK,EAAE;SAC1C,CAAC,CAAC;;QAtBI,qEAA4D;QAE5D,wDAE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BAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CACrC,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAClC,6CAA6C,EAC7C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CACnC,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAClC,4CAA4C,EAC5C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAClC,CAAC;AACJ,CAAC,qHAGC,WAA4B;IAE5B,MAAM,kBAAkB,GACtB,uBAAA,IAAI,+CAAe,EAAE,KAArB,IAAI,EAAkB,WAAW,CAAC;QAClC,CAAC,uBAAA,IAAI,6CAAa,CAAC,CAAC,CAAC,CAAC,uBAAA,IAAI,6CAAa,MAAjB,IAAI,EAAc,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAC/C,CAAC,QAAQ,EAAsC,EAAE,CAC/C,wBAAwB,CAAC,QAAQ,CAAC,CACrC,CAAC;IAEF,OAAO,eAAe,CAAC,MAAM;QAC3B,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","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';\n\nimport { updateFiatPayment } from './actions/update-fiat-payment';\nimport { updatePaymentToken } from './actions/update-payment-token';\nimport {\n CONTROLLER_NAME,\n isTransactionPayStrategy,\n TransactionPayStrategy,\n} from './constants';\nimport { QuoteRefresher } from './helpers/QuoteRefresher';\nimport type {\n GetDelegationTransactionCallback,\n TransactionConfigCallback,\n TransactionData,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerState,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types';\nimport { getStrategyOrder } from './utils/feature-flags';\nimport { updateQuotes } from './utils/quotes';\nimport { updateSourceAmounts } from './utils/source-amounts';\nimport { pollTransactionChanges } from './utils/transaction';\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 #getDelegationTransaction: GetDelegationTransactionCallback;\n\n readonly #getStrategy?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy;\n\n readonly #getStrategies?: (\n transaction: TransactionMeta,\n ) => TransactionPayStrategy[];\n\n constructor({\n getDelegationTransaction,\n getStrategy,\n getStrategies,\n messenger,\n state,\n }: TransactionPayControllerOptions) {\n super({\n name: CONTROLLER_NAME,\n metadata: stateMetadata,\n messenger,\n state: { ...getDefaultState(), ...state },\n });\n\n this.#getDelegationTransaction = getDelegationTransaction;\n this.#getStrategy = getStrategy;\n this.#getStrategies = getStrategies;\n\n this.#registerActionHandlers();\n\n pollTransactionChanges(\n messenger,\n this.#updateTransactionData.bind(this),\n this.#removeTransactionData.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 setTransactionConfig(\n transactionId: string,\n callback: TransactionConfigCallback,\n ): void {\n this.#updateTransactionData(transactionId, (transactionData) => {\n const config = {\n isMaxAmount: transactionData.isMaxAmount,\n isPostQuote: transactionData.isPostQuote,\n refundTo: transactionData.refundTo,\n };\n\n callback(config);\n\n transactionData.isMaxAmount = config.isMaxAmount;\n transactionData.isPostQuote = config.isPostQuote;\n transactionData.refundTo = config.refundTo;\n });\n }\n\n updatePaymentToken(request: UpdatePaymentTokenRequest): void {\n updatePaymentToken(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\n }\n\n updateFiatPayment(request: UpdateFiatPaymentRequest): void {\n updateFiatPayment(request, {\n messenger: this.messenger,\n updateTransactionData: this.#updateTransactionData.bind(this),\n });\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\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 isTokensUpdated = current.tokens !== originalTokens;\n const isIsMaxUpdated = current.isMaxAmount !== originalIsMaxAmount;\n const isPostQuoteUpdated = current.isPostQuote !== originalIsPostQuote;\n\n if (\n isPaymentTokenUpdated ||\n isIsMaxUpdated ||\n isTokensUpdated ||\n isPostQuoteUpdated\n ) {\n updateSourceAmounts(transactionId, current as never, this.messenger);\n\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 #registerActionHandlers(): void {\n this.messenger.registerActionHandler(\n 'TransactionPayController:getDelegationTransaction',\n this.#getDelegationTransaction.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n (transaction: TransactionMeta): TransactionPayStrategy =>\n this.#getStrategiesWithFallback(transaction)[0],\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:setTransactionConfig',\n this.setTransactionConfig.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updatePaymentToken',\n this.updatePaymentToken.bind(this),\n );\n\n this.messenger.registerActionHandler(\n 'TransactionPayController:updateFiatPayment',\n this.updateFiatPayment.bind(this),\n );\n }\n\n #getStrategiesWithFallback(\n transaction: TransactionMeta,\n ): TransactionPayStrategy[] {\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 return validStrategies.length\n ? validStrategies\n : getStrategyOrder(this.messenger);\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateFiatPayment = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
const logger_1 = require("../logger.cjs");
|
|
6
|
+
const transaction_1 = require("../utils/transaction.cjs");
|
|
7
|
+
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'update-fiat-payment');
|
|
8
|
+
/**
|
|
9
|
+
* Update fiat payment state for a specific transaction.
|
|
10
|
+
*
|
|
11
|
+
* @param request - Request parameters.
|
|
12
|
+
* @param options - Options bag.
|
|
13
|
+
*/
|
|
14
|
+
function updateFiatPayment(request, options) {
|
|
15
|
+
const { transactionId, callback } = request;
|
|
16
|
+
const { messenger, updateTransactionData } = options;
|
|
17
|
+
const transaction = (0, transaction_1.getTransaction)(transactionId, messenger);
|
|
18
|
+
if (!transaction) {
|
|
19
|
+
throw new Error('Transaction not found');
|
|
20
|
+
}
|
|
21
|
+
log('Updated fiat payment', { transactionId });
|
|
22
|
+
updateTransactionData(transactionId, (data) => {
|
|
23
|
+
const currentFiatPayment = data.fiatPayment ?? {};
|
|
24
|
+
callback(currentFiatPayment);
|
|
25
|
+
data.fiatPayment = currentFiatPayment;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.updateFiatPayment = updateFiatPayment;
|
|
29
|
+
//# sourceMappingURL=update-fiat-payment.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-fiat-payment.cjs","sourceRoot":"","sources":["../../src/actions/update-fiat-payment.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAGrD,0CAA0C;AAK1C,0DAAsD;AAEtD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,qBAAqB,CAAC,CAAC;AAOrE;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,OAAiC,EACjC,OAAiC;IAEjC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,sBAAsB,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAE/C,qBAAqB,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;QAClD,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAE7B,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AArBD,8CAqBC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\nimport type {\n UpdateFiatPaymentRequest,\n UpdateTransactionDataCallback,\n} from '../types';\nimport { getTransaction } from '../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'update-fiat-payment');\n\nexport type UpdateFiatPaymentOptions = {\n messenger: TransactionPayControllerMessenger;\n updateTransactionData: UpdateTransactionDataCallback;\n};\n\n/**\n * Update fiat payment state for a specific transaction.\n *\n * @param request - Request parameters.\n * @param options - Options bag.\n */\nexport function updateFiatPayment(\n request: UpdateFiatPaymentRequest,\n options: UpdateFiatPaymentOptions,\n): void {\n const { transactionId, callback } = request;\n const { messenger, updateTransactionData } = options;\n\n const transaction = getTransaction(transactionId, messenger);\n\n if (!transaction) {\n throw new Error('Transaction not found');\n }\n\n log('Updated fiat payment', { transactionId });\n\n updateTransactionData(transactionId, (data) => {\n const currentFiatPayment = data.fiatPayment ?? {};\n callback(currentFiatPayment);\n\n data.fiatPayment = currentFiatPayment;\n });\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TransactionPayControllerMessenger } from "../index.cjs";
|
|
2
|
+
import type { UpdateFiatPaymentRequest, UpdateTransactionDataCallback } from "../types.cjs";
|
|
3
|
+
export type UpdateFiatPaymentOptions = {
|
|
4
|
+
messenger: TransactionPayControllerMessenger;
|
|
5
|
+
updateTransactionData: UpdateTransactionDataCallback;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Update fiat payment state for a specific transaction.
|
|
9
|
+
*
|
|
10
|
+
* @param request - Request parameters.
|
|
11
|
+
* @param options - Options bag.
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateFiatPayment(request: UpdateFiatPaymentRequest, options: UpdateFiatPaymentOptions): void;
|
|
14
|
+
//# sourceMappingURL=update-fiat-payment.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-fiat-payment.d.cts","sourceRoot":"","sources":["../../src/actions/update-fiat-payment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EACV,wBAAwB,EACxB,6BAA6B,EAC9B,qBAAiB;AAKlB,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAkBN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TransactionPayControllerMessenger } from "../index.mjs";
|
|
2
|
+
import type { UpdateFiatPaymentRequest, UpdateTransactionDataCallback } from "../types.mjs";
|
|
3
|
+
export type UpdateFiatPaymentOptions = {
|
|
4
|
+
messenger: TransactionPayControllerMessenger;
|
|
5
|
+
updateTransactionData: UpdateTransactionDataCallback;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Update fiat payment state for a specific transaction.
|
|
9
|
+
*
|
|
10
|
+
* @param request - Request parameters.
|
|
11
|
+
* @param options - Options bag.
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateFiatPayment(request: UpdateFiatPaymentRequest, options: UpdateFiatPaymentOptions): void;
|
|
14
|
+
//# sourceMappingURL=update-fiat-payment.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-fiat-payment.d.mts","sourceRoot":"","sources":["../../src/actions/update-fiat-payment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EACV,wBAAwB,EACxB,6BAA6B,EAC9B,qBAAiB;AAKlB,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAkBN"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
2
|
+
import { projectLogger } from "../logger.mjs";
|
|
3
|
+
import { getTransaction } from "../utils/transaction.mjs";
|
|
4
|
+
const log = createModuleLogger(projectLogger, 'update-fiat-payment');
|
|
5
|
+
/**
|
|
6
|
+
* Update fiat payment state for a specific transaction.
|
|
7
|
+
*
|
|
8
|
+
* @param request - Request parameters.
|
|
9
|
+
* @param options - Options bag.
|
|
10
|
+
*/
|
|
11
|
+
export function updateFiatPayment(request, options) {
|
|
12
|
+
const { transactionId, callback } = request;
|
|
13
|
+
const { messenger, updateTransactionData } = options;
|
|
14
|
+
const transaction = getTransaction(transactionId, messenger);
|
|
15
|
+
if (!transaction) {
|
|
16
|
+
throw new Error('Transaction not found');
|
|
17
|
+
}
|
|
18
|
+
log('Updated fiat payment', { transactionId });
|
|
19
|
+
updateTransactionData(transactionId, (data) => {
|
|
20
|
+
const currentFiatPayment = data.fiatPayment ?? {};
|
|
21
|
+
callback(currentFiatPayment);
|
|
22
|
+
data.fiatPayment = currentFiatPayment;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=update-fiat-payment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-fiat-payment.mjs","sourceRoot":"","sources":["../../src/actions/update-fiat-payment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAGrD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAK1C,OAAO,EAAE,cAAc,EAAE,iCAA6B;AAEtD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;AAOrE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAiC,EACjC,OAAiC;IAEjC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,WAAW,GAAG,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,sBAAsB,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAE/C,qBAAqB,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;QAC5C,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;QAClD,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAE7B,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\nimport type {\n UpdateFiatPaymentRequest,\n UpdateTransactionDataCallback,\n} from '../types';\nimport { getTransaction } from '../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'update-fiat-payment');\n\nexport type UpdateFiatPaymentOptions = {\n messenger: TransactionPayControllerMessenger;\n updateTransactionData: UpdateTransactionDataCallback;\n};\n\n/**\n * Update fiat payment state for a specific transaction.\n *\n * @param request - Request parameters.\n * @param options - Options bag.\n */\nexport function updateFiatPayment(\n request: UpdateFiatPaymentRequest,\n options: UpdateFiatPaymentOptions,\n): void {\n const { transactionId, callback } = request;\n const { messenger, updateTransactionData } = options;\n\n const transaction = getTransaction(transactionId, messenger);\n\n if (!transaction) {\n throw new Error('Transaction not found');\n }\n\n log('Updated fiat payment', { transactionId });\n\n updateTransactionData(transactionId, (data) => {\n const currentFiatPayment = data.fiatPayment ?? {};\n callback(currentFiatPayment);\n\n data.fiatPayment = currentFiatPayment;\n });\n}\n"]}
|
|
@@ -31,6 +31,7 @@ function updatePaymentToken(request, options) {
|
|
|
31
31
|
log('Updated payment token', { transactionId, paymentToken });
|
|
32
32
|
updateTransactionData(transactionId, (data) => {
|
|
33
33
|
data.paymentToken = paymentToken;
|
|
34
|
+
data.fiatPayment = {};
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
exports.updatePaymentToken = updatePaymentToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-payment-token.cjs","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAIrD,0CAA0C;AAM1C,8CAKwB;AACxB,0DAAsD;AAEtD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,sBAAsB,CAAC,CAAC;AAOtE;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,OAAkC,EAClC,OAAkC;IAElC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACzD,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC;QACnC,OAAO;QACP,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAW;QACvC,SAAS;QACT,YAAY;KACb,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,GAAG,CAAC,uBAAuB,EAAE,EAAE,aAAa,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A8BC;AAED;;;;;;;;;GASG;AACH,SAAS,eAAe,CAAC,EACvB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,YAAY,GAMb;IACC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GACxB,IAAA,oBAAY,EAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAEvD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAEzE,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAExE,MAAM,EACJ,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,WAAW,GAClB,GAAG,IAAA,2BAAmB,EAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE1D,OAAO;QACL,OAAO,EAAE,YAAY;QACrB,WAAW;QACX,YAAY;QACZ,UAAU;QACV,UAAU;QACV,OAAO;QACP,QAAQ;QACR,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\nimport type {\n TransactionPaymentToken,\n UpdatePaymentTokenRequest,\n UpdateTransactionDataCallback,\n} from '../types';\nimport {\n computeTokenAmounts,\n getTokenBalance,\n getTokenFiatRate,\n getTokenInfo,\n} from '../utils/token';\nimport { getTransaction } from '../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'update-payment-token');\n\nexport type UpdatePaymentTokenOptions = {\n messenger: TransactionPayControllerMessenger;\n updateTransactionData: UpdateTransactionDataCallback;\n};\n\n/**\n * Update the payment token for a specific transaction.\n *\n * @param request - Request parameters.\n * @param options - Options bag.\n */\nexport function updatePaymentToken(\n request: UpdatePaymentTokenRequest,\n options: UpdatePaymentTokenOptions,\n): void {\n const { transactionId, tokenAddress, chainId } = request;\n const { messenger, updateTransactionData } = options;\n\n const transaction = getTransaction(transactionId, messenger);\n\n if (!transaction) {\n throw new Error('Transaction not found');\n }\n\n const paymentToken = getPaymentToken({\n chainId,\n from: transaction?.txParams.from as Hex,\n messenger,\n tokenAddress,\n });\n\n if (!paymentToken) {\n throw new Error('Payment token not found');\n }\n\n log('Updated payment token', { transactionId, paymentToken });\n\n updateTransactionData(transactionId, (data) => {\n data.paymentToken = paymentToken;\n data.fiatPayment = {};\n });\n}\n\n/**\n * Generate the full payment token data from a token address and chain ID.\n *\n * @param request - The payment token request parameters.\n * @param request.chainId - The chain ID.\n * @param request.from - The address to get the token balance for.\n * @param request.messenger - The transaction pay controller messenger.\n * @param request.tokenAddress - The token address.\n * @returns The payment token or undefined if the token data could not be retrieved.\n */\nfunction getPaymentToken({\n chainId,\n from,\n messenger,\n tokenAddress,\n}: {\n chainId: Hex;\n from: Hex;\n messenger: TransactionPayControllerMessenger;\n tokenAddress: Hex;\n}): TransactionPaymentToken | undefined {\n const { decimals, symbol } =\n getTokenInfo(messenger, tokenAddress, chainId) ?? {};\n\n if (decimals === undefined || !symbol) {\n return undefined;\n }\n\n const tokenFiatRate = getTokenFiatRate(messenger, tokenAddress, chainId);\n\n if (tokenFiatRate === undefined) {\n return undefined;\n }\n\n const balance = getTokenBalance(messenger, from, chainId, tokenAddress);\n\n const {\n raw: balanceRaw,\n human: balanceHuman,\n usd: balanceUsd,\n fiat: balanceFiat,\n } = computeTokenAmounts(balance, decimals, tokenFiatRate);\n\n return {\n address: tokenAddress,\n balanceFiat,\n balanceHuman,\n balanceRaw,\n balanceUsd,\n chainId,\n decimals,\n symbol,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-payment-token.d.cts","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EAEV,yBAAyB,EACzB,6BAA6B,EAC9B,qBAAiB;AAWlB,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,IAAI,
|
|
1
|
+
{"version":3,"file":"update-payment-token.d.cts","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EAEV,yBAAyB,EACzB,6BAA6B,EAC9B,qBAAiB;AAWlB,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,IAAI,CA2BN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-payment-token.d.mts","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EAEV,yBAAyB,EACzB,6BAA6B,EAC9B,qBAAiB;AAWlB,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,IAAI,
|
|
1
|
+
{"version":3,"file":"update-payment-token.d.mts","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAE5D,OAAO,KAAK,EAEV,yBAAyB,EACzB,6BAA6B,EAC9B,qBAAiB;AAWlB,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,qBAAqB,EAAE,6BAA6B,CAAC;CACtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,yBAAyB,GACjC,IAAI,CA2BN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-payment-token.mjs","sourceRoot":"","sources":["../../src/actions/update-payment-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAIrD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAM1C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACb,2BAAuB;AACxB,OAAO,EAAE,cAAc,EAAE,iCAA6B;AAEtD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;AAOtE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAkC,EAClC,OAAkC;IAElC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACzD,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,WAAW,GAAG,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,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,UAAU;QACV,UAAU;QACV,OAAO;QACP,QAAQ;QACR,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import { createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport { projectLogger } from '../logger';\nimport type {\n TransactionPaymentToken,\n UpdatePaymentTokenRequest,\n UpdateTransactionDataCallback,\n} from '../types';\nimport {\n computeTokenAmounts,\n getTokenBalance,\n getTokenFiatRate,\n getTokenInfo,\n} from '../utils/token';\nimport { getTransaction } from '../utils/transaction';\n\nconst log = createModuleLogger(projectLogger, 'update-payment-token');\n\nexport type UpdatePaymentTokenOptions = {\n messenger: TransactionPayControllerMessenger;\n updateTransactionData: UpdateTransactionDataCallback;\n};\n\n/**\n * Update the payment token for a specific transaction.\n *\n * @param request - Request parameters.\n * @param options - Options bag.\n */\nexport function updatePaymentToken(\n request: UpdatePaymentTokenRequest,\n options: UpdatePaymentTokenOptions,\n): void {\n const { transactionId, tokenAddress, chainId } = request;\n const { messenger, updateTransactionData } = options;\n\n const transaction = getTransaction(transactionId, messenger);\n\n if (!transaction) {\n throw new Error('Transaction not found');\n }\n\n const paymentToken = getPaymentToken({\n chainId,\n from: transaction?.txParams.from as Hex,\n messenger,\n tokenAddress,\n });\n\n if (!paymentToken) {\n throw new Error('Payment token not found');\n }\n\n log('Updated payment token', { transactionId, paymentToken });\n\n updateTransactionData(transactionId, (data) => {\n data.paymentToken = paymentToken;\n data.fiatPayment = {};\n });\n}\n\n/**\n * Generate the full payment token data from a token address and chain ID.\n *\n * @param request - The payment token request parameters.\n * @param request.chainId - The chain ID.\n * @param request.from - The address to get the token balance for.\n * @param request.messenger - The transaction pay controller messenger.\n * @param request.tokenAddress - The token address.\n * @returns The payment token or undefined if the token data could not be retrieved.\n */\nfunction getPaymentToken({\n chainId,\n from,\n messenger,\n tokenAddress,\n}: {\n chainId: Hex;\n from: Hex;\n messenger: TransactionPayControllerMessenger;\n tokenAddress: Hex;\n}): TransactionPaymentToken | undefined {\n const { decimals, symbol } =\n getTokenInfo(messenger, tokenAddress, chainId) ?? {};\n\n if (decimals === undefined || !symbol) {\n return undefined;\n }\n\n const tokenFiatRate = getTokenFiatRate(messenger, tokenAddress, chainId);\n\n if (tokenFiatRate === undefined) {\n return undefined;\n }\n\n const balance = getTokenBalance(messenger, from, chainId, tokenAddress);\n\n const {\n raw: balanceRaw,\n human: balanceHuman,\n usd: balanceUsd,\n fiat: balanceFiat,\n } = computeTokenAmounts(balance, decimals, tokenFiatRate);\n\n return {\n address: tokenAddress,\n balanceFiat,\n balanceHuman,\n balanceRaw,\n balanceUsd,\n chainId,\n decimals,\n symbol,\n };\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAyBA,6CAAqD;AAA5C,mHAAA,sBAAsB,OAAA;AAC/B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,qFAAgF;AAAvE,sIAAA,yBAAyB,OAAA","sourcesContent":["export type {\n TransactionConfig,\n TransactionConfigCallback,\n TransactionFiatPayment,\n TransactionFiatPaymentCallback,\n TransactionPayControllerActions,\n TransactionPayControllerEvents,\n TransactionPayControllerGetDelegationTransactionAction,\n TransactionPayControllerGetStateAction,\n TransactionPayControllerGetStrategyAction,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerSetTransactionConfigAction,\n TransactionPayControllerUpdateFiatPaymentAction,\n TransactionPayControllerState,\n TransactionPayControllerStateChangeEvent,\n TransactionPayControllerUpdatePaymentTokenAction,\n TransactionPaymentToken,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPaySourceAmount,\n TransactionPayTotals,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types';\nexport { TransactionPayStrategy } from './constants';\nexport { TransactionPayController } from './TransactionPayController';\nexport { TransactionPayPublishHook } from './helpers/TransactionPayPublishHook';\nexport type { TransactionPayBridgeQuote } from './strategy/bridge/types';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { TransactionConfig, TransactionConfigCallback, TransactionPayControllerActions, TransactionPayControllerEvents, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetStateAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerState, TransactionPayControllerStateChangeEvent, TransactionPayControllerUpdatePaymentTokenAction, TransactionPaymentToken, TransactionPayQuote, TransactionPayRequiredToken, TransactionPaySourceAmount, TransactionPayTotals, UpdatePaymentTokenRequest, } from "./types.cjs";
|
|
1
|
+
export type { TransactionConfig, TransactionConfigCallback, TransactionFiatPayment, TransactionFiatPaymentCallback, TransactionPayControllerActions, TransactionPayControllerEvents, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetStateAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerUpdateFiatPaymentAction, TransactionPayControllerState, TransactionPayControllerStateChangeEvent, TransactionPayControllerUpdatePaymentTokenAction, TransactionPaymentToken, TransactionPayQuote, TransactionPayRequiredToken, TransactionPaySourceAmount, TransactionPayTotals, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest, } from "./types.cjs";
|
|
2
2
|
export { TransactionPayStrategy } from "./constants.cjs";
|
|
3
3
|
export { TransactionPayController } from "./TransactionPayController.cjs";
|
|
4
4
|
export { TransactionPayPublishHook } from "./helpers/TransactionPayPublishHook.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,sDAAsD,EACtD,sCAAsC,EACtC,yCAAyC,EACzC,iCAAiC,EACjC,+BAA+B,EAC/B,kDAAkD,EAClD,6BAA6B,EAC7B,wCAAwC,EACxC,gDAAgD,EAChD,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GAC1B,oBAAgB;AACjB,OAAO,EAAE,sBAAsB,EAAE,wBAAoB;AACrD,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,yBAAyB,EAAE,gDAA4C;AAChF,YAAY,EAAE,yBAAyB,EAAE,oCAAgC"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,8BAA8B,EAC9B,sDAAsD,EACtD,sCAAsC,EACtC,yCAAyC,EACzC,iCAAiC,EACjC,+BAA+B,EAC/B,kDAAkD,EAClD,+CAA+C,EAC/C,6BAA6B,EAC7B,wCAAwC,EACxC,gDAAgD,EAChD,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,oBAAgB;AACjB,OAAO,EAAE,sBAAsB,EAAE,wBAAoB;AACrD,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,yBAAyB,EAAE,gDAA4C;AAChF,YAAY,EAAE,yBAAyB,EAAE,oCAAgC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { TransactionConfig, TransactionConfigCallback, TransactionPayControllerActions, TransactionPayControllerEvents, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetStateAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerState, TransactionPayControllerStateChangeEvent, TransactionPayControllerUpdatePaymentTokenAction, TransactionPaymentToken, TransactionPayQuote, TransactionPayRequiredToken, TransactionPaySourceAmount, TransactionPayTotals, UpdatePaymentTokenRequest, } from "./types.mjs";
|
|
1
|
+
export type { TransactionConfig, TransactionConfigCallback, TransactionFiatPayment, TransactionFiatPaymentCallback, TransactionPayControllerActions, TransactionPayControllerEvents, TransactionPayControllerGetDelegationTransactionAction, TransactionPayControllerGetStateAction, TransactionPayControllerGetStrategyAction, TransactionPayControllerMessenger, TransactionPayControllerOptions, TransactionPayControllerSetTransactionConfigAction, TransactionPayControllerUpdateFiatPaymentAction, TransactionPayControllerState, TransactionPayControllerStateChangeEvent, TransactionPayControllerUpdatePaymentTokenAction, TransactionPaymentToken, TransactionPayQuote, TransactionPayRequiredToken, TransactionPaySourceAmount, TransactionPayTotals, UpdateFiatPaymentRequest, UpdatePaymentTokenRequest, } from "./types.mjs";
|
|
2
2
|
export { TransactionPayStrategy } from "./constants.mjs";
|
|
3
3
|
export { TransactionPayController } from "./TransactionPayController.mjs";
|
|
4
4
|
export { TransactionPayPublishHook } from "./helpers/TransactionPayPublishHook.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,+BAA+B,EAC/B,8BAA8B,EAC9B,sDAAsD,EACtD,sCAAsC,EACtC,yCAAyC,EACzC,iCAAiC,EACjC,+BAA+B,EAC/B,kDAAkD,EAClD,6BAA6B,EAC7B,wCAAwC,EACxC,gDAAgD,EAChD,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GAC1B,oBAAgB;AACjB,OAAO,EAAE,sBAAsB,EAAE,wBAAoB;AACrD,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,yBAAyB,EAAE,gDAA4C;AAChF,YAAY,EAAE,yBAAyB,EAAE,oCAAgC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,8BAA8B,EAC9B,sDAAsD,EACtD,sCAAsC,EACtC,yCAAyC,EACzC,iCAAiC,EACjC,+BAA+B,EAC/B,kDAAkD,EAClD,+CAA+C,EAC/C,6BAA6B,EAC7B,wCAAwC,EACxC,gDAAgD,EAChD,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,oBAAgB;AACjB,OAAO,EAAE,sBAAsB,EAAE,wBAAoB;AACrD,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,yBAAyB,EAAE,gDAA4C;AAChF,YAAY,EAAE,yBAAyB,EAAE,oCAAgC"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,sBAAsB,EAAE,wBAAoB;AACrD,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,yBAAyB,EAAE,gDAA4C","sourcesContent":["export type {\n TransactionConfig,\n TransactionConfigCallback,\n TransactionFiatPayment,\n TransactionFiatPaymentCallback,\n TransactionPayControllerActions,\n TransactionPayControllerEvents,\n TransactionPayControllerGetDelegationTransactionAction,\n TransactionPayControllerGetStateAction,\n TransactionPayControllerGetStrategyAction,\n TransactionPayControllerMessenger,\n TransactionPayControllerOptions,\n TransactionPayControllerSetTransactionConfigAction,\n TransactionPayControllerUpdateFiatPaymentAction,\n TransactionPayControllerState,\n TransactionPayControllerStateChangeEvent,\n TransactionPayControllerUpdatePaymentTokenAction,\n TransactionPaymentToken,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPaySourceAmount,\n TransactionPayTotals,\n UpdateFiatPaymentRequest,\n UpdatePaymentTokenRequest,\n} from './types';\nexport { TransactionPayStrategy } from './constants';\nexport { TransactionPayController } from './TransactionPayController';\nexport { TransactionPayPublishHook } from './helpers/TransactionPayPublishHook';\nexport type { TransactionPayBridgeQuote } from './strategy/bridge/types';\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CurrencyRateControllerActions,\n TokenBalancesControllerGetStateAction,\n} from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { BridgeControllerActions } from '@metamask/bridge-controller';\nimport type { BridgeStatusControllerStateChangeEvent } from '@metamask/bridge-status-controller';\nimport type { BridgeStatusControllerActions } from '@metamask/bridge-status-controller';\nimport type { GasFeeControllerActions } from '@metamask/gas-fee-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\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 { CONTROLLER_NAME, TransactionPayStrategy } from './constants';\n\nexport type AllowedActions =\n | AccountTrackerControllerGetStateAction\n | BridgeControllerActions\n | BridgeStatusControllerActions\n | CurrencyRateControllerActions\n | GasFeeControllerActions\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | TokenBalancesControllerGetStateAction\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | BridgeStatusControllerStateChangeEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;\n handler: GetDelegationTransactionCallback;\n};\n\n/** Action to get the pay strategy type used for a transaction. */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `${typeof CONTROLLER_NAME}:getStrategy`;\n handler: (transaction: TransactionMeta) => TransactionPayStrategy;\n};\n\n/** Action to update the payment token for a transaction. */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;\n handler: (request: UpdatePaymentTokenRequest) => void;\n};\n\n/** Action to update transaction configuration using a callback. */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `${typeof CONTROLLER_NAME}:setTransactionConfig`;\n handler: (transactionId: string, callback: TransactionConfigCallback) => void;\n};\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\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 /** 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/** State relating to a single transaction. */\nexport type TransactionData = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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 /** 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/** 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/** 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 /** 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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay quote\n * request.\n */\n refundTo?: Hex;\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/** 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 /** 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 /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\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 /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\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 /** 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\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?: (request: PayStrategyGetQuotesRequest) => boolean;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\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 /** 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/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n}: {\n transaction: TransactionMeta;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: 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.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CurrencyRateControllerActions,\n TokenBalancesControllerGetStateAction,\n} from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { BridgeControllerActions } from '@metamask/bridge-controller';\nimport type { BridgeStatusControllerStateChangeEvent } from '@metamask/bridge-status-controller';\nimport type { BridgeStatusControllerActions } from '@metamask/bridge-status-controller';\nimport type { GasFeeControllerActions } from '@metamask/gas-fee-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\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 { CONTROLLER_NAME, TransactionPayStrategy } from './constants';\n\nexport type AllowedActions =\n | AccountTrackerControllerGetStateAction\n | BridgeControllerActions\n | BridgeStatusControllerActions\n | CurrencyRateControllerActions\n | GasFeeControllerActions\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | TokenBalancesControllerGetStateAction\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | BridgeStatusControllerStateChangeEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;\n handler: GetDelegationTransactionCallback;\n};\n\n/** Action to get the pay strategy type used for a transaction. */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `${typeof CONTROLLER_NAME}:getStrategy`;\n handler: (transaction: TransactionMeta) => TransactionPayStrategy;\n};\n\n/** Action to update fiat payment state for a transaction. */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `${typeof CONTROLLER_NAME}:updateFiatPayment`;\n handler: (request: UpdateFiatPaymentRequest) => void;\n};\n\n/** Action to update the payment token for a transaction. */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;\n handler: (request: UpdatePaymentTokenRequest) => void;\n};\n\n/** Action to update transaction configuration using a callback. */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `${typeof CONTROLLER_NAME}:setTransactionConfig`;\n handler: (transactionId: string, callback: TransactionConfigCallback) => void;\n};\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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/** 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 | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerUpdatePaymentTokenAction;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\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 /** 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/** State relating to a single transaction. */\nexport type TransactionData = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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 /** 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 /** 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/** 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 /** 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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay quote\n * request.\n */\n refundTo?: Hex;\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/** 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 /** 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 /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\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 /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\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 /** 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\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?: (request: PayStrategyGetQuotesRequest) => boolean;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\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 /** 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}: {\n transaction: TransactionMeta;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: 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/dist/types.d.cts
CHANGED
|
@@ -29,6 +29,11 @@ export type TransactionPayControllerGetStrategyAction = {
|
|
|
29
29
|
type: `${typeof CONTROLLER_NAME}:getStrategy`;
|
|
30
30
|
handler: (transaction: TransactionMeta) => TransactionPayStrategy;
|
|
31
31
|
};
|
|
32
|
+
/** Action to update fiat payment state for a transaction. */
|
|
33
|
+
export type TransactionPayControllerUpdateFiatPaymentAction = {
|
|
34
|
+
type: `${typeof CONTROLLER_NAME}:updateFiatPayment`;
|
|
35
|
+
handler: (request: UpdateFiatPaymentRequest) => void;
|
|
36
|
+
};
|
|
32
37
|
/** Action to update the payment token for a transaction. */
|
|
33
38
|
export type TransactionPayControllerUpdatePaymentTokenAction = {
|
|
34
39
|
type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;
|
|
@@ -60,8 +65,10 @@ export type TransactionConfig = {
|
|
|
60
65
|
};
|
|
61
66
|
/** Callback to update transaction config. */
|
|
62
67
|
export type TransactionConfigCallback = (config: TransactionConfig) => void;
|
|
68
|
+
/** Callback to update fiat payment state. */
|
|
69
|
+
export type TransactionFiatPaymentCallback = (fiatPayment: TransactionFiatPayment) => void;
|
|
63
70
|
export type TransactionPayControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, TransactionPayControllerState>;
|
|
64
|
-
export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdatePaymentTokenAction;
|
|
71
|
+
export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdateFiatPaymentAction | TransactionPayControllerUpdatePaymentTokenAction;
|
|
65
72
|
export type TransactionPayControllerEvents = TransactionPayControllerStateChangeEvent;
|
|
66
73
|
export type TransactionPayControllerMessenger = Messenger<typeof CONTROLLER_NAME, TransactionPayControllerActions | AllowedActions, TransactionPayControllerEvents | AllowedEvents>;
|
|
67
74
|
/** Options for the TransactionPayController. */
|
|
@@ -84,6 +91,8 @@ export type TransactionPayControllerState = {
|
|
|
84
91
|
};
|
|
85
92
|
/** State relating to a single transaction. */
|
|
86
93
|
export type TransactionData = {
|
|
94
|
+
/** Fiat payment method state. */
|
|
95
|
+
fiatPayment?: TransactionFiatPayment;
|
|
87
96
|
/** Whether quotes are currently being retrieved. */
|
|
88
97
|
isLoading: boolean;
|
|
89
98
|
/** Whether the user has selected the maximum amount. */
|
|
@@ -119,6 +128,13 @@ export type TransactionData = {
|
|
|
119
128
|
/** Calculated totals for the transaction. */
|
|
120
129
|
totals?: TransactionPayTotals;
|
|
121
130
|
};
|
|
131
|
+
/** Fiat payment state stored per transaction. */
|
|
132
|
+
export type TransactionFiatPayment = {
|
|
133
|
+
/** Entered fiat amount for the selected payment method. */
|
|
134
|
+
amountFiat?: string;
|
|
135
|
+
/** Selected fiat payment method ID. */
|
|
136
|
+
selectedPaymentMethodId?: string;
|
|
137
|
+
};
|
|
122
138
|
/** A token required by a transaction. */
|
|
123
139
|
export type TransactionPayRequiredToken = {
|
|
124
140
|
/** Address of the required token. */
|
|
@@ -347,6 +363,13 @@ export type UpdatePaymentTokenRequest = {
|
|
|
347
363
|
/** Chain ID of the new payment token. */
|
|
348
364
|
chainId: Hex;
|
|
349
365
|
};
|
|
366
|
+
/** Request to update fiat payment state for a transaction. */
|
|
367
|
+
export type UpdateFiatPaymentRequest = {
|
|
368
|
+
/** ID of the transaction to update. */
|
|
369
|
+
transactionId: string;
|
|
370
|
+
/** Callback to mutate fiat payment state. */
|
|
371
|
+
callback: TransactionFiatPaymentCallback;
|
|
372
|
+
};
|
|
350
373
|
/** Callback to convert a transaction to a redeem delegation. */
|
|
351
374
|
export type GetDelegationTransactionCallback = ({ transaction, }: {
|
|
352
375
|
transaction: TransactionMeta;
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,qCAAqC,EACtC,qCAAqC;AACtC,OAAO,KAAK,EAAE,kCAAkC,EAAE,qCAAqC;AACvF,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAqC;AACnF,OAAO,KAAK,EAAE,sCAAsC,EAAE,qCAAqC;AAC3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,oCAAoC;AAC3E,OAAO,KAAK,EAAE,sCAAsC,EAAE,2CAA2C;AACjG,OAAO,KAAK,EAAE,6BAA6B,EAAE,2CAA2C;AACxF,OAAO,KAAK,EAAE,u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,CAAC;CAC1C,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,gCAAgC,GAAG,CAAC,EAC9C,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;CAC9B,KAAK,OAAO,CAAC;IACZ,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,IAAI,EAAE,GAAG,CAAC;IACV,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC,CAAC;AAEH,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.d.mts
CHANGED
|
@@ -29,6 +29,11 @@ export type TransactionPayControllerGetStrategyAction = {
|
|
|
29
29
|
type: `${typeof CONTROLLER_NAME}:getStrategy`;
|
|
30
30
|
handler: (transaction: TransactionMeta) => TransactionPayStrategy;
|
|
31
31
|
};
|
|
32
|
+
/** Action to update fiat payment state for a transaction. */
|
|
33
|
+
export type TransactionPayControllerUpdateFiatPaymentAction = {
|
|
34
|
+
type: `${typeof CONTROLLER_NAME}:updateFiatPayment`;
|
|
35
|
+
handler: (request: UpdateFiatPaymentRequest) => void;
|
|
36
|
+
};
|
|
32
37
|
/** Action to update the payment token for a transaction. */
|
|
33
38
|
export type TransactionPayControllerUpdatePaymentTokenAction = {
|
|
34
39
|
type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;
|
|
@@ -60,8 +65,10 @@ export type TransactionConfig = {
|
|
|
60
65
|
};
|
|
61
66
|
/** Callback to update transaction config. */
|
|
62
67
|
export type TransactionConfigCallback = (config: TransactionConfig) => void;
|
|
68
|
+
/** Callback to update fiat payment state. */
|
|
69
|
+
export type TransactionFiatPaymentCallback = (fiatPayment: TransactionFiatPayment) => void;
|
|
63
70
|
export type TransactionPayControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, TransactionPayControllerState>;
|
|
64
|
-
export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdatePaymentTokenAction;
|
|
71
|
+
export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerSetTransactionConfigAction | TransactionPayControllerUpdateFiatPaymentAction | TransactionPayControllerUpdatePaymentTokenAction;
|
|
65
72
|
export type TransactionPayControllerEvents = TransactionPayControllerStateChangeEvent;
|
|
66
73
|
export type TransactionPayControllerMessenger = Messenger<typeof CONTROLLER_NAME, TransactionPayControllerActions | AllowedActions, TransactionPayControllerEvents | AllowedEvents>;
|
|
67
74
|
/** Options for the TransactionPayController. */
|
|
@@ -84,6 +91,8 @@ export type TransactionPayControllerState = {
|
|
|
84
91
|
};
|
|
85
92
|
/** State relating to a single transaction. */
|
|
86
93
|
export type TransactionData = {
|
|
94
|
+
/** Fiat payment method state. */
|
|
95
|
+
fiatPayment?: TransactionFiatPayment;
|
|
87
96
|
/** Whether quotes are currently being retrieved. */
|
|
88
97
|
isLoading: boolean;
|
|
89
98
|
/** Whether the user has selected the maximum amount. */
|
|
@@ -119,6 +128,13 @@ export type TransactionData = {
|
|
|
119
128
|
/** Calculated totals for the transaction. */
|
|
120
129
|
totals?: TransactionPayTotals;
|
|
121
130
|
};
|
|
131
|
+
/** Fiat payment state stored per transaction. */
|
|
132
|
+
export type TransactionFiatPayment = {
|
|
133
|
+
/** Entered fiat amount for the selected payment method. */
|
|
134
|
+
amountFiat?: string;
|
|
135
|
+
/** Selected fiat payment method ID. */
|
|
136
|
+
selectedPaymentMethodId?: string;
|
|
137
|
+
};
|
|
122
138
|
/** A token required by a transaction. */
|
|
123
139
|
export type TransactionPayRequiredToken = {
|
|
124
140
|
/** Address of the required token. */
|
|
@@ -347,6 +363,13 @@ export type UpdatePaymentTokenRequest = {
|
|
|
347
363
|
/** Chain ID of the new payment token. */
|
|
348
364
|
chainId: Hex;
|
|
349
365
|
};
|
|
366
|
+
/** Request to update fiat payment state for a transaction. */
|
|
367
|
+
export type UpdateFiatPaymentRequest = {
|
|
368
|
+
/** ID of the transaction to update. */
|
|
369
|
+
transactionId: string;
|
|
370
|
+
/** Callback to mutate fiat payment state. */
|
|
371
|
+
callback: TransactionFiatPaymentCallback;
|
|
372
|
+
};
|
|
350
373
|
/** Callback to convert a transaction to a redeem delegation. */
|
|
351
374
|
export type GetDelegationTransactionCallback = ({ transaction, }: {
|
|
352
375
|
transaction: TransactionMeta;
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,qCAAqC,EACtC,qCAAqC;AACtC,OAAO,KAAK,EAAE,kCAAkC,EAAE,qCAAqC;AACvF,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAqC;AACnF,OAAO,KAAK,EAAE,sCAAsC,EAAE,qCAAqC;AAC3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,kCAAkC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,oCAAoC;AAC3E,OAAO,KAAK,EAAE,sCAAsC,EAAE,2CAA2C;AACjG,OAAO,KAAK,EAAE,6BAA6B,EAAE,2CAA2C;AACxF,OAAO,KAAK,EAAE,uBAAuB,EAAE,qCAAqC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,mDAAmD,EAAE,qCAAqC;AACxG,OAAO,KAAK,EAAE,2CAA2C,EAAE,qCAAqC;AAChG,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAC1G,OAAO,KAA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ACV,EAAE,EAAE,GAAG,CAAC;IACR,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC,CAAC;AAEH,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.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CurrencyRateControllerActions,\n TokenBalancesControllerGetStateAction,\n} from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { BridgeControllerActions } from '@metamask/bridge-controller';\nimport type { BridgeStatusControllerStateChangeEvent } from '@metamask/bridge-status-controller';\nimport type { BridgeStatusControllerActions } from '@metamask/bridge-status-controller';\nimport type { GasFeeControllerActions } from '@metamask/gas-fee-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\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 { CONTROLLER_NAME, TransactionPayStrategy } from './constants';\n\nexport type AllowedActions =\n | AccountTrackerControllerGetStateAction\n | BridgeControllerActions\n | BridgeStatusControllerActions\n | CurrencyRateControllerActions\n | GasFeeControllerActions\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | TokenBalancesControllerGetStateAction\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | BridgeStatusControllerStateChangeEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;\n handler: GetDelegationTransactionCallback;\n};\n\n/** Action to get the pay strategy type used for a transaction. */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `${typeof CONTROLLER_NAME}:getStrategy`;\n handler: (transaction: TransactionMeta) => TransactionPayStrategy;\n};\n\n/** Action to update the payment token for a transaction. */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;\n handler: (request: UpdatePaymentTokenRequest) => void;\n};\n\n/** Action to update transaction configuration using a callback. */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `${typeof CONTROLLER_NAME}:setTransactionConfig`;\n handler: (transactionId: string, callback: TransactionConfigCallback) => void;\n};\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdatePaymentTokenAction;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\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 /** 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/** State relating to a single transaction. */\nexport type TransactionData = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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 /** 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/** 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/** 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 /** 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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay quote\n * request.\n */\n refundTo?: Hex;\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/** 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 /** 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 /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\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 /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\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 /** 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\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?: (request: PayStrategyGetQuotesRequest) => boolean;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\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 /** 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/** Callback to convert a transaction to a redeem delegation. */\nexport type GetDelegationTransactionCallback = ({\n transaction,\n}: {\n transaction: TransactionMeta;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: 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.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CurrencyRateControllerActions,\n TokenBalancesControllerGetStateAction,\n} from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { ControllerGetStateAction } from '@metamask/base-controller';\nimport type { BridgeControllerActions } from '@metamask/bridge-controller';\nimport type { BridgeStatusControllerStateChangeEvent } from '@metamask/bridge-status-controller';\nimport type { BridgeStatusControllerActions } from '@metamask/bridge-status-controller';\nimport type { GasFeeControllerActions } from '@metamask/gas-fee-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n AuthorizationList,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerEstimateGasAction,\n TransactionControllerEstimateGasBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type {\n BatchTransaction,\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 { CONTROLLER_NAME, TransactionPayStrategy } from './constants';\n\nexport type AllowedActions =\n | AccountTrackerControllerGetStateAction\n | BridgeControllerActions\n | BridgeStatusControllerActions\n | CurrencyRateControllerActions\n | GasFeeControllerActions\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | TokenBalancesControllerGetStateAction\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\n | TransactionControllerEstimateGasAction\n | TransactionControllerEstimateGasBatchAction\n | TransactionControllerGetGasFeeTokensAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction;\n\nexport type AllowedEvents =\n | BridgeStatusControllerStateChangeEvent\n | TransactionControllerStateChangeEvent\n | TransactionControllerUnapprovedTransactionAddedEvent;\n\nexport type TransactionPayControllerGetStateAction = ControllerGetStateAction<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n>;\n\nexport type TransactionPayControllerGetDelegationTransactionAction = {\n type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;\n handler: GetDelegationTransactionCallback;\n};\n\n/** Action to get the pay strategy type used for a transaction. */\nexport type TransactionPayControllerGetStrategyAction = {\n type: `${typeof CONTROLLER_NAME}:getStrategy`;\n handler: (transaction: TransactionMeta) => TransactionPayStrategy;\n};\n\n/** Action to update fiat payment state for a transaction. */\nexport type TransactionPayControllerUpdateFiatPaymentAction = {\n type: `${typeof CONTROLLER_NAME}:updateFiatPayment`;\n handler: (request: UpdateFiatPaymentRequest) => void;\n};\n\n/** Action to update the payment token for a transaction. */\nexport type TransactionPayControllerUpdatePaymentTokenAction = {\n type: `${typeof CONTROLLER_NAME}:updatePaymentToken`;\n handler: (request: UpdatePaymentTokenRequest) => void;\n};\n\n/** Action to update transaction configuration using a callback. */\nexport type TransactionPayControllerSetTransactionConfigAction = {\n type: `${typeof CONTROLLER_NAME}:setTransactionConfig`;\n handler: (transactionId: string, callback: TransactionConfigCallback) => void;\n};\n\n/** Configurable properties of a transaction. */\nexport type TransactionConfig = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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/** 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 | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\n | TransactionPayControllerSetTransactionConfigAction\n | TransactionPayControllerUpdateFiatPaymentAction\n | TransactionPayControllerUpdatePaymentTokenAction;\n\nexport type TransactionPayControllerEvents =\n TransactionPayControllerStateChangeEvent;\n\nexport type TransactionPayControllerMessenger = Messenger<\n typeof CONTROLLER_NAME,\n TransactionPayControllerActions | AllowedActions,\n TransactionPayControllerEvents | AllowedEvents\n>;\n\n/** Options for the TransactionPayController. */\nexport type TransactionPayControllerOptions = {\n /** Callback to convert a transaction into a redeem delegation. */\n getDelegationTransaction: GetDelegationTransactionCallback;\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 /** 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/** State relating to a single transaction. */\nexport type TransactionData = {\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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay 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 /** 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 /** 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/** 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 /** 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 /**\n * Optional address to receive refunds if the Relay transaction fails.\n * When set, overrides the default refund recipient (EOA) in the Relay quote\n * request.\n */\n refundTo?: Hex;\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/** 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 /** 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 /** Raw quote data returned by the provider. */\n original: OriginalQuote;\n\n /** Associated quote request. */\n request: QuoteRequest;\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 /** Controller messenger. */\n messenger: TransactionPayControllerMessenger;\n\n /** Quote requests for required tokens. */\n requests: QuoteRequest[];\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 /** 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\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?: (request: PayStrategyGetQuotesRequest) => boolean;\n\n /** Retrieve quotes for required tokens. */\n getQuotes: (\n request: PayStrategyGetQuotesRequest,\n ) => Promise<TransactionPayQuote<OriginalQuote>[]>;\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 /** 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}: {\n transaction: TransactionMeta;\n}) => Promise<{\n authorizationList?: AuthorizationList;\n data: Hex;\n to: Hex;\n value: 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": "16.
|
|
3
|
+
"version": "16.4.0-preview-93bf4ab29",
|
|
4
4
|
"description": "Manages alternate payment strategies to provide required funds for transactions in MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|