@metamask/transaction-pay-controller 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/TransactionPayController.cjs +6 -3
  3. package/dist/TransactionPayController.cjs.map +1 -1
  4. package/dist/TransactionPayController.d.cts +1 -1
  5. package/dist/TransactionPayController.d.cts.map +1 -1
  6. package/dist/TransactionPayController.d.mts +1 -1
  7. package/dist/TransactionPayController.d.mts.map +1 -1
  8. package/dist/TransactionPayController.mjs +6 -3
  9. package/dist/TransactionPayController.mjs.map +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/strategy/bridge/bridge-quotes.cjs.map +1 -1
  17. package/dist/strategy/bridge/bridge-quotes.mjs.map +1 -1
  18. package/dist/strategy/relay/constants.cjs +3 -1
  19. package/dist/strategy/relay/constants.cjs.map +1 -1
  20. package/dist/strategy/relay/constants.d.cts +2 -0
  21. package/dist/strategy/relay/constants.d.cts.map +1 -1
  22. package/dist/strategy/relay/constants.d.mts +2 -0
  23. package/dist/strategy/relay/constants.d.mts.map +1 -1
  24. package/dist/strategy/relay/constants.mjs +2 -0
  25. package/dist/strategy/relay/constants.mjs.map +1 -1
  26. package/dist/strategy/relay/relay-quotes.cjs +65 -25
  27. package/dist/strategy/relay/relay-quotes.cjs.map +1 -1
  28. package/dist/strategy/relay/relay-quotes.d.cts.map +1 -1
  29. package/dist/strategy/relay/relay-quotes.d.mts.map +1 -1
  30. package/dist/strategy/relay/relay-quotes.mjs +68 -28
  31. package/dist/strategy/relay/relay-quotes.mjs.map +1 -1
  32. package/dist/strategy/relay/relay-submit.cjs +29 -32
  33. package/dist/strategy/relay/relay-submit.cjs.map +1 -1
  34. package/dist/strategy/relay/relay-submit.d.cts.map +1 -1
  35. package/dist/strategy/relay/relay-submit.d.mts.map +1 -1
  36. package/dist/strategy/relay/relay-submit.mjs +30 -33
  37. package/dist/strategy/relay/relay-submit.mjs.map +1 -1
  38. package/dist/strategy/relay/types.cjs.map +1 -1
  39. package/dist/strategy/relay/types.d.cts +7 -2
  40. package/dist/strategy/relay/types.d.cts.map +1 -1
  41. package/dist/strategy/relay/types.d.mts +7 -2
  42. package/dist/strategy/relay/types.d.mts.map +1 -1
  43. package/dist/strategy/relay/types.mjs.map +1 -1
  44. package/dist/tests/messenger-mock.cjs +3 -0
  45. package/dist/tests/messenger-mock.cjs.map +1 -1
  46. package/dist/tests/messenger-mock.d.cts +20 -22
  47. package/dist/tests/messenger-mock.d.cts.map +1 -1
  48. package/dist/tests/messenger-mock.d.mts +20 -22
  49. package/dist/tests/messenger-mock.d.mts.map +1 -1
  50. package/dist/tests/messenger-mock.mjs +3 -0
  51. package/dist/tests/messenger-mock.mjs.map +1 -1
  52. package/dist/types.cjs.map +1 -1
  53. package/dist/types.d.cts +17 -2
  54. package/dist/types.d.cts.map +1 -1
  55. package/dist/types.d.mts +17 -2
  56. package/dist/types.d.mts.map +1 -1
  57. package/dist/types.mjs.map +1 -1
  58. package/dist/utils/totals.cjs +1 -1
  59. package/dist/utils/totals.cjs.map +1 -1
  60. package/dist/utils/totals.d.cts.map +1 -1
  61. package/dist/utils/totals.d.mts.map +1 -1
  62. package/dist/utils/totals.mjs +1 -1
  63. package/dist/utils/totals.mjs.map +1 -1
  64. package/package.json +2 -2
@@ -18,6 +18,7 @@ export declare function getMessengerMock({ skipRegister, }?: {
18
18
  getBridgeStatusControllerStateMock: jest.MockedFn<() => import("@metamask/bridge-status-controller").BridgeStatusControllerState>;
19
19
  getControllerStateMock: jest.MockedFn<() => import("../index.mjs").TransactionPayControllerState>;
20
20
  getCurrencyRateControllerStateMock: jest.Mock<any, any>;
21
+ getDelegationTransactionMock: jest.MockedFn<import("../types.mjs").GetDelegationTransactionCallback>;
21
22
  getGasFeeControllerStateMock: jest.Mock<any, any>;
22
23
  getNetworkClientByIdMock: jest.MockedFn<{
23
24
  (infuraNetworkClientId: import("@metamask/controller-utils").InfuraNetworkType): import("@metamask/network-controller").AutoManagedNetworkClient<import("@metamask/network-controller").InfuraNetworkClientConfiguration>;
@@ -178,28 +179,14 @@ export declare function getMessengerMock({ skipRegister, }?: {
178
179
  } | {
179
180
  unsignedPsbtBase64: string;
180
181
  inputsToSign: {}[] | null;
181
- };
182
- approval?: {
183
- chainId: number;
184
- to: string;
185
- from: string;
186
- value: string;
187
- data: string;
188
- gasLimit: number | null;
189
- effectiveGas?: number | undefined;
190
- } | undefined;
191
- } & {
192
- trade: string | {
193
- chainId: number;
194
- to: string;
195
- from: string;
196
- value: string;
197
- data: string;
198
- gasLimit: number | null;
199
- effectiveGas?: number | undefined;
200
182
  } | {
201
- unsignedPsbtBase64: string;
202
- inputsToSign: {}[] | null;
183
+ raw_data_hex: string;
184
+ visible?: boolean | undefined;
185
+ raw_data?: {
186
+ contract?: {
187
+ type?: string | undefined;
188
+ }[] | undefined;
189
+ } | null | undefined;
203
190
  };
204
191
  approval?: {
205
192
  chainId: number;
@@ -209,9 +196,20 @@ export declare function getMessengerMock({ skipRegister, }?: {
209
196
  data: string;
210
197
  gasLimit: number | null;
211
198
  effectiveGas?: number | undefined;
199
+ } | {
200
+ raw_data_hex: string;
201
+ visible?: boolean | undefined;
202
+ raw_data?: {
203
+ contract?: {
204
+ type?: string | undefined;
205
+ }[] | undefined;
206
+ } | null | undefined;
212
207
  } | undefined;
208
+ } & {
209
+ trade: import("@metamask/bridge-controller").Trade;
210
+ approval?: import("@metamask/bridge-controller").Trade | undefined;
213
211
  featureId?: import("@metamask/bridge-controller").FeatureId | undefined;
214
- } & Partial<import("@metamask/bridge-controller").QuoteMetadata>, isStxEnabledOnClient: boolean) => Promise<import("@metamask/transaction-controller").TransactionMeta & Partial<import("../../../bridge-status-controller/src/types.mjs").SolanaTransactionMeta>>>;
212
+ } & import("@metamask/bridge-controller").QuoteMetadata, isStxEnabledOnClient: boolean) => Promise<import("@metamask/transaction-controller").TransactionMeta & Partial<import("../../../bridge-status-controller/src/types.mjs").SolanaTransactionMeta>>>;
215
213
  updateTransactionMock: jest.MockedFn<(transactionMeta: import("@metamask/transaction-controller").TransactionMeta, note: string) => void>;
216
214
  };
217
215
  //# sourceMappingURL=messenger-mock.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messenger-mock.d.mts","sourceRoot":"","sources":["../../src/tests/messenger-mock.ts"],"names":[],"mappings":";AAqBA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAS5D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,GACb,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2LjC"}
1
+ {"version":3,"file":"messenger-mock.d.mts","sourceRoot":"","sources":["../../src/tests/messenger-mock.ts"],"names":[],"mappings":";AAqBA,OAAO,KAAK,EAAE,iCAAiC,EAAE,qBAAW;AAY5D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,GACb,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqMjC"}
@@ -25,6 +25,7 @@ export function getMessengerMock({ skipRegister, } = {}) {
25
25
  const getCurrencyRateControllerStateMock = jest.fn();
26
26
  const getAccountTrackerControllerStateMock = jest.fn();
27
27
  const getNetworkClientByIdMock = jest.fn();
28
+ const getDelegationTransactionMock = jest.fn();
28
29
  const messenger = new Messenger({
29
30
  namespace: MOCK_ANY_NAMESPACE,
30
31
  });
@@ -47,6 +48,7 @@ export function getMessengerMock({ skipRegister, } = {}) {
47
48
  messenger.registerActionHandler('AccountTrackerController:getState', getAccountTrackerControllerStateMock);
48
49
  messenger.registerActionHandler('CurrencyRateController:getState', getCurrencyRateControllerStateMock);
49
50
  messenger.registerActionHandler('NetworkController:getNetworkClientById', getNetworkClientByIdMock);
51
+ messenger.registerActionHandler('TransactionPayController:getDelegationTransaction', getDelegationTransactionMock);
50
52
  }
51
53
  const publish = messenger.publish.bind(messenger);
52
54
  return {
@@ -58,6 +60,7 @@ export function getMessengerMock({ skipRegister, } = {}) {
58
60
  getBridgeStatusControllerStateMock,
59
61
  getControllerStateMock,
60
62
  getCurrencyRateControllerStateMock,
63
+ getDelegationTransactionMock,
61
64
  getGasFeeControllerStateMock,
62
65
  getNetworkClientByIdMock,
63
66
  getRemoteFeatureFlagControllerStateMock,
@@ -1 +1 @@
1
- {"version":3,"file":"messenger-mock.mjs","sourceRoot":"","sources":["../../src/tests/messenger-mock.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAoBpE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,YAAY,MACkB,EAAE;IAChC,MAAM,sBAAsB,GAExB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,eAAe,GAEjB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,iCAAiC,GAEnC,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,kB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uCAAuC;QACvC,eAAe;QACf,kCAAkC;QAClC,gCAAgC;QAChC,4BAA4B;QAC5B,iCAAiC;QACjC,SAAS,EAAE,SAA8C;QACzD,OAAO;QACP,qBAAqB;QACrB,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokenBalancesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { BridgeStatusControllerGetStateAction } from '@metamask/bridge-status-controller';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\nimport { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerGetStateAction,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport type { BridgeStatusControllerSubmitTxAction } from '../../../bridge-status-controller/src/types';\nimport type { TransactionPayControllerGetStrategyAction } from '../types';\nimport { type TransactionPayControllerGetStateAction } from '../types';\n\ntype AllActions = MessengerActions<TransactionPayControllerMessenger>;\ntype AllEvents = MessengerEvents<TransactionPayControllerMessenger>;\ntype RootMessenger = Messenger<MockAnyNamespace, AllActions, AllEvents>;\n\n/**\n * Creates a mock controller messenger for testing.\n *\n * @param options - Options for creating the messenger mock.\n * @param options.skipRegister - Whether to skip registering action handlers.\n * @returns The mock messenger and associated mock functions.\n */\nexport function getMessengerMock({\n skipRegister,\n}: { skipRegister?: boolean } = {}) {\n const getControllerStateMock: jest.MockedFn<\n TransactionPayControllerGetStateAction['handler']\n > = jest.fn();\n\n const getStrategyMock: jest.MockedFn<\n TransactionPayControllerGetStrategyAction['handler']\n > = jest.fn();\n\n const getTransactionControllerStateMock: jest.MockedFn<\n TransactionControllerGetStateAction['handler']\n > = jest.fn();\n\n const addTransactionMock: jest.MockedFn<\n TransactionControllerAddTransactionAction['handler']\n > = jest.fn();\n\n const addTransactionBatchMock: jest.MockedFn<\n TransactionControllerAddTransactionBatchAction['handler']\n > = jest.fn();\n\n const findNetworkClientIdByChainIdMock: jest.MockedFn<\n NetworkControllerFindNetworkClientIdByChainIdAction['handler']\n > = jest.fn();\n\n const fetchQuotesMock = jest.fn();\n\n const getRemoteFeatureFlagControllerStateMock: jest.MockedFn<\n RemoteFeatureFlagControllerGetStateAction['handler']\n > = jest.fn();\n\n const getGasFeeControllerStateMock = jest.fn();\n\n const submitTransactionMock: jest.MockedFunction<\n BridgeStatusControllerSubmitTxAction['handler']\n > = jest.fn();\n\n const updateTransactionMock: jest.MockedFn<\n TransactionControllerUpdateTransactionAction['handler']\n > = jest.fn();\n\n const getBridgeStatusControllerStateMock: jest.MockedFn<\n BridgeStatusControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokensControllerStateMock: jest.MockedFn<\n TokensControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokenBalanceControllerStateMock: jest.MockedFn<\n TokenBalancesControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokenRatesControllerStateMock: jest.MockedFn<\n TokenRatesControllerGetStateAction['handler']\n > = jest.fn();\n\n const getCurrencyRateControllerStateMock = jest.fn();\n\n const getAccountTrackerControllerStateMock: jest.MockedFn<\n AccountTrackerControllerGetStateAction['handler']\n > = jest.fn();\n\n const getNetworkClientByIdMock: jest.MockedFn<\n NetworkControllerGetNetworkClientByIdAction['handler']\n > = jest.fn();\n\n const messenger: RootMessenger = new Messenger({\n namespace: MOCK_ANY_NAMESPACE,\n });\n\n if (skipRegister !== true) {\n messenger.registerActionHandler(\n 'TransactionPayController:getState',\n getControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n getStrategyMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:getState',\n getTransactionControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:addTransaction',\n addTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:addTransactionBatch',\n addTransactionBatchMock,\n );\n\n messenger.registerActionHandler(\n 'NetworkController:findNetworkClientIdByChainId',\n findNetworkClientIdByChainIdMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeController:fetchQuotes',\n fetchQuotesMock,\n );\n\n messenger.registerActionHandler(\n 'RemoteFeatureFlagController:getState',\n getRemoteFeatureFlagControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeStatusController:submitTx',\n submitTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'GasFeeController:getState',\n getGasFeeControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:updateTransaction',\n updateTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeStatusController:getState',\n getBridgeStatusControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokensController:getState',\n getTokensControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokenBalancesController:getState',\n getTokenBalanceControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokenRatesController:getState',\n getTokenRatesControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'AccountTrackerController:getState',\n getAccountTrackerControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'CurrencyRateController:getState',\n getCurrencyRateControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'NetworkController:getNetworkClientById',\n getNetworkClientByIdMock,\n );\n }\n\n const publish = messenger.publish.bind(messenger);\n\n return {\n addTransactionMock,\n addTransactionBatchMock,\n fetchQuotesMock,\n findNetworkClientIdByChainIdMock,\n getAccountTrackerControllerStateMock,\n getBridgeStatusControllerStateMock,\n getControllerStateMock,\n getCurrencyRateControllerStateMock,\n getGasFeeControllerStateMock,\n getNetworkClientByIdMock,\n getRemoteFeatureFlagControllerStateMock,\n getStrategyMock,\n getTokenBalanceControllerStateMock,\n getTokenRatesControllerStateMock,\n getTokensControllerStateMock,\n getTransactionControllerStateMock,\n messenger: messenger as TransactionPayControllerMessenger,\n publish,\n submitTransactionMock,\n updateTransactionMock,\n };\n}\n"]}
1
+ {"version":3,"file":"messenger-mock.mjs","sourceRoot":"","sources":["../../src/tests/messenger-mock.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,4BAA4B;AAuBpE;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,YAAY,MACkB,EAAE;IAChC,MAAM,sBAAsB,GAExB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,eAAe,GAEjB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,iCAAiC,GAEnC,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,kBAAkB,GAEpB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,uBAAuB,GAEzB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,gCAAgC,GAElC,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,eAAe,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAElC,MAAM,uCAAuC,GAEzC,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAE/C,MAAM,qBAAqB,GAEvB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,qBAAqB,GAEvB,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,kCAAkC,GAEpC,IAAI,CAAC,EAAE,EAAE,CAAC;IAEd,MAAM,4BAA4B,GAE9B,IAAI,CAAC,EAAE,EAAE,CAAC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;QAEF,SAAS,CAAC,qBAAqB,CAC7B,iCAAiC,EACjC,kCAAkC,CACnC,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,2BAA2B,EAC3B,4BAA4B,CAC7B,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,kCAAkC,EAClC,kCAAkC,CACnC,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,+BAA+B,EAC/B,gCAAgC,CACjC,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,mCAAmC,EACnC,oCAAoC,CACrC,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,iCAAiC,EACjC,kCAAkC,CACnC,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,wCAAwC,EACxC,wBAAwB,CACzB,CAAC;QAEF,SAAS,CAAC,qBAAqB,CAC7B,mDAAmD,EACnD,4BAA4B,CAC7B,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAElD,OAAO;QACL,kBAAkB;QAClB,uBAAuB;QACvB,eAAe;QACf,gCAAgC;QAChC,oCAAoC;QACpC,kCAAkC;QAClC,sBAAsB;QACtB,kCAAkC;QAClC,4BAA4B;QAC5B,4BAA4B;QAC5B,wBAAwB;QACxB,uCAAuC;QACvC,eAAe;QACf,kCAAkC;QAClC,gCAAgC;QAChC,4BAA4B;QAC5B,iCAAiC;QACjC,SAAS,EAAE,SAA8C;QACzD,OAAO;QACP,qBAAqB;QACrB,qBAAqB;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import type { TokensControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokenBalancesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { TokenRatesControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { AccountTrackerControllerGetStateAction } from '@metamask/assets-controllers';\nimport type { BridgeStatusControllerGetStateAction } from '@metamask/bridge-status-controller';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\nimport { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger';\nimport type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';\nimport type { NetworkControllerFindNetworkClientIdByChainIdAction } from '@metamask/network-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerAddTransactionBatchAction,\n TransactionControllerGetStateAction,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\n\nimport type { TransactionPayControllerMessenger } from '..';\nimport type { BridgeStatusControllerSubmitTxAction } from '../../../bridge-status-controller/src/types';\nimport type {\n TransactionPayControllerGetDelegationTransactionAction,\n TransactionPayControllerGetStrategyAction,\n} from '../types';\nimport { type TransactionPayControllerGetStateAction } from '../types';\n\ntype AllActions = MessengerActions<TransactionPayControllerMessenger>;\ntype AllEvents = MessengerEvents<TransactionPayControllerMessenger>;\ntype RootMessenger = Messenger<MockAnyNamespace, AllActions, AllEvents>;\n\n/**\n * Creates a mock controller messenger for testing.\n *\n * @param options - Options for creating the messenger mock.\n * @param options.skipRegister - Whether to skip registering action handlers.\n * @returns The mock messenger and associated mock functions.\n */\nexport function getMessengerMock({\n skipRegister,\n}: { skipRegister?: boolean } = {}) {\n const getControllerStateMock: jest.MockedFn<\n TransactionPayControllerGetStateAction['handler']\n > = jest.fn();\n\n const getStrategyMock: jest.MockedFn<\n TransactionPayControllerGetStrategyAction['handler']\n > = jest.fn();\n\n const getTransactionControllerStateMock: jest.MockedFn<\n TransactionControllerGetStateAction['handler']\n > = jest.fn();\n\n const addTransactionMock: jest.MockedFn<\n TransactionControllerAddTransactionAction['handler']\n > = jest.fn();\n\n const addTransactionBatchMock: jest.MockedFn<\n TransactionControllerAddTransactionBatchAction['handler']\n > = jest.fn();\n\n const findNetworkClientIdByChainIdMock: jest.MockedFn<\n NetworkControllerFindNetworkClientIdByChainIdAction['handler']\n > = jest.fn();\n\n const fetchQuotesMock = jest.fn();\n\n const getRemoteFeatureFlagControllerStateMock: jest.MockedFn<\n RemoteFeatureFlagControllerGetStateAction['handler']\n > = jest.fn();\n\n const getGasFeeControllerStateMock = jest.fn();\n\n const submitTransactionMock: jest.MockedFunction<\n BridgeStatusControllerSubmitTxAction['handler']\n > = jest.fn();\n\n const updateTransactionMock: jest.MockedFn<\n TransactionControllerUpdateTransactionAction['handler']\n > = jest.fn();\n\n const getBridgeStatusControllerStateMock: jest.MockedFn<\n BridgeStatusControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokensControllerStateMock: jest.MockedFn<\n TokensControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokenBalanceControllerStateMock: jest.MockedFn<\n TokenBalancesControllerGetStateAction['handler']\n > = jest.fn();\n\n const getTokenRatesControllerStateMock: jest.MockedFn<\n TokenRatesControllerGetStateAction['handler']\n > = jest.fn();\n\n const getCurrencyRateControllerStateMock = jest.fn();\n\n const getAccountTrackerControllerStateMock: jest.MockedFn<\n AccountTrackerControllerGetStateAction['handler']\n > = jest.fn();\n\n const getNetworkClientByIdMock: jest.MockedFn<\n NetworkControllerGetNetworkClientByIdAction['handler']\n > = jest.fn();\n\n const getDelegationTransactionMock: jest.MockedFn<\n TransactionPayControllerGetDelegationTransactionAction['handler']\n > = jest.fn();\n\n const messenger: RootMessenger = new Messenger({\n namespace: MOCK_ANY_NAMESPACE,\n });\n\n if (skipRegister !== true) {\n messenger.registerActionHandler(\n 'TransactionPayController:getState',\n getControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionPayController:getStrategy',\n getStrategyMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:getState',\n getTransactionControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:addTransaction',\n addTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:addTransactionBatch',\n addTransactionBatchMock,\n );\n\n messenger.registerActionHandler(\n 'NetworkController:findNetworkClientIdByChainId',\n findNetworkClientIdByChainIdMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeController:fetchQuotes',\n fetchQuotesMock,\n );\n\n messenger.registerActionHandler(\n 'RemoteFeatureFlagController:getState',\n getRemoteFeatureFlagControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeStatusController:submitTx',\n submitTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'GasFeeController:getState',\n getGasFeeControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionController:updateTransaction',\n updateTransactionMock,\n );\n\n messenger.registerActionHandler(\n 'BridgeStatusController:getState',\n getBridgeStatusControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokensController:getState',\n getTokensControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokenBalancesController:getState',\n getTokenBalanceControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'TokenRatesController:getState',\n getTokenRatesControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'AccountTrackerController:getState',\n getAccountTrackerControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'CurrencyRateController:getState',\n getCurrencyRateControllerStateMock,\n );\n\n messenger.registerActionHandler(\n 'NetworkController:getNetworkClientById',\n getNetworkClientByIdMock,\n );\n\n messenger.registerActionHandler(\n 'TransactionPayController:getDelegationTransaction',\n getDelegationTransactionMock,\n );\n }\n\n const publish = messenger.publish.bind(messenger);\n\n return {\n addTransactionMock,\n addTransactionBatchMock,\n fetchQuotesMock,\n findNetworkClientIdByChainIdMock,\n getAccountTrackerControllerStateMock,\n getBridgeStatusControllerStateMock,\n getControllerStateMock,\n getCurrencyRateControllerStateMock,\n getDelegationTransactionMock,\n getGasFeeControllerStateMock,\n getNetworkClientByIdMock,\n getRemoteFeatureFlagControllerStateMock,\n getStrategyMock,\n getTokenBalanceControllerStateMock,\n getTokenRatesControllerStateMock,\n getTokensControllerStateMock,\n getTransactionControllerStateMock,\n messenger: messenger as TransactionPayControllerMessenger,\n publish,\n submitTransactionMock,\n updateTransactionMock,\n };\n}\n"]}
@@ -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 { TokenListControllerActions } 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 TransactionControllerAddTransactionBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerStateChangeEvent } from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\nimport type { BatchTransaction } 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 | TokenListControllerActions\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\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\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) => Promise<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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\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 select the PayStrategy for a transaction. */\n getStrategy?: (\n transaction: TransactionMeta,\n ) => Promise<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 /** Source token selected for the transaction. */\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 /** Address of the required 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 /** 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 /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: FiatValue;\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 /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\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 /** 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 /** 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"]}
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 { TokenListControllerActions } 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 TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerStateChangeEvent } from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\nimport type { BatchTransaction } 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 | TokenListControllerActions\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\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) => Promise<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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\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?: (\n transaction: TransactionMeta,\n ) => Promise<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 /** Source token selected for the transaction. */\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 /** Address of the required 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 /** 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 /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: FiatValue;\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 /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\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 /** 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 /** 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"]}
package/dist/types.d.cts CHANGED
@@ -13,7 +13,7 @@ import type { Messenger } from "@metamask/messenger";
13
13
  import type { NetworkControllerFindNetworkClientIdByChainIdAction } from "@metamask/network-controller";
14
14
  import type { NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
15
15
  import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
16
- import type { TransactionControllerAddTransactionBatchAction, TransactionControllerUnapprovedTransactionAddedEvent } from "@metamask/transaction-controller";
16
+ import type { AuthorizationList, TransactionControllerAddTransactionBatchAction, TransactionControllerUnapprovedTransactionAddedEvent } from "@metamask/transaction-controller";
17
17
  import type { TransactionControllerGetStateAction } from "@metamask/transaction-controller";
18
18
  import type { TransactionControllerStateChangeEvent } from "@metamask/transaction-controller";
19
19
  import type { TransactionMeta } from "@metamask/transaction-controller";
@@ -26,6 +26,10 @@ import type { CONTROLLER_NAME, TransactionPayStrategy } from "./constants.cjs";
26
26
  export type AllowedActions = AccountTrackerControllerGetStateAction | BridgeControllerActions | BridgeStatusControllerActions | CurrencyRateControllerActions | GasFeeControllerActions | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | TokenBalancesControllerGetStateAction | TokenListControllerActions | TokenRatesControllerGetStateAction | TokensControllerGetStateAction | TransactionControllerAddTransactionAction | TransactionControllerAddTransactionBatchAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction;
27
27
  export type AllowedEvents = BridgeStatusControllerStateChangeEvent | TransactionControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent;
28
28
  export type TransactionPayControllerGetStateAction = ControllerGetStateAction<typeof CONTROLLER_NAME, TransactionPayControllerState>;
29
+ export type TransactionPayControllerGetDelegationTransactionAction = {
30
+ type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;
31
+ handler: GetDelegationTransactionCallback;
32
+ };
29
33
  /** Action to get the pay strategy type used for a transaction. */
30
34
  export type TransactionPayControllerGetStrategyAction = {
31
35
  type: `${typeof CONTROLLER_NAME}:getStrategy`;
@@ -37,11 +41,13 @@ export type TransactionPayControllerUpdatePaymentTokenAction = {
37
41
  handler: (request: UpdatePaymentTokenRequest) => void;
38
42
  };
39
43
  export type TransactionPayControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, TransactionPayControllerState>;
40
- export type TransactionPayControllerActions = TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerUpdatePaymentTokenAction;
44
+ export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerUpdatePaymentTokenAction;
41
45
  export type TransactionPayControllerEvents = TransactionPayControllerStateChangeEvent;
42
46
  export type TransactionPayControllerMessenger = Messenger<typeof CONTROLLER_NAME, TransactionPayControllerActions | AllowedActions, TransactionPayControllerEvents | AllowedEvents>;
43
47
  /** Options for the TransactionPayController. */
44
48
  export type TransactionPayControllerOptions = {
49
+ /** Callback to convert a transaction into a redeem delegation. */
50
+ getDelegationTransaction: GetDelegationTransactionCallback;
45
51
  /** Callback to select the PayStrategy for a transaction. */
46
52
  getStrategy?: (transaction: TransactionMeta) => Promise<TransactionPayStrategy>;
47
53
  /** Controller messenger. */
@@ -261,4 +267,13 @@ export type UpdatePaymentTokenRequest = {
261
267
  /** Chain ID of the new payment token. */
262
268
  chainId: Hex;
263
269
  };
270
+ /** Callback to convert a transaction to a redeem delegation. */
271
+ export type GetDelegationTransactionCallback = ({ transaction, }: {
272
+ transaction: TransactionMeta;
273
+ }) => Promise<{
274
+ authorizationList?: AuthorizationList;
275
+ data: Hex;
276
+ to: Hex;
277
+ value: Hex;
278
+ }>;
264
279
  //# sourceMappingURL=types.d.cts.map
@@ -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,0BAA0B,EAAE,qCAAqC;AAC/E,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,E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EAAE,GAAG,CAAC;KACvB,CAAC,CAAC;CACJ,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG;IACtB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAE1B,4DAA4D;IAC5D,IAAI,EAAE,kBAAkB,CAAC;IAEzB,oEAAoE;IACpE,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,yBAAyB,GAAG;IACtC,uCAAuC;IACvC,aAAa,EAAE,MAAM,CAAC;IAEtB,wCAAwC;IACxC,YAAY,EAAE,GAAG,CAAC;IAElB,yCAAyC;IACzC,OAAO,EAAE,GAAG,CAAC;CACd,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"}
package/dist/types.d.mts CHANGED
@@ -13,7 +13,7 @@ import type { Messenger } from "@metamask/messenger";
13
13
  import type { NetworkControllerFindNetworkClientIdByChainIdAction } from "@metamask/network-controller";
14
14
  import type { NetworkControllerGetNetworkClientByIdAction } from "@metamask/network-controller";
15
15
  import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
16
- import type { TransactionControllerAddTransactionBatchAction, TransactionControllerUnapprovedTransactionAddedEvent } from "@metamask/transaction-controller";
16
+ import type { AuthorizationList, TransactionControllerAddTransactionBatchAction, TransactionControllerUnapprovedTransactionAddedEvent } from "@metamask/transaction-controller";
17
17
  import type { TransactionControllerGetStateAction } from "@metamask/transaction-controller";
18
18
  import type { TransactionControllerStateChangeEvent } from "@metamask/transaction-controller";
19
19
  import type { TransactionMeta } from "@metamask/transaction-controller";
@@ -26,6 +26,10 @@ import type { CONTROLLER_NAME, TransactionPayStrategy } from "./constants.mjs";
26
26
  export type AllowedActions = AccountTrackerControllerGetStateAction | BridgeControllerActions | BridgeStatusControllerActions | CurrencyRateControllerActions | GasFeeControllerActions | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | TokenBalancesControllerGetStateAction | TokenListControllerActions | TokenRatesControllerGetStateAction | TokensControllerGetStateAction | TransactionControllerAddTransactionAction | TransactionControllerAddTransactionBatchAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction;
27
27
  export type AllowedEvents = BridgeStatusControllerStateChangeEvent | TransactionControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent;
28
28
  export type TransactionPayControllerGetStateAction = ControllerGetStateAction<typeof CONTROLLER_NAME, TransactionPayControllerState>;
29
+ export type TransactionPayControllerGetDelegationTransactionAction = {
30
+ type: `${typeof CONTROLLER_NAME}:getDelegationTransaction`;
31
+ handler: GetDelegationTransactionCallback;
32
+ };
29
33
  /** Action to get the pay strategy type used for a transaction. */
30
34
  export type TransactionPayControllerGetStrategyAction = {
31
35
  type: `${typeof CONTROLLER_NAME}:getStrategy`;
@@ -37,11 +41,13 @@ export type TransactionPayControllerUpdatePaymentTokenAction = {
37
41
  handler: (request: UpdatePaymentTokenRequest) => void;
38
42
  };
39
43
  export type TransactionPayControllerStateChangeEvent = ControllerStateChangeEvent<typeof CONTROLLER_NAME, TransactionPayControllerState>;
40
- export type TransactionPayControllerActions = TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerUpdatePaymentTokenAction;
44
+ export type TransactionPayControllerActions = TransactionPayControllerGetDelegationTransactionAction | TransactionPayControllerGetStateAction | TransactionPayControllerGetStrategyAction | TransactionPayControllerUpdatePaymentTokenAction;
41
45
  export type TransactionPayControllerEvents = TransactionPayControllerStateChangeEvent;
42
46
  export type TransactionPayControllerMessenger = Messenger<typeof CONTROLLER_NAME, TransactionPayControllerActions | AllowedActions, TransactionPayControllerEvents | AllowedEvents>;
43
47
  /** Options for the TransactionPayController. */
44
48
  export type TransactionPayControllerOptions = {
49
+ /** Callback to convert a transaction into a redeem delegation. */
50
+ getDelegationTransaction: GetDelegationTransactionCallback;
45
51
  /** Callback to select the PayStrategy for a transaction. */
46
52
  getStrategy?: (transaction: TransactionMeta) => Promise<TransactionPayStrategy>;
47
53
  /** Controller messenger. */
@@ -261,4 +267,13 @@ export type UpdatePaymentTokenRequest = {
261
267
  /** Chain ID of the new payment token. */
262
268
  chainId: Hex;
263
269
  };
270
+ /** Callback to convert a transaction to a redeem delegation. */
271
+ export type GetDelegationTransactionCallback = ({ transaction, }: {
272
+ transaction: TransactionMeta;
273
+ }) => Promise<{
274
+ authorizationList?: AuthorizationList;
275
+ data: Hex;
276
+ to: Hex;
277
+ value: Hex;
278
+ }>;
264
279
  //# sourceMappingURL=types.d.mts.map
@@ -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,0BAA0B,EAAE,qCAAqC;AAC/E,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;AAC3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":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n CurrencyRateControllerActions,\n TokenBalancesControllerGetStateAction,\n} from '@metamask/assets-controllers';\nimport type { TokenListControllerActions } 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 TransactionControllerAddTransactionBatchAction,\n TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerStateChangeEvent } from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\nimport type { BatchTransaction } 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 | TokenListControllerActions\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\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\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) => Promise<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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\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 select the PayStrategy for a transaction. */\n getStrategy?: (\n transaction: TransactionMeta,\n ) => Promise<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 /** Source token selected for the transaction. */\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 /** Address of the required 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 /** 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 /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: FiatValue;\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 /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\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 /** 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 /** 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"]}
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 { TokenListControllerActions } 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 TransactionControllerUnapprovedTransactionAddedEvent,\n} from '@metamask/transaction-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerStateChangeEvent } from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\nimport type { TransactionControllerUpdateTransactionAction } from '@metamask/transaction-controller';\nimport type { BatchTransaction } 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 | TokenListControllerActions\n | TokenRatesControllerGetStateAction\n | TokensControllerGetStateAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerAddTransactionBatchAction\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) => Promise<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\nexport type TransactionPayControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof CONTROLLER_NAME,\n TransactionPayControllerState\n >;\n\nexport type TransactionPayControllerActions =\n | TransactionPayControllerGetDelegationTransactionAction\n | TransactionPayControllerGetStateAction\n | TransactionPayControllerGetStrategyAction\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?: (\n transaction: TransactionMeta,\n ) => Promise<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 /** Source token selected for the transaction. */\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 /** Address of the required 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 /** 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 /** Fee charged by the quote provider. */\n provider: FiatValue;\n\n /** Network fee for transactions on the source network. */\n sourceNetwork: FiatValue;\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 /** Name of the strategy used to retrieve the quote. */\n strategy: TransactionPayStrategy;\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 /** 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 /** 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"]}
@@ -25,7 +25,7 @@ function calculateTotals({ quotes, messenger, tokens, transaction, }) {
25
25
  const targetNetworkFeeUsd = quotes.length
26
26
  ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)
27
27
  : transactionNetworkFee.usd;
28
- const quoteTokens = tokens.filter((t) => !t.skipIfBalance || new bignumber_js_1.BigNumber(t.balanceRaw).isLessThan(t.amountRaw));
28
+ const quoteTokens = tokens.filter((t) => !t.skipIfBalance);
29
29
  const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);
30
30
  const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);
31
31
  const totalFiat = new bignumber_js_1.BigNumber(providerFeeFiat)
@@ -1 +1 @@
1
- {"version":3,"file":"totals.cjs","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":";;;AACA,+CAAyC;AAEzC,mCAAoD;AAQpD;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GAMZ;IACC,MAAM,eAAe,GAAG,WAAW,CACjC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CACpC,CAAC;IAEF,MAAM,cAAc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,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport { calculateTransactionGasCost } from './gas';\nimport type {\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPayTotals,\n} from '../types';\n\n/**\n * Calculate totals for a list of quotes and tokens.\n *\n * @param request - Request parameters.\n * @param request.quotes - List of bridge quotes.\n * @param request.messenger - Controller messenger.\n * @param request.tokens - List of required tokens.\n * @param request.transaction - Transaction metadata.\n * @returns The calculated totals in USD and fiat currency.\n */\nexport function calculateTotals({\n quotes,\n messenger,\n tokens,\n transaction,\n}: {\n quotes: TransactionPayQuote<unknown>[];\n messenger: TransactionPayControllerMessenger;\n tokens: TransactionPayRequiredToken[];\n transaction: TransactionMeta;\n}): TransactionPayTotals {\n const providerFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.provider.fiat,\n );\n\n const providerFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.provider.usd,\n );\n\n const sourceNetworkFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.fiat,\n );\n\n const sourceNetworkFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.usd,\n );\n\n const transactionNetworkFee = calculateTransactionGasCost(\n transaction,\n messenger,\n );\n\n const targetNetworkFeeFiat = quotes?.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.fiat)\n : transactionNetworkFee.fiat;\n\n const targetNetworkFeeUsd = quotes.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)\n : transactionNetworkFee.usd;\n\n const quoteTokens = tokens.filter(\n (t) =>\n !t.skipIfBalance || new BigNumber(t.balanceRaw).isLessThan(t.amountRaw),\n );\n\n const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);\n const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);\n\n const totalFiat = new BigNumber(providerFeeFiat)\n .plus(sourceNetworkFeeFiat)\n .plus(targetNetworkFeeFiat)\n .plus(amountFiat)\n .toString(10);\n\n const totalUsd = new BigNumber(providerFeeUsd)\n .plus(sourceNetworkFeeUsd)\n .plus(targetNetworkFeeUsd)\n .plus(amountUsd)\n .toString(10);\n\n const estimatedDuration = Number(\n sumProperty(quotes, (quote) => quote.estimatedDuration),\n );\n\n return {\n estimatedDuration,\n fees: {\n provider: {\n fiat: providerFeeFiat,\n usd: providerFeeUsd,\n },\n sourceNetwork: {\n fiat: sourceNetworkFeeFiat,\n usd: sourceNetworkFeeUsd,\n },\n targetNetwork: {\n fiat: targetNetworkFeeFiat,\n usd: targetNetworkFeeUsd,\n },\n },\n total: {\n fiat: totalFiat,\n usd: totalUsd,\n },\n };\n}\n\n/**\n * Sum a specific property from a list of items.\n *\n * @param data - List of items.\n * @param getProperty - Function to extract the property to sum from each item.\n * @returns The summed value as a string.\n */\nfunction sumProperty<T>(\n data: T[],\n getProperty: (item: T) => BigNumber.Value,\n): string {\n return data\n .map(getProperty)\n .reduce<BigNumber>((total, value) => total.plus(value), new BigNumber(0))\n .toString(10);\n}\n"]}
1
+ {"version":3,"file":"totals.cjs","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":";;;AACA,+CAAyC;AAEzC,mCAAoD;AAQpD;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GAMZ;IACC,MAAM,eAAe,GAAG,WAAW,CACjC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CACpC,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CACtC,MAAM,EACN,CAAC,KAA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AEhB,MAAM,QAAQ,GAAG,IAAI,wBAAS,CAAC,cAAc,CAAC;SAC3C,IAAI,CAAC,mBAAmB,CAAC;SACzB,IAAI,CAAC,mBAAmB,CAAC;SACzB,IAAI,CAAC,SAAS,CAAC;SACf,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhB,MAAM,iBAAiB,GAAG,MAAM,CAC9B,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CACxD,CAAC;IAEF,OAAO;QACL,iBAAiB;QACjB,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE,cAAc;aACpB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;SACF;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,QAAQ;SACd;KACF,CAAC;AACJ,CAAC;AArFD,0CAqFC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,IAAS,EACT,WAAyC;IAEzC,OAAO,IAAI;SACR,GAAG,CAAC,WAAW,CAAC;SAChB,MAAM,CAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC;SACxE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport { calculateTransactionGasCost } from './gas';\nimport type {\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPayTotals,\n} from '../types';\n\n/**\n * Calculate totals for a list of quotes and tokens.\n *\n * @param request - Request parameters.\n * @param request.quotes - List of bridge quotes.\n * @param request.messenger - Controller messenger.\n * @param request.tokens - List of required tokens.\n * @param request.transaction - Transaction metadata.\n * @returns The calculated totals in USD and fiat currency.\n */\nexport function calculateTotals({\n quotes,\n messenger,\n tokens,\n transaction,\n}: {\n quotes: TransactionPayQuote<unknown>[];\n messenger: TransactionPayControllerMessenger;\n tokens: TransactionPayRequiredToken[];\n transaction: TransactionMeta;\n}): TransactionPayTotals {\n const providerFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.provider.fiat,\n );\n\n const providerFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.provider.usd,\n );\n\n const sourceNetworkFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.fiat,\n );\n\n const sourceNetworkFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.usd,\n );\n\n const transactionNetworkFee = calculateTransactionGasCost(\n transaction,\n messenger,\n );\n\n const targetNetworkFeeFiat = quotes?.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.fiat)\n : transactionNetworkFee.fiat;\n\n const targetNetworkFeeUsd = quotes.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)\n : transactionNetworkFee.usd;\n\n const quoteTokens = tokens.filter((t) => !t.skipIfBalance);\n const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);\n const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);\n\n const totalFiat = new BigNumber(providerFeeFiat)\n .plus(sourceNetworkFeeFiat)\n .plus(targetNetworkFeeFiat)\n .plus(amountFiat)\n .toString(10);\n\n const totalUsd = new BigNumber(providerFeeUsd)\n .plus(sourceNetworkFeeUsd)\n .plus(targetNetworkFeeUsd)\n .plus(amountUsd)\n .toString(10);\n\n const estimatedDuration = Number(\n sumProperty(quotes, (quote) => quote.estimatedDuration),\n );\n\n return {\n estimatedDuration,\n fees: {\n provider: {\n fiat: providerFeeFiat,\n usd: providerFeeUsd,\n },\n sourceNetwork: {\n fiat: sourceNetworkFeeFiat,\n usd: sourceNetworkFeeUsd,\n },\n targetNetwork: {\n fiat: targetNetworkFeeFiat,\n usd: targetNetworkFeeUsd,\n },\n },\n total: {\n fiat: totalFiat,\n usd: totalUsd,\n },\n };\n}\n\n/**\n * Sum a specific property from a list of items.\n *\n * @param data - List of items.\n * @param getProperty - Function to extract the property to sum from each item.\n * @returns The summed value as a string.\n */\nfunction sumProperty<T>(\n data: T[],\n getProperty: (item: T) => BigNumber.Value,\n): string {\n return data\n .map(getProperty)\n .reduce<BigNumber>((total, value) => total.plus(value), new BigNumber(0))\n .toString(10);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"totals.d.cts","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAIxE,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACrB,qBAAiB;AAElB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;IACvC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACtC,WAAW,EAAE,eAAe,CAAC;CAC9B,GAAG,oBAAoB,CA+EvB"}
1
+ {"version":3,"file":"totals.d.cts","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAIxE,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACrB,qBAAiB;AAElB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;IACvC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACtC,WAAW,EAAE,eAAe,CAAC;CAC9B,GAAG,oBAAoB,CA2EvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"totals.d.mts","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAIxE,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACrB,qBAAiB;AAElB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;IACvC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACtC,WAAW,EAAE,eAAe,CAAC;CAC9B,GAAG,oBAAoB,CA+EvB"}
1
+ {"version":3,"file":"totals.d.mts","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AAIxE,OAAO,KAAK,EACV,iCAAiC,EACjC,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACrB,qBAAiB;AAElB;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;IACvC,SAAS,EAAE,iCAAiC,CAAC;IAC7C,MAAM,EAAE,2BAA2B,EAAE,CAAC;IACtC,WAAW,EAAE,eAAe,CAAC;CAC9B,GAAG,oBAAoB,CA2EvB"}
@@ -22,7 +22,7 @@ export function calculateTotals({ quotes, messenger, tokens, transaction, }) {
22
22
  const targetNetworkFeeUsd = quotes.length
23
23
  ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)
24
24
  : transactionNetworkFee.usd;
25
- const quoteTokens = tokens.filter((t) => !t.skipIfBalance || new BigNumber(t.balanceRaw).isLessThan(t.amountRaw));
25
+ const quoteTokens = tokens.filter((t) => !t.skipIfBalance);
26
26
  const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);
27
27
  const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);
28
28
  const totalFiat = new BigNumber(providerFeeFiat)
@@ -1 +1 @@
1
- {"version":3,"file":"totals.mjs","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EAAE,2BAA2B,EAAE,kBAAc;AAQpD;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GAMZ;IACC,MAAM,eAAe,GAAG,WAAW,CACjC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CACpC,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CACtC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CACzC,CAAC;IAEF,MAAM,mBAAmB,GAAG,WAAW,CACrC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CACxC,CAAC;IAEF,MAAM,qBAAqB,GAAG,2BAA2B,CACvD,WAAW,EACX,SAAS,CACV,CAAC;IAEF,M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,iBAAiB,GAAG,MAAM,CAC9B,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CACxD,CAAC;IAEF,OAAO;QACL,iBAAiB;QACjB,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE,cAAc;aACpB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;SACF;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,QAAQ;SACd;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,IAAS,EACT,WAAyC;IAEzC,OAAO,IAAI;SACR,GAAG,CAAC,WAAW,CAAC;SAChB,MAAM,CAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACxE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport { calculateTransactionGasCost } from './gas';\nimport type {\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPayTotals,\n} from '../types';\n\n/**\n * Calculate totals for a list of quotes and tokens.\n *\n * @param request - Request parameters.\n * @param request.quotes - List of bridge quotes.\n * @param request.messenger - Controller messenger.\n * @param request.tokens - List of required tokens.\n * @param request.transaction - Transaction metadata.\n * @returns The calculated totals in USD and fiat currency.\n */\nexport function calculateTotals({\n quotes,\n messenger,\n tokens,\n transaction,\n}: {\n quotes: TransactionPayQuote<unknown>[];\n messenger: TransactionPayControllerMessenger;\n tokens: TransactionPayRequiredToken[];\n transaction: TransactionMeta;\n}): TransactionPayTotals {\n const providerFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.provider.fiat,\n );\n\n const providerFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.provider.usd,\n );\n\n const sourceNetworkFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.fiat,\n );\n\n const sourceNetworkFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.usd,\n );\n\n const transactionNetworkFee = calculateTransactionGasCost(\n transaction,\n messenger,\n );\n\n const targetNetworkFeeFiat = quotes?.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.fiat)\n : transactionNetworkFee.fiat;\n\n const targetNetworkFeeUsd = quotes.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)\n : transactionNetworkFee.usd;\n\n const quoteTokens = tokens.filter(\n (t) =>\n !t.skipIfBalance || new BigNumber(t.balanceRaw).isLessThan(t.amountRaw),\n );\n\n const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);\n const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);\n\n const totalFiat = new BigNumber(providerFeeFiat)\n .plus(sourceNetworkFeeFiat)\n .plus(targetNetworkFeeFiat)\n .plus(amountFiat)\n .toString(10);\n\n const totalUsd = new BigNumber(providerFeeUsd)\n .plus(sourceNetworkFeeUsd)\n .plus(targetNetworkFeeUsd)\n .plus(amountUsd)\n .toString(10);\n\n const estimatedDuration = Number(\n sumProperty(quotes, (quote) => quote.estimatedDuration),\n );\n\n return {\n estimatedDuration,\n fees: {\n provider: {\n fiat: providerFeeFiat,\n usd: providerFeeUsd,\n },\n sourceNetwork: {\n fiat: sourceNetworkFeeFiat,\n usd: sourceNetworkFeeUsd,\n },\n targetNetwork: {\n fiat: targetNetworkFeeFiat,\n usd: targetNetworkFeeUsd,\n },\n },\n total: {\n fiat: totalFiat,\n usd: totalUsd,\n },\n };\n}\n\n/**\n * Sum a specific property from a list of items.\n *\n * @param data - List of items.\n * @param getProperty - Function to extract the property to sum from each item.\n * @returns The summed value as a string.\n */\nfunction sumProperty<T>(\n data: T[],\n getProperty: (item: T) => BigNumber.Value,\n): string {\n return data\n .map(getProperty)\n .reduce<BigNumber>((total, value) => total.plus(value), new BigNumber(0))\n .toString(10);\n}\n"]}
1
+ {"version":3,"file":"totals.mjs","sourceRoot":"","sources":["../../src/utils/totals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EAAE,2BAA2B,EAAE,kBAAc;AAQpD;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,GAMZ;IACC,MAAM,eAAe,GAAG,WAAW,CACjC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CACpC,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CACtC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CACzC,CAAC;IAEF,MAAM,mBAAmB,GAAG,WAAW,CACrC,MAAM,EACN,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CACxC,CAAC;IAEF,MAAM,qBAAqB,GAAG,2BAA2B,CACvD,WAAW,EACX,SAAS,CACV,CAAC;IAEF,MAAM,oBAAoB,GAAG,MAAM,EAAE,MAAM;QACzC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAA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ACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,oBAAoB;gBAC1B,GAAG,EAAE,mBAAmB;aACzB;SACF;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,QAAQ;SACd;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,IAAS,EACT,WAAyC;IAEzC,OAAO,IAAI;SACR,GAAG,CAAC,WAAW,CAAC;SAChB,MAAM,CAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACxE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import type { TransactionMeta } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport { calculateTransactionGasCost } from './gas';\nimport type {\n TransactionPayControllerMessenger,\n TransactionPayQuote,\n TransactionPayRequiredToken,\n TransactionPayTotals,\n} from '../types';\n\n/**\n * Calculate totals for a list of quotes and tokens.\n *\n * @param request - Request parameters.\n * @param request.quotes - List of bridge quotes.\n * @param request.messenger - Controller messenger.\n * @param request.tokens - List of required tokens.\n * @param request.transaction - Transaction metadata.\n * @returns The calculated totals in USD and fiat currency.\n */\nexport function calculateTotals({\n quotes,\n messenger,\n tokens,\n transaction,\n}: {\n quotes: TransactionPayQuote<unknown>[];\n messenger: TransactionPayControllerMessenger;\n tokens: TransactionPayRequiredToken[];\n transaction: TransactionMeta;\n}): TransactionPayTotals {\n const providerFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.provider.fiat,\n );\n\n const providerFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.provider.usd,\n );\n\n const sourceNetworkFeeFiat = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.fiat,\n );\n\n const sourceNetworkFeeUsd = sumProperty(\n quotes,\n (quote) => quote.fees.sourceNetwork.usd,\n );\n\n const transactionNetworkFee = calculateTransactionGasCost(\n transaction,\n messenger,\n );\n\n const targetNetworkFeeFiat = quotes?.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.fiat)\n : transactionNetworkFee.fiat;\n\n const targetNetworkFeeUsd = quotes.length\n ? sumProperty(quotes, (quote) => quote.fees.targetNetwork.usd)\n : transactionNetworkFee.usd;\n\n const quoteTokens = tokens.filter((t) => !t.skipIfBalance);\n const amountFiat = sumProperty(quoteTokens, (token) => token.amountFiat);\n const amountUsd = sumProperty(quoteTokens, (token) => token.amountUsd);\n\n const totalFiat = new BigNumber(providerFeeFiat)\n .plus(sourceNetworkFeeFiat)\n .plus(targetNetworkFeeFiat)\n .plus(amountFiat)\n .toString(10);\n\n const totalUsd = new BigNumber(providerFeeUsd)\n .plus(sourceNetworkFeeUsd)\n .plus(targetNetworkFeeUsd)\n .plus(amountUsd)\n .toString(10);\n\n const estimatedDuration = Number(\n sumProperty(quotes, (quote) => quote.estimatedDuration),\n );\n\n return {\n estimatedDuration,\n fees: {\n provider: {\n fiat: providerFeeFiat,\n usd: providerFeeUsd,\n },\n sourceNetwork: {\n fiat: sourceNetworkFeeFiat,\n usd: sourceNetworkFeeUsd,\n },\n targetNetwork: {\n fiat: targetNetworkFeeFiat,\n usd: targetNetworkFeeUsd,\n },\n },\n total: {\n fiat: totalFiat,\n usd: totalUsd,\n },\n };\n}\n\n/**\n * Sum a specific property from a list of items.\n *\n * @param data - List of items.\n * @param getProperty - Function to extract the property to sum from each item.\n * @returns The summed value as a string.\n */\nfunction sumProperty<T>(\n data: T[],\n getProperty: (item: T) => BigNumber.Value,\n): string {\n return data\n .map(getProperty)\n .reduce<BigNumber>((total, value) => total.plus(value), new BigNumber(0))\n .toString(10);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/transaction-pay-controller",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Manages alternate payment strategies to provide required funds for transactions in MetaMask",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -69,7 +69,7 @@
69
69
  "@metamask/gas-fee-controller": "^25.0.0",
70
70
  "@metamask/network-controller": "^25.0.0",
71
71
  "@metamask/remote-feature-flag-controller": "^2.0.0",
72
- "@metamask/transaction-controller": "^61.1.0",
72
+ "@metamask/transaction-controller": "^61.2.0",
73
73
  "@ts-bridge/cli": "^0.6.4",
74
74
  "@types/jest": "^27.4.1",
75
75
  "deepmerge": "^4.2.2",