wowok 1.0.3

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.
@@ -0,0 +1,224 @@
1
+ import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
2
+ import { BCS } from '@mysten/bcs';
3
+ import { description_data, FnCallType, PROTOCOL, TxbObject, GuardObject, TXB_OBJECT} from './protocol';
4
+ import { array_unique } from './util';
5
+
6
+
7
+ export const MAX_ADMIN_COUNT = 64;
8
+ export const MAX_ENTITY_COUNT = 1024;
9
+ export const MAX_PERMISSION_INDEX_COUNT = 512;
10
+
11
+ export enum PermissionIndex {
12
+ repository = 100,
13
+ repository_set_description_set = 101,
14
+ repository_set_policy_mode = 102,
15
+ repository_add_policies = 106,
16
+ repository_remove_policies = 107,
17
+ repository_set_policy_description = 109,
18
+ repository_set_policy_permission = 110,
19
+ vote = 150,
20
+ vote_set_description = 151,
21
+ vote_set_reference = 152,
22
+ vote_add_guard = 153,
23
+ vote_remove_guard = 154,
24
+ vote_add_option = 155,
25
+ vote_remove_option = 156,
26
+ vote_set_max_choice_count = 157,
27
+ vote_open_voting = 158,
28
+ vote_lock_deadline = 159,
29
+ vote_expand_deadline = 160,
30
+ vote_lock_guard = 161,
31
+ service = 200,
32
+ service_set_description = 201,
33
+ service_set_price = 202,
34
+ service_set_stock = 203,
35
+ service_add_stock = 203,
36
+ service_reduce_stock = 203,
37
+ service_set_payee = 205,
38
+ service_repository_add = 206,
39
+ service_repository_remove = 207,
40
+ service_add_withdraw_guards = 208,
41
+ service_remove_withdraw_guards = 209,
42
+ service_add_refund_guards = 210,
43
+ service_remove_refund_guards = 211,
44
+ service_add_sales = 212,
45
+ service_remove_sales = 213,
46
+ service_discount_transfer = 214,
47
+ service_withdraw = 216,
48
+ service_set_buy_guard = 217,
49
+ service_set_machine = 218,
50
+ service_set_endpoint = 219,
51
+ service_publish = 220,
52
+ service_clone = 221,
53
+ service_set_customer_required = 222,
54
+ service_remove_customer_required = 222,
55
+ service_change_required_pubkey = 222,
56
+ service_change_order_required_pubkey = 224,
57
+ service_pause = 225,
58
+ reward = 240,
59
+ reward_refund = 241,
60
+ reward_expand_time = 242,
61
+ reward_add_guard = 243,
62
+ reward_remove_guard = 244,
63
+ reward_set_description = 245,
64
+ reward_lock_guards = 246,
65
+ demand = 260,
66
+ demand_refund = 261,
67
+ demand_expand_time = 262,
68
+ demand_set_guard = 263,
69
+ demand_set_description = 264,
70
+ demand_yes = 265,
71
+ machine = 600,
72
+ machine_set_description = 601,
73
+ machine_add_repository = 602,
74
+ machine_remove_repository = 603,
75
+ machine_clone = 604,
76
+ machine_add_node = 606,
77
+ machine_add_node2 = 606,
78
+ machine_remove_node = 607,
79
+ machine_set_endpoint = 608,
80
+ machine_pause = 609,
81
+ machine_publish = 610,
82
+ progress = 650,
83
+ progress_set_namedOperator = 651,
84
+ progress_bind_task = 652,
85
+ progress_set_context_repository = 653,
86
+ progress_unhold = 654,
87
+ }
88
+ export type Permission_Index = {
89
+ index:PermissionIndex;
90
+ guard?: TxbObject;
91
+ }
92
+ export type Permission_Entity = {
93
+ who:string;
94
+ permissions:Permission_Index[];
95
+ }
96
+
97
+ export type PermissionAddress = TransactionResult;
98
+ export type PermissionObject = TransactionResult;
99
+
100
+ export function permission(txb:TransactionBlock, description:string) : PermissionObject {
101
+ return txb.moveCall({
102
+ target: PROTOCOL.PermissionFn('new') as FnCallType,
103
+ arguments: [txb.pure(description_data(description))]
104
+ });
105
+ }
106
+
107
+ export function launch(txb:TransactionBlock, permission:PermissionObject) : PermissionAddress {
108
+ return txb.moveCall({ // address returned
109
+ target:PROTOCOL.PermissionFn('create') as FnCallType,
110
+ arguments:[ permission ]
111
+ })
112
+ }
113
+
114
+ export function add_entity(txb:TransactionBlock, permission:PermissionObject, entities:Permission_Entity[]) {
115
+ let guards:any[] = [];
116
+ for (let i = 0; i < entities.length; i++) {
117
+ let entity = entities[i];
118
+ let indexes :number[] = [];
119
+
120
+ for (let j = 0; j < entity.permissions.length; j++) {
121
+ let index = entity.permissions[j];
122
+ if (index?.guard) {
123
+ guards.push({who:entity.who, index:index.index, guard:index.guard});
124
+ }
125
+
126
+ if (!indexes.includes(index.index)) {
127
+ indexes.push(index.index);
128
+ }
129
+ }
130
+ if (indexes.length > 0) {
131
+ txb.moveCall({
132
+ target:PROTOCOL.PermissionFn('add_batch') as FnCallType,
133
+ arguments:[permission, txb.pure(entity.who, BCS.ADDRESS), txb.pure(indexes, 'vector<u64>')]
134
+ })
135
+ }
136
+ }
137
+ // set guards
138
+ guards.forEach(({who, index, guard}) => {
139
+ txb.moveCall({
140
+ target:PROTOCOL.PermissionFn('guard_set') as FnCallType,
141
+ arguments:[ permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, BCS.U64), TXB_OBJECT(txb, guard)]
142
+ })
143
+ })
144
+ }
145
+
146
+ // guard: undefine to set none
147
+ export function set_guard(txb:TransactionBlock, permission:PermissionObject, who:string, index:number, guard?:string | GuardObject) {
148
+ if (guard) {
149
+ txb.moveCall({
150
+ target:PROTOCOL.PermissionFn('guard_set') as FnCallType,
151
+ arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, BCS.U64), TXB_OBJECT(txb, guard)]
152
+ })
153
+ } else {
154
+ txb.moveCall({
155
+ target:PROTOCOL.PermissionFn('guard_none') as FnCallType,
156
+ arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, BCS.U64)]
157
+ })
158
+ }
159
+ }
160
+
161
+ export function add_or_modify(txb:TransactionBlock, permission:PermissionObject, who:string, index:number, modifyIfOldExist?:boolean, guard?:string | GuardObject) {
162
+ if (guard) {
163
+ txb.moveCall({
164
+ target:PROTOCOL.PermissionFn('add_or_modify') as FnCallType,
165
+ arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, BCS.U64), TXB_OBJECT(txb, guard), txb.pure(modifyIfOldExist, BCS.BOOL)]
166
+ })
167
+ } else {
168
+ txb.moveCall({
169
+ target:PROTOCOL.PermissionFn('add_or_modify') as FnCallType,
170
+ arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, BCS.U64), txb.pure([], BCS.U8), txb.pure(modifyIfOldExist, BCS.BOOL)]
171
+ })
172
+ }
173
+ }
174
+ export function remove_index(txb:TransactionBlock, permission:PermissionObject, who:string, index:number[]) {
175
+ if (index) {
176
+ txb.moveCall({
177
+ target:PROTOCOL.PermissionFn('remove_index') as FnCallType,
178
+ arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, 'vector<u64>')]
179
+ })
180
+ }
181
+ }
182
+ export function remove_entity(txb:TransactionBlock, permission:PermissionObject, who:string[]) {
183
+ if (who) {
184
+ txb.moveCall({
185
+ target:PROTOCOL.PermissionFn('remove') as FnCallType,
186
+ arguments:[permission, txb.pure(who, 'vector<address>')]
187
+ })
188
+ }
189
+ }
190
+ export function set_description(txb:TransactionBlock, permission:PermissionObject, description:string) {
191
+ txb.moveCall({
192
+ target:PROTOCOL.PermissionFn('description_set') as FnCallType,
193
+ arguments: [permission, txb.pure(description_data(description))]
194
+ })
195
+ }
196
+
197
+ export function add_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[]) {
198
+ let n = array_unique(admin);
199
+ txb.moveCall({
200
+ target:PROTOCOL.PermissionFn('admin_add_batch') as FnCallType,
201
+ arguments:[permission, txb.pure(n, 'vector<address>')]
202
+ });
203
+ }
204
+
205
+ export function remove_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[], removeall?:boolean) {
206
+ if (removeall) {
207
+ txb.moveCall({
208
+ target:PROTOCOL.PermissionFn('admins_clear') as FnCallType,
209
+ arguments:[permission]
210
+ });
211
+ } else {
212
+ txb.moveCall({
213
+ target:PROTOCOL.PermissionFn('admin_remove_batch') as FnCallType,
214
+ arguments:[permission, txb.pure(admin, 'vector<address>')]
215
+ });
216
+ }
217
+ }
218
+
219
+ export function change_owner(txb:TransactionBlock, permission:PermissionObject, new_owner:string) {
220
+ txb.moveCall({
221
+ target:PROTOCOL.PermissionFn('builder_set') as FnCallType,
222
+ arguments:[permission, txb.pure(new_owner, BCS.ADDRESS)]
223
+ });
224
+ }
@@ -0,0 +1,139 @@
1
+ import { SuiClient, getFullnodeUrl, SuiObjectResponse } from '@mysten/sui.js/client';
2
+ import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
3
+ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
4
+ import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
5
+ import { name_data, FnCallType, PROTOCOL,} from './protocol';
6
+ import { verify, PassportObject} from './passport'
7
+ import { PermissionIndex, PermissionObject } from './permission'
8
+ import { RepositoryObject } from './repository';
9
+ import { MachineObject } from './machine';
10
+
11
+ export type ProgressObject = TransactionResult;
12
+ export type ProgressAddress = TransactionResult;
13
+ export const MAX_NAMED_OPERATOR_COUNT = 64;
14
+
15
+ export function progress(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : ProgressObject {
16
+ if (passport) {
17
+ return txb.moveCall({
18
+ target:PROTOCOL.ProgressFn('new_with_passport') as FnCallType,
19
+ arguments: [passport, machine, permission],
20
+ })
21
+ } else {
22
+ return txb.moveCall({
23
+ target:PROTOCOL.ProgressFn('new') as FnCallType,
24
+ arguments: [machine, permission],
25
+ })
26
+ }
27
+ }
28
+ export function launch(txb:TransactionBlock, progress:ProgressObject) : ProgressAddress {
29
+ return txb.moveCall({
30
+ target:PROTOCOL.ProgressFn('create') as FnCallType,
31
+ arguments: [progress],
32
+ })
33
+ }
34
+ export function launch_as_child(txb:TransactionBlock, progress:ProgressObject, parent:ProgressObject, parent_next:ProgressNext) : ProgressAddress {
35
+ return txb.moveCall({
36
+ target:PROTOCOL.ProgressFn('create_as_child') as FnCallType,
37
+ arguments: [progress, parent, txb.pure(parent_next.next_node_name), txb.pure(name_data(parent_next.forward))],
38
+ })
39
+ }
40
+ export function destroy(txb:TransactionBlock, progress:ProgressObject) {
41
+ return txb.moveCall({
42
+ target:PROTOCOL.ProgressFn('destroy') as FnCallType,
43
+ arguments: [progress],
44
+ })
45
+ }
46
+ export function progress_set_namedOperator(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, name:string, addresses:string[], passport?:PassportObject) {
47
+ if (addresses.length == 0 || name.length == 0 || addresses.length > MAX_NAMED_OPERATOR_COUNT) return undefined;
48
+
49
+ if (passport) {
50
+ txb.moveCall({
51
+ target:PROTOCOL.ProgressFn('namedOperator_set_with_passport') as FnCallType,
52
+ arguments: [passport, progress, txb.pure(name_data(name)), txb.pure(addresses, 'vector<address>'),
53
+ machine, permission],
54
+ })
55
+ } else {
56
+ txb.moveCall({
57
+ target:PROTOCOL.ProgressFn('namedOperator_set') as FnCallType,
58
+ arguments: [progress, txb.pure(name_data(name)), txb.pure(addresses, 'vector<address>'),
59
+ machine, permission],
60
+ })
61
+ }
62
+ }
63
+ export function progress_bind_task(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, task_address:string, passport?:PassportObject) {
64
+ if (passport) {
65
+ txb.moveCall({
66
+ target:PROTOCOL.ProgressFn('task_set_with_passport') as FnCallType,
67
+ arguments: [passport, progress, txb.pure(task_address, BCS.ADDRESS), machine, permission],
68
+ })
69
+ } else {
70
+ txb.moveCall({
71
+ target:PROTOCOL.ProgressFn('task_set') as FnCallType,
72
+ arguments: [progress, txb.pure(task_address, BCS.ADDRESS), machine, permission],
73
+ })
74
+ }
75
+ }
76
+ export function progress_set_context_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, repository?:RepositoryObject, passport?:PassportObject) {
77
+ if (passport) {
78
+ if (repository) {
79
+ txb.moveCall({
80
+ target:PROTOCOL.ProgressFn('context_repository_set_with_passport') as FnCallType,
81
+ arguments: [passport, progress, repository, machine, permission],
82
+ })
83
+ } else {
84
+ txb.moveCall({
85
+ target:PROTOCOL.ProgressFn('context_repository_none_with_passport') as FnCallType,
86
+ arguments: [passport, progress, machine, permission],
87
+ })
88
+ }
89
+ } else {
90
+ if (repository) {
91
+ txb.moveCall({
92
+ target:PROTOCOL.ProgressFn('context_repository_set') as FnCallType,
93
+ arguments: [progress, repository, machine, permission],
94
+ })
95
+ } else {
96
+ txb.moveCall({
97
+ target:PROTOCOL.ProgressFn('context_repository_none') as FnCallType,
98
+ arguments: [progress, machine, permission],
99
+ })
100
+ }
101
+ }
102
+ }
103
+ export function progress_unhold(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, next:ProgressNext) {
104
+ txb.moveCall({
105
+ target:PROTOCOL.ProgressFn('unhold') as FnCallType,
106
+ arguments: [progress, machine, txb.pure(next.next_node_name), txb.pure(name_data(next.forward)), permission],
107
+ })
108
+ }
109
+
110
+ export type ProgressNext = {
111
+ next_node_name: string;
112
+ forward: string;
113
+ }
114
+ export function next(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, next:ProgressNext,
115
+ deliverables_address?:string, passport?:PassportObject) {
116
+ let diliverable = txb.pure([], BCS.U8);
117
+ if (deliverables_address) { diliverable = txb.pure(deliverables_address, BCS.ADDRESS)}
118
+
119
+ if (passport) {
120
+ txb.moveCall({
121
+ target:PROTOCOL.ProgressFn('run_with_passport') as FnCallType,
122
+ arguments: [passport, progress, machine, txb.pure(next.next_node_name),
123
+ txb.pure(name_data(next.forward)), diliverable, permission],
124
+ })
125
+ } else {
126
+ txb.moveCall({
127
+ target:PROTOCOL.ProgressFn('run') as FnCallType,
128
+ arguments: [progress, machine, txb.pure(next.next_node_name),
129
+ txb.pure(name_data(next.forward)), diliverable, permission],
130
+ })
131
+ }
132
+ }
133
+ export function hold(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject, next:ProgressNext, hold:boolean) {
134
+ txb.moveCall({
135
+ target:PROTOCOL.ProgressFn('hold') as FnCallType,
136
+ arguments: [progress, machine, txb.pure(next.next_node_name),
137
+ txb.pure(name_data(next.forward)), txb.pure(hold, BCS.BOOL), permission],
138
+ })
139
+ }
@@ -0,0 +1,189 @@
1
+ import { SuiClient, SuiObjectResponse, SuiObjectDataOptions, SuiTransactionBlockResponseOptions,
2
+ SuiTransactionBlockResponse, SuiObjectChange } from '@mysten/sui.js/client';
3
+ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
4
+ import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
5
+ import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
6
+ import { capitalize } from './util'
7
+
8
+ export type GuardObject = TransactionResult;
9
+ export type GuardAddress = TransactionResult;
10
+
11
+ export const MAX_DESCRIPTION_LENGTH = 1024;
12
+ export const MAX_NAME_LENGTH = 64;
13
+ export const MAX_ENDPOINT_LENGTH = 1024;
14
+
15
+ export function description_data(description:string) : string {
16
+ return description.substring(0, MAX_DESCRIPTION_LENGTH);
17
+ }
18
+ export function endpoint_data(endpoint:string) : string {
19
+ return endpoint.substring(0, MAX_ENDPOINT_LENGTH);
20
+ }
21
+ export function name_data(name:string) : string {
22
+ return name.substring(0, MAX_NAME_LENGTH);
23
+ }
24
+ export enum MODULES {
25
+ machine = 'machine',
26
+ node = 'node',
27
+ progress = 'progress',
28
+ community = 'community',
29
+ repository = 'repository',
30
+ permission = 'permission',
31
+ passport = 'passport',
32
+ guard = 'guard',
33
+ vote = 'vote',
34
+ demand = 'demand',
35
+ order = 'order',
36
+ reward = 'reward',
37
+ service = 'service',
38
+ wowok = 'wowok',
39
+ }
40
+
41
+ export type TxbObject = string | TransactionResult;
42
+ export function TXB_OBJECT(txb:TransactionBlock, arg:TxbObject) : TransactionResult {
43
+ if (typeof arg == 'string') return txb.object(arg) as TransactionResult;
44
+ return arg;
45
+ }
46
+
47
+ export type WowokObject = TransactionResult;
48
+ export type FnCallType = `${string}::${string}::${string}`;
49
+
50
+ export const CLOCK_OBJECT = Inputs.SharedObjectRef({
51
+ objectId:"0x6",
52
+ mutable: false,
53
+ initialSharedVersion: 1,
54
+ });
55
+
56
+ export enum Data_Type {
57
+ TYPE_DYNAMIC_QUERY = 1,
58
+ TYPE_LOGIC_OPERATOR_U128_GREATER = 11,
59
+ TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL = 12,
60
+ TYPE_LOGIC_OPERATOR_U128_LESSER = 13,
61
+ TYPE_LOGIC_OPERATOR_U128_LESSER_EQUAL = 14,
62
+ TYPE_LOGIC_OPERATOR_U128_EQUAL = 15,
63
+ TYPE_LOGIC_OPERATOR_EQUAL = 16, // TYPE&DATA(vector<u8>) MUST BE EQUAL
64
+ TYPE_LOGIC_OPERATOR_HAS_SUBSTRING = 17, // SUBSTRING
65
+ TYPE_LOGIC_ALWAYS_TRUE = 18, // aways true
66
+ // TYPE_LOGIC_OPERATOR_VECU8_CONTAINS = 18, // SUB VEC<U8>
67
+ TYPE_CONTEXT_SIGNER = 60,
68
+ TYPE_CONTEXT_CURRENT_PROGRESS = 61,
69
+ TYPE_CONTEXT_CURRENT_CLOCK = 62,
70
+ TYPE_STATIC_bool = 100,
71
+ TYPE_STATIC_address = 101,
72
+ TYPE_STATIC_u64 = 102,
73
+ TYPE_STATIC_u8 = 103,
74
+ TYPE_STATIC_u128 = 104,
75
+ TYPE_STATIC_vec_u8 = 105,
76
+ TYPE_STATIC_vec_address = 106,
77
+ TYPE_STATIC_vec_bool = 107,
78
+ TYPE_STATIC_vec_vec_u8 = 108,
79
+ TYPE_STATIC_vec_u64 = 109,
80
+ TYPE_STATIC_vec_u128 = 110,
81
+ TYPE_STATIC_option_address = 111,
82
+ TYPE_STATIC_option_bool = 112,
83
+ TYPE_STATIC_option_u8 = 113,
84
+ TYPE_STATIC_option_u64 = 114,
85
+ TYPE_STATIC_option_u128 = 115,
86
+ TYPE_STATIC_by_value_specified = 126,
87
+ TYPE_STATIC_error = 127,
88
+ }
89
+
90
+ export enum ENTRYPOINT {
91
+ mainnet = 'mainnet',
92
+ testnet = 'testnet',
93
+ devnet = 'devnet',
94
+ localnet = 'localnet'
95
+ }
96
+
97
+ export class Protocol {
98
+ protected network = '';
99
+ protected package = '';
100
+ protected signer = '';
101
+ protected everyone_guard = '';
102
+
103
+ constructor(network:ENTRYPOINT=ENTRYPOINT.localnet, signer="0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f") {
104
+ this.network = network;
105
+ this.signer = signer;
106
+ switch(network) {
107
+ case ENTRYPOINT.localnet:
108
+ this.package = "0x74df733df2395d0c3a34c6d086d2e1f130603b8aa16962e53781cb0fa9c6958c";
109
+ this.everyone_guard = "0xb1a2e3d0cf13c3fcb491f126af8422f7d098147659d8a58a52511cfbb783a6e8";
110
+ break;
111
+ case ENTRYPOINT.devnet:
112
+ break;
113
+ case ENTRYPOINT.testnet:
114
+ this.package = "0x038b0be329e4fd227d846b850aeb1822f9629c62c14d85ffcd22d856c843923f";
115
+ this.everyone_guard = "0xdfe42468bfc7d7988fa1707978ef9376178dcefbe938d140a1bfd97abe755998";
116
+ break;
117
+ case ENTRYPOINT.mainnet:
118
+ break;
119
+ };
120
+ }
121
+ Package(): string { return this.package }
122
+ EveryoneGuard(): string { return this.everyone_guard }
123
+ NetworkUrl() : string {
124
+ switch(this.network) {
125
+ case ENTRYPOINT.localnet:
126
+ return "http://127.0.0.1:9000";
127
+ case ENTRYPOINT.devnet:
128
+ return "https://fullnode.devnet.sui.io:443";
129
+ case ENTRYPOINT.testnet:
130
+ return "https://fullnode.testnet.sui.io:443";
131
+ case ENTRYPOINT.mainnet:
132
+ return "https://fullnode.mainnet.sui.io:443";
133
+ }; return "";
134
+ };
135
+ MachineFn = (fn:any) => { return `${this.package}::${MODULES.machine}::${fn}`};
136
+ NodeFn = (fn: any) => { return `${this.package}::${MODULES.node}::${fn}`};
137
+ ProgressFn = (fn:any) => { return `${this.package}::${MODULES.progress}::${fn}`};
138
+ CommunityFn = (fn: any) => { return `${this.package}::${MODULES.community}::${fn}`};
139
+ RepositoryFn = (fn:any) => { return `${this.package}::${MODULES.repository}::${fn}`};
140
+ PermissionFn = (fn: any) => { return `${this.package}::${MODULES.permission}::${fn}`};
141
+ PassportFn = (fn:any) => { return `${this.package}::${MODULES.passport}::${fn}`};
142
+ GuardFn = (fn: any) => { return `${this.package}::${MODULES.guard}::${fn}`};
143
+ VoteFn = (fn:any) => { return `${this.package}::${MODULES.vote}::${fn}`};
144
+ DemandFn = (fn: any) => { return `${this.package}::${MODULES.demand}::${fn}`};
145
+ OrderFn = (fn:any) => { return `${this.package}::${MODULES.order}::${fn}`};
146
+ RewardFn = (fn: any) => { return `${this.package}::${MODULES.reward}::${fn}`};
147
+ ServiceFn = (fn: any) => { return `${this.package}::${MODULES.service}::${fn}`};
148
+ WowokFn = (fn: any) => { return `${this.package}::${MODULES.wowok}::${fn}`};
149
+
150
+
151
+ Query = async (objects: Query_Param[], options:SuiObjectDataOptions={showContent:true}) : Promise<SuiObjectResponse[]> => {
152
+ const client = new SuiClient({ url: PROTOCOL.NetworkUrl() });
153
+ const ids = objects.map((value) => value.objectid);
154
+ const res = await client.call('sui_multiGetObjects', [ids, options]) as SuiObjectResponse[];
155
+ let ret:any[] = [];
156
+ for (let i = 0; i < res.length; i ++ ) {
157
+ objects.forEach((object) => {
158
+ object.callback(res[i], object, options);
159
+ })
160
+ }
161
+ return res;
162
+ }
163
+ Sign_Excute = async (exes: (txb:TransactionBlock, param:any) => void, priv_key:string, param?:any, options:SuiTransactionBlockResponseOptions={showObjectChanges:true}) : Promise<SuiTransactionBlockResponse> => {
164
+ const client = new SuiClient({ url: PROTOCOL.NetworkUrl() });
165
+ const txb = new TransactionBlock();
166
+
167
+ exes(txb, param);
168
+ const privkey = fromHEX(priv_key);
169
+ const keypair = Ed25519Keypair.fromSecretKey(privkey);
170
+
171
+ const response = await client.signAndExecuteTransactionBlock({
172
+ transactionBlock: txb,
173
+ signer: keypair,
174
+ options
175
+ });
176
+ return response;
177
+ }
178
+ }
179
+
180
+ export type Query_Param = {
181
+ objectid: string;
182
+ callback: (response:SuiObjectResponse, param:Query_Param, option:SuiObjectDataOptions)=>void;
183
+ data?: any; // response data filted by callback
184
+ };
185
+
186
+
187
+ export const PROTOCOL = new Protocol();
188
+ export const OBJECTS_TYPE_PREFIX = (Object.keys(MODULES) as Array<keyof typeof MODULES>).map((key) => { return PROTOCOL.Package() + '::' + key + '::'; })
189
+ export const OBJECTS_TYPE = (Object.keys(MODULES) as Array<keyof typeof MODULES>).map((key) => { let i = PROTOCOL.Package() + '::' + key + '::'; return i + capitalize(key); })