wowok 1.2.11 → 1.2.12

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/passport.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { type TransactionObjectInput, Inputs, TransactionObjectArgument} from '@mysten/sui.js/transactions';
2
- import { SuiObjectResponse } from '@mysten/sui.js/client';
1
+ import { type TransactionObjectInput, Inputs, Transaction as TransactionBlock} from '@mysten/sui/transactions';
2
+ import { SuiObjectResponse } from '@mysten/sui/client';
3
3
  import { FnCallType, GuardObject, Protocol, ContextType, OperatorType, Data_Type,
4
4
  ValueType, SER_VALUE, IsValidOperatorType } from './protocol';
5
5
  import { parse_object_type, array_unique, Bcs, ulebDecode, IsValidAddress, IsValidArray, OPTION_NONE, readOption, readOptionString } from './utils';
6
6
  import { BCS, BcsReader } from '@mysten/bcs';
7
7
  import { ERROR, Errors } from './exception';
8
8
  import { Guard } from './guard';
9
+ import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
9
10
 
10
11
  export type Guard_Query_Object = {
11
12
  target: FnCallType, // object fnCall
@@ -59,13 +60,11 @@ export interface PassportQuery {
59
60
  }
60
61
  export class GuardParser {
61
62
  protected guard_list: GuardInfo[] = [];
62
- protected protocol: Protocol;
63
63
  protected guards: string[];
64
64
  private index:number = 0;
65
65
  private get_index() { return this.index++ }
66
66
 
67
- private constructor(protocol: Protocol, guards: string[]) {
68
- this.protocol = protocol ;
67
+ private constructor(guards: string[]) {
69
68
  this.guards = guards;
70
69
  }
71
70
  guardlist = () => { return this.guard_list }
@@ -453,7 +452,7 @@ export class GuardParser {
453
452
  */
454
453
  private static Parse_Guard_Helper(guards: string[], res:SuiObjectResponse[]) {
455
454
  const protocol = Protocol.Instance();
456
- const me = new GuardParser(protocol, guards);
455
+ const me = new GuardParser(guards);
457
456
  res.forEach((r) => {
458
457
  let c = r.data?.content as any;
459
458
  if (!c) return;
@@ -512,7 +511,7 @@ export class GuardParser {
512
511
 
513
512
  parse_constant = (info:GuardInfo, constants:any) => {
514
513
  constants.forEach((v:any) => {
515
- if (v.type == (this.protocol.Package() + '::guard::Constant')) {
514
+ if (v.type == (Protocol.Instance().Package() + '::guard::Constant')) {
516
515
  // ValueType.TYPE_ADDRESS: Query_Cmd maybe used the address, so save it for querying
517
516
  if (v.fields.type == ContextType.TYPE_WITNESS_ID || v.fields.type == ValueType.TYPE_ADDRESS) {
518
517
  info.constant.push({identifier:v.fields.identifier, index:this.get_index(), type:v.fields.type,
@@ -643,7 +642,7 @@ export class GuardParser {
643
642
  })
644
643
 
645
644
  if (onPassportQueryReady) {
646
- this.protocol.Query_Raw(array_unique(objects), {showType:true}).then((res) => {
645
+ Protocol.Instance().Query_Raw(array_unique(objects), {showType:true}).then((res) => {
647
646
  onPassportQueryReady(this.done_helper(res));
648
647
  }).catch(e => {
649
648
  console.log(e);
@@ -651,7 +650,7 @@ export class GuardParser {
651
650
  })
652
651
  return undefined;
653
652
  } else {
654
- const res = await this.protocol.Query_Raw(array_unique(objects), {showType:true});
653
+ const res = await Protocol.Instance().Query_Raw(array_unique(objects), {showType:true});
655
654
  return this.done_helper(res);
656
655
  }
657
656
  }
@@ -686,9 +685,9 @@ export class GuardParser {
686
685
 
687
686
  // create onchain query for objects : object, movecall-types, id
688
687
  private object_query = (data: any, method:'guard_query'|'witness'='guard_query') : Guard_Query_Object | undefined=> {
689
- for (let k = 0; k < this.protocol.WOWOK_OBJECTS_TYPE().length; k++) {
690
- if (data.type.includes(this.protocol.WOWOK_OBJECTS_TYPE()[k]) ) { // type: pack::m::Object<...>
691
- return { target:this.protocol.WOWOK_OBJECTS_PREFIX_TYPE()[k] + method as FnCallType,
688
+ for (let k = 0; k < Protocol.Instance().WOWOK_OBJECTS_TYPE().length; k++) {
689
+ if (data.type.includes(Protocol.Instance().WOWOK_OBJECTS_TYPE()[k]) ) { // type: pack::m::Object<...>
690
+ return { target:Protocol.Instance().WOWOK_OBJECTS_PREFIX_TYPE()[k] + method as FnCallType,
692
691
  object:Inputs.SharedObjectRef({
693
692
  objectId: data.objectId,
694
693
  mutable: false,
@@ -705,70 +704,68 @@ export class GuardParser {
705
704
  export class Passport {
706
705
  static MAX_GUARD_COUNT = 8;
707
706
  protected passport;
708
- protected protocol;
707
+ protected txb;
709
708
 
710
709
  get_object () { return this.passport }
711
710
  // return passport object used
712
711
  // bObject(true) in cmd env; (false) in service env
713
- constructor (protocol:Protocol, query:PassportQuery, bObject:boolean=false) {
712
+ constructor (txb:TransactionBlock, query:PassportQuery, bObject:boolean=false) {
714
713
  if (!query.guard || query.guard.length > Passport.MAX_GUARD_COUNT) {
715
714
  ERROR(Errors.InvalidParam, 'guards' )
716
715
  }
717
716
 
718
- this.protocol = protocol;
719
- let txb = protocol.CurrentSession();
720
- this.passport = txb.moveCall({
721
- target: protocol.PassportFn('new') as FnCallType,
717
+ this.txb = txb;
718
+ this.passport = this.txb.moveCall({
719
+ target:Protocol.Instance().PassportFn('new') as FnCallType,
722
720
  arguments: []
723
721
  });
724
722
 
725
723
  // add others guards, if any
726
724
  query.guard.forEach((g) => {
727
- txb.moveCall({
728
- target:protocol.PassportFn('guard_add') as FnCallType,
729
- arguments:[this.passport, txb.object(g)]
725
+ this.txb.moveCall({
726
+ target:Protocol.Instance().PassportFn('guard_add') as FnCallType,
727
+ arguments:[this.passport, this.txb.object(g)]
730
728
  });
731
729
  })
732
730
 
733
731
  // witness
734
732
  query?.witness.forEach((w) => {
735
- txb.moveCall({
733
+ this.txb.moveCall({
736
734
  target: w.target as FnCallType,
737
- arguments: [this.passport, txb.object(w.object)],
735
+ arguments: [this.passport, this.txb.object(w.object)],
738
736
  typeArguments: w.types,
739
737
  })
740
738
  })
741
739
 
740
+ const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
742
741
  // rules: 'verify' & 'query' in turns; 'verify' at final end.
743
742
  query?.query.forEach((q) => {
744
- let address = txb.moveCall({
745
- target: protocol.PassportFn('passport_verify') as FnCallType,
746
- arguments: [ this.passport, txb.object(Protocol.CLOCK_OBJECT)]
743
+ let address = this.txb.moveCall({
744
+ target: Protocol.Instance().PassportFn('passport_verify') as FnCallType,
745
+ arguments: [ this.passport, this.txb.object(clock)]
747
746
  });
748
- txb.moveCall({
747
+ this.txb.moveCall({
749
748
  target: q.target as FnCallType,
750
- arguments: [ bObject ? txb.object(q.object) : txb.object(q.id), this.passport, address ],
749
+ arguments: [ bObject ? this.txb.object(q.object) : this.txb.object(q.id), this.passport, address ],
751
750
  typeArguments: q.types,
752
751
  })
753
752
  })
754
- txb.moveCall({
755
- target: protocol.PassportFn('passport_verify') as FnCallType,
756
- arguments: [ this.passport, txb.object(Protocol.CLOCK_OBJECT) ]
753
+ this.txb.moveCall({
754
+ target: Protocol.Instance().PassportFn('passport_verify') as FnCallType,
755
+ arguments: [ this.passport, this.txb.object(clock) ]
757
756
  });
758
757
  }
759
758
 
760
759
  destroy() {
761
- let txb = this.protocol.CurrentSession();
762
- txb.moveCall({
763
- target: this.protocol.PassportFn('destroy') as FnCallType,
760
+ this.txb.moveCall({
761
+ target: Protocol.Instance().PassportFn('destroy') as FnCallType,
764
762
  arguments: [ this.passport ]
765
763
  });
766
764
  }
767
765
 
768
766
  freeze() {
769
- let txb = this.protocol.CurrentSession();
770
- txb.moveCall({
771
- target: this.protocol.PassportFn('freezen') as FnCallType,
767
+ this.txb.moveCall({
768
+ target: Protocol.Instance().PassportFn('freezen') as FnCallType,
772
769
  arguments: [ this.passport ]
773
770
  });
774
771
  }
package/src/permission.ts CHANGED
@@ -4,6 +4,7 @@ import { array_unique, IsValidAddress, IsValidArray, IsValidDesription, IsValid
4
4
  import { ERROR, Errors } from './exception';
5
5
  import { ValueType } from './protocol';
6
6
  import { Passport } from './passport';
7
+ import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
7
8
 
8
9
  export enum PermissionIndex {
9
10
  repository = 100,
@@ -183,46 +184,43 @@ export type Permission_Entity = {
183
184
  }
184
185
 
185
186
  export class Permission {
186
- protected protocol;
187
+ protected txb;
187
188
  protected object : TxbObject;
188
189
 
189
190
  get_object() { return this.object }
190
- private constructor(protocol:Protocol) {
191
- this.protocol = protocol;
191
+ private constructor(txb:TransactionBlock) {
192
+ this.txb = txb;
192
193
  this.object = '';
193
194
  }
194
- static From(protocol:Protocol, object:TxbObject) : Permission {
195
- let p = new Permission(protocol);
196
- p.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
195
+ static From(txb:TransactionBlock, object:TxbObject) : Permission {
196
+ let p = new Permission(txb);
197
+ p.object = Protocol.TXB_OBJECT(txb, object);
197
198
  return p
198
199
  }
199
200
 
200
- static New(protocol:Protocol, description:string) : Permission {
201
+ static New(txb:TransactionBlock, description:string) : Permission {
201
202
  if (!IsValidDesription(description)) {
202
203
  ERROR(Errors.IsValidDesription)
203
204
  }
204
- let p = new Permission(protocol);
205
- let txb = protocol.CurrentSession();
205
+ let p = new Permission(txb);
206
206
  p.object = txb.moveCall({
207
- target: protocol.PermissionFn('new') as FnCallType,
208
- arguments: [txb.pure(description)]
207
+ target: Protocol.Instance().PermissionFn('new') as FnCallType,
208
+ arguments: [txb.pure.string(description)]
209
209
  });
210
210
  return p
211
211
  }
212
212
 
213
213
  launch() : PermissionAddress {
214
- let txb = this.protocol.CurrentSession();
215
- return txb.moveCall({ // address returned
216
- target:this.protocol.PermissionFn('create') as FnCallType,
217
- arguments:[ Protocol.TXB_OBJECT(txb, this.object) ]
214
+ return this.txb.moveCall({ // address returned
215
+ target:Protocol.Instance().PermissionFn('create') as FnCallType,
216
+ arguments:[ Protocol.TXB_OBJECT(this.txb, this.object) ]
218
217
  })
219
218
  }
220
219
 
221
220
  destroy() {
222
- let txb = this.protocol.CurrentSession();
223
- txb.moveCall({
224
- target:this.protocol.PermissionFn('destroy') as FnCallType,
225
- arguments: [Protocol.TXB_OBJECT(txb, this.object)],
221
+ this.txb.moveCall({
222
+ target:Protocol.Instance().PermissionFn('destroy') as FnCallType,
223
+ arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
226
224
  })
227
225
  }
228
226
  add_userdefine(index: number, name:string) {
@@ -233,10 +231,9 @@ export class Permission {
233
231
  if (!IsValidName(name)) {
234
232
  ERROR(Errors.IsValidName, 'add_userdefine');
235
233
  }
236
- let txb = this.protocol.CurrentSession();
237
- txb.moveCall({
238
- target:this.protocol.PermissionFn('user_define_add') as FnCallType,
239
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64), txb.pure(name)]
234
+ this.txb.moveCall({
235
+ target:Protocol.Instance().PermissionFn('user_define_add') as FnCallType,
236
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u64(index), this.txb.pure.string(name)]
240
237
  })
241
238
  }
242
239
 
@@ -245,10 +242,9 @@ export class Permission {
245
242
  ERROR(Errors.IsValidUserDefinedIndex, 'add_userdefine');
246
243
  }
247
244
 
248
- let txb = this.protocol.CurrentSession();
249
- txb.moveCall({
250
- target:this.protocol.PermissionFn('user_define_remove') as FnCallType,
251
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64)]
245
+ this.txb.moveCall({
246
+ target:Protocol.Instance().PermissionFn('user_define_remove') as FnCallType,
247
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u64(index)]
252
248
  })
253
249
  }
254
250
 
@@ -256,11 +252,11 @@ export class Permission {
256
252
  if (!IsValidAddress(old_entity) || !IsValidAddress(new_entity)) {
257
253
  ERROR(Errors.IsValidAddress, 'change_entity')
258
254
  }
259
- let txb = this.protocol.CurrentSession();
260
- txb.moveCall({
261
- target:this.protocol.PermissionFn('change_entity') as FnCallType,
262
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(old_entity, BCS.ADDRESS),
263
- txb.pure(new_entity, BCS.ADDRESS) ]
255
+
256
+ this.txb.moveCall({
257
+ target:Protocol.Instance().PermissionFn('change_entity') as FnCallType,
258
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(old_entity),
259
+ this.txb.pure.address(new_entity) ]
264
260
  })
265
261
  }
266
262
 
@@ -271,17 +267,16 @@ export class Permission {
271
267
  ERROR(Errors.IsValidArray, 'add_entity2');
272
268
  }
273
269
 
274
- let txb = this.protocol.CurrentSession();
275
270
  if (index) {
276
- txb.moveCall({
277
- target:this.protocol.PermissionFn('add_with_index') as FnCallType,
278
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64),
279
- txb.pure(array_unique(entities), 'vector<address>')]
271
+ this.txb.moveCall({
272
+ target:Protocol.Instance().PermissionFn('add_with_index') as FnCallType,
273
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u64(index),
274
+ this.txb.pure.vector('address', array_unique(entities))]
280
275
  })
281
276
  } else {
282
- txb.moveCall({
283
- target:this.protocol.PermissionFn('add') as FnCallType,
284
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(entities), 'vector<address>')]
277
+ this.txb.moveCall({
278
+ target:Protocol.Instance().PermissionFn('add') as FnCallType,
279
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(entities))]
285
280
  })
286
281
  }
287
282
  }
@@ -303,9 +298,7 @@ export class Permission {
303
298
  ERROR(Errors.InvalidParam, 'entities');
304
299
  }
305
300
 
306
- let txb = this.protocol.CurrentSession();
307
301
  let guards:any[] = [];
308
-
309
302
  for (let i = 0; i < entities.length; i++) {
310
303
  let entity = entities[i];
311
304
  let indexes :number[] = [];
@@ -324,19 +317,19 @@ export class Permission {
324
317
  }
325
318
  }
326
319
  //if (indexes.length > 0) {
327
- txb.moveCall({
328
- target:this.protocol.PermissionFn('add_batch') as FnCallType,
329
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity.entity_address, BCS.ADDRESS),
330
- txb.pure(indexes, 'vector<u64>')]
320
+ this.txb.moveCall({
321
+ target:Protocol.Instance().PermissionFn('add_batch') as FnCallType,
322
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(entity.entity_address),
323
+ this.txb.pure.vector('u64', indexes)]
331
324
  })
332
325
  //}
333
326
  }
334
327
  // set guards
335
328
  guards.forEach(({entity_address, index, guard}) => {
336
- txb.moveCall({
337
- target:this.protocol.PermissionFn('guard_set') as FnCallType,
338
- arguments:[ Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
339
- txb.pure(index, BCS.U64), Protocol.TXB_OBJECT(txb, guard)]
329
+ this.txb.moveCall({
330
+ target:Protocol.Instance().PermissionFn('guard_set') as FnCallType,
331
+ arguments:[ Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure(entity_address, BCS.ADDRESS),
332
+ this.txb.pure.u64(index), Protocol.TXB_OBJECT(this.txb, guard)]
340
333
  })
341
334
  })
342
335
  }
@@ -350,18 +343,17 @@ export class Permission {
350
343
  ERROR(Errors.IsValidPermissionIndex, 'index')
351
344
  }
352
345
 
353
- let txb = this.protocol.CurrentSession();
354
346
  if (guard) {
355
- txb.moveCall({
356
- target:this.protocol.PermissionFn('guard_set') as FnCallType,
357
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
358
- txb.pure(index, BCS.U64), Protocol.TXB_OBJECT(txb, guard)]
347
+ this.txb.moveCall({
348
+ target:Protocol.Instance().PermissionFn('guard_set') as FnCallType,
349
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(entity_address),
350
+ this.txb.pure.u64(index), Protocol.TXB_OBJECT(this.txb, guard)]
359
351
  })
360
352
  } else {
361
- txb.moveCall({
362
- target:this.protocol.PermissionFn('guard_none') as FnCallType,
363
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
364
- txb.pure(index, BCS.U64)]
353
+ this.txb.moveCall({
354
+ target:Protocol.Instance().PermissionFn('guard_none') as FnCallType,
355
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(entity_address),
356
+ this.txb.pure.u64(index)]
365
357
  })
366
358
  };
367
359
  }
@@ -374,11 +366,10 @@ export class Permission {
374
366
  ERROR(Errors.InvalidParam, 'index')
375
367
  }
376
368
 
377
- let txb = this.protocol.CurrentSession();
378
- txb.moveCall({
379
- target:this.protocol.PermissionFn('remove_index') as FnCallType,
380
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
381
- txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, array_unique(index)))]
369
+ this.txb.moveCall({
370
+ target:Protocol.Instance().PermissionFn('remove_index') as FnCallType,
371
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(entity_address),
372
+ this.txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_U64, array_unique(index)))]
382
373
  })
383
374
  }
384
375
  remove_entity(entity_address:string[]) {
@@ -386,21 +377,20 @@ export class Permission {
386
377
  ERROR(Errors.IsValidArray)
387
378
  }
388
379
 
389
- let txb = this.protocol.CurrentSession();
390
- txb.moveCall({
391
- target:this.protocol.PermissionFn('remove') as FnCallType,
392
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(entity_address), 'vector<address>')]
380
+ this.txb.moveCall({
381
+ target:Protocol.Instance().PermissionFn('remove') as FnCallType,
382
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(entity_address))]
393
383
  })
394
- ;
395
384
  }
385
+
396
386
  set_description(description:string) {
397
387
  if (!IsValidDesription(description)) {
398
388
  ERROR(Errors.IsValidDesription)
399
389
  }
400
- let txb = this.protocol.CurrentSession();
401
- txb.moveCall({
402
- target:this.protocol.PermissionFn('description_set') as FnCallType,
403
- arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(description)]
390
+
391
+ this.txb.moveCall({
392
+ target:Protocol.Instance().PermissionFn('description_set') as FnCallType,
393
+ arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description)]
404
394
  })
405
395
  ;
406
396
  }
@@ -410,12 +400,10 @@ export class Permission {
410
400
  ERROR(Errors.IsValidArray)
411
401
  }
412
402
 
413
- let txb = this.protocol.CurrentSession();
414
- txb.moveCall({
415
- target:this.protocol.PermissionFn('admin_add_batch') as FnCallType,
416
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(admin), 'vector<address>')]
403
+ this.txb.moveCall({
404
+ target:Protocol.Instance().PermissionFn('admin_add_batch') as FnCallType,
405
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(admin))]
417
406
  });
418
- ;
419
407
  }
420
408
 
421
409
  remove_admin(admin:string[], removeall?:boolean) {
@@ -424,16 +412,15 @@ export class Permission {
424
412
  ERROR(Errors.IsValidArray, 'admin')
425
413
  }
426
414
 
427
- let txb = this.protocol.CurrentSession();
428
415
  if (removeall) {
429
- txb.moveCall({
430
- target:this.protocol.PermissionFn('admins_clear') as FnCallType,
431
- arguments:[Protocol.TXB_OBJECT(txb, this.object)]
416
+ this.txb.moveCall({
417
+ target:Protocol.Instance().PermissionFn('admins_clear') as FnCallType,
418
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
432
419
  });
433
420
  } else if (admin) {
434
- txb.moveCall({
435
- target:this.protocol.PermissionFn('admin_remove_batch') as FnCallType,
436
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(admin), 'vector<address>')]
421
+ this.txb.moveCall({
422
+ target:Protocol.Instance().PermissionFn('admin_remove_batch') as FnCallType,
423
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(admin))]
437
424
  });
438
425
  }
439
426
 
@@ -444,10 +431,9 @@ export class Permission {
444
431
  ERROR(Errors.IsValidAddress)
445
432
  }
446
433
 
447
- let txb = this.protocol.CurrentSession();
448
- txb.moveCall({
449
- target:this.protocol.PermissionFn('builder_set') as FnCallType,
450
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(new_owner, BCS.ADDRESS)]
434
+ this.txb.moveCall({
435
+ target:Protocol.Instance().PermissionFn('builder_set') as FnCallType,
436
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(new_owner)]
451
437
  });
452
438
  }
453
439
  query_permissions(address_queried:string, permissions:PermissionIndexType[]) {
@@ -459,17 +445,15 @@ export class Permission {
459
445
  ERROR(Errors.InvalidParam, 'permissions count');
460
446
  }
461
447
 
462
- const txb = this.protocol.CurrentSession();
463
- txb.moveCall({
464
- target:this.protocol.PermissionFn('query_permissions') as FnCallType,
465
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(address_queried, BCS.ADDRESS), txb.pure(permissions, 'vector<u64>')]
448
+ this.txb.moveCall({
449
+ target:Protocol.Instance().PermissionFn('query_permissions') as FnCallType,
450
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(address_queried), this.txb.pure.vector('u64', permissions)]
466
451
  })
467
452
  }
468
453
 
469
- QueryPermissions(address_queried:string, permissions:PermissionIndexType[], onPermissionAnswer:OnPermissionAnswer, sender?:string) {
454
+ QueryPermissions(txb:TransactionBlock, address_queried:string, permissions:PermissionIndexType[], onPermissionAnswer:OnPermissionAnswer, sender?:string) {
470
455
  this.query_permissions(address_queried, permissions);
471
- Protocol.Client().devInspectTransactionBlock({sender:sender ?? address_queried,
472
- transactionBlock:this.protocol.CurrentSession()}).then((res) => {
456
+ Protocol.Client().devInspectTransactionBlock({sender:sender ?? address_queried, transactionBlock:txb}).then((res) => {
473
457
  if (res.results && res.results[0].returnValues && res.results[0].returnValues.length !== 3 ) {
474
458
  onPermissionAnswer({who:address_queried});
475
459
  return