@aa-sdk/core 4.0.0-alpha.0 → 4.0.0-alpha.2

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 (195) hide show
  1. package/dist/cjs/account/simple.js.map +1 -1
  2. package/dist/cjs/account/smartContractAccount.js +2 -1
  3. package/dist/cjs/account/smartContractAccount.js.map +1 -1
  4. package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +1 -1
  5. package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  6. package/dist/cjs/actions/smartAccount/sendTransaction.js.map +1 -1
  7. package/dist/cjs/actions/smartAccount/sendTransactions.js.map +1 -1
  8. package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  9. package/dist/cjs/client/bundlerClient.js.map +1 -1
  10. package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
  11. package/dist/cjs/client/decorators/smartAccountClient.js.map +1 -1
  12. package/dist/cjs/client/smartAccountClient.js.map +1 -1
  13. package/dist/cjs/ens/utils.d.ts +1 -1
  14. package/dist/cjs/ens/utils.js +3 -3
  15. package/dist/cjs/ens/utils.js.map +1 -1
  16. package/dist/cjs/entrypoint/index.js.map +1 -1
  17. package/dist/cjs/errors/account.js.map +1 -1
  18. package/dist/cjs/errors/base.js.map +1 -1
  19. package/dist/cjs/errors/client.js.map +1 -1
  20. package/dist/cjs/errors/entrypoint.js.map +1 -1
  21. package/dist/cjs/errors/signer.js.map +1 -1
  22. package/dist/cjs/errors/transaction.js.map +1 -1
  23. package/dist/cjs/index.d.ts +2 -3
  24. package/dist/cjs/index.js +35 -60
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/logger.js.map +1 -1
  27. package/dist/cjs/middleware/defaults/feeEstimator.d.ts +1 -1
  28. package/dist/cjs/middleware/defaults/feeEstimator.js +17 -15
  29. package/dist/cjs/middleware/defaults/feeEstimator.js.map +1 -1
  30. package/dist/cjs/middleware/defaults/paymasterAndData.js.map +1 -1
  31. package/dist/cjs/middleware/defaults/userOpSigner.js.map +1 -1
  32. package/dist/cjs/signer/local-account.d.ts +2 -2
  33. package/dist/cjs/signer/local-account.js.map +1 -1
  34. package/dist/cjs/signer/schema.js.map +1 -1
  35. package/dist/cjs/signer/utils.d.ts +1 -9
  36. package/dist/cjs/signer/utils.js +1 -16
  37. package/dist/cjs/signer/utils.js.map +1 -1
  38. package/dist/cjs/signer/wallet-client.d.ts +2 -2
  39. package/dist/cjs/signer/wallet-client.js.map +1 -1
  40. package/dist/cjs/utils/defaults.d.ts +1 -1
  41. package/dist/cjs/utils/defaults.js +25 -25
  42. package/dist/cjs/utils/defaults.js.map +1 -1
  43. package/dist/cjs/utils/index.d.ts +0 -4
  44. package/dist/cjs/utils/index.js +1 -33
  45. package/dist/cjs/utils/index.js.map +1 -1
  46. package/dist/cjs/version.d.ts +1 -1
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/cjs/version.js.map +1 -1
  49. package/dist/esm/account/simple.js.map +1 -1
  50. package/dist/esm/account/smartContractAccount.js +2 -1
  51. package/dist/esm/account/smartContractAccount.js.map +1 -1
  52. package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
  53. package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
  54. package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
  55. package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
  56. package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
  57. package/dist/esm/client/bundlerClient.js.map +1 -1
  58. package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
  59. package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
  60. package/dist/esm/client/smartAccountClient.js.map +1 -1
  61. package/dist/esm/ens/utils.d.ts +1 -1
  62. package/dist/esm/ens/utils.js +1 -1
  63. package/dist/esm/ens/utils.js.map +1 -1
  64. package/dist/esm/entrypoint/index.js.map +1 -1
  65. package/dist/esm/errors/account.js.map +1 -1
  66. package/dist/esm/errors/base.js.map +1 -1
  67. package/dist/esm/errors/client.js.map +1 -1
  68. package/dist/esm/errors/entrypoint.js.map +1 -1
  69. package/dist/esm/errors/signer.js.map +1 -1
  70. package/dist/esm/errors/transaction.js.map +1 -1
  71. package/dist/esm/index.d.ts +2 -3
  72. package/dist/esm/index.js +2 -3
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/logger.js.map +1 -1
  75. package/dist/esm/middleware/defaults/feeEstimator.d.ts +1 -1
  76. package/dist/esm/middleware/defaults/feeEstimator.js +17 -15
  77. package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
  78. package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
  79. package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
  80. package/dist/esm/signer/local-account.d.ts +2 -2
  81. package/dist/esm/signer/local-account.js.map +1 -1
  82. package/dist/esm/signer/schema.js.map +1 -1
  83. package/dist/esm/signer/utils.d.ts +1 -9
  84. package/dist/esm/signer/utils.js +0 -14
  85. package/dist/esm/signer/utils.js.map +1 -1
  86. package/dist/esm/signer/wallet-client.d.ts +2 -2
  87. package/dist/esm/signer/wallet-client.js.map +1 -1
  88. package/dist/esm/utils/defaults.d.ts +1 -1
  89. package/dist/esm/utils/defaults.js +2 -2
  90. package/dist/esm/utils/defaults.js.map +1 -1
  91. package/dist/esm/utils/index.d.ts +0 -4
  92. package/dist/esm/utils/index.js +0 -18
  93. package/dist/esm/utils/index.js.map +1 -1
  94. package/dist/esm/version.d.ts +1 -1
  95. package/dist/esm/version.js +1 -1
  96. package/dist/esm/version.js.map +1 -1
  97. package/dist/types/account/smartContractAccount.d.ts +49 -0
  98. package/dist/types/account/smartContractAccount.d.ts.map +1 -1
  99. package/dist/types/actions/smartAccount/buildUserOperation.d.ts +23 -0
  100. package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
  101. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
  102. package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
  103. package/dist/types/actions/smartAccount/sendTransaction.d.ts +24 -0
  104. package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
  105. package/dist/types/actions/smartAccount/sendTransactions.d.ts +23 -0
  106. package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
  107. package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
  108. package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
  109. package/dist/types/client/bundlerClient.d.ts +15 -0
  110. package/dist/types/client/bundlerClient.d.ts.map +1 -1
  111. package/dist/types/client/decorators/bundlerClient.d.ts +9 -0
  112. package/dist/types/client/decorators/bundlerClient.d.ts.map +1 -1
  113. package/dist/types/client/decorators/smartAccountClient.d.ts +8 -0
  114. package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
  115. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  116. package/dist/types/ens/utils.d.ts +46 -1
  117. package/dist/types/ens/utils.d.ts.map +1 -1
  118. package/dist/types/entrypoint/index.d.ts +14 -0
  119. package/dist/types/entrypoint/index.d.ts.map +1 -1
  120. package/dist/types/errors/account.d.ts +34 -0
  121. package/dist/types/errors/account.d.ts.map +1 -1
  122. package/dist/types/errors/base.d.ts +5 -0
  123. package/dist/types/errors/base.d.ts.map +1 -1
  124. package/dist/types/errors/client.d.ts +9 -0
  125. package/dist/types/errors/client.d.ts.map +1 -1
  126. package/dist/types/errors/entrypoint.d.ts +6 -0
  127. package/dist/types/errors/entrypoint.d.ts.map +1 -1
  128. package/dist/types/errors/signer.d.ts +3 -0
  129. package/dist/types/errors/signer.d.ts.map +1 -1
  130. package/dist/types/errors/transaction.d.ts +6 -0
  131. package/dist/types/errors/transaction.d.ts.map +1 -1
  132. package/dist/types/index.d.ts +2 -3
  133. package/dist/types/index.d.ts.map +1 -1
  134. package/dist/types/logger.d.ts +3 -0
  135. package/dist/types/logger.d.ts.map +1 -1
  136. package/dist/types/middleware/defaults/feeEstimator.d.ts +21 -1
  137. package/dist/types/middleware/defaults/feeEstimator.d.ts.map +1 -1
  138. package/dist/types/middleware/defaults/paymasterAndData.d.ts +8 -0
  139. package/dist/types/middleware/defaults/paymasterAndData.d.ts.map +1 -1
  140. package/dist/types/middleware/defaults/userOpSigner.d.ts +10 -0
  141. package/dist/types/middleware/defaults/userOpSigner.d.ts.map +1 -1
  142. package/dist/types/signer/local-account.d.ts +5 -2
  143. package/dist/types/signer/local-account.d.ts.map +1 -1
  144. package/dist/types/signer/schema.d.ts +14 -0
  145. package/dist/types/signer/schema.d.ts.map +1 -1
  146. package/dist/types/signer/utils.d.ts +21 -9
  147. package/dist/types/signer/utils.d.ts.map +1 -1
  148. package/dist/types/signer/wallet-client.d.ts +5 -2
  149. package/dist/types/signer/wallet-client.d.ts.map +1 -1
  150. package/dist/types/utils/defaults.d.ts +1 -1
  151. package/dist/types/utils/defaults.d.ts.map +1 -1
  152. package/dist/types/utils/index.d.ts +54 -11
  153. package/dist/types/utils/index.d.ts.map +1 -1
  154. package/dist/types/version.d.ts +1 -1
  155. package/package.json +2 -2
  156. package/src/account/simple.ts +6 -0
  157. package/src/account/smartContractAccount.ts +120 -15
  158. package/src/actions/smartAccount/buildUserOperation.ts +23 -0
  159. package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +22 -0
  160. package/src/actions/smartAccount/sendTransaction.ts +24 -0
  161. package/src/actions/smartAccount/sendTransactions.ts +23 -0
  162. package/src/actions/smartAccount/waitForUserOperationTransacation.ts +24 -0
  163. package/src/client/bundlerClient.ts +32 -0
  164. package/src/client/decorators/bundlerClient.ts +9 -0
  165. package/src/client/decorators/smartAccountClient.ts +8 -0
  166. package/src/client/smartAccountClient.ts +41 -0
  167. package/src/ens/utils.ts +46 -2
  168. package/src/entrypoint/index.ts +30 -62
  169. package/src/errors/account.ts +34 -0
  170. package/src/errors/base.ts +5 -2
  171. package/src/errors/client.ts +9 -0
  172. package/src/errors/entrypoint.ts +6 -0
  173. package/src/errors/signer.ts +3 -0
  174. package/src/errors/transaction.ts +6 -0
  175. package/src/index.ts +1 -28
  176. package/src/logger.ts +3 -0
  177. package/src/middleware/defaults/feeEstimator.ts +24 -4
  178. package/src/middleware/defaults/paymasterAndData.ts +8 -0
  179. package/src/middleware/defaults/userOpSigner.ts +10 -0
  180. package/src/signer/local-account.ts +3 -0
  181. package/src/signer/schema.ts +14 -0
  182. package/src/signer/utils.ts +20 -32
  183. package/src/signer/wallet-client.ts +3 -0
  184. package/src/utils/defaults.ts +3 -4
  185. package/src/utils/index.ts +54 -36
  186. package/src/version.ts +1 -1
  187. package/dist/cjs/chains/index.d.ts +0 -20
  188. package/dist/cjs/chains/index.js +0 -169
  189. package/dist/cjs/chains/index.js.map +0 -1
  190. package/dist/esm/chains/index.d.ts +0 -20
  191. package/dist/esm/chains/index.js +0 -166
  192. package/dist/esm/chains/index.js.map +0 -1
  193. package/dist/types/chains/index.d.ts +0 -21
  194. package/dist/types/chains/index.d.ts.map +0 -1
  195. package/src/chains/index.ts +0 -194
@@ -1 +1 @@
1
- {"version":3,"file":"simple.js","sourceRoot":"","sources":["../../../src/account/simple.ts"],"names":[],"mappings":";;;AACA,+BAQc;AACd,2EAAqE;AACrE,2EAAqE;AACrE,mFAA6E;AAC7E,iEAAiE;AACjE,qDAGgC;AAMhC,qDAAiE;AAGjE,sDAA6E;AAC7E,uCAAqD;AACrD,2CAA6D;AAC7D,uEAImC;AAGnC,MAAM,0BAGJ,SAAQ,kCAA6C;IAIrD,YAAY,MAAqD;QAC/D,IAAA,0CAA8B,GAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAG/C,MAAM,MAAM,GAAG,IAAA,sCAAmB,EAAC;YACjC,SAAS,EAAE,MAAM,CAAC,SAAuB;YACzC,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAC;QAGH,KAAK,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS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CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,IAAA,gDAAsB,EAAC;QACxC,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,KAAK;QACL,kBAAkB,EAAE,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC;QACxE,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,CACpB,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAC7C,EAAE,CAAC,MAAM,EACT,EAAE,CAAC,KAAK,IAAI,EAAE,EACd,EAAE,CAAC,IAAI,CACR;QACH,UAAU;QACV,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,IAAI,YAAY,CAAC,QAAQ;gBAAE,OAAO,YAAY,CAAC,QAAe,CAAC;YAC/D,OAAO,aAAa,CAAC,kBAAkB,EAAE,CAAC;QAC5C,CAAC;QACD,iBAAiB,EAAE,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC;QACtE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAC3B,aAAa,CAAC,WAAW,CACvB,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CACpD;QAEH,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC;QAC9D,cAAc,EAAE,YAAY,CAAC,cAAc;KAC5C,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,IAAI;QACP,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE;KAC3C,CAAC;AACJ,CAAC;AAzDD,4DAyDC","sourcesContent":["import type { Address } from \"abitype\";\nimport {\n concatHex,\n encodeFunctionData,\n isHex,\n type Chain,\n type FallbackTransport,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { SimpleAccountAbi_v6 } from \"../abis/SimpleAccountAbi_v6.js\";\nimport { SimpleAccountAbi_v7 } from \"../abis/SimpleAccountAbi_v7.js\";\nimport { SimpleAccountFactoryAbi } from \"../abis/SimpleAccountFactoryAbi.js\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport {\n defaultEntryPointVersion,\n getEntryPoint,\n} from \"../entrypoint/index.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointParameter,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport { AccountRequiresOwnerError } from \"../errors/account.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport type { BatchUserOperationCallData } from \"../types.js\";\nimport { getDefaultSimpleAccountFactoryAddress } from \"../utils/defaults.js\";\nimport { BaseSmartContractAccount } from \"./base.js\";\nimport { SimpleSmartAccountParamsSchema } from \"./schema.js\";\nimport {\n toSmartContractAccount,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"./smartContractAccount.js\";\nimport type { SimpleSmartAccountParams } from \"./types.js\";\n\nclass SimpleSmartContractAccount<\n TTransport extends Transport | FallbackTransport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> extends BaseSmartContractAccount<TTransport, TSigner> {\n protected index: bigint;\n protected entryPointVersion: EntryPointVersion;\n\n constructor(params: SimpleSmartAccountParams<TTransport, TSigner>) {\n SimpleSmartAccountParamsSchema().parse(params);\n\n // This is a hack for now, we should kill the SimpleSmart Account when we kill Base Account\n const client = createBundlerClient({\n transport: params.transport as TTransport,\n chain: params.chain,\n });\n\n // @ts-expect-error zod custom type not recognized as required params for signers\n super({ ...params, rpcClient: client });\n this.signer = params.signer as TSigner;\n this.index = params.salt ?? 0n;\n this.entryPointVersion =\n params.entryPointVersion ?? defaultEntryPointVersion;\n }\n\n getDummySignature(): `0x${string}` {\n return \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n }\n\n async encodeExecute(\n target: Hex,\n value: bigint,\n data: Hex\n ): Promise<`0x${string}`> {\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"execute\",\n args: [target, value, data],\n });\n }\n\n override async encodeBatchExecute(\n txs: BatchUserOperationCallData\n ): Promise<`0x${string}`> {\n const [targets, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.data);\n\n return accum;\n },\n [[], []] as [Address[], Hex[]]\n );\n\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"executeBatch\",\n args: [targets, datas],\n });\n }\n\n signMessage(msg: Uint8Array | string): Promise<`0x${string}`> {\n return this.signer.signMessage(\n typeof msg === \"string\" && !isHex(msg) ? msg : { raw: msg }\n );\n }\n\n public async getAccountInitCode(): Promise<`0x${string}`> {\n return concatHex([\n this.factoryAddress,\n encodeFunctionData({\n abi: SimpleAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [await this.signer.getAddress(), this.index],\n }),\n ]);\n }\n}\n\nexport type SimpleSmartAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccountWithSigner<\n \"SimpleAccount\",\n TSigner,\n TEntryPointVersion\n>;\n\nexport type CreateSimpleAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n> = Pick<\n ToSmartContractAccountParams<\n \"SimpleAccount\",\n TTransport,\n Chain,\n TEntryPointVersion\n >,\n \"chain\" | \"transport\"\n> & {\n signer: TSigner;\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n initCode?: Hex;\n} & EntryPointParameter<TEntryPointVersion, Chain>;\n\nexport async function createSimpleSmartAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n>(\n config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>\n): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;\n\nexport async function createSimpleSmartAccount({\n chain,\n entryPoint = getEntryPoint(chain),\n factoryAddress = getDefaultSimpleAccountFactoryAddress(\n chain,\n entryPoint.version\n ),\n ...params\n}: CreateSimpleAccountParams): Promise<SimpleSmartAccount> {\n if (!params.signer) throw new AccountRequiresOwnerError(\"SimpleAccount\");\n const simpleAccount = new SimpleSmartContractAccount(\n SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n factoryAddress,\n ...params,\n })\n );\n\n const parsedParams = SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n factoryAddress,\n ...params,\n });\n\n const base = await toSmartContractAccount({\n source: \"SimpleAccount\",\n transport: params.transport,\n chain,\n encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),\n encodeExecute: (tx) =>\n simpleAccount.encodeExecute.bind(simpleAccount)(\n tx.target,\n tx.value ?? 0n,\n tx.data\n ),\n entryPoint,\n getAccountInitCode: async () => {\n if (parsedParams.initCode) return parsedParams.initCode as Hex;\n return simpleAccount.getAccountInitCode();\n },\n getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),\n signMessage: ({ message }) =>\n simpleAccount.signMessage(\n typeof message === \"string\" ? message : message.raw\n ),\n // @ts-expect-error these types still represent the same thing, but they are just a little off in there definitions\n signTypedData: simpleAccount.signTypedData.bind(simpleAccount),\n accountAddress: parsedParams.accountAddress,\n });\n\n return {\n ...base,\n getSigner: () => simpleAccount.getSigner(),\n };\n}\n"]}
1
+ {"version":3,"file":"simple.js","sourceRoot":"","sources":["../../../src/account/simple.ts"],"names":[],"mappings":";;;AACA,+BAQc;AACd,2EAAqE;AACrE,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AG,CACpD;QAEH,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC;QAC9D,cAAc,EAAE,YAAY,CAAC,cAAc;KAC5C,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,IAAI;QACP,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE;KAC3C,CAAC;AACJ,CAAC;AAzDD,4DAyDC","sourcesContent":["import type { Address } from \"abitype\";\nimport {\n concatHex,\n encodeFunctionData,\n isHex,\n type Chain,\n type FallbackTransport,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { SimpleAccountAbi_v6 } from \"../abis/SimpleAccountAbi_v6.js\";\nimport { SimpleAccountAbi_v7 } from \"../abis/SimpleAccountAbi_v7.js\";\nimport { SimpleAccountFactoryAbi } from \"../abis/SimpleAccountFactoryAbi.js\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport {\n defaultEntryPointVersion,\n getEntryPoint,\n} from \"../entrypoint/index.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointParameter,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport { AccountRequiresOwnerError } from \"../errors/account.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport type { BatchUserOperationCallData } from \"../types.js\";\nimport { getDefaultSimpleAccountFactoryAddress } from \"../utils/defaults.js\";\nimport { BaseSmartContractAccount } from \"./base.js\";\nimport { SimpleSmartAccountParamsSchema } from \"./schema.js\";\nimport {\n toSmartContractAccount,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"./smartContractAccount.js\";\nimport type { SimpleSmartAccountParams } from \"./types.js\";\n\nclass SimpleSmartContractAccount<\n TTransport extends Transport | FallbackTransport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> extends BaseSmartContractAccount<TTransport, TSigner> {\n protected index: bigint;\n protected entryPointVersion: EntryPointVersion;\n\n constructor(params: SimpleSmartAccountParams<TTransport, TSigner>) {\n SimpleSmartAccountParamsSchema().parse(params);\n\n // This is a hack for now, we should kill the SimpleSmart Account when we kill Base Account\n const client = createBundlerClient({\n transport: params.transport as TTransport,\n chain: params.chain,\n });\n\n // @ts-expect-error zod custom type not recognized as required params for signers\n super({ ...params, rpcClient: client });\n this.signer = params.signer as TSigner;\n this.index = params.salt ?? 0n;\n this.entryPointVersion =\n params.entryPointVersion ?? defaultEntryPointVersion;\n }\n\n getDummySignature(): `0x${string}` {\n return \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n }\n\n async encodeExecute(\n target: Hex,\n value: bigint,\n data: Hex\n ): Promise<`0x${string}`> {\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"execute\",\n args: [target, value, data],\n });\n }\n\n override async encodeBatchExecute(\n txs: BatchUserOperationCallData\n ): Promise<`0x${string}`> {\n const [targets, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.data);\n\n return accum;\n },\n [[], []] as [Address[], Hex[]]\n );\n\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"executeBatch\",\n args: [targets, datas],\n });\n }\n\n signMessage(msg: Uint8Array | string): Promise<`0x${string}`> {\n return this.signer.signMessage(\n typeof msg === \"string\" && !isHex(msg) ? msg : { raw: msg }\n );\n }\n\n public async getAccountInitCode(): Promise<`0x${string}`> {\n return concatHex([\n this.factoryAddress,\n encodeFunctionData({\n abi: SimpleAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [await this.signer.getAddress(), this.index],\n }),\n ]);\n }\n}\n\nexport type SimpleSmartAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccountWithSigner<\n \"SimpleAccount\",\n TSigner,\n TEntryPointVersion\n>;\n\nexport type CreateSimpleAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n> = Pick<\n ToSmartContractAccountParams<\n \"SimpleAccount\",\n TTransport,\n Chain,\n TEntryPointVersion\n >,\n \"chain\" | \"transport\"\n> & {\n signer: TSigner;\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n initCode?: Hex;\n} & EntryPointParameter<TEntryPointVersion, Chain>;\n\nexport async function createSimpleSmartAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n>(\n config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>\n): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;\n\n/**\n * Creates a simple smart account using the provided parameters, including chain, entry point, factory address, and additional parameters. This function also ensures that a signer is provided.\n *\n * @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account\n * @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods\n */\nexport async function createSimpleSmartAccount({\n chain,\n entryPoint = getEntryPoint(chain),\n factoryAddress = getDefaultSimpleAccountFactoryAddress(\n chain,\n entryPoint.version\n ),\n ...params\n}: CreateSimpleAccountParams): Promise<SimpleSmartAccount> {\n if (!params.signer) throw new AccountRequiresOwnerError(\"SimpleAccount\");\n const simpleAccount = new SimpleSmartContractAccount(\n SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n factoryAddress,\n ...params,\n })\n );\n\n const parsedParams = SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n factoryAddress,\n ...params,\n });\n\n const base = await toSmartContractAccount({\n source: \"SimpleAccount\",\n transport: params.transport,\n chain,\n encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),\n encodeExecute: (tx) =>\n simpleAccount.encodeExecute.bind(simpleAccount)(\n tx.target,\n tx.value ?? 0n,\n tx.data\n ),\n entryPoint,\n getAccountInitCode: async () => {\n if (parsedParams.initCode) return parsedParams.initCode as Hex;\n return simpleAccount.getAccountInitCode();\n },\n getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),\n signMessage: ({ message }) =>\n simpleAccount.signMessage(\n typeof message === \"string\" ? message : message.raw\n ),\n // @ts-expect-error these types still represent the same thing, but they are just a little off in there definitions\n signTypedData: simpleAccount.signTypedData.bind(simpleAccount),\n accountAddress: parsedParams.accountAddress,\n });\n\n return {\n ...base,\n getSigner: () => simpleAccount.getSigner(),\n };\n}\n"]}
@@ -46,7 +46,8 @@ const getAccountAddress = async ({ client, entryPoint, accountAddress, getAccoun
46
46
  throw new account_js_1.GetCounterFactualAddressError();
47
47
  };
48
48
  exports.getAccountAddress = getAccountAddress;
49
- async function toSmartContractAccount({ transport, chain, entryPoint, source, accountAddress, getAccountInitCode, signMessage, signTypedData, encodeBatchExecute, encodeExecute, getDummySignature, signUserOperationHash, encodeUpgradeToAndCall, }) {
49
+ async function toSmartContractAccount(params) {
50
+ const { transport, chain, entryPoint, source, accountAddress, getAccountInitCode, signMessage, signTypedData, encodeBatchExecute, encodeExecute, getDummySignature, signUserOperationHash, encodeUpgradeToAndCall, } = params;
50
51
  const client = (0, bundlerClient_js_1.createBundlerClient)({
51
52
  transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),
52
53
  chain,
@@ -1 +1 @@
1
- {"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":";;;AAAA,+BAcc;AACd,4CAA0C;AAC1C,iEAAiE;AAMjE,qDAM8B;AAC9B,mDAAyD;AACzD,2DAAiE;AACjE,4CAAsC;AAEtC,iDAA2D;AAG3D,uCA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C,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,wBAAwB,GAAG,KAAK,IAAoC,EAAE;QAC1E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;YACxC,OAAO,EAAE,OAAO,CAAC,OAAO;YAExB,IAAI,EAAE,oEAAoE;SAC3E,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,wCAA2B,CACnC,oEAAoE,EACpE,8BAA8B,CAC/B,CAAC;QACJ,CAAC;QAED,OAAO,IAAA,WAAI,EAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACrE,MAAM,IAAI,sCAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,MAAM;QAGN,qBAAqB,EAAE,sBAAsB;QAC7C,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAChB,kBAAkB;YAClB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,4CAA+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,QAAQ;QACR,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AAvLD,wDAuLC","sourcesContent":["import {\n getContract,\n hexToBytes,\n trim,\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\";\nimport { DeploymentState } from \"./base.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\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\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 getNonce(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 // 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} & Omit<CustomSource, \"signTransaction\" | \"address\">;\n// [!endregion ToSmartContractAccountParams]\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 const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n}) => {\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 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\nexport async function toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams): Promise<SmartContractAccount> {\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\n const contractCode = await client.getBytecode({\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 = 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 = async (): Promise<NullAddress | Address> => {\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 return trim(storage);\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 getNonce,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress,\n };\n}\n"]}
1
+ {"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":";;;AAAA,+BAcc;AACd,4CAA0C;AAC1C,iEAAiE;AAMjE,qDAM8B;AAC9B,mDAAyD;AACzD,2DAAiE;AACjE,4CAAsC;AAEtC,iDAA2D;AAG3D,uCAA4C;AAuDrC,MAAM,wBAAwB,GAAG,CACtC,OAA6B,EACc,EAAE;IAC7C,OAAO,WAAW,IAAI,OAAO,CAAC;AAChC,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAyEK,MAAM,sCAAsC,GAAG,CACpD,QAAa,EACG,EAAE;IAClB,MAAM,cAAc,GAAY,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IACjE,MAAM,eAAe,GAAQ,KAAK,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3D,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sCAAsC,0CAMjD;AAuBK,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,MAAM,EACN,UAAU,EACV,cAAc,EACd,kBAAkB,GAMnB,EAAE,EAAE;IACH,IAAI,cAAc;QAAE,OAAO,cAAc,CAAC;IAE1C,MAAM,kBAAkB,GAAG,IAAA,kBAAW,EAAC;QACrC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC5C,kBAAM,CAAC,OAAO,CA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,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,QAAQ;QACR,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AA3LD,wDA2LC","sourcesContent":["import {\n getContract,\n hexToBytes,\n trim,\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\";\nimport { DeploymentState } from \"./base.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\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 getNonce(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 // 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} & 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\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 {object} config The configuration object\n * @param {PublicClient} config.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} config.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} config.accountAddress Optional existing account address\n * @param {function(): Promise<Hex>} config.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}: {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n}) => {\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 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 encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\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\n const contractCode = await client.getBytecode({\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 = 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 = async (): Promise<NullAddress | Address> => {\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 return trim(storage);\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 getNonce,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,0EAAqE;AACrE,4EAAuE;AAMhE,KAAK,UAAU,kBAAkB,CAWtC,MAA4C,EAC5C,IAA0E;IAE1E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,IAAA,2CAAmB,EAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC;AAnCD,gDAmCC","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 { 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\";\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 { 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 \"buildUserOperation\",\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/buildUserOperation.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AAEjE,0EAAqE;AACrE,4EAAuE;AA6BhE,KAAK,UAAU,kBAAkB,CAWtC,MAA4C,EAC5C,IAA0E;IAE1E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,IAAA,2CAAmB,EAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC;AAnCD,gDAmCC","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 { 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\";\n\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 { 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 \"buildUserOperation\",\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":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":";;;AAKA,kFAAgF;AAEhF,wDAA+D;AAC/D,sDAAiE;AAMjE,mDAAiE;AACjE,4EAAuE;AACvE,0EAAqE;AAM9D,KAAK,UAAU,2BA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AE,UAAU;QACd,SAAS;QACT,OAAO;KACR,CACF,CAAC;IAEF,MAAM,UAAU,GAAG;QACjB,GAAG,SAAS;QACZ,YAAY,EAAE,IAAA,oBAAS,EACrB,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EAC1B,IAAA,yBAAc,EAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,CAC3C;QACD,oBAAoB,EAAE,IAAA,oBAAS,EAC7B,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAClC,IAAA,yBAAc,EAAC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,CACnD;KAC4C,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,IAAA,2CAAmB,EAAC,MAAM,EAAE;QACjD,EAAE,EAAE,UAAU;QACd,SAAS,EAAE,UAAU;QACrB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,IAAA,yCAAkB,EAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC;AAxFD,kEAwFC","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 { bigIntMax, bigIntMultiply } 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\";\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 { 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 // Run once to get the fee estimates\n // This can happen at any part of the middleware stack, so we want to run it all\n const { maxFeePerGas, maxPriorityFeePerGas } = await _runMiddlewareStack(\n client,\n {\n uo: uoToSubmit,\n overrides,\n account,\n }\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,kFAAgF;AAEhF,wDAA+D;AAC/D,sDAAiE;AAMjE,mDAAiE;AACjE,4EAAuE;AACvE,0EAAqE;AA4B9D,KAAK,UAAU,2BAA2B,CAW/C,MAA4C,EAC5C,IAA+D;IAE/D,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,iCAAoB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,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,CAAC,MAAM;YAC1D,KAAK,EAAG,QAA0C,CAAC,KAAK;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P,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC;AAxFD,kEAwFC","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 { bigIntMax, bigIntMultiply } 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\";\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 { 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 // Run once to get the fee estimates\n // This can happen at any part of the middleware stack, so we want to run it all\n const { maxFeePerGas, maxPriorityFeePerGas } = await _runMiddlewareStack(\n client,\n {\n uo: uoToSubmit,\n overrides,\n account,\n }\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":"sendTransaction.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":";;;AAWA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAC7E,oEAA0E;AAE1E,+EAAyE;AACzE,0EAAqE;AAErE,+FAAwF;AAEjF,KAAK,UAAU,eAAe,CAWnC,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,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,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,+CAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,sDAAwB,EAC7C,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,yCAAkB,EAAC,MAAM,EAAE;QACzD,OAAO,EAAE,OAA+B;QACxC,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,IAAA,qEAA+B,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,4CAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAlDD,0CAkDC","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\";\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 { 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,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,gEAA6E;AAC7E,oEAA0E;AAE1E,+EAAyE;AACzE,0EAAqE;AAErE,+FAAwF;AA0BjF,KAAK,UAAU,eAAe,CAWnC,MAA2C,EAC3C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,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,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,+CAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,sDAAwB,EAC7C,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,yCAAkB,EAAC,MAAM,EAAE;QACzD,OAAO,EAAE,OAA+B;QACxC,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,IAAA,qEAA+B,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,4CAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAlDD,0CAkDC","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\";\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 { 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/actions/smartAccount/sendTransactions.ts"],"names":[],"mappings":";;;AAEA,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,oEAA0E;AAC1E,iFAA2E;AAC3E,0EAAqE;AAErE,+FAAwF;AAEjF,KAAK,UAAU,gBAAgB,CAQpC,MAA4C,EAC5C,IAAoD;IAEpD,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,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,wDAAyB,EAAC,MAAM,EAAE;QAC3D,QAAQ;QACR,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,yCAAkB,EAAC,MAAM,EAAE;QACzD,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,IAAA,qEAA+B,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,4CAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAzCD,4CAyCC","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\";\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 { 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,kFAAgF;AAChF,wDAA+D;AAC/D,sDAAiE;AACjE,oEAA0E;AAC1E,iFAA2E;AAC3E,0EAAqE;AAErE,+FAAwF;AAyBjF,KAAK,UAAU,gBAAgB,CAQpC,MAA4C,EAC5C,IAAoD;IAEpD,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,iCAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,wDAAyB,EAAC,MAAM,EAAE;QAC3D,QAAQ;QACR,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,yCAAkB,EAAC,MAAM,EAAE;QACzD,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,IAAA,qEAA+B,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,4CAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC;AAzCD,4CAyCC","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\";\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 { 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 +1 @@
1
- {"version":3,"file":"waitForUserOperationTransacation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/waitForUserOperationTransacation.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,kFAAgF;AAChF,sDAAiE;AACjE,gEAA2E;AAC3E,+CAAyC;AAGlC,MAAM,+BAA+B,GAMxB,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IACzC,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,iCAAiC,EACjC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EACJ,IAAI,EACJ,OAAO,GAAG;QACR,UAAU,EAAE,MAAM,CAAC,YAAY;QAC/B,UAAU,EAAE,MAAM,CAAC,iBAAiB;QACpC,UAAU,EAAE,MAAM,CAAC,iBAAiB;KACrC,GACF,GAAG,IAAI,CAAC;IAET,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,2BAA2B,GAC/B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QAEtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,2BAA2B,CAAC,CACjD,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,MAAM;aACzB,uBAAuB,CAAC,IAAqB,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,kBAAM,CAAC,KAAK,CACV,qFAAqF,IAAI,KAAK,CAAC,EAAE,CAClG,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAA,wBAAc,EAAC,MAAM,EAAE;gBAC5B,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,eAAe;aACtC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,6CAA4B,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC,CAAC;AAjDW,QAAA,+BAA+B,mCAiD1C","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport { getTransaction } from \"viem/actions\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { FailedToFindTransactionError } from \"../../errors/transaction.js\";\nimport { Logger } from \"../../logger.js\";\nimport type { WaitForUserOperationTxParameters } from \"./types.js\";\n\nexport const waitForUserOperationTransaction: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined\n>(\n client: Client<TTransport, TChain, any>,\n args: WaitForUserOperationTxParameters\n) => Promise<Hex> = async (client, args) => {\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"waitForUserOperationTransaction\",\n client\n );\n }\n\n const {\n hash,\n retries = {\n maxRetries: client.txMaxRetries,\n intervalMs: client.txRetryIntervalMs,\n multiplier: client.txRetryMultiplier,\n },\n } = args;\n\n for (let i = 0; i < retries.maxRetries; i++) {\n const txRetryIntervalWithJitterMs =\n retries.intervalMs * Math.pow(retries.multiplier, i) +\n Math.random() * 100;\n\n await new Promise((resolve) =>\n setTimeout(resolve, txRetryIntervalWithJitterMs)\n );\n\n const receipt = await client\n .getUserOperationReceipt(hash as `0x${string}`)\n .catch((e) => {\n Logger.error(\n `[SmartAccountProvider] waitForUserOperationTransaction error fetching receipt for ${hash}: ${e}`\n );\n });\n\n if (receipt) {\n return getTransaction(client, {\n hash: receipt.receipt.transactionHash,\n }).then((x) => x.hash);\n }\n }\n\n throw new FailedToFindTransactionError(hash);\n};\n"]}
1
+ {"version":3,"file":"waitForUserOperationTransacation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/waitForUserOperationTransacation.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,kFAAgF;AAChF,sDAAiE;AACjE,gEAA2E;AAC3E,+CAAyC;AA2BlC,MAAM,+BAA+B,GAMxB,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IACzC,IAAI,CAAC,IAAA,kDAAwB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,mCAAuB,CAC/B,wBAAwB,EACxB,iCAAiC,EACjC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EACJ,IAAI,EACJ,OAAO,GAAG;QACR,UAAU,EAAE,MAAM,CAAC,YAAY;QAC/B,UAAU,EAAE,MAAM,CAAC,iBAAiB;QACpC,UAAU,EAAE,MAAM,CAAC,iBAAiB;KACrC,GACF,GAAG,IAAI,CAAC;IAET,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,2BAA2B,GAC/B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QAEtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,2BAA2B,CAAC,CACjD,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,MAAM;aACzB,uBAAuB,CAAC,IAAqB,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,kBAAM,CAAC,KAAK,CACV,qFAAqF,IAAI,KAAK,CAAC,EAAE,CAClG,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAA,wBAAc,EAAC,MAAM,EAAE;gBAC5B,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,eAAe;aACtC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,IAAI,6CAA4B,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC,CAAC;AAjDW,QAAA,+BAA+B,mCAiD1C","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport { getTransaction } from \"viem/actions\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { FailedToFindTransactionError } from \"../../errors/transaction.js\";\nimport { Logger } from \"../../logger.js\";\nimport type { WaitForUserOperationTxParameters } from \"./types.js\";\n\n/**\n * Waits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with waitForUserOperationTransaction\n * const client = createSmartAccountClient(...);\n * const result = await client.waitForUserOperationTransaction({\n * hash: \"0x...\",\n * retries: {...} // optional param to configure the retry amounts\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, any>} client The client instance used to interact with the blockchain\n * @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for\n * @param {Hex} args.hash The transaction hash to wait for\n * @param {WaitForUserOperationTxParameters[\"retries\"]} [args.retries] Optional retry parameters\n * @param {number} [args.retries.maxRetries] The maximum number of retry attempts\n * @param {number} [args.retries.intervalMs] The interval in milliseconds between retries\n * @param {number} [args.retries.multiplier] The multiplier for the interval between retries\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed\n */\nexport const waitForUserOperationTransaction: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined\n>(\n client: Client<TTransport, TChain, any>,\n args: WaitForUserOperationTxParameters\n) => Promise<Hex> = async (client, args) => {\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"waitForUserOperationTransaction\",\n client\n );\n }\n\n const {\n hash,\n retries = {\n maxRetries: client.txMaxRetries,\n intervalMs: client.txRetryIntervalMs,\n multiplier: client.txRetryMultiplier,\n },\n } = args;\n\n for (let i = 0; i < retries.maxRetries; i++) {\n const txRetryIntervalWithJitterMs =\n retries.intervalMs * Math.pow(retries.multiplier, i) +\n Math.random() * 100;\n\n await new Promise((resolve) =>\n setTimeout(resolve, txRetryIntervalWithJitterMs)\n );\n\n const receipt = await client\n .getUserOperationReceipt(hash as `0x${string}`)\n .catch((e) => {\n Logger.error(\n `[SmartAccountProvider] waitForUserOperationTransaction error fetching receipt for ${hash}: ${e}`\n );\n });\n\n if (receipt) {\n return getTransaction(client, {\n hash: receipt.receipt.transactionHash,\n }).then((x) => x.hash);\n }\n }\n\n throw new FailedToFindTransactionError(hash);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../src/client/bundlerClient.ts"],"names":[],"mappings":";;;AAAA,+BAac;AACd,mDAAyD;AACzD,8CAAwC;AAC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AA,WAAI,EAAC,GAAG,EAAE;oBACnB,GAAG,iBAAiB,CAAC,MAAM;oBAC3B,YAAY;iBACb,CAAC;aACH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,mBAAY,EAAmB,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AAC7D,CAAC;AAtDD,kDAsDC","sourcesContent":["import {\n createClient,\n http,\n publicActions,\n type Chain,\n type Client,\n type FallbackTransport,\n type HttpTransportConfig,\n type PublicActions,\n type PublicClient,\n type PublicClientConfig,\n type PublicRpcSchema,\n type Transport,\n} from \"viem\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { VERSION } from \"../version.js\";\nimport {\n bundlerActions,\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\n\n// [!region BundlerClient]\nexport type BundlerClient<T extends Transport = Transport> = Client<\n T,\n Chain,\n undefined,\n [...PublicRpcSchema, ...BundlerRpcSchema],\n PublicActions<T, Chain> & BundlerActions\n>;\n\nexport const createBundlerClientFromExisting: <\n T extends Transport | FallbackTransport = Transport\n>(\n client: PublicClient<T, Chain>\n) => BundlerClient<T> = <T extends Transport | FallbackTransport = Transport>(\n client: PublicClient<T, Chain>\n): BundlerClient<T> => {\n return client.extend(bundlerActions);\n};\n// [!endregion BundlerClient]\n\n/**\n * Creates a PublicClient with methods for calling Bundler RPC methods\n *\n * @param args - configuration for the client\n * @returns a PublicClient with methods for calling Bundler RPC methods\n */\nexport function createBundlerClient<TTransport extends Transport>(\n args: PublicClientConfig<TTransport, Chain> & { type?: string }\n): BundlerClient<TTransport>;\n\nexport function createBundlerClient(\n args: PublicClientConfig & { type?: string }\n): BundlerClient {\n if (!args.chain) {\n throw new ChainNotFoundError();\n }\n const {\n key = \"bundler-public\",\n name = \"Public Bundler Client\",\n type = \"bundlerClient\",\n } = args;\n\n const { transport, ...opts } = args;\n const resolvedTransport = transport({\n chain: args.chain,\n pollingInterval: opts.pollingInterval,\n });\n\n const baseParameters = {\n ...args,\n key,\n name,\n type,\n };\n\n const client = (() => {\n if (resolvedTransport.config.type === \"http\") {\n const { url, fetchOptions: fetchOptions_ } = resolvedTransport.value as {\n fetchOptions: HttpTransportConfig[\"fetchOptions\"];\n url: string;\n };\n\n const fetchOptions = fetchOptions_ ?? {};\n\n if (url.toLowerCase().indexOf(\"alchemy\") > -1) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n }\n\n return createClient<Transport, Chain>({\n ...baseParameters,\n transport: http(url, {\n ...resolvedTransport.config,\n fetchOptions,\n }),\n });\n }\n\n return createClient<Transport, Chain>(baseParameters);\n })();\n\n return client.extend(publicActions).extend(bundlerActions);\n}\n"]}
1
+ {"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../src/client/bundlerClient.ts"],"names":[],"mappings":";;;AAAA,+BAac;AACd,mDAAyD;AACzD,8CAAwC;AACxC,oEAIuC;AA0BhC,MAAM,+BAA+B,GAIpB,CACtB,MAA8B,EACZ,EAAE;IACpB,OAAO,MAAM,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AACvC,CAAC,CAAC;AARW,QAAA,+BAA+B,mCAQ1C;AA8BF,SAAgB,mBAAmB,CACjC,IAA4C;IAE5C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,8BAAkB,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,EACJ,GAAG,GAAG,gBAAgB,EACtB,IAAI,GAAG,uBAAuB,EAC9B,IAAI,GAAG,eAAe,GACvB,GAAG,IAAI,CAAC;IAET,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IACpC,MAAM,iBAAiB,GAAG,SAAS,CAAC;QAClC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG;QACrB,GAAG,IAAI;QACP,GAAG;QACH,IAAI;QACJ,IAAI;KACL,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE;QACnB,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC,KAG9D,CAAC;YAEF,MAAM,YAAY,GAAG,aAAa,IAAI,EAAE,CAAC;YAEzC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC9C,YAAY,CAAC,OAAO,GAAG;oBACrB,GAAG,YAAY,CAAC,OAAO;oBACvB,wBAAwB,EAAE,oBAAO;iBAClC,CAAC;YACJ,CAAC;YAED,OAAO,IAAA,mBAAY,EAAmB;gBACpC,GAAG,cAAc;gBACjB,SAAS,EAAE,IAAA,WAAI,EAAC,GAAG,EAAE;oBACnB,GAAG,iBAAiB,CAAC,MAAM;oBAC3B,YAAY;iBACb,CAAC;aACH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,mBAAY,EAAmB,cAAc,CAAC,CAAC;IACxD,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAa,CAAC,CAAC,MAAM,CAAC,iCAAc,CAAC,CAAC;AAC7D,CAAC;AAtDD,kDAsDC","sourcesContent":["import {\n createClient,\n http,\n publicActions,\n type Chain,\n type Client,\n type FallbackTransport,\n type HttpTransportConfig,\n type PublicActions,\n type PublicClient,\n type PublicClientConfig,\n type PublicRpcSchema,\n type Transport,\n} from \"viem\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { VERSION } from \"../version.js\";\nimport {\n bundlerActions,\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\n\n// [!region BundlerClient]\nexport type BundlerClient<T extends Transport = Transport> = Client<\n T,\n Chain,\n undefined,\n [...PublicRpcSchema, ...BundlerRpcSchema],\n PublicActions<T, Chain> & BundlerActions\n>;\n\n/**\n * Creates a bundler client from an existing public client with the provided transport and chain.\n *\n * @example\n * ```ts\n * import { createPublicClient } from \"viem\";\n * import { createBundlerClientFromExisting } from \"@aa-sdk/core\";\n *\n * const publicClient = createPublicClient(...);\n * const bundlerClient = createBundlerClientFromExisting(publicClient);\n * ```\n *\n * @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions\n * @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client\n */\nexport const createBundlerClientFromExisting: <\n T extends Transport | FallbackTransport = Transport\n>(\n client: PublicClient<T, Chain>\n) => BundlerClient<T> = <T extends Transport | FallbackTransport = Transport>(\n client: PublicClient<T, Chain>\n): BundlerClient<T> => {\n return client.extend(bundlerActions);\n};\n// [!endregion BundlerClient]\n\n/**\n * Creates a PublicClient with methods for calling Bundler RPC methods\n *\n * @param args - configuration for the client\n * @returns a PublicClient with methods for calling Bundler RPC methods\n */\nexport function createBundlerClient<TTransport extends Transport>(\n args: PublicClientConfig<TTransport, Chain> & { type?: string }\n): BundlerClient<TTransport>;\n\n/**\n * Creates a Bundler Client using the provided configuration parameters, including chain and optional type.\n *\n * @example\n * ```ts\n * import { createBundlerClient } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createBundlerClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * });\n * ```\n *\n * @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type\n * @returns {BundlerClient} The created Bundler Client with extended public and bundler actions\n */\nexport function createBundlerClient(\n args: PublicClientConfig & { type?: string }\n): BundlerClient {\n if (!args.chain) {\n throw new ChainNotFoundError();\n }\n const {\n key = \"bundler-public\",\n name = \"Public Bundler Client\",\n type = \"bundlerClient\",\n } = args;\n\n const { transport, ...opts } = args;\n const resolvedTransport = transport({\n chain: args.chain,\n pollingInterval: opts.pollingInterval,\n });\n\n const baseParameters = {\n ...args,\n key,\n name,\n type,\n };\n\n const client = (() => {\n if (resolvedTransport.config.type === \"http\") {\n const { url, fetchOptions: fetchOptions_ } = resolvedTransport.value as {\n fetchOptions: HttpTransportConfig[\"fetchOptions\"];\n url: string;\n };\n\n const fetchOptions = fetchOptions_ ?? {};\n\n if (url.toLowerCase().indexOf(\"alchemy\") > -1) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n }\n\n return createClient<Transport, Chain>({\n ...baseParameters,\n transport: http(url, {\n ...resolvedTransport.config,\n fetchOptions,\n }),\n });\n }\n\n return createClient<Transport, Chain>(baseParameters);\n })();\n\n return client.extend(publicActions).extend(bundlerActions);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/bundlerClient.ts"],"names":[],"mappings":";;;AAUA,mGAA6F;AAC7F,iGAA2F;AAC3F,+FAAyF;AACzF,iGAA2F;AAC3F,2FAAqF;AA+F9E,MAAM,cAAc,GASL,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CACrE,IAAA,sDAAwB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC1E,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAClD,IAAA,8CAAoB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACvD,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACrC,IAAA,kDAAsB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;IAC1C,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oDAAuB,EAAC,MAAM,CAAC;IACpE,uBAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACtC,IAAA,oDAAuB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;CAC5C,CAAC,CAAC;AAnBU,QAAA,cAAc,kBAmBxB","sourcesContent":["import type {\n Address,\n Chain,\n Client,\n Hash,\n PublicRpcSchema,\n RpcStateOverride,\n StateOverride,\n Transport,\n} from \"viem\";\nimport { estimateUserOperationGas } from \"../../actions/bundler/estimateUserOperationGas.js\";\nimport { getSupportedEntryPoints } from \"../../actions/bundler/getSupportedEntryPoints.js\";\nimport { getUserOperationByHash } from \"../../actions/bundler/getUserOperationByHash.js\";\nimport { getUserOperationReceipt } from \"../../actions/bundler/getUserOperationReceipt.js\";\nimport { sendRawUserOperation } from \"../../actions/bundler/sendRawUserOperation.js\";\nimport type { EntryPointVersion } from \"../../entrypoint/types.js\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationReceipt,\n UserOperationRequest,\n UserOperationResponse,\n} from \"../../types.js\";\n\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace\nexport type BundlerRpcSchema = [\n {\n Method: \"eth_sendUserOperation\";\n Parameters: [UserOperationRequest, Address];\n ReturnType: Hash;\n },\n {\n Method: \"eth_estimateUserOperationGas\";\n Parameters: [UserOperationRequest, Address, RpcStateOverride?];\n ReturnType: UserOperationEstimateGasResponse;\n },\n {\n Method: \"eth_getUserOperationReceipt\";\n Parameters: [Hash];\n ReturnType: UserOperationReceipt | null;\n },\n {\n Method: \"eth_getUserOperationByHash\";\n Parameters: [Hash];\n ReturnType: UserOperationResponse | null;\n },\n {\n Method: \"eth_supportedEntryPoints\";\n Parameters: [];\n ReturnType: Address[];\n }\n];\n\n// [!region BundlerActions]\nexport type BundlerActions = {\n /**\n * calls `eth_estimateUserOperationGas` and returns the result\n *\n * @param request - the {@link UserOperationRequest} to estimate gas for\n * @param entryPoint - the entry point address the op will be sent to\n * @param stateOverride - the state override to use for the estimation\n * @returns the gas estimates for the given response (see: {@link UserOperationEstimateGasResponse})\n */\n estimateUserOperationGas<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address,\n stateOverride?: StateOverride\n ): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;\n\n /**\n * calls `eth_sendUserOperation` and returns the hash of the sent UserOperation\n *\n * @param request - the {@link UserOperationRequest} to send\n * @param entryPoint - the entry point address the op will be sent to\n * @returns the hash of the sent UserOperation\n */\n sendRawUserOperation<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address\n ): Promise<Hash>;\n\n /**\n * calls `eth_getUserOperationByHash` and returns the {@link UserOperationResponse}\n *\n * @param hash - the hash of the UserOperation to fetch\n * @returns - {@link UserOperationResponse}\n */\n getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;\n\n /**\n * calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}\n *\n * @param hash - the hash of the UserOperation to get the receipt for\n * @returns - {@link UserOperationReceipt}\n */\n getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;\n\n /**\n * calls `eth_supportedEntryPoints` and returns the entry points the RPC supports\n *\n * @returns - {@link Address}[]\n */\n getSupportedEntryPoints(): Promise<Address[]>;\n};\n// [!endregion BundlerActions]\n\nexport const bundlerActions: <\n TClient extends Client<\n Transport,\n Chain | undefined,\n any,\n [...PublicRpcSchema, ...BundlerRpcSchema]\n >\n>(\n client: TClient\n) => BundlerActions = (client) => ({\n estimateUserOperationGas: async (request, entryPoint, stateOverride) =>\n estimateUserOperationGas(client, { request, entryPoint, stateOverride }),\n sendRawUserOperation: async (request, entryPoint) =>\n sendRawUserOperation(client, { request, entryPoint }),\n getUserOperationByHash: async (hash) =>\n getUserOperationByHash(client, { hash }),\n getSupportedEntryPoints: async () => getSupportedEntryPoints(client),\n getUserOperationReceipt: async (hash) =>\n getUserOperationReceipt(client, { hash }),\n});\n"]}
1
+ {"version":3,"file":"bundlerClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/bundlerClient.ts"],"names":[],"mappings":";;;AAUA,mGAA6F;AAC7F,iGAA2F;AAC3F,+FAAyF;AACzF,iGAA2F;AAC3F,2FAAqF;AAwG9E,MAAM,cAAc,GASL,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CACrE,IAAA,sDAAwB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC1E,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,CAClD,IAAA,8CAAoB,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACvD,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACrC,IAAA,kDAAsB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;IAC1C,uBAAuB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAA,oDAAuB,EAAC,MAAM,CAAC;IACpE,uBAAuB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACtC,IAAA,oDAAuB,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC;CAC5C,CAAC,CAAC;AAnBU,QAAA,cAAc,kBAmBxB","sourcesContent":["import type {\n Address,\n Chain,\n Client,\n Hash,\n PublicRpcSchema,\n RpcStateOverride,\n StateOverride,\n Transport,\n} from \"viem\";\nimport { estimateUserOperationGas } from \"../../actions/bundler/estimateUserOperationGas.js\";\nimport { getSupportedEntryPoints } from \"../../actions/bundler/getSupportedEntryPoints.js\";\nimport { getUserOperationByHash } from \"../../actions/bundler/getUserOperationByHash.js\";\nimport { getUserOperationReceipt } from \"../../actions/bundler/getUserOperationReceipt.js\";\nimport { sendRawUserOperation } from \"../../actions/bundler/sendRawUserOperation.js\";\nimport type { EntryPointVersion } from \"../../entrypoint/types.js\";\nimport type {\n UserOperationEstimateGasResponse,\n UserOperationReceipt,\n UserOperationRequest,\n UserOperationResponse,\n} from \"../../types.js\";\n\n// Reference: https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace\nexport type BundlerRpcSchema = [\n {\n Method: \"eth_sendUserOperation\";\n Parameters: [UserOperationRequest, Address];\n ReturnType: Hash;\n },\n {\n Method: \"eth_estimateUserOperationGas\";\n Parameters: [UserOperationRequest, Address, RpcStateOverride?];\n ReturnType: UserOperationEstimateGasResponse;\n },\n {\n Method: \"eth_getUserOperationReceipt\";\n Parameters: [Hash];\n ReturnType: UserOperationReceipt | null;\n },\n {\n Method: \"eth_getUserOperationByHash\";\n Parameters: [Hash];\n ReturnType: UserOperationResponse | null;\n },\n {\n Method: \"eth_supportedEntryPoints\";\n Parameters: [];\n ReturnType: Address[];\n }\n];\n\n// [!region BundlerActions]\nexport type BundlerActions = {\n /**\n * calls `eth_estimateUserOperationGas` and returns the result\n *\n * @param request - the {@link UserOperationRequest} to estimate gas for\n * @param entryPoint - the entry point address the op will be sent to\n * @param stateOverride - the state override to use for the estimation\n * @returns the gas estimates for the given response (see: {@link UserOperationEstimateGasResponse})\n */\n estimateUserOperationGas<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address,\n stateOverride?: StateOverride\n ): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;\n\n /**\n * calls `eth_sendUserOperation` and returns the hash of the sent UserOperation\n *\n * @param request - the {@link UserOperationRequest} to send\n * @param entryPoint - the entry point address the op will be sent to\n * @returns the hash of the sent UserOperation\n */\n sendRawUserOperation<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n >(\n request: UserOperationRequest<TEntryPointVersion>,\n entryPoint: Address\n ): Promise<Hash>;\n\n /**\n * calls `eth_getUserOperationByHash` and returns the {@link UserOperationResponse}\n *\n * @param hash - the hash of the UserOperation to fetch\n * @returns - {@link UserOperationResponse}\n */\n getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;\n\n /**\n * calls `eth_getUserOperationReceipt` and returns the {@link UserOperationReceipt}\n *\n * @param hash - the hash of the UserOperation to get the receipt for\n * @returns - {@link UserOperationReceipt}\n */\n getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;\n\n /**\n * calls `eth_supportedEntryPoints` and returns the entry points the RPC supports\n *\n * @returns - {@link Address}[]\n */\n getSupportedEntryPoints(): Promise<Address[]>;\n};\n// [!endregion BundlerActions]\n\n/**\n * A viem client decorator that provides Bundler specific actions.\n * These actions include estimating gas for user operations, sending raw user operations, retrieving user operations by hash, getting supported entry points, and getting user operation receipts.\n *\n * NOTE: this is already added to the client returned from `createBundlerClient`\n *\n * @param {TClient} client The client instance that will be used to perform bundler actions\n * @returns {BundlerActions} An object containing various bundler-related actions that can be executed using the provided client\n */\nexport const bundlerActions: <\n TClient extends Client<\n Transport,\n Chain | undefined,\n any,\n [...PublicRpcSchema, ...BundlerRpcSchema]\n >\n>(\n client: TClient\n) => BundlerActions = (client) => ({\n estimateUserOperationGas: async (request, entryPoint, stateOverride) =>\n estimateUserOperationGas(client, { request, entryPoint, stateOverride }),\n sendRawUserOperation: async (request, entryPoint) =>\n sendRawUserOperation(client, { request, entryPoint }),\n getUserOperationByHash: async (hash) =>\n getUserOperationByHash(client, { hash }),\n getSupportedEntryPoints: async () => getSupportedEntryPoints(client),\n getUserOperationReceipt: async (hash) =>\n getUserOperationReceipt(client, { hash }),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccountClient.ts"],"names":[],"mappings":";;;AAcA,4FAAsF;AACtF,wGAAkG;AAClG,0GAAoG;AACpG,oHAA8G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AAI,EAAE,EAAE,CACxC,qEAA+B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5D,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,kCAAc,EAAC,MAAM,EAAE,IAAI,CAAC;IACtD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,MAAM,EAAE,IAAI,CAAC;IAC9C,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,4BAAW,EAAC,MAAM,EAAE,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,gCAAa,EAAC,MAAM,EAAE,IAAI,CAAC;IACpD,mBAAmB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,4CAAmB,EAAC,MAAM,EAAE,IAAI,CAAC;IAChE,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,gDAAqB,EAAC,MAAM,EAAE,IAAI,CAAC;CACrE,CAAC,CAAC;AAjCU,QAAA,yBAAyB,6BAiCnC;AAEU,QAAA,4BAA4B,GAAG,MAAM,CAAC,IAAI,CAErD,IAAA,iCAAyB,EAAC,SAAS,CAAC,CACrC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACvB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC","sourcesContent":["import {\n type Address,\n type Chain,\n type Client,\n type Hex,\n type SendTransactionParameters,\n type Transport,\n type TypedData,\n} from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { buildUserOperation } from \"../../actions/smartAccount/buildUserOperation.js\";\nimport { buildUserOperationFromTx } from \"../../actions/smartAccount/buildUserOperationFromTx.js\";\nimport { buildUserOperationFromTxs } from \"../../actions/smartAccount/buildUserOperationFromTxs.js\";\nimport { checkGasSponsorshipEligibility } from \"../../actions/smartAccount/checkGasSponsorshipEligibility.js\";\nimport { dropAndReplaceUserOperation } from \"../../actions/smartAccount/dropAndReplaceUserOperation.js\";\nimport { getAddress } from \"../../actions/smartAccount/getAddress.js\";\nimport { sendTransaction } from \"../../actions/smartAccount/sendTransaction.js\";\nimport { sendTransactions } from \"../../actions/smartAccount/sendTransactions.js\";\nimport { sendUserOperation } from \"../../actions/smartAccount/sendUserOperation.js\";\nimport {\n signMessage,\n type SignMessageParameters,\n} from \"../../actions/smartAccount/signMessage.js\";\nimport { signMessageWith6492 } from \"../../actions/smartAccount/signMessageWith6492.js\";\nimport {\n signTypedData,\n type SignTypedDataParameters,\n} from \"../../actions/smartAccount/signTypedData.js\";\nimport { signTypedDataWith6492 } from \"../../actions/smartAccount/signTypedDataWith6492.js\";\nimport { signUserOperation } from \"../../actions/smartAccount/signUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n BuildUserOperationParameters,\n DropAndReplaceUserOperationParameters,\n SendTransactionsParameters,\n SendUserOperationParameters,\n SignUserOperationParameters,\n UpgradeAccountParams,\n UserOperationContext,\n WaitForUserOperationTxParameters,\n} from \"../../actions/smartAccount/types\";\nimport { upgradeAccount } from \"../../actions/smartAccount/upgradeAccount.js\";\nimport { waitForUserOperationTransaction } from \"../../actions/smartAccount/waitForUserOperationTransacation.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport type { IsUndefined } from \"../../utils\";\nimport type { SendUserOperationResult } from \"../types\";\n\n//#region SmartAccountClientActions\nexport type BaseSmartAccountClientActions<\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 buildUserOperation: (\n args: BuildUserOperationParameters<TAccount, TContext>\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTx: (\n args: SendTransactionParameters<TChain, TAccount>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTxs: (\n args: BuildTransactionParameters<TAccount, TContext>\n ) => Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;\n checkGasSponsorshipEligibility: <\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n >(\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<boolean>;\n signUserOperation: (\n args: SignUserOperationParameters<TAccount, TEntryPointVersion, TContext>\n ) => Promise<UserOperationRequest<TEntryPointVersion>>;\n dropAndReplaceUserOperation: (\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n // TODO: for v4 we should combine override and context into an `opts` parameter\n // which wraps both of these properties so we can use GetContextParameter\n sendTransaction: <TChainOverride extends Chain | undefined = undefined>(\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<Hex>;\n sendTransactions: (\n args: SendTransactionsParameters<TAccount, TContext>\n ) => Promise<Hex>;\n sendUserOperation: (\n args: SendUserOperationParameters<\n TAccount,\n TContext,\n GetEntryPointFromAccount<TAccount>\n >\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n waitForUserOperationTransaction: (\n args: WaitForUserOperationTxParameters\n ) => Promise<Hex>;\n upgradeAccount: (\n args: UpgradeAccountParams<TAccount, TContext>\n ) => Promise<Hex>;\n signMessage: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n signMessageWith6492: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedDataWith6492: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n} & (IsUndefined<TAccount> extends false\n ? { getAddress: () => Address }\n : {\n getAddress: (args: GetAccountParameter<TAccount>) => Address;\n });\n// #endregion SmartAccountClientActions\n\nexport const smartAccountClientActions: <\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) => BaseSmartAccountClientActions<TChain, TAccount, TContext> = (client) => ({\n buildUserOperation: (args) => buildUserOperation(client, args),\n buildUserOperationFromTx: (args, overrides, context) =>\n buildUserOperationFromTx(client, args, overrides, context),\n buildUserOperationFromTxs: (args) => buildUserOperationFromTxs(client, args),\n checkGasSponsorshipEligibility: (args) =>\n checkGasSponsorshipEligibility(client, args),\n signUserOperation: (args) => signUserOperation(client, args),\n dropAndReplaceUserOperation: (args) =>\n dropAndReplaceUserOperation(client, args),\n sendTransaction: (args, overrides, context) =>\n sendTransaction(client, args, overrides, context),\n sendTransactions: (args) => sendTransactions(client, args),\n sendUserOperation: (args) => sendUserOperation(client, args),\n waitForUserOperationTransaction: (args) =>\n waitForUserOperationTransaction.bind(client)(client, args),\n upgradeAccount: (args) => upgradeAccount(client, args),\n getAddress: (args) => getAddress(client, args),\n signMessage: (args) => signMessage(client, args),\n signTypedData: (args) => signTypedData(client, args),\n signMessageWith6492: (args) => signMessageWith6492(client, args),\n signTypedDataWith6492: (args) => signTypedDataWith6492(client, args),\n});\n\nexport const smartAccountClientMethodKeys = Object.keys(\n // @ts-expect-error we just want to get the keys\n smartAccountClientActions(undefined)\n).reduce((accum, curr) => {\n accum.add(curr);\n return accum;\n}, new Set<string>());\n"]}
1
+ {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccountClient.ts"],"names":[],"mappings":";;;AAcA,4FAAsF;AACtF,wGAAkG;AAClG,0GAAoG;AACpG,oHAA8G;AAC9G,8GAAwG;AACxG,4EAAsE;AACtE,sFAAgF;AAChF,wFAAkF;AAClF,0FAAoF;AACpF,8EAGmD;AACnD,8FAAwF;AACxF,kFAGqD;AACrD,kGAA4F;AAC5F,0FAAoF;AAapF,oFAA8E;AAC9E,wHAAiH;AAgG1G,MAAM,yBAAyB,GAW2B,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5E,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,0CAAkB,EAAC,MAAM,EAAE,IAAI,CAAC;IAC9D,wBAAwB,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,CACrD,IAAA,sDAAwB,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;IAC5D,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,wDAAyB,EAAC,MAAM,EAAE,IAAI,CAAC;IAC5E,8BAA8B,EAAE,CAAC,IAAI,EAAE,EAAE,CACvC,IAAA,kEAA8B,EAAC,MAAM,EAAE,IAAI,CAAC;IAC9C,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,wCAAiB,EAAC,MAAM,EAAE,IAAI,CAAC;IAC5D,2BAA2B,EAAE,CAAC,IAAI,EAAE,EAAE,CACpC,IAAA,4DAA2B,EAAC,MAAM,EAAE,IAAI,CAAC;IAC3C,eAAe,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,CAC5C,IAAA,oCAAe,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;IACnD,gB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\n type Transport,\n type TypedData,\n} from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { buildUserOperation } from \"../../actions/smartAccount/buildUserOperation.js\";\nimport { buildUserOperationFromTx } from \"../../actions/smartAccount/buildUserOperationFromTx.js\";\nimport { buildUserOperationFromTxs } from \"../../actions/smartAccount/buildUserOperationFromTxs.js\";\nimport { checkGasSponsorshipEligibility } from \"../../actions/smartAccount/checkGasSponsorshipEligibility.js\";\nimport { dropAndReplaceUserOperation } from \"../../actions/smartAccount/dropAndReplaceUserOperation.js\";\nimport { getAddress } from \"../../actions/smartAccount/getAddress.js\";\nimport { sendTransaction } from \"../../actions/smartAccount/sendTransaction.js\";\nimport { sendTransactions } from \"../../actions/smartAccount/sendTransactions.js\";\nimport { sendUserOperation } from \"../../actions/smartAccount/sendUserOperation.js\";\nimport {\n signMessage,\n type SignMessageParameters,\n} from \"../../actions/smartAccount/signMessage.js\";\nimport { signMessageWith6492 } from \"../../actions/smartAccount/signMessageWith6492.js\";\nimport {\n signTypedData,\n type SignTypedDataParameters,\n} from \"../../actions/smartAccount/signTypedData.js\";\nimport { signTypedDataWith6492 } from \"../../actions/smartAccount/signTypedDataWith6492.js\";\nimport { signUserOperation } from \"../../actions/smartAccount/signUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n BuildUserOperationParameters,\n DropAndReplaceUserOperationParameters,\n SendTransactionsParameters,\n SendUserOperationParameters,\n SignUserOperationParameters,\n UpgradeAccountParams,\n UserOperationContext,\n WaitForUserOperationTxParameters,\n} from \"../../actions/smartAccount/types\";\nimport { upgradeAccount } from \"../../actions/smartAccount/upgradeAccount.js\";\nimport { waitForUserOperationTransaction } from \"../../actions/smartAccount/waitForUserOperationTransacation.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport type { IsUndefined } from \"../../utils\";\nimport type { SendUserOperationResult } from \"../types\";\n\n//#region SmartAccountClientActions\nexport type BaseSmartAccountClientActions<\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 buildUserOperation: (\n args: BuildUserOperationParameters<TAccount, TContext>\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTx: (\n args: SendTransactionParameters<TChain, TAccount>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTxs: (\n args: BuildTransactionParameters<TAccount, TContext>\n ) => Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;\n checkGasSponsorshipEligibility: <\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n >(\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<boolean>;\n signUserOperation: (\n args: SignUserOperationParameters<TAccount, TEntryPointVersion, TContext>\n ) => Promise<UserOperationRequest<TEntryPointVersion>>;\n dropAndReplaceUserOperation: (\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n // TODO: for v4 we should combine override and context into an `opts` parameter\n // which wraps both of these properties so we can use GetContextParameter\n sendTransaction: <TChainOverride extends Chain | undefined = undefined>(\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<Hex>;\n sendTransactions: (\n args: SendTransactionsParameters<TAccount, TContext>\n ) => Promise<Hex>;\n sendUserOperation: (\n args: SendUserOperationParameters<\n TAccount,\n TContext,\n GetEntryPointFromAccount<TAccount>\n >\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n waitForUserOperationTransaction: (\n args: WaitForUserOperationTxParameters\n ) => Promise<Hex>;\n upgradeAccount: (\n args: UpgradeAccountParams<TAccount, TContext>\n ) => Promise<Hex>;\n signMessage: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n signMessageWith6492: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedDataWith6492: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n} & (IsUndefined<TAccount> extends false\n ? { getAddress: () => Address }\n : {\n getAddress: (args: GetAccountParameter<TAccount>) => Address;\n });\n// #endregion SmartAccountClientActions\n\n/**\n * Provides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.\n *\n * NOTE: this is already added to clients returned from `createSmartAccountClient`\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to\n * @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions\n */\nexport const smartAccountClientActions: <\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) => BaseSmartAccountClientActions<TChain, TAccount, TContext> = (client) => ({\n buildUserOperation: (args) => buildUserOperation(client, args),\n buildUserOperationFromTx: (args, overrides, context) =>\n buildUserOperationFromTx(client, args, overrides, context),\n buildUserOperationFromTxs: (args) => buildUserOperationFromTxs(client, args),\n checkGasSponsorshipEligibility: (args) =>\n checkGasSponsorshipEligibility(client, args),\n signUserOperation: (args) => signUserOperation(client, args),\n dropAndReplaceUserOperation: (args) =>\n dropAndReplaceUserOperation(client, args),\n sendTransaction: (args, overrides, context) =>\n sendTransaction(client, args, overrides, context),\n sendTransactions: (args) => sendTransactions(client, args),\n sendUserOperation: (args) => sendUserOperation(client, args),\n waitForUserOperationTransaction: (args) =>\n waitForUserOperationTransaction.bind(client)(client, args),\n upgradeAccount: (args) => upgradeAccount(client, args),\n getAddress: (args) => getAddress(client, args),\n signMessage: (args) => signMessage(client, args),\n signTypedData: (args) => signTypedData(client, args),\n signMessageWith6492: (args) => signMessageWith6492(client, args),\n signTypedDataWith6492: (args) => signTypedDataWith6492(client, args),\n});\n\nexport const smartAccountClientMethodKeys = Object.keys(\n // @ts-expect-error we just want to get the keys\n smartAccountClientActions(undefined)\n).reduce((accum, curr) => {\n accum.add(curr);\n return accum;\n}, new Set<string>());\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAAA,+BAWc;AAId,qDAA4D;AAC5D,mDAAyD;AACzD,yDAA6D;AAG7D,yDAA6E;AAK7E,8EAG4C;AAC5C,2CAA2D;AA4G3D,SAAgB,wBAAwB,CACtC,MAAgC;IAEhC,MAAM,EACJ,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,kBAAkB,EACzB,SAAS,EACT,IAAI,GAAG,oBAAoB,EAC3B,GAAG,MAAM,EACV,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAuB,IAAA,sCAAmB,EAAC;QACrD,GAAG,MAAM;QACT,GAAG;QACH,IAAI;QAIJ,IAAI,EAAE,oBAAoB;QAE1B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAErC,OAAO,IAAA,aAAM,EAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;oBAC9B,QAAQ,MAAM,EAAE,CAAC;wBACf,KAAK,qBAAqB;4BACxB,IAAI,C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client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n//#region SmartAccountClientActions\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n//#endregion SmartAccountClientActions\n\n//#region SmartAccountClient\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n//#endregion SmartAccountClient\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\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 config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n async request({ method, params }) {\n switch (method) {\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => ({\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n }))\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
1
+ {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAAA,+BAWc;AAId,qDAA4D;AAC5D,mDAAyD;AACzD,yDAA6D;AAG7D,yDAA6E;AAK7E,8EAG4C;AAC5C,2CAA2D;AAgI3D,SAAgB,wBAAwB,CACtC,MAAgC;IAEhC,MAAM,EACJ,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,kBAAkB,EACzB,SAAS,EACT,IAAI,GAAG,oBAAoB,EAC3B,GAAG,MAAM,EACV,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAuB,IAAA,sCAAmB,EAAC;QACrD,GAAG,MAAM;QACT,GAAG;QACH,IAAI;QAIJ,IAAI,EAAE,oBAAoB;QAE1B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAErC,OAAO,IAAA,aAAM,EAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;oBAC9B,QAAQ,MAAM,EAAE,CAAC;wBACf,KAAK,qBAAqB;4BACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gCACpB,MAAM,IAAI,iCAAoB,EAAE,CAAC;4BACnC,CAAC;4BACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gCAClB,MAAM,IAAI,8BAAkB,EAAE,CAAC;4BACjC,CAAC;4BACD,MAAM,CAAC,EAA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KAAK,CACb,yDAAyD,CAC1D,CAAC;4BACJ,CAAC;4BACD,OAAO,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;wBAC1C,CAAC;wBACD,KAAK,aAAa;4BAChB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gCAChB,MAAM,IAAI,8BAAkB,EAAE,CAAC;4BACjC,CAAC;4BAED,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;wBACvB;4BAGE,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBACpD,CAAC;gBACH,CAAC;aACF,CAAC,CAAC,IAAI,CAAC,CAAC;QACX,CAAC;KACF,CAAC;SACC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACb,GAAG,wCAA4B,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;KACzD,CAAC,CAAC;SACF,MAAM,CAAC,IAAA,8BAAiB,EAAC,MAAM,CAAC,CAAC;SACjC,MAAM,CAAC,iDAAyB,CAAC,CAAC;IAErC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAhGD,4DAgGC;AAqDD,SAAgB,oCAAoC,CAClD,MAEC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,SAAS,EAAE,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAVD,oFAUC","sourcesContent":["import {\n custom,\n type Chain,\n type Client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n//#region SmartAccountClientActions\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n//#endregion SmartAccountClientActions\n\n//#region SmartAccountClient\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n//#endregion SmartAccountClient\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\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 config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\n/**\n * Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * // optionally hoist the account\n * account: toSmartContractAccount(...),\n * });\n * ```\n *\n * @param {SmartAccountClientConfig} config The configuration for creating the smart account client\n * @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account\n */\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n async request({ method, params }) {\n switch (method) {\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => ({\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n }))\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\n/**\n * Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.\n *\n * @example\n * ```ts\n * import {\n * createBundlerClient,\n * createSmartAccountClientFromExisting,\n * toSmartContractAccount\n * } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n * const client = createSmartAccountClientFromExisting({\n * client,\n * account: toSmartContractAccount(...),\n * })\n * ```\n *\n * @param {Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {client: BundlerClient}} config the configuration object which includes the client\n * @returns {SmartAccountClient} A smart account client created from the existing BundlerClient\n */\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Chain } from "viem/chains";
2
1
  import * as chains from "viem/chains";
2
+ import { type Chain } from "viem/chains";
3
3
  export declare const ChainsById: Map<number, chains.Chain>;
4
4
  export declare const convertChainIdToCoinType: (chainId: number) => number;
5
5
  export declare const convertCoinTypeToChainId: (coinType: number) => number;
@@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.convertCoinTypeToChain = exports.convertCoinTypeToChainId = exports.convertChainIdToCoinType = exports.ChainsById = void 0;
27
27
  const chains = __importStar(require("viem/chains"));
28
- const index_js_1 = require("../chains/index.js");
28
+ const chains_1 = require("viem/chains");
29
29
  exports.ChainsById = new Map(Object.values(chains).map((x) => [x.id, x]));
30
30
  const convertChainIdToCoinType = (chainId) => {
31
- if (chainId === index_js_1.mainnet.id) {
31
+ if (chainId === chains_1.mainnet.id) {
32
32
  return 60;
33
33
  }
34
34
  return (0x80000000 | chainId) >>> 0;
@@ -36,7 +36,7 @@ const convertChainIdToCoinType = (chainId) => {
36
36
  exports.convertChainIdToCoinType = convertChainIdToCoinType;
37
37
  const convertCoinTypeToChainId = (coinType) => {
38
38
  if (coinType === 60) {
39
- return index_js_1.mainnet.id;
39
+ return chains_1.mainnet.id;
40
40
  }
41
41
  return (0x7fffffff & coinType) >> 0;
42
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/ens/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAsC;AACtC,iDAA6C;AAEhC,QAAA,UAAU,GAA8B,IAAI,GAAG,CAC1D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAC5C,CAAC;AAEK,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAU,EAAE;IAClE,IAAI,OAAO,KAAK,kBAAO,CAAC,EAAE,EAAE,CAAC;QAE3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAGD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAEK,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAU,EAAE;IACnE,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QAEpB,OAAO,kBAAO,CAAC,EAAE,CAAC;IACpB,CAAC;IAGD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAEK,MAAM,sBAAsB,GAAG,CAAC,QAAgB,EAAS,EAAE;IAChE,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,kBAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC","sourcesContent":["import type { Chain } from \"viem/chains\";\nimport * as chains from \"viem/chains\";\nimport { mainnet } from \"../chains/index.js\";\n\nexport const ChainsById: Map<number, chains.Chain> = new Map(\n Object.values(chains).map((x) => [x.id, x])\n);\n\nexport const convertChainIdToCoinType = (chainId: number): number => {\n if (chainId === mainnet.id) {\n // this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)\n return 60;\n }\n\n // this is using [ENSIP-11](https://docs.ens.domains/ens-improvement-proposals/ensip-11-evmchain-address-resolution) and assumes this is how mappings are stored for non mainnet chains\n return (0x80000000 | chainId) >>> 0;\n};\n\nexport const convertCoinTypeToChainId = (coinType: number): number => {\n if (coinType === 60) {\n // this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)\n return mainnet.id;\n }\n\n // this is using [ENSIP-11](https://docs.ens.domains/ens-improvement-proposals/ensip-11-evmchain-address-resolution) and assumes this is how mappings are stored for non mainnet chains\n return (0x7fffffff & coinType) >> 0;\n};\n\nexport const convertCoinTypeToChain = (coinType: number): Chain => {\n const chainId = convertCoinTypeToChainId(coinType);\n const chain = ChainsById.get(chainId);\n if (!chain) {\n throw new Error(\"CoinType does not map to a supported chain\");\n }\n\n return chain;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/ens/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,wCAAkD;AAErC,QAAA,UAAU,GAA8B,IAAI,GAAG,CAC1D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAC5C,CAAC;AAgBK,MAAM,wBAAwB,GAAG,CAAC,OAAe,EAAU,EAAE;IAClE,IAAI,OAAO,KAAK,gBAAO,CAAC,EAAE,EAAE,CAAC;QAE3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAGD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAiBK,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAU,EAAE;IACnE,IAAI,QAAQ,KAAK,EAAE,EAAE,CAAC;QAEpB,OAAO,gBAAO,CAAC,EAAE,CAAC;IACpB,CAAC;IAGD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC;AAkBK,MAAM,sBAAsB,GAAG,CAAC,QAAgB,EAAS,EAAE;IAChE,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,kBAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC","sourcesContent":["import * as chains from \"viem/chains\";\nimport { mainnet, type Chain } from \"viem/chains\";\n\nexport const ChainsById: Map<number, chains.Chain> = new Map(\n Object.values(chains).map((x) => [x.id, x])\n);\n\n/**\n * Converts a given chain ID to a coin type, following specific standards for mainnet and non-mainnet chains.\n *\n * @example\n * ```ts\n * import { convertChainIdToCoinType } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const coinType = convertChainIdToCoinType(sepolia.id);\n * ```\n *\n * @param {number} chainId the blockchain chain ID that you want to convert to a coin type\n * @returns {number} the corresponding coin type for the given chain ID\n */\nexport const convertChainIdToCoinType = (chainId: number): number => {\n if (chainId === mainnet.id) {\n // this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)\n return 60;\n }\n\n // this is using [ENSIP-11](https://docs.ens.domains/ens-improvement-proposals/ensip-11-evmchain-address-resolution) and assumes this is how mappings are stored for non mainnet chains\n return (0x80000000 | chainId) >>> 0;\n};\n\n/**\n * Converts a coin type to a chain ID based on predefined mappings. This function follows ENSIP-9 for coin type 60 and ENSIP-11 for other coin types.\n *\n * @example\n * ```ts\n * import { convertChainIdToCoinType, convertCoinTypeToChainId } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const coinType = convertChainIdToCoinType(sepolia.id);\n * const chainId = convertCoinTypeToChainId(coinType);\n * ```\n *\n * @param {number} coinType the coin type to be converted to a chain ID\n * @returns {number} the corresponding chain ID\n */\nexport const convertCoinTypeToChainId = (coinType: number): number => {\n if (coinType === 60) {\n // this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)\n return mainnet.id;\n }\n\n // this is using [ENSIP-11](https://docs.ens.domains/ens-improvement-proposals/ensip-11-evmchain-address-resolution) and assumes this is how mappings are stored for non mainnet chains\n return (0x7fffffff & coinType) >> 0;\n};\n\n/**\n * Converts a coin type to its corresponding blockchain chain based on a predefined mapping.\n *\n * @example\n * ```ts\n * import { convertChainIdToCoinType, convertCoinTypeToChain } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const coinType = convertChainIdToCoinType(sepolia.id);\n * const chain = convertCoinTypeToChain(coinType);\n * ```\n *\n * @param {number} coinType The numerical identifier for the coin type\n * @returns {Chain} The corresponding blockchain chain\n * @throws {Error} If the coin type does not map to a supported chain\n */\nexport const convertCoinTypeToChain = (coinType: number): Chain => {\n const chainId = convertCoinTypeToChainId(coinType);\n const chain = ChainsById.get(chainId);\n if (!chain) {\n throw new Error(\"CoinType does not map to a supported chain\");\n }\n\n return chain;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entrypoint/index.ts"],"names":[],"mappings":";;;;;;AACA,2DAAkE;AAClE,uDAAqC;AACrC,uDAAqC;AASxB,QAAA,wBAAwB,GAA6B,OAAO,CAAC;AAE7D,QAAA,kBAAkB,GAAuB;IACpD,OAAO,EAAE,iBAAa;IACtB,OAAO,EAAE,iBAAa;CACvB,CAAC;AAEK,MAAM,mBAAmB,GAAG,CACjC,KAAU,EACyB,EAAE;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,0BAAkB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B;AAuBF,SAAgB,aAAa,CAI3B,KAAa,EACb,OAAiD;IAEjD,MAAM,EAAE,OAAO,GAAG,gCAAwB,EAAE,eAAe,EAAE,GAAG,OAAO,IAAI;QACzE,OAAO,EAAE,gCAAwB;KAClC,CAAC;IAEF,MAAM,UAAU,GAAG,0BAAkB,CAAC,OAAO,IAAI,gCAAwB,CAAC,CAAC;IAC3E,MAAM,OAAO,GACX,eAAe;QACf,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,uCAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACnC,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,OAAO;YACP,KAAK;YACL,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACvD,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;SAChD,CAAC;IACJ,CAAC;SAAM,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAC1C,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,OAAO;YACP,KAAK;YACL,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACvD,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;SAChD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,uCAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AA3CD,sCA2CC","sourcesContent":["import { type Chain } from \"viem\";\nimport { EntryPointNotFoundError } from \"../errors/entrypoint.js\";\nimport EntryPoint_v6 from \"./0.6.js\";\nimport EntryPoint_v7 from \"./0.7.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointDefRegistry,\n EntryPointRegistry,\n EntryPointVersion,\n GetEntryPointOptions,\n} from \"./types.js\";\n\nexport const defaultEntryPointVersion: DefaultEntryPointVersion = \"0.6.0\";\n\nexport const entryPointRegistry: EntryPointRegistry = {\n \"0.6.0\": EntryPoint_v6,\n \"0.7.0\": EntryPoint_v7,\n};\n\nexport const isEntryPointVersion = (\n value: any\n): value is keyof EntryPointRegistry => {\n return Object.keys(entryPointRegistry).includes(value);\n};\n\nexport function getEntryPoint<\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[TEntryPointVersion];\n\nexport function getEntryPoint<\n TEntryPointVersion extends DefaultEntryPointVersion = DefaultEntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options?: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[TEntryPointVersion];\n\nexport function getEntryPoint<TChain extends Chain = Chain>(\n chain: TChain,\n options?: GetEntryPointOptions<DefaultEntryPointVersion>\n): EntryPointDefRegistry<TChain>[DefaultEntryPointVersion];\n\nexport function getEntryPoint<\n TEntryPointVersion extends EntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[EntryPointVersion] {\n const { version = defaultEntryPointVersion, addressOverride } = options ?? {\n version: defaultEntryPointVersion,\n };\n\n const entryPoint = entryPointRegistry[version ?? defaultEntryPointVersion];\n const address =\n addressOverride ??\n entryPoint.address[chain.id] ??\n entryPoint.address.default;\n if (!address) {\n throw new EntryPointNotFoundError(chain, version);\n }\n\n if (entryPoint.version === \"0.6.0\") {\n return {\n version: entryPoint.version,\n address,\n chain,\n abi: entryPoint.abi,\n getUserOperationHash: (r) =>\n entryPoint.getUserOperationHash(r, address, chain.id),\n packUserOperation: entryPoint.packUserOperation,\n };\n } else if (entryPoint.version === \"0.7.0\") {\n return {\n version: entryPoint.version,\n address,\n chain,\n abi: entryPoint.abi,\n getUserOperationHash: (r) =>\n entryPoint.getUserOperationHash(r, address, chain.id),\n packUserOperation: entryPoint.packUserOperation,\n };\n }\n\n throw new EntryPointNotFoundError(chain, version);\n}\n\n// // =================================================================================\n// // TODO: Add tests for the following cases\n\n// const chain: Chain = mainnet;\n\n// // 1. left and right hand side version type should match, as well as the param\n\n// // === Error ===\n// const ep1_a: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain, {\n// version: \"0.7.0\",\n// }); // error\n// const ep1_b: EntryPointDef<\"0.7.0\"> = getEntryPoint(chain); // error\n// const ep1_c: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain, {\n// version: \"0.7.0\",\n// }); // error\n// const ep1_d: EntryPointDef<\"0.6.0\"> = getEntryPoint<\"0.6.0\">(chain, {\n// version: \"0.7.0\",\n// }); // error\n\n// // === Valid ===\n// const ep1a: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain);\n// const ep1b: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain, { version: \"0.6.0\" });\n// const ep1c: EntryPointDef<\"0.7.0\"> = getEntryPoint(chain, { version: \"0.7.0\" });\n// const ep1d: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain, {\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// });\n// const ep1e: EntryPointDef<\"0.6.0\"> = getEntryPoint(chain, {\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// version: \"0.6.0\",\n// });\n// const ep1f: EntryPointDef<\"0.7.0\"> = getEntryPoint(chain, {\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// version: \"0.7.0\",\n// });\n\n// // 2. If non-default type is specified, version option param of the type is required\n\n// // === Error ===\n// const ep2_a: EntryPointDef<\"0.7.0\"> = getEntryPoint<\"0.7.0\">(chain); // error\n// const ep2_b: EntryPointDef<\"0.7.0\"> = getEntryPoint<\"0.7.0\">(chain, {\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// });\n\n// // === Valid ===\n// const ep2a: EntryPointDef<\"0.7.0\"> = getEntryPoint<\"0.7.0\">(chain, {\n// version: \"0.7.0\",\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// });\n// const ep2b: EntryPointDef<\"0.6.0\"> = getEntryPoint<\"0.6.0\">(chain, {\n// version: \"0.6.0\",\n// });\n// const ep2c: EntryPointDef<\"0.6.0\"> = getEntryPoint<\"0.6.0\">(chain);\n// const ep2d: EntryPointDef<\"0.6.0\"> = getEntryPoint<\"0.6.0\">(chain, {\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// });\n// const ep2e: EntryPointDef<\"0.7.0\"> = getEntryPoint<\"0.7.0\">(chain, {\n// version: \"0.7.0\",\n// addressOverride: \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\",\n// });\n\n// // =================================================================================\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entrypoint/index.ts"],"names":[],"mappings":";;;;;;AACA,2DAAkE;AAClE,uDAAqC;AACrC,uDAAqC;AASxB,QAAA,wBAAwB,GAA6B,OAAO,CAAC;AAE7D,QAAA,kBAAkB,GAAuB;IACpD,OAAO,EAAE,iBAAa;IACtB,OAAO,EAAE,iBAAa;CACvB,CAAC;AAgBK,MAAM,mBAAmB,GAAG,CACjC,KAAU,EACyB,EAAE;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,0BAAkB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B;AAuCF,SAAgB,aAAa,CAI3B,KAAa,EACb,OAAiD;IAEjD,MAAM,EAAE,OAAO,GAAG,gCAAwB,EAAE,eAAe,EAAE,GAAG,OAAO,IAAI;QACzE,OAAO,EAAE,gCAAwB;KAClC,CAAC;IAEF,MAAM,UAAU,GAAG,0BAAkB,CAAC,OAAO,IAAI,gCAAwB,CAAC,CAAC;IAC3E,MAAM,OAAO,GACX,eAAe;QACf,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,uCAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACnC,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,OAAO;YACP,KAAK;YACL,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACvD,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;SAChD,CAAC;IACJ,CAAC;SAAM,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAC1C,OAAO;YACL,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,OAAO;YACP,KAAK;YACL,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,UAAU,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACvD,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;SAChD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,uCAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AA3CD,sCA2CC","sourcesContent":["import { type Chain } from \"viem\";\nimport { EntryPointNotFoundError } from \"../errors/entrypoint.js\";\nimport EntryPoint_v6 from \"./0.6.js\";\nimport EntryPoint_v7 from \"./0.7.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointDefRegistry,\n EntryPointRegistry,\n EntryPointVersion,\n GetEntryPointOptions,\n} from \"./types.js\";\n\nexport const defaultEntryPointVersion: DefaultEntryPointVersion = \"0.6.0\";\n\nexport const entryPointRegistry: EntryPointRegistry = {\n \"0.6.0\": EntryPoint_v6,\n \"0.7.0\": EntryPoint_v7,\n};\n\n/**\n * Checks if the given value is a valid key of the EntryPointRegistry.\n *\n * @example\n * ```ts\n * import { isEntryPointVersion } from \"@aa-sdk/core\";\n *\n * const valid = isEntryPointVersion(\"0.6.0\");\n * const invalid = isEntryPointVersion(\"0.8.0\");\n * ```\n *\n * @param {*} value The value to be checked\n * @returns {boolean} true if the value is a valid key of EntryPointRegistry, false otherwise\n */\nexport const isEntryPointVersion = (\n value: any\n): value is keyof EntryPointRegistry => {\n return Object.keys(entryPointRegistry).includes(value);\n};\n\nexport function getEntryPoint<\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[TEntryPointVersion];\n\nexport function getEntryPoint<\n TEntryPointVersion extends DefaultEntryPointVersion = DefaultEntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options?: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[TEntryPointVersion];\n\nexport function getEntryPoint<TChain extends Chain = Chain>(\n chain: TChain,\n options?: GetEntryPointOptions<DefaultEntryPointVersion>\n): EntryPointDefRegistry<TChain>[DefaultEntryPointVersion];\n\n/**\n * Retrieves the entry point definition for the specified chain and version, falling back to the default version if not provided. Throws an error if the entry point address cannot be found.\n *\n * @example\n * ```ts\n * import { getEntryPoint } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n *\n * const entryPoint060 = getEntryPoint(sepolia);\n * const entryPoint070 = getEntryPoint(sepolia, { version: \"0.7.0\" });\n * ```\n *\n * @param {Chain} chain The chain for which the entry point is being retrieved\n * @param {GetEntryPointOptions<TEntryPointVersion>} options Options containing the version and address overrides for the entry point\n * @returns {EntryPointDefRegistry<TChain>[EntryPointVersion]} The entry point definition for the specified chain and version\n */\nexport function getEntryPoint<\n TEntryPointVersion extends EntryPointVersion,\n TChain extends Chain = Chain\n>(\n chain: TChain,\n options: GetEntryPointOptions<TEntryPointVersion>\n): EntryPointDefRegistry<TChain>[EntryPointVersion] {\n const { version = defaultEntryPointVersion, addressOverride } = options ?? {\n version: defaultEntryPointVersion,\n };\n\n const entryPoint = entryPointRegistry[version ?? defaultEntryPointVersion];\n const address =\n addressOverride ??\n entryPoint.address[chain.id] ??\n entryPoint.address.default;\n if (!address) {\n throw new EntryPointNotFoundError(chain, version);\n }\n\n if (entryPoint.version === \"0.6.0\") {\n return {\n version: entryPoint.version,\n address,\n chain,\n abi: entryPoint.abi,\n getUserOperationHash: (r) =>\n entryPoint.getUserOperationHash(r, address, chain.id),\n packUserOperation: entryPoint.packUserOperation,\n };\n } else if (entryPoint.version === \"0.7.0\") {\n return {\n version: entryPoint.version,\n address,\n chain,\n abi: entryPoint.abi,\n getUserOperationHash: (r) =>\n entryPoint.getUserOperationHash(r, address, chain.id),\n packUserOperation: entryPoint.packUserOperation,\n };\n }\n\n throw new EntryPointNotFoundError(chain, version);\n}\n"]}