@alchemy/smart-accounts 0.0.0-alpha.0

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 (422) hide show
  1. package/LICENSE +21 -0
  2. package/dist/esm/errors/EntityIdOverrideError.d.ts +11 -0
  3. package/dist/esm/errors/EntityIdOverrideError.js +19 -0
  4. package/dist/esm/errors/EntityIdOverrideError.js.map +1 -0
  5. package/dist/esm/errors/InvalidDeferredActionNonceError.d.ts +11 -0
  6. package/dist/esm/errors/InvalidDeferredActionNonceError.js +19 -0
  7. package/dist/esm/errors/InvalidDeferredActionNonceError.js.map +1 -0
  8. package/dist/esm/errors/InvalidEntityIdError.d.ts +13 -0
  9. package/dist/esm/errors/InvalidEntityIdError.js +21 -0
  10. package/dist/esm/errors/InvalidEntityIdError.js.map +1 -0
  11. package/dist/esm/errors/InvalidNonceKeyError.d.ts +13 -0
  12. package/dist/esm/errors/InvalidNonceKeyError.js +21 -0
  13. package/dist/esm/errors/InvalidNonceKeyError.js.map +1 -0
  14. package/dist/esm/errors/InvalidOwnerError.d.ts +13 -0
  15. package/dist/esm/errors/InvalidOwnerError.js +21 -0
  16. package/dist/esm/errors/InvalidOwnerError.js.map +1 -0
  17. package/dist/esm/errors/permissionBuilderErrors.d.ts +150 -0
  18. package/dist/esm/errors/permissionBuilderErrors.js +233 -0
  19. package/dist/esm/errors/permissionBuilderErrors.js.map +1 -0
  20. package/dist/esm/index.d.ts +59 -0
  21. package/dist/esm/index.js +40 -0
  22. package/dist/esm/index.js.map +1 -0
  23. package/dist/esm/light-account/abis/LightAccountAbi_v1.d.ts +532 -0
  24. package/dist/esm/light-account/abis/LightAccountAbi_v1.js +379 -0
  25. package/dist/esm/light-account/abis/LightAccountAbi_v1.js.map +1 -0
  26. package/dist/esm/light-account/abis/LightAccountAbi_v2.d.ts +491 -0
  27. package/dist/esm/light-account/abis/LightAccountAbi_v2.js +355 -0
  28. package/dist/esm/light-account/abis/LightAccountAbi_v2.js.map +1 -0
  29. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.d.ts +55 -0
  30. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.js +75 -0
  31. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v1.js.map +1 -0
  32. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.d.ts +256 -0
  33. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.js +210 -0
  34. package/dist/esm/light-account/abis/LightAccountFactoryAbi_v2.js.map +1 -0
  35. package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.d.ts +507 -0
  36. package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.js +372 -0
  37. package/dist/esm/light-account/abis/MultiOwnerLightAccountAbi.js.map +1 -0
  38. package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts +286 -0
  39. package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.js +229 -0
  40. package/dist/esm/light-account/abis/MultiOwnerLightAccountFactoryAbi.js.map +1 -0
  41. package/dist/esm/light-account/abis/OZ_ERC1967Proxy.d.ts +13 -0
  42. package/dist/esm/light-account/abis/OZ_ERC1967Proxy.js +20 -0
  43. package/dist/esm/light-account/abis/OZ_ERC1967Proxy.js.map +1 -0
  44. package/dist/esm/light-account/accounts/account.d.ts +22 -0
  45. package/dist/esm/light-account/accounts/account.js +86 -0
  46. package/dist/esm/light-account/accounts/account.js.map +1 -0
  47. package/dist/esm/light-account/accounts/base.d.ts +28 -0
  48. package/dist/esm/light-account/accounts/base.js +170 -0
  49. package/dist/esm/light-account/accounts/base.js.map +1 -0
  50. package/dist/esm/light-account/accounts/calldataCodec.d.ts +3 -0
  51. package/dist/esm/light-account/accounts/calldataCodec.js +74 -0
  52. package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -0
  53. package/dist/esm/light-account/accounts/multi-owner-account.d.ts +20 -0
  54. package/dist/esm/light-account/accounts/multi-owner-account.js +79 -0
  55. package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -0
  56. package/dist/esm/light-account/decorators/multiOwner.d.ts +17 -0
  57. package/dist/esm/light-account/decorators/multiOwner.js +38 -0
  58. package/dist/esm/light-account/decorators/multiOwner.js.map +1 -0
  59. package/dist/esm/light-account/decorators/singleOwner.d.ts +16 -0
  60. package/dist/esm/light-account/decorators/singleOwner.js +35 -0
  61. package/dist/esm/light-account/decorators/singleOwner.js.map +1 -0
  62. package/dist/esm/light-account/lightAccountStaticImpl.d.ts +24 -0
  63. package/dist/esm/light-account/lightAccountStaticImpl.js +112 -0
  64. package/dist/esm/light-account/lightAccountStaticImpl.js.map +1 -0
  65. package/dist/esm/light-account/predictAddress.d.ts +35 -0
  66. package/dist/esm/light-account/predictAddress.js +113 -0
  67. package/dist/esm/light-account/predictAddress.js.map +1 -0
  68. package/dist/esm/light-account/registry.d.ts +7115 -0
  69. package/dist/esm/light-account/registry.js +18 -0
  70. package/dist/esm/light-account/registry.js.map +1 -0
  71. package/dist/esm/light-account/utils.d.ts +1454 -0
  72. package/dist/esm/light-account/utils.js +65 -0
  73. package/dist/esm/light-account/utils.js.map +1 -0
  74. package/dist/esm/logger.d.ts +2 -0
  75. package/dist/esm/logger.js +8 -0
  76. package/dist/esm/logger.js.map +1 -0
  77. package/dist/esm/ma-v1/abis/IStandardExecutor.d.ts +50 -0
  78. package/dist/esm/ma-v1/abis/IStandardExecutor.js +32 -0
  79. package/dist/esm/ma-v1/abis/IStandardExecutor.js.map +1 -0
  80. package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts +234 -0
  81. package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.js +191 -0
  82. package/dist/esm/ma-v1/abis/MultiOwnerModularAccountFactory.js.map +1 -0
  83. package/dist/esm/ma-v1/abis/MultiOwnerPlugin.d.ts +698 -0
  84. package/dist/esm/ma-v1/abis/MultiOwnerPlugin.js +529 -0
  85. package/dist/esm/ma-v1/abis/MultiOwnerPlugin.js.map +1 -0
  86. package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts +67 -0
  87. package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.js +38 -0
  88. package/dist/esm/ma-v1/abis/MultiOwnerPluginExecutionFunction.js.map +1 -0
  89. package/dist/esm/ma-v1/abis/UpgradeableModularAccount.d.ts +880 -0
  90. package/dist/esm/ma-v1/abis/UpgradeableModularAccount.js +646 -0
  91. package/dist/esm/ma-v1/abis/UpgradeableModularAccount.js.map +1 -0
  92. package/dist/esm/ma-v1/account.d.ts +16 -0
  93. package/dist/esm/ma-v1/account.js +17 -0
  94. package/dist/esm/ma-v1/account.js.map +1 -0
  95. package/dist/esm/ma-v1/accounts/base.d.ts +29 -0
  96. package/dist/esm/ma-v1/accounts/base.js +150 -0
  97. package/dist/esm/ma-v1/accounts/base.js.map +1 -0
  98. package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +22 -0
  99. package/dist/esm/ma-v1/accounts/multi-owner-account.js +101 -0
  100. package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -0
  101. package/dist/esm/ma-v1/decorators/multiOwner.d.ts +17 -0
  102. package/dist/esm/ma-v1/decorators/multiOwner.js +38 -0
  103. package/dist/esm/ma-v1/decorators/multiOwner.js.map +1 -0
  104. package/dist/esm/ma-v1/mav1StaticImpl.d.ts +15 -0
  105. package/dist/esm/ma-v1/mav1StaticImpl.js +38 -0
  106. package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -0
  107. package/dist/esm/ma-v1/predictAddress.d.ts +28 -0
  108. package/dist/esm/ma-v1/predictAddress.js +51 -0
  109. package/dist/esm/ma-v1/predictAddress.js.map +1 -0
  110. package/dist/esm/ma-v2/abis/accountFactoryAbi.d.ts +348 -0
  111. package/dist/esm/ma-v2/abis/accountFactoryAbi.js +645 -0
  112. package/dist/esm/ma-v2/abis/accountFactoryAbi.js.map +1 -0
  113. package/dist/esm/ma-v2/abis/entityIdAndNonceReader.d.ts +9 -0
  114. package/dist/esm/ma-v2/abis/entityIdAndNonceReader.js +24 -0
  115. package/dist/esm/ma-v2/abis/entityIdAndNonceReader.js.map +1 -0
  116. package/dist/esm/ma-v2/abis/modularAccountAbi.d.ts +954 -0
  117. package/dist/esm/ma-v2/abis/modularAccountAbi.js +1242 -0
  118. package/dist/esm/ma-v2/abis/modularAccountAbi.js.map +1 -0
  119. package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +991 -0
  120. package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.js +1289 -0
  121. package/dist/esm/ma-v2/abis/semiModularAccountBytecodeAbi.js.map +1 -0
  122. package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1001 -0
  123. package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.js +1302 -0
  124. package/dist/esm/ma-v2/abis/semiModularAccountStorageAbi.js.map +1 -0
  125. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.d.ts +330 -0
  126. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js +260 -0
  127. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js.map +1 -0
  128. package/dist/esm/ma-v2/accounts/account.d.ts +32 -0
  129. package/dist/esm/ma-v2/accounts/account.js +134 -0
  130. package/dist/esm/ma-v2/accounts/account.js.map +1 -0
  131. package/dist/esm/ma-v2/accounts/base.d.ts +40 -0
  132. package/dist/esm/ma-v2/accounts/base.js +371 -0
  133. package/dist/esm/ma-v2/accounts/base.js.map +1 -0
  134. package/dist/esm/ma-v2/decorators/deferralActions.d.ts +51 -0
  135. package/dist/esm/ma-v2/decorators/deferralActions.js +100 -0
  136. package/dist/esm/ma-v2/decorators/deferralActions.js.map +1 -0
  137. package/dist/esm/ma-v2/decorators/installValidation.d.ts +71 -0
  138. package/dist/esm/ma-v2/decorators/installValidation.js +137 -0
  139. package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -0
  140. package/dist/esm/ma-v2/mav2StaticImpl.d.ts +37 -0
  141. package/dist/esm/ma-v2/mav2StaticImpl.js +88 -0
  142. package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -0
  143. package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +556 -0
  144. package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js +716 -0
  145. package/dist/esm/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js.map +1 -0
  146. package/dist/esm/ma-v2/modules/allowlist-module/module.d.ts +593 -0
  147. package/dist/esm/ma-v2/modules/allowlist-module/module.js +70 -0
  148. package/dist/esm/ma-v2/modules/allowlist-module/module.js.map +1 -0
  149. package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +312 -0
  150. package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js +404 -0
  151. package/dist/esm/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js.map +1 -0
  152. package/dist/esm/ma-v2/modules/native-token-limit-module/module.d.ts +322 -0
  153. package/dist/esm/ma-v2/modules/native-token-limit-module/module.js +14 -0
  154. package/dist/esm/ma-v2/modules/native-token-limit-module/module.js.map +1 -0
  155. package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +186 -0
  156. package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js +242 -0
  157. package/dist/esm/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js.map +1 -0
  158. package/dist/esm/ma-v2/modules/paymaster-guard-module/module.d.ts +196 -0
  159. package/dist/esm/ma-v2/modules/paymaster-guard-module/module.js +25 -0
  160. package/dist/esm/ma-v2/modules/paymaster-guard-module/module.js.map +1 -0
  161. package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +45 -0
  162. package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js +331 -0
  163. package/dist/esm/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js.map +1 -0
  164. package/dist/esm/ma-v2/modules/single-signer-validation/module.d.ts +10 -0
  165. package/dist/esm/ma-v2/modules/single-signer-validation/module.js +16 -0
  166. package/dist/esm/ma-v2/modules/single-signer-validation/module.js.map +1 -0
  167. package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +229 -0
  168. package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js +296 -0
  169. package/dist/esm/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js.map +1 -0
  170. package/dist/esm/ma-v2/modules/time-range-module/module.d.ts +254 -0
  171. package/dist/esm/ma-v2/modules/time-range-module/module.js +62 -0
  172. package/dist/esm/ma-v2/modules/time-range-module/module.js.map +1 -0
  173. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +287 -0
  174. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +374 -0
  175. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +1 -0
  176. package/dist/esm/ma-v2/modules/webauthn-validation/module.d.ts +11 -0
  177. package/dist/esm/ma-v2/modules/webauthn-validation/module.js +16 -0
  178. package/dist/esm/ma-v2/modules/webauthn-validation/module.js.map +1 -0
  179. package/dist/esm/ma-v2/permissionBuilder.d.ts +158 -0
  180. package/dist/esm/ma-v2/permissionBuilder.js +557 -0
  181. package/dist/esm/ma-v2/permissionBuilder.js.map +1 -0
  182. package/dist/esm/ma-v2/predictAddress.d.ts +37 -0
  183. package/dist/esm/ma-v2/predictAddress.js +73 -0
  184. package/dist/esm/ma-v2/predictAddress.js.map +1 -0
  185. package/dist/esm/ma-v2/types.d.ts +57 -0
  186. package/dist/esm/ma-v2/types.js +9 -0
  187. package/dist/esm/ma-v2/types.js.map +1 -0
  188. package/dist/esm/ma-v2/utils/account.d.ts +85 -0
  189. package/dist/esm/ma-v2/utils/account.js +96 -0
  190. package/dist/esm/ma-v2/utils/account.js.map +1 -0
  191. package/dist/esm/ma-v2/utils/deferredActions.d.ts +29 -0
  192. package/dist/esm/ma-v2/utils/deferredActions.js +38 -0
  193. package/dist/esm/ma-v2/utils/deferredActions.js.map +1 -0
  194. package/dist/esm/ma-v2/utils/hooks.d.ts +55 -0
  195. package/dist/esm/ma-v2/utils/hooks.js +78 -0
  196. package/dist/esm/ma-v2/utils/hooks.js.map +1 -0
  197. package/dist/esm/ma-v2/utils/signature.d.ts +63 -0
  198. package/dist/esm/ma-v2/utils/signature.js +84 -0
  199. package/dist/esm/ma-v2/utils/signature.js.map +1 -0
  200. package/dist/esm/test-utils/getAccountAddressViaEntryPoint.d.ts +18 -0
  201. package/dist/esm/test-utils/getAccountAddressViaEntryPoint.js +31 -0
  202. package/dist/esm/test-utils/getAccountAddressViaEntryPoint.js.map +1 -0
  203. package/dist/esm/types.d.ts +30 -0
  204. package/dist/esm/types.js +2 -0
  205. package/dist/esm/types.js.map +1 -0
  206. package/dist/esm/utils.d.ts +6 -0
  207. package/dist/esm/utils.js +52 -0
  208. package/dist/esm/utils.js.map +1 -0
  209. package/dist/esm/version.d.ts +1 -0
  210. package/dist/esm/version.js +4 -0
  211. package/dist/esm/version.js.map +1 -0
  212. package/dist/types/errors/EntityIdOverrideError.d.ts +12 -0
  213. package/dist/types/errors/EntityIdOverrideError.d.ts.map +1 -0
  214. package/dist/types/errors/InvalidDeferredActionNonceError.d.ts +12 -0
  215. package/dist/types/errors/InvalidDeferredActionNonceError.d.ts.map +1 -0
  216. package/dist/types/errors/InvalidEntityIdError.d.ts +14 -0
  217. package/dist/types/errors/InvalidEntityIdError.d.ts.map +1 -0
  218. package/dist/types/errors/InvalidNonceKeyError.d.ts +14 -0
  219. package/dist/types/errors/InvalidNonceKeyError.d.ts.map +1 -0
  220. package/dist/types/errors/InvalidOwnerError.d.ts +14 -0
  221. package/dist/types/errors/InvalidOwnerError.d.ts.map +1 -0
  222. package/dist/types/errors/permissionBuilderErrors.d.ts +151 -0
  223. package/dist/types/errors/permissionBuilderErrors.d.ts.map +1 -0
  224. package/dist/types/index.d.ts +60 -0
  225. package/dist/types/index.d.ts.map +1 -0
  226. package/dist/types/light-account/abis/LightAccountAbi_v1.d.ts +533 -0
  227. package/dist/types/light-account/abis/LightAccountAbi_v1.d.ts.map +1 -0
  228. package/dist/types/light-account/abis/LightAccountAbi_v2.d.ts +492 -0
  229. package/dist/types/light-account/abis/LightAccountAbi_v2.d.ts.map +1 -0
  230. package/dist/types/light-account/abis/LightAccountFactoryAbi_v1.d.ts +56 -0
  231. package/dist/types/light-account/abis/LightAccountFactoryAbi_v1.d.ts.map +1 -0
  232. package/dist/types/light-account/abis/LightAccountFactoryAbi_v2.d.ts +257 -0
  233. package/dist/types/light-account/abis/LightAccountFactoryAbi_v2.d.ts.map +1 -0
  234. package/dist/types/light-account/abis/MultiOwnerLightAccountAbi.d.ts +508 -0
  235. package/dist/types/light-account/abis/MultiOwnerLightAccountAbi.d.ts.map +1 -0
  236. package/dist/types/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts +287 -0
  237. package/dist/types/light-account/abis/MultiOwnerLightAccountFactoryAbi.d.ts.map +1 -0
  238. package/dist/types/light-account/abis/OZ_ERC1967Proxy.d.ts +14 -0
  239. package/dist/types/light-account/abis/OZ_ERC1967Proxy.d.ts.map +1 -0
  240. package/dist/types/light-account/accounts/account.d.ts +23 -0
  241. package/dist/types/light-account/accounts/account.d.ts.map +1 -0
  242. package/dist/types/light-account/accounts/base.d.ts +29 -0
  243. package/dist/types/light-account/accounts/base.d.ts.map +1 -0
  244. package/dist/types/light-account/accounts/calldataCodec.d.ts +4 -0
  245. package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -0
  246. package/dist/types/light-account/accounts/multi-owner-account.d.ts +21 -0
  247. package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -0
  248. package/dist/types/light-account/decorators/multiOwner.d.ts +18 -0
  249. package/dist/types/light-account/decorators/multiOwner.d.ts.map +1 -0
  250. package/dist/types/light-account/decorators/singleOwner.d.ts +17 -0
  251. package/dist/types/light-account/decorators/singleOwner.d.ts.map +1 -0
  252. package/dist/types/light-account/lightAccountStaticImpl.d.ts +25 -0
  253. package/dist/types/light-account/lightAccountStaticImpl.d.ts.map +1 -0
  254. package/dist/types/light-account/predictAddress.d.ts +36 -0
  255. package/dist/types/light-account/predictAddress.d.ts.map +1 -0
  256. package/dist/types/light-account/registry.d.ts +7116 -0
  257. package/dist/types/light-account/registry.d.ts.map +1 -0
  258. package/dist/types/light-account/utils.d.ts +1455 -0
  259. package/dist/types/light-account/utils.d.ts.map +1 -0
  260. package/dist/types/logger.d.ts +3 -0
  261. package/dist/types/logger.d.ts.map +1 -0
  262. package/dist/types/ma-v1/abis/IStandardExecutor.d.ts +51 -0
  263. package/dist/types/ma-v1/abis/IStandardExecutor.d.ts.map +1 -0
  264. package/dist/types/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts +235 -0
  265. package/dist/types/ma-v1/abis/MultiOwnerModularAccountFactory.d.ts.map +1 -0
  266. package/dist/types/ma-v1/abis/MultiOwnerPlugin.d.ts +699 -0
  267. package/dist/types/ma-v1/abis/MultiOwnerPlugin.d.ts.map +1 -0
  268. package/dist/types/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts +68 -0
  269. package/dist/types/ma-v1/abis/MultiOwnerPluginExecutionFunction.d.ts.map +1 -0
  270. package/dist/types/ma-v1/abis/UpgradeableModularAccount.d.ts +881 -0
  271. package/dist/types/ma-v1/abis/UpgradeableModularAccount.d.ts.map +1 -0
  272. package/dist/types/ma-v1/account.d.ts +17 -0
  273. package/dist/types/ma-v1/account.d.ts.map +1 -0
  274. package/dist/types/ma-v1/accounts/base.d.ts +30 -0
  275. package/dist/types/ma-v1/accounts/base.d.ts.map +1 -0
  276. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +23 -0
  277. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -0
  278. package/dist/types/ma-v1/decorators/multiOwner.d.ts +18 -0
  279. package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +1 -0
  280. package/dist/types/ma-v1/mav1StaticImpl.d.ts +16 -0
  281. package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -0
  282. package/dist/types/ma-v1/predictAddress.d.ts +29 -0
  283. package/dist/types/ma-v1/predictAddress.d.ts.map +1 -0
  284. package/dist/types/ma-v2/abis/accountFactoryAbi.d.ts +349 -0
  285. package/dist/types/ma-v2/abis/accountFactoryAbi.d.ts.map +1 -0
  286. package/dist/types/ma-v2/abis/entityIdAndNonceReader.d.ts +10 -0
  287. package/dist/types/ma-v2/abis/entityIdAndNonceReader.d.ts.map +1 -0
  288. package/dist/types/ma-v2/abis/modularAccountAbi.d.ts +955 -0
  289. package/dist/types/ma-v2/abis/modularAccountAbi.d.ts.map +1 -0
  290. package/dist/types/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +992 -0
  291. package/dist/types/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts.map +1 -0
  292. package/dist/types/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1002 -0
  293. package/dist/types/ma-v2/abis/semiModularAccountStorageAbi.d.ts.map +1 -0
  294. package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts +331 -0
  295. package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts.map +1 -0
  296. package/dist/types/ma-v2/accounts/account.d.ts +33 -0
  297. package/dist/types/ma-v2/accounts/account.d.ts.map +1 -0
  298. package/dist/types/ma-v2/accounts/base.d.ts +41 -0
  299. package/dist/types/ma-v2/accounts/base.d.ts.map +1 -0
  300. package/dist/types/ma-v2/decorators/deferralActions.d.ts +52 -0
  301. package/dist/types/ma-v2/decorators/deferralActions.d.ts.map +1 -0
  302. package/dist/types/ma-v2/decorators/installValidation.d.ts +72 -0
  303. package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -0
  304. package/dist/types/ma-v2/mav2StaticImpl.d.ts +38 -0
  305. package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -0
  306. package/dist/types/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +557 -0
  307. package/dist/types/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts.map +1 -0
  308. package/dist/types/ma-v2/modules/allowlist-module/module.d.ts +594 -0
  309. package/dist/types/ma-v2/modules/allowlist-module/module.d.ts.map +1 -0
  310. package/dist/types/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +313 -0
  311. package/dist/types/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts.map +1 -0
  312. package/dist/types/ma-v2/modules/native-token-limit-module/module.d.ts +323 -0
  313. package/dist/types/ma-v2/modules/native-token-limit-module/module.d.ts.map +1 -0
  314. package/dist/types/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +187 -0
  315. package/dist/types/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts.map +1 -0
  316. package/dist/types/ma-v2/modules/paymaster-guard-module/module.d.ts +197 -0
  317. package/dist/types/ma-v2/modules/paymaster-guard-module/module.d.ts.map +1 -0
  318. package/dist/types/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +46 -0
  319. package/dist/types/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts.map +1 -0
  320. package/dist/types/ma-v2/modules/single-signer-validation/module.d.ts +11 -0
  321. package/dist/types/ma-v2/modules/single-signer-validation/module.d.ts.map +1 -0
  322. package/dist/types/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +230 -0
  323. package/dist/types/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts.map +1 -0
  324. package/dist/types/ma-v2/modules/time-range-module/module.d.ts +255 -0
  325. package/dist/types/ma-v2/modules/time-range-module/module.d.ts.map +1 -0
  326. package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +288 -0
  327. package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +1 -0
  328. package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts +12 -0
  329. package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts.map +1 -0
  330. package/dist/types/ma-v2/permissionBuilder.d.ts +159 -0
  331. package/dist/types/ma-v2/permissionBuilder.d.ts.map +1 -0
  332. package/dist/types/ma-v2/predictAddress.d.ts +38 -0
  333. package/dist/types/ma-v2/predictAddress.d.ts.map +1 -0
  334. package/dist/types/ma-v2/types.d.ts +58 -0
  335. package/dist/types/ma-v2/types.d.ts.map +1 -0
  336. package/dist/types/ma-v2/utils/account.d.ts +86 -0
  337. package/dist/types/ma-v2/utils/account.d.ts.map +1 -0
  338. package/dist/types/ma-v2/utils/deferredActions.d.ts +30 -0
  339. package/dist/types/ma-v2/utils/deferredActions.d.ts.map +1 -0
  340. package/dist/types/ma-v2/utils/hooks.d.ts +56 -0
  341. package/dist/types/ma-v2/utils/hooks.d.ts.map +1 -0
  342. package/dist/types/ma-v2/utils/signature.d.ts +64 -0
  343. package/dist/types/ma-v2/utils/signature.d.ts.map +1 -0
  344. package/dist/types/test-utils/getAccountAddressViaEntryPoint.d.ts +19 -0
  345. package/dist/types/test-utils/getAccountAddressViaEntryPoint.d.ts.map +1 -0
  346. package/dist/types/types.d.ts +31 -0
  347. package/dist/types/types.d.ts.map +1 -0
  348. package/dist/types/utils.d.ts +7 -0
  349. package/dist/types/utils.d.ts.map +1 -0
  350. package/dist/types/version.d.ts +2 -0
  351. package/dist/types/version.d.ts.map +1 -0
  352. package/package.json +63 -0
  353. package/src/errors/EntityIdOverrideError.ts +15 -0
  354. package/src/errors/InvalidDeferredActionNonceError.ts +15 -0
  355. package/src/errors/InvalidEntityIdError.ts +19 -0
  356. package/src/errors/InvalidNonceKeyError.ts +19 -0
  357. package/src/errors/InvalidOwnerError.ts +17 -0
  358. package/src/errors/permissionBuilderErrors.ts +212 -0
  359. package/src/index.ts +152 -0
  360. package/src/light-account/abis/LightAccountAbi_v1.ts +378 -0
  361. package/src/light-account/abis/LightAccountAbi_v2.ts +354 -0
  362. package/src/light-account/abis/LightAccountFactoryAbi_v1.ts +74 -0
  363. package/src/light-account/abis/LightAccountFactoryAbi_v2.ts +209 -0
  364. package/src/light-account/abis/MultiOwnerLightAccountAbi.ts +371 -0
  365. package/src/light-account/abis/MultiOwnerLightAccountFactoryAbi.ts +228 -0
  366. package/src/light-account/abis/OZ_ERC1967Proxy.ts +19 -0
  367. package/src/light-account/accounts/account.ts +154 -0
  368. package/src/light-account/accounts/base.ts +340 -0
  369. package/src/light-account/accounts/calldataCodec.ts +101 -0
  370. package/src/light-account/accounts/multi-owner-account.ts +138 -0
  371. package/src/light-account/decorators/multiOwner.ts +69 -0
  372. package/src/light-account/decorators/singleOwner.ts +61 -0
  373. package/src/light-account/lightAccountStaticImpl.ts +172 -0
  374. package/src/light-account/predictAddress.ts +174 -0
  375. package/src/light-account/registry.ts +72 -0
  376. package/src/light-account/utils.ts +95 -0
  377. package/src/logger.ts +9 -0
  378. package/src/ma-v1/abis/IStandardExecutor.ts +31 -0
  379. package/src/ma-v1/abis/MultiOwnerModularAccountFactory.ts +190 -0
  380. package/src/ma-v1/abis/MultiOwnerPlugin.ts +528 -0
  381. package/src/ma-v1/abis/MultiOwnerPluginExecutionFunction.ts +37 -0
  382. package/src/ma-v1/abis/UpgradeableModularAccount.ts +645 -0
  383. package/src/ma-v1/account.ts +19 -0
  384. package/src/ma-v1/accounts/base.ts +245 -0
  385. package/src/ma-v1/accounts/multi-owner-account.ts +162 -0
  386. package/src/ma-v1/decorators/multiOwner.ts +69 -0
  387. package/src/ma-v1/mav1StaticImpl.ts +53 -0
  388. package/src/ma-v1/predictAddress.ts +85 -0
  389. package/src/ma-v2/abis/accountFactoryAbi.ts +644 -0
  390. package/src/ma-v2/abis/entityIdAndNonceReader.ts +23 -0
  391. package/src/ma-v2/abis/modularAccountAbi.ts +1241 -0
  392. package/src/ma-v2/abis/semiModularAccountBytecodeAbi.ts +1288 -0
  393. package/src/ma-v2/abis/semiModularAccountStorageAbi.ts +1301 -0
  394. package/src/ma-v2/abis/webAuthnFactoryAbi.ts +259 -0
  395. package/src/ma-v2/accounts/account.ts +211 -0
  396. package/src/ma-v2/accounts/base.ts +569 -0
  397. package/src/ma-v2/decorators/deferralActions.ts +193 -0
  398. package/src/ma-v2/decorators/installValidation.ts +257 -0
  399. package/src/ma-v2/mav2StaticImpl.ts +134 -0
  400. package/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.ts +715 -0
  401. package/src/ma-v2/modules/allowlist-module/module.ts +116 -0
  402. package/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.ts +403 -0
  403. package/src/ma-v2/modules/native-token-limit-module/module.ts +21 -0
  404. package/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.ts +241 -0
  405. package/src/ma-v2/modules/paymaster-guard-module/module.ts +35 -0
  406. package/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.ts +330 -0
  407. package/src/ma-v2/modules/single-signer-validation/module.ts +24 -0
  408. package/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.ts +295 -0
  409. package/src/ma-v2/modules/time-range-module/module.ts +96 -0
  410. package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +373 -0
  411. package/src/ma-v2/modules/webauthn-validation/module.ts +28 -0
  412. package/src/ma-v2/permissionBuilder.ts +761 -0
  413. package/src/ma-v2/predictAddress.ts +149 -0
  414. package/src/ma-v2/types.ts +73 -0
  415. package/src/ma-v2/utils/account.ts +137 -0
  416. package/src/ma-v2/utils/deferredActions.ts +66 -0
  417. package/src/ma-v2/utils/hooks.ts +79 -0
  418. package/src/ma-v2/utils/signature.ts +129 -0
  419. package/src/test-utils/getAccountAddressViaEntryPoint.ts +43 -0
  420. package/src/types.ts +58 -0
  421. package/src/utils.ts +85 -0
  422. package/src/version.ts +3 -0
@@ -0,0 +1,149 @@
1
+ import { assertNever } from "@alchemy/common";
2
+ import {
3
+ concatHex,
4
+ encodePacked,
5
+ getContractAddress,
6
+ keccak256,
7
+ type Address,
8
+ type Hex,
9
+ } from "viem";
10
+ import { parsePublicKey } from "webauthn-p256";
11
+
12
+ export type PredictModularAccountV2AddressParams = {
13
+ factoryAddress: Address;
14
+ implementationAddress: Address; // Should be the implementation address of the account type you are predicting the address for.
15
+ salt: bigint;
16
+ } & (
17
+ | {
18
+ type: "MA";
19
+ ownerAddress: Address;
20
+ entityId: number;
21
+ }
22
+ | {
23
+ type: "SMA";
24
+ ownerAddress: Address;
25
+ }
26
+ | {
27
+ type: "WebAuthn";
28
+ ownerPublicKey: Hex;
29
+ entityId: number;
30
+ }
31
+ );
32
+
33
+ /**
34
+ * Predicts the address of a modular account V2 based on the provided parameters, which include factory address, salt, and implementation address. This function supports different types of accounts including "SMA", "MA", and "WebAuthn".
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { predictModularAccountV2Address } from "@alchemy/smart-accounts";
39
+ *
40
+ * const accountAddress = predictModularAccountV2Address({
41
+ * factoryAddress: "0xFactoryAddress" as Address,
42
+ * implementationAddress: "0xImplementation" as Address,
43
+ * salt: 0n,
44
+ * type: "SMA",
45
+ * ownerAddress: "0xOwner" as Address,
46
+ * });
47
+ * ```
48
+ *
49
+ * @param {PredictModularAccountV2AddressParams} params The parameters for predicting the modular account address, including `factoryAddress`, `salt`, `implementationAddress`, and additional properties based on the account type.
50
+ * @returns {Address} The predicted address for the modular account V2.
51
+ */
52
+ export function predictModularAccountV2Address(
53
+ params: PredictModularAccountV2AddressParams,
54
+ ): Address {
55
+ const { factoryAddress, salt, implementationAddress } = params;
56
+
57
+ // Note(v4): prediction for MA is currently untested, because it is not supported as an account type yet.
58
+ // Prior to using this prediction logic, ensure that the counterfactual computation is correct by updating `predictAddress.test.ts` to include a test for MA.
59
+ const { combinedSalt, initcode } = (() => {
60
+ switch (params.type) {
61
+ case "SMA":
62
+ // MAv2 factory uses max uint32 for SMA entityId
63
+ return {
64
+ combinedSalt: getCombinedSaltK1(
65
+ params.ownerAddress,
66
+ salt,
67
+ 0xffffffff,
68
+ ),
69
+ initcode: getProxyBytecodeWithImmutableArgs(
70
+ implementationAddress,
71
+ params.ownerAddress,
72
+ ),
73
+ };
74
+ case "MA":
75
+ return {
76
+ combinedSalt: getCombinedSaltK1(
77
+ params.ownerAddress,
78
+ salt,
79
+ params.entityId,
80
+ ),
81
+ initcode: getProxyBytecode(implementationAddress),
82
+ };
83
+ case "WebAuthn":
84
+ const { x, y } = parsePublicKey(params.ownerPublicKey);
85
+ return {
86
+ combinedSalt: getCombinedSaltWebAuthn(
87
+ { x, y },
88
+ salt,
89
+ params.entityId,
90
+ ),
91
+ initcode: getProxyBytecode(implementationAddress),
92
+ };
93
+ default:
94
+ return assertNever(params, "Unexpected MAv2 type");
95
+ }
96
+ })();
97
+
98
+ return getContractAddress({
99
+ from: factoryAddress,
100
+ opcode: "CREATE2",
101
+ salt: combinedSalt,
102
+ bytecode: initcode,
103
+ });
104
+ }
105
+
106
+ function getCombinedSaltK1(
107
+ ownerAddress: Address,
108
+ salt: bigint,
109
+ entityId: number,
110
+ ): Hex {
111
+ return keccak256(
112
+ encodePacked(
113
+ ["address", "uint256", "uint32"],
114
+ [ownerAddress, salt, entityId],
115
+ ),
116
+ );
117
+ }
118
+
119
+ function getCombinedSaltWebAuthn(
120
+ ownerPublicKey: { x: bigint; y: bigint },
121
+ salt: bigint,
122
+ entityId: number,
123
+ ): Hex {
124
+ return keccak256(
125
+ encodePacked(
126
+ ["uint256", "uint256", "uint256", "uint32"],
127
+ [ownerPublicKey.x, ownerPublicKey.y, salt, entityId],
128
+ ),
129
+ );
130
+ }
131
+
132
+ function getProxyBytecode(implementationAddress: Address): Hex {
133
+ return concatHex([
134
+ "0x603d3d8160223d3973",
135
+ implementationAddress,
136
+ "0x60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3",
137
+ ]);
138
+ }
139
+
140
+ function getProxyBytecodeWithImmutableArgs(
141
+ implementationAddress: Address,
142
+ immutableArgs: Hex,
143
+ ): Hex {
144
+ return `0x6100513d8160233d3973${implementationAddress.slice(
145
+ 2,
146
+ )}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3${immutableArgs.slice(
147
+ 2,
148
+ )}`;
149
+ }
@@ -0,0 +1,73 @@
1
+ import type { Address, Hex } from "viem";
2
+
3
+ export const SignaturePrefix = {
4
+ EOA: "0x00",
5
+ CONTRACT: "0x01",
6
+ } as const;
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
9
+ export type SignaturePrefix =
10
+ (typeof SignaturePrefix)[keyof typeof SignaturePrefix];
11
+
12
+ export type SignerEntity = {
13
+ isGlobalValidation: boolean;
14
+ entityId: number;
15
+ };
16
+
17
+ export type ExecutionDataView = {
18
+ module: Address;
19
+ skipRuntimeValidation: boolean;
20
+ allowGlobalValidation: boolean;
21
+ executionHooks: readonly Hex[];
22
+ };
23
+
24
+ export type ValidationDataView = {
25
+ validationHooks: readonly Hex[];
26
+ executionHooks: readonly Hex[];
27
+ selectors: readonly Hex[];
28
+ validationFlags: number;
29
+ };
30
+
31
+ export type ModuleEntity = {
32
+ moduleAddress: Address;
33
+ entityId: number;
34
+ };
35
+
36
+ export type ValidationConfig = {
37
+ moduleAddress: Address;
38
+ entityId: number; // uint32
39
+ isGlobal: boolean;
40
+ isSignatureValidation: boolean;
41
+ isUserOpValidation: boolean;
42
+ };
43
+
44
+ export const HookType = {
45
+ EXECUTION: "0x00",
46
+ VALIDATION: "0x01",
47
+ } as const;
48
+
49
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
50
+ export type HookType = (typeof HookType)[keyof typeof HookType];
51
+
52
+ export type HookConfig = {
53
+ address: Address;
54
+ entityId: number; // uint32
55
+ hookType: HookType;
56
+ hasPreHooks: boolean;
57
+ hasPostHooks: boolean;
58
+ };
59
+
60
+ // maps to type ValidationStorage in MAv2 implementation
61
+ export type ValidationData = {
62
+ isGlobal: boolean; // validation flag
63
+ isSignatureValidation: boolean; // validation flag
64
+ isUserOpValidation: boolean;
65
+ validationHooks: HookConfig[];
66
+ executionHooks: Hex[];
67
+ selectors: Hex[];
68
+ };
69
+
70
+ export type UpgradeToData = {
71
+ implAddress: Address;
72
+ initializationData: Hex;
73
+ };
@@ -0,0 +1,137 @@
1
+ import {
2
+ concatHex,
3
+ encodeFunctionData,
4
+ toHex,
5
+ type Address,
6
+ type Hex,
7
+ } from "viem";
8
+ import type { SmartAccount } from "viem/account-abstraction";
9
+ import type { GetAccountParameter } from "../../types.js";
10
+ import type { ModuleEntity, UpgradeToData } from "../types.js";
11
+ import { semiModularAccountStorageAbi } from "../abis/semiModularAccountStorageAbi.js";
12
+ import type { ModularAccountV2Base } from "../accounts/base.js";
13
+
14
+ /**
15
+ * A mapping of default addresses for the ModularAccountV2.
16
+ */
17
+ export const DefaultAddress = {
18
+ MAV2_FACTORY: "0x00000000000017c61b5bEe81050EC8eFc9c6fecd",
19
+ MAV2_FACTORY_WEBAUTHN: "0x55010E571dCf07e254994bfc88b9C1C8FAe31960",
20
+ SMAV2_BYTECODE: "0x000000000000c5A9089039570Dd36455b5C07383",
21
+ SMAV2_STORAGE: "0x0000000000006E2f9d80CaEc0Da6500f005EB25A",
22
+ SMAV2_7702: "0x69007702764179f14F51cdce752f4f775d74E139",
23
+ MAV2: "0x00000000000002377B26b1EdA7b0BC371C60DD4f",
24
+ } satisfies Record<string, Address>;
25
+
26
+ /**
27
+ * A mapping of default addresses for the ModularAccountV2 modules.
28
+ */
29
+ export const DefaultModuleAddress = {
30
+ SINGLE_SIGNER_VALIDATION: "0x00000000000099DE0BF6fA90dEB851E2A2df7d83",
31
+ WEBAUTHN_VALIDATION: "0x0000000000001D9d34E07D9834274dF9ae575217",
32
+ TIME_RANGE: "0x00000000000082B8e2012be914dFA4f62A0573eA",
33
+ PAYMASTER_GUARD: "0x0000000000001aA7A7F7E29abe0be06c72FD42A1",
34
+ NATIVE_TOKEN_LIMIT: "0x00000000000001e541f0D090868FBe24b59Fbe06",
35
+ ALLOWLIST: "0x00000000003e826473a313e600b5b9b791f5a59a",
36
+ } satisfies Record<string, Address>;
37
+
38
+ /**
39
+ * The default owner entity ID.
40
+ */
41
+ export const DEFAULT_OWNER_ENTITY_ID = 0;
42
+
43
+ /**
44
+ * The selector for the execute user operation function.
45
+ */
46
+ export const EXECUTE_USER_OP_SELECTOR: Hex = "0x8DD7712F";
47
+
48
+ export type GetMAV2UpgradeToData<
49
+ TAccount extends SmartAccount | undefined = SmartAccount | undefined,
50
+ > = GetAccountParameter<TAccount>;
51
+
52
+ /**
53
+ * Gets the upgrade to data for the ModularAccountV2.
54
+ *
55
+ * @param {Address} ownerAddress - The address of the owner.
56
+ * @returns {Promise<UpgradeToData>} The upgrade to data.
57
+ */
58
+ export async function getMAV2UpgradeToData(
59
+ ownerAddress: Address,
60
+ ): Promise<UpgradeToData> {
61
+ const initData = encodeFunctionData({
62
+ abi: semiModularAccountStorageAbi,
63
+ functionName: "initialize",
64
+ args: [ownerAddress],
65
+ });
66
+
67
+ return {
68
+ implAddress: DefaultAddress.SMAV2_STORAGE,
69
+ initializationData: initData,
70
+ // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?
71
+ // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.
72
+ };
73
+ }
74
+
75
+ export type BuildNonceParams = {
76
+ nonceKey?: bigint;
77
+ entityId?: number;
78
+ isGlobalValidation?: boolean;
79
+ isDeferredAction?: boolean;
80
+ isDirectCallValidation?: boolean;
81
+ };
82
+
83
+ /**
84
+ * Builds a full nonce key.
85
+ *
86
+ * @param {BuildNonceParams} params - The parameters for building a full nonce key.
87
+ * @returns {bigint} The full nonce key.
88
+ */
89
+ export const buildFullNonceKey = ({
90
+ nonceKey = 0n,
91
+ entityId = 0,
92
+ isGlobalValidation = true,
93
+ isDeferredAction = false,
94
+ }: BuildNonceParams): bigint => {
95
+ return (
96
+ (nonceKey << 40n) +
97
+ (BigInt(entityId) << 8n) +
98
+ (isDeferredAction ? 2n : 0n) +
99
+ (isGlobalValidation ? 1n : 0n)
100
+ );
101
+ };
102
+
103
+ /**
104
+ * Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { serializeModuleEntity } from "@alchemy/smart-accounts";
109
+ * import { Address } from "viem";
110
+ *
111
+ * const moduleAddress: Address = "0x1234";
112
+ * const entityId: number = 1234;
113
+ *
114
+ * const moduleEntityHex = serializeModuleEntity({
115
+ * moduleAddress,
116
+ * entityId
117
+ * });
118
+ * ```
119
+ *
120
+ * @param {ModuleEntity} config The module entity configuration containing the module address and entity ID
121
+ * @returns {Hex} A hexadecimal string representation of the serialized module entity
122
+ */
123
+ export function serializeModuleEntity(config: ModuleEntity): Hex {
124
+ return concatHex([config.moduleAddress, toHex(config.entityId, { size: 4 })]);
125
+ }
126
+
127
+ /**
128
+ * Checks if an account is a ModularAccountV2.
129
+ *
130
+ * @param {SmartAccount} account - The account to check.
131
+ * @returns {boolean} True if the account is a ModularAccountV2, false otherwise.
132
+ */
133
+ export function isModularAccountV2(
134
+ account: SmartAccount,
135
+ ): account is ModularAccountV2Base {
136
+ return "source" in account && account.source === "ModularAccountV2";
137
+ }
@@ -0,0 +1,66 @@
1
+ import {
2
+ concatHex,
3
+ hexToNumber,
4
+ parseErc6492Signature,
5
+ size,
6
+ toHex,
7
+ type Hex,
8
+ } from "viem";
9
+ import { SignaturePrefix } from "../types.js";
10
+
11
+ /**
12
+ * Parses out the 3 components from a deferred action.
13
+ *
14
+ * @param {Hex} deferredAction - The deferred action to parse.
15
+ * @returns {object} The parsed deferred action.
16
+ */
17
+ export const parseDeferredAction = (
18
+ deferredAction: Hex,
19
+ ): {
20
+ entityId: number;
21
+ isGlobalValidation: boolean;
22
+ nonce: bigint;
23
+ deferredActionData: Hex;
24
+ hasAssociatedExecHooks: boolean;
25
+ } => {
26
+ // 2 for 0x, 2 for 00/01, 38 for parallel nonce, 8 for entity id, 2 for options byte, 16 for parallel nonce
27
+ return {
28
+ entityId: hexToNumber(`0x${deferredAction.slice(42, 50)}`),
29
+ isGlobalValidation:
30
+ hexToNumber(`0x${deferredAction.slice(50, 52)}`) % 2 === 1,
31
+ nonce: BigInt(`0x${deferredAction.slice(4, 68)}`),
32
+ deferredActionData: `0x${deferredAction.slice(68)}` as Hex,
33
+ hasAssociatedExecHooks: deferredAction[3] === "1",
34
+ };
35
+ };
36
+
37
+ export type BuildDeferredActionDigestParams = {
38
+ fullPreSignatureDeferredActionDigest: Hex;
39
+ sig: Hex;
40
+ signaturePrefix?: SignaturePrefix;
41
+ };
42
+
43
+ /**
44
+ * Creates the digest which must be prepended to the userOp signature.
45
+ *
46
+ * Assumption: The client this extends is used to sign the typed data.
47
+ *
48
+ * @param {BuildDeferredActionDigestParams} params - The parameters for building the deferred action digest.
49
+ * @returns {Hex} The encoded digest to be prepended to the userOp signature.
50
+ */
51
+ export const buildDeferredActionDigest = ({
52
+ fullPreSignatureDeferredActionDigest,
53
+ sig,
54
+ }: BuildDeferredActionDigestParams): Hex => {
55
+ // 6492 sigs don't work here.
56
+ const _sig = parseErc6492Signature(sig).signature;
57
+
58
+ const sigLength = size(_sig);
59
+
60
+ const encodedData = concatHex([
61
+ fullPreSignatureDeferredActionDigest,
62
+ toHex(sigLength, { size: 4 }),
63
+ _sig,
64
+ ]);
65
+ return encodedData;
66
+ };
@@ -0,0 +1,79 @@
1
+ import { concatHex, toHex, type Hex } from "viem";
2
+ import { HookType, type HookConfig, type ValidationConfig } from "../types.js";
3
+ import { serializeModuleEntity } from "./account.js";
4
+
5
+ /**
6
+ * Serializes a validation configuration into a hexadecimal string representation. This involves converting boolean flags into bitwise representation and combining them with serialized module entity data.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { serializeValidationConfig } from "@alchemy/smart-accounts";
11
+ * import { Address } from "viem";
12
+ *
13
+ * const moduleAddress: Address = "0x1234";
14
+ * const entityId: number = 1234;
15
+ * const isGlobal: boolean = true;
16
+ * const isSignatureValidation: boolean = false;
17
+ * const isUserOpValidation: boolean = true;
18
+ *
19
+ * const validationConfigHex = serializeValidationConfig({
20
+ * moduleAddress,
21
+ * entityId,
22
+ * isGlobal,
23
+ * isSignatureValidation,
24
+ * isUserOpValidation
25
+ * });
26
+ * ```
27
+ * @param {ValidationConfig} config The validation configuration object containing details to serialize
28
+ * @returns {Hex} A hexadecimal string representing the serialized configuration
29
+ */
30
+ export function serializeValidationConfig(config: ValidationConfig): Hex {
31
+ const isUserOpValidationBit = config.isUserOpValidation ? 1 : 0;
32
+ const isSignatureValidationBit = config.isSignatureValidation ? 2 : 0;
33
+ const isGlobalBit = config.isGlobal ? 4 : 0;
34
+ return concatHex([
35
+ serializeModuleEntity(config),
36
+ toHex(isUserOpValidationBit + isSignatureValidationBit + isGlobalBit, {
37
+ size: 1,
38
+ }),
39
+ ]);
40
+ }
41
+
42
+ /**
43
+ * Serializes a `HookConfig` object into a `Hex` format by encoding the hook type, presence of post/pre hooks, address, and entity ID.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { type HookType, serializeHookConfig } from "@alchemy/smart-accounts";
48
+ * import { Address } from "viem";
49
+ *
50
+ * const moduleAddress: Address = "0x1234";
51
+ * const entityId: number = 1234;
52
+ * const hookType: HookType = HookType.Validation;
53
+ * const hasPostHooks: boolean = false;
54
+ * const hasPreHooks: boolean = true;
55
+ *
56
+ * const hookConfigHex = serializeHookConfig({
57
+ * moduleAddress,
58
+ * entityId,
59
+ * hookType,
60
+ * hasPostHooks,
61
+ * hasPreHooks
62
+ * });
63
+ * ```
64
+ *
65
+ * @param {HookConfig} config The hook configuration containing address, entity ID, hook type, and post/pre hook indicators
66
+ * @returns {Hex} The serialized hook configuration in hexadecimal format
67
+ */
68
+ export function serializeHookConfig(config: HookConfig): Hex {
69
+ const hookTypeBit = config.hookType === HookType.VALIDATION ? 1 : 0;
70
+ const hasPostHooksBit = config.hasPostHooks ? 2 : 0;
71
+ const hasPreHooksBit = config.hasPreHooks ? 4 : 0;
72
+ return concatHex([
73
+ config.address,
74
+ toHex(config.entityId, { size: 4 }),
75
+ toHex(hookTypeBit + hasPostHooksBit + hasPreHooksBit, {
76
+ size: 1,
77
+ }),
78
+ ]);
79
+ }
@@ -0,0 +1,129 @@
1
+ import {
2
+ concatHex,
3
+ encodeAbiParameters,
4
+ toHex,
5
+ type Address,
6
+ type Hash,
7
+ type Hex,
8
+ } from "viem";
9
+ import { SignaturePrefix } from "../types.js";
10
+ import { Signature, type WebAuthnP256 } from "ox";
11
+
12
+ export type PackUOSignatureParams = {
13
+ // orderedHookData: HookData[];
14
+ validationSignature: Hex;
15
+ };
16
+
17
+ /**
18
+ * Signature packing utility for user operations.
19
+ *
20
+ * @param {PackUOSignatureParams} params - The parameters for packing a user operation signature.
21
+ * @returns {Hex} The packed user operation signature.
22
+ */
23
+ export const packUOSignature = ({
24
+ // orderedHookData, TODO: integrate in next iteration of MAv2 sdk
25
+ validationSignature,
26
+ }: PackUOSignatureParams): Hex => {
27
+ return concatHex(["0xFF", "0x00", validationSignature]);
28
+ };
29
+
30
+ // TODO(v4): direct call validation 1271
31
+ export type Pack1271SignatureParams = {
32
+ entityId: number;
33
+ validationSignaturePrefix: SignaturePrefix | null;
34
+ validationSignature: Hex;
35
+ };
36
+
37
+ /**
38
+ * Signature packing utility for 1271 signatures.
39
+ *
40
+ * @param {Pack1271SignatureParams} params - The parameters for packing a 1271 signature.
41
+ * @returns {Hex} The packed 1271 signature.
42
+ */
43
+ export const pack1271Signature = ({
44
+ entityId,
45
+ validationSignaturePrefix,
46
+ validationSignature,
47
+ }: Pack1271SignatureParams): Hex => {
48
+ return concatHex([
49
+ "0x00",
50
+ toHex(entityId, { size: 4 }),
51
+ "0xFF",
52
+ ...(validationSignaturePrefix ? [validationSignaturePrefix] : []),
53
+ validationSignature,
54
+ ]);
55
+ };
56
+
57
+ /**
58
+ * Converts a hash to a replay safe typed data.
59
+ *
60
+ * @param {ToReplaySafeTypedDataParams} params - The parameters for converting a hash to a replay safe typed data.
61
+ * @returns {object} The replay safe typed data.
62
+ */
63
+ export function toReplaySafeTypedData({
64
+ address,
65
+ chainId,
66
+ hash,
67
+ salt,
68
+ }: {
69
+ address: Address;
70
+ chainId: number;
71
+ hash: Hash;
72
+ salt?: Hex;
73
+ }) {
74
+ return {
75
+ domain: {
76
+ chainId,
77
+ verifyingContract: address,
78
+ ...(salt ? { salt } : {}),
79
+ },
80
+ types: {
81
+ ReplaySafeHash: [{ name: "hash", type: "bytes32" }],
82
+ },
83
+ message: {
84
+ hash,
85
+ },
86
+ primaryType: "ReplaySafeHash" as const,
87
+ };
88
+ }
89
+ /**
90
+ * Wraps a P256 signature with the webauthn metadata.
91
+ *
92
+ * @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.
93
+ * @returns {object} The wrapped P256 signature.
94
+ */
95
+ export function toWebAuthnSignature({
96
+ webauthn,
97
+ signature,
98
+ }: {
99
+ webauthn: WebAuthnP256.SignMetadata;
100
+ signature: Hex;
101
+ }) {
102
+ const { r, s } = Signature.fromHex(signature);
103
+ return encodeAbiParameters(
104
+ [
105
+ {
106
+ name: "params",
107
+ type: "tuple",
108
+ components: [
109
+ { name: "authenticatorData", type: "bytes" },
110
+ { name: "clientDataJSON", type: "string" },
111
+ { name: "challengeIndex", type: "uint256" },
112
+ { name: "typeIndex", type: "uint256" },
113
+ { name: "r", type: "uint256" },
114
+ { name: "s", type: "uint256" },
115
+ ],
116
+ },
117
+ ],
118
+ [
119
+ {
120
+ authenticatorData: webauthn.authenticatorData,
121
+ clientDataJSON: webauthn.clientDataJSON,
122
+ challengeIndex: BigInt(webauthn.challengeIndex),
123
+ typeIndex: BigInt(webauthn.typeIndex),
124
+ r,
125
+ s,
126
+ },
127
+ ],
128
+ );
129
+ }
@@ -0,0 +1,43 @@
1
+ import { getContract, type Address, type Hex, type Client } from "viem";
2
+
3
+ /**
4
+ * Test utility function that computes the counterfactual address using the EntryPoint's getSenderAddress function.
5
+ * This is copied from v4's @aa-sdk/core's getAccountAddress logic.
6
+ *
7
+ * @param {object} params - The parameters object
8
+ * @param {Client} params.client - The viem client for blockchain interaction
9
+ * @param {Address} params.entryPointAddress - The EntryPoint contract address
10
+ * @param {Array} params.entryPointAbi - The EntryPoint contract ABI
11
+ * @param {() => Promise<Hex>} params.getAccountInitCode - Function that returns the account init code
12
+ * @returns {Promise<Address>} Promise that resolves to the counterfactual account address
13
+ */
14
+ export async function getAccountAddressViaEntryPoint({
15
+ client,
16
+ entryPointAddress,
17
+ entryPointAbi,
18
+ getAccountInitCode,
19
+ }: {
20
+ client: Client;
21
+ entryPointAddress: Address;
22
+ entryPointAbi: readonly any[];
23
+ getAccountInitCode: () => Promise<Hex>;
24
+ }): Promise<Address> {
25
+ const entryPointContract = getContract({
26
+ address: entryPointAddress,
27
+ abi: entryPointAbi,
28
+ client,
29
+ });
30
+
31
+ const initCode = await getAccountInitCode();
32
+
33
+ try {
34
+ await entryPointContract.simulate.getSenderAddress([initCode]);
35
+ } catch (err: any) {
36
+ if (err.cause?.data?.errorName === "SenderAddressResult") {
37
+ return err.cause.data.args[0] as Address;
38
+ }
39
+ throw err;
40
+ }
41
+
42
+ throw new Error("Failed to get counterfactual address");
43
+ }