wowok 1.4.32 → 1.5.36
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/guard.ts +84 -21
- package/src/machine.ts +0 -7
- package/src/permission.ts +32 -5
- package/src/protocol.ts +6 -4
- package/src/reward.ts +4 -0
- package/src/treasury.ts +10 -6
- package/src/vote.ts +5 -0
package/package.json
CHANGED
package/src/guard.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType,
|
|
3
|
+
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject, GuardObject} from './protocol';
|
|
4
4
|
import { concatenate, array_equal } from './utils';
|
|
5
5
|
import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase, insertAtHead } from './utils';
|
|
6
6
|
import { ERROR, Errors } from './exception';
|
|
@@ -23,7 +23,22 @@ export interface Guard_Options {
|
|
|
23
23
|
|
|
24
24
|
export class Guard {
|
|
25
25
|
static MAX_INPUT_LENGTH = 10240;
|
|
26
|
-
|
|
26
|
+
protected txb;
|
|
27
|
+
protected object : TxbObject;
|
|
28
|
+
get_object() { return this.object }
|
|
29
|
+
|
|
30
|
+
static From(txb:TransactionBlock, object:TxbObject) : Guard {
|
|
31
|
+
let d = new Guard(txb)
|
|
32
|
+
d.object = Protocol.TXB_OBJECT(txb, object)
|
|
33
|
+
return d
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private constructor(txb:TransactionBlock) {
|
|
37
|
+
this.txb = txb;
|
|
38
|
+
this.object = '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static New(txb:TransactionBlock, description:string, maker:GuardMaker) : Guard {
|
|
27
42
|
if (!maker.IsReady()) {
|
|
28
43
|
ERROR(Errors.InvalidParam, 'launch maker');
|
|
29
44
|
}
|
|
@@ -50,7 +65,8 @@ export class Guard {
|
|
|
50
65
|
let input = new Uint8Array(bcs_input); // copy new uint8array to reserve!
|
|
51
66
|
|
|
52
67
|
// reserve the bytes for guard
|
|
53
|
-
let
|
|
68
|
+
let g = new Guard(txb);
|
|
69
|
+
g.object = txb.moveCall({
|
|
54
70
|
target: Protocol.Instance().GuardFn('new') as FnCallType,
|
|
55
71
|
arguments: [txb.pure.string(description), txb.pure.vector('u8', [].slice.call(input.reverse()))],
|
|
56
72
|
});
|
|
@@ -60,20 +76,23 @@ export class Guard {
|
|
|
60
76
|
const n = new Uint8Array(1); n.set([v.type], 0);
|
|
61
77
|
txb.moveCall({
|
|
62
78
|
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
63
|
-
arguments:[
|
|
79
|
+
arguments:[txb.object(g.object), txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
64
80
|
})
|
|
65
81
|
} else {
|
|
66
82
|
const n = insertAtHead(v.value!, v.type);
|
|
67
83
|
txb.moveCall({
|
|
68
84
|
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
69
|
-
arguments:[
|
|
85
|
+
arguments:[txb.object(g.object), txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
70
86
|
})
|
|
71
87
|
}
|
|
72
88
|
});
|
|
73
|
-
|
|
74
|
-
|
|
89
|
+
return g
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
launch() : GuardAddress {
|
|
93
|
+
return this.txb.moveCall({
|
|
75
94
|
target:Protocol.Instance().GuardFn("create") as FnCallType,
|
|
76
|
-
arguments:[
|
|
95
|
+
arguments:[this.txb.object(this.object)]
|
|
77
96
|
});
|
|
78
97
|
}
|
|
79
98
|
|
|
@@ -124,7 +143,7 @@ export class Guard {
|
|
|
124
143
|
[MODULES.repository, 'Address Vector Data', 119, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_ADDRESS, 'Data for a field at an address and get address vector type data.', ['address', 'the field name']],
|
|
125
144
|
[MODULES.repository, 'Bool Vector Data', 120, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_BOOL, 'Data for a field at an address and get bool vector type data.', ['address', 'the field name']],
|
|
126
145
|
|
|
127
|
-
[MODULES.entity, '
|
|
146
|
+
[MODULES.entity, 'Has Entity', 200, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an entity already registered?', ['address']],
|
|
128
147
|
[MODULES.entity, 'Likes', 201, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of likes for an address by other addresses.', ['address']],
|
|
129
148
|
[MODULES.entity, 'Dislikes', 202, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of dislikes for an address by other addresses.', ['address']],
|
|
130
149
|
[MODULES.entity, 'Entity Info', 203, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8, 'Public information about an entity.', ['address']],
|
|
@@ -162,6 +181,8 @@ export class Guard {
|
|
|
162
181
|
[MODULES.service, 'Has Required Info', 416, [], ValueType.TYPE_BOOL, 'Whether the necessary information that needs to be provided by the customer is set?', []],
|
|
163
182
|
[MODULES.service, 'Required Info of Service-Pubkey', 417, [], ValueType.TYPE_STRING, 'The public key used to encrypt customer information, and only the service provider can decrypt and view customer information.', []],
|
|
164
183
|
[MODULES.service, 'Required Info', 418, [], ValueType.TYPE_VEC_STRING, 'Names of the required information item that needs to be provided by the customer.', []],
|
|
184
|
+
[MODULES.service, 'Number of Treasuries', 419, [], ValueType.TYPE_U64, 'The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives.', []],
|
|
185
|
+
[MODULES.service, 'Contains Treasury', 420, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?', ['treasury address']],
|
|
165
186
|
|
|
166
187
|
[MODULES.order, 'Amount', 500, [], ValueType.TYPE_U64, 'Order amount.', []],
|
|
167
188
|
[MODULES.order, 'Payer', 501, [], ValueType.TYPE_ADDRESS, 'Order payer.', []],
|
|
@@ -216,13 +237,13 @@ export class Guard {
|
|
|
216
237
|
[MODULES.progress, 'Parent Next Node', 814, [], ValueType.TYPE_STRING, 'The child process is started at the next node stage of the parent process.', []],
|
|
217
238
|
[MODULES.progress, 'Parent Forward', 815, [], ValueType.TYPE_STRING, 'The child process is started in the Forward phase of the next node of the parent process.', []],
|
|
218
239
|
[MODULES.progress, 'Parent Node', 816, [], ValueType.TYPE_STRING, 'The node name of the parent process where the child process is located.', []],
|
|
219
|
-
[MODULES.progress, 'Forward Accomplished', 817, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has
|
|
240
|
+
[MODULES.progress, 'Forward Accomplished', 817, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has the forward been accomplished?', ['session-id', 'next node name', 'forward name']],
|
|
220
241
|
[MODULES.progress, 'Forward Operator', 818, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward operator.', ['session-id', 'next node name', 'forward name']],
|
|
221
242
|
[MODULES.progress, 'Forward Sub-progress', 819, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward child process address(if set).', ['session-id', 'next node name', 'forward name']],
|
|
222
243
|
[MODULES.progress, 'Forward Deliverables', 820, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward deliverable(if set).', ['session-id', 'next node name', 'forward name']],
|
|
223
244
|
[MODULES.progress, 'Forward time', 821, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time when the forward was last triggered.', ['session-id', 'next node name', 'forward name']],
|
|
224
245
|
[MODULES.progress, 'Closest Session Time', 822, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time a node that closest time to the current node completes its session.', ['node name']],
|
|
225
|
-
[MODULES.progress, 'Closest Forward Accomplished', 823, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has
|
|
246
|
+
[MODULES.progress, 'Closest Forward Accomplished', 823, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has the forward been accomplished?', ['node name', 'next node name', 'forward name']],
|
|
226
247
|
[MODULES.progress, 'Closest Forward Operator', 824, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The operator of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
|
|
227
248
|
[MODULES.progress, 'Closest Forward Sub-progress', 825, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The child process address(if set) of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
|
|
228
249
|
[MODULES.progress, 'Closest Forward Deliverables', 826, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The deliverable(if set) of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
|
|
@@ -298,14 +319,54 @@ export class Guard {
|
|
|
298
319
|
[MODULES.treasury, 'Number of Flow Records', 1402, [], ValueType.TYPE_U64, 'Number of treasury transactions.', []],
|
|
299
320
|
[MODULES.treasury, 'Inflow Amount', 1403, [], ValueType.TYPE_U128, 'Treasury inflow amount.', []],
|
|
300
321
|
[MODULES.treasury, 'Outflow Amount', 1404, [], ValueType.TYPE_U128, 'Treasury outflow amount.', []],
|
|
301
|
-
[MODULES.treasury, 'Has
|
|
302
|
-
[MODULES.treasury, '
|
|
303
|
-
[MODULES.treasury, '
|
|
304
|
-
[MODULES.treasury, '
|
|
305
|
-
[MODULES.treasury, '
|
|
306
|
-
[MODULES.treasury, '
|
|
307
|
-
[MODULES.treasury, '
|
|
308
|
-
[MODULES.treasury, '
|
|
322
|
+
[MODULES.treasury, 'Has Deposit Guard', 1405, [], ValueType.TYPE_BOOL, 'Whether the deposit Guard set?', []],
|
|
323
|
+
[MODULES.treasury, 'Deposit Guard', 1406, [], ValueType.TYPE_ADDRESS, 'Deposit Guard address.', []],
|
|
324
|
+
[MODULES.treasury, 'Number of Withdraw Guards', 1407, [], ValueType.TYPE_U64, 'Number of withdraw guards.', []],
|
|
325
|
+
[MODULES.treasury, 'Has Withdraw Guard', 1408, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has a Withdraw Guard added?', ['guard address']],
|
|
326
|
+
[MODULES.treasury, 'Withdrawal Amount with Guard', 1409, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'withdrawal amount corresponding the Guard.', ['guard address']],
|
|
327
|
+
[MODULES.treasury, 'Recent Time with Operation', 1410, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'Time of the most recent fund operation.', ['operation']],
|
|
328
|
+
[MODULES.treasury, 'Recent Signer with Operation', 1411, [ValueType.TYPE_U8], ValueType.TYPE_ADDRESS, 'Signer address of the most recent fund operation.', ['operation']],
|
|
329
|
+
[MODULES.treasury, 'Recent Payment with Operation', 1412, [ValueType.TYPE_U8], ValueType.TYPE_ADDRESS, 'Payment address of the most recent fund operation.', ['operation']],
|
|
330
|
+
[MODULES.treasury, 'Recent Amount with Operation', 1413, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'Amount of the most recent fund operation.', ['operation']],
|
|
331
|
+
[MODULES.treasury, 'Recent Time with Op/Pmt', 1414, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation with payment specified.', ['operation', 'payment address']],
|
|
332
|
+
[MODULES.treasury, 'Recent Signer with Op&Pmt', 1415, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Signer of the most recent fund operationwith payment specified.', ['operation', 'payment address']],
|
|
333
|
+
[MODULES.treasury, 'Recent Amount with Op/Pmt', 1416, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation with payment specified.', ['operation', 'payment address']],
|
|
334
|
+
[MODULES.treasury, 'Recent Time with Op/Sgr', 1417, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation with signer specified.', ['operation', 'signer address']],
|
|
335
|
+
[MODULES.treasury, 'Recent Payment with Op/Sgr', 1418, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Payment of the most recent fund operation with singner specified.', ['operation', 'signer address']],
|
|
336
|
+
[MODULES.treasury, 'Recent Amount with Op/Sgr', 1419, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation with singer specified.', ['operation', 'signer address']],
|
|
337
|
+
[MODULES.treasury, 'Recent Time with Op/Pmt/Sgr', 1420, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation.', ['operation', 'payment address', 'singer address']],
|
|
338
|
+
[MODULES.treasury, 'Recent Amount with Op/Pmt/Sgr', 1421, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation.', ['operation', 'payment address', 'singer address']],
|
|
339
|
+
[MODULES.treasury, 'Has Operation', 1422, [ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Whether there was a fund operation?', ['operation']],
|
|
340
|
+
[MODULES.treasury, 'Has Operation with Pmt', 1423, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation with payment specified?', ['operation', 'payment address']],
|
|
341
|
+
[MODULES.treasury, 'Has Operation with Sgr', 1424, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation with singer specified?', ['operation', 'singer address']],
|
|
342
|
+
[MODULES.treasury, 'Has Operation with Pmt/Sgr', 1425, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation?', ['operation', 'payment address', 'singer address']],
|
|
343
|
+
[MODULES.treasury, 'Operation at Least Times', 1426, [ValueType.TYPE_U8, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times?', ['operation', 'at least times']],
|
|
344
|
+
[MODULES.treasury, 'Operation at Least Times by a Signer', 1427, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times by a signer?', ['operation', 'signer address', 'at least times']],
|
|
345
|
+
|
|
346
|
+
[MODULES.arbitration, 'Permission', 1500, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
|
|
347
|
+
[MODULES.arbitration, 'Published', 1501, [], ValueType.TYPE_BOOL, "Is it allowed to create Arb?", []],
|
|
348
|
+
[MODULES.arbitration, 'Fee', 1502, [], ValueType.TYPE_U64, 'Cost of arbitration.', []],
|
|
349
|
+
[MODULES.arbitration, 'Has Endpoint', 1503, [], ValueType.TYPE_BOOL, 'Is the endpoint set?', []],
|
|
350
|
+
[MODULES.arbitration, 'Endpoint', 1504, [], ValueType.TYPE_STRING, 'Endpoint url/ipfs.', []],
|
|
351
|
+
[MODULES.arbitration, 'Has Guard', 1505, [], ValueType.TYPE_BOOL, 'Is there Guard set to apply for arbitration?', []],
|
|
352
|
+
[MODULES.arbitration, 'Guard', 1506, [], ValueType.TYPE_ADDRESS, 'Guard to apply for arbitration.', []],
|
|
353
|
+
[MODULES.arbitration, 'Number of Voting Guard', 1507, [], ValueType.TYPE_U64, 'Number of voting guards.', []],
|
|
354
|
+
[MODULES.arbitration, 'Has Voting Guard', 1508, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has the voting Guard added?', ['guard address']],
|
|
355
|
+
[MODULES.arbitration, 'Voting Weight', 1509, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Voting weight of the voting Guard.', ['guard address']],
|
|
356
|
+
|
|
357
|
+
[MODULES.arb, 'Order', 1600, [], ValueType.TYPE_ADDRESS, 'Order under arbitration.', []],
|
|
358
|
+
[MODULES.arb, 'Arbitration', 1601, [], ValueType.TYPE_ADDRESS, "Arbitration object address.", []],
|
|
359
|
+
[MODULES.arb, 'Feedback', 1602, [], ValueType.TYPE_STRING, 'Arbitration feedback.', []],
|
|
360
|
+
[MODULES.arb, 'Has Compensation', 1603, [], ValueType.TYPE_BOOL, 'Whether there is an arbitration result?', []],
|
|
361
|
+
[MODULES.arb, 'Compensation', 1604, [], ValueType.TYPE_U64, 'Compensation should be given to the order payer.', []],
|
|
362
|
+
[MODULES.arb, 'Unclaimed Arbitration Costs', 1605, [], ValueType.TYPE_U64, 'Unclaimed arbitration costs.', []],
|
|
363
|
+
[MODULES.arb, 'Turnout', 1606, [], ValueType.TYPE_U64, 'The number of addresses have voted.', []],
|
|
364
|
+
[MODULES.arb, 'Has voted', 1607, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has someone voted?', ['voter address']],
|
|
365
|
+
[MODULES.arb, 'Voting weight', 1608, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The weight of a complete vote for the address.', ['voter address']],
|
|
366
|
+
[MODULES.arb, 'Voting Time', 1609, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The time of a complete vote for the address.', ['voter address']],
|
|
367
|
+
[MODULES.arb, 'Voting Option', 1610, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does an address complete voting for the option?', ['voter address', 'option index']],
|
|
368
|
+
[MODULES.arb, 'Number of Options', 1611, [], ValueType.TYPE_U64, 'Number of voting options.', []],
|
|
369
|
+
[MODULES.arb, 'Number of Votes', 1612, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'The number of votes received for an option.', ['option index']],
|
|
309
370
|
];
|
|
310
371
|
|
|
311
372
|
static BoolCmd = Guard.QUERIES.filter(q => q[4] === ValueType.TYPE_BOOL);
|
|
@@ -490,7 +551,9 @@ export class GuardMaker {
|
|
|
490
551
|
|
|
491
552
|
// object_address_from: string for static address; number as identifier inconstant
|
|
492
553
|
add_query(module:MODULES, query_name:string, object_address_from:string | number) : GuardMaker {
|
|
493
|
-
let query_index = Guard.QUERIES.findIndex((q) => {
|
|
554
|
+
let query_index = Guard.QUERIES.findIndex((q) => {
|
|
555
|
+
return q[0] == module && q[1] == query_name
|
|
556
|
+
})
|
|
494
557
|
if (query_index == -1) {
|
|
495
558
|
ERROR(Errors.InvalidParam, 'query_name:'+query_name);
|
|
496
559
|
}
|
|
@@ -507,7 +570,7 @@ export class GuardMaker {
|
|
|
507
570
|
|
|
508
571
|
let offset = this.type_validator.length - Guard.QUERIES[query_index][3].length;
|
|
509
572
|
if (offset < 0) {
|
|
510
|
-
ERROR(Errors.InvalidParam, '
|
|
573
|
+
ERROR(Errors.InvalidParam, 'offset:'+query_name);
|
|
511
574
|
}
|
|
512
575
|
|
|
513
576
|
let types = this.type_validator.slice(offset);
|
package/src/machine.ts
CHANGED
|
@@ -543,12 +543,5 @@ export class Machine {
|
|
|
543
543
|
})
|
|
544
544
|
}
|
|
545
545
|
static INITIAL_NODE_NAME = '';
|
|
546
|
-
/* static NODE_NAME_RESERVED = 'origin';
|
|
547
|
-
static IsNodeNameReserved = (name:string) => {
|
|
548
|
-
return name.toLowerCase() === Machine.NODE_NAME_RESERVED
|
|
549
|
-
}*/
|
|
550
|
-
static SolveNodeName = (name:string) => {
|
|
551
|
-
return name ? name : '⚪';
|
|
552
|
-
}
|
|
553
546
|
static OPERATOR_ORDER_PAYER = 'OrderPayer';
|
|
554
547
|
}
|
package/src/permission.ts
CHANGED
|
@@ -45,6 +45,7 @@ export enum PermissionIndex {
|
|
|
45
45
|
service_customer_required = 222,
|
|
46
46
|
//service_change_order_required_pubkey = 224,
|
|
47
47
|
service_pause = 225,
|
|
48
|
+
service_treasury = 226,
|
|
48
49
|
|
|
49
50
|
reward = 240,
|
|
50
51
|
reward_refund = 241,
|
|
@@ -87,6 +88,17 @@ export enum PermissionIndex {
|
|
|
87
88
|
treasury_withdraw_mode = 706,
|
|
88
89
|
treasury_withdraw_guard = 707,
|
|
89
90
|
|
|
91
|
+
arbitration = 800,
|
|
92
|
+
arbitration_description = 801,
|
|
93
|
+
arbitration_fee = 802,
|
|
94
|
+
arbitration_voting_guard = 803,
|
|
95
|
+
arbitration_endpoint = 804,
|
|
96
|
+
arbitration_guard = 805,
|
|
97
|
+
arbitration_publish = 806,
|
|
98
|
+
arbitration_vote = 807,
|
|
99
|
+
arbitration_arbitration = 808,
|
|
100
|
+
arbitration_withdraw = 809,
|
|
101
|
+
|
|
90
102
|
user_defined_start = 1000,
|
|
91
103
|
}
|
|
92
104
|
|
|
@@ -147,11 +159,12 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
147
159
|
{index:PermissionIndex.service_buyer_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service'},
|
|
148
160
|
{index:PermissionIndex.service_machine, name:'Machine', description:'Set Machine for Service', module: 'service'},
|
|
149
161
|
{index:PermissionIndex.service_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service'},
|
|
150
|
-
{index:PermissionIndex.service_publish, name:'Publish', description:'
|
|
162
|
+
{index:PermissionIndex.service_publish, name:'Publish', description:'Allowing the creation of Order', module: 'service'},
|
|
151
163
|
{index:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service'},
|
|
152
164
|
{index:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service'},
|
|
153
165
|
//{index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'Update Serivce order pubkey', module: 'service'},
|
|
154
166
|
{index:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service'},
|
|
167
|
+
{index:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service'},
|
|
155
168
|
|
|
156
169
|
{index:PermissionIndex.reward, name:'reward', description:'Launch new reward', module: 'reward'},
|
|
157
170
|
{index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from reward', module: 'reward'},
|
|
@@ -176,7 +189,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
176
189
|
{index:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine'},
|
|
177
190
|
{index:PermissionIndex.machine_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine'},
|
|
178
191
|
{index:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine'},
|
|
179
|
-
{index:PermissionIndex.machine_publish, name: 'Publish', description:'
|
|
192
|
+
{index:PermissionIndex.machine_publish, name: 'Publish', description:'Allowing the creation of Progress', module: 'machine'},
|
|
180
193
|
|
|
181
194
|
{index:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress'},
|
|
182
195
|
{index:PermissionIndex.progress_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress'},
|
|
@@ -192,6 +205,18 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
192
205
|
{index:PermissionIndex.treasury_withdraw_guard, name: 'Withdraw Guard', description:'Add/Remove Treasury withdraw guard', module: 'treasury'},
|
|
193
206
|
{index:PermissionIndex.treasury_withdraw_mode, name: 'Withdraw mode', description:'Set Treasury withdraw mode', module: 'treasury'},
|
|
194
207
|
{index:PermissionIndex.treasury_deposit_guard, name: 'Deposit Guard', description:'Set Treasury deposit guard', module: 'treasury'},
|
|
208
|
+
{index:PermissionIndex.treasury_descritption, name: 'Description', description:'Set Treasury description', module: 'treasury'},
|
|
209
|
+
|
|
210
|
+
{index:PermissionIndex.arbitration, name: 'Arbitration', description:'Launch new Arbitration', module: 'arbitration'},
|
|
211
|
+
{index:PermissionIndex.arbitration_description, name: 'Description', description:'Set Arbitration description', module: 'arbitration'},
|
|
212
|
+
{index:PermissionIndex.arbitration_endpoint, name: 'Endpoint', description:'Set Arbitration endpoint', module: 'arbitration'},
|
|
213
|
+
{index:PermissionIndex.arbitration_fee, name: 'Fee', description:'Set Arbitration fee', module: 'arbitration'},
|
|
214
|
+
{index:PermissionIndex.arbitration_guard, name: 'Guard', description:'Set Guard to apply for arbitration', module: 'arbitration'},
|
|
215
|
+
{index:PermissionIndex.arbitration_arbitration, name: 'Arbitrate', description:'Determine the outcome of arbitration', module: 'arbitration'},
|
|
216
|
+
{index:PermissionIndex.arbitration_publish, name: 'Publish', description:'Allowing the creation of Arb', module: 'arbitration'},
|
|
217
|
+
{index:PermissionIndex.arbitration_voting_guard, name: 'Voting Guard', description:'Add/Remove voting Guard', module: 'arbitration'},
|
|
218
|
+
{index:PermissionIndex.arbitration_vote, name: 'Vote', description:'Vote on the application for arbitration', module: 'arbitration'},
|
|
219
|
+
{index:PermissionIndex.arbitration_withdraw, name: 'Withdraw', description:'Withdraw the arbitration fee', module: 'arbitration'},
|
|
195
220
|
]
|
|
196
221
|
|
|
197
222
|
export type PermissionIndexType = PermissionIndex | number;
|
|
@@ -548,12 +573,14 @@ export class Permission {
|
|
|
548
573
|
let i = answer.items?.find((v)=>v.query == index); // index maybe string, so ==
|
|
549
574
|
if (i) {
|
|
550
575
|
return {has:i.permission, guard:i.guard, owner:answer.owner};
|
|
551
|
-
}
|
|
576
|
+
} else {
|
|
577
|
+
return {has:false, guard:undefined, owner:answer?.owner}
|
|
578
|
+
}
|
|
552
579
|
}
|
|
553
580
|
if (bStrict) {
|
|
554
|
-
return {has:false, guard:undefined, owner:
|
|
581
|
+
return {has:false, guard:undefined, owner:false}
|
|
555
582
|
}
|
|
556
|
-
return undefined
|
|
583
|
+
return undefined // basic: !== false ; otherwise: !
|
|
557
584
|
}
|
|
558
585
|
|
|
559
586
|
static MAX_ADMIN_COUNT = 64;
|
package/src/protocol.ts
CHANGED
|
@@ -24,6 +24,8 @@ export enum MODULES {
|
|
|
24
24
|
wowok = 'wowok',
|
|
25
25
|
treasury = 'treasury',
|
|
26
26
|
payment = 'payment',
|
|
27
|
+
arbitration = 'arbitration',
|
|
28
|
+
arb = 'arb',
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export type PermissionAddress = TransactionResult;
|
|
@@ -213,11 +215,11 @@ const TESTNET = {
|
|
|
213
215
|
}
|
|
214
216
|
*/
|
|
215
217
|
const TESTNET = {
|
|
216
|
-
wowok: "
|
|
217
|
-
wowok_origin:'
|
|
218
|
+
wowok: "0xd8909c47713ee1199f41caaccff1a822cd82512e0ec4f9e7af04e71d3db6cb4b",
|
|
219
|
+
wowok_origin:'0xd8909c47713ee1199f41caaccff1a822cd82512e0ec4f9e7af04e71d3db6cb4b' ,
|
|
218
220
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
219
|
-
wowok_object: '
|
|
220
|
-
entity_object: '
|
|
221
|
+
wowok_object: '0xb1105b665e0bc583cb91e80c7ea17cb35f5f145ccda25145328db1c1b984ea1a',
|
|
222
|
+
entity_object: '0x9d5a8823ccdbc369097d74672d25ac2045bce9bfb993858441513469469a44d0',
|
|
221
223
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
222
224
|
}
|
|
223
225
|
const MAINNET = {
|
package/src/reward.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/*****************
|
|
2
|
+
* depreacted
|
|
3
|
+
******************/
|
|
4
|
+
|
|
1
5
|
import { TransactionArgument, Transaction as TransactionBlock, type TransactionResult, } from '@mysten/sui/transactions';
|
|
2
6
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, RewardAddress, Protocol, TxbObject, } from './protocol';
|
|
3
7
|
import { array_unique, IsValidAddress, IsValidArgType, IsValidArray, IsValidDesription, IsValidU64, parseObjectType} from './utils';
|
package/src/treasury.ts
CHANGED
|
@@ -136,7 +136,8 @@ export class Treasury {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
// return payment address
|
|
140
|
+
deposit(param:DepositParam, passport?:PassportObject) :TransactionResult {
|
|
140
141
|
if (!Protocol.IsValidObjects([param.coin])) {
|
|
141
142
|
ERROR(Errors.IsValidObjects, 'deposit.param.coin')
|
|
142
143
|
}
|
|
@@ -191,7 +192,8 @@ export class Treasury {
|
|
|
191
192
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
// return current balance
|
|
196
|
+
receive(payment:PaymentObject, received:ReceivedObject, passport?:PassportObject) : TransactionResult {
|
|
195
197
|
if (!Protocol.IsValidObjects([payment, received])) {
|
|
196
198
|
ERROR(Errors.IsValidArray, 'receive.payment&received');
|
|
197
199
|
}
|
|
@@ -213,7 +215,8 @@ export class Treasury {
|
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
|
|
216
|
-
|
|
218
|
+
// return payment address
|
|
219
|
+
withdraw(param:WithdrawParam, passport?:PassportObject) : TransactionResult | undefined {
|
|
217
220
|
if (param.items.length === 0) return undefined;
|
|
218
221
|
if (!IsValidArray(param.items, (item:WithdrawItem) => IsValidU64(item.amount) && IsValidAddress(item.address))) {
|
|
219
222
|
ERROR(Errors.IsValidArray, 'withdraw.param.items')
|
|
@@ -421,9 +424,10 @@ export class Treasury {
|
|
|
421
424
|
return parseObjectType(chain_type, 'treasury::Treasury<')
|
|
422
425
|
}
|
|
423
426
|
|
|
424
|
-
static OP_WITHDRAW =
|
|
425
|
-
static OP_DEPOSIT =
|
|
426
|
-
static OP_RECEIVE =
|
|
427
|
+
static OP_WITHDRAW = 1;
|
|
428
|
+
static OP_DEPOSIT = 2;
|
|
429
|
+
static OP_RECEIVE = 4;
|
|
430
|
+
|
|
427
431
|
static MAX_WITHDRAW_GUARD_COUNT = 16;
|
|
428
432
|
}
|
|
429
433
|
|
package/src/vote.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
/*****************
|
|
3
|
+
* depreacted
|
|
4
|
+
******************/
|
|
5
|
+
|
|
1
6
|
import { FnCallType, PassportObject, PermissionObject, GuardObject, VoteAddress, Protocol, TxbObject} from './protocol';
|
|
2
7
|
import { IsValidDesription, IsValidAddress, Bcs, array_unique, IsValidArray, IsValidName, IsValidU64, IsValidU256, IsValidU8 } from './utils';
|
|
3
8
|
import { ERROR, Errors } from './exception';
|