@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,16 +1,28 @@
1
- import { type Address, type Hash, type Hex, type PublicClient } from "viem";
1
+ import { type Address, type Hash, type Hex } from "viem";
2
2
  export type SignWith6492Params = {
3
3
  factoryAddress: Address;
4
4
  factoryCalldata: Hex;
5
5
  signature: Hash;
6
6
  };
7
- type VerifyEIP6492SignatureParams = {
8
- signer: Address;
9
- hash: Hash;
10
- signature: Hash;
11
- client: PublicClient;
12
- };
7
+ /**
8
+ * Wraps a given signature with additional data following the EIP-6492 standard.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { wrapSignatureWith6492 } from "@aa-sdk/core";
13
+ *
14
+ * const signature = wrapSignatureWith6492({
15
+ * factoryAddress: "0x...",
16
+ * factoryCalldata: "0x...",
17
+ * signature: "0x...",
18
+ * });
19
+ * ```
20
+ *
21
+ * @param {SignWith6492Params} params The parameters to wrap the signature
22
+ * @param {Hex} params.factoryAddress The address of the factory
23
+ * @param {Hex} params.factoryCalldata The calldata for the factory
24
+ * @param {Hex} params.signature The original signature that needs to be wrapped
25
+ * @returns {Hash} The wrapped signature
26
+ */
13
27
  export declare const wrapSignatureWith6492: ({ factoryAddress, factoryCalldata, signature, }: SignWith6492Params) => Hash;
14
- export declare const verifyEIP6492Signature: ({ signer, hash, signature, client, }: VerifyEIP6492SignatureParams) => Promise<boolean>;
15
- export {};
16
28
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,GAAG,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,oDAI/B,kBAAkB,KAAG,IAgBvB,CAAC;AAMF,eAAO,MAAM,sBAAsB,yCAKhC,4BAA4B,KAAG,QAAQ,OAAO,CAahD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/signer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,GAAG,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,qBAAqB,oDAI/B,kBAAkB,KAAG,IAgBvB,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import { type Hex, type SignableMessage, type TypedDataDefinition, type WalletClient } from "viem";
2
2
  import type { SmartAccountSigner } from "./types";
3
+ /**
4
+ * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
5
+ */
3
6
  export declare class WalletClientSigner implements SmartAccountSigner<WalletClient> {
4
7
  signerType: string;
5
8
  inner: WalletClient;
@@ -33,13 +36,13 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
33
36
  [x: `bytes9[${string}]`]: undefined;
34
37
  [x: `bytes10[${string}]`]: undefined;
35
38
  [x: `bytes25[${string}]`]: undefined;
36
- [x: `bytes18[${string}]`]: undefined;
37
39
  [x: `bytes12[${string}]`]: undefined;
38
40
  [x: `bytes13[${string}]`]: undefined;
39
41
  [x: `bytes14[${string}]`]: undefined;
40
42
  [x: `bytes15[${string}]`]: undefined;
41
43
  [x: `bytes16[${string}]`]: undefined;
42
44
  [x: `bytes17[${string}]`]: undefined;
45
+ [x: `bytes18[${string}]`]: undefined;
43
46
  [x: `bytes19[${string}]`]: undefined;
44
47
  [x: `bytes20[${string}]`]: undefined;
45
48
  [x: `bytes21[${string}]`]: undefined;
@@ -135,13 +138,13 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
135
138
  bytes9?: undefined;
136
139
  bytes10?: undefined;
137
140
  bytes25?: undefined;
138
- bytes18?: undefined;
139
141
  bytes12?: undefined;
140
142
  bytes13?: undefined;
141
143
  bytes14?: undefined;
142
144
  bytes15?: undefined;
143
145
  bytes16?: undefined;
144
146
  bytes17?: undefined;
147
+ bytes18?: undefined;
145
148
  bytes19?: undefined;
146
149
  bytes20?: undefined;
147
150
  bytes21?: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-client.d.ts","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"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E,MAAM;IAQpD,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAGtC;IAEF,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAKtE;IAEJ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0GAKV,QAAQ,GAAG,CAAC,CAOb;CACH"}
@@ -1,6 +1,6 @@
1
1
  import { type Address, type Chain } from "viem";
2
2
  import type { EntryPointVersion } from "../entrypoint/types.js";
3
- import type { UserOperationFeeOptions } from "../types";
3
+ import type { UserOperationFeeOptions } from "../types.js";
4
4
  /**
5
5
  * Utility method returning the default simple account factory address given a {@link Chain} object
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/utils/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAuBhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,UACzC,KAAK,YACH,iBAAiB,KACzB,OAqCF,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAIvC,CAAC;AAEH,eAAO,MAAM,iCAAiC,UACrC,KAAK,KACX,uBAOF,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/utils/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAsBhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,UACzC,KAAK,YACH,iBAAiB,KACzB,OAqCF,CAAC;AAEF,eAAO,MAAM,4BAA4B,qBAIvC,CAAC;AAEH,eAAO,MAAM,iCAAiC,UACrC,KAAK,KACX,uBAOF,CAAC"}
@@ -1,15 +1,5 @@
1
- import type { Chain } from "viem";
2
1
  import type { PromiseOrValue } from "../types.js";
3
2
  import type { RecordableKeys } from "./types.js";
4
- export declare const AlchemyChainMap: Map<number, Chain>;
5
- /**
6
- * Utility method for converting a chainId to a {@link Chain} object
7
- *
8
- * @param chainId - the chainId to convert
9
- * @returns a {@link Chain} object for the given chainId
10
- * @throws if the chainId is not found
11
- */
12
- export declare const getChain: (chainId: number) => Chain;
13
3
  /**
14
4
  * Utility function that allows for piping a series of async functions together
15
5
  *
@@ -34,8 +24,41 @@ export declare function resolveProperties<T>(object: Deferrable<T>): Promise<T>;
34
24
  * @returns object with all of its values hexlified
35
25
  */
36
26
  export declare function deepHexlify(obj: any): any;
37
- export declare function defineReadOnly<T, K extends keyof T>(object: T, key: K, value: T[K]): void;
27
+ /**
28
+ * Filters out properties with undefined or null values from the provided object.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { filterUndefined } from "@aa-sdk/core";
33
+ *
34
+ * const result = filterUndefined({
35
+ * foo: undefined,
36
+ * bar: null,
37
+ * baz: "baz",
38
+ * }); // { baz: "baz" }
39
+ * ```
40
+ *
41
+ * @param {T} obj the object from which to remove properties with undefined or null values
42
+ * @returns {T} the object with undefined or null properties removed
43
+ */
38
44
  export declare function filterUndefined<T>(obj: T): T;
45
+ /**
46
+ * Picks the specified keys from an object and returns a new object containing only those key-value pairs.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { pick } from "@aa-sdk/core";
51
+ *
52
+ * const picked = pick({
53
+ * foo: "foo",
54
+ * bar: "bar",
55
+ * }, ["foo"]); // { foo: "foo" }
56
+ * ```
57
+ *
58
+ * @param {Record<string, unknown>} obj The object from which to pick keys
59
+ * @param {string|string[]} keys A single key or an array of keys to pick from the object
60
+ * @returns {Record<string, unknown>} A new object containing only the picked key-value pairs
61
+ */
39
62
  export declare function pick(obj: Record<string, unknown>, keys: string | string[]): {};
40
63
  /**
41
64
  * Utility method for checking if the passed in values are all equal (strictly)
@@ -53,6 +76,26 @@ export declare const allEqual: (...params: any[]) => boolean;
53
76
  * @returns the value if condition holds true, undefined if not
54
77
  */
55
78
  export declare const conditionalReturn: <T>(condition: Promise<boolean>, value: () => Promise<T>) => Promise<T | undefined>;
79
+ /**
80
+ * Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { toRecord } from "@aa-sdk/core";
85
+ * import { sepolia, mainnet } from "viem/chains";
86
+ *
87
+ * const addressesByChain = toRecord(
88
+ * [sepolia, mainnet],
89
+ * "id",
90
+ * () => "0x..."
91
+ * ); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
92
+ * ```
93
+ *
94
+ * @param {T[]} array The array of objects to convert to a record
95
+ * @param {K} selector The key used to select the property that will become the record's key
96
+ * @param {(item: T) => V} fn The function that transforms each item in the array into the record's value
97
+ * @returns {Record<T[K], V>} The resulting record object
98
+ */
56
99
  export declare const toRecord: <T extends { [K in RecordableKeys<T>]: string | number | symbol; }, K_1 extends RecordableKeys<T>, V>(array: T[], selector: K_1, fn: (item: T) => V) => Record<T[K_1], V>;
57
100
  export * from "./bigint.js";
58
101
  export * from "./bytes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,mBAAmB,YAAY,CAAC;AAChC,cAAc,aAAa,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.0.0-alpha.0";
1
+ export declare const VERSION = "4.0.0-alpha.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.0.0-alpha.0",
4
+ "version": "4.0.0-alpha.2",
5
5
  "description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
6
6
  "author": "Alchemy",
7
7
  "type": "module",
@@ -66,5 +66,5 @@
66
66
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
67
67
  },
68
68
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
69
- "gitHead": "bd1788c2bd7f28ba762a06c649f30b544f8bade9"
69
+ "gitHead": "af70c1ea67be7f49339a1267ccadd8dc10aabde1"
70
70
  }
@@ -155,6 +155,12 @@ export async function createSimpleSmartAccount<
155
155
  config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>
156
156
  ): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;
157
157
 
158
+ /**
159
+ * 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.
160
+ *
161
+ * @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account
162
+ * @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods
163
+ */
158
164
  export async function createSimpleSmartAccount({
159
165
  chain,
160
166
  entryPoint = getEntryPoint(chain),
@@ -74,6 +74,21 @@ export type SmartContractAccountWithSigner<
74
74
  getSigner: () => TSigner;
75
75
  };
76
76
 
77
+ /**
78
+ * Determines if the given SmartContractAccount has a signer associated with it.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { toSmartContractAccount } from "@aa-sdk/core";
83
+ *
84
+ * const account = await toSmartContractAccount(...);
85
+ *
86
+ * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer
87
+ * ```
88
+ *
89
+ * @param {SmartContractAccount} account The account to check.
90
+ * @returns {boolean} true if the account has a signer, otherwise false.
91
+ */
77
92
  export const isSmartAccountWithSigner = (
78
93
  account: SmartContractAccount
79
94
  ): account is SmartContractAccountWithSigner => {
@@ -138,6 +153,19 @@ export type ToSmartContractAccountParams<
138
153
  } & Omit<CustomSource, "signTransaction" | "address">;
139
154
  // [!endregion ToSmartContractAccountParams]
140
155
 
156
+ /**
157
+ * Parses the factory address and factory calldata from the provided account initialization code (initCode).
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { parseFactoryAddressFromAccountInitCode } from "@aa-sdk/core";
162
+ *
163
+ * const [address, calldata] = parseFactoryAddressFromAccountInitCode("0xAddressCalldata");
164
+ * ```
165
+ *
166
+ * @param {Hex} initCode The initialization code from which to parse the factory address and calldata
167
+ * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata
168
+ */
141
169
  export const parseFactoryAddressFromAccountInitCode = (
142
170
  initCode: Hex
143
171
  ): [Address, Hex] => {
@@ -146,6 +174,27 @@ export const parseFactoryAddressFromAccountInitCode = (
146
174
  return [factoryAddress, factoryCalldata];
147
175
  };
148
176
 
177
+ /**
178
+ * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * import { getEntryPoint, getAccountAddress } from "@aa-sdk/core";
183
+ *
184
+ * const accountAddress = await getAccountAddress({
185
+ * client,
186
+ * entryPoint: getEntryPoint(chain),
187
+ * getAccountInitCode: async () => "0x{factoryAddress}{factoryCallData}",
188
+ * });
189
+ * ```
190
+ *
191
+ * @param {object} config The configuration object
192
+ * @param {PublicClient} config.client A public client instance to interact with the blockchain
193
+ * @param {EntryPointDef} config.entryPoint The entry point definition which includes the address and ABI
194
+ * @param {Address} config.accountAddress Optional existing account address
195
+ * @param {function(): Promise<Hex>} config.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account
196
+ * @returns {Promise<Address>} A promise that resolves to the account address
197
+ */
149
198
  export const getAccountAddress = async ({
150
199
  client,
151
200
  entryPoint,
@@ -220,21 +269,77 @@ export async function toSmartContractAccount<
220
269
  >): Promise<SmartContractAccount<Name, TEntryPointVersion>>;
221
270
  // [!endregion toSmartContractAccount]
222
271
 
223
- export async function toSmartContractAccount({
224
- transport,
225
- chain,
226
- entryPoint,
227
- source,
228
- accountAddress,
229
- getAccountInitCode,
230
- signMessage,
231
- signTypedData,
232
- encodeBatchExecute,
233
- encodeExecute,
234
- getDummySignature,
235
- signUserOperationHash,
236
- encodeUpgradeToAndCall,
237
- }: ToSmartContractAccountParams): Promise<SmartContractAccount> {
272
+ /**
273
+ * 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.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * import { http, type SignableMessage } from "viem";
278
+ * import { sepolia } from "viem/chains";
279
+ *
280
+ * const myAccount = await toSmartContractAccount({
281
+ * /// REQUIRED PARAMS ///
282
+ * source: "MyAccount",
283
+ * transport: http("RPC_URL"),
284
+ * chain: sepolia,
285
+ * // The EntryPointDef that your account is com"patible with
286
+ * entryPoint: getEntryPoint(sepolia, { version: "0.6.0" }),
287
+ * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method
288
+ * getAccountInitCode: async () => "0x{factoryAddress}{callData}",
289
+ * // an invalid signature that doesn't cause your account to revert during validation
290
+ * getDummySignature: () => "0x1234...",
291
+ * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method
292
+ * encodeExecute: async (uo) => "0xcalldata",
293
+ * signMessage: async ({ message }: { message: SignableMessage }) => "0x...",
294
+ * signTypedData: async (typedData) => "0x000",
295
+ *
296
+ * /// OPTIONAL PARAMS ///
297
+ * // if you already know your account's address, pass that in here to avoid generating a new counterfactual
298
+ * accountAddress: "0xaddressoverride",
299
+ * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method
300
+ * encodeBatchExecute: async (uos) => "0x...",
301
+ * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here
302
+ * signUserOperationHash: async (hash) => "0x...",
303
+ * // allows you to define the calldata for upgrading your account
304
+ * encodeUpgradeToAndCall: async (params) => "0x...",
305
+ * });
306
+ * ```
307
+ *
308
+ * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account
309
+ * @param {Transport} params.transport the transport mechanism used for communication
310
+ * @param {Chain} params.chain the blockchain chain used in the account
311
+ * @param {EntryPoint} params.entryPoint the entry point of the smart contract
312
+ * @param {string} params.source the source identifier for the account
313
+ * @param {Address} [params.accountAddress] the address of the account
314
+ * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account
315
+ * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message
316
+ * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data
317
+ * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions
318
+ * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction
319
+ * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature
320
+ * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations
321
+ * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call
322
+ * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account
323
+ */
324
+ export async function toSmartContractAccount(
325
+ params: ToSmartContractAccountParams
326
+ ): Promise<SmartContractAccount> {
327
+ const {
328
+ transport,
329
+ chain,
330
+ entryPoint,
331
+ source,
332
+ accountAddress,
333
+ getAccountInitCode,
334
+ signMessage,
335
+ signTypedData,
336
+ encodeBatchExecute,
337
+ encodeExecute,
338
+ getDummySignature,
339
+ signUserOperationHash,
340
+ encodeUpgradeToAndCall,
341
+ } = params;
342
+
238
343
  const client = createBundlerClient({
239
344
  // we set the retry count to 0 so that viem doesn't retry during
240
345
  // getting the address. That call always reverts and without this
@@ -14,6 +14,29 @@ import type {
14
14
  UserOperationContext,
15
15
  } from "./types";
16
16
 
17
+ /**
18
+ * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { createSmartAccountClient } from "@aa-sdk/core";
23
+ *
24
+ * // smart account client is already extended with buildUserOperation
25
+ * const client = createSmartAccountClient(...);
26
+ * const result = await client.buildUserOperation({
27
+ * uo: {
28
+ * target: "0x...",
29
+ * data: "0x...", // or "0x",
30
+ * value: 0n, // optional
31
+ * },
32
+ * account, // only required if the client above is not connected to an account
33
+ * });
34
+ * ```
35
+ *
36
+ * @param {Client<TTransport, TChain, TAccount>} client the client instance used to build the user operation
37
+ * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context
38
+ * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details
39
+ */
17
40
  export async function buildUserOperation<
18
41
  TTransport extends Transport = Transport,
19
42
  TChain extends Chain | undefined = Chain | undefined,
@@ -20,6 +20,28 @@ import type {
20
20
  UserOperationContext,
21
21
  } from "./types";
22
22
 
23
+ /**
24
+ * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import {
29
+ * createSmartAccountClient,
30
+ * } from "@aa-sdk/core";
31
+ *
32
+ * // smart account client is already extended with dropAndReplaceUserOperation
33
+ * const client = createSmartAccountClient(...);
34
+ * const { request } = await client.sendUserOperation(...);
35
+ * const result = await client.dropAndReplaceUserOperation({
36
+ * uoToDrop: request,
37
+ * account, // only required if the client above is not connected to an account
38
+ * });
39
+ * ```
40
+ *
41
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance with the transport, chain, and account information
42
+ * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
43
+ * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
44
+ */
23
45
  export async function dropAndReplaceUserOperation<
24
46
  TTransport extends Transport = Transport,
25
47
  TChain extends Chain | undefined = Chain | undefined,
@@ -20,6 +20,30 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
20
20
  import type { UserOperationContext } from "./types.js";
21
21
  import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
22
22
 
23
+ /**
24
+ * Sends a transaction using the provided client, arguments, optional overrides, and context.
25
+ * This sends a UO and then waits for it to be mined
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { createSmartAccountClient } from "@aa-sdk/core";
30
+ *
31
+ * // smart account client is already extended with sendTransaction
32
+ * const client = createSmartAccountClient(...);
33
+ * const result = await client.sendTransaction({
34
+ * to: "0x...",
35
+ * data: "0x...", // or "0x",
36
+ * value: 0n, // optional
37
+ * account, // only required if the client above is not connected to an account
38
+ * });
39
+ * ```
40
+ *
41
+ * @param {Client<Transport, TChain, TAccount>} client The client to send the transaction through
42
+ * @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction
43
+ * @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation
44
+ * @param {UserOperationContext} [context] Optional context for the user operation
45
+ * @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash
46
+ */
23
47
  export async function sendTransaction<
24
48
  TChain extends Chain | undefined = Chain | undefined,
25
49
  TAccount extends SmartContractAccount | undefined =
@@ -9,6 +9,29 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
9
9
  import type { SendTransactionsParameters, UserOperationContext } from "./types";
10
10
  import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
11
11
 
12
+ /**
13
+ * 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.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { createSmartAccountClient } from "@aa-sdk/core";
18
+ *
19
+ * // smart account client is already extended with sendTransactions
20
+ * const client = createSmartAccountClient(...);
21
+ * const result = await client.sendTransactions({
22
+ * requests: [{
23
+ * to: "0x...",
24
+ * data: "0x...", // or "0x",
25
+ * value: 0n, // optional
26
+ * }],
27
+ * account, // only required if the client above is not connected to an account
28
+ * });
29
+ * ```
30
+ *
31
+ * @param {Client<TTransport, TChain, TAccount>} client The client used to send the transactions
32
+ * @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context
33
+ * @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions
34
+ */
12
35
  export async function sendTransactions<
13
36
  TTransport extends Transport = Transport,
14
37
  TChain extends Chain | undefined = Chain | undefined,
@@ -6,6 +6,30 @@ import { FailedToFindTransactionError } from "../../errors/transaction.js";
6
6
  import { Logger } from "../../logger.js";
7
7
  import type { WaitForUserOperationTxParameters } from "./types.js";
8
8
 
9
+ /**
10
+ * 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.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createSmartAccountClient } from "@aa-sdk/core";
15
+ *
16
+ * // smart account client is already extended with waitForUserOperationTransaction
17
+ * const client = createSmartAccountClient(...);
18
+ * const result = await client.waitForUserOperationTransaction({
19
+ * hash: "0x...",
20
+ * retries: {...} // optional param to configure the retry amounts
21
+ * });
22
+ * ```
23
+ *
24
+ * @param {Client<TTransport, TChain, any>} client The client instance used to interact with the blockchain
25
+ * @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for
26
+ * @param {Hex} args.hash The transaction hash to wait for
27
+ * @param {WaitForUserOperationTxParameters["retries"]} [args.retries] Optional retry parameters
28
+ * @param {number} [args.retries.maxRetries] The maximum number of retry attempts
29
+ * @param {number} [args.retries.intervalMs] The interval in milliseconds between retries
30
+ * @param {number} [args.retries.multiplier] The multiplier for the interval between retries
31
+ * @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed
32
+ */
9
33
  export const waitForUserOperationTransaction: <
10
34
  TTransport extends Transport = Transport,
11
35
  TChain extends Chain | undefined = Chain | undefined
@@ -29,6 +29,21 @@ export type BundlerClient<T extends Transport = Transport> = Client<
29
29
  PublicActions<T, Chain> & BundlerActions
30
30
  >;
31
31
 
32
+ /**
33
+ * Creates a bundler client from an existing public client with the provided transport and chain.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { createPublicClient } from "viem";
38
+ * import { createBundlerClientFromExisting } from "@aa-sdk/core";
39
+ *
40
+ * const publicClient = createPublicClient(...);
41
+ * const bundlerClient = createBundlerClientFromExisting(publicClient);
42
+ * ```
43
+ *
44
+ * @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions
45
+ * @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client
46
+ */
32
47
  export const createBundlerClientFromExisting: <
33
48
  T extends Transport | FallbackTransport = Transport
34
49
  >(
@@ -50,6 +65,23 @@ export function createBundlerClient<TTransport extends Transport>(
50
65
  args: PublicClientConfig<TTransport, Chain> & { type?: string }
51
66
  ): BundlerClient<TTransport>;
52
67
 
68
+ /**
69
+ * Creates a Bundler Client using the provided configuration parameters, including chain and optional type.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { createBundlerClient } from "@aa-sdk/core";
74
+ * import { sepolia } from "viem/chains";
75
+ *
76
+ * const client = createBundlerClient({
77
+ * chain: sepolia,
78
+ * transport: http("RPC_URL"),
79
+ * });
80
+ * ```
81
+ *
82
+ * @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type
83
+ * @returns {BundlerClient} The created Bundler Client with extended public and bundler actions
84
+ */
53
85
  export function createBundlerClient(
54
86
  args: PublicClientConfig & { type?: string }
55
87
  ): BundlerClient {
@@ -107,6 +107,15 @@ export type BundlerActions = {
107
107
  };
108
108
  // [!endregion BundlerActions]
109
109
 
110
+ /**
111
+ * A viem client decorator that provides Bundler specific actions.
112
+ * 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.
113
+ *
114
+ * NOTE: this is already added to the client returned from `createBundlerClient`
115
+ *
116
+ * @param {TClient} client The client instance that will be used to perform bundler actions
117
+ * @returns {BundlerActions} An object containing various bundler-related actions that can be executed using the provided client
118
+ */
110
119
  export const bundlerActions: <
111
120
  TClient extends Client<
112
121
  Transport,
@@ -133,6 +133,14 @@ export type BaseSmartAccountClientActions<
133
133
  });
134
134
  // #endregion SmartAccountClientActions
135
135
 
136
+ /**
137
+ * 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.
138
+ *
139
+ * NOTE: this is already added to clients returned from `createSmartAccountClient`
140
+ *
141
+ * @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to
142
+ * @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions
143
+ */
136
144
  export const smartAccountClientActions: <
137
145
  TTransport extends Transport = Transport,
138
146
  TChain extends Chain | undefined = Chain | undefined,