@account-kit/smart-contracts 4.8.0 → 4.10.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.
- package/dist/esm/src/light-account/clients/alchemyClient.js +6 -12
- package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/client.d.ts +9 -4
- package/dist/esm/src/light-account/clients/client.js +26 -1
- package/dist/esm/src/light-account/clients/client.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js +6 -11
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerLightAccount.d.ts +10 -4
- package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js +27 -3
- package/dist/esm/src/light-account/clients/multiOwnerLightAccount.js.map +1 -1
- package/dist/esm/src/ma-v2/client/client.d.ts +10 -3
- package/dist/esm/src/ma-v2/client/client.js +18 -1
- package/dist/esm/src/ma-v2/client/client.js.map +1 -1
- package/dist/esm/src/msca/client/alchemyClient.js +4 -17
- package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/esm/src/msca/client/client.d.ts +14 -5
- package/dist/esm/src/msca/client/client.js +62 -0
- package/dist/esm/src/msca/client/client.js.map +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +4 -2
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js +5 -19
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
- package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/client.d.ts +9 -4
- package/dist/types/src/light-account/clients/client.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerLightAccount.d.ts +10 -4
- package/dist/types/src/light-account/clients/multiOwnerLightAccount.d.ts.map +1 -1
- package/dist/types/src/ma-v2/client/client.d.ts +10 -3
- package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
- package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/client/client.d.ts +14 -5
- package/dist/types/src/msca/client/client.d.ts.map +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +4 -2
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/light-account/clients/alchemyClient.ts +5 -14
- package/src/light-account/clients/client.ts +52 -6
- package/src/light-account/clients/multiOwnerAlchemyClient.ts +5 -13
- package/src/light-account/clients/multiOwnerLightAccount.ts +64 -8
- package/src/ma-v2/client/client.ts +53 -7
- package/src/msca/client/alchemyClient.ts +3 -22
- package/src/msca/client/client.ts +157 -13
- package/src/msca/client/multiSigAlchemyClient.ts +6 -29
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSmartAccountClient,
|
|
3
|
+
type NotType,
|
|
3
4
|
type SmartAccountClient,
|
|
4
5
|
type SmartAccountClientActions,
|
|
5
6
|
type SmartAccountClientConfig,
|
|
@@ -8,14 +9,19 @@ import {
|
|
|
8
9
|
} from "@aa-sdk/core";
|
|
9
10
|
import { type Chain, type CustomTransport, type Transport } from "viem";
|
|
10
11
|
import {
|
|
12
|
+
multiOwnerLightAccountClientActions,
|
|
11
13
|
createMultiOwnerLightAccount,
|
|
12
14
|
type CreateMultiOwnerLightAccountParams,
|
|
13
15
|
type MultiOwnerLightAccount,
|
|
14
|
-
} from "../accounts/multiOwner.js";
|
|
15
|
-
import {
|
|
16
|
-
multiOwnerLightAccountClientActions,
|
|
17
16
|
type MultiOwnerLightAccountClientActions,
|
|
18
|
-
|
|
17
|
+
type AlchemyMultiOwnerLightAccountClientConfig,
|
|
18
|
+
} from "@account-kit/smart-contracts";
|
|
19
|
+
import {
|
|
20
|
+
isAlchemyTransport,
|
|
21
|
+
createAlchemySmartAccountClient,
|
|
22
|
+
type AlchemySmartAccountClient,
|
|
23
|
+
type AlchemyTransport,
|
|
24
|
+
} from "@account-kit/infra";
|
|
19
25
|
|
|
20
26
|
export type CreateMultiOwnerLightAccountClientParams<
|
|
21
27
|
TTransport extends Transport = Transport,
|
|
@@ -36,11 +42,37 @@ export type CreateMultiOwnerLightAccountClientParams<
|
|
|
36
42
|
"transport" | "account" | "chain"
|
|
37
43
|
>;
|
|
38
44
|
|
|
45
|
+
export type CreateMultiOwnerLightAccountClientDynamicTransportParams<
|
|
46
|
+
TTransport extends Transport = Transport,
|
|
47
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
48
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
49
|
+
> =
|
|
50
|
+
| (AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {
|
|
51
|
+
transport: AlchemyTransport;
|
|
52
|
+
})
|
|
53
|
+
| CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner>;
|
|
54
|
+
|
|
55
|
+
export async function createMultiOwnerLightAccountClient<
|
|
56
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
57
|
+
>(
|
|
58
|
+
params: AlchemyMultiOwnerLightAccountClientConfig<TSigner> & {
|
|
59
|
+
transport: AlchemyTransport;
|
|
60
|
+
}
|
|
61
|
+
): Promise<
|
|
62
|
+
AlchemySmartAccountClient<
|
|
63
|
+
Chain | undefined,
|
|
64
|
+
MultiOwnerLightAccount<TSigner>,
|
|
65
|
+
MultiOwnerLightAccountClientActions<TSigner>
|
|
66
|
+
>
|
|
67
|
+
>;
|
|
68
|
+
|
|
39
69
|
export function createMultiOwnerLightAccountClient<
|
|
70
|
+
TTransport extends Transport = Transport,
|
|
40
71
|
TChain extends Chain | undefined = Chain | undefined,
|
|
41
72
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
42
73
|
>(
|
|
43
|
-
args: CreateMultiOwnerLightAccountClientParams<
|
|
74
|
+
args: CreateMultiOwnerLightAccountClientParams<TTransport, TChain, TSigner> &
|
|
75
|
+
NotType<TTransport, AlchemyTransport>
|
|
44
76
|
): Promise<
|
|
45
77
|
SmartAccountClient<
|
|
46
78
|
CustomTransport,
|
|
@@ -71,12 +103,28 @@ export function createMultiOwnerLightAccountClient<
|
|
|
71
103
|
* });
|
|
72
104
|
* ```
|
|
73
105
|
*
|
|
74
|
-
* @
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { createMultiOwnerLightAccountClient } from "@account-kit/smart-contracts";
|
|
109
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
110
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
111
|
+
* import { generatePrivateKey } from "viem"
|
|
112
|
+
*
|
|
113
|
+
* const lightAccountClient = await createMultiOwnerLightAccountClient({
|
|
114
|
+
* transport: alchemy({
|
|
115
|
+
* apiKey: "your-api-key",
|
|
116
|
+
* }),
|
|
117
|
+
* chain: sepolia
|
|
118
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @param {CreateMultiOwnerLightAccountClientDynamicTransportParams} params the configuration for creating the multi-owner light / alchemy account client with the provided parameters transport
|
|
75
123
|
* @returns {Promise<SmartAccountClient>} a promise that resolves to a `SmartAccountClient` containing the created account client and relevant methods
|
|
76
124
|
*/
|
|
77
125
|
export async function createMultiOwnerLightAccountClient(
|
|
78
|
-
params:
|
|
79
|
-
): Promise<SmartAccountClient> {
|
|
126
|
+
params: CreateMultiOwnerLightAccountClientDynamicTransportParams
|
|
127
|
+
): Promise<SmartAccountClient | AlchemySmartAccountClient> {
|
|
80
128
|
const { transport, chain } = params;
|
|
81
129
|
|
|
82
130
|
const lightAccount = await createMultiOwnerLightAccount({
|
|
@@ -84,6 +132,14 @@ export async function createMultiOwnerLightAccountClient(
|
|
|
84
132
|
transport,
|
|
85
133
|
chain,
|
|
86
134
|
});
|
|
135
|
+
if (isAlchemyTransport(transport, chain)) {
|
|
136
|
+
return createAlchemySmartAccountClient({
|
|
137
|
+
...params,
|
|
138
|
+
transport,
|
|
139
|
+
chain,
|
|
140
|
+
account: lightAccount,
|
|
141
|
+
}).extend(multiOwnerLightAccountClientActions);
|
|
142
|
+
}
|
|
87
143
|
|
|
88
144
|
return createSmartAccountClient({
|
|
89
145
|
...params,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createSmartAccountClient,
|
|
3
2
|
type SmartAccountClient,
|
|
4
3
|
type SmartAccountSigner,
|
|
5
4
|
type SmartAccountClientConfig,
|
|
5
|
+
type NotType,
|
|
6
|
+
createSmartAccountClient,
|
|
6
7
|
} from "@aa-sdk/core";
|
|
7
8
|
import { type Chain, type Transport } from "viem";
|
|
8
9
|
|
|
@@ -11,10 +12,18 @@ import {
|
|
|
11
12
|
type CreateSMAV2AccountParams,
|
|
12
13
|
type MAV2Account,
|
|
13
14
|
} from "../account/semiModularAccountV2.js";
|
|
14
|
-
|
|
15
|
+
import {
|
|
16
|
+
createAlchemySmartAccountClient,
|
|
17
|
+
isAlchemyTransport,
|
|
18
|
+
type AlchemySmartAccountClientConfig,
|
|
19
|
+
type AlchemyTransport,
|
|
20
|
+
} from "@account-kit/infra";
|
|
21
|
+
import type { LightAccount } from "../../light-account/accounts/account.js";
|
|
15
22
|
export type SMAV2AccountClient<
|
|
16
|
-
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
17
|
-
|
|
23
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
24
|
+
TChain extends Chain = Chain,
|
|
25
|
+
TTransport extends Transport | AlchemyTransport = Transport
|
|
26
|
+
> = SmartAccountClient<TTransport, TChain, MAV2Account<TSigner>>;
|
|
18
27
|
|
|
19
28
|
export type CreateSMAV2AccountClientParams<
|
|
20
29
|
TTransport extends Transport = Transport,
|
|
@@ -25,13 +34,34 @@ export type CreateSMAV2AccountClientParams<
|
|
|
25
34
|
SmartAccountClientConfig<TTransport, TChain>,
|
|
26
35
|
"transport" | "account" | "chain"
|
|
27
36
|
>;
|
|
37
|
+
export type CreateSMAV2AlchemyAccountClientParams<
|
|
38
|
+
TTransport extends Transport = Transport,
|
|
39
|
+
TChain extends Chain = Chain,
|
|
40
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
41
|
+
> = Omit<
|
|
42
|
+
CreateSMAV2AccountClientParams<TTransport, TChain, TSigner>,
|
|
43
|
+
"transport"
|
|
44
|
+
> &
|
|
45
|
+
Omit<
|
|
46
|
+
AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>,
|
|
47
|
+
"account"
|
|
48
|
+
> & { paymasterAndData?: never; dummyPaymasterAndData?: never };
|
|
28
49
|
|
|
29
50
|
export function createSMAV2AccountClient<
|
|
30
51
|
TChain extends Chain = Chain,
|
|
31
52
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
32
53
|
>(
|
|
33
|
-
args:
|
|
34
|
-
): Promise<SMAV2AccountClient<TSigner>>;
|
|
54
|
+
args: CreateSMAV2AlchemyAccountClientParams<AlchemyTransport, TChain, TSigner>
|
|
55
|
+
): Promise<SMAV2AccountClient<TSigner, TChain, AlchemyTransport>>;
|
|
56
|
+
|
|
57
|
+
export function createSMAV2AccountClient<
|
|
58
|
+
TTransport extends Transport = Transport,
|
|
59
|
+
TChain extends Chain = Chain,
|
|
60
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
61
|
+
>(
|
|
62
|
+
args: CreateSMAV2AccountClientParams<TTransport, TChain, TSigner> &
|
|
63
|
+
NotType<TTransport, AlchemyTransport>
|
|
64
|
+
): Promise<SMAV2AccountClient<TSigner, TChain>>;
|
|
35
65
|
|
|
36
66
|
/**
|
|
37
67
|
* Creates a SMAv2 account client using the provided configuration parameters.
|
|
@@ -52,10 +82,13 @@ export function createSMAV2AccountClient<
|
|
|
52
82
|
*
|
|
53
83
|
* const transport = http(RPC_URL);
|
|
54
84
|
*
|
|
85
|
+
* const policyId = "...";
|
|
86
|
+
*
|
|
55
87
|
* const SMAV2SignerAccountClient = await createSMAV2AccountClient({
|
|
56
88
|
* chain,
|
|
57
89
|
* signer,
|
|
58
90
|
* transport,
|
|
91
|
+
* policyId, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!
|
|
59
92
|
* });
|
|
60
93
|
* ```
|
|
61
94
|
*
|
|
@@ -65,7 +98,20 @@ export function createSMAV2AccountClient<
|
|
|
65
98
|
export async function createSMAV2AccountClient(
|
|
66
99
|
config: CreateSMAV2AccountClientParams
|
|
67
100
|
): Promise<SmartAccountClient> {
|
|
68
|
-
const
|
|
101
|
+
const { transport, chain } = config;
|
|
102
|
+
const smaV2Account = await createSMAV2Account({
|
|
103
|
+
...config,
|
|
104
|
+
transport,
|
|
105
|
+
chain,
|
|
106
|
+
});
|
|
107
|
+
if (isAlchemyTransport(transport, chain)) {
|
|
108
|
+
return createAlchemySmartAccountClient({
|
|
109
|
+
...config,
|
|
110
|
+
transport,
|
|
111
|
+
chain,
|
|
112
|
+
account: smaV2Account,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
69
115
|
|
|
70
116
|
return createSmartAccountClient({
|
|
71
117
|
...config,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import {
|
|
3
|
-
createAlchemySmartAccountClient,
|
|
4
3
|
type AlchemySmartAccountClient,
|
|
5
4
|
type AlchemySmartAccountClientConfig,
|
|
6
5
|
} from "@account-kit/infra";
|
|
7
6
|
import {
|
|
8
|
-
|
|
9
|
-
createMultiOwnerModularAccount,
|
|
10
|
-
multiOwnerPluginActions,
|
|
11
|
-
pluginManagerActions,
|
|
7
|
+
createMultiOwnerModularAccountClient,
|
|
12
8
|
type AccountLoupeActions,
|
|
13
9
|
type CreateMultiOwnerModularAccountParams,
|
|
14
10
|
type LightAccount,
|
|
@@ -59,27 +55,12 @@ export function createModularAccountAlchemyClient<
|
|
|
59
55
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
60
56
|
* });
|
|
61
57
|
* ```
|
|
62
|
-
*
|
|
58
|
+
* @deprecated Use createModularAccountClient instead of this function, we are switching based on the transport
|
|
63
59
|
* @param {AlchemyModularAccountClientConfig} config The configuration for creating the Alchemy client
|
|
64
60
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` configured with the desired plugins and actions
|
|
65
61
|
*/
|
|
66
62
|
export async function createModularAccountAlchemyClient(
|
|
67
63
|
config: AlchemyModularAccountClientConfig
|
|
68
64
|
): Promise<AlchemySmartAccountClient> {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const account = await createMultiOwnerModularAccount({
|
|
72
|
-
...config,
|
|
73
|
-
transport,
|
|
74
|
-
chain,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return createAlchemySmartAccountClient({
|
|
78
|
-
...config,
|
|
79
|
-
account,
|
|
80
|
-
opts,
|
|
81
|
-
})
|
|
82
|
-
.extend(multiOwnerPluginActions)
|
|
83
|
-
.extend(pluginManagerActions)
|
|
84
|
-
.extend(accountLoupeActions);
|
|
65
|
+
return createMultiOwnerModularAccountClient(config);
|
|
85
66
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSmartAccountClient,
|
|
3
3
|
smartAccountClientActions,
|
|
4
|
+
type NotType,
|
|
4
5
|
type SmartAccountClient,
|
|
5
6
|
type SmartAccountClientRpcSchema,
|
|
6
7
|
type SmartAccountSigner,
|
|
@@ -35,8 +36,16 @@ import {
|
|
|
35
36
|
type MultisigUserOperationContext,
|
|
36
37
|
} from "../plugins/multisig/index.js";
|
|
37
38
|
import { multisigSignatureMiddleware } from "../plugins/multisig/middleware.js";
|
|
39
|
+
import type { AlchemyModularAccountClientConfig } from "./alchemyClient.js";
|
|
40
|
+
import {
|
|
41
|
+
createAlchemySmartAccountClient,
|
|
42
|
+
isAlchemyTransport,
|
|
43
|
+
type AlchemySmartAccountClient,
|
|
44
|
+
type AlchemyTransport,
|
|
45
|
+
} from "@account-kit/infra";
|
|
46
|
+
import type { AlchemyMultisigAccountClientConfig } from "./multiSigAlchemyClient.js";
|
|
38
47
|
|
|
39
|
-
export type
|
|
48
|
+
export type CreateMultiOwnerModularAccountClientWithoutAlchemyParams<
|
|
40
49
|
TTransport extends Transport = Transport,
|
|
41
50
|
TChain extends Chain | undefined = Chain | undefined,
|
|
42
51
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
@@ -45,8 +54,19 @@ export type CreateMultiOwnerModularAccountClientParams<
|
|
|
45
54
|
"transport" | "chain"
|
|
46
55
|
> &
|
|
47
56
|
Omit<CreateLightAccountClientParams<TTransport, TChain, TSigner>, "account">;
|
|
57
|
+
export type CreateMultiOwnerModularAccountClientParams<
|
|
58
|
+
TTransport extends Transport = Transport,
|
|
59
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
60
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
61
|
+
> =
|
|
62
|
+
| CreateMultiOwnerModularAccountClientWithoutAlchemyParams<
|
|
63
|
+
TTransport,
|
|
64
|
+
TChain,
|
|
65
|
+
TSigner
|
|
66
|
+
>
|
|
67
|
+
| AlchemyModularAccountClientConfig<TSigner>;
|
|
48
68
|
|
|
49
|
-
export type
|
|
69
|
+
export type CreateMultisigModularAccountClientWithoutAlchemyParams<
|
|
50
70
|
TTransport extends Transport = Transport,
|
|
51
71
|
TChain extends Chain | undefined = Chain | undefined,
|
|
52
72
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
@@ -56,11 +76,45 @@ export type CreateMultisigModularAccountClientParams<
|
|
|
56
76
|
> &
|
|
57
77
|
Omit<CreateLightAccountClientParams<TTransport, TChain, TSigner>, "account">;
|
|
58
78
|
|
|
79
|
+
export type CreateMultisigModularAccountClientParams<
|
|
80
|
+
TTransport extends Transport = Transport,
|
|
81
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
82
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
83
|
+
> =
|
|
84
|
+
| CreateMultisigModularAccountClientWithoutAlchemyParams<
|
|
85
|
+
TTransport,
|
|
86
|
+
TChain,
|
|
87
|
+
TSigner
|
|
88
|
+
>
|
|
89
|
+
| AlchemyMultisigAccountClientConfig<TSigner>;
|
|
90
|
+
|
|
91
|
+
export function createMultiOwnerModularAccountClient<
|
|
92
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
93
|
+
>(
|
|
94
|
+
params: AlchemyModularAccountClientConfig<TSigner> & {
|
|
95
|
+
transport: AlchemyTransport;
|
|
96
|
+
}
|
|
97
|
+
): Promise<
|
|
98
|
+
AlchemySmartAccountClient<
|
|
99
|
+
Chain | undefined,
|
|
100
|
+
MultiOwnerModularAccount<TSigner>,
|
|
101
|
+
MultiOwnerPluginActions<MultiOwnerModularAccount<TSigner>> &
|
|
102
|
+
PluginManagerActions<MultiOwnerModularAccount<TSigner>> &
|
|
103
|
+
AccountLoupeActions<MultiOwnerModularAccount<TSigner>>
|
|
104
|
+
>
|
|
105
|
+
>;
|
|
106
|
+
|
|
59
107
|
export function createMultiOwnerModularAccountClient<
|
|
108
|
+
TTransport extends Transport = Transport,
|
|
60
109
|
TChain extends Chain | undefined = Chain | undefined,
|
|
61
110
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
62
111
|
>(
|
|
63
|
-
args: CreateMultiOwnerModularAccountClientParams<
|
|
112
|
+
args: CreateMultiOwnerModularAccountClientParams<
|
|
113
|
+
TTransport,
|
|
114
|
+
TChain,
|
|
115
|
+
TSigner
|
|
116
|
+
> &
|
|
117
|
+
NotType<TTransport, AlchemyTransport>
|
|
64
118
|
): Promise<
|
|
65
119
|
SmartAccountClient<
|
|
66
120
|
CustomTransport,
|
|
@@ -89,6 +143,19 @@ export function createMultiOwnerModularAccountClient<
|
|
|
89
143
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
90
144
|
* });
|
|
91
145
|
* ```
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { createMultiOwnerModularAccountClient } from "@account-kit/smart-contracts";
|
|
149
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
150
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
151
|
+
* import { generatePrivateKey } from "viem"
|
|
152
|
+
*
|
|
153
|
+
* const alchemyAccountClient = await createMultiOwnerModularAccountClient({
|
|
154
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
155
|
+
* chain: sepolia,
|
|
156
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
92
159
|
*
|
|
93
160
|
* @param {CreateMultiOwnerModularAccountClientParams} config The parameters for creating the multi-owner modular account client
|
|
94
161
|
* @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance with extended plugin actions
|
|
@@ -97,12 +164,28 @@ export async function createMultiOwnerModularAccountClient({
|
|
|
97
164
|
transport,
|
|
98
165
|
chain,
|
|
99
166
|
...params
|
|
100
|
-
}: CreateMultiOwnerModularAccountClientParams): Promise<
|
|
167
|
+
}: CreateMultiOwnerModularAccountClientParams): Promise<
|
|
168
|
+
SmartAccountClient | AlchemySmartAccountClient
|
|
169
|
+
> {
|
|
101
170
|
const modularAccount = await createMultiOwnerModularAccount({
|
|
102
171
|
...params,
|
|
103
172
|
transport,
|
|
104
173
|
chain,
|
|
105
174
|
});
|
|
175
|
+
if (isAlchemyTransport(transport, chain)) {
|
|
176
|
+
const { opts } = params;
|
|
177
|
+
|
|
178
|
+
return createAlchemySmartAccountClient({
|
|
179
|
+
...params,
|
|
180
|
+
account: modularAccount,
|
|
181
|
+
transport,
|
|
182
|
+
chain,
|
|
183
|
+
opts,
|
|
184
|
+
})
|
|
185
|
+
.extend(multiOwnerPluginActions)
|
|
186
|
+
.extend(pluginManagerActions)
|
|
187
|
+
.extend(accountLoupeActions);
|
|
188
|
+
}
|
|
106
189
|
|
|
107
190
|
return createSmartAccountClient({
|
|
108
191
|
...params,
|
|
@@ -116,10 +199,27 @@ export async function createMultiOwnerModularAccountClient({
|
|
|
116
199
|
}
|
|
117
200
|
|
|
118
201
|
export function createMultisigModularAccountClient<
|
|
202
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
203
|
+
>(
|
|
204
|
+
params: AlchemyMultisigAccountClientConfig<TSigner>
|
|
205
|
+
): Promise<
|
|
206
|
+
AlchemySmartAccountClient<
|
|
207
|
+
Chain | undefined,
|
|
208
|
+
MultisigModularAccount<TSigner>,
|
|
209
|
+
MultisigPluginActions<MultisigModularAccount<TSigner>> &
|
|
210
|
+
PluginManagerActions<MultisigModularAccount<TSigner>> &
|
|
211
|
+
AccountLoupeActions<MultisigModularAccount<TSigner>>,
|
|
212
|
+
MultisigUserOperationContext
|
|
213
|
+
>
|
|
214
|
+
>;
|
|
215
|
+
|
|
216
|
+
export function createMultisigModularAccountClient<
|
|
217
|
+
TTransport extends Transport = Transport,
|
|
119
218
|
TChain extends Chain | undefined = Chain | undefined,
|
|
120
219
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
121
220
|
>(
|
|
122
|
-
args: CreateMultisigModularAccountClientParams<
|
|
221
|
+
args: CreateMultisigModularAccountClientParams<TTransport, TChain, TSigner> &
|
|
222
|
+
NotType<TTransport, AlchemyTransport>
|
|
123
223
|
): Promise<
|
|
124
224
|
SmartAccountClient<
|
|
125
225
|
CustomTransport,
|
|
@@ -152,6 +252,21 @@ export function createMultisigModularAccountClient<
|
|
|
152
252
|
* threshold: 2, // 2 of N signatures
|
|
153
253
|
* });
|
|
154
254
|
* ```
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { createMultisigModularAccountClient } from "@account-kit/smart-contracts";
|
|
258
|
+
* import { sepolia } from "@account-kit/infra";
|
|
259
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
260
|
+
* import { generatePrivateKey } from "viem"
|
|
261
|
+
*
|
|
262
|
+
* const alchemyAccountClient = await createMultisigModularAccountClient({
|
|
263
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
264
|
+
* chain: sepolia,
|
|
265
|
+
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
|
|
266
|
+
* owners: [...], // other owners on the account
|
|
267
|
+
* threshold: 2, // 2 of N signatures
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
155
270
|
*
|
|
156
271
|
* @param {CreateMultisigModularAccountClientParams} config the parameters for configuring the multisig modular account client
|
|
157
272
|
* @returns {Promise<SmartAccountClient<Transport, Chain, MultisigModularAccount<SmartAccountSigner>, {}, SmartAccountClientRpcSchema, MultisigUserOperationContext>>} a promise that resolves to a `SmartAccountClient` object extended with the multisig modular account and additional actions
|
|
@@ -161,20 +276,49 @@ export async function createMultisigModularAccountClient({
|
|
|
161
276
|
chain,
|
|
162
277
|
...params
|
|
163
278
|
}: CreateMultisigModularAccountClientParams): Promise<
|
|
164
|
-
SmartAccountClient<
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
279
|
+
| SmartAccountClient<
|
|
280
|
+
Transport,
|
|
281
|
+
Chain,
|
|
282
|
+
MultisigModularAccount<SmartAccountSigner>,
|
|
283
|
+
{},
|
|
284
|
+
SmartAccountClientRpcSchema,
|
|
285
|
+
MultisigUserOperationContext
|
|
286
|
+
>
|
|
287
|
+
| AlchemySmartAccountClient<
|
|
288
|
+
Chain | undefined,
|
|
289
|
+
MultisigModularAccount<SmartAccountSigner>,
|
|
290
|
+
MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> &
|
|
291
|
+
PluginManagerActions<MultisigModularAccount<SmartAccountSigner>> &
|
|
292
|
+
AccountLoupeActions<MultisigModularAccount<SmartAccountSigner>>,
|
|
293
|
+
MultisigUserOperationContext
|
|
294
|
+
>
|
|
172
295
|
> {
|
|
173
296
|
const modularAccount = await createMultisigModularAccount({
|
|
174
297
|
...params,
|
|
175
298
|
transport,
|
|
176
299
|
chain,
|
|
177
300
|
});
|
|
301
|
+
if (isAlchemyTransport(transport, chain)) {
|
|
302
|
+
// Need to fit the type into this since the previous multiSigAlchemyClient had it at this point, but without an Value as Type should be safe
|
|
303
|
+
// And the createAlchemySmartAccountClient signUserOperation could not infer without this
|
|
304
|
+
let config: AlchemyMultisigAccountClientConfig = {
|
|
305
|
+
...params,
|
|
306
|
+
chain,
|
|
307
|
+
transport,
|
|
308
|
+
};
|
|
309
|
+
const { opts } = config;
|
|
310
|
+
|
|
311
|
+
return createAlchemySmartAccountClient({
|
|
312
|
+
...config,
|
|
313
|
+
account: modularAccount,
|
|
314
|
+
opts,
|
|
315
|
+
signUserOperation: multisigSignatureMiddleware,
|
|
316
|
+
})
|
|
317
|
+
.extend(smartAccountClientActions)
|
|
318
|
+
.extend(multisigPluginActions)
|
|
319
|
+
.extend(pluginManagerActions)
|
|
320
|
+
.extend(accountLoupeActions);
|
|
321
|
+
}
|
|
178
322
|
|
|
179
323
|
const client = createSmartAccountClient({
|
|
180
324
|
...params,
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
|
-
smartAccountClientActions,
|
|
3
|
-
type SmartAccountSigner,
|
|
4
|
-
} from "@aa-sdk/core";
|
|
5
|
-
import {
|
|
6
|
-
createAlchemySmartAccountClient,
|
|
7
3
|
type AlchemySmartAccountClient,
|
|
8
4
|
type AlchemySmartAccountClientConfig,
|
|
5
|
+
type AlchemyTransport,
|
|
9
6
|
} from "@account-kit/infra";
|
|
10
7
|
import {
|
|
11
|
-
|
|
12
|
-
createMultisigModularAccount,
|
|
13
|
-
multisigPluginActions,
|
|
14
|
-
multisigSignatureMiddleware,
|
|
15
|
-
pluginManagerActions,
|
|
8
|
+
createMultisigModularAccountClient,
|
|
16
9
|
type AccountLoupeActions,
|
|
17
10
|
type CreateMultisigModularAccountParams,
|
|
18
11
|
type LightAccount,
|
|
@@ -38,7 +31,7 @@ export type AlchemyMultisigAccountClientConfig<
|
|
|
38
31
|
MultisigUserOperationContext
|
|
39
32
|
>,
|
|
40
33
|
"account"
|
|
41
|
-
|
|
34
|
+
> & { transport: AlchemyTransport };
|
|
42
35
|
|
|
43
36
|
export function createMultisigAccountAlchemyClient<
|
|
44
37
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
@@ -74,6 +67,7 @@ export function createMultisigAccountAlchemyClient<
|
|
|
74
67
|
* });
|
|
75
68
|
* ```
|
|
76
69
|
*
|
|
70
|
+
* @deprecated Use createModularAccountClient instead of this function, we are switching based on the transport
|
|
77
71
|
* @param {AlchemyMultisigAccountClientConfig} config The configuration for the Alchemy multisig account client
|
|
78
72
|
* @returns {Promise<AlchemySmartAccountClient<Transport, Chain | undefined, MultisigModularAccount<SmartAccountSigner>, MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> & PluginManagerActions<MultisigModularAccount<SmartAccountSigner>> & AccountLoupeActions<MultisigModularAccount<SmartAccountSigner>>, MultisigUserOperationContext>>} A promise that resolves to an Alchemy Smart Account Client for multisig accounts with extended functionalities.
|
|
79
73
|
*/
|
|
@@ -89,22 +83,5 @@ export async function createMultisigAccountAlchemyClient(
|
|
|
89
83
|
MultisigUserOperationContext
|
|
90
84
|
>
|
|
91
85
|
> {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const account = await createMultisigModularAccount({
|
|
95
|
-
...config,
|
|
96
|
-
transport,
|
|
97
|
-
chain,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return createAlchemySmartAccountClient({
|
|
101
|
-
...config,
|
|
102
|
-
account,
|
|
103
|
-
opts,
|
|
104
|
-
signUserOperation: multisigSignatureMiddleware,
|
|
105
|
-
})
|
|
106
|
-
.extend(smartAccountClientActions)
|
|
107
|
-
.extend(multisigPluginActions)
|
|
108
|
-
.extend(pluginManagerActions)
|
|
109
|
-
.extend(accountLoupeActions);
|
|
86
|
+
return createMultisigModularAccountClient(config);
|
|
110
87
|
}
|