@idos-network/kwil-infra 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.turbo/turbo-build.log +47 -0
  2. package/.turbo/turbo-test.log +126 -0
  3. package/.turbo/turbo-typecheck.log +5 -0
  4. package/CHANGELOG.md +20 -0
  5. package/LICENSE +21 -0
  6. package/README.md +63 -0
  7. package/dist/actions/index.d.mts +2 -0
  8. package/dist/actions/index.mjs +1371 -0
  9. package/dist/actions/index.mjs.map +1 -0
  10. package/dist/facesign/index.d.mts +2 -0
  11. package/dist/facesign/index.mjs +2 -0
  12. package/dist/facesign-signer-ADd4EASX.d.mts +29 -0
  13. package/dist/facesign-signer-ADd4EASX.d.mts.map +1 -0
  14. package/dist/facesign-signer-BY9Nti9F.mjs +244 -0
  15. package/dist/facesign-signer-BY9Nti9F.mjs.map +1 -0
  16. package/dist/index-Ci6QhKJo.d.mts +644 -0
  17. package/dist/index-Ci6QhKJo.d.mts.map +1 -0
  18. package/dist/index.d.mts +2 -0
  19. package/dist/index.mjs +429 -0
  20. package/dist/index.mjs.map +1 -0
  21. package/dist/signature-verification/index.d.mts +14 -0
  22. package/dist/signature-verification/index.d.mts.map +1 -0
  23. package/dist/signature-verification/index.mjs +140 -0
  24. package/dist/signature-verification/index.mjs.map +1 -0
  25. package/dist/xrp/utils.d.mts +1165 -0
  26. package/dist/xrp/utils.d.mts.map +1 -0
  27. package/dist/xrp/utils.mjs +105 -0
  28. package/dist/xrp/utils.mjs.map +1 -0
  29. package/dist/xrpl-credentials/index.d.mts +179 -0
  30. package/dist/xrpl-credentials/index.d.mts.map +1 -0
  31. package/dist/xrpl-credentials/index.mjs +224 -0
  32. package/dist/xrpl-credentials/index.mjs.map +1 -0
  33. package/package.json +93 -0
  34. package/src/actions/actions.ts +2197 -0
  35. package/src/actions/index.ts +55 -0
  36. package/src/create-kwil-client.ts +144 -0
  37. package/src/create-kwil-signer.ts +270 -0
  38. package/src/facesign/facesign-signer.ts +327 -0
  39. package/src/facesign/index.ts +2 -0
  40. package/src/index.ts +7 -0
  41. package/src/near/create-near-wallet-kwil-signer.ts +245 -0
  42. package/src/near/get-config.ts +43 -0
  43. package/src/near/nep413.ts +62 -0
  44. package/src/near/signature-verification.ts +85 -0
  45. package/src/signature-verification/evm.ts +33 -0
  46. package/src/signature-verification/facesign.ts +19 -0
  47. package/src/signature-verification/index.test.ts +110 -0
  48. package/src/signature-verification/index.ts +72 -0
  49. package/src/signature-verification/stellar.ts +31 -0
  50. package/src/xrp/signature-verification.ts +18 -0
  51. package/src/xrp/signer.ts +43 -0
  52. package/src/xrp/utils.ts +178 -0
  53. package/src/xrpl-credentials/accept.ts +143 -0
  54. package/src/xrpl-credentials/create.ts +199 -0
  55. package/src/xrpl-credentials/index.ts +12 -0
  56. package/tsconfig.json +33 -0
  57. package/tsdown.config.ts +13 -0
  58. package/vitest.config.ts +6 -0
@@ -0,0 +1,2197 @@
1
+ import { Utils } from "@idos-network/kwil-js";
2
+ import * as z from "zod";
3
+
4
+ import type { KwilActionClient } from "../";
5
+
6
+ // This file is generated by the generator. Do not edit it manually.
7
+ export const DataType: typeof Utils.DataType = Utils.DataType;
8
+ export const WALLET_TYPES = ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign"] as const;
9
+
10
+ export type WalletType = (typeof WALLET_TYPES)[number];
11
+
12
+ export const walletTypeSchema: z.ZodType<WalletType> = z.enum(WALLET_TYPES);
13
+ export const ENCRYPTION_PASSWORD_STORES = ["user", "mpc"] as const;
14
+
15
+ export type EncryptionPasswordStore = (typeof ENCRYPTION_PASSWORD_STORES)[number];
16
+
17
+ export const encryptionPasswordStoreSchema: z.ZodType<EncryptionPasswordStore> = z.enum(
18
+ ENCRYPTION_PASSWORD_STORES,
19
+ );
20
+
21
+ export type ActionSchemaElement = {
22
+ name: string;
23
+ type: typeof DataType.Uuid | typeof DataType.Text | typeof DataType.Int | typeof DataType.Boolean;
24
+ };
25
+
26
+ export const actionSchema: Record<string, ActionSchemaElement[]> = {
27
+ add_inserter_as_owner: [
28
+ {
29
+ name: "id",
30
+ type: DataType.Uuid,
31
+ },
32
+ {
33
+ name: "name",
34
+ type: DataType.Text,
35
+ },
36
+ ],
37
+ delete_inserter_as_owner: [
38
+ {
39
+ name: "id",
40
+ type: DataType.Uuid,
41
+ },
42
+ ],
43
+ add_delegate_as_owner: [
44
+ {
45
+ name: "address",
46
+ type: DataType.Text,
47
+ },
48
+ {
49
+ name: "inserter_id",
50
+ type: DataType.Uuid,
51
+ },
52
+ ],
53
+ delete_delegate_as_owner: [
54
+ {
55
+ name: "address",
56
+ type: DataType.Text,
57
+ },
58
+ ],
59
+ add_user_as_inserter: [
60
+ {
61
+ name: "id",
62
+ type: DataType.Uuid,
63
+ },
64
+ {
65
+ name: "recipient_encryption_public_key",
66
+ type: DataType.Text,
67
+ },
68
+ {
69
+ name: "encryption_password_store",
70
+ type: DataType.Text,
71
+ },
72
+ ],
73
+ update_user_pub_key_as_inserter: [
74
+ {
75
+ name: "id",
76
+ type: DataType.Uuid,
77
+ },
78
+ {
79
+ name: "recipient_encryption_public_key",
80
+ type: DataType.Text,
81
+ },
82
+ {
83
+ name: "encryption_password_store",
84
+ type: DataType.Text,
85
+ },
86
+ ],
87
+ get_user: [],
88
+ get_user_as_inserter: [
89
+ {
90
+ name: "id",
91
+ type: DataType.Uuid,
92
+ },
93
+ ],
94
+ upsert_wallet_as_inserter: [
95
+ {
96
+ name: "id",
97
+ type: DataType.Uuid,
98
+ },
99
+ {
100
+ name: "user_id",
101
+ type: DataType.Uuid,
102
+ },
103
+ {
104
+ name: "address",
105
+ type: DataType.Text,
106
+ },
107
+ {
108
+ name: "public_key",
109
+ type: DataType.Text,
110
+ },
111
+ {
112
+ name: "wallet_type",
113
+ type: DataType.Text,
114
+ },
115
+ {
116
+ name: "message",
117
+ type: DataType.Text,
118
+ },
119
+ {
120
+ name: "signature",
121
+ type: DataType.Text,
122
+ },
123
+ ],
124
+ add_wallet: [
125
+ {
126
+ name: "id",
127
+ type: DataType.Uuid,
128
+ },
129
+ {
130
+ name: "address",
131
+ type: DataType.Text,
132
+ },
133
+ {
134
+ name: "public_key",
135
+ type: DataType.Text,
136
+ },
137
+ {
138
+ name: "wallet_type",
139
+ type: DataType.Text,
140
+ },
141
+ {
142
+ name: "message",
143
+ type: DataType.Text,
144
+ },
145
+ {
146
+ name: "signature",
147
+ type: DataType.Text,
148
+ },
149
+ ],
150
+ get_wallets: [],
151
+ remove_wallet: [
152
+ {
153
+ name: "id",
154
+ type: DataType.Uuid,
155
+ },
156
+ ],
157
+ upsert_credential_as_inserter: [
158
+ {
159
+ name: "id",
160
+ type: DataType.Uuid,
161
+ },
162
+ {
163
+ name: "user_id",
164
+ type: DataType.Uuid,
165
+ },
166
+ {
167
+ name: "issuer_auth_public_key",
168
+ type: DataType.Text,
169
+ },
170
+ {
171
+ name: "encryptor_public_key",
172
+ type: DataType.Text,
173
+ },
174
+ {
175
+ name: "content",
176
+ type: DataType.Text,
177
+ },
178
+ {
179
+ name: "public_notes",
180
+ type: DataType.Text,
181
+ },
182
+ {
183
+ name: "public_notes_signature",
184
+ type: DataType.Text,
185
+ },
186
+ {
187
+ name: "broader_signature",
188
+ type: DataType.Text,
189
+ },
190
+ ],
191
+ add_credential: [
192
+ {
193
+ name: "id",
194
+ type: DataType.Uuid,
195
+ },
196
+ {
197
+ name: "issuer_auth_public_key",
198
+ type: DataType.Text,
199
+ },
200
+ {
201
+ name: "encryptor_public_key",
202
+ type: DataType.Text,
203
+ },
204
+ {
205
+ name: "content",
206
+ type: DataType.Text,
207
+ },
208
+ {
209
+ name: "public_notes",
210
+ type: DataType.Text,
211
+ },
212
+ {
213
+ name: "public_notes_signature",
214
+ type: DataType.Text,
215
+ },
216
+ {
217
+ name: "broader_signature",
218
+ type: DataType.Text,
219
+ },
220
+ ],
221
+ get_credentials: [],
222
+ get_credentials_shared_by_user: [
223
+ {
224
+ name: "user_id",
225
+ type: DataType.Uuid,
226
+ },
227
+ {
228
+ name: "original_issuer_auth_public_key",
229
+ type: DataType.Text,
230
+ },
231
+ ],
232
+ edit_credential: [
233
+ {
234
+ name: "id",
235
+ type: DataType.Uuid,
236
+ },
237
+ {
238
+ name: "public_notes",
239
+ type: DataType.Text,
240
+ },
241
+ {
242
+ name: "public_notes_signature",
243
+ type: DataType.Text,
244
+ },
245
+ {
246
+ name: "broader_signature",
247
+ type: DataType.Text,
248
+ },
249
+ {
250
+ name: "content",
251
+ type: DataType.Text,
252
+ },
253
+ {
254
+ name: "encryptor_public_key",
255
+ type: DataType.Text,
256
+ },
257
+ {
258
+ name: "issuer_auth_public_key",
259
+ type: DataType.Text,
260
+ },
261
+ ],
262
+ edit_public_notes_as_issuer: [
263
+ {
264
+ name: "public_notes_id",
265
+ type: DataType.Text,
266
+ },
267
+ {
268
+ name: "public_notes",
269
+ type: DataType.Text,
270
+ },
271
+ ],
272
+ remove_credential: [
273
+ {
274
+ name: "id",
275
+ type: DataType.Uuid,
276
+ },
277
+ ],
278
+ rescind_shared_credential: [
279
+ {
280
+ name: "credential_id",
281
+ type: DataType.Uuid,
282
+ },
283
+ ],
284
+ share_credential: [
285
+ {
286
+ name: "id",
287
+ type: DataType.Uuid,
288
+ },
289
+ {
290
+ name: "original_credential_id",
291
+ type: DataType.Uuid,
292
+ },
293
+ {
294
+ name: "public_notes",
295
+ type: DataType.Text,
296
+ },
297
+ {
298
+ name: "public_notes_signature",
299
+ type: DataType.Text,
300
+ },
301
+ {
302
+ name: "broader_signature",
303
+ type: DataType.Text,
304
+ },
305
+ {
306
+ name: "content",
307
+ type: DataType.Text,
308
+ },
309
+ {
310
+ name: "content_hash",
311
+ type: DataType.Text,
312
+ },
313
+ {
314
+ name: "encryptor_public_key",
315
+ type: DataType.Text,
316
+ },
317
+ {
318
+ name: "issuer_auth_public_key",
319
+ type: DataType.Text,
320
+ },
321
+ {
322
+ name: "grantee_wallet_identifier",
323
+ type: DataType.Text,
324
+ },
325
+ {
326
+ name: "locked_until",
327
+ type: DataType.Int,
328
+ },
329
+ ],
330
+ create_credentials_by_dwg: [
331
+ {
332
+ name: "issuer_auth_public_key",
333
+ type: DataType.Text,
334
+ },
335
+ {
336
+ name: "original_encryptor_public_key",
337
+ type: DataType.Text,
338
+ },
339
+ {
340
+ name: "original_credential_id",
341
+ type: DataType.Uuid,
342
+ },
343
+ {
344
+ name: "original_content",
345
+ type: DataType.Text,
346
+ },
347
+ {
348
+ name: "original_public_notes",
349
+ type: DataType.Text,
350
+ },
351
+ {
352
+ name: "original_public_notes_signature",
353
+ type: DataType.Text,
354
+ },
355
+ {
356
+ name: "original_broader_signature",
357
+ type: DataType.Text,
358
+ },
359
+ {
360
+ name: "copy_encryptor_public_key",
361
+ type: DataType.Text,
362
+ },
363
+ {
364
+ name: "copy_credential_id",
365
+ type: DataType.Uuid,
366
+ },
367
+ {
368
+ name: "copy_content",
369
+ type: DataType.Text,
370
+ },
371
+ {
372
+ name: "copy_public_notes_signature",
373
+ type: DataType.Text,
374
+ },
375
+ {
376
+ name: "copy_broader_signature",
377
+ type: DataType.Text,
378
+ },
379
+ {
380
+ name: "content_hash",
381
+ type: DataType.Text,
382
+ },
383
+ {
384
+ name: "dwg_owner",
385
+ type: DataType.Text,
386
+ },
387
+ {
388
+ name: "dwg_grantee",
389
+ type: DataType.Text,
390
+ },
391
+ {
392
+ name: "dwg_issuer_public_key",
393
+ type: DataType.Text,
394
+ },
395
+ {
396
+ name: "dwg_id",
397
+ type: DataType.Uuid,
398
+ },
399
+ {
400
+ name: "dwg_access_grant_timelock",
401
+ type: DataType.Text,
402
+ },
403
+ {
404
+ name: "dwg_not_before",
405
+ type: DataType.Text,
406
+ },
407
+ {
408
+ name: "dwg_not_after",
409
+ type: DataType.Text,
410
+ },
411
+ {
412
+ name: "dwg_signature",
413
+ type: DataType.Text,
414
+ },
415
+ ],
416
+ credential_exist_as_inserter: [
417
+ {
418
+ name: "id",
419
+ type: DataType.Uuid,
420
+ },
421
+ ],
422
+ get_credential_owned: [
423
+ {
424
+ name: "id",
425
+ type: DataType.Uuid,
426
+ },
427
+ ],
428
+ get_credential_shared: [
429
+ {
430
+ name: "id",
431
+ type: DataType.Uuid,
432
+ },
433
+ ],
434
+ get_sibling_credential_id: [
435
+ {
436
+ name: "content_hash",
437
+ type: DataType.Text,
438
+ },
439
+ ],
440
+ add_attribute_as_inserter: [
441
+ {
442
+ name: "id",
443
+ type: DataType.Uuid,
444
+ },
445
+ {
446
+ name: "user_id",
447
+ type: DataType.Uuid,
448
+ },
449
+ {
450
+ name: "attribute_key",
451
+ type: DataType.Text,
452
+ },
453
+ {
454
+ name: "value",
455
+ type: DataType.Text,
456
+ },
457
+ ],
458
+ add_attribute: [
459
+ {
460
+ name: "id",
461
+ type: DataType.Uuid,
462
+ },
463
+ {
464
+ name: "attribute_key",
465
+ type: DataType.Text,
466
+ },
467
+ {
468
+ name: "value",
469
+ type: DataType.Text,
470
+ },
471
+ ],
472
+ get_attributes: [],
473
+ edit_attribute: [
474
+ {
475
+ name: "id",
476
+ type: DataType.Uuid,
477
+ },
478
+ {
479
+ name: "attribute_key",
480
+ type: DataType.Text,
481
+ },
482
+ {
483
+ name: "value",
484
+ type: DataType.Text,
485
+ },
486
+ ],
487
+ remove_attribute: [
488
+ {
489
+ name: "id",
490
+ type: DataType.Uuid,
491
+ },
492
+ ],
493
+ share_attribute: [
494
+ {
495
+ name: "id",
496
+ type: DataType.Uuid,
497
+ },
498
+ {
499
+ name: "original_attribute_id",
500
+ type: DataType.Uuid,
501
+ },
502
+ {
503
+ name: "attribute_key",
504
+ type: DataType.Text,
505
+ },
506
+ {
507
+ name: "value",
508
+ type: DataType.Text,
509
+ },
510
+ ],
511
+ dwg_message: [
512
+ {
513
+ name: "owner_wallet_identifier",
514
+ type: DataType.Text,
515
+ },
516
+ {
517
+ name: "grantee_wallet_identifier",
518
+ type: DataType.Text,
519
+ },
520
+ {
521
+ name: "issuer_public_key",
522
+ type: DataType.Text,
523
+ },
524
+ {
525
+ name: "id",
526
+ type: DataType.Uuid,
527
+ },
528
+ {
529
+ name: "access_grant_timelock",
530
+ type: DataType.Text,
531
+ },
532
+ {
533
+ name: "not_usable_before",
534
+ type: DataType.Text,
535
+ },
536
+ {
537
+ name: "not_usable_after",
538
+ type: DataType.Text,
539
+ },
540
+ ],
541
+ revoke_access_grant: [
542
+ {
543
+ name: "id",
544
+ type: DataType.Uuid,
545
+ },
546
+ ],
547
+ get_access_grants_owned: [],
548
+ get_access_grants_granted: [
549
+ {
550
+ name: "user_id",
551
+ type: DataType.Uuid,
552
+ },
553
+ {
554
+ name: "page",
555
+ type: DataType.Int,
556
+ },
557
+ {
558
+ name: "size",
559
+ type: DataType.Int,
560
+ },
561
+ ],
562
+ get_access_grants_granted_count: [
563
+ {
564
+ name: "user_id",
565
+ type: DataType.Uuid,
566
+ },
567
+ ],
568
+ has_locked_access_grants: [
569
+ {
570
+ name: "id",
571
+ type: DataType.Uuid,
572
+ },
573
+ ],
574
+ dag_message: [
575
+ {
576
+ name: "dag_owner_wallet_identifier",
577
+ type: DataType.Text,
578
+ },
579
+ {
580
+ name: "dag_grantee_wallet_identifier",
581
+ type: DataType.Text,
582
+ },
583
+ {
584
+ name: "dag_data_id",
585
+ type: DataType.Uuid,
586
+ },
587
+ {
588
+ name: "dag_locked_until",
589
+ type: DataType.Int,
590
+ },
591
+ {
592
+ name: "dag_content_hash",
593
+ type: DataType.Text,
594
+ },
595
+ ],
596
+ create_ag_by_dag_for_copy: [
597
+ {
598
+ name: "dag_owner_wallet_identifier",
599
+ type: DataType.Text,
600
+ },
601
+ {
602
+ name: "dag_grantee_wallet_identifier",
603
+ type: DataType.Text,
604
+ },
605
+ {
606
+ name: "dag_data_id",
607
+ type: DataType.Uuid,
608
+ },
609
+ {
610
+ name: "dag_locked_until",
611
+ type: DataType.Int,
612
+ },
613
+ {
614
+ name: "dag_content_hash",
615
+ type: DataType.Text,
616
+ },
617
+ {
618
+ name: "dag_signature",
619
+ type: DataType.Text,
620
+ },
621
+ ],
622
+ get_access_grants_for_credential: [
623
+ {
624
+ name: "credential_id",
625
+ type: DataType.Uuid,
626
+ },
627
+ ],
628
+ has_profile: [
629
+ {
630
+ name: "address",
631
+ type: DataType.Text,
632
+ },
633
+ ],
634
+ check_balance: [
635
+ {
636
+ name: "address",
637
+ type: DataType.Text,
638
+ },
639
+ {
640
+ name: "token",
641
+ type: DataType.Text,
642
+ },
643
+ ],
644
+ get_wallet_with_balance: [
645
+ {
646
+ name: "token",
647
+ type: DataType.Text,
648
+ },
649
+ ],
650
+ request_withdrawal: [
651
+ {
652
+ name: "token",
653
+ type: DataType.Text,
654
+ },
655
+ ],
656
+ get_allowance: [],
657
+ action_costing_gas: [],
658
+ action_costing_idos_token: [
659
+ {
660
+ name: "amount",
661
+ type: DataType.Int,
662
+ },
663
+ ],
664
+ get_issuer_fee: [
665
+ {
666
+ name: "credential_id",
667
+ type: DataType.Uuid,
668
+ },
669
+ ],
670
+ action_costing_fee: [
671
+ {
672
+ name: "credential_id",
673
+ type: DataType.Uuid,
674
+ },
675
+ ],
676
+ request_balance_withdrawal: [
677
+ {
678
+ name: "token",
679
+ type: DataType.Text,
680
+ },
681
+ {
682
+ name: "evm_address_to",
683
+ type: DataType.Text,
684
+ },
685
+ ],
686
+ };
687
+ export const AddInserterAsOwnerInputSchema: z.ZodObject<{
688
+ id: z.ZodUUID;
689
+ name: z.ZodString;
690
+ }> = z.object({
691
+ id: z.uuid(),
692
+ name: z.string(),
693
+ });
694
+
695
+ export type AddInserterAsOwnerInput = z.infer<typeof AddInserterAsOwnerInputSchema>;
696
+
697
+ /** INSERTER AND DELEGATE ACTIONS */
698
+ export async function addInserterAsOwner(
699
+ kwilClient: KwilActionClient,
700
+ params: AddInserterAsOwnerInput,
701
+ ): Promise<void> {
702
+ const inputs = AddInserterAsOwnerInputSchema.parse(params);
703
+ await kwilClient.execute({
704
+ name: "add_inserter_as_owner",
705
+ inputs,
706
+ description: "Add inserter as owner",
707
+ });
708
+ }
709
+
710
+ export const DeleteInserterAsOwnerInputSchema: z.ZodObject<{
711
+ id: z.ZodUUID;
712
+ }> = z.object({
713
+ id: z.uuid(),
714
+ });
715
+
716
+ export type DeleteInserterAsOwnerInput = z.infer<typeof DeleteInserterAsOwnerInputSchema>;
717
+
718
+ export async function deleteInserterAsOwner(
719
+ kwilClient: KwilActionClient,
720
+ params: DeleteInserterAsOwnerInput,
721
+ ): Promise<void> {
722
+ const inputs = DeleteInserterAsOwnerInputSchema.parse(params);
723
+ await kwilClient.execute({
724
+ name: "delete_inserter_as_owner",
725
+ inputs,
726
+ description: "Delete inserter as owner",
727
+ });
728
+ }
729
+
730
+ export const AddDelegateAsOwnerInputSchema: z.ZodObject<{
731
+ address: z.ZodString;
732
+ inserter_id: z.ZodUUID;
733
+ }> = z.object({
734
+ address: z.string(),
735
+ inserter_id: z.uuid(),
736
+ });
737
+
738
+ export type AddDelegateAsOwnerInput = z.infer<typeof AddDelegateAsOwnerInputSchema>;
739
+
740
+ export async function addDelegateAsOwner(
741
+ kwilClient: KwilActionClient,
742
+ params: AddDelegateAsOwnerInput,
743
+ ): Promise<void> {
744
+ const inputs = AddDelegateAsOwnerInputSchema.parse(params);
745
+ await kwilClient.execute({
746
+ name: "add_delegate_as_owner",
747
+ inputs,
748
+ description: "Add a delegate as owner",
749
+ });
750
+ }
751
+
752
+ export const DeleteDelegateAsOwnerInputSchema: z.ZodObject<{
753
+ address: z.ZodString;
754
+ }> = z.object({
755
+ address: z.string(),
756
+ });
757
+
758
+ export type DeleteDelegateAsOwnerInput = z.infer<typeof DeleteDelegateAsOwnerInputSchema>;
759
+
760
+ export async function deleteDelegateAsOwner(
761
+ kwilClient: KwilActionClient,
762
+ params: DeleteDelegateAsOwnerInput,
763
+ ): Promise<void> {
764
+ const inputs = DeleteDelegateAsOwnerInputSchema.parse(params);
765
+ await kwilClient.execute({
766
+ name: "delete_delegate_as_owner",
767
+ inputs,
768
+ description: "Delete a delegate from idOS",
769
+ });
770
+ }
771
+
772
+ export const AddUserAsInserterInputSchema: z.ZodObject<{
773
+ id: z.ZodUUID;
774
+ recipient_encryption_public_key: z.ZodString;
775
+ encryption_password_store: z.ZodType<EncryptionPasswordStore>;
776
+ }> = z.object({
777
+ id: z.uuid(),
778
+ recipient_encryption_public_key: z.string(),
779
+ encryption_password_store: encryptionPasswordStoreSchema,
780
+ });
781
+
782
+ export type AddUserAsInserterInput = z.infer<typeof AddUserAsInserterInputSchema>;
783
+
784
+ /** USER ACTIONS */
785
+ export async function addUserAsInserter(
786
+ kwilClient: KwilActionClient,
787
+ params: AddUserAsInserterInput,
788
+ ): Promise<void> {
789
+ const inputs = AddUserAsInserterInputSchema.parse(params);
790
+ await kwilClient.execute({
791
+ name: "add_user_as_inserter",
792
+ inputs,
793
+ description: "Add a user to idOS",
794
+ });
795
+ }
796
+
797
+ export const UpdateUserPubKeyAsInserterInputSchema: z.ZodObject<{
798
+ id: z.ZodUUID;
799
+ recipient_encryption_public_key: z.ZodString;
800
+ encryption_password_store: z.ZodType<EncryptionPasswordStore>;
801
+ }> = z.object({
802
+ id: z.uuid(),
803
+ recipient_encryption_public_key: z.string(),
804
+ encryption_password_store: encryptionPasswordStoreSchema,
805
+ });
806
+
807
+ export type UpdateUserPubKeyAsInserterInput = z.infer<typeof UpdateUserPubKeyAsInserterInputSchema>;
808
+
809
+ export async function updateUserPubKeyAsInserter(
810
+ kwilClient: KwilActionClient,
811
+ params: UpdateUserPubKeyAsInserterInput,
812
+ ): Promise<void> {
813
+ const inputs = UpdateUserPubKeyAsInserterInputSchema.parse(params);
814
+ await kwilClient.execute({
815
+ name: "update_user_pub_key_as_inserter",
816
+ inputs,
817
+ description:
818
+ "Update user's encryption key and password store in idOS as inserter (profile creator)",
819
+ });
820
+ }
821
+
822
+ export const GetUserOutputSchema: z.ZodObject<{
823
+ id: z.ZodUUID;
824
+ recipient_encryption_public_key: z.ZodString;
825
+ encryption_password_store: z.ZodType<EncryptionPasswordStore>;
826
+ }> = z.object({
827
+ id: z.uuid(),
828
+ recipient_encryption_public_key: z.string(),
829
+ encryption_password_store: encryptionPasswordStoreSchema,
830
+ });
831
+
832
+ export type GetUserOutput = z.infer<typeof GetUserOutputSchema>;
833
+
834
+ export async function getUser(kwilClient: KwilActionClient): Promise<GetUserOutput> {
835
+ return await kwilClient
836
+ .call<GetUserOutput[]>({
837
+ name: "get_user",
838
+ inputs: {},
839
+ })
840
+ .then((result) => result[0]);
841
+ }
842
+
843
+ export const GetUserAsInserterInputSchema: z.ZodObject<{
844
+ id: z.ZodUUID;
845
+ }> = z.object({
846
+ id: z.uuid(),
847
+ });
848
+
849
+ export type GetUserAsInserterInput = z.infer<typeof GetUserAsInserterInputSchema>;
850
+
851
+ export const GetUserAsInserterOutputSchema: z.ZodObject<{
852
+ id: z.ZodUUID;
853
+ recipient_encryption_public_key: z.ZodString;
854
+ encryption_password_store: z.ZodType<EncryptionPasswordStore>;
855
+ inserter: z.ZodString;
856
+ }> = z.object({
857
+ id: z.uuid(),
858
+ recipient_encryption_public_key: z.string(),
859
+ encryption_password_store: encryptionPasswordStoreSchema,
860
+ inserter: z.string(),
861
+ });
862
+
863
+ export type GetUserAsInserterOutput = z.infer<typeof GetUserAsInserterOutputSchema>;
864
+
865
+ export async function getUserAsInserter(
866
+ kwilClient: KwilActionClient,
867
+ params: GetUserAsInserterInput,
868
+ ): Promise<GetUserAsInserterOutput> {
869
+ const inputs = GetUserAsInserterInputSchema.parse(params);
870
+ return await kwilClient
871
+ .call<GetUserAsInserterOutput[]>({
872
+ name: "get_user_as_inserter",
873
+ inputs,
874
+ })
875
+ .then((result) => result[0]);
876
+ }
877
+
878
+ export const UpsertWalletAsInserterInputSchema: z.ZodObject<{
879
+ id: z.ZodUUID;
880
+ user_id: z.ZodUUID;
881
+ address: z.ZodString;
882
+ public_key: z.ZodNullable<z.ZodString>;
883
+ wallet_type: z.ZodType<WalletType>;
884
+ message: z.ZodString;
885
+ signature: z.ZodString;
886
+ }> = z.object({
887
+ id: z.uuid(),
888
+ user_id: z.uuid(),
889
+ address: z.string(),
890
+ public_key: z.string().nullable(),
891
+ wallet_type: walletTypeSchema,
892
+ message: z.string(),
893
+ signature: z.string(),
894
+ });
895
+
896
+ export type UpsertWalletAsInserterInput = z.infer<typeof UpsertWalletAsInserterInputSchema>;
897
+
898
+ /** WALLET ACTIONS */
899
+ export async function upsertWalletAsInserter(
900
+ kwilClient: KwilActionClient,
901
+ params: UpsertWalletAsInserterInput,
902
+ ): Promise<void> {
903
+ const inputs = UpsertWalletAsInserterInputSchema.parse(params);
904
+ await kwilClient.execute({
905
+ name: "upsert_wallet_as_inserter",
906
+ inputs,
907
+ description: "Add a wallet to idOS by inserter (profile creator)",
908
+ });
909
+ }
910
+
911
+ export const AddWalletInputSchema: z.ZodObject<{
912
+ id: z.ZodUUID;
913
+ address: z.ZodString;
914
+ public_key: z.ZodNullable<z.ZodString>;
915
+ wallet_type: z.ZodType<WalletType>;
916
+ message: z.ZodString;
917
+ signature: z.ZodString;
918
+ }> = z.object({
919
+ id: z.uuid(),
920
+ address: z.string(),
921
+ public_key: z.string().nullable(),
922
+ wallet_type: walletTypeSchema,
923
+ message: z.string(),
924
+ signature: z.string(),
925
+ });
926
+
927
+ export type AddWalletInput = z.infer<typeof AddWalletInputSchema>;
928
+
929
+ export async function addWallet(
930
+ kwilClient: KwilActionClient,
931
+ params: AddWalletInput,
932
+ ): Promise<void> {
933
+ const inputs = AddWalletInputSchema.parse(params);
934
+ await kwilClient.execute({
935
+ name: "add_wallet",
936
+ inputs,
937
+ description: "Add a wallet to idOS",
938
+ });
939
+ }
940
+
941
+ export const GetWalletsOutputSchema: z.ZodObject<{
942
+ id: z.ZodUUID;
943
+ user_id: z.ZodUUID;
944
+ address: z.ZodString;
945
+ public_key: z.ZodNullable<z.ZodString>;
946
+ wallet_type: z.ZodType<WalletType>;
947
+ message: z.ZodString;
948
+ signature: z.ZodString;
949
+ inserter: z.ZodNullable<z.ZodString>;
950
+ }> = z.object({
951
+ id: z.uuid(),
952
+ user_id: z.uuid(),
953
+ address: z.string(),
954
+ public_key: z.string().nullable(),
955
+ wallet_type: walletTypeSchema,
956
+ message: z.string(),
957
+ signature: z.string(),
958
+ inserter: z.string().nullable(),
959
+ });
960
+
961
+ export type GetWalletsOutput = z.infer<typeof GetWalletsOutputSchema>;
962
+
963
+ export async function getWallets(kwilClient: KwilActionClient): Promise<GetWalletsOutput[]> {
964
+ return await kwilClient.call<GetWalletsOutput[]>({
965
+ name: "get_wallets",
966
+ inputs: {},
967
+ });
968
+ }
969
+
970
+ export const RemoveWalletInputSchema: z.ZodObject<{
971
+ id: z.ZodUUID;
972
+ }> = z.object({
973
+ id: z.uuid(),
974
+ });
975
+
976
+ export type RemoveWalletInput = z.infer<typeof RemoveWalletInputSchema>;
977
+
978
+ export async function removeWallet(
979
+ kwilClient: KwilActionClient,
980
+ params: RemoveWalletInput,
981
+ ): Promise<void> {
982
+ const inputs = RemoveWalletInputSchema.parse(params);
983
+ await kwilClient.execute({
984
+ name: "remove_wallet",
985
+ inputs,
986
+ description: "Remove a wallet from idOS",
987
+ });
988
+ }
989
+
990
+ export const UpsertCredentialAsInserterInputSchema: z.ZodObject<{
991
+ id: z.ZodUUID;
992
+ user_id: z.ZodUUID;
993
+ issuer_auth_public_key: z.ZodString;
994
+ encryptor_public_key: z.ZodString;
995
+ content: z.ZodString;
996
+ public_notes: z.ZodString;
997
+ public_notes_signature: z.ZodString;
998
+ broader_signature: z.ZodString;
999
+ }> = z.object({
1000
+ id: z.uuid(),
1001
+ user_id: z.uuid(),
1002
+ issuer_auth_public_key: z.string(),
1003
+ encryptor_public_key: z.string(),
1004
+ content: z.string(),
1005
+ public_notes: z.string(),
1006
+ public_notes_signature: z.string(),
1007
+ broader_signature: z.string(),
1008
+ });
1009
+
1010
+ export type UpsertCredentialAsInserterInput = z.infer<typeof UpsertCredentialAsInserterInputSchema>;
1011
+
1012
+ /**
1013
+ * CREDENTIAL ACTIONS
1014
+ * throw an error if not authorized
1015
+ */
1016
+ export async function upsertCredentialAsInserter(
1017
+ kwilClient: KwilActionClient,
1018
+ params: UpsertCredentialAsInserterInput,
1019
+ ): Promise<void> {
1020
+ const inputs = UpsertCredentialAsInserterInputSchema.parse(params);
1021
+ await kwilClient.execute({
1022
+ name: "upsert_credential_as_inserter",
1023
+ inputs,
1024
+ description:
1025
+ "Add or update a credential in idOS on behalf of a user by permissioned profile creator (inserter) ",
1026
+ });
1027
+ }
1028
+
1029
+ export const AddCredentialInputSchema: z.ZodObject<{
1030
+ id: z.ZodUUID;
1031
+ issuer_auth_public_key: z.ZodString;
1032
+ encryptor_public_key: z.ZodString;
1033
+ content: z.ZodString;
1034
+ public_notes: z.ZodString;
1035
+ public_notes_signature: z.ZodString;
1036
+ broader_signature: z.ZodString;
1037
+ }> = z.object({
1038
+ id: z.uuid(),
1039
+ issuer_auth_public_key: z.string(),
1040
+ encryptor_public_key: z.string(),
1041
+ content: z.string(),
1042
+ public_notes: z.string(),
1043
+ public_notes_signature: z.string(),
1044
+ broader_signature: z.string(),
1045
+ });
1046
+
1047
+ export type AddCredentialInput = z.infer<typeof AddCredentialInputSchema>;
1048
+
1049
+ export async function addCredential(
1050
+ kwilClient: KwilActionClient,
1051
+ params: AddCredentialInput,
1052
+ ): Promise<void> {
1053
+ const inputs = AddCredentialInputSchema.parse(params);
1054
+ await kwilClient.execute({
1055
+ name: "add_credential",
1056
+ inputs,
1057
+ description: "Add a new credential",
1058
+ });
1059
+ }
1060
+
1061
+ export const GetCredentialsOutputSchema: z.ZodObject<{
1062
+ id: z.ZodUUID;
1063
+ user_id: z.ZodUUID;
1064
+ public_notes: z.ZodString;
1065
+ issuer_auth_public_key: z.ZodString;
1066
+ inserter: z.ZodNullable<z.ZodString>;
1067
+ original_id: z.ZodNullable<z.ZodUUID>;
1068
+ }> = z.object({
1069
+ id: z.uuid(),
1070
+ user_id: z.uuid(),
1071
+ public_notes: z.string(),
1072
+ issuer_auth_public_key: z.string(),
1073
+ inserter: z.string().nullable(),
1074
+ original_id: z.uuid().nullable(),
1075
+ });
1076
+
1077
+ export type GetCredentialsOutput = z.infer<typeof GetCredentialsOutputSchema>;
1078
+
1079
+ export async function getCredentials(
1080
+ kwilClient: KwilActionClient,
1081
+ ): Promise<GetCredentialsOutput[]> {
1082
+ return await kwilClient.call<GetCredentialsOutput[]>({
1083
+ name: "get_credentials",
1084
+ inputs: {},
1085
+ });
1086
+ }
1087
+
1088
+ export const GetCredentialsSharedByUserInputSchema: z.ZodObject<{
1089
+ user_id: z.ZodUUID;
1090
+ original_issuer_auth_public_key: z.ZodNullable<z.ZodString>;
1091
+ }> = z.object({
1092
+ user_id: z.uuid(),
1093
+ original_issuer_auth_public_key: z.string().nullable(),
1094
+ });
1095
+
1096
+ export type GetCredentialsSharedByUserInput = z.infer<typeof GetCredentialsSharedByUserInputSchema>;
1097
+
1098
+ export const GetCredentialsSharedByUserOutputSchema: z.ZodObject<{
1099
+ id: z.ZodUUID;
1100
+ user_id: z.ZodUUID;
1101
+ public_notes: z.ZodString;
1102
+ encryptor_public_key: z.ZodString;
1103
+ issuer_auth_public_key: z.ZodString;
1104
+ inserter: z.ZodNullable<z.ZodString>;
1105
+ original_id: z.ZodNullable<z.ZodUUID>;
1106
+ }> = z.object({
1107
+ id: z.uuid(),
1108
+ user_id: z.uuid(),
1109
+ public_notes: z.string(),
1110
+ encryptor_public_key: z.string(),
1111
+ issuer_auth_public_key: z.string(),
1112
+ inserter: z.string().nullable(),
1113
+ original_id: z.uuid().nullable(),
1114
+ });
1115
+
1116
+ export type GetCredentialsSharedByUserOutput = z.infer<
1117
+ typeof GetCredentialsSharedByUserOutputSchema
1118
+ >;
1119
+
1120
+ export async function getCredentialsSharedByUser(
1121
+ kwilClient: KwilActionClient,
1122
+ params: GetCredentialsSharedByUserInput,
1123
+ ): Promise<GetCredentialsSharedByUserOutput[]> {
1124
+ const inputs = GetCredentialsSharedByUserInputSchema.parse(params);
1125
+ return await kwilClient.call<GetCredentialsSharedByUserOutput[]>({
1126
+ name: "get_credentials_shared_by_user",
1127
+ inputs,
1128
+ });
1129
+ }
1130
+
1131
+ export const EditCredentialInputSchema: z.ZodObject<{
1132
+ id: z.ZodUUID;
1133
+ public_notes: z.ZodString;
1134
+ public_notes_signature: z.ZodString;
1135
+ broader_signature: z.ZodString;
1136
+ content: z.ZodString;
1137
+ encryptor_public_key: z.ZodString;
1138
+ issuer_auth_public_key: z.ZodString;
1139
+ }> = z.object({
1140
+ id: z.uuid(),
1141
+ public_notes: z.string(),
1142
+ public_notes_signature: z.string(),
1143
+ broader_signature: z.string(),
1144
+ content: z.string(),
1145
+ encryptor_public_key: z.string(),
1146
+ issuer_auth_public_key: z.string(),
1147
+ });
1148
+
1149
+ export type EditCredentialInput = z.infer<typeof EditCredentialInputSchema>;
1150
+
1151
+ /**
1152
+ * we forbid to edit a copy
1153
+ * only copies can have AGs, so data_id in AGs is id of a copy
1154
+ * if $id is shared_credentials.copy_id - it is a copy
1155
+ */
1156
+ export async function editCredential(
1157
+ kwilClient: KwilActionClient,
1158
+ params: EditCredentialInput,
1159
+ ): Promise<void> {
1160
+ const inputs = EditCredentialInputSchema.parse(params);
1161
+ await kwilClient.execute({
1162
+ name: "edit_credential",
1163
+ inputs,
1164
+ description: "Edit a credential",
1165
+ });
1166
+ }
1167
+
1168
+ export const EditPublicNotesAsIssuerInputSchema: z.ZodObject<{
1169
+ public_notes_id: z.ZodString;
1170
+ public_notes: z.ZodString;
1171
+ }> = z.object({
1172
+ public_notes_id: z.string(),
1173
+ public_notes: z.string(),
1174
+ });
1175
+
1176
+ export type EditPublicNotesAsIssuerInput = z.infer<typeof EditPublicNotesAsIssuerInputSchema>;
1177
+
1178
+ /**
1179
+ * Be aware that @caller here is ed25519 public key, hex encoded.
1180
+ * All other @caller in the schema are either secp256k1 or nep413
1181
+ * This action can't be called by kwil-cli (as kwil-cli uses secp256k1 only)
1182
+ */
1183
+ export async function editPublicNotesAsIssuer(
1184
+ kwilClient: KwilActionClient,
1185
+ params: EditPublicNotesAsIssuerInput,
1186
+ ): Promise<void> {
1187
+ const inputs = EditPublicNotesAsIssuerInputSchema.parse(params);
1188
+ await kwilClient.execute({
1189
+ name: "edit_public_notes_as_issuer",
1190
+ inputs,
1191
+ description: "Edit public notes in a credential as issuer",
1192
+ });
1193
+ }
1194
+
1195
+ export const RemoveCredentialInputSchema: z.ZodObject<{
1196
+ id: z.ZodUUID;
1197
+ }> = z.object({
1198
+ id: z.uuid(),
1199
+ });
1200
+
1201
+ export type RemoveCredentialInput = z.infer<typeof RemoveCredentialInputSchema>;
1202
+
1203
+ export async function removeCredential(
1204
+ kwilClient: KwilActionClient,
1205
+ params: RemoveCredentialInput,
1206
+ ): Promise<void> {
1207
+ const inputs = RemoveCredentialInputSchema.parse(params);
1208
+ await kwilClient.execute({
1209
+ name: "remove_credential",
1210
+ inputs,
1211
+ description: "Remove a credential from your idOS profile",
1212
+ });
1213
+ }
1214
+
1215
+ export const RescindSharedCredentialInputSchema: z.ZodObject<{
1216
+ credential_id: z.ZodUUID;
1217
+ }> = z.object({
1218
+ credential_id: z.uuid(),
1219
+ });
1220
+
1221
+ export type RescindSharedCredentialInput = z.infer<typeof RescindSharedCredentialInputSchema>;
1222
+
1223
+ export async function rescindSharedCredential(
1224
+ kwilClient: KwilActionClient,
1225
+ params: RescindSharedCredentialInput,
1226
+ ): Promise<void> {
1227
+ const inputs = RescindSharedCredentialInputSchema.parse(params);
1228
+ await kwilClient.execute({
1229
+ name: "rescind_shared_credential",
1230
+ inputs,
1231
+ description: "Rescind a shared credential as a grantee",
1232
+ });
1233
+ }
1234
+
1235
+ export const ShareCredentialInputSchema: z.ZodObject<{
1236
+ id: z.ZodUUID;
1237
+ original_credential_id: z.ZodUUID;
1238
+ public_notes: z.ZodString;
1239
+ public_notes_signature: z.ZodString;
1240
+ broader_signature: z.ZodString;
1241
+ content: z.ZodString;
1242
+ content_hash: z.ZodString;
1243
+ encryptor_public_key: z.ZodString;
1244
+ issuer_auth_public_key: z.ZodString;
1245
+ grantee_wallet_identifier: z.ZodString;
1246
+ locked_until: z.ZodNumber;
1247
+ }> = z.object({
1248
+ id: z.uuid(),
1249
+ original_credential_id: z.uuid(),
1250
+ public_notes: z.string(),
1251
+ public_notes_signature: z.string(),
1252
+ broader_signature: z.string(),
1253
+ content: z.string(),
1254
+ content_hash: z.string(),
1255
+ encryptor_public_key: z.string(),
1256
+ issuer_auth_public_key: z.string(),
1257
+ grantee_wallet_identifier: z.string(),
1258
+ locked_until: z.number(),
1259
+ });
1260
+
1261
+ export type ShareCredentialInput = z.infer<typeof ShareCredentialInputSchema>;
1262
+
1263
+ export async function shareCredential(
1264
+ kwilClient: KwilActionClient,
1265
+ params: ShareCredentialInput,
1266
+ ): Promise<void> {
1267
+ const inputs = ShareCredentialInputSchema.parse(params);
1268
+ await kwilClient.execute({
1269
+ name: "share_credential",
1270
+ inputs,
1271
+ description: "Share a credential with creating AG",
1272
+ });
1273
+ }
1274
+
1275
+ export const CreateCredentialsByDwgInputSchema: z.ZodObject<{
1276
+ issuer_auth_public_key: z.ZodString;
1277
+ original_encryptor_public_key: z.ZodString;
1278
+ original_credential_id: z.ZodUUID;
1279
+ original_content: z.ZodString;
1280
+ original_public_notes: z.ZodString;
1281
+ original_public_notes_signature: z.ZodString;
1282
+ original_broader_signature: z.ZodString;
1283
+ copy_encryptor_public_key: z.ZodString;
1284
+ copy_credential_id: z.ZodUUID;
1285
+ copy_content: z.ZodString;
1286
+ copy_public_notes_signature: z.ZodString;
1287
+ copy_broader_signature: z.ZodString;
1288
+ content_hash: z.ZodString;
1289
+ dwg_owner: z.ZodString;
1290
+ dwg_grantee: z.ZodString;
1291
+ dwg_issuer_public_key: z.ZodString;
1292
+ dwg_id: z.ZodUUID;
1293
+ dwg_access_grant_timelock: z.ZodString;
1294
+ dwg_not_before: z.ZodString;
1295
+ dwg_not_after: z.ZodString;
1296
+ dwg_signature: z.ZodString;
1297
+ }> = z.object({
1298
+ issuer_auth_public_key: z.string(),
1299
+ original_encryptor_public_key: z.string(),
1300
+ original_credential_id: z.uuid(),
1301
+ original_content: z.string(),
1302
+ original_public_notes: z.string(),
1303
+ original_public_notes_signature: z.string(),
1304
+ original_broader_signature: z.string(),
1305
+ copy_encryptor_public_key: z.string(),
1306
+ copy_credential_id: z.uuid(),
1307
+ copy_content: z.string(),
1308
+ copy_public_notes_signature: z.string(),
1309
+ copy_broader_signature: z.string(),
1310
+ content_hash: z.string(),
1311
+ dwg_owner: z.string(),
1312
+ dwg_grantee: z.string(),
1313
+ dwg_issuer_public_key: z.string(),
1314
+ dwg_id: z.uuid(),
1315
+ dwg_access_grant_timelock: z.string(),
1316
+ dwg_not_before: z.string(),
1317
+ dwg_not_after: z.string(),
1318
+ dwg_signature: z.string(),
1319
+ });
1320
+
1321
+ export type CreateCredentialsByDwgInput = z.infer<typeof CreateCredentialsByDwgInputSchema>;
1322
+
1323
+ /**
1324
+ * Delegated write credential actions
1325
+ * For access grant
1326
+ * Check the content creator (encryptor) of credentials is the issuer that user delegated to issue the credentials
1327
+ * Get the wallet type and public key for XRPL/NEAR wallets from database
1328
+ * Will fail if not in the RFC3339 format
1329
+ * Check the format and precedence
1330
+ * Check if current block timestamp in time range allowed by write grant.
1331
+ * @block_timestamp is a timestamp of previous block, which is can be a few seconds earlier
1332
+ * (max is 6 seconds in current network consensus settings) then a time on a requester's machine.
1333
+ * Also, if requester's machine has wrong time, it can be an issue.
1334
+ * Insert original credential
1335
+ * Insert copy credential
1336
+ */
1337
+ export async function createCredentialsByDwg(
1338
+ kwilClient: KwilActionClient,
1339
+ params: CreateCredentialsByDwgInput,
1340
+ ): Promise<void> {
1341
+ const inputs = CreateCredentialsByDwgInputSchema.parse(params);
1342
+ await kwilClient.execute({
1343
+ name: "create_credentials_by_dwg",
1344
+ inputs,
1345
+ description:
1346
+ "Add original credential and copy credential with AG on behalf of a user (using delegated write grant given by the user)",
1347
+ });
1348
+ }
1349
+
1350
+ export const CredentialExistAsInserterInputSchema: z.ZodObject<{
1351
+ id: z.ZodUUID;
1352
+ }> = z.object({
1353
+ id: z.uuid(),
1354
+ });
1355
+
1356
+ export type CredentialExistAsInserterInput = z.infer<typeof CredentialExistAsInserterInputSchema>;
1357
+
1358
+ export const CredentialExistAsInserterOutputSchema: z.ZodObject<{
1359
+ credential_exist: z.ZodBoolean;
1360
+ }> = z.object({
1361
+ credential_exist: z.boolean(),
1362
+ });
1363
+
1364
+ export type CredentialExistAsInserterOutput = z.infer<typeof CredentialExistAsInserterOutputSchema>;
1365
+
1366
+ export async function credentialExistAsInserter(
1367
+ kwilClient: KwilActionClient,
1368
+ params: CredentialExistAsInserterInput,
1369
+ ): Promise<CredentialExistAsInserterOutput> {
1370
+ const inputs = CredentialExistAsInserterInputSchema.parse(params);
1371
+ return await kwilClient
1372
+ .call<CredentialExistAsInserterOutput[]>({
1373
+ name: "credential_exist_as_inserter",
1374
+ inputs,
1375
+ })
1376
+ .then((result) => result[0]);
1377
+ }
1378
+
1379
+ export const GetCredentialOwnedInputSchema: z.ZodObject<{
1380
+ id: z.ZodUUID;
1381
+ }> = z.object({
1382
+ id: z.uuid(),
1383
+ });
1384
+
1385
+ export type GetCredentialOwnedInput = z.infer<typeof GetCredentialOwnedInputSchema>;
1386
+
1387
+ export const GetCredentialOwnedOutputSchema: z.ZodObject<{
1388
+ id: z.ZodUUID;
1389
+ user_id: z.ZodUUID;
1390
+ public_notes: z.ZodString;
1391
+ content: z.ZodString;
1392
+ encryptor_public_key: z.ZodString;
1393
+ issuer_auth_public_key: z.ZodString;
1394
+ inserter: z.ZodNullable<z.ZodString>;
1395
+ }> = z.object({
1396
+ id: z.uuid(),
1397
+ user_id: z.uuid(),
1398
+ public_notes: z.string(),
1399
+ content: z.string(),
1400
+ encryptor_public_key: z.string(),
1401
+ issuer_auth_public_key: z.string(),
1402
+ inserter: z.string().nullable(),
1403
+ });
1404
+
1405
+ export type GetCredentialOwnedOutput = z.infer<typeof GetCredentialOwnedOutputSchema>;
1406
+
1407
+ export async function getCredentialOwned(
1408
+ kwilClient: KwilActionClient,
1409
+ params: GetCredentialOwnedInput,
1410
+ ): Promise<GetCredentialOwnedOutput[]> {
1411
+ const inputs = GetCredentialOwnedInputSchema.parse(params);
1412
+ return await kwilClient.call<GetCredentialOwnedOutput[]>({
1413
+ name: "get_credential_owned",
1414
+ inputs,
1415
+ });
1416
+ }
1417
+
1418
+ export const GetCredentialSharedInputSchema: z.ZodObject<{
1419
+ id: z.ZodUUID;
1420
+ }> = z.object({
1421
+ id: z.uuid(),
1422
+ });
1423
+
1424
+ export type GetCredentialSharedInput = z.infer<typeof GetCredentialSharedInputSchema>;
1425
+
1426
+ export const GetCredentialSharedOutputSchema: z.ZodObject<{
1427
+ id: z.ZodUUID;
1428
+ user_id: z.ZodUUID;
1429
+ public_notes: z.ZodString;
1430
+ content: z.ZodString;
1431
+ encryptor_public_key: z.ZodString;
1432
+ issuer_auth_public_key: z.ZodString;
1433
+ inserter: z.ZodNullable<z.ZodString>;
1434
+ }> = z.object({
1435
+ id: z.uuid(),
1436
+ user_id: z.uuid(),
1437
+ public_notes: z.string(),
1438
+ content: z.string(),
1439
+ encryptor_public_key: z.string(),
1440
+ issuer_auth_public_key: z.string(),
1441
+ inserter: z.string().nullable(),
1442
+ });
1443
+
1444
+ export type GetCredentialSharedOutput = z.infer<typeof GetCredentialSharedOutputSchema>;
1445
+
1446
+ /** As a credential copy doesn't contain PUBLIC notes, we return respective original credential PUBLIC notes */
1447
+ export async function getCredentialShared(
1448
+ kwilClient: KwilActionClient,
1449
+ params: GetCredentialSharedInput,
1450
+ ): Promise<GetCredentialSharedOutput[]> {
1451
+ const inputs = GetCredentialSharedInputSchema.parse(params);
1452
+ return await kwilClient.call<GetCredentialSharedOutput[]>({
1453
+ name: "get_credential_shared",
1454
+ inputs,
1455
+ });
1456
+ }
1457
+
1458
+ export const GetSiblingCredentialIdInputSchema: z.ZodObject<{
1459
+ content_hash: z.ZodString;
1460
+ }> = z.object({
1461
+ content_hash: z.string(),
1462
+ });
1463
+
1464
+ export type GetSiblingCredentialIdInput = z.infer<typeof GetSiblingCredentialIdInputSchema>;
1465
+
1466
+ export const GetSiblingCredentialIdOutputSchema: z.ZodObject<{
1467
+ id: z.ZodUUID;
1468
+ }> = z.object({
1469
+ id: z.uuid(),
1470
+ });
1471
+
1472
+ export type GetSiblingCredentialIdOutput = z.infer<typeof GetSiblingCredentialIdOutputSchema>;
1473
+
1474
+ export async function getSiblingCredentialId(
1475
+ kwilClient: KwilActionClient,
1476
+ params: GetSiblingCredentialIdInput,
1477
+ ): Promise<GetSiblingCredentialIdOutput> {
1478
+ const inputs = GetSiblingCredentialIdInputSchema.parse(params);
1479
+ return await kwilClient
1480
+ .call<GetSiblingCredentialIdOutput[]>({
1481
+ name: "get_sibling_credential_id",
1482
+ inputs,
1483
+ })
1484
+ .then((result) => result[0]);
1485
+ }
1486
+
1487
+ export const AddAttributeAsInserterInputSchema: z.ZodObject<{
1488
+ id: z.ZodUUID;
1489
+ user_id: z.ZodUUID;
1490
+ attribute_key: z.ZodString;
1491
+ value: z.ZodString;
1492
+ }> = z.object({
1493
+ id: z.uuid(),
1494
+ user_id: z.uuid(),
1495
+ attribute_key: z.string(),
1496
+ value: z.string(),
1497
+ });
1498
+
1499
+ export type AddAttributeAsInserterInput = z.infer<typeof AddAttributeAsInserterInputSchema>;
1500
+
1501
+ /** ATTRIBUTE ACTIONS */
1502
+ export async function addAttributeAsInserter(
1503
+ kwilClient: KwilActionClient,
1504
+ params: AddAttributeAsInserterInput,
1505
+ ): Promise<void> {
1506
+ const inputs = AddAttributeAsInserterInputSchema.parse(params);
1507
+ await kwilClient.execute({
1508
+ name: "add_attribute_as_inserter",
1509
+ inputs,
1510
+ description: "Add a new attribute as inserter",
1511
+ });
1512
+ }
1513
+
1514
+ export const AddAttributeInputSchema: z.ZodObject<{
1515
+ id: z.ZodUUID;
1516
+ attribute_key: z.ZodString;
1517
+ value: z.ZodString;
1518
+ }> = z.object({
1519
+ id: z.uuid(),
1520
+ attribute_key: z.string(),
1521
+ value: z.string(),
1522
+ });
1523
+
1524
+ export type AddAttributeInput = z.infer<typeof AddAttributeInputSchema>;
1525
+
1526
+ export async function addAttribute(
1527
+ kwilClient: KwilActionClient,
1528
+ params: AddAttributeInput,
1529
+ ): Promise<void> {
1530
+ const inputs = AddAttributeInputSchema.parse(params);
1531
+ await kwilClient.execute({
1532
+ name: "add_attribute",
1533
+ inputs,
1534
+ description: "Create a new attribute in your idOS profile",
1535
+ });
1536
+ }
1537
+
1538
+ export const GetAttributesOutputSchema: z.ZodObject<{
1539
+ id: z.ZodUUID;
1540
+ user_id: z.ZodUUID;
1541
+ attribute_key: z.ZodString;
1542
+ value: z.ZodString;
1543
+ original_id: z.ZodUUID;
1544
+ }> = z.object({
1545
+ id: z.uuid(),
1546
+ user_id: z.uuid(),
1547
+ attribute_key: z.string(),
1548
+ value: z.string(),
1549
+ original_id: z.uuid(),
1550
+ });
1551
+
1552
+ export type GetAttributesOutput = z.infer<typeof GetAttributesOutputSchema>;
1553
+
1554
+ export async function getAttributes(kwilClient: KwilActionClient): Promise<GetAttributesOutput[]> {
1555
+ return await kwilClient.call<GetAttributesOutput[]>({
1556
+ name: "get_attributes",
1557
+ inputs: {},
1558
+ });
1559
+ }
1560
+
1561
+ export const EditAttributeInputSchema: z.ZodObject<{
1562
+ id: z.ZodUUID;
1563
+ attribute_key: z.ZodString;
1564
+ value: z.ZodString;
1565
+ }> = z.object({
1566
+ id: z.uuid(),
1567
+ attribute_key: z.string(),
1568
+ value: z.string(),
1569
+ });
1570
+
1571
+ export type EditAttributeInput = z.infer<typeof EditAttributeInputSchema>;
1572
+
1573
+ export async function editAttribute(
1574
+ kwilClient: KwilActionClient,
1575
+ params: EditAttributeInput,
1576
+ ): Promise<void> {
1577
+ const inputs = EditAttributeInputSchema.parse(params);
1578
+ await kwilClient.execute({
1579
+ name: "edit_attribute",
1580
+ inputs,
1581
+ description: "Edit an existing attribute",
1582
+ });
1583
+ }
1584
+
1585
+ export const RemoveAttributeInputSchema: z.ZodObject<{
1586
+ id: z.ZodUUID;
1587
+ }> = z.object({
1588
+ id: z.uuid(),
1589
+ });
1590
+
1591
+ export type RemoveAttributeInput = z.infer<typeof RemoveAttributeInputSchema>;
1592
+
1593
+ export async function removeAttribute(
1594
+ kwilClient: KwilActionClient,
1595
+ params: RemoveAttributeInput,
1596
+ ): Promise<void> {
1597
+ const inputs = RemoveAttributeInputSchema.parse(params);
1598
+ await kwilClient.execute({
1599
+ name: "remove_attribute",
1600
+ inputs,
1601
+ description: "Remove an existing attribute",
1602
+ });
1603
+ }
1604
+
1605
+ export const ShareAttributeInputSchema: z.ZodObject<{
1606
+ id: z.ZodUUID;
1607
+ original_attribute_id: z.ZodUUID;
1608
+ attribute_key: z.ZodString;
1609
+ value: z.ZodString;
1610
+ }> = z.object({
1611
+ id: z.uuid(),
1612
+ original_attribute_id: z.uuid(),
1613
+ attribute_key: z.string(),
1614
+ value: z.string(),
1615
+ });
1616
+
1617
+ export type ShareAttributeInput = z.infer<typeof ShareAttributeInputSchema>;
1618
+
1619
+ export async function shareAttribute(
1620
+ kwilClient: KwilActionClient,
1621
+ params: ShareAttributeInput,
1622
+ ): Promise<void> {
1623
+ const inputs = ShareAttributeInputSchema.parse(params);
1624
+ await kwilClient.execute({
1625
+ name: "share_attribute",
1626
+ inputs,
1627
+ description: "Share an attribute",
1628
+ });
1629
+ }
1630
+
1631
+ export const DwgMessageInputSchema: z.ZodObject<{
1632
+ owner_wallet_identifier: z.ZodString;
1633
+ grantee_wallet_identifier: z.ZodString;
1634
+ issuer_public_key: z.ZodString;
1635
+ id: z.ZodUUID;
1636
+ access_grant_timelock: z.ZodString;
1637
+ not_usable_before: z.ZodString;
1638
+ not_usable_after: z.ZodString;
1639
+ }> = z.object({
1640
+ owner_wallet_identifier: z.string(),
1641
+ grantee_wallet_identifier: z.string(),
1642
+ issuer_public_key: z.string(),
1643
+ id: z.uuid(),
1644
+ access_grant_timelock: z.string(),
1645
+ not_usable_before: z.string(),
1646
+ not_usable_after: z.string(),
1647
+ });
1648
+
1649
+ export type DwgMessageInput = z.infer<typeof DwgMessageInputSchema>;
1650
+
1651
+ export const DwgMessageOutputSchema: z.ZodObject<{
1652
+ message: z.ZodString;
1653
+ }> = z.object({
1654
+ message: z.string(),
1655
+ });
1656
+
1657
+ export type DwgMessageOutput = z.infer<typeof DwgMessageOutputSchema>;
1658
+
1659
+ /**
1660
+ * WRITE GRANTS ACTIONS
1661
+ * Must be in yyyy-mm-ddThh:mm:ssZ format
1662
+ * Must be in yyyy-mm-ddThh:mm:ssZ format
1663
+ * Must be in yyyy-mm-ddThh:mm:ssZ format
1664
+ * Will fail if not in the yyyy-mm-ddThh:mm:ssZ format, and not comply to RFC3339
1665
+ * Check the format and precedence
1666
+ */
1667
+ export async function dwgMessage(
1668
+ kwilClient: KwilActionClient,
1669
+ params: DwgMessageInput,
1670
+ ): Promise<DwgMessageOutput> {
1671
+ const inputs = DwgMessageInputSchema.parse(params);
1672
+ return await kwilClient
1673
+ .call<DwgMessageOutput[]>({
1674
+ name: "dwg_message",
1675
+ inputs,
1676
+ })
1677
+ .then((result) => result[0]);
1678
+ }
1679
+
1680
+ export const RevokeAccessGrantInputSchema: z.ZodObject<{
1681
+ id: z.ZodUUID;
1682
+ }> = z.object({
1683
+ id: z.uuid(),
1684
+ });
1685
+
1686
+ export type RevokeAccessGrantInput = z.infer<typeof RevokeAccessGrantInputSchema>;
1687
+
1688
+ /** ACCESS GRANTS ACTIONS */
1689
+ export async function revokeAccessGrant(
1690
+ kwilClient: KwilActionClient,
1691
+ params: RevokeAccessGrantInput,
1692
+ ): Promise<void> {
1693
+ const inputs = RevokeAccessGrantInputSchema.parse(params);
1694
+ await kwilClient.execute({
1695
+ name: "revoke_access_grant",
1696
+ inputs,
1697
+ description: "Revoke an Access Grant from idOS",
1698
+ });
1699
+ }
1700
+
1701
+ export const GetAccessGrantsOwnedOutputSchema: z.ZodObject<{
1702
+ id: z.ZodUUID;
1703
+ ag_owner_user_id: z.ZodUUID;
1704
+ ag_grantee_wallet_identifier: z.ZodString;
1705
+ data_id: z.ZodUUID;
1706
+ locked_until: z.ZodNumber;
1707
+ content_hash: z.ZodNullable<z.ZodString>;
1708
+ inserter_type: z.ZodString;
1709
+ inserter_id: z.ZodString;
1710
+ }> = z.object({
1711
+ id: z.uuid(),
1712
+ ag_owner_user_id: z.uuid(),
1713
+ ag_grantee_wallet_identifier: z.string(),
1714
+ data_id: z.uuid(),
1715
+ locked_until: z.number(),
1716
+ content_hash: z.string().nullable(),
1717
+ inserter_type: z.string(),
1718
+ inserter_id: z.string(),
1719
+ });
1720
+
1721
+ export type GetAccessGrantsOwnedOutput = z.infer<typeof GetAccessGrantsOwnedOutputSchema>;
1722
+
1723
+ export async function getAccessGrantsOwned(
1724
+ kwilClient: KwilActionClient,
1725
+ ): Promise<GetAccessGrantsOwnedOutput[]> {
1726
+ return await kwilClient.call<GetAccessGrantsOwnedOutput[]>({
1727
+ name: "get_access_grants_owned",
1728
+ inputs: {},
1729
+ });
1730
+ }
1731
+
1732
+ export const GetAccessGrantsGrantedInputSchema: z.ZodObject<{
1733
+ user_id: z.ZodNullable<z.ZodUUID>;
1734
+ page: z.ZodNumber;
1735
+ size: z.ZodNumber;
1736
+ }> = z.object({
1737
+ user_id: z.uuid().nullable(),
1738
+ page: z.number(),
1739
+ size: z.number(),
1740
+ });
1741
+
1742
+ export type GetAccessGrantsGrantedInput = z.infer<typeof GetAccessGrantsGrantedInputSchema>;
1743
+
1744
+ export const GetAccessGrantsGrantedOutputSchema: z.ZodObject<{
1745
+ id: z.ZodUUID;
1746
+ ag_owner_user_id: z.ZodUUID;
1747
+ ag_grantee_wallet_identifier: z.ZodString;
1748
+ data_id: z.ZodUUID;
1749
+ locked_until: z.ZodNumber;
1750
+ content_hash: z.ZodNullable<z.ZodString>;
1751
+ inserter_type: z.ZodString;
1752
+ inserter_id: z.ZodString;
1753
+ }> = z.object({
1754
+ id: z.uuid(),
1755
+ ag_owner_user_id: z.uuid(),
1756
+ ag_grantee_wallet_identifier: z.string(),
1757
+ data_id: z.uuid(),
1758
+ locked_until: z.number(),
1759
+ content_hash: z.string().nullable(),
1760
+ inserter_type: z.string(),
1761
+ inserter_id: z.string(),
1762
+ });
1763
+
1764
+ export type GetAccessGrantsGrantedOutput = z.infer<typeof GetAccessGrantsGrantedOutputSchema>;
1765
+
1766
+ /**
1767
+ * As arguments can be undefined (user can not send them at all), we have to have default values: page=1, size=20
1768
+ * Page number starts from 1, as UI usually shows to user in pagination element
1769
+ * Ordering is consistent because we use height as first ordering parameter
1770
+ */
1771
+ export async function getAccessGrantsGranted(
1772
+ kwilClient: KwilActionClient,
1773
+ params: GetAccessGrantsGrantedInput,
1774
+ ): Promise<GetAccessGrantsGrantedOutput[]> {
1775
+ const inputs = GetAccessGrantsGrantedInputSchema.parse(params);
1776
+ return await kwilClient.call<GetAccessGrantsGrantedOutput[]>({
1777
+ name: "get_access_grants_granted",
1778
+ inputs,
1779
+ });
1780
+ }
1781
+
1782
+ export const GetAccessGrantsGrantedCountInputSchema: z.ZodObject<{
1783
+ user_id: z.ZodNullable<z.ZodUUID>;
1784
+ }> = z.object({
1785
+ user_id: z.uuid().nullable(),
1786
+ });
1787
+
1788
+ export type GetAccessGrantsGrantedCountInput = z.infer<
1789
+ typeof GetAccessGrantsGrantedCountInputSchema
1790
+ >;
1791
+
1792
+ export const GetAccessGrantsGrantedCountOutputSchema: z.ZodObject<{
1793
+ count: z.ZodNumber;
1794
+ }> = z.object({
1795
+ count: z.number(),
1796
+ });
1797
+
1798
+ export type GetAccessGrantsGrantedCountOutput = z.infer<
1799
+ typeof GetAccessGrantsGrantedCountOutputSchema
1800
+ >;
1801
+
1802
+ export async function getAccessGrantsGrantedCount(
1803
+ kwilClient: KwilActionClient,
1804
+ params: GetAccessGrantsGrantedCountInput,
1805
+ ): Promise<GetAccessGrantsGrantedCountOutput> {
1806
+ const inputs = GetAccessGrantsGrantedCountInputSchema.parse(params);
1807
+ return await kwilClient
1808
+ .call<GetAccessGrantsGrantedCountOutput[]>({
1809
+ name: "get_access_grants_granted_count",
1810
+ inputs,
1811
+ })
1812
+ .then((result) => result[0]);
1813
+ }
1814
+
1815
+ export const HasLockedAccessGrantsInputSchema: z.ZodObject<{
1816
+ id: z.ZodUUID;
1817
+ }> = z.object({
1818
+ id: z.uuid(),
1819
+ });
1820
+
1821
+ export type HasLockedAccessGrantsInput = z.infer<typeof HasLockedAccessGrantsInputSchema>;
1822
+
1823
+ export const HasLockedAccessGrantsOutputSchema: z.ZodObject<{
1824
+ has: z.ZodBoolean;
1825
+ }> = z.object({
1826
+ has: z.boolean(),
1827
+ });
1828
+
1829
+ export type HasLockedAccessGrantsOutput = z.infer<typeof HasLockedAccessGrantsOutputSchema>;
1830
+
1831
+ export async function hasLockedAccessGrants(
1832
+ kwilClient: KwilActionClient,
1833
+ params: HasLockedAccessGrantsInput,
1834
+ ): Promise<HasLockedAccessGrantsOutput> {
1835
+ const inputs = HasLockedAccessGrantsInputSchema.parse(params);
1836
+ return await kwilClient
1837
+ .call<HasLockedAccessGrantsOutput[]>({
1838
+ name: "has_locked_access_grants",
1839
+ inputs,
1840
+ })
1841
+ .then((result) => result[0]);
1842
+ }
1843
+
1844
+ export const DagMessageInputSchema: z.ZodObject<{
1845
+ dag_owner_wallet_identifier: z.ZodString;
1846
+ dag_grantee_wallet_identifier: z.ZodString;
1847
+ dag_data_id: z.ZodUUID;
1848
+ dag_locked_until: z.ZodNumber;
1849
+ dag_content_hash: z.ZodString;
1850
+ }> = z.object({
1851
+ dag_owner_wallet_identifier: z.string(),
1852
+ dag_grantee_wallet_identifier: z.string(),
1853
+ dag_data_id: z.uuid(),
1854
+ dag_locked_until: z.number(),
1855
+ dag_content_hash: z.string(),
1856
+ });
1857
+
1858
+ export type DagMessageInput = z.infer<typeof DagMessageInputSchema>;
1859
+
1860
+ export const DagMessageOutputSchema: z.ZodObject<{
1861
+ message: z.ZodString;
1862
+ }> = z.object({
1863
+ message: z.string(),
1864
+ });
1865
+
1866
+ export type DagMessageOutput = z.infer<typeof DagMessageOutputSchema>;
1867
+
1868
+ export async function dagMessage(
1869
+ kwilClient: KwilActionClient,
1870
+ params: DagMessageInput,
1871
+ ): Promise<DagMessageOutput> {
1872
+ const inputs = DagMessageInputSchema.parse(params);
1873
+ return await kwilClient
1874
+ .call<DagMessageOutput[]>({
1875
+ name: "dag_message",
1876
+ inputs,
1877
+ })
1878
+ .then((result) => result[0]);
1879
+ }
1880
+
1881
+ export const CreateAgByDagForCopyInputSchema: z.ZodObject<{
1882
+ dag_owner_wallet_identifier: z.ZodString;
1883
+ dag_grantee_wallet_identifier: z.ZodString;
1884
+ dag_data_id: z.ZodUUID;
1885
+ dag_locked_until: z.ZodNumber;
1886
+ dag_content_hash: z.ZodString;
1887
+ dag_signature: z.ZodString;
1888
+ }> = z.object({
1889
+ dag_owner_wallet_identifier: z.string(),
1890
+ dag_grantee_wallet_identifier: z.string(),
1891
+ dag_data_id: z.uuid(),
1892
+ dag_locked_until: z.number(),
1893
+ dag_content_hash: z.string(),
1894
+ dag_signature: z.string(),
1895
+ });
1896
+
1897
+ export type CreateAgByDagForCopyInput = z.infer<typeof CreateAgByDagForCopyInputSchema>;
1898
+
1899
+ /**
1900
+ * Get the wallet type and public key for XRPL/NEAR wallets from database
1901
+ * This works for EVM-compatible signatures only
1902
+ */
1903
+ export async function createAgByDagForCopy(
1904
+ kwilClient: KwilActionClient,
1905
+ params: CreateAgByDagForCopyInput,
1906
+ ): Promise<void> {
1907
+ const inputs = CreateAgByDagForCopyInputSchema.parse(params);
1908
+ await kwilClient.execute({
1909
+ name: "create_ag_by_dag_for_copy",
1910
+ inputs,
1911
+ description: "Create an Access Grant in idOS",
1912
+ });
1913
+ }
1914
+
1915
+ export const GetAccessGrantsForCredentialInputSchema: z.ZodObject<{
1916
+ credential_id: z.ZodUUID;
1917
+ }> = z.object({
1918
+ credential_id: z.uuid(),
1919
+ });
1920
+
1921
+ export type GetAccessGrantsForCredentialInput = z.infer<
1922
+ typeof GetAccessGrantsForCredentialInputSchema
1923
+ >;
1924
+
1925
+ export const GetAccessGrantsForCredentialOutputSchema: z.ZodObject<{
1926
+ id: z.ZodUUID;
1927
+ ag_owner_user_id: z.ZodUUID;
1928
+ ag_grantee_wallet_identifier: z.ZodString;
1929
+ data_id: z.ZodUUID;
1930
+ locked_until: z.ZodNumber;
1931
+ content_hash: z.ZodNullable<z.ZodString>;
1932
+ inserter_type: z.ZodString;
1933
+ inserter_id: z.ZodString;
1934
+ }> = z.object({
1935
+ id: z.uuid(),
1936
+ ag_owner_user_id: z.uuid(),
1937
+ ag_grantee_wallet_identifier: z.string(),
1938
+ data_id: z.uuid(),
1939
+ locked_until: z.number(),
1940
+ content_hash: z.string().nullable(),
1941
+ inserter_type: z.string(),
1942
+ inserter_id: z.string(),
1943
+ });
1944
+
1945
+ export type GetAccessGrantsForCredentialOutput = z.infer<
1946
+ typeof GetAccessGrantsForCredentialOutputSchema
1947
+ >;
1948
+
1949
+ export async function getAccessGrantsForCredential(
1950
+ kwilClient: KwilActionClient,
1951
+ params: GetAccessGrantsForCredentialInput,
1952
+ ): Promise<GetAccessGrantsForCredentialOutput[]> {
1953
+ const inputs = GetAccessGrantsForCredentialInputSchema.parse(params);
1954
+ return await kwilClient.call<GetAccessGrantsForCredentialOutput[]>({
1955
+ name: "get_access_grants_for_credential",
1956
+ inputs,
1957
+ });
1958
+ }
1959
+
1960
+ export const HasProfileInputSchema: z.ZodObject<{
1961
+ address: z.ZodString;
1962
+ }> = z.object({
1963
+ address: z.string(),
1964
+ });
1965
+
1966
+ export type HasProfileInput = z.infer<typeof HasProfileInputSchema>;
1967
+
1968
+ export const HasProfileOutputSchema: z.ZodObject<{
1969
+ has_profile: z.ZodBoolean;
1970
+ }> = z.object({
1971
+ has_profile: z.boolean(),
1972
+ });
1973
+
1974
+ export type HasProfileOutput = z.infer<typeof HasProfileOutputSchema>;
1975
+
1976
+ /**
1977
+ * OTHER ACTIONS
1978
+ * Should we improve it to work with near wallets too?
1979
+ */
1980
+ export async function hasProfile(
1981
+ kwilClient: KwilActionClient,
1982
+ params: HasProfileInput,
1983
+ ): Promise<HasProfileOutput> {
1984
+ const inputs = HasProfileInputSchema.parse(params);
1985
+ return await kwilClient
1986
+ .call<HasProfileOutput[]>(
1987
+ {
1988
+ name: "has_profile",
1989
+ inputs,
1990
+ },
1991
+ undefined, // Signer is not required here
1992
+ )
1993
+ .then((result) => result[0]);
1994
+ }
1995
+
1996
+ export const CheckBalanceInputSchema: z.ZodObject<{
1997
+ address: z.ZodString;
1998
+ token: z.ZodString;
1999
+ }> = z.object({
2000
+ address: z.string(),
2001
+ token: z.string(),
2002
+ });
2003
+
2004
+ export type CheckBalanceInput = z.infer<typeof CheckBalanceInputSchema>;
2005
+
2006
+ export const CheckBalanceOutputSchema: z.ZodObject<{
2007
+ balance: z.ZodNumber;
2008
+ }> = z.object({
2009
+ balance: z.number(),
2010
+ });
2011
+
2012
+ export type CheckBalanceOutput = z.infer<typeof CheckBalanceOutputSchema>;
2013
+
2014
+ /** GAS AND FEES */
2015
+ export async function checkBalance(
2016
+ kwilClient: KwilActionClient,
2017
+ params: CheckBalanceInput,
2018
+ ): Promise<CheckBalanceOutput> {
2019
+ const inputs = CheckBalanceInputSchema.parse(params);
2020
+ return await kwilClient
2021
+ .call<CheckBalanceOutput[]>({
2022
+ name: "check_balance",
2023
+ inputs,
2024
+ })
2025
+ .then((result) => result[0]);
2026
+ }
2027
+
2028
+ export const GetWalletWithBalanceInputSchema: z.ZodObject<{
2029
+ token: z.ZodString;
2030
+ }> = z.object({
2031
+ token: z.string(),
2032
+ });
2033
+
2034
+ export type GetWalletWithBalanceInput = z.infer<typeof GetWalletWithBalanceInputSchema>;
2035
+
2036
+ export const GetWalletWithBalanceOutputSchema: z.ZodObject<{
2037
+ wallet_address: z.ZodString;
2038
+ }> = z.object({
2039
+ wallet_address: z.string(),
2040
+ });
2041
+
2042
+ export type GetWalletWithBalanceOutput = z.infer<typeof GetWalletWithBalanceOutputSchema>;
2043
+
2044
+ /**
2045
+ * even if the @caller is not EVM address, there is no harm to try to get the balance, it will return nothing
2046
+ * because bridge.balance can only have records with EVM addresses (it is filled from EVM-compatible contract events)
2047
+ */
2048
+ export async function getWalletWithBalance(
2049
+ kwilClient: KwilActionClient,
2050
+ params: GetWalletWithBalanceInput,
2051
+ ): Promise<GetWalletWithBalanceOutput> {
2052
+ const inputs = GetWalletWithBalanceInputSchema.parse(params);
2053
+ return await kwilClient
2054
+ .call<GetWalletWithBalanceOutput[]>({
2055
+ name: "get_wallet_with_balance",
2056
+ inputs,
2057
+ })
2058
+ .then((result) => result[0]);
2059
+ }
2060
+
2061
+ export const RequestWithdrawalInputSchema: z.ZodObject<{
2062
+ token: z.ZodString;
2063
+ }> = z.object({
2064
+ token: z.string(),
2065
+ });
2066
+
2067
+ export type RequestWithdrawalInput = z.infer<typeof RequestWithdrawalInputSchema>;
2068
+
2069
+ /** we use lock_admin()+issue() because bridge() is tied to @caller */
2070
+ export async function requestWithdrawal(
2071
+ kwilClient: KwilActionClient,
2072
+ params: RequestWithdrawalInput,
2073
+ ): Promise<void> {
2074
+ const inputs = RequestWithdrawalInputSchema.parse(params);
2075
+ await kwilClient.execute({
2076
+ name: "request_withdrawal",
2077
+ inputs,
2078
+ description: "Request a withdrawal of all tokens from idOS to user's EVM wallet",
2079
+ });
2080
+ }
2081
+
2082
+ export const GetAllowanceOutputSchema: z.ZodObject<{
2083
+ gas_allowance: z.ZodNumber;
2084
+ }> = z.object({
2085
+ gas_allowance: z.number(),
2086
+ });
2087
+
2088
+ export type GetAllowanceOutput = z.infer<typeof GetAllowanceOutputSchema>;
2089
+
2090
+ /** FaceSign should not be able to call this */
2091
+ export async function getAllowance(kwilClient: KwilActionClient): Promise<GetAllowanceOutput> {
2092
+ return await kwilClient
2093
+ .call<GetAllowanceOutput[]>({
2094
+ name: "get_allowance",
2095
+ inputs: {},
2096
+ })
2097
+ .then((result) => result[0]);
2098
+ }
2099
+
2100
+ export async function actionCostingGas(kwilClient: KwilActionClient): Promise<void> {
2101
+ await kwilClient.execute({
2102
+ name: "action_costing_gas",
2103
+ inputs: {},
2104
+ description: "Get cost of action for 1.2 gas",
2105
+ });
2106
+ }
2107
+
2108
+ export const ActionCostingIdosTokenInputSchema: z.ZodObject<{
2109
+ amount: z.ZodNumber;
2110
+ }> = z.object({
2111
+ amount: z.number(),
2112
+ });
2113
+
2114
+ export type ActionCostingIdosTokenInput = z.infer<typeof ActionCostingIdosTokenInputSchema>;
2115
+
2116
+ export async function actionCostingIdosToken(
2117
+ kwilClient: KwilActionClient,
2118
+ params: ActionCostingIdosTokenInput,
2119
+ ): Promise<void> {
2120
+ const inputs = ActionCostingIdosTokenInputSchema.parse(params);
2121
+ await kwilClient.execute({
2122
+ name: "action_costing_idos_token",
2123
+ inputs,
2124
+ description: "Action that captures IDOS tokens from the caller",
2125
+ });
2126
+ }
2127
+
2128
+ export const GetIssuerFeeInputSchema: z.ZodObject<{
2129
+ credential_id: z.ZodUUID;
2130
+ }> = z.object({
2131
+ credential_id: z.uuid(),
2132
+ });
2133
+
2134
+ export type GetIssuerFeeInput = z.infer<typeof GetIssuerFeeInputSchema>;
2135
+
2136
+ export const GetIssuerFeeOutputSchema: z.ZodObject<{
2137
+ issuer_fee: z.ZodNumber;
2138
+ }> = z.object({
2139
+ issuer_fee: z.number(),
2140
+ });
2141
+
2142
+ export type GetIssuerFeeOutput = z.infer<typeof GetIssuerFeeOutputSchema>;
2143
+
2144
+ export async function getIssuerFee(
2145
+ kwilClient: KwilActionClient,
2146
+ params: GetIssuerFeeInput,
2147
+ ): Promise<GetIssuerFeeOutput> {
2148
+ const inputs = GetIssuerFeeInputSchema.parse(params);
2149
+ return await kwilClient
2150
+ .call<GetIssuerFeeOutput[]>({
2151
+ name: "get_issuer_fee",
2152
+ inputs,
2153
+ })
2154
+ .then((result) => result[0]);
2155
+ }
2156
+
2157
+ export const ActionCostingFeeInputSchema: z.ZodObject<{
2158
+ credential_id: z.ZodUUID;
2159
+ }> = z.object({
2160
+ credential_id: z.uuid(),
2161
+ });
2162
+
2163
+ export type ActionCostingFeeInput = z.infer<typeof ActionCostingFeeInputSchema>;
2164
+
2165
+ export async function actionCostingFee(
2166
+ kwilClient: KwilActionClient,
2167
+ params: ActionCostingFeeInput,
2168
+ ): Promise<void> {
2169
+ const inputs = ActionCostingFeeInputSchema.parse(params);
2170
+ await kwilClient.execute({
2171
+ name: "action_costing_fee",
2172
+ inputs,
2173
+ description: "Capture fee from credentials",
2174
+ });
2175
+ }
2176
+
2177
+ export const RequestBalanceWithdrawalInputSchema: z.ZodObject<{
2178
+ token: z.ZodString;
2179
+ evm_address_to: z.ZodString;
2180
+ }> = z.object({
2181
+ token: z.string(),
2182
+ evm_address_to: z.string(),
2183
+ });
2184
+
2185
+ export type RequestBalanceWithdrawalInput = z.infer<typeof RequestBalanceWithdrawalInputSchema>;
2186
+
2187
+ export async function requestBalanceWithdrawal(
2188
+ kwilClient: KwilActionClient,
2189
+ params: RequestBalanceWithdrawalInput,
2190
+ ): Promise<void> {
2191
+ const inputs = RequestBalanceWithdrawalInputSchema.parse(params);
2192
+ await kwilClient.execute({
2193
+ name: "request_balance_withdrawal",
2194
+ inputs,
2195
+ description: "Request a withdrawal of all tokens from idOS to specified EVM address",
2196
+ });
2197
+ }