wowok 1.2.7 → 1.2.9
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 +5 -5
- package/src/entity.ts +8 -0
- package/src/guard.ts +217 -144
- package/src/machine.ts +205 -53
- package/src/passport.ts +8 -8
- package/src/permission.ts +91 -119
- package/src/progress.ts +101 -43
- package/src/protocol.ts +46 -55
- package/src/repository.ts +107 -20
- package/src/resource.ts +19 -9
- package/src/reward.ts +9 -11
- package/src/service.ts +35 -33
- package/src/utils.ts +88 -43
- package/src/vote.ts +18 -21
- package/src/wowok.ts +2 -2
package/src/permission.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BCS } from '@mysten/bcs';
|
|
2
2
|
import { FnCallType, TxbObject, PermissionObject, PermissionAddress, GuardObject, Protocol} from './protocol';
|
|
3
|
-
import { array_unique, IsValidAddress, IsValidArray, IsValidDesription,
|
|
3
|
+
import { array_unique, IsValidAddress, IsValidArray, IsValidDesription, IsValidUintLarge, Bcs, IsValidName} from './utils';
|
|
4
4
|
import { ERROR, Errors } from './exception';
|
|
5
5
|
import { ValueType } from './protocol';
|
|
6
6
|
|
|
@@ -8,21 +8,16 @@ export enum PermissionIndex {
|
|
|
8
8
|
repository = 100,
|
|
9
9
|
repository_set_description_set = 101,
|
|
10
10
|
repository_set_policy_mode = 102,
|
|
11
|
-
|
|
12
|
-
repository_remove_policies = 103,
|
|
11
|
+
repository_add_remove_policies = 103,
|
|
13
12
|
repository_set_policy_description = 105,
|
|
14
13
|
repository_set_policy_permission = 106,
|
|
15
|
-
|
|
16
|
-
repository_reference_remove = 107,
|
|
17
|
-
repository_reference_removeall = 107,
|
|
14
|
+
repository_reference = 107,
|
|
18
15
|
|
|
19
16
|
vote = 150,
|
|
20
17
|
vote_set_description = 151,
|
|
21
18
|
vote_set_reference = 152,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
vote_add_option = 155,
|
|
25
|
-
vote_remove_option = 156,
|
|
19
|
+
vote_guard = 153,
|
|
20
|
+
vote_option = 155,
|
|
26
21
|
vote_set_max_choice_count = 157,
|
|
27
22
|
vote_open_voting = 158,
|
|
28
23
|
vote_lock_deadline = 159,
|
|
@@ -32,19 +27,12 @@ export enum PermissionIndex {
|
|
|
32
27
|
service = 200,
|
|
33
28
|
service_set_description = 201,
|
|
34
29
|
service_set_price = 202,
|
|
35
|
-
|
|
36
|
-
service_add_stock = 203,
|
|
37
|
-
service_reduce_stock = 203,
|
|
30
|
+
service_set_add_reduce_stock = 203,
|
|
38
31
|
service_set_sale_endpoint = 204,
|
|
39
32
|
service_set_payee = 205,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
service_remove_withdraw_guards = 208,
|
|
44
|
-
service_removeall_withdraw_guards = 208,
|
|
45
|
-
service_add_refund_guards = 210,
|
|
46
|
-
service_remove_refund_guards = 210,
|
|
47
|
-
service_removeall_refund_guards = 210,
|
|
33
|
+
service_repository = 206,
|
|
34
|
+
service_withdraw_guards = 208,
|
|
35
|
+
service_refund_guards = 210,
|
|
48
36
|
service_add_sales = 212,
|
|
49
37
|
service_remove_sales = 213,
|
|
50
38
|
service_discount_transfer = 214,
|
|
@@ -54,36 +42,33 @@ export enum PermissionIndex {
|
|
|
54
42
|
service_set_endpoint = 219,
|
|
55
43
|
service_publish = 220,
|
|
56
44
|
service_clone = 221,
|
|
57
|
-
|
|
58
|
-
service_remove_customer_required = 222,
|
|
59
|
-
service_change_required_pubkey = 222,
|
|
45
|
+
service_customer_required = 222,
|
|
60
46
|
service_change_order_required_pubkey = 224,
|
|
61
47
|
service_pause = 225,
|
|
62
48
|
|
|
63
49
|
reward = 240,
|
|
64
50
|
reward_refund = 241,
|
|
65
51
|
reward_expand_time = 242,
|
|
66
|
-
|
|
67
|
-
reward_remove_guard = 243,
|
|
52
|
+
reward_guard = 243,
|
|
68
53
|
reward_set_description = 245,
|
|
69
54
|
reward_lock_guards = 246,
|
|
55
|
+
|
|
70
56
|
demand = 260,
|
|
71
57
|
demand_refund = 261,
|
|
72
58
|
demand_expand_time = 262,
|
|
73
59
|
demand_set_guard = 263,
|
|
74
60
|
demand_set_description = 264,
|
|
75
61
|
demand_yes = 265,
|
|
62
|
+
|
|
76
63
|
machine = 600,
|
|
77
64
|
machine_set_description = 601,
|
|
78
|
-
|
|
79
|
-
machine_remove_repository = 603,
|
|
65
|
+
machine_repository = 602,
|
|
80
66
|
machine_clone = 604,
|
|
81
|
-
|
|
82
|
-
machine_add_node2 = 606,
|
|
83
|
-
machine_remove_node = 607,
|
|
67
|
+
machine_node = 606,
|
|
84
68
|
machine_set_endpoint = 608,
|
|
85
69
|
machine_pause = 609,
|
|
86
70
|
machine_publish = 610,
|
|
71
|
+
|
|
87
72
|
progress = 650,
|
|
88
73
|
progress_set_namedOperator = 651,
|
|
89
74
|
progress_bind_task = 652,
|
|
@@ -101,83 +86,74 @@ export interface PermissionInfoType {
|
|
|
101
86
|
}
|
|
102
87
|
|
|
103
88
|
export const PermissionInfo : PermissionInfoType[] = [
|
|
104
|
-
{index:PermissionIndex.repository, name:'Repository', description:'
|
|
105
|
-
{index:PermissionIndex.repository_set_description_set, name:'Description', description:'
|
|
106
|
-
{index:PermissionIndex.repository_set_policy_mode, name:'Policy mode', description:'
|
|
107
|
-
{index:PermissionIndex.
|
|
108
|
-
{index:PermissionIndex.
|
|
109
|
-
{index:PermissionIndex.
|
|
110
|
-
{index:PermissionIndex.
|
|
111
|
-
|
|
112
|
-
{index:PermissionIndex.
|
|
113
|
-
|
|
114
|
-
{index:PermissionIndex.
|
|
115
|
-
{index:PermissionIndex.
|
|
116
|
-
{index:PermissionIndex.
|
|
117
|
-
{index:PermissionIndex.
|
|
118
|
-
{index:PermissionIndex.
|
|
119
|
-
{index:PermissionIndex.
|
|
120
|
-
{index:PermissionIndex.
|
|
121
|
-
{index:PermissionIndex.
|
|
122
|
-
|
|
123
|
-
{index:PermissionIndex.
|
|
124
|
-
{index:PermissionIndex.
|
|
125
|
-
{index:PermissionIndex.
|
|
126
|
-
|
|
127
|
-
{index:PermissionIndex.
|
|
128
|
-
{index:PermissionIndex.
|
|
129
|
-
{index:PermissionIndex.
|
|
130
|
-
{index:PermissionIndex.
|
|
131
|
-
{index:PermissionIndex.
|
|
132
|
-
{index:PermissionIndex.
|
|
133
|
-
{index:PermissionIndex.
|
|
134
|
-
{index:PermissionIndex.
|
|
135
|
-
{index:PermissionIndex.
|
|
136
|
-
{index:PermissionIndex.
|
|
137
|
-
{index:PermissionIndex.
|
|
138
|
-
{index:PermissionIndex.
|
|
139
|
-
{index:PermissionIndex.
|
|
140
|
-
{index:PermissionIndex.
|
|
141
|
-
{index:PermissionIndex.
|
|
142
|
-
{index:PermissionIndex.
|
|
143
|
-
|
|
144
|
-
{index:PermissionIndex.
|
|
145
|
-
{index:PermissionIndex.
|
|
146
|
-
{index:PermissionIndex.
|
|
147
|
-
{index:PermissionIndex.
|
|
148
|
-
{index:PermissionIndex.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
{index:PermissionIndex.
|
|
152
|
-
{index:PermissionIndex.
|
|
153
|
-
{index:PermissionIndex.
|
|
154
|
-
{index:PermissionIndex.
|
|
155
|
-
{index:PermissionIndex.
|
|
156
|
-
{index:PermissionIndex.
|
|
157
|
-
|
|
158
|
-
{index:PermissionIndex.
|
|
159
|
-
{index:PermissionIndex.
|
|
160
|
-
{index:PermissionIndex.
|
|
161
|
-
{index:PermissionIndex.
|
|
162
|
-
{index:PermissionIndex.
|
|
163
|
-
{index:PermissionIndex.
|
|
164
|
-
|
|
165
|
-
{index:PermissionIndex.
|
|
166
|
-
|
|
167
|
-
{index:PermissionIndex.
|
|
168
|
-
{index:PermissionIndex.
|
|
169
|
-
{index:PermissionIndex.
|
|
170
|
-
{index:PermissionIndex.
|
|
171
|
-
{index:PermissionIndex.
|
|
172
|
-
{index:PermissionIndex.machine_set_endpoint, name: 'Endpoint', description:'machine_set_endpoint', module: 'machine'},
|
|
173
|
-
{index:PermissionIndex.machine_pause, name: 'Pause', description:'machine_pause', module: 'machine'},
|
|
174
|
-
{index:PermissionIndex.machine_publish, name: 'Publish', description:'machine_publish', module: 'machine'},
|
|
175
|
-
|
|
176
|
-
{index:PermissionIndex.progress, name: 'Progress', description:'build progress', module: 'progress'},
|
|
177
|
-
{index:PermissionIndex.progress_set_namedOperator, name: 'Operator', description:'progress_set_namedOperator', module: 'progress'},
|
|
178
|
-
{index:PermissionIndex.progress_bind_task, name: 'Bind', description:'progress_bind_task', module: 'progress'},
|
|
179
|
-
{index:PermissionIndex.progress_set_context_repository, name: 'Repository', description:'progress_set_context_repository', module: 'progress'},
|
|
180
|
-
{index:PermissionIndex.progress_unhold, name: 'Unhold', description:'progress_unhold', module: 'progress'},
|
|
89
|
+
{index:PermissionIndex.repository, name:'Repository', description:'Launch new Repository', module: 'repository'},
|
|
90
|
+
{index:PermissionIndex.repository_set_description_set, name:'Description', description:'Set Repository description', module: 'repository'},
|
|
91
|
+
{index:PermissionIndex.repository_set_policy_mode, name:'Policy mode', description:'Set Repository policy mode', module: 'repository'},
|
|
92
|
+
{index:PermissionIndex.repository_add_remove_policies, name:'Policy', description:'Add/Remove Repository policy', module: 'repository'},
|
|
93
|
+
{index:PermissionIndex.repository_set_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository'},
|
|
94
|
+
{index:PermissionIndex.repository_set_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository'},
|
|
95
|
+
{index:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository'},
|
|
96
|
+
|
|
97
|
+
{index:PermissionIndex.vote, name:'Vote', description:'Launch new Vote', module: 'vote'},
|
|
98
|
+
{index:PermissionIndex.vote_set_description, name:'Description', description:'Set Vote description', module: 'vote'},
|
|
99
|
+
{index:PermissionIndex.vote_set_reference, name:'Reference', description:'Set Vote reference', module: 'vote'},
|
|
100
|
+
{index:PermissionIndex.vote_guard, name:'Guard', description:'Set Vote guards', module: 'vote'},
|
|
101
|
+
{index:PermissionIndex.vote_option, name:'Option', description:'Set Vote options', module: 'vote'},
|
|
102
|
+
{index:PermissionIndex.vote_set_max_choice_count, name:'Choice count', description:'Set Vote max choice count', module: 'vote'},
|
|
103
|
+
{index:PermissionIndex.vote_open_voting, name:'Open voting', description:'Open voting', module: 'vote'},
|
|
104
|
+
{index:PermissionIndex.vote_lock_deadline, name:'Lock deadline', description:'Set Vote deadline immutable', module: 'vote'},
|
|
105
|
+
{index:PermissionIndex.vote_expand_deadline, name:'Expand deadline', description:'Expand Vote deadline', module: 'vote'},
|
|
106
|
+
{index:PermissionIndex.vote_lock_guard, name:'Lock Guard', description:'Set Vote guards immutable', module: 'vote'},
|
|
107
|
+
|
|
108
|
+
{index:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service'},
|
|
109
|
+
{index:PermissionIndex.service_set_description, name:'Description', description:'Set Service description', module: 'service'},
|
|
110
|
+
{index:PermissionIndex.service_set_price, name:'Price', description:'Set Service item price', module: 'service'},
|
|
111
|
+
{index:PermissionIndex.service_set_add_reduce_stock, name:'Inventory', description:'Set Service item inventory', module: 'service'},
|
|
112
|
+
{index:PermissionIndex.service_set_payee, name:'Payee', description:'Set Service payee', module: 'service'},
|
|
113
|
+
{index:PermissionIndex.service_repository, name:'Repository', description:'Set Service repositories', module: 'service'},
|
|
114
|
+
{index:PermissionIndex.service_withdraw_guards, name:'Withdraw Guard', description:'Set Service withdraw guards', module: 'service'},
|
|
115
|
+
{index:PermissionIndex.service_refund_guards, name:'Refund Guard', description:'Set Service refund guards', module: 'service'},
|
|
116
|
+
{index:PermissionIndex.service_add_sales, name:'Add sales', description:'Add sale items for Service', module: 'service'},
|
|
117
|
+
{index:PermissionIndex.service_remove_sales, name:'Remove sales', description:'Remove sale items for Service', module: 'service'},
|
|
118
|
+
{index:PermissionIndex.service_discount_transfer, name:'Discount', description:'Launch discounts for Service', module: 'service'},
|
|
119
|
+
{index:PermissionIndex.service_withdraw, name:'Withdraw', description:'Widthraw from Service orders', module: 'service'},
|
|
120
|
+
{index:PermissionIndex.service_set_buy_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service'},
|
|
121
|
+
{index:PermissionIndex.service_set_machine, name:'Machine', description:'Set Machine for Service', module: 'service'},
|
|
122
|
+
{index:PermissionIndex.service_set_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service'},
|
|
123
|
+
{index:PermissionIndex.service_publish, name:'Publish', description:'Publish Service', module: 'service'},
|
|
124
|
+
{index:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service'},
|
|
125
|
+
{index:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service'},
|
|
126
|
+
{index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'Update Serivce order pubkey', module: 'service'},
|
|
127
|
+
{index:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service'},
|
|
128
|
+
|
|
129
|
+
{index:PermissionIndex.reward, name:'Reward', description:'Launch new Reward', module: 'reward'},
|
|
130
|
+
{index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from Reward', module: 'reward'},
|
|
131
|
+
{index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'Expand Reward deadline', module: 'reward'},
|
|
132
|
+
{index:PermissionIndex.reward_guard, name:'Guard', description:'build machine', module: 'Set Reward guard'},
|
|
133
|
+
{index:PermissionIndex.reward_set_description, name:'Description', description:'Set Reward description', module: 'reward'},
|
|
134
|
+
{index:PermissionIndex.reward_lock_guards, name:'Lock Guard', description:'Set Reward guard immutable', module: 'reward'},
|
|
135
|
+
|
|
136
|
+
{index:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand'},
|
|
137
|
+
{index:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand'},
|
|
138
|
+
{index:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand'},
|
|
139
|
+
{index:PermissionIndex.demand_set_guard, name:'Guard', description:'Set Demand guard', module: 'demand'},
|
|
140
|
+
{index:PermissionIndex.demand_set_description, name:'Description', description:'Set Demand description', module: 'demand'},
|
|
141
|
+
{index:PermissionIndex.demand_yes, name:'Yes', description:'Pick the Deamand serice', module: 'demand'},
|
|
142
|
+
|
|
143
|
+
{index:PermissionIndex.machine, name: 'Machine', description:'Launch new Machine', module: 'machine'},
|
|
144
|
+
{index:PermissionIndex.machine_set_description, name: 'Description', description:'Set Machine description', module: 'machine'},
|
|
145
|
+
{index:PermissionIndex.machine_repository, name: 'Repository', description:'Set Machine repository', module: 'machine'},
|
|
146
|
+
{index:PermissionIndex.machine_clone, name: 'Clone', description:'Clone Machine', module: 'machine'},
|
|
147
|
+
{index:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine'},
|
|
148
|
+
{index:PermissionIndex.machine_set_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine'},
|
|
149
|
+
{index:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine'},
|
|
150
|
+
{index:PermissionIndex.machine_publish, name: 'Publish', description:'Publish Machine', module: 'machine'},
|
|
151
|
+
|
|
152
|
+
{index:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress'},
|
|
153
|
+
{index:PermissionIndex.progress_set_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress'},
|
|
154
|
+
{index:PermissionIndex.progress_bind_task, name: 'Bind', description:'Set Progress task', module: 'progress'},
|
|
155
|
+
{index:PermissionIndex.progress_set_context_repository, name: 'Repository', description:'Set Progress repository', module: 'progress'},
|
|
156
|
+
{index:PermissionIndex.progress_unhold, name: 'Unhold', description:'Release Progress holdings', module: 'progress'},
|
|
181
157
|
]
|
|
182
158
|
|
|
183
159
|
export type PermissionIndexType = PermissionIndex | number;
|
|
@@ -246,7 +222,7 @@ export class Permission {
|
|
|
246
222
|
let txb = this.protocol.CurrentSession();
|
|
247
223
|
txb.moveCall({
|
|
248
224
|
target:this.protocol.PermissionFn('user_define_add') as FnCallType,
|
|
249
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64), txb.pure(name
|
|
225
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64), txb.pure(name)]
|
|
250
226
|
})
|
|
251
227
|
}
|
|
252
228
|
|
|
@@ -275,9 +251,8 @@ export class Permission {
|
|
|
275
251
|
}
|
|
276
252
|
|
|
277
253
|
add_entity2(entities: string[], index?:PermissionIndexType) {
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
}
|
|
254
|
+
if (entities.length === 0) return;
|
|
255
|
+
|
|
281
256
|
if (!IsValidArray(entities, IsValidAddress)) {
|
|
282
257
|
ERROR(Errors.IsValidArray, 'add_entity2');
|
|
283
258
|
}
|
|
@@ -429,12 +404,9 @@ export class Permission {
|
|
|
429
404
|
;
|
|
430
405
|
}
|
|
431
406
|
|
|
432
|
-
remove_admin(admin
|
|
433
|
-
if (!removeall &&
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (admin && !IsValidArray(admin, IsValidAddress)) {
|
|
407
|
+
remove_admin(admin:string[], removeall?:boolean) {
|
|
408
|
+
if (!removeall && admin.length === 0) return
|
|
409
|
+
if (!IsValidArray(admin, IsValidAddress)) {
|
|
438
410
|
ERROR(Errors.IsValidArray, 'admin')
|
|
439
411
|
}
|
|
440
412
|
|
|
@@ -470,7 +442,7 @@ export class Permission {
|
|
|
470
442
|
static MAX_PERMISSION_INDEX_COUNT = 200;
|
|
471
443
|
static MAX_PERSONAL_PERMISSION_COUNT = 200;
|
|
472
444
|
static IsValidUserDefinedIndex = (index:number) => {
|
|
473
|
-
return index >= PermissionIndex.user_defined_start &&
|
|
445
|
+
return index >= PermissionIndex.user_defined_start && IsValidUintLarge(index)
|
|
474
446
|
}
|
|
475
447
|
|
|
476
448
|
static IsValidPermissionIndex = (index:PermissionIndexType) : boolean => {
|
package/src/progress.ts
CHANGED
|
@@ -14,6 +14,25 @@ export type ProgressNext = {
|
|
|
14
14
|
export type ParentProgress = {
|
|
15
15
|
parent_id: string;
|
|
16
16
|
parent_session_id: number;
|
|
17
|
+
next_node: string;
|
|
18
|
+
forward: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Holder {
|
|
22
|
+
forward: string;
|
|
23
|
+
who?:string;
|
|
24
|
+
sub_progress?:string;
|
|
25
|
+
deliverables?:string;
|
|
26
|
+
accomplished:boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface Session {
|
|
29
|
+
id?:number; // for parent progress's history
|
|
30
|
+
next_node: string;
|
|
31
|
+
holders: Holder[];
|
|
32
|
+
weights: number;
|
|
33
|
+
threshold: number;
|
|
34
|
+
node?:string;
|
|
35
|
+
bComplete?: boolean;
|
|
17
36
|
}
|
|
18
37
|
|
|
19
38
|
export class Progress {
|
|
@@ -34,23 +53,24 @@ export class Progress {
|
|
|
34
53
|
p.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
|
|
35
54
|
return p
|
|
36
55
|
}
|
|
37
|
-
static New(protocol:Protocol, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : Progress {
|
|
56
|
+
static New(protocol:Protocol, machine:MachineObject, permission:PermissionObject, task?:string, passport?:PassportObject) : Progress {
|
|
38
57
|
if (!Protocol.IsValidObjects([machine, permission])) {
|
|
39
58
|
ERROR(Errors.IsValidObjects, 'machine & permission')
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
let p = new Progress(protocol, machine, permission);
|
|
43
62
|
let txb = protocol.CurrentSession();
|
|
63
|
+
let t = task? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_ADDRESS, task)) : OptionNone(txb);
|
|
44
64
|
|
|
45
65
|
if (passport) {
|
|
46
66
|
p.object = txb.moveCall({
|
|
47
67
|
target:protocol.ProgressFn('new_with_passport') as FnCallType,
|
|
48
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, machine), Protocol.TXB_OBJECT(txb, permission)],
|
|
68
|
+
arguments: [passport, t, Protocol.TXB_OBJECT(txb, machine), Protocol.TXB_OBJECT(txb, permission)],
|
|
49
69
|
})
|
|
50
70
|
} else {
|
|
51
71
|
p.object = txb.moveCall({
|
|
52
72
|
target:protocol.ProgressFn('new') as FnCallType,
|
|
53
|
-
arguments: [Protocol.TXB_OBJECT(txb, machine), Protocol.TXB_OBJECT(txb, permission)],
|
|
73
|
+
arguments: [t, Protocol.TXB_OBJECT(txb, machine), Protocol.TXB_OBJECT(txb, permission)],
|
|
54
74
|
})
|
|
55
75
|
}
|
|
56
76
|
return p
|
|
@@ -91,7 +111,7 @@ export class Progress {
|
|
|
91
111
|
if (!IsValidName(name)) {
|
|
92
112
|
ERROR(Errors.IsValidName, 'name')
|
|
93
113
|
}
|
|
94
|
-
if (
|
|
114
|
+
if (addresses.length > Progress.MAX_NAMED_OPERATOR_COUNT || !IsValidArray(addresses, IsValidAddress)) {
|
|
95
115
|
ERROR(Errors.InvalidParam, 'addresses')
|
|
96
116
|
}
|
|
97
117
|
|
|
@@ -99,14 +119,14 @@ export class Progress {
|
|
|
99
119
|
if (passport) {
|
|
100
120
|
txb.moveCall({
|
|
101
121
|
target:this.protocol.ProgressFn('namedOperator_set_with_passport') as FnCallType,
|
|
102
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(name
|
|
122
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(name),
|
|
103
123
|
txb.pure(array_unique(addresses), 'vector<address>'),
|
|
104
124
|
Protocol.TXB_OBJECT(txb, this.machine), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
105
125
|
})
|
|
106
126
|
} else {
|
|
107
127
|
txb.moveCall({
|
|
108
128
|
target:this.protocol.ProgressFn('namedOperator_set') as FnCallType,
|
|
109
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(name
|
|
129
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(name),
|
|
110
130
|
txb.pure(array_unique(addresses), 'vector<address>'),
|
|
111
131
|
Protocol.TXB_OBJECT(txb, this.machine), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
112
132
|
})
|
|
@@ -132,7 +152,6 @@ export class Progress {
|
|
|
132
152
|
Protocol.TXB_OBJECT(txb, this.machine), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
133
153
|
})
|
|
134
154
|
}
|
|
135
|
-
|
|
136
155
|
}
|
|
137
156
|
set_context_repository(repository?:RepositoryObject, passport?:PassportObject) {
|
|
138
157
|
if (repository && !Protocol.IsValidObjects([repository])) {
|
|
@@ -190,45 +209,52 @@ export class Progress {
|
|
|
190
209
|
})
|
|
191
210
|
}
|
|
192
211
|
}
|
|
212
|
+
parent_none(passport?:PassportObject) {
|
|
213
|
+
let txb = this.protocol.CurrentSession();
|
|
214
|
+
if (passport) {
|
|
215
|
+
txb.moveCall({
|
|
216
|
+
target:this.protocol.ProgressFn('parent_none_with_passport') as FnCallType,
|
|
217
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
218
|
+
Protocol.TXB_OBJECT(txb, this.machine), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
219
|
+
})
|
|
220
|
+
} else {
|
|
221
|
+
txb.moveCall({
|
|
222
|
+
target:this.protocol.ProgressFn('parent_none') as FnCallType,
|
|
223
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
|
|
224
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
}
|
|
193
228
|
|
|
194
229
|
parent(parent:ParentProgress, passport?:PassportObject) {
|
|
195
230
|
if (!IsValidAddress(parent.parent_id) || !IsValidInt(parent.parent_session_id)) {
|
|
196
231
|
ERROR(Errors.InvalidParam, 'parent')
|
|
197
232
|
}
|
|
233
|
+
if (!parent.next_node || !parent.forward) {
|
|
234
|
+
ERROR(Errors.InvalidParam, 'parent')
|
|
235
|
+
}
|
|
198
236
|
|
|
199
237
|
let txb = this.protocol.CurrentSession();
|
|
200
238
|
if (passport) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
txb.moveCall({
|
|
211
|
-
target:this.protocol.ProgressFn('parent_none_with_passport') as FnCallType,
|
|
212
|
-
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
213
|
-
Protocol.TXB_OBJECT(txb, this.machine), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
214
|
-
})
|
|
215
|
-
}
|
|
239
|
+
txb.moveCall({
|
|
240
|
+
target:this.protocol.ProgressFn('parent_set_with_passport') as FnCallType,
|
|
241
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
|
|
242
|
+
txb.pure(parent.parent_id, BCS.ADDRESS),
|
|
243
|
+
txb.pure(parent.parent_session_id, BCS.U64),
|
|
244
|
+
txb.pure(parent.next_node),
|
|
245
|
+
txb.pure(parent.forward),
|
|
246
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
247
|
+
})
|
|
216
248
|
} else {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
txb.moveCall({
|
|
227
|
-
target:this.protocol.ProgressFn('parent_none') as FnCallType,
|
|
228
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
|
|
229
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
230
|
-
})
|
|
231
|
-
}
|
|
249
|
+
txb.moveCall({
|
|
250
|
+
target:this.protocol.ProgressFn('parent_set') as FnCallType,
|
|
251
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
|
|
252
|
+
txb.pure(parent.parent_id, BCS.ADDRESS),
|
|
253
|
+
txb.pure(parent.parent_session_id, BCS.U64),
|
|
254
|
+
txb.pure(parent.next_node),
|
|
255
|
+
txb.pure(parent.forward),
|
|
256
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
257
|
+
})
|
|
232
258
|
}
|
|
233
259
|
}
|
|
234
260
|
|
|
@@ -251,15 +277,15 @@ export class Progress {
|
|
|
251
277
|
txb.moveCall({
|
|
252
278
|
target:this.protocol.ProgressFn('next_with_passport') as FnCallType,
|
|
253
279
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
|
|
254
|
-
txb.pure(next.next_node_name
|
|
255
|
-
txb.pure(next.forward
|
|
280
|
+
txb.pure(next.next_node_name),
|
|
281
|
+
txb.pure(next.forward), diliverable, sub,
|
|
256
282
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
257
283
|
})
|
|
258
284
|
} else {
|
|
259
285
|
txb.moveCall({
|
|
260
286
|
target:this.protocol.ProgressFn('next') as FnCallType,
|
|
261
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine), txb.pure(next.next_node_name
|
|
262
|
-
txb.pure(next.forward
|
|
287
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine), txb.pure(next.next_node_name),
|
|
288
|
+
txb.pure(next.forward), diliverable, sub, Protocol.TXB_OBJECT(txb, this.permission)],
|
|
263
289
|
})
|
|
264
290
|
}
|
|
265
291
|
}
|
|
@@ -276,9 +302,41 @@ export class Progress {
|
|
|
276
302
|
txb.pure(next.forward), txb.pure(hold, BCS.BOOL), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
277
303
|
})
|
|
278
304
|
}
|
|
279
|
-
static
|
|
305
|
+
static rpc_de_sessions = (session: any) : Session[] => {
|
|
306
|
+
let sessions : Session[] = [];
|
|
307
|
+
session?.fields?.contents?.forEach((v:any) => {
|
|
308
|
+
var s:Session = {next_node: v.fields.key, holders:[], weights:v.fields.value.fields.weights, threshold:v.fields.value.fields.threshold};
|
|
309
|
+
v.fields.value.fields.forwards.fields.contents.forEach((i:any) => {
|
|
310
|
+
s.holders.push({forward:i.fields.key, accomplished:i.fields.value.fields.accomplished,
|
|
311
|
+
who:i.fields.value.fields.who, deliverables:i.fields.value.fields.deliverables ?? undefined,
|
|
312
|
+
sub_progress: i.fields.value.fields.sub_progress ?? undefined
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
sessions.push(s);
|
|
316
|
+
})
|
|
317
|
+
return sessions;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
static rpc_de_history = (fields: any) : Session[] => {
|
|
321
|
+
let sessions : Session[] = [];
|
|
322
|
+
fields?.forEach((v:any) => {
|
|
323
|
+
const next_node = v.data.content.fields.value.fields.next_node;
|
|
324
|
+
v.data.content.fields.value.fields.session.fields.contents.forEach((i:any) => {
|
|
325
|
+
var s:Session = {id:v.data.content.fields.name,
|
|
326
|
+
node:v.data.content.fields.value.fields.node, next_node: i.fields.key, holders:[],
|
|
327
|
+
weights:i.fields.value.fields.weights, threshold:i.fields.value.fields.threshold, bComplete:i.fields.key === next_node};
|
|
328
|
+
i.fields.value.fields.forwards.fields.contents.forEach((k:any) => {
|
|
329
|
+
s.holders.push({forward:k.fields.key, who:k.fields.value.fields.who, accomplished:k.fields.value.fields.accomplished,
|
|
330
|
+
sub_progress:k.fields.value.fields.sub_progress ?? undefined, deliverables:k.fields.value.fields.deliverables ?? undefined});
|
|
331
|
+
})
|
|
332
|
+
sessions.push(s);
|
|
333
|
+
})
|
|
334
|
+
})
|
|
335
|
+
return sessions;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
static MAX_NAMED_OPERATOR_COUNT = 20;
|
|
280
339
|
static IsValidProgressNext = (next:ProgressNext) => {
|
|
281
340
|
return IsValidName(next.forward) && IsValidName(next.next_node_name);
|
|
282
341
|
}
|
|
283
|
-
|
|
284
342
|
}
|