wowok 1.2.5 → 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.
Files changed (51) hide show
  1. package/dist/demand.d.ts +3 -2
  2. package/dist/demand.d.ts.map +1 -1
  3. package/dist/demand.js +21 -7
  4. package/dist/entity.d.ts +2 -1
  5. package/dist/entity.d.ts.map +1 -1
  6. package/dist/entity.js +23 -7
  7. package/dist/exception.d.ts +3 -1
  8. package/dist/exception.d.ts.map +1 -1
  9. package/dist/exception.js +3 -1
  10. package/dist/guard.js +1 -1
  11. package/dist/machine.js +2 -2
  12. package/dist/permission.d.ts +20 -4
  13. package/dist/permission.d.ts.map +1 -1
  14. package/dist/permission.js +146 -13
  15. package/dist/protocol.d.ts +30 -6
  16. package/dist/protocol.d.ts.map +1 -1
  17. package/dist/protocol.js +124 -17
  18. package/dist/repository.d.ts +6 -3
  19. package/dist/repository.d.ts.map +1 -1
  20. package/dist/repository.js +59 -40
  21. package/dist/resource.d.ts +20 -6
  22. package/dist/resource.d.ts.map +1 -1
  23. package/dist/resource.js +58 -21
  24. package/dist/reward.d.ts +6 -3
  25. package/dist/reward.d.ts.map +1 -1
  26. package/dist/reward.js +43 -19
  27. package/dist/service.d.ts +6 -3
  28. package/dist/service.d.ts.map +1 -1
  29. package/dist/service.js +76 -44
  30. package/dist/utils.d.ts +15 -1
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +150 -13
  33. package/dist/vote.d.ts +2 -2
  34. package/dist/vote.d.ts.map +1 -1
  35. package/dist/vote.js +14 -14
  36. package/package.json +1 -1
  37. package/src/demand.ts +26 -12
  38. package/src/entity.ts +33 -6
  39. package/src/exception.ts +3 -1
  40. package/src/guard.ts +2 -2
  41. package/src/machine.ts +207 -55
  42. package/src/permission.ts +168 -41
  43. package/src/progress.ts +101 -43
  44. package/src/protocol.ts +129 -20
  45. package/src/repository.ts +160 -53
  46. package/src/resource.ts +75 -24
  47. package/src/reward.ts +53 -32
  48. package/src/service.ts +109 -74
  49. package/src/utils.ts +174 -22
  50. package/src/vote.ts +30 -33
  51. 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, IsValidUint, Bcs} 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,38 +8,31 @@ 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 = 104,
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 = 108,
17
- repository_reference_removeall = 108,
14
+ repository_reference = 107,
15
+
18
16
  vote = 150,
19
17
  vote_set_description = 151,
20
18
  vote_set_reference = 152,
21
- vote_add_guard = 153,
22
- vote_remove_guard = 154,
23
- vote_add_option = 155,
24
- vote_remove_option = 156,
19
+ vote_guard = 153,
20
+ vote_option = 155,
25
21
  vote_set_max_choice_count = 157,
26
22
  vote_open_voting = 158,
27
23
  vote_lock_deadline = 159,
28
24
  vote_expand_deadline = 160,
29
25
  vote_lock_guard = 161,
26
+
30
27
  service = 200,
31
28
  service_set_description = 201,
32
29
  service_set_price = 202,
33
- service_set_stock = 203,
34
- service_add_stock = 203,
35
- service_reduce_stock = 203,
30
+ service_set_add_reduce_stock = 203,
31
+ service_set_sale_endpoint = 204,
36
32
  service_set_payee = 205,
37
- service_repository_add = 206,
38
- service_repository_remove = 207,
39
- service_add_withdraw_guards = 208,
40
- service_remove_withdraw_guards = 208,
41
- service_add_refund_guards = 210,
42
- service_remove_refund_guards = 210,
33
+ service_repository = 206,
34
+ service_withdraw_guards = 208,
35
+ service_refund_guards = 210,
43
36
  service_add_sales = 212,
44
37
  service_remove_sales = 213,
45
38
  service_discount_transfer = 214,
@@ -49,35 +42,33 @@ export enum PermissionIndex {
49
42
  service_set_endpoint = 219,
50
43
  service_publish = 220,
51
44
  service_clone = 221,
52
- service_set_customer_required = 222,
53
- service_remove_customer_required = 222,
54
- service_change_required_pubkey = 222,
45
+ service_customer_required = 222,
55
46
  service_change_order_required_pubkey = 224,
56
47
  service_pause = 225,
48
+
57
49
  reward = 240,
58
50
  reward_refund = 241,
59
51
  reward_expand_time = 242,
60
- reward_add_guard = 243,
61
- reward_remove_guard = 244,
52
+ reward_guard = 243,
62
53
  reward_set_description = 245,
63
54
  reward_lock_guards = 246,
55
+
64
56
  demand = 260,
65
57
  demand_refund = 261,
66
58
  demand_expand_time = 262,
67
59
  demand_set_guard = 263,
68
60
  demand_set_description = 264,
69
61
  demand_yes = 265,
62
+
70
63
  machine = 600,
71
64
  machine_set_description = 601,
72
- machine_add_repository = 602,
73
- machine_remove_repository = 603,
65
+ machine_repository = 602,
74
66
  machine_clone = 604,
75
- machine_add_node = 606,
76
- machine_add_node2 = 606,
77
- machine_remove_node = 607,
67
+ machine_node = 606,
78
68
  machine_set_endpoint = 608,
79
69
  machine_pause = 609,
80
70
  machine_publish = 610,
71
+
81
72
  progress = 650,
82
73
  progress_set_namedOperator = 651,
83
74
  progress_bind_task = 652,
@@ -86,6 +77,85 @@ export enum PermissionIndex {
86
77
  user_defined_start = 10000,
87
78
  }
88
79
 
80
+ export interface PermissionInfoType {
81
+ index: number;
82
+ name:string;
83
+ description:string;
84
+ module: string;
85
+ guard?: string;
86
+ }
87
+
88
+ export const PermissionInfo : PermissionInfoType[] = [
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'},
157
+ ]
158
+
89
159
  export type PermissionIndexType = PermissionIndex | number;
90
160
 
91
161
  export type Permission_Index = {
@@ -141,10 +211,70 @@ export class Permission {
141
211
  arguments: [Protocol.TXB_OBJECT(txb, this.object)],
142
212
  })
143
213
  }
214
+ add_userdefine(index: number, name:string) {
215
+ if (!Permission.IsValidUserDefinedIndex(index)) {
216
+ ERROR(Errors.IsValidUserDefinedIndex, 'add_userdefine');
217
+ }
218
+
219
+ if (!IsValidName(name)) {
220
+ ERROR(Errors.IsValidName, 'add_userdefine');
221
+ }
222
+ let txb = this.protocol.CurrentSession();
223
+ txb.moveCall({
224
+ target:this.protocol.PermissionFn('user_define_add') as FnCallType,
225
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64), txb.pure(name)]
226
+ })
227
+ }
228
+
229
+ remove_userdefine(index: number) {
230
+ if (!Permission.IsValidUserDefinedIndex(index)) {
231
+ ERROR(Errors.IsValidUserDefinedIndex, 'add_userdefine');
232
+ }
233
+
234
+ let txb = this.protocol.CurrentSession();
235
+ txb.moveCall({
236
+ target:this.protocol.PermissionFn('user_define_remove') as FnCallType,
237
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64)]
238
+ })
239
+ }
240
+
241
+ change_entity(old_entity: string, new_entity: string) {
242
+ if (!IsValidAddress(old_entity) || !IsValidAddress(new_entity)) {
243
+ ERROR(Errors.IsValidAddress, 'change_entity')
244
+ }
245
+ let txb = this.protocol.CurrentSession();
246
+ txb.moveCall({
247
+ target:this.protocol.PermissionFn('change_entity') as FnCallType,
248
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(old_entity, BCS.ADDRESS),
249
+ txb.pure(new_entity, BCS.ADDRESS) ]
250
+ })
251
+ }
252
+
253
+ add_entity2(entities: string[], index?:PermissionIndexType) {
254
+ if (entities.length === 0) return;
255
+
256
+ if (!IsValidArray(entities, IsValidAddress)) {
257
+ ERROR(Errors.IsValidArray, 'add_entity2');
258
+ }
259
+
260
+ let txb = this.protocol.CurrentSession();
261
+ if (index) {
262
+ txb.moveCall({
263
+ target:this.protocol.PermissionFn('add_with_index') as FnCallType,
264
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(index, BCS.U64),
265
+ txb.pure(array_unique(entities), 'vector<address>')]
266
+ })
267
+ } else {
268
+ txb.moveCall({
269
+ target:this.protocol.PermissionFn('add') as FnCallType,
270
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(entities), 'vector<address>')]
271
+ })
272
+ }
273
+ }
144
274
 
145
275
  add_entity(entities:Permission_Entity[]) {
146
276
  if (!entities) {
147
- ERROR(Errors.InvalidParam, 'entities');
277
+ ERROR(Errors.InvalidParam, 'add_entity');
148
278
  }
149
279
 
150
280
  let bValid = true;
@@ -179,13 +309,13 @@ export class Permission {
179
309
  }
180
310
  }
181
311
  }
182
- if (indexes.length > 0) {
312
+ //if (indexes.length > 0) {
183
313
  txb.moveCall({
184
314
  target:this.protocol.PermissionFn('add_batch') as FnCallType,
185
315
  arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity.entity_address, BCS.ADDRESS),
186
316
  txb.pure(indexes, 'vector<u64>')]
187
317
  })
188
- }
318
+ //}
189
319
  }
190
320
  // set guards
191
321
  guards.forEach(({entity_address, index, guard}) => {
@@ -219,8 +349,7 @@ export class Permission {
219
349
  arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(entity_address, BCS.ADDRESS),
220
350
  txb.pure(index, BCS.U64)]
221
351
  })
222
- }
223
- ;
352
+ };
224
353
  }
225
354
 
226
355
  remove_index(entity_address:string, index:PermissionIndexType[]) {
@@ -275,12 +404,9 @@ export class Permission {
275
404
  ;
276
405
  }
277
406
 
278
- remove_admin(admin?:string[], removeall?:boolean) {
279
- if (!removeall && !admin) {
280
- ERROR(Errors.AllInvalid, 'admin & removeall')
281
- }
282
-
283
- if (admin && !IsValidArray(admin, IsValidAddress)) {
407
+ remove_admin(admin:string[], removeall?:boolean) {
408
+ if (!removeall && admin.length === 0) return
409
+ if (!IsValidArray(admin, IsValidAddress)) {
284
410
  ERROR(Errors.IsValidArray, 'admin')
285
411
  }
286
412
 
@@ -314,8 +440,9 @@ export class Permission {
314
440
  static MAX_ADMIN_COUNT = 64;
315
441
  static MAX_ENTITY_COUNT = 2000;
316
442
  static MAX_PERMISSION_INDEX_COUNT = 200;
443
+ static MAX_PERSONAL_PERMISSION_COUNT = 200;
317
444
  static IsValidUserDefinedIndex = (index:number) => {
318
- return index >= PermissionIndex.user_defined_start && IsValidUint(index)
445
+ return index >= PermissionIndex.user_defined_start && IsValidUintLarge(index)
319
446
  }
320
447
 
321
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
  }