@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.
- package/README.md +12 -0
- package/package.json +37 -0
- package/src/_generated/index.js +6 -0
- package/src/_generated/utils/index.ts +181 -0
- package/src/_generated/zing_framework/coin_utils.ts +41 -0
- package/src/_generated/zing_framework/deps/sui/object.ts +16 -0
- package/src/_generated/zing_framework/derived_object_bag.ts +400 -0
- package/src/_generated/zing_framework/derived_table.ts +366 -0
- package/src/_generated/zing_governance/admin.ts +47 -0
- package/src/_generated/zing_governance/deps/sui/object.ts +16 -0
- package/src/_generated/zing_governance/treasury.ts +134 -0
- package/src/_generated/zing_identity/config.ts +191 -0
- package/src/_generated/zing_identity/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_identity/deps/sui/object.ts +16 -0
- package/src/_generated/zing_identity/deps/sui/object_table.ts +26 -0
- package/src/_generated/zing_identity/deps/sui/table.ts +38 -0
- package/src/_generated/zing_identity/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_identity/ecdsa.ts +166 -0
- package/src/_generated/zing_identity/identity.ts +661 -0
- package/src/_generated/zing_identity/reclaim.ts +803 -0
- package/src/_generated/zing_studio/app.ts +855 -0
- package/src/_generated/zing_studio/article.ts +598 -0
- package/src/_generated/zing_studio/config.ts +475 -0
- package/src/_generated/zing_studio/deps/std/type_name.ts +25 -0
- package/src/_generated/zing_studio/deps/sui/bag.ts +43 -0
- package/src/_generated/zing_studio/deps/sui/balance.ts +20 -0
- package/src/_generated/zing_studio/deps/sui/coin.ts +21 -0
- package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +272 -0
- package/src/_generated/zing_studio/deps/sui/object.ts +16 -0
- package/src/_generated/zing_studio/deps/sui/table.ts +38 -0
- package/src/_generated/zing_studio/deps/sui/vec_map.ts +39 -0
- package/src/_generated/zing_studio/deps/sui/vec_set.ts +28 -0
- package/src/_generated/zing_studio/deps/walrus/blob.ts +22 -0
- package/src/_generated/zing_studio/deps/walrus/events.ts +124 -0
- package/src/_generated/zing_studio/deps/walrus/metadata.ts +137 -0
- package/src/_generated/zing_studio/deps/walrus/storage_resource.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts +17 -0
- package/src/_generated/zing_studio/deps/zing_framework/derived_table.ts +17 -0
- package/src/_generated/zing_studio/donation.ts +18 -0
- package/src/_generated/zing_studio/enclave.ts +466 -0
- package/src/_generated/zing_studio/nitro_attestation.ts +308 -0
- package/src/_generated/zing_studio/referral.ts +447 -0
- package/src/_generated/zing_studio/storage.ts +664 -0
- package/src/_generated/zing_studio/studio.ts +682 -0
- package/src/bcs.ts +139 -0
- package/src/client/index.ts +557 -0
- package/src/client/types.ts +28 -0
- package/src/components/index.ts +3 -0
- package/src/components/wallet-provider.tsx +53 -0
- package/src/components/walrus-provider.tsx +212 -0
- package/src/components/zing-provider.tsx +54 -0
- package/src/config/common.ts +82 -0
- package/src/config/index.ts +45 -0
- package/src/config/mainnet.ts +109 -0
- package/src/config/testnet.ts +111 -0
- package/src/config/types.ts +69 -0
- package/src/const.ts +32 -0
- package/src/getters.ts +523 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/useGetStudio.ts +22 -0
- package/src/hooks/useGetTierPlan.ts +115 -0
- package/src/hooks/useReclaim.ts +165 -0
- package/src/hooks/useSignAndExecuteTransaction.ts +57 -0
- package/src/hooks/useSignPersonalMessage.ts +28 -0
- package/src/hooks/useZingInfiniteQueries.ts +92 -0
- package/src/hooks/useZingMutation.ts +66 -0
- package/src/hooks/useZingQueries.ts +107 -0
- package/src/hooks/useZingQuery.ts +88 -0
- package/src/index.ts +15 -0
- package/src/lib/utils/colorful-logger.ts +27 -0
- package/src/lib/utils/const.ts +25 -0
- package/src/lib/utils/helpers.ts +78 -0
- package/src/lib/utils/index.ts +5 -0
- package/src/lib/utils/init-app-with-shadow.ts +42 -0
- package/src/lib/utils/quilt.ts +317 -0
- package/src/lib/utils/reclaim.ts +148 -0
- package/src/lib/utils/types.ts +14 -0
- package/src/mutations/index.ts +3 -0
- package/src/mutations/seal.ts +78 -0
- package/src/mutations/signer.ts +241 -0
- package/src/mutations/walrus.ts +862 -0
- package/src/stores/index.ts +3 -0
- package/src/stores/walletStore.ts +360 -0
- package/src/stores/walrusStore.ts +118 -0
- package/src/stores/zkloginStore.ts +53 -0
- package/src/types.ts +120 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import * as object from "./object.js";
|
|
2
|
+
import { MoveStruct, normalizeMoveArguments } from "../../../utils/index.js";
|
|
3
|
+
import type { RawTransactionArgument } from "../../../utils/index.js";
|
|
4
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
5
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
6
|
+
|
|
7
|
+
const $moduleName = "@local-pkg/suiii::dynamic_field";
|
|
8
|
+
/** Internal object used for storing the field and value */
|
|
9
|
+
export function Field<Name extends BcsType<any>, Value extends BcsType<any>>(
|
|
10
|
+
...typeParameters: [Name, Value]
|
|
11
|
+
) {
|
|
12
|
+
return new MoveStruct({
|
|
13
|
+
name: `${$moduleName}::Field<${typeParameters[0].name as Name["name"]}, ${typeParameters[1].name as Value["name"]}>`,
|
|
14
|
+
fields: {
|
|
15
|
+
/**
|
|
16
|
+
* Determined by the hash of the object ID, the field name value and it's type,
|
|
17
|
+
* i.e. hash(parent.id || name || Name)
|
|
18
|
+
*/
|
|
19
|
+
id: object.UID,
|
|
20
|
+
/** The value for the name of this field */
|
|
21
|
+
name: typeParameters[0],
|
|
22
|
+
/** The value bound to this field */
|
|
23
|
+
value: typeParameters[1],
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export interface BorrowArguments<Name extends BcsType<any>> {
|
|
28
|
+
object: RawTransactionArgument<string>;
|
|
29
|
+
name: RawTransactionArgument<Name>;
|
|
30
|
+
}
|
|
31
|
+
export interface BorrowOptions<Name extends BcsType<any>> {
|
|
32
|
+
package?: string;
|
|
33
|
+
arguments:
|
|
34
|
+
| BorrowArguments<Name>
|
|
35
|
+
| [
|
|
36
|
+
object: RawTransactionArgument<string>,
|
|
37
|
+
name: RawTransactionArgument<Name>,
|
|
38
|
+
];
|
|
39
|
+
typeArguments: [string, string];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Immutably borrows the `object`s dynamic field with the name specified by
|
|
43
|
+
* `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a
|
|
44
|
+
* field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but
|
|
45
|
+
* the value does not have the specified type.
|
|
46
|
+
*/
|
|
47
|
+
export function borrow<Name extends BcsType<any>>(
|
|
48
|
+
options: BorrowOptions<Name>,
|
|
49
|
+
) {
|
|
50
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
51
|
+
const argumentsTypes = [
|
|
52
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
53
|
+
`${options.typeArguments[0]}`,
|
|
54
|
+
] satisfies string[];
|
|
55
|
+
const parameterNames = ["object", "name"];
|
|
56
|
+
return (tx: Transaction) =>
|
|
57
|
+
tx.moveCall({
|
|
58
|
+
package: packageAddress,
|
|
59
|
+
module: "dynamic_field",
|
|
60
|
+
function: "borrow",
|
|
61
|
+
arguments: normalizeMoveArguments(
|
|
62
|
+
options.arguments,
|
|
63
|
+
argumentsTypes,
|
|
64
|
+
parameterNames,
|
|
65
|
+
),
|
|
66
|
+
typeArguments: options.typeArguments,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export interface BorrowMutArguments<Name extends BcsType<any>> {
|
|
70
|
+
object: RawTransactionArgument<string>;
|
|
71
|
+
name: RawTransactionArgument<Name>;
|
|
72
|
+
}
|
|
73
|
+
export interface BorrowMutOptions<Name extends BcsType<any>> {
|
|
74
|
+
package?: string;
|
|
75
|
+
arguments:
|
|
76
|
+
| BorrowMutArguments<Name>
|
|
77
|
+
| [
|
|
78
|
+
object: RawTransactionArgument<string>,
|
|
79
|
+
name: RawTransactionArgument<Name>,
|
|
80
|
+
];
|
|
81
|
+
typeArguments: [string, string];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Mutably borrows the `object`s dynamic field with the name specified by
|
|
85
|
+
* `name: Name`. Aborts with `EFieldDoesNotExist` if the object does not have a
|
|
86
|
+
* field with that name. Aborts with `EFieldTypeMismatch` if the field exists, but
|
|
87
|
+
* the value does not have the specified type.
|
|
88
|
+
*/
|
|
89
|
+
export function borrowMut<Name extends BcsType<any>>(
|
|
90
|
+
options: BorrowMutOptions<Name>,
|
|
91
|
+
) {
|
|
92
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
93
|
+
const argumentsTypes = [
|
|
94
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
95
|
+
`${options.typeArguments[0]}`,
|
|
96
|
+
] satisfies string[];
|
|
97
|
+
const parameterNames = ["object", "name"];
|
|
98
|
+
return (tx: Transaction) =>
|
|
99
|
+
tx.moveCall({
|
|
100
|
+
package: packageAddress,
|
|
101
|
+
module: "dynamic_field",
|
|
102
|
+
function: "borrow_mut",
|
|
103
|
+
arguments: normalizeMoveArguments(
|
|
104
|
+
options.arguments,
|
|
105
|
+
argumentsTypes,
|
|
106
|
+
parameterNames,
|
|
107
|
+
),
|
|
108
|
+
typeArguments: options.typeArguments,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export interface RemoveArguments<Name extends BcsType<any>> {
|
|
112
|
+
object: RawTransactionArgument<string>;
|
|
113
|
+
name: RawTransactionArgument<Name>;
|
|
114
|
+
}
|
|
115
|
+
export interface RemoveOptions<Name extends BcsType<any>> {
|
|
116
|
+
package?: string;
|
|
117
|
+
arguments:
|
|
118
|
+
| RemoveArguments<Name>
|
|
119
|
+
| [
|
|
120
|
+
object: RawTransactionArgument<string>,
|
|
121
|
+
name: RawTransactionArgument<Name>,
|
|
122
|
+
];
|
|
123
|
+
typeArguments: [string, string];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Removes the `object`s dynamic field with the name specified by `name: Name` and
|
|
127
|
+
* returns the bound value. Aborts with `EFieldDoesNotExist` if the object does not
|
|
128
|
+
* have a field with that name. Aborts with `EFieldTypeMismatch` if the field
|
|
129
|
+
* exists, but the value does not have the specified type.
|
|
130
|
+
*/
|
|
131
|
+
export function remove<Name extends BcsType<any>>(
|
|
132
|
+
options: RemoveOptions<Name>,
|
|
133
|
+
) {
|
|
134
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
135
|
+
const argumentsTypes = [
|
|
136
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
137
|
+
`${options.typeArguments[0]}`,
|
|
138
|
+
] satisfies string[];
|
|
139
|
+
const parameterNames = ["object", "name"];
|
|
140
|
+
return (tx: Transaction) =>
|
|
141
|
+
tx.moveCall({
|
|
142
|
+
package: packageAddress,
|
|
143
|
+
module: "dynamic_field",
|
|
144
|
+
function: "remove",
|
|
145
|
+
arguments: normalizeMoveArguments(
|
|
146
|
+
options.arguments,
|
|
147
|
+
argumentsTypes,
|
|
148
|
+
parameterNames,
|
|
149
|
+
),
|
|
150
|
+
typeArguments: options.typeArguments,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
export interface Exists_Arguments<Name extends BcsType<any>> {
|
|
154
|
+
object: RawTransactionArgument<string>;
|
|
155
|
+
name: RawTransactionArgument<Name>;
|
|
156
|
+
}
|
|
157
|
+
export interface Exists_Options<Name extends BcsType<any>> {
|
|
158
|
+
package?: string;
|
|
159
|
+
arguments:
|
|
160
|
+
| Exists_Arguments<Name>
|
|
161
|
+
| [
|
|
162
|
+
object: RawTransactionArgument<string>,
|
|
163
|
+
name: RawTransactionArgument<Name>,
|
|
164
|
+
];
|
|
165
|
+
typeArguments: [string];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Returns true if and only if the `object` has a dynamic field with the name
|
|
169
|
+
* specified by `name: Name` but without specifying the `Value` type
|
|
170
|
+
*/
|
|
171
|
+
export function exists_<Name extends BcsType<any>>(
|
|
172
|
+
options: Exists_Options<Name>,
|
|
173
|
+
) {
|
|
174
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
175
|
+
const argumentsTypes = [
|
|
176
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
177
|
+
`${options.typeArguments[0]}`,
|
|
178
|
+
] satisfies string[];
|
|
179
|
+
const parameterNames = ["object", "name"];
|
|
180
|
+
return (tx: Transaction) =>
|
|
181
|
+
tx.moveCall({
|
|
182
|
+
package: packageAddress,
|
|
183
|
+
module: "dynamic_field",
|
|
184
|
+
function: "exists_",
|
|
185
|
+
arguments: normalizeMoveArguments(
|
|
186
|
+
options.arguments,
|
|
187
|
+
argumentsTypes,
|
|
188
|
+
parameterNames,
|
|
189
|
+
),
|
|
190
|
+
typeArguments: options.typeArguments,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
export interface RemoveIfExistsArguments<Name extends BcsType<any>> {
|
|
194
|
+
object: RawTransactionArgument<string>;
|
|
195
|
+
name: RawTransactionArgument<Name>;
|
|
196
|
+
}
|
|
197
|
+
export interface RemoveIfExistsOptions<Name extends BcsType<any>> {
|
|
198
|
+
package?: string;
|
|
199
|
+
arguments:
|
|
200
|
+
| RemoveIfExistsArguments<Name>
|
|
201
|
+
| [
|
|
202
|
+
object: RawTransactionArgument<string>,
|
|
203
|
+
name: RawTransactionArgument<Name>,
|
|
204
|
+
];
|
|
205
|
+
typeArguments: [string, string];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Removes the dynamic field if it exists. Returns the `some(Value)` if it exists
|
|
209
|
+
* or none otherwise.
|
|
210
|
+
*/
|
|
211
|
+
export function removeIfExists<Name extends BcsType<any>>(
|
|
212
|
+
options: RemoveIfExistsOptions<Name>,
|
|
213
|
+
) {
|
|
214
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
215
|
+
const argumentsTypes = [
|
|
216
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
217
|
+
`${options.typeArguments[0]}`,
|
|
218
|
+
] satisfies string[];
|
|
219
|
+
const parameterNames = ["object", "name"];
|
|
220
|
+
return (tx: Transaction) =>
|
|
221
|
+
tx.moveCall({
|
|
222
|
+
package: packageAddress,
|
|
223
|
+
module: "dynamic_field",
|
|
224
|
+
function: "remove_if_exists",
|
|
225
|
+
arguments: normalizeMoveArguments(
|
|
226
|
+
options.arguments,
|
|
227
|
+
argumentsTypes,
|
|
228
|
+
parameterNames,
|
|
229
|
+
),
|
|
230
|
+
typeArguments: options.typeArguments,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export interface ExistsWithTypeArguments<Name extends BcsType<any>> {
|
|
234
|
+
object: RawTransactionArgument<string>;
|
|
235
|
+
name: RawTransactionArgument<Name>;
|
|
236
|
+
}
|
|
237
|
+
export interface ExistsWithTypeOptions<Name extends BcsType<any>> {
|
|
238
|
+
package?: string;
|
|
239
|
+
arguments:
|
|
240
|
+
| ExistsWithTypeArguments<Name>
|
|
241
|
+
| [
|
|
242
|
+
object: RawTransactionArgument<string>,
|
|
243
|
+
name: RawTransactionArgument<Name>,
|
|
244
|
+
];
|
|
245
|
+
typeArguments: [string, string];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Returns true if and only if the `object` has a dynamic field with the name
|
|
249
|
+
* specified by `name: Name` with an assigned value of type `Value`.
|
|
250
|
+
*/
|
|
251
|
+
export function existsWithType<Name extends BcsType<any>>(
|
|
252
|
+
options: ExistsWithTypeOptions<Name>,
|
|
253
|
+
) {
|
|
254
|
+
const packageAddress = options.package ?? "@local-pkg/suiii";
|
|
255
|
+
const argumentsTypes = [
|
|
256
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
257
|
+
`${options.typeArguments[0]}`,
|
|
258
|
+
] satisfies string[];
|
|
259
|
+
const parameterNames = ["object", "name"];
|
|
260
|
+
return (tx: Transaction) =>
|
|
261
|
+
tx.moveCall({
|
|
262
|
+
package: packageAddress,
|
|
263
|
+
module: "dynamic_field",
|
|
264
|
+
function: "exists_with_type",
|
|
265
|
+
arguments: normalizeMoveArguments(
|
|
266
|
+
options.arguments,
|
|
267
|
+
argumentsTypes,
|
|
268
|
+
parameterNames,
|
|
269
|
+
),
|
|
270
|
+
typeArguments: options.typeArguments,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/** Sui object identifiers */
|
|
6
|
+
|
|
7
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
8
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
9
|
+
|
|
10
|
+
const $moduleName = "0x2::object";
|
|
11
|
+
export const UID = new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::UID`,
|
|
13
|
+
fields: {
|
|
14
|
+
id: bcs.Address,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A table is a map-like collection. But unlike a traditional collection, it's keys
|
|
7
|
+
* and values are not stored within the `Table` value, but instead are stored using
|
|
8
|
+
* Sui's object system. The `Table` struct acts only as a handle into the object
|
|
9
|
+
* system to retrieve those keys and values. Note that this means that `Table`
|
|
10
|
+
* values with exactly the same key-value mapping will not be equal, with `==`, at
|
|
11
|
+
* runtime. For example
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* let table1 = table::new<u64, bool>();
|
|
15
|
+
* let table2 = table::new<u64, bool>();
|
|
16
|
+
* table::add(&mut table1, 0, false);
|
|
17
|
+
* table::add(&mut table1, 1, true);
|
|
18
|
+
* table::add(&mut table2, 0, false);
|
|
19
|
+
* table::add(&mut table2, 1, true);
|
|
20
|
+
* // table1 does not equal table2, despite having the same entries
|
|
21
|
+
* assert!(&table1 != &table2);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import * as object from "./object.js";
|
|
26
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
27
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
28
|
+
|
|
29
|
+
const $moduleName = "0x2::table";
|
|
30
|
+
export const Table = new MoveStruct({
|
|
31
|
+
name: `${$moduleName}::Table`,
|
|
32
|
+
fields: {
|
|
33
|
+
/** the ID of this table */
|
|
34
|
+
id: object.UID,
|
|
35
|
+
/** the number of key-value pairs in the table */
|
|
36
|
+
size: bcs.u64(),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
5
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
6
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
const $moduleName = "0x2::vec_map";
|
|
9
|
+
/** An entry in the map */
|
|
10
|
+
export function Entry<K extends BcsType<any>, V extends BcsType<any>>(
|
|
11
|
+
...typeParameters: [K, V]
|
|
12
|
+
) {
|
|
13
|
+
return new MoveStruct({
|
|
14
|
+
name: `${$moduleName}::Entry<${typeParameters[0].name as K["name"]}, ${typeParameters[1].name as V["name"]}>`,
|
|
15
|
+
fields: {
|
|
16
|
+
key: typeParameters[0],
|
|
17
|
+
value: typeParameters[1],
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
23
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
24
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
25
|
+
* of this data structure is only to provide the convenience of programming against
|
|
26
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
27
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
28
|
+
* also be handwritten.
|
|
29
|
+
*/
|
|
30
|
+
export function VecMap<K extends BcsType<any>, V extends BcsType<any>>(
|
|
31
|
+
...typeParameters: [K, V]
|
|
32
|
+
) {
|
|
33
|
+
return new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::VecMap<${typeParameters[0].name as K["name"]}, ${typeParameters[1].name as V["name"]}>`,
|
|
35
|
+
fields: {
|
|
36
|
+
contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
5
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
6
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
const $moduleName = "0x2::vec_set";
|
|
9
|
+
/**
|
|
10
|
+
* A set data structure backed by a vector. The set is guaranteed not to contain
|
|
11
|
+
* duplicate keys. All operations are O(N) in the size of the set
|
|
12
|
+
*
|
|
13
|
+
* - the intention of this data structure is only to provide the convenience of
|
|
14
|
+
* programming against a set API. Sets that need sorted iteration rather than
|
|
15
|
+
* insertion order iteration should be handwritten.
|
|
16
|
+
*/
|
|
17
|
+
export function VecSet<K extends BcsType<any>>(
|
|
18
|
+
...typeParameters: [K]
|
|
19
|
+
): MoveStruct<{
|
|
20
|
+
contents: ReturnType<typeof bcs.vector<K>>;
|
|
21
|
+
}> {
|
|
22
|
+
return new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::VecSet<${typeParameters[0].name as K["name"]}>`,
|
|
24
|
+
fields: {
|
|
25
|
+
contents: bcs.vector(typeParameters[0]),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import * as storage_resource from "./storage_resource.js";
|
|
5
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
6
|
+
import * as object from "../sui/object.js";
|
|
7
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
8
|
+
|
|
9
|
+
const $moduleName = "walrus::blob";
|
|
10
|
+
export const Blob = new MoveStruct({
|
|
11
|
+
name: `${$moduleName}::Blob`,
|
|
12
|
+
fields: {
|
|
13
|
+
id: object.UID,
|
|
14
|
+
registered_epoch: bcs.u32(),
|
|
15
|
+
blob_id: bcs.u256(),
|
|
16
|
+
size: bcs.u64(),
|
|
17
|
+
encoding_type: bcs.u8(),
|
|
18
|
+
certified_epoch: bcs.option(bcs.u32()),
|
|
19
|
+
storage: storage_resource.Storage,
|
|
20
|
+
deletable: bcs.bool(),
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
const $moduleName = "@local-pkg/walrus::events";
|
|
5
|
+
|
|
6
|
+
export const BlobRegistered = new MoveStruct({
|
|
7
|
+
name: `${$moduleName}::BlobRegistered`,
|
|
8
|
+
fields: {
|
|
9
|
+
epoch: bcs.u32(),
|
|
10
|
+
blob_id: bcs.u256(),
|
|
11
|
+
size: bcs.u64(),
|
|
12
|
+
encoding_type: bcs.u8(),
|
|
13
|
+
end_epoch: bcs.u32(),
|
|
14
|
+
deletable: bcs.bool(),
|
|
15
|
+
object_id: bcs.Address,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export const BlobCertified = new MoveStruct({
|
|
19
|
+
name: `${$moduleName}::BlobCertified`,
|
|
20
|
+
fields: {
|
|
21
|
+
epoch: bcs.u32(),
|
|
22
|
+
blob_id: bcs.u256(),
|
|
23
|
+
end_epoch: bcs.u32(),
|
|
24
|
+
deletable: bcs.bool(),
|
|
25
|
+
object_id: bcs.Address,
|
|
26
|
+
is_extension: bcs.bool(),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
export const BlobDeleted = new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::BlobDeleted`,
|
|
31
|
+
fields: {
|
|
32
|
+
epoch: bcs.u32(),
|
|
33
|
+
blob_id: bcs.u256(),
|
|
34
|
+
end_epoch: bcs.u32(),
|
|
35
|
+
object_id: bcs.Address,
|
|
36
|
+
was_certified: bcs.bool(),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export const InvalidBlobID = new MoveStruct({
|
|
40
|
+
name: `${$moduleName}::InvalidBlobID`,
|
|
41
|
+
fields: {
|
|
42
|
+
epoch: bcs.u32(),
|
|
43
|
+
blob_id: bcs.u256(),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export const EpochChangeStart = new MoveStruct({
|
|
47
|
+
name: `${$moduleName}::EpochChangeStart`,
|
|
48
|
+
fields: {
|
|
49
|
+
epoch: bcs.u32(),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
export const EpochChangeDone = new MoveStruct({
|
|
53
|
+
name: `${$moduleName}::EpochChangeDone`,
|
|
54
|
+
fields: {
|
|
55
|
+
epoch: bcs.u32(),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
export const ShardsReceived = new MoveStruct({
|
|
59
|
+
name: `${$moduleName}::ShardsReceived`,
|
|
60
|
+
fields: {
|
|
61
|
+
epoch: bcs.u32(),
|
|
62
|
+
shards: bcs.vector(bcs.u16()),
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
export const EpochParametersSelected = new MoveStruct({
|
|
66
|
+
name: `${$moduleName}::EpochParametersSelected`,
|
|
67
|
+
fields: {
|
|
68
|
+
next_epoch: bcs.u32(),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
export const ShardRecoveryStart = new MoveStruct({
|
|
72
|
+
name: `${$moduleName}::ShardRecoveryStart`,
|
|
73
|
+
fields: {
|
|
74
|
+
epoch: bcs.u32(),
|
|
75
|
+
shards: bcs.vector(bcs.u16()),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
export const ContractUpgraded = new MoveStruct({
|
|
79
|
+
name: `${$moduleName}::ContractUpgraded`,
|
|
80
|
+
fields: {
|
|
81
|
+
epoch: bcs.u32(),
|
|
82
|
+
package_id: bcs.Address,
|
|
83
|
+
version: bcs.u64(),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
export const RegisterDenyListUpdate = new MoveStruct({
|
|
87
|
+
name: `${$moduleName}::RegisterDenyListUpdate`,
|
|
88
|
+
fields: {
|
|
89
|
+
epoch: bcs.u32(),
|
|
90
|
+
root: bcs.u256(),
|
|
91
|
+
sequence_number: bcs.u64(),
|
|
92
|
+
node_id: bcs.Address,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
export const DenyListUpdate = new MoveStruct({
|
|
96
|
+
name: `${$moduleName}::DenyListUpdate`,
|
|
97
|
+
fields: {
|
|
98
|
+
epoch: bcs.u32(),
|
|
99
|
+
root: bcs.u256(),
|
|
100
|
+
sequence_number: bcs.u64(),
|
|
101
|
+
node_id: bcs.Address,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
export const DenyListBlobDeleted = new MoveStruct({
|
|
105
|
+
name: `${$moduleName}::DenyListBlobDeleted`,
|
|
106
|
+
fields: {
|
|
107
|
+
epoch: bcs.u32(),
|
|
108
|
+
blob_id: bcs.u256(),
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
export const ContractUpgradeProposed = new MoveStruct({
|
|
112
|
+
name: `${$moduleName}::ContractUpgradeProposed`,
|
|
113
|
+
fields: {
|
|
114
|
+
epoch: bcs.u32(),
|
|
115
|
+
package_digest: bcs.vector(bcs.u8()),
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
export const ContractUpgradeQuorumReached = new MoveStruct({
|
|
119
|
+
name: `${$moduleName}::ContractUpgradeQuorumReached`,
|
|
120
|
+
fields: {
|
|
121
|
+
epoch: bcs.u32(),
|
|
122
|
+
package_digest: bcs.vector(bcs.u8()),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { MoveStruct, normalizeMoveArguments } from "../../../utils/index.js";
|
|
2
|
+
import * as vec_map from "../sui/vec_map.js";
|
|
3
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
4
|
+
import type { RawTransactionArgument } from "../../../utils/index.js";
|
|
5
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
6
|
+
|
|
7
|
+
const $moduleName = "@local-pkg/walrus::metadata";
|
|
8
|
+
export const Metadata = new MoveStruct({
|
|
9
|
+
name: `${$moduleName}::Metadata`,
|
|
10
|
+
fields: {
|
|
11
|
+
metadata: vec_map.VecMap(bcs.string(), bcs.string()),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export interface NewOptions {
|
|
15
|
+
package?: string;
|
|
16
|
+
arguments?: [];
|
|
17
|
+
}
|
|
18
|
+
/** Creates a new instance of Metadata. */
|
|
19
|
+
export function _new(options: NewOptions = {}) {
|
|
20
|
+
const packageAddress = options.package ?? "@local-pkg/walrus";
|
|
21
|
+
return (tx: Transaction) =>
|
|
22
|
+
tx.moveCall({
|
|
23
|
+
package: packageAddress,
|
|
24
|
+
module: "metadata",
|
|
25
|
+
function: "new",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export interface InsertOrUpdateArguments {
|
|
29
|
+
self: RawTransactionArgument<string>;
|
|
30
|
+
key: RawTransactionArgument<string>;
|
|
31
|
+
value: RawTransactionArgument<string>;
|
|
32
|
+
}
|
|
33
|
+
export interface InsertOrUpdateOptions {
|
|
34
|
+
package?: string;
|
|
35
|
+
arguments:
|
|
36
|
+
| InsertOrUpdateArguments
|
|
37
|
+
| [
|
|
38
|
+
self: RawTransactionArgument<string>,
|
|
39
|
+
key: RawTransactionArgument<string>,
|
|
40
|
+
value: RawTransactionArgument<string>,
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Inserts a key-value pair into the metadata.
|
|
45
|
+
*
|
|
46
|
+
* If the key is already present, the value is updated.
|
|
47
|
+
*/
|
|
48
|
+
export function insertOrUpdate(options: InsertOrUpdateOptions) {
|
|
49
|
+
const packageAddress = options.package ?? "@local-pkg/walrus";
|
|
50
|
+
const argumentsTypes = [
|
|
51
|
+
`${packageAddress}::metadata::Metadata`,
|
|
52
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::string::String",
|
|
53
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::string::String",
|
|
54
|
+
] satisfies string[];
|
|
55
|
+
const parameterNames = ["self", "key", "value"];
|
|
56
|
+
return (tx: Transaction) =>
|
|
57
|
+
tx.moveCall({
|
|
58
|
+
package: packageAddress,
|
|
59
|
+
module: "metadata",
|
|
60
|
+
function: "insert_or_update",
|
|
61
|
+
arguments: normalizeMoveArguments(
|
|
62
|
+
options.arguments,
|
|
63
|
+
argumentsTypes,
|
|
64
|
+
parameterNames,
|
|
65
|
+
),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export interface RemoveArguments {
|
|
69
|
+
self: RawTransactionArgument<string>;
|
|
70
|
+
key: RawTransactionArgument<string>;
|
|
71
|
+
}
|
|
72
|
+
export interface RemoveOptions {
|
|
73
|
+
package?: string;
|
|
74
|
+
arguments:
|
|
75
|
+
| RemoveArguments
|
|
76
|
+
| [
|
|
77
|
+
self: RawTransactionArgument<string>,
|
|
78
|
+
key: RawTransactionArgument<string>,
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
/** Removes the metadata associated with the given key. */
|
|
82
|
+
export function remove(options: RemoveOptions) {
|
|
83
|
+
const packageAddress = options.package ?? "@local-pkg/walrus";
|
|
84
|
+
const argumentsTypes = [
|
|
85
|
+
`${packageAddress}::metadata::Metadata`,
|
|
86
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::string::String",
|
|
87
|
+
] satisfies string[];
|
|
88
|
+
const parameterNames = ["self", "key"];
|
|
89
|
+
return (tx: Transaction) =>
|
|
90
|
+
tx.moveCall({
|
|
91
|
+
package: packageAddress,
|
|
92
|
+
module: "metadata",
|
|
93
|
+
function: "remove",
|
|
94
|
+
arguments: normalizeMoveArguments(
|
|
95
|
+
options.arguments,
|
|
96
|
+
argumentsTypes,
|
|
97
|
+
parameterNames,
|
|
98
|
+
),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export interface RemoveIfExistsArguments {
|
|
102
|
+
self: RawTransactionArgument<string>;
|
|
103
|
+
key: RawTransactionArgument<string>;
|
|
104
|
+
}
|
|
105
|
+
export interface RemoveIfExistsOptions {
|
|
106
|
+
package?: string;
|
|
107
|
+
arguments:
|
|
108
|
+
| RemoveIfExistsArguments
|
|
109
|
+
| [
|
|
110
|
+
self: RawTransactionArgument<string>,
|
|
111
|
+
key: RawTransactionArgument<string>,
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Removes the metadata associated with the given key, if it exists.
|
|
116
|
+
*
|
|
117
|
+
* Optionally returns the previous value associated with the key.
|
|
118
|
+
*/
|
|
119
|
+
export function removeIfExists(options: RemoveIfExistsOptions) {
|
|
120
|
+
const packageAddress = options.package ?? "@local-pkg/walrus";
|
|
121
|
+
const argumentsTypes = [
|
|
122
|
+
`${packageAddress}::metadata::Metadata`,
|
|
123
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001::string::String",
|
|
124
|
+
] satisfies string[];
|
|
125
|
+
const parameterNames = ["self", "key"];
|
|
126
|
+
return (tx: Transaction) =>
|
|
127
|
+
tx.moveCall({
|
|
128
|
+
package: packageAddress,
|
|
129
|
+
module: "metadata",
|
|
130
|
+
function: "remove_if_exists",
|
|
131
|
+
arguments: normalizeMoveArguments(
|
|
132
|
+
options.arguments,
|
|
133
|
+
argumentsTypes,
|
|
134
|
+
parameterNames,
|
|
135
|
+
),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
5
|
+
import * as object from "../sui/object.js";
|
|
6
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
7
|
+
|
|
8
|
+
const $moduleName = "walrus::storage_resource";
|
|
9
|
+
export const Storage = new MoveStruct({
|
|
10
|
+
name: `${$moduleName}::Storage`,
|
|
11
|
+
fields: {
|
|
12
|
+
id: object.UID,
|
|
13
|
+
start_epoch: bcs.u32(),
|
|
14
|
+
end_epoch: bcs.u32(),
|
|
15
|
+
storage_size: bcs.u64(),
|
|
16
|
+
},
|
|
17
|
+
});
|