@account-kit/smart-contracts 4.35.0 → 4.36.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 (186) hide show
  1. package/dist/esm/plugindefs/session-key/config.js.map +1 -1
  2. package/dist/esm/src/light-account/accounts/account.js.map +1 -1
  3. package/dist/esm/src/light-account/accounts/base.js.map +1 -1
  4. package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
  5. package/dist/esm/src/light-account/accounts/predictAddress.js.map +1 -1
  6. package/dist/esm/src/light-account/actions/transferOwnership.d.ts +1 -1
  7. package/dist/esm/src/light-account/actions/transferOwnership.js.map +1 -1
  8. package/dist/esm/src/light-account/actions/updateOwners.js.map +1 -1
  9. package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
  10. package/dist/esm/src/light-account/clients/client.js.map +1 -1
  11. package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
  12. package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
  13. package/dist/esm/src/light-account/decorators/lightAccount.js.map +1 -1
  14. package/dist/esm/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
  15. package/dist/esm/src/light-account/types.js.map +1 -1
  16. package/dist/esm/src/light-account/utils.d.ts +1 -1
  17. package/dist/esm/src/light-account/utils.js.map +1 -1
  18. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -1
  19. package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -1
  20. package/dist/esm/src/ma-v2/account/nativeSMASigner.d.ts +2 -207
  21. package/dist/esm/src/ma-v2/account/nativeSMASigner.js +7 -4
  22. package/dist/esm/src/ma-v2/account/nativeSMASigner.js.map +1 -1
  23. package/dist/esm/src/ma-v2/account/predictAddress.js.map +1 -1
  24. package/dist/esm/src/ma-v2/actions/deferralActions.js.map +1 -1
  25. package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js.map +1 -1
  26. package/dist/esm/src/ma-v2/client/client.js.map +1 -1
  27. package/dist/esm/src/ma-v2/modules/allowlist-module/module.js.map +1 -1
  28. package/dist/esm/src/ma-v2/modules/native-token-limit-module/module.js.map +1 -1
  29. package/dist/esm/src/ma-v2/modules/paymaster-guard-module/module.js.map +1 -1
  30. package/dist/esm/src/ma-v2/modules/single-signer-validation/module.js.map +1 -1
  31. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.d.ts +2 -207
  32. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +7 -4
  33. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -1
  34. package/dist/esm/src/ma-v2/modules/time-range-module/module.js.map +1 -1
  35. package/dist/esm/src/ma-v2/modules/utils.js.map +1 -1
  36. package/dist/esm/src/ma-v2/modules/webauthn-validation/module.js.map +1 -1
  37. package/dist/esm/src/ma-v2/permissionBuilder.js.map +1 -1
  38. package/dist/esm/src/ma-v2/permissionBuilderErrors.js +1 -1
  39. package/dist/esm/src/ma-v2/permissionBuilderErrors.js.map +1 -1
  40. package/dist/esm/src/ma-v2/utils.js.map +1 -1
  41. package/dist/esm/src/msca/account/multiOwnerAccount.js.map +1 -1
  42. package/dist/esm/src/msca/account/multisigAccount.d.ts +1 -1
  43. package/dist/esm/src/msca/account/multisigAccount.js.map +1 -1
  44. package/dist/esm/src/msca/account-loupe/decorator.js.map +1 -1
  45. package/dist/esm/src/msca/account-loupe/types.js.map +1 -1
  46. package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
  47. package/dist/esm/src/msca/client/client.js.map +1 -1
  48. package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
  49. package/dist/esm/src/msca/plugin-manager/decorator.js.map +1 -1
  50. package/dist/esm/src/msca/plugin-manager/installPlugin.js.map +1 -1
  51. package/dist/esm/src/msca/plugin-manager/uninstallPlugin.js.map +1 -1
  52. package/dist/esm/src/msca/plugins/multi-owner/extension.js.map +1 -1
  53. package/dist/esm/src/msca/plugins/multi-owner/plugin.js.map +1 -1
  54. package/dist/esm/src/msca/plugins/multi-owner/signer.d.ts +3 -208
  55. package/dist/esm/src/msca/plugins/multi-owner/signer.js.map +1 -1
  56. package/dist/esm/src/msca/plugins/multisig/actions/getThreshold.js.map +1 -1
  57. package/dist/esm/src/msca/plugins/multisig/actions/isOwnerOf.js.map +1 -1
  58. package/dist/esm/src/msca/plugins/multisig/actions/proposeUserOperation.js.map +1 -1
  59. package/dist/esm/src/msca/plugins/multisig/actions/readOwners.js.map +1 -1
  60. package/dist/esm/src/msca/plugins/multisig/actions/signMultisigUserOperation.js.map +1 -1
  61. package/dist/esm/src/msca/plugins/multisig/extension.js.map +1 -1
  62. package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
  63. package/dist/esm/src/msca/plugins/multisig/plugin.js.map +1 -1
  64. package/dist/esm/src/msca/plugins/multisig/signer.d.ts +3 -208
  65. package/dist/esm/src/msca/plugins/multisig/signer.js.map +1 -1
  66. package/dist/esm/src/msca/plugins/multisig/types.js.map +1 -1
  67. package/dist/esm/src/msca/plugins/multisig/utils/formatSignatures.js.map +1 -1
  68. package/dist/esm/src/msca/plugins/multisig/utils/getSignerType.d.ts +1 -1
  69. package/dist/esm/src/msca/plugins/multisig/utils/getSignerType.js.map +1 -1
  70. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +1 -1
  71. package/dist/esm/src/msca/plugins/multisig/utils/splitAggregatedSignature.js.map +1 -1
  72. package/dist/esm/src/msca/plugins/session-key/extension.js.map +1 -1
  73. package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
  74. package/dist/esm/src/msca/plugins/session-key/plugin.js.map +1 -1
  75. package/dist/esm/src/msca/plugins/session-key/signer.d.ts +4 -209
  76. package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
  77. package/dist/esm/src/msca/plugins/session-key/utils.js.map +1 -1
  78. package/dist/esm/src/msca/plugins/types.js.map +1 -1
  79. package/dist/esm/src/msca/utils.js.map +1 -1
  80. package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
  81. package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
  82. package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
  83. package/dist/types/src/light-account/actions/transferOwnership.d.ts +1 -1
  84. package/dist/types/src/light-account/actions/transferOwnership.d.ts.map +1 -1
  85. package/dist/types/src/light-account/actions/updateOwners.d.ts.map +1 -1
  86. package/dist/types/src/light-account/types.d.ts.map +1 -1
  87. package/dist/types/src/light-account/utils.d.ts +1 -1
  88. package/dist/types/src/light-account/utils.d.ts.map +1 -1
  89. package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +2 -207
  90. package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts.map +1 -1
  91. package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts.map +1 -1
  92. package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +2 -207
  93. package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts.map +1 -1
  94. package/dist/types/src/ma-v2/modules/utils.d.ts.map +1 -1
  95. package/dist/types/src/ma-v2/permissionBuilderErrors.d.ts.map +1 -1
  96. package/dist/types/src/ma-v2/utils.d.ts.map +1 -1
  97. package/dist/types/src/msca/account/multisigAccount.d.ts +1 -1
  98. package/dist/types/src/msca/account/multisigAccount.d.ts.map +1 -1
  99. package/dist/types/src/msca/plugin-manager/decorator.d.ts.map +1 -1
  100. package/dist/types/src/msca/plugin-manager/installPlugin.d.ts.map +1 -1
  101. package/dist/types/src/msca/plugin-manager/uninstallPlugin.d.ts.map +1 -1
  102. package/dist/types/src/msca/plugins/multi-owner/plugin.d.ts.map +1 -1
  103. package/dist/types/src/msca/plugins/multi-owner/signer.d.ts +3 -208
  104. package/dist/types/src/msca/plugins/multi-owner/signer.d.ts.map +1 -1
  105. package/dist/types/src/msca/plugins/multisig/actions/proposeUserOperation.d.ts.map +1 -1
  106. package/dist/types/src/msca/plugins/multisig/plugin.d.ts.map +1 -1
  107. package/dist/types/src/msca/plugins/multisig/signer.d.ts +3 -208
  108. package/dist/types/src/msca/plugins/multisig/signer.d.ts.map +1 -1
  109. package/dist/types/src/msca/plugins/multisig/types.d.ts.map +1 -1
  110. package/dist/types/src/msca/plugins/multisig/utils/formatSignatures.d.ts.map +1 -1
  111. package/dist/types/src/msca/plugins/multisig/utils/getSignerType.d.ts +1 -1
  112. package/dist/types/src/msca/plugins/multisig/utils/getSignerType.d.ts.map +1 -1
  113. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts +1 -1
  114. package/dist/types/src/msca/plugins/multisig/utils/splitAggregatedSignature.d.ts.map +1 -1
  115. package/dist/types/src/msca/plugins/session-key/extension.d.ts.map +1 -1
  116. package/dist/types/src/msca/plugins/session-key/plugin.d.ts.map +1 -1
  117. package/dist/types/src/msca/plugins/session-key/signer.d.ts +4 -209
  118. package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
  119. package/dist/types/src/msca/utils.d.ts.map +1 -1
  120. package/package.json +7 -9
  121. package/plugindefs/session-key/config.ts +1 -1
  122. package/src/light-account/accounts/account.ts +7 -5
  123. package/src/light-account/accounts/base.ts +18 -15
  124. package/src/light-account/accounts/multiOwner.ts +9 -6
  125. package/src/light-account/accounts/predictAddress.ts +5 -5
  126. package/src/light-account/actions/transferOwnership.ts +5 -4
  127. package/src/light-account/actions/updateOwners.ts +6 -5
  128. package/src/light-account/clients/alchemyClient.ts +3 -3
  129. package/src/light-account/clients/client.ts +6 -6
  130. package/src/light-account/clients/multiOwnerAlchemyClient.ts +3 -3
  131. package/src/light-account/clients/multiOwnerLightAccount.ts +7 -7
  132. package/src/light-account/decorators/lightAccount.ts +4 -4
  133. package/src/light-account/decorators/multiOwnerLightAccount.ts +4 -4
  134. package/src/light-account/types.ts +3 -2
  135. package/src/light-account/utils.ts +10 -10
  136. package/src/ma-v2/account/common/modularAccountV2Base.ts +8 -8
  137. package/src/ma-v2/account/modularAccountV2.ts +4 -4
  138. package/src/ma-v2/account/nativeSMASigner.ts +16 -13
  139. package/src/ma-v2/account/predictAddress.ts +13 -13
  140. package/src/ma-v2/actions/deferralActions.ts +7 -7
  141. package/src/ma-v2/actions/install-validation/installValidation.ts +14 -14
  142. package/src/ma-v2/client/client.ts +8 -8
  143. package/src/ma-v2/modules/allowlist-module/module.ts +5 -5
  144. package/src/ma-v2/modules/native-token-limit-module/module.ts +1 -1
  145. package/src/ma-v2/modules/paymaster-guard-module/module.ts +2 -2
  146. package/src/ma-v2/modules/single-signer-validation/module.ts +2 -2
  147. package/src/ma-v2/modules/single-signer-validation/signer.ts +14 -11
  148. package/src/ma-v2/modules/time-range-module/module.ts +6 -6
  149. package/src/ma-v2/modules/utils.ts +4 -4
  150. package/src/ma-v2/modules/webauthn-validation/module.ts +2 -2
  151. package/src/ma-v2/permissionBuilder.ts +14 -14
  152. package/src/ma-v2/permissionBuilderErrors.ts +9 -7
  153. package/src/ma-v2/utils.ts +4 -4
  154. package/src/msca/account/multiOwnerAccount.ts +5 -5
  155. package/src/msca/account/multisigAccount.ts +6 -6
  156. package/src/msca/account-loupe/decorator.ts +11 -11
  157. package/src/msca/account-loupe/types.ts +1 -1
  158. package/src/msca/client/alchemyClient.ts +4 -4
  159. package/src/msca/client/client.ts +12 -12
  160. package/src/msca/client/multiSigAlchemyClient.ts +4 -4
  161. package/src/msca/plugin-manager/decorator.ts +6 -5
  162. package/src/msca/plugin-manager/installPlugin.ts +8 -7
  163. package/src/msca/plugin-manager/uninstallPlugin.ts +6 -5
  164. package/src/msca/plugins/multi-owner/extension.ts +10 -10
  165. package/src/msca/plugins/multi-owner/plugin.ts +21 -19
  166. package/src/msca/plugins/multi-owner/signer.ts +4 -4
  167. package/src/msca/plugins/multisig/actions/getThreshold.ts +3 -3
  168. package/src/msca/plugins/multisig/actions/isOwnerOf.ts +2 -2
  169. package/src/msca/plugins/multisig/actions/proposeUserOperation.ts +4 -3
  170. package/src/msca/plugins/multisig/actions/readOwners.ts +3 -3
  171. package/src/msca/plugins/multisig/actions/signMultisigUserOperation.ts +5 -5
  172. package/src/msca/plugins/multisig/extension.ts +16 -16
  173. package/src/msca/plugins/multisig/middleware.ts +2 -2
  174. package/src/msca/plugins/multisig/plugin.ts +21 -19
  175. package/src/msca/plugins/multisig/signer.ts +5 -5
  176. package/src/msca/plugins/multisig/types.ts +4 -2
  177. package/src/msca/plugins/multisig/utils/formatSignatures.ts +1 -1
  178. package/src/msca/plugins/multisig/utils/getSignerType.ts +2 -2
  179. package/src/msca/plugins/multisig/utils/splitAggregatedSignature.ts +7 -6
  180. package/src/msca/plugins/session-key/extension.ts +16 -14
  181. package/src/msca/plugins/session-key/permissions.ts +7 -7
  182. package/src/msca/plugins/session-key/plugin.ts +30 -28
  183. package/src/msca/plugins/session-key/signer.ts +5 -5
  184. package/src/msca/plugins/session-key/utils.ts +4 -4
  185. package/src/msca/plugins/types.ts +1 -1
  186. package/src/msca/utils.ts +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../plugindefs/session-key/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,WAAW,EACX,OAAO,EACP,OAAO,EACP,QAAQ,EACR,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,IAAI,EACJ,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,CAAC,MAAM,yBAAyB,GAAiB;IACrD,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,mBAAmB;IACxB,SAAS,EAAE;QACT,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC1D,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC9D,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC1D,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC9D,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAChE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC3D,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAClE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC3D,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAClE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,4CAA4C;QACvD,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC1D,IAAI,EAAE,4CAA4C;QAClD,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,4CAA4C;QACvD,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,4CAA4C;QAC9D,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,4CAA4C;KAC3D;IACD,aAAa,EAAE;QACb,aAAa,EAAE,kBAAkB,CAC/B,qEAAqE,CACtE;QACD,YAAY,EAAE;YACZ;gBACE,MAAM,EAAE,yBAAyB;gBACjC,UAAU,EAAE,KAAK;aAClB;YACD;gBACE,MAAM,EAAE,yBAAyB;gBACjC,UAAU,EAAE,KAAK;aAClB;SACF;KACF;CACF,CAAC","sourcesContent":["import type { PluginConfig } from \"@account-kit/plugingen\";\nimport { parseAbiParameters } from \"viem\";\nimport {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n fraxtal,\n mainnet,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"viem/chains\";\nimport { MultiOwnerPluginGenConfig } from \"../multi-owner/config.js\";\nimport { SessionKeyPluginAbi } from \"./abi.js\";\n\nexport const SessionKeyPluginGenConfig: PluginConfig = {\n name: \"SessionKeyPlugin\",\n abi: SessionKeyPluginAbi,\n addresses: {\n [sepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [baseSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygon.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygonAmoy.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygonMumbai.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [optimism.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [optimismSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [arbitrum.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [arbitrumSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [base.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [fraxtal.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n 2523: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [zora.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [zoraSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [mainnet.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n },\n installConfig: {\n initAbiParams: parseAbiParameters(\n \"address[] initialKeys, bytes32[] tags, bytes[][] initialPermissions\"\n ),\n dependencies: [\n {\n plugin: MultiOwnerPluginGenConfig,\n functionId: \"0x0\",\n },\n {\n plugin: MultiOwnerPluginGenConfig,\n functionId: \"0x1\",\n },\n ],\n },\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../plugindefs/session-key/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,WAAW,EACX,O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K;aAClB;YACD;gBACE,MAAM,EAAE,yBAAyB;gBACjC,UAAU,EAAE,KAAK;aAClB;SACF;KACF;CACF,CAAC","sourcesContent":["import type { PluginConfig } from \"@account-kit/plugingen\";\nimport { parseAbiParameters } from \"viem\";\nimport {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n fraxtal,\n mainnet,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"viem/chains\";\nimport { MultiOwnerPluginGenConfig } from \"../multi-owner/config.js\";\nimport { SessionKeyPluginAbi } from \"./abi.js\";\n\nexport const SessionKeyPluginGenConfig: PluginConfig = {\n name: \"SessionKeyPlugin\",\n abi: SessionKeyPluginAbi,\n addresses: {\n [sepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [baseSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygon.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygonAmoy.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [polygonMumbai.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [optimism.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [optimismSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [arbitrum.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [arbitrumSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [base.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [fraxtal.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n 2523: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [zora.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [zoraSepolia.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n [mainnet.id]: \"0x0000003E0000a96de4058e1E02a62FaaeCf23d8d\",\n },\n installConfig: {\n initAbiParams: parseAbiParameters(\n \"address[] initialKeys, bytes32[] tags, bytes[][] initialPermissions\",\n ),\n dependencies: [\n {\n plugin: MultiOwnerPluginGenConfig,\n functionId: \"0x0\",\n },\n {\n plugin: MultiOwnerPluginGenConfig,\n functionId: \"0x1\",\n },\n ],\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,GAId,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,GAInB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAKjF,OAAO,EACL,sBAAsB,EACtB,oCAAoC,EACpC,0BAA0B,EAC1B,oCAAoC,GACrC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,GAGvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAiDjE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,0BAA0B,EAAE,EACtC,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE;IAChC,OAAO,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC;SACrD,iBAAwB;CAC5B,CAAC,EACF,cAAc,EACd,cAAc,GAAG,oCAAoC,CAAC,KAAK,EAAE,OAAO,CA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AkB,CAAC;gBACxB,GAAG,EAAE,UAAU;gBACf,YAAY,EAAE,mBAAmB;gBACjC,IAAI,EAAE,CAAC,QAAQ,CAAC;aACjB,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBAC3C,OAAO;gBACP,GAAG,EAAE,UAAU;gBACf,YAAY,EAAE,OAAO;aACtB,CAAC,CAAC;YAEH,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAClD,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n type Address,\n type EntryPointDef,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\nimport { LightAccountAbi_v2 } from \"../abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v1 } from \"../abis/LightAccountFactoryAbi_v1.js\";\nimport { LightAccountFactoryAbi_v2 } from \"../abis/LightAccountFactoryAbi_v2.js\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountVersion,\n} from \"../types.js\";\nimport {\n AccountVersionRegistry,\n LightAccountUnsupported1271Factories,\n defaultLightAccountVersion,\n getDefaultLightAccountFactoryAddress,\n} from \"../utils.js\";\nimport {\n createLightAccountBase,\n type CreateLightAccountBaseParams,\n type LightAccountBase,\n} from \"./base.js\";\nimport { predictLightAccountAddress } from \"./predictAddress.js\";\n\nexport type LightAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">\n> = LightAccountBase<TSigner, \"LightAccount\", TLightAccountVersion> & {\n encodeTransferOwnership: (newOwner: Address) => Hex;\n getOwnerAddress: () => Promise<Address>;\n};\n\n// [!region CreateLightAccountParams]\nexport type CreateLightAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">\n> = Omit<\n CreateLightAccountBaseParams<\n \"LightAccount\",\n TLightAccountVersion,\n TTransport,\n TSigner\n >,\n | \"getAccountInitCode\"\n | \"entryPoint\"\n | \"version\"\n | \"abi\"\n | \"accountAddress\"\n | \"type\"\n> & {\n salt?: bigint;\n initCode?: Hex;\n accountAddress?: Address;\n factoryAddress?: Address;\n version?: TLightAccountVersion;\n entryPoint?: EntryPointDef<\n LightAccountEntryPointVersion<\"LightAccount\", TLightAccountVersion>,\n Chain\n >;\n};\n// [!endregion CreateLightAccountParams]\n\nexport async function createLightAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"LightAccount\"> = \"v2.0.0\"\n>(\n config: CreateLightAccountParams<TTransport, TSigner, TLightAccountVersion>\n): Promise<LightAccount<TSigner, TLightAccountVersion>>;\n\n/**\n * Creates a light account based on the provided parameters such as transport, chain, signer, init code, and more. Ensures that an account is configured and returned with various capabilities, such as transferring ownership and retrieving the owner's address.\n *\n * @example\n * ```ts\n * import { createLightAccount } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createLightAccount({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateLightAccountParams} config The parameters for creating a light account\n * @returns {Promise<LightAccount>} A promise that resolves to a `LightAccount` object containing the created account information and methods\n */\nexport async function createLightAccount({\n transport,\n chain,\n signer,\n initCode,\n version = defaultLightAccountVersion(),\n entryPoint = getEntryPoint(chain, {\n version: AccountVersionRegistry[\"LightAccount\"][version]\n .entryPointVersion as any,\n }),\n accountAddress,\n factoryAddress = getDefaultLightAccountFactoryAddress(chain, version),\n salt: salt_ = 0n,\n}: CreateLightAccountParams): Promise<LightAccount> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const accountAbi =\n version === \"v2.0.0\" ? LightAccountAbi_v2 : LightAccountAbi_v1;\n const factoryAbi =\n version === \"v2.0.0\"\n ? LightAccountFactoryAbi_v1\n : LightAccountFactoryAbi_v2;\n\n const signerAddress = await signer.getAddress();\n\n const salt = LightAccountUnsupported1271Factories.has(\n factoryAddress.toLowerCase() as Address\n )\n ? 0n\n : salt_;\n\n const getAccountInitCode = async () => {\n if (initCode) return initCode;\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [signerAddress, salt],\n }),\n ]);\n };\n\n const address =\n accountAddress ??\n predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress: signerAddress,\n version,\n });\n\n const account = await createLightAccountBase<\n \"LightAccount\",\n LightAccountVersion<\"LightAccount\">,\n Transport,\n SmartAccountSigner\n >({\n transport,\n chain,\n signer,\n abi: accountAbi,\n type: \"LightAccount\",\n version,\n entryPoint,\n accountAddress: address,\n getAccountInitCode,\n });\n\n return {\n ...account,\n\n encodeTransferOwnership: (newOwner: Address) => {\n return encodeFunctionData({\n abi: accountAbi,\n functionName: \"transferOwnership\",\n args: [newOwner],\n });\n },\n async getOwnerAddress(): Promise<Address> {\n const callResult = await client.readContract({\n address,\n abi: accountAbi,\n functionName: \"owner\",\n });\n\n if (callResult == null) {\n throw new Error(\"could not get on-chain owner\");\n }\n\n return callResult;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aA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ClD,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n type Address,\n type EntryPointDef,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\nimport { LightAccountAbi_v2 } from \"../abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v1 } from \"../abis/LightAccountFactoryAbi_v1.js\";\nimport { LightAccountFactoryAbi_v2 } from \"../abis/LightAccountFactoryAbi_v2.js\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountVersion,\n} from \"../types.js\";\nimport {\n AccountVersionRegistry,\n LightAccountUnsupported1271Factories,\n defaultLightAccountVersion,\n getDefaultLightAccountFactoryAddress,\n} from \"../utils.js\";\nimport {\n createLightAccountBase,\n type CreateLightAccountBaseParams,\n type LightAccountBase,\n} from \"./base.js\";\nimport { predictLightAccountAddress } from \"./predictAddress.js\";\n\nexport type LightAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = LightAccountBase<TSigner, \"LightAccount\", TLightAccountVersion> & {\n encodeTransferOwnership: (newOwner: Address) => Hex;\n getOwnerAddress: () => Promise<Address>;\n};\n\n// [!region CreateLightAccountParams]\nexport type CreateLightAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = Omit<\n CreateLightAccountBaseParams<\n \"LightAccount\",\n TLightAccountVersion,\n TTransport,\n TSigner\n >,\n | \"getAccountInitCode\"\n | \"entryPoint\"\n | \"version\"\n | \"abi\"\n | \"accountAddress\"\n | \"type\"\n> & {\n salt?: bigint;\n initCode?: Hex;\n accountAddress?: Address;\n factoryAddress?: Address;\n version?: TLightAccountVersion;\n entryPoint?: EntryPointDef<\n LightAccountEntryPointVersion<\"LightAccount\", TLightAccountVersion>,\n Chain\n >;\n};\n// [!endregion CreateLightAccountParams]\n\nexport async function createLightAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"LightAccount\"> = \"v2.0.0\",\n>(\n config: CreateLightAccountParams<TTransport, TSigner, TLightAccountVersion>,\n): Promise<LightAccount<TSigner, TLightAccountVersion>>;\n\n/**\n * Creates a light account based on the provided parameters such as transport, chain, signer, init code, and more. Ensures that an account is configured and returned with various capabilities, such as transferring ownership and retrieving the owner's address.\n *\n * @example\n * ```ts\n * import { createLightAccount } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createLightAccount({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateLightAccountParams} config The parameters for creating a light account\n * @returns {Promise<LightAccount>} A promise that resolves to a `LightAccount` object containing the created account information and methods\n */\nexport async function createLightAccount({\n transport,\n chain,\n signer,\n initCode,\n version = defaultLightAccountVersion(),\n entryPoint = getEntryPoint(chain, {\n version: AccountVersionRegistry[\"LightAccount\"][version]\n .entryPointVersion as any,\n }),\n accountAddress,\n factoryAddress = getDefaultLightAccountFactoryAddress(chain, version),\n salt: salt_ = 0n,\n}: CreateLightAccountParams): Promise<LightAccount> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const accountAbi =\n version === \"v2.0.0\" ? LightAccountAbi_v2 : LightAccountAbi_v1;\n const factoryAbi =\n version === \"v2.0.0\"\n ? LightAccountFactoryAbi_v1\n : LightAccountFactoryAbi_v2;\n\n const signerAddress = await signer.getAddress();\n\n const salt = LightAccountUnsupported1271Factories.has(\n factoryAddress.toLowerCase() as Address,\n )\n ? 0n\n : salt_;\n\n const getAccountInitCode = async () => {\n if (initCode) return initCode;\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [signerAddress, salt],\n }),\n ]);\n };\n\n const address =\n accountAddress ??\n predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress: signerAddress,\n version,\n });\n\n const account = await createLightAccountBase<\n \"LightAccount\",\n LightAccountVersion<\"LightAccount\">,\n Transport,\n SmartAccountSigner\n >({\n transport,\n chain,\n signer,\n abi: accountAbi,\n type: \"LightAccount\",\n version,\n entryPoint,\n accountAddress: address,\n getAccountInitCode,\n });\n\n return {\n ...account,\n\n encodeTransferOwnership: (newOwner: Address) => {\n return encodeFunctionData({\n abi: accountAbi,\n functionName: \"transferOwnership\",\n args: [newOwner],\n });\n },\n async getOwnerAddress(): Promise<Address> {\n const callResult = await client.readContract({\n address,\n abi: accountAbi,\n functionName: \"owner\",\n });\n\n if (callResult == null) {\n throw new Error(\"could not get on-chain owner\");\n }\n\n return callResult;\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,GAOvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,aAAa,EACb,IAAI,GAML,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,IAAK,aAIJ;AAJD,WAAK,aAAa;IAChB,6BAAY,CAAA;IACZ,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAJI,aAAa,KAAb,aAAa,QAIjB;AAkCD,yCAAyC;AA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,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QACD,sBAAsB;KACvB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,IAAI;QACZ,sBAAsB,EAAE,GAAG,EAAE,CAAC,OAAO;QACrC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n FailedToGetStorageSlotError,\n createBundlerClient,\n toSmartContractAccount,\n type Abi,\n type EntryPointDef,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n type UpgradeToAndCallParams,\n} from \"@aa-sdk/core\";\nimport {\n concat,\n encodeFunctionData,\n fromHex,\n hashMessage,\n hashTypedData,\n trim,\n type Address,\n type Chain,\n type Hex,\n type SignTypedDataParameters,\n type Transport,\n} from \"viem\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountType,\n LightAccountVersion,\n} from \"../types.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\n\nenum SignatureType {\n EOA = \"0x00\",\n CONTRACT = \"0x01\",\n CONTRACT_WITH_ADDR = \"0x02\",\n}\n\nexport type LightAccountBase<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountType extends LightAccountType = LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>\n> = SmartContractAccountWithSigner<\n TLightAccountType,\n TSigner,\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>\n> & {\n getLightAccountVersion: () => TLightAccountVersion;\n};\n\n//#region CreateLightAccountBaseParams\nexport type CreateLightAccountBaseParams<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Pick<\n ToSmartContractAccountParams<TLightAccountType, TTransport, Chain>,\n \"transport\" | \"chain\" | \"getAccountInitCode\"\n> & {\n abi: Abi;\n signer: TSigner;\n accountAddress: Address;\n type: TLightAccountType;\n version: TLightAccountVersion;\n entryPoint: EntryPointDef<\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>,\n Chain\n >;\n};\n//#endregion CreateLightAccountBaseParams\n\nexport async function createLightAccountBase<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>({\n transport,\n chain,\n signer,\n abi,\n version,\n type,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: CreateLightAccountBaseParams<\n TLightAccountType,\n TLightAccountVersion,\n TTransport,\n TSigner\n>): Promise<\n LightAccountBase<TSigner, TLightAccountType, TLightAccountVersion>\n> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const encodeUpgradeToAndCall = async ({\n upgradeToAddress,\n upgradeToInitData,\n }: UpgradeToAndCallParams): Promise<Hex> => {\n const storage = await client.getStorageAt({\n address: accountAddress,\n // the slot at which impl addresses are stored by UUPS\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n const implementationAddresses = Object.values(\n AccountVersionRegistry[type]\n ).map(\n (x) => x.addresses.overrides?.[chain.id]?.impl ?? x.addresses.default.impl\n );\n\n // only upgrade undeployed accounts (storage 0) or deployed light accounts, error otherwise\n if (\n fromHex(storage, \"number\") !== 0 &&\n !implementationAddresses.some((x) => x === trim(storage))\n ) {\n throw new Error(\n `could not determine if smart account implementation is ${type} ${String(\n version\n )}`\n );\n }\n\n return encodeFunctionData({\n abi,\n functionName: \"upgradeToAndCall\",\n args: [upgradeToAddress, upgradeToInitData],\n });\n };\n\n const signWith1271Wrapper = async (\n hashedMessage: Hex,\n version: string\n ): Promise<Hex> => {\n return signer.signTypedData({\n // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\n // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236\n domain: {\n chainId: Number(client.chain.id),\n name: type,\n verifyingContract: accountAddress,\n version,\n },\n types: {\n LightAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: hashedMessage,\n },\n primaryType: \"LightAccountMessage\",\n });\n };\n\n const account = await toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n accountAddress,\n source: type,\n getAccountInitCode,\n encodeExecute: async ({ target, data, value }) => {\n return encodeFunctionData({\n abi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n });\n },\n encodeBatchExecute: async (txs) => {\n const [targets, values, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.value ?? 0n);\n accum[2].push(curr.data);\n\n return accum;\n },\n [[], [], []] as [Address[], bigint[], Hex[]]\n );\n return encodeFunctionData({\n abi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n },\n signUserOperationHash: async (uoHash: Hex) => {\n const signature = await signer.signMessage({ raw: uoHash });\n switch (version) {\n case \"v2.0.0\":\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n return signature;\n }\n },\n async signMessage({ message }) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signMessage(message);\n case \"v1.0.2\":\n throw new Error(`${type} ${String(version)} doesn't support 1271`);\n case \"v1.1.0\":\n return signWith1271Wrapper(hashMessage(message), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashMessage(message),\n \"2\"\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n async signTypedData(params) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signTypedData(\n params as unknown as SignTypedDataParameters\n );\n case \"v1.0.2\":\n throw new Error(\n `Version ${String(version)} of LightAccount doesn't support 1271`\n );\n case \"v1.1.0\":\n return signWith1271Wrapper(hashTypedData(params), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashTypedData(params),\n \"2\"\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${String(version)} of LightAccount`);\n }\n },\n getDummySignature: (): Hex => {\n const signature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n switch (version as string) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n return signature;\n case \"v2.0.0\":\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n encodeUpgradeToAndCall,\n });\n\n return {\n ...account,\n source: type,\n getLightAccountVersion: () => version,\n getSigner: () => signer,\n };\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,GAOvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,aAAa,EACb,IAAI,GAML,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,IAAK,aAIJ;AAJD,WAAK,aAAa;IAChB,6BAAY,CAAA;IACZ,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAJI,aAAa,KAAb,aAAa,QAIjB;AAoCD,yCAAyC;AAEzC,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAK1C,EACA,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,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AO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,IAAI;QACZ,sBAAsB,EAAE,GAAG,EAAE,CAAC,OAAO;QACrC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n FailedToGetStorageSlotError,\n createBundlerClient,\n toSmartContractAccount,\n type Abi,\n type EntryPointDef,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n type UpgradeToAndCallParams,\n} from \"@aa-sdk/core\";\nimport {\n concat,\n encodeFunctionData,\n fromHex,\n hashMessage,\n hashTypedData,\n trim,\n type Address,\n type Chain,\n type Hex,\n type SignTypedDataParameters,\n type Transport,\n} from \"viem\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountType,\n LightAccountVersion,\n} from \"../types.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\n\nenum SignatureType {\n EOA = \"0x00\",\n CONTRACT = \"0x01\",\n CONTRACT_WITH_ADDR = \"0x02\",\n}\n\nexport type LightAccountBase<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountType extends LightAccountType = LightAccountType,\n TLightAccountVersion extends\n LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n> = SmartContractAccountWithSigner<\n TLightAccountType,\n TSigner,\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>\n> & {\n getLightAccountVersion: () => TLightAccountVersion;\n};\n\n//#region CreateLightAccountBaseParams\nexport type CreateLightAccountBaseParams<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends\n LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Pick<\n ToSmartContractAccountParams<TLightAccountType, TTransport, Chain>,\n \"transport\" | \"chain\" | \"getAccountInitCode\"\n> & {\n abi: Abi;\n signer: TSigner;\n accountAddress: Address;\n type: TLightAccountType;\n version: TLightAccountVersion;\n entryPoint: EntryPointDef<\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>,\n Chain\n >;\n};\n//#endregion CreateLightAccountBaseParams\n\nexport async function createLightAccountBase<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>({\n transport,\n chain,\n signer,\n abi,\n version,\n type,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: CreateLightAccountBaseParams<\n TLightAccountType,\n TLightAccountVersion,\n TTransport,\n TSigner\n>): Promise<\n LightAccountBase<TSigner, TLightAccountType, TLightAccountVersion>\n> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const encodeUpgradeToAndCall = async ({\n upgradeToAddress,\n upgradeToInitData,\n }: UpgradeToAndCallParams): Promise<Hex> => {\n const storage = await client.getStorageAt({\n address: accountAddress,\n // the slot at which impl addresses are stored by UUPS\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\",\n );\n }\n\n const implementationAddresses = Object.values(\n AccountVersionRegistry[type],\n ).map(\n (x) =>\n x.addresses.overrides?.[chain.id]?.impl ?? x.addresses.default.impl,\n );\n\n // only upgrade undeployed accounts (storage 0) or deployed light accounts, error otherwise\n if (\n fromHex(storage, \"number\") !== 0 &&\n !implementationAddresses.some((x) => x === trim(storage))\n ) {\n throw new Error(\n `could not determine if smart account implementation is ${type} ${String(\n version,\n )}`,\n );\n }\n\n return encodeFunctionData({\n abi,\n functionName: \"upgradeToAndCall\",\n args: [upgradeToAddress, upgradeToInitData],\n });\n };\n\n const signWith1271Wrapper = async (\n hashedMessage: Hex,\n version: string,\n ): Promise<Hex> => {\n return signer.signTypedData({\n // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\n // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236\n domain: {\n chainId: Number(client.chain.id),\n name: type,\n verifyingContract: accountAddress,\n version,\n },\n types: {\n LightAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: hashedMessage,\n },\n primaryType: \"LightAccountMessage\",\n });\n };\n\n const account = await toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n accountAddress,\n source: type,\n getAccountInitCode,\n encodeExecute: async ({ target, data, value }) => {\n return encodeFunctionData({\n abi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n });\n },\n encodeBatchExecute: async (txs) => {\n const [targets, values, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.value ?? 0n);\n accum[2].push(curr.data);\n\n return accum;\n },\n [[], [], []] as [Address[], bigint[], Hex[]],\n );\n return encodeFunctionData({\n abi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n },\n signUserOperationHash: async (uoHash: Hex) => {\n const signature = await signer.signMessage({ raw: uoHash });\n switch (version) {\n case \"v2.0.0\":\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n return signature;\n }\n },\n async signMessage({ message }) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signMessage(message);\n case \"v1.0.2\":\n throw new Error(`${type} ${String(version)} doesn't support 1271`);\n case \"v1.1.0\":\n return signWith1271Wrapper(hashMessage(message), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashMessage(message),\n \"2\",\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n async signTypedData(params) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signTypedData(\n params as unknown as SignTypedDataParameters,\n );\n case \"v1.0.2\":\n throw new Error(\n `Version ${String(version)} of LightAccount doesn't support 1271`,\n );\n case \"v1.1.0\":\n return signWith1271Wrapper(hashTypedData(params), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashTypedData(params),\n \"2\",\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${String(version)} of LightAccount`);\n }\n },\n getDummySignature: (): Hex => {\n const signature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n switch (version as string) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n return signature;\n case \"v2.0.0\":\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n encodeUpgradeToAndCall,\n });\n\n return {\n ...account,\n source: type,\n getLightAccountVersion: () => version,\n getSigner: () => signer,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,WAAW,GAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAK/F,OAAO,EACL,0BAA0B,EAC1B,8CAA8C,GAC/C,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,GAGvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AA8D3E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,GAA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IAEF,MAAM,OAAO,GACX,cAAc;QACd,oCAAoC,CAAC;YACnC,cAAc;YACd,IAAI,EAAE,KAAK;YACX,cAAc,EAAE,OAAO;SACxB,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAK1C;QACA,SAAS;QACT,KAAK;QACL,MAAM;QACN,GAAG,EAAE,yBAAyB;QAC9B,OAAO;QACP,IAAI,EAAE,wBAAwB;QAC9B,UAAU;QACV,cAAc,EAAE,OAAO;QACvB,kBAAkB;KACnB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,kBAAkB,EAAE,CAAC,WAAsB,EAAE,cAAyB,EAAE,EAAE;YACxE,OAAO,kBAAkB,CAAC;gBACxB,GAAG,EAAE,yBAAyB;gBAC9B,YAAY,EAAE,cAAc;gBAC5B,IAAI,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,iBAAiB;YACrB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBAC3C,OAAO;gBACP,GAAG,EAAE,yBAAyB;gBAC9B,YAAY,EAAE,QAAQ;aACvB,CAAC,CAAC;YAEH,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACnD,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACzE,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n type EntryPointDef,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n hexToBigInt,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { MultiOwnerLightAccountAbi } from \"../abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"../abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountVersion,\n} from \"../types.js\";\nimport {\n defaultLightAccountVersion,\n getDefaultMultiOwnerLightAccountFactoryAddress,\n} from \"../utils.js\";\nimport {\n createLightAccountBase,\n type CreateLightAccountBaseParams,\n type LightAccountBase,\n} from \"./base.js\";\nimport { predictMultiOwnerLightAccountAddress } from \"./predictAddress.js\";\n\nexport type MultiOwnerLightAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">\n> = LightAccountBase<\n TSigner,\n \"MultiOwnerLightAccount\",\n TLightAccountVersion\n> & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[]\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type CreateMultiOwnerLightAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">\n> = Omit<\n CreateLightAccountBaseParams<\n \"MultiOwnerLightAccount\",\n TLightAccountVersion,\n TTransport,\n TSigner\n >,\n | \"getAccountInitCode\"\n | \"entryPoint\"\n | \"version\"\n | \"abi\"\n | \"accountAddress\"\n | \"type\"\n> & {\n salt?: bigint;\n initCode?: Hex;\n accountAddress?: Address;\n factoryAddress?: Address;\n version?: TLightAccountVersion;\n entryPoint?: EntryPointDef<\n LightAccountEntryPointVersion<\n \"MultiOwnerLightAccount\",\n TLightAccountVersion\n >,\n Chain\n >;\n owners?: Address[];\n};\n\nexport async function createMultiOwnerLightAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">\n>(\n config: CreateMultiOwnerLightAccountParams<\n TTransport,\n TSigner,\n TLightAccountVersion\n >\n): Promise<MultiOwnerLightAccount<TSigner, TLightAccountVersion>>;\n\n/**\n * Creates a multi-owner light account using the provided parameters, including transport, chain, signer, initialization code, version, account address, factory address, salt, and owners. Ensures the owners list is deduplicated, ordered, and valid.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccount } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createMultiOwnerLightAccount({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateMultiOwnerLightAccountParams} config The parameters for creating a multi-owner light account\n * @returns {Promise<MultiOwnerLightAccount>} A promise that resolves to a `MultiOwnerLightAccount` object containing the created account information and methods\n */\nexport async function createMultiOwnerLightAccount({\n transport,\n chain,\n signer,\n initCode,\n version = defaultLightAccountVersion(),\n entryPoint = getEntryPoint(chain, {\n version: \"0.7.0\",\n }),\n accountAddress,\n factoryAddress = getDefaultMultiOwnerLightAccountFactoryAddress(\n chain,\n version\n ),\n salt: salt_ = 0n,\n owners = [],\n}: CreateMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n // NOTE: the current signer connected will be one of the owners as well\n const ownerAddress = await signer.getAddress();\n // owners need to be dedupe + ordered in ascending order and not == to zero address\n const owners_ = Array.from(new Set([...owners, ownerAddress]))\n .filter((x) => hexToBigInt(x) !== 0n)\n .sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const getAccountInitCode = async () => {\n if (initCode) return initCode;\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [owners_, salt_],\n }),\n ]);\n };\n\n const address =\n accountAddress ??\n predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt: salt_,\n ownerAddresses: owners_,\n });\n\n const account = await createLightAccountBase<\n \"MultiOwnerLightAccount\",\n LightAccountVersion<\"MultiOwnerLightAccount\">,\n Transport,\n SmartAccountSigner\n >({\n transport,\n chain,\n signer,\n abi: MultiOwnerLightAccountAbi,\n version,\n type: \"MultiOwnerLightAccount\",\n entryPoint,\n accountAddress: address,\n getAccountInitCode,\n });\n\n return {\n ...account,\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const callResult = await client.readContract({\n address,\n abi: MultiOwnerLightAccountAbi,\n functionName: \"owners\",\n });\n\n if (callResult == null) {\n throw new Error(\"could not get on-chain owners\");\n }\n\n if (!callResult.includes(await signer.getAddress())) {\n throw new Error(\"on-chain owners does not include the current signer\");\n }\n\n return callResult;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,WAAW,GAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAK/F,OAAO,EACL,0BAA0B,EAC1B,8CAA8C,GAC/C,MAAM,aAAa,CAA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AC,CAAC;YACzE,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n type EntryPointDef,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n hexToBigInt,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { MultiOwnerLightAccountAbi } from \"../abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"../abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountVersion,\n} from \"../types.js\";\nimport {\n defaultLightAccountVersion,\n getDefaultMultiOwnerLightAccountFactoryAddress,\n} from \"../utils.js\";\nimport {\n createLightAccountBase,\n type CreateLightAccountBaseParams,\n type LightAccountBase,\n} from \"./base.js\";\nimport { predictMultiOwnerLightAccountAddress } from \"./predictAddress.js\";\n\nexport type MultiOwnerLightAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends\n LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">,\n> = LightAccountBase<\n TSigner,\n \"MultiOwnerLightAccount\",\n TLightAccountVersion\n> & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[],\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type CreateMultiOwnerLightAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends\n LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">,\n> = Omit<\n CreateLightAccountBaseParams<\n \"MultiOwnerLightAccount\",\n TLightAccountVersion,\n TTransport,\n TSigner\n >,\n | \"getAccountInitCode\"\n | \"entryPoint\"\n | \"version\"\n | \"abi\"\n | \"accountAddress\"\n | \"type\"\n> & {\n salt?: bigint;\n initCode?: Hex;\n accountAddress?: Address;\n factoryAddress?: Address;\n version?: TLightAccountVersion;\n entryPoint?: EntryPointDef<\n LightAccountEntryPointVersion<\n \"MultiOwnerLightAccount\",\n TLightAccountVersion\n >,\n Chain\n >;\n owners?: Address[];\n};\n\nexport async function createMultiOwnerLightAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountVersion extends\n LightAccountVersion<\"MultiOwnerLightAccount\"> = LightAccountVersion<\"MultiOwnerLightAccount\">,\n>(\n config: CreateMultiOwnerLightAccountParams<\n TTransport,\n TSigner,\n TLightAccountVersion\n >,\n): Promise<MultiOwnerLightAccount<TSigner, TLightAccountVersion>>;\n\n/**\n * Creates a multi-owner light account using the provided parameters, including transport, chain, signer, initialization code, version, account address, factory address, salt, and owners. Ensures the owners list is deduplicated, ordered, and valid.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccount } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createMultiOwnerLightAccount({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateMultiOwnerLightAccountParams} config The parameters for creating a multi-owner light account\n * @returns {Promise<MultiOwnerLightAccount>} A promise that resolves to a `MultiOwnerLightAccount` object containing the created account information and methods\n */\nexport async function createMultiOwnerLightAccount({\n transport,\n chain,\n signer,\n initCode,\n version = defaultLightAccountVersion(),\n entryPoint = getEntryPoint(chain, {\n version: \"0.7.0\",\n }),\n accountAddress,\n factoryAddress = getDefaultMultiOwnerLightAccountFactoryAddress(\n chain,\n version,\n ),\n salt: salt_ = 0n,\n owners = [],\n}: CreateMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n // NOTE: the current signer connected will be one of the owners as well\n const ownerAddress = await signer.getAddress();\n // owners need to be dedupe + ordered in ascending order and not == to zero address\n const owners_ = Array.from(new Set([...owners, ownerAddress]))\n .filter((x) => hexToBigInt(x) !== 0n)\n .sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const getAccountInitCode = async () => {\n if (initCode) return initCode;\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [owners_, salt_],\n }),\n ]);\n };\n\n const address =\n accountAddress ??\n predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt: salt_,\n ownerAddresses: owners_,\n });\n\n const account = await createLightAccountBase<\n \"MultiOwnerLightAccount\",\n LightAccountVersion<\"MultiOwnerLightAccount\">,\n Transport,\n SmartAccountSigner\n >({\n transport,\n chain,\n signer,\n abi: MultiOwnerLightAccountAbi,\n version,\n type: \"MultiOwnerLightAccount\",\n entryPoint,\n accountAddress: address,\n getAccountInitCode,\n });\n\n return {\n ...account,\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const callResult = await client.readContract({\n address,\n abi: MultiOwnerLightAccountAbi,\n functionName: \"owners\",\n });\n\n if (callResult == null) {\n throw new Error(\"could not get on-chain owners\");\n }\n\n if (!callResult.includes(await signer.getAddress())) {\n throw new Error(\"on-chain owners does not include the current signer\");\n }\n\n return callResult;\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"predictAddress.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,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;QACxB,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED,+HAA+H;AAE/H,SAAS,oBAAoB,CAAC,qBAA8B;IAC1D,OAAO,uBAAuB,qBAAqB,CAAC,KAAK,CACvD,CAAC,CACF,sIAAsI,CAAC;AAC1I,CAAC;AAED,SAAS,8BAA8B,CAAC,OAAc;IACpD,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import {\n encodeAbiParameters,\n encodeDeployData,\n keccak256,\n getContractAddress,\n type Address,\n type Hex,\n toHex,\n encodeFunctionData,\n} from \"viem\";\nimport type { LightAccountVersionConfigs } from \"../types\";\nimport { OZ_ERC1967Proxy_ConstructorAbi } from \"../abis/OZ_ERC1967Proxy.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\n\nexport type PredictLightAccountAddressParams = {\n factoryAddress: Address;\n salt: bigint;\n ownerAddress: Address;\n version: keyof LightAccountVersionConfigs[\"LightAccount\"];\n};\n\nexport function predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress,\n version,\n}: PredictLightAccountAddressParams): Address {\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress !==\n AccountVersionRegistry.LightAccount[version].addresses.default.factory\n ? getContractAddress({\n from: factoryAddress,\n nonce: 1n,\n })\n : AccountVersionRegistry.LightAccount[version].addresses.default.impl;\n\n switch (version) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n // Same proxy initcode for all LA v1 factories\n const LAv1_proxy_bytecode: Hex =\n \"0x60406080815261042c908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160e790816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe60806040523615605f5773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f35b3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f3fea26469706673582212205da2750cd2b0cadfd354d8a1ca4752ed7f22214c8069d852f7dc6b8e9e5ee66964736f6c63430008150033\";\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: toHex(salt, { size: 32 }),\n bytecode: encodeDeployData({\n bytecode: LAv1_proxy_bytecode,\n abi: OZ_ERC1967Proxy_ConstructorAbi,\n args: [\n implementationAddress,\n encodeFunctionData({\n abi: LightAccountAbi_v1,\n functionName: \"initialize\",\n args: [ownerAddress],\n }),\n ],\n }),\n });\n\n case \"v2.0.0\":\n // Logic ported from LA factory v2.0.0\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address\" }, { type: \"uint256\" }],\n [ownerAddress, salt]\n )\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n\n default:\n assertNeverLightAccountVersion(version);\n }\n}\n\nexport type PredictMultiOwnerLightAccountAddressParams = {\n factoryAddress: Address;\n salt: bigint;\n ownerAddresses: Address[];\n // There's just one version of the MultiOwnerLightAccount for now, so skip requiring the version as a parameter.\n};\n\n// Note: assumes the owner addresses are already deduped, sorted in ascending order, and have the signer address included.\nexport function predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddresses,\n}: PredictMultiOwnerLightAccountAddressParams): Address {\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress !==\n AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].addresses.default\n .factory\n ? getContractAddress({\n from: factoryAddress,\n nonce: 1n,\n })\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].addresses\n .default.impl;\n\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address[]\" }, { type: \"uint256\" }],\n [ownerAddresses, salt]\n )\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n}\n\n// Bytecode from https://github.com/Vectorized/solady/blob/c6e5238e5f3b621789c59e1a443f43b6606394b2/src/utils/LibClone.sol#L721\n\nfunction getLAv2ProxyBytecode(implementationAddress: Address): Hex {\n return `0x603d3d8160223d3973${implementationAddress.slice(\n 2\n )}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3`;\n}\n\nfunction assertNeverLightAccountVersion(version: never): never {\n throw new Error(`Unknown light account version: ${version}`);\n}\n"]}
1
+ {"version":3,"file":"predictAddress.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAGlB,KAAK,EACL,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AASnE,MAAM,UAAU,0BAA0B,CAAC,EACzC,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,OAAO,GAC0B;IACjC,MAAM,qBAAqB;IACzB,gIAAgI;IAChI,sJAAsJ;IACtJ,cAAc;QACd,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO;QACpE,CAAC,CAAC,kBAAkB,CAAC;YACjB,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,EAAE;SACV,CAAC;QACJ,CAAC,CAAC,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IAE1E,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,8CAA8C;YAC9C,MAAM,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kB,CAAC;YACjB,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,EAAE;SACV,CAAC;QACJ,CAAC,CAAC,sBAAsB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC,SAAS;aAC9D,OAAO,CAAC,IAAI,CAAC;IAEtB,MAAM,YAAY,GAAG,SAAS,CAC5B,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC5C,CAAC,cAAc,EAAE,IAAI,CAAC,CACvB,CACF,CAAC;IAEF,MAAM,QAAQ,GAAQ,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;IAElE,OAAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED,+HAA+H;AAE/H,SAAS,oBAAoB,CAAC,qBAA8B;IAC1D,OAAO,uBAAuB,qBAAqB,CAAC,KAAK,CACvD,CAAC,CACF,sIAAsI,CAAC;AAC1I,CAAC;AAED,SAAS,8BAA8B,CAAC,OAAc;IACpD,MAAM,IAAI,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import {\n encodeAbiParameters,\n encodeDeployData,\n keccak256,\n getContractAddress,\n type Address,\n type Hex,\n toHex,\n encodeFunctionData,\n} from \"viem\";\nimport type { LightAccountVersionConfigs } from \"../types\";\nimport { OZ_ERC1967Proxy_ConstructorAbi } from \"../abis/OZ_ERC1967Proxy.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\n\nexport type PredictLightAccountAddressParams = {\n factoryAddress: Address;\n salt: bigint;\n ownerAddress: Address;\n version: keyof LightAccountVersionConfigs[\"LightAccount\"];\n};\n\nexport function predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress,\n version,\n}: PredictLightAccountAddressParams): Address {\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress !==\n AccountVersionRegistry.LightAccount[version].addresses.default.factory\n ? getContractAddress({\n from: factoryAddress,\n nonce: 1n,\n })\n : AccountVersionRegistry.LightAccount[version].addresses.default.impl;\n\n switch (version) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n // Same proxy initcode for all LA v1 factories\n const LAv1_proxy_bytecode: Hex =\n \"0x60406080815261042c908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160e790816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe60806040523615605f5773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f35b3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f3fea26469706673582212205da2750cd2b0cadfd354d8a1ca4752ed7f22214c8069d852f7dc6b8e9e5ee66964736f6c63430008150033\";\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: toHex(salt, { size: 32 }),\n bytecode: encodeDeployData({\n bytecode: LAv1_proxy_bytecode,\n abi: OZ_ERC1967Proxy_ConstructorAbi,\n args: [\n implementationAddress,\n encodeFunctionData({\n abi: LightAccountAbi_v1,\n functionName: \"initialize\",\n args: [ownerAddress],\n }),\n ],\n }),\n });\n\n case \"v2.0.0\":\n // Logic ported from LA factory v2.0.0\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address\" }, { type: \"uint256\" }],\n [ownerAddress, salt],\n ),\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n\n default:\n assertNeverLightAccountVersion(version);\n }\n}\n\nexport type PredictMultiOwnerLightAccountAddressParams = {\n factoryAddress: Address;\n salt: bigint;\n ownerAddresses: Address[];\n // There's just one version of the MultiOwnerLightAccount for now, so skip requiring the version as a parameter.\n};\n\n// Note: assumes the owner addresses are already deduped, sorted in ascending order, and have the signer address included.\nexport function predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddresses,\n}: PredictMultiOwnerLightAccountAddressParams): Address {\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress !==\n AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].addresses.default\n .factory\n ? getContractAddress({\n from: factoryAddress,\n nonce: 1n,\n })\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].addresses\n .default.impl;\n\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address[]\" }, { type: \"uint256\" }],\n [ownerAddresses, salt],\n ),\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n}\n\n// Bytecode from https://github.com/Vectorized/solady/blob/c6e5238e5f3b621789c59e1a443f43b6606394b2/src/utils/LibClone.sol#L721\n\nfunction getLAv2ProxyBytecode(implementationAddress: Address): Hex {\n return `0x603d3d8160223d3973${implementationAddress.slice(\n 2,\n )}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3`;\n}\n\nfunction assertNeverLightAccountVersion(version: never): never {\n throw new Error(`Unknown light account version: ${version}`);\n}\n"]}
@@ -30,4 +30,4 @@ export type TransferLightAccountOwnershipParams<TSigner extends SmartAccountSign
30
30
  * @param {TransferLightAccountOwnershipParams<TSigner, TAccount>} args The parameters for transferring ownership
31
31
  * @returns {Promise<Hex>} The transaction or UO hash as a Hex string
32
32
  */
33
- export declare const transferOwnership: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TSigner extends SmartAccountSigner<any> = SmartAccountSigner<any>, TAccount extends LightAccount<TSigner> | undefined = LightAccount<TSigner> | undefined>(client: Client<TTransport, TChain, TAccount>, args: TransferLightAccountOwnershipParams<TSigner, TAccount, GetEntryPointFromAccount<TAccount, import("@aa-sdk/core").SmartContractAccount<string, keyof import("@aa-sdk/core").EntryPointRegistryBase<unknown>>>>) => Promise<Hex>;
33
+ export declare const transferOwnership: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TSigner extends SmartAccountSigner = SmartAccountSigner, TAccount extends LightAccount<TSigner> | undefined = LightAccount<TSigner> | undefined>(client: Client<TTransport, TChain, TAccount>, args: TransferLightAccountOwnershipParams<TSigner, TAccount>) => Promise<Hex>;
@@ -1 +1 @@
1
- {"version":3,"file":"transferOwnership.js","sourceRoot":"","sources":["../../../../../src/light-account/actions/transferOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,GAKrB,MAAM,cAAc,CAAC;AAgBtB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAQpC,MAA4C,EAC5C,IAA4D,EAC9C,EAAE;IAChB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QAC5C,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,IAAI;SACL;QACD,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n isSmartAccountClient,\n type GetAccountParameter,\n type GetEntryPointFromAccount,\n type SmartAccountSigner,\n type UserOperationOverridesParameter,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { LightAccount } from \"../accounts/account\";\n\nexport type TransferLightAccountOwnershipParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n newOwner: TSigner;\n waitForTxn?: boolean;\n} & GetAccountParameter<TAccount, LightAccount<TSigner>> &\n UserOperationOverridesParameter<TEntryPointVersion>;\n\n/**\n * Transfers the ownership of a light account to a new owner.\n * This function ensures that the client is a compatible smart acccount client and that a Light Account is provided.\n * If the waitForTxn parameter is true, it will wait for the transaction to be completed before returning.\n *\n * @example\n * ```ts\n * import { transferOwnership, createLightAccountClient } from \"@account-kit/smart-contracts\";\n *\n * const lightAccountClient = createLightAccountClient({\n * signer,\n * transport,\n * chain,\n * });\n *\n * const txHash = await transferOwnership(lightAccountClient, {\n * newOwner: newOwnerSigner,\n * waitForTxn: true, // set to false to return a uoHash instead\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The smart account client instance used to execute the transfer\n * @param {TransferLightAccountOwnershipParams<TSigner, TAccount>} args The parameters for transferring ownership\n * @returns {Promise<Hex>} The transaction or UO hash as a Hex string\n */\nexport const transferOwnership = async <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: TransferLightAccountOwnershipParams<TSigner, TAccount>\n): Promise<Hex> => {\n const { newOwner, waitForTxn, overrides, account = client.account } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"transferOwnership\",\n client\n );\n }\n\n const data = account.encodeTransferOwnership(await newOwner.getAddress());\n\n const result = await client.sendUserOperation({\n uo: {\n target: account.address,\n data,\n },\n account,\n overrides,\n });\n\n if (waitForTxn) {\n return client.waitForUserOperationTransaction(result);\n }\n\n return result.hash;\n};\n"]}
1
+ {"version":3,"file":"transferOwnership.js","sourceRoot":"","sources":["../../../../../src/light-account/actions/transferOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,GAKrB,MAAM,cAAc,CAAC;AAiBtB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAQpC,MAA4C,EAC5C,IAA4D,EAC9C,EAAE;IAChB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QAC5C,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,IAAI;SACL;QACD,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n isSmartAccountClient,\n type GetAccountParameter,\n type GetEntryPointFromAccount,\n type SmartAccountSigner,\n type UserOperationOverridesParameter,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { LightAccount } from \"../accounts/account\";\n\nexport type TransferLightAccountOwnershipParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n> = {\n newOwner: TSigner;\n waitForTxn?: boolean;\n} & GetAccountParameter<TAccount, LightAccount<TSigner>> &\n UserOperationOverridesParameter<TEntryPointVersion>;\n\n/**\n * Transfers the ownership of a light account to a new owner.\n * This function ensures that the client is a compatible smart acccount client and that a Light Account is provided.\n * If the waitForTxn parameter is true, it will wait for the transaction to be completed before returning.\n *\n * @example\n * ```ts\n * import { transferOwnership, createLightAccountClient } from \"@account-kit/smart-contracts\";\n *\n * const lightAccountClient = createLightAccountClient({\n * signer,\n * transport,\n * chain,\n * });\n *\n * const txHash = await transferOwnership(lightAccountClient, {\n * newOwner: newOwnerSigner,\n * waitForTxn: true, // set to false to return a uoHash instead\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The smart account client instance used to execute the transfer\n * @param {TransferLightAccountOwnershipParams<TSigner, TAccount>} args The parameters for transferring ownership\n * @returns {Promise<Hex>} The transaction or UO hash as a Hex string\n */\nexport const transferOwnership = async <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: TransferLightAccountOwnershipParams<TSigner, TAccount>,\n): Promise<Hex> => {\n const { newOwner, waitForTxn, overrides, account = client.account } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"transferOwnership\",\n client,\n );\n }\n\n const data = account.encodeTransferOwnership(await newOwner.getAddress());\n\n const result = await client.sendUserOperation({\n uo: {\n target: account.address,\n data,\n },\n account,\n overrides,\n });\n\n if (waitForTxn) {\n return client.waitForUserOperationTransaction(result);\n }\n\n return result.hash;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"updateOwners.js","sourceRoot":"","sources":["../../../../../src/light-account/actions/updateOwners.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,GAKrB,MAAM,cAAc,CAAC;AAiBtB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,YAAY,GAUL,KAAK,EACvB,MAAM,EACN,EACE,WAAW,EACX,cAAc,EACd,UAAU,EACV,SAAS,EACT,OAAO,GAAG,MAAM,CAAC,OAAO,GACzB,EACD,EAAE;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,cAAc,EACd,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QAC5C,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,IAAI;SACL;QACD,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n isSmartAccountClient,\n type GetAccountParameter,\n type GetEntryPointFromAccount,\n type SmartAccountSigner,\n type UserOperationOverridesParameter,\n} from \"@aa-sdk/core\";\nimport type { Address, Chain, Client, Hex, Transport } from \"viem\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multiOwner\";\n\nexport type UpdateMultiOwnerLightAccountOwnersParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n waitForTxn?: boolean;\n} & GetAccountParameter<TAccount, MultiOwnerLightAccount<TSigner>> &\n UserOperationOverridesParameter<TEntryPointVersion>;\n\n/**\n * Updates the owners of a multi-owner light account. This includes adding new owners and removing existing ones.\n *\n * @example\n * ```ts\n * import { updateOwners, createLightAccountClient } from \"@account-kit/smart-contracts\";\n *\n * const lightAccountClient = createLightAccountClient({\n * signer,\n * transport,\n * chain,\n * });\n *\n * const txHash = await updateOwners(lightAccountClient, {\n * ownerstoAdd: [newOwnerAddress], // or empty if you just want to remove owners\n * ownersToRemove: [oldOwnerAddress], // or empty if you just want to add owners\n * waitForTxn: true, // set to false to return a uoHash instead\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @param {UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>} args The parameters for updating the account owners\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash or the full transaction result if `waitForTxn` is `true`\n */\nexport const updateOwners: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>\n) => Promise<Hex> = async (\n client,\n {\n ownersToAdd,\n ownersToRemove,\n waitForTxn,\n overrides,\n account = client.account,\n }\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"updateOwners\",\n client\n );\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const result = await client.sendUserOperation({\n uo: {\n target: account.address,\n data,\n },\n account,\n overrides,\n });\n\n if (waitForTxn) {\n return client.waitForUserOperationTransaction(result);\n }\n\n return result.hash;\n};\n"]}
1
+ {"version":3,"file":"updateOwners.js","sourceRoot":"","sources":["../../../../../src/light-account/actions/updateOwners.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,GAKrB,MAAM,cAAc,CAAC;AAkBtB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,YAAY,GAUL,KAAK,EACvB,MAAM,EACN,EACE,WAAW,EACX,cAAc,EACd,UAAU,EACV,SAAS,EACT,OAAO,GAAG,MAAM,CAAC,OAAO,GACzB,EACD,EAAE;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,cAAc,EACd,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QAC5C,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,IAAI;SACL;QACD,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n isSmartAccountClient,\n type GetAccountParameter,\n type GetEntryPointFromAccount,\n type SmartAccountSigner,\n type UserOperationOverridesParameter,\n} from \"@aa-sdk/core\";\nimport type { Address, Chain, Client, Hex, Transport } from \"viem\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multiOwner\";\n\nexport type UpdateMultiOwnerLightAccountOwnersParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined,\n TEntryPointVersion extends\n GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n> = {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n waitForTxn?: boolean;\n} & GetAccountParameter<TAccount, MultiOwnerLightAccount<TSigner>> &\n UserOperationOverridesParameter<TEntryPointVersion>;\n\n/**\n * Updates the owners of a multi-owner light account. This includes adding new owners and removing existing ones.\n *\n * @example\n * ```ts\n * import { updateOwners, createLightAccountClient } from \"@account-kit/smart-contracts\";\n *\n * const lightAccountClient = createLightAccountClient({\n * signer,\n * transport,\n * chain,\n * });\n *\n * const txHash = await updateOwners(lightAccountClient, {\n * ownerstoAdd: [newOwnerAddress], // or empty if you just want to remove owners\n * ownersToRemove: [oldOwnerAddress], // or empty if you just want to add owners\n * waitForTxn: true, // set to false to return a uoHash instead\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @param {UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>} args The parameters for updating the account owners\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash or the full transaction result if `waitForTxn` is `true`\n */\nexport const updateOwners: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>,\n) => Promise<Hex> = async (\n client,\n {\n ownersToAdd,\n ownersToRemove,\n waitForTxn,\n overrides,\n account = client.account,\n },\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"updateOwners\",\n client,\n );\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const result = await client.sendUserOperation({\n uo: {\n target: account.address,\n data,\n },\n account,\n overrides,\n });\n\n if (waitForTxn) {\n return client.waitForUserOperationTransaction(result);\n }\n\n return result.hash;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,GAIzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAsBlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,EACpD,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACuB;IAChC,OAAO,wBAAwB,CAAC;QAC9B,IAAI;QACJ,SAAS;QACT,KAAK;QACL,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createLightAccountClient,\n type CreateLightAccountParams,\n type LightAccount,\n type LightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, \"transport\"> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyLightAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n LightAccount<TSigner>,\n LightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates an Alchemy smart account client connected to a Light Account instance.\n *\n * @example\n * ```ts\n * import { createLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createLightAccountAlchemyClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n * @deprecated Use createLightAccountClient instead now, it should switch depending on the transport\n * @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client\n */\nexport async function createLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n return createLightAccountClient({\n opts,\n transport,\n chain,\n ...config,\n });\n}\n"]}
1
+ {"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,GAIzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAsBlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,EACpD,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACuB;IAChC,OAAO,wBAAwB,CAAC;QAC9B,IAAI;QACJ,SAAS;QACT,KAAK;QACL,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createLightAccountClient,\n type CreateLightAccountParams,\n type LightAccount,\n type LightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, \"transport\"> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n params: AlchemyLightAccountClientConfig<TSigner>,\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n LightAccount<TSigner>,\n LightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates an Alchemy smart account client connected to a Light Account instance.\n *\n * @example\n * ```ts\n * import { createLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createLightAccountAlchemyClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n * @deprecated Use createLightAccountClient instead now, it should switch depending on the transport\n * @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client\n */\nexport async function createLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n return createLightAccountClient({\n opts,\n transport,\n chain,\n ...config,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAOzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoD,MAAM,MAAM,CAAC;AACxE,OAAO,EACL,kBAAkB,GAGnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwC,MAAM,oBAAoB,CAAC;AA6C1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAsC;IAEtC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC;QAC5C,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IACH,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS;QACT,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type NotType,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { type Chain, type CustomTransport, type Transport } from \"viem\";\nimport {\n createLightAccount,\n type CreateLightAccountParams,\n type LightAccount,\n} from \"@account-kit/smart-contracts\";\nimport {\n lightAccountClientActions,\n type LightAccountClientActions,\n} from \"../decorators/lightAccount.js\";\nimport {\n isAlchemyTransport,\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport { type AlchemyLightAccountClientConfig } from \"./alchemyClient.js\";\n\nexport type CreateLightAccountClientParams<\n TTransport extends Transport | AlchemyTransport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = {\n transport: CreateLightAccountParams<TTransport, TSigner>[\"transport\"];\n chain: CreateLightAccountParams<TTransport, TSigner>[\"chain\"];\n} & Omit<CreateLightAccountParams<TTransport, TSigner>, \"transport\" | \"chain\"> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport function createLightAccountClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n }\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n LightAccount<TSigner>,\n LightAccountClientActions<TSigner>\n >\n>;\nexport function createLightAccountClient<\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport\n>(\n args: CreateLightAccountClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>\n): Promise<\n SmartAccountClient<\n CustomTransport,\n TChain,\n LightAccount<TSigner>,\n SmartAccountClientActions<Chain, SmartContractAccount> &\n LightAccountClientActions<TSigner, LightAccount<TSigner>>\n >\n>;\n\n/**\n * Creates a light account client using the provided parameters, including account information, transport mechanism, blockchain chain, and additional client configurations. This function first creates a light account and then uses it to create a smart account client, extending it with light account client actions.\n *\n * Also, we modified the return type to be the light account alchemy client if the transport is alchemy.\n *\n * @example\n * ```ts\n * import { createLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createLightAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n * @example\n * ```ts\n * import { createLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAlchemyAccountClient = await createLightAccountClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateLightAccountClientParams} params The parameters for creating a light account client\n * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` object containing the created account information and methods\n */\nexport async function createLightAccountClient(\n params: CreateLightAccountClientParams\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = params;\n\n const lightAccount = await createLightAccount({\n ...params,\n transport,\n chain,\n });\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...params,\n transport,\n chain,\n account: lightAccount,\n }).extend(lightAccountClientActions);\n }\n\n return createSmartAccountClient({\n ...params,\n transport,\n chain: chain,\n account: lightAccount,\n }).extend(lightAccountClientActions);\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAOzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoD,MAAM,MAAM,CAAC;AACxE,OAAO,EACL,kBAAkB,GAGnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwC,MAAM,oBAAoB,CAAC;AA6C1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAsC;IAEtC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC;QAC5C,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IACH,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS;QACT,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type NotType,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { type Chain, type CustomTransport, type Transport } from \"viem\";\nimport {\n createLightAccount,\n type CreateLightAccountParams,\n type LightAccount,\n} from \"@account-kit/smart-contracts\";\nimport {\n lightAccountClientActions,\n type LightAccountClientActions,\n} from \"../decorators/lightAccount.js\";\nimport {\n isAlchemyTransport,\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport { type AlchemyLightAccountClientConfig } from \"./alchemyClient.js\";\n\nexport type CreateLightAccountClientParams<\n TTransport extends Transport | AlchemyTransport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = {\n transport: CreateLightAccountParams<TTransport, TSigner>[\"transport\"];\n chain: CreateLightAccountParams<TTransport, TSigner>[\"chain\"];\n} & Omit<CreateLightAccountParams<TTransport, TSigner>, \"transport\" | \"chain\"> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport function createLightAccountClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n params: AlchemyLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n },\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n LightAccount<TSigner>,\n LightAccountClientActions<TSigner>\n >\n>;\nexport function createLightAccountClient<\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport,\n>(\n args: CreateLightAccountClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>,\n): Promise<\n SmartAccountClient<\n CustomTransport,\n TChain,\n LightAccount<TSigner>,\n SmartAccountClientActions<Chain, SmartContractAccount> &\n LightAccountClientActions<TSigner, LightAccount<TSigner>>\n >\n>;\n\n/**\n * Creates a light account client using the provided parameters, including account information, transport mechanism, blockchain chain, and additional client configurations. This function first creates a light account and then uses it to create a smart account client, extending it with light account client actions.\n *\n * Also, we modified the return type to be the light account alchemy client if the transport is alchemy.\n *\n * @example\n * ```ts\n * import { createLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createLightAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n * @example\n * ```ts\n * import { createLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAlchemyAccountClient = await createLightAccountClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateLightAccountClientParams} params The parameters for creating a light account client\n * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` object containing the created account information and methods\n */\nexport async function createLightAccountClient(\n params: CreateLightAccountClientParams,\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = params;\n\n const lightAccount = await createLightAccount({\n ...params,\n transport,\n chain,\n });\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...params,\n transport,\n chain,\n account: lightAccount,\n }).extend(lightAccountClientActions);\n }\n\n return createSmartAccountClient({\n ...params,\n transport,\n chain: chain,\n account: lightAccount,\n }).extend(lightAccountClientActions);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multiOwnerAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kCAAkC,GAInC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAyBlC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAAC,EAC9D,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACiC;IAC1C,OAAO,kCAAkC,CAAC;QACxC,IAAI;QACJ,SAAS;QACT,KAAK;QACL,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createMultiOwnerLightAccountClient,\n type CreateMultiOwnerLightAccountParams,\n type MultiOwnerLightAccount,\n type MultiOwnerLightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyMultiOwnerLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<\n CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>,\n \"transport\" | \"type\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createMultiOwnerLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerLightAccount<TSigner>,\n MultiOwnerLightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates a multi-owner light account Alchemy client using the provided configuration.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({\n * transport: alchemy({\n * apiKey: \"your-api-key\",\n * }),\n * chain: sepolia\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @deprecated Use createMultiOwnerLightAccountAlchemyClient instead now, it should switch depending on the transport\n * @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods\n */\nexport async function createMultiOwnerLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyMultiOwnerLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n return createMultiOwnerLightAccountClient({\n opts,\n transport,\n chain,\n ...config,\n });\n}\n"]}
1
+ {"version":3,"file":"multiOwnerAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kCAAkC,GAInC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAyBlC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAAC,EAC9D,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACiC;IAC1C,OAAO,kCAAkC,CAAC;QACxC,IAAI;QACJ,SAAS;QACT,KAAK;QACL,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createMultiOwnerLightAccountClient,\n type CreateMultiOwnerLightAccountParams,\n type MultiOwnerLightAccount,\n type MultiOwnerLightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyMultiOwnerLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Omit<\n CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>,\n \"transport\" | \"type\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createMultiOwnerLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>,\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerLightAccount<TSigner>,\n MultiOwnerLightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates a multi-owner light account Alchemy client using the provided configuration.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({\n * transport: alchemy({\n * apiKey: \"your-api-key\",\n * }),\n * chain: sepolia\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @deprecated Use createMultiOwnerLightAccountAlchemyClient instead now, it should switch depending on the transport\n * @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods\n */\nexport async function createMultiOwnerLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyMultiOwnerLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n return createMultiOwnerLightAccountClient({\n opts,\n transport,\n chain,\n ...config,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multiOwnerLightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerLightAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAOzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoD,MAAM,MAAM,CAAC;AACxE,OAAO,EACL,mCAAmC,EACnC,4BAA4B,GAK7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAiE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,MAAgE;IAEhE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,YAAY,GAAG,MAAM,4BAA4B,CAAC;QACtD,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IACH,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS;QACT,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type NotType,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { type Chain, type CustomTransport, type Transport } from \"viem\";\nimport {\n multiOwnerLightAccountClientActions,\n createMultiOwnerLightAccount,\n type CreateMultiOwnerLightAccountParams,\n type MultiOwnerLightAccount,\n type MultiOwnerLightAccountClientActions,\n type AlchemyMultiOwnerLightAccountClientConfig,\n} from \"@account-kit/smart-contracts\";\nimport {\n isAlchemyTransport,\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\n\nexport type CreateMultiOwnerLightAccountClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = {\n transport: CreateMultiOwnerLightAccountParams<\n TTransport,\n TSigner\n >[\"transport\"];\n chain: CreateMultiOwnerLightAccountParams<TTransport, TSigner>[\"chain\"];\n} & Omit<\n CreateMultiOwnerLightAccountParams<TTransport, TSigner>,\n \"transport\" | \"chain\"\n> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport type CreateMultiOwnerLightAccountClientDynamicTransportParams<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> =\n | (AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n })\n | CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner>;\n\nexport async function createMultiOwnerLightAccountClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n }\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerLightAccount<TSigner>,\n MultiOwnerLightAccountClientActions<TSigner>\n >\n>;\n\nexport function createMultiOwnerLightAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n args: CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>\n): Promise<\n SmartAccountClient<\n CustomTransport,\n Chain,\n MultiOwnerLightAccount<TSigner>,\n SmartAccountClientActions<Chain, SmartContractAccount> &\n MultiOwnerLightAccountClientActions<\n TSigner,\n MultiOwnerLightAccount<TSigner>\n >\n >\n>;\n\n/**\n * Creates a multi-owner light account client using the provided parameters. It first creates a multi-owner light account and then creates a smart account client with the provided configurations.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createMultiOwnerLightAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createMultiOwnerLightAccountClient({\n * transport: alchemy({\n * apiKey: \"your-api-key\",\n * }),\n * chain: sepolia\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateMultiOwnerLightAccountClientDynamicTransportParams} params the configuration for creating the multi-owner light / alchemy account client with the provided parameters transport\n * @returns {Promise<SmartAccountClient>} a promise that resolves to a `SmartAccountClient` containing the created account client and relevant methods\n */\nexport async function createMultiOwnerLightAccountClient(\n params: CreateMultiOwnerLightAccountClientDynamicTransportParams\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = params;\n\n const lightAccount = await createMultiOwnerLightAccount({\n ...params,\n transport,\n chain,\n });\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...params,\n transport,\n chain,\n account: lightAccount,\n }).extend(multiOwnerLightAccountClientActions);\n }\n\n return createSmartAccountClient({\n ...params,\n transport,\n chain: chain,\n account: lightAccount,\n }).extend(multiOwnerLightAccountClientActions);\n}\n"]}
1
+ {"version":3,"file":"multiOwnerLightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerLightAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAOzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoD,MAAM,MAAM,CAAC;AACxE,OAAO,EACL,mCAAmC,EACnC,4BAA4B,GAK7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAiE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,MAAgE;IAEhE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,YAAY,GAAG,MAAM,4BAA4B,CAAC;QACtD,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IACH,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO,EAAE,YAAY;SACtB,CAAC,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,SAAS;QACT,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type NotType,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { type Chain, type CustomTransport, type Transport } from \"viem\";\nimport {\n multiOwnerLightAccountClientActions,\n createMultiOwnerLightAccount,\n type CreateMultiOwnerLightAccountParams,\n type MultiOwnerLightAccount,\n type MultiOwnerLightAccountClientActions,\n type AlchemyMultiOwnerLightAccountClientConfig,\n} from \"@account-kit/smart-contracts\";\nimport {\n isAlchemyTransport,\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\n\nexport type CreateMultiOwnerLightAccountClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = {\n transport: CreateMultiOwnerLightAccountParams<\n TTransport,\n TSigner\n >[\"transport\"];\n chain: CreateMultiOwnerLightAccountParams<TTransport, TSigner>[\"chain\"];\n} & Omit<\n CreateMultiOwnerLightAccountParams<TTransport, TSigner>,\n \"transport\" | \"chain\"\n> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport type CreateMultiOwnerLightAccountClientDynamicTransportParams<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> =\n | (AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n })\n | CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner>;\n\nexport async function createMultiOwnerLightAccountClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n params: AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {\n transport: AlchemyTransport;\n },\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerLightAccount<TSigner>,\n MultiOwnerLightAccountClientActions<TSigner>\n >\n>;\n\nexport function createMultiOwnerLightAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n args: CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>,\n): Promise<\n SmartAccountClient<\n CustomTransport,\n Chain,\n MultiOwnerLightAccount<TSigner>,\n SmartAccountClientActions<Chain, SmartContractAccount> &\n MultiOwnerLightAccountClientActions<\n TSigner,\n MultiOwnerLightAccount<TSigner>\n >\n >\n>;\n\n/**\n * Creates a multi-owner light account client using the provided parameters. It first creates a multi-owner light account and then creates a smart account client with the provided configurations.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { sepolia } from \"viem/chains\";\n * import { http, generatePrivateKey } from \"viem\"\n *\n * const account = await createMultiOwnerLightAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createMultiOwnerLightAccountClient({\n * transport: alchemy({\n * apiKey: \"your-api-key\",\n * }),\n * chain: sepolia\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {CreateMultiOwnerLightAccountClientDynamicTransportParams} params the configuration for creating the multi-owner light / alchemy account client with the provided parameters transport\n * @returns {Promise<SmartAccountClient>} a promise that resolves to a `SmartAccountClient` containing the created account client and relevant methods\n */\nexport async function createMultiOwnerLightAccountClient(\n params: CreateMultiOwnerLightAccountClientDynamicTransportParams,\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = params;\n\n const lightAccount = await createMultiOwnerLightAccount({\n ...params,\n transport,\n chain,\n });\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...params,\n transport,\n chain,\n account: lightAccount,\n }).extend(multiOwnerLightAccountClientActions);\n }\n\n return createSmartAccountClient({\n ...params,\n transport,\n chain: chain,\n account: lightAccount,\n }).extend(multiOwnerLightAccountClientActions);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/decorators/lightAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,GAElB,MAAM,iCAAiC,CAAC;AAazC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GASc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/D,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;CACnE,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { LightAccount } from \"../accounts/account\";\nimport {\n transferOwnership,\n type TransferLightAccountOwnershipParams,\n} from \"../actions/transferOwnership.js\";\n\nexport type LightAccountClientActions<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined\n> = {\n transferOwnership: (\n args: TransferLightAccountOwnershipParams<TSigner, TAccount>\n ) => Promise<Hex>;\n};\n\n/**\n * Provides a set of actions for managing a light account client, including transferring ownership.\n *\n * @example\n * ```ts\n * import { lightAccountClientActions, createLightAccount } from \"@account-kit/smart-contracts\";\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra\";\n *\n * const smartAccountClient = createAlchemySmartAccountClient({\n * account: await createLightAccount(...),\n * apiKey: \"your-api-key\",\n * chain: sepolia,\n * }).extend(lightAccountClientActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions\n * @returns {LightAccountClientActions<TSigner, TAccount>} An object containing the available light account client actions\n */\nexport const lightAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => LightAccountClientActions<TSigner, TAccount> = (client) => ({\n transferOwnership: async (args) => transferOwnership(client, args),\n});\n"]}
1
+ {"version":3,"file":"lightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/decorators/lightAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,GAElB,MAAM,iCAAiC,CAAC;AAazC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GASc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/D,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;CACnE,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { LightAccount } from \"../accounts/account\";\nimport {\n transferOwnership,\n type TransferLightAccountOwnershipParams,\n} from \"../actions/transferOwnership.js\";\n\nexport type LightAccountClientActions<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined,\n> = {\n transferOwnership: (\n args: TransferLightAccountOwnershipParams<TSigner, TAccount>,\n ) => Promise<Hex>;\n};\n\n/**\n * Provides a set of actions for managing a light account client, including transferring ownership.\n *\n * @example\n * ```ts\n * import { lightAccountClientActions, createLightAccount } from \"@account-kit/smart-contracts\";\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra\";\n *\n * const smartAccountClient = createAlchemySmartAccountClient({\n * account: await createLightAccount(...),\n * apiKey: \"your-api-key\",\n * chain: sepolia,\n * }).extend(lightAccountClientActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions\n * @returns {LightAccountClientActions<TSigner, TAccount>} An object containing the available light account client actions\n */\nexport const lightAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends LightAccount<TSigner> | undefined =\n | LightAccount<TSigner>\n | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n) => LightAccountClientActions<TSigner, TAccount> = (client) => ({\n transferOwnership: async (args) => transferOwnership(client, args),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multiOwnerLightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/decorators/multiOwnerLightAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,GAEb,MAAM,4BAA4B,CAAC;AAapC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mCAAmC,GASc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;CACzD,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multiOwner\";\nimport {\n updateOwners,\n type UpdateMultiOwnerLightAccountOwnersParams,\n} from \"../actions/updateOwners.js\";\n\nexport type MultiOwnerLightAccountClientActions<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined\n> = {\n updateOwners: (\n args: UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>\n ) => Promise<Hex>;\n};\n\n/**\n * Generates client actions for a multi-owner light account, including the ability to update owners.\n *\n * @example\n * ```ts\n * import { multiOwnerLightAccountClientActions, createMultiOwnerLightAccount } from \"@account-kit/smart-contracts\";\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra\";\n *\n * const smartAccountClient = createAlchemySmartAccountClient({\n * account: await createMultiOwnerLightAccount(...),\n * apiKey: \"your-api-key\",\n * chain: sepolia,\n * }).extend(multiOwnerLightAccountClientActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the client for interacting with the multi-owner light account\n * @returns {MultiOwnerLightAccountClientActions<TSigner, TAccount>} an object containing the client actions specifically for a multi-owner light account\n */\nexport const multiOwnerLightAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => MultiOwnerLightAccountClientActions<TSigner, TAccount> = (client) => ({\n updateOwners: async (args) => updateOwners(client, args),\n});\n"]}
1
+ {"version":3,"file":"multiOwnerLightAccount.js","sourceRoot":"","sources":["../../../../../src/light-account/decorators/multiOwnerLightAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,GAEb,MAAM,4BAA4B,CAAC;AAapC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mCAAmC,GASc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC;CACzD,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multiOwner\";\nimport {\n updateOwners,\n type UpdateMultiOwnerLightAccountOwnersParams,\n} from \"../actions/updateOwners.js\";\n\nexport type MultiOwnerLightAccountClientActions<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined,\n> = {\n updateOwners: (\n args: UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>,\n ) => Promise<Hex>;\n};\n\n/**\n * Generates client actions for a multi-owner light account, including the ability to update owners.\n *\n * @example\n * ```ts\n * import { multiOwnerLightAccountClientActions, createMultiOwnerLightAccount } from \"@account-kit/smart-contracts\";\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra\";\n *\n * const smartAccountClient = createAlchemySmartAccountClient({\n * account: await createMultiOwnerLightAccount(...),\n * apiKey: \"your-api-key\",\n * chain: sepolia,\n * }).extend(multiOwnerLightAccountClientActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the client for interacting with the multi-owner light account\n * @returns {MultiOwnerLightAccountClientActions<TSigner, TAccount>} an object containing the client actions specifically for a multi-owner light account\n */\nexport const multiOwnerLightAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TAccount extends MultiOwnerLightAccount<TSigner> | undefined =\n | MultiOwnerLightAccount<TSigner>\n | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n) => MultiOwnerLightAccountClientActions<TSigner, TAccount> = (client) => ({\n updateOwners: async (args) => updateOwners(client, args),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/light-account/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,MAAM,cAAc,CAAC;AACtD,OAAO,EAA4B,MAAM,MAAM,CAAC","sourcesContent":["import { type EntryPointVersion } from \"@aa-sdk/core\";\nimport { type Address, type Chain } from \"viem\";\nimport type { LightAccountBase } from \"./accounts/base\";\n\n/**\n * Light account types supported: LightAccount, MultiOwnerLightAccount\n *\n */\nexport type LightAccountType = \"LightAccount\" | \"MultiOwnerLightAccount\";\n\nexport type LightAccountVersionConfig<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n entryPointVersion: TEntryPointVersion;\n addresses: {\n default: {\n factory: Address;\n impl: Address;\n };\n overrides?: Record<\n Chain[\"id\"],\n {\n factory: Address;\n impl: Address;\n }\n >;\n };\n};\n\nexport type LightAccountVersionConfigs = {\n LightAccount: {\n \"v1.0.1\": LightAccountVersionConfig<\"0.6.0\">;\n \"v1.0.2\": LightAccountVersionConfig<\"0.6.0\">;\n \"v1.1.0\": LightAccountVersionConfig<\"0.6.0\">;\n \"v2.0.0\": LightAccountVersionConfig<\"0.7.0\">;\n };\n MultiOwnerLightAccount: {\n \"v2.0.0\": LightAccountVersionConfig<\"0.7.0\">;\n };\n};\n\nexport type LightAccountVersion<TAccountType extends LightAccountType> =\n keyof LightAccountVersionConfigs[TAccountType];\n\nexport type GetLightAccountType<TAccount extends LightAccountBase> =\n TAccount[\"source\"] extends LightAccountType ? TAccount[\"source\"] : never;\n\nexport type LightAccountEntryPointVersion<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>\n> = LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion] extends LightAccountVersionConfig\n ? LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion][\"entryPointVersion\"]\n : never;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/light-account/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,MAAM,cAAc,CAAC;AACtD,OAAO,EAA4B,MAAM,MAAM,CAAC","sourcesContent":["import { type EntryPointVersion } from \"@aa-sdk/core\";\nimport { type Address, type Chain } from \"viem\";\nimport type { LightAccountBase } from \"./accounts/base\";\n\n/**\n * Light account types supported: LightAccount, MultiOwnerLightAccount\n *\n */\nexport type LightAccountType = \"LightAccount\" | \"MultiOwnerLightAccount\";\n\nexport type LightAccountVersionConfig<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = {\n entryPointVersion: TEntryPointVersion;\n addresses: {\n default: {\n factory: Address;\n impl: Address;\n };\n overrides?: Record<\n Chain[\"id\"],\n {\n factory: Address;\n impl: Address;\n }\n >;\n };\n};\n\nexport type LightAccountVersionConfigs = {\n LightAccount: {\n \"v1.0.1\": LightAccountVersionConfig<\"0.6.0\">;\n \"v1.0.2\": LightAccountVersionConfig<\"0.6.0\">;\n \"v1.1.0\": LightAccountVersionConfig<\"0.6.0\">;\n \"v2.0.0\": LightAccountVersionConfig<\"0.7.0\">;\n };\n MultiOwnerLightAccount: {\n \"v2.0.0\": LightAccountVersionConfig<\"0.7.0\">;\n };\n};\n\nexport type LightAccountVersion<TAccountType extends LightAccountType> =\n keyof LightAccountVersionConfigs[TAccountType];\n\nexport type GetLightAccountType<TAccount extends LightAccountBase> =\n TAccount[\"source\"] extends LightAccountType ? TAccount[\"source\"] : never;\n\nexport type LightAccountEntryPointVersion<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends\n LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n> = LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion] extends LightAccountVersionConfig\n ? LightAccountVersionConfigs[TLightAccountType][TLightAccountVersion][\"entryPointVersion\"]\n : never;\n"]}
@@ -13,7 +13,7 @@ export declare const AccountVersionRegistry: LightAccountVersionConfigs;
13
13
  * @template {LightAccountType} TLightAccountType
14
14
  * @returns {LightAccountVersion<TLightAccountType>} the default version for the given light account type
15
15
  */
16
- export declare const defaultLightAccountVersion: <TLightAccountType extends LightAccountType>() => keyof LightAccountVersionConfigs[TLightAccountType];
16
+ export declare const defaultLightAccountVersion: <TLightAccountType extends LightAccountType>() => LightAccountVersion<TLightAccountType>;
17
17
  /**
18
18
  * Utility method returning the default light account factory address given a Chain object
19
19
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/light-account/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EA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CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,GACX,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,EAAE;QACnC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,EAAa,CAAC;QAC/D,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,EAAa,CAAC,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,CAAC,MAAM,sBAAsB,KAAK,CAAC,EAAE,EAAE,CACtE,CAAC;IACJ,CAAC;IAED,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { GetEntryPointFromAccount } from \"@aa-sdk/core\";\nimport { fromHex, type Address, type Chain } from \"viem\";\nimport type { LightAccountBase } from \"./accounts/base\";\nimport type {\n LightAccountType,\n LightAccountVersion,\n LightAccountVersionConfig,\n LightAccountVersionConfigs,\n} from \"./types\";\n\n/**\n * Account version registry interface that defines the light account versions\n * and the version definition for each light account type\n *\n */\nexport const AccountVersionRegistry: LightAccountVersionConfigs = {\n LightAccount: {\n \"v1.0.1\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x000000893A26168158fbeaDD9335Be5bC96592E2\".toLowerCase() as Address,\n impl: \"0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0\".toLowerCase() as Address,\n },\n },\n },\n \"v1.0.2\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x00000055C0b4fA41dde26A74435ff03692292FBD\".toLowerCase() as Address,\n impl: \"0x5467b1947F47d0646704EB801E075e72aeAe8113\".toLowerCase() as Address,\n },\n },\n },\n \"v1.1.0\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x00004EC70002a32400f8ae005A26081065620D20\".toLowerCase() as Address,\n impl: \"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba\".toLowerCase() as Address,\n },\n },\n },\n \"v2.0.0\": {\n entryPointVersion: \"0.7.0\",\n addresses: {\n default: {\n factory:\n \"0x0000000000400CdFef5E2714E63d8040b700BC24\".toLowerCase() as Address,\n impl: \"0x8E8e658E22B12ada97B402fF0b044D6A325013C7\".toLowerCase() as Address,\n },\n },\n },\n },\n MultiOwnerLightAccount: {\n \"v2.0.0\": {\n entryPointVersion: \"0.7.0\",\n addresses: {\n default: {\n factory:\n \"0x000000000019d2Ee9F2729A65AfE20bb0020AefC\".toLowerCase() as Address,\n impl: \"0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D\".toLowerCase() as Address,\n },\n },\n },\n },\n};\n\n/**\n * Get the default light account version for the given light account type\n *\n * @template {LightAccountType} TLightAccountType\n * @returns {LightAccountVersion<TLightAccountType>} the default version for the given light account type\n */\nexport const defaultLightAccountVersion = <\n TLightAccountType extends LightAccountType\n>(): LightAccountVersion<TLightAccountType> => \"v2.0.0\";\n\n/**\n * Utility method returning the default light account factory address given a Chain object\n *\n * @param {Chain} chain - a Chain object\n * @param {LightAccountVersion} version - the version of the light account to get the factory address for\n * @returns {Address} an for the given chain\n * @throws if the chain doesn't have an address currently deployed\n */\nexport const getDefaultLightAccountFactoryAddress = (\n chain: Chain,\n version: LightAccountVersion<\"LightAccount\">\n): Address => {\n return (\n AccountVersionRegistry.LightAccount[version].addresses.overrides?.[chain.id]\n ?.factory ??\n AccountVersionRegistry.LightAccount[version].addresses.default.factory\n );\n};\n\n/**\n * Utility method returning the default multi owner light account factory address given a Chain object\n *\n * @param {Chain} chain - a Chain object\n * @param {string} version - the version of the light account to get the factory address for\n * @returns {Address} an Address for the given chain\n */\nexport const getDefaultMultiOwnerLightAccountFactoryAddress = (\n chain: Chain,\n version: LightAccountVersion<\"MultiOwnerLightAccount\">\n) => {\n return (\n AccountVersionRegistry.MultiOwnerLightAccount[version].addresses\n .overrides?.[chain.id]?.factory ??\n AccountVersionRegistry.MultiOwnerLightAccount[version].addresses.default\n .factory\n );\n};\n\n/**\n * Can be used to check if the account with one of the following implementation addresses\n * to not support 1271 signing.\n *\n * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.\n */\nexport const LightAccountUnsupported1271Impls = [\n AccountVersionRegistry.LightAccount[\"v1.0.1\"],\n AccountVersionRegistry.LightAccount[\"v1.0.2\"],\n];\n\n/**\n * Can be used to check if the account with one of the following factory addresses\n * to not support 1271 signing.\n *\n * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.\n */\nexport const LightAccountUnsupported1271Factories = new Set(\n LightAccountUnsupported1271Impls.map((x) => [\n x.addresses.default.factory,\n ...Object.values(x.addresses.overrides ?? {}).map((z) => z.factory),\n ]).flat()\n);\n\n/**\n * Get the light account version definition for the given light account and chain\n *\n * @template {LightAccountBase} TAccount\n * @param {LightAccountBase} account the light account to get the version for\n * @param {Chain} chain - the chain to get the version for\n * @returns {Promise<LightAccountVersionConfig>} the light account version definition for the given light account and chain\n */\nexport async function getLightAccountVersionForAccount<\n TAccount extends LightAccountBase\n>(account: TAccount, chain: Chain): Promise<LightAccountVersionConfig> {\n const accountType = account.source as LightAccountType;\n const factoryAddress = await account.getFactoryAddress();\n const implAddress = await account.getImplementationAddress();\n const implToVersion = new Map(\n Object.entries(AccountVersionRegistry[accountType]).map((pair) => {\n const [version, def] = pair as [\n LightAccountVersion<LightAccountType>,\n LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>\n ];\n\n if (\n def.addresses.overrides != null &&\n chain.id in def.addresses.overrides!\n ) {\n return [def.addresses.overrides[chain.id].impl, version];\n }\n\n return [def.addresses.default.impl, version];\n })\n );\n\n const factoryToVersion = new Map(\n Object.entries(AccountVersionRegistry[accountType]).map((pair) => {\n const [version, def] = pair as [\n LightAccountVersion<LightAccountType>,\n LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>\n ];\n\n if (\n def.addresses.overrides != null &&\n chain.id in def.addresses.overrides!\n ) {\n return [def.addresses.overrides[chain.id].factory, version];\n }\n\n return [def.addresses.default.factory, version];\n })\n );\n\n const version =\n fromHex(implAddress, \"bigint\") === 0n\n ? factoryToVersion.get(factoryAddress.toLowerCase() as Address)\n : implToVersion.get(implAddress.toLowerCase() as Address);\n\n if (!version) {\n throw new Error(\n `Could not determine ${account.source} version for chain ${chain.id}`\n );\n }\n\n return AccountVersionRegistry[accountType][version];\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/light-account/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA4B,MAAM,MAAM,CAAC;AASzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA+B;IAChE,YAAY,EAAE;QACZ,QAAQ,EAAE;YACR,iBAAiB,EAAE,OAAO;YAC1B,SAAS,EAAE;gBACT,OAAO,EAAE;oBACP,OAAO,EACL,4CAA4C,CAAC,WAAW,EAAa;oBACvE,IAAI,EAAE,4CAA4C,CAAC,WAAW,EAAa;iBAC5E;aACF;SACF;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,OAAO;YAC1B,SAAS,EAAE;gBACT,OAAO,EAAE;oBACP,OAAO,EACL,4CAA4C,CAAC,WAAW,EAAa;oBACvE,IAAI,EAAE,4CAA4C,CAAC,WAAW,EAAa;iBAC5E;aACF;SACF;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,OAAO;YAC1B,SAAS,EAAE;gBACT,OAAO,EAAE;oBACP,OAAO,EACL,4CAA4C,CAAC,WAAW,EAAa;oBACvE,IAAI,EAAE,4CAA4C,CAAC,WAAW,EAAa;iBAC5E;aACF;SACF;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,OAAO;YAC1B,SAAS,EAAE;gBACT,OAAO,EAAE;oBACP,OAAO,EACL,4CAA4C,CAAC,WAAW,EAAa;oBACvE,IAAI,EAAE,4CAA4C,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AsB,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/D,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAGtB,CAAC;QAEF,IACE,GAAG,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI;YAC/B,KAAK,CAAC,EAAE,IAAI,GAAG,CAAC,SAAS,CAAC,SAAU,EACpC,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,OAAO,GACX,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,EAAE;QACnC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,EAAa,CAAC;QAC/D,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,EAAa,CAAC,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,CAAC,MAAM,sBAAsB,KAAK,CAAC,EAAE,EAAE,CACtE,CAAC;IACJ,CAAC;IAED,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { GetEntryPointFromAccount } from \"@aa-sdk/core\";\nimport { fromHex, type Address, type Chain } from \"viem\";\nimport type { LightAccountBase } from \"./accounts/base\";\nimport type {\n LightAccountType,\n LightAccountVersion,\n LightAccountVersionConfig,\n LightAccountVersionConfigs,\n} from \"./types\";\n\n/**\n * Account version registry interface that defines the light account versions\n * and the version definition for each light account type\n *\n */\nexport const AccountVersionRegistry: LightAccountVersionConfigs = {\n LightAccount: {\n \"v1.0.1\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x000000893A26168158fbeaDD9335Be5bC96592E2\".toLowerCase() as Address,\n impl: \"0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0\".toLowerCase() as Address,\n },\n },\n },\n \"v1.0.2\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x00000055C0b4fA41dde26A74435ff03692292FBD\".toLowerCase() as Address,\n impl: \"0x5467b1947F47d0646704EB801E075e72aeAe8113\".toLowerCase() as Address,\n },\n },\n },\n \"v1.1.0\": {\n entryPointVersion: \"0.6.0\",\n addresses: {\n default: {\n factory:\n \"0x00004EC70002a32400f8ae005A26081065620D20\".toLowerCase() as Address,\n impl: \"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba\".toLowerCase() as Address,\n },\n },\n },\n \"v2.0.0\": {\n entryPointVersion: \"0.7.0\",\n addresses: {\n default: {\n factory:\n \"0x0000000000400CdFef5E2714E63d8040b700BC24\".toLowerCase() as Address,\n impl: \"0x8E8e658E22B12ada97B402fF0b044D6A325013C7\".toLowerCase() as Address,\n },\n },\n },\n },\n MultiOwnerLightAccount: {\n \"v2.0.0\": {\n entryPointVersion: \"0.7.0\",\n addresses: {\n default: {\n factory:\n \"0x000000000019d2Ee9F2729A65AfE20bb0020AefC\".toLowerCase() as Address,\n impl: \"0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D\".toLowerCase() as Address,\n },\n },\n },\n },\n};\n\n/**\n * Get the default light account version for the given light account type\n *\n * @template {LightAccountType} TLightAccountType\n * @returns {LightAccountVersion<TLightAccountType>} the default version for the given light account type\n */\nexport const defaultLightAccountVersion = <\n TLightAccountType extends LightAccountType,\n>(): LightAccountVersion<TLightAccountType> => \"v2.0.0\";\n\n/**\n * Utility method returning the default light account factory address given a Chain object\n *\n * @param {Chain} chain - a Chain object\n * @param {LightAccountVersion} version - the version of the light account to get the factory address for\n * @returns {Address} an for the given chain\n * @throws if the chain doesn't have an address currently deployed\n */\nexport const getDefaultLightAccountFactoryAddress = (\n chain: Chain,\n version: LightAccountVersion<\"LightAccount\">,\n): Address => {\n return (\n AccountVersionRegistry.LightAccount[version].addresses.overrides?.[chain.id]\n ?.factory ??\n AccountVersionRegistry.LightAccount[version].addresses.default.factory\n );\n};\n\n/**\n * Utility method returning the default multi owner light account factory address given a Chain object\n *\n * @param {Chain} chain - a Chain object\n * @param {string} version - the version of the light account to get the factory address for\n * @returns {Address} an Address for the given chain\n */\nexport const getDefaultMultiOwnerLightAccountFactoryAddress = (\n chain: Chain,\n version: LightAccountVersion<\"MultiOwnerLightAccount\">,\n) => {\n return (\n AccountVersionRegistry.MultiOwnerLightAccount[version].addresses\n .overrides?.[chain.id]?.factory ??\n AccountVersionRegistry.MultiOwnerLightAccount[version].addresses.default\n .factory\n );\n};\n\n/**\n * Can be used to check if the account with one of the following implementation addresses\n * to not support 1271 signing.\n *\n * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.\n */\nexport const LightAccountUnsupported1271Impls = [\n AccountVersionRegistry.LightAccount[\"v1.0.1\"],\n AccountVersionRegistry.LightAccount[\"v1.0.2\"],\n];\n\n/**\n * Can be used to check if the account with one of the following factory addresses\n * to not support 1271 signing.\n *\n * Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.\n */\nexport const LightAccountUnsupported1271Factories = new Set(\n LightAccountUnsupported1271Impls.map((x) => [\n x.addresses.default.factory,\n ...Object.values(x.addresses.overrides ?? {}).map((z) => z.factory),\n ]).flat(),\n);\n\n/**\n * Get the light account version definition for the given light account and chain\n *\n * @template {LightAccountBase} TAccount\n * @param {LightAccountBase} account the light account to get the version for\n * @param {Chain} chain - the chain to get the version for\n * @returns {Promise<LightAccountVersionConfig>} the light account version definition for the given light account and chain\n */\nexport async function getLightAccountVersionForAccount<\n TAccount extends LightAccountBase,\n>(account: TAccount, chain: Chain): Promise<LightAccountVersionConfig> {\n const accountType = account.source as LightAccountType;\n const factoryAddress = await account.getFactoryAddress();\n const implAddress = await account.getImplementationAddress();\n const implToVersion = new Map(\n Object.entries(AccountVersionRegistry[accountType]).map((pair) => {\n const [version, def] = pair as [\n LightAccountVersion<LightAccountType>,\n LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>,\n ];\n\n if (\n def.addresses.overrides != null &&\n chain.id in def.addresses.overrides!\n ) {\n return [def.addresses.overrides[chain.id].impl, version];\n }\n\n return [def.addresses.default.impl, version];\n }),\n );\n\n const factoryToVersion = new Map(\n Object.entries(AccountVersionRegistry[accountType]).map((pair) => {\n const [version, def] = pair as [\n LightAccountVersion<LightAccountType>,\n LightAccountVersionConfig<GetEntryPointFromAccount<TAccount>>,\n ];\n\n if (\n def.addresses.overrides != null &&\n chain.id in def.addresses.overrides!\n ) {\n return [def.addresses.overrides[chain.id].factory, version];\n }\n\n return [def.addresses.default.factory, version];\n }),\n );\n\n const version =\n fromHex(implAddress, \"bigint\") === 0n\n ? factoryToVersion.get(factoryAddress.toLowerCase() as Address)\n : implToVersion.get(implAddress.toLowerCase() as Address);\n\n if (!version) {\n throw new Error(\n `Could not determine ${account.source} version for chain ${chain.id}`,\n );\n }\n\n return AccountVersionRegistry[accountType][version];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"modularAccountV2Base.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAKL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,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AC;YACpE,CAAC,CAAC,yBAAyB,CACvB,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB,CAAC;KACP,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n InvalidDeferredActionNonce,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } from \"../../utils.js\";\nimport {\n type Hex,\n type Address,\n type Chain,\n type Transport,\n encodeFunctionData,\n maxUint32,\n zeroAddress,\n getContract,\n concatHex,\n maxUint152,\n} from \"viem\";\nimport { modularAccountAbi } from \"../../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../../actions/common/utils.js\";\nimport { nativeSMASigner } from \"../nativeSMASigner.js\";\nimport { singleSignerMessageSigner } from \"../../modules/single-signer-validation/signer.js\";\n\nexport const executeUserOpSelector: Hex = \"0x8DD7712F\";\n\nexport type SignerEntity = {\n isGlobalValidation: boolean;\n entityId: number;\n};\n\nexport type ExecutionDataView = {\n module: Address;\n skipRuntimeValidation: boolean;\n allowGlobalValidation: boolean;\n executionHooks: readonly Hex[];\n};\n\nexport type ValidationDataView = {\n validationHooks: readonly Hex[];\n executionHooks: readonly Hex[];\n selectors: readonly Hex[];\n validationFlags: number;\n};\n\nexport type ValidationDataParams =\n | {\n validationModuleAddress: Address;\n entityId?: never;\n }\n | {\n validationModuleAddress?: never;\n entityId: number;\n };\n\nexport type ModularAccountV2<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = SmartContractAccountWithSigner<\"ModularAccountV2\", TSigner, \"0.7.0\"> & {\n signerEntity: SignerEntity;\n getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;\n getValidationData: (\n args: ValidationDataParams\n ) => Promise<ValidationDataView>;\n encodeCallData: (callData: Hex) => Promise<Hex>;\n};\n\nexport type CreateMAV2BaseParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport\n> = Omit<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.\n | \"encodeExecute\"\n | \"encodeBatchExecute\"\n | \"getNonce\"\n | \"signMessage\"\n | \"signTypedData\"\n | \"getDummySignature\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n deferredAction?: Hex;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Promise<ModularAccountV2<TSigner>>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {\n let {\n transport,\n chain,\n signer,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: {\n isGlobalValidation = true,\n entityId = DEFAULT_OWNER_ENTITY_ID,\n } = {},\n accountAddress,\n deferredAction,\n ...remainingToSmartContractAccountParams\n } = config;\n\n if (entityId > Number(maxUint32)) {\n throw new InvalidEntityIdError(entityId);\n }\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n // These default values signal that we should not use the set deferred action nonce\n let nonce: bigint | undefined;\n let deferredActionData: Hex | undefined;\n let hasAssociatedExecHooks: boolean = false;\n\n if (deferredAction) {\n let deferredActionNonce: bigint = 0n;\n // We always update entity id and isGlobalValidation to the deferred action value since the client could be used to send multiple calls\n ({\n entityId,\n isGlobalValidation,\n nonce: deferredActionNonce,\n } = parseDeferredAction(deferredAction));\n\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n accountAddress,\n deferredActionNonce >> 64n,\n ])) as bigint;\n\n if (deferredActionNonce === nextNonceForDeferredAction) {\n ({ nonce, deferredActionData, hasAssociatedExecHooks } =\n parseDeferredAction(deferredAction));\n } else if (deferredActionNonce > nextNonceForDeferredAction) {\n // if nonce is greater than the next nonce, its invalid, so we throw\n throw new InvalidDeferredActionNonce();\n }\n }\n\n const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({\n target,\n data,\n value,\n }) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n })\n );\n\n const encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex> = async (txs) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"executeBatch\",\n args: [\n txs.map((tx) => ({\n target: tx.target,\n data: tx.data,\n value: tx.value ?? 0n,\n })),\n ],\n })\n );\n\n const isAccountDeployed: () => Promise<boolean> = async () =>\n !!(await client.getCode({ address: accountAddress }));\n\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonce) {\n const tempNonce = nonce;\n nonce = undefined; // set to falsy value once used\n return tempNonce;\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const fullNonceKey: bigint =\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isGlobalValidation ? 1n : 0n);\n\n return entryPointContract.read.getNonce([\n accountAddress,\n fullNonceKey,\n ]) as Promise<bigint>;\n };\n\n const accountContract = getContract({\n address: accountAddress,\n abi: modularAccountAbi,\n client,\n });\n\n const getExecutionData = async (selector: Hex) => {\n if (!(await isAccountDeployed())) {\n return {\n module: zeroAddress,\n skipRuntimeValidation: false,\n allowGlobalValidation: false,\n executionHooks: [],\n };\n }\n\n return await accountContract.read.getExecutionData([selector]);\n };\n\n const getValidationData = async (args: ValidationDataParams) => {\n if (!(await isAccountDeployed())) {\n return {\n validationHooks: [],\n executionHooks: [],\n selectors: [],\n validationFlags: 0,\n };\n }\n\n const { validationModuleAddress, entityId } = args;\n return await accountContract.read.getValidationData([\n serializeModuleEntity({\n moduleAddress: validationModuleAddress ?? zeroAddress,\n entityId: entityId ?? Number(maxUint32),\n }),\n ]);\n };\n\n const encodeCallData = async (callData: Hex): Promise<Hex> => {\n const validationData = await getValidationData({\n entityId: Number(entityId),\n });\n if (hasAssociatedExecHooks) {\n hasAssociatedExecHooks = false; // set to falsy value once used\n return concatHex([executeUserOpSelector, callData]);\n }\n if (validationData.executionHooks.length) {\n return concatHex([executeUserOpSelector, callData]);\n }\n return callData;\n };\n\n const baseAccount = await toSmartContractAccount({\n ...remainingToSmartContractAccountParams,\n transport,\n chain,\n entryPoint,\n accountAddress,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)\n : singleSignerMessageSigner(\n signer,\n chain,\n accountAddress,\n entityId,\n deferredActionData\n )),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
1
+ {"version":3,"file":"modularAccountV2Base.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAKL,kBAAkB,EAClB,SAAS,EACT,WAAW,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B,QAAQ;QACR,GAAG,CAAC,QAAQ,KAAK,uBAAuB;YACtC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,kBAAkB,CAAC;YACpE,CAAC,CAAC,yBAAyB,CACvB,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB,CAAC;KACP,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n InvalidDeferredActionNonce,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } from \"../../utils.js\";\nimport {\n type Hex,\n type Address,\n type Chain,\n type Transport,\n encodeFunctionData,\n maxUint32,\n zeroAddress,\n getContract,\n concatHex,\n maxUint152,\n} from \"viem\";\nimport { modularAccountAbi } from \"../../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../../actions/common/utils.js\";\nimport { nativeSMASigner } from \"../nativeSMASigner.js\";\nimport { singleSignerMessageSigner } from \"../../modules/single-signer-validation/signer.js\";\n\nexport const executeUserOpSelector: Hex = \"0x8DD7712F\";\n\nexport type SignerEntity = {\n isGlobalValidation: boolean;\n entityId: number;\n};\n\nexport type ExecutionDataView = {\n module: Address;\n skipRuntimeValidation: boolean;\n allowGlobalValidation: boolean;\n executionHooks: readonly Hex[];\n};\n\nexport type ValidationDataView = {\n validationHooks: readonly Hex[];\n executionHooks: readonly Hex[];\n selectors: readonly Hex[];\n validationFlags: number;\n};\n\nexport type ValidationDataParams =\n | {\n validationModuleAddress: Address;\n entityId?: never;\n }\n | {\n validationModuleAddress?: never;\n entityId: number;\n };\n\nexport type ModularAccountV2<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = SmartContractAccountWithSigner<\"ModularAccountV2\", TSigner, \"0.7.0\"> & {\n signerEntity: SignerEntity;\n getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;\n getValidationData: (\n args: ValidationDataParams,\n ) => Promise<ValidationDataView>;\n encodeCallData: (callData: Hex) => Promise<Hex>;\n};\n\nexport type CreateMAV2BaseParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport,\n> = Omit<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.\n | \"encodeExecute\"\n | \"encodeBatchExecute\"\n | \"getNonce\"\n | \"signMessage\"\n | \"signTypedData\"\n | \"getDummySignature\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n deferredAction?: Hex;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Promise<ModularAccountV2<TSigner>>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {\n let {\n transport,\n chain,\n signer,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: {\n isGlobalValidation = true,\n entityId = DEFAULT_OWNER_ENTITY_ID,\n } = {},\n accountAddress,\n deferredAction,\n ...remainingToSmartContractAccountParams\n } = config;\n\n if (entityId > Number(maxUint32)) {\n throw new InvalidEntityIdError(entityId);\n }\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n // These default values signal that we should not use the set deferred action nonce\n let nonce: bigint | undefined;\n let deferredActionData: Hex | undefined;\n let hasAssociatedExecHooks: boolean = false;\n\n if (deferredAction) {\n let deferredActionNonce: bigint = 0n;\n // We always update entity id and isGlobalValidation to the deferred action value since the client could be used to send multiple calls\n ({\n entityId,\n isGlobalValidation,\n nonce: deferredActionNonce,\n } = parseDeferredAction(deferredAction));\n\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n accountAddress,\n deferredActionNonce >> 64n,\n ])) as bigint;\n\n if (deferredActionNonce === nextNonceForDeferredAction) {\n ({ nonce, deferredActionData, hasAssociatedExecHooks } =\n parseDeferredAction(deferredAction));\n } else if (deferredActionNonce > nextNonceForDeferredAction) {\n // if nonce is greater than the next nonce, its invalid, so we throw\n throw new InvalidDeferredActionNonce();\n }\n }\n\n const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({\n target,\n data,\n value,\n }) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n }),\n );\n\n const encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex> = async (txs) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"executeBatch\",\n args: [\n txs.map((tx) => ({\n target: tx.target,\n data: tx.data,\n value: tx.value ?? 0n,\n })),\n ],\n }),\n );\n\n const isAccountDeployed: () => Promise<boolean> = async () =>\n !!(await client.getCode({ address: accountAddress }));\n\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonce) {\n const tempNonce = nonce;\n nonce = undefined; // set to falsy value once used\n return tempNonce;\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const fullNonceKey: bigint =\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isGlobalValidation ? 1n : 0n);\n\n return entryPointContract.read.getNonce([\n accountAddress,\n fullNonceKey,\n ]) as Promise<bigint>;\n };\n\n const accountContract = getContract({\n address: accountAddress,\n abi: modularAccountAbi,\n client,\n });\n\n const getExecutionData = async (selector: Hex) => {\n if (!(await isAccountDeployed())) {\n return {\n module: zeroAddress,\n skipRuntimeValidation: false,\n allowGlobalValidation: false,\n executionHooks: [],\n };\n }\n\n return await accountContract.read.getExecutionData([selector]);\n };\n\n const getValidationData = async (args: ValidationDataParams) => {\n if (!(await isAccountDeployed())) {\n return {\n validationHooks: [],\n executionHooks: [],\n selectors: [],\n validationFlags: 0,\n };\n }\n\n const { validationModuleAddress, entityId } = args;\n return await accountContract.read.getValidationData([\n serializeModuleEntity({\n moduleAddress: validationModuleAddress ?? zeroAddress,\n entityId: entityId ?? Number(maxUint32),\n }),\n ]);\n };\n\n const encodeCallData = async (callData: Hex): Promise<Hex> => {\n const validationData = await getValidationData({\n entityId: Number(entityId),\n });\n if (hasAssociatedExecHooks) {\n hasAssociatedExecHooks = false; // set to falsy value once used\n return concatHex([executeUserOpSelector, callData]);\n }\n if (validationData.executionHooks.length) {\n return concatHex([executeUserOpSelector, callData]);\n }\n return callData;\n };\n\n const baseAccount = await toSmartContractAccount({\n ...remainingToSmartContractAccountParams,\n transport,\n chain,\n entryPoint,\n accountAddress,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)\n : singleSignerMessageSigner(\n signer,\n chain,\n accountAddress,\n entityId,\n deferredActionData,\n )),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}