wowok 1.7.13 → 1.7.16
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/arbitration.d.ts.map +1 -1
- package/dist/arbitration.js +21 -32
- package/dist/arbitration.js.map +1 -1
- package/dist/entity.d.ts +1 -0
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +12 -6
- package/dist/entity.js.map +1 -1
- package/dist/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -0
- package/dist/exception.js.map +1 -1
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +8 -4
- package/dist/guard.js.map +1 -1
- package/dist/payment.d.ts +2 -2
- package/dist/payment.d.ts.map +1 -1
- package/dist/payment.js +2 -2
- package/dist/payment.js.map +1 -1
- package/dist/protocol.d.ts +21 -19
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +211 -58
- package/dist/protocol.js.map +1 -1
- package/dist/service.d.ts +2 -2
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +5 -6
- package/dist/service.js.map +1 -1
- package/package.json +5 -2
- package/src/arbitration.ts +0 -551
- package/src/demand.ts +0 -300
- package/src/entity.ts +0 -171
- package/src/exception.ts +0 -37
- package/src/guard.ts +0 -810
- package/src/index.ts +0 -40
- package/src/machine.ts +0 -542
- package/src/passport.ts +0 -777
- package/src/payment.ts +0 -94
- package/src/permission.ts +0 -550
- package/src/progress.ts +0 -367
- package/src/protocol.ts +0 -549
- package/src/repository.ts +0 -680
- package/src/resource.ts +0 -155
- package/src/service.ts +0 -1349
- package/src/treasury.ts +0 -425
- package/src/utils.ts +0 -660
- package/src/wowok.ts +0 -70
- package/tsconfig.json +0 -30
- package/tsconfig.tsbuildinfo +0 -1
- package/webpack.config.cjs +0 -23
package/src/treasury.ts
DELETED
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
2
|
-
import { FnCallType, Protocol, PassportObject, PermissionObject, TreasuryAddress, TxbObject, CoinObject, PaymentObject,
|
|
3
|
-
ReceivedObject } from './protocol.js';
|
|
4
|
-
import { IsValidDesription, IsValidU64, IsValidAddress, IsValidArgType, IsValidArray, parseObjectType} from './utils.js'
|
|
5
|
-
import { Errors, ERROR} from './exception.js'
|
|
6
|
-
|
|
7
|
-
export enum Treasury_WithdrawMode {
|
|
8
|
-
PERMISSION = 0,
|
|
9
|
-
GUARD_ONLY_AND_IMMUTABLE = 1,
|
|
10
|
-
BOTH_PERMISSION_AND_GUARD = 2,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export enum Treasury_Operation {
|
|
14
|
-
WITHDRAW = 1,
|
|
15
|
-
DEPOSIT = 2,
|
|
16
|
-
RECEIVE = 4,
|
|
17
|
-
}
|
|
18
|
-
export interface DepositParam {
|
|
19
|
-
coin: CoinObject,
|
|
20
|
-
index: bigint,
|
|
21
|
-
remark: string,
|
|
22
|
-
for_object?: string,
|
|
23
|
-
for_guard?: string,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface WithdrawItem {
|
|
27
|
-
address: string,
|
|
28
|
-
amount: bigint | number | string,
|
|
29
|
-
}
|
|
30
|
-
export interface WithdrawParam {
|
|
31
|
-
items: WithdrawItem[],
|
|
32
|
-
index: bigint | number | string,
|
|
33
|
-
remark: string,
|
|
34
|
-
for_object?: string,
|
|
35
|
-
for_guard?: string,
|
|
36
|
-
withdraw_guard?: string,
|
|
37
|
-
}
|
|
38
|
-
export class Treasury {
|
|
39
|
-
protected token_type;
|
|
40
|
-
protected permission ;
|
|
41
|
-
protected object : TxbObject;
|
|
42
|
-
protected txb;
|
|
43
|
-
|
|
44
|
-
get_token_type() { return this.token_type }
|
|
45
|
-
get_object() { return this.object }
|
|
46
|
-
|
|
47
|
-
static From(txb:TransactionBlock, token_type:string, permission:PermissionObject, object:TxbObject) : Treasury {
|
|
48
|
-
let d = new Treasury(txb, token_type, permission)
|
|
49
|
-
d.object = Protocol.TXB_OBJECT(txb, object)
|
|
50
|
-
return d
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private constructor(txb:TransactionBlock, token_type:string, permission:PermissionObject) {
|
|
54
|
-
this.token_type = token_type;
|
|
55
|
-
this.permission = permission;
|
|
56
|
-
this.txb = txb;
|
|
57
|
-
this.object = '';
|
|
58
|
-
}
|
|
59
|
-
static New(txb:TransactionBlock, token_type:string, permission:PermissionObject, description:string, passport?:PassportObject) : Treasury {
|
|
60
|
-
if (!Protocol.IsValidObjects([permission])) {
|
|
61
|
-
ERROR(Errors.IsValidObjects, 'Treasury.New permission, bounty');
|
|
62
|
-
}
|
|
63
|
-
if (!IsValidDesription(description)) {
|
|
64
|
-
ERROR(Errors.IsValidDesription, 'Treasury.New.description');
|
|
65
|
-
}
|
|
66
|
-
if (!IsValidArgType(token_type)) {
|
|
67
|
-
ERROR(Errors.IsValidArgType, token_type);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let d = new Treasury(txb, token_type, permission);
|
|
71
|
-
if (passport) {
|
|
72
|
-
d.object = txb.moveCall({
|
|
73
|
-
target:Protocol.Instance().treasuryFn('new_with_passport') as FnCallType,
|
|
74
|
-
arguments:[passport, txb.pure.string(description), Protocol.TXB_OBJECT(txb, permission)],
|
|
75
|
-
typeArguments:[token_type],
|
|
76
|
-
})
|
|
77
|
-
} else {
|
|
78
|
-
d.object = txb.moveCall({
|
|
79
|
-
target:Protocol.Instance().treasuryFn('new') as FnCallType,
|
|
80
|
-
arguments:[txb.pure.string(description), Protocol.TXB_OBJECT(txb, permission)],
|
|
81
|
-
typeArguments:[token_type],
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
return d
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
launch() : TreasuryAddress {
|
|
88
|
-
return this.txb.moveCall({
|
|
89
|
-
target:Protocol.Instance().treasuryFn('create') as FnCallType,
|
|
90
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
91
|
-
typeArguments:[this.token_type],
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set_deposit_guard(guard?:string, passport?:PassportObject) {
|
|
96
|
-
if (guard && !IsValidAddress(guard)) {
|
|
97
|
-
ERROR(Errors.IsValidAddress, 'set_deposit_guard.guard')
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (passport) {
|
|
101
|
-
if (guard) {
|
|
102
|
-
this.txb.moveCall({
|
|
103
|
-
target:Protocol.Instance().treasuryFn('deposit_guard_set_with_passport') as FnCallType,
|
|
104
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
105
|
-
this.txb.object(guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
106
|
-
typeArguments:[this.token_type],
|
|
107
|
-
})
|
|
108
|
-
} else {
|
|
109
|
-
this.txb.moveCall({
|
|
110
|
-
target:Protocol.Instance().treasuryFn('deposit_guard_none_with_passport') as FnCallType,
|
|
111
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
112
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
113
|
-
typeArguments:[this.token_type],
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
if (guard) {
|
|
118
|
-
this.txb.moveCall({
|
|
119
|
-
target:Protocol.Instance().treasuryFn('deposit_guard_set') as FnCallType,
|
|
120
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
121
|
-
this.txb.object(guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
122
|
-
typeArguments:[this.token_type],
|
|
123
|
-
})
|
|
124
|
-
} else {
|
|
125
|
-
this.txb.moveCall({
|
|
126
|
-
target:Protocol.Instance().treasuryFn('deposit_guard_none') as FnCallType,
|
|
127
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
128
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
129
|
-
typeArguments:[this.token_type],
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// return payment address
|
|
136
|
-
deposit(param:DepositParam, passport?:PassportObject) :TransactionResult {
|
|
137
|
-
if (!Protocol.IsValidObjects([param.coin])) {
|
|
138
|
-
ERROR(Errors.IsValidObjects, 'deposit.param.coin')
|
|
139
|
-
}
|
|
140
|
-
if (!IsValidDesription(param.remark)) {
|
|
141
|
-
ERROR(Errors.IsValidDesription, 'deposit.param.remark')
|
|
142
|
-
}
|
|
143
|
-
if (param?.for_object && !IsValidAddress(param.for_object)) {
|
|
144
|
-
ERROR(Errors.IsValidAddress, 'deposit.param.for_object')
|
|
145
|
-
}
|
|
146
|
-
if (param?.for_guard && !IsValidAddress(param.for_guard)) {
|
|
147
|
-
ERROR(Errors.IsValidAddress, 'deposit.param.for_guard')
|
|
148
|
-
}
|
|
149
|
-
if (param.index !== undefined && !IsValidU64(param.index)) {
|
|
150
|
-
ERROR(Errors.InvalidParam, 'deposit.param.index')
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object: undefined);
|
|
154
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
155
|
-
if (passport) {
|
|
156
|
-
if (param.for_guard) {
|
|
157
|
-
return this.txb.moveCall({
|
|
158
|
-
target:Protocol.Instance().treasuryFn('deposit_forGuard_with_passport') as FnCallType,
|
|
159
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.coin), this.txb.pure.u64(param.index),
|
|
160
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(param.for_guard), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
161
|
-
typeArguments:[this.token_type],
|
|
162
|
-
})
|
|
163
|
-
} else {
|
|
164
|
-
return this.txb.moveCall({
|
|
165
|
-
target:Protocol.Instance().treasuryFn('deposit_with_passport') as FnCallType,
|
|
166
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.coin), this.txb.pure.u64(param.index),
|
|
167
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
168
|
-
typeArguments:[this.token_type],
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
if (param.for_guard) {
|
|
173
|
-
return this.txb.moveCall({
|
|
174
|
-
target:Protocol.Instance().treasuryFn('deposit_forGuard') as FnCallType,
|
|
175
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.coin), this.txb.pure.u64(param.index),
|
|
176
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(param.for_guard), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
177
|
-
typeArguments:[this.token_type],
|
|
178
|
-
})
|
|
179
|
-
} else {
|
|
180
|
-
return this.txb.moveCall({
|
|
181
|
-
target:Protocol.Instance().treasuryFn('deposit') as FnCallType,
|
|
182
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.coin), this.txb.pure.u64(param.index),
|
|
183
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
184
|
-
typeArguments:[this.token_type],
|
|
185
|
-
})
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// return current balance
|
|
192
|
-
receive(payment:PaymentObject, received:ReceivedObject, passport?:PassportObject) : TransactionResult {
|
|
193
|
-
if (!Protocol.IsValidObjects([payment, received])) {
|
|
194
|
-
ERROR(Errors.IsValidArray, 'receive.payment&received');
|
|
195
|
-
}
|
|
196
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
197
|
-
if (passport) {
|
|
198
|
-
return this.txb.moveCall({
|
|
199
|
-
target:Protocol.Instance().treasuryFn('receive_with_passport') as FnCallType,
|
|
200
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, received), Protocol.TXB_OBJECT(this.txb, payment),
|
|
201
|
-
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
202
|
-
typeArguments:[this.token_type],
|
|
203
|
-
})
|
|
204
|
-
} else {
|
|
205
|
-
return this.txb.moveCall({
|
|
206
|
-
target:Protocol.Instance().treasuryFn('receive') as FnCallType,
|
|
207
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, received), Protocol.TXB_OBJECT(this.txb, payment),
|
|
208
|
-
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
209
|
-
typeArguments:[this.token_type],
|
|
210
|
-
})
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// return payment address
|
|
215
|
-
withdraw(param:WithdrawParam, passport?:PassportObject) : TransactionResult | undefined {
|
|
216
|
-
if (param.items.length === 0) return undefined;
|
|
217
|
-
if (!IsValidArray(param.items, (item:WithdrawItem) => IsValidU64(item.amount) && IsValidAddress(item.address))) {
|
|
218
|
-
ERROR(Errors.IsValidArray, 'withdraw.param.items')
|
|
219
|
-
}
|
|
220
|
-
if (!IsValidDesription(param.remark)) {
|
|
221
|
-
ERROR(Errors.IsValidDesription, 'withdraw.param.remark')
|
|
222
|
-
}
|
|
223
|
-
if (!IsValidU64(param.index)) {
|
|
224
|
-
ERROR(Errors.IsValidU64, 'withdraw.param.index')
|
|
225
|
-
}
|
|
226
|
-
if (param?.for_guard && !IsValidAddress(param.for_guard)) {
|
|
227
|
-
ERROR(Errors.IsValidAddress, 'withdraw.param.for_guard')
|
|
228
|
-
}
|
|
229
|
-
if (param?.for_object && !IsValidAddress(param.for_object)) {
|
|
230
|
-
ERROR(Errors.IsValidAddress, 'withdraw.param.for_object')
|
|
231
|
-
}
|
|
232
|
-
if (param?.withdraw_guard && !IsValidAddress(param.withdraw_guard)) {
|
|
233
|
-
ERROR(Errors.IsValidAddress, 'withdraw.param.withdraw_guard')
|
|
234
|
-
}
|
|
235
|
-
if (param?.withdraw_guard && !passport) {
|
|
236
|
-
ERROR(Errors.IsValidAddress, 'withdraw.param.withdraw_guard')
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
|
|
240
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
241
|
-
|
|
242
|
-
if (param.withdraw_guard && passport) { //@ dont need passport, use withdraw guard!
|
|
243
|
-
if (param.for_guard) {
|
|
244
|
-
return this.txb.moveCall({
|
|
245
|
-
target:Protocol.Instance().treasuryFn('withdraw_useGuard_forGuard') as FnCallType,
|
|
246
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
247
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
|
|
248
|
-
for_obj, this.txb.object(param.for_guard), this.txb.object(clock), this.txb.object(param.withdraw_guard)],
|
|
249
|
-
typeArguments:[this.token_type],
|
|
250
|
-
})
|
|
251
|
-
} else {
|
|
252
|
-
return this.txb.moveCall({
|
|
253
|
-
target:Protocol.Instance().treasuryFn('withdraw_useGuard') as FnCallType,
|
|
254
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
255
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
|
|
256
|
-
for_obj, this.txb.object(clock), this.txb.object(param.withdraw_guard)],
|
|
257
|
-
typeArguments:[this.token_type],
|
|
258
|
-
})
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
if (passport) {
|
|
262
|
-
if (param.for_guard) {
|
|
263
|
-
return this.txb.moveCall({
|
|
264
|
-
target:Protocol.Instance().treasuryFn('withdraw_forGuard_with_passport') as FnCallType,
|
|
265
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
266
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index),
|
|
267
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(param.for_guard), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
268
|
-
typeArguments:[this.token_type],
|
|
269
|
-
})
|
|
270
|
-
} else {
|
|
271
|
-
return this.txb.moveCall({
|
|
272
|
-
target:Protocol.Instance().treasuryFn('withdraw_with_passport') as FnCallType,
|
|
273
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
274
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index),
|
|
275
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
276
|
-
typeArguments:[this.token_type],
|
|
277
|
-
})
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
if (param.for_guard) {
|
|
281
|
-
return this.txb.moveCall({
|
|
282
|
-
target:Protocol.Instance().treasuryFn('withdraw_forGuard') as FnCallType,
|
|
283
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
284
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index),
|
|
285
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(param.for_guard), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
286
|
-
typeArguments:[this.token_type],
|
|
287
|
-
})
|
|
288
|
-
} else {
|
|
289
|
-
return this.txb.moveCall({
|
|
290
|
-
target:Protocol.Instance().treasuryFn('withdraw') as FnCallType,
|
|
291
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|
|
292
|
-
this.txb.pure.vector('u64', param.items.map(v=>v.amount)), this.txb.pure.u64(param.index),
|
|
293
|
-
this.txb.pure.string(param.remark), for_obj, this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
294
|
-
typeArguments:[this.token_type],
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
set_description(description:string, passport?:PassportObject) {
|
|
302
|
-
if (!IsValidDesription(description)) {
|
|
303
|
-
ERROR(Errors.IsValidDesription, 'set_description.description');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (passport) {
|
|
307
|
-
this.txb.moveCall({
|
|
308
|
-
target:Protocol.Instance().treasuryFn('description_set_with_passport') as FnCallType,
|
|
309
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description),
|
|
310
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
311
|
-
typeArguments:[this.token_type],
|
|
312
|
-
})
|
|
313
|
-
} else {
|
|
314
|
-
this.txb.moveCall({
|
|
315
|
-
target:Protocol.Instance().treasuryFn('description_set') as FnCallType,
|
|
316
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
317
|
-
typeArguments:[this.token_type],
|
|
318
|
-
})
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
set_withdraw_mode(mode: Treasury_WithdrawMode, passport?: PassportObject) {
|
|
323
|
-
if (passport) {
|
|
324
|
-
this.txb.moveCall({
|
|
325
|
-
target:Protocol.Instance().treasuryFn('withdraw_mode_set_with_passport') as FnCallType,
|
|
326
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u8(mode), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
327
|
-
typeArguments:[this.token_type],
|
|
328
|
-
})
|
|
329
|
-
} else {
|
|
330
|
-
this.txb.moveCall({
|
|
331
|
-
target:Protocol.Instance().treasuryFn('withdraw_mode_set') as FnCallType,
|
|
332
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u8(mode), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
333
|
-
typeArguments:[this.token_type],
|
|
334
|
-
})
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
add_withdraw_guard(guard:string, amount:bigint, passport?:PassportObject) {
|
|
339
|
-
if (!IsValidAddress(guard)) {
|
|
340
|
-
ERROR(Errors.IsValidAddress, 'add_withdraw_guard.guard')
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (!IsValidU64(amount)) {
|
|
344
|
-
ERROR(Errors.IsValidU64, 'add_withdraw_guard.amount')
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (passport) {
|
|
348
|
-
this.txb.moveCall({
|
|
349
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_add_with_passport') as FnCallType,
|
|
350
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(guard), this.txb.pure.u64(amount),
|
|
351
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
352
|
-
typeArguments:[this.token_type],
|
|
353
|
-
})
|
|
354
|
-
} else {
|
|
355
|
-
this.txb.moveCall({
|
|
356
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_add') as FnCallType,
|
|
357
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(guard), this.txb.pure.u64(amount),
|
|
358
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
359
|
-
typeArguments:[this.token_type],
|
|
360
|
-
})
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
remove_withdraw_guard(guard:string[], removeall?:boolean, passport?:PassportObject) {
|
|
365
|
-
if (guard.length === 0 && !removeall) return ;
|
|
366
|
-
|
|
367
|
-
if (!IsValidArray(guard, IsValidAddress)) {
|
|
368
|
-
ERROR(Errors.IsValidArray, 'add_withdraw_guard.guard')
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (passport) {
|
|
372
|
-
if (removeall) {
|
|
373
|
-
this.txb.moveCall({
|
|
374
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_remove_all_with_passport') as FnCallType,
|
|
375
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
376
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
377
|
-
typeArguments:[this.token_type],
|
|
378
|
-
})
|
|
379
|
-
} else {
|
|
380
|
-
this.txb.moveCall({
|
|
381
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_remove_with_passport') as FnCallType,
|
|
382
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', guard),
|
|
383
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
384
|
-
typeArguments:[this.token_type],
|
|
385
|
-
})
|
|
386
|
-
}
|
|
387
|
-
} else {
|
|
388
|
-
if (removeall) {
|
|
389
|
-
this.txb.moveCall({
|
|
390
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_remove_all') as FnCallType,
|
|
391
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
392
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
393
|
-
typeArguments:[this.token_type],
|
|
394
|
-
})
|
|
395
|
-
} else {
|
|
396
|
-
this.txb.moveCall({
|
|
397
|
-
target:Protocol.Instance().treasuryFn('withdraw_guard_remove') as FnCallType,
|
|
398
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', guard),
|
|
399
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
400
|
-
typeArguments:[this.token_type],
|
|
401
|
-
})
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
change_permission(new_permission:PermissionObject) {
|
|
407
|
-
if (!Protocol.IsValidObjects([new_permission])) {
|
|
408
|
-
ERROR(Errors.IsValidObjects, 'change_permission.new_permission')
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
this.txb.moveCall({
|
|
412
|
-
target:Protocol.Instance().treasuryFn('permission_set') as FnCallType,
|
|
413
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
|
|
414
|
-
typeArguments:[this.token_type]
|
|
415
|
-
})
|
|
416
|
-
this.permission = new_permission
|
|
417
|
-
}
|
|
418
|
-
static parseObjectType = (chain_type?:string) : string => {
|
|
419
|
-
return parseObjectType(chain_type, 'treasury::Treasury<')
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
static MAX_WITHDRAW_GUARD_COUNT = 16;
|
|
424
|
-
}
|
|
425
|
-
|