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

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 +0 -4
  2. package/dist/BlockTrackerPollingController.cjs +68 -0
  3. package/dist/BlockTrackerPollingController.cjs.map +1 -0
  4. package/dist/{BlockTrackerPollingController.d.ts → BlockTrackerPollingController.d.cts} +11 -11
  5. package/dist/BlockTrackerPollingController.d.cts.map +1 -0
  6. package/dist/BlockTrackerPollingController.d.mts +41 -0
  7. package/dist/BlockTrackerPollingController.d.mts.map +1 -0
  8. package/dist/{BlockTrackerPollingController.js → BlockTrackerPollingController.mjs} +16 -17
  9. package/dist/BlockTrackerPollingController.mjs.map +1 -0
  10. package/dist/UserOperationController-method-action-types.cjs +7 -0
  11. package/dist/UserOperationController-method-action-types.cjs.map +1 -0
  12. package/dist/{UserOperationController-method-action-types.d.ts → UserOperationController-method-action-types.d.cts} +2 -2
  13. package/dist/UserOperationController-method-action-types.d.cts.map +1 -0
  14. package/dist/UserOperationController-method-action-types.d.mts +57 -0
  15. package/dist/UserOperationController-method-action-types.d.mts.map +1 -0
  16. package/dist/{UserOperationController-method-action-types.js → UserOperationController-method-action-types.mjs} +1 -1
  17. package/dist/UserOperationController-method-action-types.mjs.map +1 -0
  18. package/dist/UserOperationController.cjs +495 -0
  19. package/dist/UserOperationController.cjs.map +1 -0
  20. package/dist/{UserOperationController.d.ts → UserOperationController.d.cts} +15 -13
  21. package/dist/UserOperationController.d.cts.map +1 -0
  22. package/dist/UserOperationController.d.mts +136 -0
  23. package/dist/UserOperationController.d.mts.map +1 -0
  24. package/dist/{UserOperationController.js → UserOperationController.mjs} +20 -19
  25. package/dist/UserOperationController.mjs.map +1 -0
  26. package/dist/constants.cjs +7 -0
  27. package/dist/constants.cjs.map +1 -0
  28. package/dist/{constants.d.ts → constants.d.cts} +1 -1
  29. package/dist/constants.d.cts.map +1 -0
  30. package/dist/constants.d.mts +4 -0
  31. package/dist/constants.d.mts.map +1 -0
  32. package/dist/{constants.js → constants.mjs} +1 -1
  33. package/dist/constants.mjs.map +1 -0
  34. package/dist/helpers/Bundler.cjs +91 -0
  35. package/dist/helpers/Bundler.cjs.map +1 -0
  36. package/dist/helpers/{Bundler.d.ts → Bundler.d.cts} +2 -2
  37. package/dist/helpers/Bundler.d.cts.map +1 -0
  38. package/dist/helpers/Bundler.d.mts +46 -0
  39. package/dist/helpers/Bundler.d.mts.map +1 -0
  40. package/dist/helpers/{Bundler.js → Bundler.mjs} +2 -2
  41. package/dist/helpers/Bundler.mjs.map +1 -0
  42. package/dist/helpers/PendingUserOperationTracker.cjs +127 -0
  43. package/dist/helpers/PendingUserOperationTracker.cjs.map +1 -0
  44. package/dist/helpers/{PendingUserOperationTracker.d.ts → PendingUserOperationTracker.d.cts} +12 -10
  45. package/dist/helpers/PendingUserOperationTracker.d.cts.map +1 -0
  46. package/dist/helpers/PendingUserOperationTracker.d.mts +51 -0
  47. package/dist/helpers/PendingUserOperationTracker.d.mts.map +1 -0
  48. package/dist/helpers/{PendingUserOperationTracker.js → PendingUserOperationTracker.mjs} +16 -9
  49. package/dist/helpers/PendingUserOperationTracker.mjs.map +1 -0
  50. package/dist/helpers/SnapSmartContractAccount.cjs +64 -0
  51. package/dist/helpers/SnapSmartContractAccount.cjs.map +1 -0
  52. package/dist/helpers/{SnapSmartContractAccount.d.ts → SnapSmartContractAccount.d.cts} +3 -3
  53. package/dist/helpers/SnapSmartContractAccount.d.cts.map +1 -0
  54. package/dist/helpers/SnapSmartContractAccount.d.mts +10 -0
  55. package/dist/helpers/SnapSmartContractAccount.d.mts.map +1 -0
  56. package/dist/helpers/{SnapSmartContractAccount.js → SnapSmartContractAccount.mjs} +3 -3
  57. package/dist/helpers/SnapSmartContractAccount.mjs.map +1 -0
  58. package/dist/index.cjs +19 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +4 -0
  61. package/dist/index.d.cts.map +1 -0
  62. package/dist/index.d.mts +4 -0
  63. package/dist/index.d.mts.map +1 -0
  64. package/dist/index.mjs +3 -0
  65. package/dist/index.mjs.map +1 -0
  66. package/dist/logger.cjs +8 -0
  67. package/dist/logger.cjs.map +1 -0
  68. package/dist/logger.d.cts +5 -0
  69. package/dist/logger.d.cts.map +1 -0
  70. package/dist/logger.d.mts +5 -0
  71. package/dist/logger.d.mts.map +1 -0
  72. package/dist/{logger.js → logger.mjs} +2 -2
  73. package/dist/logger.mjs.map +1 -0
  74. package/dist/types.cjs +16 -0
  75. package/dist/types.cjs.map +1 -0
  76. package/dist/{types.d.ts → types.d.cts} +3 -3
  77. package/dist/types.d.cts.map +1 -0
  78. package/dist/types.d.mts +294 -0
  79. package/dist/types.d.mts.map +1 -0
  80. package/dist/{types.js → types.mjs} +1 -1
  81. package/dist/types.mjs.map +1 -0
  82. package/dist/utils/chain-id.cjs +17 -0
  83. package/dist/utils/chain-id.cjs.map +1 -0
  84. package/dist/utils/{chain-id.d.ts → chain-id.d.cts} +1 -1
  85. package/dist/utils/chain-id.d.cts.map +1 -0
  86. package/dist/utils/chain-id.d.mts +8 -0
  87. package/dist/utils/chain-id.d.mts.map +1 -0
  88. package/dist/utils/{chain-id.js → chain-id.mjs} +1 -1
  89. package/dist/utils/chain-id.mjs.map +1 -0
  90. package/dist/utils/gas-fees.cjs +194 -0
  91. package/dist/utils/gas-fees.cjs.map +1 -0
  92. package/dist/utils/{gas-fees.d.ts → gas-fees.d.cts} +6 -6
  93. package/dist/utils/gas-fees.d.cts.map +1 -0
  94. package/dist/utils/gas-fees.d.mts +24 -0
  95. package/dist/utils/gas-fees.d.mts.map +1 -0
  96. package/dist/utils/{gas-fees.js → gas-fees.mjs} +15 -8
  97. package/dist/utils/gas-fees.mjs.map +1 -0
  98. package/dist/utils/gas.cjs +72 -0
  99. package/dist/utils/gas.cjs.map +1 -0
  100. package/dist/utils/{gas.d.ts → gas.d.cts} +2 -2
  101. package/dist/utils/gas.d.cts.map +1 -0
  102. package/dist/utils/gas.d.mts +10 -0
  103. package/dist/utils/gas.d.mts.map +1 -0
  104. package/dist/utils/{gas.js → gas.mjs} +14 -7
  105. package/dist/utils/gas.mjs.map +1 -0
  106. package/dist/utils/transaction.cjs +117 -0
  107. package/dist/utils/transaction.cjs.map +1 -0
  108. package/dist/utils/{transaction.d.ts → transaction.d.cts} +3 -3
  109. package/dist/utils/transaction.d.cts.map +1 -0
  110. package/dist/utils/transaction.d.mts +10 -0
  111. package/dist/utils/transaction.d.mts.map +1 -0
  112. package/dist/utils/{transaction.js → transaction.mjs} +13 -6
  113. package/dist/utils/transaction.mjs.map +1 -0
  114. package/dist/utils/validation.cjs +162 -0
  115. package/dist/utils/validation.cjs.map +1 -0
  116. package/dist/utils/{validation.d.ts → validation.d.cts} +3 -3
  117. package/dist/utils/validation.d.cts.map +1 -0
  118. package/dist/utils/validation.d.mts +33 -0
  119. package/dist/utils/validation.d.mts.map +1 -0
  120. package/dist/utils/{validation.js → validation.mjs} +5 -5
  121. package/dist/utils/validation.mjs.map +1 -0
  122. package/package.json +17 -13
  123. package/dist/BlockTrackerPollingController.d.ts.map +0 -1
  124. package/dist/BlockTrackerPollingController.js.map +0 -1
  125. package/dist/UserOperationController-method-action-types.d.ts.map +0 -1
  126. package/dist/UserOperationController-method-action-types.js.map +0 -1
  127. package/dist/UserOperationController.d.ts.map +0 -1
  128. package/dist/UserOperationController.js.map +0 -1
  129. package/dist/constants.d.ts.map +0 -1
  130. package/dist/constants.js.map +0 -1
  131. package/dist/helpers/Bundler.d.ts.map +0 -1
  132. package/dist/helpers/Bundler.js.map +0 -1
  133. package/dist/helpers/PendingUserOperationTracker.d.ts.map +0 -1
  134. package/dist/helpers/PendingUserOperationTracker.js.map +0 -1
  135. package/dist/helpers/SnapSmartContractAccount.d.ts.map +0 -1
  136. package/dist/helpers/SnapSmartContractAccount.js.map +0 -1
  137. package/dist/index.d.ts +0 -4
  138. package/dist/index.d.ts.map +0 -1
  139. package/dist/index.js +0 -3
  140. package/dist/index.js.map +0 -1
  141. package/dist/logger.d.ts +0 -4
  142. package/dist/logger.d.ts.map +0 -1
  143. package/dist/logger.js.map +0 -1
  144. package/dist/types.d.ts.map +0 -1
  145. package/dist/types.js.map +0 -1
  146. package/dist/utils/chain-id.d.ts.map +0 -1
  147. package/dist/utils/chain-id.js.map +0 -1
  148. package/dist/utils/gas-fees.d.ts.map +0 -1
  149. package/dist/utils/gas-fees.js.map +0 -1
  150. package/dist/utils/gas.d.ts.map +0 -1
  151. package/dist/utils/gas.js.map +0 -1
  152. package/dist/utils/transaction.d.ts.map +0 -1
  153. package/dist/utils/transaction.js.map +0 -1
  154. package/dist/utils/validation.d.ts.map +0 -1
  155. package/dist/utils/validation.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,YAAY,EACV,6CAA6C,EAC7C,4DAA4D,EAC5D,0DAA0D,GAC3D,MAAM,kDAAkD,CAAC;AAC1D,cAAc,YAAY,CAAC"}
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './UserOperationController.js';
2
- export * from './types.js';
3
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAM7C,cAAc,YAAY,CAAC","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.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { createModuleLogger } from '@metamask/utils';
2
- export declare const projectLogger: import("debug").Debugger;
3
- export { createModuleLogger };
4
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,aAAa,0BAAmD,CAAC;AAE9E,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,YAAY,EACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IAEjB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CA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gDAAyB,CAAA;IACzB,4CAAqB,CAAA;IACrB,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;IACvB,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;AACzB,CAAC,EAPW,mBAAmB,KAAnB,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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chain-id.d.ts","sourceRoot":"","sources":["../../src/utils/chain-id.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMvD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chain-id.js","sourceRoot":"","sources":["../../src/utils/chain-id.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAEtC,oGAAoG;IACpG,4BAA4B;IAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9E,CAAC","sourcesContent":["/**\n * Converts a chain ID string to a compliant CAIP-2 chain ID reference for EIP-155 chains.\n *\n * @param chainId - Chain ID string\n * @returns An CAIP-2 chain ID reference for EIP-155 chains.\n */\nexport function toEip155ChainId(chainId: string): string {\n const chainIdNumber = Number(chainId);\n\n // If for some reason the chainId isn't convertible to a decimal integer representation, we fallback\n // to the initial `chainId`.\n return Number.isInteger(chainIdNumber) ? chainIdNumber.toString() : chainId;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gas-fees.d.ts","sourceRoot":"","sources":["../../src/utils/gas-fees.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE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W,CAAC;AACzC,CAAC","sourcesContent":["import {\n gweiDecToWEIBN,\n ORIGIN_METAMASK,\n query,\n toHex,\n} from '@metamask/controller-utils';\nimport EthQuery from '@metamask/eth-query';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type { Provider } from '@metamask/network-controller';\nimport type { TransactionParams } from '@metamask/transaction-controller';\nimport { UserFeeLevel } from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport { EMPTY_BYTES } from '../constants.js';\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type { UserOperation, UserOperationMetadata } from '../types.js';\nimport type { AddUserOperationRequest } from '../UserOperationController.js';\n\nconst log = createModuleLogger(projectLogger, 'gas-fees');\n\nexport type UpdateGasFeesRequest = {\n getGasFeeEstimates: () => Promise<GasFeeState>;\n metadata: UserOperationMetadata;\n originalRequest: AddUserOperationRequest;\n provider: Provider;\n transaction?: TransactionParams;\n};\n\ntype SuggestedGasFees = {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n};\n\n/**\n * Populates the gas fee properties for a user operation.\n *\n * @param request - The request to update the gas fees.\n * @param request.getGasFeeEstimates - A callback to get gas fee estimates.\n * @param request.metadata - The metadata for the user operation.\n * @param request.originalRequest - The original request to add the user operation.\n * @param request.provider - A provider to query the network.\n * @param request.transaction - The transaction that created the user operation.\n */\nexport async function updateGasFees(request: UpdateGasFeesRequest) {\n const { metadata, originalRequest, transaction } = request;\n const { userOperation } = metadata;\n let suggestedGasFees: SuggestedGasFees | undefined;\n\n const getGasFeeEstimates = async () => {\n if (!suggestedGasFees) {\n suggestedGasFees = await getSuggestedGasFees(request);\n }\n\n return suggestedGasFees;\n };\n\n userOperation.maxFeePerGas = await getMaxFeePerGas(\n originalRequest,\n getGasFeeEstimates,\n transaction,\n );\n\n userOperation.maxPriorityFeePerGas = await getMaxPriorityFeePerGas(\n originalRequest,\n getGasFeeEstimates,\n userOperation,\n transaction,\n );\n\n metadata.userFeeLevel = getUserFeeLevel(\n metadata,\n originalRequest,\n suggestedGasFees,\n transaction,\n );\n}\n\n/**\n * Gets the maxFeePerGas for a user operation.\n *\n * @param originalRequest - The original request to add the user operation.\n * @param getGetFasEstimates - A callback to get gas fee estimates.\n * @param transaction - The transaction that created the user operation.\n * @returns The maxFeePerGas for the user operation.\n */\nasync function getMaxFeePerGas(\n originalRequest: AddUserOperationRequest,\n getGetFasEstimates: () => Promise<SuggestedGasFees>,\n transaction?: TransactionParams,\n) {\n const { maxFeePerGas, maxPriorityFeePerGas } = originalRequest;\n const { gasPrice } = transaction ?? {};\n\n if (!isGasFeeEmpty(maxFeePerGas)) {\n log('Using maxFeePerGas from request', maxFeePerGas);\n return maxFeePerGas as string;\n }\n\n if (isGasFeeEmpty(maxPriorityFeePerGas) && gasPrice) {\n log('Setting maxFeePerGas to transaction gasPrice', gasPrice);\n return gasPrice;\n }\n\n const { maxFeePerGas: suggestedMaxFeePerGas } = await getGetFasEstimates();\n\n if (!suggestedMaxFeePerGas) {\n throw new Error('Failed to get gas fee estimate for maxFeePerGas');\n }\n\n log('Using maxFeePerGas from estimate', suggestedMaxFeePerGas);\n\n return suggestedMaxFeePerGas;\n}\n\n/**\n * Gets the maxPriorityFeePerGas for a user operation.\n *\n * @param originalRequest - The original request to add the user operation.\n * @param getGetFasEstimates - A callback to get gas fee estimates.\n * @param userOperation - The user operation being updated.\n * @param transaction - The transaction that created the user operation.\n * @returns The maxPriorityFeePerGas for the user operation.\n */\nasync function getMaxPriorityFeePerGas(\n originalRequest: AddUserOperationRequest,\n getGetFasEstimates: () => Promise<SuggestedGasFees>,\n userOperation: UserOperation,\n transaction?: TransactionParams,\n) {\n const { maxFeePerGas, maxPriorityFeePerGas } = originalRequest;\n const { gasPrice } = transaction ?? {};\n const { maxFeePerGas: updatedMaxFeePerGas } = userOperation;\n\n if (!isGasFeeEmpty(maxPriorityFeePerGas)) {\n log('Using maxPriorityFeePerGas from request', maxPriorityFeePerGas);\n return maxPriorityFeePerGas as string;\n }\n\n if (isGasFeeEmpty(maxFeePerGas) && gasPrice) {\n log('Setting maxPriorityFeePerGas to transaction gasPrice', gasPrice);\n return gasPrice;\n }\n\n const { maxPriorityFeePerGas: suggestedMaxPriorityFeePerGas } =\n await getGetFasEstimates();\n\n if (suggestedMaxPriorityFeePerGas) {\n log(\n 'Using maxPriorityFeePerGas from estimate',\n suggestedMaxPriorityFeePerGas,\n );\n return suggestedMaxPriorityFeePerGas;\n }\n\n log('Setting maxPriorityFeePerGas to maxFeePerGas', updatedMaxFeePerGas);\n\n return updatedMaxFeePerGas;\n}\n\n/**\n * Gets the userFeeLevel for a user operation.\n *\n * @param metadata - The metadata for the user operation.\n * @param originalRequest - The original request to add the user operation.\n * @param suggestedGasFees - The suggested gas fees, if any.\n * @param transaction - The transaction that created the user operation.\n * @returns The userFeeLevel for the user operation.\n */\nfunction getUserFeeLevel(\n metadata: UserOperationMetadata,\n originalRequest: AddUserOperationRequest,\n suggestedGasFees?: SuggestedGasFees,\n transaction?: TransactionParams,\n): UserFeeLevel {\n const { origin } = metadata;\n const { maxFeePerGas, maxPriorityFeePerGas } = originalRequest;\n\n const {\n maxFeePerGas: suggestedMaxFeePerGas,\n maxPriorityFeePerGas: suggestedMaxPriorityFeePerGas,\n } = suggestedGasFees || {};\n\n if (\n isGasFeeEmpty(maxFeePerGas) &&\n isGasFeeEmpty(maxPriorityFeePerGas) &&\n transaction?.gasPrice\n ) {\n return origin === ORIGIN_METAMASK\n ? UserFeeLevel.CUSTOM\n : UserFeeLevel.DAPP_SUGGESTED;\n }\n\n if (\n isGasFeeEmpty(maxFeePerGas) &&\n isGasFeeEmpty(maxPriorityFeePerGas) &&\n suggestedMaxFeePerGas &&\n suggestedMaxPriorityFeePerGas\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (origin === ORIGIN_METAMASK) {\n return UserFeeLevel.CUSTOM;\n }\n\n return UserFeeLevel.DAPP_SUGGESTED;\n}\n\n/**\n * Gets suggested gas fees.\n *\n * @param request - The request to update the gas fees.\n * @param request.getGasFeeEstimates - A callback to get gas fee estimates.\n * @param request.provider - A provider to query the network.\n * @returns The suggested gas fees.\n */\nasync function getSuggestedGasFees(\n request: UpdateGasFeesRequest,\n): Promise<{ maxFeePerGas?: Hex; maxPriorityFeePerGas?: Hex }> {\n const { getGasFeeEstimates, provider } = request;\n\n try {\n const { gasFeeEstimates, gasEstimateType } = await getGasFeeEstimates();\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n /* istanbul ignore next */\n const {\n medium: { suggestedMaxPriorityFeePerGas, suggestedMaxFeePerGas } = {},\n } = gasFeeEstimates;\n\n if (suggestedMaxPriorityFeePerGas && suggestedMaxFeePerGas) {\n const values = {\n maxFeePerGas: gweiDecimalToWeiHex(suggestedMaxFeePerGas),\n maxPriorityFeePerGas: gweiDecimalToWeiHex(\n suggestedMaxPriorityFeePerGas,\n ),\n };\n\n log('Using medium values from fee market estimate', values);\n\n return values;\n }\n }\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n const maxFeePerGas = gweiDecimalToWeiHex(gasFeeEstimates.medium);\n\n log('Using medium value from legacy estimate', maxFeePerGas);\n\n return {\n maxFeePerGas,\n };\n }\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.ETH_GASPRICE) {\n const maxFeePerGas = gweiDecimalToWeiHex(gasFeeEstimates.gasPrice);\n\n log('Using gasPrice from estimate', maxFeePerGas);\n\n return {\n maxFeePerGas,\n };\n }\n } catch (error) {\n log('Failed to get estimate', error);\n }\n\n const gasPriceDecimal = (await query(new EthQuery(provider), 'gasPrice')) as\n | number\n | undefined;\n\n if (!gasPriceDecimal) {\n return {};\n }\n\n const maxFeePerGas = add0x(gasPriceDecimal.toString(16));\n\n log('Using gasPrice from network as fallback', maxFeePerGas);\n\n return { maxFeePerGas };\n}\n\n/**\n * Converts a GWEI decimal string to a WEI hexadecimal string.\n *\n * @param value - The GWEI decimal string to convert.\n * @returns The WEI hexadecimal string.\n */\nfunction gweiDecimalToWeiHex(value: string) {\n return toHex(gweiDecToWEIBN(value));\n}\n\n/**\n * Checks if a gas fee property is empty.\n *\n * @param value - The gas fee value to check.\n * @returns Whether the gas fee property is empty.\n */\nfunction isGasFeeEmpty(value?: string): boolean {\n return !value || value === EMPTY_BYTES;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,aAAa,CAAC;AASrB;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,qBAAqB,EAC/B,eAAe,EAAE,4BAA4B,EAC7C,UAAU,EAAE,MAAM,iBAgDnB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMjE,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAA+B,EAC/B,eAA6C,EAC7C,UAAkB;IAElB,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IAEnC,IAAI,eAAe,CAAC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KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,KAAK,GACT,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC;IAEtE,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAE1D,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { hexToBN } from '@metamask/controller-utils';\nimport { add0x } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { VALUE_ZERO } from '../constants.js';\nimport { Bundler } from '../helpers/Bundler.js';\nimport { createModuleLogger, projectLogger } from '../logger.js';\nimport type {\n PrepareUserOperationResponse,\n UserOperationMetadata,\n} from '../types.js';\n\nconst log = createModuleLogger(projectLogger, 'gas');\n\n/**\n * A multiplier to apply to all gas estimate values returned from the bundler.\n */\nconst GAS_ESTIMATE_MULTIPLIER = 1.5;\n\n/**\n * Populates the gas properties for a user operation.\n *\n * @param metadata - The metadata for the user operation.\n * @param prepareResponse - The prepare response from the smart contract account.\n * @param entrypoint - Address of the entrypoint contract.\n */\nexport async function updateGas(\n metadata: UserOperationMetadata,\n prepareResponse: PrepareUserOperationResponse,\n entrypoint: string,\n) {\n const { userOperation } = metadata;\n\n if (prepareResponse.gas) {\n userOperation.callGasLimit = prepareResponse.gas.callGasLimit;\n userOperation.preVerificationGas = prepareResponse.gas.preVerificationGas;\n userOperation.verificationGasLimit =\n prepareResponse.gas.verificationGasLimit;\n\n log('Using gas values from smart contract account', {\n callGasLimit: userOperation.callGasLimit,\n preVerificationGas: userOperation.preVerificationGas,\n verificationGasLimit: userOperation.verificationGasLimit,\n });\n\n return;\n }\n\n const payload = {\n ...userOperation,\n maxFeePerGas: VALUE_ZERO,\n maxPriorityFeePerGas: VALUE_ZERO,\n callGasLimit: VALUE_ZERO,\n preVerificationGas: VALUE_ZERO,\n verificationGasLimit: '0xF4240',\n };\n\n const bundler = new Bundler(metadata.bundlerUrl as string);\n const estimate = await bundler.estimateUserOperationGas(payload, entrypoint);\n\n userOperation.callGasLimit = normalizeGasEstimate(estimate.callGasLimit);\n userOperation.preVerificationGas = normalizeGasEstimate(\n estimate.preVerificationGas,\n );\n userOperation.verificationGasLimit = normalizeGasEstimate(\n (estimate.verificationGasLimit ?? estimate.verificationGas) as\n | string\n | number,\n );\n\n log('Using buffered gas values from bundler estimate', {\n callGasLimit: userOperation.callGasLimit,\n preVerificationGas: userOperation.preVerificationGas,\n verificationGasLimit: userOperation.verificationGasLimit,\n multiplier: GAS_ESTIMATE_MULTIPLIER,\n estimate,\n });\n}\n\n/**\n * Normalizes a gas estimate value from the bundler.\n *\n * @param rawValue - The raw value to normalize.\n * @returns The normalized value as a hexadecimal string.\n */\nfunction normalizeGasEstimate(rawValue: string | number): string {\n const value =\n typeof rawValue === 'string' ? hexToBN(rawValue) : new BN(rawValue);\n\n const bufferedValue = value.muln(GAS_ESTIMATE_MULTIPLIER);\n\n return add0x(bufferedValue.toString(16));\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAW1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,qBAAqB,GAC9B,eAAe,GAAG,SAAS,CA0H7B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/utils/transaction.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAE1C,OAA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,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,SAAS;QACX,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type {\n TransactionError,\n TransactionMeta,\n TransactionParams,\n} from '@metamask/transaction-controller';\nimport {\n TransactionStatus,\n UserFeeLevel,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, remove0x } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { EMPTY_BYTES, VALUE_ZERO } from '../constants.js';\nimport { UserOperationStatus } from '../types.js';\nimport type { UserOperationMetadata } from '../types.js';\n\n/**\n * Converts a user operation metadata object into a transaction metadata object.\n *\n * @param metadata - The user operation metadata object to convert.\n * @returns The equivalent transaction metadata object.\n */\nexport function getTransactionMetadata(\n metadata: UserOperationMetadata,\n): TransactionMeta | undefined {\n const {\n actualGasCost,\n actualGasUsed,\n baseFeePerGas,\n chainId,\n error: rawError,\n origin,\n transactionHash,\n id,\n swapsMetadata,\n time,\n transactionParams,\n transactionType,\n userFeeLevel: rawUserFeeLevel,\n userOperation,\n } = metadata;\n\n if (!transactionParams) {\n return undefined;\n }\n\n // effectiveGasPrice = actualGasCost / actualGasUsed\n const effectiveGasPrice =\n actualGasCost && actualGasUsed\n ? add0x(\n new BN(remove0x(actualGasCost), 16)\n .div(new BN(remove0x(actualGasUsed), 16))\n .toString(16),\n )\n : undefined;\n\n const error = (\n rawError\n ? {\n name: rawError.name,\n message: rawError.message,\n stack: rawError.stack,\n code: rawError.code,\n rpc: rawError.rpc,\n }\n : undefined\n ) as TransactionError;\n\n const status: TransactionStatus = {\n [UserOperationStatus.Unapproved]: TransactionStatus.unapproved,\n [UserOperationStatus.Approved]: TransactionStatus.approved,\n [UserOperationStatus.Signed]: TransactionStatus.signed,\n [UserOperationStatus.Submitted]: TransactionStatus.submitted,\n [UserOperationStatus.Confirmed]: TransactionStatus.confirmed,\n [UserOperationStatus.Failed]: TransactionStatus.failed,\n }[metadata.status];\n\n const gas = addHex(\n userOperation.preVerificationGas,\n userOperation.verificationGasLimit,\n userOperation.callGasLimit,\n );\n\n const hasPaymaster = userOperation.paymasterAndData !== EMPTY_BYTES;\n\n const maxFeePerGas = hasPaymaster ? VALUE_ZERO : userOperation.maxFeePerGas;\n\n const maxPriorityFeePerGas = hasPaymaster\n ? VALUE_ZERO\n : userOperation.maxPriorityFeePerGas;\n\n const nonce =\n userOperation.nonce === EMPTY_BYTES ? undefined : userOperation.nonce;\n\n const txParams = {\n ...transactionParams,\n from: userOperation.sender,\n gas,\n nonce,\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as TransactionParams;\n\n // User operations only support EIP-1559 gas fee properties.\n delete txParams.gasPrice;\n\n const swaps = {\n approvalTxId: swapsMetadata?.approvalTxId ?? undefined,\n destinationTokenAddress:\n swapsMetadata?.destinationTokenAddress ?? undefined,\n destinationTokenAmount: swapsMetadata?.destinationTokenAmount ?? undefined,\n destinationTokenDecimals:\n swapsMetadata?.destinationTokenDecimals ?? undefined,\n destinationTokenSymbol: swapsMetadata?.destinationTokenSymbol ?? undefined,\n estimatedBaseFee: swapsMetadata?.estimatedBaseFee ?? undefined,\n sourceTokenAddress: swapsMetadata?.sourceTokenAddress ?? undefined,\n sourceTokenAmount: swapsMetadata?.sourceTokenAmount ?? undefined,\n sourceTokenDecimals: swapsMetadata?.sourceTokenDecimals ?? undefined,\n sourceTokenSymbol: swapsMetadata?.sourceTokenSymbol ?? undefined,\n swapAndSendRecipient: swapsMetadata?.swapAndSendRecipient ?? undefined,\n swapMetaData: swapsMetadata?.swapMetaData ?? undefined,\n swapTokenValue: swapsMetadata?.swapTokenValue ?? undefined,\n };\n\n const userFeeLevel = hasPaymaster ? UserFeeLevel.CUSTOM : rawUserFeeLevel;\n\n return {\n baseFeePerGas: (baseFeePerGas as Hex) ?? undefined,\n chainId: chainId as Hex,\n error,\n hash: transactionHash ?? undefined,\n id,\n isUserOperation: true,\n networkClientId: 'user-operation',\n origin,\n status,\n time,\n txParams,\n txReceipt: {\n effectiveGasPrice: effectiveGasPrice ?? undefined,\n gasUsed: actualGasUsed ?? undefined,\n },\n type: transactionType ?? undefined,\n userFeeLevel: userFeeLevel as string,\n ...swaps,\n };\n}\n\n/**\n * Adds the given hexadecimal values together.\n *\n * @param values - The hexadecimal values to add together.\n * @returns The sum of the given hexadecimal values.\n */\nfunction addHex(...values: (string | undefined)[]) {\n const total = new BN(0);\n\n for (const value of values) {\n if (!value) {\n continue;\n }\n\n total.iadd(new BN(remove0x(value), 16));\n }\n\n return add0x(total.toString(16));\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAejC;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,QAkCjC;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,4BAA4B,QAsCvC;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,2BAA2B,QAgBtC;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,QAapC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AACA,OA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,CAAI,IAAa,EAAE,MAAiB,EAAE,OAAe;IACpE,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAI,KAAqB;aAClC,QAAQ,EAAE;aACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACzB,OAAO,OAAO,CAAC,OAAO,CAAC;YACzB,CAAC;YAED,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1D,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,YAAY,GAAG,GAAG,OAAO,KAAK,MAAM,EAAE,CAAC;QAE7C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS;IAChB,OAAO,MAAM,CAAS,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CACpD,iBAAiB,CAAC,KAAK,CAAC,CACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB;IAC5B,OAAO,MAAM,CACX,0BAA0B,EAC1B,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,WAAW,CAC7D,CAAC;AACJ,CAAC","sourcesContent":["import type { Struct, StructError } from '@metamask/superstruct';\nimport {\n assert,\n boolean,\n define,\n enums,\n func,\n number,\n object,\n optional,\n refine,\n string,\n} from '@metamask/superstruct';\nimport { TransactionType } from '@metamask/transaction-controller';\nimport { isStrictHexString } from '@metamask/utils';\n\nimport { EMPTY_BYTES } from '../constants.js';\nimport type {\n PrepareUserOperationResponse,\n SignUserOperationResponse,\n UpdateUserOperationResponse,\n} from '../types.js';\nimport type {\n AddUserOperationOptions,\n AddUserOperationRequest,\n} from '../UserOperationController.js';\n\n/**\n * Validate a request to add a user operation.\n *\n * @param request - The request to validate.\n */\nexport function validateAddUserOperationRequest(\n request: AddUserOperationRequest,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidRequest = object({\n data: optional(HexOrEmptyBytes),\n from: Hex,\n maxFeePerGas: optional(Hex),\n maxPriorityFeePerGas: optional(Hex),\n to: optional(Hex),\n value: optional(Hex),\n });\n\n validate(request, ValidRequest, 'Invalid request to add user operation');\n}\n\n/**\n * Validate the options when adding a user operation.\n *\n * @param options - The options to validate.\n */\nexport function validateAddUserOperationOptions(\n options: AddUserOperationOptions,\n) {\n const ValidOptions = object({\n networkClientId: string(),\n origin: string(),\n requireApproval: optional(boolean()),\n smartContractAccount: optional(\n object({\n prepareUserOperation: func(),\n updateUserOperation: func(),\n signUserOperation: func(),\n }),\n ),\n swaps: optional(\n object({\n approvalTxId: optional(string()),\n destinationTokenAddress: optional(string()),\n destinationTokenDecimals: optional(number()),\n destinationTokenSymbol: optional(string()),\n estimatedBaseFee: optional(string()),\n sourceTokenSymbol: optional(string()),\n swapMetaData: optional(object()),\n swapTokenValue: optional(string()),\n destinationTokenAmount: optional(string()),\n sourceTokenAddress: optional(string()),\n sourceTokenAmount: optional(string()),\n sourceTokenDecimals: optional(number()),\n swapAndSendRecipient: optional(string()),\n }),\n ),\n type: optional(enums(Object.values(TransactionType))),\n });\n\n validate(options, ValidOptions, 'Invalid options to add user operation');\n}\n\n/**\n * Validate the response from a smart contract account when preparing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validatePrepareUserOperationResponse(\n response: PrepareUserOperationResponse,\n) {\n const Hex = defineHex();\n const HexOrEmptyBytes = defineHexOrEmptyBytes();\n\n const ValidResponse = refine(\n object({\n bundler: string(),\n callData: Hex,\n dummyPaymasterAndData: optional(HexOrEmptyBytes),\n dummySignature: optional(HexOrEmptyBytes),\n gas: optional(\n object({\n callGasLimit: Hex,\n preVerificationGas: Hex,\n verificationGasLimit: Hex,\n }),\n ),\n initCode: optional(HexOrEmptyBytes),\n nonce: Hex,\n sender: Hex,\n }),\n 'ValidPrepareUserOperationResponse',\n ({ gas, dummySignature }) => {\n if (!gas && (!dummySignature || dummySignature === EMPTY_BYTES)) {\n return 'Must specify dummySignature if not specifying gas';\n }\n\n /* istanbul ignore next */\n return true;\n },\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when preparing user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when updating the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateUpdateUserOperationResponse(\n response: UpdateUserOperationResponse,\n) {\n const ValidResponse = optional(\n object({\n paymasterAndData: optional(defineHexOrEmptyBytes()),\n callGasLimit: optional(defineHexOrEmptyBytes()),\n preVerificationGas: optional(defineHexOrEmptyBytes()),\n verificationGasLimit: optional(defineHexOrEmptyBytes()),\n }),\n );\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when updating user operation',\n );\n}\n\n/**\n * Validate the response from a smart contract account when signing the user operation.\n *\n * @param response - The response to validate.\n */\nexport function validateSignUserOperationResponse(\n response: SignUserOperationResponse,\n) {\n const Hex = defineHex();\n\n const ValidResponse = object({\n signature: Hex,\n });\n\n validate(\n response,\n ValidResponse,\n 'Invalid response when signing user operation',\n );\n}\n\n/**\n * Validate data against a struct.\n *\n * @param data - The data to validate.\n * @param struct - The struct to validate against.\n * @param message - The message to throw if validation fails.\n */\nfunction validate<T>(data: unknown, struct: Struct<T>, message: string) {\n try {\n assert(data, struct, message);\n } catch (error) {\n const causes = (error as StructError)\n .failures()\n .map((failure) => {\n if (!failure.path.length) {\n return failure.message;\n }\n\n return `${failure.path.join('.')} - ${failure.message}`;\n })\n .join('\\n');\n\n const finalMessage = `${message}\\n${causes}`;\n\n throw new Error(finalMessage);\n }\n}\n\n/**\n * Define the Hex type used by superstruct.\n *\n * @returns The Hex superstruct type.\n */\nfunction defineHex() {\n return define<string>('Hexadecimal String', (value) =>\n isStrictHexString(value),\n );\n}\n\n/**\n * Define the HexOrEmptyBytes type used by superstruct.\n *\n * @returns The HexOrEmptyBytes superstruct type.\n */\nfunction defineHexOrEmptyBytes() {\n return define<string>(\n 'Hexadecimal String or 0x',\n (value) => isStrictHexString(value) || value === EMPTY_BYTES,\n );\n}\n"]}