wowok 1.0.3 → 1.0.4

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/src/machine.ts CHANGED
@@ -1,29 +1,27 @@
1
1
  import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
2
2
  import { BCS } from '@mysten/bcs';
3
- import { name_data, CLOCK_OBJECT, PROTOCOL, FnCallType, description_data, MAX_ENDPOINT_LENGTH} from './protocol';
4
- import { verify, PassportObject} from './passport'
5
- import { PermissionIndex, PermissionObject } from './permission'
6
- import { RepositoryObject } from './repository';
3
+ import { PROTOCOL, FnCallType, PermissionObject, RepositoryObject, IsValidEndpoint, OptionNone, IsValidDesription, PassportObject,
4
+ TXB_OBJECT, MachineObject, MachineAddress, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty, GuardObject,
5
+ IsValidInt, IsValidUint, IsValidObjects} from './protocol';
7
6
  import { BCS_CONVERT } from './util'
7
+ import { IsValidPermissionIndex, PermissionIndexType } from './permission';
8
8
 
9
9
 
10
- export type MachineAddress = TransactionResult;
11
- export type MachineObject = TransactionResult;
12
10
  export type MachineNodeObject = TransactionResult;
13
11
 
14
12
  export const INITIAL_NODE_NAME = '';
15
13
 
16
14
  export type Machine_Forward = {
17
15
  name: string; // foward name
18
- namedOperator?: string;
19
- permission?: number; // permission-index or named-operator MUST one defined.
16
+ namedOperator?: string; // dynamic operator
17
+ permission?: PermissionIndexType; // permission-index or named-operator MUST one defined.
20
18
  weight?: number;
21
- guard_address?: string;
19
+ guard?: GuardObject;
22
20
  }
23
21
  export type Machine_Node_Pair = {
24
22
  prior_node: string;
25
- threshold: number;
26
23
  forwards: Machine_Forward[];
24
+ threshold?: number;
27
25
  }
28
26
  export type Machine_Node = {
29
27
  name: string;
@@ -31,227 +29,274 @@ export type Machine_Node = {
31
29
  pairs: Machine_Node_Pair[];
32
30
  }
33
31
 
34
- // node & forward & forward permission string length validation
35
- export function is_valid_name(name:string):boolean { return name.length > 0 && name.length < 33 }
36
-
37
32
  // 创建新的node加入到machine
38
- export function machine_add_node(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, nodes:Machine_Node[], passport?:PassportObject) {
33
+ export function machine_add_node(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
34
+ nodes:Machine_Node[], passport?:PassportObject) : boolean {
35
+ if (!IsValidObjects([machine, permission])) return false;
36
+ let bValid = true;
37
+ nodes.forEach((node) => {
38
+ if (!IsValidDesription(node.description) || !IsValidName(node.name)) { bValid = false; }
39
+
40
+ node.pairs.forEach((p) => {
41
+ if (!IsValidName_AllowEmpty(p.prior_node)) { bValid = false; }
42
+ if (p?.threshold && !IsValidInt(p.threshold)) { bValid = false; }
43
+ p.forwards.forEach((f) => {
44
+ if (!IsValidName(f.name)) { bValid = false }
45
+ if (f?.namedOperator && !IsValidName_AllowEmpty(f?.namedOperator)) { bValid = false }
46
+ if (f?.permission && !IsValidPermissionIndex(f?.permission)) { bValid = false }
47
+ if (!f?.permission && !f?.namedOperator) { bValid = false; }
48
+ if (f?.weight && !IsValidUint(f.weight)) { bValid = false; }
49
+ })
50
+ })
51
+ })
52
+ if (!bValid) return false
53
+
39
54
  let new_nodes: MachineNodeObject[] = [];
40
55
  nodes.forEach((node) => {
41
56
  let n = txb.moveCall({
42
57
  target:PROTOCOL.NodeFn('new') as FnCallType,
43
- arguments:[txb.pure(name_data(node.name)), txb.pure(description_data(node.description))]
58
+ arguments:[txb.pure(node.name), txb.pure(node.description)]
44
59
  });
45
60
  node.pairs.forEach((pair) => {
61
+ let threshold = pair?.threshold ? txb.pure(BCS_CONVERT.ser_option_u64(pair.threshold)) : OptionNone(txb);
62
+
46
63
  pair.forwards.forEach((forward) => {
47
- if (!forward?.namedOperator && !forward?.permission) { return }
48
- let weight = txb.pure(1);
49
- if (forward?.weight && forward.weight > 0) {
50
- weight = txb.pure(forward.weight)
51
- }
52
-
53
- let per = txb.pure([], BCS.U8);
54
- if (forward?.permission) {
55
- per = txb.pure(BCS_CONVERT.ser_option_u64(forward.permission as number));
56
- };
57
- let namedOperator = txb.pure('');
58
- if (forward?.namedOperator) {
59
- namedOperator = txb.pure(forward.namedOperator)
60
- }; let f;
64
+ let weight = forward?.weight ? forward.weight : 1;
65
+ let perm = forward?.permission ? txb.pure(BCS_CONVERT.ser_option_u64(forward.permission)) : OptionNone(txb);
66
+ let namedOperator = forward?.namedOperator ? txb.pure(forward.namedOperator) : txb.pure('');
67
+ let f;
61
68
 
62
- if (forward?.guard_address) {
69
+ if (forward?.guard) {
63
70
  f = txb.moveCall({
64
71
  target:PROTOCOL.NodeFn('forward') as FnCallType,
65
- arguments:[namedOperator, weight, txb.object(forward.guard_address), per]
72
+ arguments:[namedOperator, txb.pure(weight), txb.object(TXB_OBJECT(txb, forward.guard)), perm]
66
73
  });
67
74
  } else {
68
75
  f = txb.moveCall({
69
76
  target:PROTOCOL.NodeFn('forward2') as FnCallType,
70
- arguments:[namedOperator, weight, per]
77
+ arguments:[namedOperator, txb.pure(weight), perm]
71
78
  });
72
79
  }
73
80
  txb.moveCall({ // add forward
74
81
  target:PROTOCOL.NodeFn('forward_add') as FnCallType,
75
- arguments:[n, txb.pure(pair.prior_node), txb.pure(name_data(forward.name)),
76
- txb.pure(BCS_CONVERT.ser_option_u64(pair.threshold)), f]
82
+ arguments:[n, txb.pure(pair.prior_node), txb.pure(forward.name), threshold, f]
77
83
  });
78
84
  });
79
85
  });
80
86
  new_nodes.push(n);
81
- }); machine_add_node2(txb, machine, permission, new_nodes, passport)
87
+ }); return machine_add_node2(txb, machine, permission, new_nodes, passport)
82
88
  }
83
89
  // 把个人拥有的node加入到machine
84
- export function machine_add_node2(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, nodes:MachineNodeObject[], passport?:PassportObject) {
90
+ export function machine_add_node2(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
91
+ nodes:MachineNodeObject[], passport?:PassportObject) : boolean {
92
+ if (!IsValidObjects([machine, permission])) return false;
93
+ if (!nodes) return false;
94
+
85
95
  if (passport) {
86
96
  txb.moveCall({ // add node
87
97
  target:PROTOCOL.MachineFn('node_add_with_passport') as FnCallType,
88
- arguments:[passport, machine, txb.makeMoveVec({objects:nodes}), permission]
98
+ arguments:[passport, TXB_OBJECT(txb, machine), txb.makeMoveVec({objects:nodes}), TXB_OBJECT(txb, permission)]
89
99
  });
90
100
  } else {
91
101
  txb.moveCall({ // add node
92
102
  target:PROTOCOL.MachineFn('node_add') as FnCallType,
93
- arguments:[machine, txb.makeMoveVec({objects:nodes}), permission]
103
+ arguments:[TXB_OBJECT(txb, machine), txb.makeMoveVec({objects:nodes}), TXB_OBJECT(txb, permission)]
94
104
  });
95
105
  }
106
+ return true
96
107
  }
97
108
  // 从machine把node移动到个人地址
98
- export function machine_remove_node(txb:TransactionBlock, machine:MachineObject, permission:TransactionResult, nodes_name:string[], receive_address:string, passport?:PassportObject) {
109
+ export function machine_remove_node(txb:TransactionBlock, machine:MachineObject, permission:TransactionResult,
110
+ nodes_name:string[], passport?:PassportObject) : boolean {
111
+ if (!IsValidObjects([machine, permission])) return false;
112
+ if (!nodes_name || !IsValidArray(nodes_name, IsValidName)) return false;
113
+
99
114
  if (passport) {
100
115
  txb.moveCall({
101
116
  target:PROTOCOL.MachineFn('node_remove_with_passport') as FnCallType,
102
- arguments:[passport, machine, txb.pure(BCS_CONVERT.ser_vector_string(nodes_name)), permission],
117
+ arguments:[passport, TXB_OBJECT(txb, machine), txb.pure(BCS_CONVERT.ser_vector_string(nodes_name)), permission],
103
118
  });
104
119
  } else {
105
120
  txb.moveCall({
106
121
  target:PROTOCOL.MachineFn('node_remove') as FnCallType,
107
- arguments:[machine, txb.pure(BCS_CONVERT.ser_vector_string(nodes_name)), permission],
122
+ arguments:[TXB_OBJECT(txb, machine), txb.pure(BCS_CONVERT.ser_vector_string(nodes_name)), permission],
108
123
  });
109
124
  }
125
+ return true;
110
126
  }
111
- export function machine(txb:TransactionBlock, permission:PermissionObject, description:string, endpoint_url?:string, passport?:PassportObject) : MachineObject | undefined {
112
- if (endpoint_url && endpoint_url.length > MAX_ENDPOINT_LENGTH) return undefined;
113
- let endpoint = endpoint_url? txb.pure(BCS_CONVERT.ser_option_string(endpoint_url)) : txb.pure([], BCS.U8);
127
+ export function machine(txb:TransactionBlock, permission:PermissionObject, description:string,
128
+ endpoint?:string, passport?:PassportObject) : MachineObject | boolean {
129
+ if (!IsValidObjects([permission])) return false;
130
+ if (!IsValidDesription(description)) return false;
131
+ if (endpoint && !IsValidEndpoint(endpoint)) return false;
132
+ let ep = endpoint? txb.pure(BCS_CONVERT.ser_option_string(endpoint)) : OptionNone(txb);
114
133
 
115
134
  if (passport) {
116
135
  return txb.moveCall({
117
136
  target:PROTOCOL.MachineFn('new_with_passport') as FnCallType,
118
- arguments:[passport, txb.pure(description_data(description)), endpoint, permission],
137
+ arguments:[passport, txb.pure(description), ep, TXB_OBJECT(txb, permission)],
119
138
  })
120
139
  } else {
121
- //console.log(endpoint)
122
140
  return txb.moveCall({
123
141
  target:PROTOCOL.MachineFn('new') as FnCallType,
124
- arguments:[txb.pure(description_data(description)), endpoint, permission],
142
+ arguments:[txb.pure(description), ep, TXB_OBJECT(txb, permission)],
125
143
  })
126
144
  }
127
145
  }
128
- export function destroy(txb:TransactionBlock, machine:MachineObject) {
129
- return txb.moveCall({
146
+ export function destroy(txb:TransactionBlock, machine:MachineObject) : boolean{
147
+ if (!IsValidObjects([machine])) return false;
148
+ txb.moveCall({
130
149
  target:PROTOCOL.MachineFn('destroy') as FnCallType,
131
- arguments: [machine],
132
- })
150
+ arguments: [TXB_OBJECT(txb, machine)],
151
+ })
152
+ return true
133
153
  }
134
- export function launch(txb:TransactionBlock, machine:MachineObject) : MachineAddress {
154
+ export function launch(txb:TransactionBlock, machine:MachineObject) : MachineAddress | boolean {
155
+ if (!IsValidObjects([machine])) return false;
135
156
  return txb.moveCall({
136
157
  target:PROTOCOL.MachineFn('create') as FnCallType,
137
- arguments:[machine],
158
+ arguments:[TXB_OBJECT(txb, machine)],
138
159
  })
139
160
  }
140
- export function machine_set_description(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, description:string, passport?:PassportObject) {
161
+ export function machine_set_description(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
162
+ description:string, passport?:PassportObject) : boolean {
163
+ if (!IsValidObjects([machine, permission])) return false;
164
+ if (!IsValidDesription(description)) return false;
165
+
141
166
  if (passport) {
142
167
  txb.moveCall({
143
168
  target:PROTOCOL.MachineFn('description_set_with_passport') as FnCallType,
144
- arguments:[passport, machine, txb.pure(description_data(description)), permission],
169
+ arguments:[passport, TXB_OBJECT(txb, machine), txb.pure(description), TXB_OBJECT(txb, permission)],
145
170
  })
146
171
  } else {
147
172
  txb.moveCall({
148
173
  target:PROTOCOL.MachineFn('description_set') as FnCallType,
149
- arguments:[machine, txb.pure(description_data(description)), permission],
174
+ arguments:[TXB_OBJECT(txb, machine), txb.pure(description), TXB_OBJECT(txb, permission)],
150
175
  })
151
176
  }
177
+ return true
152
178
  }
153
- export function machine_add_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, repository:RepositoryObject, passport?:PassportObject) {
179
+ export function machine_add_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
180
+ repository:RepositoryObject, passport?:PassportObject) : boolean {
181
+ if (!IsValidObjects([machine, permission, repository])) return false;
154
182
  if (passport) {
155
183
  txb.moveCall({
156
184
  target:PROTOCOL.MachineFn('repository_add_with_passport') as FnCallType,
157
- arguments:[passport, machine, repository, permission],
185
+ arguments:[passport, TXB_OBJECT(txb, machine), TXB_OBJECT(txb, repository), TXB_OBJECT(txb, permission)],
158
186
  })
159
187
  } else {
160
188
  txb.moveCall({
161
189
  target:PROTOCOL.MachineFn('repository_add') as FnCallType,
162
- arguments:[machine, repository, permission],
190
+ arguments:[TXB_OBJECT(txb, machine), TXB_OBJECT(txb, repository), TXB_OBJECT(txb, permission)],
163
191
  })
164
192
  }
193
+ return true
165
194
  }
166
195
 
167
- export function machine_remove_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, repositories:string[], removeall?:boolean, passport?:PassportObject) {
196
+ export function machine_remove_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
197
+ repositories:string[], removeall?:boolean, passport?:PassportObject) : boolean {
198
+ if (!IsValidObjects([machine, permission])) return false;
199
+ if (!removeall && !repositories) return false;
200
+ if (!IsValidArray(repositories, IsValidAddress)) return false;
201
+
168
202
  if (passport) {
169
203
  if (removeall) {
170
204
  txb.moveCall({
171
205
  target:PROTOCOL.MachineFn('repository_remove_all_with_passport') as FnCallType,
172
- arguments:[passport, machine, permission],
206
+ arguments:[passport, TXB_OBJECT(txb, machine), TXB_OBJECT(txb, machine)],
173
207
  })
174
208
  } else {
175
209
  txb.moveCall({
176
210
  target:PROTOCOL.MachineFn('repository_remove_with_passport') as FnCallType,
177
- arguments:[passport, machine, txb.pure(repositories, 'vector<address>'), permission],
211
+ arguments:[passport, TXB_OBJECT(txb, machine), txb.pure(repositories, 'vector<address>'), TXB_OBJECT(txb, permission)],
178
212
  })
179
213
  }
180
214
  } else {
181
215
  if (removeall) {
182
216
  txb.moveCall({
183
217
  target:PROTOCOL.MachineFn('repository_remove_all') as FnCallType,
184
- arguments:[machine, permission],
218
+ arguments:[TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
185
219
  })
186
220
  } else {
187
221
  txb.moveCall({
188
222
  target:PROTOCOL.MachineFn('repository_remove') as FnCallType,
189
- arguments:[machine, txb.pure(repositories, 'vector<address>'), permission],
223
+ arguments:[TXB_OBJECT(txb, machine), txb.pure(repositories, 'vector<address>'), TXB_OBJECT(txb, permission)],
190
224
  })
191
225
  }
192
- }
226
+ }
227
+ return true
193
228
  }
194
229
 
195
- export function machine_clone(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : MachineObject {
230
+ export function machine_clone(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : MachineObject | boolean {
231
+ if (!IsValidObjects([machine, permission])) return false;
196
232
  if (passport) {
197
233
  return txb.moveCall({
198
234
  target:PROTOCOL.MachineFn('clone_with_passport') as FnCallType,
199
- arguments:[passport, machine, permission],
235
+ arguments:[passport, TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
200
236
  })
201
237
  } else {
202
238
  return txb.moveCall({
203
239
  target:PROTOCOL.MachineFn('clone') as FnCallType,
204
- arguments:[machine, permission],
240
+ arguments:[TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
205
241
  })
206
242
  }
207
243
  }
208
- export function machine_set_endpoint(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, endpoint_url?:string, passport?:PassportObject) {
209
- if (endpoint_url && endpoint_url.length > MAX_ENDPOINT_LENGTH) return undefined;
210
- let endpoint = endpoint_url? txb.pure(BCS_CONVERT.ser_option_string(endpoint_url)) : txb.pure([], BCS.U8);
244
+ export function machine_set_endpoint(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
245
+ endpoint?:string, passport?:PassportObject) : boolean {
246
+ if (!IsValidObjects([machine, permission])) return false;
247
+ if (endpoint && !IsValidEndpoint(endpoint)) return false;
248
+ let ep = endpoint? txb.pure(BCS_CONVERT.ser_option_string(endpoint)) : OptionNone(txb);
211
249
 
212
250
  if (passport) {
213
251
  txb.moveCall({
214
252
  target:PROTOCOL.MachineFn('endpoint_set_with_passport') as FnCallType,
215
- arguments:[passport, machine, endpoint, permission],
253
+ arguments:[passport, TXB_OBJECT(txb, machine), ep, TXB_OBJECT(txb, permission)],
216
254
  })
217
255
  } else {
218
256
  txb.moveCall({
219
257
  target:PROTOCOL.MachineFn('endpoint_set') as FnCallType,
220
- arguments:[machine, endpoint, permission],
258
+ arguments:[TXB_OBJECT(txb, machine), ep, TXB_OBJECT(txb, permission)],
221
259
  })
222
260
  }
261
+ return true
223
262
  }
224
- export function machine_pause(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, bPaused:boolean, passport?:PassportObject) {
263
+ export function machine_pause(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, bPaused:boolean, passport?:PassportObject) : boolean {
264
+ if (!IsValidObjects([machine, permission])) return false;
225
265
  if (passport) {
226
266
  txb.moveCall({
227
267
  target:PROTOCOL.MachineFn('pause_with_passport') as FnCallType,
228
- arguments:[passport, machine, txb.pure(bPaused), permission],
268
+ arguments:[passport, TXB_OBJECT(txb, machine), txb.pure(bPaused), TXB_OBJECT(txb, permission)],
229
269
  })
230
270
  } else {
231
271
  txb.moveCall({
232
272
  target:PROTOCOL.MachineFn('pause') as FnCallType,
233
- arguments:[machine, txb.pure(bPaused), permission],
273
+ arguments:[TXB_OBJECT(txb, machine), txb.pure(bPaused), TXB_OBJECT(txb, permission)],
234
274
  })
235
275
  }
276
+ return true
236
277
  }
237
- export function machine_publish(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) {
278
+ export function machine_publish(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : boolean {
279
+ if (!IsValidObjects([machine, permission])) return false;
238
280
  if (passport) {
239
281
  txb.moveCall({
240
282
  target:PROTOCOL.MachineFn('publish_with_passport') as FnCallType,
241
- arguments:[passport, machine, permission],
283
+ arguments:[passport, TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
242
284
  })
243
285
  } else {
244
286
  txb.moveCall({
245
287
  target:PROTOCOL.MachineFn('publish') as FnCallType,
246
- arguments:[machine, permission],
288
+ arguments:[TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
247
289
  })
248
290
  }
291
+ return true
249
292
  }
250
293
 
251
- export function change_permission(txb:TransactionBlock, machine:MachineObject, old_permission:PermissionObject, new_permission:PermissionObject) {
294
+ export function change_permission(txb:TransactionBlock, machine:MachineObject, old_permission:PermissionObject, new_permission:PermissionObject) : boolean {
295
+ if (!IsValidObjects([machine, old_permission, new_permission])) return false;
252
296
  txb.moveCall({
253
297
  target:PROTOCOL.MachineFn('permission_set') as FnCallType,
254
- arguments: [machine, old_permission, new_permission],
298
+ arguments: [TXB_OBJECT(txb, machine), TXB_OBJECT(txb, old_permission), TXB_OBJECT(txb, new_permission)],
255
299
  typeArguments:[]
256
300
  })
301
+ return true
257
302
  }
@@ -0,0 +1,30 @@
1
+ {
2
+ object(
3
+ address: "0x30feecaf0e3930da9c6deab887413a25e956572330a1071f3b29ad83764ba384"
4
+ ) {
5
+ asMoveObject {
6
+ contents {
7
+ json
8
+ type {
9
+ repr
10
+ }
11
+ }
12
+ }
13
+ dynamicFields {
14
+ pageInfo {
15
+ hasNextPage
16
+ endCursor
17
+ }
18
+ nodes {
19
+ name {
20
+ json
21
+ }
22
+ value {
23
+ ... on MoveValue {
24
+ json
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
package/src/passport.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { SuiObjectResponse, SuiObjectDataOptions } from '@mysten/sui.js/client';
2
2
  import { TransactionBlock, TransactionResult, type TransactionObjectInput, Inputs } from '@mysten/sui.js/transactions';
3
- import { PROTOCOL, FnCallType, CLOCK_OBJECT, Query_Param, OBJECTS_TYPE, OBJECTS_TYPE_PREFIX} from './protocol';
3
+ import { PROTOCOL, FnCallType, CLOCK_OBJECT, Query_Param, OBJECTS_TYPE, OBJECTS_TYPE_PREFIX, PassportObject} from './protocol';
4
4
  import { parse_object_type, array_unique } from './util';
5
5
  import { sense_objects_fn } from './guard';
6
6
 
7
- export const MAX_GUARD_COUNT = 4;
7
+ export const MAX_GUARD_COUNT = 8;
8
8
 
9
9
  // passport verify for some guards, MUST be in ONE pxb:
10
10
  // 0. construct Guard_Query_Objects(passport_quries) from queries for guards of objects
@@ -15,9 +15,8 @@ export const MAX_GUARD_COUNT = 4;
15
15
  // 5. ops using passport(guard set on object)
16
16
  // 6. destroy passport
17
17
 
18
- export type PassportObject = TransactionResult;
19
18
 
20
- export const passport_quries = async (guards:string[]) : Promise<Guard_Query_Object[]> => {
19
+ export const passport_queries = async (guards:string[]) : Promise<Guard_Query_Object[]> => {
21
20
  let sense_objects = guards.map((value) => {
22
21
  return {objectid:value, callback:sense_objects_fn, data:[]} as Query_Param
23
22
  });
@@ -38,9 +37,9 @@ export const passport_quries = async (guards:string[]) : Promise<Guard_Query_Obj
38
37
  })
39
38
  }
40
39
  // return passport object for using
41
- export function verify(txb:TransactionBlock, passport_queries:Guard_Query_Object[]) : PassportObject | undefined {
40
+ export function verify(txb:TransactionBlock, passport_queries:Guard_Query_Object[]) : PassportObject | boolean {
42
41
  if (passport_queries.length == 0 || passport_queries.length > MAX_GUARD_COUNT) {
43
- return undefined;
42
+ return false;
44
43
  }
45
44
  let guard_ids = passport_queries.map((value)=>value.id);
46
45
  var passport = txb.moveCall({
@@ -76,11 +75,12 @@ export function verify(txb:TransactionBlock, passport_queries:Guard_Query_Object
76
75
  return passport;
77
76
  }
78
77
 
79
- export function destroy(txb:TransactionBlock, passport:PassportObject) {
78
+ export function destroy(txb:TransactionBlock, passport:PassportObject) : boolean {
80
79
  txb.moveCall({
81
80
  target: PROTOCOL.PassportFn('destroy') as FnCallType,
82
81
  arguments: [ passport ]
83
82
  });
83
+ return true
84
84
  }
85
85
 
86
86
  export type Guard_Query_Object = {