wowok 1.5.38 → 1.5.39
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/arbitration.ts +80 -12
- package/src/guard.ts +1 -0
- package/src/payment.ts +1 -1
- package/src/permission.ts +2 -0
- package/src/protocol.ts +4 -4
- package/src/treasury.ts +2 -3
package/package.json
CHANGED
package/src/arbitration.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IsValidArray, array_unique, IsValidTokenType, IsValidDesription, parseObjectType,
|
|
2
2
|
IsValidAddress, IsValidEndpoint, IsValidU64, IsValidName, } from './utils'
|
|
3
3
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, CoinObject, Protocol,
|
|
4
|
-
TxbObject, ArbitrationAddress, OrderObject, ArbObject} from './protocol';
|
|
4
|
+
TxbObject, ArbitrationAddress, OrderObject, ArbObject, PaymentAddress, TreasuryObject} from './protocol';
|
|
5
5
|
import { ERROR, Errors } from './exception';
|
|
6
6
|
import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
|
|
7
7
|
|
|
@@ -30,6 +30,14 @@ export interface Dispute {
|
|
|
30
30
|
fee?: CoinObject,
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export interface WithdrawFee {
|
|
34
|
+
treasury: TreasuryObject,
|
|
35
|
+
index: bigint,
|
|
36
|
+
remark: string,
|
|
37
|
+
for_object?: string,
|
|
38
|
+
for_guard?: GuardObject,
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
export class Arbitration {
|
|
34
42
|
protected pay_token_type;
|
|
35
43
|
protected permission;
|
|
@@ -52,8 +60,8 @@ export class Arbitration {
|
|
|
52
60
|
return s
|
|
53
61
|
}
|
|
54
62
|
static New(txb: TransactionBlock, token_type:string, permission:PermissionObject, description:string,
|
|
55
|
-
fee:bigint, passport?:PassportObject) : Arbitration {
|
|
56
|
-
if (!Protocol.IsValidObjects([permission])) {
|
|
63
|
+
fee:bigint, withdrawTreasury:TreasuryObject, passport?:PassportObject) : Arbitration {
|
|
64
|
+
if (!Protocol.IsValidObjects([permission, withdrawTreasury])) {
|
|
57
65
|
ERROR(Errors.IsValidObjects)
|
|
58
66
|
}
|
|
59
67
|
if (!IsValidTokenType(token_type)) {
|
|
@@ -72,13 +80,13 @@ export class Arbitration {
|
|
|
72
80
|
if (passport) {
|
|
73
81
|
obj.object = txb.moveCall({
|
|
74
82
|
target:Protocol.Instance().ArbitrationFn('new_with_passport') as FnCallType,
|
|
75
|
-
arguments:[passport, txb.pure.string(description), txb.pure.u64(fee), Protocol.TXB_OBJECT(txb, permission)],
|
|
83
|
+
arguments:[passport, txb.pure.string(description), txb.pure.u64(fee), txb.object(withdrawTreasury), Protocol.TXB_OBJECT(txb, permission)],
|
|
76
84
|
typeArguments:[pay_token_type],
|
|
77
85
|
})
|
|
78
86
|
} else {
|
|
79
87
|
obj.object = txb.moveCall({
|
|
80
88
|
target:Protocol.Instance().ArbitrationFn('new') as FnCallType,
|
|
81
|
-
arguments:[txb.pure.string(description), txb.pure.u64(fee), Protocol.TXB_OBJECT(txb, permission)],
|
|
89
|
+
arguments:[txb.pure.string(description), txb.pure.u64(fee), txb.object(withdrawTreasury), Protocol.TXB_OBJECT(txb, permission)],
|
|
82
90
|
typeArguments:[pay_token_type],
|
|
83
91
|
})
|
|
84
92
|
}
|
|
@@ -353,22 +361,78 @@ export class Arbitration {
|
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
|
|
356
|
-
withdraw_fee(arb:ArbObject, passport?:PassportObject) {
|
|
357
|
-
if (!Protocol.IsValidObjects([arb])) {
|
|
358
|
-
ERROR(Errors.IsValidObjects, 'withdraw_fee.arb')
|
|
364
|
+
withdraw_fee(arb:ArbObject, param:WithdrawFee, passport?:PassportObject) : PaymentAddress {
|
|
365
|
+
if (!Protocol.IsValidObjects([arb, param.treasury])) {
|
|
366
|
+
ERROR(Errors.IsValidObjects, 'withdraw_fee.arb or treasury')
|
|
367
|
+
}
|
|
368
|
+
if (param?.for_guard && !Protocol.IsValidObjects([param.for_guard])) {
|
|
369
|
+
ERROR(Errors.IsValidObjects, 'withdraw_fee.param.for_guard')
|
|
370
|
+
}
|
|
371
|
+
if (param?.for_object && !IsValidAddress(param.for_object)) {
|
|
372
|
+
ERROR(Errors.IsValidAddress, 'withdraw_fee.param.for_object')
|
|
373
|
+
}
|
|
374
|
+
if (!IsValidDesription(param.remark)) {
|
|
375
|
+
ERROR(Errors.IsValidDesription, 'withdraw_fee.param.remark')
|
|
376
|
+
}
|
|
377
|
+
if (!IsValidU64(param.index)) {
|
|
378
|
+
ERROR(Errors.IsValidU64, 'withdraw_fee.param.index')
|
|
379
|
+
}
|
|
380
|
+
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
|
|
381
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
382
|
+
|
|
383
|
+
if (passport) {
|
|
384
|
+
if (param.for_guard) {
|
|
385
|
+
return this.txb.moveCall({
|
|
386
|
+
target:Protocol.Instance().ArbitrationFn('withdraw_forGuard_with_passport') as FnCallType,
|
|
387
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(arb), this.txb.object(param.treasury),
|
|
388
|
+
for_obj, this.txb.object(param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock),
|
|
389
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
390
|
+
typeArguments:[this.pay_token_type]
|
|
391
|
+
})
|
|
392
|
+
} else {
|
|
393
|
+
return this.txb.moveCall({
|
|
394
|
+
target:Protocol.Instance().ArbitrationFn('withdraw_with_passport') as FnCallType,
|
|
395
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(arb), this.txb.object(param.treasury),
|
|
396
|
+
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)],
|
|
397
|
+
typeArguments:[this.pay_token_type]
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
if (param.for_guard) {
|
|
402
|
+
return this.txb.moveCall({
|
|
403
|
+
target:Protocol.Instance().ArbitrationFn('withdraw_forGuard') as FnCallType,
|
|
404
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(arb), this.txb.object(param.treasury),
|
|
405
|
+
for_obj, this.txb.object(param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark), this.txb.object(clock),
|
|
406
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
407
|
+
typeArguments:[this.pay_token_type]
|
|
408
|
+
})
|
|
409
|
+
} else {
|
|
410
|
+
return this.txb.moveCall({
|
|
411
|
+
target:Protocol.Instance().ArbitrationFn('withdraw') as FnCallType,
|
|
412
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(arb), this.txb.object(param.treasury),
|
|
413
|
+
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)],
|
|
414
|
+
typeArguments:[this.pay_token_type]
|
|
415
|
+
})
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
set_withdrawTreasury(treasury:TreasuryObject, passport?:PassportObject) {
|
|
421
|
+
if (!Protocol.IsValidObjects([treasury])) {
|
|
422
|
+
ERROR(Errors.IsValidObjects, 'set_withdrawTreasury.treasury')
|
|
359
423
|
}
|
|
360
424
|
if (passport) {
|
|
361
425
|
this.txb.moveCall({
|
|
362
|
-
target:Protocol.Instance().ArbitrationFn('
|
|
426
|
+
target:Protocol.Instance().ArbitrationFn('withdraw_treasury_set_with_passport') as FnCallType,
|
|
363
427
|
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
364
|
-
this.txb.object(
|
|
428
|
+
this.txb.object(treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
365
429
|
typeArguments:[this.pay_token_type]
|
|
366
430
|
})
|
|
367
431
|
} else {
|
|
368
432
|
this.txb.moveCall({
|
|
369
|
-
target:Protocol.Instance().ArbitrationFn('
|
|
433
|
+
target:Protocol.Instance().ArbitrationFn('withdraw_treasury_set') as FnCallType,
|
|
370
434
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
371
|
-
this.txb.object(
|
|
435
|
+
this.txb.object(treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
372
436
|
typeArguments:[this.pay_token_type]
|
|
373
437
|
})
|
|
374
438
|
}
|
|
@@ -443,6 +507,10 @@ export class Arbitration {
|
|
|
443
507
|
static parseArbObjectType = (chain_type:string | undefined | null) : string => {
|
|
444
508
|
return parseObjectType(chain_type, 'arb::Arb<')
|
|
445
509
|
}
|
|
510
|
+
|
|
511
|
+
static queryArbVoted = () => {
|
|
512
|
+
|
|
513
|
+
}
|
|
446
514
|
static MAX_PROPOSITION_COUNT = 16;
|
|
447
515
|
static MAX_VOTING_GUARD_COUNT = 16;
|
|
448
516
|
}
|
package/src/guard.ts
CHANGED
|
@@ -340,6 +340,7 @@ export class Guard {
|
|
|
340
340
|
[MODULES.arbitration, 'Number of Voting Guard', 1507, [], ValueType.TYPE_U64, 'Number of voting guards.', []],
|
|
341
341
|
[MODULES.arbitration, 'Has Voting Guard', 1508, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has the voting Guard added?', ['guard address']],
|
|
342
342
|
[MODULES.arbitration, 'Voting Weight', 1509, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Voting weight of the voting Guard.', ['guard address']],
|
|
343
|
+
[MODULES.arbitration, 'Treasury', 1510, [], ValueType.TYPE_ADDRESS, 'The address of the Treasury where fees was collected at the time of withdrawal.', []],
|
|
343
344
|
|
|
344
345
|
[MODULES.arb, 'Order', 1600, [], ValueType.TYPE_ADDRESS, 'Order under arbitration.', []],
|
|
345
346
|
[MODULES.arb, 'Arbitration', 1601, [], ValueType.TYPE_ADDRESS, "Arbitration object address.", []],
|
package/src/payment.ts
CHANGED
|
@@ -50,7 +50,7 @@ export function create_payment(txb:TransactionBlock, pay_token_type:string, para
|
|
|
50
50
|
})
|
|
51
51
|
} else {
|
|
52
52
|
return txb.moveCall({
|
|
53
|
-
target:Protocol.Instance().PaymentFn('
|
|
53
|
+
target:Protocol.Instance().PaymentFn('create') as FnCallType,
|
|
54
54
|
arguments:[txb.pure.vector('address', param.receiver.map((i)=>i.address)), txb.makeMoveVec({elements:param.receiver.map((i)=>i.coin)}),
|
|
55
55
|
obj, txb.pure.u64(param.business_index), txb.pure.string(param.business_remark), txb.object(clock)],
|
|
56
56
|
typeArguments:[pay_token_type],
|
package/src/permission.ts
CHANGED
|
@@ -98,6 +98,7 @@ export enum PermissionIndex {
|
|
|
98
98
|
arbitration_vote = 807,
|
|
99
99
|
arbitration_arbitration = 808,
|
|
100
100
|
arbitration_withdraw = 809,
|
|
101
|
+
arbitration_treasury = 810,
|
|
101
102
|
|
|
102
103
|
user_defined_start = 1000,
|
|
103
104
|
}
|
|
@@ -217,6 +218,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
217
218
|
{index:PermissionIndex.arbitration_voting_guard, name: 'Voting Guard', description:'Add/Remove voting Guard', module: 'arbitration'},
|
|
218
219
|
{index:PermissionIndex.arbitration_vote, name: 'Vote', description:'Vote on the application for arbitration', module: 'arbitration'},
|
|
219
220
|
{index:PermissionIndex.arbitration_withdraw, name: 'Withdraw', description:'Withdraw the arbitration fee', module: 'arbitration'},
|
|
221
|
+
{index:PermissionIndex.arbitration_treasury, name: 'Withdraw', description:'Set Treasury that fees was collected at the time of withdrawal', module: 'arbitration'},
|
|
220
222
|
]
|
|
221
223
|
|
|
222
224
|
export type PermissionIndexType = PermissionIndex | number;
|
package/src/protocol.ts
CHANGED
|
@@ -220,13 +220,13 @@ const TESTNET = {
|
|
|
220
220
|
}
|
|
221
221
|
*/
|
|
222
222
|
const TESTNET = {
|
|
223
|
-
wowok: "
|
|
224
|
-
wowok_origin:'
|
|
223
|
+
wowok: "0x1633497f1d7a9cdb7f8afc619fb25e138dcfa3b04d8685a0b3f266c5f4c33d37",
|
|
224
|
+
wowok_origin:'0x1633497f1d7a9cdb7f8afc619fb25e138dcfa3b04d8685a0b3f266c5f4c33d37' ,
|
|
225
225
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
226
226
|
base_origin: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
227
227
|
|
|
228
|
-
wowok_object: '
|
|
229
|
-
entity_object: '
|
|
228
|
+
wowok_object: '0x2806f245ec96a33c9dcb1b03c569f262e94f00d8ae9e759f8c8edbcffdb99986',
|
|
229
|
+
entity_object: '0x2e90eeafd6df01a92704ffc3420f18801626403b322b1a0267bf4d6db268037a',
|
|
230
230
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
231
231
|
}
|
|
232
232
|
const MAINNET = {
|
package/src/treasury.ts
CHANGED
|
@@ -154,7 +154,7 @@ export class Treasury {
|
|
|
154
154
|
ERROR(Errors.InvalidParam, 'deposit.param.index')
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
const for_obj = this.txb.pure.option('address', param.for_object
|
|
157
|
+
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object: undefined);
|
|
158
158
|
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
159
159
|
if (passport) {
|
|
160
160
|
if (param.for_guard) {
|
|
@@ -240,7 +240,7 @@ export class Treasury {
|
|
|
240
240
|
ERROR(Errors.IsValidAddress, 'withdraw.param.withdraw_guard')
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
const for_obj = this.txb.pure.option('address', param.for_object
|
|
243
|
+
const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
|
|
244
244
|
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
245
245
|
|
|
246
246
|
if (param.withdraw_guard && passport) { //@ dont need passport, use withdraw guard!
|
|
@@ -290,7 +290,6 @@ export class Treasury {
|
|
|
290
290
|
typeArguments:[this.token_type],
|
|
291
291
|
})
|
|
292
292
|
} else {
|
|
293
|
-
console.log(param)
|
|
294
293
|
return this.txb.moveCall({
|
|
295
294
|
target:Protocol.Instance().TreasuryFn('withdraw') as FnCallType,
|
|
296
295
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', param.items.map(v=>v.address)),
|