@idos-network/kwil-infra 1.5.0 → 2.2.2

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 (54) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +46 -1
  3. package/dist/actions/index.d.mts +2 -2
  4. package/dist/actions/index.mjs +1 -1370
  5. package/dist/actions/index.mjs.map +1 -1
  6. package/dist/facesign/index.d.mts +1 -1
  7. package/dist/facesign/index.mjs +1 -2
  8. package/dist/{facesign-signer-BC24j1eN.d.mts → facesign-signer-5I8juA7p.d.mts} +2 -1
  9. package/dist/facesign-signer-5I8juA7p.d.mts.map +1 -0
  10. package/dist/facesign-signer-z5T312uQ.mjs +2 -0
  11. package/dist/facesign-signer-z5T312uQ.mjs.map +1 -0
  12. package/dist/{index-iqkJfgWf.d.mts → index-Bqz6trCk.d.mts} +223 -136
  13. package/dist/index-Bqz6trCk.d.mts.map +1 -0
  14. package/dist/index.d.mts +2 -2
  15. package/dist/index.mjs +1 -429
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/signature-verification/index.d.mts +3 -4
  18. package/dist/signature-verification/index.d.mts.map +1 -1
  19. package/dist/signature-verification/index.mjs +1 -134
  20. package/dist/signature-verification/index.mjs.map +1 -1
  21. package/dist/xrp/utils.d.mts +130 -20
  22. package/dist/xrp/utils.d.mts.map +1 -1
  23. package/dist/xrp/utils.mjs +1 -104
  24. package/dist/xrp/utils.mjs.map +1 -1
  25. package/dist/xrpl-credentials/index.d.mts +6 -7
  26. package/dist/xrpl-credentials/index.d.mts.map +1 -1
  27. package/dist/xrpl-credentials/index.mjs +1 -223
  28. package/dist/xrpl-credentials/index.mjs.map +1 -1
  29. package/package.json +9 -8
  30. package/src/actions/actions.test.ts +189 -0
  31. package/src/actions/actions.ts +368 -467
  32. package/src/actions/index.ts +38 -0
  33. package/src/create-kgw-authenticated-fetch.test.ts +377 -0
  34. package/src/create-kgw-authenticated-fetch.ts +321 -0
  35. package/src/create-kwil-client.ts +33 -10
  36. package/src/create-kwil-signer.test.ts +80 -0
  37. package/src/create-kwil-signer.ts +31 -5
  38. package/src/facesign/facesign-signer.test.ts +77 -0
  39. package/src/facesign/facesign-signer.ts +50 -2
  40. package/src/index.ts +2 -0
  41. package/src/mm-token/create-mm-token-kwil-signer.test.ts +148 -0
  42. package/src/mm-token/create-mm-token-kwil-signer.ts +166 -0
  43. package/src/near/create-near-wallet-kwil-signer.ts +1 -1
  44. package/src/signature-verification/index.test.ts +18 -0
  45. package/src/signature-verification/index.ts +7 -1
  46. package/src/wait-for-kwil-tx.test.ts +92 -0
  47. package/src/wait-for-kwil-tx.ts +111 -0
  48. package/src/xrp/signer.ts +2 -1
  49. package/src/xrp/utils.ts +7 -25
  50. package/tsdown.config.ts +1 -0
  51. package/dist/facesign-signer-BC24j1eN.d.mts.map +0 -1
  52. package/dist/facesign-signer-qzCcwunk.mjs +0 -244
  53. package/dist/facesign-signer-qzCcwunk.mjs.map +0 -1
  54. package/dist/index-iqkJfgWf.d.mts.map +0 -1
@@ -3,20 +3,33 @@ import * as z from "zod";
3
3
 
4
4
  import type { KwilActionClient } from "../";
5
5
 
6
+ // Any changes you make will be overwritten.
6
7
  // This file is generated by the generator. Do not edit it manually.
8
+ // WARNING:
7
9
  export const DataType: typeof Utils.DataType = Utils.DataType;
8
- export const WALLET_TYPES = ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign"] as const;
10
+ export const WALLET_TYPES = ["EVM", "NEAR", "XRPL", "Stellar", "FaceSign", "MM"] as const;
9
11
 
10
12
  export type WalletType = (typeof WALLET_TYPES)[number];
11
13
 
12
14
  export const walletTypeSchema: z.ZodType<WalletType> = z.enum(WALLET_TYPES);
13
- export const ENCRYPTION_PASSWORD_STORES = ["user", "mpc"] as const;
15
+ export const ENCRYPTION_PASSWORD_STORES = ["user", "mpc", "mm"] as const;
14
16
 
15
17
  export type EncryptionPasswordStore = (typeof ENCRYPTION_PASSWORD_STORES)[number];
16
18
 
17
19
  export const encryptionPasswordStoreSchema: z.ZodType<EncryptionPasswordStore> = z.enum(
18
20
  ENCRYPTION_PASSWORD_STORES,
19
21
  );
22
+ const IPFS_URI_PREFIX = "ipfs://",
23
+ UKYC_URI_PREFIX = "ukyc://";
24
+ const blobContentUriSchema = z
25
+ .string()
26
+ .refine(
27
+ (value) => value.startsWith(IPFS_URI_PREFIX) || value.startsWith(UKYC_URI_PREFIX),
28
+ `content_uri must start with ${IPFS_URI_PREFIX} or ${UKYC_URI_PREFIX}`,
29
+ );
30
+
31
+ const contentSizeSchema = z.number().int().positive();
32
+ const rfc3339DateTimeSchema = z.iso.datetime({ precision: 0 });
20
33
 
21
34
  export type ActionSchemaElement = {
22
35
  name: string;
@@ -24,38 +37,6 @@ export type ActionSchemaElement = {
24
37
  };
25
38
 
26
39
  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
40
  add_user_as_inserter: [
60
41
  {
61
42
  name: "id",
@@ -113,25 +94,21 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
113
94
  type: DataType.Text,
114
95
  },
115
96
  {
116
- name: "message",
97
+ name: "not_before",
117
98
  type: DataType.Text,
118
99
  },
119
100
  {
120
- name: "signature",
101
+ name: "not_after",
121
102
  type: DataType.Text,
122
103
  },
123
- ],
124
- add_wallet: [
125
- {
126
- name: "id",
127
- type: DataType.Uuid,
128
- },
129
104
  {
130
- name: "address",
105
+ name: "signature",
131
106
  type: DataType.Text,
132
107
  },
108
+ ],
109
+ add_wallet_message: [
133
110
  {
134
- name: "public_key",
111
+ name: "address",
135
112
  type: DataType.Text,
136
113
  },
137
114
  {
@@ -139,101 +116,84 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
139
116
  type: DataType.Text,
140
117
  },
141
118
  {
142
- name: "message",
143
- type: DataType.Text,
119
+ name: "user_id",
120
+ type: DataType.Uuid,
144
121
  },
145
122
  {
146
- name: "signature",
123
+ name: "not_before",
147
124
  type: DataType.Text,
148
125
  },
149
- ],
150
- get_wallets: [],
151
- remove_wallet: [
152
126
  {
153
- name: "id",
154
- type: DataType.Uuid,
127
+ name: "not_after",
128
+ type: DataType.Text,
155
129
  },
156
130
  ],
157
- upsert_credential_as_inserter: [
131
+ add_wallet: [
158
132
  {
159
133
  name: "id",
160
134
  type: DataType.Uuid,
161
135
  },
162
136
  {
163
- name: "user_id",
164
- type: DataType.Uuid,
165
- },
166
- {
167
- name: "issuer_auth_public_key",
137
+ name: "address",
168
138
  type: DataType.Text,
169
139
  },
170
140
  {
171
- name: "encryptor_public_key",
141
+ name: "public_key",
172
142
  type: DataType.Text,
173
143
  },
174
144
  {
175
- name: "content",
145
+ name: "wallet_type",
176
146
  type: DataType.Text,
177
147
  },
178
148
  {
179
- name: "public_notes",
149
+ name: "not_before",
180
150
  type: DataType.Text,
181
151
  },
182
152
  {
183
- name: "public_notes_signature",
153
+ name: "not_after",
184
154
  type: DataType.Text,
185
155
  },
186
156
  {
187
- name: "broader_signature",
157
+ name: "signature",
188
158
  type: DataType.Text,
189
159
  },
190
160
  ],
191
- add_credential: [
161
+ get_wallets: [],
162
+ remove_wallet: [
192
163
  {
193
164
  name: "id",
194
165
  type: DataType.Uuid,
195
166
  },
167
+ ],
168
+ create_preliminary_credential: [
196
169
  {
197
- name: "issuer_auth_public_key",
198
- type: DataType.Text,
199
- },
200
- {
201
- name: "encryptor_public_key",
202
- type: DataType.Text,
170
+ name: "request_id",
171
+ type: DataType.Uuid,
203
172
  },
204
173
  {
205
- name: "content",
206
- type: DataType.Text,
174
+ name: "credential_id",
175
+ type: DataType.Uuid,
207
176
  },
208
177
  {
209
- name: "public_notes",
178
+ name: "issuer_auth_public_key",
210
179
  type: DataType.Text,
211
180
  },
212
181
  {
213
- name: "public_notes_signature",
182
+ name: "encryptor_public_key",
214
183
  type: DataType.Text,
215
184
  },
216
185
  {
217
- name: "broader_signature",
186
+ name: "content_uri",
218
187
  type: DataType.Text,
219
188
  },
220
- ],
221
- get_credentials: [],
222
- get_credentials_shared_by_user: [
223
189
  {
224
- name: "user_id",
225
- type: DataType.Uuid,
190
+ name: "content_size",
191
+ type: DataType.Int,
226
192
  },
227
193
  {
228
- name: "original_issuer_auth_public_key",
194
+ name: "content_hash",
229
195
  type: DataType.Text,
230
196
  },
231
- ],
232
- edit_credential: [
233
- {
234
- name: "id",
235
- type: DataType.Uuid,
236
- },
237
197
  {
238
198
  name: "public_notes",
239
199
  type: DataType.Text,
@@ -246,16 +206,15 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
246
206
  name: "broader_signature",
247
207
  type: DataType.Text,
248
208
  },
209
+ ],
210
+ get_credentials: [],
211
+ get_credentials_shared_by_user: [
249
212
  {
250
- name: "content",
251
- type: DataType.Text,
252
- },
253
- {
254
- name: "encryptor_public_key",
255
- type: DataType.Text,
213
+ name: "user_id",
214
+ type: DataType.Uuid,
256
215
  },
257
216
  {
258
- name: "issuer_auth_public_key",
217
+ name: "original_issuer_auth_public_key",
259
218
  type: DataType.Text,
260
219
  },
261
220
  ],
@@ -281,13 +240,17 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
281
240
  type: DataType.Uuid,
282
241
  },
283
242
  ],
284
- share_credential: [
243
+ share_preliminary_credential: [
285
244
  {
286
- name: "id",
245
+ name: "request_id",
246
+ type: DataType.Uuid,
247
+ },
248
+ {
249
+ name: "copy_id",
287
250
  type: DataType.Uuid,
288
251
  },
289
252
  {
290
- name: "original_credential_id",
253
+ name: "original_id",
291
254
  type: DataType.Uuid,
292
255
  },
293
256
  {
@@ -303,9 +266,13 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
303
266
  type: DataType.Text,
304
267
  },
305
268
  {
306
- name: "content",
269
+ name: "content_uri",
307
270
  type: DataType.Text,
308
271
  },
272
+ {
273
+ name: "content_size",
274
+ type: DataType.Int,
275
+ },
309
276
  {
310
277
  name: "content_hash",
311
278
  type: DataType.Text,
@@ -327,7 +294,11 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
327
294
  type: DataType.Int,
328
295
  },
329
296
  ],
330
- create_credentials_by_dwg: [
297
+ create_preliminary_credentials_by_dwg: [
298
+ {
299
+ name: "request_id",
300
+ type: DataType.Uuid,
301
+ },
331
302
  {
332
303
  name: "issuer_auth_public_key",
333
304
  type: DataType.Text,
@@ -337,13 +308,17 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
337
308
  type: DataType.Text,
338
309
  },
339
310
  {
340
- name: "original_credential_id",
311
+ name: "original_id",
341
312
  type: DataType.Uuid,
342
313
  },
343
314
  {
344
- name: "original_content",
315
+ name: "original_content_uri",
345
316
  type: DataType.Text,
346
317
  },
318
+ {
319
+ name: "original_content_size",
320
+ type: DataType.Int,
321
+ },
347
322
  {
348
323
  name: "original_public_notes",
349
324
  type: DataType.Text,
@@ -361,13 +336,17 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
361
336
  type: DataType.Text,
362
337
  },
363
338
  {
364
- name: "copy_credential_id",
339
+ name: "copy_id",
365
340
  type: DataType.Uuid,
366
341
  },
367
342
  {
368
- name: "copy_content",
343
+ name: "copy_content_uri",
369
344
  type: DataType.Text,
370
345
  },
346
+ {
347
+ name: "copy_content_size",
348
+ type: DataType.Int,
349
+ },
371
350
  {
372
351
  name: "copy_public_notes_signature",
373
352
  type: DataType.Text,
@@ -571,61 +550,31 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
571
550
  type: DataType.Uuid,
572
551
  },
573
552
  ],
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
- },
553
+ get_access_grants_for_credential: [
583
554
  {
584
- name: "dag_data_id",
555
+ name: "credential_id",
585
556
  type: DataType.Uuid,
586
557
  },
587
- {
588
- name: "dag_locked_until",
589
- type: DataType.Int,
590
- },
591
- {
592
- name: "dag_content_hash",
593
- type: DataType.Text,
594
- },
595
558
  ],
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
- },
559
+ has_profile: [
613
560
  {
614
- name: "dag_content_hash",
561
+ name: "address",
615
562
  type: DataType.Text,
616
563
  },
564
+ ],
565
+ set_caller_payer: [
617
566
  {
618
- name: "dag_signature",
567
+ name: "address",
619
568
  type: DataType.Text,
620
569
  },
621
570
  ],
622
- get_access_grants_for_credential: [
571
+ check_caller_payer: [
623
572
  {
624
- name: "credential_id",
625
- type: DataType.Uuid,
573
+ name: "address",
574
+ type: DataType.Text,
626
575
  },
627
576
  ],
628
- has_profile: [
577
+ unset_caller_payer: [
629
578
  {
630
579
  name: "address",
631
580
  type: DataType.Text,
@@ -646,6 +595,10 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
646
595
  name: "token",
647
596
  type: DataType.Text,
648
597
  },
598
+ {
599
+ name: "minimum_balance",
600
+ type: DataType.Int,
601
+ },
649
602
  ],
650
603
  request_withdrawal: [
651
604
  {
@@ -684,91 +637,6 @@ export const actionSchema: Record<string, ActionSchemaElement[]> = {
684
637
  },
685
638
  ],
686
639
  };
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
640
  export const AddUserAsInserterInputSchema: z.ZodObject<{
773
641
  id: z.ZodUUID;
774
642
  recipient_encryption_public_key: z.ZodString;
@@ -837,7 +705,10 @@ export async function getUser(kwilClient: KwilActionClient): Promise<GetUserOutp
837
705
  name: "get_user",
838
706
  inputs: {},
839
707
  })
840
- .then((result) => result[0]);
708
+ .then((result) => {
709
+ if (!result[0]) throw new Error("get_user returned no rows");
710
+ return result[0];
711
+ });
841
712
  }
842
713
 
843
714
  export const GetUserAsInserterInputSchema: z.ZodObject<{
@@ -879,19 +750,30 @@ export const UpsertWalletAsInserterInputSchema: z.ZodObject<{
879
750
  id: z.ZodUUID;
880
751
  user_id: z.ZodUUID;
881
752
  address: z.ZodString;
882
- public_key: z.ZodNullable<z.ZodString>;
753
+ public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
883
754
  wallet_type: z.ZodType<WalletType>;
884
- message: z.ZodString;
755
+ not_before: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
756
+ not_after: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
885
757
  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
- });
758
+ }> = z
759
+ .object({
760
+ id: z.uuid(),
761
+ user_id: z.uuid(),
762
+ address: z.string(),
763
+ public_key: z.string().nullish(),
764
+ wallet_type: walletTypeSchema,
765
+ not_before: rfc3339DateTimeSchema.nullish(),
766
+ not_after: rfc3339DateTimeSchema.nullish(),
767
+ signature: z.string(),
768
+ })
769
+ .refine((v) => (v.wallet_type === "MM") === (v.not_before == null), {
770
+ path: ["not_before"],
771
+ message: "not_before must be null when wallet_type is MM, and set otherwise",
772
+ })
773
+ .refine((v) => (v.wallet_type === "MM") === (v.not_after == null), {
774
+ path: ["not_after"],
775
+ message: "not_after must be null when wallet_type is MM, and set otherwise",
776
+ });
895
777
 
896
778
  export type UpsertWalletAsInserterInput = z.infer<typeof UpsertWalletAsInserterInputSchema>;
897
779
 
@@ -908,19 +790,61 @@ export async function upsertWalletAsInserter(
908
790
  });
909
791
  }
910
792
 
793
+ export const AddWalletMessageInputSchema: z.ZodObject<{
794
+ address: z.ZodString;
795
+ wallet_type: z.ZodType<WalletType>;
796
+ user_id: z.ZodUUID;
797
+ not_before: z.ZodISODateTime;
798
+ not_after: z.ZodISODateTime;
799
+ }> = z.object({
800
+ address: z.string(),
801
+ wallet_type: walletTypeSchema,
802
+ user_id: z.uuid(),
803
+ not_before: rfc3339DateTimeSchema,
804
+ not_after: rfc3339DateTimeSchema,
805
+ });
806
+
807
+ export type AddWalletMessageInput = z.infer<typeof AddWalletMessageInputSchema>;
808
+
809
+ export const AddWalletMessageOutputSchema: z.ZodObject<{
810
+ message: z.ZodString;
811
+ }> = z.object({
812
+ message: z.string(),
813
+ });
814
+
815
+ export type AddWalletMessageOutput = z.infer<typeof AddWalletMessageOutputSchema>;
816
+
817
+ export async function addWalletMessage(
818
+ kwilClient: KwilActionClient,
819
+ params: AddWalletMessageInput,
820
+ ): Promise<AddWalletMessageOutput> {
821
+ const inputs = AddWalletMessageInputSchema.parse(params);
822
+ return await kwilClient
823
+ .call<AddWalletMessageOutput[]>({
824
+ name: "add_wallet_message",
825
+ inputs,
826
+ })
827
+ .then((result) => {
828
+ if (!result[0]) throw new Error("add_wallet_message returned no rows");
829
+ return result[0];
830
+ });
831
+ }
832
+
911
833
  export const AddWalletInputSchema: z.ZodObject<{
912
834
  id: z.ZodUUID;
913
835
  address: z.ZodString;
914
- public_key: z.ZodNullable<z.ZodString>;
836
+ public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
915
837
  wallet_type: z.ZodType<WalletType>;
916
- message: z.ZodString;
838
+ not_before: z.ZodISODateTime;
839
+ not_after: z.ZodISODateTime;
917
840
  signature: z.ZodString;
918
841
  }> = z.object({
919
842
  id: z.uuid(),
920
843
  address: z.string(),
921
- public_key: z.string().nullable(),
844
+ public_key: z.string().nullish(),
922
845
  wallet_type: walletTypeSchema,
923
- message: z.string(),
846
+ not_before: rfc3339DateTimeSchema,
847
+ not_after: rfc3339DateTimeSchema,
924
848
  signature: z.string(),
925
849
  });
926
850
 
@@ -987,74 +911,44 @@ export async function removeWallet(
987
911
  });
988
912
  }
989
913
 
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;
914
+ export const CreatePreliminaryCredentialInputSchema: z.ZodObject<{
915
+ request_id: z.ZodUUID;
916
+ credential_id: z.ZodUUID;
1031
917
  issuer_auth_public_key: z.ZodString;
1032
918
  encryptor_public_key: z.ZodString;
1033
- content: z.ZodString;
919
+ content_uri: z.ZodString;
920
+ content_size: z.ZodNumber;
921
+ content_hash: z.ZodString;
1034
922
  public_notes: z.ZodString;
1035
923
  public_notes_signature: z.ZodString;
1036
924
  broader_signature: z.ZodString;
1037
925
  }> = z.object({
1038
- id: z.uuid(),
926
+ request_id: z.uuid(),
927
+ credential_id: z.uuid(),
1039
928
  issuer_auth_public_key: z.string(),
1040
929
  encryptor_public_key: z.string(),
1041
- content: z.string(),
930
+ content_uri: blobContentUriSchema,
931
+ content_size: contentSizeSchema,
932
+ content_hash: z.string(),
1042
933
  public_notes: z.string(),
1043
934
  public_notes_signature: z.string(),
1044
935
  broader_signature: z.string(),
1045
936
  });
1046
937
 
1047
- export type AddCredentialInput = z.infer<typeof AddCredentialInputSchema>;
938
+ export type CreatePreliminaryCredentialInput = z.infer<
939
+ typeof CreatePreliminaryCredentialInputSchema
940
+ >;
1048
941
 
1049
- export async function addCredential(
942
+ /** CREDENTIAL ACTIONS */
943
+ export async function createPreliminaryCredential(
1050
944
  kwilClient: KwilActionClient,
1051
- params: AddCredentialInput,
945
+ params: CreatePreliminaryCredentialInput,
1052
946
  ): Promise<void> {
1053
- const inputs = AddCredentialInputSchema.parse(params);
947
+ const inputs = CreatePreliminaryCredentialInputSchema.parse(params);
1054
948
  await kwilClient.execute({
1055
- name: "add_credential",
949
+ name: "create_preliminary_credential",
1056
950
  inputs,
1057
- description: "Add a new credential",
951
+ description: "Create a new preliminary credential",
1058
952
  });
1059
953
  }
1060
954
 
@@ -1062,15 +956,21 @@ export const GetCredentialsOutputSchema: z.ZodObject<{
1062
956
  id: z.ZodUUID;
1063
957
  user_id: z.ZodUUID;
1064
958
  public_notes: z.ZodString;
959
+ content_uri: z.ZodNullable<z.ZodString>;
960
+ content_size: z.ZodNullable<z.ZodNumber>;
1065
961
  issuer_auth_public_key: z.ZodString;
1066
- inserter: z.ZodNullable<z.ZodString>;
962
+ inserter_type: z.ZodNullable<z.ZodString>;
963
+ inserter_id: z.ZodNullable<z.ZodString>;
1067
964
  original_id: z.ZodNullable<z.ZodUUID>;
1068
965
  }> = z.object({
1069
966
  id: z.uuid(),
1070
967
  user_id: z.uuid(),
1071
968
  public_notes: z.string(),
969
+ content_uri: z.string().nullable(),
970
+ content_size: z.number().nullable(),
1072
971
  issuer_auth_public_key: z.string(),
1073
- inserter: z.string().nullable(),
972
+ inserter_type: z.string().nullable(),
973
+ inserter_id: z.string().nullable(),
1074
974
  original_id: z.uuid().nullable(),
1075
975
  });
1076
976
 
@@ -1087,10 +987,10 @@ export async function getCredentials(
1087
987
 
1088
988
  export const GetCredentialsSharedByUserInputSchema: z.ZodObject<{
1089
989
  user_id: z.ZodUUID;
1090
- original_issuer_auth_public_key: z.ZodNullable<z.ZodString>;
990
+ original_issuer_auth_public_key: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1091
991
  }> = z.object({
1092
992
  user_id: z.uuid(),
1093
- original_issuer_auth_public_key: z.string().nullable(),
993
+ original_issuer_auth_public_key: z.string().nullish(),
1094
994
  });
1095
995
 
1096
996
  export type GetCredentialsSharedByUserInput = z.infer<typeof GetCredentialsSharedByUserInputSchema>;
@@ -1101,7 +1001,8 @@ export const GetCredentialsSharedByUserOutputSchema: z.ZodObject<{
1101
1001
  public_notes: z.ZodString;
1102
1002
  encryptor_public_key: z.ZodString;
1103
1003
  issuer_auth_public_key: z.ZodString;
1104
- inserter: z.ZodNullable<z.ZodString>;
1004
+ inserter_type: z.ZodNullable<z.ZodString>;
1005
+ inserter_id: z.ZodNullable<z.ZodString>;
1105
1006
  original_id: z.ZodNullable<z.ZodUUID>;
1106
1007
  }> = z.object({
1107
1008
  id: z.uuid(),
@@ -1109,7 +1010,8 @@ export const GetCredentialsSharedByUserOutputSchema: z.ZodObject<{
1109
1010
  public_notes: z.string(),
1110
1011
  encryptor_public_key: z.string(),
1111
1012
  issuer_auth_public_key: z.string(),
1112
- inserter: z.string().nullable(),
1013
+ inserter_type: z.string().nullable(),
1014
+ inserter_id: z.string().nullable(),
1113
1015
  original_id: z.uuid().nullable(),
1114
1016
  });
1115
1017
 
@@ -1128,43 +1030,6 @@ export async function getCredentialsSharedByUser(
1128
1030
  });
1129
1031
  }
1130
1032
 
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
1033
  export const EditPublicNotesAsIssuerInputSchema: z.ZodObject<{
1169
1034
  public_notes_id: z.ZodString;
1170
1035
  public_notes: z.ZodString;
@@ -1200,6 +1065,12 @@ export const RemoveCredentialInputSchema: z.ZodObject<{
1200
1065
 
1201
1066
  export type RemoveCredentialInput = z.infer<typeof RemoveCredentialInputSchema>;
1202
1067
 
1068
+ /**
1069
+ * Already requested: succeed so the client can retry the blob DELETE.
1070
+ * A second insert is impossible (credential_id is the primary key).
1071
+ * Legacy inline credentials (no blob): delete immediately.
1072
+ * Blob-backed: record intent; credential stays live until gateway finalizes.
1073
+ */
1203
1074
  export async function removeCredential(
1204
1075
  kwilClient: KwilActionClient,
1205
1076
  params: RemoveCredentialInput,
@@ -1220,6 +1091,10 @@ export const RescindSharedCredentialInputSchema: z.ZodObject<{
1220
1091
 
1221
1092
  export type RescindSharedCredentialInput = z.infer<typeof RescindSharedCredentialInputSchema>;
1222
1093
 
1094
+ /**
1095
+ * Already requested: succeed so the client can retry the blob DELETE.
1096
+ * Legacy inline credentials (no blob): delete immediately.
1097
+ */
1223
1098
  export async function rescindSharedCredential(
1224
1099
  kwilClient: KwilActionClient,
1225
1100
  params: RescindSharedCredentialInput,
@@ -1232,25 +1107,29 @@ export async function rescindSharedCredential(
1232
1107
  });
1233
1108
  }
1234
1109
 
1235
- export const ShareCredentialInputSchema: z.ZodObject<{
1236
- id: z.ZodUUID;
1237
- original_credential_id: z.ZodUUID;
1110
+ export const SharePreliminaryCredentialInputSchema: z.ZodObject<{
1111
+ request_id: z.ZodUUID;
1112
+ copy_id: z.ZodUUID;
1113
+ original_id: z.ZodUUID;
1238
1114
  public_notes: z.ZodString;
1239
1115
  public_notes_signature: z.ZodString;
1240
1116
  broader_signature: z.ZodString;
1241
- content: z.ZodString;
1117
+ content_uri: z.ZodString;
1118
+ content_size: z.ZodNumber;
1242
1119
  content_hash: z.ZodString;
1243
1120
  encryptor_public_key: z.ZodString;
1244
1121
  issuer_auth_public_key: z.ZodString;
1245
1122
  grantee_wallet_identifier: z.ZodString;
1246
1123
  locked_until: z.ZodNumber;
1247
1124
  }> = z.object({
1248
- id: z.uuid(),
1249
- original_credential_id: z.uuid(),
1125
+ request_id: z.uuid(),
1126
+ copy_id: z.uuid(),
1127
+ original_id: z.uuid(),
1250
1128
  public_notes: z.string(),
1251
1129
  public_notes_signature: z.string(),
1252
1130
  broader_signature: z.string(),
1253
- content: z.string(),
1131
+ content_uri: blobContentUriSchema,
1132
+ content_size: contentSizeSchema,
1254
1133
  content_hash: z.string(),
1255
1134
  encryptor_public_key: z.string(),
1256
1135
  issuer_auth_public_key: z.string(),
@@ -1258,31 +1137,34 @@ export const ShareCredentialInputSchema: z.ZodObject<{
1258
1137
  locked_until: z.number(),
1259
1138
  });
1260
1139
 
1261
- export type ShareCredentialInput = z.infer<typeof ShareCredentialInputSchema>;
1140
+ export type SharePreliminaryCredentialInput = z.infer<typeof SharePreliminaryCredentialInputSchema>;
1262
1141
 
1263
- export async function shareCredential(
1142
+ export async function sharePreliminaryCredential(
1264
1143
  kwilClient: KwilActionClient,
1265
- params: ShareCredentialInput,
1144
+ params: SharePreliminaryCredentialInput,
1266
1145
  ): Promise<void> {
1267
- const inputs = ShareCredentialInputSchema.parse(params);
1146
+ const inputs = SharePreliminaryCredentialInputSchema.parse(params);
1268
1147
  await kwilClient.execute({
1269
- name: "share_credential",
1148
+ name: "share_preliminary_credential",
1270
1149
  inputs,
1271
1150
  description: "Share a credential with creating AG",
1272
1151
  });
1273
1152
  }
1274
1153
 
1275
- export const CreateCredentialsByDwgInputSchema: z.ZodObject<{
1154
+ export const CreatePreliminaryCredentialsByDwgInputSchema: z.ZodObject<{
1155
+ request_id: z.ZodUUID;
1276
1156
  issuer_auth_public_key: z.ZodString;
1277
1157
  original_encryptor_public_key: z.ZodString;
1278
- original_credential_id: z.ZodUUID;
1279
- original_content: z.ZodString;
1158
+ original_id: z.ZodUUID;
1159
+ original_content_uri: z.ZodString;
1160
+ original_content_size: z.ZodNumber;
1280
1161
  original_public_notes: z.ZodString;
1281
1162
  original_public_notes_signature: z.ZodString;
1282
1163
  original_broader_signature: z.ZodString;
1283
1164
  copy_encryptor_public_key: z.ZodString;
1284
- copy_credential_id: z.ZodUUID;
1285
- copy_content: z.ZodString;
1165
+ copy_id: z.ZodUUID;
1166
+ copy_content_uri: z.ZodString;
1167
+ copy_content_size: z.ZodNumber;
1286
1168
  copy_public_notes_signature: z.ZodString;
1287
1169
  copy_broader_signature: z.ZodString;
1288
1170
  content_hash: z.ZodString;
@@ -1290,21 +1172,24 @@ export const CreateCredentialsByDwgInputSchema: z.ZodObject<{
1290
1172
  dwg_grantee: z.ZodString;
1291
1173
  dwg_issuer_public_key: z.ZodString;
1292
1174
  dwg_id: z.ZodUUID;
1293
- dwg_access_grant_timelock: z.ZodString;
1294
- dwg_not_before: z.ZodString;
1295
- dwg_not_after: z.ZodString;
1175
+ dwg_access_grant_timelock: z.ZodISODateTime;
1176
+ dwg_not_before: z.ZodISODateTime;
1177
+ dwg_not_after: z.ZodISODateTime;
1296
1178
  dwg_signature: z.ZodString;
1297
1179
  }> = z.object({
1180
+ request_id: z.uuid(),
1298
1181
  issuer_auth_public_key: z.string(),
1299
1182
  original_encryptor_public_key: z.string(),
1300
- original_credential_id: z.uuid(),
1301
- original_content: z.string(),
1183
+ original_id: z.uuid(),
1184
+ original_content_uri: blobContentUriSchema,
1185
+ original_content_size: contentSizeSchema,
1302
1186
  original_public_notes: z.string(),
1303
1187
  original_public_notes_signature: z.string(),
1304
1188
  original_broader_signature: z.string(),
1305
1189
  copy_encryptor_public_key: z.string(),
1306
- copy_credential_id: z.uuid(),
1307
- copy_content: z.string(),
1190
+ copy_id: z.uuid(),
1191
+ copy_content_uri: blobContentUriSchema,
1192
+ copy_content_size: contentSizeSchema,
1308
1193
  copy_public_notes_signature: z.string(),
1309
1194
  copy_broader_signature: z.string(),
1310
1195
  content_hash: z.string(),
@@ -1312,18 +1197,29 @@ export const CreateCredentialsByDwgInputSchema: z.ZodObject<{
1312
1197
  dwg_grantee: z.string(),
1313
1198
  dwg_issuer_public_key: z.string(),
1314
1199
  dwg_id: z.uuid(),
1315
- dwg_access_grant_timelock: z.string(),
1316
- dwg_not_before: z.string(),
1317
- dwg_not_after: z.string(),
1200
+ dwg_access_grant_timelock: rfc3339DateTimeSchema,
1201
+ dwg_not_before: rfc3339DateTimeSchema,
1202
+ dwg_not_after: rfc3339DateTimeSchema,
1318
1203
  dwg_signature: z.string(),
1319
1204
  });
1320
1205
 
1321
- export type CreateCredentialsByDwgInput = z.infer<typeof CreateCredentialsByDwgInputSchema>;
1206
+ export type CreatePreliminaryCredentialsByDwgInput = z.infer<
1207
+ typeof CreatePreliminaryCredentialsByDwgInputSchema
1208
+ >;
1322
1209
 
1323
1210
  /**
1324
1211
  * Delegated write credential actions
1325
1212
  * For access grant
1326
- * Check the content creator (encryptor) of credentials is the issuer that user delegated to issue the credentials
1213
+ * We will use the same ids for preliminary credentials as for credentials, so we need to check if they already exist
1214
+ * We capture gas upfront to prevent the real credential from being created if the gas is not enough
1215
+ * The gas can be refunded fully or partially
1216
+ * Temporary: an issuer is not an inserter/caller. A user grants a DWG to an issuer_key;
1217
+ * the issuer must issue the credential and sign the proof with that same issuer_key.
1218
+ * Today we approximate "same issuer" via delegates sharing an inserter_id.
1219
+ * TODO: once the SDK distinguishes issuer_key from delegate_key, replace with:
1220
+ * if $issuer_auth_public_key != $dwg_issuer_public_key {
1221
+ * error('credentials issuer must be an issuer of delegated write grant');
1222
+ * }
1327
1223
  * Get the wallet type and public key for XRPL/NEAR wallets from database
1328
1224
  * Will fail if not in the RFC3339 format
1329
1225
  * Check the format and precedence
@@ -1331,16 +1227,14 @@ export type CreateCredentialsByDwgInput = z.infer<typeof CreateCredentialsByDwgI
1331
1227
  * @block_timestamp is a timestamp of previous block, which is can be a few seconds earlier
1332
1228
  * (max is 6 seconds in current network consensus settings) then a time on a requester's machine.
1333
1229
  * Also, if requester's machine has wrong time, it can be an issue.
1334
- * Insert original credential
1335
- * Insert copy credential
1336
1230
  */
1337
- export async function createCredentialsByDwg(
1231
+ export async function createPreliminaryCredentialsByDwg(
1338
1232
  kwilClient: KwilActionClient,
1339
- params: CreateCredentialsByDwgInput,
1233
+ params: CreatePreliminaryCredentialsByDwgInput,
1340
1234
  ): Promise<void> {
1341
- const inputs = CreateCredentialsByDwgInputSchema.parse(params);
1235
+ const inputs = CreatePreliminaryCredentialsByDwgInputSchema.parse(params);
1342
1236
  await kwilClient.execute({
1343
- name: "create_credentials_by_dwg",
1237
+ name: "create_preliminary_credentials_by_dwg",
1344
1238
  inputs,
1345
1239
  description:
1346
1240
  "Add original credential and copy credential with AG on behalf of a user (using delegated write grant given by the user)",
@@ -1388,18 +1282,24 @@ export const GetCredentialOwnedOutputSchema: z.ZodObject<{
1388
1282
  id: z.ZodUUID;
1389
1283
  user_id: z.ZodUUID;
1390
1284
  public_notes: z.ZodString;
1391
- content: z.ZodString;
1285
+ content: z.ZodNullable<z.ZodString>;
1286
+ content_uri: z.ZodNullable<z.ZodString>;
1287
+ content_size: z.ZodNullable<z.ZodNumber>;
1392
1288
  encryptor_public_key: z.ZodString;
1393
1289
  issuer_auth_public_key: z.ZodString;
1394
- inserter: z.ZodNullable<z.ZodString>;
1290
+ inserter_type: z.ZodNullable<z.ZodString>;
1291
+ inserter_id: z.ZodNullable<z.ZodString>;
1395
1292
  }> = z.object({
1396
1293
  id: z.uuid(),
1397
1294
  user_id: z.uuid(),
1398
1295
  public_notes: z.string(),
1399
- content: z.string(),
1296
+ content: z.string().nullable(),
1297
+ content_uri: z.string().nullable(),
1298
+ content_size: z.number().nullable(),
1400
1299
  encryptor_public_key: z.string(),
1401
1300
  issuer_auth_public_key: z.string(),
1402
- inserter: z.string().nullable(),
1301
+ inserter_type: z.string().nullable(),
1302
+ inserter_id: z.string().nullable(),
1403
1303
  });
1404
1304
 
1405
1305
  export type GetCredentialOwnedOutput = z.infer<typeof GetCredentialOwnedOutputSchema>;
@@ -1427,18 +1327,24 @@ export const GetCredentialSharedOutputSchema: z.ZodObject<{
1427
1327
  id: z.ZodUUID;
1428
1328
  user_id: z.ZodUUID;
1429
1329
  public_notes: z.ZodString;
1430
- content: z.ZodString;
1330
+ content: z.ZodNullable<z.ZodString>;
1331
+ content_uri: z.ZodNullable<z.ZodString>;
1332
+ content_size: z.ZodNullable<z.ZodNumber>;
1431
1333
  encryptor_public_key: z.ZodString;
1432
1334
  issuer_auth_public_key: z.ZodString;
1433
- inserter: z.ZodNullable<z.ZodString>;
1335
+ inserter_type: z.ZodNullable<z.ZodString>;
1336
+ inserter_id: z.ZodNullable<z.ZodString>;
1434
1337
  }> = z.object({
1435
1338
  id: z.uuid(),
1436
1339
  user_id: z.uuid(),
1437
1340
  public_notes: z.string(),
1438
- content: z.string(),
1341
+ content: z.string().nullable(),
1342
+ content_uri: z.string().nullable(),
1343
+ content_size: z.number().nullable(),
1439
1344
  encryptor_public_key: z.string(),
1440
1345
  issuer_auth_public_key: z.string(),
1441
- inserter: z.string().nullable(),
1346
+ inserter_type: z.string().nullable(),
1347
+ inserter_id: z.string().nullable(),
1442
1348
  });
1443
1349
 
1444
1350
  export type GetCredentialSharedOutput = z.infer<typeof GetCredentialSharedOutputSchema>;
@@ -1633,17 +1539,17 @@ export const DwgMessageInputSchema: z.ZodObject<{
1633
1539
  grantee_wallet_identifier: z.ZodString;
1634
1540
  issuer_public_key: z.ZodString;
1635
1541
  id: z.ZodUUID;
1636
- access_grant_timelock: z.ZodString;
1637
- not_usable_before: z.ZodString;
1638
- not_usable_after: z.ZodString;
1542
+ access_grant_timelock: z.ZodISODateTime;
1543
+ not_usable_before: z.ZodISODateTime;
1544
+ not_usable_after: z.ZodISODateTime;
1639
1545
  }> = z.object({
1640
1546
  owner_wallet_identifier: z.string(),
1641
1547
  grantee_wallet_identifier: z.string(),
1642
1548
  issuer_public_key: z.string(),
1643
1549
  id: z.uuid(),
1644
- access_grant_timelock: z.string(),
1645
- not_usable_before: z.string(),
1646
- not_usable_after: z.string(),
1550
+ access_grant_timelock: rfc3339DateTimeSchema,
1551
+ not_usable_before: rfc3339DateTimeSchema,
1552
+ not_usable_after: rfc3339DateTimeSchema,
1647
1553
  });
1648
1554
 
1649
1555
  export type DwgMessageInput = z.infer<typeof DwgMessageInputSchema>;
@@ -1730,11 +1636,11 @@ export async function getAccessGrantsOwned(
1730
1636
  }
1731
1637
 
1732
1638
  export const GetAccessGrantsGrantedInputSchema: z.ZodObject<{
1733
- user_id: z.ZodNullable<z.ZodUUID>;
1639
+ user_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
1734
1640
  page: z.ZodNumber;
1735
1641
  size: z.ZodNumber;
1736
1642
  }> = z.object({
1737
- user_id: z.uuid().nullable(),
1643
+ user_id: z.uuid().nullish(),
1738
1644
  page: z.number(),
1739
1645
  size: z.number(),
1740
1646
  });
@@ -1780,9 +1686,9 @@ export async function getAccessGrantsGranted(
1780
1686
  }
1781
1687
 
1782
1688
  export const GetAccessGrantsGrantedCountInputSchema: z.ZodObject<{
1783
- user_id: z.ZodNullable<z.ZodUUID>;
1689
+ user_id: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
1784
1690
  }> = z.object({
1785
- user_id: z.uuid().nullable(),
1691
+ user_id: z.uuid().nullish(),
1786
1692
  });
1787
1693
 
1788
1694
  export type GetAccessGrantsGrantedCountInput = z.infer<
@@ -1841,77 +1747,6 @@ export async function hasLockedAccessGrants(
1841
1747
  .then((result) => result[0]);
1842
1748
  }
1843
1749
 
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
1750
  export const GetAccessGrantsForCredentialInputSchema: z.ZodObject<{
1916
1751
  credential_id: z.ZodUUID;
1917
1752
  }> = z.object({
@@ -1993,6 +1828,75 @@ export async function hasProfile(
1993
1828
  .then((result) => result[0]);
1994
1829
  }
1995
1830
 
1831
+ export const SetCallerPayerInputSchema: z.ZodObject<{
1832
+ address: z.ZodString;
1833
+ }> = z.object({
1834
+ address: z.string(),
1835
+ });
1836
+
1837
+ export type SetCallerPayerInput = z.infer<typeof SetCallerPayerInputSchema>;
1838
+
1839
+ export async function setCallerPayer(
1840
+ kwilClient: KwilActionClient,
1841
+ params: SetCallerPayerInput,
1842
+ ): Promise<void> {
1843
+ const inputs = SetCallerPayerInputSchema.parse(params);
1844
+ await kwilClient.execute({
1845
+ name: "set_caller_payer",
1846
+ inputs,
1847
+ description: "Set the caller as a payer for a specific EVM address",
1848
+ });
1849
+ }
1850
+
1851
+ export const CheckCallerPayerInputSchema: z.ZodObject<{
1852
+ address: z.ZodString;
1853
+ }> = z.object({
1854
+ address: z.string(),
1855
+ });
1856
+
1857
+ export type CheckCallerPayerInput = z.infer<typeof CheckCallerPayerInputSchema>;
1858
+
1859
+ export const CheckCallerPayerOutputSchema: z.ZodObject<{
1860
+ is_payer: z.ZodBoolean;
1861
+ }> = z.object({
1862
+ is_payer: z.boolean(),
1863
+ });
1864
+
1865
+ export type CheckCallerPayerOutput = z.infer<typeof CheckCallerPayerOutputSchema>;
1866
+
1867
+ export async function checkCallerPayer(
1868
+ kwilClient: KwilActionClient,
1869
+ params: CheckCallerPayerInput,
1870
+ ): Promise<CheckCallerPayerOutput> {
1871
+ const inputs = CheckCallerPayerInputSchema.parse(params);
1872
+ return await kwilClient
1873
+ .call<CheckCallerPayerOutput[]>({
1874
+ name: "check_caller_payer",
1875
+ inputs,
1876
+ })
1877
+ .then((result) => result[0]);
1878
+ }
1879
+
1880
+ export const UnsetCallerPayerInputSchema: z.ZodObject<{
1881
+ address: z.ZodString;
1882
+ }> = z.object({
1883
+ address: z.string(),
1884
+ });
1885
+
1886
+ export type UnsetCallerPayerInput = z.infer<typeof UnsetCallerPayerInputSchema>;
1887
+
1888
+ export async function unsetCallerPayer(
1889
+ kwilClient: KwilActionClient,
1890
+ params: UnsetCallerPayerInput,
1891
+ ): Promise<void> {
1892
+ const inputs = UnsetCallerPayerInputSchema.parse(params);
1893
+ await kwilClient.execute({
1894
+ name: "unset_caller_payer",
1895
+ inputs,
1896
+ description: "Remove the caller as a payer for a specific EVM address",
1897
+ });
1898
+ }
1899
+
1996
1900
  export const CheckBalanceInputSchema: z.ZodObject<{
1997
1901
  address: z.ZodString;
1998
1902
  token: z.ZodString;
@@ -2011,7 +1915,6 @@ export const CheckBalanceOutputSchema: z.ZodObject<{
2011
1915
 
2012
1916
  export type CheckBalanceOutput = z.infer<typeof CheckBalanceOutputSchema>;
2013
1917
 
2014
- /** GAS AND FEES */
2015
1918
  export async function checkBalance(
2016
1919
  kwilClient: KwilActionClient,
2017
1920
  params: CheckBalanceInput,
@@ -2027,8 +1930,10 @@ export async function checkBalance(
2027
1930
 
2028
1931
  export const GetWalletWithBalanceInputSchema: z.ZodObject<{
2029
1932
  token: z.ZodString;
1933
+ minimum_balance: z.ZodNumber;
2030
1934
  }> = z.object({
2031
1935
  token: z.string(),
1936
+ minimum_balance: z.number(),
2032
1937
  });
2033
1938
 
2034
1939
  export type GetWalletWithBalanceInput = z.infer<typeof GetWalletWithBalanceInputSchema>;
@@ -2041,10 +1946,6 @@ export const GetWalletWithBalanceOutputSchema: z.ZodObject<{
2041
1946
 
2042
1947
  export type GetWalletWithBalanceOutput = z.infer<typeof GetWalletWithBalanceOutputSchema>;
2043
1948
 
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
1949
  export async function getWalletWithBalance(
2049
1950
  kwilClient: KwilActionClient,
2050
1951
  params: GetWalletWithBalanceInput,