@zing-protocol/zing-sdk 0.0.1 → 0.0.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.
- package/dist/_generated/index.js +6 -0
- package/dist/_generated/utils/index.d.ts +12 -0
- package/dist/_generated/utils/index.js +135 -0
- package/dist/_generated/zing_framework/coin_utils.d.ts +15 -0
- package/dist/_generated/zing_framework/coin_utils.js +19 -0
- package/dist/_generated/zing_framework/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_governance/deps/sui/object.ts → dist/_generated/zing_framework/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_framework/derived_object_bag.d.ts +166 -0
- package/dist/_generated/zing_framework/derived_object_bag.js +221 -0
- package/dist/_generated/zing_framework/derived_table.d.ts +153 -0
- package/dist/_generated/zing_framework/derived_table.js +200 -0
- package/dist/_generated/zing_governance/admin.d.ts +20 -0
- package/dist/_generated/zing_governance/admin.js +26 -0
- package/dist/_generated/zing_governance/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_identity/deps/sui/object.ts → dist/_generated/zing_governance/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_governance/treasury.d.ts +56 -0
- package/dist/_generated/zing_governance/treasury.js +78 -0
- package/dist/_generated/zing_identity/config.d.ts +87 -0
- package/dist/_generated/zing_identity/config.js +98 -0
- package/{src/_generated/zing_studio/deps/std/type_name.ts → dist/_generated/zing_identity/deps/std/type_name.d.ts} +3 -11
- package/dist/_generated/zing_identity/deps/std/type_name.js +22 -0
- package/dist/_generated/zing_identity/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_studio/deps/sui/object.ts → dist/_generated/zing_identity/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_identity/deps/sui/object_table.d.ts +12 -0
- package/{src/_generated/zing_identity/deps/sui/object_table.ts → dist/_generated/zing_identity/deps/sui/object_table.js} +7 -10
- package/dist/_generated/zing_identity/deps/sui/table.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/table.ts → dist/_generated/zing_identity/deps/sui/table.js} +7 -10
- package/{src/_generated/zing_identity/deps/sui/vec_set.ts → dist/_generated/zing_identity/deps/sui/vec_set.d.ts} +3 -14
- package/dist/_generated/zing_identity/deps/sui/vec_set.js +22 -0
- package/dist/_generated/zing_identity/ecdsa.d.ts +81 -0
- package/dist/_generated/zing_identity/ecdsa.js +87 -0
- package/dist/_generated/zing_identity/identity.d.ts +262 -0
- package/dist/_generated/zing_identity/identity.js +294 -0
- package/dist/_generated/zing_identity/reclaim.d.ts +356 -0
- package/dist/_generated/zing_identity/reclaim.js +414 -0
- package/dist/_generated/zing_studio/app.d.ts +351 -0
- package/dist/_generated/zing_studio/app.js +451 -0
- package/dist/_generated/zing_studio/article.d.ts +331 -0
- package/dist/_generated/zing_studio/article.js +331 -0
- package/dist/_generated/zing_studio/config.d.ts +203 -0
- package/dist/_generated/zing_studio/config.js +233 -0
- package/{src/_generated/zing_identity/deps/std/type_name.ts → dist/_generated/zing_studio/deps/std/type_name.d.ts} +3 -11
- package/dist/_generated/zing_studio/deps/std/type_name.js +22 -0
- package/dist/_generated/zing_studio/deps/sui/bag.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/bag.ts → dist/_generated/zing_studio/deps/sui/bag.js} +7 -10
- package/dist/_generated/zing_studio/deps/sui/balance.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/balance.ts → dist/_generated/zing_studio/deps/sui/balance.js} +4 -7
- package/dist/_generated/zing_studio/deps/sui/coin.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/sui/coin.ts → dist/_generated/zing_studio/deps/sui/coin.js} +5 -8
- package/dist/_generated/zing_studio/deps/sui/dynamic_field.d.ts +126 -0
- package/dist/_generated/zing_studio/deps/sui/dynamic_field.js +140 -0
- package/dist/_generated/zing_studio/deps/sui/object.d.ts +8 -0
- package/{src/_generated/zing_framework/deps/sui/object.ts → dist/_generated/zing_studio/deps/sui/object.js} +4 -7
- package/dist/_generated/zing_studio/deps/sui/table.d.ts +12 -0
- package/{src/_generated/zing_identity/deps/sui/table.ts → dist/_generated/zing_studio/deps/sui/table.js} +7 -10
- package/dist/_generated/zing_studio/deps/sui/vec_map.d.ts +30 -0
- package/{src/_generated/zing_studio/deps/sui/vec_map.ts → dist/_generated/zing_studio/deps/sui/vec_map.js} +15 -21
- package/{src/_generated/zing_studio/deps/sui/vec_set.ts → dist/_generated/zing_studio/deps/sui/vec_set.d.ts} +3 -14
- package/dist/_generated/zing_studio/deps/sui/vec_set.js +22 -0
- package/dist/_generated/zing_studio/deps/walrus/blob.d.ts +20 -0
- package/{src/_generated/zing_studio/deps/walrus/blob.ts → dist/_generated/zing_studio/deps/walrus/blob.js} +11 -12
- package/dist/_generated/zing_studio/deps/walrus/events.d.ts +83 -0
- package/dist/_generated/zing_studio/deps/walrus/events.js +122 -0
- package/dist/_generated/zing_studio/deps/walrus/metadata.d.ts +71 -0
- package/dist/_generated/zing_studio/deps/walrus/metadata.js +73 -0
- package/dist/_generated/zing_studio/deps/walrus/storage_resource.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/walrus/storage_resource.ts → dist/_generated/zing_studio/deps/walrus/storage_resource.js} +7 -8
- package/dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/zing_framework/derived_object_bag.ts → dist/_generated/zing_studio/deps/zing_framework/derived_object_bag.js} +7 -8
- package/dist/_generated/zing_studio/deps/zing_framework/derived_table.d.ts +12 -0
- package/{src/_generated/zing_studio/deps/zing_framework/derived_table.ts → dist/_generated/zing_studio/deps/zing_framework/derived_table.js} +7 -8
- package/dist/_generated/zing_studio/donation.d.ts +24 -0
- package/{src/_generated/zing_studio/donation.ts → dist/_generated/zing_studio/donation.js} +7 -8
- package/dist/_generated/zing_studio/enclave.d.ts +187 -0
- package/dist/_generated/zing_studio/enclave.js +231 -0
- package/dist/_generated/zing_studio/nitro_attestation.d.ts +148 -0
- package/dist/_generated/zing_studio/nitro_attestation.js +183 -0
- package/dist/_generated/zing_studio/referral.d.ts +166 -0
- package/dist/_generated/zing_studio/referral.js +224 -0
- package/dist/_generated/zing_studio/storage.d.ts +327 -0
- package/dist/_generated/zing_studio/storage.js +365 -0
- package/dist/_generated/zing_studio/studio.d.ts +282 -0
- package/dist/_generated/zing_studio/studio.js +360 -0
- package/dist/bcs.d.ts +61 -0
- package/dist/bcs.js +109 -0
- package/dist/client/index.d.ts +228 -0
- package/dist/client/index.js +296 -0
- package/dist/client/types.d.ts +23 -0
- package/dist/client/types.js +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/wallet-provider.d.ts +7 -0
- package/dist/components/wallet-provider.js +33 -0
- package/dist/components/walrus-provider.d.ts +31 -0
- package/dist/components/walrus-provider.js +71 -0
- package/dist/components/zing-provider.d.ts +15 -0
- package/dist/components/zing-provider.js +22 -0
- package/dist/config/common.d.ts +23 -0
- package/dist/config/common.js +61 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +28 -0
- package/dist/config/mainnet.d.ts +6 -0
- package/dist/config/mainnet.js +80 -0
- package/dist/config/testnet.d.ts +6 -0
- package/dist/config/testnet.js +81 -0
- package/dist/config/types.d.ts +49 -0
- package/dist/config/types.js +1 -0
- package/dist/const.d.ts +4 -0
- package/dist/const.js +25 -0
- package/dist/getters.d.ts +228 -0
- package/dist/getters.js +317 -0
- package/{src/hooks/index.ts → dist/hooks/index.d.ts} +2 -3
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useGetStudio.d.ts +26 -0
- package/dist/hooks/useGetStudio.js +17 -0
- package/dist/hooks/useGetTierPlan.d.ts +7 -0
- package/dist/hooks/useGetTierPlan.js +85 -0
- package/dist/hooks/useReclaim.d.ts +12 -0
- package/dist/hooks/useReclaim.js +87 -0
- package/dist/hooks/useSignAndExecuteTransaction.d.ts +6 -0
- package/dist/hooks/useSignAndExecuteTransaction.js +40 -0
- package/dist/hooks/useSignPersonalMessage.d.ts +8 -0
- package/dist/hooks/useSignPersonalMessage.js +21 -0
- package/dist/hooks/useZingInfiniteQueries.d.ts +75 -0
- package/dist/hooks/useZingInfiniteQueries.js +28 -0
- package/dist/hooks/useZingMutation.d.ts +35 -0
- package/dist/hooks/useZingMutation.js +37 -0
- package/dist/hooks/useZingQueries.d.ts +127 -0
- package/dist/hooks/useZingQueries.js +37 -0
- package/dist/hooks/useZingQuery.d.ts +147 -0
- package/dist/hooks/useZingQuery.js +34 -0
- package/{src/index.ts → dist/index.d.ts} +2 -3
- package/dist/index.js +9 -0
- package/dist/lib/utils/colorful-logger.d.ts +2 -0
- package/dist/lib/utils/colorful-logger.js +23 -0
- package/dist/lib/utils/const.d.ts +25 -0
- package/dist/lib/utils/const.js +25 -0
- package/dist/lib/utils/helpers.d.ts +10 -0
- package/dist/lib/utils/helpers.js +49 -0
- package/dist/lib/utils/index.js +4 -0
- package/dist/lib/utils/init-app-with-shadow.d.ts +6 -0
- package/dist/lib/utils/init-app-with-shadow.js +28 -0
- package/dist/lib/utils/quilt.d.ts +61 -0
- package/dist/lib/utils/quilt.js +194 -0
- package/dist/lib/utils/reclaim.d.ts +29 -0
- package/dist/lib/utils/reclaim.js +88 -0
- package/dist/lib/utils/types.d.ts +5 -0
- package/dist/lib/utils/types.js +1 -0
- package/dist/mutations/index.js +3 -0
- package/dist/mutations/seal.d.ts +12 -0
- package/dist/mutations/seal.js +41 -0
- package/dist/mutations/signer.d.ts +10 -0
- package/dist/mutations/signer.js +176 -0
- package/dist/mutations/walrus.d.ts +98 -0
- package/dist/mutations/walrus.js +488 -0
- package/dist/stores/index.js +3 -0
- package/dist/stores/walletStore.d.ts +48 -0
- package/dist/stores/walletStore.js +232 -0
- package/dist/stores/walrusStore.d.ts +28 -0
- package/dist/stores/walrusStore.js +61 -0
- package/dist/stores/zkloginStore.d.ts +28 -0
- package/dist/stores/zkloginStore.js +27 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.js +1 -0
- package/package.json +14 -6
- package/src/_generated/utils/index.ts +0 -181
- package/src/_generated/zing_framework/coin_utils.ts +0 -41
- package/src/_generated/zing_framework/derived_object_bag.ts +0 -400
- package/src/_generated/zing_framework/derived_table.ts +0 -366
- package/src/_generated/zing_governance/admin.ts +0 -47
- package/src/_generated/zing_governance/treasury.ts +0 -134
- package/src/_generated/zing_identity/config.ts +0 -191
- package/src/_generated/zing_identity/ecdsa.ts +0 -166
- package/src/_generated/zing_identity/identity.ts +0 -661
- package/src/_generated/zing_identity/reclaim.ts +0 -803
- package/src/_generated/zing_studio/app.ts +0 -855
- package/src/_generated/zing_studio/article.ts +0 -598
- package/src/_generated/zing_studio/config.ts +0 -475
- package/src/_generated/zing_studio/deps/sui/dynamic_field.ts +0 -272
- package/src/_generated/zing_studio/deps/walrus/events.ts +0 -124
- package/src/_generated/zing_studio/deps/walrus/metadata.ts +0 -137
- package/src/_generated/zing_studio/enclave.ts +0 -466
- package/src/_generated/zing_studio/nitro_attestation.ts +0 -308
- package/src/_generated/zing_studio/referral.ts +0 -447
- package/src/_generated/zing_studio/storage.ts +0 -664
- package/src/_generated/zing_studio/studio.ts +0 -682
- package/src/bcs.ts +0 -139
- package/src/client/index.ts +0 -557
- package/src/client/types.ts +0 -28
- package/src/components/wallet-provider.tsx +0 -53
- package/src/components/walrus-provider.tsx +0 -212
- package/src/components/zing-provider.tsx +0 -54
- package/src/config/common.ts +0 -82
- package/src/config/index.ts +0 -45
- package/src/config/mainnet.ts +0 -109
- package/src/config/testnet.ts +0 -111
- package/src/config/types.ts +0 -69
- package/src/const.ts +0 -32
- package/src/getters.ts +0 -523
- package/src/hooks/useGetStudio.ts +0 -22
- package/src/hooks/useGetTierPlan.ts +0 -115
- package/src/hooks/useReclaim.ts +0 -165
- package/src/hooks/useSignAndExecuteTransaction.ts +0 -57
- package/src/hooks/useSignPersonalMessage.ts +0 -28
- package/src/hooks/useZingInfiniteQueries.ts +0 -92
- package/src/hooks/useZingMutation.ts +0 -66
- package/src/hooks/useZingQueries.ts +0 -107
- package/src/hooks/useZingQuery.ts +0 -88
- package/src/lib/utils/colorful-logger.ts +0 -27
- package/src/lib/utils/const.ts +0 -25
- package/src/lib/utils/helpers.ts +0 -78
- package/src/lib/utils/init-app-with-shadow.ts +0 -42
- package/src/lib/utils/quilt.ts +0 -317
- package/src/lib/utils/reclaim.ts +0 -148
- package/src/lib/utils/types.ts +0 -14
- package/src/mutations/seal.ts +0 -78
- package/src/mutations/signer.ts +0 -241
- package/src/mutations/walrus.ts +0 -862
- package/src/stores/walletStore.ts +0 -360
- package/src/stores/walrusStore.ts +0 -118
- package/src/stores/zkloginStore.ts +0 -53
- package/src/types.ts +0 -120
- package/tsconfig.json +0 -12
- /package/{src/_generated/index.js → dist/_generated/index.d.ts} +0 -0
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/lib/utils/index.ts → dist/lib/utils/index.d.ts} +0 -0
- /package/{src/mutations/index.ts → dist/mutations/index.d.ts} +0 -0
- /package/{src/stores/index.ts → dist/stores/index.d.ts} +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as Reclaim from "./zing_identity/reclaim.js";
|
|
2
|
+
export * as Identity from "./zing_identity/identity.js";
|
|
3
|
+
export * as StudioApp from "./zing_studio/app.js";
|
|
4
|
+
export * as Studio from "./zing_studio/studio.js";
|
|
5
|
+
export * as Article from "./zing_studio/article.js";
|
|
6
|
+
export * as Storage from "./zing_studio/storage.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BcsStruct, BcsEnum, BcsTuple } from "@mysten/sui/bcs";
|
|
2
|
+
import type { BcsType, TypeTag } from "@mysten/sui/bcs";
|
|
3
|
+
import type { TransactionArgument } from "@mysten/sui/transactions";
|
|
4
|
+
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
5
|
+
export declare function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null;
|
|
6
|
+
export declare function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]): TransactionArgument[];
|
|
7
|
+
export declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
8
|
+
}
|
|
9
|
+
export declare class MoveEnum<T extends Record<string, BcsType<any> | null>, const Name extends string> extends BcsEnum<T, Name> {
|
|
10
|
+
}
|
|
11
|
+
export declare class MoveTuple<T extends readonly BcsType<any>[], const Name extends string> extends BcsTuple<T, Name> {
|
|
12
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple, } from "@mysten/sui/bcs";
|
|
2
|
+
import { isArgument } from "@mysten/sui/transactions";
|
|
3
|
+
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
4
|
+
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
|
|
5
|
+
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
|
|
6
|
+
const SUI_SYSTEM_ADDRESS = normalizeSuiAddress("0x3");
|
|
7
|
+
function stringify(val) {
|
|
8
|
+
if (typeof val === "object") {
|
|
9
|
+
return JSON.stringify(val, (val) => val);
|
|
10
|
+
}
|
|
11
|
+
if (typeof val === "bigint") {
|
|
12
|
+
return val.toString();
|
|
13
|
+
}
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
export function getPureBcsSchema(typeTag) {
|
|
17
|
+
const parsedTag = typeof typeTag === "string"
|
|
18
|
+
? TypeTagSerializer.parseFromStr(typeTag)
|
|
19
|
+
: typeTag;
|
|
20
|
+
if ("u8" in parsedTag) {
|
|
21
|
+
return bcs.U8;
|
|
22
|
+
}
|
|
23
|
+
else if ("u16" in parsedTag) {
|
|
24
|
+
return bcs.U16;
|
|
25
|
+
}
|
|
26
|
+
else if ("u32" in parsedTag) {
|
|
27
|
+
return bcs.U32;
|
|
28
|
+
}
|
|
29
|
+
else if ("u64" in parsedTag) {
|
|
30
|
+
return bcs.U64;
|
|
31
|
+
}
|
|
32
|
+
else if ("u128" in parsedTag) {
|
|
33
|
+
return bcs.U128;
|
|
34
|
+
}
|
|
35
|
+
else if ("u256" in parsedTag) {
|
|
36
|
+
return bcs.U256;
|
|
37
|
+
}
|
|
38
|
+
else if ("address" in parsedTag) {
|
|
39
|
+
return bcs.Address;
|
|
40
|
+
}
|
|
41
|
+
else if ("bool" in parsedTag) {
|
|
42
|
+
return bcs.Bool;
|
|
43
|
+
}
|
|
44
|
+
else if ("vector" in parsedTag) {
|
|
45
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
46
|
+
return type ? bcs.vector(type) : null;
|
|
47
|
+
}
|
|
48
|
+
else if ("struct" in parsedTag) {
|
|
49
|
+
const structTag = parsedTag.struct;
|
|
50
|
+
const pkg = normalizeSuiAddress(parsedTag.struct.address);
|
|
51
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
52
|
+
if ((structTag.module === "ascii" || structTag.module === "string") &&
|
|
53
|
+
structTag.name === "String") {
|
|
54
|
+
return bcs.String;
|
|
55
|
+
}
|
|
56
|
+
if (structTag.module === "option" && structTag.name === "Option") {
|
|
57
|
+
const type = getPureBcsSchema(structTag.typeParams[0]);
|
|
58
|
+
return type ? bcs.option(type) : null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS &&
|
|
62
|
+
structTag.module === "Object" &&
|
|
63
|
+
structTag.name === "ID") {
|
|
64
|
+
return bcs.Address;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
export function normalizeMoveArguments(args, argTypes, parameterNames) {
|
|
70
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
71
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
72
|
+
throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
|
|
73
|
+
}
|
|
74
|
+
const normalizedArgs = [];
|
|
75
|
+
let index = 0;
|
|
76
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
77
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
78
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
82
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
86
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
90
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let arg;
|
|
94
|
+
if (Array.isArray(args)) {
|
|
95
|
+
if (index >= args.length) {
|
|
96
|
+
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
97
|
+
}
|
|
98
|
+
arg = args[index];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (!parameterNames) {
|
|
102
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
103
|
+
}
|
|
104
|
+
const name = parameterNames[index];
|
|
105
|
+
arg = args[name];
|
|
106
|
+
if (arg === undefined) {
|
|
107
|
+
throw new Error(`Parameter ${name} is required`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
index += 1;
|
|
111
|
+
if (typeof arg === "function" || isArgument(arg)) {
|
|
112
|
+
normalizedArgs.push(arg);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const type = argTypes[i];
|
|
116
|
+
const bcsType = getPureBcsSchema(type);
|
|
117
|
+
if (bcsType) {
|
|
118
|
+
const bytes = bcsType.serialize(arg);
|
|
119
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
else if (typeof arg === "string") {
|
|
123
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
127
|
+
}
|
|
128
|
+
return normalizedArgs;
|
|
129
|
+
}
|
|
130
|
+
export class MoveStruct extends BcsStruct {
|
|
131
|
+
}
|
|
132
|
+
export class MoveEnum extends BcsEnum {
|
|
133
|
+
}
|
|
134
|
+
export class MoveTuple extends BcsTuple {
|
|
135
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RawTransactionArgument } from "../utils/index.js";
|
|
2
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
3
|
+
export interface BurnOrSendPositiveCoinArguments {
|
|
4
|
+
coin: RawTransactionArgument<string>;
|
|
5
|
+
recipient: RawTransactionArgument<string>;
|
|
6
|
+
}
|
|
7
|
+
export interface BurnOrSendPositiveCoinOptions {
|
|
8
|
+
package?: string;
|
|
9
|
+
arguments: BurnOrSendPositiveCoinArguments | [
|
|
10
|
+
coin: RawTransactionArgument<string>,
|
|
11
|
+
recipient: RawTransactionArgument<string>
|
|
12
|
+
];
|
|
13
|
+
typeArguments: [string];
|
|
14
|
+
}
|
|
15
|
+
export declare function burnOrSendPositiveCoin(options: BurnOrSendPositiveCoinOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { normalizeMoveArguments } from "../utils/index.js";
|
|
5
|
+
export function burnOrSendPositiveCoin(options) {
|
|
6
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
7
|
+
const argumentsTypes = [
|
|
8
|
+
`0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<${options.typeArguments[0]}>`,
|
|
9
|
+
"address",
|
|
10
|
+
];
|
|
11
|
+
const parameterNames = ["coin", "recipient"];
|
|
12
|
+
return (tx) => tx.moveCall({
|
|
13
|
+
package: packageAddress,
|
|
14
|
+
module: "coin_utils",
|
|
15
|
+
function: "burn_or_send_positive_coin",
|
|
16
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
17
|
+
typeArguments: options.typeArguments,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
/** Sui object identifiers */
|
|
5
|
+
import { MoveStruct } from "../../../utils/index.js";
|
|
6
|
+
export declare const UID: MoveStruct<{
|
|
7
|
+
id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
}, "0x2::object::UID">;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**************************************************************
|
|
2
2
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
3
|
**************************************************************/
|
|
4
|
-
|
|
5
4
|
/** Sui object identifiers */
|
|
6
|
-
|
|
7
5
|
import { MoveStruct } from "../../../utils/index.js";
|
|
8
6
|
import { bcs } from "@mysten/sui/bcs";
|
|
9
|
-
|
|
10
7
|
const $moduleName = "0x2::object";
|
|
11
8
|
export const UID = new MoveStruct({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
name: `${$moduleName}::UID`,
|
|
10
|
+
fields: {
|
|
11
|
+
id: bcs.Address,
|
|
12
|
+
},
|
|
16
13
|
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.js";
|
|
2
|
+
import type { RawTransactionArgument } from "../utils/index.js";
|
|
3
|
+
import type { BcsType } from "@mysten/sui/bcs";
|
|
4
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
5
|
+
export declare const DerivedObjectBag: MoveStruct<{
|
|
6
|
+
/** the ID of this bag */
|
|
7
|
+
id: MoveStruct<{
|
|
8
|
+
id: BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
9
|
+
}, "0x2::object::UID">;
|
|
10
|
+
/** the number of key-value pairs in the bag */
|
|
11
|
+
size: BcsType<string, string | number | bigint, "u64">;
|
|
12
|
+
}, "@local-pkg/zing_framework::derived_object_bag::DerivedObjectBag">;
|
|
13
|
+
export interface NewArguments<K extends BcsType<any>> {
|
|
14
|
+
parent: RawTransactionArgument<string>;
|
|
15
|
+
key: RawTransactionArgument<K>;
|
|
16
|
+
}
|
|
17
|
+
export interface NewOptions<K extends BcsType<any>> {
|
|
18
|
+
package?: string;
|
|
19
|
+
arguments: NewArguments<K> | [parent: RawTransactionArgument<string>, key: RawTransactionArgument<K>];
|
|
20
|
+
typeArguments: [string];
|
|
21
|
+
}
|
|
22
|
+
/** Creates a new, empty bag */
|
|
23
|
+
export declare function _new<K extends BcsType<any>>(options: NewOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
24
|
+
export interface AddArguments<K extends BcsType<any>, V extends BcsType<any>> {
|
|
25
|
+
bag: RawTransactionArgument<string>;
|
|
26
|
+
k: RawTransactionArgument<K>;
|
|
27
|
+
v: RawTransactionArgument<V>;
|
|
28
|
+
}
|
|
29
|
+
export interface AddOptions<K extends BcsType<any>, V extends BcsType<any>> {
|
|
30
|
+
package?: string;
|
|
31
|
+
arguments: AddArguments<K, V> | [
|
|
32
|
+
bag: RawTransactionArgument<string>,
|
|
33
|
+
k: RawTransactionArgument<K>,
|
|
34
|
+
v: RawTransactionArgument<V>
|
|
35
|
+
];
|
|
36
|
+
typeArguments: [string, string];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Adds a key-value pair to the bag `bag: &mut DerivedObjectBag` Aborts with
|
|
40
|
+
* `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with
|
|
41
|
+
* that key `k: K`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function add<K extends BcsType<any>, V extends BcsType<any>>(options: AddOptions<K, V>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
44
|
+
export interface BorrowArguments<K extends BcsType<any>> {
|
|
45
|
+
bag: RawTransactionArgument<string>;
|
|
46
|
+
k: RawTransactionArgument<K>;
|
|
47
|
+
}
|
|
48
|
+
export interface BorrowOptions<K extends BcsType<any>> {
|
|
49
|
+
package?: string;
|
|
50
|
+
arguments: BorrowArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
51
|
+
typeArguments: [string, string];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Immutably borrows the value associated with the key in the bag
|
|
55
|
+
* `bag: &DerivedObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist`
|
|
56
|
+
* if the bag does not have an entry with that key `k: K`. Aborts with
|
|
57
|
+
* `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key,
|
|
58
|
+
* but the value does not have the specified type.
|
|
59
|
+
*/
|
|
60
|
+
export declare function borrow<K extends BcsType<any>>(options: BorrowOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
61
|
+
export interface BorrowMutArguments<K extends BcsType<any>> {
|
|
62
|
+
bag: RawTransactionArgument<string>;
|
|
63
|
+
k: RawTransactionArgument<K>;
|
|
64
|
+
}
|
|
65
|
+
export interface BorrowMutOptions<K extends BcsType<any>> {
|
|
66
|
+
package?: string;
|
|
67
|
+
arguments: BorrowMutArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
68
|
+
typeArguments: [string, string];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Mutably borrows the value associated with the key in the bag
|
|
72
|
+
* `bag: &mut DerivedObjectBag`. Aborts with
|
|
73
|
+
* `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an entry with
|
|
74
|
+
* that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` if the bag
|
|
75
|
+
* has an entry for the key, but the value does not have the specified type.
|
|
76
|
+
*/
|
|
77
|
+
export declare function borrowMut<K extends BcsType<any>>(options: BorrowMutOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
78
|
+
export interface RemoveArguments<K extends BcsType<any>> {
|
|
79
|
+
bag: RawTransactionArgument<string>;
|
|
80
|
+
k: RawTransactionArgument<K>;
|
|
81
|
+
}
|
|
82
|
+
export interface RemoveOptions<K extends BcsType<any>> {
|
|
83
|
+
package?: string;
|
|
84
|
+
arguments: RemoveArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
85
|
+
typeArguments: [string, string];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Mutably borrows the key-value pair in the bag `bag: &mut DerivedObjectBag` and
|
|
89
|
+
* returns the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the
|
|
90
|
+
* bag does not have an entry with that key `k: K`. Aborts with
|
|
91
|
+
* `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key,
|
|
92
|
+
* but the value does not have the specified type.
|
|
93
|
+
*/
|
|
94
|
+
export declare function remove<K extends BcsType<any>>(options: RemoveOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
95
|
+
export interface ContainsArguments<K extends BcsType<any>> {
|
|
96
|
+
bag: RawTransactionArgument<string>;
|
|
97
|
+
k: RawTransactionArgument<K>;
|
|
98
|
+
}
|
|
99
|
+
export interface ContainsOptions<K extends BcsType<any>> {
|
|
100
|
+
package?: string;
|
|
101
|
+
arguments: ContainsArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
102
|
+
typeArguments: [string];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns true iff there is an value associated with the key `k: K` in the bag
|
|
106
|
+
* `bag: &DerivedObjectBag`
|
|
107
|
+
*/
|
|
108
|
+
export declare function contains<K extends BcsType<any>>(options: ContainsOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
109
|
+
export interface ContainsWithTypeArguments<K extends BcsType<any>> {
|
|
110
|
+
bag: RawTransactionArgument<string>;
|
|
111
|
+
k: RawTransactionArgument<K>;
|
|
112
|
+
}
|
|
113
|
+
export interface ContainsWithTypeOptions<K extends BcsType<any>> {
|
|
114
|
+
package?: string;
|
|
115
|
+
arguments: ContainsWithTypeArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
116
|
+
typeArguments: [string, string];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns true iff there is an value associated with the key `k: K` in the bag
|
|
120
|
+
* `bag: &DerivedObjectBag` with an assigned value of type `V`
|
|
121
|
+
*/
|
|
122
|
+
export declare function containsWithType<K extends BcsType<any>>(options: ContainsWithTypeOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
123
|
+
export interface LengthArguments {
|
|
124
|
+
bag: RawTransactionArgument<string>;
|
|
125
|
+
}
|
|
126
|
+
export interface LengthOptions {
|
|
127
|
+
package?: string;
|
|
128
|
+
arguments: LengthArguments | [bag: RawTransactionArgument<string>];
|
|
129
|
+
}
|
|
130
|
+
/** Returns the size of the bag, the number of key-value pairs */
|
|
131
|
+
export declare function length(options: LengthOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
132
|
+
export interface IsEmptyArguments {
|
|
133
|
+
bag: RawTransactionArgument<string>;
|
|
134
|
+
}
|
|
135
|
+
export interface IsEmptyOptions {
|
|
136
|
+
package?: string;
|
|
137
|
+
arguments: IsEmptyArguments | [bag: RawTransactionArgument<string>];
|
|
138
|
+
}
|
|
139
|
+
/** Returns true iff the bag is empty (if `length` returns `0`) */
|
|
140
|
+
export declare function isEmpty(options: IsEmptyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
141
|
+
export interface DestroyEmptyArguments {
|
|
142
|
+
bag: RawTransactionArgument<string>;
|
|
143
|
+
}
|
|
144
|
+
export interface DestroyEmptyOptions {
|
|
145
|
+
package?: string;
|
|
146
|
+
arguments: DestroyEmptyArguments | [bag: RawTransactionArgument<string>];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains
|
|
150
|
+
* values
|
|
151
|
+
*/
|
|
152
|
+
export declare function destroyEmpty(options: DestroyEmptyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
153
|
+
export interface ValueIdArguments<K extends BcsType<any>> {
|
|
154
|
+
bag: RawTransactionArgument<string>;
|
|
155
|
+
k: RawTransactionArgument<K>;
|
|
156
|
+
}
|
|
157
|
+
export interface ValueIdOptions<K extends BcsType<any>> {
|
|
158
|
+
package?: string;
|
|
159
|
+
arguments: ValueIdArguments<K> | [bag: RawTransactionArgument<string>, k: RawTransactionArgument<K>];
|
|
160
|
+
typeArguments: [string];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns the ID of the object associated with the key if the bag has an entry
|
|
164
|
+
* with key `k: K` Returns none otherwise
|
|
165
|
+
*/
|
|
166
|
+
export declare function valueId<K extends BcsType<any>>(options: ValueIdOptions<K>): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import * as object from "./deps/sui/object.js";
|
|
5
|
+
import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
|
|
6
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
7
|
+
const $moduleName = "@local-pkg/zing_framework::derived_object_bag";
|
|
8
|
+
export const DerivedObjectBag = new MoveStruct({
|
|
9
|
+
name: `${$moduleName}::DerivedObjectBag`,
|
|
10
|
+
fields: {
|
|
11
|
+
/** the ID of this bag */
|
|
12
|
+
id: object.UID,
|
|
13
|
+
/** the number of key-value pairs in the bag */
|
|
14
|
+
size: bcs.u64(),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
/** Creates a new, empty bag */
|
|
18
|
+
export function _new(options) {
|
|
19
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
20
|
+
const argumentsTypes = [
|
|
21
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002::object::UID",
|
|
22
|
+
`${options.typeArguments[0]}`,
|
|
23
|
+
];
|
|
24
|
+
const parameterNames = ["parent", "key"];
|
|
25
|
+
return (tx) => tx.moveCall({
|
|
26
|
+
package: packageAddress,
|
|
27
|
+
module: "derived_object_bag",
|
|
28
|
+
function: "new",
|
|
29
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
30
|
+
typeArguments: options.typeArguments,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Adds a key-value pair to the bag `bag: &mut DerivedObjectBag` Aborts with
|
|
35
|
+
* `sui::dynamic_field::EFieldAlreadyExists` if the bag already has an entry with
|
|
36
|
+
* that key `k: K`.
|
|
37
|
+
*/
|
|
38
|
+
export function add(options) {
|
|
39
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
40
|
+
const argumentsTypes = [
|
|
41
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
42
|
+
`${options.typeArguments[0]}`,
|
|
43
|
+
`${options.typeArguments[1]}`,
|
|
44
|
+
];
|
|
45
|
+
const parameterNames = ["bag", "k", "v"];
|
|
46
|
+
return (tx) => tx.moveCall({
|
|
47
|
+
package: packageAddress,
|
|
48
|
+
module: "derived_object_bag",
|
|
49
|
+
function: "add",
|
|
50
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
51
|
+
typeArguments: options.typeArguments,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Immutably borrows the value associated with the key in the bag
|
|
56
|
+
* `bag: &DerivedObjectBag`. Aborts with `sui::dynamic_field::EFieldDoesNotExist`
|
|
57
|
+
* if the bag does not have an entry with that key `k: K`. Aborts with
|
|
58
|
+
* `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key,
|
|
59
|
+
* but the value does not have the specified type.
|
|
60
|
+
*/
|
|
61
|
+
export function borrow(options) {
|
|
62
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
63
|
+
const argumentsTypes = [
|
|
64
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
65
|
+
`${options.typeArguments[0]}`,
|
|
66
|
+
];
|
|
67
|
+
const parameterNames = ["bag", "k"];
|
|
68
|
+
return (tx) => tx.moveCall({
|
|
69
|
+
package: packageAddress,
|
|
70
|
+
module: "derived_object_bag",
|
|
71
|
+
function: "borrow",
|
|
72
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
73
|
+
typeArguments: options.typeArguments,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Mutably borrows the value associated with the key in the bag
|
|
78
|
+
* `bag: &mut DerivedObjectBag`. Aborts with
|
|
79
|
+
* `sui::dynamic_field::EFieldDoesNotExist` if the bag does not have an entry with
|
|
80
|
+
* that key `k: K`. Aborts with `sui::dynamic_field::EFieldTypeMismatch` if the bag
|
|
81
|
+
* has an entry for the key, but the value does not have the specified type.
|
|
82
|
+
*/
|
|
83
|
+
export function borrowMut(options) {
|
|
84
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
85
|
+
const argumentsTypes = [
|
|
86
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
87
|
+
`${options.typeArguments[0]}`,
|
|
88
|
+
];
|
|
89
|
+
const parameterNames = ["bag", "k"];
|
|
90
|
+
return (tx) => tx.moveCall({
|
|
91
|
+
package: packageAddress,
|
|
92
|
+
module: "derived_object_bag",
|
|
93
|
+
function: "borrow_mut",
|
|
94
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
95
|
+
typeArguments: options.typeArguments,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mutably borrows the key-value pair in the bag `bag: &mut DerivedObjectBag` and
|
|
100
|
+
* returns the value. Aborts with `sui::dynamic_field::EFieldDoesNotExist` if the
|
|
101
|
+
* bag does not have an entry with that key `k: K`. Aborts with
|
|
102
|
+
* `sui::dynamic_field::EFieldTypeMismatch` if the bag has an entry for the key,
|
|
103
|
+
* but the value does not have the specified type.
|
|
104
|
+
*/
|
|
105
|
+
export function remove(options) {
|
|
106
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
107
|
+
const argumentsTypes = [
|
|
108
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
109
|
+
`${options.typeArguments[0]}`,
|
|
110
|
+
];
|
|
111
|
+
const parameterNames = ["bag", "k"];
|
|
112
|
+
return (tx) => tx.moveCall({
|
|
113
|
+
package: packageAddress,
|
|
114
|
+
module: "derived_object_bag",
|
|
115
|
+
function: "remove",
|
|
116
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
117
|
+
typeArguments: options.typeArguments,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns true iff there is an value associated with the key `k: K` in the bag
|
|
122
|
+
* `bag: &DerivedObjectBag`
|
|
123
|
+
*/
|
|
124
|
+
export function contains(options) {
|
|
125
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
126
|
+
const argumentsTypes = [
|
|
127
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
128
|
+
`${options.typeArguments[0]}`,
|
|
129
|
+
];
|
|
130
|
+
const parameterNames = ["bag", "k"];
|
|
131
|
+
return (tx) => tx.moveCall({
|
|
132
|
+
package: packageAddress,
|
|
133
|
+
module: "derived_object_bag",
|
|
134
|
+
function: "contains",
|
|
135
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
136
|
+
typeArguments: options.typeArguments,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns true iff there is an value associated with the key `k: K` in the bag
|
|
141
|
+
* `bag: &DerivedObjectBag` with an assigned value of type `V`
|
|
142
|
+
*/
|
|
143
|
+
export function containsWithType(options) {
|
|
144
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
145
|
+
const argumentsTypes = [
|
|
146
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
147
|
+
`${options.typeArguments[0]}`,
|
|
148
|
+
];
|
|
149
|
+
const parameterNames = ["bag", "k"];
|
|
150
|
+
return (tx) => tx.moveCall({
|
|
151
|
+
package: packageAddress,
|
|
152
|
+
module: "derived_object_bag",
|
|
153
|
+
function: "contains_with_type",
|
|
154
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
155
|
+
typeArguments: options.typeArguments,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Returns the size of the bag, the number of key-value pairs */
|
|
159
|
+
export function length(options) {
|
|
160
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
161
|
+
const argumentsTypes = [
|
|
162
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
163
|
+
];
|
|
164
|
+
const parameterNames = ["bag"];
|
|
165
|
+
return (tx) => tx.moveCall({
|
|
166
|
+
package: packageAddress,
|
|
167
|
+
module: "derived_object_bag",
|
|
168
|
+
function: "length",
|
|
169
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** Returns true iff the bag is empty (if `length` returns `0`) */
|
|
173
|
+
export function isEmpty(options) {
|
|
174
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
175
|
+
const argumentsTypes = [
|
|
176
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
177
|
+
];
|
|
178
|
+
const parameterNames = ["bag"];
|
|
179
|
+
return (tx) => tx.moveCall({
|
|
180
|
+
package: packageAddress,
|
|
181
|
+
module: "derived_object_bag",
|
|
182
|
+
function: "is_empty",
|
|
183
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Destroys an empty bag Aborts with `EBagNotEmpty` if the bag still contains
|
|
188
|
+
* values
|
|
189
|
+
*/
|
|
190
|
+
export function destroyEmpty(options) {
|
|
191
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
192
|
+
const argumentsTypes = [
|
|
193
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
194
|
+
];
|
|
195
|
+
const parameterNames = ["bag"];
|
|
196
|
+
return (tx) => tx.moveCall({
|
|
197
|
+
package: packageAddress,
|
|
198
|
+
module: "derived_object_bag",
|
|
199
|
+
function: "destroy_empty",
|
|
200
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns the ID of the object associated with the key if the bag has an entry
|
|
205
|
+
* with key `k: K` Returns none otherwise
|
|
206
|
+
*/
|
|
207
|
+
export function valueId(options) {
|
|
208
|
+
const packageAddress = options.package ?? "@local-pkg/zing_framework";
|
|
209
|
+
const argumentsTypes = [
|
|
210
|
+
`${packageAddress}::derived_object_bag::DerivedObjectBag`,
|
|
211
|
+
`${options.typeArguments[0]}`,
|
|
212
|
+
];
|
|
213
|
+
const parameterNames = ["bag", "k"];
|
|
214
|
+
return (tx) => tx.moveCall({
|
|
215
|
+
package: packageAddress,
|
|
216
|
+
module: "derived_object_bag",
|
|
217
|
+
function: "value_id",
|
|
218
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
219
|
+
typeArguments: options.typeArguments,
|
|
220
|
+
});
|
|
221
|
+
}
|