wowok 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/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, IsValidUint, Bcs, IsValidName} from './utils';
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
- repository_add_policies = 103,
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
- repository_reference_add = 107,
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
- vote_add_guard = 153,
23
- vote_remove_guard = 154,
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
- service_set_stock = 203,
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
- service_repository_add = 206,
41
- service_repository_remove = 207,
42
- service_add_withdraw_guards = 208,
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
- service_set_customer_required = 222,
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
- reward_add_guard = 243,
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
- machine_add_repository = 602,
79
- machine_remove_repository = 603,
65
+ machine_repository = 602,
80
66
  machine_clone = 604,
81
- machine_add_node = 606,
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:'repository', module: 'repository'},
105
- {index:PermissionIndex.repository_set_description_set, name:'Description', description:'repository_set_description_set', module: 'repository'},
106
- {index:PermissionIndex.repository_set_policy_mode, name:'Policy mode', description:'repository_set_policy_mode', module: 'repository'},
107
- {index:PermissionIndex.repository_add_policies, name:'Add Policy', description:'brepository_add_policies', module: 'repository'},
108
- {index:PermissionIndex.repository_remove_policies, name:'Remove Policy', description:'build machine', module: 'repository'},
109
- {index:PermissionIndex.repository_set_policy_description, name:'Policy Description', description:'build machine', module: 'repository'},
110
- {index:PermissionIndex.repository_set_policy_permission, name:'Policy Permission', description:'build machine', module: 'repository'},
111
- {index:PermissionIndex.repository_reference_add, name:'Add Reference', description:'build machine', module: 'repository'},
112
- {index:PermissionIndex.repository_reference_remove, name:'Remove Reference', description:'build machine', module: 'repository'},
113
-
114
- {index:PermissionIndex.vote, name:'Vote', description:'build machine', module: 'vote'},
115
- {index:PermissionIndex.vote_set_description, name:'Description', description:'build machine', module: 'vote'},
116
- {index:PermissionIndex.vote_set_reference, name:'Reference', description:'build machine', module: 'vote'},
117
- {index:PermissionIndex.vote_add_guard, name:'Add Guard', description:'build machine', module: 'vote'},
118
- {index:PermissionIndex.vote_remove_guard, name:'Remove Guard', description:'build machine', module: 'vote'},
119
- {index:PermissionIndex.vote_add_option, name:'Add Option', description:'build machine', module: 'vote'},
120
- {index:PermissionIndex.vote_remove_option, name:'Remove Option', description:'build machine', module: 'vote'},
121
- {index:PermissionIndex.vote_set_max_choice_count, name:'Choice count', description:'build machine', module: 'vote'},
122
- {index:PermissionIndex.vote_open_voting, name:'Open voting', description:'build machine', module: 'vote'},
123
- {index:PermissionIndex.vote_lock_deadline, name:'Lock deadline', description:'build machine', module: 'vote'},
124
- {index:PermissionIndex.vote_expand_deadline, name:'Expand deadline', description:'build machine', module: 'vote'},
125
- {index:PermissionIndex.vote_lock_guard, name:'Lock Guard', description:'build machine', module: 'vote'},
126
-
127
- {index:PermissionIndex.service, name:'Service', description:'build machine', module: 'service'},
128
- {index:PermissionIndex.service_set_description, name:'Description', description:'build machine', module: 'service'},
129
- {index:PermissionIndex.service_set_price, name:'Price', description:'build machine', module: 'service'},
130
- {index:PermissionIndex.service_set_stock, name:'Inventory', description:'build machine', module: 'service'},
131
- {index:PermissionIndex.service_set_payee, name:'Payee', description:'build machine', module: 'service'},
132
- {index:PermissionIndex.service_repository_add, name:'Add Repository', description:'build machine', module: 'service'},
133
- {index:PermissionIndex.service_repository_remove, name:'Remove Repository', description:'build machine', module: 'service'},
134
- {index:PermissionIndex.service_add_withdraw_guards, name:'Withdraw Guard', description:'Add, remove withdraw guards', module: 'service'},
135
- {index:PermissionIndex.service_add_refund_guards, name:'Refund Guard', description:'Add, remove refund guards', module: 'service'},
136
- {index:PermissionIndex.service_remove_refund_guards, name:'Remove Refund Guard', description:'build machine', module: 'service'},
137
- {index:PermissionIndex.service_add_sales, name:'Add sales', description:'build machine', module: 'service'},
138
- {index:PermissionIndex.service_remove_sales, name:'Remove sales', description:'build machine', module: 'service'},
139
- {index:PermissionIndex.service_discount_transfer, name:'Discount', description:'build machine', module: 'service'},
140
- {index:PermissionIndex.service_withdraw, name:'Withdraw', description:'build machine', module: 'service'},
141
- {index:PermissionIndex.service_set_buy_guard, name:'Buyer Guard', description:'build machine', module: 'service'},
142
- {index:PermissionIndex.service_set_machine, name:'Machine', description:'build machine', module: 'service'},
143
- {index:PermissionIndex.service_set_endpoint, name:'Endpoint', description:'build machine', module: 'service'},
144
- {index:PermissionIndex.service_publish, name:'Publish', description:'build machine', module: 'service'},
145
- {index:PermissionIndex.service_clone, name:'Clone', description:'build machine', module: 'service'},
146
- {index:PermissionIndex.service_set_customer_required, name:'Buyer info', description:'build machine', module: 'service'},
147
- {index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'build machine', module: 'service'},
148
- {index:PermissionIndex.service_pause, name:'Pause', description:'build machine', module: 'service'},
149
-
150
- {index:PermissionIndex.reward, name:'Reward', description:'build machine', module: 'reward'},
151
- {index:PermissionIndex.reward_refund, name:'Refund', description:'build machine', module: 'reward'},
152
- {index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'build machine', module: 'reward'},
153
- {index:PermissionIndex.reward_add_guard, name:'Add Guard', description:'build machine', module: 'reward'},
154
- {index:PermissionIndex.reward_remove_guard, name:'Remove Guard', description:'build machine', module: 'reward'},
155
- {index:PermissionIndex.reward_set_description, name:'Description', description:'build machine', module: 'reward'},
156
- {index:PermissionIndex.reward_lock_guards, name:'Lock Guard', description:'build machine', module: 'reward'},
157
-
158
- {index:PermissionIndex.demand, name:'Demand', description:'build machine', module: 'demand'},
159
- {index:PermissionIndex.demand_refund, name:'Refund', description:'build machine', module: 'demand'},
160
- {index:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'build machine', module: 'demand'},
161
- {index:PermissionIndex.demand_set_guard, name:'Guard', description:'build machine', module: 'demand'},
162
- {index:PermissionIndex.demand_set_description, name:'Description', description:'build machine', module: 'demand'},
163
- {index:PermissionIndex.demand_yes, name:'Yes', description:'build machine', module: 'demand'},
164
-
165
- {index:PermissionIndex.machine, name: 'Machine', description:'build machine', module: 'machine'},
166
- {index:PermissionIndex.machine_set_description, name: 'Description', description:'machine_set_description', module: 'machine'},
167
- {index:PermissionIndex.machine_add_repository, name: 'Add Repository', description:'machine_add_repository', module: 'machine'},
168
- {index:PermissionIndex.machine_remove_repository, name: 'Remove Repository', description:'machine_remove_repository', module: 'machine'},
169
- {index:PermissionIndex.machine_clone, name: 'Clone', description:'machine_clone', module: 'machine'},
170
- {index:PermissionIndex.machine_add_node, name: 'Add node', description:'machine_add_node/2', module: 'machine'},
171
- {index:PermissionIndex.machine_remove_node, name: 'Remove node', description:'machine_remove_node', module: 'machine'},
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, BCS.STRING)]
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 (!entities) {
279
- ERROR(Errors.InvalidParam, 'add_entity2');
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?:string[], removeall?:boolean) {
433
- if (!removeall && !admin) {
434
- ERROR(Errors.AllInvalid, 'admin & removeall')
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 && IsValidUint(index)
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 (!addresses || addresses.length > Progress.MAX_NAMED_OPERATOR_COUNT || !IsValidArray(addresses, IsValidAddress)) {
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, BCS.STRING),
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, BCS.STRING),
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
- if (parent.parent_id) {
202
- txb.moveCall({
203
- target:this.protocol.ProgressFn('parent_set_with_passport') as FnCallType,
204
- arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
205
- txb.pure(parent.parent_id, BCS.ADDRESS),
206
- txb.pure(parent.parent_session_id, BCS.U64),
207
- Protocol.TXB_OBJECT(txb, this.permission)],
208
- })
209
- } else {
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
- if (parent.parent_id) {
218
- txb.moveCall({
219
- target:this.protocol.ProgressFn('parent_set') as FnCallType,
220
- arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.machine),
221
- txb.pure(parent.parent_id, BCS.ADDRESS),
222
- txb.pure(parent.parent_session_id, BCS.U64),
223
- Protocol.TXB_OBJECT(txb, this.permission)],
224
- })
225
- } else {
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, BCS.STRING),
255
- txb.pure(next.forward, BCS.STRING), diliverable, sub,
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, BCS.STRING),
262
- txb.pure(next.forward, BCS.STRING), diliverable, sub, Protocol.TXB_OBJECT(txb, this.permission)],
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 MAX_NAMED_OPERATOR_COUNT = 100;
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
  }
package/src/protocol.ts CHANGED
@@ -79,8 +79,8 @@ export enum OperatorType {
79
79
  export enum ValueType {
80
80
  TYPE_BOOL = 100,
81
81
  TYPE_ADDRESS = 101,
82
- TYPE_U64 = 102,
83
- TYPE_U8 = 103,
82
+ TYPE_U8 = 102,
83
+ TYPE_U64 = 103,
84
84
  TYPE_VEC_U8 = 104,
85
85
  TYPE_U128 = 105,
86
86
  TYPE_VEC_ADDRESS = 106,
@@ -111,12 +111,12 @@ export enum RepositoryValueType {
111
111
  }
112
112
 
113
113
  export const RepositoryValueTypeInfo = [
114
- {type: RepositoryValueType.Address, name:'Address', description:'Object id or Personal address.'},
115
- {type: RepositoryValueType.Address_Vec, name:'Address vector', description:'Vector of address.'},
116
114
  {type: RepositoryValueType.String, name:'String', description:'String.'},
115
+ {type: RepositoryValueType.Address, name:'Address', description:'Object id or Personal address.'},
116
+ {type: RepositoryValueType.PositiveNumber, name:'Positive number or Zero', description:'Positive number or 0. including u8, u16 ,..., u256'},
117
117
  {type: RepositoryValueType.String_Vec, name:'String vector', description:'Vector of string.'},
118
- {type: RepositoryValueType.PositiveNumber, name:'Positive number', description:'Positive number. including u8, u16 ,..., u256'},
119
- {type: RepositoryValueType.PositiveNumber_Vec, name:'Positive number vector', description:'Vector of positive number'},
118
+ {type: RepositoryValueType.Address_Vec, name:'Address vector', description:'Vector of address.'},
119
+ {type: RepositoryValueType.PositiveNumber_Vec, name:'Positive number or Zero vector', description:'Vector of positive number or 0'},
120
120
  ]
121
121
 
122
122
  export const ValueTypeInfo = [
@@ -199,9 +199,9 @@ export enum ENTRYPOINT {
199
199
  }
200
200
 
201
201
  const TESTNET = {
202
- package: "0x852fa17575b1ae11932b475110bf46981458fdb67a2f07b922022e1516560fad",
203
- wowok_object: '0xf98cc6d8bd9feadc5dce7365270b4ffb32f69a5320ab739193d301103e686e8c',
204
- entity_object: '0xe0469c187499273ec39a575cc28d4d93f0a66b11e1b92028c61bc69bfc1167c6',
202
+ package: "0xdf85200f7a9dcac175724d10d1002c7481f718bb8f609f2ff27da47ce5d04870",
203
+ wowok_object: '0xcbbc4a23b63ab77291e885998ef1d03ac13537bb6b8ffb108913f8196cd7f62b',
204
+ entity_object: '0x362aa575fa8c1506776f13e8f5849fd932b26b080f7a6f238856f42ce6114e31',
205
205
  }
206
206
 
207
207
  const MAINNET = {
@@ -279,7 +279,6 @@ export class Protocol {
279
279
  };
280
280
 
281
281
  MachineFn = (fn:any) => { return `${this.package}::${MODULES.machine}::${fn}`};
282
- NodeFn = (fn: any) => { return `${this.package}::${MODULES.node}::${fn}`};
283
282
  ProgressFn = (fn:any) => { return `${this.package}::${MODULES.progress}::${fn}`};
284
283
  CommunityFn = (fn: any) => { return `${this.package}::${MODULES.community}::${fn}`};
285
284
  RepositoryFn = (fn:any) => { return `${this.package}::${MODULES.repository}::${fn}`};