@metamask-previews/user-operation-controller 41.2.9-preview-3e34650c2 → 41.2.9-preview-4f4c98e

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 (155) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/{BlockTrackerPollingController.d.mts → BlockTrackerPollingController.d.ts} +11 -11
  3. package/dist/BlockTrackerPollingController.d.ts.map +1 -0
  4. package/dist/{BlockTrackerPollingController.mjs → BlockTrackerPollingController.js} +17 -16
  5. package/dist/BlockTrackerPollingController.js.map +1 -0
  6. package/dist/{UserOperationController-method-action-types.d.cts → UserOperationController-method-action-types.d.ts} +2 -2
  7. package/dist/UserOperationController-method-action-types.d.ts.map +1 -0
  8. package/dist/{UserOperationController-method-action-types.mjs → UserOperationController-method-action-types.js} +1 -1
  9. package/dist/UserOperationController-method-action-types.js.map +1 -0
  10. package/dist/{UserOperationController.d.cts → UserOperationController.d.ts} +13 -15
  11. package/dist/UserOperationController.d.ts.map +1 -0
  12. package/dist/{UserOperationController.mjs → UserOperationController.js} +19 -20
  13. package/dist/UserOperationController.js.map +1 -0
  14. package/dist/{constants.d.cts → constants.d.ts} +1 -1
  15. package/dist/constants.d.ts.map +1 -0
  16. package/dist/{constants.mjs → constants.js} +1 -1
  17. package/dist/constants.js.map +1 -0
  18. package/dist/helpers/{Bundler.d.cts → Bundler.d.ts} +2 -2
  19. package/dist/helpers/Bundler.d.ts.map +1 -0
  20. package/dist/helpers/{Bundler.mjs → Bundler.js} +2 -2
  21. package/dist/helpers/Bundler.js.map +1 -0
  22. package/dist/helpers/{PendingUserOperationTracker.d.cts → PendingUserOperationTracker.d.ts} +10 -12
  23. package/dist/helpers/PendingUserOperationTracker.d.ts.map +1 -0
  24. package/dist/helpers/{PendingUserOperationTracker.mjs → PendingUserOperationTracker.js} +9 -16
  25. package/dist/helpers/PendingUserOperationTracker.js.map +1 -0
  26. package/dist/helpers/{SnapSmartContractAccount.d.cts → SnapSmartContractAccount.d.ts} +3 -3
  27. package/dist/helpers/SnapSmartContractAccount.d.ts.map +1 -0
  28. package/dist/helpers/{SnapSmartContractAccount.mjs → SnapSmartContractAccount.js} +3 -3
  29. package/dist/helpers/SnapSmartContractAccount.js.map +1 -0
  30. package/dist/index.d.ts +4 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +3 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/logger.d.ts +4 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/{logger.mjs → logger.js} +2 -2
  37. package/dist/logger.js.map +1 -0
  38. package/dist/{types.d.mts → types.d.ts} +3 -3
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/{types.mjs → types.js} +1 -1
  41. package/dist/types.js.map +1 -0
  42. package/dist/utils/{chain-id.d.cts → chain-id.d.ts} +1 -1
  43. package/dist/utils/chain-id.d.ts.map +1 -0
  44. package/dist/utils/{chain-id.mjs → chain-id.js} +1 -1
  45. package/dist/utils/chain-id.js.map +1 -0
  46. package/dist/utils/{gas-fees.d.cts → gas-fees.d.ts} +6 -6
  47. package/dist/utils/gas-fees.d.ts.map +1 -0
  48. package/dist/utils/{gas-fees.mjs → gas-fees.js} +8 -15
  49. package/dist/utils/gas-fees.js.map +1 -0
  50. package/dist/utils/{gas.d.mts → gas.d.ts} +2 -2
  51. package/dist/utils/gas.d.ts.map +1 -0
  52. package/dist/utils/{gas.mjs → gas.js} +7 -14
  53. package/dist/utils/gas.js.map +1 -0
  54. package/dist/utils/{transaction.d.cts → transaction.d.ts} +3 -3
  55. package/dist/utils/transaction.d.ts.map +1 -0
  56. package/dist/utils/{transaction.mjs → transaction.js} +6 -13
  57. package/dist/utils/transaction.js.map +1 -0
  58. package/dist/utils/{validation.d.cts → validation.d.ts} +3 -3
  59. package/dist/utils/validation.d.ts.map +1 -0
  60. package/dist/utils/{validation.mjs → validation.js} +5 -5
  61. package/dist/utils/validation.js.map +1 -0
  62. package/package.json +13 -17
  63. package/dist/BlockTrackerPollingController.cjs +0 -68
  64. package/dist/BlockTrackerPollingController.cjs.map +0 -1
  65. package/dist/BlockTrackerPollingController.d.cts +0 -41
  66. package/dist/BlockTrackerPollingController.d.cts.map +0 -1
  67. package/dist/BlockTrackerPollingController.d.mts.map +0 -1
  68. package/dist/BlockTrackerPollingController.mjs.map +0 -1
  69. package/dist/UserOperationController-method-action-types.cjs +0 -7
  70. package/dist/UserOperationController-method-action-types.cjs.map +0 -1
  71. package/dist/UserOperationController-method-action-types.d.cts.map +0 -1
  72. package/dist/UserOperationController-method-action-types.d.mts +0 -57
  73. package/dist/UserOperationController-method-action-types.d.mts.map +0 -1
  74. package/dist/UserOperationController-method-action-types.mjs.map +0 -1
  75. package/dist/UserOperationController.cjs +0 -495
  76. package/dist/UserOperationController.cjs.map +0 -1
  77. package/dist/UserOperationController.d.cts.map +0 -1
  78. package/dist/UserOperationController.d.mts +0 -136
  79. package/dist/UserOperationController.d.mts.map +0 -1
  80. package/dist/UserOperationController.mjs.map +0 -1
  81. package/dist/constants.cjs +0 -7
  82. package/dist/constants.cjs.map +0 -1
  83. package/dist/constants.d.cts.map +0 -1
  84. package/dist/constants.d.mts +0 -4
  85. package/dist/constants.d.mts.map +0 -1
  86. package/dist/constants.mjs.map +0 -1
  87. package/dist/helpers/Bundler.cjs +0 -91
  88. package/dist/helpers/Bundler.cjs.map +0 -1
  89. package/dist/helpers/Bundler.d.cts.map +0 -1
  90. package/dist/helpers/Bundler.d.mts +0 -46
  91. package/dist/helpers/Bundler.d.mts.map +0 -1
  92. package/dist/helpers/Bundler.mjs.map +0 -1
  93. package/dist/helpers/PendingUserOperationTracker.cjs +0 -127
  94. package/dist/helpers/PendingUserOperationTracker.cjs.map +0 -1
  95. package/dist/helpers/PendingUserOperationTracker.d.cts.map +0 -1
  96. package/dist/helpers/PendingUserOperationTracker.d.mts +0 -51
  97. package/dist/helpers/PendingUserOperationTracker.d.mts.map +0 -1
  98. package/dist/helpers/PendingUserOperationTracker.mjs.map +0 -1
  99. package/dist/helpers/SnapSmartContractAccount.cjs +0 -64
  100. package/dist/helpers/SnapSmartContractAccount.cjs.map +0 -1
  101. package/dist/helpers/SnapSmartContractAccount.d.cts.map +0 -1
  102. package/dist/helpers/SnapSmartContractAccount.d.mts +0 -10
  103. package/dist/helpers/SnapSmartContractAccount.d.mts.map +0 -1
  104. package/dist/helpers/SnapSmartContractAccount.mjs.map +0 -1
  105. package/dist/index.cjs +0 -19
  106. package/dist/index.cjs.map +0 -1
  107. package/dist/index.d.cts +0 -4
  108. package/dist/index.d.cts.map +0 -1
  109. package/dist/index.d.mts +0 -4
  110. package/dist/index.d.mts.map +0 -1
  111. package/dist/index.mjs +0 -3
  112. package/dist/index.mjs.map +0 -1
  113. package/dist/logger.cjs +0 -8
  114. package/dist/logger.cjs.map +0 -1
  115. package/dist/logger.d.cts +0 -5
  116. package/dist/logger.d.cts.map +0 -1
  117. package/dist/logger.d.mts +0 -5
  118. package/dist/logger.d.mts.map +0 -1
  119. package/dist/logger.mjs.map +0 -1
  120. package/dist/types.cjs +0 -16
  121. package/dist/types.cjs.map +0 -1
  122. package/dist/types.d.cts +0 -294
  123. package/dist/types.d.cts.map +0 -1
  124. package/dist/types.d.mts.map +0 -1
  125. package/dist/types.mjs.map +0 -1
  126. package/dist/utils/chain-id.cjs +0 -17
  127. package/dist/utils/chain-id.cjs.map +0 -1
  128. package/dist/utils/chain-id.d.cts.map +0 -1
  129. package/dist/utils/chain-id.d.mts +0 -8
  130. package/dist/utils/chain-id.d.mts.map +0 -1
  131. package/dist/utils/chain-id.mjs.map +0 -1
  132. package/dist/utils/gas-fees.cjs +0 -194
  133. package/dist/utils/gas-fees.cjs.map +0 -1
  134. package/dist/utils/gas-fees.d.cts.map +0 -1
  135. package/dist/utils/gas-fees.d.mts +0 -24
  136. package/dist/utils/gas-fees.d.mts.map +0 -1
  137. package/dist/utils/gas-fees.mjs.map +0 -1
  138. package/dist/utils/gas.cjs +0 -72
  139. package/dist/utils/gas.cjs.map +0 -1
  140. package/dist/utils/gas.d.cts +0 -10
  141. package/dist/utils/gas.d.cts.map +0 -1
  142. package/dist/utils/gas.d.mts.map +0 -1
  143. package/dist/utils/gas.mjs.map +0 -1
  144. package/dist/utils/transaction.cjs +0 -117
  145. package/dist/utils/transaction.cjs.map +0 -1
  146. package/dist/utils/transaction.d.cts.map +0 -1
  147. package/dist/utils/transaction.d.mts +0 -10
  148. package/dist/utils/transaction.d.mts.map +0 -1
  149. package/dist/utils/transaction.mjs.map +0 -1
  150. package/dist/utils/validation.cjs +0 -162
  151. package/dist/utils/validation.cjs.map +0 -1
  152. package/dist/utils/validation.d.cts.map +0 -1
  153. package/dist/utils/validation.d.mts +0 -33
  154. package/dist/utils/validation.d.mts.map +0 -1
  155. package/dist/utils/validation.mjs.map +0 -1
@@ -1,51 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="npm-which/node_modules/@types/node/events.js" />
3
- import type { NetworkClient, NetworkClientId } from "@metamask/network-controller";
4
- import EventEmitter from "events";
5
- import type { UserOperationMetadata } from "../types.mjs";
6
- import type { UserOperationControllerMessenger } from "../UserOperationController.mjs";
7
- type Events = {
8
- 'user-operation-confirmed': [metadata: UserOperationMetadata];
9
- 'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];
10
- 'user-operation-updated': [txMeta: UserOperationMetadata];
11
- };
12
- export type PendingUserOperationTrackerEventEmitter = EventEmitter & {
13
- on<T extends keyof Events>(eventName: T, listener: (...args: Events[T]) => void): PendingUserOperationTrackerEventEmitter;
14
- once<T extends keyof Events>(eventName: T, listener: (...args: Events[T]) => void): PendingUserOperationTrackerEventEmitter;
15
- emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;
16
- };
17
- /** The input to start polling for the {@link PendingUserOperationTracker} */
18
- type PendingUserOperationPollingInput = {
19
- networkClientId: NetworkClientId;
20
- };
21
- declare const PendingUserOperationTracker_base: (abstract new (...args: any[]) => {
22
- "__#21@#activeListeners": Record<string, (options: import("@metamask/utils").Json) => Promise<void>>;
23
- _getNetworkClientById(networkClientId: string): NetworkClient | undefined;
24
- _startPolling(input: PendingUserOperationPollingInput): void;
25
- _stopPollingByPollingTokenSetId(key: string): void;
26
- readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
27
- readonly "__#3@#callbacks": Map<string, Set<(input: PendingUserOperationPollingInput) => void>>;
28
- _executePoll(input: PendingUserOperationPollingInput): Promise<void>;
29
- startPolling(input: PendingUserOperationPollingInput): string;
30
- stopAllPolling(): void;
31
- stopPollingByPollingToken(pollingToken: string): void;
32
- onPollingComplete(input: PendingUserOperationPollingInput, callback: (input: PendingUserOperationPollingInput) => void): void;
33
- }) & {
34
- new (): {};
35
- };
36
- /**
37
- * A helper class to periodically query the bundlers
38
- * and update the status of any submitted user operations.
39
- */
40
- export declare class PendingUserOperationTracker extends PendingUserOperationTracker_base {
41
- #private;
42
- hub: PendingUserOperationTrackerEventEmitter;
43
- constructor({ getUserOperations, messenger, }: {
44
- getUserOperations: () => UserOperationMetadata[];
45
- messenger: UserOperationControllerMessenger;
46
- });
47
- _executePoll({ networkClientId }: PendingUserOperationPollingInput): Promise<void>;
48
- _getNetworkClientById(networkClientId: string): NetworkClient | undefined;
49
- }
50
- export {};
51
- //# sourceMappingURL=PendingUserOperationTracker.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PendingUserOperationTracker.d.mts","sourceRoot":"","sources":["../../src/helpers/PendingUserOperationTracker.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,qCAAqC;AAKtC,OAAO,YAAY,eAAe;AAIlC,OAAO,KAAK,EAAE,qBAAqB,EAAwB,qBAAoB;AAE/E,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAKtF,KAAK,MAAM,GAAG;IACZ,0BAA0B,EAAE,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC9D,uBAAuB,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,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\n NetworkClient,\n NetworkClientId,\n Provider,\n} from '@metamask/network-controller';\nimport { createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n// This package purposefully relies on Node's EventEmitter module.\n// eslint-disable-next-line import-x/no-nodejs-modules\nimport EventEmitter from 'events';\n\nimport { BlockTrackerPollingControllerOnly } from '../BlockTrackerPollingController.js';\nimport { projectLogger } from '../logger.js';\nimport type { UserOperationMetadata, UserOperationReceipt } from '../types.js';\nimport { UserOperationStatus } from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { Bundler } from './Bundler.js';\n\nconst log = createModuleLogger(projectLogger, 'pending-user-operations');\n\ntype Events = {\n 'user-operation-confirmed': [metadata: UserOperationMetadata];\n 'user-operation-failed': [txMeta: UserOperationMetadata, error: Error];\n 'user-operation-updated': [txMeta: UserOperationMetadata];\n};\n\nexport type PendingUserOperationTrackerEventEmitter = EventEmitter & {\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n once<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): PendingUserOperationTrackerEventEmitter;\n\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n};\n\n/** The input to start polling for the {@link PendingUserOperationTracker} */\ntype PendingUserOperationPollingInput = {\n networkClientId: NetworkClientId;\n};\n\n/**\n * A helper class to periodically query the bundlers\n * and update the status of any submitted user operations.\n */\nexport class PendingUserOperationTracker extends BlockTrackerPollingControllerOnly<PendingUserOperationPollingInput>() {\n hub: PendingUserOperationTrackerEventEmitter;\n\n readonly #getUserOperations: () => UserOperationMetadata[];\n\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor({\n getUserOperations,\n messenger,\n }: {\n getUserOperations: () => UserOperationMetadata[];\n messenger: UserOperationControllerMessenger;\n }) {\n super();\n\n this.hub = new EventEmitter() as PendingUserOperationTrackerEventEmitter;\n\n this.#getUserOperations = getUserOperations;\n this.#messenger = messenger;\n }\n\n async _executePoll({ networkClientId }: PendingUserOperationPollingInput) {\n try {\n const { blockTracker, configuration, provider } =\n this._getNetworkClientById(networkClientId) as NetworkClient;\n\n log('Polling', {\n blockNumber: blockTracker.getCurrentBlock(),\n chainId: configuration.chainId,\n });\n\n await this.#checkUserOperations(configuration.chainId, provider);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check user operations', error);\n }\n }\n\n _getNetworkClientById(networkClientId: string): NetworkClient | undefined {\n return this.#messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n }\n\n async #checkUserOperations(chainId: string, provider: Provider) {\n const pendingUserOperations = this.#getPendingUserOperations().filter(\n (metadata) => metadata.chainId === chainId,\n );\n\n if (!pendingUserOperations.length) {\n log('No pending user operations to check');\n return;\n }\n\n log('Found pending user operations to check', {\n count: pendingUserOperations.length,\n ids: pendingUserOperations.map((userOperation) => userOperation.id),\n });\n\n await Promise.all(\n pendingUserOperations.map((userOperation) =>\n this.#checkUserOperation(userOperation, provider),\n ),\n );\n }\n\n async #checkUserOperation(\n metadata: UserOperationMetadata,\n provider: Provider,\n ) {\n const { bundlerUrl, hash, id } = metadata;\n\n if (!hash || !bundlerUrl) {\n log('Skipping user operation as missing hash or bundler', id);\n return;\n }\n\n try {\n const receipt = await this.#getUserOperationReceipt(hash, bundlerUrl);\n const isSuccess = receipt?.success;\n\n if (receipt && !isSuccess) {\n this.#onUserOperationFailed(metadata, receipt);\n return;\n }\n\n if (isSuccess) {\n await this.#onUserOperationConfirmed(metadata, receipt, provider);\n return;\n }\n\n log('No receipt found for user operation', { id, hash });\n } catch (error) {\n log('Failed to check user operation', id, error);\n }\n }\n\n async #onUserOperationConfirmed(\n metadata: UserOperationMetadata,\n receipt: UserOperationReceipt,\n provider: Provider,\n ) {\n const { id } = metadata;\n\n const {\n actualGasCost,\n actualGasUsed,\n receipt: { blockHash, transactionHash },\n } = receipt;\n\n log('User operation confirmed', id, transactionHash);\n\n const { baseFeePerGas } = await query(\n new EthQuery(provider),\n 'getBlockByHash',\n [blockHash, false],\n );\n\n metadata.actualGasCost = this.#normalizeGasValue(actualGasCost);\n metadata.actualGasUsed = this.#normalizeGasValue(actualGasUsed);\n metadata.baseFeePerGas = baseFeePerGas;\n metadata.status = UserOperationStatus.Confirmed;\n metadata.transactionHash = transactionHash;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit('user-operation-confirmed', metadata);\n }\n\n #onUserOperationFailed(\n metadata: UserOperationMetadata,\n _receipt: UserOperationReceipt,\n ) {\n const { id } = metadata;\n\n log('User operation failed', id);\n\n metadata.status = UserOperationStatus.Failed;\n\n this.#updateUserOperation(metadata);\n\n this.hub.emit(\n 'user-operation-failed',\n metadata,\n new Error('User operation receipt has failed status'),\n );\n }\n\n #getPendingUserOperations(): UserOperationMetadata[] {\n return this.#getUserOperations().filter(\n (userOperation) => userOperation.status === UserOperationStatus.Submitted,\n );\n }\n\n #updateUserOperation(metadata: UserOperationMetadata) {\n this.hub.emit('user-operation-updated', metadata);\n }\n\n async #getUserOperationReceipt(\n hash: string,\n bundlerUrl: string,\n ): Promise<UserOperationReceipt | undefined> {\n const bundler = new Bundler(bundlerUrl);\n return bundler.getUserOperationReceipt(hash);\n }\n\n #normalizeGasValue(gasValue: Hex | number): string {\n if (typeof gasValue === 'number') {\n return toHex(gasValue);\n }\n return gasValue;\n }\n}\n"]}
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _SnapSmartContractAccount_messenger;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SnapSmartContractAccount = void 0;
16
- const constants_js_1 = require("../constants.cjs");
17
- const chain_id_js_1 = require("../utils/chain-id.cjs");
18
- class SnapSmartContractAccount {
19
- constructor(messenger) {
20
- _SnapSmartContractAccount_messenger.set(this, void 0);
21
- __classPrivateFieldSet(this, _SnapSmartContractAccount_messenger, messenger, "f");
22
- }
23
- async prepareUserOperation(request) {
24
- const { chainId, data: requestData, from: sender, to: requestTo, value: requestValue, } = request;
25
- const data = requestData ?? constants_js_1.EMPTY_BYTES;
26
- const to = requestTo ?? constants_js_1.ADDRESS_ZERO;
27
- const value = requestValue ?? constants_js_1.VALUE_ZERO;
28
- const response = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:prepareUserOperation', sender, [{ data, to, value }], { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
29
- const { bundlerUrl: bundler, callData, dummyPaymasterAndData, dummySignature, gasLimits: gas, initCode, nonce, } = response;
30
- return {
31
- bundler,
32
- callData,
33
- dummyPaymasterAndData,
34
- dummySignature,
35
- gas,
36
- initCode,
37
- nonce,
38
- sender,
39
- };
40
- }
41
- async updateUserOperation(request) {
42
- const { userOperation, chainId } = request;
43
- const { sender } = userOperation;
44
- const { paymasterAndData: responsePaymasterAndData, verificationGasLimit, preVerificationGas, callGasLimit, } = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:patchUserOperation', sender, userOperation, { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
45
- const paymasterAndData = responsePaymasterAndData === constants_js_1.EMPTY_BYTES
46
- ? undefined
47
- : responsePaymasterAndData;
48
- return {
49
- paymasterAndData,
50
- verificationGasLimit,
51
- preVerificationGas,
52
- callGasLimit,
53
- };
54
- }
55
- async signUserOperation(request) {
56
- const { userOperation, chainId } = request;
57
- const { sender } = userOperation;
58
- const signature = await __classPrivateFieldGet(this, _SnapSmartContractAccount_messenger, "f").call('KeyringController:signUserOperation', sender, userOperation, { chainId: (0, chain_id_js_1.toEip155ChainId)(chainId) });
59
- return { signature };
60
- }
61
- }
62
- exports.SnapSmartContractAccount = SnapSmartContractAccount;
63
- _SnapSmartContractAccount_messenger = new WeakMap();
64
- //# sourceMappingURL=SnapSmartContractAccount.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SnapSmartContractAccount.cjs","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAwE;AAWxE,uDAAuD;AAEvD,MAAa,wBAAwB;IAGnC,YAAY,SAA2C;QAF9C,sDAA6C;QAGpD,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,OAAoC;QAEpC,MAAM,EACJ,OAAO,EACP,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,YAAY,GACpB,GAAG,OAAO,CAAC;QAEZ,MAAM,IAAI,GAAG,WAAW,IAAI,0BAAW,CAAC;QACxC,MAAM,EAAE,GAAG,SAAS,IAAI,2BAAY,CAAC;QACrC,MAAM,KAAK,GAAG,YAAY,IAAI,yBAAU,CAAC;QAEzC,MAAM,QAAQ,GAAG,MAAM,uBAAA,IAAI,2CAAW,CAAC,IAAI,CACzC,wCAAwC,EACxC,MAAM,EACN,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EACrB,EAAE,OAAO,EAAE,IAAA,6BAAe,EAAC,OAAO,CAAC,EAAE,CACtC,CAAC;QAE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AAjGD,4DAiGC","sourcesContent":["import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from '../constants.js';\nimport type {\n PrepareUserOperationRequest,\n PrepareUserOperationResponse,\n SignUserOperationRequest,\n SignUserOperationResponse,\n SmartContractAccount,\n UpdateUserOperationRequest,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { toEip155ChainId } from '../utils/chain-id.js';\n\nexport class SnapSmartContractAccount implements SmartContractAccount {\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor(messenger: UserOperationControllerMessenger) {\n this.#messenger = messenger;\n }\n\n async prepareUserOperation(\n request: PrepareUserOperationRequest,\n ): Promise<PrepareUserOperationResponse> {\n const {\n chainId,\n data: requestData,\n from: sender,\n to: requestTo,\n value: requestValue,\n } = request;\n\n const data = requestData ?? EMPTY_BYTES;\n const to = requestTo ?? ADDRESS_ZERO;\n const value = requestValue ?? VALUE_ZERO;\n\n const response = await this.#messenger.call(\n 'KeyringController:prepareUserOperation',\n sender,\n [{ data, to, value }],\n { chainId: toEip155ChainId(chainId) },\n );\n\n const {\n bundlerUrl: bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gasLimits: gas,\n initCode,\n nonce,\n } = response;\n\n return {\n bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gas,\n initCode,\n nonce,\n sender,\n };\n }\n\n async updateUserOperation(\n request: UpdateUserOperationRequest,\n ): Promise<UpdateUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const {\n paymasterAndData: responsePaymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n } = await this.#messenger.call(\n 'KeyringController:patchUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n const paymasterAndData =\n responsePaymasterAndData === EMPTY_BYTES\n ? undefined\n : responsePaymasterAndData;\n\n return {\n paymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n };\n }\n\n async signUserOperation(\n request: SignUserOperationRequest,\n ): Promise<SignUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const signature = await this.#messenger.call(\n 'KeyringController:signUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n return { signature };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SnapSmartContractAccount.d.cts","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAGtF,qBAAa,wBAAyB,YAAW,oBAAoB;;gBAGvD,SAAS,EAAE,gCAAgC;IAIjD,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IA0ClC,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IA6BjC,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC;CAatC"}
@@ -1,10 +0,0 @@
1
- import type { PrepareUserOperationRequest, PrepareUserOperationResponse, SignUserOperationRequest, SignUserOperationResponse, SmartContractAccount, UpdateUserOperationRequest, UpdateUserOperationResponse } from "../types.mjs";
2
- import type { UserOperationControllerMessenger } from "../UserOperationController.mjs";
3
- export declare class SnapSmartContractAccount implements SmartContractAccount {
4
- #private;
5
- constructor(messenger: UserOperationControllerMessenger);
6
- prepareUserOperation(request: PrepareUserOperationRequest): Promise<PrepareUserOperationResponse>;
7
- updateUserOperation(request: UpdateUserOperationRequest): Promise<UpdateUserOperationResponse>;
8
- signUserOperation(request: SignUserOperationRequest): Promise<SignUserOperationResponse>;
9
- }
10
- //# sourceMappingURL=SnapSmartContractAccount.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SnapSmartContractAccount.d.mts","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC5B,qBAAoB;AACrB,OAAO,KAAK,EAAE,gCAAgC,EAAE,uCAAsC;AAGtF,qBAAa,wBAAyB,YAAW,oBAAoB;;gBAGvD,SAAS,EAAE,gCAAgC;IAIjD,oBAAoB,CACxB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,4BAA4B,CAAC;IA0ClC,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IA6BjC,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,yBAAyB,CAAC;CAatC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SnapSmartContractAccount.mjs","sourceRoot":"","sources":["../../src/helpers/SnapSmartContractAccount.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,yBAAwB;AAWxE,OAAO,EAAE,eAAe,EAAE,8BAA6B;AAEvD,MAAM,OAAO,wBAAwB;IAGnC,YAAY,SAA2C;QAF9C,sDAA6C;QAGpD,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,OAAoC;QAEpC,MAAM,EACJ,OAAO,EACP,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,YAAY,GACpB,GAAG,OAAO,CAAC;QAEZ,MAAM,IAAI,GAAG,WAAW,IAAI,WAAW,CAAC;QACxC,MAAM,EAAE,GA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AAO,CAAC;QAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;QAEjC,MAAM,SAAS,GAAG,MAAM,uBAAA,IAAI,2CAAW,CAAC,IAAI,CAC1C,qCAAqC,EACrC,MAAM,EACN,aAAa,EACb,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CACtC,CAAC;QAEF,OAAO,EAAE,SAAS,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from '../constants.js';\nimport type {\n PrepareUserOperationRequest,\n PrepareUserOperationResponse,\n SignUserOperationRequest,\n SignUserOperationResponse,\n SmartContractAccount,\n UpdateUserOperationRequest,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type { UserOperationControllerMessenger } from '../UserOperationController.js';\nimport { toEip155ChainId } from '../utils/chain-id.js';\n\nexport class SnapSmartContractAccount implements SmartContractAccount {\n readonly #messenger: UserOperationControllerMessenger;\n\n constructor(messenger: UserOperationControllerMessenger) {\n this.#messenger = messenger;\n }\n\n async prepareUserOperation(\n request: PrepareUserOperationRequest,\n ): Promise<PrepareUserOperationResponse> {\n const {\n chainId,\n data: requestData,\n from: sender,\n to: requestTo,\n value: requestValue,\n } = request;\n\n const data = requestData ?? EMPTY_BYTES;\n const to = requestTo ?? ADDRESS_ZERO;\n const value = requestValue ?? VALUE_ZERO;\n\n const response = await this.#messenger.call(\n 'KeyringController:prepareUserOperation',\n sender,\n [{ data, to, value }],\n { chainId: toEip155ChainId(chainId) },\n );\n\n const {\n bundlerUrl: bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gasLimits: gas,\n initCode,\n nonce,\n } = response;\n\n return {\n bundler,\n callData,\n dummyPaymasterAndData,\n dummySignature,\n gas,\n initCode,\n nonce,\n sender,\n };\n }\n\n async updateUserOperation(\n request: UpdateUserOperationRequest,\n ): Promise<UpdateUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const {\n paymasterAndData: responsePaymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n } = await this.#messenger.call(\n 'KeyringController:patchUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n const paymasterAndData =\n responsePaymasterAndData === EMPTY_BYTES\n ? undefined\n : responsePaymasterAndData;\n\n return {\n paymasterAndData,\n verificationGasLimit,\n preVerificationGas,\n callGasLimit,\n };\n }\n\n async signUserOperation(\n request: SignUserOperationRequest,\n ): Promise<SignUserOperationResponse> {\n const { userOperation, chainId } = request;\n const { sender } = userOperation;\n\n const signature = await this.#messenger.call(\n 'KeyringController:signUserOperation',\n sender,\n userOperation,\n { chainId: toEip155ChainId(chainId) },\n );\n\n return { signature };\n }\n}\n"]}
package/dist/index.cjs DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./UserOperationController.cjs"), exports);
18
- __exportStar(require("./types.cjs"), exports);
19
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA6C;AAM7C,8CAA2B","sourcesContent":["export * from './UserOperationController.js';\nexport type {\n UserOperationControllerAddUserOperationAction,\n UserOperationControllerAddUserOperationFromTransactionAction,\n UserOperationControllerStartPollingByNetworkClientIdAction,\n} from './UserOperationController-method-action-types.js';\nexport * from './types.js';\n"]}
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./UserOperationController.cjs";
2
- export type { UserOperationControllerAddUserOperationAction, UserOperationControllerAddUserOperationFromTransactionAction, UserOperationControllerStartPollingByNetworkClientIdAction, } from "./UserOperationController-method-action-types.cjs";
3
- export * from "./types.cjs";
4
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAC7C,YAAY,EACV,6CAA6C,EAC7C,4DAA4D,EAC5D,0DAA0D,GAC3D,0DAAyD;AAC1D,4BAA2B"}
package/dist/index.d.mts DELETED
@@ -1,4 +0,0 @@
1
- export * from "./UserOperationController.mjs";
2
- export type { UserOperationControllerAddUserOperationAction, UserOperationControllerAddUserOperationFromTransactionAction, UserOperationControllerStartPollingByNetworkClientIdAction, } from "./UserOperationController-method-action-types.mjs";
3
- export * from "./types.mjs";
4
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAC7C,YAAY,EACV,6CAA6C,EAC7C,4DAA4D,EAC5D,0DAA0D,GAC3D,0DAAyD;AAC1D,4BAA2B"}
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- export * from "./UserOperationController.mjs";
2
- export * from "./types.mjs";
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8CAA6C;AAM7C,4BAA2B","sourcesContent":["export * from './UserOperationController.js';\nexport type {\n UserOperationControllerAddUserOperationAction,\n UserOperationControllerAddUserOperationFromTransactionAction,\n UserOperationControllerStartPollingByNetworkClientIdAction,\n} from './UserOperationController-method-action-types.js';\nexport * from './types.js';\n"]}
package/dist/logger.cjs DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /* istanbul ignore file */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createModuleLogger = exports.projectLogger = void 0;
5
- const utils_1 = require("@metamask/utils");
6
- Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } });
7
- exports.projectLogger = (0, utils_1.createProjectLogger)('user-operation-controller');
8
- //# sourceMappingURL=logger.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.cjs","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAE1B,2CAA0E;AAIjE,mGAJqB,0BAAkB,OAIrB;AAFd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('user-operation-controller');\n\nexport { createModuleLogger };\n"]}
package/dist/logger.d.cts DELETED
@@ -1,5 +0,0 @@
1
- /// <reference types="debug" />
2
- import { createModuleLogger } from "@metamask/utils";
3
- export declare const projectLogger: import("debug").Debugger;
4
- export { createModuleLogger };
5
- //# sourceMappingURL=logger.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAAmD,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/logger.d.mts DELETED
@@ -1,5 +0,0 @@
1
- /// <reference types="debug" />
2
- import { createModuleLogger } from "@metamask/utils";
3
- export declare const projectLogger: import("debug").Debugger;
4
- export { createModuleLogger };
5
- //# sourceMappingURL=logger.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAEA,OAAO,EAAuB,kBAAkB,EAAE,wBAAwB;AAE1E,eAAO,MAAM,aAAa,0BAAmD,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.mjs","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB;AAE1E,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/* istanbul ignore file */\n\nimport { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('user-operation-controller');\n\nexport { createModuleLogger };\n"]}
package/dist/types.cjs DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserOperationStatus = void 0;
4
- /**
5
- * The possible statuses of a single user operation.
6
- */
7
- var UserOperationStatus;
8
- (function (UserOperationStatus) {
9
- UserOperationStatus["Unapproved"] = "unapproved";
10
- UserOperationStatus["Approved"] = "approved";
11
- UserOperationStatus["Signed"] = "signed";
12
- UserOperationStatus["Submitted"] = "submitted";
13
- UserOperationStatus["Failed"] = "failed";
14
- UserOperationStatus["Confirmed"] = "confirmed";
15
- })(UserOperationStatus || (exports.UserOperationStatus = UserOperationStatus = {}));
16
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA0DA;;GAEG;AACH,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,gDAAyB,CAAA;IACzB,4CAAqB,CAAA;IACrB,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;IACvB,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;AACzB,CAAC,EAPW,mBAAmB,mCAAnB,mBAAmB,QAO9B","sourcesContent":["import type {\n TransactionParams,\n TransactionType,\n UserFeeLevel,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\n\n/**\n * A complete user operation to be submitted to a bundler.\n * Defined in EIP-4337.\n */\nexport type UserOperation = {\n /** The data to pass to the sender during the main execution call. */\n callData: string;\n\n /** The amount of gas to allocate the main execution call. */\n callGasLimit: string;\n\n /**\n * The initCode of the account.\n * Needed if and only if the account is not yet on-chain and needs to be created.\n */\n initCode: string;\n\n /**\n * Maximum fee per gas.\n * Similar to EIP-1559 max_fee_per_gas.\n */\n maxFeePerGas: string;\n\n /**\n * Maximum priority fee per gas.\n * Similar to EIP-1559 max_priority_fee_per_gas.\n */\n maxPriorityFeePerGas: string;\n\n /** Anti-replay parameter. */\n nonce: string;\n\n /**\n * Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster.\n * Empty for self-sponsored transactions.\n */\n paymasterAndData: string;\n\n /** The amount of gas to pay to compensate the bundler for pre-verification execution, calldata and any gas overhead that cannot be tracked on-chain. */\n preVerificationGas: string;\n\n /** The account making the operation. */\n sender: string;\n\n /** Data passed into the account along with the nonce during the verification step. */\n signature: string;\n\n /** The amount of gas to allocate for the verification step. */\n verificationGasLimit: string;\n};\n\n/**\n * The possible statuses of a single user operation.\n */\nexport enum UserOperationStatus {\n Unapproved = 'unapproved',\n Approved = 'approved',\n Signed = 'signed',\n Submitted = 'submitted',\n Failed = 'failed',\n Confirmed = 'confirmed',\n}\n\n/** Information concerning an error while creating a user operation. */\nexport type UserOperationError = {\n /**\n * A descriptive error name.\n */\n name: string;\n\n /**\n * A descriptive error message providing details about the encountered error.\n */\n message: string;\n\n /**\n * The stack trace associated with the error, if available.\n */\n stack: string | null;\n\n /**\n * An optional error code associated with the error.\n */\n code: string | null;\n\n /**\n * Additional information related to the error.\n */\n rpc: string | null;\n};\n\n/**\n * Metadata concerning a single user operation, stored in the client state.\n */\nexport type UserOperationMetadata = {\n /** Confirmed total cost of the gas for the user operation. */\n actualGasCost: string | null;\n\n /** Confirmed total amount of gas used by the user operation. */\n actualGasUsed: string | null;\n\n /** Base fee of the transaction block as a hex value. */\n baseFeePerGas: string | null;\n\n /** URL of the bundler that the operation was submitted to. */\n bundlerUrl: string | null;\n\n /** Hexadecimal chain ID of the target network. */\n chainId: string;\n\n /** An error that occurred while creating the operation. */\n error: UserOperationError | null;\n\n /** Hash of the user operation, generated by the bundler. */\n hash: string | null;\n\n /** A unique ID used to identify a user operation in the client. */\n id: string;\n\n /** The origin of the user operation, such as the hostname of a dApp. */\n origin: string;\n\n /** Current status of the user operation. */\n status: UserOperationStatus;\n\n /** Metadata specific to swap transactions. */\n swapsMetadata: SwapsMetadata | null;\n\n /** Timestamp of when the user operation was created. */\n time: number;\n\n /** Hash of the transaction that submitted the user operation to the entrypoint. */\n transactionHash: string | null;\n\n /** The initial transaction parameters that the user operation was created from. */\n transactionParams: Required<TransactionParams> | null;\n\n /** The type of transaction that the user operation will create. */\n transactionType: TransactionType | null;\n\n /** The origin of the gas fee values. */\n userFeeLevel: UserFeeLevel | null;\n\n /** Resulting user operation object to be submitted to the bundler. */\n userOperation: UserOperation;\n};\n\n/**\n * The data provided to the smart contract account when preparing a user operation.\n */\nexport type PrepareUserOperationRequest = {\n /** The hexadecimal chain ID of the target network. */\n chainId: string;\n\n /** The data to include in the resulting transaction. */\n data?: string;\n\n /** Address of the account requesting the user operation. */\n from: string;\n\n /** The destination address of the resulting transaction. */\n to?: string;\n\n /** The value to send in the resulting transaction. */\n value?: string;\n};\n\n/**\n * The data provided to the smart contract account when updating a user operation.\n */\nexport type UpdateUserOperationRequest = {\n /** The user operation to update including the dummy signature and dummy paymasterAndData values. */\n userOperation: UserOperation;\n\n /** The hexadecimal chain ID of the target network. */\n chainId: string;\n};\n\n/**\n * The data provided to the smart contract account when signing a user operation.\n */\nexport type SignUserOperationRequest = {\n /** The user operation to sign including the dummy signature and final paymasterAndData values. */\n userOperation: UserOperation;\n\n /** The hexadecimal chain ID of the target network. */\n chainId: string;\n};\n\n/**\n * The data returned by the smart contract account when preparing a user operation.\n */\nexport type PrepareUserOperationResponse = {\n /** The URL of the bundler to submit the user operation to. */\n bundler: string;\n\n /** The data to pass to the sender during the main execution call. */\n callData: string;\n\n /**\n * A dummy paymasterAndData value required to estimate gas using the bundler.\n * Only required if the smart contract account is not providing gas values.\n */\n dummyPaymasterAndData?: string;\n\n /**\n * A dummy signature value required to estimate gas using the bundler.\n * Only required if the smart contract account is not providing gas values.\n */\n dummySignature?: string;\n\n /**\n * The estimated gas limits for the user operation.\n * Gas is automatically estimated using the bundler if not provided.\n */\n gas?: {\n /** The amount of gas to allocate to the main execution call. */\n callGasLimit: string;\n\n /** The amount of gas to pay to compensate the bundler for pre-verification execution, calldata and any gas overhead that cannot be tracked on-chain. */\n preVerificationGas: string;\n\n /** The amount of gas to allocate for the verification step. */\n verificationGasLimit: string;\n };\n\n /**\n * The initCode to include in the user operation.\n * Required only if the smart contract is not yet deployed.\n */\n initCode?: string;\n\n /**\n * The nonce to include in the user operation, specific to the smart contract account.\n */\n nonce: string;\n\n /**\n * The address of the smart contract account creating the user operation.\n */\n sender: string;\n};\n\n/**\n * The data returned by the smart contract account when updating a user operation.\n */\nexport type UpdateUserOperationResponse = {\n /**\n * The final paymasterAndData to include in the user operation.\n * Not required if a paymaster is not sponsoring the transaction.\n */\n paymasterAndData?: string;\n\n /**\n * The final gas limits for the user operation suggested by the smart contract account.\n * The simulated gas limits may be different after the bundler estimates gas with the use\n * of the paymaster.\n */\n callGasLimit?: string;\n preVerificationGas?: string;\n verificationGasLimit?: string;\n};\n\n/**\n * The data returned by the smart contract account when signing a user operation.\n */\nexport type SignUserOperationResponse = {\n /** The final signature of the user operation. */\n signature: string;\n};\n\n/**\n * An abstraction to provide smart contract and paymaster specific data when creating a user operation.\n * This will typically communicate with an account snap installed in the client.\n */\nexport type SmartContractAccount = {\n /**\n * Retrieve the initial values required to create a user operation.\n *\n * @param request - The data needed by the smart contract account to provide the initial user operation values.\n * @returns The initial values required to create a user operation.\n */\n prepareUserOperation: (\n request: PrepareUserOperationRequest,\n ) => Promise<PrepareUserOperationResponse>;\n\n /**\n * Retrieve additional data required to create a user operation, such as the paymasterAndData value.\n * If gas values were not provided in the prepare response, this will be called after estimating gas using the bundler.\n *\n * @param request - The data needed by the smart contract account to provide the additional user operation values.\n * @returns The additional values required to create a user operation.\n */\n updateUserOperation: (\n request: UpdateUserOperationRequest,\n ) => Promise<UpdateUserOperationResponse>;\n\n /**\n * Sign the final user operation.\n *\n * @param request - The data needed by the smart contract account to generate the signature.\n * @returns The final values required to sign a user operation.\n */\n signUserOperation: (\n request: SignUserOperationRequest,\n ) => Promise<SignUserOperationResponse>;\n};\n\n/**\n * Response from the `eth_getUserOperationReceipt` bundler method.\n * Includes the status of a completed user operation and the receipt of the transaction that submitted it.\n */\nexport type UserOperationReceipt = {\n /** Confirmed total cost of the gas for the user operation. */\n actualGasCost: Hex | number;\n\n /** Confirmed total amount of gas used by the user operation. */\n actualGasUsed: Hex | number;\n\n /** True if the user operation was successfully confirmed on chain. */\n success: boolean;\n\n /** Receipt for the associated transaction. */\n receipt: {\n /** Hash of the block the transaction was added to. */\n blockHash: string;\n\n /** Hash of the confirmed transaction. */\n transactionHash: string;\n };\n};\n\n/** Information specific to user operations created from swap transactions. */\nexport type SwapsMetadata = {\n /** ID of the associated approval transaction. */\n approvalTxId: string | null;\n\n /** Address of the destination token. */\n destinationTokenAddress: string | null;\n\n /** Number of decimals of the destination token. */\n destinationTokenDecimals: number | null;\n\n /** Symbol of the destination token. */\n destinationTokenSymbol: string | null;\n\n /** Amount of the destination token. */\n destinationTokenAmount: string | null;\n\n /** Estimated base fee of the swap. */\n estimatedBaseFee: string | null;\n\n /** Address of the source token. */\n sourceTokenAddress: string | null;\n\n /** Amount of the source token. */\n sourceTokenAmount: string | null;\n\n /** Number of decimals of the source token. */\n sourceTokenDecimals: number | null;\n\n /** Symbol of the source token. */\n sourceTokenSymbol: string | null;\n\n /** Recipient of the swap and send transaction. */\n swapAndSendRecipient: string | null;\n\n /** Untyped raw metadata values. */\n swapMetaData: Record<string, never> | null;\n\n /** Value of the token being swapped. */\n swapTokenValue: string | null;\n};\n"]}
package/dist/types.d.cts DELETED
@@ -1,294 +0,0 @@
1
- import type { TransactionParams, TransactionType, UserFeeLevel } from "@metamask/transaction-controller";
2
- import type { Hex } from "@metamask/utils";
3
- /**
4
- * A complete user operation to be submitted to a bundler.
5
- * Defined in EIP-4337.
6
- */
7
- export type UserOperation = {
8
- /** The data to pass to the sender during the main execution call. */
9
- callData: string;
10
- /** The amount of gas to allocate the main execution call. */
11
- callGasLimit: string;
12
- /**
13
- * The initCode of the account.
14
- * Needed if and only if the account is not yet on-chain and needs to be created.
15
- */
16
- initCode: string;
17
- /**
18
- * Maximum fee per gas.
19
- * Similar to EIP-1559 max_fee_per_gas.
20
- */
21
- maxFeePerGas: string;
22
- /**
23
- * Maximum priority fee per gas.
24
- * Similar to EIP-1559 max_priority_fee_per_gas.
25
- */
26
- maxPriorityFeePerGas: string;
27
- /** Anti-replay parameter. */
28
- nonce: string;
29
- /**
30
- * Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster.
31
- * Empty for self-sponsored transactions.
32
- */
33
- paymasterAndData: string;
34
- /** The amount of gas to pay to compensate the bundler for pre-verification execution, calldata and any gas overhead that cannot be tracked on-chain. */
35
- preVerificationGas: string;
36
- /** The account making the operation. */
37
- sender: string;
38
- /** Data passed into the account along with the nonce during the verification step. */
39
- signature: string;
40
- /** The amount of gas to allocate for the verification step. */
41
- verificationGasLimit: string;
42
- };
43
- /**
44
- * The possible statuses of a single user operation.
45
- */
46
- export declare enum UserOperationStatus {
47
- Unapproved = "unapproved",
48
- Approved = "approved",
49
- Signed = "signed",
50
- Submitted = "submitted",
51
- Failed = "failed",
52
- Confirmed = "confirmed"
53
- }
54
- /** Information concerning an error while creating a user operation. */
55
- export type UserOperationError = {
56
- /**
57
- * A descriptive error name.
58
- */
59
- name: string;
60
- /**
61
- * A descriptive error message providing details about the encountered error.
62
- */
63
- message: string;
64
- /**
65
- * The stack trace associated with the error, if available.
66
- */
67
- stack: string | null;
68
- /**
69
- * An optional error code associated with the error.
70
- */
71
- code: string | null;
72
- /**
73
- * Additional information related to the error.
74
- */
75
- rpc: string | null;
76
- };
77
- /**
78
- * Metadata concerning a single user operation, stored in the client state.
79
- */
80
- export type UserOperationMetadata = {
81
- /** Confirmed total cost of the gas for the user operation. */
82
- actualGasCost: string | null;
83
- /** Confirmed total amount of gas used by the user operation. */
84
- actualGasUsed: string | null;
85
- /** Base fee of the transaction block as a hex value. */
86
- baseFeePerGas: string | null;
87
- /** URL of the bundler that the operation was submitted to. */
88
- bundlerUrl: string | null;
89
- /** Hexadecimal chain ID of the target network. */
90
- chainId: string;
91
- /** An error that occurred while creating the operation. */
92
- error: UserOperationError | null;
93
- /** Hash of the user operation, generated by the bundler. */
94
- hash: string | null;
95
- /** A unique ID used to identify a user operation in the client. */
96
- id: string;
97
- /** The origin of the user operation, such as the hostname of a dApp. */
98
- origin: string;
99
- /** Current status of the user operation. */
100
- status: UserOperationStatus;
101
- /** Metadata specific to swap transactions. */
102
- swapsMetadata: SwapsMetadata | null;
103
- /** Timestamp of when the user operation was created. */
104
- time: number;
105
- /** Hash of the transaction that submitted the user operation to the entrypoint. */
106
- transactionHash: string | null;
107
- /** The initial transaction parameters that the user operation was created from. */
108
- transactionParams: Required<TransactionParams> | null;
109
- /** The type of transaction that the user operation will create. */
110
- transactionType: TransactionType | null;
111
- /** The origin of the gas fee values. */
112
- userFeeLevel: UserFeeLevel | null;
113
- /** Resulting user operation object to be submitted to the bundler. */
114
- userOperation: UserOperation;
115
- };
116
- /**
117
- * The data provided to the smart contract account when preparing a user operation.
118
- */
119
- export type PrepareUserOperationRequest = {
120
- /** The hexadecimal chain ID of the target network. */
121
- chainId: string;
122
- /** The data to include in the resulting transaction. */
123
- data?: string;
124
- /** Address of the account requesting the user operation. */
125
- from: string;
126
- /** The destination address of the resulting transaction. */
127
- to?: string;
128
- /** The value to send in the resulting transaction. */
129
- value?: string;
130
- };
131
- /**
132
- * The data provided to the smart contract account when updating a user operation.
133
- */
134
- export type UpdateUserOperationRequest = {
135
- /** The user operation to update including the dummy signature and dummy paymasterAndData values. */
136
- userOperation: UserOperation;
137
- /** The hexadecimal chain ID of the target network. */
138
- chainId: string;
139
- };
140
- /**
141
- * The data provided to the smart contract account when signing a user operation.
142
- */
143
- export type SignUserOperationRequest = {
144
- /** The user operation to sign including the dummy signature and final paymasterAndData values. */
145
- userOperation: UserOperation;
146
- /** The hexadecimal chain ID of the target network. */
147
- chainId: string;
148
- };
149
- /**
150
- * The data returned by the smart contract account when preparing a user operation.
151
- */
152
- export type PrepareUserOperationResponse = {
153
- /** The URL of the bundler to submit the user operation to. */
154
- bundler: string;
155
- /** The data to pass to the sender during the main execution call. */
156
- callData: string;
157
- /**
158
- * A dummy paymasterAndData value required to estimate gas using the bundler.
159
- * Only required if the smart contract account is not providing gas values.
160
- */
161
- dummyPaymasterAndData?: string;
162
- /**
163
- * A dummy signature value required to estimate gas using the bundler.
164
- * Only required if the smart contract account is not providing gas values.
165
- */
166
- dummySignature?: string;
167
- /**
168
- * The estimated gas limits for the user operation.
169
- * Gas is automatically estimated using the bundler if not provided.
170
- */
171
- gas?: {
172
- /** The amount of gas to allocate to the main execution call. */
173
- callGasLimit: string;
174
- /** The amount of gas to pay to compensate the bundler for pre-verification execution, calldata and any gas overhead that cannot be tracked on-chain. */
175
- preVerificationGas: string;
176
- /** The amount of gas to allocate for the verification step. */
177
- verificationGasLimit: string;
178
- };
179
- /**
180
- * The initCode to include in the user operation.
181
- * Required only if the smart contract is not yet deployed.
182
- */
183
- initCode?: string;
184
- /**
185
- * The nonce to include in the user operation, specific to the smart contract account.
186
- */
187
- nonce: string;
188
- /**
189
- * The address of the smart contract account creating the user operation.
190
- */
191
- sender: string;
192
- };
193
- /**
194
- * The data returned by the smart contract account when updating a user operation.
195
- */
196
- export type UpdateUserOperationResponse = {
197
- /**
198
- * The final paymasterAndData to include in the user operation.
199
- * Not required if a paymaster is not sponsoring the transaction.
200
- */
201
- paymasterAndData?: string;
202
- /**
203
- * The final gas limits for the user operation suggested by the smart contract account.
204
- * The simulated gas limits may be different after the bundler estimates gas with the use
205
- * of the paymaster.
206
- */
207
- callGasLimit?: string;
208
- preVerificationGas?: string;
209
- verificationGasLimit?: string;
210
- };
211
- /**
212
- * The data returned by the smart contract account when signing a user operation.
213
- */
214
- export type SignUserOperationResponse = {
215
- /** The final signature of the user operation. */
216
- signature: string;
217
- };
218
- /**
219
- * An abstraction to provide smart contract and paymaster specific data when creating a user operation.
220
- * This will typically communicate with an account snap installed in the client.
221
- */
222
- export type SmartContractAccount = {
223
- /**
224
- * Retrieve the initial values required to create a user operation.
225
- *
226
- * @param request - The data needed by the smart contract account to provide the initial user operation values.
227
- * @returns The initial values required to create a user operation.
228
- */
229
- prepareUserOperation: (request: PrepareUserOperationRequest) => Promise<PrepareUserOperationResponse>;
230
- /**
231
- * Retrieve additional data required to create a user operation, such as the paymasterAndData value.
232
- * If gas values were not provided in the prepare response, this will be called after estimating gas using the bundler.
233
- *
234
- * @param request - The data needed by the smart contract account to provide the additional user operation values.
235
- * @returns The additional values required to create a user operation.
236
- */
237
- updateUserOperation: (request: UpdateUserOperationRequest) => Promise<UpdateUserOperationResponse>;
238
- /**
239
- * Sign the final user operation.
240
- *
241
- * @param request - The data needed by the smart contract account to generate the signature.
242
- * @returns The final values required to sign a user operation.
243
- */
244
- signUserOperation: (request: SignUserOperationRequest) => Promise<SignUserOperationResponse>;
245
- };
246
- /**
247
- * Response from the `eth_getUserOperationReceipt` bundler method.
248
- * Includes the status of a completed user operation and the receipt of the transaction that submitted it.
249
- */
250
- export type UserOperationReceipt = {
251
- /** Confirmed total cost of the gas for the user operation. */
252
- actualGasCost: Hex | number;
253
- /** Confirmed total amount of gas used by the user operation. */
254
- actualGasUsed: Hex | number;
255
- /** True if the user operation was successfully confirmed on chain. */
256
- success: boolean;
257
- /** Receipt for the associated transaction. */
258
- receipt: {
259
- /** Hash of the block the transaction was added to. */
260
- blockHash: string;
261
- /** Hash of the confirmed transaction. */
262
- transactionHash: string;
263
- };
264
- };
265
- /** Information specific to user operations created from swap transactions. */
266
- export type SwapsMetadata = {
267
- /** ID of the associated approval transaction. */
268
- approvalTxId: string | null;
269
- /** Address of the destination token. */
270
- destinationTokenAddress: string | null;
271
- /** Number of decimals of the destination token. */
272
- destinationTokenDecimals: number | null;
273
- /** Symbol of the destination token. */
274
- destinationTokenSymbol: string | null;
275
- /** Amount of the destination token. */
276
- destinationTokenAmount: string | null;
277
- /** Estimated base fee of the swap. */
278
- estimatedBaseFee: string | null;
279
- /** Address of the source token. */
280
- sourceTokenAddress: string | null;
281
- /** Amount of the source token. */
282
- sourceTokenAmount: string | null;
283
- /** Number of decimals of the source token. */
284
- sourceTokenDecimals: number | null;
285
- /** Symbol of the source token. */
286
- sourceTokenSymbol: string | null;
287
- /** Recipient of the swap and send transaction. */
288
- swapAndSendRecipient: string | null;
289
- /** Untyped raw metadata values. */
290
- swapMetaData: Record<string, never> | null;
291
- /** Value of the token being swapped. */
292
- swapTokenValue: string | null;
293
- };
294
- //# sourceMappingURL=types.d.cts.map