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/package.json +3 -3
- package/src/demand.ts +85 -98
- package/src/entity.ts +34 -34
- package/src/guard.ts +15 -15
- package/src/machine.ts +150 -174
- package/src/passport.ts +34 -37
- package/src/permission.ts +80 -96
- package/src/progress.ts +118 -118
- package/src/protocol.ts +25 -28
- package/src/repository.ts +147 -160
- package/src/resource.ts +43 -45
- package/src/reward.ts +108 -119
- package/src/service.ts +338 -364
- package/src/utils.ts +4 -4
- package/src/vote.ts +139 -157
- package/src/wowok.ts +19 -23
package/src/passport.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { type TransactionObjectInput, Inputs,
|
|
2
|
-
import { SuiObjectResponse } from '@mysten/sui
|
|
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(
|
|
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(
|
|
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 == (
|
|
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
|
-
|
|
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
|
|
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 <
|
|
690
|
-
if (data.type.includes(
|
|
691
|
-
return { target:
|
|
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
|
|
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 (
|
|
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.
|
|
719
|
-
|
|
720
|
-
|
|
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:
|
|
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:
|
|
746
|
-
arguments: [ this.passport, txb.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:
|
|
756
|
-
arguments: [ this.passport, txb.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
|
-
|
|
762
|
-
|
|
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
|
-
|
|
770
|
-
|
|
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
|
|
187
|
+
protected txb;
|
|
187
188
|
protected object : TxbObject;
|
|
188
189
|
|
|
189
190
|
get_object() { return this.object }
|
|
190
|
-
private constructor(
|
|
191
|
-
this.
|
|
191
|
+
private constructor(txb:TransactionBlock) {
|
|
192
|
+
this.txb = txb;
|
|
192
193
|
this.object = '';
|
|
193
194
|
}
|
|
194
|
-
static From(
|
|
195
|
-
let p = new Permission(
|
|
196
|
-
p.object = Protocol.TXB_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(
|
|
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(
|
|
205
|
-
let txb = protocol.CurrentSession();
|
|
205
|
+
let p = new Permission(txb);
|
|
206
206
|
p.object = txb.moveCall({
|
|
207
|
-
target:
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
260
|
-
txb.moveCall({
|
|
261
|
-
target:
|
|
262
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(old_entity
|
|
263
|
-
txb.pure(new_entity
|
|
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:
|
|
278
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index
|
|
279
|
-
txb.pure(array_unique(entities)
|
|
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:
|
|
284
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(entities)
|
|
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:
|
|
329
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity.entity_address
|
|
330
|
-
txb.pure(
|
|
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:
|
|
338
|
-
arguments:[ Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
|
|
339
|
-
txb.pure(index
|
|
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:
|
|
357
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address
|
|
358
|
-
txb.pure(index
|
|
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:
|
|
363
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address
|
|
364
|
-
txb.pure(index
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
401
|
-
txb.moveCall({
|
|
402
|
-
target:
|
|
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
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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:
|
|
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:
|
|
436
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(admin)
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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
|