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
package/src/service.ts DELETED
@@ -1,1349 +0,0 @@
1
- import { IsValidArray, IsValidPercent, IsValidName_AllowEmpty, parseObjectType, array_unique, IsValidTokenType, IsValidDesription,
2
- IsValidAddress, IsValidEndpoint, IsValidU64, IsValidName, IsValidStringLength,
3
- IsValidLocation} from './utils.js'
4
- import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryObject, MachineObject, ServiceAddress,
5
- ServiceObject, DiscountObject, OrderObject, OrderAddress, CoinObject, Protocol, ValueType,
6
- TxbObject, TreasuryObject, PaymentAddress, ArbObject,
7
- ArbitrationObject, ProgressObject, ProgressAddress,
8
- PaymentObject, ReceivedObject} from './protocol.js';
9
- import { ERROR, Errors } from './exception.js';
10
- import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
11
- import { SuiObjectData } from '@mysten/sui/client';
12
- import { TransactionResult } from './index.js';
13
-
14
- export type Service_Guard_Percent = {
15
- guard:GuardObject;
16
- percent: number; // [0-100]
17
- }
18
- export type Service_Sale = {
19
- item: string;
20
- price: string | number | bigint;
21
- stock: string | number | bigint;
22
- endpoint?:string | null;
23
- }
24
- export enum Service_Discount_Type {
25
- ratio = 0, // -off%
26
- minus = 1, // -off
27
- }
28
- export type Service_Discount = {
29
- name: string; // not empty
30
- type: Service_Discount_Type;
31
- off: number;
32
- duration_minutes: number;
33
- time_start?: number; // current time if undefined
34
- price_greater?: bigint | string | number;
35
- }
36
-
37
- export type Service_Buy_RequiredInfo = {
38
- pubkey: string;
39
- customer_info: string[];
40
- }
41
- export type Customer_RequiredInfo = {
42
- customer_pubkey: string;
43
- customer_info_crypt: string;
44
- }
45
- export enum BuyRequiredEnum {
46
- address = 'address',
47
- phone = 'phone',
48
- name = 'name',
49
- postcode = 'postcode'
50
- }
51
-
52
- export type Service_Buy = {
53
- item: string;
54
- max_price: string | number | bigint;
55
- count: string | number | bigint;
56
- }
57
-
58
- export type DicountDispatch = {
59
- receiver: string;
60
- count: number;
61
- discount: Service_Discount;
62
- }
63
- export interface WithdrawPayee {
64
- withdraw_guard: GuardObject;
65
- treasury: TreasuryObject,
66
- index: bigint | number | string,
67
- remark: string,
68
- for_object?: string,
69
- for_guard?: GuardObject,
70
- }
71
-
72
- export interface BuyResult {
73
- order: OrderAddress;
74
- progress?: ProgressAddress;
75
- }
76
-
77
- export interface OrderResult {
78
- order: OrderObject;
79
- progress?: ProgressObject;
80
- }
81
-
82
- export type handleDiscountObject = (owner:string, objects:(SuiObjectData|null|undefined)[]) => void;
83
- export class Service {
84
- protected pay_token_type;
85
- protected permission;
86
- protected object : TxbObject;
87
- protected txb;
88
-
89
- //static token2coin = (token:string) => { return '0x2::coin::Coin<' + token + '>'};
90
-
91
- get_pay_type() { return this.pay_token_type }
92
- get_object() { return this.object }
93
- get_txb() { return this.txb }
94
-
95
- private constructor(txb: TransactionBlock, pay_token_type:string, permission:PermissionObject) {
96
- this.pay_token_type = pay_token_type
97
- this.txb = txb
98
- this.permission = permission
99
- this.object = ''
100
- }
101
- static From(txb: TransactionBlock, token_type:string, permission:PermissionObject, object:TxbObject) : Service {
102
- let s = new Service(txb, token_type, permission);
103
- s.object = Protocol.TXB_OBJECT(txb, object);
104
- return s
105
- }
106
- static New(txb: TransactionBlock, token_type:string, permission:PermissionObject, description:string,
107
- payee_treasury:TreasuryObject, passport?:PassportObject) : Service {
108
- if (!Protocol.IsValidObjects([permission, payee_treasury])) {
109
- ERROR(Errors.IsValidObjects)
110
- }
111
- if (!IsValidTokenType(token_type)) {
112
- ERROR(Errors.IsValidTokenType, 'New: pay_token_type')
113
- }
114
- if (!IsValidDesription(description)) {
115
- ERROR(Errors.IsValidDesription)
116
- }
117
-
118
- let pay_token_type = token_type;
119
- let s = new Service(txb, pay_token_type, permission);
120
-
121
-
122
- if (passport) {
123
- s.object = txb.moveCall({
124
- target:Protocol.Instance().serviceFn('new_with_passport') as FnCallType,
125
- arguments:[passport, txb.pure.string(description), Protocol.TXB_OBJECT(txb, payee_treasury), Protocol.TXB_OBJECT(txb, permission)],
126
- typeArguments:[pay_token_type],
127
- })
128
- } else {
129
- s.object = txb.moveCall({
130
- target:Protocol.Instance().serviceFn('new') as FnCallType,
131
- arguments:[txb.pure.string(description), Protocol.TXB_OBJECT(txb, payee_treasury), Protocol.TXB_OBJECT(txb, permission)],
132
- typeArguments:[pay_token_type],
133
- })
134
- }
135
- return s
136
- }
137
-
138
- launch() : ServiceAddress {
139
- return this.txb.moveCall({
140
- target:Protocol.Instance().serviceFn('create') as FnCallType,
141
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
142
- typeArguments:[this.pay_token_type]
143
- })
144
- }
145
-
146
- set_location(location:string, passport?:PassportObject) {
147
- if (!IsValidLocation(location)) {
148
- ERROR(Errors.IsValidLocation, `Service.set_location.location ${location}`)
149
- }
150
-
151
- if (passport) {
152
- this.txb.moveCall({
153
- target:Protocol.Instance().serviceFn('location_set_with_passport') as FnCallType,
154
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(location), Protocol.TXB_OBJECT(this.txb, this.permission)],
155
- typeArguments:[this.pay_token_type]
156
- })
157
- } else {
158
- this.txb.moveCall({
159
- target:Protocol.Instance().serviceFn('location_set') as FnCallType,
160
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(location), Protocol.TXB_OBJECT(this.txb, this.permission)],
161
- typeArguments:[this.pay_token_type]
162
- })
163
- }
164
- }
165
-
166
- set_description(description:string, passport?:PassportObject) {
167
- if (!IsValidDesription(description)) {
168
- ERROR(Errors.IsValidDesription)
169
- }
170
-
171
- if (passport) {
172
- this.txb.moveCall({
173
- target:Protocol.Instance().serviceFn('description_set_with_passport') as FnCallType,
174
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
175
- typeArguments:[this.pay_token_type]
176
- })
177
- } else {
178
- this.txb.moveCall({
179
- target:Protocol.Instance().serviceFn('description_set') as FnCallType,
180
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
181
- typeArguments:[this.pay_token_type]
182
- })
183
- }
184
- }
185
- set_price(item:string, price:bigint, bNotFoundAssert:boolean=true, passport?:PassportObject) {
186
- if (!IsValidU64(price)) {
187
- ERROR(Errors.IsValidU64, 'set_price price')
188
- }
189
-
190
- if (!Service.IsValidItemName(item)) {
191
- ERROR(Errors.IsValidServiceItemName, 'set_price item')
192
- }
193
-
194
- if (passport) {
195
- this.txb.moveCall({
196
- target:Protocol.Instance().serviceFn('price_set_with_passport') as FnCallType,
197
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
198
- this.txb.pure.u64(price),
199
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
200
- typeArguments:[this.pay_token_type]
201
- })
202
- } else {
203
- this.txb.moveCall({
204
- target:Protocol.Instance().serviceFn('price_set') as FnCallType,
205
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
206
- this.txb.pure.u64(price),
207
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
208
- typeArguments:[this.pay_token_type]
209
- })
210
- }
211
- }
212
- set_stock(item:string, stock:bigint, bNotFoundAssert:boolean=true, passport?:PassportObject) {
213
- if (!Service.IsValidItemName(item)) {
214
- ERROR(Errors.IsValidServiceItemName, 'item')
215
- }
216
- if (!IsValidU64(stock)) {
217
- ERROR(Errors.IsValidU64, 'stock')
218
- }
219
-
220
- if (passport) {
221
- this.txb.moveCall({
222
- target:Protocol.Instance().serviceFn('stock_set_with_passport') as FnCallType,
223
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
224
- this.txb.pure.u64(stock),
225
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
226
- typeArguments:[this.pay_token_type]
227
- })
228
- } else {
229
- this.txb.moveCall({
230
- target:Protocol.Instance().serviceFn('stock_set') as FnCallType,
231
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
232
- this.txb.pure.u64(stock),
233
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
234
- typeArguments:[this.pay_token_type]
235
- })
236
- }
237
- }
238
- add_stock(item:string, stock_add:bigint, bNotFoundAssert:boolean=true, passport?:PassportObject) {
239
- if (!Service.IsValidItemName(item)) {
240
- ERROR(Errors.IsValidServiceItemName, 'add_stock item')
241
- }
242
- if (!IsValidU64(stock_add)) {
243
- ERROR(Errors.IsValidUint, 'add_stock stock_add')
244
- }
245
-
246
- if (passport) {
247
- this.txb.moveCall({
248
- target:Protocol.Instance().serviceFn('stock_add_with_passport') as FnCallType,
249
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
250
- this.txb.pure.u64(stock_add),
251
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
252
- typeArguments:[this.pay_token_type]
253
- })
254
- } else {
255
- this.txb.moveCall({
256
- target:Protocol.Instance().serviceFn('stock_add') as FnCallType,
257
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
258
- this.txb.pure.u64(stock_add),
259
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
260
- typeArguments:[this.pay_token_type]
261
- })
262
- }
263
- }
264
- reduce_stock(item:string, stock_reduce:bigint, bNotFoundAssert:boolean=true, passport?:PassportObject) {
265
- if (!Service.IsValidItemName(item)) {
266
- ERROR(Errors.IsValidServiceItemName, 'reduce_stock item')
267
- }
268
- if (!IsValidU64(stock_reduce)) {
269
- ERROR(Errors.IsValidUint, 'reduce_stock stock_reduce')
270
- }
271
-
272
- if (passport) {
273
- this.txb.moveCall({
274
- target:Protocol.Instance().serviceFn('stock_reduce_with_passport') as FnCallType,
275
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
276
- this.txb.pure.u64(stock_reduce),
277
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
278
- typeArguments:[this.pay_token_type]
279
- })
280
- } else {
281
- this.txb.moveCall({
282
- target:Protocol.Instance().serviceFn('stock_reduce') as FnCallType,
283
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item),
284
- this.txb.pure.u64(stock_reduce),
285
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
286
- typeArguments:[this.pay_token_type]
287
- })
288
- }
289
- }
290
-
291
- set_sale_endpoint(item:string, endpoint?:string|null, bNotFoundAssert:boolean=true, passport?:PassportObject) {
292
- if (!Service.IsValidItemName(item)) {
293
- ERROR(Errors.IsValidServiceItemName, 'set_sale_endpoint item')
294
- }
295
- if (endpoint && !IsValidEndpoint(endpoint)) {
296
- ERROR(Errors.IsValidEndpoint, 'set_sale_endpoint endpoint')
297
- }
298
-
299
- let ep = this.txb.pure.option('string', endpoint ? endpoint : undefined);
300
- if (passport) {
301
- this.txb.moveCall({
302
- target:Protocol.Instance().serviceFn('sale_endpoint_set_with_passport') as FnCallType,
303
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item), ep,
304
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
305
- typeArguments:[this.pay_token_type]
306
- })
307
- } else {
308
- this.txb.moveCall({
309
- target:Protocol.Instance().serviceFn('sale_endpoint_set') as FnCallType,
310
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(item), ep,
311
- this.txb.pure.bool(bNotFoundAssert), Protocol.TXB_OBJECT(this.txb, this.permission)],
312
- typeArguments:[this.pay_token_type]
313
- })
314
- }
315
- }
316
-
317
- set_payee(payee:TreasuryObject, passport?:PassportObject) {
318
- if (!Protocol.IsValidObjects([payee])) {
319
- ERROR(Errors.IsValidObjects, 'set_payee');
320
- }
321
-
322
- if (passport) {
323
- this.txb.moveCall({
324
- target:Protocol.Instance().serviceFn('payee_set_with_passport') as FnCallType,
325
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, payee), Protocol.TXB_OBJECT(this.txb, this.permission)],
326
- typeArguments:[this.pay_token_type]
327
- })
328
- } else {
329
- this.txb.moveCall({
330
- target:Protocol.Instance().serviceFn('payee_set') as FnCallType,
331
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, payee), Protocol.TXB_OBJECT(this.txb, this.permission)],
332
- typeArguments:[this.pay_token_type]
333
- })
334
- }
335
- }
336
- add_repository(repository:RepositoryObject, passport?:PassportObject) {
337
- if (!Protocol.IsValidObjects([repository])) {
338
- ERROR(Errors.IsValidObjects, 'repository_add');
339
- }
340
-
341
- if (passport) {
342
- this.txb.moveCall({
343
- target:Protocol.Instance().serviceFn('repository_add_with_passport') as FnCallType,
344
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, repository), Protocol.TXB_OBJECT(this.txb, this.permission)],
345
- typeArguments:[this.pay_token_type]
346
- })
347
- } else {
348
- this.txb.moveCall({
349
- target:Protocol.Instance().serviceFn('repository_add') as FnCallType,
350
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, repository), Protocol.TXB_OBJECT(this.txb, this.permission)],
351
- typeArguments:[this.pay_token_type]
352
- })
353
- }
354
- }
355
- remove_repository(repository_address:string[], removeall?:boolean, passport?:PassportObject) {
356
- if (!removeall && repository_address.length===0) return;
357
-
358
- if (!IsValidArray(repository_address, IsValidAddress)) {
359
- ERROR(Errors.IsValidArray, 'repository_address');
360
- }
361
-
362
- if (passport) {
363
- if (removeall) {
364
- this.txb.moveCall({
365
- target:Protocol.Instance().serviceFn('repository_remove_all_with_passport') as FnCallType,
366
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
367
- typeArguments:[this.pay_token_type]
368
- })
369
- } else {
370
- this.txb.moveCall({
371
- target:Protocol.Instance().serviceFn('repository_remove_with_passport') as FnCallType,
372
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(repository_address!)),
373
- Protocol.TXB_OBJECT(this.txb, this.permission)],
374
- typeArguments:[this.pay_token_type]
375
- })
376
- }
377
- } else {
378
- if (removeall) {
379
- this.txb.moveCall({
380
- target:Protocol.Instance().serviceFn('repository_remove_all') as FnCallType,
381
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
382
- typeArguments:[this.pay_token_type]
383
- })
384
- } else {
385
- this.txb.moveCall({
386
- target:Protocol.Instance().serviceFn('repository_remove') as FnCallType,
387
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(repository_address!)),
388
- Protocol.TXB_OBJECT(this.txb, this.permission)],
389
- typeArguments:[this.pay_token_type]
390
- })
391
- }
392
- }
393
- }
394
- add_arbitration(arbitraion:ArbitrationObject, arbitraion_token_type:string, passport?:PassportObject) {
395
- if (!Protocol.IsValidObjects([arbitraion])) {
396
- ERROR(Errors.IsValidObjects, 'add_arbitration.arbitraion');
397
- }
398
- if (!IsValidTokenType(arbitraion_token_type)) {
399
- ERROR(Errors.IsValidTokenType, 'add_arbitration.arbitraion_token_type')
400
- }
401
- if (passport) {
402
- this.txb.moveCall({
403
- target:Protocol.Instance().serviceFn('arbitration_add_with_passport') as FnCallType,
404
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arbitraion), Protocol.TXB_OBJECT(this.txb, this.permission)],
405
- typeArguments:[this.pay_token_type, arbitraion_token_type]
406
- })
407
- } else {
408
- this.txb.moveCall({
409
- target:Protocol.Instance().serviceFn('arbitration_add') as FnCallType,
410
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, arbitraion), Protocol.TXB_OBJECT(this.txb, this.permission)],
411
- typeArguments:[this.pay_token_type, arbitraion_token_type]
412
- })
413
- }
414
- }
415
- remove_arbitration(address:string[], removeall?:boolean, passport?:PassportObject) {
416
- if (!removeall && address.length===0) return;
417
-
418
- if (!IsValidArray(address, IsValidAddress)) {
419
- ERROR(Errors.IsValidArray, 'remove_arbitration.address');
420
- }
421
-
422
- if (passport) {
423
- if (removeall) {
424
- this.txb.moveCall({
425
- target:Protocol.Instance().serviceFn('arbitration_remove_all_with_passport') as FnCallType,
426
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
427
- typeArguments:[this.pay_token_type]
428
- })
429
- } else {
430
- this.txb.moveCall({
431
- target:Protocol.Instance().serviceFn('arbitration_remove_with_passport') as FnCallType,
432
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(address!)),
433
- Protocol.TXB_OBJECT(this.txb, this.permission)],
434
- typeArguments:[this.pay_token_type]
435
- })
436
- }
437
- } else {
438
- if (removeall) {
439
- this.txb.moveCall({
440
- target:Protocol.Instance().serviceFn('arbitration_remove_all') as FnCallType,
441
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
442
- typeArguments:[this.pay_token_type]
443
- })
444
- } else {
445
- this.txb.moveCall({
446
- target:Protocol.Instance().serviceFn('arbitration_remove') as FnCallType,
447
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(address!)),
448
- Protocol.TXB_OBJECT(this.txb, this.permission)],
449
- typeArguments:[this.pay_token_type]
450
- })
451
- }
452
- }
453
- }
454
- add_withdraw_guards(guards:Service_Guard_Percent[], passport?:PassportObject) {
455
- if (guards.length === 0) return;
456
-
457
- guards.forEach((v) => {
458
- if (!Protocol.IsValidObjects([v.guard])) ERROR(Errors.IsValidObjects, `add_withdraw_guards.guard ${v}`)
459
- if (!IsValidPercent(v.percent)) ERROR(Errors.IsValidPercent, `add_withdraw_guards.percent ${v}`)
460
- })
461
-
462
- guards.forEach((guard) => {
463
- if (passport) {
464
- this.txb.moveCall({
465
- target:Protocol.Instance().serviceFn('withdraw_guard_add_with_passport') as FnCallType,
466
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard),
467
- this.txb.pure.u8(guard.percent), Protocol.TXB_OBJECT(this.txb, this.permission)],
468
- typeArguments:[this.pay_token_type]
469
- })
470
- } else {
471
- this.txb.moveCall({
472
- target:Protocol.Instance().serviceFn('withdraw_guard_add') as FnCallType,
473
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard), this.txb.pure.u8(guard.percent),
474
- Protocol.TXB_OBJECT(this.txb, this.permission)],
475
- typeArguments:[this.pay_token_type]
476
- })
477
- }
478
- })
479
- }
480
- remove_withdraw_guards(guard_address:string[], removeall?:boolean, passport?:PassportObject) {
481
- if (!removeall && guard_address.length===0) {
482
- return
483
- }
484
-
485
- if (!IsValidArray(guard_address, IsValidAddress)) {
486
- ERROR(Errors.IsValidArray, 'guard_address')
487
- }
488
-
489
- if (passport) {
490
- if (removeall) {
491
- this.txb.moveCall({
492
- target:Protocol.Instance().serviceFn('withdraw_guard_remove_all_with_passport') as FnCallType,
493
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
494
- typeArguments:[this.pay_token_type]
495
- })
496
- } else {
497
- this.txb.moveCall({
498
- target:Protocol.Instance().serviceFn('withdraw_guard_remove_with_passport') as FnCallType,
499
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(guard_address!)),
500
- Protocol.TXB_OBJECT(this.txb, this.permission)],
501
- typeArguments:[this.pay_token_type]
502
- })
503
- }
504
- } else {
505
- if (removeall) {
506
- this.txb.moveCall({
507
- target:Protocol.Instance().serviceFn('withdraw_guard_remove_all') as FnCallType,
508
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
509
- typeArguments:[this.pay_token_type]
510
- })
511
- } else {
512
- this.txb.moveCall({
513
- target:Protocol.Instance().serviceFn('withdraw_guard_remove') as FnCallType,
514
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(guard_address!)),
515
- Protocol.TXB_OBJECT(this.txb, this.permission)],
516
- typeArguments:[this.pay_token_type]
517
- })
518
- }
519
- }
520
- }
521
- add_refund_guards(guards:Service_Guard_Percent[], passport?:PassportObject) {
522
- if (guards.length === 0) return;
523
-
524
- guards.forEach((v) => {
525
- if (!Protocol.IsValidObjects([v.guard])) ERROR(Errors.IsValidObjects, `add_refund_guards.guard ${v}`)
526
- if (!IsValidPercent(v.percent)) ERROR(Errors.IsValidPercent, `add_refund_guards.percent ${v}`)
527
- })
528
-
529
- guards.forEach((guard) => {
530
- if (passport) {
531
- this.txb.moveCall({
532
- target:Protocol.Instance().serviceFn('refund_guard_add_with_passport') as FnCallType,
533
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard),
534
- this.txb.pure.u8(guard.percent), Protocol.TXB_OBJECT(this.txb, this.permission)],
535
- typeArguments:[this.pay_token_type]
536
- })
537
- } else {
538
- this.txb.moveCall({
539
- target:Protocol.Instance().serviceFn('refund_guard_add') as FnCallType,
540
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard), this.txb.pure.u8(guard.percent),
541
- Protocol.TXB_OBJECT(this.txb, this.permission)],
542
- typeArguments:[this.pay_token_type]
543
- })
544
- }
545
- })
546
- }
547
- remove_refund_guards(guard_address:string[], removeall?:boolean, passport?:PassportObject) {
548
- if (guard_address.length===0 && !removeall) return ;
549
- if (!IsValidArray(guard_address, IsValidAddress)) {
550
- ERROR(Errors.InvalidParam, 'guard_address')
551
- }
552
-
553
- if (passport) {
554
- if (removeall) {
555
- this.txb.moveCall({
556
- target:Protocol.Instance().serviceFn('refund_guard_remove_all_with_passport') as FnCallType,
557
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
558
- typeArguments:[this.pay_token_type]
559
- })
560
- } else {
561
- this.txb.moveCall({
562
- target:Protocol.Instance().serviceFn('refund_guard_remove_with_passport') as FnCallType,
563
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(guard_address!)),
564
- Protocol.TXB_OBJECT(this.txb, this.permission)],
565
- typeArguments:[this.pay_token_type]
566
- })
567
- }
568
- } else {
569
- if (removeall) {
570
- this.txb.moveCall({
571
- target:Protocol.Instance().serviceFn('refund_guard_remove_all') as FnCallType,
572
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
573
- typeArguments:[this.pay_token_type]
574
- })
575
- } else {
576
- this.txb.moveCall({
577
- target:Protocol.Instance().serviceFn('refund_guard_remove') as FnCallType,
578
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', array_unique(guard_address!)),
579
- Protocol.TXB_OBJECT(this.txb, this.permission)],
580
- typeArguments:[this.pay_token_type]
581
- })
582
- }
583
- }
584
- }
585
-
586
- check_valid_sale(sales:Service_Sale[]) {
587
- const names:string[] = [];
588
- sales.forEach((v) => {
589
- if (!Service.IsValidItemName(v.item)) ERROR(Errors.IsValidName, `check_valid_sale.sales.item ${v}`)
590
- if (!IsValidU64(v.price)) ERROR(Errors.IsValidU64, `check_valid_sale.sales.price ${v}`)
591
- if (!IsValidU64(v.stock)) ERROR(Errors.IsValidU64, `check_valid_sale.sales.stock ${v}`)
592
- if (names.includes(v.item)) ERROR(Errors.IsValidName, `check_valid_sale.sales.item repeat ${v}`)
593
- names.push(v.item)
594
- })
595
- }
596
-
597
- add_sales(sales:Service_Sale[], bExistAssert:boolean=false, passport?:PassportObject) {
598
- if (sales.length === 0) return;
599
-
600
- this.check_valid_sale(sales);
601
-
602
- let names: string[] = []; let price: (string | number | bigint)[] = []; let stock: (string | number | bigint)[] = []; let endpoint: string[] = [];
603
- sales.forEach((s) => {
604
- if (s.endpoint && !IsValidEndpoint(s.endpoint)) {
605
- ERROR(Errors.IsValidEndpoint, 'add_sales')
606
- }
607
- names.push(s.item); price.push(s.price); stock.push(s.stock); endpoint.push(s.endpoint ?? '')
608
- })
609
-
610
- if (passport) {
611
- this.txb.moveCall({
612
- target:Protocol.Instance().serviceFn('sales_add_with_passport') as FnCallType,
613
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', names),
614
- this.txb.pure.vector('string', endpoint),
615
- this.txb.pure.vector('u64', price), this.txb.pure.vector('u64', stock),
616
- this.txb.pure.bool(bExistAssert),
617
- Protocol.TXB_OBJECT(this.txb, this.permission)],
618
- typeArguments:[this.pay_token_type]
619
- })
620
- } else {
621
- this.txb.moveCall({
622
- target:Protocol.Instance().serviceFn('sales_add') as FnCallType,
623
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', names),
624
- this.txb.pure.vector('string', endpoint),
625
- this.txb.pure.vector('u64', price), this.txb.pure.vector('u64', stock),
626
- this.txb.pure.bool(bExistAssert),
627
- Protocol.TXB_OBJECT(this.txb, this.permission)],
628
- typeArguments:[this.pay_token_type]
629
- })
630
- }
631
- }
632
-
633
- remove_sales(sales:string[], passport?:PassportObject) {
634
- if (sales.length === 0) return;
635
-
636
- if (!IsValidArray(sales, Service.IsValidItemName)) {
637
- ERROR(Errors.IsValidArray, 'remove_sales')
638
- }
639
-
640
- if (passport) {
641
- this.txb.moveCall({
642
- target:Protocol.Instance().serviceFn('sales_remove_with_passport') as FnCallType,
643
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', array_unique(sales!)),
644
- Protocol.TXB_OBJECT(this.txb, this.permission)],
645
- typeArguments:[this.pay_token_type]
646
- })
647
- } else {
648
- this.txb.moveCall({
649
- target:Protocol.Instance().serviceFn('sales_remove') as FnCallType,
650
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', array_unique(sales!)),
651
- Protocol.TXB_OBJECT(this.txb, this.permission)],
652
- typeArguments:[this.pay_token_type]
653
- })
654
- }
655
- }
656
-
657
- discount_transfer(discount_dispatch:DicountDispatch[], passport?:PassportObject) {
658
- if (!discount_dispatch || discount_dispatch.length > Service.MAX_DISCOUNT_RECEIVER_COUNT) {
659
- ERROR(Errors.InvalidParam, 'discount_dispatch')
660
- }
661
-
662
- discount_dispatch.forEach((v) => {
663
- if (!IsValidAddress(v.receiver)) ERROR(Errors.IsValidAddress, `discount_transfer.discount_dispatch.receiver ${v}`)
664
-
665
- if (!IsValidU64(v.count) || v.count > Service.MAX_DISCOUNT_COUNT_ONCE) ERROR(Errors.IsValidU64, `discount_transfer.discount_dispatch.count ${v}`)
666
- if (!IsValidName_AllowEmpty(v.discount.name)) ERROR(Errors.IsValidName, `discount_transfer.discount_dispatch.discount.name ${v}`)
667
- if (v.discount.type == Service_Discount_Type.ratio && !IsValidPercent(v.discount.off)) ERROR(Errors.IsValidPercent, `discount_transfer.discount_dispatch.discount.off ${v}`)
668
- if (!IsValidU64(v.discount.duration_minutes)) ERROR(Errors.IsValidU64, `discount_transfer.discount_dispatch.discount.duration_minutes ${v}`)
669
- if (v.discount?.time_start && !IsValidU64(v.discount.time_start)) ERROR(Errors.IsValidU64, `discount_transfer.discount_dispatch.discount.time_start ${v}`)
670
- if (v.discount?.price_greater && !IsValidU64(v.discount.price_greater)) ERROR(Errors.IsValidU64, `discount_transfer.discount_dispatch.discount.price_greater ${v}`)
671
- })
672
-
673
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
674
- discount_dispatch.forEach((discount) => {
675
- let price_greater = this.txb.pure.option('u64', discount.discount?.price_greater ? discount.discount?.price_greater : undefined);
676
- let time_start = this.txb.pure.option('u64', discount.discount?.time_start ? discount.discount?.time_start : undefined);
677
-
678
- if (passport) {
679
- this.txb.moveCall({
680
- target:Protocol.Instance().serviceFn('dicscount_create_with_passport') as FnCallType,
681
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(discount.discount.name),
682
- this.txb.pure.u8(discount.discount.type),
683
- this.txb.pure.u64(discount.discount.off), price_greater, time_start,
684
- this.txb.pure.u64(discount.discount.duration_minutes), this.txb.pure.u64(discount.count),
685
- Protocol.TXB_OBJECT(this.txb, this.permission), this.txb.pure.address(discount.receiver), this.txb.object(clock)],
686
- typeArguments:[this.pay_token_type]
687
- });
688
- } else {
689
- this.txb.moveCall({
690
- target:Protocol.Instance().serviceFn('dicscount_create') as FnCallType,
691
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(discount.discount.name),
692
- this.txb.pure.u8(discount.discount.type),
693
- this.txb.pure.u64(discount.discount.off), price_greater, time_start,
694
- this.txb.pure.u64(discount.discount.duration_minutes), this.txb.pure.u64(discount.count),
695
- Protocol.TXB_OBJECT(this.txb, this.permission), this.txb.pure.address(discount.receiver),
696
- this.txb.object(clock)],
697
- typeArguments:[this.pay_token_type]
698
- })
699
- }
700
- });
701
- }
702
-
703
- // support both withdraw guard and permission guard
704
- // withdraw_guard & passport must BOTH valid.
705
- withdraw(order:OrderObject, param:WithdrawPayee, passport:PassportObject) : PaymentAddress {
706
- if (!Protocol.IsValidObjects([order, param.treasury, param.withdraw_guard, passport])) {
707
- ERROR(Errors.IsValidObjects,)
708
- }
709
- if (param?.for_guard && !Protocol.IsValidObjects([param.for_guard])) {
710
- ERROR(Errors.IsValidObjects, 'withdraw.param.for_guard')
711
- }
712
- if (param?.for_object && !IsValidAddress(param.for_object)) {
713
- ERROR(Errors.IsValidAddress, 'withdraw.param.for_object')
714
- }
715
- if (!IsValidU64(param.index)) {
716
- ERROR(Errors.IsValidU64, 'withdraw.param.index')
717
- }
718
- if (!IsValidDesription(param.remark)) {
719
- ERROR(Errors.IsValidDesription, 'withdraw.param.remark')
720
- }
721
-
722
- const for_obj = this.txb.pure.option('address', param.for_object ? param.for_object : undefined);
723
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
724
-
725
- if (param.for_guard) {
726
- return this.txb.moveCall({
727
- target:Protocol.Instance().serviceFn('withdraw_forGuard_with_passport') as FnCallType,
728
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, param.withdraw_guard),
729
- Protocol.TXB_OBJECT(this.txb, param.treasury), for_obj, Protocol.TXB_OBJECT(this.txb, param.for_guard), this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
730
- this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
731
- typeArguments:[this.pay_token_type]
732
- })
733
- } else {
734
- return this.txb.moveCall({
735
- target:Protocol.Instance().serviceFn('withdraw_with_passport') as FnCallType,
736
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, param.withdraw_guard),
737
- Protocol.TXB_OBJECT(this.txb, param.treasury), for_obj, this.txb.pure.u64(param.index), this.txb.pure.string(param.remark),
738
- this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
739
- typeArguments:[this.pay_token_type]
740
- })
741
- }
742
- }
743
-
744
- set_buy_guard(guard?:GuardObject | null, passport?:PassportObject) {
745
- if (passport) {
746
- if (guard) {
747
- this.txb.moveCall({
748
- target:Protocol.Instance().serviceFn('buy_guard_set_with_passport') as FnCallType,
749
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
750
- typeArguments:[this.pay_token_type]
751
- })
752
- } else {
753
- this.txb.moveCall({
754
- target:Protocol.Instance().serviceFn('buy_guard_none_with_passport') as FnCallType,
755
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
756
- typeArguments:[this.pay_token_type]
757
- })
758
- }
759
- } else {
760
- if (guard) {
761
- this.txb.moveCall({
762
- target:Protocol.Instance().serviceFn('buy_guard_set') as FnCallType,
763
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), Protocol.TXB_OBJECT(this.txb, this.permission)],
764
- typeArguments:[this.pay_token_type]
765
- })
766
- } else {
767
- this.txb.moveCall({
768
- target:Protocol.Instance().serviceFn('buy_guard_none') as FnCallType,
769
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
770
- typeArguments:[this.pay_token_type]
771
- })
772
- }
773
- }
774
- }
775
- set_machine(machine?:MachineObject, passport?:PassportObject) {
776
- if (passport) {
777
- if (machine) {
778
- this.txb.moveCall({
779
- target:Protocol.Instance().serviceFn('machine_set_with_passport') as FnCallType,
780
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, machine), Protocol.TXB_OBJECT(this.txb, this.permission)],
781
- typeArguments:[this.pay_token_type]
782
- })
783
- } else {
784
- this.txb.moveCall({
785
- target:Protocol.Instance().serviceFn('machine_none_with_passport') as FnCallType,
786
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
787
- typeArguments:[this.pay_token_type]
788
- })
789
- }
790
- } else {
791
- if (machine) {
792
- this.txb.moveCall({
793
- target:Protocol.Instance().serviceFn('machine_set') as FnCallType,
794
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, machine), Protocol.TXB_OBJECT(this.txb, this.permission)],
795
- typeArguments:[this.pay_token_type]
796
- })
797
- } else {
798
- this.txb.moveCall({
799
- target:Protocol.Instance().serviceFn('machine_none') as FnCallType,
800
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
801
- typeArguments:[this.pay_token_type]
802
- })
803
- }
804
- }
805
- }
806
-
807
- set_endpoint(endpoint?:string | null, passport?:PassportObject) {
808
- if (endpoint && !IsValidEndpoint(endpoint)) {
809
- ERROR(Errors.IsValidEndpoint);
810
- }
811
-
812
- let ep = this.txb.pure.option('string', endpoint ? endpoint : undefined);
813
- if (passport) {
814
- this.txb.moveCall({
815
- target:Protocol.Instance().serviceFn('endpoint_set_with_passport') as FnCallType,
816
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), ep, Protocol.TXB_OBJECT(this.txb, this.permission)],
817
- typeArguments:[this.pay_token_type]
818
- })
819
- } else {
820
- this.txb.moveCall({
821
- target:Protocol.Instance().serviceFn('endpoint_set') as FnCallType,
822
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), ep, Protocol.TXB_OBJECT(this.txb, this.permission)],
823
- typeArguments:[this.pay_token_type]
824
- })
825
- }
826
- }
827
-
828
- publish(passport?:PassportObject) {
829
- if (passport) {
830
- this.txb.moveCall({
831
- target:Protocol.Instance().serviceFn('publish_with_passport') as FnCallType,
832
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
833
- typeArguments:[this.pay_token_type]
834
- })
835
- } else {
836
- this.txb.moveCall({
837
- target:Protocol.Instance().serviceFn('publish') as FnCallType,
838
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
839
- typeArguments:[this.pay_token_type]
840
- })
841
- }
842
-
843
- }
844
-
845
- clone(new_token_type?:string, bLaunch?:boolean, passport?:PassportObject) : ServiceObject | ServiceAddress {
846
- let ret : ServiceObject | undefined;
847
- if (passport) {
848
- ret = this.txb.moveCall({
849
- target:Protocol.Instance().serviceFn('clone_withpassport') as FnCallType,
850
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
851
- typeArguments:[this.pay_token_type, new_token_type ? new_token_type : this.pay_token_type]
852
- })
853
- } else {
854
- ret = this.txb.moveCall({
855
- target:Protocol.Instance().serviceFn('clone') as FnCallType,
856
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
857
- typeArguments:[this.pay_token_type, new_token_type ? new_token_type : this.pay_token_type]
858
- })
859
- }
860
- if (bLaunch) {
861
- return this.txb.moveCall({
862
- target:Protocol.Instance().serviceFn('create') as FnCallType,
863
- arguments:[Protocol.TXB_OBJECT(this.txb, ret)],
864
- typeArguments:[new_token_type ? new_token_type : this.pay_token_type]
865
- })
866
- } else {
867
- return ret;
868
- }
869
- }
870
-
871
- set_customer_required(pubkey:string, customer_required: (BuyRequiredEnum | string)[], passport?:PassportObject) {
872
- if(customer_required.length > 0 && !pubkey) {
873
- ERROR(Errors.InvalidParam, 'set_customer_required')
874
- }
875
- if(pubkey.length > Service.MAX_PUBKEY_SIZE) {
876
- ERROR(Errors.InvalidParam, 'set_customer_required.pubkey')
877
- }
878
- if(customer_required.length > Service.MAX_REQUIRES_COUNT) {
879
- ERROR(Errors.InvalidParam, 'set_customer_required.customer_required')
880
- }
881
- if(!IsValidArray(customer_required, IsValidName)) {
882
- ERROR(Errors.IsValidArray, 'set_customer_required.customer_required')
883
- }
884
-
885
- let req = array_unique(customer_required) as string[];
886
-
887
- if (passport) {
888
- this.txb.moveCall({
889
- target:Protocol.Instance().serviceFn('required_set_with_passport') as FnCallType,
890
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
891
- this.txb.pure.vector('string', req),
892
- this.txb.pure.string(pubkey), Protocol.TXB_OBJECT(this.txb, this.permission)],
893
- typeArguments:[this.pay_token_type]
894
- })
895
- } else {
896
- this.txb.moveCall({
897
- target:Protocol.Instance().serviceFn('required_set') as FnCallType,
898
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
899
- this.txb.pure.vector('string', req),
900
- this.txb.pure.string(pubkey), Protocol.TXB_OBJECT(this.txb, this.permission)],
901
- typeArguments:[this.pay_token_type]
902
- })
903
- }
904
- }
905
-
906
- remove_customer_required(passport?:PassportObject) {
907
- if (passport) {
908
- this.txb.moveCall({
909
- target:Protocol.Instance().serviceFn('required_none_with_passport') as FnCallType,
910
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
911
- typeArguments:[this.pay_token_type]
912
- })
913
- } else {
914
- this.txb.moveCall({
915
- target:Protocol.Instance().serviceFn('required_none') as FnCallType,
916
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
917
- typeArguments:[this.pay_token_type]
918
- })
919
- }
920
- }
921
-
922
- change_required_pubkey(pubkey:string, passport?:PassportObject) {
923
- if (!pubkey) {
924
- ERROR(Errors.InvalidParam, 'pubkey')
925
- }
926
-
927
- if (passport) {
928
- this.txb.moveCall({
929
- target:Protocol.Instance().serviceFn('required_pubkey_set_with_passport') as FnCallType,
930
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(pubkey),
931
- Protocol.TXB_OBJECT(this.txb, this.permission)],
932
- typeArguments:[this.pay_token_type]
933
- })
934
- } else {
935
- this.txb.moveCall({
936
- target:Protocol.Instance().serviceFn('required_pubkey_set') as FnCallType,
937
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(pubkey),
938
- Protocol.TXB_OBJECT(this.txb, this.permission)],
939
- typeArguments:[this.pay_token_type]
940
- })
941
- }
942
- }
943
- /*
944
- change_order_required_pubkey(order:OrderObject, pubkey:string, passport?:PassportObject) {
945
- if (!Protocol.IsValidObjects([order])) {
946
- ERROR(Errors.IsValidObjects, 'order')
947
- }
948
- if (!pubkey) {
949
- ERROR(Errors.InvalidParam, 'pubkey')
950
- }
951
-
952
- if (passport) {
953
- this.txb.moveCall({
954
- target:Protocol.Instance().serviceFn('order_pubkey_update_with_passport') as FnCallType,
955
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.pure.string(pubkey),
956
- Protocol.TXB_OBJECT(this.txb, this.permission)],
957
- typeArguments:[this.pay_token_type]
958
- })
959
- } else {
960
- this.txb.moveCall({
961
- target:Protocol.Instance().serviceFn('order_pubkey_update') as FnCallType,
962
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), this.txb.pure.string(pubkey),
963
- Protocol.TXB_OBJECT(this.txb, this.permission)],
964
- typeArguments:[this.pay_token_type]
965
- })
966
- }
967
- } */
968
- refund_by_service(order:OrderObject, passport?:PassportObject) {
969
- if (!Protocol.IsValidObjects([order])) {
970
- ERROR(Errors.IsValidObjects, `refund_by_service.order ${order}`)
971
- }
972
- if (passport) {
973
- this.txb.moveCall({
974
- target:Protocol.Instance().serviceFn('refund_by_service_with_passport') as FnCallType,
975
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, this.permission)],
976
- typeArguments:[this.pay_token_type]
977
- })
978
- } else {
979
- this.txb.moveCall({
980
- target:Protocol.Instance().serviceFn('refund_by_service') as FnCallType,
981
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, this.permission)],
982
- typeArguments:[this.pay_token_type]
983
- })
984
- }
985
- }
986
-
987
- pause(pause:boolean, passport?:PassportObject) {
988
- if (passport) {
989
- this.txb.moveCall({
990
- target:Protocol.Instance().serviceFn('pause_with_passport') as FnCallType,
991
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(pause), Protocol.TXB_OBJECT(this.txb, this.permission)],
992
- typeArguments:[this.pay_token_type]
993
- })
994
- } else {
995
- this.txb.moveCall({
996
- target:Protocol.Instance().serviceFn('pause') as FnCallType,
997
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(pause), Protocol.TXB_OBJECT(this.txb, this.permission)],
998
- typeArguments:[this.pay_token_type]
999
- })
1000
- }
1001
- }
1002
-
1003
- refund_withArb(order:OrderObject, arb:ArbObject, arb_type:string) {
1004
- if (!Protocol.IsValidObjects([order, arb])) {
1005
- ERROR(Errors.IsValidObjects, 'refund_withArb.order or arb')
1006
- }
1007
- if (!IsValidTokenType(arb_type)) {
1008
- ERROR(Errors.IsValidTokenType, 'refund_withArb.arb_type')
1009
- }
1010
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
1011
- this.txb.moveCall({
1012
- target:Protocol.Instance().serviceFn('refund_with_arb') as FnCallType,
1013
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, arb), this.txb.object(clock)],
1014
- typeArguments:[this.pay_token_type, arb_type]
1015
- })
1016
- }
1017
-
1018
- refund(order:OrderObject, refund_guard?:GuardObject, passport?:PassportObject) {
1019
- if (!Protocol.IsValidObjects([order])) {
1020
- ERROR(Errors.IsValidObjects, 'refund.order')
1021
- }
1022
- if (refund_guard && !Protocol.IsValidObjects([refund_guard])) {
1023
- ERROR(Errors.IsValidObjects, 'refund.refund_guard')
1024
- }
1025
- if (passport && !refund_guard) {
1026
- ERROR(Errors.InvalidParam, 'refund.passport need refund_guard')
1027
- }
1028
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
1029
- if (passport && refund_guard) {
1030
- this.txb.moveCall({
1031
- target:Protocol.Instance().serviceFn('refund_with_passport') as FnCallType,
1032
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, refund_guard),
1033
- passport, this.txb.object(clock)],
1034
- typeArguments:[this.pay_token_type]
1035
- })
1036
- } else {
1037
- this.txb.moveCall({
1038
- target:Protocol.Instance().serviceFn('refund') as FnCallType,
1039
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order)],
1040
- typeArguments:[this.pay_token_type]
1041
- })
1042
- }
1043
- }
1044
-
1045
- update_order_required_info(order:OrderObject, customer_info_crypto: Customer_RequiredInfo) {
1046
- if (!customer_info_crypto.customer_pubkey) {
1047
- return
1048
- }
1049
-
1050
- if (!Protocol.IsValidObjects([order])) {
1051
- ERROR(Errors.IsValidObjects, 'update_order_required_info.order')
1052
- }
1053
-
1054
- this.txb.moveCall({
1055
- target:Protocol.Instance().serviceFn('order_required_info_update') as FnCallType,
1056
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order),
1057
- this.txb.pure.string(customer_info_crypto.customer_pubkey),
1058
- this.txb.pure.string(customer_info_crypto.customer_info_crypt)],
1059
- typeArguments:[this.pay_token_type]
1060
- })
1061
- }
1062
-
1063
- order(buy_items:Service_Buy[], coin:CoinObject, discount?:DiscountObject|null, machine?:MachineObject,
1064
- customer_info_crypto?: Customer_RequiredInfo, passport?:PassportObject) : OrderResult {
1065
- if (buy_items.length === 0) ERROR(Errors.InvalidParam, 'order.buy_items empty');
1066
-
1067
- const repeat:string[] = [];
1068
- buy_items.forEach((v) => {
1069
- if (!Service.IsValidItemName(v.item)) ERROR(Errors.InvalidParam, `order.buy_items.item ${v}`)
1070
- if (!IsValidU64(v.max_price)) ERROR(Errors.IsValidU64, `order.buy_items.max_price ${v}`)
1071
- if (!IsValidU64(v.count)) ERROR(Errors.IsValidU64, `order.buy_items.count ${v}`)
1072
- if (repeat.includes(v.item)) ERROR(Errors.InvalidParam, `order.buy_items.item repeat ${v}`)
1073
- repeat.push(v.item)
1074
- })
1075
-
1076
- const name:string[] = [];
1077
- const price:bigint[] = [];
1078
- const stock:bigint[] = [];
1079
- let order;
1080
-
1081
- buy_items.forEach((b) => { name.push(b.item); price.push(BigInt(b.max_price)); stock.push(BigInt(b.count))})
1082
- const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
1083
- if (passport) {
1084
- if (discount) {
1085
- order = this.txb.moveCall({
1086
- target:Protocol.Instance().serviceFn('dicount_buy_with_passport') as FnCallType,
1087
- arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
1088
- this.txb.pure.vector('u64', price), this.txb.pure.vector('u64', stock),
1089
- Protocol.TXB_OBJECT(this.txb, coin), Protocol.TXB_OBJECT(this.txb, discount), this.txb.object(clock)],
1090
- typeArguments:[this.pay_token_type]
1091
- })} else {
1092
- order = this.txb.moveCall({
1093
- target:Protocol.Instance().serviceFn('buy_with_passport') as FnCallType,
1094
- arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
1095
- this.txb.pure.vector('u64', price), this.txb.pure.vector('u64', stock),
1096
- Protocol.TXB_OBJECT(this.txb, coin)],
1097
- typeArguments:[this.pay_token_type]
1098
- })}
1099
- } else {
1100
- if (discount) {
1101
- order = this.txb.moveCall({
1102
- target:Protocol.Instance().serviceFn('disoucnt_buy') as FnCallType,
1103
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
1104
- this.txb.pure.vector('u64', price),
1105
- this.txb.pure.vector('u64', stock),
1106
- Protocol.TXB_OBJECT(this.txb, coin),
1107
- Protocol.TXB_OBJECT(this.txb, discount), this.txb.object(clock)],
1108
- typeArguments:[this.pay_token_type]
1109
- })} else {
1110
- order = this.txb.moveCall({
1111
- target:Protocol.Instance().serviceFn('buy') as FnCallType,
1112
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
1113
- this.txb.pure.vector('u64', price),
1114
- this.txb.pure.vector('u64', stock),
1115
- Protocol.TXB_OBJECT(this.txb, coin)],
1116
- typeArguments:[this.pay_token_type]
1117
- })}
1118
- }
1119
-
1120
- if (customer_info_crypto) {
1121
- this.update_order_required_info(order, customer_info_crypto);
1122
- }
1123
-
1124
- var progress : ProgressObject | undefined = undefined;
1125
- if (machine) {
1126
- progress = this.order_bind_machine(order, machine);
1127
- }
1128
- return {order:order, progress: progress}
1129
- }
1130
-
1131
- order_launch(order:OrderResult) : BuyResult {
1132
- var progress : ProgressAddress | undefined;
1133
- if (order.progress) {
1134
- progress = this.txb.moveCall({
1135
- target:Protocol.Instance().progressFn('create') as FnCallType,
1136
- arguments: [Protocol.TXB_OBJECT(this.txb, order.progress)],
1137
- })
1138
- }
1139
-
1140
- return {order: this.txb.moveCall({
1141
- target:Protocol.Instance().serviceFn('order_create') as FnCallType,
1142
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order.order)],
1143
- typeArguments:[this.pay_token_type]
1144
- }), progress:progress}
1145
- }
1146
-
1147
- buy(buy_items:Service_Buy[], coin:CoinObject, discount?:DiscountObject, machine?:MachineObject,
1148
- customer_info_crypto?: Customer_RequiredInfo, passport?:PassportObject) : BuyResult {
1149
- const r = this.order(buy_items, coin ,discount, machine, customer_info_crypto, passport);
1150
- return this.order_launch(r);
1151
- }
1152
-
1153
- order_bind_machine(order:OrderObject, machine:MachineObject) : ProgressObject {
1154
- if (!Protocol.IsValidObjects([order, machine])) {
1155
- ERROR(Errors.IsValidObjects, 'order & machine');
1156
- }
1157
-
1158
- return this.txb.moveCall({
1159
- target:Protocol.Instance().serviceFn('order_bind_machine') as FnCallType,
1160
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, machine)],
1161
- typeArguments:[this.pay_token_type]
1162
- })
1163
- }
1164
-
1165
- add_treasury(treasury:TreasuryObject, treasury_token_type:string, passport?:PassportObject) {
1166
- if (!Protocol.IsValidObjects([treasury])) {
1167
- ERROR(Errors.IsValidObjects, 'add_treasury.treasury')
1168
- }
1169
- if (!IsValidTokenType(treasury_token_type)) {
1170
- ERROR(Errors.IsValidTokenType, 'add_treasury.treasury_token_type')
1171
- }
1172
-
1173
- if (passport) {
1174
- this.txb.moveCall({
1175
- target:Protocol.Instance().serviceFn('treasury_add_with_passport') as FnCallType,
1176
- arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
1177
- typeArguments:[this.pay_token_type, treasury_token_type]
1178
- })
1179
- } else {
1180
- this.txb.moveCall({
1181
- target:Protocol.Instance().serviceFn('treasury_add') as FnCallType,
1182
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
1183
- typeArguments:[this.pay_token_type, treasury_token_type]
1184
- })
1185
- }
1186
- }
1187
-
1188
- remove_treasury(treasury:string[], removeall?:boolean, passport?:PassportObject) {
1189
- if (!removeall && treasury.length === 0) return ;
1190
-
1191
- if (passport) {
1192
- if (removeall) {
1193
- this.txb.moveCall({
1194
- target:Protocol.Instance().serviceFn('treasury_remove_all_with_passport') as FnCallType,
1195
- arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
1196
- typeArguments:[this.pay_token_type]
1197
- })
1198
- } else {
1199
- this.txb.moveCall({
1200
- target:Protocol.Instance().serviceFn('treasury_remove_with_passport') as FnCallType,
1201
- arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
1202
- typeArguments:[this.pay_token_type]
1203
- })
1204
- }
1205
- } else {
1206
- if (removeall) {
1207
- this.txb.moveCall({
1208
- target:Protocol.Instance().serviceFn('treasury_remove_all') as FnCallType,
1209
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
1210
- typeArguments:[this.pay_token_type]
1211
- })
1212
- } else {
1213
- this.txb.moveCall({
1214
- target:Protocol.Instance().serviceFn('treasury_remove') as FnCallType,
1215
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('address', treasury), Protocol.TXB_OBJECT(this.txb, this.permission)],
1216
- typeArguments:[this.pay_token_type]
1217
- })
1218
- }
1219
- }
1220
- }
1221
-
1222
- change_permission(new_permission:PermissionObject) {
1223
- if (!Protocol.IsValidObjects([new_permission])) {
1224
- ERROR(Errors.IsValidObjects)
1225
- }
1226
-
1227
- this.txb.moveCall({
1228
- target:Protocol.Instance().serviceFn('permission_set') as FnCallType,
1229
- arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
1230
- typeArguments:[this.pay_token_type]
1231
- })
1232
- this.permission = new_permission
1233
- }
1234
-
1235
- set_order_agent(order:OrderObject, agent:string[], orderProgress?:ProgressObject) {
1236
- Service.SetOrderAgent(this.txb, this.pay_token_type, order, agent, orderProgress)
1237
- }
1238
- change_order_payer(order:OrderObject, new_addr:string, orderProgress?:ProgressObject) {
1239
- Service.ChangeOrderPayer(this.txb, this.pay_token_type, order, new_addr, orderProgress)
1240
- }
1241
- static MAX_DISCOUNT_COUNT_ONCE = 200;
1242
- static MAX_DISCOUNT_RECEIVER_COUNT = 20;
1243
- static MAX_GUARD_COUNT = 16;
1244
- static MAX_REPOSITORY_COUNT = 32;
1245
- static MAX_ITEM_NAME_LENGTH = 256;
1246
- static MAX_TREASURY_COUNT= 8;
1247
- static MAX_ORDER_AGENT_COUNT = 8;
1248
- static MAX_ORDER_ARBS_COUNT = 8;
1249
- static MAX_ARBITRATION_COUNT = 8;
1250
- static MAX_REQUIRES_COUNT = 16;
1251
- static MAX_PUBKEY_SIZE = 3000;
1252
-
1253
- static IsValidItemName(name:string) : boolean {
1254
- if (!name) return false;
1255
- return IsValidStringLength(name, Service.MAX_ITEM_NAME_LENGTH);
1256
- }
1257
-
1258
- static parseObjectType = (chain_type:string | undefined | null) : string => {
1259
- return parseObjectType(chain_type, 'service::Service<')
1260
- }
1261
-
1262
- static parseOrderObjectType = (chain_type:string | undefined | null) : string => {
1263
- return parseObjectType(chain_type, 'order::Order<')
1264
- }
1265
-
1266
- static endpoint = (service_endpoint:string, item_endpoint:string, item_name:string) => {
1267
- if (item_endpoint) {
1268
- return item_endpoint
1269
- } else if (service_endpoint) {
1270
- return service_endpoint + '/sales/' + encodeURI(item_name);
1271
- }
1272
- }
1273
-
1274
- static DiscountObjects = (owner:string, handleDiscountObject:handleDiscountObject) => {
1275
- Protocol.Client().getOwnedObjects({owner:owner,
1276
- filter:{MoveModule:{module:'order', package:Protocol.Instance().package('wowok')}},
1277
- options:{showContent:true, showType:true}}).then((res) => {
1278
- handleDiscountObject(owner, res.data.map((v)=>v.data));
1279
- }).catch((e) => {
1280
- //console.log(e);
1281
- })
1282
- }
1283
-
1284
- // The agent has the same order operation power as the order payer; The agent can only be set by the order payer.
1285
- static SetOrderAgent = (txb:TransactionBlock, order_token_type:string, order:OrderObject, agent:string[], order_progress?:ProgressObject) => {
1286
- if (!IsValidTokenType(order_token_type)) {
1287
- ERROR(Errors.IsValidTokenType, 'SetOrderAgent.order_token_type');
1288
- }
1289
- if (!Protocol.IsValidObjects([order])) {
1290
- ERROR(Errors.IsValidObjects, 'SetOrderAgent.order')
1291
- }
1292
- if (!IsValidArray(agent, IsValidAddress)) {
1293
- ERROR(Errors.IsValidArray, 'SetOrderAgent.agent')
1294
- }
1295
- if (array_unique(agent).length > Service.MAX_ORDER_AGENT_COUNT) {
1296
- ERROR(Errors.Fail, 'SetOrderAgent.agent count')
1297
- }
1298
-
1299
- txb.moveCall({
1300
- target:Protocol.Instance().orderFn('agent_set') as FnCallType,
1301
- arguments: [Protocol.TXB_OBJECT(txb, order), txb.pure.vector('address', array_unique(agent))],
1302
- typeArguments:[order_token_type]
1303
- })
1304
- if (order_progress) {
1305
- txb.moveCall({
1306
- target:Protocol.Instance().orderFn('order_ops_to_progress') as FnCallType,
1307
- arguments: [Protocol.TXB_OBJECT(txb, order), Protocol.TXB_OBJECT(txb, order_progress)],
1308
- typeArguments:[order_token_type]
1309
- })
1310
- }
1311
- }
1312
- static ChangeOrderPayer = (txb:TransactionBlock, order_token_type:string, order:OrderObject, new_addr:string, order_progress?:ProgressObject) => {
1313
- if (!IsValidTokenType(order_token_type)) {
1314
- ERROR(Errors.IsValidTokenType, 'ChangeOrderPayer.order_token_type');
1315
- }
1316
- if (!Protocol.IsValidObjects([order])) {
1317
- ERROR(Errors.IsValidObjects, 'ChangeOrderPayer.order')
1318
- }
1319
- if (!IsValidAddress(new_addr)) {
1320
- ERROR(Errors.IsValidAddress, 'ChangeOrderPayer.new_addr')
1321
- }
1322
- txb.moveCall({
1323
- target:Protocol.Instance().orderFn('payer_change') as FnCallType,
1324
- arguments: [Protocol.TXB_OBJECT(txb, order), txb.pure.address(new_addr)],
1325
- typeArguments:[order_token_type]
1326
- })
1327
- if (order_progress) {
1328
- txb.moveCall({
1329
- target:Protocol.Instance().orderFn('order_ops_to_progress') as FnCallType,
1330
- arguments: [Protocol.TXB_OBJECT(txb, order), Protocol.TXB_OBJECT(txb, order_progress)],
1331
- typeArguments:[order_token_type]
1332
- })
1333
- }
1334
- }
1335
-
1336
- // return current balance
1337
- static OrderReceive(txb:TransactionBlock, order_token_type:string, order:OrderObject,
1338
- payment:PaymentObject, received:ReceivedObject, token_type:string) : TransactionResult {
1339
- if (!Protocol.IsValidObjects([payment, received])) {
1340
- ERROR(Errors.IsValidArray, 'OrderReceive.payment&received');
1341
- }
1342
-
1343
- return txb.moveCall({
1344
- target:Protocol.Instance().orderFn('receive') as FnCallType,
1345
- arguments:[Protocol.TXB_OBJECT(txb, order), Protocol.TXB_OBJECT(txb, received), Protocol.TXB_OBJECT(txb, payment)],
1346
- typeArguments:[order_token_type, token_type],
1347
- })
1348
- }
1349
- }