wowok 1.5.39 → 1.5.40
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/protocol.ts +4 -4
- package/src/service.ts +51 -31
package/package.json
CHANGED
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: "0xfa33358cf5f883038d124855567972241cd7036381fbc150a2208ab0e5939621",
|
|
224
|
+
wowok_origin:'0xfa33358cf5f883038d124855567972241cd7036381fbc150a2208ab0e5939621' ,
|
|
225
225
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
226
226
|
base_origin: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
227
227
|
|
|
228
|
-
wowok_object: '
|
|
229
|
-
entity_object: '
|
|
228
|
+
wowok_object: '0x459ed2fd2ad4aac9fd417d50584fae607ee557508dcb9b9f55722e0d18ed81ab',
|
|
229
|
+
entity_object: '0xfeb95d277598ebb8a358bfda3c62a32d7622de9af7ec3219e67c5749e020f12b',
|
|
230
230
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
231
231
|
}
|
|
232
232
|
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) {
|