@account-kit/wallet-client 0.1.0-alpha.11 → 0.1.0-alpha.13
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/client/actions/getCallsStatus.d.ts +4 -3
- package/dist/esm/client/actions/getCallsStatus.js +1 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +5 -4
- package/dist/esm/client/actions/grantPermissions.js +21 -5
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +4 -3
- package/dist/esm/client/actions/prepareCalls.js +3 -2
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +4 -3
- package/dist/esm/client/actions/prepareSign.js +1 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.js +1 -1
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +171 -349
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/index.d.ts +8 -6
- package/dist/esm/client/index.js +18 -18
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +1 -5
- package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +8 -32
- package/dist/esm/internal/account.js.map +1 -0
- package/dist/esm/types.d.ts +4 -10
- package/dist/esm/types.js.map +1 -1
- package/dist/types/client/actions/getCallsStatus.d.ts +4 -3
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +5 -4
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +4 -3
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +4 -3
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +8 -6
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +2 -6
- package/dist/types/internal/account.d.ts.map +1 -0
- package/dist/types/types.d.ts +4 -10
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -8
- package/src/client/actions/getCallsStatus.ts +8 -6
- package/src/client/actions/grantPermissions.ts +41 -10
- package/src/client/actions/prepareCalls.ts +13 -8
- package/src/client/actions/prepareSign.ts +9 -6
- package/src/client/actions/requestAccount.ts +1 -1
- package/src/client/client.e2e-test.ts +208 -442
- package/src/client/index.ts +39 -30
- package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +9 -49
- package/src/types.ts +6 -17
- package/dist/esm/exports/internal.d.ts +0 -4
- package/dist/esm/exports/internal.js +0 -3
- package/dist/esm/exports/internal.js.map +0 -1
- package/dist/esm/isomorphic/actions/createSession.d.ts +0 -13
- package/dist/esm/isomorphic/actions/createSession.js +0 -94
- package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
- package/dist/esm/isomorphic/actions/formatSign.d.ts +0 -8
- package/dist/esm/isomorphic/actions/formatSign.js +0 -42
- package/dist/esm/isomorphic/actions/formatSign.js.map +0 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -7
- package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -71
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -7
- package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
- package/dist/esm/isomorphic/actions/prepareSign.d.ts +0 -7
- package/dist/esm/isomorphic/actions/prepareSign.js +0 -49
- package/dist/esm/isomorphic/actions/prepareSign.js.map +0 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -7
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -183
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
- package/dist/esm/isomorphic/client.d.ts +0 -275
- package/dist/esm/isomorphic/client.js +0 -41
- package/dist/esm/isomorphic/client.js.map +0 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +0 -19
- package/dist/esm/isomorphic/utils/7702.js +0 -70
- package/dist/esm/isomorphic/utils/7702.js.map +0 -1
- package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
- package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
- package/dist/esm/isomorphic/utils/decodeSignature.js +0 -15
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
- package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
- package/dist/esm/local/client.d.ts +0 -3
- package/dist/esm/local/client.js +0 -97
- package/dist/esm/local/client.js.map +0 -1
- package/dist/esm/remote/client.d.ts +0 -9
- package/dist/esm/remote/client.js +0 -41
- package/dist/esm/remote/client.js.map +0 -1
- package/dist/types/exports/internal.d.ts +0 -5
- package/dist/types/exports/internal.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/createSession.d.ts +0 -14
- package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/formatSign.d.ts +0 -9
- package/dist/types/isomorphic/actions/formatSign.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -8
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -8
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/prepareSign.d.ts +0 -8
- package/dist/types/isomorphic/actions/prepareSign.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/client.d.ts +0 -276
- package/dist/types/isomorphic/client.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/7702.d.ts +0 -20
- package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
- package/dist/types/local/client.d.ts +0 -4
- package/dist/types/local/client.d.ts.map +0 -1
- package/dist/types/remote/client.d.ts +0 -10
- package/dist/types/remote/client.d.ts.map +0 -1
- package/src/exports/internal.ts +0 -8
- package/src/isomorphic/actions/createSession.ts +0 -163
- package/src/isomorphic/actions/formatSign.ts +0 -76
- package/src/isomorphic/actions/getCallsStatus.ts +0 -112
- package/src/isomorphic/actions/prepareCalls.ts +0 -172
- package/src/isomorphic/actions/prepareSign.ts +0 -88
- package/src/isomorphic/actions/sendPreparedCalls.ts +0 -271
- package/src/isomorphic/client.ts +0 -102
- package/src/isomorphic/utils/7702.ts +0 -135
- package/src/isomorphic/utils/createDummySigner.ts +0 -27
- package/src/isomorphic/utils/decodeSignature.ts +0 -21
- package/src/isomorphic/utils/parsePermissionsContext.ts +0 -51
- package/src/isomorphic/utils/supportsFeature.ts +0 -34
- package/src/local/client.ts +0 -136
- package/src/remote/client.ts +0 -67
|
@@ -15,507 +15,273 @@ describe("Client E2E Tests", () => {
|
|
|
15
15
|
apiKey: process.env.TEST_ALCHEMY_API_KEY!,
|
|
16
16
|
},
|
|
17
17
|
);
|
|
18
|
-
describe("Local Mode Tests", () => {
|
|
19
|
-
const signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
20
|
-
"0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03",
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const client = createSmartWalletClient({
|
|
24
|
-
transport,
|
|
25
|
-
chain: arbitrumSepolia,
|
|
26
|
-
mode: "local",
|
|
27
|
-
signer,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const publicClient = createPublicClient({
|
|
31
|
-
chain: arbitrumSepolia,
|
|
32
|
-
transport,
|
|
33
|
-
});
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`,
|
|
39
|
-
);
|
|
40
|
-
});
|
|
19
|
+
const signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
20
|
+
"0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
|
|
21
|
+
);
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
const client = createSmartWalletClient({
|
|
24
|
+
transport,
|
|
25
|
+
chain: arbitrumSepolia,
|
|
26
|
+
signer,
|
|
27
|
+
});
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
29
|
+
const publicClient = createPublicClient({
|
|
30
|
+
chain: arbitrumSepolia,
|
|
31
|
+
transport,
|
|
32
|
+
});
|
|
52
33
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
34
|
+
it("should successfully get a counterfactual address", async () => {
|
|
35
|
+
const account = await client.requestAccount();
|
|
36
|
+
expect(account.address).toMatchInlineSnapshot(
|
|
37
|
+
`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
59
40
|
|
|
60
|
-
|
|
41
|
+
it("should successfully request account with different salt", async () => {
|
|
42
|
+
const account = await client.requestAccount({
|
|
43
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
44
|
+
creationHint: { salt: "0x1" },
|
|
61
45
|
});
|
|
62
46
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const isValid = await publicClient.verifyMessage({
|
|
68
|
-
address: account.address,
|
|
69
|
-
message,
|
|
70
|
-
signature,
|
|
71
|
-
});
|
|
72
|
-
expect(isValid).toBeTrue();
|
|
73
|
-
});
|
|
47
|
+
expect(account.address).toMatchInlineSnapshot(
|
|
48
|
+
`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
signature,
|
|
81
|
-
address: account.address,
|
|
82
|
-
});
|
|
83
|
-
expect(isValid).toBeTrue();
|
|
52
|
+
it("should not cache account if different inputs provided", async () => {
|
|
53
|
+
const account = await client.requestAccount();
|
|
54
|
+
const account2 = await client.requestAccount({
|
|
55
|
+
id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
|
|
56
|
+
creationHint: { salt: "0x2" },
|
|
84
57
|
});
|
|
85
58
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
|
|
89
|
-
creationHint: { salt: "0x1" },
|
|
90
|
-
});
|
|
91
|
-
const message = "hello world";
|
|
59
|
+
expect(account.address).not.toEqual(account2.address);
|
|
60
|
+
});
|
|
92
61
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
expect(isValid).toBeTrue();
|
|
62
|
+
it("can correctly sign a message", async () => {
|
|
63
|
+
const account = await client.requestAccount();
|
|
64
|
+
const message = "hello world";
|
|
65
|
+
const signature = await client.signMessage({ message });
|
|
66
|
+
const isValid = await publicClient.verifyMessage({
|
|
67
|
+
address: account.address,
|
|
68
|
+
message: "hello world",
|
|
69
|
+
signature,
|
|
103
70
|
});
|
|
71
|
+
expect(isValid).toBeTrue();
|
|
72
|
+
});
|
|
104
73
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
...givenTypedData,
|
|
113
|
-
account: account.address,
|
|
114
|
-
});
|
|
115
|
-
const isValid = await publicClient.verifyTypedData({
|
|
116
|
-
...givenTypedData,
|
|
117
|
-
signature,
|
|
118
|
-
address: account.address,
|
|
119
|
-
});
|
|
120
|
-
expect(isValid).toBeTrue();
|
|
74
|
+
it("can correctly sign typed data", async () => {
|
|
75
|
+
const account = await client.requestAccount();
|
|
76
|
+
const signature = await client.signTypedData(givenTypedData);
|
|
77
|
+
const isValid = await publicClient.verifyTypedData({
|
|
78
|
+
...givenTypedData,
|
|
79
|
+
signature,
|
|
80
|
+
address: account.address,
|
|
121
81
|
});
|
|
122
|
-
|
|
123
|
-
it(
|
|
124
|
-
"should successfully send a UO with paymaster using 7702",
|
|
125
|
-
async () => {
|
|
126
|
-
const _signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
127
|
-
"0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f",
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const _client = createSmartWalletClient({
|
|
131
|
-
transport,
|
|
132
|
-
chain: arbitrumSepolia,
|
|
133
|
-
mode: "local",
|
|
134
|
-
signer: _signer,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const account = await _client.requestAccount({
|
|
138
|
-
creationHint: {
|
|
139
|
-
accountType: "7702",
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const preparedCalls = await _client.prepareCalls({
|
|
144
|
-
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
145
|
-
from: account.address,
|
|
146
|
-
capabilities: {
|
|
147
|
-
paymasterService: {
|
|
148
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const signedCalls = await _client.signPreparedCalls(preparedCalls);
|
|
154
|
-
|
|
155
|
-
const result = await _client.sendPreparedCalls(signedCalls);
|
|
156
|
-
|
|
157
|
-
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
158
|
-
|
|
159
|
-
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
timeout: 45_000,
|
|
163
|
-
},
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
it(
|
|
167
|
-
"should successfully send a UO with paymaster",
|
|
168
|
-
async () => {
|
|
169
|
-
const account = await client.requestAccount();
|
|
170
|
-
const preparedCalls = await client.prepareCalls({
|
|
171
|
-
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
172
|
-
from: account.address,
|
|
173
|
-
capabilities: {
|
|
174
|
-
paymasterService: {
|
|
175
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
181
|
-
|
|
182
|
-
const result = await client.sendPreparedCalls(signedCalls);
|
|
183
|
-
|
|
184
|
-
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
185
|
-
|
|
186
|
-
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
timeout: 45_000,
|
|
190
|
-
},
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
it(
|
|
194
|
-
"should successfully create a session with grantPermissions and send a UO",
|
|
195
|
-
async () => {
|
|
196
|
-
const account = await client.requestAccount();
|
|
197
|
-
|
|
198
|
-
const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
199
|
-
|
|
200
|
-
const permissions = await client.grantPermissions({
|
|
201
|
-
account: account.address,
|
|
202
|
-
expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
|
|
203
|
-
key: {
|
|
204
|
-
publicKey: await sessionKey.getAddress(),
|
|
205
|
-
type: "secp256k1",
|
|
206
|
-
},
|
|
207
|
-
permissions: [{ type: "root" }],
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const sessionKeyClient = createSmartWalletClient({
|
|
211
|
-
transport,
|
|
212
|
-
chain: arbitrumSepolia,
|
|
213
|
-
mode: "local",
|
|
214
|
-
signer: sessionKey,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const preparedCalls = await sessionKeyClient.prepareCalls({
|
|
218
|
-
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
219
|
-
from: account.address,
|
|
220
|
-
capabilities: {
|
|
221
|
-
paymasterService: {
|
|
222
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
223
|
-
},
|
|
224
|
-
permissions,
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
const signedCalls =
|
|
229
|
-
await sessionKeyClient.signPreparedCalls(preparedCalls);
|
|
230
|
-
|
|
231
|
-
const result = await sessionKeyClient.sendPreparedCalls({
|
|
232
|
-
...signedCalls,
|
|
233
|
-
capabilities: {
|
|
234
|
-
permissions,
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
239
|
-
|
|
240
|
-
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
timeout: 45_000,
|
|
244
|
-
},
|
|
245
|
-
);
|
|
82
|
+
expect(isValid).toBeTrue();
|
|
246
83
|
});
|
|
247
84
|
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
"
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const client = createSmartWalletClient({
|
|
254
|
-
transport,
|
|
255
|
-
chain: arbitrumSepolia,
|
|
256
|
-
mode: "remote",
|
|
257
|
-
signer,
|
|
85
|
+
it("can correctly sign a message with a different account", async () => {
|
|
86
|
+
const account = await client.requestAccount({
|
|
87
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
88
|
+
creationHint: { salt: "0x1" },
|
|
258
89
|
});
|
|
259
90
|
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
91
|
+
const message = "hello world";
|
|
92
|
+
const signature = await client.signMessage({
|
|
93
|
+
message,
|
|
94
|
+
account: account.address,
|
|
263
95
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
|
|
269
|
-
);
|
|
96
|
+
const isValid = await publicClient.verifyMessage({
|
|
97
|
+
address: account.address,
|
|
98
|
+
message: "hello world",
|
|
99
|
+
signature,
|
|
270
100
|
});
|
|
101
|
+
expect(isValid).toBeTrue();
|
|
102
|
+
});
|
|
271
103
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
expect(account.address).toMatchInlineSnapshot(
|
|
279
|
-
`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
|
|
280
|
-
);
|
|
104
|
+
it("can correctly sign typed data with a different account", async () => {
|
|
105
|
+
const account = await client.requestAccount({
|
|
106
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
107
|
+
creationHint: { salt: "0x1" },
|
|
281
108
|
});
|
|
282
109
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
|
|
287
|
-
creationHint: { salt: "0x2" },
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
expect(account.address).not.toEqual(account2.address);
|
|
110
|
+
const signature = await client.signTypedData({
|
|
111
|
+
...givenTypedData,
|
|
112
|
+
account: account.address,
|
|
291
113
|
});
|
|
292
114
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const isValid = await publicClient.verifyMessage({
|
|
298
|
-
address: account.address,
|
|
299
|
-
message: "hello world",
|
|
300
|
-
signature,
|
|
301
|
-
});
|
|
302
|
-
expect(isValid).toBeTrue();
|
|
115
|
+
const isValid = await publicClient.verifyTypedData({
|
|
116
|
+
...givenTypedData,
|
|
117
|
+
signature,
|
|
118
|
+
address: account.address,
|
|
303
119
|
});
|
|
120
|
+
expect(isValid).toBeTrue();
|
|
121
|
+
});
|
|
304
122
|
|
|
305
|
-
|
|
123
|
+
it(
|
|
124
|
+
"should successfully send a UO with paymaster",
|
|
125
|
+
async () => {
|
|
306
126
|
const account = await client.requestAccount();
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
127
|
+
const preparedCalls = await client.prepareCalls({
|
|
128
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
129
|
+
from: account.address,
|
|
130
|
+
capabilities: {
|
|
131
|
+
paymasterService: {
|
|
132
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
312
135
|
});
|
|
313
|
-
expect(isValid).toBeTrue();
|
|
314
|
-
});
|
|
315
136
|
|
|
316
|
-
|
|
317
|
-
const account = await client.requestAccount({
|
|
318
|
-
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
319
|
-
creationHint: { salt: "0x1" },
|
|
320
|
-
});
|
|
137
|
+
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
321
138
|
|
|
322
|
-
const
|
|
323
|
-
const signature = await client.signMessage({
|
|
324
|
-
message,
|
|
325
|
-
account: account.address,
|
|
326
|
-
});
|
|
327
|
-
const isValid = await publicClient.verifyMessage({
|
|
328
|
-
address: account.address,
|
|
329
|
-
message: "hello world",
|
|
330
|
-
signature,
|
|
331
|
-
});
|
|
332
|
-
expect(isValid).toBeTrue();
|
|
333
|
-
});
|
|
139
|
+
const result = await client.sendPreparedCalls(signedCalls);
|
|
334
140
|
|
|
335
|
-
|
|
336
|
-
const account = await client.requestAccount({
|
|
337
|
-
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
338
|
-
creationHint: { salt: "0x1" },
|
|
339
|
-
});
|
|
141
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
340
142
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
...givenTypedData,
|
|
348
|
-
signature,
|
|
349
|
-
address: account.address,
|
|
350
|
-
});
|
|
351
|
-
expect(isValid).toBeTrue();
|
|
352
|
-
});
|
|
143
|
+
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
timeout: 45_000,
|
|
147
|
+
},
|
|
148
|
+
);
|
|
353
149
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
},
|
|
150
|
+
it(
|
|
151
|
+
"should successfully drop and replace a UO with repeat calls",
|
|
152
|
+
async () => {
|
|
153
|
+
const account = await client.requestAccount();
|
|
154
|
+
const preparedCalls = await client.prepareCalls({
|
|
155
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
156
|
+
from: account.address,
|
|
157
|
+
capabilities: {
|
|
158
|
+
paymasterService: {
|
|
159
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
365
160
|
},
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
161
|
+
},
|
|
162
|
+
});
|
|
369
163
|
|
|
370
|
-
|
|
164
|
+
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
165
|
+
const result = await client.sendPreparedCalls(signedCalls);
|
|
371
166
|
|
|
372
|
-
|
|
167
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
373
168
|
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
timeout: 45_000,
|
|
378
|
-
},
|
|
379
|
-
);
|
|
169
|
+
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
380
170
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
from: account.address,
|
|
388
|
-
capabilities: {
|
|
389
|
-
paymasterService: {
|
|
390
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
391
|
-
},
|
|
171
|
+
const prepareCalls2 = await client.prepareCalls({
|
|
172
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
173
|
+
from: account.address,
|
|
174
|
+
capabilities: {
|
|
175
|
+
paymasterService: {
|
|
176
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
392
177
|
},
|
|
393
|
-
}
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
|
|
181
|
+
const result2 = await client.sendPreparedCalls(signedCalls2);
|
|
394
182
|
|
|
395
|
-
|
|
396
|
-
const result = await client.sendPreparedCalls(signedCalls);
|
|
183
|
+
expect(result2.preparedCallIds).toBeArrayOfSize(1);
|
|
397
184
|
|
|
398
|
-
|
|
185
|
+
await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
timeout: 90_000,
|
|
189
|
+
},
|
|
190
|
+
);
|
|
399
191
|
|
|
400
|
-
|
|
192
|
+
it(
|
|
193
|
+
"should successfully send a UO with paymaster using 7702",
|
|
194
|
+
async () => {
|
|
195
|
+
const _signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
196
|
+
"0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
|
|
197
|
+
);
|
|
401
198
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
});
|
|
411
|
-
const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
|
|
412
|
-
const result2 = await client.sendPreparedCalls(signedCalls2);
|
|
199
|
+
const _client = createSmartWalletClient({
|
|
200
|
+
transport,
|
|
201
|
+
chain: arbitrumSepolia,
|
|
202
|
+
signer: _signer,
|
|
203
|
+
});
|
|
413
204
|
|
|
414
|
-
|
|
205
|
+
const account = await _client.requestAccount({
|
|
206
|
+
creationHint: {
|
|
207
|
+
accountType: "7702",
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
expect(account.address).toBe(await _signer.getAddress());
|
|
211
|
+
|
|
212
|
+
const preparedCalls = await _client.prepareCalls({
|
|
213
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
214
|
+
from: account.address,
|
|
215
|
+
capabilities: {
|
|
216
|
+
paymasterService: {
|
|
217
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
415
221
|
|
|
416
|
-
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
timeout: 90_000,
|
|
420
|
-
},
|
|
421
|
-
);
|
|
222
|
+
const signedCalls = await _client.signPreparedCalls(preparedCalls);
|
|
422
223
|
|
|
423
|
-
|
|
424
|
-
"should successfully send a UO with paymaster using 7702",
|
|
425
|
-
async () => {
|
|
426
|
-
const _signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
427
|
-
"0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
|
|
428
|
-
);
|
|
429
|
-
|
|
430
|
-
const _client = createSmartWalletClient({
|
|
431
|
-
transport,
|
|
432
|
-
chain: arbitrumSepolia,
|
|
433
|
-
mode: "remote",
|
|
434
|
-
signer: _signer,
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
const account = await _client.requestAccount({
|
|
438
|
-
creationHint: {
|
|
439
|
-
accountType: "7702",
|
|
440
|
-
},
|
|
441
|
-
});
|
|
442
|
-
expect(account.address).toBe(await _signer.getAddress());
|
|
443
|
-
|
|
444
|
-
const preparedCalls = await _client.prepareCalls({
|
|
445
|
-
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
446
|
-
from: account.address,
|
|
447
|
-
capabilities: {
|
|
448
|
-
paymasterService: {
|
|
449
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
});
|
|
224
|
+
const result = await _client.sendPreparedCalls(signedCalls);
|
|
453
225
|
|
|
454
|
-
|
|
226
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
455
227
|
|
|
456
|
-
|
|
228
|
+
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
229
|
+
},
|
|
230
|
+
{ timeout: 45_000 },
|
|
231
|
+
);
|
|
457
232
|
|
|
458
|
-
|
|
233
|
+
it(
|
|
234
|
+
"should successfully create a session with grantPermissions and send a UO",
|
|
235
|
+
async () => {
|
|
236
|
+
const account = await client.requestAccount();
|
|
459
237
|
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
{ timeout: 45_000 },
|
|
463
|
-
);
|
|
238
|
+
const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
464
239
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
240
|
+
const permissions = await client.grantPermissions({
|
|
241
|
+
account: account.address,
|
|
242
|
+
expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
|
|
243
|
+
key: {
|
|
244
|
+
publicKey: await sessionKey.getAddress(),
|
|
245
|
+
type: "secp256k1",
|
|
246
|
+
},
|
|
247
|
+
permissions: [{ type: "root" }],
|
|
248
|
+
});
|
|
469
249
|
|
|
470
|
-
|
|
250
|
+
const sessionKeyClient = createSmartWalletClient({
|
|
251
|
+
transport,
|
|
252
|
+
chain: arbitrumSepolia,
|
|
253
|
+
signer: sessionKey,
|
|
254
|
+
});
|
|
471
255
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
256
|
+
const preparedCalls = await sessionKeyClient.prepareCalls({
|
|
257
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
258
|
+
from: account.address,
|
|
259
|
+
capabilities: {
|
|
260
|
+
paymasterService: {
|
|
261
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
478
262
|
},
|
|
479
|
-
permissions
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
const sessionKeyClient = createSmartWalletClient({
|
|
483
|
-
transport,
|
|
484
|
-
chain: arbitrumSepolia,
|
|
485
|
-
mode: "remote",
|
|
486
|
-
signer: sessionKey,
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
const preparedCalls = await sessionKeyClient.prepareCalls({
|
|
490
|
-
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
491
|
-
from: account.address,
|
|
492
|
-
capabilities: {
|
|
493
|
-
paymasterService: {
|
|
494
|
-
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
495
|
-
},
|
|
496
|
-
permissions,
|
|
497
|
-
},
|
|
498
|
-
});
|
|
263
|
+
permissions,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
499
266
|
|
|
500
|
-
|
|
501
|
-
|
|
267
|
+
const signedCalls =
|
|
268
|
+
await sessionKeyClient.signPreparedCalls(preparedCalls);
|
|
502
269
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
270
|
+
const result = await sessionKeyClient.sendPreparedCalls({
|
|
271
|
+
...signedCalls,
|
|
272
|
+
capabilities: {
|
|
273
|
+
permissions,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
509
276
|
|
|
510
|
-
|
|
277
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
511
278
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
});
|
|
279
|
+
await waitForUserOpSuccess(client, result.preparedCallIds[0]);
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
timeout: 45_000,
|
|
283
|
+
},
|
|
284
|
+
);
|
|
519
285
|
|
|
520
286
|
const givenTypedData = {
|
|
521
287
|
types: {
|