wowok 1.5.39 → 1.5.41
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 +38 -25
- package/src/passport.ts +22 -30
- package/src/protocol.ts +16 -15
- package/src/service.ts +51 -31
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, 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';
|
|
@@ -587,11 +587,11 @@ export class GuardMaker {
|
|
|
587
587
|
return this;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
-
add_logic(type:OperatorType, logic_count
|
|
590
|
+
add_logic(type:OperatorType, logic_count?:number) : GuardMaker {
|
|
591
591
|
var e:any = LogicsInfo.find((v:any) => v[0] === type);
|
|
592
592
|
if (e) { e=e[1] }
|
|
593
593
|
|
|
594
|
-
let splice_len = 2;
|
|
594
|
+
let splice_len = 2; let cur:any;
|
|
595
595
|
let ret = ValueType.TYPE_BOOL;
|
|
596
596
|
switch (type) {
|
|
597
597
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
@@ -599,26 +599,28 @@ export class GuardMaker {
|
|
|
599
599
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
600
600
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
|
|
601
601
|
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
if (
|
|
602
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
603
|
+
splice_len = logic_count!;
|
|
604
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
605
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
606
|
+
if (!GuardMaker.match_u256(this.type_validator[this.type_validator.length - i])) { ERROR(Errors.Fail, 'type_validator check:'+e) }
|
|
607
|
+
}
|
|
605
608
|
break;
|
|
606
609
|
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
} else {
|
|
614
|
-
ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
610
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
611
|
+
splice_len = logic_count!;
|
|
612
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
613
|
+
cur = this.type_validator[this.type_validator.length - 1];
|
|
614
|
+
for (let i = 2; i <= splice_len; ++i) {
|
|
615
|
+
if (this.type_validator[this.type_validator.length - i] !== cur) ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
615
616
|
}
|
|
616
617
|
break;
|
|
617
618
|
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
618
|
-
if (
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
619
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
620
|
+
splice_len = logic_count!;
|
|
621
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
622
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
623
|
+
if (this.type_validator[this.type_validator.length - i] !== ValueType.TYPE_STRING) ERROR(Errors.Fail, 'type_validator check:' + e) ;
|
|
622
624
|
}
|
|
623
625
|
break;
|
|
624
626
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
@@ -642,9 +644,12 @@ export class GuardMaker {
|
|
|
642
644
|
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
643
645
|
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
644
646
|
case OperatorType.TYPE_NUMBER_MOD:
|
|
647
|
+
if (!logic_count || logic_count < 2) ERROR(Errors.Fail, 'logic param invalid:'+e);
|
|
648
|
+
splice_len = logic_count!;
|
|
645
649
|
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length:'+e) }
|
|
646
|
-
|
|
647
|
-
|
|
650
|
+
for (let i = 1; i <= splice_len; ++i) {
|
|
651
|
+
if(!GuardMaker.match_u256(this.type_validator[this.type_validator.length -1])) { ERROR(Errors.Fail, 'type_validator check:'+e) }
|
|
652
|
+
}
|
|
648
653
|
ret = ValueType.TYPE_U256;
|
|
649
654
|
break;
|
|
650
655
|
default:
|
|
@@ -652,7 +657,7 @@ export class GuardMaker {
|
|
|
652
657
|
}
|
|
653
658
|
|
|
654
659
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type)); // TYPE
|
|
655
|
-
if (
|
|
660
|
+
if (GuardMaker.is_multi_input_op(type)) {
|
|
656
661
|
this.data.push((Bcs.getInstance().ser(ValueType.TYPE_U8, logic_count))); //@ logics
|
|
657
662
|
}
|
|
658
663
|
this.type_validator.splice(this.type_validator.length - splice_len); // delete type stack
|
|
@@ -660,10 +665,6 @@ export class GuardMaker {
|
|
|
660
665
|
return this;
|
|
661
666
|
}
|
|
662
667
|
|
|
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
668
|
hasIdentifier(id:number) : boolean {
|
|
668
669
|
return this.constant.has(id)
|
|
669
670
|
}
|
|
@@ -720,6 +721,18 @@ export class GuardMaker {
|
|
|
720
721
|
static match_u256(type:number) : boolean {
|
|
721
722
|
return (type == ValueType.TYPE_U8 || type == ValueType.TYPE_U64 || type == ValueType.TYPE_U128 || type == ValueType.TYPE_U256);
|
|
722
723
|
}
|
|
724
|
+
static is_multi_input_op(type:number) : boolean {
|
|
725
|
+
return (type === OperatorType.TYPE_LOGIC_AS_U256_GREATER ||
|
|
726
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL ||
|
|
727
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER ||
|
|
728
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER ||
|
|
729
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL ||
|
|
730
|
+
type === OperatorType.TYPE_LOGIC_AS_U256_EQUAL ||
|
|
731
|
+
type === OperatorType.TYPE_LOGIC_EQUAL ||
|
|
732
|
+
type === OperatorType.TYPE_LOGIC_HAS_SUBSTRING ||
|
|
733
|
+
type === OperatorType.TYPE_LOGIC_AND ||
|
|
734
|
+
type === OperatorType.TYPE_LOGIC_OR)
|
|
735
|
+
}
|
|
723
736
|
}
|
|
724
737
|
|
|
725
738
|
|
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/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,13 +221,13 @@ const TESTNET = {
|
|
|
220
221
|
}
|
|
221
222
|
*/
|
|
222
223
|
const TESTNET = {
|
|
223
|
-
wowok: "
|
|
224
|
-
wowok_origin:'
|
|
224
|
+
wowok: "0x95541edbae1f167f8679df2bbee57eafaf09cf81230094ffc196e78a0df200e4",
|
|
225
|
+
wowok_origin:'0x95541edbae1f167f8679df2bbee57eafaf09cf81230094ffc196e78a0df200e4' ,
|
|
225
226
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
226
227
|
base_origin: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
227
228
|
|
|
228
|
-
wowok_object: '
|
|
229
|
-
entity_object: '
|
|
229
|
+
wowok_object: '0x33917cc62420ba654a0d4a0325e4d31778b12b4f736812d7427904e9911abad3',
|
|
230
|
+
entity_object: '0xf6f8ee1a3bc19288ac1067f77eae6e72bd1887b35a0c7996635eee975d758901',
|
|
230
231
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
231
232
|
}
|
|
232
233
|
const MAINNET = {
|
package/src/service.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { IsValidArray, IsValidPercent, IsValidName_AllowEmpty, parseObjectType,
|
|
|
3
3
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryObject, MachineObject, ServiceAddress,
|
|
4
4
|
ServiceObject, DiscountObject, OrderObject, OrderAddress, CoinObject, Protocol, ValueType,
|
|
5
5
|
TxbObject,
|
|
6
|
-
TreasuryObject
|
|
6
|
+
TreasuryObject,
|
|
7
|
+
PaymentAddress} from './protocol';
|
|
7
8
|
import { ERROR, Errors } from './exception';
|
|
8
9
|
import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
|
|
9
10
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
@@ -57,6 +58,14 @@ export type DicountDispatch = {
|
|
|
57
58
|
count: bigint;
|
|
58
59
|
discount: Service_Discount;
|
|
59
60
|
}
|
|
61
|
+
export interface WithdrawPayee {
|
|
62
|
+
withdraw_guard: GuardObject;
|
|
63
|
+
treasury: TreasuryObject,
|
|
64
|
+
index: bigint,
|
|
65
|
+
remark: string,
|
|
66
|
+
for_object?: string,
|
|
67
|
+
for_guard?: GuardObject,
|
|
68
|
+
}
|
|
60
69
|
|
|
61
70
|
export type handleDiscountObject = (owner:string, objects:(SuiObjectData|null|undefined)[]) => void;
|
|
62
71
|
export class Service {
|
|
@@ -81,8 +90,8 @@ export class Service {
|
|
|
81
90
|
return s
|
|
82
91
|
}
|
|
83
92
|
static New(txb: TransactionBlock, token_type:string, permission:PermissionObject, description:string,
|
|
84
|
-
|
|
85
|
-
if (!Protocol.IsValidObjects([permission])) {
|
|
93
|
+
payee_treasury:TreasuryObject, passport?:PassportObject) : Service {
|
|
94
|
+
if (!Protocol.IsValidObjects([permission, payee_treasury])) {
|
|
86
95
|
ERROR(Errors.IsValidObjects)
|
|
87
96
|
}
|
|
88
97
|
if (!IsValidTokenType(token_type)) {
|
|
@@ -91,9 +100,6 @@ export class Service {
|
|
|
91
100
|
if (!IsValidDesription(description)) {
|
|
92
101
|
ERROR(Errors.IsValidDesription)
|
|
93
102
|
}
|
|
94
|
-
if (!IsValidAddress(payee_address)) {
|
|
95
|
-
ERROR(Errors.IsValidAddress, 'payee_address')
|
|
96
|
-
}
|
|
97
103
|
|
|
98
104
|
let pay_token_type = token_type;
|
|
99
105
|
let s = new Service(txb, pay_token_type, permission);
|
|
@@ -102,13 +108,13 @@ export class Service {
|
|
|
102
108
|
if (passport) {
|
|
103
109
|
s.object = txb.moveCall({
|
|
104
110
|
target:Protocol.Instance().ServiceFn('new_with_passport') as FnCallType,
|
|
105
|
-
arguments:[passport, txb.pure.string(description), txb.
|
|
111
|
+
arguments:[passport, txb.pure.string(description), txb.object(payee_treasury), Protocol.TXB_OBJECT(txb, permission)],
|
|
106
112
|
typeArguments:[pay_token_type],
|
|
107
113
|
})
|
|
108
114
|
} else {
|
|
109
115
|
s.object = txb.moveCall({
|
|
110
116
|
target:Protocol.Instance().ServiceFn('new') as FnCallType,
|
|
111
|
-
arguments:[txb.pure.string(description), txb.
|
|
117
|
+
arguments:[txb.pure.string(description), txb.object(payee_treasury), Protocol.TXB_OBJECT(txb, permission)],
|
|
112
118
|
typeArguments:[pay_token_type],
|
|
113
119
|
})
|
|
114
120
|
}
|
|
@@ -281,21 +287,21 @@ export class Service {
|
|
|
281
287
|
}
|
|
282
288
|
}
|
|
283
289
|
|
|
284
|
-
set_payee(payee:
|
|
285
|
-
if (!
|
|
286
|
-
ERROR(Errors.
|
|
290
|
+
set_payee(payee:TreasuryObject, passport?:PassportObject) {
|
|
291
|
+
if (!Protocol.IsValidObjects([payee])) {
|
|
292
|
+
ERROR(Errors.IsValidObjects, 'set_payee');
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
if (passport) {
|
|
290
296
|
this.txb.moveCall({
|
|
291
297
|
target:Protocol.Instance().ServiceFn('payee_set_with_passport') as FnCallType,
|
|
292
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.
|
|
298
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(payee), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
293
299
|
typeArguments:[this.pay_token_type]
|
|
294
300
|
})
|
|
295
301
|
} else {
|
|
296
302
|
this.txb.moveCall({
|
|
297
303
|
target:Protocol.Instance().ServiceFn('payee_set') as FnCallType,
|
|
298
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.
|
|
304
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(payee), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
299
305
|
typeArguments:[this.pay_token_type]
|
|
300
306
|
})
|
|
301
307
|
}
|
|
@@ -622,30 +628,44 @@ export class Service {
|
|
|
622
628
|
}
|
|
623
629
|
|
|
624
630
|
// support both withdraw guard and permission guard
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
631
|
+
// withdraw_guard & passport must BOTH valid.
|
|
632
|
+
withdraw(order:OrderObject, param:WithdrawPayee, passport:PassportObject) : PaymentAddress {
|
|
633
|
+
if (!Protocol.IsValidObjects([order, param.treasury, param.withdraw_guard, passport])) {
|
|
634
|
+
ERROR(Errors.IsValidObjects,)
|
|
628
635
|
}
|
|
629
|
-
if (
|
|
630
|
-
ERROR(Errors.
|
|
636
|
+
if (param?.for_guard && !Protocol.IsValidObjects([param.for_guard])) {
|
|
637
|
+
ERROR(Errors.IsValidObjects, 'withdraw.param.for_guard')
|
|
631
638
|
}
|
|
632
|
-
if (
|
|
633
|
-
ERROR(Errors.
|
|
639
|
+
if (param?.for_object && !IsValidAddress(param.for_object)) {
|
|
640
|
+
ERROR(Errors.IsValidAddress, 'withdraw.param.for_object')
|
|
634
641
|
}
|
|
635
|
-
if (
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
642
|
+
if (!IsValidU64(param.index)) {
|
|
643
|
+
ERROR(Errors.IsValidU64, 'withdraw.param.index')
|
|
644
|
+
}
|
|
645
|
+
if (!IsValidDesription(param.remark)) {
|
|
646
|
+
ERROR(Errors.IsValidDesription, 'withdraw.param.remark')
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
|
|
650
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
651
|
+
|
|
652
|
+
if (param.for_guard) {
|
|
653
|
+
return this.txb.moveCall({
|
|
654
|
+
target:Protocol.Instance().ServiceFn('withdraw_forGuard_with_passport') as FnCallType,
|
|
655
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.object(param.withdraw_guard),
|
|
656
|
+
this.txb.object(param.treasury), for_obj, this.txb.object(param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
|
|
657
|
+
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
640
658
|
typeArguments:[this.pay_token_type]
|
|
641
|
-
})
|
|
659
|
+
})
|
|
642
660
|
} else {
|
|
643
|
-
this.txb.moveCall({
|
|
644
|
-
target:Protocol.Instance().ServiceFn('
|
|
645
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order),
|
|
661
|
+
return this.txb.moveCall({
|
|
662
|
+
target:Protocol.Instance().ServiceFn('withdraw_with_passport') as FnCallType,
|
|
663
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.object(param.withdraw_guard),
|
|
664
|
+
this.txb.object(param.treasury), for_obj, this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
|
|
665
|
+
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
646
666
|
typeArguments:[this.pay_token_type]
|
|
647
|
-
})
|
|
648
|
-
}
|
|
667
|
+
})
|
|
668
|
+
}
|
|
649
669
|
}
|
|
650
670
|
|
|
651
671
|
set_buy_guard(guard?:GuardObject, passport?:PassportObject) {
|