@account-kit/smart-contracts 4.0.0-alpha.0 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/plugindefs/multi-owner/config.js +16 -17
- package/dist/cjs/plugindefs/multi-owner/config.js.map +1 -1
- package/dist/cjs/plugindefs/multisig/config.js +15 -15
- package/dist/cjs/plugindefs/multisig/config.js.map +1 -1
- package/dist/cjs/plugindefs/session-key/config.js +17 -17
- package/dist/cjs/plugindefs/session-key/config.js.map +1 -1
- package/dist/cjs/src/index.d.ts +3 -3
- package/dist/cjs/src/index.js +15 -15
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/light-account/accounts/account.js +1 -1
- package/dist/cjs/src/light-account/accounts/account.js.map +1 -1
- package/dist/cjs/src/light-account/accounts/multiOwner.js +2 -4
- package/dist/cjs/src/light-account/accounts/multiOwner.js.map +1 -1
- package/dist/cjs/src/light-account/actions/transferOwnership.d.ts +1 -1
- package/dist/cjs/src/light-account/actions/transferOwnership.js +2 -1
- package/dist/cjs/src/light-account/actions/transferOwnership.js.map +1 -1
- package/dist/cjs/src/light-account/actions/updateOwners.js.map +1 -1
- package/dist/cjs/src/light-account/clients/alchemyClient.d.ts +1 -1
- package/dist/cjs/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/cjs/src/light-account/clients/client.js +2 -1
- package/dist/cjs/src/light-account/clients/client.js.map +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/cjs/src/light-account/clients/multiOwnerLightAccount.js +2 -1
- package/dist/cjs/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
- package/dist/cjs/src/light-account/decorators/lightAccount.js.map +1 -1
- package/dist/cjs/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
- package/dist/cjs/src/light-account/utils.d.ts +3 -2
- package/dist/cjs/src/light-account/utils.js +34 -24
- package/dist/cjs/src/light-account/utils.js.map +1 -1
- package/dist/cjs/src/msca/account/multiOwnerAccount.js +2 -1
- package/dist/cjs/src/msca/account/multiOwnerAccount.js.map +1 -1
- package/dist/cjs/src/msca/account/multisigAccount.js +4 -3
- package/dist/cjs/src/msca/account/multisigAccount.js.map +1 -1
- package/dist/cjs/src/msca/account-loupe/decorator.js.map +1 -1
- package/dist/cjs/src/msca/client/alchemyClient.d.ts +1 -1
- package/dist/cjs/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/cjs/src/msca/client/client.js.map +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.js +1 -1
- package/dist/cjs/src/msca/client/multiSigAlchemyClient.js.map +1 -1
- package/dist/cjs/src/msca/errors.js.map +1 -1
- package/dist/cjs/src/msca/plugin-manager/decorator.d.ts +1 -1
- package/dist/cjs/src/msca/plugin-manager/decorator.js +6 -4
- package/dist/cjs/src/msca/plugin-manager/decorator.js.map +1 -1
- package/dist/cjs/src/msca/plugin-manager/installPlugin.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multi-owner/extension.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multi-owner/index.d.ts +1 -1
- package/dist/cjs/src/msca/plugins/multi-owner/index.js +2 -1
- package/dist/cjs/src/msca/plugins/multi-owner/index.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/actions/proposeUserOperation.js +2 -2
- package/dist/cjs/src/msca/plugins/multisig/actions/proposeUserOperation.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/actions/signMultisigUserOperation.js +1 -1
- package/dist/cjs/src/msca/plugins/multisig/actions/signMultisigUserOperation.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/extension.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/index.d.ts +1 -8
- package/dist/cjs/src/msca/plugins/multisig/index.js +1 -16
- package/dist/cjs/src/msca/plugins/multisig/index.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/middleware.d.ts +1 -1
- package/dist/cjs/src/msca/plugins/multisig/middleware.js +1 -1
- package/dist/cjs/src/msca/plugins/multisig/middleware.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/utils/combineSignatures.d.ts +3 -2
- package/dist/cjs/src/msca/plugins/multisig/utils/combineSignatures.js +2 -2
- package/dist/cjs/src/msca/plugins/multisig/utils/combineSignatures.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/utils/getSignerType.d.ts +2 -2
- package/dist/cjs/src/msca/plugins/multisig/utils/getSignerType.js.map +1 -1
- package/dist/cjs/src/msca/plugins/multisig/utils/index.d.ts +4 -0
- package/dist/cjs/src/msca/plugins/multisig/utils/index.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/extension.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/index.d.ts +1 -1
- package/dist/cjs/src/msca/plugins/session-key/index.js +3 -1
- package/dist/cjs/src/msca/plugins/session-key/index.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/permissions.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/signer.js.map +1 -1
- package/dist/cjs/src/msca/plugins/session-key/utils.d.ts +4 -2
- package/dist/cjs/src/msca/plugins/session-key/utils.js +3 -2
- package/dist/cjs/src/msca/plugins/session-key/utils.js.map +1 -1
- package/dist/cjs/src/msca/utils.d.ts +6 -4
- package/dist/cjs/src/msca/utils.js +11 -10
- package/dist/cjs/src/msca/utils.js.map +1 -1
- package/dist/esm/plugindefs/multi-owner/config.js +1 -2
- package/dist/esm/plugindefs/multi-owner/config.js.map +1 -1
- package/dist/esm/plugindefs/multisig/config.js +1 -1
- package/dist/esm/plugindefs/multisig/config.js.map +1 -1
- package/dist/esm/plugindefs/session-key/config.js +1 -1
- package/dist/esm/plugindefs/session-key/config.js.map +1 -1
- package/dist/esm/src/index.d.ts +3 -3
- package/dist/esm/src/index.js +2 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/light-account/accounts/account.js +2 -2
- package/dist/esm/src/light-account/accounts/account.js.map +1 -1
- package/dist/esm/src/light-account/accounts/multiOwner.js +3 -5
- package/dist/esm/src/light-account/accounts/multiOwner.js.map +1 -1
- package/dist/esm/src/light-account/actions/transferOwnership.d.ts +1 -1
- package/dist/esm/src/light-account/actions/transferOwnership.js +2 -1
- package/dist/esm/src/light-account/actions/transferOwnership.js.map +1 -1
- package/dist/esm/src/light-account/actions/updateOwners.js.map +1 -1
- package/dist/esm/src/light-account/clients/alchemyClient.d.ts +1 -1
- package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/client.js +2 -1
- package/dist/esm/src/light-account/clients/client.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js +2 -1
- package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
- package/dist/esm/src/light-account/decorators/lightAccount.js.map +1 -1
- package/dist/esm/src/light-account/decorators/multiOwnerLightAccount.js.map +1 -1
- package/dist/esm/src/light-account/utils.d.ts +3 -2
- package/dist/esm/src/light-account/utils.js +14 -5
- package/dist/esm/src/light-account/utils.js.map +1 -1
- package/dist/esm/src/msca/account/multiOwnerAccount.js +2 -1
- package/dist/esm/src/msca/account/multiOwnerAccount.js.map +1 -1
- package/dist/esm/src/msca/account/multisigAccount.js +4 -3
- package/dist/esm/src/msca/account/multisigAccount.js.map +1 -1
- package/dist/esm/src/msca/account-loupe/decorator.js.map +1 -1
- package/dist/esm/src/msca/client/alchemyClient.d.ts +1 -1
- package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/esm/src/msca/client/client.js.map +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
- package/dist/esm/src/msca/errors.js.map +1 -1
- package/dist/esm/src/msca/plugin-manager/decorator.d.ts +1 -1
- package/dist/esm/src/msca/plugin-manager/decorator.js +6 -4
- package/dist/esm/src/msca/plugin-manager/decorator.js.map +1 -1
- package/dist/esm/src/msca/plugin-manager/installPlugin.js.map +1 -1
- package/dist/esm/src/msca/plugins/multi-owner/extension.js.map +1 -1
- package/dist/esm/src/msca/plugins/multi-owner/index.d.ts +1 -1
- package/dist/esm/src/msca/plugins/multi-owner/index.js +1 -1
- package/dist/esm/src/msca/plugins/multi-owner/index.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/actions/proposeUserOperation.js +1 -1
- package/dist/esm/src/msca/plugins/multisig/actions/proposeUserOperation.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/actions/signMultisigUserOperation.js +1 -1
- package/dist/esm/src/msca/plugins/multisig/actions/signMultisigUserOperation.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/extension.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/index.d.ts +1 -8
- package/dist/esm/src/msca/plugins/multisig/index.js +0 -7
- package/dist/esm/src/msca/plugins/multisig/index.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/middleware.d.ts +1 -1
- package/dist/esm/src/msca/plugins/multisig/middleware.js +2 -1
- package/dist/esm/src/msca/plugins/multisig/middleware.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/utils/combineSignatures.d.ts +3 -2
- package/dist/esm/src/msca/plugins/multisig/utils/combineSignatures.js +2 -2
- package/dist/esm/src/msca/plugins/multisig/utils/combineSignatures.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/utils/getSignerType.d.ts +2 -2
- package/dist/esm/src/msca/plugins/multisig/utils/getSignerType.js.map +1 -1
- package/dist/esm/src/msca/plugins/multisig/utils/index.d.ts +4 -0
- package/dist/esm/src/msca/plugins/multisig/utils/index.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/extension.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/index.d.ts +1 -1
- package/dist/esm/src/msca/plugins/session-key/index.js +1 -1
- package/dist/esm/src/msca/plugins/session-key/index.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/permissions.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/utils.d.ts +4 -2
- package/dist/esm/src/msca/plugins/session-key/utils.js +3 -2
- package/dist/esm/src/msca/plugins/session-key/utils.js.map +1 -1
- package/dist/esm/src/msca/utils.d.ts +6 -4
- package/dist/esm/src/msca/utils.js +2 -1
- package/dist/esm/src/msca/utils.js.map +1 -1
- package/dist/types/plugindefs/multi-owner/config.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/light-account/accounts/account.d.ts.map +1 -1
- package/dist/types/src/light-account/accounts/multiOwner.d.ts.map +1 -1
- package/dist/types/src/light-account/actions/transferOwnership.d.ts +26 -1
- package/dist/types/src/light-account/actions/transferOwnership.d.ts.map +1 -1
- package/dist/types/src/light-account/actions/updateOwners.d.ts +24 -0
- package/dist/types/src/light-account/actions/updateOwners.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/alchemyClient.d.ts +1 -1
- package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/decorators/lightAccount.d.ts +19 -0
- package/dist/types/src/light-account/decorators/lightAccount.d.ts.map +1 -1
- package/dist/types/src/light-account/decorators/multiOwnerLightAccount.d.ts +19 -0
- package/dist/types/src/light-account/decorators/multiOwnerLightAccount.d.ts.map +1 -1
- package/dist/types/src/light-account/utils.d.ts +11 -4
- package/dist/types/src/light-account/utils.d.ts.map +1 -1
- package/dist/types/src/msca/account/multisigAccount.d.ts.map +1 -1
- package/dist/types/src/msca/account-loupe/decorator.d.ts +15 -0
- package/dist/types/src/msca/account-loupe/decorator.d.ts.map +1 -1
- package/dist/types/src/msca/client/alchemyClient.d.ts +1 -1
- package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/client/client.d.ts.map +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/errors.d.ts +12 -0
- package/dist/types/src/msca/errors.d.ts.map +1 -1
- package/dist/types/src/msca/plugin-manager/decorator.d.ts +16 -1
- package/dist/types/src/msca/plugin-manager/decorator.d.ts.map +1 -1
- package/dist/types/src/msca/plugin-manager/installPlugin.d.ts +21 -0
- package/dist/types/src/msca/plugin-manager/installPlugin.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multi-owner/extension.d.ts +15 -0
- package/dist/types/src/msca/plugins/multi-owner/extension.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multi-owner/index.d.ts +1 -1
- package/dist/types/src/msca/plugins/multi-owner/index.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/actions/proposeUserOperation.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/actions/signMultisigUserOperation.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/extension.d.ts +13 -0
- package/dist/types/src/msca/plugins/multisig/extension.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/index.d.ts +1 -8
- package/dist/types/src/msca/plugins/multisig/index.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/middleware.d.ts +1 -1
- package/dist/types/src/msca/plugins/multisig/middleware.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/utils/combineSignatures.d.ts +28 -2
- package/dist/types/src/msca/plugins/multisig/utils/combineSignatures.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/utils/getSignerType.d.ts +21 -2
- package/dist/types/src/msca/plugins/multisig/utils/getSignerType.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/multisig/utils/index.d.ts +4 -0
- package/dist/types/src/msca/plugins/multisig/utils/index.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/extension.d.ts +13 -0
- package/dist/types/src/msca/plugins/session-key/extension.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/index.d.ts +1 -1
- package/dist/types/src/msca/plugins/session-key/index.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/permissions.d.ts +3 -0
- package/dist/types/src/msca/plugins/session-key/permissions.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts +1 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/utils.d.ts +22 -2
- package/dist/types/src/msca/plugins/session-key/utils.d.ts.map +1 -1
- package/dist/types/src/msca/utils.d.ts +43 -5
- package/dist/types/src/msca/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/plugindefs/multi-owner/config.ts +1 -2
- package/plugindefs/multisig/config.ts +1 -1
- package/plugindefs/session-key/config.ts +1 -1
- package/src/index.ts +2 -3
- package/src/light-account/accounts/account.ts +22 -3
- package/src/light-account/accounts/multiOwner.ts +26 -5
- package/src/light-account/actions/transferOwnership.ts +28 -5
- package/src/light-account/actions/updateOwners.ts +24 -0
- package/src/light-account/clients/alchemyClient.ts +21 -1
- package/src/light-account/clients/client.ts +27 -6
- package/src/light-account/clients/multiOwnerAlchemyClient.ts +21 -1
- package/src/light-account/clients/multiOwnerLightAccount.ts +27 -6
- package/src/light-account/decorators/lightAccount.ts +19 -0
- package/src/light-account/decorators/multiOwnerLightAccount.ts +19 -0
- package/src/light-account/utils.ts +31 -9
- package/src/msca/account/multiOwnerAccount.ts +36 -11
- package/src/msca/account/multisigAccount.ts +40 -14
- package/src/msca/account-loupe/decorator.ts +15 -0
- package/src/msca/client/alchemyClient.ts +21 -1
- package/src/msca/client/client.ts +46 -0
- package/src/msca/client/multiSigAlchemyClient.ts +26 -4
- package/src/msca/errors.ts +12 -0
- package/src/msca/plugin-manager/decorator.ts +22 -5
- package/src/msca/plugin-manager/installPlugin.ts +21 -0
- package/src/msca/plugins/multi-owner/extension.ts +15 -0
- package/src/msca/plugins/multi-owner/index.ts +3 -0
- package/src/msca/plugins/multisig/actions/proposeUserOperation.ts +1 -1
- package/src/msca/plugins/multisig/actions/signMultisigUserOperation.ts +1 -1
- package/src/msca/plugins/multisig/extension.ts +13 -0
- package/src/msca/plugins/multisig/index.ts +1 -12
- package/src/msca/plugins/multisig/middleware.ts +2 -2
- package/src/msca/plugins/multisig/utils/combineSignatures.ts +36 -9
- package/src/msca/plugins/multisig/utils/getSignerType.ts +23 -4
- package/src/msca/plugins/multisig/utils/index.ts +4 -0
- package/src/msca/plugins/session-key/extension.ts +13 -0
- package/src/msca/plugins/session-key/index.ts +7 -1
- package/src/msca/plugins/session-key/permissions.ts +3 -0
- package/src/msca/plugins/session-key/signer.ts +1 -2
- package/src/msca/plugins/session-key/utils.ts +33 -12
- package/src/msca/utils.ts +73 -16
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
import {
|
|
24
24
|
AccountVersionRegistry,
|
|
25
25
|
defaultLightAccountVersion,
|
|
26
|
+
getDefaultMultiOwnerLightAccountFactoryAddress,
|
|
26
27
|
} from "../utils.js";
|
|
27
28
|
import {
|
|
28
29
|
createLightAccountBase,
|
|
@@ -105,6 +106,26 @@ export async function createMultiOwnerLightAccount<
|
|
|
105
106
|
MultiOwnerLightAccount<TSigner, TLightAccountVersion, TEntryPointVersion>
|
|
106
107
|
>;
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* 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.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { createMultiOwnerLightAccount } from "@account-kit/smart-contracts";
|
|
115
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
116
|
+
* import { sepolia } from "viem/chains";
|
|
117
|
+
* import { http, generatePrivateKey } from "viem"
|
|
118
|
+
*
|
|
119
|
+
* const account = await createMultiOwnerLightAccount({
|
|
120
|
+
* chain: sepolia,
|
|
121
|
+
* transport: http("RPC_URL"),
|
|
122
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param {CreateMultiOwnerLightAccountParams} config The parameters for creating a multi-owner light account
|
|
127
|
+
* @returns {Promise<MultiOwnerLightAccount>} A promise that resolves to a `MultiOwnerLightAccount` object containing the created account information and methods
|
|
128
|
+
*/
|
|
108
129
|
export async function createMultiOwnerLightAccount({
|
|
109
130
|
transport,
|
|
110
131
|
chain,
|
|
@@ -112,13 +133,13 @@ export async function createMultiOwnerLightAccount({
|
|
|
112
133
|
initCode,
|
|
113
134
|
version = defaultLightAccountVersion("MultiOwnerLightAccount"),
|
|
114
135
|
entryPoint = getEntryPoint(chain, {
|
|
115
|
-
version:
|
|
116
|
-
AccountVersionRegistry["MultiOwnerLightAccount"][version]
|
|
117
|
-
.entryPointVersion,
|
|
136
|
+
version: "0.7.0",
|
|
118
137
|
}),
|
|
119
138
|
accountAddress,
|
|
120
|
-
factoryAddress =
|
|
121
|
-
|
|
139
|
+
factoryAddress = getDefaultMultiOwnerLightAccountFactoryAddress(
|
|
140
|
+
chain,
|
|
141
|
+
version
|
|
142
|
+
),
|
|
122
143
|
salt: salt_ = 0n,
|
|
123
144
|
owners = [],
|
|
124
145
|
}: CreateMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {
|
|
@@ -22,7 +22,32 @@ export type TransferLightAccountOwnershipParams<
|
|
|
22
22
|
} & GetAccountParameter<TAccount, LightAccount<TSigner>> &
|
|
23
23
|
UserOperationOverridesParameter<TEntryPointVersion>;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Transfers the ownership of a light account to a new owner.
|
|
27
|
+
* This function ensures that the client is a compatible smart acccount client and that a Light Account is provided.
|
|
28
|
+
* If the waitForTxn parameter is true, it will wait for the transaction to be completed before returning.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { transferOwnership, createLightAccountClient } from "@account-kit/smart-contracts";
|
|
33
|
+
*
|
|
34
|
+
* const lightAccountClient = createLightAccountClient({
|
|
35
|
+
* signer,
|
|
36
|
+
* transport,
|
|
37
|
+
* chain,
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const txHash = await transferOwnership(lightAccountClient, {
|
|
41
|
+
* newOwner: newOwnerSigner,
|
|
42
|
+
* waitForTxn: true, // set to false to return a uoHash instead
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param {Client<TTransport, TChain, TAccount>} client The smart account client instance used to execute the transfer
|
|
47
|
+
* @param {TransferLightAccountOwnershipParams<TSigner, TAccount>} args The parameters for transferring ownership
|
|
48
|
+
* @returns {Promise<Hex>} The transaction or UO hash as a Hex string
|
|
49
|
+
*/
|
|
50
|
+
export const transferOwnership = async <
|
|
26
51
|
TTransport extends Transport = Transport,
|
|
27
52
|
TChain extends Chain | undefined = Chain | undefined,
|
|
28
53
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
@@ -32,10 +57,8 @@ export const transferOwnership: <
|
|
|
32
57
|
>(
|
|
33
58
|
client: Client<TTransport, TChain, TAccount>,
|
|
34
59
|
args: TransferLightAccountOwnershipParams<TSigner, TAccount>
|
|
35
|
-
)
|
|
36
|
-
client
|
|
37
|
-
{ newOwner, waitForTxn, overrides, account = client.account }
|
|
38
|
-
) => {
|
|
60
|
+
): Promise<Hex> => {
|
|
61
|
+
const { newOwner, waitForTxn, overrides, account = client.account } = args;
|
|
39
62
|
if (!account) {
|
|
40
63
|
throw new AccountNotFoundError();
|
|
41
64
|
}
|
|
@@ -23,6 +23,30 @@ export type UpdateMultiOwnerLightAccountOwnersParams<
|
|
|
23
23
|
} & GetAccountParameter<TAccount, MultiOwnerLightAccount<TSigner>> &
|
|
24
24
|
UserOperationOverridesParameter<TEntryPointVersion>;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Updates the owners of a multi-owner light account. This includes adding new owners and removing existing ones.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { updateOwners, createLightAccountClient } from "@account-kit/smart-contracts";
|
|
32
|
+
*
|
|
33
|
+
* const lightAccountClient = createLightAccountClient({
|
|
34
|
+
* signer,
|
|
35
|
+
* transport,
|
|
36
|
+
* chain,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const txHash = await updateOwners(lightAccountClient, {
|
|
40
|
+
* ownerstoAdd: [newOwnerAddress], // or empty if you just want to remove owners
|
|
41
|
+
* ownersToRemove: [oldOwnerAddress], // or empty if you just want to add owners
|
|
42
|
+
* waitForTxn: true, // set to false to return a uoHash instead
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
47
|
+
* @param {UpdateMultiOwnerLightAccountOwnersParams<TSigner, TAccount>} args The parameters for updating the account owners
|
|
48
|
+
* @returns {Promise<Hex>} A promise that resolves to the transaction hash or the full transaction result if `waitForTxn` is `true`
|
|
49
|
+
*/
|
|
26
50
|
export const updateOwners: <
|
|
27
51
|
TTransport extends Transport = Transport,
|
|
28
52
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
AlchemyProviderConfigSchema,
|
|
3
4
|
createAlchemyPublicRpcClient,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
type LightAccount,
|
|
13
14
|
type LightAccountClientActions,
|
|
14
15
|
} from "@account-kit/smart-contracts";
|
|
15
|
-
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
16
16
|
import { custom, type Chain, type CustomTransport, type Transport } from "viem";
|
|
17
17
|
|
|
18
18
|
export type AlchemyLightAccountClientConfig<
|
|
@@ -39,6 +39,26 @@ export async function createLightAccountAlchemyClient<
|
|
|
39
39
|
>
|
|
40
40
|
>;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Creates an Alchemy smart account client connected to a Light Account instance.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { createLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
48
|
+
* import { sepolia } from "@account-kit/infra";
|
|
49
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
50
|
+
* import { generatePrivateKey } from "viem"
|
|
51
|
+
*
|
|
52
|
+
* const lightAccountClient = await createLightAccountAlchemyClient({
|
|
53
|
+
* apiKey: "your-api-key",
|
|
54
|
+
* chain: sepolia,
|
|
55
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client
|
|
60
|
+
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client
|
|
61
|
+
*/
|
|
42
62
|
export async function createLightAccountAlchemyClient(
|
|
43
63
|
config: AlchemyLightAccountClientConfig
|
|
44
64
|
): Promise<AlchemySmartAccountClient> {
|
|
@@ -48,12 +48,33 @@ export function createLightAccountClient<
|
|
|
48
48
|
>
|
|
49
49
|
>;
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
/**
|
|
52
|
+
* 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.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { createLightAccountClient } from "@account-kit/smart-contracts";
|
|
57
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
58
|
+
* import { sepolia } from "viem/chains";
|
|
59
|
+
* import { http, generatePrivateKey } from "viem"
|
|
60
|
+
*
|
|
61
|
+
* const account = await createLightAccountClient({
|
|
62
|
+
* chain: sepolia,
|
|
63
|
+
* transport: http("RPC_URL"),
|
|
64
|
+
* account: {
|
|
65
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param {CreateLightAccountClientParams} params The parameters for creating a light account client
|
|
71
|
+
* @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` object containing the created account information and methods
|
|
72
|
+
*/
|
|
73
|
+
export async function createLightAccountClient(
|
|
74
|
+
params: CreateLightAccountClientParams
|
|
75
|
+
): Promise<SmartAccountClient> {
|
|
76
|
+
const { account, transport, chain, ...clientConfig } = params;
|
|
77
|
+
|
|
57
78
|
const lightAccount = await createLightAccount({
|
|
58
79
|
...account,
|
|
59
80
|
transport,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
AlchemyProviderConfigSchema,
|
|
3
4
|
createAlchemyPublicRpcClient,
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
type MultiOwnerLightAccount,
|
|
13
14
|
type MultiOwnerLightAccountClientActions,
|
|
14
15
|
} from "@account-kit/smart-contracts";
|
|
15
|
-
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
16
16
|
import { custom, type Chain, type CustomTransport, type Transport } from "viem";
|
|
17
17
|
|
|
18
18
|
export type AlchemyMultiOwnerLightAccountClientConfig<
|
|
@@ -43,6 +43,26 @@ export async function createMultiOwnerLightAccountAlchemyClient<
|
|
|
43
43
|
>
|
|
44
44
|
>;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Creates a multi-owner light account Alchemy client using the provided configuration.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { createMultiOwnerLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
52
|
+
* import { sepolia } from "@account-kit/infra";
|
|
53
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
54
|
+
* import { generatePrivateKey } from "viem"
|
|
55
|
+
*
|
|
56
|
+
* const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({
|
|
57
|
+
* apiKey: "your-api-key",
|
|
58
|
+
* chain: sepolia,
|
|
59
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client
|
|
64
|
+
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods
|
|
65
|
+
*/
|
|
46
66
|
export async function createMultiOwnerLightAccountAlchemyClient(
|
|
47
67
|
config: AlchemyMultiOwnerLightAccountClientConfig
|
|
48
68
|
): Promise<AlchemySmartAccountClient> {
|
|
@@ -54,12 +54,33 @@ export function createMultiOwnerLightAccountClient<
|
|
|
54
54
|
>
|
|
55
55
|
>;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
/**
|
|
58
|
+
* 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.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { createMultiOwnerLightAccountClient } from "@account-kit/smart-contracts";
|
|
63
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
64
|
+
* import { sepolia } from "viem/chains";
|
|
65
|
+
* import { http, generatePrivateKey } from "viem"
|
|
66
|
+
*
|
|
67
|
+
* const account = await createMultiOwnerLightAccountClient({
|
|
68
|
+
* chain: sepolia,
|
|
69
|
+
* transport: http("RPC_URL"),
|
|
70
|
+
* account: {
|
|
71
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @param {CreateMultiOwnerLightAccountClientParams} params the configuration for creating the multi-owner light account client
|
|
77
|
+
* @returns {Promise<SmartAccountClient>} a promise that resolves to a `SmartAccountClient` containing the created account client and relevant methods
|
|
78
|
+
*/
|
|
79
|
+
export async function createMultiOwnerLightAccountClient(
|
|
80
|
+
params: CreateMultiOwnerLightAccountClientParams
|
|
81
|
+
): Promise<SmartAccountClient> {
|
|
82
|
+
const { account, transport, chain, ...clientConfig } = params;
|
|
83
|
+
|
|
63
84
|
const lightAccount = await createMultiOwnerLightAccount({
|
|
64
85
|
...account,
|
|
65
86
|
transport,
|
|
@@ -17,6 +17,25 @@ export type LightAccountClientActions<
|
|
|
17
17
|
) => Promise<Hex>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Provides a set of actions for managing a light account client, including transferring ownership.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { lightAccountClientActions, createLightAccount } from "@account-kit/smart-contracts";
|
|
26
|
+
* import { createAlchemySmartAccountClient } from "@account-kit/infra";
|
|
27
|
+
* import { sepolia } from "@account-kit/infra";
|
|
28
|
+
*
|
|
29
|
+
* const smartAccountClient = createAlchemySmartAccountClient({
|
|
30
|
+
* account: await createLightAccount(...),
|
|
31
|
+
* apiKey: "your-api-key",
|
|
32
|
+
* chain: sepolia,
|
|
33
|
+
* }).extend(lightAccountClientActions);
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
|
|
37
|
+
* @returns {LightAccountClientActions<TSigner, TAccount>} An object containing the available light account client actions
|
|
38
|
+
*/
|
|
20
39
|
export const lightAccountClientActions: <
|
|
21
40
|
TTransport extends Transport = Transport,
|
|
22
41
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -17,6 +17,25 @@ export type MultiOwnerLightAccountClientActions<
|
|
|
17
17
|
) => Promise<Hex>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Generates client actions for a multi-owner light account, including the ability to update owners.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { multiOwnerLightAccountClientActions, createMultiOwnerLightAccount } from "@account-kit/smart-contracts";
|
|
26
|
+
* import { createAlchemySmartAccountClient } from "@account-kit/infra";
|
|
27
|
+
* import { sepolia } from "@account-kit/infra";
|
|
28
|
+
*
|
|
29
|
+
* const smartAccountClient = createAlchemySmartAccountClient({
|
|
30
|
+
* account: await createMultiOwnerLightAccount(...),
|
|
31
|
+
* apiKey: "your-api-key",
|
|
32
|
+
* chain: sepolia,
|
|
33
|
+
* }).extend(multiOwnerLightAccountClientActions);
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param {Client<TTransport, TChain, TAccount>} client the client for interacting with the multi-owner light account
|
|
37
|
+
* @returns {MultiOwnerLightAccountClientActions<TSigner, TAccount>} an object containing the client actions specifically for a multi-owner light account
|
|
38
|
+
*/
|
|
20
39
|
export const multiOwnerLightAccountClientActions: <
|
|
21
40
|
TTransport extends Transport = Transport,
|
|
22
41
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { DefaultFactoryNotDefinedError, toRecord } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
|
-
DefaultFactoryNotDefinedError,
|
|
3
3
|
arbitrum,
|
|
4
4
|
arbitrumGoerli,
|
|
5
5
|
arbitrumSepolia,
|
|
@@ -17,10 +17,9 @@ import {
|
|
|
17
17
|
polygonAmoy,
|
|
18
18
|
polygonMumbai,
|
|
19
19
|
sepolia,
|
|
20
|
-
toRecord,
|
|
21
20
|
zora,
|
|
22
21
|
zoraSepolia,
|
|
23
|
-
} from "@
|
|
22
|
+
} from "@account-kit/infra";
|
|
24
23
|
import { fromHex, type Address, type Chain } from "viem";
|
|
25
24
|
import type { LightAccountBase } from "./accounts/base";
|
|
26
25
|
import type {
|
|
@@ -168,21 +167,45 @@ export const defaultLightAccountVersion = <
|
|
|
168
167
|
*/
|
|
169
168
|
export const getDefaultLightAccountFactoryAddress = (
|
|
170
169
|
chain: Chain,
|
|
171
|
-
version:
|
|
170
|
+
version: GetLightAccountVersion<"LightAccount">
|
|
172
171
|
): Address => {
|
|
173
172
|
const address =
|
|
174
|
-
AccountVersionRegistry.LightAccount[version].address[chain.id]
|
|
173
|
+
AccountVersionRegistry.LightAccount[version].address[chain.id] ??
|
|
174
|
+
AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
|
|
175
175
|
if (!address)
|
|
176
176
|
throw new DefaultFactoryNotDefinedError("LightAccount", chain, "0.6.0");
|
|
177
177
|
return address.factory;
|
|
178
178
|
};
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Utility method returning the default multi owner light account factory address given a {@link Chain} object
|
|
182
|
+
*
|
|
183
|
+
* @param chain - a {@link Chain} object
|
|
184
|
+
* @param version - the version of the light account to get the factory address for
|
|
185
|
+
* @returns a {@link Address} for the given chain
|
|
186
|
+
* @throws if the chain doesn't have an address currently deployed
|
|
187
|
+
*/
|
|
188
|
+
export const getDefaultMultiOwnerLightAccountFactoryAddress = (
|
|
189
|
+
chain: Chain,
|
|
190
|
+
version: GetLightAccountVersion<"MultiOwnerLightAccount">
|
|
191
|
+
) => {
|
|
192
|
+
const address =
|
|
193
|
+
AccountVersionRegistry.LightAccount[version].address[chain.id] ??
|
|
194
|
+
AccountVersionRegistry.LightAccount[version].address[supportedChains[0].id];
|
|
195
|
+
if (!address)
|
|
196
|
+
throw new DefaultFactoryNotDefinedError(
|
|
197
|
+
"MultiOwnerLightAccount",
|
|
198
|
+
chain,
|
|
199
|
+
"0.7.0"
|
|
200
|
+
);
|
|
201
|
+
return address.factory;
|
|
202
|
+
};
|
|
203
|
+
|
|
180
204
|
/**
|
|
181
205
|
* Can be used to check if the account with one of the following implementation addresses
|
|
182
206
|
* to not support 1271 signing.
|
|
183
207
|
*
|
|
184
208
|
* Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.
|
|
185
|
-
*
|
|
186
209
|
*/
|
|
187
210
|
export const LightAccountUnsupported1271Impls = [
|
|
188
211
|
AccountVersionRegistry.LightAccount["v1.0.1"],
|
|
@@ -194,7 +217,6 @@ export const LightAccountUnsupported1271Impls = [
|
|
|
194
217
|
* to not support 1271 signing.
|
|
195
218
|
*
|
|
196
219
|
* Light accounts with versions v1.0.1 and v1.0.2 do not support 1271 signing.
|
|
197
|
-
*
|
|
198
220
|
*/
|
|
199
221
|
export const LightAccountUnsupported1271Factories = new Set(
|
|
200
222
|
LightAccountUnsupported1271Impls.map((x) =>
|
|
@@ -266,7 +288,7 @@ export async function getLightAccountVersionDef<
|
|
|
266
288
|
];
|
|
267
289
|
return chain.id in def.address
|
|
268
290
|
? [def.address[chain.id].impl, version]
|
|
269
|
-
: [
|
|
291
|
+
: [def.address[supportedChains[0].id].impl, version];
|
|
270
292
|
})
|
|
271
293
|
.filter(([impl]) => impl !== null) as [
|
|
272
294
|
Address,
|
|
@@ -283,7 +305,7 @@ export async function getLightAccountVersionDef<
|
|
|
283
305
|
];
|
|
284
306
|
return chain.id in def.address
|
|
285
307
|
? [def.address[chain.id].factory, version]
|
|
286
|
-
: [
|
|
308
|
+
: [def.address[supportedChains[0].id].factory, version];
|
|
287
309
|
})
|
|
288
310
|
.filter(([impl]) => impl !== null) as [
|
|
289
311
|
Address,
|
|
@@ -62,17 +62,42 @@ export async function createMultiOwnerModularAccount<
|
|
|
62
62
|
config: CreateMultiOwnerModularAccountParams<TTransport, TSigner>
|
|
63
63
|
): Promise<MultiOwnerModularAccount<TSigner>>;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Creates a multi-owner modular account with the given parameters, including transport, chain, signer, account address, initialization code, entry point, factory address, owners, and salt.
|
|
67
|
+
* Ensures that the owners are unique, ordered, and non-zero.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { createMultiOwnerModularAccount } from "@account-kit/smart-contracts";
|
|
72
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
73
|
+
* import { sepolia } from "viem/chains";
|
|
74
|
+
* import { http, generatePrivateKey } from "viem"
|
|
75
|
+
*
|
|
76
|
+
* const account = await createMultiOwnerModularAccount({
|
|
77
|
+
* chain: sepolia,
|
|
78
|
+
* transport: http("RPC_URL"),
|
|
79
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param {CreateMultiOwnerModularAccountParams} config Configuration parameters for creating a multi-owner modular account
|
|
84
|
+
* @returns {Promise<MultiOwnerModularAccount>} A promise that resolves to a `MultiOwnerModularAccount` object containing the created account information and methods
|
|
85
|
+
*/
|
|
86
|
+
export async function createMultiOwnerModularAccount(
|
|
87
|
+
config: CreateMultiOwnerModularAccountParams
|
|
88
|
+
): Promise<MultiOwnerModularAccount> {
|
|
89
|
+
const {
|
|
90
|
+
transport,
|
|
91
|
+
chain,
|
|
92
|
+
signer,
|
|
93
|
+
accountAddress,
|
|
94
|
+
initCode,
|
|
95
|
+
entryPoint = getEntryPoint(chain, { version: "0.6.0" }),
|
|
96
|
+
factoryAddress = getDefaultMultiOwnerModularAccountFactoryAddress(chain),
|
|
97
|
+
owners = [],
|
|
98
|
+
salt = 0n,
|
|
99
|
+
} = config;
|
|
100
|
+
|
|
76
101
|
const client = createBundlerClient({
|
|
77
102
|
transport,
|
|
78
103
|
chain,
|
|
@@ -64,18 +64,44 @@ export async function createMultisigModularAccount<
|
|
|
64
64
|
config: CreateMultisigModularAccountParams<TTransport, TSigner>
|
|
65
65
|
): Promise<MultisigModularAccount<TSigner>>;
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Creates a multisig modular account using the provided parameters, including transport, chain, signer, account address, and other account settings. It configures the account with multiple owners and the specified threshold.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { createMultisigModularAccount } from "@account-kit/smart-contracts";
|
|
73
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
74
|
+
* import { sepolia } from "viem/chains";
|
|
75
|
+
* import { http, generatePrivateKey } from "viem"
|
|
76
|
+
*
|
|
77
|
+
* const account = await createMultisigModularAccount({
|
|
78
|
+
* chain: sepolia,
|
|
79
|
+
* transport: http("RPC_URL"),
|
|
80
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
|
|
81
|
+
* owners: [...], // other owners on the account
|
|
82
|
+
* threshold: 2, // 2 of N signatures
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param {CreateMultisigModularAccountParams} config The parameters for creating a multisig modular account.
|
|
87
|
+
* @returns {Promise<MultisigModularAccount>} A promise that resolves to a `MultisigModularAccount` object containing the created account information and methods.
|
|
88
|
+
*/
|
|
89
|
+
export async function createMultisigModularAccount(
|
|
90
|
+
config: CreateMultisigModularAccountParams
|
|
91
|
+
): Promise<MultisigModularAccount> {
|
|
92
|
+
const {
|
|
93
|
+
transport,
|
|
94
|
+
chain,
|
|
95
|
+
signer,
|
|
96
|
+
accountAddress: accountAddress_,
|
|
97
|
+
initCode,
|
|
98
|
+
entryPoint = getEntryPoint(chain, { version: "0.6.0" }),
|
|
99
|
+
factoryAddress = getDefaultMultisigModularAccountFactoryAddress(chain),
|
|
100
|
+
owners = [],
|
|
101
|
+
salt = 0n,
|
|
102
|
+
threshold,
|
|
103
|
+
} = config;
|
|
104
|
+
|
|
79
105
|
const client = createBundlerClient({
|
|
80
106
|
transport,
|
|
81
107
|
chain,
|
|
@@ -108,10 +134,10 @@ export async function createMultisigModularAccount({
|
|
|
108
134
|
]);
|
|
109
135
|
};
|
|
110
136
|
|
|
111
|
-
accountAddress = await getAccountAddress({
|
|
137
|
+
const accountAddress = await getAccountAddress({
|
|
112
138
|
client,
|
|
113
139
|
entryPoint,
|
|
114
|
-
accountAddress:
|
|
140
|
+
accountAddress: accountAddress_,
|
|
115
141
|
getAccountInitCode,
|
|
116
142
|
});
|
|
117
143
|
|
|
@@ -51,6 +51,21 @@ export type AccountLoupeActions<
|
|
|
51
51
|
): Promise<ReadonlyArray<Address>>;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Provides a set of actions for account loupe operations using the specified client.
|
|
56
|
+
* NOTE: this is already added to the client when using any of the Modular Account Clients.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { accountLoupeActions } from "@account-kit/smart-contracts";
|
|
61
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
62
|
+
*
|
|
63
|
+
* const client = createSmartAccountClient(...).extend(accountLoupeActions);
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param {Client<TTransport, TChain, TAccount>} client the client to be used for executing the account loupe actions
|
|
67
|
+
* @returns {AccountLoupeActions<TAccount>} an object containing account loupe actions like `getExecutionFunctionConfig`, `getExecutionHooks`, `getPreValidationHooks`, and `getInstalledPlugins`
|
|
68
|
+
*/
|
|
54
69
|
export const accountLoupeActions: <
|
|
55
70
|
TTransport extends Transport = Transport,
|
|
56
71
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
AlchemyProviderConfigSchema,
|
|
3
4
|
createAlchemyPublicRpcClient,
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
type MultiOwnerPluginActions,
|
|
18
19
|
type PluginManagerActions,
|
|
19
20
|
} from "@account-kit/smart-contracts";
|
|
20
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
21
21
|
import {
|
|
22
22
|
custom,
|
|
23
23
|
type Chain,
|
|
@@ -52,6 +52,26 @@ export function createModularAccountAlchemyClient<
|
|
|
52
52
|
>
|
|
53
53
|
>;
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Creates a modular account Alchemy client with the provided configuration.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
61
|
+
* import { sepolia } from "@account-kit/infra";
|
|
62
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
63
|
+
* import { generatePrivateKey } from "viem"
|
|
64
|
+
*
|
|
65
|
+
* const alchemyAccountClient = await createModularAccountAlchemyClient({
|
|
66
|
+
* apiKey: "your-api-key",
|
|
67
|
+
* chain: sepolia,
|
|
68
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param {AlchemyModularAccountClientConfig} config The configuration for creating the Alchemy client
|
|
73
|
+
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` configured with the desired plugins and actions
|
|
74
|
+
*/
|
|
55
75
|
export async function createModularAccountAlchemyClient(
|
|
56
76
|
config: AlchemyModularAccountClientConfig
|
|
57
77
|
): Promise<AlchemySmartAccountClient> {
|