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.
- package/dist/demand.d.ts +3 -2
- package/dist/demand.d.ts.map +1 -1
- package/dist/demand.js +21 -7
- package/dist/entity.d.ts +2 -1
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +23 -7
- package/dist/exception.d.ts +3 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +3 -1
- package/dist/guard.js +1 -1
- package/dist/machine.js +2 -2
- package/dist/permission.d.ts +20 -4
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +146 -13
- package/dist/protocol.d.ts +30 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +124 -17
- package/dist/repository.d.ts +6 -3
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +59 -40
- package/dist/resource.d.ts +20 -6
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +58 -21
- package/dist/reward.d.ts +6 -3
- package/dist/reward.d.ts.map +1 -1
- package/dist/reward.js +43 -19
- package/dist/service.d.ts +6 -3
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +76 -44
- package/dist/utils.d.ts +15 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +150 -13
- package/dist/vote.d.ts +2 -2
- package/dist/vote.d.ts.map +1 -1
- package/dist/vote.js +14 -14
- package/package.json +1 -1
- package/src/demand.ts +26 -12
- package/src/entity.ts +33 -6
- package/src/exception.ts +3 -1
- package/src/guard.ts +2 -2
- package/src/machine.ts +207 -55
- package/src/permission.ts +168 -41
- package/src/progress.ts +101 -43
- package/src/protocol.ts +129 -20
- package/src/repository.ts +160 -53
- package/src/resource.ts +75 -24
- package/src/reward.ts +53 -32
- package/src/service.ts +109 -74
- package/src/utils.ts +174 -22
- package/src/vote.ts +30 -33
- package/src/wowok.ts +2 -2
package/src/machine.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
3
|
import { Protocol, FnCallType, PermissionObject, RepositoryObject, PassportObject, MachineObject, MachineAddress, GuardObject, TxbObject} from './protocol';
|
|
4
|
-
import { IsValidInt,
|
|
5
|
-
IsValidEndpoint, OptionNone, IsValidDesription
|
|
4
|
+
import { IsValidInt, Bcs, array_unique, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty,
|
|
5
|
+
IsValidEndpoint, OptionNone, IsValidDesription,
|
|
6
|
+
IsValidUintLarge} from './utils'
|
|
6
7
|
import { Permission, PermissionIndexType } from './permission';
|
|
7
8
|
import { Errors, ERROR} from './exception'
|
|
8
9
|
import { ValueType } from './protocol';
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
export type MachineNodeObject = TransactionResult | String;
|
|
12
|
-
|
|
13
12
|
export interface Machine_Forward {
|
|
14
13
|
name: string; // foward name
|
|
15
14
|
namedOperator?: string; // dynamic operator
|
|
@@ -24,7 +23,6 @@ export interface Machine_Node_Pair {
|
|
|
24
23
|
}
|
|
25
24
|
export interface Machine_Node {
|
|
26
25
|
name: string;
|
|
27
|
-
description: string;
|
|
28
26
|
pairs: Machine_Node_Pair[];
|
|
29
27
|
}
|
|
30
28
|
|
|
@@ -46,7 +44,7 @@ export class Machine {
|
|
|
46
44
|
this.permission = permission;
|
|
47
45
|
this.object = '';
|
|
48
46
|
}
|
|
49
|
-
static New(protocol:Protocol, permission:PermissionObject, description:string, endpoint?:string, passport?:PassportObject) : Machine {
|
|
47
|
+
static New(protocol:Protocol, permission:PermissionObject, description:string, endpoint?:string|null, passport?:PassportObject) : Machine {
|
|
50
48
|
if (!Protocol.IsValidObjects([permission])) {
|
|
51
49
|
ERROR(Errors.IsValidObjects, 'permission')
|
|
52
50
|
}
|
|
@@ -74,77 +72,84 @@ export class Machine {
|
|
|
74
72
|
}
|
|
75
73
|
return m
|
|
76
74
|
}
|
|
77
|
-
|
|
75
|
+
|
|
78
76
|
// create new nodes for machine
|
|
79
77
|
add_node(nodes:Machine_Node[], passport?:PassportObject) {
|
|
78
|
+
if (nodes.length === 0) return ;
|
|
79
|
+
|
|
80
80
|
let bValid = true;
|
|
81
81
|
nodes.forEach((node) => {
|
|
82
|
-
if (!
|
|
82
|
+
if (!IsValidName(node.name)) { bValid = false; }
|
|
83
83
|
node.pairs.forEach((p) => {
|
|
84
84
|
if (!IsValidName_AllowEmpty(p.prior_node)) { bValid = false; }
|
|
85
85
|
if (p?.threshold && !IsValidInt(p.threshold)) { bValid = false; }
|
|
86
86
|
p.forwards.forEach((f) => {
|
|
87
|
-
if (!
|
|
88
|
-
if (f?.namedOperator && !IsValidName_AllowEmpty(f?.namedOperator)) { bValid = false }
|
|
89
|
-
if (f?.permission && !Permission.IsValidPermissionIndex(f?.permission)) { bValid = false }
|
|
90
|
-
if (!f?.permission && !f?.namedOperator) { bValid = false; }
|
|
91
|
-
if (f?.weight && !IsValidUint(f.weight)) { bValid = false; }
|
|
87
|
+
if (!Machine.isValidForward(f)) bValid = false;
|
|
92
88
|
})
|
|
93
89
|
})
|
|
94
90
|
})
|
|
95
91
|
if (!bValid) {
|
|
96
|
-
ERROR(Errors.InvalidParam, '
|
|
92
|
+
ERROR(Errors.InvalidParam, 'add_node')
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
let new_nodes:
|
|
95
|
+
let new_nodes: TxbObject[] = [];
|
|
100
96
|
let txb = this.protocol.CurrentSession();
|
|
101
97
|
nodes.forEach((node) => {
|
|
102
98
|
let n = txb.moveCall({
|
|
103
|
-
target:this.protocol.
|
|
104
|
-
arguments:[txb.pure(node.name)
|
|
105
|
-
});
|
|
99
|
+
target:this.protocol.MachineFn('node_new') as FnCallType,
|
|
100
|
+
arguments:[txb.pure(node.name)]
|
|
101
|
+
});
|
|
106
102
|
node.pairs.forEach((pair) => {
|
|
107
|
-
let threshold = pair?.threshold ? txb.pure(Bcs.getInstance().
|
|
103
|
+
let threshold = pair?.threshold ? txb.pure(Bcs.getInstance().ser_option_u32(pair.threshold)) : OptionNone(txb);
|
|
108
104
|
|
|
109
105
|
pair.forwards.forEach((forward) => {
|
|
110
|
-
let weight = forward?.weight ? forward.weight : 1;
|
|
111
|
-
let perm = forward?.permission ? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, forward.permission)) : OptionNone(txb);
|
|
112
|
-
let namedOperator = forward?.namedOperator ? txb.pure(forward.namedOperator) : txb.pure('');
|
|
113
|
-
let f;
|
|
114
|
-
|
|
115
|
-
if (forward?.guard) {
|
|
116
|
-
f = txb.moveCall({
|
|
117
|
-
target:this.protocol.NodeFn('forward') as FnCallType,
|
|
118
|
-
arguments:[namedOperator, txb.pure(weight), txb.object(Protocol.TXB_OBJECT(txb, forward.guard)), perm]
|
|
119
|
-
});
|
|
120
|
-
} else {
|
|
121
|
-
f = txb.moveCall({
|
|
122
|
-
target:this.protocol.NodeFn('forward2') as FnCallType,
|
|
123
|
-
arguments:[namedOperator, txb.pure(weight), perm]
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
106
|
txb.moveCall({ // add forward
|
|
127
|
-
target:this.protocol.
|
|
128
|
-
arguments:[n, txb.pure(pair.prior_node), txb.pure(forward.name), threshold,
|
|
107
|
+
target:this.protocol.MachineFn('forward_add') as FnCallType,
|
|
108
|
+
arguments:[n, txb.pure(pair.prior_node), txb.pure(forward.name), threshold, this.forward(forward)]
|
|
129
109
|
});
|
|
130
110
|
});
|
|
111
|
+
if (pair.forwards.length === 0) {
|
|
112
|
+
txb.moveCall({ // add forward
|
|
113
|
+
target:this.protocol.MachineFn('forward_add_none') as FnCallType,
|
|
114
|
+
arguments:[n, txb.pure(pair.prior_node), threshold]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
131
117
|
});
|
|
132
118
|
new_nodes.push(n);
|
|
133
119
|
});
|
|
134
120
|
this.add_node2(new_nodes, passport)
|
|
135
121
|
}
|
|
136
122
|
|
|
123
|
+
forward(forward:Machine_Forward) : TransactionResult {
|
|
124
|
+
const txb = this.protocol.CurrentSession();
|
|
125
|
+
|
|
126
|
+
let weight = forward?.weight ? forward.weight : 1;
|
|
127
|
+
let perm = forward?.permission ? txb.pure(Bcs.getInstance().ser(ValueType.TYPE_OPTION_U64, forward.permission)) : OptionNone(txb);
|
|
128
|
+
let namedOperator = forward?.namedOperator ? txb.pure(forward.namedOperator) : txb.pure('');
|
|
129
|
+
let f:any;
|
|
130
|
+
|
|
131
|
+
if (forward?.guard) {
|
|
132
|
+
f = txb.moveCall({
|
|
133
|
+
target:this.protocol.MachineFn('forward') as FnCallType,
|
|
134
|
+
arguments:[namedOperator, txb.pure(weight), txb.object(Protocol.TXB_OBJECT(txb, forward.guard)), perm]
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
f = txb.moveCall({
|
|
138
|
+
target:this.protocol.MachineFn('forward2') as FnCallType,
|
|
139
|
+
arguments:[namedOperator, txb.pure(weight), perm]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return f
|
|
143
|
+
}
|
|
144
|
+
|
|
137
145
|
// move MachineNodeObject to the machine from signer-owned MachineNode object
|
|
138
|
-
add_node2(nodes:
|
|
139
|
-
if (
|
|
140
|
-
ERROR(Errors.InvalidParam, '
|
|
146
|
+
add_node2(nodes:TxbObject[], passport?:PassportObject) {
|
|
147
|
+
if (nodes.length === 0) {
|
|
148
|
+
ERROR(Errors.InvalidParam, 'add_node2');
|
|
141
149
|
}
|
|
142
150
|
|
|
143
151
|
let txb = this.protocol.CurrentSession();
|
|
144
|
-
let n: TransactionResult[] =
|
|
145
|
-
array_unique(nodes).forEach((v) => {
|
|
146
|
-
n.push(Protocol.TXB_OBJECT(txb, v));
|
|
147
|
-
})
|
|
152
|
+
let n: TransactionResult[] = nodes.map((v)=>Protocol.TXB_OBJECT(txb, v));
|
|
148
153
|
|
|
149
154
|
if (passport) {
|
|
150
155
|
txb.moveCall({ // add node
|
|
@@ -158,10 +163,54 @@ export class Machine {
|
|
|
158
163
|
});
|
|
159
164
|
}
|
|
160
165
|
}
|
|
166
|
+
|
|
167
|
+
fetch_node(node_name:string, passport?:PassportObject) : TxbObject {
|
|
168
|
+
if (!IsValidName(node_name)) {
|
|
169
|
+
ERROR(Errors.IsValidName, 'fetch_node');
|
|
170
|
+
}
|
|
171
|
+
let txb = this.protocol.CurrentSession();
|
|
172
|
+
if (passport) {
|
|
173
|
+
return txb.moveCall({
|
|
174
|
+
target:this.protocol.MachineFn('node_fetch_with_passport') as FnCallType,
|
|
175
|
+
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name),
|
|
176
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
return txb.moveCall({
|
|
180
|
+
target:this.protocol.MachineFn('node_fetch') as FnCallType,
|
|
181
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
rename_node(node_name:string, new_name:string, passport?:PassportObject) {
|
|
186
|
+
if (node_name === new_name) return
|
|
187
|
+
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'rename_node');
|
|
188
|
+
if (!IsValidName(new_name)) ERROR(Errors.IsValidName, 'rename_node');
|
|
189
|
+
|
|
190
|
+
let txb = this.protocol.CurrentSession();
|
|
191
|
+
|
|
192
|
+
if (passport) {
|
|
193
|
+
txb.moveCall({
|
|
194
|
+
target:this.protocol.MachineFn('node_rename_with_passport') as FnCallType,
|
|
195
|
+
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
196
|
+
txb.pure(node_name), txb.pure(new_name),
|
|
197
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
txb.moveCall({
|
|
201
|
+
target:this.protocol.MachineFn('node_rename') as FnCallType,
|
|
202
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object),
|
|
203
|
+
txb.pure(node_name), txb.pure(new_name),
|
|
204
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
161
208
|
|
|
162
209
|
// move MachineNodeObject from this.object to signer-owned MachineNode object
|
|
163
210
|
remove_node(nodes_name:string[], bTransferMyself:boolean = false, passport?:PassportObject) {
|
|
164
|
-
if (
|
|
211
|
+
if (nodes_name.length === 0) return;
|
|
212
|
+
|
|
213
|
+
if (!IsValidArray(nodes_name, IsValidName)) {
|
|
165
214
|
ERROR(Errors.IsValidArray, 'nodes_name')
|
|
166
215
|
}
|
|
167
216
|
|
|
@@ -179,7 +228,7 @@ export class Machine {
|
|
|
179
228
|
});
|
|
180
229
|
}
|
|
181
230
|
}
|
|
182
|
-
|
|
231
|
+
|
|
183
232
|
destroy() {
|
|
184
233
|
let txb = this.protocol.CurrentSession();
|
|
185
234
|
txb.moveCall({
|
|
@@ -230,11 +279,12 @@ export class Machine {
|
|
|
230
279
|
}
|
|
231
280
|
|
|
232
281
|
remove_repository(repositories:string[], removeall?:boolean, passport?:PassportObject) {
|
|
233
|
-
if (!removeall &&
|
|
234
|
-
|
|
282
|
+
if (!removeall && repositories.length===0) {
|
|
283
|
+
return;
|
|
235
284
|
}
|
|
236
|
-
|
|
237
|
-
|
|
285
|
+
|
|
286
|
+
if (!IsValidArray(repositories, IsValidAddress)){
|
|
287
|
+
ERROR(Errors.IsValidArray, 'remove_repository')
|
|
238
288
|
}
|
|
239
289
|
|
|
240
290
|
let txb = this.protocol.CurrentSession();
|
|
@@ -247,7 +297,7 @@ export class Machine {
|
|
|
247
297
|
} else {
|
|
248
298
|
txb.moveCall({
|
|
249
299
|
target:this.protocol.MachineFn('repository_remove_with_passport') as FnCallType,
|
|
250
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(repositories, 'vector<address>'),
|
|
300
|
+
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(repositories), 'vector<address>'),
|
|
251
301
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
252
302
|
})
|
|
253
303
|
}
|
|
@@ -260,7 +310,7 @@ export class Machine {
|
|
|
260
310
|
} else {
|
|
261
311
|
txb.moveCall({
|
|
262
312
|
target:this.protocol.MachineFn('repository_remove') as FnCallType,
|
|
263
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(repositories, 'vector<address>'),
|
|
313
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(array_unique(repositories), 'vector<address>'),
|
|
264
314
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
265
315
|
})
|
|
266
316
|
}
|
|
@@ -282,7 +332,7 @@ export class Machine {
|
|
|
282
332
|
}
|
|
283
333
|
}
|
|
284
334
|
|
|
285
|
-
set_endpoint(endpoint?:string, passport?:PassportObject) {
|
|
335
|
+
set_endpoint(endpoint?:string|null, passport?:PassportObject) {
|
|
286
336
|
if (endpoint && !IsValidEndpoint(endpoint)) {
|
|
287
337
|
ERROR(Errors.IsValidEndpoint)
|
|
288
338
|
}
|
|
@@ -329,7 +379,6 @@ export class Machine {
|
|
|
329
379
|
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
330
380
|
})
|
|
331
381
|
}
|
|
332
|
-
|
|
333
382
|
}
|
|
334
383
|
|
|
335
384
|
change_permission(new_permission:PermissionObject) {
|
|
@@ -346,6 +395,109 @@ export class Machine {
|
|
|
346
395
|
this.permission = new_permission;
|
|
347
396
|
}
|
|
348
397
|
|
|
398
|
+
add_forward(node_prior:string, node_name:string, foward: Machine_Forward, threshold?:number, passport?:PassportObject) {
|
|
399
|
+
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'add_forward');
|
|
400
|
+
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'add_forward');
|
|
401
|
+
if (!Machine.isValidForward(foward)) ERROR(Errors.InvalidParam, 'add_forward');
|
|
402
|
+
|
|
403
|
+
let txb = this.protocol.CurrentSession();
|
|
404
|
+
let n : any;
|
|
405
|
+
if (passport) {
|
|
406
|
+
n = txb.moveCall({
|
|
407
|
+
target:this.protocol.MachineFn('node_fetch_with_passport') as FnCallType,
|
|
408
|
+
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
} else {
|
|
412
|
+
n = txb.moveCall({
|
|
413
|
+
target:this.protocol.MachineFn('node_fetch') as FnCallType,
|
|
414
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
415
|
+
})
|
|
416
|
+
}
|
|
417
|
+
const f = this.forward(foward);
|
|
418
|
+
const t = threshold ? txb.pure(Bcs.getInstance().ser_option_u32(threshold)) : OptionNone(txb);
|
|
419
|
+
txb.moveCall({
|
|
420
|
+
target:this.protocol.MachineFn('forward_add') as FnCallType,
|
|
421
|
+
arguments:[n, txb.pure(node_prior), txb.pure(foward.name), t, f],
|
|
422
|
+
})
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
remove_forward(node_prior:string, node_name:string, foward_name: string, passport?:PassportObject) {
|
|
426
|
+
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'add_forward');
|
|
427
|
+
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'add_forward');
|
|
428
|
+
|
|
429
|
+
let txb = this.protocol.CurrentSession();
|
|
430
|
+
let n : any;
|
|
431
|
+
if (passport) {
|
|
432
|
+
n = txb.moveCall({
|
|
433
|
+
target:this.protocol.MachineFn('node_fetch_with_passport') as FnCallType,
|
|
434
|
+
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
} else {
|
|
438
|
+
n = txb.moveCall({
|
|
439
|
+
target:this.protocol.MachineFn('node_fetch') as FnCallType,
|
|
440
|
+
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(node_name), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
txb.moveCall({
|
|
444
|
+
target:this.protocol.MachineFn('forward_remove') as FnCallType,
|
|
445
|
+
arguments:[n, txb.pure(node_prior), txb.pure(foward_name)],
|
|
446
|
+
})
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
static rpc_de_nodes(fields: any) : Machine_Node[] {
|
|
450
|
+
const machine_nodes:Machine_Node[] = [];
|
|
451
|
+
fields.forEach((n:any) => {
|
|
452
|
+
let pairs:Machine_Node_Pair[] = [];
|
|
453
|
+
n.data.content.fields.value.fields.value.fields.contents.forEach((p:any) => {
|
|
454
|
+
let forwards:Machine_Forward[] = [];
|
|
455
|
+
p.fields.value.fields.forwards.fields.contents.forEach((f:any) => {
|
|
456
|
+
let forward_name = f.fields.key;
|
|
457
|
+
let forward_weight = f.fields.value.fields.weight;
|
|
458
|
+
let forward_guard = f.fields.value.fields.guard;
|
|
459
|
+
let forward_namedOperator = f.fields.value.fields.namedOperator;
|
|
460
|
+
let forward_permission_index = f.fields.value.fields.permission_index;
|
|
461
|
+
forwards.push({name:forward_name, namedOperator:forward_namedOperator, permission:forward_permission_index,
|
|
462
|
+
weight:forward_weight, guard:forward_guard?forward_guard:''});
|
|
463
|
+
});
|
|
464
|
+
pairs.push({prior_node:p.fields.key, threshold:p.fields.value.fields.threshold, forwards:forwards});
|
|
465
|
+
});
|
|
466
|
+
machine_nodes.push({name:n.data.content.fields.name, pairs:pairs});
|
|
467
|
+
});
|
|
468
|
+
return machine_nodes;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
static namedOperators(nodes:Machine_Node[]) : string[] {
|
|
472
|
+
let ret: string[] = [];
|
|
473
|
+
nodes.forEach((v)=> {
|
|
474
|
+
v.pairs.forEach((i) => {
|
|
475
|
+
i.forwards.forEach((k) => {
|
|
476
|
+
if (k?.namedOperator && !ret.find((x)=>x===k.namedOperator)) {
|
|
477
|
+
ret.push(k.namedOperator);
|
|
478
|
+
}
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
})
|
|
482
|
+
return ret;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
static isValidForward(forward:Machine_Forward) {
|
|
486
|
+
if (!IsValidName(forward.name)) return false
|
|
487
|
+
if (forward?.namedOperator && !IsValidName_AllowEmpty(forward?.namedOperator)) return false;
|
|
488
|
+
if (forward?.permission && !Permission.IsValidPermissionIndex(forward?.permission)) return false;
|
|
489
|
+
if (!forward?.permission && !forward?.namedOperator) return false;
|
|
490
|
+
if (forward?.weight && !IsValidUintLarge(forward.weight)) return false;
|
|
491
|
+
return true
|
|
492
|
+
}
|
|
493
|
+
|
|
349
494
|
static INITIAL_NODE_NAME = '';
|
|
350
|
-
static
|
|
495
|
+
/* static NODE_NAME_RESERVED = 'origin';
|
|
496
|
+
static IsNodeNameReserved = (name:string) => {
|
|
497
|
+
return name.toLowerCase() === Machine.NODE_NAME_RESERVED
|
|
498
|
+
}*/
|
|
499
|
+
static SolveNodeName = (name:string) => {
|
|
500
|
+
return name ? name : '⚪';
|
|
501
|
+
}
|
|
502
|
+
static OPERATOR_ORDER_PAYER = 'OrderPayer';
|
|
351
503
|
}
|