wowok 1.5.36 → 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 +3 -2
- package/src/arbitration.ts +516 -0
- package/src/guard.ts +14 -26
- package/src/index.ts +3 -3
- package/src/payment.ts +1 -1
- package/src/permission.ts +12 -10
- package/src/protocol.ts +26 -11
- package/src/service.ts +94 -12
- package/src/treasury.ts +2 -3
- package/src/graphql.ts +0 -123
- package/src/reward.ts +0 -317
- package/src/vote.ts +0 -411
package/src/permission.ts
CHANGED
|
@@ -12,7 +12,7 @@ export enum PermissionIndex {
|
|
|
12
12
|
repository_policy_description = 105,
|
|
13
13
|
repository_policy_permission = 106,
|
|
14
14
|
repository_reference = 107,
|
|
15
|
-
|
|
15
|
+
/*
|
|
16
16
|
vote = 150,
|
|
17
17
|
vote_description = 151,
|
|
18
18
|
vote_reference = 152,
|
|
@@ -23,7 +23,7 @@ export enum PermissionIndex {
|
|
|
23
23
|
vote_lock_deadline = 159,
|
|
24
24
|
vote_expand_deadline = 160,
|
|
25
25
|
vote_lock_guard = 161,
|
|
26
|
-
|
|
26
|
+
*/
|
|
27
27
|
service = 200,
|
|
28
28
|
service_description = 201,
|
|
29
29
|
service_price = 202,
|
|
@@ -46,7 +46,7 @@ export enum PermissionIndex {
|
|
|
46
46
|
//service_change_order_required_pubkey = 224,
|
|
47
47
|
service_pause = 225,
|
|
48
48
|
service_treasury = 226,
|
|
49
|
-
|
|
49
|
+
/*
|
|
50
50
|
reward = 240,
|
|
51
51
|
reward_refund = 241,
|
|
52
52
|
reward_expand_time = 242,
|
|
@@ -55,7 +55,7 @@ export enum PermissionIndex {
|
|
|
55
55
|
reward_lock_guards = 246,
|
|
56
56
|
reward_claim_repeatably = 247,
|
|
57
57
|
reward_allow_claiming = 248,
|
|
58
|
-
|
|
58
|
+
*/
|
|
59
59
|
demand = 260,
|
|
60
60
|
demand_refund = 261,
|
|
61
61
|
demand_expand_time = 262,
|
|
@@ -94,10 +94,11 @@ export enum PermissionIndex {
|
|
|
94
94
|
arbitration_voting_guard = 803,
|
|
95
95
|
arbitration_endpoint = 804,
|
|
96
96
|
arbitration_guard = 805,
|
|
97
|
-
|
|
97
|
+
arbitration_pause = 806,
|
|
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
|
}
|
|
@@ -132,7 +133,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
132
133
|
{index:PermissionIndex.repository_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository'},
|
|
133
134
|
{index:PermissionIndex.repository_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository'},
|
|
134
135
|
{index:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository'},
|
|
135
|
-
|
|
136
|
+
/*
|
|
136
137
|
{index:PermissionIndex.vote, name:'Vote', description:'Launch new Vote', module: 'vote'},
|
|
137
138
|
{index:PermissionIndex.vote_description, name:'Description', description:'Set Vote description', module: 'vote'},
|
|
138
139
|
{index:PermissionIndex.vote_reference, name:'Reference', description:'Set Vote reference', module: 'vote'},
|
|
@@ -143,7 +144,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
143
144
|
{index:PermissionIndex.vote_lock_deadline, name:'Lock deadline', description:'Set Vote deadline immutable', module: 'vote'},
|
|
144
145
|
{index:PermissionIndex.vote_expand_deadline, name:'Expand deadline', description:'Expand Vote deadline', module: 'vote'},
|
|
145
146
|
{index:PermissionIndex.vote_lock_guard, name:'Lock Guard', description:'Set Vote guards immutable', module: 'vote'},
|
|
146
|
-
|
|
147
|
+
*/
|
|
147
148
|
{index:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service'},
|
|
148
149
|
{index:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: 'service'},
|
|
149
150
|
{index:PermissionIndex.service_price, name:'Price', description:'Set Service item price', module: 'service'},
|
|
@@ -165,7 +166,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
165
166
|
//{index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'Update Serivce order pubkey', module: 'service'},
|
|
166
167
|
{index:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service'},
|
|
167
168
|
{index:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service'},
|
|
168
|
-
|
|
169
|
+
/*
|
|
169
170
|
{index:PermissionIndex.reward, name:'reward', description:'Launch new reward', module: 'reward'},
|
|
170
171
|
{index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from reward', module: 'reward'},
|
|
171
172
|
{index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'Expand reward deadline', module: 'reward'},
|
|
@@ -174,7 +175,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
174
175
|
{index:PermissionIndex.reward_lock_guards, name:'Lock Guard', description:'Set reward guard immutable', module: 'reward'},
|
|
175
176
|
{index:PermissionIndex.reward_claim_repeatably, name:'Claim repeatably', description:'Allow claimming repeatably', module: 'reward'},
|
|
176
177
|
{index:PermissionIndex.reward_allow_claiming, name:'Allow claiming', description:'Allow claiming', module: 'reward'},
|
|
177
|
-
|
|
178
|
+
*/
|
|
178
179
|
{index:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand'},
|
|
179
180
|
{index:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand'},
|
|
180
181
|
{index:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand'},
|
|
@@ -213,10 +214,11 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
213
214
|
{index:PermissionIndex.arbitration_fee, name: 'Fee', description:'Set Arbitration fee', module: 'arbitration'},
|
|
214
215
|
{index:PermissionIndex.arbitration_guard, name: 'Guard', description:'Set Guard to apply for arbitration', module: 'arbitration'},
|
|
215
216
|
{index:PermissionIndex.arbitration_arbitration, name: 'Arbitrate', description:'Determine the outcome of arbitration', module: 'arbitration'},
|
|
216
|
-
{index:PermissionIndex.
|
|
217
|
+
{index:PermissionIndex.arbitration_pause, name: 'Pause', description:'Allowing/forbidding the creation of Arb', module: 'arbitration'},
|
|
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
|
@@ -41,28 +41,33 @@ export type DemandAddress = TransactionResult;
|
|
|
41
41
|
export type DemandObject = TransactionResult | string | TransactionArgument;
|
|
42
42
|
export type ServiceObject = TransactionResult | string | TransactionArgument;
|
|
43
43
|
export type ServiceAddress = TransactionResult;
|
|
44
|
+
export type ArbitrationObject = TransactionResult | string | TransactionArgument;
|
|
45
|
+
export type ArbitrationAddress = TransactionResult;
|
|
46
|
+
export type ArbObject = TransactionResult | string | TransactionArgument;
|
|
47
|
+
export type ArbAddress = TransactionResult;
|
|
44
48
|
export type ProgressObject = TransactionResult | string | TransactionArgument;
|
|
45
49
|
export type ProgressAddress = TransactionResult;
|
|
46
|
-
export type
|
|
47
|
-
export type
|
|
50
|
+
export type TreasuryObject = TransactionResult | string | TransactionArgument;
|
|
51
|
+
export type TreasuryAddress = TransactionResult;
|
|
52
|
+
//export type RewardObject = TransactionResult | string | TransactionArgument;
|
|
53
|
+
//export type RewardAddress = TransactionResult;
|
|
48
54
|
export type OrderObject = TransactionResult | string | TransactionArgument;
|
|
49
55
|
export type OrderAddress = TransactionResult;
|
|
50
56
|
export type DiscountObject = TransactionResult | string | TransactionArgument;
|
|
51
57
|
export type CoinObject = TransactionResult | string | TransactionArgument;
|
|
52
|
-
export type VoteObject = TransactionResult | string | TransactionArgument;
|
|
53
|
-
export type VoteAddress = TransactionResult;
|
|
58
|
+
//export type VoteObject = TransactionResult | string | TransactionArgument;
|
|
59
|
+
//export type VoteAddress = TransactionResult;
|
|
54
60
|
export type ResourceObject = TransactionResult | string | TransactionArgument;
|
|
55
61
|
export type ResourceAddress = TransactionResult;
|
|
56
62
|
export type EntityObject = TransactionResult | string | TransactionArgument;
|
|
57
63
|
export type EntityAddress = TransactionResult;
|
|
58
|
-
export type TreasuryAddress = TransactionResult;
|
|
59
64
|
export type PaymentObject = TransactionResult | string | TransactionArgument;
|
|
60
65
|
export type PaymentAddress = TransactionResult;
|
|
61
66
|
export type ReceivedObject = TransactionResult | string | TransactionArgument;
|
|
62
67
|
export type CoinWrapperObject = TransactionResult;
|
|
63
68
|
|
|
64
69
|
export type TxbObject = string | TransactionResult | TransactionArgument | GuardObject | RepositoryObject | PermissionObject | MachineObject | PassportObject |
|
|
65
|
-
DemandObject | ServiceObject
|
|
70
|
+
DemandObject | ServiceObject | OrderObject | DiscountObject | DemandObject | ResourceObject | EntityObject | ArbitrationObject | ArbObject | TreasuryObject;
|
|
66
71
|
|
|
67
72
|
export type WowokObject = TransactionResult;
|
|
68
73
|
export type FnCallType = `${string}::${string}::${string}`;
|
|
@@ -215,16 +220,21 @@ const TESTNET = {
|
|
|
215
220
|
}
|
|
216
221
|
*/
|
|
217
222
|
const TESTNET = {
|
|
218
|
-
wowok: "
|
|
219
|
-
wowok_origin:'
|
|
223
|
+
wowok: "0x1633497f1d7a9cdb7f8afc619fb25e138dcfa3b04d8685a0b3f266c5f4c33d37",
|
|
224
|
+
wowok_origin:'0x1633497f1d7a9cdb7f8afc619fb25e138dcfa3b04d8685a0b3f266c5f4c33d37' ,
|
|
220
225
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
base_origin: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
227
|
+
|
|
228
|
+
wowok_object: '0x2806f245ec96a33c9dcb1b03c569f262e94f00d8ae9e759f8c8edbcffdb99986',
|
|
229
|
+
entity_object: '0x2e90eeafd6df01a92704ffc3420f18801626403b322b1a0267bf4d6db268037a',
|
|
223
230
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
224
231
|
}
|
|
225
232
|
const MAINNET = {
|
|
226
233
|
wowok: "",
|
|
234
|
+
wowok_origin:"",
|
|
227
235
|
base:"",
|
|
236
|
+
base_origin:"",
|
|
237
|
+
|
|
228
238
|
wowok_object: '',
|
|
229
239
|
entity_object: '',
|
|
230
240
|
treasury_cap:'',
|
|
@@ -272,6 +282,7 @@ export class Protocol {
|
|
|
272
282
|
this.package.set('wowok', TESTNET.wowok);
|
|
273
283
|
this.package.set('base', TESTNET.base);
|
|
274
284
|
this.package.set('wowok_origin', TESTNET.wowok_origin); //@ orgin package!!!
|
|
285
|
+
this.package.set('base_origin', TESTNET.base_origin);
|
|
275
286
|
this.wowok_object = TESTNET.wowok_object;
|
|
276
287
|
this.entity_object= TESTNET.entity_object;
|
|
277
288
|
this.treasury_cap = TESTNET.treasury_cap;
|
|
@@ -280,6 +291,8 @@ export class Protocol {
|
|
|
280
291
|
case ENTRYPOINT.mainnet:
|
|
281
292
|
this.package.set('wowok', MAINNET.wowok);
|
|
282
293
|
this.package.set('base', MAINNET.base);
|
|
294
|
+
this.package.set('wowok_origin', MAINNET.wowok_origin); //@ orgin package!!!
|
|
295
|
+
this.package.set('base_origin', MAINNET.base_origin);
|
|
283
296
|
this.wowok_object = MAINNET.wowok_object;
|
|
284
297
|
this.entity_object= MAINNET.entity_object;
|
|
285
298
|
this.treasury_cap = MAINNET.treasury_cap;
|
|
@@ -326,7 +339,9 @@ export class Protocol {
|
|
|
326
339
|
PaymentFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.payment}::${fn}`};
|
|
327
340
|
GuardFn = (fn: any) => { return `${this.package.get('base')}::${MODULES.guard}::${fn}`};
|
|
328
341
|
MintFn = (fn: any) => { return `${this.package.get('base')}::${MODULES.wowok}::${fn}`};
|
|
329
|
-
|
|
342
|
+
ArbitrationFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.arbitration}::${fn}`};
|
|
343
|
+
ArbFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.arb}::${fn}`};
|
|
344
|
+
|
|
330
345
|
Query = async (objects: Query_Param[], options:SuiObjectDataOptions={showContent:true}) : Promise<SuiObjectResponse[]> => {
|
|
331
346
|
const client = new SuiClient({ url: this.NetworkUrl() });
|
|
332
347
|
const ids = objects.map((value) => value.objectid);
|
package/src/service.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { IsValidArray, IsValidPercent, IsValidName_AllowEmpty, parseObjectType,
|
|
|
2
2
|
IsValidAddress, IsValidEndpoint, IsValidU64, } from './utils'
|
|
3
3
|
import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryObject, MachineObject, ServiceAddress,
|
|
4
4
|
ServiceObject, DiscountObject, OrderObject, OrderAddress, CoinObject, Protocol, ValueType,
|
|
5
|
-
TxbObject
|
|
5
|
+
TxbObject,
|
|
6
|
+
TreasuryObject} from './protocol';
|
|
6
7
|
import { ERROR, Errors } from './exception';
|
|
7
8
|
import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
|
|
8
9
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
@@ -80,7 +81,7 @@ export class Service {
|
|
|
80
81
|
return s
|
|
81
82
|
}
|
|
82
83
|
static New(txb: TransactionBlock, token_type:string, permission:PermissionObject, description:string,
|
|
83
|
-
payee_address:string,
|
|
84
|
+
payee_address:string, passport?:PassportObject) : Service {
|
|
84
85
|
if (!Protocol.IsValidObjects([permission])) {
|
|
85
86
|
ERROR(Errors.IsValidObjects)
|
|
86
87
|
}
|
|
@@ -94,25 +95,20 @@ export class Service {
|
|
|
94
95
|
ERROR(Errors.IsValidAddress, 'payee_address')
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
if (endpoint && !IsValidEndpoint(endpoint)) {
|
|
98
|
-
ERROR(Errors.IsValidEndpoint)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
98
|
let pay_token_type = token_type;
|
|
102
99
|
let s = new Service(txb, pay_token_type, permission);
|
|
103
|
-
let ep = txb.pure.option('string', endpoint ? endpoint : undefined);
|
|
104
100
|
|
|
105
101
|
|
|
106
102
|
if (passport) {
|
|
107
103
|
s.object = txb.moveCall({
|
|
108
104
|
target:Protocol.Instance().ServiceFn('new_with_passport') as FnCallType,
|
|
109
|
-
arguments:[passport, txb.pure.string(description), txb.pure.address(payee_address),
|
|
105
|
+
arguments:[passport, txb.pure.string(description), txb.pure.address(payee_address), Protocol.TXB_OBJECT(txb, permission)],
|
|
110
106
|
typeArguments:[pay_token_type],
|
|
111
107
|
})
|
|
112
108
|
} else {
|
|
113
109
|
s.object = txb.moveCall({
|
|
114
110
|
target:Protocol.Instance().ServiceFn('new') as FnCallType,
|
|
115
|
-
arguments:[txb.pure.string(description), txb.pure.address(payee_address),
|
|
111
|
+
arguments:[txb.pure.string(description), txb.pure.address(payee_address), Protocol.TXB_OBJECT(txb, permission)],
|
|
116
112
|
typeArguments:[pay_token_type],
|
|
117
113
|
})
|
|
118
114
|
}
|
|
@@ -124,8 +120,8 @@ export class Service {
|
|
|
124
120
|
target:Protocol.Instance().ServiceFn('create') as FnCallType,
|
|
125
121
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
126
122
|
typeArguments:[this.pay_token_type]
|
|
127
|
-
|
|
128
|
-
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
129
125
|
destroy() {
|
|
130
126
|
this.txb.moveCall({
|
|
131
127
|
target:Protocol.Instance().ServiceFn('destroy') as FnCallType,
|
|
@@ -1006,6 +1002,63 @@ export class Service {
|
|
|
1006
1002
|
})
|
|
1007
1003
|
}
|
|
1008
1004
|
|
|
1005
|
+
add_treasury(treasury_token_type:string, treasury:TreasuryObject, passport?:PassportObject) {
|
|
1006
|
+
if (!Protocol.IsValidObjects([treasury])) {
|
|
1007
|
+
ERROR(Errors.IsValidObjects, 'add_treasury.treasury')
|
|
1008
|
+
}
|
|
1009
|
+
if (!IsValidTokenType(treasury_token_type)) {
|
|
1010
|
+
ERROR(Errors.IsValidTokenType, 'add_treasury.treasury_token_type')
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if (passport) {
|
|
1014
|
+
this.txb.moveCall({
|
|
1015
|
+
target:Protocol.Instance().ServiceFn('treasury_add_with_passport') as FnCallType,
|
|
1016
|
+
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1017
|
+
typeArguments:[this.pay_token_type, treasury_token_type]
|
|
1018
|
+
})
|
|
1019
|
+
} else {
|
|
1020
|
+
this.txb.moveCall({
|
|
1021
|
+
target:Protocol.Instance().ServiceFn('treasury_add') as FnCallType,
|
|
1022
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1023
|
+
typeArguments:[this.pay_token_type, treasury_token_type]
|
|
1024
|
+
})
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
remove_treasury(treasury:string[], removeall?:boolean, passport?:PassportObject) {
|
|
1029
|
+
if (!removeall && treasury.length === 0) return ;
|
|
1030
|
+
|
|
1031
|
+
if (passport) {
|
|
1032
|
+
if (removeall) {
|
|
1033
|
+
this.txb.moveCall({
|
|
1034
|
+
target:Protocol.Instance().ServiceFn('treasury_remove_all_with_passport') as FnCallType,
|
|
1035
|
+
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1036
|
+
typeArguments:[this.pay_token_type]
|
|
1037
|
+
})
|
|
1038
|
+
} else {
|
|
1039
|
+
this.txb.moveCall({
|
|
1040
|
+
target:Protocol.Instance().ServiceFn('treasury_remove_with_passport') as FnCallType,
|
|
1041
|
+
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1042
|
+
typeArguments:[this.pay_token_type]
|
|
1043
|
+
})
|
|
1044
|
+
}
|
|
1045
|
+
} else {
|
|
1046
|
+
if (removeall) {
|
|
1047
|
+
this.txb.moveCall({
|
|
1048
|
+
target:Protocol.Instance().ServiceFn('treasury_remove_all') as FnCallType,
|
|
1049
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1050
|
+
typeArguments:[this.pay_token_type]
|
|
1051
|
+
})
|
|
1052
|
+
} else {
|
|
1053
|
+
this.txb.moveCall({
|
|
1054
|
+
target:Protocol.Instance().ServiceFn('treasury_remove') as FnCallType,
|
|
1055
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
1056
|
+
typeArguments:[this.pay_token_type]
|
|
1057
|
+
})
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1009
1062
|
change_permission(new_permission:PermissionObject) {
|
|
1010
1063
|
if (!Protocol.IsValidObjects([new_permission])) {
|
|
1011
1064
|
ERROR(Errors.IsValidObjects)
|
|
@@ -1019,12 +1072,19 @@ export class Service {
|
|
|
1019
1072
|
this.permission = new_permission
|
|
1020
1073
|
}
|
|
1021
1074
|
|
|
1075
|
+
set_order_agent(order:OrderObject, agent:string[]) {
|
|
1076
|
+
Service.SetOrderAgent(this.txb, this.pay_token_type, order, agent)
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1022
1079
|
static MAX_DISCOUNT_COUNT_ONCE = 200;
|
|
1023
1080
|
static MAX_DISCOUNT_RECEIVER_COUNT = 20;
|
|
1024
1081
|
static MAX_GUARD_COUNT = 16;
|
|
1025
1082
|
static MAX_REPOSITORY_COUNT = 32;
|
|
1026
1083
|
static MAX_ITEM_NAME_LENGTH = 256;
|
|
1027
|
-
|
|
1084
|
+
static MAX_TREASURY_COUNT= 8;
|
|
1085
|
+
static MAX_ORDER_AGENT_COUNT = 8;
|
|
1086
|
+
static MAX_ORDER_ARBS_COUNT = 8;
|
|
1087
|
+
|
|
1028
1088
|
static IsValidItemName(name:string) : boolean {
|
|
1029
1089
|
if (!name) return false;
|
|
1030
1090
|
return new TextEncoder().encode(name).length <= Service.MAX_ITEM_NAME_LENGTH;
|
|
@@ -1055,4 +1115,26 @@ export class Service {
|
|
|
1055
1115
|
console.log(e);
|
|
1056
1116
|
})
|
|
1057
1117
|
}
|
|
1118
|
+
|
|
1119
|
+
// The agent has the same order operation power as the order payer; The agent can only be set by the order payer.
|
|
1120
|
+
static SetOrderAgent = (txb:TransactionBlock, order_token_type:string, order:OrderObject, agent:string[]) => {
|
|
1121
|
+
if (!IsValidTokenType(order_token_type)) {
|
|
1122
|
+
ERROR(Errors.IsValidTokenType, 'SetOrderAgent.order_token_type');
|
|
1123
|
+
}
|
|
1124
|
+
if (!Protocol.IsValidObjects([order])) {
|
|
1125
|
+
ERROR(Errors.IsValidObjects, 'SetOrderAgent.order')
|
|
1126
|
+
}
|
|
1127
|
+
if (!IsValidArray(agent, IsValidAddress)) {
|
|
1128
|
+
ERROR(Errors.IsValidArray, 'SetOrderAgent.agent')
|
|
1129
|
+
}
|
|
1130
|
+
if (array_unique(agent).length > Service.MAX_ORDER_AGENT_COUNT) {
|
|
1131
|
+
ERROR(Errors.Fail, 'SetOrderAgent.agent count')
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
txb.moveCall({
|
|
1135
|
+
target:Protocol.Instance().OrderFn('agent_set') as FnCallType,
|
|
1136
|
+
arguments: [txb.object(order), txb.pure.vector('string', array_unique(agent))],
|
|
1137
|
+
typeArguments:[order_token_type]
|
|
1138
|
+
})
|
|
1139
|
+
}
|
|
1058
1140
|
}
|
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)),
|
package/src/graphql.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { gql } from "graphql-tag";
|
|
2
|
-
|
|
3
|
-
export const GRAPHQL_OBJECTS_TYPE = gql(`
|
|
4
|
-
query objects_type_version($filter:ObjectFilter!) {
|
|
5
|
-
objects(filter:$filter) {
|
|
6
|
-
nodes {
|
|
7
|
-
address
|
|
8
|
-
version
|
|
9
|
-
asMoveObject {
|
|
10
|
-
contents {
|
|
11
|
-
type {
|
|
12
|
-
repr
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
`);
|
|
20
|
-
export const GRAPHQL_CHILD_OBJECT = gql(`
|
|
21
|
-
query object($ObjectID:SuiAddress!) {
|
|
22
|
-
object(address:$ObjectID) {
|
|
23
|
-
address
|
|
24
|
-
asMoveObject {
|
|
25
|
-
contents {
|
|
26
|
-
json
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`);
|
|
32
|
-
|
|
33
|
-
export const GRAPHQL_OBJECT = gql(`
|
|
34
|
-
query object($ObjectID:SuiAddress!) {
|
|
35
|
-
object(address:$ObjectID) {
|
|
36
|
-
address
|
|
37
|
-
asMoveObject {
|
|
38
|
-
contents {
|
|
39
|
-
json
|
|
40
|
-
type {
|
|
41
|
-
repr
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
dynamicFields {
|
|
46
|
-
pageInfo {
|
|
47
|
-
hasNextPage
|
|
48
|
-
endCursor
|
|
49
|
-
}
|
|
50
|
-
nodes {
|
|
51
|
-
name {
|
|
52
|
-
json
|
|
53
|
-
}
|
|
54
|
-
value {
|
|
55
|
-
... on MoveValue {
|
|
56
|
-
json
|
|
57
|
-
}
|
|
58
|
-
... on MoveObject {
|
|
59
|
-
contents {
|
|
60
|
-
json
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
`);
|
|
69
|
-
|
|
70
|
-
export const GRAPHQL_OWNER = gql(`
|
|
71
|
-
query owner($ObjectID:SuiAddress!) {
|
|
72
|
-
owner (address: $ObjectID) {
|
|
73
|
-
address
|
|
74
|
-
dynamicFields {
|
|
75
|
-
pageInfo {
|
|
76
|
-
hasNextPage
|
|
77
|
-
endCursor
|
|
78
|
-
}
|
|
79
|
-
nodes {
|
|
80
|
-
name {
|
|
81
|
-
json
|
|
82
|
-
}
|
|
83
|
-
value {
|
|
84
|
-
... on MoveValue {
|
|
85
|
-
json
|
|
86
|
-
}
|
|
87
|
-
... on MoveObject {
|
|
88
|
-
contents {
|
|
89
|
-
json
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`);
|
|
98
|
-
|
|
99
|
-
export const GRAPHQL_OBJECTS = gql(`
|
|
100
|
-
query objects($filter:ObjectFilter!){
|
|
101
|
-
objects(filter:$filter) {
|
|
102
|
-
nodes {
|
|
103
|
-
address
|
|
104
|
-
asMoveObject {
|
|
105
|
-
contents {
|
|
106
|
-
json
|
|
107
|
-
type {
|
|
108
|
-
repr
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
`);
|
|
116
|
-
|
|
117
|
-
export const GRAPHQL_DECIMALS = gql(`
|
|
118
|
-
query getTotalSupply($coinType: String!) {
|
|
119
|
-
coinMetadata(coinType: $coinType) {
|
|
120
|
-
decimals
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
`);
|