@aa-sdk/core 4.34.1 → 4.35.1

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 (215) hide show
  1. package/README.md +1 -1
  2. package/dist/esm/account/smartContractAccount.d.ts +1 -1
  3. package/dist/esm/account/smartContractAccount.js.map +1 -1
  4. package/dist/esm/actions/bundler/estimateUserOperationGas.d.ts +3 -2
  5. package/dist/esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
  6. package/dist/esm/actions/bundler/getSupportedEntryPoints.js.map +1 -1
  7. package/dist/esm/actions/bundler/getUserOperationByHash.js.map +1 -1
  8. package/dist/esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
  9. package/dist/esm/actions/bundler/sendRawUserOperation.d.ts +2 -1
  10. package/dist/esm/actions/bundler/sendRawUserOperation.js.map +1 -1
  11. package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
  12. package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
  13. package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
  14. package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
  15. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  16. package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
  17. package/dist/esm/actions/smartAccount/getAddress.js.map +1 -1
  18. package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
  19. package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
  20. package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
  21. package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
  22. package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
  23. package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
  24. package/dist/esm/actions/smartAccount/signMessage.js.map +1 -1
  25. package/dist/esm/actions/smartAccount/signTypedData.js.map +1 -1
  26. package/dist/esm/actions/smartAccount/signUserOperation.js.map +1 -1
  27. package/dist/esm/actions/smartAccount/types.js.map +1 -1
  28. package/dist/esm/actions/smartAccount/upgradeAccount.js.map +1 -1
  29. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  30. package/dist/esm/client/addBreadcrumb.js.map +1 -1
  31. package/dist/esm/client/bundlerClient.js.map +1 -1
  32. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  33. package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
  34. package/dist/esm/client/isSmartAccountClient.js.map +1 -1
  35. package/dist/esm/client/schema.d.ts +25 -25
  36. package/dist/esm/client/schema.js.map +1 -1
  37. package/dist/esm/client/smartAccountClient.js +5 -8
  38. package/dist/esm/client/smartAccountClient.js.map +1 -1
  39. package/dist/esm/client/types.js.map +1 -1
  40. package/dist/esm/ens/utils.js.map +1 -1
  41. package/dist/esm/entrypoint/0.6.d.ts +2 -2
  42. package/dist/esm/entrypoint/0.6.js.map +1 -1
  43. package/dist/esm/entrypoint/0.7.d.ts +1 -1
  44. package/dist/esm/entrypoint/0.7.js.map +1 -1
  45. package/dist/esm/entrypoint/index.d.ts +1 -1
  46. package/dist/esm/entrypoint/index.js.map +1 -1
  47. package/dist/esm/entrypoint/types.js.map +1 -1
  48. package/dist/esm/errors/account.js.map +1 -1
  49. package/dist/esm/errors/client.js.map +1 -1
  50. package/dist/esm/errors/entrypoint.js.map +1 -1
  51. package/dist/esm/errors/signer.js.map +1 -1
  52. package/dist/esm/errors/useroperation.js.map +1 -1
  53. package/dist/esm/middleware/actions.js.map +1 -1
  54. package/dist/esm/middleware/defaults/7702gasEstimator.d.ts +2 -2
  55. package/dist/esm/middleware/defaults/7702gasEstimator.js +2 -2
  56. package/dist/esm/middleware/defaults/7702gasEstimator.js.map +1 -1
  57. package/dist/esm/middleware/defaults/7702signer.d.ts +1 -1
  58. package/dist/esm/middleware/defaults/7702signer.js +1 -1
  59. package/dist/esm/middleware/defaults/7702signer.js.map +1 -1
  60. package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
  61. package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
  62. package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
  63. package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
  64. package/dist/esm/middleware/erc7677middleware.js.map +1 -1
  65. package/dist/esm/middleware/types.js.map +1 -1
  66. package/dist/esm/signer/local-account.d.ts +2 -207
  67. package/dist/esm/signer/local-account.js.map +1 -1
  68. package/dist/esm/signer/schema.d.ts +1 -1
  69. package/dist/esm/signer/types.js.map +1 -1
  70. package/dist/esm/signer/wallet-client.d.ts +2 -207
  71. package/dist/esm/signer/wallet-client.js.map +1 -1
  72. package/dist/esm/transport/split.js +1 -1
  73. package/dist/esm/transport/split.js.map +1 -1
  74. package/dist/esm/types.js.map +1 -1
  75. package/dist/esm/utils/bigint.js.map +1 -1
  76. package/dist/esm/utils/defaults.js.map +1 -1
  77. package/dist/esm/utils/index.d.ts +2 -2
  78. package/dist/esm/utils/index.js.map +1 -1
  79. package/dist/esm/utils/schema.js.map +1 -1
  80. package/dist/esm/utils/stateOverride.js.map +1 -1
  81. package/dist/esm/utils/testUtils.js.map +1 -1
  82. package/dist/esm/utils/traceHeader.js.map +1 -1
  83. package/dist/esm/utils/types.js.map +1 -1
  84. package/dist/esm/utils/userop.d.ts +2 -2
  85. package/dist/esm/utils/userop.js +1 -1
  86. package/dist/esm/utils/userop.js.map +1 -1
  87. package/dist/esm/version.d.ts +1 -1
  88. package/dist/esm/version.js +1 -1
  89. package/dist/esm/version.js.map +1 -1
  90. package/dist/types/account/smartContractAccount.d.ts +1 -1
  91. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  92. package/dist/types/actions/bundler/estimateUserOperationGas.d.ts +3 -2
  93. package/dist/types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  94. package/dist/types/actions/bundler/getSupportedEntryPoints.d.ts.map +1 -1
  95. package/dist/types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
  96. package/dist/types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
  97. package/dist/types/actions/bundler/sendRawUserOperation.d.ts +2 -1
  98. package/dist/types/actions/bundler/sendRawUserOperation.d.ts.map +1 -1
  99. package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
  100. package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts.map +1 -1
  101. package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
  102. package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts.map +1 -1
  103. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
  104. package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts.map +1 -1
  105. package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
  106. package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
  107. package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
  108. package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
  109. package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
  110. package/dist/types/actions/smartAccount/signUserOperation.d.ts.map +1 -1
  111. package/dist/types/actions/smartAccount/types.d.ts.map +1 -1
  112. package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
  113. package/dist/types/client/schema.d.ts +25 -25
  114. package/dist/types/client/schema.d.ts.map +1 -1
  115. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  116. package/dist/types/ens/utils.d.ts.map +1 -1
  117. package/dist/types/entrypoint/0.6.d.ts +2 -2
  118. package/dist/types/entrypoint/0.6.d.ts.map +1 -1
  119. package/dist/types/entrypoint/0.7.d.ts +1 -1
  120. package/dist/types/entrypoint/0.7.d.ts.map +1 -1
  121. package/dist/types/entrypoint/index.d.ts +1 -1
  122. package/dist/types/entrypoint/index.d.ts.map +1 -1
  123. package/dist/types/entrypoint/types.d.ts.map +1 -1
  124. package/dist/types/errors/useroperation.d.ts.map +1 -1
  125. package/dist/types/middleware/actions.d.ts.map +1 -1
  126. package/dist/types/middleware/defaults/7702gasEstimator.d.ts +2 -2
  127. package/dist/types/middleware/defaults/7702signer.d.ts +1 -1
  128. package/dist/types/middleware/types.d.ts.map +1 -1
  129. package/dist/types/signer/local-account.d.ts +2 -207
  130. package/dist/types/signer/local-account.d.ts.map +1 -1
  131. package/dist/types/signer/schema.d.ts +1 -1
  132. package/dist/types/signer/schema.d.ts.map +1 -1
  133. package/dist/types/signer/utils.d.ts.map +1 -1
  134. package/dist/types/signer/wallet-client.d.ts +2 -207
  135. package/dist/types/signer/wallet-client.d.ts.map +1 -1
  136. package/dist/types/transport/split.d.ts.map +1 -1
  137. package/dist/types/types.d.ts.map +1 -1
  138. package/dist/types/utils/bigint.d.ts.map +1 -1
  139. package/dist/types/utils/bytes.d.ts.map +1 -1
  140. package/dist/types/utils/defaults.d.ts.map +1 -1
  141. package/dist/types/utils/index.d.ts +2 -2
  142. package/dist/types/utils/index.d.ts.map +1 -1
  143. package/dist/types/utils/testUtils.d.ts.map +1 -1
  144. package/dist/types/utils/traceHeader.d.ts.map +1 -1
  145. package/dist/types/utils/userop.d.ts +2 -2
  146. package/dist/types/utils/userop.d.ts.map +1 -1
  147. package/dist/types/version.d.ts +1 -1
  148. package/package.json +3 -6
  149. package/src/account/smartContractAccount.ts +27 -25
  150. package/src/actions/bundler/estimateUserOperationGas.ts +2 -2
  151. package/src/actions/bundler/getSupportedEntryPoints.ts +2 -2
  152. package/src/actions/bundler/getUserOperationByHash.ts +2 -2
  153. package/src/actions/bundler/getUserOperationReceipt.ts +2 -2
  154. package/src/actions/bundler/sendRawUserOperation.ts +2 -2
  155. package/src/actions/smartAccount/buildUserOperation.ts +5 -4
  156. package/src/actions/smartAccount/buildUserOperationFromTx.ts +4 -3
  157. package/src/actions/smartAccount/buildUserOperationFromTxs.ts +9 -8
  158. package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +5 -4
  159. package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +7 -6
  160. package/src/actions/smartAccount/estimateUserOperationGas.ts +5 -4
  161. package/src/actions/smartAccount/getAddress.ts +2 -2
  162. package/src/actions/smartAccount/internal/initUserOperation.ts +7 -6
  163. package/src/actions/smartAccount/internal/runMiddlewareStack.ts +13 -12
  164. package/src/actions/smartAccount/internal/sendUserOperation.ts +3 -2
  165. package/src/actions/smartAccount/sendTransaction.ts +5 -4
  166. package/src/actions/smartAccount/sendTransactions.ts +3 -3
  167. package/src/actions/smartAccount/sendUserOperation.ts +4 -3
  168. package/src/actions/smartAccount/signMessage.ts +3 -3
  169. package/src/actions/smartAccount/signTypedData.ts +3 -3
  170. package/src/actions/smartAccount/signUserOperation.ts +4 -3
  171. package/src/actions/smartAccount/types.ts +23 -15
  172. package/src/actions/smartAccount/upgradeAccount.ts +3 -3
  173. package/src/actions/smartAccount/waitForUserOperationTransacation.ts +5 -5
  174. package/src/client/addBreadcrumb.ts +1 -1
  175. package/src/client/bundlerClient.ts +5 -5
  176. package/src/client/decorators/bundlerClient.ts +7 -7
  177. package/src/client/decorators/smartAccountClient.ts +20 -18
  178. package/src/client/isSmartAccountClient.ts +4 -4
  179. package/src/client/schema.ts +2 -2
  180. package/src/client/smartAccountClient.ts +98 -104
  181. package/src/client/types.ts +2 -2
  182. package/src/ens/utils.ts +1 -1
  183. package/src/entrypoint/0.6.ts +3 -3
  184. package/src/entrypoint/0.7.ts +4 -4
  185. package/src/entrypoint/index.ts +10 -9
  186. package/src/entrypoint/types.ts +30 -28
  187. package/src/errors/account.ts +1 -1
  188. package/src/errors/client.ts +3 -3
  189. package/src/errors/entrypoint.ts +2 -2
  190. package/src/errors/signer.ts +1 -1
  191. package/src/errors/useroperation.ts +6 -3
  192. package/src/middleware/actions.ts +3 -3
  193. package/src/middleware/defaults/7702gasEstimator.ts +4 -4
  194. package/src/middleware/defaults/7702signer.ts +3 -3
  195. package/src/middleware/defaults/feeEstimator.ts +4 -4
  196. package/src/middleware/defaults/gasEstimator.ts +6 -6
  197. package/src/middleware/defaults/paymasterAndData.ts +1 -1
  198. package/src/middleware/defaults/userOpSigner.ts +2 -2
  199. package/src/middleware/erc7677middleware.ts +9 -9
  200. package/src/middleware/types.ts +7 -5
  201. package/src/signer/local-account.ts +7 -7
  202. package/src/signer/types.ts +3 -3
  203. package/src/signer/wallet-client.ts +2 -2
  204. package/src/transport/split.ts +9 -12
  205. package/src/types.ts +29 -29
  206. package/src/utils/bigint.ts +4 -4
  207. package/src/utils/defaults.ts +1 -1
  208. package/src/utils/index.ts +12 -9
  209. package/src/utils/schema.ts +2 -2
  210. package/src/utils/stateOverride.ts +4 -4
  211. package/src/utils/testUtils.ts +2 -2
  212. package/src/utils/traceHeader.ts +14 -11
  213. package/src/utils/types.ts +1 -1
  214. package/src/utils/userop.ts +17 -17
  215. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -38,7 +38,7 @@ import { http } from "viem";
38
38
 
39
39
  const chain = polygonMumbai;
40
40
  const signer: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(
41
- "YOUR_OWNER_MNEMONIC"
41
+ "YOUR_OWNER_MNEMONIC",
42
42
  );
43
43
  const rpcTransport = http("https://polygon-mumbai.g.alchemy.com/v2/demo");
44
44
 
@@ -41,7 +41,7 @@ export type SmartContractAccountWithSigner<Name extends string = string, TSigner
41
41
  * @param {SmartContractAccount} account The account to check.
42
42
  * @returns {boolean} true if the account has a signer, otherwise false.
43
43
  */
44
- export declare const isSmartAccountWithSigner: (account: SmartContractAccount) => account is SmartContractAccountWithSigner<string, SmartAccountSigner<any>, keyof EntryPointRegistryBase<unknown>>;
44
+ export declare const isSmartAccountWithSigner: (account: SmartContractAccount) => account is SmartContractAccountWithSigner;
45
45
  export type SmartContractAccount<Name extends string = string, TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = LocalAccount<Name> & {
46
46
  source: Name;
47
47
  getDummySignature: () => Hex | Prom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ACpB,MAAM,IAAI,2BAA2B,CACnC,oEAAoE,EACpE,8BAA8B,CAC/B,CAAC;YACJ,CAAC;YAED,gFAAgF;YAChF,2HAA2H;YAC3H,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IAEL,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACrE,MAAM,IAAI,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,MAAM;QACN,kEAAkE;QAClE,+DAA+D;QAC/D,qBAAqB,EAAE,sBAAsB;QAC7C,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAChB,kBAAkB;YAClB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,eAAe,EAAE,SAAS;QAC1B,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB,EAAE,yBAAyB;KACpD,CAAC;AACJ,CAAC","sourcesContent":["import {\n getContract,\n hexToBytes,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined } from \"../utils/types.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = GetAccountParameter<\n TAccount,\n TAccountOverride\n> extends SmartContractAccount<string, infer TEntryPointVersion>\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getAccountNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n};\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n getNonce?: (nonceKey?: bigint) => Promise<bigint>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getImplementationAddress?: () => Promise<NullAddress | Address>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\">;\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\nexport type GetAccountAddressParams = {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {GetAccountAddressParams} params The configuration object\n * @param {PublicClient} params.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} params.accountAddress Optional existing account address\n * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: GetAccountAddressParams) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0]\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n getNonce,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n getImplementationAddress,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n const contractCode = await client.getCode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce_ =\n getNonce ??\n (async (nonceKey = 0n): Promise<bigint> => {\n if (!(await isAccountDeployed())) {\n return 0n;\n }\n\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n });\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress_ =\n getImplementationAddress ??\n (async () => {\n const storage = await client.getStorageAt({\n address: account.address,\n // This is the default slot for the implementation address for Proxies\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n // The storage slot contains a full bytes32, but we want only the last 20 bytes.\n // So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.\n return `0x${storage.slice(26)}`;\n });\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getAccountNonce: getNonce_,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress: getImplementationAddress_,\n };\n}\n"]}
1
+ {"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAWX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,mCAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAoCD;;;;;;;;;;;;;;GAcG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;QAC1B,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB,EAAE,yBAAyB;KACpD,CAAC;AACJ,CAAC","sourcesContent":["import {\n getContract,\n hexToBytes,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined } from \"../utils/types.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n GetAccountParameter<TAccount, TAccountOverride> extends SmartContractAccount<\n string,\n infer TEntryPointVersion\n >\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount,\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getAccountNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n};\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n getNonce?: (nonceKey?: bigint) => Promise<bigint>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getImplementationAddress?: () => Promise<NullAddress | Address>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\">;\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex,\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\nexport type GetAccountAddressParams = {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {GetAccountAddressParams} params The configuration object\n * @param {PublicClient} params.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} params.accountAddress Optional existing account address\n * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: GetAccountAddressParams) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err,\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0],\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n getNonce,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams,\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n getImplementationAddress,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n const contractCode = await client.getCode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce_ =\n getNonce ??\n (async (nonceKey = 0n): Promise<bigint> => {\n if (!(await isAccountDeployed())) {\n return 0n;\n }\n\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n });\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress_ =\n getImplementationAddress ??\n (async () => {\n const storage = await client.getStorageAt({\n address: account.address,\n // This is the default slot for the implementation address for Proxies\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\",\n );\n }\n\n // The storage slot contains a full bytes32, but we want only the last 20 bytes.\n // So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.\n return `0x${storage.slice(26)}`;\n });\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getAccountNonce: getNonce_,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress: getImplementationAddress_,\n };\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import type { Address, Chain, Client, StateOverride, Transport } from "viem";
2
2
  import type { BundlerRpcSchema } from "../../client/decorators/bundlerClient";
3
+ import type { EntryPointVersion } from "../../entrypoint/types";
3
4
  import type { UserOperationEstimateGasResponse, UserOperationRequest } from "../../types";
4
- export declare const estimateUserOperationGas: <TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>, TEntryPointVersion extends keyof import("../../entrypoint/types").EntryPointRegistryBase<unknown> = keyof import("../../entrypoint/types").EntryPointRegistryBase<unknown>>(client: TClient, args: {
5
+ export declare const estimateUserOperationGas: <TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>, TEntryPointVersion extends EntryPointVersion = EntryPointVersion>(client: TClient, args: {
5
6
  request: UserOperationRequest<TEntryPointVersion>;
6
7
  entryPoint: Address;
7
- stateOverride?: StateOverride | undefined;
8
+ stateOverride?: StateOverride;
8
9
  }) => Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;
@@ -1 +1 @@
1
- {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/bundler/estimateUserOperationGas.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAI3C,MAAe,EACf,IAIC,EAC8D,EAAE;IACjE,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,8BAA8B;QACtC,MAAM,EACJ,IAAI,CAAC,aAAa,IAAI,IAAI;YACxB,CAAC,CAAC;gBACE,IAAI,CAAC,OAAO;gBACZ,IAAI,CAAC,UAAU;gBACf,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC;aAC3C;YACH,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;KACtC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, StateOverride, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { EntryPointVersion } from \"../../entrypoint/types\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationRequest,\n} from \"../../types\";\nimport { serializeStateOverride } from \"../../utils/stateOverride.js\";\n\nexport const estimateUserOperationGas = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n client: TClient,\n args: {\n request: UserOperationRequest<TEntryPointVersion>;\n entryPoint: Address;\n stateOverride?: StateOverride;\n }\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> => {\n return client.request({\n method: \"eth_estimateUserOperationGas\",\n params:\n args.stateOverride != null\n ? [\n args.request,\n args.entryPoint,\n serializeStateOverride(args.stateOverride),\n ]\n : [args.request, args.entryPoint],\n });\n};\n"]}
1
+ {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/bundler/estimateUserOperationGas.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAI3C,MAAe,EACf,IAIC,EAC8D,EAAE;IACjE,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,8BAA8B;QACtC,MAAM,EACJ,IAAI,CAAC,aAAa,IAAI,IAAI;YACxB,CAAC,CAAC;gBACE,IAAI,CAAC,OAAO;gBACZ,IAAI,CAAC,UAAU;gBACf,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC;aAC3C;YACH,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;KACtC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, StateOverride, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { EntryPointVersion } from \"../../entrypoint/types\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationRequest,\n} from \"../../types\";\nimport { serializeStateOverride } from \"../../utils/stateOverride.js\";\n\nexport const estimateUserOperationGas = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n>(\n client: TClient,\n args: {\n request: UserOperationRequest<TEntryPointVersion>;\n entryPoint: Address;\n stateOverride?: StateOverride;\n },\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> => {\n return client.request({\n method: \"eth_estimateUserOperationGas\",\n params:\n args.stateOverride != null\n ? [\n args.request,\n args.entryPoint,\n serializeStateOverride(args.stateOverride),\n ]\n : [args.request, args.entryPoint],\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getSupportedEntryPoints.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getSupportedEntryPoints.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAG1C,MAAe,EACK,EAAE;IACtB,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,EAAE;KACX,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\n\nexport const getSupportedEntryPoints = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>\n>(\n client: TClient\n): Promise<Address[]> => {\n return client.request({\n method: \"eth_supportedEntryPoints\",\n params: [],\n });\n};\n"]}
1
+ {"version":3,"file":"getSupportedEntryPoints.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getSupportedEntryPoints.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAG1C,MAAe,EACK,EAAE;IACtB,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,EAAE;KACX,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\n\nexport const getSupportedEntryPoints = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n>(\n client: TClient,\n): Promise<Address[]> => {\n return client.request({\n method: \"eth_supportedEntryPoints\",\n params: [],\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getUserOperationByHash.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getUserOperationByHash.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAGzC,MAAe,EACf,IAEC,EACsC,EAAE;IACzC,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,4BAA4B;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;KACpB,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { UserOperationResponse } from \"../../types\";\n\nexport const getUserOperationByHash = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>\n>(\n client: TClient,\n args: {\n hash: Hex;\n }\n): Promise<UserOperationResponse | null> => {\n return client.request({\n method: \"eth_getUserOperationByHash\",\n params: [args.hash],\n });\n};\n"]}
1
+ {"version":3,"file":"getUserOperationByHash.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getUserOperationByHash.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAGzC,MAAe,EACf,IAEC,EACsC,EAAE;IACzC,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,4BAA4B;QACpC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;KACpB,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { UserOperationResponse } from \"../../types\";\n\nexport const getUserOperationByHash = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n>(\n client: TClient,\n args: {\n hash: Hex;\n },\n): Promise<UserOperationResponse | null> => {\n return client.request({\n method: \"eth_getUserOperationByHash\",\n params: [args.hash],\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getUserOperationReceipt.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAG1C,MAAe,EACf,IAEC,EACqC,EAAE;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;KACpB,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { UserOperationReceipt } from \"../../types\";\n\nexport const getUserOperationReceipt = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>\n>(\n client: TClient,\n args: {\n hash: Hex;\n }\n): Promise<UserOperationReceipt | null> => {\n return client.request({\n method: \"eth_getUserOperationReceipt\",\n params: [args.hash],\n });\n};\n"]}
1
+ {"version":3,"file":"getUserOperationReceipt.js","sourceRoot":"","sources":["../../../../src/actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAG1C,MAAe,EACf,IAEC,EACqC,EAAE;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,6BAA6B;QACrC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;KACpB,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { UserOperationReceipt } from \"../../types\";\n\nexport const getUserOperationReceipt = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n>(\n client: TClient,\n args: {\n hash: Hex;\n },\n): Promise<UserOperationReceipt | null> => {\n return client.request({\n method: \"eth_getUserOperationReceipt\",\n params: [args.hash],\n });\n};\n"]}
@@ -1,7 +1,8 @@
1
1
  import type { Address, Chain, Client, Hex, Transport } from "viem";
2
2
  import type { BundlerRpcSchema } from "../../client/decorators/bundlerClient";
3
+ import type { EntryPointVersion } from "../../entrypoint/types";
3
4
  import type { UserOperationRequest } from "../../types";
4
- export declare const sendRawUserOperation: <TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>, TEntryPointVersion extends keyof import("../../entrypoint/types").EntryPointRegistryBase<unknown> = keyof import("../../entrypoint/types").EntryPointRegistryBase<unknown>>(client: TClient, args: {
5
+ export declare const sendRawUserOperation: <TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>, TEntryPointVersion extends EntryPointVersion = EntryPointVersion>(client: TClient, args: {
5
6
  request: UserOperationRequest<TEntryPointVersion>;
6
7
  entryPoint: Address;
7
8
  }) => Promise<Hex>;
@@ -1 +1 @@
1
- {"version":3,"file":"sendRawUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/bundler/sendRawUserOperation.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAIvC,MAAe,EACf,IAGC,EACa,EAAE;IAChB,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;KACxC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { EntryPointVersion } from \"../../entrypoint/types\";\nimport type { UserOperationRequest } from \"../../types\";\n\nexport const sendRawUserOperation = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n client: TClient,\n args: {\n request: UserOperationRequest<TEntryPointVersion>;\n entryPoint: Address;\n }\n): Promise<Hex> => {\n return client.request({\n method: \"eth_sendUserOperation\",\n params: [args.request, args.entryPoint],\n });\n};\n"]}
1
+ {"version":3,"file":"sendRawUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/bundler/sendRawUserOperation.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAIvC,MAAe,EACf,IAGC,EACa,EAAE;IAChB,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;KACxC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, Transport } from \"viem\";\nimport type { BundlerRpcSchema } from \"../../client/decorators/bundlerClient\";\nimport type { EntryPointVersion } from \"../../entrypoint/types\";\nimport type { UserOperationRequest } from \"../../types\";\n\nexport const sendRawUserOperation = async <\n TClient extends Client<Transport, Chain | undefined, any, BundlerRpcSchema>,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n>(\n client: TClient,\n args: {\n request: UserOperationRequest<TEntryPointVersion>;\n entryPoint: Address;\n },\n): Promise<Hex> => {\n return client.request({\n method: \"eth_sendUserOperation\",\n params: [args.request, args.entryPoint],\n });\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,MAAM,MAAM,CAAC;AAC/D,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,OAA6C,EAC7C,IAA0E;IAE1E,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IACjE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,qBAAqB,EACrB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,mBAAmB,CAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type Chain, type Client, type Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport type {\n BuildUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../client/addBreadcrumb.js\";\n\nconst USER_OPERATION_METHOD = \"buildUserOperation\";\n/**\n * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with buildUserOperation\n * const client = createSmartAccountClient(...);\n * const result = await client.buildUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * },\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the client instance used to build the user operation\n * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details\n */\nexport async function buildUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, USER_OPERATION_METHOD);\n const { account = client.account, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n USER_OPERATION_METHOD,\n client\n );\n }\n\n return _initUserOperation(client, args).then((_uo) =>\n _runMiddlewareStack(client, {\n uo: _uo,\n overrides,\n account,\n context,\n })\n );\n}\n"]}
1
+ {"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/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{\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport type {\n BuildUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../client/addBreadcrumb.js\";\n\nconst USER_OPERATION_METHOD = \"buildUserOperation\";\n/**\n * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with buildUserOperation\n * const client = createSmartAccountClient(...);\n * const result = await client.buildUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * },\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the client instance used to build the user operation\n * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details\n */\nexport async function buildUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>,\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, USER_OPERATION_METHOD);\n const { account = client.account, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n USER_OPERATION_METHOD,\n client,\n );\n }\n\n return _initUserOperation(client, args).then((_uo) =>\n _runMiddlewareStack(client, {\n uo: _uo,\n overrides,\n account,\n context,\n }),\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,OAA4C,EAC5C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACrE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;YAChD,CAAC,CAAC,OAAO,CAAC,oBAAoB;YAC9B,CAAC,CAAC,SAAS;KACgC,CAAC;IAEhD,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,EAAE;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;SAC1C;QACD,OAAO,EAAE,OAA+B;QACxC,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured `ClientMiddlewares` on the `SmartAccountClient`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTx\");\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
1
+ {"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,KAA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type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured `ClientMiddlewares` on the `SmartAccountClient`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext,\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTx\");\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client,\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mapp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M,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,oFAAoF;QACpF,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use to make RPC calls\n * @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTxs\");\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
1
+ {"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,MAAM,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;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,YAAY,IAAI,IAAI;QAC7B,CAAC,CAAC,SAAS,EAAE,YAAY;QACzB,CAAC,CAAC,iBAAiB,EAAE,CAAC,MAAM,GAAG,CAAC;YAC9B,CAAC,CAAC,SAAS,CAAC,GAAG,iBAAiB,EAAE,CAAC;YACnC,CAAC,CAAC,SAAS,CAAC;IAElB,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAC9B,QAAQ;SACL,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,oBAAoB,IAAI,IAAI,CAAC;SAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GACxB,SAAS,EAAE,oBAAoB,IAAI,IAAI;QACrC,CAAC,CAAC,SAAS,EAAE,oBAAoB;QACjC,CAAC,CAAC,kBAAkB,EAAE,CAAC,MAAM,GAAG,CAAC;YAC/B,CAAC,CAAC,SAAS,CAAC,GAAG,kBAAkB,EAAE,CAAC;YACpC,CAAC,CAAC,SAAS,CAAC;IAElB,MAAM,UAAU,GAAG;QACjB,YAAY;QACZ,oBAAoB;KACyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QAChD,EAAE,EAAE,KAAK;QACT,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,oFAAoF;QACpF,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use to make RPC calls\n * @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>,\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTxs\");\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client,\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,8BAA8B,CAU5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;IAC5E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC9B,QAAQ,EACN,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAE,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;gBAC3B,mBAAoD;qBAClD,gBAAgB,KAAK,IAAI;YAC9B,CAAC,CAAE,mBAAoD;iBAClD,aAAa,KAAK,IAAI;gBACxB,mBAAoD;qBAClD,aAAa,KAAK,IAAI;QAC/B,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;SACF,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\nexport type CheckGasSponsorshipEligibilityResult<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n eligible: boolean;\n request?: UserOperationStruct<TEntryPointVersion>;\n};\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.\n * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<CheckGasSponsorshipEligibilityResult<TAccount>> {\n const client = clientHeaderTrack(client_, \"checkGasSponsorshipEligibility\");\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) => ({\n eligible:\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null,\n request: userOperationStruct,\n }))\n .catch(() => ({\n eligible: false,\n }));\n}\n"]}
1
+ {"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAanD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,8BAA8B,CAU5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;IAC5E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC9B,QAAQ,EACN,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAE,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;gBAC3B,mBAAoD;qBAClD,gBAAgB,KAAK,IAAI;YAC9B,CAAC,CAAE,mBAAoD;iBAClD,aAAa,KAAK,IAAI;gBACxB,mBAAoD;qBAClD,aAAa,KAAK,IAAI;QAC/B,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;SACF,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\nexport type CheckGasSponsorshipEligibilityResult<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n> = {\n eligible: boolean;\n request?: UserOperationStruct<TEntryPointVersion>;\n};\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.\n * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>,\n): Promise<CheckGasSponsorshipEligibilityResult<TAccount>> {\n const client = clientHeaderTrack(client_, \"checkGasSponsorshipEligibility\");\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client,\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) => ({\n eligible:\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null,\n request: userOperationStruct,\n }))\n .catch(() => ({\n eligible: false,\n }));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAW/C,OAA6C,EAC7C,IAA+D;IAE/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IACzE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,6BAA6B,EAC7B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,UAAU,GAAG,CACjB,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,QAAQ,EAAG,QAA0C,CAAC,QAAQ;YAC9D,MAAM,EAAG,QAA0C,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,kBAAkB,CAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport {\n bigIntMax,\n bigIntMultiply,\n resolveProperties,\n} from \"../../utils/index.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n DropAndReplaceUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.\n *\n * @example\n * ```ts\n * import {\n * createSmartAccountClient,\n * } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with dropAndReplaceUserOperation\n * const client = createSmartAccountClient(...);\n * const { request } = await client.sendUserOperation(...);\n * const result = await client.dropAndReplaceUserOperation({\n * uoToDrop: request,\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client instance with the transport, chain, and account information\n * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation\n */\nexport async function dropAndReplaceUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"dropAndReplaceUserOperation\");\n const { account = client.account, uoToDrop, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"dropAndReplaceUserOperation\",\n client\n );\n }\n\n const entryPoint = account.getEntryPoint();\n\n const uoToSubmit = (\n entryPoint.version === \"0.6.0\"\n ? {\n initCode: (uoToDrop as UserOperationRequest<\"0.6.0\">).initCode,\n sender: (uoToDrop as UserOperationRequest<\"0.6.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.6.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.6.0\">).callData,\n signature: await account.getDummySignature(),\n }\n : {\n ...((uoToDrop as UserOperationRequest<\"0.7.0\">).factory &&\n (uoToDrop as UserOperationRequest<\"0.7.0\">).factoryData\n ? {\n factory: (uoToDrop as UserOperationRequest<\"0.7.0\">).factory,\n factoryData: (uoToDrop as UserOperationRequest<\"0.7.0\">)\n .factoryData,\n }\n : {}),\n sender: (uoToDrop as UserOperationRequest<\"0.7.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.7.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.7.0\">).callData,\n signature: await account.getDummySignature(),\n }\n ) as UserOperationStruct<TEntryPointVersion>;\n\n // If the fee estimator is not the one estimating fees, then this won't work\n // however, we have migrated to using erc7677middleware for alchemy paymaster flows\n // and most of the other paymasters we've seen don't do fee estimation\n const { maxFeePerGas, maxPriorityFeePerGas } = await resolveProperties(\n await client.middleware.feeEstimator(uoToSubmit, { account, client })\n );\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: bigIntMax(\n BigInt(maxFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxFeePerGas, 1.1)\n ),\n maxPriorityFeePerGas: bigIntMax(\n BigInt(maxPriorityFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxPriorityFeePerGas, 1.1)\n ),\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoToSend = await _runMiddlewareStack(client, {\n uo: uoToSubmit,\n overrides: _overrides,\n account,\n });\n\n return _sendUserOperation(client, {\n uoStruct: uoToSend,\n account,\n context,\n overrides: _overrides,\n });\n}\n"]}
1
+ {"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAY/C,OAA6C,EAC7C,IAA+D;IAE/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IACzE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,C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,CACrB,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAC1B,cAAc,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAC3C;QACD,oBAAoB,EAAE,SAAS,CAC7B,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAClC,cAAc,CAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,CACnD;KAC4C,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE;QACjD,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,UAAU;QACrB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport {\n bigIntMax,\n bigIntMultiply,\n resolveProperties,\n} from \"../../utils/index.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n DropAndReplaceUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.\n *\n * @example\n * ```ts\n * import {\n * createSmartAccountClient,\n * } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with dropAndReplaceUserOperation\n * const client = createSmartAccountClient(...);\n * const { request } = await client.sendUserOperation(...);\n * const result = await client.dropAndReplaceUserOperation({\n * uoToDrop: request,\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client instance with the transport, chain, and account information\n * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation\n */\nexport async function dropAndReplaceUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>,\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"dropAndReplaceUserOperation\");\n const { account = client.account, uoToDrop, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"dropAndReplaceUserOperation\",\n client,\n );\n }\n\n const entryPoint = account.getEntryPoint();\n\n const uoToSubmit = (\n entryPoint.version === \"0.6.0\"\n ? {\n initCode: (uoToDrop as UserOperationRequest<\"0.6.0\">).initCode,\n sender: (uoToDrop as UserOperationRequest<\"0.6.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.6.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.6.0\">).callData,\n signature: await account.getDummySignature(),\n }\n : {\n ...((uoToDrop as UserOperationRequest<\"0.7.0\">).factory &&\n (uoToDrop as UserOperationRequest<\"0.7.0\">).factoryData\n ? {\n factory: (uoToDrop as UserOperationRequest<\"0.7.0\">).factory,\n factoryData: (uoToDrop as UserOperationRequest<\"0.7.0\">)\n .factoryData,\n }\n : {}),\n sender: (uoToDrop as UserOperationRequest<\"0.7.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.7.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.7.0\">).callData,\n signature: await account.getDummySignature(),\n }\n ) as UserOperationStruct<TEntryPointVersion>;\n\n // If the fee estimator is not the one estimating fees, then this won't work\n // however, we have migrated to using erc7677middleware for alchemy paymaster flows\n // and most of the other paymasters we've seen don't do fee estimation\n const { maxFeePerGas, maxPriorityFeePerGas } = await resolveProperties(\n await client.middleware.feeEstimator(uoToSubmit, { account, client }),\n );\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: bigIntMax(\n BigInt(maxFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxFeePerGas, 1.1),\n ),\n maxPriorityFeePerGas: bigIntMax(\n BigInt(maxPriorityFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxPriorityFeePerGas, 1.1),\n ),\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoToSend = await _runMiddlewareStack(client, {\n uo: uoToSubmit,\n overrides: _overrides,\n account,\n });\n\n return _sendUserOperation(client, {\n uoStruct: uoToSend,\n account,\n context,\n overrides: _overrides,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client_ smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
1
+ {"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAY5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client_ smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>,\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client,\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride,\n );\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getAddress.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/getAddress.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GASR,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\n\nexport const getAddress: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: GetAccountParameter<TAccount>\n) => Address = (client, args) => {\n const { account } = args ?? { account: client.account };\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return account.address;\n};\n"]}
1
+ {"version":3,"file":"getAddress.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/getAddress.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,CAAC,MAAM,UAAU,GASR,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\n\nexport const getAddress: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: GetAccountParameter<TAccount>,\n) => Address = (client, args) => {\n const { account } = args ?? { account: client.account };\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return account.address;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/initUserOperation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAmB,MAAM,yBAAyB,CAAC;AAO7E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,MAA4D,EAC5D,IAEwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChC,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ;YACxB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAE9B,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAE9C,MAAM,KAAK,GACT,SAAS,EAAE,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEnE,MAAM,MAAM,GACV,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAE;YACC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE;YAC/B,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,KAAK;YACL,QAAQ;YACR,SAAS;SAC8C;QAC3D,CAAC,CAAE;YACC,OAAO,EAAE,iBAAiB,CACxB,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EACzD,OAAO,CAAC,iBAAiB,CAC1B;YACD,WAAW,EAAE,iBAAiB,CAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EACzD,OAAO,CAAC,cAAc,CACvB;YACD,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,KAAK;YACL,QAAQ;YACR,SAAS;SAC8C,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount.js\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../../types.js\";\nimport { conditionalReturn, type Deferrable } from \"../../../utils/index.js\";\nimport type {\n BuildUserOperationParameters,\n SendUserOperationParameters,\n UserOperationContext,\n} from \"../types.js\";\n\n/**\n * Description internal action function of SmartAccountClient for initializing\n * a user operation for the sender account\n *\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount} TEntryPointVersion\n * @param {BaseSmartAccountClient<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args send user operation parameters\n * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} initialized user operation struct\n */\nexport async function _initUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args:\n | SendUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>> {\n const { account = client.account, uo, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n\n const callData = Array.isArray(uo)\n ? account.encodeBatchExecute(uo)\n : typeof uo === \"string\"\n ? uo\n : account.encodeExecute(uo);\n\n const signature = account.getDummySignature();\n\n const nonce =\n overrides?.nonce ?? account.getAccountNonce(overrides?.nonceKey);\n\n const struct =\n entryPoint.version === \"0.6.0\"\n ? ({\n initCode: account.getInitCode(),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>)\n : ({\n factory: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryAddress\n ),\n factoryData: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryData\n ),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>);\n\n return struct;\n}\n"]}
1
+ {"version":3,"file":"initUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/initUserOperation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAmB,MAAM,yBAAyB,CAAC;AAO7E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAYtC,MAA4D,EAC5D,IAEwE;IAExE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChC,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAE9C,MAAM,KAAK,GACT,SAAS,EAAE,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEnE,MAAM,MAAM,GACV,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAE;YACC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE;YAC/B,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,KAAK;YACL,QAAQ;YACR,SAAS;SAC8C;QAC3D,CAAC,CAAE;YACC,OAAO,EAAE,iBAAiB,CACxB,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EACzD,OAAO,CAAC,iBAAiB,CAC1B;YACD,WAAW,EAAE,iBAAiB,CAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EACzD,OAAO,CAAC,cAAc,CACvB;YACD,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,KAAK;YACL,QAAQ;YACR,SAAS;SAC8C,CAAC;IAEhE,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount.js\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../../types.js\";\nimport { conditionalReturn, type Deferrable } from \"../../../utils/index.js\";\nimport type {\n BuildUserOperationParameters,\n SendUserOperationParameters,\n UserOperationContext,\n} from \"../types.js\";\n\n/**\n * Description internal action function of SmartAccountClient for initializing\n * a user operation for the sender account\n *\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount} TEntryPointVersion\n * @param {BaseSmartAccountClient<TTransport, TChain, TAccount>} client smart account client\n * @param {SendUserOperationParameters<TAccount, TContext, TEntryPointVersion> | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args send user operation parameters\n * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} initialized user operation struct\n */\nexport async function _initUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args:\n | SendUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n | BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>,\n): Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>> {\n const { account = client.account, uo, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n\n const callData = Array.isArray(uo)\n ? account.encodeBatchExecute(uo)\n : typeof uo === \"string\"\n ? uo\n : account.encodeExecute(uo);\n\n const signature = account.getDummySignature();\n\n const nonce =\n overrides?.nonce ?? account.getAccountNonce(overrides?.nonceKey);\n\n const struct =\n entryPoint.version === \"0.6.0\"\n ? ({\n initCode: account.getInitCode(),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>)\n : ({\n factory: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryAddress,\n ),\n factoryData: conditionalReturn(\n account.isAccountDeployed().then((deployed) => !deployed),\n account.getFactoryData,\n ),\n sender: account.address,\n nonce,\n callData,\n signature,\n } as Deferrable<UserOperationStruct<TEntryPointVersion>>);\n\n return struct;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"runMiddlewareStack.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/runMiddlewareStack.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAMvE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,SAAS,GACb,CAAU,GAAG,GAAyC,EAAE,EAAE,CAC1D,KAAK,EAAE,CAAI,EAAE,IAAU,EAAE,EAAE;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEJ,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAWvC,MAA4D,EAC5D,IAIqD;IAErD,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAClE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,EACJ,qBAAqB,EACrB,gBAAgB,GACjB,GAGG,sBAAsB,CAAC,SAAS,CAAC;QACnC,CAAC,CAAC;YACE,qBAAqB,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;gBACjD,OAAO;oBACL,GAAG,EAAE;oBACL,GAAG,CAAC,kBAAkB,IAAI,SAAU;wBAClC,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,EAAE;wBAClD,CAAC,CAAC,eAAe,IAAI,SAAU;4BAC7B,WAAW,IAAI,SAAS;4BACxB,SAAS,CAAC,aAAa,KAAK,IAAI;4BAClC,CAAC,CAAC;gCACE,aAAa,EAAE,SAAS,CAAC,aAAa;gCACtC,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;4BACH,CAAC,CAAC,sDAAsD;gCACtD,qEAAqE;gCACrE,SAAS,CAAC;iBACf,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,cAAc;SACjC;QACH,CAAC,CAAC;YACE,qBAAqB,EAAE,MAAM,CAAC,UAAU,CAAC,qBAAqB;YAC9D,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,gBAAgB;SACrD,CAAC;IAEN,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,qBAAqB,EACrB,MAAM,CAAC,UAAU,CAAC,YAAY,EAC9B,MAAM,CAAC,UAAU,CAAC,YAAY,EAC9B,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAClC,gBAAgB,EAChB,MAAM,CAAC,UAAU,CAAC,sBAAsB,CACzC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAE9E,OAAO,iBAAiB,CAEtB,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { noopMiddleware } from \"../../../middleware/noopMiddleware.js\";\nimport type { ClientMiddleware } from \"../../../middleware/types\";\nimport type {\n UserOperationOverridesParameter,\n UserOperationStruct,\n} from \"../../../types\";\nimport {\n bypassPaymasterAndData,\n resolveProperties,\n type Deferrable,\n} from \"../../../utils/index.js\";\nimport type { UserOperationContext } from \"../types\";\n\nconst asyncPipe =\n <S, Opts>(...fns: ((s: S, opts: Opts) => Promise<S>)[]) =>\n async (s: S, opts: Opts) => {\n let result = s;\n for (const fn of fns) {\n result = await fn(result, opts);\n }\n return result;\n };\n\nexport async function _runMiddlewareStack<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uo: Deferrable<UserOperationStruct<TEntryPointVersion>>;\n context?: TContext;\n } & GetAccountParameter<TAccount> &\n UserOperationOverridesParameter<TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { uo, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const {\n dummyPaymasterAndData,\n paymasterAndData,\n }: Pick<\n ClientMiddleware<TContext>,\n \"dummyPaymasterAndData\" | \"paymasterAndData\"\n > = bypassPaymasterAndData(overrides)\n ? {\n dummyPaymasterAndData: async (uo, { overrides }) => {\n return {\n ...uo,\n ...(\"paymasterAndData\" in overrides!\n ? { paymasterAndData: overrides.paymasterAndData }\n : \"paymasterData\" in overrides! &&\n \"paymaster\" in overrides &&\n overrides.paymasterData !== \"0x\"\n ? {\n paymasterData: overrides.paymasterData,\n paymaster: overrides.paymaster,\n }\n : // At this point, nothing has run so no fields are set\n // for 0.7 when not using a paymaster, all fields should be undefined\n undefined),\n };\n },\n paymasterAndData: noopMiddleware,\n }\n : {\n dummyPaymasterAndData: client.middleware.dummyPaymasterAndData,\n paymasterAndData: client.middleware.paymasterAndData,\n };\n\n const result = await asyncPipe(\n dummyPaymasterAndData,\n client.middleware.feeEstimator,\n client.middleware.gasEstimator,\n client.middleware.customMiddleware,\n paymasterAndData,\n client.middleware.userOperationSimulator\n )(uo, { overrides, feeOptions: client.feeOptions, account, client, context });\n\n return resolveProperties<\n UserOperationStruct<GetEntryPointFromAccount<TAccount>>\n >(result);\n}\n"]}
1
+ {"version":3,"file":"runMiddlewareStack.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/runMiddlewareStack.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAMvE,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,SAAS,GACb,CAAU,GAAG,GAAyC,EAAE,EAAE,CAC1D,KAAK,EAAE,CAAI,EAAE,IAAU,EAAE,EAAE;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEJ,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAYvC,MAA4D,EAC5D,IAIqD;IAErD,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAClE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,EACJ,qBAAqB,EACrB,gBAAgB,GACjB,GAGG,sBAAsB,CAAC,SAAS,CAAC;QACnC,CAAC,CAAC;YACE,qBAAqB,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;gBACjD,OAAO;oBACL,GAAG,EAAE;oBACL,GAAG,CAAC,kBAAkB,IAAI,SAAU;wBAClC,CAAC,CAAC,EAAE,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,EAAE;wBAClD,CAAC,CAAC,eAAe,IAAI,SAAU;4BAC3B,WAAW,IAAI,SAAS;4BACxB,SAAS,CAAC,aAAa,KAAK,IAAI;4BAClC,CAAC,CAAC;gCACE,aAAa,EAAE,SAAS,CAAC,aAAa;gCACtC,SAAS,EAAE,SAAS,CAAC,SAAS;6BAC/B;4BACH,CAAC,CAAC,sDAAsD;gCACtD,qEAAqE;gCACrE,SAAS,CAAC;iBACjB,CAAC;YACJ,CAAC;YACD,gBAAgB,EAAE,cAAc;SACjC;QACH,CAAC,CAAC;YACE,qBAAqB,EAAE,MAAM,CAAC,UAAU,CAAC,qBAAqB;YAC9D,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,gBAAgB;SACrD,CAAC;IAEN,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,qBAAqB,EACrB,MAAM,CAAC,UAAU,CAAC,YAAY,EAC9B,MAAM,CAAC,UAAU,CAAC,YAAY,EAC9B,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAClC,gBAAgB,EAChB,MAAM,CAAC,UAAU,CAAC,sBAAsB,CACzC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAE9E,OAAO,iBAAiB,CAEtB,MAAM,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { noopMiddleware } from \"../../../middleware/noopMiddleware.js\";\nimport type { ClientMiddleware } from \"../../../middleware/types\";\nimport type {\n UserOperationOverridesParameter,\n UserOperationStruct,\n} from \"../../../types\";\nimport {\n bypassPaymasterAndData,\n resolveProperties,\n type Deferrable,\n} from \"../../../utils/index.js\";\nimport type { UserOperationContext } from \"../types\";\n\nconst asyncPipe =\n <S, Opts>(...fns: ((s: S, opts: Opts) => Promise<S>)[]) =>\n async (s: S, opts: Opts) => {\n let result = s;\n for (const fn of fns) {\n result = await fn(result, opts);\n }\n return result;\n };\n\nexport async function _runMiddlewareStack<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uo: Deferrable<UserOperationStruct<TEntryPointVersion>>;\n context?: TContext;\n } & GetAccountParameter<TAccount> &\n UserOperationOverridesParameter<TEntryPointVersion>,\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const { uo, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const {\n dummyPaymasterAndData,\n paymasterAndData,\n }: Pick<\n ClientMiddleware<TContext>,\n \"dummyPaymasterAndData\" | \"paymasterAndData\"\n > = bypassPaymasterAndData(overrides)\n ? {\n dummyPaymasterAndData: async (uo, { overrides }) => {\n return {\n ...uo,\n ...(\"paymasterAndData\" in overrides!\n ? { paymasterAndData: overrides.paymasterAndData }\n : \"paymasterData\" in overrides! &&\n \"paymaster\" in overrides &&\n overrides.paymasterData !== \"0x\"\n ? {\n paymasterData: overrides.paymasterData,\n paymaster: overrides.paymaster,\n }\n : // At this point, nothing has run so no fields are set\n // for 0.7 when not using a paymaster, all fields should be undefined\n undefined),\n };\n },\n paymasterAndData: noopMiddleware,\n }\n : {\n dummyPaymasterAndData: client.middleware.dummyPaymasterAndData,\n paymasterAndData: client.middleware.paymasterAndData,\n };\n\n const result = await asyncPipe(\n dummyPaymasterAndData,\n client.middleware.feeEstimator,\n client.middleware.gasEstimator,\n client.middleware.customMiddleware,\n paymasterAndData,\n client.middleware.userOperationSimulator,\n )(uo, { overrides, feeOptions: client.feeOptions, account, client, context });\n\n return resolveProperties<\n UserOperationStruct<GetEntryPointFromAccount<TAccount>>\n >(result);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/sendUserOperation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,MAA4D,EAC5D,IAI+B;IAE/B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC9C,QAAQ;QACR,OAAO;QACP,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QACpE,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport type { SendUserOperationResult } from \"../../../client/types\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../../types\";\nimport { signUserOperation } from \"../signUserOperation.js\";\nimport type { GetContextParameter, UserOperationContext } from \"../types\";\n\nexport async function _sendUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uoStruct: UserOperationStruct<TEntryPointVersion>;\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n } & GetAccountParameter<TAccount> &\n GetContextParameter<TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, uoStruct, context, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n const request = await signUserOperation(client, {\n uoStruct,\n account,\n context,\n overrides,\n });\n\n return {\n hash: await client.sendRawUserOperation(request, entryPoint.address),\n request,\n };\n}\n"]}
1
+ {"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../../src/actions/smartAccount/internal/sendUserOperation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAYtC,MAA4D,EAC5D,IAI+B;IAE/B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC9C,QAAQ;QACR,OAAO;QACP,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,MAAM,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;QACpE,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Chain, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../../account/smartContractAccount\";\nimport type { BaseSmartAccountClient } from \"../../../client/smartAccountClient\";\nimport type { SendUserOperationResult } from \"../../../client/types\";\nimport { AccountNotFoundError } from \"../../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../../types\";\nimport { signUserOperation } from \"../signUserOperation.js\";\nimport type { GetContextParameter, UserOperationContext } from \"../types\";\n\nexport async function _sendUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client: BaseSmartAccountClient<TTransport, TChain, TAccount>,\n args: {\n uoStruct: UserOperationStruct<TEntryPointVersion>;\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n } & GetAccountParameter<TAccount> &\n GetContextParameter<TContext>,\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const { account = client.account, uoStruct, context, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n const request = await signUserOperation(client, {\n uoStruct,\n account,\n context,\n overrides,\n });\n\n return {\n hash: await client.sendRawUserOperation(request, entryPoint.address),\n request,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAWnC,OAA4C,EAC5C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC1C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAC7C,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QACzD,OAAO,EAAE,OAA+B;QACxC,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n Chain,\n Client,\n Hex,\n SendTransactionParameters,\n Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport type { UserOperationOverrides } from \"../../types.js\";\nimport { buildUserOperationFromTx } from \"./buildUserOperationFromTx.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends a transaction using the provided client, arguments, optional overrides, and context.\n * This sends a UO and then waits for it to be mined\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransaction\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransaction({\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ The client to send the transaction through\n * @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction\n * @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation\n * @param {UserOperationContext} [context] Optional context for the user operation\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash\n */\nexport async function sendTransaction<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!args.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransaction\",\n client\n );\n }\n\n const uoStruct = await buildUserOperationFromTx(\n client,\n args,\n overrides,\n context\n );\n\n const { hash, request } = await _sendUserOperation(client, {\n account: account as SmartContractAccount,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}
1
+ {"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAYnC,OAA4C,EAC5C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC1C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAC7C,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QACzD,OAAO,EAAE,OAA+B;QACxC,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n Chain,\n Client,\n Hex,\n SendTransactionParameters,\n Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport type { UserOperationOverrides } from \"../../types.js\";\nimport { buildUserOperationFromTx } from \"./buildUserOperationFromTx.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends a transaction using the provided client, arguments, optional overrides, and context.\n * This sends a UO and then waits for it to be mined\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransaction\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransaction({\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ The client to send the transaction through\n * @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction\n * @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation\n * @param {UserOperationContext} [context] Optional context for the user operation\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash\n */\nexport async function sendTransaction<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext,\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!args.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransaction\",\n client,\n );\n }\n\n const uoStruct = await buildUserOperationFromTx(\n client,\n args,\n overrides,\n context,\n );\n\n const { hash, request } = await _sendUserOperation(client, {\n account: account as SmartContractAccount,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sendTransactions.js","sourceRoot":"","sources":["../../../../src/act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ACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport { buildUserOperationFromTxs } from \"./buildUserOperationFromTxs.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { SendTransactionsParameters, UserOperationContext } from \"./types\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransactions\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransactions({\n * requests: [{\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * }],\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client used to send the transactions\n * @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions\n */\nexport async function sendTransactions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined = UserOperationContext\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendTransactionsParameters<TAccount, TContext>\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { requests, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransactions\",\n client\n );\n }\n\n const { uoStruct } = await buildUserOperationFromTxs(client, {\n requests,\n overrides,\n account,\n context,\n });\n\n const { hash, request } = await _sendUserOperation(client, {\n account,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}
1
+ {"version":3,"file":"sendTransactions.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAQpC,OAA6C,EAC7C,IAAoD;IAEpD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,yBAAyB,CAAC,MAAM,EAAE;QAC3D,QAAQ;QACR,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QACzD,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport { buildUserOperationFromTxs } from \"./buildUserOperationFromTxs.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { SendTransactionsParameters, UserOperationContext } from \"./types\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransactions\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransactions({\n * requests: [{\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * }],\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client used to send the transactions\n * @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions\n */\nexport async function sendTransactions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined = UserOperationContext,\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendTransactionsParameters<TAccount, TContext>,\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { requests, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransactions\",\n client,\n );\n }\n\n const { uoStruct } = await buildUserOperationFromTxs(client, {\n requests,\n overrides,\n account,\n context,\n });\n\n const { hash, request } = await _sendUserOperation(client, {\n account,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}