@cofhe/sdk 0.0.0-beta-20251027110729

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 (110) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/adapters/ethers5.test.ts +174 -0
  3. package/adapters/ethers5.ts +36 -0
  4. package/adapters/ethers6.test.ts +169 -0
  5. package/adapters/ethers6.ts +36 -0
  6. package/adapters/hardhat-node.ts +167 -0
  7. package/adapters/hardhat.hh2.test.ts +159 -0
  8. package/adapters/hardhat.ts +37 -0
  9. package/adapters/index.test.ts +25 -0
  10. package/adapters/index.ts +5 -0
  11. package/adapters/smartWallet.ts +91 -0
  12. package/adapters/test-utils.ts +53 -0
  13. package/adapters/types.ts +6 -0
  14. package/adapters/wagmi.test.ts +156 -0
  15. package/adapters/wagmi.ts +17 -0
  16. package/chains/chains/arbSepolia.ts +14 -0
  17. package/chains/chains/baseSepolia.ts +14 -0
  18. package/chains/chains/hardhat.ts +15 -0
  19. package/chains/chains/sepolia.ts +14 -0
  20. package/chains/chains.test.ts +49 -0
  21. package/chains/defineChain.ts +18 -0
  22. package/chains/index.ts +33 -0
  23. package/chains/types.ts +32 -0
  24. package/core/baseBuilder.ts +138 -0
  25. package/core/client.test.ts +298 -0
  26. package/core/client.ts +308 -0
  27. package/core/config.test.ts +224 -0
  28. package/core/config.ts +213 -0
  29. package/core/decrypt/MockQueryDecrypterAbi.ts +129 -0
  30. package/core/decrypt/cofheMocksSealOutput.ts +57 -0
  31. package/core/decrypt/decryptHandleBuilder.ts +281 -0
  32. package/core/decrypt/decryptUtils.ts +28 -0
  33. package/core/decrypt/tnSealOutput.ts +59 -0
  34. package/core/encrypt/MockZkVerifierAbi.ts +106 -0
  35. package/core/encrypt/cofheMocksZkVerifySign.ts +278 -0
  36. package/core/encrypt/encryptInputsBuilder.test.ts +735 -0
  37. package/core/encrypt/encryptInputsBuilder.ts +512 -0
  38. package/core/encrypt/encryptUtils.ts +64 -0
  39. package/core/encrypt/zkPackProveVerify.ts +273 -0
  40. package/core/error.ts +170 -0
  41. package/core/fetchKeys.test.ts +212 -0
  42. package/core/fetchKeys.ts +170 -0
  43. package/core/index.ts +77 -0
  44. package/core/keyStore.test.ts +226 -0
  45. package/core/keyStore.ts +127 -0
  46. package/core/permits.test.ts +242 -0
  47. package/core/permits.ts +136 -0
  48. package/core/result.test.ts +180 -0
  49. package/core/result.ts +67 -0
  50. package/core/test-utils.ts +45 -0
  51. package/core/types.ts +352 -0
  52. package/core/utils.ts +88 -0
  53. package/dist/adapters.cjs +88 -0
  54. package/dist/adapters.d.cts +14558 -0
  55. package/dist/adapters.d.ts +14558 -0
  56. package/dist/adapters.js +83 -0
  57. package/dist/chains.cjs +101 -0
  58. package/dist/chains.d.cts +99 -0
  59. package/dist/chains.d.ts +99 -0
  60. package/dist/chains.js +1 -0
  61. package/dist/chunk-GZCQQYVI.js +93 -0
  62. package/dist/chunk-KFGPTJ6X.js +2295 -0
  63. package/dist/chunk-LU7BMUUT.js +804 -0
  64. package/dist/core.cjs +3174 -0
  65. package/dist/core.d.cts +16 -0
  66. package/dist/core.d.ts +16 -0
  67. package/dist/core.js +3 -0
  68. package/dist/node.cjs +3090 -0
  69. package/dist/node.d.cts +22 -0
  70. package/dist/node.d.ts +22 -0
  71. package/dist/node.js +90 -0
  72. package/dist/permit-S9CnI6MF.d.cts +333 -0
  73. package/dist/permit-S9CnI6MF.d.ts +333 -0
  74. package/dist/permits.cjs +856 -0
  75. package/dist/permits.d.cts +1056 -0
  76. package/dist/permits.d.ts +1056 -0
  77. package/dist/permits.js +1 -0
  78. package/dist/types-KImPrEIe.d.cts +48 -0
  79. package/dist/types-KImPrEIe.d.ts +48 -0
  80. package/dist/types-PhwGgQvs.d.ts +953 -0
  81. package/dist/types-bB7wLj0q.d.cts +953 -0
  82. package/dist/web.cjs +3067 -0
  83. package/dist/web.d.cts +22 -0
  84. package/dist/web.d.ts +22 -0
  85. package/dist/web.js +64 -0
  86. package/node/client.test.ts +152 -0
  87. package/node/config.test.ts +68 -0
  88. package/node/encryptInputs.test.ts +175 -0
  89. package/node/index.ts +96 -0
  90. package/node/storage.ts +51 -0
  91. package/package.json +120 -0
  92. package/permits/index.ts +67 -0
  93. package/permits/localstorage.test.ts +118 -0
  94. package/permits/permit.test.ts +474 -0
  95. package/permits/permit.ts +396 -0
  96. package/permits/sealing.test.ts +84 -0
  97. package/permits/sealing.ts +131 -0
  98. package/permits/signature.ts +79 -0
  99. package/permits/store.test.ts +128 -0
  100. package/permits/store.ts +168 -0
  101. package/permits/test-utils.ts +20 -0
  102. package/permits/types.ts +174 -0
  103. package/permits/utils.ts +63 -0
  104. package/permits/validation.test.ts +288 -0
  105. package/permits/validation.ts +349 -0
  106. package/web/client.web.test.ts +152 -0
  107. package/web/config.web.test.ts +71 -0
  108. package/web/encryptInputs.web.test.ts +195 -0
  109. package/web/index.ts +97 -0
  110. package/web/storage.ts +20 -0
@@ -0,0 +1,474 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ PermitUtils,
4
+ type CreateSelfPermitOptions,
5
+ type CreateSharingPermitOptions,
6
+ type ImportSharedPermitOptions,
7
+ } from './index.js';
8
+ import { createPublicClient, createWalletClient, http, type PublicClient, type WalletClient } from 'viem';
9
+ import { arbitrumSepolia } from 'viem/chains';
10
+ import { privateKeyToAccount } from 'viem/accounts';
11
+
12
+ // Test private keys (well-known test keys from Anvil/Hardhat)
13
+ const BOB_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; // Bob - always issuer
14
+ const ALICE_PRIVATE_KEY = '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'; // Alice - always recipient
15
+
16
+ // Create real viem clients for Arbitrum Sepolia
17
+ const publicClient: PublicClient = createPublicClient({
18
+ chain: arbitrumSepolia,
19
+ transport: http(),
20
+ });
21
+
22
+ const bobWalletClient: WalletClient = createWalletClient({
23
+ chain: arbitrumSepolia,
24
+ transport: http(),
25
+ account: privateKeyToAccount(BOB_PRIVATE_KEY),
26
+ });
27
+
28
+ const aliceWalletClient: WalletClient = createWalletClient({
29
+ chain: arbitrumSepolia,
30
+ transport: http(),
31
+ account: privateKeyToAccount(ALICE_PRIVATE_KEY),
32
+ });
33
+
34
+ // Helper to get the wallet addresses
35
+ const bobAddress = bobWalletClient.account!.address;
36
+ const aliceAddress = aliceWalletClient.account!.address;
37
+
38
+ describe('PermitUtils Tests', () => {
39
+ describe('createSelf', () => {
40
+ it('should create a self permit with valid options', async () => {
41
+ const options: CreateSelfPermitOptions = {
42
+ type: 'self',
43
+ issuer: bobAddress,
44
+ name: 'Test Permit',
45
+ };
46
+
47
+ const permit = await PermitUtils.createSelf(options);
48
+
49
+ expect(permit.type).toBe('self');
50
+ expect(permit.name).toBe('Test Permit');
51
+ expect(permit.type).toBe('self');
52
+ expect(permit.issuer).toBe(bobAddress);
53
+ expect(permit.sealingPair).toBeDefined();
54
+ expect(permit.sealingPair.privateKey).toBeDefined();
55
+ expect(permit.sealingPair.publicKey).toBeDefined();
56
+
57
+ // Should not be signed yet
58
+ expect(permit.issuerSignature).toBe('0x');
59
+ expect(permit.recipientSignature).toBe('0x');
60
+ });
61
+
62
+ it('should throw error for invalid options', async () => {
63
+ const options: CreateSelfPermitOptions = {
64
+ type: 'self',
65
+ issuer: 'invalid-address',
66
+ name: 'Test Permit',
67
+ };
68
+
69
+ await expect(PermitUtils.createSelf(options)).rejects.toThrow();
70
+ });
71
+ });
72
+
73
+ describe('createSharing', () => {
74
+ it('should create a sharing permit with valid options', async () => {
75
+ const options: CreateSharingPermitOptions = {
76
+ type: 'sharing',
77
+ issuer: bobAddress,
78
+ recipient: aliceAddress,
79
+ name: 'Test Sharing Permit',
80
+ };
81
+
82
+ const permit = await PermitUtils.createSharing(options);
83
+
84
+ expect(permit.type).toBe('sharing');
85
+ expect(permit.name).toBe('Test Sharing Permit');
86
+ expect(permit.type).toBe('sharing');
87
+ expect(permit.issuer).toBe(bobAddress);
88
+ expect(permit.recipient).toBe(aliceAddress);
89
+ expect(permit.sealingPair).toBeDefined();
90
+ expect(permit.sealingPair.privateKey).toBeDefined();
91
+ expect(permit.sealingPair.publicKey).toBeDefined();
92
+
93
+ // Should not be signed yet
94
+ expect(permit.issuerSignature).toBe('0x');
95
+ expect(permit.recipientSignature).toBe('0x');
96
+ });
97
+
98
+ it('should throw error for invalid recipient', async () => {
99
+ const options: CreateSharingPermitOptions = {
100
+ type: 'sharing',
101
+ issuer: bobAddress,
102
+ recipient: 'invalid-address',
103
+ name: 'Test Sharing Permit',
104
+ };
105
+
106
+ await expect(PermitUtils.createSharing(options)).rejects.toThrow();
107
+ });
108
+ });
109
+
110
+ describe('importShared', () => {
111
+ it('should import a shared permit with valid options', async () => {
112
+ const options: ImportSharedPermitOptions = {
113
+ issuer: bobAddress,
114
+ recipient: aliceAddress,
115
+ issuerSignature: '0x1234567890abcdef',
116
+ name: 'Test Import Permit',
117
+ };
118
+
119
+ const permit = await PermitUtils.importShared(options);
120
+
121
+ expect(permit.type).toBe('recipient');
122
+ expect(permit.name).toBe('Test Import Permit');
123
+ expect(permit.issuer).toBe(bobAddress);
124
+ expect(permit.recipient).toBe(aliceAddress);
125
+ expect(permit.issuerSignature).toBe('0x1234567890abcdef');
126
+ expect(permit.sealingPair).toBeDefined();
127
+ expect(permit.sealingPair.privateKey).toBeDefined();
128
+ expect(permit.sealingPair.publicKey).toBeDefined();
129
+
130
+ // Should not be signed yet
131
+ expect(permit.recipientSignature).toBe('0x');
132
+ });
133
+
134
+ it('should import a shared permit with valid options as string', async () => {
135
+ const options: ImportSharedPermitOptions = {
136
+ issuer: bobAddress,
137
+ recipient: aliceAddress,
138
+ issuerSignature: '0x1234567890abcdef',
139
+ };
140
+
141
+ const stringOptions = JSON.stringify(options);
142
+
143
+ const permit = await PermitUtils.importShared(stringOptions);
144
+
145
+ expect(permit.type).toBe('recipient');
146
+ });
147
+
148
+ it('should throw error for invalid permit type', async () => {
149
+ const options = {
150
+ type: 'self',
151
+ issuer: bobAddress,
152
+ recipient: aliceAddress,
153
+ issuerSignature: '0x1234567890abcdef',
154
+ } as unknown as ImportSharedPermitOptions;
155
+
156
+ await expect(PermitUtils.importShared(options)).rejects.toThrow();
157
+
158
+ const options2 = {
159
+ type: 'recipient',
160
+ issuer: bobAddress,
161
+ recipient: aliceAddress,
162
+ issuerSignature: '0x1234567890abcdef',
163
+ } as unknown as ImportSharedPermitOptions;
164
+
165
+ await expect(PermitUtils.importShared(options2)).rejects.toThrow();
166
+ });
167
+
168
+ it('should throw error for missing issuerSignature', async () => {
169
+ const options: ImportSharedPermitOptions = {
170
+ issuer: bobAddress,
171
+ recipient: aliceAddress,
172
+ issuerSignature: '0x', // Invalid empty signature
173
+ name: 'Test Import Permit',
174
+ };
175
+
176
+ await expect(PermitUtils.importShared(options)).rejects.toThrow();
177
+ });
178
+ });
179
+
180
+ describe('createSelfAndSign', () => {
181
+ it('should create and sign a self permit', async () => {
182
+ const options: CreateSelfPermitOptions = {
183
+ issuer: bobAddress,
184
+ name: 'Test Permit',
185
+ };
186
+
187
+ const permit = await PermitUtils.createSelfAndSign(options, publicClient, bobWalletClient);
188
+
189
+ expect(permit.type).toBe('self');
190
+ expect(permit.issuerSignature).toBeDefined();
191
+ expect(permit.issuerSignature).not.toBe('0x');
192
+ expect(permit.recipientSignature).toBe('0x');
193
+ expect(permit._signedDomain).toBeDefined();
194
+ });
195
+ });
196
+
197
+ describe('createSharingAndSign', () => {
198
+ it('should create and sign a sharing permit', async () => {
199
+ const options: CreateSharingPermitOptions = {
200
+ issuer: bobAddress,
201
+ recipient: aliceAddress,
202
+ name: 'Test Sharing Permit',
203
+ };
204
+
205
+ const permit = await PermitUtils.createSharingAndSign(options, publicClient, bobWalletClient);
206
+
207
+ expect(permit.type).toBe('sharing');
208
+ expect(permit.issuerSignature).toBeDefined();
209
+ expect(permit.issuerSignature).not.toBe('0x');
210
+ expect(permit.recipientSignature).toBe('0x');
211
+ expect(permit._signedDomain).toBeDefined();
212
+ });
213
+ });
214
+
215
+ describe('importSharedAndSign', () => {
216
+ it('should import and sign a shared permit', async () => {
217
+ const options: ImportSharedPermitOptions = {
218
+ issuer: bobAddress,
219
+ recipient: aliceAddress,
220
+ issuerSignature: '0x1234567890abcdef',
221
+ name: 'Test Import Permit',
222
+ };
223
+
224
+ const permit = await PermitUtils.importSharedAndSign(options, publicClient, aliceWalletClient);
225
+
226
+ expect(permit.type).toBe('recipient');
227
+ expect(permit.recipientSignature).toBeDefined();
228
+ expect(permit.recipientSignature).not.toBe('0x');
229
+ expect(permit._signedDomain).toBeDefined();
230
+ });
231
+
232
+ it('should import and sign a shared permit string', async () => {
233
+ const options: ImportSharedPermitOptions = {
234
+ issuer: bobAddress,
235
+ recipient: aliceAddress,
236
+ issuerSignature: '0x1234567890abcdef',
237
+ };
238
+
239
+ const stringOptions = JSON.stringify(options);
240
+
241
+ const permit = await PermitUtils.importSharedAndSign(stringOptions, publicClient, aliceWalletClient);
242
+
243
+ expect(permit.type).toBe('recipient');
244
+ expect(permit.recipientSignature).toBeDefined();
245
+ expect(permit.recipientSignature).not.toBe('0x');
246
+ expect(permit._signedDomain).toBeDefined();
247
+ });
248
+
249
+ it('should import and sign a shared permit json object', async () => {
250
+ const options: ImportSharedPermitOptions = {
251
+ issuer: bobAddress,
252
+ recipient: aliceAddress,
253
+ issuerSignature: '0x1234567890abcdef',
254
+ };
255
+
256
+ const jsonOptions = JSON.parse(JSON.stringify(options));
257
+
258
+ const permit = await PermitUtils.importSharedAndSign(jsonOptions, publicClient, aliceWalletClient);
259
+
260
+ expect(permit.type).toBe('recipient');
261
+ expect(permit.recipientSignature).toBeDefined();
262
+ expect(permit.recipientSignature).not.toBe('0x');
263
+ expect(permit._signedDomain).toBeDefined();
264
+ });
265
+ });
266
+
267
+ describe('sign', () => {
268
+ it('should sign a self permit', async () => {
269
+ const permit = await PermitUtils.createSelf({
270
+ issuer: bobAddress,
271
+ name: 'Test Permit',
272
+ });
273
+
274
+ const signedPermit = await PermitUtils.sign(permit, publicClient, bobWalletClient);
275
+
276
+ expect(signedPermit.type).toBe('self');
277
+ expect(signedPermit.issuerSignature).toBeDefined();
278
+ expect(signedPermit.issuerSignature).not.toBe('0x');
279
+ expect(signedPermit._signedDomain).toBeDefined();
280
+ });
281
+
282
+ it('should sign a recipient permit', async () => {
283
+ const permit = await PermitUtils.importShared({
284
+ issuer: bobAddress,
285
+ recipient: aliceAddress,
286
+ issuerSignature: '0xexisting-signature',
287
+ name: 'Test Permit',
288
+ });
289
+
290
+ const signedPermit = await PermitUtils.sign(permit, publicClient, aliceWalletClient);
291
+
292
+ expect(signedPermit.recipientSignature).toBeDefined();
293
+ expect(signedPermit.recipientSignature).not.toBe('0x');
294
+ expect(signedPermit._signedDomain).toBeDefined();
295
+ });
296
+
297
+ it('should throw error for undefined signer', async () => {
298
+ const permit = await PermitUtils.createSelf({
299
+ issuer: bobAddress,
300
+ name: 'Test Permit',
301
+ });
302
+
303
+ await expect(
304
+ // @ts-expect-error - undefined signer
305
+ PermitUtils.sign(permit, publicClient, undefined)
306
+ ).rejects.toThrow();
307
+ });
308
+ });
309
+
310
+ describe('serialize/deserialize', () => {
311
+ it('should serialize and deserialize a permit', async () => {
312
+ const originalPermit = await PermitUtils.createSelf({
313
+ issuer: bobAddress,
314
+ name: 'Test Permit',
315
+ });
316
+
317
+ const serialized = PermitUtils.serialize(originalPermit);
318
+ const deserialized = PermitUtils.deserialize(serialized);
319
+
320
+ expect(deserialized.type).toBe('self');
321
+ expect(deserialized.name).toBe(originalPermit.name);
322
+ expect(deserialized.type).toBe(originalPermit.type);
323
+ expect(deserialized.issuer).toBe(originalPermit.issuer);
324
+ expect(deserialized.sealingPair.privateKey).toBe(originalPermit.sealingPair.privateKey);
325
+ expect(deserialized.sealingPair.publicKey).toBe(originalPermit.sealingPair.publicKey);
326
+ });
327
+ });
328
+
329
+ describe('getPermission', () => {
330
+ it('should extract permission from permit', async () => {
331
+ const permit = await PermitUtils.createSelfAndSign(
332
+ {
333
+ issuer: bobAddress,
334
+ name: 'Test Permit',
335
+ },
336
+ publicClient,
337
+ bobWalletClient
338
+ );
339
+
340
+ const permission = PermitUtils.getPermission(permit);
341
+
342
+ expect(permission.issuer).toBe(permit.issuer);
343
+ expect(permission.sealingKey).toBe(`0x${permit.sealingPair.publicKey}`);
344
+ expect(permission).not.toHaveProperty('name');
345
+ expect(permission).not.toHaveProperty('type');
346
+ });
347
+ });
348
+
349
+ describe('getHash', () => {
350
+ it('should generate consistent hash for same permit data', async () => {
351
+ const permit1 = await PermitUtils.createSelf({
352
+ issuer: bobAddress,
353
+ name: 'Test Permit',
354
+ });
355
+
356
+ const permit2 = await PermitUtils.createSelf({
357
+ issuer: bobAddress,
358
+ name: 'Test Permit',
359
+ });
360
+
361
+ const hash1 = PermitUtils.getHash(permit1);
362
+ const hash2 = PermitUtils.getHash(permit2);
363
+
364
+ expect(hash1).toBe(hash2);
365
+ });
366
+ });
367
+
368
+ describe('export', () => {
369
+ it('should export permit data without sensitive fields', async () => {
370
+ const permit = await PermitUtils.createSelf({
371
+ issuer: bobAddress,
372
+ name: 'Test Permit',
373
+ });
374
+
375
+ const exported = PermitUtils.export(permit);
376
+ const parsed = JSON.parse(exported);
377
+
378
+ expect(parsed.name).toBe('Test Permit');
379
+ expect(parsed.issuer).toBe(bobAddress);
380
+ expect(parsed).not.toHaveProperty('sealingPair');
381
+ expect(parsed).not.toHaveProperty('issuerSignature');
382
+ });
383
+ });
384
+
385
+ describe('updateName', () => {
386
+ it('should update permit name immutably', async () => {
387
+ const permit = await PermitUtils.createSelf({
388
+ issuer: bobAddress,
389
+ name: 'Original Name',
390
+ });
391
+
392
+ const updatedPermit = PermitUtils.updateName(permit, 'New Name');
393
+
394
+ expect(updatedPermit.name).toBe('New Name');
395
+ expect(permit.name).toBe('Original Name'); // Original should be unchanged
396
+ expect(updatedPermit).not.toBe(permit); // Should be a new object
397
+ });
398
+ });
399
+
400
+ describe('validation helpers', () => {
401
+ it('should check if permit is expired', async () => {
402
+ const expiredPermit = await PermitUtils.createSelf({
403
+ issuer: bobAddress,
404
+ name: 'Test Permit',
405
+ expiration: Math.floor(Date.now() / 1000) - 3600, // 1 hour ago
406
+ });
407
+
408
+ const validPermit = await PermitUtils.createSelf({
409
+ issuer: bobAddress,
410
+ name: 'Test Permit',
411
+ expiration: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
412
+ });
413
+
414
+ expect(PermitUtils.isExpired(expiredPermit)).toBe(true);
415
+ expect(PermitUtils.isExpired(validPermit)).toBe(false);
416
+ });
417
+
418
+ it('should check if permit is signed', async () => {
419
+ const unsignedPermit = await PermitUtils.createSelf({
420
+ issuer: bobAddress,
421
+ name: 'Test Permit',
422
+ });
423
+
424
+ const signedPermit = await PermitUtils.sign(unsignedPermit, publicClient, bobWalletClient);
425
+
426
+ expect(PermitUtils.isSigned(unsignedPermit)).toBe(false);
427
+ expect(PermitUtils.isSigned(signedPermit)).toBe(true);
428
+ });
429
+
430
+ it('should check overall validity', async () => {
431
+ const validPermit = await PermitUtils.createSelf({
432
+ issuer: bobAddress,
433
+ name: 'Test Permit',
434
+ expiration: Math.floor(Date.now() / 1000) + 3600,
435
+ });
436
+
437
+ const signedPermit = await PermitUtils.sign(validPermit, publicClient, bobWalletClient);
438
+
439
+ const validation = PermitUtils.isValid(signedPermit);
440
+ expect(validation.valid).toBe(true);
441
+ expect(validation.error).toBeNull();
442
+ });
443
+ });
444
+
445
+ describe('real contract interactions', () => {
446
+ it('should fetch EIP712 domain from real Arbitrum Sepolia contract', async () => {
447
+ // This test uses the real public client to fetch actual contract data
448
+ const domain = await PermitUtils.fetchEIP712Domain(publicClient);
449
+
450
+ expect(domain).toBeDefined();
451
+ expect(domain.name).toBeDefined();
452
+ expect(domain.version).toBeDefined();
453
+ expect(domain.chainId).toBeDefined();
454
+ expect(domain.verifyingContract).toBeDefined();
455
+ expect(domain.verifyingContract).toMatch(/^0x[a-fA-F0-9]{40}$/); // Valid Ethereum address
456
+ }, 10000); // 10 second timeout for network call
457
+
458
+ it('should check signed domain validity with real contract data', async () => {
459
+ const permit = await PermitUtils.createSelf({
460
+ type: 'self',
461
+ issuer: bobAddress,
462
+ name: 'Test Permit',
463
+ });
464
+
465
+ // Sign the permit to get a domain
466
+ const signedPermit = await PermitUtils.sign(permit, publicClient, bobWalletClient);
467
+
468
+ // Check if the signed domain is valid against the real contract
469
+ const isValid = await PermitUtils.checkSignedDomainValid(signedPermit, publicClient);
470
+
471
+ expect(typeof isValid).toBe('boolean');
472
+ }, 10000); // 10 second timeout for network call
473
+ });
474
+ });