wowok 1.5.40 → 1.5.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/demand.ts +2 -11
- package/src/guard.ts +43 -34
- package/src/machine.ts +0 -7
- package/src/passport.ts +22 -30
- package/src/permission.ts +4 -7
- package/src/progress.ts +0 -8
- package/src/protocol.ts +20 -19
- package/src/repository.ts +0 -8
- package/src/service.ts +86 -15
- package/src/treasury.ts +0 -8
package/package.json
CHANGED
package/src/demand.ts
CHANGED
|
@@ -67,14 +67,6 @@ export class Demand {
|
|
|
67
67
|
})
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
destroy() {
|
|
71
|
-
this.txb.moveCall({
|
|
72
|
-
target:Protocol.Instance().DemandFn('destroy') as FnCallType,
|
|
73
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
74
|
-
typeArguments:[this.bounty_type]
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
refund(passport?:PassportObject) {
|
|
79
71
|
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
80
72
|
if (passport) {
|
|
@@ -98,19 +90,18 @@ export class Demand {
|
|
|
98
90
|
if (!IsValidU64(time)) {
|
|
99
91
|
ERROR(Errors.IsValidUint, 'time');
|
|
100
92
|
}
|
|
101
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
102
93
|
if (passport) {
|
|
103
94
|
this.txb.moveCall({
|
|
104
95
|
target:Protocol.Instance().DemandFn('time_expand_with_passport') as FnCallType,
|
|
105
96
|
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
106
|
-
this.txb.pure.u64(time),
|
|
97
|
+
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
107
98
|
typeArguments:[this.bounty_type],
|
|
108
99
|
})
|
|
109
100
|
} else {
|
|
110
101
|
this.txb.moveCall({
|
|
111
102
|
target:Protocol.Instance().DemandFn('time_expand') as FnCallType,
|
|
112
103
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
113
|
-
this.txb.pure.u64(time),
|
|
104
|
+
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
114
105
|
typeArguments:[this.bounty_type],
|
|
115
106
|
})
|
|
116
107
|
}
|
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, TxbObject, GuardObject} from './protocol';
|
|
3
|
+
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject, GuardObject, IsValidOperatorType} from './protocol';
|
|
4
4
|
import { concatenate, array_equal, ValueTypeConvert } from './utils';
|
|
5
5
|
import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase, insertAtHead } from './utils';
|
|
6
6
|
import { ERROR, Errors } from './exception';
|
|
@@ -23,6 +23,8 @@ export interface Guard_Options {
|
|
|
23
23
|
|
|
24
24
|
export class Guard {
|
|
25
25
|
static MAX_INPUT_LENGTH = 10240;
|
|
26
|
+
// static MAX_PAYLOADS_LENGTH = 4096;
|
|
27
|
+
|
|
26
28
|
protected txb;
|
|
27
29
|
protected object : TxbObject;
|
|
28
30
|
get_object() { return this.object }
|
|
@@ -96,13 +98,6 @@ export class Guard {
|
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
static signer_guard(txb: TransactionBlock) : GuardAddress {
|
|
100
|
-
return txb.moveCall({
|
|
101
|
-
target: Protocol.Instance().GuardFn('signer_guard') as FnCallType,
|
|
102
|
-
arguments: []
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
101
|
static everyone_guard(txb:TransactionBlock) : GuardAddress {
|
|
107
102
|
return txb.moveCall({
|
|
108
103
|
target: Protocol.Instance().GuardFn('everyone_guard') as FnCallType,
|
|
@@ -151,7 +146,6 @@ export class Guard {
|
|
|
151
146
|
[MODULES.entity, 'Entity Resource', 205, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'The address of a resource object created by an entity.', ['address']],
|
|
152
147
|
|
|
153
148
|
[MODULES.demand, 'Permission', 300, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
|
|
154
|
-
[MODULES.demand, 'Has Deadline', 301, [], ValueType.TYPE_BOOL, 'Whether to set the expiration time of presenting?', []],
|
|
155
149
|
[MODULES.demand, 'Deadline', 302, [], ValueType.TYPE_U64, 'The expiration time of presenting.', []],
|
|
156
150
|
[MODULES.demand, 'Bounty Count', 303, [], ValueType.TYPE_U64, 'Number of Bounties.', []],
|
|
157
151
|
[MODULES.demand, 'Has Guard', 304, [], ValueType.TYPE_BOOL, 'Whether the present guard is set?', []],
|
|
@@ -183,6 +177,8 @@ export class Guard {
|
|
|
183
177
|
[MODULES.service, 'Required Info', 418, [], ValueType.TYPE_VEC_STRING, 'Names of the required information item that needs to be provided by the customer.', []],
|
|
184
178
|
[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
179
|
[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']],
|
|
180
|
+
[MODULES.service, 'Number of Arbitrations', 421, [], ValueType.TYPE_U64, 'The number of arbitrations that allows a refund to be made from the order at any time based on the arbitration result.', []],
|
|
181
|
+
[MODULES.service, 'Contains Arbitration', 422, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Does it contain an arbitration that allows a refund to be made from the order at any time based on the arbitration result.?', ['arbitration address']],
|
|
186
182
|
|
|
187
183
|
[MODULES.order, 'Amount', 500, [], ValueType.TYPE_U64, 'Order amount.', []],
|
|
188
184
|
[MODULES.order, 'Payer', 501, [], ValueType.TYPE_ADDRESS, 'Order payer.', []],
|
|
@@ -193,8 +189,8 @@ export class Guard {
|
|
|
193
189
|
[MODULES.order, 'Discount Used', 506, [], ValueType.TYPE_BOOL, 'Discount coupon used for this order?', []],
|
|
194
190
|
[MODULES.order, 'Discount', 507, [], ValueType.TYPE_ADDRESS, 'Discount address that already used.', []],
|
|
195
191
|
[MODULES.order, 'Balance', 508, [], ValueType.TYPE_U64, 'The amount currently in the order.', []],
|
|
196
|
-
[MODULES.order, 'Refunded', 509, [], ValueType.TYPE_BOOL, 'Whether a refund has occurred?', []],
|
|
197
|
-
[MODULES.order, 'Withdrawed', 510, [], ValueType.TYPE_BOOL, 'Whether a service provider withdrawal has occurred?', []],
|
|
192
|
+
// [MODULES.order, 'Refunded', 509, [], ValueType.TYPE_BOOL, 'Whether a refund has occurred?', []],
|
|
193
|
+
// [MODULES.order, 'Withdrawed', 510, [], ValueType.TYPE_BOOL, 'Whether a service provider withdrawal has occurred?', []],
|
|
198
194
|
[MODULES.order, 'Number of Agents', 511, [], ValueType.TYPE_U64, 'The number of agents for the order.', []],
|
|
199
195
|
[MODULES.order, 'Has Agent', 512, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address is an order agent?', ['agent address']],
|
|
200
196
|
[MODULES.order, 'Number of Disputes', 513, [], ValueType.TYPE_U64, 'Number of arbitrations for the order.', []],
|
|
@@ -591,7 +587,7 @@ export class GuardMaker {
|
|
|
591
587
|
var e:any = LogicsInfo.find((v:any) => v[0] === type);
|
|
592
588
|
if (e) { e=e[1] }
|
|
593
589
|
|
|
594
|
-
let splice_len = 2;
|
|
590
|
+
let splice_len = 2; let cur:any;
|
|
595
591
|
let ret = ValueType.TYPE_BOOL;
|
|
596
592
|
switch (type) {
|
|
597
593
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
@@ -599,26 +595,28 @@ export class GuardMaker {
|
|
|
599
595
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
600
596
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
|
|
601
597
|
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
if (
|
|
598
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
599
|
+
splice_len = logic_count!;
|
|
600
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
601
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
602
|
+
if (!GuardMaker.match_u256(this.type_validator[this.type_validator.length - i])) { ERROR(Errors.Fail, 'type_validator check:'+e) }
|
|
603
|
+
}
|
|
605
604
|
break;
|
|
606
605
|
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
} else {
|
|
614
|
-
ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
606
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
607
|
+
splice_len = logic_count!;
|
|
608
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
609
|
+
cur = this.type_validator[this.type_validator.length - 1];
|
|
610
|
+
for (let i = 2; i <= splice_len; ++i) {
|
|
611
|
+
if (this.type_validator[this.type_validator.length - i] !== cur) ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
615
612
|
}
|
|
616
613
|
break;
|
|
617
614
|
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
618
|
-
if (
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
615
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
616
|
+
splice_len = logic_count!;
|
|
617
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
618
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
619
|
+
if (this.type_validator[this.type_validator.length - i] !== ValueType.TYPE_STRING) ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
622
620
|
}
|
|
623
621
|
break;
|
|
624
622
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
@@ -642,9 +640,12 @@ export class GuardMaker {
|
|
|
642
640
|
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
643
641
|
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
644
642
|
case OperatorType.TYPE_NUMBER_MOD:
|
|
643
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
644
|
+
splice_len = logic_count!;
|
|
645
645
|
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
646
|
-
|
|
647
|
-
|
|
646
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
647
|
+
if(!GuardMaker.match_u256(this.type_validator[this.type_validator.length -1])) { ERROR(Errors.Fail, 'type_validator check:'+e) }
|
|
648
|
+
}
|
|
648
649
|
ret = ValueType.TYPE_U256;
|
|
649
650
|
break;
|
|
650
651
|
default:
|
|
@@ -652,7 +653,7 @@ export class GuardMaker {
|
|
|
652
653
|
}
|
|
653
654
|
|
|
654
655
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type)); // TYPE
|
|
655
|
-
if (
|
|
656
|
+
if (GuardMaker.is_multi_input_op(type)) {
|
|
656
657
|
this.data.push((Bcs.getInstance().ser(ValueType.TYPE_U8, logic_count))); //@ logics
|
|
657
658
|
}
|
|
658
659
|
this.type_validator.splice(this.type_validator.length - splice_len); // delete type stack
|
|
@@ -660,10 +661,6 @@ export class GuardMaker {
|
|
|
660
661
|
return this;
|
|
661
662
|
}
|
|
662
663
|
|
|
663
|
-
static IsNumberType(type:Data_Type) : boolean {
|
|
664
|
-
return (type === ValueType.TYPE_U8 || type === ValueType.TYPE_U64 || type === ValueType.TYPE_U128 || type === ValueType.TYPE_U256)
|
|
665
|
-
}
|
|
666
|
-
|
|
667
664
|
hasIdentifier(id:number) : boolean {
|
|
668
665
|
return this.constant.has(id)
|
|
669
666
|
}
|
|
@@ -720,6 +717,18 @@ export class GuardMaker {
|
|
|
720
717
|
static match_u256(type:number) : boolean {
|
|
721
718
|
return (type == ValueType.TYPE_U8 || type == ValueType.TYPE_U64 || type == ValueType.TYPE_U128 || type == ValueType.TYPE_U256);
|
|
722
719
|
}
|
|
720
|
+
static is_multi_input_op(type:number) : boolean {
|
|
721
|
+
return (type === OperatorType.TYPE_LOGIC_AS_U256_GREATER ||
|
|
722
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL ||
|
|
723
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER ||
|
|
724
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER ||
|
|
725
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL ||
|
|
726
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_EQUAL ||
|
|
727
|
+
type === OperatorType.TYPE_LOGIC_EQUAL ||
|
|
728
|
+
type === OperatorType.TYPE_LOGIC_HAS_SUBSTRING ||
|
|
729
|
+
type === OperatorType.TYPE_LOGIC_AND ||
|
|
730
|
+
type === OperatorType.TYPE_LOGIC_OR)
|
|
731
|
+
}
|
|
723
732
|
}
|
|
724
733
|
|
|
725
734
|
|
package/src/machine.ts
CHANGED
|
@@ -238,13 +238,6 @@ export class Machine {
|
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
destroy() {
|
|
243
|
-
this.txb.moveCall({
|
|
244
|
-
target:Protocol.Instance().MachineFn('destroy') as FnCallType,
|
|
245
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
241
|
|
|
249
242
|
launch() : MachineAddress {
|
|
250
243
|
return this.txb.moveCall({
|
package/src/passport.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { FnCallType, GuardObject, Protocol, ContextType, OperatorType, Data_Type
|
|
|
4
4
|
ValueType, SER_VALUE, IsValidOperatorType } from './protocol';
|
|
5
5
|
import { parse_object_type, array_unique, Bcs, ulebDecode, IsValidAddress, IsValidArray, insertAtHead, readOption, readOptionString } from './utils';
|
|
6
6
|
import { ERROR, Errors } from './exception';
|
|
7
|
-
import { Guard } from './guard';
|
|
7
|
+
import { Guard, GuardMaker } from './guard';
|
|
8
8
|
|
|
9
9
|
export type Guard_Query_Object = {
|
|
10
10
|
target: FnCallType, // object fnCall
|
|
@@ -137,41 +137,33 @@ export class GuardParser {
|
|
|
137
137
|
current.ret_type = ValueType.TYPE_U256;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
if (stack.length < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
141
|
-
for (let i = 0; i <
|
|
142
|
-
|
|
143
|
-
if (!p.ret_type)
|
|
144
|
-
if (p.ret_type != ValueType.TYPE_U8 && p.ret_type != ValueType.TYPE_U64 &&
|
|
145
|
-
p.ret_type != ValueType.TYPE_U128 && p.ret_type != ValueType.TYPE_U256) {
|
|
146
|
-
ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' INVALID param type');
|
|
147
|
-
};
|
|
140
|
+
if (stack.length < current.value || current.value < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
141
|
+
for (let i = 0; i < current.value; ++i) {
|
|
142
|
+
var p = stack.pop() as DeGuardData;
|
|
143
|
+
if (!p.ret_type || !GuardMaker.match_u256(p.ret_type)) ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' INVALID param type');
|
|
148
144
|
current.child.push(p);
|
|
149
145
|
}
|
|
150
146
|
stack.push(current);
|
|
151
|
-
return
|
|
147
|
+
return
|
|
152
148
|
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
153
149
|
current.ret_type = ValueType.TYPE_BOOL;
|
|
154
|
-
if (stack.length < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
current.child.push(p2);
|
|
150
|
+
if (stack.length < current.value || current.value < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
151
|
+
var p0 = stack.pop() as DeGuardData;
|
|
152
|
+
for (let i = 1; i < current.value; ++i) {
|
|
153
|
+
var p = stack.pop() as DeGuardData;
|
|
154
|
+
if (!p.ret_type || (p.ret_type != p0.ret_type)) ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' INVALID param type');
|
|
155
|
+
current.child.push(p);
|
|
156
|
+
}
|
|
162
157
|
stack.push(current);
|
|
163
|
-
return
|
|
158
|
+
return
|
|
164
159
|
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
165
160
|
current.ret_type = ValueType.TYPE_BOOL;
|
|
166
|
-
if (stack.length < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
if (stack.length < current.value || current.value < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
162
|
+
for (let i = 0; i < current.value; ++i) {
|
|
163
|
+
var p = stack.pop() as DeGuardData;
|
|
164
|
+
if (!p.ret_type || (p.ret_type != ValueType.TYPE_STRING)) ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' INVALID param type');
|
|
165
|
+
current.child.push(p);
|
|
171
166
|
}
|
|
172
|
-
|
|
173
|
-
current.child.push(p1);
|
|
174
|
-
current.child.push(p2);
|
|
175
167
|
stack.push(current);
|
|
176
168
|
return
|
|
177
169
|
case OperatorType.TYPE_LOGIC_AND:
|
|
@@ -370,6 +362,9 @@ export class GuardParser {
|
|
|
370
362
|
case ContextType.TYPE_SIGNER:
|
|
371
363
|
case ContextType.TYPE_CLOCK:
|
|
372
364
|
case ContextType.TYPE_GUARD:
|
|
365
|
+
case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
366
|
+
case OperatorType.TYPE_LOGIC_NOT:
|
|
367
|
+
break;
|
|
373
368
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
374
369
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL:
|
|
375
370
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
@@ -377,14 +372,11 @@ export class GuardParser {
|
|
|
377
372
|
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
378
373
|
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
379
374
|
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
380
|
-
case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
381
|
-
case OperatorType.TYPE_LOGIC_NOT:
|
|
382
375
|
case OperatorType.TYPE_NUMBER_ADD:
|
|
383
376
|
case OperatorType.TYPE_NUMBER_DEVIDE:
|
|
384
377
|
case OperatorType.TYPE_NUMBER_MOD:
|
|
385
378
|
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
386
379
|
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
387
|
-
break;
|
|
388
380
|
case OperatorType.TYPE_LOGIC_AND: //@ with logics count
|
|
389
381
|
case OperatorType.TYPE_LOGIC_OR:
|
|
390
382
|
value = arr.shift()! as number;
|
package/src/permission.ts
CHANGED
|
@@ -46,6 +46,7 @@ export enum PermissionIndex {
|
|
|
46
46
|
//service_change_order_required_pubkey = 224,
|
|
47
47
|
service_pause = 225,
|
|
48
48
|
service_treasury = 226,
|
|
49
|
+
service_arbitration = 227,
|
|
49
50
|
/*
|
|
50
51
|
reward = 240,
|
|
51
52
|
reward_refund = 241,
|
|
@@ -166,7 +167,9 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
166
167
|
//{index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'Update Serivce order pubkey', module: 'service'},
|
|
167
168
|
{index:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service'},
|
|
168
169
|
{index:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service'},
|
|
169
|
-
|
|
170
|
+
{index:PermissionIndex.service_arbitration, name:'Arbitration', description:'Add/Remove arbitration that allows refunds from orders at any time based on arbitration results', module: 'service'},
|
|
171
|
+
|
|
172
|
+
/*
|
|
170
173
|
{index:PermissionIndex.reward, name:'reward', description:'Launch new reward', module: 'reward'},
|
|
171
174
|
{index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from reward', module: 'reward'},
|
|
172
175
|
{index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'Expand reward deadline', module: 'reward'},
|
|
@@ -267,12 +270,6 @@ export class Permission {
|
|
|
267
270
|
})
|
|
268
271
|
}
|
|
269
272
|
|
|
270
|
-
destroy() {
|
|
271
|
-
this.txb.moveCall({
|
|
272
|
-
target:Protocol.Instance().PermissionFn('destroy') as FnCallType,
|
|
273
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
274
|
-
})
|
|
275
|
-
}
|
|
276
273
|
add_userdefine(index: number, name:string) {
|
|
277
274
|
if (!Permission.IsValidUserDefinedIndex(index)) {
|
|
278
275
|
ERROR(Errors.IsValidUserDefinedIndex, 'add_userdefine');
|
package/src/progress.ts
CHANGED
|
@@ -99,14 +99,6 @@ export class Progress {
|
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
destroy() {
|
|
103
|
-
|
|
104
|
-
this.txb.moveCall({
|
|
105
|
-
target:Protocol.Instance().ProgressFn('destroy') as FnCallType,
|
|
106
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
102
|
set_namedOperator(name:string, addresses:string[], passport?:PassportObject) {
|
|
111
103
|
if (!IsValidName(name)) {
|
|
112
104
|
ERROR(Errors.IsValidName, 'name')
|
package/src/protocol.ts
CHANGED
|
@@ -94,17 +94,17 @@ export enum OperatorType {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export const LogicsInfo = [
|
|
97
|
-
[OperatorType.TYPE_LOGIC_AS_U256_GREATER, 'Unsigned Integer >'],
|
|
98
|
-
[OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL, 'Unsigned Integer >='],
|
|
99
|
-
[OperatorType.TYPE_LOGIC_AS_U256_LESSER, 'Unsigned Integer <'],
|
|
100
|
-
[OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL, 'Unsigned Integer <='],
|
|
101
|
-
[OperatorType.TYPE_LOGIC_AS_U256_EQUAL, 'Unsigned Integer ='],
|
|
102
|
-
[OperatorType.TYPE_LOGIC_EQUAL, 'Equal'],
|
|
103
|
-
[OperatorType.TYPE_LOGIC_HAS_SUBSTRING, 'Sub String'],
|
|
104
|
-
[OperatorType.TYPE_LOGIC_ALWAYS_TRUE, 'Always True'],
|
|
105
|
-
[OperatorType.TYPE_LOGIC_NOT, 'Not'],
|
|
106
|
-
[OperatorType.TYPE_LOGIC_AND, 'And'],
|
|
107
|
-
[OperatorType.TYPE_LOGIC_OR, 'Or'],
|
|
97
|
+
[OperatorType.TYPE_LOGIC_AS_U256_GREATER, 'Unsigned Integer >', 'The first item > anything that follows'],
|
|
98
|
+
[OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL, 'Unsigned Integer >=', 'The first item >= anything that follows'],
|
|
99
|
+
[OperatorType.TYPE_LOGIC_AS_U256_LESSER, 'Unsigned Integer <', 'The first item < anything that follows'],
|
|
100
|
+
[OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL, 'Unsigned Integer <=', 'The first item <= anything that follows'],
|
|
101
|
+
[OperatorType.TYPE_LOGIC_AS_U256_EQUAL, 'Unsigned Integer =', 'The first item = anything that follows'],
|
|
102
|
+
[OperatorType.TYPE_LOGIC_EQUAL, 'Equal', 'Data and type are exactly equal for all items'],
|
|
103
|
+
[OperatorType.TYPE_LOGIC_HAS_SUBSTRING, 'Has Sub String', 'The first item contains anything that follows'],
|
|
104
|
+
[OperatorType.TYPE_LOGIC_ALWAYS_TRUE, 'Always True', 'Always True'],
|
|
105
|
+
[OperatorType.TYPE_LOGIC_NOT, 'Not', 'Not operation'],
|
|
106
|
+
[OperatorType.TYPE_LOGIC_AND, 'And', 'All Items And operations'],
|
|
107
|
+
[OperatorType.TYPE_LOGIC_OR, 'Or', 'All Items Or operations'],
|
|
108
108
|
];
|
|
109
109
|
|
|
110
110
|
export enum ValueType {
|
|
@@ -165,6 +165,7 @@ export enum ContextType {
|
|
|
165
165
|
TYPE_SIGNER = 60,
|
|
166
166
|
TYPE_CLOCK = 61,
|
|
167
167
|
TYPE_GUARD = 62, // current guard address
|
|
168
|
+
TYPE_STACK_ADDRESS = 63, // object queried from current stack top
|
|
168
169
|
TYPE_CONSTANT = 80,
|
|
169
170
|
}
|
|
170
171
|
interface ValueTypeString {
|
|
@@ -220,14 +221,14 @@ const TESTNET = {
|
|
|
220
221
|
}
|
|
221
222
|
*/
|
|
222
223
|
const TESTNET = {
|
|
223
|
-
wowok: "
|
|
224
|
-
wowok_origin:'
|
|
225
|
-
base: '
|
|
226
|
-
base_origin: '
|
|
227
|
-
|
|
228
|
-
wowok_object: '
|
|
229
|
-
entity_object: '
|
|
230
|
-
treasury_cap:'
|
|
224
|
+
wowok: "0x5cfe867c71e4e65bbe3a1214567926a5fef8b4206f7f219bb7446bd9630f528f",
|
|
225
|
+
wowok_origin:'0x5cfe867c71e4e65bbe3a1214567926a5fef8b4206f7f219bb7446bd9630f528f' ,
|
|
226
|
+
base: '0xcabc5d750dfacb78550b812531598e02fd83650a0ea804fe48767ecca9e46b51',
|
|
227
|
+
base_origin: '0xcabc5d750dfacb78550b812531598e02fd83650a0ea804fe48767ecca9e46b51',
|
|
228
|
+
|
|
229
|
+
wowok_object: '0xa99cd0ef84bfe5ad9321ef6f2314c529067957fbdff0493f0f59ab7cd68d56e7',
|
|
230
|
+
entity_object: '0xa3fe3a125aaa73b805b65c1ca04f4936f654eed8edabbb972d0f660b1ca83b95',
|
|
231
|
+
treasury_cap:'0xfda28fecf646badf857e60d59797709735af2f7af7eec7a1f5c9c65f5f7554d0',
|
|
231
232
|
}
|
|
232
233
|
const MAINNET = {
|
|
233
234
|
wowok: "",
|
package/src/repository.ts
CHANGED
|
@@ -82,14 +82,6 @@ export class Repository {
|
|
|
82
82
|
})
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
destroy() {
|
|
86
|
-
if (!Protocol.IsValidObjects([this.object])) return false;
|
|
87
|
-
this.txb.moveCall({
|
|
88
|
-
target:Protocol.Instance().RepositoryFn('destroy') as FnCallType,
|
|
89
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
|
|
93
85
|
add_data(data:Repository_Policy_Data) {
|
|
94
86
|
if (!Repository.IsValidName(data.key)) {
|
|
95
87
|
ERROR(Errors.IsValidName)
|
package/src/service.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryOb
|
|
|
4
4
|
ServiceObject, DiscountObject, OrderObject, OrderAddress, CoinObject, Protocol, ValueType,
|
|
5
5
|
TxbObject,
|
|
6
6
|
TreasuryObject,
|
|
7
|
-
PaymentAddress
|
|
7
|
+
PaymentAddress,
|
|
8
|
+
ArbObject,
|
|
9
|
+
ArbitrationObject} from './protocol';
|
|
8
10
|
import { ERROR, Errors } from './exception';
|
|
9
11
|
import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
|
|
10
12
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
@@ -67,6 +69,7 @@ export interface WithdrawPayee {
|
|
|
67
69
|
for_guard?: GuardObject,
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
|
|
70
73
|
export type handleDiscountObject = (owner:string, objects:(SuiObjectData|null|undefined)[]) => void;
|
|
71
74
|
export class Service {
|
|
72
75
|
protected pay_token_type;
|
|
@@ -128,13 +131,6 @@ export class Service {
|
|
|
128
131
|
typeArguments:[this.pay_token_type]
|
|
129
132
|
})
|
|
130
133
|
}
|
|
131
|
-
destroy() {
|
|
132
|
-
this.txb.moveCall({
|
|
133
|
-
target:Protocol.Instance().ServiceFn('destroy') as FnCallType,
|
|
134
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
135
|
-
typeArguments:[this.pay_token_type]
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
134
|
|
|
139
135
|
set_description(description:string, passport?:PassportObject) {
|
|
140
136
|
if (!IsValidDesription(description)) {
|
|
@@ -306,7 +302,7 @@ export class Service {
|
|
|
306
302
|
})
|
|
307
303
|
}
|
|
308
304
|
}
|
|
309
|
-
|
|
305
|
+
add_repository(repository:RepositoryObject, passport?:PassportObject) {
|
|
310
306
|
if (!Protocol.IsValidObjects([repository])) {
|
|
311
307
|
ERROR(Errors.IsValidObjects, 'repository_add');
|
|
312
308
|
}
|
|
@@ -325,7 +321,7 @@ export class Service {
|
|
|
325
321
|
})
|
|
326
322
|
}
|
|
327
323
|
}
|
|
328
|
-
|
|
324
|
+
remove_repository(repository_address:string[], removeall?:boolean, passport?:PassportObject) {
|
|
329
325
|
if (!removeall && repository_address.length===0) return;
|
|
330
326
|
|
|
331
327
|
if (!IsValidArray(repository_address, IsValidAddress)) {
|
|
@@ -364,7 +360,64 @@ export class Service {
|
|
|
364
360
|
}
|
|
365
361
|
}
|
|
366
362
|
}
|
|
367
|
-
|
|
363
|
+
add_arbitration(arbitraion:ArbitrationObject, passport?:PassportObject) {
|
|
364
|
+
if (!Protocol.IsValidObjects([arbitraion])) {
|
|
365
|
+
ERROR(Errors.IsValidObjects, 'arbitration_add');
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (passport) {
|
|
369
|
+
this.txb.moveCall({
|
|
370
|
+
target:Protocol.Instance().ServiceFn('arbitration_add_with_passport') as FnCallType,
|
|
371
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arbitraion), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
372
|
+
typeArguments:[this.pay_token_type]
|
|
373
|
+
})
|
|
374
|
+
} else {
|
|
375
|
+
this.txb.moveCall({
|
|
376
|
+
target:Protocol.Instance().ServiceFn('repository_add') as FnCallType,
|
|
377
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arbitraion), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
378
|
+
typeArguments:[this.pay_token_type]
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
remove_arbitration(address:string[], removeall?:boolean, passport?:PassportObject) {
|
|
383
|
+
if (!removeall && address.length===0) return;
|
|
384
|
+
|
|
385
|
+
if (!IsValidArray(address, IsValidAddress)) {
|
|
386
|
+
ERROR(Errors.IsValidArray, 'arbitration_remove.address');
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (passport) {
|
|
390
|
+
if (removeall) {
|
|
391
|
+
this.txb.moveCall({
|
|
392
|
+
target:Protocol.Instance().ServiceFn('arbitration_remove_all_with_passport') as FnCallType,
|
|
393
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
394
|
+
typeArguments:[this.pay_token_type]
|
|
395
|
+
})
|
|
396
|
+
} else {
|
|
397
|
+
this.txb.moveCall({
|
|
398
|
+
target:Protocol.Instance().ServiceFn('arbitration_remove_with_passport') as FnCallType,
|
|
399
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(address!)),
|
|
400
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
401
|
+
typeArguments:[this.pay_token_type]
|
|
402
|
+
})
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
if (removeall) {
|
|
406
|
+
this.txb.moveCall({
|
|
407
|
+
target:Protocol.Instance().ServiceFn('arbitration_remove_all') as FnCallType,
|
|
408
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
409
|
+
typeArguments:[this.pay_token_type]
|
|
410
|
+
})
|
|
411
|
+
} else {
|
|
412
|
+
this.txb.moveCall({
|
|
413
|
+
target:Protocol.Instance().ServiceFn('arbitration_remove') as FnCallType,
|
|
414
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(address!)),
|
|
415
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
416
|
+
typeArguments:[this.pay_token_type]
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
368
421
|
add_withdraw_guards(guards:Service_Guard_Percent[], passport?:PassportObject) {
|
|
369
422
|
if (guards.length === 0) return;
|
|
370
423
|
|
|
@@ -890,20 +943,37 @@ export class Service {
|
|
|
890
943
|
}
|
|
891
944
|
}
|
|
892
945
|
|
|
893
|
-
|
|
946
|
+
refund_withArb(order:OrderObject, arb:ArbObject, arb_type:string) {
|
|
947
|
+
if (!Protocol.IsValidObjects([order, arb])) {
|
|
948
|
+
ERROR(Errors.IsValidObjects, 'refund_withArb.order or arb')
|
|
949
|
+
}
|
|
950
|
+
if (!IsValidTokenType(arb_type)) {
|
|
951
|
+
ERROR(Errors.IsValidTokenType, 'refund_withArb.arb_type')
|
|
952
|
+
}
|
|
953
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
954
|
+
this.txb.moveCall({
|
|
955
|
+
target:Protocol.Instance().ServiceFn('refund_with_arb') as FnCallType,
|
|
956
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.object(arb), this.txb.object(clock)],
|
|
957
|
+
typeArguments:[this.pay_token_type, arb_type]
|
|
958
|
+
})
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
refund(order:OrderObject, refund_guard?:GuardObject, passport?:PassportObject) {
|
|
894
962
|
if (!Protocol.IsValidObjects([order])) {
|
|
895
963
|
ERROR(Errors.IsValidObjects, 'refund.order')
|
|
896
964
|
}
|
|
897
|
-
if (refund_guard && !
|
|
898
|
-
ERROR(Errors.
|
|
965
|
+
if (refund_guard && !Protocol.IsValidObjects([refund_guard])) {
|
|
966
|
+
ERROR(Errors.IsValidObjects, 'refund.refund_guard')
|
|
899
967
|
}
|
|
900
968
|
if (passport && !refund_guard) {
|
|
901
969
|
ERROR(Errors.InvalidParam, 'refund.passport need refund_guard')
|
|
902
970
|
}
|
|
971
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
903
972
|
if (passport && refund_guard) {
|
|
904
973
|
this.txb.moveCall({
|
|
905
974
|
target:Protocol.Instance().ServiceFn('refund_with_passport') as FnCallType,
|
|
906
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.object(refund_guard),
|
|
975
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.object(refund_guard),
|
|
976
|
+
passport, this.txb.object(clock)],
|
|
907
977
|
typeArguments:[this.pay_token_type]
|
|
908
978
|
})
|
|
909
979
|
} else {
|
|
@@ -1104,6 +1174,7 @@ export class Service {
|
|
|
1104
1174
|
static MAX_TREASURY_COUNT= 8;
|
|
1105
1175
|
static MAX_ORDER_AGENT_COUNT = 8;
|
|
1106
1176
|
static MAX_ORDER_ARBS_COUNT = 8;
|
|
1177
|
+
static MAX_ARBITRATION_COUNT = 8;
|
|
1107
1178
|
|
|
1108
1179
|
static IsValidItemName(name:string) : boolean {
|
|
1109
1180
|
if (!name) return false;
|
package/src/treasury.ts
CHANGED
|
@@ -88,14 +88,6 @@ export class Treasury {
|
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
destroy() {
|
|
92
|
-
this.txb.moveCall({
|
|
93
|
-
target:Protocol.Instance().TreasuryFn('destroy') as FnCallType,
|
|
94
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
95
|
-
typeArguments:[this.token_type]
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
91
|
set_deposit_guard(guard?:string, passport?:PassportObject) {
|
|
100
92
|
if (guard && !IsValidAddress(guard)) {
|
|
101
93
|
ERROR(Errors.IsValidAddress, 'set_deposit_guard.guard')
|