@zing-protocol/zing-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +12 -0
  2. package/package.json +37 -0
  3. package/src/_generated/index.js +6 -0
  4. package/src/_generated/utils/index.ts +181 -0
  5. package/src/_generated/zing_framework/coin_utils.ts +41 -0
  6. package/src/_generated/zing_framework/deps/sui/object.ts +16 -0
  7. package/src/_generated/zing_framework/derived_object_bag.ts +400 -0
  8. package/src/_generated/zing_framework/derived_table.ts +366 -0
  9. package/src/_generated/zing_governance/admin.ts +47 -0
  10. package/src/_generated/zing_governance/deps/sui/object.ts +16 -0
  11. package/src/_generated/zing_governance/treasury.ts +134 -0
  12. package/src/_generated/zing_identity/config.ts +191 -0
  13. package/src/_generated/zing_identity/deps/std/type_name.ts +25 -0
  14. package/src/_generated/zing_identity/deps/sui/object.ts +16 -0
  15. package/src/_generated/zing_identity/deps/sui/object_table.ts +26 -0
  16. package/src/_generated/zing_identity/deps/sui/table.ts +38 -0
  17. package/src/_generated/zing_identity/deps/sui/vec_set.ts +28 -0
  18. package/src/_generated/zing_identity/ecdsa.ts +166 -0
  19. package/src/_generated/zing_identity/identity.ts +661 -0
  20. package/src/_generated/zing_identity/reclaim.ts +803 -0
  21. package/src/_generated/zing_studio/app.ts +855 -0
  22. package/src/_generated/zing_studio/article.ts +598 -0
  23. package/src/_generated/zing_studio/config.ts +475 -0
  24. package/src/_generated/zing_studio/deps/std/type_name.ts +25 -0
  25. package/src/_generated/zing_studio/deps/sui/bag.ts +43 -0
  26. package/src/_generated/zing_studio/deps/sui/balance.ts +20 -0
  27. package/src/_generated/zing_studio/deps/sui/coin.ts +21 -0
  28. package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +272 -0
  29. package/src/_generated/zing_studio/deps/sui/object.ts +16 -0
  30. package/src/_generated/zing_studio/deps/sui/table.ts +38 -0
  31. package/src/_generated/zing_studio/deps/sui/vec_map.ts +39 -0
  32. package/src/_generated/zing_studio/deps/sui/vec_set.ts +28 -0
  33. package/src/_generated/zing_studio/deps/walrus/blob.ts +22 -0
  34. package/src/_generated/zing_studio/deps/walrus/events.ts +124 -0
  35. package/src/_generated/zing_studio/deps/walrus/metadata.ts +137 -0
  36. package/src/_generated/zing_studio/deps/walrus/storage_resource.ts +17 -0
  37. package/src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts +17 -0
  38. package/src/_generated/zing_studio/deps/zing_framework/derived_table.ts +17 -0
  39. package/src/_generated/zing_studio/donation.ts +18 -0
  40. package/src/_generated/zing_studio/enclave.ts +466 -0
  41. package/src/_generated/zing_studio/nitro_attestation.ts +308 -0
  42. package/src/_generated/zing_studio/referral.ts +447 -0
  43. package/src/_generated/zing_studio/storage.ts +664 -0
  44. package/src/_generated/zing_studio/studio.ts +682 -0
  45. package/src/bcs.ts +139 -0
  46. package/src/client/index.ts +557 -0
  47. package/src/client/types.ts +28 -0
  48. package/src/components/index.ts +3 -0
  49. package/src/components/wallet-provider.tsx +53 -0
  50. package/src/components/walrus-provider.tsx +212 -0
  51. package/src/components/zing-provider.tsx +54 -0
  52. package/src/config/common.ts +82 -0
  53. package/src/config/index.ts +45 -0
  54. package/src/config/mainnet.ts +109 -0
  55. package/src/config/testnet.ts +111 -0
  56. package/src/config/types.ts +69 -0
  57. package/src/const.ts +32 -0
  58. package/src/getters.ts +523 -0
  59. package/src/hooks/index.ts +14 -0
  60. package/src/hooks/useGetStudio.ts +22 -0
  61. package/src/hooks/useGetTierPlan.ts +115 -0
  62. package/src/hooks/useReclaim.ts +165 -0
  63. package/src/hooks/useSignAndExecuteTransaction.ts +57 -0
  64. package/src/hooks/useSignPersonalMessage.ts +28 -0
  65. package/src/hooks/useZingInfiniteQueries.ts +92 -0
  66. package/src/hooks/useZingMutation.ts +66 -0
  67. package/src/hooks/useZingQueries.ts +107 -0
  68. package/src/hooks/useZingQuery.ts +88 -0
  69. package/src/index.ts +15 -0
  70. package/src/lib/utils/colorful-logger.ts +27 -0
  71. package/src/lib/utils/const.ts +25 -0
  72. package/src/lib/utils/helpers.ts +78 -0
  73. package/src/lib/utils/index.ts +5 -0
  74. package/src/lib/utils/init-app-with-shadow.ts +42 -0
  75. package/src/lib/utils/quilt.ts +317 -0
  76. package/src/lib/utils/reclaim.ts +148 -0
  77. package/src/lib/utils/types.ts +14 -0
  78. package/src/mutations/index.ts +3 -0
  79. package/src/mutations/seal.ts +78 -0
  80. package/src/mutations/signer.ts +241 -0
  81. package/src/mutations/walrus.ts +862 -0
  82. package/src/stores/index.ts +3 -0
  83. package/src/stores/walletStore.ts +360 -0
  84. package/src/stores/walrusStore.ts +118 -0
  85. package/src/stores/zkloginStore.ts +53 -0
  86. package/src/types.ts +120 -0
  87. package/tsconfig.json +12 -0
@@ -0,0 +1,664 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+ import * as coin from "./deps/sui/coin.js";
5
+ import * as object from "./deps/sui/object.js";
6
+ import * as vec_map from "./deps/sui/vec_map.js";
7
+ import * as storage_resource from "./deps/walrus/storage_resource.js";
8
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
9
+ import { bcs } from "@mysten/sui/bcs";
10
+ import type { RawTransactionArgument } from "../utils/index.js";
11
+ import type { Transaction } from "@mysten/sui/transactions";
12
+
13
+ const $moduleName = "@local-pkg/zing_studio::storage";
14
+ export const AddStorageEvent = new MoveStruct({
15
+ name: `${$moduleName}::AddStorageEvent`,
16
+ fields: {
17
+ current_epoch: bcs.u32(),
18
+ added_epoch: bcs.u32(),
19
+ added_size: bcs.u64(),
20
+ },
21
+ });
22
+ export const RemoveStorageEvent = new MoveStruct({
23
+ name: `${$moduleName}::RemoveStorageEvent`,
24
+ fields: {
25
+ current_epoch: bcs.u32(),
26
+ removed_epoch: bcs.u32(),
27
+ removed_size: bcs.u64(),
28
+ },
29
+ });
30
+ export const AllocateStorageEvent = new MoveStruct({
31
+ name: `${$moduleName}::AllocateStorageEvent`,
32
+ fields: {
33
+ current_epoch: bcs.u32(),
34
+ start_epoch: bcs.u32(),
35
+ end_epoch: bcs.u32(),
36
+ size_per_epoch: bcs.u64(),
37
+ },
38
+ });
39
+ export const DeallocateStorageEvent = new MoveStruct({
40
+ name: `${$moduleName}::DeallocateStorageEvent`,
41
+ fields: {
42
+ current_epoch: bcs.u32(),
43
+ start_epoch: bcs.u32(),
44
+ end_epoch: bcs.u32(),
45
+ size_per_epoch: bcs.u64(),
46
+ },
47
+ });
48
+ export const STORAGE = new MoveStruct({
49
+ name: `${$moduleName}::STORAGE`,
50
+ fields: {
51
+ dummy_field: bcs.bool(),
52
+ },
53
+ });
54
+ export const StorageTier = new MoveStruct({
55
+ name: `${$moduleName}::StorageTier`,
56
+ fields: {
57
+ price: bcs.u64(),
58
+ duration_days: bcs.u16(),
59
+ storage_limit: bcs.u64(),
60
+ },
61
+ });
62
+ export const StorageTreasury = new MoveStruct({
63
+ name: `${$moduleName}::StorageTreasury`,
64
+ fields: {
65
+ id: object.UID,
66
+ tier_plan: vec_map.VecMap(bcs.u8(), StorageTier),
67
+ /**
68
+ * Maps epoch number to storage resources available for that epoch Each epoch can
69
+ * have multiple storage resources that get fused together
70
+ */
71
+ storages_by_epoch: vec_map.VecMap(bcs.u32(), storage_resource.Storage),
72
+ wal_treasury: coin.Coin,
73
+ },
74
+ });
75
+ export const StorageSpace = new MoveStruct({
76
+ name: `${$moduleName}::StorageSpace`,
77
+ fields: {
78
+ id: object.UID,
79
+ owner: bcs.Address,
80
+ /** Storage tier that determines the storage limit and pricing */
81
+ tier: bcs.option(bcs.u8()),
82
+ /** Maps epoch number to storage used in that epoch */
83
+ storage_used: vec_map.VecMap(bcs.u32(), bcs.u64()),
84
+ credits: bcs.u64(),
85
+ },
86
+ });
87
+ export interface TierPlanArguments {
88
+ self: RawTransactionArgument<string>;
89
+ }
90
+ export interface TierPlanOptions {
91
+ package?: string;
92
+ arguments: TierPlanArguments | [self: RawTransactionArgument<string>];
93
+ }
94
+ export function tierPlan(options: TierPlanOptions) {
95
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
96
+ const argumentsTypes = [
97
+ `${packageAddress}::storage::StorageTreasury`,
98
+ ] satisfies string[];
99
+ const parameterNames = ["self"];
100
+ return (tx: Transaction) =>
101
+ tx.moveCall({
102
+ package: packageAddress,
103
+ module: "storage",
104
+ function: "tier_plan",
105
+ arguments: normalizeMoveArguments(
106
+ options.arguments,
107
+ argumentsTypes,
108
+ parameterNames,
109
+ ),
110
+ });
111
+ }
112
+ export interface StoragesByEpochArguments {
113
+ self: RawTransactionArgument<string>;
114
+ }
115
+ export interface StoragesByEpochOptions {
116
+ package?: string;
117
+ arguments: StoragesByEpochArguments | [self: RawTransactionArgument<string>];
118
+ }
119
+ export function storagesByEpoch(options: StoragesByEpochOptions) {
120
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
121
+ const argumentsTypes = [
122
+ `${packageAddress}::storage::StorageTreasury`,
123
+ ] satisfies string[];
124
+ const parameterNames = ["self"];
125
+ return (tx: Transaction) =>
126
+ tx.moveCall({
127
+ package: packageAddress,
128
+ module: "storage",
129
+ function: "storages_by_epoch",
130
+ arguments: normalizeMoveArguments(
131
+ options.arguments,
132
+ argumentsTypes,
133
+ parameterNames,
134
+ ),
135
+ });
136
+ }
137
+ export interface WalTreasuryArguments {
138
+ self: RawTransactionArgument<string>;
139
+ }
140
+ export interface WalTreasuryOptions {
141
+ package?: string;
142
+ arguments: WalTreasuryArguments | [self: RawTransactionArgument<string>];
143
+ }
144
+ export function walTreasury(options: WalTreasuryOptions) {
145
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
146
+ const argumentsTypes = [
147
+ `${packageAddress}::storage::StorageTreasury`,
148
+ ] satisfies string[];
149
+ const parameterNames = ["self"];
150
+ return (tx: Transaction) =>
151
+ tx.moveCall({
152
+ package: packageAddress,
153
+ module: "storage",
154
+ function: "wal_treasury",
155
+ arguments: normalizeMoveArguments(
156
+ options.arguments,
157
+ argumentsTypes,
158
+ parameterNames,
159
+ ),
160
+ });
161
+ }
162
+ export interface TierPriceArguments {
163
+ tier: RawTransactionArgument<string>;
164
+ }
165
+ export interface TierPriceOptions {
166
+ package?: string;
167
+ arguments: TierPriceArguments | [tier: RawTransactionArgument<string>];
168
+ }
169
+ export function tierPrice(options: TierPriceOptions) {
170
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
171
+ const argumentsTypes = [
172
+ `${packageAddress}::storage::StorageTier`,
173
+ ] satisfies string[];
174
+ const parameterNames = ["tier"];
175
+ return (tx: Transaction) =>
176
+ tx.moveCall({
177
+ package: packageAddress,
178
+ module: "storage",
179
+ function: "tier_price",
180
+ arguments: normalizeMoveArguments(
181
+ options.arguments,
182
+ argumentsTypes,
183
+ parameterNames,
184
+ ),
185
+ });
186
+ }
187
+ export interface TierDurationDaysArguments {
188
+ tier: RawTransactionArgument<string>;
189
+ }
190
+ export interface TierDurationDaysOptions {
191
+ package?: string;
192
+ arguments: TierDurationDaysArguments | [tier: RawTransactionArgument<string>];
193
+ }
194
+ export function tierDurationDays(options: TierDurationDaysOptions) {
195
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
196
+ const argumentsTypes = [
197
+ `${packageAddress}::storage::StorageTier`,
198
+ ] satisfies string[];
199
+ const parameterNames = ["tier"];
200
+ return (tx: Transaction) =>
201
+ tx.moveCall({
202
+ package: packageAddress,
203
+ module: "storage",
204
+ function: "tier_duration_days",
205
+ arguments: normalizeMoveArguments(
206
+ options.arguments,
207
+ argumentsTypes,
208
+ parameterNames,
209
+ ),
210
+ });
211
+ }
212
+ export interface TierDurationArguments {
213
+ tier: RawTransactionArgument<string>;
214
+ }
215
+ export interface TierDurationOptions {
216
+ package?: string;
217
+ arguments: TierDurationArguments | [tier: RawTransactionArgument<string>];
218
+ }
219
+ export function tierDuration(options: TierDurationOptions) {
220
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
221
+ const argumentsTypes = [
222
+ `${packageAddress}::storage::StorageTier`,
223
+ ] satisfies string[];
224
+ const parameterNames = ["tier"];
225
+ return (tx: Transaction) =>
226
+ tx.moveCall({
227
+ package: packageAddress,
228
+ module: "storage",
229
+ function: "tier_duration",
230
+ arguments: normalizeMoveArguments(
231
+ options.arguments,
232
+ argumentsTypes,
233
+ parameterNames,
234
+ ),
235
+ });
236
+ }
237
+ export interface TierStorageLimitArguments {
238
+ tier: RawTransactionArgument<string>;
239
+ }
240
+ export interface TierStorageLimitOptions {
241
+ package?: string;
242
+ arguments: TierStorageLimitArguments | [tier: RawTransactionArgument<string>];
243
+ }
244
+ export function tierStorageLimit(options: TierStorageLimitOptions) {
245
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
246
+ const argumentsTypes = [
247
+ `${packageAddress}::storage::StorageTier`,
248
+ ] satisfies string[];
249
+ const parameterNames = ["tier"];
250
+ return (tx: Transaction) =>
251
+ tx.moveCall({
252
+ package: packageAddress,
253
+ module: "storage",
254
+ function: "tier_storage_limit",
255
+ arguments: normalizeMoveArguments(
256
+ options.arguments,
257
+ argumentsTypes,
258
+ parameterNames,
259
+ ),
260
+ });
261
+ }
262
+ export interface StorageLimitArguments {
263
+ self: RawTransactionArgument<string>;
264
+ storageSpace: RawTransactionArgument<string>;
265
+ }
266
+ export interface StorageLimitOptions {
267
+ package?: string;
268
+ arguments:
269
+ | StorageLimitArguments
270
+ | [
271
+ self: RawTransactionArgument<string>,
272
+ storageSpace: RawTransactionArgument<string>,
273
+ ];
274
+ }
275
+ export function storageLimit(options: StorageLimitOptions) {
276
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
277
+ const argumentsTypes = [
278
+ `${packageAddress}::storage::StorageTreasury`,
279
+ `${packageAddress}::storage::StorageSpace`,
280
+ ] satisfies string[];
281
+ const parameterNames = ["self", "storageSpace"];
282
+ return (tx: Transaction) =>
283
+ tx.moveCall({
284
+ package: packageAddress,
285
+ module: "storage",
286
+ function: "storage_limit",
287
+ arguments: normalizeMoveArguments(
288
+ options.arguments,
289
+ argumentsTypes,
290
+ parameterNames,
291
+ ),
292
+ });
293
+ }
294
+ export interface OwnerArguments {
295
+ storageSpace: RawTransactionArgument<string>;
296
+ }
297
+ export interface OwnerOptions {
298
+ package?: string;
299
+ arguments: OwnerArguments | [storageSpace: RawTransactionArgument<string>];
300
+ }
301
+ export function owner(options: OwnerOptions) {
302
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
303
+ const argumentsTypes = [
304
+ `${packageAddress}::storage::StorageSpace`,
305
+ ] satisfies string[];
306
+ const parameterNames = ["storageSpace"];
307
+ return (tx: Transaction) =>
308
+ tx.moveCall({
309
+ package: packageAddress,
310
+ module: "storage",
311
+ function: "owner",
312
+ arguments: normalizeMoveArguments(
313
+ options.arguments,
314
+ argumentsTypes,
315
+ parameterNames,
316
+ ),
317
+ });
318
+ }
319
+ export interface TierArguments {
320
+ storageSpace: RawTransactionArgument<string>;
321
+ }
322
+ export interface TierOptions {
323
+ package?: string;
324
+ arguments: TierArguments | [storageSpace: RawTransactionArgument<string>];
325
+ }
326
+ export function tier(options: TierOptions) {
327
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
328
+ const argumentsTypes = [
329
+ `${packageAddress}::storage::StorageSpace`,
330
+ ] satisfies string[];
331
+ const parameterNames = ["storageSpace"];
332
+ return (tx: Transaction) =>
333
+ tx.moveCall({
334
+ package: packageAddress,
335
+ module: "storage",
336
+ function: "tier",
337
+ arguments: normalizeMoveArguments(
338
+ options.arguments,
339
+ argumentsTypes,
340
+ parameterNames,
341
+ ),
342
+ });
343
+ }
344
+ export interface StorageUsedArguments {
345
+ storageSpace: RawTransactionArgument<string>;
346
+ }
347
+ export interface StorageUsedOptions {
348
+ package?: string;
349
+ arguments:
350
+ | StorageUsedArguments
351
+ | [storageSpace: RawTransactionArgument<string>];
352
+ }
353
+ /** Returns the storage limit for this storage space */
354
+ export function storageUsed(options: StorageUsedOptions) {
355
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
356
+ const argumentsTypes = [
357
+ `${packageAddress}::storage::StorageSpace`,
358
+ ] satisfies string[];
359
+ const parameterNames = ["storageSpace"];
360
+ return (tx: Transaction) =>
361
+ tx.moveCall({
362
+ package: packageAddress,
363
+ module: "storage",
364
+ function: "storage_used",
365
+ arguments: normalizeMoveArguments(
366
+ options.arguments,
367
+ argumentsTypes,
368
+ parameterNames,
369
+ ),
370
+ });
371
+ }
372
+ export interface StorageUsedByEpochArguments {
373
+ storageSpace: RawTransactionArgument<string>;
374
+ epoch: RawTransactionArgument<number>;
375
+ }
376
+ export interface StorageUsedByEpochOptions {
377
+ package?: string;
378
+ arguments:
379
+ | StorageUsedByEpochArguments
380
+ | [
381
+ storageSpace: RawTransactionArgument<string>,
382
+ epoch: RawTransactionArgument<number>,
383
+ ];
384
+ }
385
+ export function storageUsedByEpoch(options: StorageUsedByEpochOptions) {
386
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
387
+ const argumentsTypes = [
388
+ `${packageAddress}::storage::StorageSpace`,
389
+ "u32",
390
+ ] satisfies string[];
391
+ const parameterNames = ["storageSpace", "epoch"];
392
+ return (tx: Transaction) =>
393
+ tx.moveCall({
394
+ package: packageAddress,
395
+ module: "storage",
396
+ function: "storage_used_by_epoch",
397
+ arguments: normalizeMoveArguments(
398
+ options.arguments,
399
+ argumentsTypes,
400
+ parameterNames,
401
+ ),
402
+ });
403
+ }
404
+ export interface CreditsArguments {
405
+ storageSpace: RawTransactionArgument<string>;
406
+ }
407
+ export interface CreditsOptions {
408
+ package?: string;
409
+ arguments: CreditsArguments | [storageSpace: RawTransactionArgument<string>];
410
+ }
411
+ export function credits(options: CreditsOptions) {
412
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
413
+ const argumentsTypes = [
414
+ `${packageAddress}::storage::StorageSpace`,
415
+ ] satisfies string[];
416
+ const parameterNames = ["storageSpace"];
417
+ return (tx: Transaction) =>
418
+ tx.moveCall({
419
+ package: packageAddress,
420
+ module: "storage",
421
+ function: "credits",
422
+ arguments: normalizeMoveArguments(
423
+ options.arguments,
424
+ argumentsTypes,
425
+ parameterNames,
426
+ ),
427
+ });
428
+ }
429
+ export interface RemainingStorageArguments {
430
+ self: RawTransactionArgument<string>;
431
+ storageSpace: RawTransactionArgument<string>;
432
+ epoch: RawTransactionArgument<number>;
433
+ }
434
+ export interface RemainingStorageOptions {
435
+ package?: string;
436
+ arguments:
437
+ | RemainingStorageArguments
438
+ | [
439
+ self: RawTransactionArgument<string>,
440
+ storageSpace: RawTransactionArgument<string>,
441
+ epoch: RawTransactionArgument<number>,
442
+ ];
443
+ }
444
+ /**
445
+ * Calculates the remaining available storage capacity Returns 0 if already over
446
+ * limit (defensive programming)
447
+ */
448
+ export function remainingStorage(options: RemainingStorageOptions) {
449
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
450
+ const argumentsTypes = [
451
+ `${packageAddress}::storage::StorageTreasury`,
452
+ `${packageAddress}::storage::StorageSpace`,
453
+ "u32",
454
+ ] satisfies string[];
455
+ const parameterNames = ["self", "storageSpace", "epoch"];
456
+ return (tx: Transaction) =>
457
+ tx.moveCall({
458
+ package: packageAddress,
459
+ module: "storage",
460
+ function: "remaining_storage",
461
+ arguments: normalizeMoveArguments(
462
+ options.arguments,
463
+ argumentsTypes,
464
+ parameterNames,
465
+ ),
466
+ });
467
+ }
468
+ export interface UpdateTierPlanArguments {
469
+ self: RawTransactionArgument<string>;
470
+ Cap: RawTransactionArgument<string>;
471
+ tierIndex: RawTransactionArgument<number>;
472
+ price: RawTransactionArgument<number | bigint>;
473
+ durationDays: RawTransactionArgument<number>;
474
+ storageLimit: RawTransactionArgument<number | bigint>;
475
+ }
476
+ export interface UpdateTierPlanOptions {
477
+ package?: string;
478
+ arguments:
479
+ | UpdateTierPlanArguments
480
+ | [
481
+ self: RawTransactionArgument<string>,
482
+ Cap: RawTransactionArgument<string>,
483
+ tierIndex: RawTransactionArgument<number>,
484
+ price: RawTransactionArgument<number | bigint>,
485
+ durationDays: RawTransactionArgument<number>,
486
+ storageLimit: RawTransactionArgument<number | bigint>,
487
+ ];
488
+ }
489
+ export function updateTierPlan(options: UpdateTierPlanOptions) {
490
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
491
+ const argumentsTypes = [
492
+ `${packageAddress}::storage::StorageTreasury`,
493
+ `${packageAddress}::admin::AdminCap`,
494
+ "u8",
495
+ "u64",
496
+ "u16",
497
+ "u64",
498
+ ] satisfies string[];
499
+ const parameterNames = [
500
+ "self",
501
+ "Cap",
502
+ "tierIndex",
503
+ "price",
504
+ "durationDays",
505
+ "storageLimit",
506
+ ];
507
+ return (tx: Transaction) =>
508
+ tx.moveCall({
509
+ package: packageAddress,
510
+ module: "storage",
511
+ function: "update_tier_plan",
512
+ arguments: normalizeMoveArguments(
513
+ options.arguments,
514
+ argumentsTypes,
515
+ parameterNames,
516
+ ),
517
+ });
518
+ }
519
+ export interface RemoveStorageByAdminArguments {
520
+ self: RawTransactionArgument<string>;
521
+ walrusSystem: RawTransactionArgument<string>;
522
+ Cap: RawTransactionArgument<string>;
523
+ epoch: RawTransactionArgument<number>;
524
+ splitSize: RawTransactionArgument<number | bigint>;
525
+ }
526
+ export interface RemoveStorageByAdminOptions {
527
+ package?: string;
528
+ arguments:
529
+ | RemoveStorageByAdminArguments
530
+ | [
531
+ self: RawTransactionArgument<string>,
532
+ walrusSystem: RawTransactionArgument<string>,
533
+ Cap: RawTransactionArgument<string>,
534
+ epoch: RawTransactionArgument<number>,
535
+ splitSize: RawTransactionArgument<number | bigint>,
536
+ ];
537
+ }
538
+ /**
539
+ * Admin function to remove storage from treasury for a specific epoch Requires
540
+ * AdminCap to ensure only authorized users can call this Returns the requested
541
+ * storage amount, splitting if necessary
542
+ */
543
+ export function removeStorageByAdmin(options: RemoveStorageByAdminOptions) {
544
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
545
+ const argumentsTypes = [
546
+ `${packageAddress}::storage::StorageTreasury`,
547
+ `${packageAddress}::system::System`,
548
+ `${packageAddress}::admin::AdminCap`,
549
+ "u32",
550
+ "u64",
551
+ ] satisfies string[];
552
+ const parameterNames = ["self", "walrusSystem", "Cap", "epoch", "splitSize"];
553
+ return (tx: Transaction) =>
554
+ tx.moveCall({
555
+ package: packageAddress,
556
+ module: "storage",
557
+ function: "remove_storage_by_admin",
558
+ arguments: normalizeMoveArguments(
559
+ options.arguments,
560
+ argumentsTypes,
561
+ parameterNames,
562
+ ),
563
+ });
564
+ }
565
+ export interface ShareStorageSpaceArguments {
566
+ storageSpace: RawTransactionArgument<string>;
567
+ }
568
+ export interface ShareStorageSpaceOptions {
569
+ package?: string;
570
+ arguments:
571
+ | ShareStorageSpaceArguments
572
+ | [storageSpace: RawTransactionArgument<string>];
573
+ }
574
+ export function shareStorageSpace(options: ShareStorageSpaceOptions) {
575
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
576
+ const argumentsTypes = [
577
+ `${packageAddress}::storage::StorageSpace`,
578
+ ] satisfies string[];
579
+ const parameterNames = ["storageSpace"];
580
+ return (tx: Transaction) =>
581
+ tx.moveCall({
582
+ package: packageAddress,
583
+ module: "storage",
584
+ function: "share_storage_space",
585
+ arguments: normalizeMoveArguments(
586
+ options.arguments,
587
+ argumentsTypes,
588
+ parameterNames,
589
+ ),
590
+ });
591
+ }
592
+ export interface FundWalTreasuryArguments {
593
+ self: RawTransactionArgument<string>;
594
+ config: RawTransactionArgument<string>;
595
+ coin: RawTransactionArgument<string>;
596
+ }
597
+ export interface FundWalTreasuryOptions {
598
+ package?: string;
599
+ arguments:
600
+ | FundWalTreasuryArguments
601
+ | [
602
+ self: RawTransactionArgument<string>,
603
+ config: RawTransactionArgument<string>,
604
+ coin: RawTransactionArgument<string>,
605
+ ];
606
+ }
607
+ export function fundWalTreasury(options: FundWalTreasuryOptions) {
608
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
609
+ const argumentsTypes = [
610
+ `${packageAddress}::storage::StorageTreasury`,
611
+ `${packageAddress}::config::Config`,
612
+ `0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${packageAddress}::wal::WAL>`,
613
+ ] satisfies string[];
614
+ const parameterNames = ["self", "config", "coin"];
615
+ return (tx: Transaction) =>
616
+ tx.moveCall({
617
+ package: packageAddress,
618
+ module: "storage",
619
+ function: "fund_wal_treasury",
620
+ arguments: normalizeMoveArguments(
621
+ options.arguments,
622
+ argumentsTypes,
623
+ parameterNames,
624
+ ),
625
+ });
626
+ }
627
+ export interface AddStorageToTreasuryArguments {
628
+ self: RawTransactionArgument<string>;
629
+ config: RawTransactionArgument<string>;
630
+ walrusSystem: RawTransactionArgument<string>;
631
+ storage: RawTransactionArgument<string>;
632
+ }
633
+ export interface AddStorageToTreasuryOptions {
634
+ package?: string;
635
+ arguments:
636
+ | AddStorageToTreasuryArguments
637
+ | [
638
+ self: RawTransactionArgument<string>,
639
+ config: RawTransactionArgument<string>,
640
+ walrusSystem: RawTransactionArgument<string>,
641
+ storage: RawTransactionArgument<string>,
642
+ ];
643
+ }
644
+ export function addStorageToTreasury(options: AddStorageToTreasuryOptions) {
645
+ const packageAddress = options.package ?? "@local-pkg/zing_studio";
646
+ const argumentsTypes = [
647
+ `${packageAddress}::storage::StorageTreasury`,
648
+ `${packageAddress}::config::Config`,
649
+ `${packageAddress}::system::System`,
650
+ `${packageAddress}::storage_resource::Storage`,
651
+ ] satisfies string[];
652
+ const parameterNames = ["self", "config", "walrusSystem", "storage"];
653
+ return (tx: Transaction) =>
654
+ tx.moveCall({
655
+ package: packageAddress,
656
+ module: "storage",
657
+ function: "add_storage_to_treasury",
658
+ arguments: normalizeMoveArguments(
659
+ options.arguments,
660
+ argumentsTypes,
661
+ parameterNames,
662
+ ),
663
+ });
664
+ }