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.
Files changed (48) hide show
  1. package/dist/arbitration.d.ts.map +1 -1
  2. package/dist/arbitration.js +21 -32
  3. package/dist/arbitration.js.map +1 -1
  4. package/dist/entity.d.ts +1 -0
  5. package/dist/entity.d.ts.map +1 -1
  6. package/dist/entity.js +12 -6
  7. package/dist/entity.js.map +1 -1
  8. package/dist/exception.d.ts +2 -1
  9. package/dist/exception.d.ts.map +1 -1
  10. package/dist/exception.js +1 -0
  11. package/dist/exception.js.map +1 -1
  12. package/dist/guard.d.ts.map +1 -1
  13. package/dist/guard.js +8 -4
  14. package/dist/guard.js.map +1 -1
  15. package/dist/payment.d.ts +2 -2
  16. package/dist/payment.d.ts.map +1 -1
  17. package/dist/payment.js +2 -2
  18. package/dist/payment.js.map +1 -1
  19. package/dist/protocol.d.ts +21 -19
  20. package/dist/protocol.d.ts.map +1 -1
  21. package/dist/protocol.js +211 -58
  22. package/dist/protocol.js.map +1 -1
  23. package/dist/service.d.ts +2 -2
  24. package/dist/service.d.ts.map +1 -1
  25. package/dist/service.js +5 -6
  26. package/dist/service.js.map +1 -1
  27. package/package.json +5 -2
  28. package/src/arbitration.ts +0 -551
  29. package/src/demand.ts +0 -300
  30. package/src/entity.ts +0 -171
  31. package/src/exception.ts +0 -37
  32. package/src/guard.ts +0 -810
  33. package/src/index.ts +0 -40
  34. package/src/machine.ts +0 -542
  35. package/src/passport.ts +0 -777
  36. package/src/payment.ts +0 -94
  37. package/src/permission.ts +0 -550
  38. package/src/progress.ts +0 -367
  39. package/src/protocol.ts +0 -549
  40. package/src/repository.ts +0 -680
  41. package/src/resource.ts +0 -155
  42. package/src/service.ts +0 -1349
  43. package/src/treasury.ts +0 -425
  44. package/src/utils.ts +0 -660
  45. package/src/wowok.ts +0 -70
  46. package/tsconfig.json +0 -30
  47. package/tsconfig.tsbuildinfo +0 -1
  48. package/webpack.config.cjs +0 -23
@@ -1,551 +0,0 @@
1
-
2
- import { IsValidArray, array_unique, IsValidTokenType, IsValidDesription, parseObjectType,
3
- IsValidAddress, IsValidEndpoint, IsValidU64, IsValidName,
4
- IsValidLocation, } from './utils.js'
5
- import { FnCallType, GuardObject, PassportObject, PermissionObject, CoinObject, Protocol,
6
- TxbObject, ArbitrationAddress, OrderObject, ArbObject, PaymentAddress, TreasuryObject,
7
- ArbAddress} from './protocol.js';
8
- import { ERROR, Errors } from './exception.js';
9
- import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
10
-
11
- export interface VotingGuard {
12
- guard: GuardObject,
13
- voting_weight:string | number | bigint, // bigint
14
- }
15
-
16
- export interface Vote {
17
- arb: ArbObject,
18
- voting_guard?: GuardObject,
19
- agrees: number[],
20
- }
21
-
22
- export interface Feedback {
23
- arb:ArbObject,
24
- feedback:string,
25
- indemnity?:string | number | bigint | null, // bigint
26
- }
27
-
28
- export interface Dispute {
29
- order: OrderObject,
30
- order_token_type: string,
31
- description: string,
32
- votable_proposition: string[],
33
- fee?: CoinObject,
34
- }
35
-
36
- export interface WithdrawFee {
37
- treasury: TreasuryObject,
38
- index: bigint | string | number,
39
- remark: string,
40
- for_object?: string,
41
- for_guard?: GuardObject,
42
- }
43
-
44
- export class Arbitration {
45
- protected pay_token_type;
46
- protected permission;
47
- protected object : TxbObject;
48
- protected txb;
49
-
50
- //static token2coin = (token:string) => { return '0x2::coin::Coin<' + token + '>'};
51
-
52
- get_pay_type() { return this.pay_token_type }
53
- get_object() { return this.object }
54
- private constructor(txb: TransactionBlock, pay_token_type:string, permission:PermissionObject) {
55
- this.pay_token_type = pay_token_type
56
- this.txb = txb
57
- this.permission = permission
58
- this.object = ''
59
- }
60
- static From(txb: TransactionBlock, token_type:string, permission:PermissionObject, object:TxbObject) : Arbitration {
61
- let s = new Arbitration(txb, token_type, permission);
62
- s.object = Protocol.TXB_OBJECT(txb, object);
63
- return s
64
- }
65
- static New(txb: TransactionBlock, token_type:string, permission:PermissionObject, description:string,
66
- fee:bigint|number|string, withdrawTreasury:TreasuryObject, passport?:PassportObject) : Arbitration {
67
- if (!Protocol.IsValidObjects([permission, withdrawTreasury])) {
68
- ERROR(Errors.IsValidObjects)
69
- }
70
- if (!IsValidTokenType(token_type)) {
71
- ERROR(Errors.IsValidTokenType, 'New.token_type')
72
- }
73
- if (!IsValidDesription(description)) {
74
- ERROR(Errors.IsValidDesription)
75
- }
76
- if (!IsValidU64(fee)) {
77
- ERROR(Errors.IsValidU64, 'New.fee')
78
- }
79
-
80
- let pay_token_type = token_type;
81
- let obj = new Arbitration(txb, pay_token_type, permission);
82
-
83
- if (passport) {
84
- obj.object = txb.moveCall({
85
- target:Protocol.Instance().arbitrationFn('new_with_passport') as FnCallType,
86
- arguments:[passport, txb.pure.string(description), txb.pure.u64(fee), Protocol.TXB_OBJECT(txb, withdrawTreasury), Protocol.TXB_OBJECT(txb, permission)],
87
- typeArguments:[pay_token_type],
88
- })
89
- } else {
90
- obj.object = txb.moveCall({
91
- target:Protocol.Instance().arbitrationFn('new') as FnCallType,
92
- arguments:[txb.pure.string(description), txb.pure.u64(fee), Protocol.TXB_OBJECT(txb, withdrawTreasury), Protocol.TXB_OBJECT(txb, permission)],
93
- typeArguments:[pay_token_type],
94
- })
95
- }
96
- return obj
97
- }
98
-
99
- launch() : ArbitrationAddress {
100
- return this.txb.moveCall({
101
- target:Protocol.Instance().arbitrationFn('create') as FnCallType,
102
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
103
- typeArguments:[this.pay_token_type]
104
- })
105
- }
106
-
107
- set_location(location:string, passport?:PassportObject) {
108
- if (!IsValidLocation(location)) {
109
- ERROR(Errors.IsValidLocation, `Arbitration.set_location.location ${location}`)
110
- }
111
- if (passport) {
112
- this.txb.moveCall({
113
- target:Protocol.Instance().arbitrationFn('location_set_with_passport') as FnCallType,
114
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(location), Protocol.TXB_OBJECT(this.txb, this.permission)],
115
- typeArguments:[this.pay_token_type]
116
- })
117
- } else {
118
- this.txb.moveCall({
119
- target:Protocol.Instance().arbitrationFn('location_set') as FnCallType,
120
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(location), Protocol.TXB_OBJECT(this.txb, this.permission)],
121
- typeArguments:[this.pay_token_type]
122
- })
123
- }
124
- }
125
-
126
- set_description(description:string, passport?:PassportObject) {
127
- if (!IsValidDesription(description)) {
128
- ERROR(Errors.IsValidDesription, 'set_description.description')
129
- }
130
-
131
- if (passport) {
132
- this.txb.moveCall({
133
- target:Protocol.Instance().arbitrationFn('description_set_with_passport') as FnCallType,
134
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
135
- typeArguments:[this.pay_token_type]
136
- })
137
- } else {
138
- this.txb.moveCall({
139
- target:Protocol.Instance().arbitrationFn('description_set') as FnCallType,
140
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
141
- typeArguments:[this.pay_token_type]
142
- })
143
- }
144
- }
145
-
146
- set_fee(fee:bigint, passport?:PassportObject) {
147
- if (!IsValidU64(fee)) {
148
- ERROR(Errors.IsValidU64, 'set_fee.fee')
149
- }
150
-
151
- if (passport) {
152
- this.txb.moveCall({
153
- target:Protocol.Instance().arbitrationFn('fee_set_with_passport') as FnCallType,
154
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u64(fee), Protocol.TXB_OBJECT(this.txb, this.permission)],
155
- typeArguments:[this.pay_token_type]
156
- })
157
- } else {
158
- this.txb.moveCall({
159
- target:Protocol.Instance().arbitrationFn('fee_set') as FnCallType,
160
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u64(fee), Protocol.TXB_OBJECT(this.txb, this.permission)],
161
- typeArguments:[this.pay_token_type]
162
- })
163
- }
164
- }
165
-
166
- set_endpoint(endpoint?:string|null, passport?:PassportObject) {
167
- if (endpoint && !IsValidEndpoint(endpoint)) {
168
- ERROR(Errors.IsValidEndpoint, 'set_endpoint.endpoint')
169
- }
170
-
171
- if (passport) {
172
- if (endpoint) {
173
- this.txb.moveCall({
174
- target:Protocol.Instance().arbitrationFn('endpoint_set_with_passport') as FnCallType,
175
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(endpoint), Protocol.TXB_OBJECT(this.txb, this.permission)],
176
- typeArguments:[this.pay_token_type]
177
- })
178
- } else {
179
- this.txb.moveCall({
180
- target:Protocol.Instance().arbitrationFn('endpoint_none_with_passport') as FnCallType,
181
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
182
- typeArguments:[this.pay_token_type]
183
- })
184
- }
185
- } else {
186
- if (endpoint) {
187
- this.txb.moveCall({
188
- target:Protocol.Instance().arbitrationFn('endpoint_set') as FnCallType,
189
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(endpoint), Protocol.TXB_OBJECT(this.txb, this.permission)],
190
- typeArguments:[this.pay_token_type]
191
- })
192
- } else {
193
- this.txb.moveCall({
194
- target:Protocol.Instance().arbitrationFn('endpoint_none') as FnCallType,
195
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
196
- typeArguments:[this.pay_token_type]
197
- })
198
- }
199
- }
200
- }
201
-
202
- add_voting_guard(guard: VotingGuard[], passport?:PassportObject) {
203
- if (guard.length === 0) return ;
204
- if (!IsValidArray(guard, (g:VotingGuard) => Protocol.IsValidObjects([g.guard]) && IsValidU64(g.voting_weight))) {
205
- ERROR(Errors.IsValidArray, 'add_voting_guard.guard')
206
- }
207
- if (passport) {
208
- guard.forEach(v => {
209
- this.txb.moveCall({
210
- target:Protocol.Instance().arbitrationFn('voting_guard_add_with_passport') as FnCallType,
211
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, v.guard),
212
- this.txb.pure.u64(v.voting_weight), Protocol.TXB_OBJECT(this.txb, this.permission)],
213
- typeArguments:[this.pay_token_type]
214
- })
215
- })
216
- } else {
217
- guard.forEach(v => {
218
- this.txb.moveCall({
219
- target:Protocol.Instance().arbitrationFn('voting_guard_add') as FnCallType,
220
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, v.guard),
221
- this.txb.pure.u64(v.voting_weight), Protocol.TXB_OBJECT(this.txb, this.permission)],
222
- typeArguments:[this.pay_token_type]
223
- })
224
- })
225
- }
226
- }
227
- remove_voting_guard(guard: string[], removeall?:boolean, passport?:PassportObject) {
228
- if (!removeall && guard.length===0) return;
229
-
230
- if (!IsValidArray(guard, IsValidAddress)) {
231
- ERROR(Errors.IsValidArray, 'remove_voting_guard.guard');
232
- }
233
-
234
- if (passport) {
235
- if (removeall) {
236
- this.txb.moveCall({
237
- target:Protocol.Instance().arbitrationFn('voting_guard_removeall_with_passport') as FnCallType,
238
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
239
- typeArguments:[this.pay_token_type]
240
- })
241
- } else {
242
- this.txb.moveCall({
243
- target:Protocol.Instance().arbitrationFn('voting_guard_remove_with_passport') as FnCallType,
244
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', guard),
245
- Protocol.TXB_OBJECT(this.txb, this.permission)],
246
- typeArguments:[this.pay_token_type]
247
- })
248
- }
249
- } else {
250
- if (removeall) {
251
- this.txb.moveCall({
252
- target:Protocol.Instance().arbitrationFn('voting_guard_removeall') as FnCallType,
253
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
254
- typeArguments:[this.pay_token_type]
255
- })
256
- } else {
257
- this.txb.moveCall({
258
- target:Protocol.Instance().arbitrationFn('voting_guard_remove') as FnCallType,
259
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', guard),
260
- Protocol.TXB_OBJECT(this.txb, this.permission)],
261
- typeArguments:[this.pay_token_type]
262
- })
263
- }
264
- }
265
- }
266
-
267
- set_guard(apply_guard?:string, passport?:PassportObject) {
268
- if (apply_guard && !IsValidAddress(apply_guard)) {
269
- ERROR(Errors.IsValidAddress, 'set_guard.apply_guard')
270
- }
271
-
272
- if (passport) {
273
- if (apply_guard) {
274
- this.txb.moveCall({
275
- target:Protocol.Instance().arbitrationFn('usage_guard_set_with_passport') as FnCallType,
276
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(apply_guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
277
- typeArguments:[this.pay_token_type]
278
- })
279
- } else {
280
- this.txb.moveCall({
281
- target:Protocol.Instance().arbitrationFn('usage_guard_none_with_passport') as FnCallType,
282
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
283
- typeArguments:[this.pay_token_type]
284
- })
285
- }
286
- } else {
287
- if (apply_guard) {
288
- this.txb.moveCall({
289
- target:Protocol.Instance().arbitrationFn('usage_guard_set') as FnCallType,
290
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(apply_guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
291
- typeArguments:[this.pay_token_type]
292
- })
293
- } else {
294
- this.txb.moveCall({
295
- target:Protocol.Instance().arbitrationFn('usage_guard_none') as FnCallType,
296
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
297
- typeArguments:[this.pay_token_type]
298
- })
299
- }
300
- }
301
- }
302
- pause(pause:boolean, passport?:PassportObject) {
303
- if (passport) {
304
- this.txb.moveCall({
305
- target:Protocol.Instance().arbitrationFn('pause_with_passport') as FnCallType,
306
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(pause), Protocol.TXB_OBJECT(this.txb, this.permission)],
307
- typeArguments:[this.pay_token_type]
308
- })
309
- } else {
310
- this.txb.moveCall({
311
- target:Protocol.Instance().arbitrationFn('pause') as FnCallType,
312
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(pause), Protocol.TXB_OBJECT(this.txb, this.permission)],
313
- typeArguments:[this.pay_token_type]
314
- })
315
- }
316
- }
317
- vote(param:Vote, passport?:PassportObject) {
318
- if (param.voting_guard && !Protocol.IsValidObjects([param.voting_guard])) {
319
- ERROR(Errors.IsValidObjects, 'vote.param.voting_guard')
320
- }
321
- if (!IsValidArray(param.agrees, (v:number)=> IsValidU64(v) && v < Arbitration.MAX_PROPOSITION_COUNT)) {
322
- ERROR(Errors.IsValidArray, 'vote.param.agrees')
323
- }
324
- if (!Protocol.IsValidObjects([param.arb])) {
325
- ERROR(Errors.IsValidObjects, 'vote.param.arb')
326
- }
327
-
328
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
329
- if (passport) {
330
- if (param.voting_guard) {
331
- this.txb.moveCall({
332
- target:Protocol.Instance().arbitrationFn('vote_with_passport') as FnCallType,
333
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, param.voting_guard), Protocol.TXB_OBJECT(this.txb, this.object),
334
- Protocol.TXB_OBJECT(this.txb, param.arb), this.txb.pure.vector('u8', param.agrees),
335
- this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
336
- typeArguments:[this.pay_token_type]
337
- })
338
- } else {
339
- this.txb.moveCall({
340
- target:Protocol.Instance().arbitrationFn('vote2_with_passport') as FnCallType,
341
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.arb), this.txb.pure.vector('u8', param.agrees),
342
- this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
343
- typeArguments:[this.pay_token_type]
344
- })
345
- }
346
- } else {
347
- this.txb.moveCall({
348
- target:Protocol.Instance().arbitrationFn('vote') as FnCallType,
349
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.arb), this.txb.pure.vector('u8', param.agrees),
350
- this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
351
- typeArguments:[this.pay_token_type]
352
- })
353
- }
354
- }
355
-
356
- arbitration(param:Feedback, passport?:PassportObject) {
357
- if (!IsValidDesription(param.feedback)) {
358
- ERROR(Errors.IsValidDesription, 'arbitration.param.feedback')
359
- }
360
- if (!Protocol.IsValidObjects([param.arb])) {
361
- ERROR(Errors.IsValidObjects, 'arbitration.param.arb')
362
- }
363
-
364
- if (param.indemnity && !IsValidU64(param.indemnity)) {
365
- ERROR(Errors.IsValidU64, 'arbitration.param.indemnity')
366
- }
367
- let ind = this.txb.pure.option('u64', param.indemnity ? param.indemnity : undefined);
368
-
369
- if (passport) {
370
- this.txb.moveCall({
371
- target:Protocol.Instance().arbitrationFn('arbitration_with_passport') as FnCallType,
372
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
373
- Protocol.TXB_OBJECT(this.txb, param.arb), this.txb.pure.string(param.feedback), ind, Protocol.TXB_OBJECT(this.txb, this.permission)],
374
- typeArguments:[this.pay_token_type]
375
- })
376
- } else {
377
- this.txb.moveCall({
378
- target:Protocol.Instance().arbitrationFn('arbitration') as FnCallType,
379
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
380
- Protocol.TXB_OBJECT(this.txb, param.arb), this.txb.pure.string(param.feedback), ind, Protocol.TXB_OBJECT(this.txb, this.permission)],
381
- typeArguments:[this.pay_token_type]
382
- })
383
- }
384
- }
385
-
386
- withdraw_fee(arb:ArbObject, param:WithdrawFee, passport?:PassportObject) : PaymentAddress {
387
- if (!Protocol.IsValidObjects([arb, param.treasury])) {
388
- ERROR(Errors.IsValidObjects, 'withdraw_fee.arb or treasury')
389
- }
390
- if (param?.for_guard && !Protocol.IsValidObjects([param.for_guard])) {
391
- ERROR(Errors.IsValidObjects, 'withdraw_fee.param.for_guard')
392
- }
393
- if (param?.for_object && !IsValidAddress(param.for_object)) {
394
- ERROR(Errors.IsValidAddress, 'withdraw_fee.param.for_object')
395
- }
396
- if (!IsValidDesription(param.remark)) {
397
- ERROR(Errors.IsValidDesription, 'withdraw_fee.param.remark')
398
- }
399
- if (!IsValidU64(param.index)) {
400
- ERROR(Errors.IsValidU64, 'withdraw_fee.param.index')
401
- }
402
- const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
403
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
404
-
405
- if (passport) {
406
- if (param.for_guard) {
407
- return this.txb.moveCall({
408
- target:Protocol.Instance().arbitrationFn('withdraw_forGuard_with_passport') as FnCallType,
409
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arb), Protocol.TXB_OBJECT(this.txb, param.treasury),
410
- for_obj, Protocol.TXB_OBJECT(this.txb, param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock),
411
- Protocol.TXB_OBJECT(this.txb, this.permission)],
412
- typeArguments:[this.pay_token_type]
413
- })
414
- } else {
415
- return this.txb.moveCall({
416
- target:Protocol.Instance().arbitrationFn('withdraw_with_passport') as FnCallType,
417
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arb), Protocol.TXB_OBJECT(this.txb, param.treasury),
418
- for_obj, this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
419
- typeArguments:[this.pay_token_type]
420
- })
421
- }
422
- } else {
423
- if (param.for_guard) {
424
- return this.txb.moveCall({
425
- target:Protocol.Instance().arbitrationFn('withdraw_forGuard') as FnCallType,
426
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arb), Protocol.TXB_OBJECT(this.txb, param.treasury),
427
- for_obj, Protocol.TXB_OBJECT(this.txb, param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock),
428
- Protocol.TXB_OBJECT(this.txb, this.permission)],
429
- typeArguments:[this.pay_token_type]
430
- })
431
- } else {
432
- return this.txb.moveCall({
433
- target:Protocol.Instance().arbitrationFn('withdraw') as FnCallType,
434
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arb), Protocol.TXB_OBJECT(this.txb, param.treasury),
435
- for_obj, this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
436
- typeArguments:[this.pay_token_type]
437
- })
438
- }
439
- }
440
- }
441
-
442
- set_withdrawTreasury(treasury:TreasuryObject, passport?:PassportObject) {
443
- if (!Protocol.IsValidObjects([treasury])) {
444
- ERROR(Errors.IsValidObjects, 'set_withdrawTreasury.treasury')
445
- }
446
- if (passport) {
447
- this.txb.moveCall({
448
- target:Protocol.Instance().arbitrationFn('withdraw_treasury_set_with_passport') as FnCallType,
449
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
450
- Protocol.TXB_OBJECT(this.txb, treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
451
- typeArguments:[this.pay_token_type]
452
- })
453
- } else {
454
- this.txb.moveCall({
455
- target:Protocol.Instance().arbitrationFn('withdraw_treasury_set') as FnCallType,
456
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
457
- Protocol.TXB_OBJECT(this.txb, treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
458
- typeArguments:[this.pay_token_type]
459
- })
460
- }
461
- }
462
-
463
- arb(param:Dispute, passport?:PassportObject) : ArbObject {
464
- if (!Protocol.IsValidObjects([param.order])) {
465
- ERROR(Errors.IsValidObjects, 'arb.param.order')
466
- }
467
- if (!IsValidTokenType(param.order_token_type)) {
468
- ERROR(Errors.IsValidTokenType, 'arb.param.order_token_type')
469
- }
470
- if (!IsValidDesription(param.description)) {
471
- ERROR(Errors.IsValidDesription, 'arb.param.description')
472
- }
473
- if (!IsValidArray(param.votable_proposition, IsValidName)) {
474
- ERROR(Errors.IsValidArray, 'arb.param.votable_proposition')
475
- }
476
-
477
- if (passport) {
478
- if (param.fee) {
479
- return this.txb.moveCall({
480
- target:Protocol.Instance().arbitrationFn('dispute_with_passport') as FnCallType,
481
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.order), this.txb.pure.string(param.description),
482
- this.txb.pure.vector('string', array_unique(param.votable_proposition)), Protocol.TXB_OBJECT(this.txb, param.fee)],
483
- typeArguments:[this.pay_token_type, param.order_token_type]
484
- })
485
- } else {
486
- return this.txb.moveCall({
487
- target:Protocol.Instance().arbitrationFn('free_dispute_with_passport') as FnCallType,
488
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.order), this.txb.pure.string(param.description),
489
- this.txb.pure.vector('string', array_unique(param.votable_proposition))],
490
- typeArguments:[this.pay_token_type, param.order_token_type]
491
- })
492
- }
493
- } else {
494
- if (param.fee) {
495
- return this.txb.moveCall({
496
- target:Protocol.Instance().arbitrationFn('dispute') as FnCallType,
497
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.order), this.txb.pure.string(param.description),
498
- this.txb.pure.vector('string', array_unique(param.votable_proposition)), Protocol.TXB_OBJECT(this.txb, param.fee)],
499
- typeArguments:[this.pay_token_type, param.order_token_type]
500
- })
501
- } else {
502
- return this.txb.moveCall({
503
- target:Protocol.Instance().arbitrationFn('free_dispute') as FnCallType,
504
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, param.order), this.txb.pure.string(param.description),
505
- this.txb.pure.vector('string', array_unique(param.votable_proposition))],
506
- typeArguments:[this.pay_token_type, param.order_token_type]
507
- })
508
- }
509
- }
510
- }
511
-
512
- arb_launch(arb:ArbObject) : ArbAddress {
513
- return this.txb.moveCall({
514
- target:Protocol.Instance().arbFn('create') as FnCallType,
515
- arguments:[Protocol.TXB_OBJECT(this.txb, arb)],
516
- typeArguments:[this.pay_token_type]
517
- })
518
- }
519
-
520
- dispute(param:Dispute, passport?:PassportObject) : ArbAddress {
521
- const arb = this.arb(param, passport);
522
- return this.arb_launch(arb)
523
- }
524
-
525
- change_permission(new_permission:PermissionObject) {
526
- if (!Protocol.IsValidObjects([new_permission])) {
527
- ERROR(Errors.IsValidObjects)
528
- }
529
-
530
- this.txb.moveCall({
531
- target:Protocol.Instance().arbitrationFn('permission_set') as FnCallType,
532
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
533
- typeArguments:[this.pay_token_type]
534
- })
535
- this.permission = new_permission
536
- }
537
-
538
- static parseObjectType = (chain_type:string | undefined | null) : string => {
539
- return parseObjectType(chain_type, 'arbitration::Arbitration<')
540
- }
541
-
542
- static parseArbObjectType = (chain_type:string | undefined | null) : string => {
543
- return parseObjectType(chain_type, 'arb::Arb<')
544
- }
545
-
546
- static queryArbVoted = () => {
547
-
548
- }
549
- static MAX_PROPOSITION_COUNT = 16;
550
- static MAX_VOTING_GUARD_COUNT = 16;
551
- }