wowok 1.2.12 → 1.3.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.
- package/package.json +1 -1
- package/src/demand.ts +0 -1
- package/src/entity.ts +0 -1
- package/src/guard.ts +1 -1
- package/src/machine.ts +70 -22
- package/src/passport.ts +45 -2
- package/src/permission.ts +76 -63
- package/src/progress.ts +7 -8
- package/src/protocol.ts +4 -5
- package/src/repository.ts +1 -2
- package/src/resource.ts +0 -1
- package/src/reward.ts +0 -2
- package/src/service.ts +2 -3
- package/src/utils.ts +2 -3
- package/src/wowok.ts +0 -1
package/package.json
CHANGED
package/src/demand.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
2
|
-
import { BCS } from '@mysten/bcs';
|
|
3
2
|
import { FnCallType, Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject, ResourceObject} from './protocol';
|
|
4
3
|
import { IsValidDesription, IsValidUintLarge, IsValidAddress, IsValidArgType, } from './utils'
|
|
5
4
|
import { Errors, ERROR} from './exception'
|
package/src/entity.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BCS, encodeStr, getSuiMoveConfig } from '@mysten/bcs';
|
|
2
1
|
import { Protocol, FnCallType, TxbObject, ResourceAddress, PermissionObject, ResourceObject} from './protocol';
|
|
3
2
|
import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, Bcs, } from './utils';
|
|
4
3
|
import { ERROR, Errors } from './exception';
|
package/src/guard.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, ConstantType, SER_VALUE} from './protocol';
|
|
4
4
|
import { concatenate, array_equal } from './utils';
|
|
5
5
|
import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase } from './utils';
|
package/src/machine.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Transaction as TransactionBlock, TransactionObjectArgument, type TransactionResult } from '@mysten/sui/transactions';
|
|
2
|
-
import { BCS } from '@mysten/bcs';
|
|
3
2
|
import { Protocol, FnCallType, PermissionObject, RepositoryObject, PassportObject, MachineObject, MachineAddress, GuardObject, TxbObject} from './protocol';
|
|
4
3
|
import { IsValidInt, Bcs, array_unique, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty,
|
|
5
4
|
IsValidEndpoint, IsValidDesription,
|
|
6
|
-
IsValidUintLarge
|
|
5
|
+
IsValidUintLarge,
|
|
6
|
+
IsValidU64} from './utils'
|
|
7
7
|
import { Permission, PermissionIndexType } from './permission';
|
|
8
8
|
import { Errors, ERROR} from './exception'
|
|
9
9
|
import { ValueType } from './protocol';
|
|
@@ -26,6 +26,14 @@ export interface Machine_Node {
|
|
|
26
26
|
pairs: Machine_Node_Pair[];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export interface QueryGuardParam {
|
|
30
|
+
node: string;
|
|
31
|
+
prior_node: string;
|
|
32
|
+
forward: string;
|
|
33
|
+
txb: TransactionBlock;
|
|
34
|
+
guard: string | null;
|
|
35
|
+
}
|
|
36
|
+
export type OnQueryGuard = (param: QueryGuardParam) => void;
|
|
29
37
|
export class Machine {
|
|
30
38
|
protected txb;
|
|
31
39
|
protected object : TxbObject;
|
|
@@ -83,7 +91,7 @@ export class Machine {
|
|
|
83
91
|
if (!IsValidName_AllowEmpty(p.prior_node)) { bValid = false; }
|
|
84
92
|
if (p?.threshold && !IsValidInt(p.threshold)) { bValid = false; }
|
|
85
93
|
p.forwards.forEach((f) => {
|
|
86
|
-
if (
|
|
94
|
+
if (Machine.checkValidForward(f) !== '') bValid = false;
|
|
87
95
|
})
|
|
88
96
|
})
|
|
89
97
|
})
|
|
@@ -120,21 +128,30 @@ export class Machine {
|
|
|
120
128
|
|
|
121
129
|
forward(forward:Machine_Forward) : TransactionResult {
|
|
122
130
|
let weight = forward?.weight ? forward.weight : 1;
|
|
123
|
-
let perm = this.txb.pure.option('u64', forward?.permission);
|
|
124
|
-
let namedOperator = forward?.namedOperator ? this.txb.pure.string(forward.namedOperator) : this.txb.pure.string('');
|
|
125
131
|
let f:any;
|
|
126
132
|
|
|
127
|
-
|
|
133
|
+
// namedOperator first.
|
|
134
|
+
if (forward?.namedOperator && IsValidName(forward.namedOperator)) {
|
|
135
|
+
if (forward?.guard) {
|
|
136
|
+
f = this.txb.moveCall({
|
|
137
|
+
target:Protocol.Instance().MachineFn('forward') as FnCallType,
|
|
138
|
+
arguments:[this.txb.pure.string(forward.namedOperator), this.txb.pure.u16(weight), this.txb.object(Protocol.TXB_OBJECT(this.txb, forward.guard))]
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
f = this.txb.moveCall({
|
|
142
|
+
target:Protocol.Instance().MachineFn('forward2') as FnCallType,
|
|
143
|
+
arguments:[this.txb.pure.string(forward.namedOperator), this.txb.pure.u16(weight)]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} else if (forward?.permission !== undefined && IsValidU64(forward.permission)) {
|
|
128
147
|
f = this.txb.moveCall({
|
|
129
|
-
target:Protocol.Instance().MachineFn('
|
|
130
|
-
arguments:[
|
|
131
|
-
});
|
|
148
|
+
target:Protocol.Instance().MachineFn('forward3') as FnCallType,
|
|
149
|
+
arguments:[this.txb.pure.u64(forward.permission), this.txb.pure.u16(weight)]
|
|
150
|
+
});
|
|
132
151
|
} else {
|
|
133
|
-
|
|
134
|
-
target:Protocol.Instance().MachineFn('forward2') as FnCallType,
|
|
135
|
-
arguments:[namedOperator, this.txb.pure.u16(weight), perm]
|
|
136
|
-
});
|
|
152
|
+
ERROR(Errors.InvalidParam, 'forward')
|
|
137
153
|
}
|
|
154
|
+
|
|
138
155
|
return f
|
|
139
156
|
}
|
|
140
157
|
|
|
@@ -373,10 +390,10 @@ export class Machine {
|
|
|
373
390
|
this.permission = new_permission;
|
|
374
391
|
}
|
|
375
392
|
|
|
376
|
-
add_forward(node_prior:string, node_name:string, foward: Machine_Forward, threshold?:number, passport?:PassportObject) {
|
|
393
|
+
add_forward(node_prior:string, node_name:string, foward: Machine_Forward, threshold?:number, old_forward_name?:string, passport?:PassportObject) {
|
|
377
394
|
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'add_forward');
|
|
378
395
|
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'add_forward');
|
|
379
|
-
|
|
396
|
+
const err = Machine.checkValidForward(foward); if (err) ERROR(Errors.InvalidParam, err);
|
|
380
397
|
|
|
381
398
|
let n : any;
|
|
382
399
|
if (passport) {
|
|
@@ -397,6 +414,14 @@ export class Machine {
|
|
|
397
414
|
target:Protocol.Instance().MachineFn('forward_add') as FnCallType,
|
|
398
415
|
arguments:[n, this.txb.pure.string(node_prior), this.txb.pure.string(foward.name), t, f],
|
|
399
416
|
})
|
|
417
|
+
|
|
418
|
+
if (old_forward_name && old_forward_name !== foward.name) {
|
|
419
|
+
this.txb.moveCall({
|
|
420
|
+
target:Protocol.Instance().MachineFn('forward_remove') as FnCallType,
|
|
421
|
+
arguments:[n, this.txb.pure.string(node_prior), this.txb.pure.string(old_forward_name)],
|
|
422
|
+
})
|
|
423
|
+
}
|
|
424
|
+
this.add_node2([n], passport);
|
|
400
425
|
}
|
|
401
426
|
|
|
402
427
|
remove_forward(node_prior:string, node_name:string, foward_name: string, passport?:PassportObject) {
|
|
@@ -420,6 +445,7 @@ export class Machine {
|
|
|
420
445
|
target:Protocol.Instance().MachineFn('forward_remove') as FnCallType,
|
|
421
446
|
arguments:[n, this.txb.pure.string(node_prior), this.txb.pure.string(foward_name)],
|
|
422
447
|
})
|
|
448
|
+
this.add_node2([n], passport);
|
|
423
449
|
}
|
|
424
450
|
|
|
425
451
|
static rpc_de_nodes(fields: any) : Machine_Node[] {
|
|
@@ -458,15 +484,37 @@ export class Machine {
|
|
|
458
484
|
return ret;
|
|
459
485
|
}
|
|
460
486
|
|
|
461
|
-
static
|
|
462
|
-
if (!IsValidName(forward.name)) return
|
|
463
|
-
if (forward?.namedOperator && !IsValidName_AllowEmpty(forward?.namedOperator)) return
|
|
464
|
-
if (forward?.permission && !Permission.IsValidPermissionIndex(forward?.permission)) return
|
|
465
|
-
if (!forward?.permission && !forward?.namedOperator) return
|
|
466
|
-
if (forward?.weight && !IsValidUintLarge(forward.weight)) return
|
|
467
|
-
return
|
|
487
|
+
static checkValidForward(forward:Machine_Forward) : string {
|
|
488
|
+
if (!IsValidName(forward.name)) return 'Forward name invalid'
|
|
489
|
+
if (forward?.namedOperator && !IsValidName_AllowEmpty(forward?.namedOperator)) return 'Progress Operator invalid';
|
|
490
|
+
if (forward?.permission && !Permission.IsValidPermissionIndex(forward?.permission)) return 'Permission index invalid';
|
|
491
|
+
if (!forward?.permission && !forward?.namedOperator) return 'Both Permission index and Progress Operator empty';
|
|
492
|
+
if (forward?.weight && !IsValidUintLarge(forward.weight)) return 'Weight invalid';
|
|
493
|
+
return ''
|
|
468
494
|
}
|
|
469
495
|
|
|
496
|
+
|
|
497
|
+
QueryForwardGuard(sender:string, node:string, prior_node:string, forward:string, onGuard:OnQueryGuard) {
|
|
498
|
+
if (!node || !forward) { // prior_node maybe ''
|
|
499
|
+
ERROR(Errors.InvalidParam, 'QueryForwardGuard');
|
|
500
|
+
return ;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this.txb.moveCall({
|
|
504
|
+
target:Protocol.Instance().MachineFn('query_guard') as FnCallType,
|
|
505
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node),
|
|
506
|
+
this.txb.pure.string(prior_node), this.txb.pure.string(forward)],
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
Protocol.Client().devInspectTransactionBlock({sender:sender, transactionBlock:this.txb}).then((res) => {
|
|
510
|
+
if (res.results?.length === 1 && res.results[0].returnValues?.length === 1) {
|
|
511
|
+
const guard = Bcs.getInstance().de('Option<address>', Uint8Array.from(res.results[0].returnValues[0][0]));
|
|
512
|
+
onGuard({node:node, prior_node:prior_node, forward:forward, guard:guard?.some?('0x'+guard?.some):'', txb:this.txb});
|
|
513
|
+
}
|
|
514
|
+
}).catch(e=>{
|
|
515
|
+
console.log(e);
|
|
516
|
+
})
|
|
517
|
+
}
|
|
470
518
|
static INITIAL_NODE_NAME = '';
|
|
471
519
|
/* static NODE_NAME_RESERVED = 'origin';
|
|
472
520
|
static IsNodeNameReserved = (name:string) => {
|
package/src/passport.ts
CHANGED
|
@@ -3,10 +3,8 @@ 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
|
-
import { BCS, BcsReader } from '@mysten/bcs';
|
|
7
6
|
import { ERROR, Errors } from './exception';
|
|
8
7
|
import { Guard } from './guard';
|
|
9
|
-
import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
|
|
10
8
|
|
|
11
9
|
export type Guard_Query_Object = {
|
|
12
10
|
target: FnCallType, // object fnCall
|
|
@@ -769,6 +767,51 @@ export class Passport {
|
|
|
769
767
|
arguments: [ this.passport ]
|
|
770
768
|
});
|
|
771
769
|
}
|
|
770
|
+
|
|
771
|
+
query_result(sender:string, handleResult:OnQueryPassportResult) {
|
|
772
|
+
this.txb.moveCall({
|
|
773
|
+
target: Protocol.Instance().PassportFn('query_result') as FnCallType,
|
|
774
|
+
arguments: [ this.passport ]
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
Protocol.Client().devInspectTransactionBlock({sender:sender, transactionBlock:this.txb}).then((res) => {
|
|
778
|
+
const r = Passport.ResolveQueryRes(this.txb, res);
|
|
779
|
+
if (r) handleResult(r);
|
|
780
|
+
}).catch(e=>{
|
|
781
|
+
console.log(e);
|
|
782
|
+
})
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
query_result_async = async (sender:string) : Promise<QueryPassportResult | undefined> => {
|
|
786
|
+
this.txb.moveCall({
|
|
787
|
+
target: Protocol.Instance().PassportFn('query_result') as FnCallType,
|
|
788
|
+
arguments: [ this.passport ]
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
const res = await Protocol.Client().devInspectTransactionBlock({sender:sender, transactionBlock:this.txb});
|
|
792
|
+
return Passport.ResolveQueryRes(this.txb, res);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
private static ResolveQueryRes(txb:TransactionBlock, res:any) : QueryPassportResult | undefined {
|
|
796
|
+
for (let i = 0; i < res.results?.length; ++ i) {
|
|
797
|
+
const v = res.results[i];
|
|
798
|
+
if (v?.returnValues && v.returnValues.length === 2 &&
|
|
799
|
+
v.returnValues[0][1] === 'bool' && v.returnValues[1][1] === 'vector<address>') { // (bool, vector<address>)
|
|
800
|
+
const result = Bcs.getInstance().de('bool', Uint8Array.from(v.returnValues[0][0]));
|
|
801
|
+
const guards = Bcs.getInstance().de('vector<address>', Uint8Array.from(v.returnValues[1][0])).map((v:string)=>'0x'+v);
|
|
802
|
+
return {txb:txb, result:result, guards:guards}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return undefined
|
|
806
|
+
}
|
|
772
807
|
}
|
|
773
808
|
|
|
809
|
+
export interface QueryPassportResult {
|
|
810
|
+
txb: TransactionBlock;
|
|
811
|
+
result: boolean;
|
|
812
|
+
guards: string[];
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
export type OnQueryPassportResult = (result:QueryPassportResult) => void;
|
|
816
|
+
|
|
774
817
|
|
package/src/permission.ts
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { BCS } from '@mysten/bcs';
|
|
2
1
|
import { FnCallType, TxbObject, PermissionObject, PermissionAddress, GuardObject, Protocol} from './protocol';
|
|
3
2
|
import { array_unique, IsValidAddress, IsValidArray, IsValidDesription, IsValidUintLarge, Bcs, IsValidName} from './utils';
|
|
4
3
|
import { ERROR, Errors } from './exception';
|
|
5
4
|
import { ValueType } from './protocol';
|
|
6
|
-
import {
|
|
5
|
+
import { BCS } from '@mysten/bcs';
|
|
7
6
|
import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
8
7
|
|
|
9
8
|
export enum PermissionIndex {
|
|
10
9
|
repository = 100,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
repository_description = 101,
|
|
11
|
+
repository_policy_mode = 102,
|
|
12
|
+
repository_policies = 103,
|
|
13
|
+
repository_policy_description = 105,
|
|
14
|
+
repository_policy_permission = 106,
|
|
16
15
|
repository_reference = 107,
|
|
17
16
|
|
|
18
17
|
vote = 150,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
vote_description = 151,
|
|
19
|
+
vote_reference = 152,
|
|
21
20
|
vote_guard = 153,
|
|
22
21
|
vote_option = 155,
|
|
23
|
-
|
|
22
|
+
vote_max_choice_count = 157,
|
|
24
23
|
vote_open_voting = 158,
|
|
25
24
|
vote_lock_deadline = 159,
|
|
26
25
|
vote_expand_deadline = 160,
|
|
27
26
|
vote_lock_guard = 161,
|
|
28
27
|
|
|
29
28
|
service = 200,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
service_description = 201,
|
|
30
|
+
service_price = 202,
|
|
31
|
+
service_stock = 203,
|
|
32
|
+
service_sale_endpoint = 204,
|
|
33
|
+
service_payee = 205,
|
|
35
34
|
service_repository = 206,
|
|
36
35
|
service_withdraw_guards = 208,
|
|
37
36
|
service_refund_guards = 210,
|
|
@@ -39,9 +38,9 @@ export enum PermissionIndex {
|
|
|
39
38
|
service_remove_sales = 213,
|
|
40
39
|
service_discount_transfer = 214,
|
|
41
40
|
service_withdraw = 216,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
service_buy_guard = 217,
|
|
42
|
+
service_machine = 218,
|
|
43
|
+
service_endpoint = 219,
|
|
45
44
|
service_publish = 220,
|
|
46
45
|
service_clone = 221,
|
|
47
46
|
service_customer_required = 222,
|
|
@@ -52,30 +51,33 @@ export enum PermissionIndex {
|
|
|
52
51
|
reward_refund = 241,
|
|
53
52
|
reward_expand_time = 242,
|
|
54
53
|
reward_guard = 243,
|
|
55
|
-
|
|
54
|
+
reward_description = 245,
|
|
56
55
|
reward_lock_guards = 246,
|
|
56
|
+
reward_claim_repeatably = 247,
|
|
57
|
+
reward_allow_claiming = 248,
|
|
57
58
|
|
|
58
59
|
demand = 260,
|
|
59
60
|
demand_refund = 261,
|
|
60
61
|
demand_expand_time = 262,
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
demand_guard = 263,
|
|
63
|
+
demand_description = 264,
|
|
63
64
|
demand_yes = 265,
|
|
64
65
|
|
|
65
66
|
machine = 600,
|
|
66
|
-
|
|
67
|
+
machine_description = 601,
|
|
67
68
|
machine_repository = 602,
|
|
68
69
|
machine_clone = 604,
|
|
69
70
|
machine_node = 606,
|
|
70
|
-
|
|
71
|
+
machine_endpoint = 608,
|
|
71
72
|
machine_pause = 609,
|
|
72
73
|
machine_publish = 610,
|
|
73
74
|
|
|
74
75
|
progress = 650,
|
|
75
|
-
|
|
76
|
+
progress_namedOperator = 651,
|
|
76
77
|
progress_bind_task = 652,
|
|
77
|
-
|
|
78
|
+
progress_context_repository = 653,
|
|
78
79
|
progress_unhold = 654,
|
|
80
|
+
progress_parent = 655,
|
|
79
81
|
user_defined_start = 10000,
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -92,6 +94,7 @@ export interface PermissionAnswer {
|
|
|
92
94
|
owner?: boolean;
|
|
93
95
|
admin?: boolean;
|
|
94
96
|
items?: PermissionAnswerItem[]; // items === undefined, while errors
|
|
97
|
+
object: string; // permission object
|
|
95
98
|
}
|
|
96
99
|
export interface PermissionAnswerItem {
|
|
97
100
|
query: PermissionIndexType;
|
|
@@ -102,29 +105,29 @@ export type OnPermissionAnswer = (answer: PermissionAnswer) => void;
|
|
|
102
105
|
|
|
103
106
|
export const PermissionInfo : PermissionInfoType[] = [
|
|
104
107
|
{index:PermissionIndex.repository, name:'Repository', description:'Launch new Repository', module: 'repository'},
|
|
105
|
-
{index:PermissionIndex.
|
|
106
|
-
{index:PermissionIndex.
|
|
107
|
-
{index:PermissionIndex.
|
|
108
|
-
{index:PermissionIndex.
|
|
109
|
-
{index:PermissionIndex.
|
|
108
|
+
{index:PermissionIndex.repository_description, name:'Description', description:'Set Repository description', module: 'repository'},
|
|
109
|
+
{index:PermissionIndex.repository_policy_mode, name:'Policy mode', description:'Set Repository policy mode', module: 'repository'},
|
|
110
|
+
{index:PermissionIndex.repository_policies, name:'Policy', description:'Add/Remove/Edit Repository policy', module: 'repository'},
|
|
111
|
+
{index:PermissionIndex.repository_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository'},
|
|
112
|
+
{index:PermissionIndex.repository_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository'},
|
|
110
113
|
{index:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository'},
|
|
111
114
|
|
|
112
115
|
{index:PermissionIndex.vote, name:'Vote', description:'Launch new Vote', module: 'vote'},
|
|
113
|
-
{index:PermissionIndex.
|
|
114
|
-
{index:PermissionIndex.
|
|
116
|
+
{index:PermissionIndex.vote_description, name:'Description', description:'Set Vote description', module: 'vote'},
|
|
117
|
+
{index:PermissionIndex.vote_reference, name:'Reference', description:'Set Vote reference', module: 'vote'},
|
|
115
118
|
{index:PermissionIndex.vote_guard, name:'Guard', description:'Set Vote guards', module: 'vote'},
|
|
116
119
|
{index:PermissionIndex.vote_option, name:'Option', description:'Set Vote options', module: 'vote'},
|
|
117
|
-
{index:PermissionIndex.
|
|
120
|
+
{index:PermissionIndex.vote_max_choice_count, name:'Choice count', description:'Set Vote max choice count', module: 'vote'},
|
|
118
121
|
{index:PermissionIndex.vote_open_voting, name:'Open voting', description:'Open voting', module: 'vote'},
|
|
119
122
|
{index:PermissionIndex.vote_lock_deadline, name:'Lock deadline', description:'Set Vote deadline immutable', module: 'vote'},
|
|
120
123
|
{index:PermissionIndex.vote_expand_deadline, name:'Expand deadline', description:'Expand Vote deadline', module: 'vote'},
|
|
121
124
|
{index:PermissionIndex.vote_lock_guard, name:'Lock Guard', description:'Set Vote guards immutable', module: 'vote'},
|
|
122
125
|
|
|
123
126
|
{index:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service'},
|
|
124
|
-
{index:PermissionIndex.
|
|
125
|
-
{index:PermissionIndex.
|
|
126
|
-
{index:PermissionIndex.
|
|
127
|
-
{index:PermissionIndex.
|
|
127
|
+
{index:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: 'service'},
|
|
128
|
+
{index:PermissionIndex.service_price, name:'Price', description:'Set Service item price', module: 'service'},
|
|
129
|
+
{index:PermissionIndex.service_stock, name:'Inventory', description:'Set Service item inventory', module: 'service'},
|
|
130
|
+
{index:PermissionIndex.service_payee, name:'Payee', description:'Set Service payee', module: 'service'},
|
|
128
131
|
{index:PermissionIndex.service_repository, name:'Repository', description:'Set Service repositories', module: 'service'},
|
|
129
132
|
{index:PermissionIndex.service_withdraw_guards, name:'Withdraw Guard', description:'Set Service withdraw guards', module: 'service'},
|
|
130
133
|
{index:PermissionIndex.service_refund_guards, name:'Refund Guard', description:'Set Service refund guards', module: 'service'},
|
|
@@ -132,9 +135,9 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
132
135
|
{index:PermissionIndex.service_remove_sales, name:'Remove sales', description:'Remove sale items for Service', module: 'service'},
|
|
133
136
|
{index:PermissionIndex.service_discount_transfer, name:'Discount', description:'Launch discounts for Service', module: 'service'},
|
|
134
137
|
{index:PermissionIndex.service_withdraw, name:'Withdraw', description:'Widthraw from Service orders', module: 'service'},
|
|
135
|
-
{index:PermissionIndex.
|
|
136
|
-
{index:PermissionIndex.
|
|
137
|
-
{index:PermissionIndex.
|
|
138
|
+
{index:PermissionIndex.service_buy_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service'},
|
|
139
|
+
{index:PermissionIndex.service_machine, name:'Machine', description:'Set Machine for Service', module: 'service'},
|
|
140
|
+
{index:PermissionIndex.service_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service'},
|
|
138
141
|
{index:PermissionIndex.service_publish, name:'Publish', description:'Publish Service', module: 'service'},
|
|
139
142
|
{index:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service'},
|
|
140
143
|
{index:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service'},
|
|
@@ -144,31 +147,34 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
144
147
|
{index:PermissionIndex.reward, name:'Reward', description:'Launch new Reward', module: 'reward'},
|
|
145
148
|
{index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from Reward', module: 'reward'},
|
|
146
149
|
{index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'Expand Reward deadline', module: 'reward'},
|
|
147
|
-
{index:PermissionIndex.reward_guard, name:'Guard', description:'
|
|
148
|
-
{index:PermissionIndex.
|
|
150
|
+
{index:PermissionIndex.reward_guard, name:'Guard', description:'Set Reward guard', module: 'reward'},
|
|
151
|
+
{index:PermissionIndex.reward_description, name:'Description', description:'Set Reward description', module: 'reward'},
|
|
149
152
|
{index:PermissionIndex.reward_lock_guards, name:'Lock Guard', description:'Set Reward guard immutable', module: 'reward'},
|
|
153
|
+
{index:PermissionIndex.reward_claim_repeatably, name:'Claim repeatably', description:'Allow claimming repeatably', module: 'reward'},
|
|
154
|
+
{index:PermissionIndex.reward_allow_claiming, name:'Allow claiming', description:'Allow claiming', module: 'reward'},
|
|
150
155
|
|
|
151
156
|
{index:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand'},
|
|
152
157
|
{index:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand'},
|
|
153
158
|
{index:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand'},
|
|
154
|
-
{index:PermissionIndex.
|
|
155
|
-
{index:PermissionIndex.
|
|
159
|
+
{index:PermissionIndex.demand_guard, name:'Guard', description:'Set Demand guard', module: 'demand'},
|
|
160
|
+
{index:PermissionIndex.demand_description, name:'Description', description:'Set Demand description', module: 'demand'},
|
|
156
161
|
{index:PermissionIndex.demand_yes, name:'Yes', description:'Pick the Deamand serice', module: 'demand'},
|
|
157
162
|
|
|
158
163
|
{index:PermissionIndex.machine, name: 'Machine', description:'Launch new Machine', module: 'machine'},
|
|
159
|
-
{index:PermissionIndex.
|
|
164
|
+
{index:PermissionIndex.machine_description, name: 'Description', description:'Set Machine description', module: 'machine'},
|
|
160
165
|
{index:PermissionIndex.machine_repository, name: 'Repository', description:'Set Machine repository', module: 'machine'},
|
|
161
166
|
{index:PermissionIndex.machine_clone, name: 'Clone', description:'Clone Machine', module: 'machine'},
|
|
162
167
|
{index:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine'},
|
|
163
|
-
{index:PermissionIndex.
|
|
168
|
+
{index:PermissionIndex.machine_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine'},
|
|
164
169
|
{index:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine'},
|
|
165
170
|
{index:PermissionIndex.machine_publish, name: 'Publish', description:'Publish Machine', module: 'machine'},
|
|
166
171
|
|
|
167
172
|
{index:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress'},
|
|
168
|
-
{index:PermissionIndex.
|
|
173
|
+
{index:PermissionIndex.progress_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress'},
|
|
169
174
|
{index:PermissionIndex.progress_bind_task, name: 'Bind', description:'Set Progress task', module: 'progress'},
|
|
170
|
-
{index:PermissionIndex.
|
|
175
|
+
{index:PermissionIndex.progress_context_repository, name: 'Repository', description:'Set Progress repository', module: 'progress'},
|
|
171
176
|
{index:PermissionIndex.progress_unhold, name: 'Unhold', description:'Release Progress holdings', module: 'progress'},
|
|
177
|
+
{index:PermissionIndex.progress_parent, name: 'Parent', description:'Set Progress parent', module: 'progress'},
|
|
172
178
|
]
|
|
173
179
|
|
|
174
180
|
export type PermissionIndexType = PermissionIndex | number;
|
|
@@ -328,7 +334,7 @@ export class Permission {
|
|
|
328
334
|
guards.forEach(({entity_address, index, guard}) => {
|
|
329
335
|
this.txb.moveCall({
|
|
330
336
|
target:Protocol.Instance().PermissionFn('guard_set') as FnCallType,
|
|
331
|
-
arguments:[ Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure(entity_address
|
|
337
|
+
arguments:[ Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(entity_address),
|
|
332
338
|
this.txb.pure.u64(index), Protocol.TXB_OBJECT(this.txb, guard)]
|
|
333
339
|
})
|
|
334
340
|
})
|
|
@@ -339,7 +345,7 @@ export class Permission {
|
|
|
339
345
|
if (!IsValidAddress(entity_address)) {
|
|
340
346
|
ERROR(Errors.IsValidAddress, 'entity_address')
|
|
341
347
|
}
|
|
342
|
-
if(!Permission.IsValidPermissionIndex(index)) {
|
|
348
|
+
if(!Permission.IsValidPermissionIndex(index) && !Permission.IsValidUserDefinedIndex(index)) {
|
|
343
349
|
ERROR(Errors.IsValidPermissionIndex, 'index')
|
|
344
350
|
}
|
|
345
351
|
|
|
@@ -396,7 +402,9 @@ export class Permission {
|
|
|
396
402
|
}
|
|
397
403
|
|
|
398
404
|
add_admin(admin:string[]) {
|
|
399
|
-
if (
|
|
405
|
+
if (admin.length === 0) return ;
|
|
406
|
+
|
|
407
|
+
if (!IsValidArray(admin, IsValidAddress)) {
|
|
400
408
|
ERROR(Errors.IsValidArray)
|
|
401
409
|
}
|
|
402
410
|
|
|
@@ -407,7 +415,7 @@ export class Permission {
|
|
|
407
415
|
}
|
|
408
416
|
|
|
409
417
|
remove_admin(admin:string[], removeall?:boolean) {
|
|
410
|
-
if (!removeall && admin.length === 0) return
|
|
418
|
+
if (!removeall && admin.length === 0) return;
|
|
411
419
|
if (!IsValidArray(admin, IsValidAddress)) {
|
|
412
420
|
ERROR(Errors.IsValidArray, 'admin')
|
|
413
421
|
}
|
|
@@ -447,27 +455,29 @@ export class Permission {
|
|
|
447
455
|
|
|
448
456
|
this.txb.moveCall({
|
|
449
457
|
target:Protocol.Instance().PermissionFn('query_permissions') as FnCallType,
|
|
450
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(address_queried),
|
|
458
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(address_queried),
|
|
459
|
+
this.txb.pure.vector('u64', permissions)]
|
|
451
460
|
})
|
|
452
461
|
}
|
|
453
462
|
|
|
454
|
-
QueryPermissions(
|
|
463
|
+
QueryPermissions(permission:string, address_queried:string, permissions:PermissionIndexType[], onPermissionAnswer:OnPermissionAnswer, sender?:string) {
|
|
464
|
+
//@ be the same txb
|
|
455
465
|
this.query_permissions(address_queried, permissions);
|
|
456
|
-
Protocol.Client().devInspectTransactionBlock({sender:sender ?? address_queried, transactionBlock:txb}).then((res) => {
|
|
466
|
+
Protocol.Client().devInspectTransactionBlock({sender:sender ?? address_queried, transactionBlock:this.txb}).then((res) => {
|
|
457
467
|
if (res.results && res.results[0].returnValues && res.results[0].returnValues.length !== 3 ) {
|
|
458
|
-
onPermissionAnswer({who:address_queried});
|
|
468
|
+
onPermissionAnswer({who:address_queried, object:permission});
|
|
459
469
|
return
|
|
460
470
|
}
|
|
461
471
|
|
|
462
472
|
const perm = Bcs.getInstance().de(BCS.U8, Uint8Array.from((res.results as any)[0].returnValues[0][0]));
|
|
463
473
|
|
|
464
474
|
if (perm === Permission.PERMISSION_ADMIN || perm === Permission.PERMISSION_OWNER_AND_ADMIN) {
|
|
465
|
-
onPermissionAnswer({who:address_queried, admin:true, owner:perm%2===1, items:[]})
|
|
475
|
+
onPermissionAnswer({who:address_queried, admin:true, owner:perm%2===1, items:[], object:permission})
|
|
466
476
|
} else {
|
|
467
477
|
const perms = Bcs.getInstance().de('vector<u8>', Uint8Array.from((res.results as any)[0].returnValues[1][0]));
|
|
468
478
|
const guards = Bcs.getInstance().de('vector<address>', Uint8Array.from((res.results as any)[0].returnValues[2][0]));
|
|
469
479
|
if (perms.length !== permissions.length) {
|
|
470
|
-
onPermissionAnswer({who:address_queried});
|
|
480
|
+
onPermissionAnswer({who:address_queried, object:permission});
|
|
471
481
|
return
|
|
472
482
|
}
|
|
473
483
|
|
|
@@ -479,22 +489,25 @@ export class Permission {
|
|
|
479
489
|
}
|
|
480
490
|
return {query:v, permission:p, guard:g}
|
|
481
491
|
})
|
|
482
|
-
onPermissionAnswer({who:address_queried, admin:false, owner:perm%2===1, items:items});
|
|
492
|
+
onPermissionAnswer({who:address_queried, admin:false, owner:perm%2===1, items:items, object:permission});
|
|
483
493
|
}
|
|
484
494
|
}).catch((e) => {
|
|
485
495
|
console.log(e);
|
|
486
|
-
onPermissionAnswer({who:address_queried});
|
|
496
|
+
onPermissionAnswer({who:address_queried, object:permission});
|
|
487
497
|
})
|
|
488
498
|
}
|
|
489
|
-
static HasPermission(answer:PermissionAnswer|undefined, index:PermissionIndexType) : {has:boolean, guard?:string, owner?:boolean} {
|
|
499
|
+
static HasPermission(answer:PermissionAnswer|undefined, index:PermissionIndexType, bStrict:boolean=false) : {has:boolean, guard?:string, owner?:boolean} | undefined {
|
|
490
500
|
if (answer) {
|
|
491
501
|
if (answer.admin) return {has:true, owner:answer.owner}; // admin
|
|
492
502
|
let i = answer.items?.find((v)=>v.query === index);
|
|
493
503
|
if (i) {
|
|
494
504
|
return {has:i.permission, guard:i.guard, owner:answer.owner};
|
|
495
|
-
}
|
|
505
|
+
}
|
|
496
506
|
}
|
|
497
|
-
|
|
507
|
+
if (bStrict) {
|
|
508
|
+
return {has:false, guard:undefined, owner:answer?.owner}
|
|
509
|
+
}
|
|
510
|
+
return undefined
|
|
498
511
|
}
|
|
499
512
|
|
|
500
513
|
static MAX_ADMIN_COUNT = 64;
|
package/src/progress.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { FnCallType, PermissionObject, RepositoryObject, PassportObject, MachineObject,
|
|
3
3
|
ProgressObject, ProgressAddress, Protocol, ValueType,
|
|
4
4
|
TxbObject} from './protocol';
|
|
@@ -158,7 +158,6 @@ export class Progress {
|
|
|
158
158
|
ERROR(Errors.IsValidObjects, 'repository')
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
|
|
162
161
|
if (passport) {
|
|
163
162
|
if (repository) {
|
|
164
163
|
this.txb.moveCall({
|
|
@@ -189,8 +188,9 @@ export class Progress {
|
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
190
|
unhold(next:ProgressNext, passport?:PassportObject) {
|
|
191
|
+
console.log(next)
|
|
192
192
|
if (!Progress.IsValidProgressNext(next)) {
|
|
193
|
-
ERROR(Errors.InvalidParam, '
|
|
193
|
+
ERROR(Errors.InvalidParam, 'unhold')
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
if (passport) {
|
|
@@ -210,7 +210,6 @@ export class Progress {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
parent_none(passport?:PassportObject) {
|
|
213
|
-
|
|
214
213
|
if (passport) {
|
|
215
214
|
this.txb.moveCall({
|
|
216
215
|
target:Protocol.Instance().ProgressFn('parent_none_with_passport') as FnCallType,
|
|
@@ -234,7 +233,6 @@ export class Progress {
|
|
|
234
233
|
ERROR(Errors.InvalidParam, 'parent')
|
|
235
234
|
}
|
|
236
235
|
|
|
237
|
-
|
|
238
236
|
if (passport) {
|
|
239
237
|
this.txb.moveCall({
|
|
240
238
|
target:Protocol.Instance().ProgressFn('parent_set_with_passport') as FnCallType,
|
|
@@ -259,6 +257,7 @@ export class Progress {
|
|
|
259
257
|
}
|
|
260
258
|
|
|
261
259
|
next(next:ProgressNext, deliverables_address?:string, sub_id?:string, passport?:PassportObject) {
|
|
260
|
+
console.log(next)
|
|
262
261
|
if (!Progress.IsValidProgressNext(next)) {
|
|
263
262
|
ERROR(Errors.InvalidParam, 'next')
|
|
264
263
|
}
|
|
@@ -268,12 +267,12 @@ export class Progress {
|
|
|
268
267
|
if (sub_id && !IsValidAddress(sub_id)) {
|
|
269
268
|
ERROR(Errors.IsValidAddress, 'sub_id');
|
|
270
269
|
}
|
|
271
|
-
|
|
272
270
|
|
|
273
271
|
let diliverable = this.txb.pure.option('address', deliverables_address ? deliverables_address : undefined);
|
|
274
272
|
let sub = this.txb.pure.option('address', sub_id ? sub_id : undefined);
|
|
275
273
|
|
|
276
274
|
if (passport) {
|
|
275
|
+
console.log(11111)
|
|
277
276
|
this.txb.moveCall({
|
|
278
277
|
target:Protocol.Instance().ProgressFn('next_with_passport') as FnCallType,
|
|
279
278
|
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.machine),
|
|
@@ -292,9 +291,8 @@ export class Progress {
|
|
|
292
291
|
|
|
293
292
|
hold(next:ProgressNext, hold:boolean) {
|
|
294
293
|
if (!Progress.IsValidProgressNext(next)) {
|
|
295
|
-
ERROR(Errors.InvalidParam, '
|
|
294
|
+
ERROR(Errors.InvalidParam, 'hold')
|
|
296
295
|
}
|
|
297
|
-
|
|
298
296
|
|
|
299
297
|
this.txb.moveCall({
|
|
300
298
|
target:Protocol.Instance().ProgressFn('hold') as FnCallType,
|
|
@@ -302,6 +300,7 @@ export class Progress {
|
|
|
302
300
|
this.txb.pure.string(next.forward), this.txb.pure.bool(hold), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
303
301
|
})
|
|
304
302
|
}
|
|
303
|
+
|
|
305
304
|
static rpc_de_sessions = (session: any) : Session[] => {
|
|
306
305
|
let sessions : Session[] = [];
|
|
307
306
|
session?.fields?.contents?.forEach((v:any) => {
|
package/src/protocol.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiClient, SuiObjectResponse, SuiObjectDataOptions, SuiTransactionBlockResponseOptions,
|
|
2
2
|
SuiTransactionBlockResponse, SuiObjectChange } from '@mysten/sui/client';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import {
|
|
4
|
+
import { toHEX, fromHEX, BcsReader } from '@mysten/bcs';
|
|
5
5
|
import { Transaction as TransactionBlock, Inputs, TransactionResult, TransactionArgument } from '@mysten/sui/transactions';
|
|
6
6
|
import { capitalize, IsValidAddress, IsValidArray, IsValidU128, IsValidU64, IsValidU8, IsValidUintLarge } from './utils'
|
|
7
7
|
import { GuardConstant } from './guard';
|
|
@@ -191,9 +191,9 @@ export enum ENTRYPOINT {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const TESTNET = {
|
|
194
|
-
package: "
|
|
195
|
-
wowok_object: '
|
|
196
|
-
entity_object: '
|
|
194
|
+
package: "0x8f547c4bd00eedc72307d67c8c1c7b22da88c29ac530cce57bbfe7b6add45a91",
|
|
195
|
+
wowok_object: '0x1ccee2dbac69f76db35d92869cc4840fb537020a927dd035cdac811803d9d191',
|
|
196
|
+
entity_object: '0xb75b6953254cf9a426fb06b1ceb711784031cf7817b66630ba00daf5660ab04e',
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
const MAINNET = {
|
|
@@ -320,7 +320,6 @@ export class Protocol {
|
|
|
320
320
|
transaction: this.CurrentSession(),
|
|
321
321
|
signer: keypair,
|
|
322
322
|
options,
|
|
323
|
-
|
|
324
323
|
});
|
|
325
324
|
this.txb = undefined; // reset the txb to undefine
|
|
326
325
|
return response;
|
package/src/repository.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BCS } from '@mysten/bcs';
|
|
2
1
|
import { Protocol, FnCallType, ValueType, RepositoryValueType, RepositoryAddress, PermissionObject, PassportObject, TxbObject} from './protocol';
|
|
3
2
|
import { PermissionIndexType, Permission } from './permission'
|
|
4
3
|
import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, IsValidName, ValueTypeConvert} from './utils';
|
|
@@ -222,7 +221,7 @@ export class Repository {
|
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
policies.forEach((policy) => {
|
|
225
|
-
let permission_index = this.txb.pure.option('u64', policy?.permission);
|
|
224
|
+
let permission_index = this.txb.pure.option('u64', policy?.permission ? policy?.permission : undefined);
|
|
226
225
|
if (passport) {
|
|
227
226
|
this.txb.moveCall({
|
|
228
227
|
target:Protocol.Instance().RepositoryFn('policy_add_with_passport') as FnCallType,
|
package/src/resource.ts
CHANGED
package/src/reward.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { TransactionArgument, Transaction as TransactionBlock, type TransactionResult, } from '@mysten/sui/transactions';
|
|
2
|
-
import { BCS} from '@mysten/bcs';
|
|
3
2
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, RewardAddress, Protocol, TxbObject, } from './protocol';
|
|
4
3
|
import { array_unique, IsValidAddress, IsValidArgType, IsValidArray, IsValidDesription, IsValidUintLarge, } from './utils';
|
|
5
4
|
import { ERROR, Errors } from './exception';
|
|
6
|
-
import { Resource } from './resource';
|
|
7
5
|
|
|
8
6
|
export type CoinReward = TransactionResult;
|
|
9
7
|
export type RewardGuardPortions = {
|
package/src/service.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { bcs, BCS, toHEX, fromHEX, getSuiMoveConfig } from '@mysten/bcs';
|
|
2
1
|
import { IsValidArray, IsValidPercent, IsValidName_AllowEmpty, Bcs, array_unique, IsValidTokenType, IsValidDesription,
|
|
3
2
|
IsValidAddress, IsValidEndpoint, IsValidUintLarge, IsValidInt, IsValidName, } from './utils'
|
|
4
3
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryObject, MachineObject, ServiceAddress,
|
|
@@ -594,8 +593,8 @@ export class Service {
|
|
|
594
593
|
}
|
|
595
594
|
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
596
595
|
discount_dispatch.forEach((discount) => {
|
|
597
|
-
let price_greater = this.txb.pure.option('u64', discount.discount?.price_greater);
|
|
598
|
-
let time_start = this.txb.pure.option('u64', discount.discount?.time_start);
|
|
596
|
+
let price_greater = this.txb.pure.option('u64', discount.discount?.price_greater ? discount.discount?.price_greater : undefined);
|
|
597
|
+
let time_start = this.txb.pure.option('u64', discount.discount?.time_start ? discount.discount?.time_start : undefined);
|
|
599
598
|
|
|
600
599
|
if (passport) {
|
|
601
600
|
this.txb.moveCall({
|
package/src/utils.ts
CHANGED
|
@@ -314,7 +314,8 @@ export class Bcs {
|
|
|
314
314
|
const dislike = reader.read32();
|
|
315
315
|
return {avatar:avatar, resource:resource, like:like, dislike:dislike}*/
|
|
316
316
|
}
|
|
317
|
-
de_entInfo(data:Uint8Array) : any {
|
|
317
|
+
de_entInfo(data:Uint8Array | undefined) : any {
|
|
318
|
+
if (!data || data.length === 0) return ''
|
|
318
319
|
let r = this.bcs.de('PersonalInfo', data);
|
|
319
320
|
r.name = new TextDecoder().decode(Uint8Array.from(r.name));
|
|
320
321
|
r.description = new TextDecoder().decode(Uint8Array.from(r.description));
|
|
@@ -473,8 +474,6 @@ export const ResolveBalance = (balance:string, decimals:number) : string => {
|
|
|
473
474
|
}
|
|
474
475
|
}
|
|
475
476
|
|
|
476
|
-
//export const OptionNone = (txb:TransactionBlock) : TransactionArgument => { return txb.pure.option([], BCS.U8) };
|
|
477
|
-
|
|
478
477
|
export type ArgType = {
|
|
479
478
|
isCoin: boolean;
|
|
480
479
|
coin: string;
|
package/src/wowok.ts
CHANGED