kokio-sdk 0.0.1
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/.env.example +1 -0
- package/.github/workflows/npm_publish.yaml +19 -0
- package/LICENSE +21 -0
- package/package.json +45 -0
- package/src/abis/BeaconProxy.json +985 -0
- package/src/abis/DeviceWallet.json +907 -0
- package/src/abis/DeviceWalletFactory.json +739 -0
- package/src/abis/ESIMWallet.json +486 -0
- package/src/abis/ESIMWalletFactory.json +467 -0
- package/src/abis/LazyWalletRegistry.json +734 -0
- package/src/abis/P256Verifier.json +73 -0
- package/src/abis/Registry.json +811 -0
- package/src/abis/RegistryHelper.json +382 -0
- package/src/abis/index.ts +21 -0
- package/src/config.ts +46 -0
- package/src/interface/P256VerifierClass.ts +19 -0
- package/src/interface/constantsClass.ts +35 -0
- package/src/interface/deviceWalletClass.ts +62 -0
- package/src/interface/deviceWalletFactoryClass.ts +35 -0
- package/src/interface/eSIMWalletClass.ts +55 -0
- package/src/interface/eSIMWalletFactoryClass.ts +36 -0
- package/src/interface/lazyWalletRegistryClass.ts +34 -0
- package/src/interface/smartAccountClass.ts +26 -0
- package/src/interface/utilsClass.ts +21 -0
- package/src/logic/P256Verifier.ts +31 -0
- package/src/logic/account-kit/createSmartAccount.ts +282 -0
- package/src/logic/constants.ts +188 -0
- package/src/logic/deviceWallet.ts +175 -0
- package/src/logic/deviceWalletFactory.ts +70 -0
- package/src/logic/eSIMWallet.ts +149 -0
- package/src/logic/eSIMWalletFactory.ts +78 -0
- package/src/logic/lazyWalletRegistry.ts +98 -0
- package/src/logic/services/turnkeyClient.ts +80 -0
- package/src/logic/utils.ts +86 -0
- package/src/types.ts +38 -0
- package/tsconfig.json +114 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "function",
|
|
4
|
+
"name": "deployLazyWallet",
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"name": "_deviceWalletOwnerKey",
|
|
8
|
+
"type": "bytes32[2]",
|
|
9
|
+
"internalType": "bytes32[2]"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "_deviceUniqueIdentifier",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"internalType": "string"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "_salt",
|
|
18
|
+
"type": "uint256",
|
|
19
|
+
"internalType": "uint256"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "_eSIMUniqueIdentifiers",
|
|
23
|
+
"type": "string[]",
|
|
24
|
+
"internalType": "string[]"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "_dataBundleDetails",
|
|
28
|
+
"type": "tuple[][]",
|
|
29
|
+
"internalType": "struct DataBundleDetails[][]",
|
|
30
|
+
"components": [
|
|
31
|
+
{
|
|
32
|
+
"name": "dataBundleID",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"internalType": "string"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "dataBundlePrice",
|
|
38
|
+
"type": "uint256",
|
|
39
|
+
"internalType": "uint256"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "_depositAmount",
|
|
45
|
+
"type": "uint256",
|
|
46
|
+
"internalType": "uint256"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"outputs": [
|
|
50
|
+
{
|
|
51
|
+
"name": "",
|
|
52
|
+
"type": "address",
|
|
53
|
+
"internalType": "address"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "",
|
|
57
|
+
"type": "address[]",
|
|
58
|
+
"internalType": "address[]"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"stateMutability": "payable"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "function",
|
|
65
|
+
"name": "deviceWalletFactory",
|
|
66
|
+
"inputs": [],
|
|
67
|
+
"outputs": [
|
|
68
|
+
{
|
|
69
|
+
"name": "",
|
|
70
|
+
"type": "address",
|
|
71
|
+
"internalType": "contract DeviceWalletFactory"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"stateMutability": "view"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"type": "function",
|
|
78
|
+
"name": "deviceWalletToOwner",
|
|
79
|
+
"inputs": [
|
|
80
|
+
{
|
|
81
|
+
"name": "deviceWalletAddress",
|
|
82
|
+
"type": "address",
|
|
83
|
+
"internalType": "address"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "",
|
|
87
|
+
"type": "uint256",
|
|
88
|
+
"internalType": "uint256"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"outputs": [
|
|
92
|
+
{
|
|
93
|
+
"name": "ownerP256Keys",
|
|
94
|
+
"type": "bytes32",
|
|
95
|
+
"internalType": "bytes32"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"stateMutability": "view"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"type": "function",
|
|
102
|
+
"name": "eSIMWalletFactory",
|
|
103
|
+
"inputs": [],
|
|
104
|
+
"outputs": [
|
|
105
|
+
{
|
|
106
|
+
"name": "",
|
|
107
|
+
"type": "address",
|
|
108
|
+
"internalType": "contract ESIMWalletFactory"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"stateMutability": "view"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "function",
|
|
115
|
+
"name": "isDeviceWalletValid",
|
|
116
|
+
"inputs": [
|
|
117
|
+
{
|
|
118
|
+
"name": "deviceWalletAddress",
|
|
119
|
+
"type": "address",
|
|
120
|
+
"internalType": "address"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"outputs": [
|
|
124
|
+
{
|
|
125
|
+
"name": "valid",
|
|
126
|
+
"type": "bool",
|
|
127
|
+
"internalType": "bool"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"stateMutability": "view"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "function",
|
|
134
|
+
"name": "isESIMWalletOnStandby",
|
|
135
|
+
"inputs": [
|
|
136
|
+
{
|
|
137
|
+
"name": "eSIMWalletAddress",
|
|
138
|
+
"type": "address",
|
|
139
|
+
"internalType": "address"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"outputs": [
|
|
143
|
+
{
|
|
144
|
+
"name": "isOnStandby",
|
|
145
|
+
"type": "bool",
|
|
146
|
+
"internalType": "bool"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"stateMutability": "view"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "function",
|
|
153
|
+
"name": "isESIMWalletValid",
|
|
154
|
+
"inputs": [
|
|
155
|
+
{
|
|
156
|
+
"name": "eSIMWalletAddress",
|
|
157
|
+
"type": "address",
|
|
158
|
+
"internalType": "address"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"outputs": [
|
|
162
|
+
{
|
|
163
|
+
"name": "deviceWalletAddress",
|
|
164
|
+
"type": "address",
|
|
165
|
+
"internalType": "address"
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
"stateMutability": "view"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "function",
|
|
172
|
+
"name": "lazyWalletRegistry",
|
|
173
|
+
"inputs": [],
|
|
174
|
+
"outputs": [
|
|
175
|
+
{
|
|
176
|
+
"name": "",
|
|
177
|
+
"type": "address",
|
|
178
|
+
"internalType": "address"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"stateMutability": "view"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"type": "function",
|
|
185
|
+
"name": "registeredP256Keys",
|
|
186
|
+
"inputs": [
|
|
187
|
+
{
|
|
188
|
+
"name": "hashOfOwnerP256Keys",
|
|
189
|
+
"type": "bytes32",
|
|
190
|
+
"internalType": "bytes32"
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
"outputs": [
|
|
194
|
+
{
|
|
195
|
+
"name": "deviceWalletAddress",
|
|
196
|
+
"type": "address",
|
|
197
|
+
"internalType": "address"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
"stateMutability": "view"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "function",
|
|
204
|
+
"name": "uniqueIdentifierToDeviceWallet",
|
|
205
|
+
"inputs": [
|
|
206
|
+
{
|
|
207
|
+
"name": "deviceIdentifier",
|
|
208
|
+
"type": "string",
|
|
209
|
+
"internalType": "string"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"outputs": [
|
|
213
|
+
{
|
|
214
|
+
"name": "deviceWalletAddress",
|
|
215
|
+
"type": "address",
|
|
216
|
+
"internalType": "address"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
"stateMutability": "view"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"type": "event",
|
|
223
|
+
"name": "DeviceWalletInfoUpdated",
|
|
224
|
+
"inputs": [
|
|
225
|
+
{
|
|
226
|
+
"name": "_deviceWallet",
|
|
227
|
+
"type": "address",
|
|
228
|
+
"indexed": true,
|
|
229
|
+
"internalType": "address"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "_deviceUniqueIdentifier",
|
|
233
|
+
"type": "string",
|
|
234
|
+
"indexed": false,
|
|
235
|
+
"internalType": "string"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"name": "_deviceWalletOwnerKey",
|
|
239
|
+
"type": "bytes32[2]",
|
|
240
|
+
"indexed": false,
|
|
241
|
+
"internalType": "bytes32[2]"
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
"anonymous": false
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"type": "event",
|
|
248
|
+
"name": "ESIMWalletSetOnStandby",
|
|
249
|
+
"inputs": [
|
|
250
|
+
{
|
|
251
|
+
"name": "_eSIMWalletAddress",
|
|
252
|
+
"type": "address",
|
|
253
|
+
"indexed": true,
|
|
254
|
+
"internalType": "address"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"name": "_isOnStandby",
|
|
258
|
+
"type": "bool",
|
|
259
|
+
"indexed": false,
|
|
260
|
+
"internalType": "bool"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"name": "_deviceWalletAddress",
|
|
264
|
+
"type": "address",
|
|
265
|
+
"indexed": true,
|
|
266
|
+
"internalType": "address"
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"anonymous": false
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"type": "event",
|
|
273
|
+
"name": "LazyWalletDeployed",
|
|
274
|
+
"inputs": [
|
|
275
|
+
{
|
|
276
|
+
"name": "_deviceWallet",
|
|
277
|
+
"type": "address",
|
|
278
|
+
"indexed": true,
|
|
279
|
+
"internalType": "address"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"name": "_deviceUniqueIdentifier",
|
|
283
|
+
"type": "string",
|
|
284
|
+
"indexed": false,
|
|
285
|
+
"internalType": "string"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "_eSIMWallet",
|
|
289
|
+
"type": "address",
|
|
290
|
+
"indexed": true,
|
|
291
|
+
"internalType": "address"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"name": "_eSIMUniqueIdentifier",
|
|
295
|
+
"type": "string",
|
|
296
|
+
"indexed": false,
|
|
297
|
+
"internalType": "string"
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
"anonymous": false
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"type": "event",
|
|
304
|
+
"name": "RegistryInitialized",
|
|
305
|
+
"inputs": [
|
|
306
|
+
{
|
|
307
|
+
"name": "_eSIMWalletAdmin",
|
|
308
|
+
"type": "address",
|
|
309
|
+
"indexed": false,
|
|
310
|
+
"internalType": "address"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"name": "_vault",
|
|
314
|
+
"type": "address",
|
|
315
|
+
"indexed": false,
|
|
316
|
+
"internalType": "address"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"name": "_upgradeManager",
|
|
320
|
+
"type": "address",
|
|
321
|
+
"indexed": true,
|
|
322
|
+
"internalType": "address"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"name": "_deviceWalletFactory",
|
|
326
|
+
"type": "address",
|
|
327
|
+
"indexed": true,
|
|
328
|
+
"internalType": "address"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "_eSIMWalletFactory",
|
|
332
|
+
"type": "address",
|
|
333
|
+
"indexed": true,
|
|
334
|
+
"internalType": "address"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "_verifier",
|
|
338
|
+
"type": "address",
|
|
339
|
+
"indexed": false,
|
|
340
|
+
"internalType": "address"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"anonymous": false
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"type": "event",
|
|
347
|
+
"name": "UpdatedDeviceWalletassociatedWithESIMWallet",
|
|
348
|
+
"inputs": [
|
|
349
|
+
{
|
|
350
|
+
"name": "_eSIMWalletAddress",
|
|
351
|
+
"type": "address",
|
|
352
|
+
"indexed": true,
|
|
353
|
+
"internalType": "address"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "_deviceWalletAddress",
|
|
357
|
+
"type": "address",
|
|
358
|
+
"indexed": true,
|
|
359
|
+
"internalType": "address"
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"anonymous": false
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"type": "event",
|
|
366
|
+
"name": "UpdatedLazyWalletRegistryAddress",
|
|
367
|
+
"inputs": [
|
|
368
|
+
{
|
|
369
|
+
"name": "_lazyWalletRegistry",
|
|
370
|
+
"type": "address",
|
|
371
|
+
"indexed": true,
|
|
372
|
+
"internalType": "address"
|
|
373
|
+
}
|
|
374
|
+
],
|
|
375
|
+
"anonymous": false
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"type": "error",
|
|
379
|
+
"name": "OnlyLazyWalletRegistry",
|
|
380
|
+
"inputs": []
|
|
381
|
+
}
|
|
382
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import DeviceWallet from './DeviceWallet.json' assert { type: 'json' };
|
|
2
|
+
import DeviceWalletFactory from './DeviceWalletFactory.json' assert { type: 'json' };
|
|
3
|
+
import ESIMWallet from './ESIMWallet.json' assert { type: 'json' };
|
|
4
|
+
import ESIMWalletFactory from './ESIMWalletFactory.json' assert { type: 'json' };
|
|
5
|
+
import LazyWalletRegistry from './LazyWalletRegistry.json' assert { type: 'json' };
|
|
6
|
+
import P256Verifier from './P256Verifier.json' assert { type: 'json' };
|
|
7
|
+
import Registry from './Registry.json' assert { type: 'json' };
|
|
8
|
+
import RegistryHelper from './RegistryHelper.json' assert { type: 'json' };
|
|
9
|
+
import BeaconProxy from './BeaconProxy.json' assert { type: 'json' }
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
DeviceWallet,
|
|
13
|
+
DeviceWalletFactory,
|
|
14
|
+
ESIMWallet,
|
|
15
|
+
ESIMWalletFactory,
|
|
16
|
+
LazyWalletRegistry,
|
|
17
|
+
P256Verifier,
|
|
18
|
+
Registry,
|
|
19
|
+
RegistryHelper,
|
|
20
|
+
BeaconProxy
|
|
21
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Address, WalletClient } from "viem";
|
|
2
|
+
import { ConstantsSubPackage } from "./interface/constantsClass.js";
|
|
3
|
+
import { smartAccountSubPackage } from "./interface/smartAccountClass.js";
|
|
4
|
+
import { deviceWalletFactorySubPackage } from "./interface/deviceWalletFactoryClass.js";
|
|
5
|
+
import { P256VerifierSubPackage } from "./interface/P256VerifierClass.js";
|
|
6
|
+
import { lazyWalletRegistrySubPackage } from "./interface/lazyWalletRegistryClass.js";
|
|
7
|
+
import { deviceWalletSubPackage } from "./interface/deviceWalletClass.js";
|
|
8
|
+
import { eSIMWalletSubPackage } from "./interface/eSIMWalletClass.js";
|
|
9
|
+
import { eSIMWalletFactorySubPackage } from "./interface/eSIMWalletFactoryClass.js";
|
|
10
|
+
import { SmartAccountClient } from "@aa-sdk/core";
|
|
11
|
+
import { TurnkeyClient } from "@turnkey/http";
|
|
12
|
+
|
|
13
|
+
export class Kokio {
|
|
14
|
+
viemWalletClient: WalletClient;
|
|
15
|
+
turnkeyClient: TurnkeyClient;
|
|
16
|
+
organizationId: string;
|
|
17
|
+
constants: ConstantsSubPackage;
|
|
18
|
+
smartAccount: smartAccountSubPackage;
|
|
19
|
+
deviceWalletFactory?: deviceWalletFactorySubPackage;
|
|
20
|
+
eSIMWalletFactory?: eSIMWalletFactorySubPackage;
|
|
21
|
+
lazyWalletRegistry?: lazyWalletRegistrySubPackage;
|
|
22
|
+
deviceWallet?: deviceWalletSubPackage;
|
|
23
|
+
eSIMWallet?: eSIMWalletSubPackage;
|
|
24
|
+
P256Verifier?: P256VerifierSubPackage;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
viemWalletClient: WalletClient,
|
|
28
|
+
turnkeyClient: TurnkeyClient,
|
|
29
|
+
organizationId: string,
|
|
30
|
+
smartAccountClient?: SmartAccountClient,
|
|
31
|
+
deviceWalletAddress?: Address,
|
|
32
|
+
eSIMWalletAddress?: Address
|
|
33
|
+
) {
|
|
34
|
+
this.viemWalletClient = viemWalletClient;
|
|
35
|
+
this.turnkeyClient = turnkeyClient;
|
|
36
|
+
this.organizationId = organizationId;
|
|
37
|
+
this.constants = new ConstantsSubPackage(this.viemWalletClient);
|
|
38
|
+
this.smartAccount = new smartAccountSubPackage(this.viemWalletClient, this.turnkeyClient, this.organizationId);
|
|
39
|
+
this.deviceWalletFactory = smartAccountClient? new deviceWalletFactorySubPackage(viemWalletClient, smartAccountClient): undefined;
|
|
40
|
+
this.eSIMWalletFactory = smartAccountClient? new eSIMWalletFactorySubPackage(viemWalletClient, smartAccountClient): undefined;
|
|
41
|
+
this.lazyWalletRegistry = smartAccountClient? new lazyWalletRegistrySubPackage(smartAccountClient): undefined;
|
|
42
|
+
this.P256Verifier = smartAccountClient? new P256VerifierSubPackage(smartAccountClient): undefined;
|
|
43
|
+
this.deviceWallet = deviceWalletAddress && smartAccountClient? new deviceWalletSubPackage(viemWalletClient, smartAccountClient, deviceWalletAddress): undefined;
|
|
44
|
+
this.eSIMWallet = eSIMWalletAddress && smartAccountClient? new eSIMWalletSubPackage(smartAccountClient, eSIMWalletAddress): undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Address, WalletClient } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
_verifySignature
|
|
4
|
+
} from "../logic/P256Verifier.js"
|
|
5
|
+
import { WebAuthnSignature } from "../types";
|
|
6
|
+
import { SmartAccountClient } from "@aa-sdk/core";
|
|
7
|
+
|
|
8
|
+
export class P256VerifierSubPackage {
|
|
9
|
+
|
|
10
|
+
client;
|
|
11
|
+
|
|
12
|
+
constructor(client: SmartAccountClient) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
verifySignature (message: string, requireMessageVerification: boolean, webAuthnSignature: WebAuthnSignature, x: bigint, y: bigint) {
|
|
17
|
+
return _verifySignature(this.client, message, requireMessageVerification, webAuthnSignature, x, y);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WalletClient } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
_extractChainID,
|
|
4
|
+
_getChainSpecificConstants,
|
|
5
|
+
mainnetFactoryAddresses,
|
|
6
|
+
sepoliaFactoryAddresses,
|
|
7
|
+
optimismMainnetFactoryAddresses,
|
|
8
|
+
optimismSepoliaFactoryAddresses,
|
|
9
|
+
arbitrumOneFactoryAddresses,
|
|
10
|
+
arbitrumSepoliaFactoryAddresses,
|
|
11
|
+
customErrors
|
|
12
|
+
} from "../logic/constants.js"
|
|
13
|
+
|
|
14
|
+
export class ConstantsSubPackage {
|
|
15
|
+
factoryAddresses!:
|
|
16
|
+
typeof sepoliaFactoryAddresses |
|
|
17
|
+
typeof mainnetFactoryAddresses |
|
|
18
|
+
typeof optimismMainnetFactoryAddresses |
|
|
19
|
+
typeof optimismSepoliaFactoryAddresses |
|
|
20
|
+
typeof arbitrumOneFactoryAddresses |
|
|
21
|
+
typeof arbitrumSepoliaFactoryAddresses;
|
|
22
|
+
customErrors!: typeof customErrors;
|
|
23
|
+
|
|
24
|
+
constructor(client: WalletClient) {
|
|
25
|
+
(async () => {
|
|
26
|
+
const chainID = await _extractChainID(client);
|
|
27
|
+
const values = _getChainSpecificConstants(chainID);
|
|
28
|
+
|
|
29
|
+
this.factoryAddresses = values?.factoryAddresses;
|
|
30
|
+
this.customErrors = values?.customErrors;
|
|
31
|
+
|
|
32
|
+
return this;
|
|
33
|
+
})();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Address, WalletClient } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
_addESIMWallet,
|
|
4
|
+
_deployESIMWallet,
|
|
5
|
+
_getOwner,
|
|
6
|
+
_getVaultAddress,
|
|
7
|
+
_payETHForDataBundles,
|
|
8
|
+
_pullETH,
|
|
9
|
+
_removeESIMWallet,
|
|
10
|
+
_setESIMUniqueIdentifierForAnESIMWallet,
|
|
11
|
+
_toggleAccessToETH
|
|
12
|
+
} from "../logic/deviceWallet.js"
|
|
13
|
+
import { SmartAccountClient } from "@aa-sdk/core";
|
|
14
|
+
|
|
15
|
+
export class deviceWalletSubPackage {
|
|
16
|
+
|
|
17
|
+
smartAccountClient;
|
|
18
|
+
walletClient;
|
|
19
|
+
address;
|
|
20
|
+
|
|
21
|
+
constructor(walletClient: WalletClient, smartAccountClient: SmartAccountClient, address: Address) {
|
|
22
|
+
this.smartAccountClient = smartAccountClient;
|
|
23
|
+
this.walletClient = walletClient;
|
|
24
|
+
this.address = address;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
addESIMWallet (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
|
|
28
|
+
return _addESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
deployESIMWallet (hasAccessToETH: boolean, salt: bigint) {
|
|
32
|
+
return _deployESIMWallet(this.smartAccountClient, this.address, hasAccessToETH, salt);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getVaultAddress () {
|
|
36
|
+
return _getVaultAddress(this.smartAccountClient, this.address);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
payETHForDataBundles (amount: bigint) {
|
|
40
|
+
return _payETHForDataBundles(this.smartAccountClient, this.address, amount);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pullETH (amount: bigint) {
|
|
44
|
+
return _pullETH(this.smartAccountClient, this.address, amount);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
removeESIMWallet (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
|
|
48
|
+
return _removeESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setESIMUniqueIdentifierForAnESIMWallet (eSIMWalletAddress: Address, eSIMUniqueIdentifier: string) {
|
|
52
|
+
return _setESIMUniqueIdentifierForAnESIMWallet(this.smartAccountClient, this.address, eSIMWalletAddress, eSIMUniqueIdentifier);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
toggleAccessToETH (eSIMWalletAddress: Address, hasAccessToETH: boolean) {
|
|
56
|
+
return _toggleAccessToETH(this.smartAccountClient, this.address, eSIMWalletAddress, hasAccessToETH);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getOwner () {
|
|
60
|
+
return _getOwner (this.walletClient, this.address);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Address, WalletClient } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
_createAccountWithEOA,
|
|
4
|
+
_getAddress,
|
|
5
|
+
_getCurrentDeviceWalletImplementation
|
|
6
|
+
} from "../logic/deviceWalletFactory.js"
|
|
7
|
+
import { SmartAccountClient } from "@aa-sdk/core";
|
|
8
|
+
|
|
9
|
+
export class deviceWalletFactorySubPackage {
|
|
10
|
+
|
|
11
|
+
smartAccountClient;
|
|
12
|
+
walletClient;
|
|
13
|
+
|
|
14
|
+
constructor(walletClient: WalletClient, smartAccountClient: SmartAccountClient) {
|
|
15
|
+
this.smartAccountClient = smartAccountClient;
|
|
16
|
+
this.walletClient = walletClient
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
createAccountWithEOA (
|
|
20
|
+
deviceUniqueIdentifier: string,
|
|
21
|
+
deviceWalletOwnerKey: string,
|
|
22
|
+
salt: bigint,
|
|
23
|
+
depositAmount: bigint
|
|
24
|
+
) {
|
|
25
|
+
return _createAccountWithEOA(this.walletClient, deviceUniqueIdentifier, deviceWalletOwnerKey, salt, depositAmount);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getAddress (deviceUniqueIdentifier: string, deviceWalletOwnerKey: string, salt: bigint) {
|
|
29
|
+
return _getAddress(this.smartAccountClient, deviceUniqueIdentifier, deviceWalletOwnerKey, salt);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getCurrentDeviceWalletImplementation () {
|
|
33
|
+
return _getCurrentDeviceWalletImplementation(this.smartAccountClient);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Address, WalletClient } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
_acceptOwnershipTransfer,
|
|
4
|
+
_buyDataBundle,
|
|
5
|
+
_owner,
|
|
6
|
+
_populateHistory,
|
|
7
|
+
_requestTransferOwnership,
|
|
8
|
+
_sendETHToDeviceWallet,
|
|
9
|
+
_setESIMUniqueIdentifier,
|
|
10
|
+
_transferOwnership
|
|
11
|
+
} from "../logic/eSIMWallet.js"
|
|
12
|
+
import { DataBundleDetails } from "../types";
|
|
13
|
+
import { SmartAccountClient } from "@aa-sdk/core";
|
|
14
|
+
|
|
15
|
+
export class eSIMWalletSubPackage {
|
|
16
|
+
|
|
17
|
+
client;
|
|
18
|
+
address;
|
|
19
|
+
|
|
20
|
+
constructor(client: SmartAccountClient, address: Address) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.address = address;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
acceptOwnershipTransfer () {
|
|
26
|
+
return _acceptOwnershipTransfer(this.client, this.address);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
buyDataBundle (dataBundleDetails: DataBundleDetails) {
|
|
30
|
+
return _buyDataBundle(this.client, this.address, dataBundleDetails);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
owner () {
|
|
34
|
+
return _owner(this.client, this.address);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
populateHistory (dataBundleDetails: Array<DataBundleDetails>) {
|
|
38
|
+
return _populateHistory(this.client, this.address, dataBundleDetails);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
requestTransferOwnership (newOwner: Address) {
|
|
42
|
+
return _requestTransferOwnership(this.client, this.address, newOwner);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
sendETHToDeviceWallet (amount: bigint) {
|
|
46
|
+
return _sendETHToDeviceWallet(this.client, this.address, amount);
|
|
47
|
+
}
|
|
48
|
+
_setESIMUniqueIdentifier (eSIMUniqueIdentifier: string) {
|
|
49
|
+
return _setESIMUniqueIdentifier(this.client, this.address, eSIMUniqueIdentifier);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_transferOwnership (amount: bigint) {
|
|
53
|
+
return _transferOwnership(this.client, this.address, amount);
|
|
54
|
+
}
|
|
55
|
+
}
|