@account-kit/wallet-client 0.1.0-alpha.11 → 0.1.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/esm/client/actions/getCallsStatus.d.ts +4 -3
  2. package/dist/esm/client/actions/getCallsStatus.js +1 -0
  3. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  4. package/dist/esm/client/actions/grantPermissions.d.ts +5 -4
  5. package/dist/esm/client/actions/grantPermissions.js +21 -5
  6. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  7. package/dist/esm/client/actions/prepareCalls.d.ts +4 -3
  8. package/dist/esm/client/actions/prepareCalls.js +1 -0
  9. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  10. package/dist/esm/client/actions/prepareSign.d.ts +4 -3
  11. package/dist/esm/client/actions/prepareSign.js +1 -0
  12. package/dist/esm/client/actions/prepareSign.js.map +1 -1
  13. package/dist/esm/client/actions/requestAccount.js +1 -1
  14. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  15. package/dist/esm/client/client.e2e-test.js +171 -349
  16. package/dist/esm/client/client.e2e-test.js.map +1 -1
  17. package/dist/esm/client/index.d.ts +1 -4
  18. package/dist/esm/client/index.js +13 -18
  19. package/dist/esm/client/index.js.map +1 -1
  20. package/dist/esm/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +1 -5
  21. package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +8 -32
  22. package/dist/esm/internal/account.js.map +1 -0
  23. package/dist/esm/types.d.ts +2 -8
  24. package/dist/esm/types.js.map +1 -1
  25. package/dist/types/client/actions/getCallsStatus.d.ts +4 -3
  26. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  27. package/dist/types/client/actions/grantPermissions.d.ts +5 -4
  28. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  29. package/dist/types/client/actions/prepareCalls.d.ts +4 -3
  30. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  31. package/dist/types/client/actions/prepareSign.d.ts +4 -3
  32. package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
  33. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  34. package/dist/types/client/index.d.ts +1 -4
  35. package/dist/types/client/index.d.ts.map +1 -1
  36. package/dist/types/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +2 -6
  37. package/dist/types/internal/account.d.ts.map +1 -0
  38. package/dist/types/types.d.ts +2 -8
  39. package/dist/types/types.d.ts.map +1 -1
  40. package/package.json +3 -8
  41. package/src/client/actions/getCallsStatus.ts +8 -6
  42. package/src/client/actions/grantPermissions.ts +41 -10
  43. package/src/client/actions/prepareCalls.ts +11 -6
  44. package/src/client/actions/prepareSign.ts +9 -6
  45. package/src/client/actions/requestAccount.ts +1 -1
  46. package/src/client/client.e2e-test.ts +208 -442
  47. package/src/client/index.ts +22 -23
  48. package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +9 -49
  49. package/src/types.ts +4 -15
  50. package/dist/esm/exports/internal.d.ts +0 -4
  51. package/dist/esm/exports/internal.js +0 -3
  52. package/dist/esm/exports/internal.js.map +0 -1
  53. package/dist/esm/isomorphic/actions/createSession.d.ts +0 -13
  54. package/dist/esm/isomorphic/actions/createSession.js +0 -94
  55. package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
  56. package/dist/esm/isomorphic/actions/formatSign.d.ts +0 -8
  57. package/dist/esm/isomorphic/actions/formatSign.js +0 -42
  58. package/dist/esm/isomorphic/actions/formatSign.js.map +0 -1
  59. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -7
  60. package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -71
  61. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
  62. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -7
  63. package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
  64. package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
  65. package/dist/esm/isomorphic/actions/prepareSign.d.ts +0 -7
  66. package/dist/esm/isomorphic/actions/prepareSign.js +0 -49
  67. package/dist/esm/isomorphic/actions/prepareSign.js.map +0 -1
  68. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -7
  69. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -183
  70. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
  71. package/dist/esm/isomorphic/client.d.ts +0 -275
  72. package/dist/esm/isomorphic/client.js +0 -41
  73. package/dist/esm/isomorphic/client.js.map +0 -1
  74. package/dist/esm/isomorphic/utils/7702.d.ts +0 -19
  75. package/dist/esm/isomorphic/utils/7702.js +0 -70
  76. package/dist/esm/isomorphic/utils/7702.js.map +0 -1
  77. package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
  78. package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
  79. package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
  80. package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
  81. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
  82. package/dist/esm/isomorphic/utils/decodeSignature.js +0 -15
  83. package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
  84. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
  85. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
  86. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
  87. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
  88. package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
  89. package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
  90. package/dist/esm/local/client.d.ts +0 -3
  91. package/dist/esm/local/client.js +0 -97
  92. package/dist/esm/local/client.js.map +0 -1
  93. package/dist/esm/remote/client.d.ts +0 -9
  94. package/dist/esm/remote/client.js +0 -41
  95. package/dist/esm/remote/client.js.map +0 -1
  96. package/dist/types/exports/internal.d.ts +0 -5
  97. package/dist/types/exports/internal.d.ts.map +0 -1
  98. package/dist/types/isomorphic/actions/createSession.d.ts +0 -14
  99. package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
  100. package/dist/types/isomorphic/actions/formatSign.d.ts +0 -9
  101. package/dist/types/isomorphic/actions/formatSign.d.ts.map +0 -1
  102. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -8
  103. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
  104. package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -8
  105. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
  106. package/dist/types/isomorphic/actions/prepareSign.d.ts +0 -8
  107. package/dist/types/isomorphic/actions/prepareSign.d.ts.map +0 -1
  108. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
  109. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
  110. package/dist/types/isomorphic/client.d.ts +0 -276
  111. package/dist/types/isomorphic/client.d.ts.map +0 -1
  112. package/dist/types/isomorphic/utils/7702.d.ts +0 -20
  113. package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
  114. package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
  115. package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
  116. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
  117. package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
  118. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
  119. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
  120. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
  121. package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
  122. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
  123. package/dist/types/local/client.d.ts +0 -4
  124. package/dist/types/local/client.d.ts.map +0 -1
  125. package/dist/types/remote/client.d.ts +0 -10
  126. package/dist/types/remote/client.d.ts.map +0 -1
  127. package/src/exports/internal.ts +0 -8
  128. package/src/isomorphic/actions/createSession.ts +0 -163
  129. package/src/isomorphic/actions/formatSign.ts +0 -76
  130. package/src/isomorphic/actions/getCallsStatus.ts +0 -112
  131. package/src/isomorphic/actions/prepareCalls.ts +0 -172
  132. package/src/isomorphic/actions/prepareSign.ts +0 -88
  133. package/src/isomorphic/actions/sendPreparedCalls.ts +0 -271
  134. package/src/isomorphic/client.ts +0 -102
  135. package/src/isomorphic/utils/7702.ts +0 -135
  136. package/src/isomorphic/utils/createDummySigner.ts +0 -27
  137. package/src/isomorphic/utils/decodeSignature.ts +0 -21
  138. package/src/isomorphic/utils/parsePermissionsContext.ts +0 -51
  139. package/src/isomorphic/utils/supportsFeature.ts +0 -34
  140. package/src/local/client.ts +0 -136
  141. package/src/remote/client.ts +0 -67
@@ -12,381 +12,203 @@ describe("Client E2E Tests", () => {
12
12
  : {
13
13
  apiKey: process.env.TEST_ALCHEMY_API_KEY,
14
14
  });
15
- describe("Local Mode Tests", () => {
16
- const signer = LocalAccountSigner.privateKeyToAccountSigner("0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03");
17
- const client = createSmartWalletClient({
18
- transport,
19
- chain: arbitrumSepolia,
20
- mode: "local",
21
- signer,
15
+ const signer = LocalAccountSigner.privateKeyToAccountSigner("0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d");
16
+ const client = createSmartWalletClient({
17
+ transport,
18
+ chain: arbitrumSepolia,
19
+ signer,
20
+ });
21
+ const publicClient = createPublicClient({
22
+ chain: arbitrumSepolia,
23
+ transport,
24
+ });
25
+ it("should successfully get a counterfactual address", async () => {
26
+ const account = await client.requestAccount();
27
+ expect(account.address).toMatchInlineSnapshot(`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`);
28
+ });
29
+ it("should successfully request account with different salt", async () => {
30
+ const account = await client.requestAccount({
31
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
32
+ creationHint: { salt: "0x1" },
22
33
  });
23
- const publicClient = createPublicClient({
24
- chain: arbitrumSepolia,
25
- transport,
34
+ expect(account.address).toMatchInlineSnapshot(`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`);
35
+ });
36
+ it("should not cache account if different inputs provided", async () => {
37
+ const account = await client.requestAccount();
38
+ const account2 = await client.requestAccount({
39
+ id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
40
+ creationHint: { salt: "0x2" },
26
41
  });
27
- it("should successfully get a counterfactual address", async () => {
28
- const account = await client.requestAccount();
29
- expect(account.address).toMatchInlineSnapshot(`"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`);
42
+ expect(account.address).not.toEqual(account2.address);
43
+ });
44
+ it("can correctly sign a message", async () => {
45
+ const account = await client.requestAccount();
46
+ const message = "hello world";
47
+ const signature = await client.signMessage({ message });
48
+ const isValid = await publicClient.verifyMessage({
49
+ address: account.address,
50
+ message: "hello world",
51
+ signature,
52
+ });
53
+ expect(isValid).toBeTrue();
54
+ });
55
+ it("can correctly sign typed data", async () => {
56
+ const account = await client.requestAccount();
57
+ const signature = await client.signTypedData(givenTypedData);
58
+ const isValid = await publicClient.verifyTypedData({
59
+ ...givenTypedData,
60
+ signature,
61
+ address: account.address,
30
62
  });
31
- it("should successfully request account with different salt", async () => {
32
- const account = await client.requestAccount({
33
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
34
- creationHint: { salt: "0x1" },
35
- });
36
- expect(account.address).toMatchInlineSnapshot(`"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`);
63
+ expect(isValid).toBeTrue();
64
+ });
65
+ it("can correctly sign a message with a different account", async () => {
66
+ const account = await client.requestAccount({
67
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
68
+ creationHint: { salt: "0x1" },
37
69
  });
38
- it("should not cache account if different inputs provided", async () => {
39
- const account = await client.requestAccount();
40
- const account2 = await client.requestAccount({
41
- id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
42
- creationHint: { salt: "0x2" },
43
- });
44
- expect(account.address).not.toEqual(account2.address);
70
+ const message = "hello world";
71
+ const signature = await client.signMessage({
72
+ message,
73
+ account: account.address,
45
74
  });
46
- it("can correctly sign a message", async () => {
47
- const account = await client.requestAccount();
48
- const message = "hello world";
49
- const signature = await client.signMessage({ message });
50
- const isValid = await publicClient.verifyMessage({
51
- address: account.address,
52
- message,
53
- signature,
54
- });
55
- expect(isValid).toBeTrue();
75
+ const isValid = await publicClient.verifyMessage({
76
+ address: account.address,
77
+ message: "hello world",
78
+ signature,
56
79
  });
57
- it("can correctly sign typed data", async () => {
58
- const account = await client.requestAccount();
59
- const signature = await client.signTypedData(givenTypedData);
60
- const isValid = await publicClient.verifyTypedData({
61
- ...givenTypedData,
62
- signature,
63
- address: account.address,
64
- });
65
- expect(isValid).toBeTrue();
80
+ expect(isValid).toBeTrue();
81
+ });
82
+ it("can correctly sign typed data with a different account", async () => {
83
+ const account = await client.requestAccount({
84
+ id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
85
+ creationHint: { salt: "0x1" },
66
86
  });
67
- it("can correctly sign a message with a different account", async () => {
68
- const account = await client.requestAccount({
69
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
70
- creationHint: { salt: "0x1" },
71
- });
72
- const message = "hello world";
73
- const signature = await client.signMessage({
74
- message,
75
- account: account.address,
76
- });
77
- const isValid = await publicClient.verifyMessage({
78
- address: account.address,
79
- message,
80
- signature,
81
- });
82
- expect(isValid).toBeTrue();
87
+ const signature = await client.signTypedData({
88
+ ...givenTypedData,
89
+ account: account.address,
83
90
  });
84
- it("can correctly sign typed data with a different account", async () => {
85
- const account = await client.requestAccount({
86
- id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
87
- creationHint: { salt: "0x1" },
88
- });
89
- const signature = await client.signTypedData({
90
- ...givenTypedData,
91
- account: account.address,
92
- });
93
- const isValid = await publicClient.verifyTypedData({
94
- ...givenTypedData,
95
- signature,
96
- address: account.address,
97
- });
98
- expect(isValid).toBeTrue();
91
+ const isValid = await publicClient.verifyTypedData({
92
+ ...givenTypedData,
93
+ signature,
94
+ address: account.address,
99
95
  });
100
- it("should successfully send a UO with paymaster using 7702", async () => {
101
- const _signer = LocalAccountSigner.privateKeyToAccountSigner("0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f");
102
- const _client = createSmartWalletClient({
103
- transport,
104
- chain: arbitrumSepolia,
105
- mode: "local",
106
- signer: _signer,
107
- });
108
- const account = await _client.requestAccount({
109
- creationHint: {
110
- accountType: "7702",
111
- },
112
- });
113
- const preparedCalls = await _client.prepareCalls({
114
- calls: [{ to: zeroAddress, value: "0x0" }],
115
- from: account.address,
116
- capabilities: {
117
- paymasterService: {
118
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
119
- },
96
+ expect(isValid).toBeTrue();
97
+ });
98
+ it("should successfully send a UO with paymaster", async () => {
99
+ const account = await client.requestAccount();
100
+ const preparedCalls = await client.prepareCalls({
101
+ calls: [{ to: zeroAddress, value: "0x0" }],
102
+ from: account.address,
103
+ capabilities: {
104
+ paymasterService: {
105
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
120
106
  },
121
- });
122
- const signedCalls = await _client.signPreparedCalls(preparedCalls);
123
- const result = await _client.sendPreparedCalls(signedCalls);
124
- expect(result.preparedCallIds).toBeArrayOfSize(1);
125
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
126
- }, {
127
- timeout: 45_000,
107
+ },
128
108
  });
129
- it("should successfully send a UO with paymaster", async () => {
130
- const account = await client.requestAccount();
131
- const preparedCalls = await client.prepareCalls({
132
- calls: [{ to: zeroAddress, value: "0x0" }],
133
- from: account.address,
134
- capabilities: {
135
- paymasterService: {
136
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
137
- },
109
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
110
+ const result = await client.sendPreparedCalls(signedCalls);
111
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
112
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
113
+ }, {
114
+ timeout: 45_000,
115
+ });
116
+ it("should successfully drop and replace a UO with repeat calls", async () => {
117
+ const account = await client.requestAccount();
118
+ const preparedCalls = await client.prepareCalls({
119
+ calls: [{ to: zeroAddress, value: "0x0" }],
120
+ from: account.address,
121
+ capabilities: {
122
+ paymasterService: {
123
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
138
124
  },
139
- });
140
- const signedCalls = await client.signPreparedCalls(preparedCalls);
141
- const result = await client.sendPreparedCalls(signedCalls);
142
- expect(result.preparedCallIds).toBeArrayOfSize(1);
143
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
144
- }, {
145
- timeout: 45_000,
125
+ },
146
126
  });
147
- it("should successfully create a session with grantPermissions and send a UO", async () => {
148
- const account = await client.requestAccount();
149
- const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
150
- const permissions = await client.grantPermissions({
151
- account: account.address,
152
- expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
153
- key: {
154
- publicKey: await sessionKey.getAddress(),
155
- type: "secp256k1",
156
- },
157
- permissions: [{ type: "root" }],
158
- });
159
- const sessionKeyClient = createSmartWalletClient({
160
- transport,
161
- chain: arbitrumSepolia,
162
- mode: "local",
163
- signer: sessionKey,
164
- });
165
- const preparedCalls = await sessionKeyClient.prepareCalls({
166
- calls: [{ to: zeroAddress, value: "0x0" }],
167
- from: account.address,
168
- capabilities: {
169
- paymasterService: {
170
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
171
- },
172
- permissions,
173
- },
174
- });
175
- const signedCalls = await sessionKeyClient.signPreparedCalls(preparedCalls);
176
- const result = await sessionKeyClient.sendPreparedCalls({
177
- ...signedCalls,
178
- capabilities: {
179
- permissions,
127
+ const signedCalls = await client.signPreparedCalls(preparedCalls);
128
+ const result = await client.sendPreparedCalls(signedCalls);
129
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
130
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
131
+ const prepareCalls2 = await client.prepareCalls({
132
+ calls: [{ to: zeroAddress, value: "0x0" }],
133
+ from: account.address,
134
+ capabilities: {
135
+ paymasterService: {
136
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
180
137
  },
181
- });
182
- expect(result.preparedCallIds).toBeArrayOfSize(1);
183
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
184
- }, {
185
- timeout: 45_000,
138
+ },
186
139
  });
140
+ const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
141
+ const result2 = await client.sendPreparedCalls(signedCalls2);
142
+ expect(result2.preparedCallIds).toBeArrayOfSize(1);
143
+ await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
144
+ }, {
145
+ timeout: 90_000,
187
146
  });
188
- describe("Remote Mode Tests", () => {
189
- const signer = LocalAccountSigner.privateKeyToAccountSigner("0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d");
190
- const client = createSmartWalletClient({
147
+ it("should successfully send a UO with paymaster using 7702", async () => {
148
+ const _signer = LocalAccountSigner.privateKeyToAccountSigner("0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8");
149
+ const _client = createSmartWalletClient({
191
150
  transport,
192
151
  chain: arbitrumSepolia,
193
- mode: "remote",
194
- signer,
152
+ signer: _signer,
195
153
  });
196
- const publicClient = createPublicClient({
197
- chain: arbitrumSepolia,
198
- transport,
199
- });
200
- it("should successfully get a counterfactual address", async () => {
201
- const account = await client.requestAccount();
202
- expect(account.address).toMatchInlineSnapshot(`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`);
203
- });
204
- it("should successfully request account with different salt", async () => {
205
- const account = await client.requestAccount({
206
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
207
- creationHint: { salt: "0x1" },
208
- });
209
- expect(account.address).toMatchInlineSnapshot(`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`);
210
- });
211
- it("should not cache account if different inputs provided", async () => {
212
- const account = await client.requestAccount();
213
- const account2 = await client.requestAccount({
214
- id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
215
- creationHint: { salt: "0x2" },
216
- });
217
- expect(account.address).not.toEqual(account2.address);
218
- });
219
- it("can correctly sign a message", async () => {
220
- const account = await client.requestAccount();
221
- const message = "hello world";
222
- const signature = await client.signMessage({ message });
223
- const isValid = await publicClient.verifyMessage({
224
- address: account.address,
225
- message: "hello world",
226
- signature,
227
- });
228
- expect(isValid).toBeTrue();
229
- });
230
- it("can correctly sign typed data", async () => {
231
- const account = await client.requestAccount();
232
- const signature = await client.signTypedData(givenTypedData);
233
- const isValid = await publicClient.verifyTypedData({
234
- ...givenTypedData,
235
- signature,
236
- address: account.address,
237
- });
238
- expect(isValid).toBeTrue();
154
+ const account = await _client.requestAccount({
155
+ creationHint: {
156
+ accountType: "7702",
157
+ },
239
158
  });
240
- it("can correctly sign a message with a different account", async () => {
241
- const account = await client.requestAccount({
242
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
243
- creationHint: { salt: "0x1" },
244
- });
245
- const message = "hello world";
246
- const signature = await client.signMessage({
247
- message,
248
- account: account.address,
249
- });
250
- const isValid = await publicClient.verifyMessage({
251
- address: account.address,
252
- message: "hello world",
253
- signature,
254
- });
255
- expect(isValid).toBeTrue();
159
+ expect(account.address).toBe(await _signer.getAddress());
160
+ const preparedCalls = await _client.prepareCalls({
161
+ calls: [{ to: zeroAddress, value: "0x0" }],
162
+ from: account.address,
163
+ capabilities: {
164
+ paymasterService: {
165
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
166
+ },
167
+ },
256
168
  });
257
- it("can correctly sign typed data with a different account", async () => {
258
- const account = await client.requestAccount({
259
- id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
260
- creationHint: { salt: "0x1" },
261
- });
262
- const signature = await client.signTypedData({
263
- ...givenTypedData,
264
- account: account.address,
265
- });
266
- const isValid = await publicClient.verifyTypedData({
267
- ...givenTypedData,
268
- signature,
269
- address: account.address,
270
- });
271
- expect(isValid).toBeTrue();
169
+ const signedCalls = await _client.signPreparedCalls(preparedCalls);
170
+ const result = await _client.sendPreparedCalls(signedCalls);
171
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
172
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
173
+ }, { timeout: 45_000 });
174
+ it("should successfully create a session with grantPermissions and send a UO", async () => {
175
+ const account = await client.requestAccount();
176
+ const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
177
+ const permissions = await client.grantPermissions({
178
+ account: account.address,
179
+ expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
180
+ key: {
181
+ publicKey: await sessionKey.getAddress(),
182
+ type: "secp256k1",
183
+ },
184
+ permissions: [{ type: "root" }],
272
185
  });
273
- it("should successfully send a UO with paymaster", async () => {
274
- const account = await client.requestAccount();
275
- const preparedCalls = await client.prepareCalls({
276
- calls: [{ to: zeroAddress, value: "0x0" }],
277
- from: account.address,
278
- capabilities: {
279
- paymasterService: {
280
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
281
- },
282
- },
283
- });
284
- const signedCalls = await client.signPreparedCalls(preparedCalls);
285
- const result = await client.sendPreparedCalls(signedCalls);
286
- expect(result.preparedCallIds).toBeArrayOfSize(1);
287
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
288
- }, {
289
- timeout: 45_000,
186
+ const sessionKeyClient = createSmartWalletClient({
187
+ transport,
188
+ chain: arbitrumSepolia,
189
+ signer: sessionKey,
290
190
  });
291
- it("should successfully drop and replace a UO with repeat calls", async () => {
292
- const account = await client.requestAccount();
293
- const preparedCalls = await client.prepareCalls({
294
- calls: [{ to: zeroAddress, value: "0x0" }],
295
- from: account.address,
296
- capabilities: {
297
- paymasterService: {
298
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
299
- },
300
- },
301
- });
302
- const signedCalls = await client.signPreparedCalls(preparedCalls);
303
- const result = await client.sendPreparedCalls(signedCalls);
304
- expect(result.preparedCallIds).toBeArrayOfSize(1);
305
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
306
- const prepareCalls2 = await client.prepareCalls({
307
- calls: [{ to: zeroAddress, value: "0x0" }],
308
- from: account.address,
309
- capabilities: {
310
- paymasterService: {
311
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
312
- },
191
+ const preparedCalls = await sessionKeyClient.prepareCalls({
192
+ calls: [{ to: zeroAddress, value: "0x0" }],
193
+ from: account.address,
194
+ capabilities: {
195
+ paymasterService: {
196
+ policyId: process.env.TEST_PAYMASTER_POLICY_ID,
313
197
  },
314
- });
315
- const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
316
- const result2 = await client.sendPreparedCalls(signedCalls2);
317
- expect(result2.preparedCallIds).toBeArrayOfSize(1);
318
- await waitForUserOpSuccess(client, result2.preparedCallIds[0]);
319
- }, {
320
- timeout: 90_000,
198
+ permissions,
199
+ },
321
200
  });
322
- it("should successfully send a UO with paymaster using 7702", async () => {
323
- const _signer = LocalAccountSigner.privateKeyToAccountSigner("0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8");
324
- const _client = createSmartWalletClient({
325
- transport,
326
- chain: arbitrumSepolia,
327
- mode: "remote",
328
- signer: _signer,
329
- });
330
- const account = await _client.requestAccount({
331
- creationHint: {
332
- accountType: "7702",
333
- },
334
- });
335
- expect(account.address).toBe(await _signer.getAddress());
336
- const preparedCalls = await _client.prepareCalls({
337
- calls: [{ to: zeroAddress, value: "0x0" }],
338
- from: account.address,
339
- capabilities: {
340
- paymasterService: {
341
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
342
- },
343
- },
344
- });
345
- const signedCalls = await _client.signPreparedCalls(preparedCalls);
346
- const result = await _client.sendPreparedCalls(signedCalls);
347
- expect(result.preparedCallIds).toBeArrayOfSize(1);
348
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
349
- }, { timeout: 45_000 });
350
- it("should successfully create a session with grantPermissions and send a UO", async () => {
351
- const account = await client.requestAccount();
352
- const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
353
- const permissions = await client.grantPermissions({
354
- account: account.address,
355
- expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
356
- key: {
357
- publicKey: await sessionKey.getAddress(),
358
- type: "secp256k1",
359
- },
360
- permissions: [{ type: "root" }],
361
- });
362
- const sessionKeyClient = createSmartWalletClient({
363
- transport,
364
- chain: arbitrumSepolia,
365
- mode: "remote",
366
- signer: sessionKey,
367
- });
368
- const preparedCalls = await sessionKeyClient.prepareCalls({
369
- calls: [{ to: zeroAddress, value: "0x0" }],
370
- from: account.address,
371
- capabilities: {
372
- paymasterService: {
373
- policyId: process.env.TEST_PAYMASTER_POLICY_ID,
374
- },
375
- permissions,
376
- },
377
- });
378
- const signedCalls = await sessionKeyClient.signPreparedCalls(preparedCalls);
379
- const result = await sessionKeyClient.sendPreparedCalls({
380
- ...signedCalls,
381
- capabilities: {
382
- permissions,
383
- },
384
- });
385
- expect(result.preparedCallIds).toBeArrayOfSize(1);
386
- await waitForUserOpSuccess(client, result.preparedCallIds[0]);
387
- }, {
388
- timeout: 45_000,
201
+ const signedCalls = await sessionKeyClient.signPreparedCalls(preparedCalls);
202
+ const result = await sessionKeyClient.sendPreparedCalls({
203
+ ...signedCalls,
204
+ capabilities: {
205
+ permissions,
206
+ },
389
207
  });
208
+ expect(result.preparedCallIds).toBeArrayOfSize(1);
209
+ await waitForUserOpSuccess(client, result.preparedCallIds[0]);
210
+ }, {
211
+ timeout: 45_000,
390
212
  });
391
213
  const givenTypedData = {
392
214
  types: {