wowok 1.4.35 → 1.5.38

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/src/guard.ts CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
- import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, SER_VALUE} from './protocol';
4
- import { concatenate, array_equal } from './utils';
3
+ import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject, GuardObject} from './protocol';
4
+ import { concatenate, array_equal, ValueTypeConvert } from './utils';
5
5
  import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase, insertAtHead } from './utils';
6
6
  import { ERROR, Errors } from './exception';
7
7
  import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
@@ -23,7 +23,22 @@ export interface Guard_Options {
23
23
 
24
24
  export class Guard {
25
25
  static MAX_INPUT_LENGTH = 10240;
26
- static launch(txb:TransactionBlock, description:string, maker:GuardMaker) : GuardAddress {
26
+ protected txb;
27
+ protected object : TxbObject;
28
+ get_object() { return this.object }
29
+
30
+ static From(txb:TransactionBlock, object:TxbObject) : Guard {
31
+ let d = new Guard(txb)
32
+ d.object = Protocol.TXB_OBJECT(txb, object)
33
+ return d
34
+ }
35
+
36
+ private constructor(txb:TransactionBlock) {
37
+ this.txb = txb;
38
+ this.object = '';
39
+ }
40
+
41
+ static New(txb:TransactionBlock, description:string, maker:GuardMaker) : Guard {
27
42
  if (!maker.IsReady()) {
28
43
  ERROR(Errors.InvalidParam, 'launch maker');
29
44
  }
@@ -50,7 +65,8 @@ export class Guard {
50
65
  let input = new Uint8Array(bcs_input); // copy new uint8array to reserve!
51
66
 
52
67
  // reserve the bytes for guard
53
- let guard = txb.moveCall({
68
+ let g = new Guard(txb);
69
+ g.object = txb.moveCall({
54
70
  target: Protocol.Instance().GuardFn('new') as FnCallType,
55
71
  arguments: [txb.pure.string(description), txb.pure.vector('u8', [].slice.call(input.reverse()))],
56
72
  });
@@ -60,20 +76,23 @@ export class Guard {
60
76
  const n = new Uint8Array(1); n.set([v.type], 0);
61
77
  txb.moveCall({
62
78
  target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
63
- arguments:[guard, txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
79
+ arguments:[txb.object(g.object), txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
64
80
  })
65
81
  } else {
66
82
  const n = insertAtHead(v.value!, v.type);
67
83
  txb.moveCall({
68
84
  target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
69
- arguments:[guard, txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
85
+ arguments:[txb.object(g.object), txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
70
86
  })
71
87
  }
72
88
  });
73
-
74
- return txb.moveCall({
89
+ return g
90
+ }
91
+
92
+ launch() : GuardAddress {
93
+ return this.txb.moveCall({
75
94
  target:Protocol.Instance().GuardFn("create") as FnCallType,
76
- arguments:[guard]
95
+ arguments:[this.txb.object(this.object)]
77
96
  });
78
97
  }
79
98
 
@@ -124,7 +143,7 @@ export class Guard {
124
143
  [MODULES.repository, 'Address Vector Data', 119, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_ADDRESS, 'Data for a field at an address and get address vector type data.', ['address', 'the field name']],
125
144
  [MODULES.repository, 'Bool Vector Data', 120, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_BOOL, 'Data for a field at an address and get bool vector type data.', ['address', 'the field name']],
126
145
 
127
- [MODULES.entity, 'Contains Entity?', 200, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an entity already registered?', ['address']],
146
+ [MODULES.entity, 'Has Entity', 200, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an entity already registered?', ['address']],
128
147
  [MODULES.entity, 'Likes', 201, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of likes for an address by other addresses.', ['address']],
129
148
  [MODULES.entity, 'Dislikes', 202, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of dislikes for an address by other addresses.', ['address']],
130
149
  [MODULES.entity, 'Entity Info', 203, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8, 'Public information about an entity.', ['address']],
@@ -162,6 +181,8 @@ export class Guard {
162
181
  [MODULES.service, 'Has Required Info', 416, [], ValueType.TYPE_BOOL, 'Whether the necessary information that needs to be provided by the customer is set?', []],
163
182
  [MODULES.service, 'Required Info of Service-Pubkey', 417, [], ValueType.TYPE_STRING, 'The public key used to encrypt customer information, and only the service provider can decrypt and view customer information.', []],
164
183
  [MODULES.service, 'Required Info', 418, [], ValueType.TYPE_VEC_STRING, 'Names of the required information item that needs to be provided by the customer.', []],
184
+ [MODULES.service, 'Number of Treasuries', 419, [], ValueType.TYPE_U64, 'The number of treasuries that can be externally withdrawn for purposes such as compensation or incentives.', []],
185
+ [MODULES.service, 'Contains Treasury', 420, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Does it contain externally withdrawable Treasury for purposes such as compensation or incentives?', ['treasury address']],
165
186
 
166
187
  [MODULES.order, 'Amount', 500, [], ValueType.TYPE_U64, 'Order amount.', []],
167
188
  [MODULES.order, 'Payer', 501, [], ValueType.TYPE_ADDRESS, 'Order payer.', []],
@@ -174,7 +195,11 @@ export class Guard {
174
195
  [MODULES.order, 'Balance', 508, [], ValueType.TYPE_U64, 'The amount currently in the order.', []],
175
196
  [MODULES.order, 'Refunded', 509, [], ValueType.TYPE_BOOL, 'Whether a refund has occurred?', []],
176
197
  [MODULES.order, 'Withdrawed', 510, [], ValueType.TYPE_BOOL, 'Whether a service provider withdrawal has occurred?', []],
177
-
198
+ [MODULES.order, 'Number of Agents', 511, [], ValueType.TYPE_U64, 'The number of agents for the order.', []],
199
+ [MODULES.order, 'Has Agent', 512, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address is an order agent?', ['agent address']],
200
+ [MODULES.order, 'Number of Disputes', 513, [], ValueType.TYPE_U64, 'Number of arbitrations for the order.', []],
201
+ [MODULES.order, 'Has Arb', 514, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Does the order contain an Arb for arbitration?', ['arb address']],
202
+ /* @Deprecated
178
203
  [MODULES.reward, 'Permission', 600, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
179
204
  [MODULES.reward, 'Rewards Remaining', 601, [], ValueType.TYPE_U64, 'Number of rewards to be claimed.', []],
180
205
  [MODULES.reward, 'Reward Count Supplied', 602, [], ValueType.TYPE_U64, 'Total rewards supplied.', []],
@@ -189,9 +214,8 @@ export class Guard {
189
214
  [MODULES.reward, 'Portions by A Sponsor', 611, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of sponsorship reward pools for a certain address.', ['address']],
190
215
  [MODULES.reward, 'Number of Sponsors', 612, [], ValueType.TYPE_U64, 'Number of sponsors in the sponsorship reward pool.', []],
191
216
  [MODULES.reward, 'Allow Repeated Claims', 613, [], ValueType.TYPE_BOOL, 'Whether to allow repeated claims?', []],
192
-
193
- // , means that data fields and data outside the consensus policy definition are allowed to be written
194
- // , means that only data fields and data defined by the consensus policy are allowed to be written.
217
+ */
218
+
195
219
  [MODULES.machine, 'Permission', 700, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
196
220
  [MODULES.machine, 'Paused', 701, [], ValueType.TYPE_BOOL, 'Pause the creation of new Progress?', []],
197
221
  [MODULES.machine, 'Published', 702, [], ValueType.TYPE_BOOL, 'Is it allowed to create Progress?', []],
@@ -216,13 +240,13 @@ export class Guard {
216
240
  [MODULES.progress, 'Parent Next Node', 814, [], ValueType.TYPE_STRING, 'The child process is started at the next node stage of the parent process.', []],
217
241
  [MODULES.progress, 'Parent Forward', 815, [], ValueType.TYPE_STRING, 'The child process is started in the Forward phase of the next node of the parent process.', []],
218
242
  [MODULES.progress, 'Parent Node', 816, [], ValueType.TYPE_STRING, 'The node name of the parent process where the child process is located.', []],
219
- [MODULES.progress, 'Forward Accomplished', 817, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has a forward been accomplished?', ['session-id', 'next node name', 'forward name']],
243
+ [MODULES.progress, 'Forward Accomplished', 817, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has the forward been accomplished?', ['session-id', 'next node name', 'forward name']],
220
244
  [MODULES.progress, 'Forward Operator', 818, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward operator.', ['session-id', 'next node name', 'forward name']],
221
245
  [MODULES.progress, 'Forward Sub-progress', 819, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward child process address(if set).', ['session-id', 'next node name', 'forward name']],
222
246
  [MODULES.progress, 'Forward Deliverables', 820, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward deliverable(if set).', ['session-id', 'next node name', 'forward name']],
223
247
  [MODULES.progress, 'Forward time', 821, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time when the forward was last triggered.', ['session-id', 'next node name', 'forward name']],
224
248
  [MODULES.progress, 'Closest Session Time', 822, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time a node that closest time to the current node completes its session.', ['node name']],
225
- [MODULES.progress, 'Closest Forward Accomplished', 823, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has a forward been accomplished?', ['node name', 'next node name', 'forward name']],
249
+ [MODULES.progress, 'Closest Forward Accomplished', 823, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has the forward been accomplished?', ['node name', 'next node name', 'forward name']],
226
250
  [MODULES.progress, 'Closest Forward Operator', 824, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The operator of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
227
251
  [MODULES.progress, 'Closest Forward Sub-progress', 825, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The child process address(if set) of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
228
252
  [MODULES.progress, 'Closest Forward Deliverables', 826, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The deliverable(if set) of the forward that closest time to the current node.', ['node name', 'next node name', 'forward name']],
@@ -237,7 +261,7 @@ export class Guard {
237
261
  [MODULES.wowok, 'Grantor Registration Time', 906, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Registration time of a grantor.', ['address']],
238
262
  [MODULES.wowok, 'Grantor Expired Time', 907, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The expiration time of a grantor.', ['address']],
239
263
  [MODULES.wowok, 'Grantee Object for Grantor', 908, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Grantee repository address of a grantor.', ['address']],
240
-
264
+ /* @Deprecated
241
265
  [MODULES.vote, 'Permission', 1101, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
242
266
  [MODULES.vote, 'Be Voting', 1102, [], ValueType.TYPE_BOOL, 'Whether to start voting and options will not be changed?', []],
243
267
  [MODULES.vote, 'Deadline Locked', 1103, [], ValueType.TYPE_BOOL, 'Whether the deadline cannot be modified?', []],
@@ -261,7 +285,7 @@ export class Guard {
261
285
  [MODULES.vote, 'Top1 Option by Votes', 1121, [], ValueType.TYPE_STRING, 'The content of the voting option ranked first by the number of votes.', []],
262
286
  [MODULES.vote, 'Top1 Counts by Votes', 1122, [], ValueType.TYPE_U64, 'Number of votes for the top voting option by number of votes.', []],
263
287
  [MODULES.vote, 'Voted Time by Address', 1113, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The time of whether an address has been voted on.', ['adddress']],
264
-
288
+ */
265
289
  [MODULES.payment, 'Sender', 1200, [], ValueType.TYPE_ADDRESS, 'Payment originator address.', []],
266
290
  [MODULES.payment, 'Total Amount', 1201, [], ValueType.TYPE_U128, "Payment amount.", []],
267
291
  [MODULES.payment, 'Remark', 1202, [], ValueType.TYPE_STRING, 'Payment remark.', ['address']],
@@ -277,22 +301,6 @@ export class Guard {
277
301
  [MODULES.payment, 'Treasury Address', 1212, [], ValueType.TYPE_ADDRESS, 'The Treasury from which the payment comes.', []],
278
302
  [MODULES.payment, 'Biz-ID', 1213, [], ValueType.TYPE_U64, 'Bisiness ID number of the payment.', []],
279
303
 
280
- [MODULES.reward, 'Amount', 1300, [], ValueType.TYPE_U64, 'Total amount deposited with reward.' , []],
281
- [MODULES.reward, 'Original Type Deposited', 1301, [], ValueType.TYPE_STRING, "Original type name of asserts deposited.", []],
282
- [MODULES.reward, 'Original Package', 1302, [], ValueType.TYPE_ADDRESS, 'Original package address of asserts deposited.', []],
283
- [MODULES.reward, 'Original Module', 1303, [], ValueType.TYPE_STRING, 'Original module name of asserts deposited.', []],
284
- [MODULES.reward, 'Type Deposited', 1304, [], ValueType.TYPE_STRING, 'Type name of asserts deposited.', []],
285
- [MODULES.reward, 'Package', 1305, [], ValueType.TYPE_ADDRESS, 'Package address of asserts deposited.', , []],
286
- [MODULES.reward, 'Module', 1306, [], ValueType.TYPE_STRING, 'Module name of asserts deposited.', []],
287
- [MODULES.reward, 'Balance', 1307, [], ValueType.TYPE_U64, 'The amount currently remaining in reward.', []],
288
- [MODULES.reward, 'Deposit Time', 1308, [], ValueType.TYPE_U64, 'Deposit time.', []],
289
- [MODULES.reward, 'Be Withdrawable', 1309, [], ValueType.TYPE_BOOL, 'Whether to allow amount withdrawal?' , []],
290
- [MODULES.reward, 'Be Deposited from', 1310, [], ValueType.TYPE_BOOL, 'Is the deposit from source set?', []],
291
- [MODULES.reward, 'Deposited from Object', 1311, [], ValueType.TYPE_ADDRESS, 'The source object set when depositing.', []],
292
- [MODULES.reward, 'Contains Guard', 1312, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether the guard for withdrawal is set up?', []],
293
- [MODULES.reward, 'Withdrawal percentage', 1313, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U8, 'The percentage of withdrawals corresponding to Guard.', ['address']],
294
- [MODULES.reward, 'Number of withdrawals', 1314, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Number of withdrawals.'],
295
-
296
304
  [MODULES.treasury, 'Permission', 1400, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
297
305
  [MODULES.treasury, 'Balance', 1401, [], ValueType.TYPE_U64, "Treasury balance.", []],
298
306
  [MODULES.treasury, 'Number of Flow Records', 1402, [], ValueType.TYPE_U64, 'Number of treasury transactions.', []],
@@ -321,6 +329,31 @@ export class Guard {
321
329
  [MODULES.treasury, 'Has Operation with Pmt/Sgr', 1425, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation?', ['operation', 'payment address', 'singer address']],
322
330
  [MODULES.treasury, 'Operation at Least Times', 1426, [ValueType.TYPE_U8, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times?', ['operation', 'at least times']],
323
331
  [MODULES.treasury, 'Operation at Least Times by a Signer', 1427, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times by a signer?', ['operation', 'signer address', 'at least times']],
332
+
333
+ [MODULES.arbitration, 'Permission', 1500, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
334
+ [MODULES.arbitration, 'Paused', 1501, [], ValueType.TYPE_BOOL, "Is it allowed to create Arb?", []],
335
+ [MODULES.arbitration, 'Fee', 1502, [], ValueType.TYPE_U64, 'Cost of arbitration.', []],
336
+ [MODULES.arbitration, 'Has Endpoint', 1503, [], ValueType.TYPE_BOOL, 'Is the endpoint set?', []],
337
+ [MODULES.arbitration, 'Endpoint', 1504, [], ValueType.TYPE_STRING, 'Endpoint url/ipfs.', []],
338
+ [MODULES.arbitration, 'Has Customer Guard', 1505, [], ValueType.TYPE_BOOL, 'Is there Guard set to apply for arbitration?', []],
339
+ [MODULES.arbitration, 'Customer Guard', 1506, [], ValueType.TYPE_ADDRESS, 'Guard to apply for arbitration.', []],
340
+ [MODULES.arbitration, 'Number of Voting Guard', 1507, [], ValueType.TYPE_U64, 'Number of voting guards.', []],
341
+ [MODULES.arbitration, 'Has Voting Guard', 1508, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has the voting Guard added?', ['guard address']],
342
+ [MODULES.arbitration, 'Voting Weight', 1509, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Voting weight of the voting Guard.', ['guard address']],
343
+
344
+ [MODULES.arb, 'Order', 1600, [], ValueType.TYPE_ADDRESS, 'Order under arbitration.', []],
345
+ [MODULES.arb, 'Arbitration', 1601, [], ValueType.TYPE_ADDRESS, "Arbitration object address.", []],
346
+ [MODULES.arb, 'Feedback', 1602, [], ValueType.TYPE_STRING, 'Arbitration feedback.', []],
347
+ [MODULES.arb, 'Has Compensation', 1603, [], ValueType.TYPE_BOOL, 'Whether there is an arbitration result?', []],
348
+ [MODULES.arb, 'Compensation', 1604, [], ValueType.TYPE_U64, 'Compensation should be given to the order payer.', []],
349
+ [MODULES.arb, 'Unclaimed Arbitration Costs', 1605, [], ValueType.TYPE_U64, 'Unclaimed arbitration costs.', []],
350
+ [MODULES.arb, 'Turnout', 1606, [], ValueType.TYPE_U64, 'The number of addresses have voted.', []],
351
+ [MODULES.arb, 'Has voted', 1607, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has someone voted?', ['voter address']],
352
+ [MODULES.arb, 'Voting weight', 1608, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The weight of a complete vote for the address.', ['voter address']],
353
+ [MODULES.arb, 'Voting Time', 1609, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The time of a complete vote for the address.', ['voter address']],
354
+ [MODULES.arb, 'Voting Option', 1610, [ValueType.TYPE_ADDRESS, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does an address complete voting for the option?', ['voter address', 'option index']],
355
+ [MODULES.arb, 'Number of Options', 1611, [], ValueType.TYPE_U64, 'Number of voting options.', []],
356
+ [MODULES.arb, 'Number of Votes', 1612, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'The number of votes received for an option.', ['option index']],
324
357
  ];
325
358
 
326
359
  static BoolCmd = Guard.QUERIES.filter(q => q[4] === ValueType.TYPE_BOOL);
package/src/index.ts CHANGED
@@ -4,15 +4,15 @@ export * from './utils'
4
4
  export * from './permission'
5
5
  export * from './guard'
6
6
  export * from './repository'
7
- export * from './vote'
8
7
  export * from './protocol'
9
8
  export * from './passport'
10
9
  export * from './machine'
11
10
  export * from './service'
12
- export * from './graphql'
13
11
  export * from './entity'
14
12
  export * from './wowok'
15
13
  export * from './resource'
16
14
  export * from './treasury'
17
15
  export * from './payment'
18
- export * from './reward'
16
+ export * from './arbitration'
17
+ // export * from './reward'
18
+ // export * from './vote'
package/src/machine.ts CHANGED
@@ -543,12 +543,5 @@ export class Machine {
543
543
  })
544
544
  }
545
545
  static INITIAL_NODE_NAME = '';
546
- /* static NODE_NAME_RESERVED = 'origin';
547
- static IsNodeNameReserved = (name:string) => {
548
- return name.toLowerCase() === Machine.NODE_NAME_RESERVED
549
- }*/
550
- static SolveNodeName = (name:string) => {
551
- return name ? name : '⚪';
552
- }
553
546
  static OPERATOR_ORDER_PAYER = 'OrderPayer';
554
547
  }
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,
@@ -45,7 +45,8 @@ export enum PermissionIndex {
45
45
  service_customer_required = 222,
46
46
  //service_change_order_required_pubkey = 224,
47
47
  service_pause = 225,
48
-
48
+ service_treasury = 226,
49
+ /*
49
50
  reward = 240,
50
51
  reward_refund = 241,
51
52
  reward_expand_time = 242,
@@ -54,7 +55,7 @@ export enum PermissionIndex {
54
55
  reward_lock_guards = 246,
55
56
  reward_claim_repeatably = 247,
56
57
  reward_allow_claiming = 248,
57
-
58
+ */
58
59
  demand = 260,
59
60
  demand_refund = 261,
60
61
  demand_expand_time = 262,
@@ -87,6 +88,17 @@ export enum PermissionIndex {
87
88
  treasury_withdraw_mode = 706,
88
89
  treasury_withdraw_guard = 707,
89
90
 
91
+ arbitration = 800,
92
+ arbitration_description = 801,
93
+ arbitration_fee = 802,
94
+ arbitration_voting_guard = 803,
95
+ arbitration_endpoint = 804,
96
+ arbitration_guard = 805,
97
+ arbitration_pause = 806,
98
+ arbitration_vote = 807,
99
+ arbitration_arbitration = 808,
100
+ arbitration_withdraw = 809,
101
+
90
102
  user_defined_start = 1000,
91
103
  }
92
104
 
@@ -120,7 +132,7 @@ export const PermissionInfo : PermissionInfoType[] = [
120
132
  {index:PermissionIndex.repository_policy_description, name:'Policy Description', description:'Set Repository policy description', module: 'repository'},
121
133
  {index:PermissionIndex.repository_policy_permission, name:'Policy Permission', description:'Set Repository policy permission', module: 'repository'},
122
134
  {index:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: 'repository'},
123
-
135
+ /*
124
136
  {index:PermissionIndex.vote, name:'Vote', description:'Launch new Vote', module: 'vote'},
125
137
  {index:PermissionIndex.vote_description, name:'Description', description:'Set Vote description', module: 'vote'},
126
138
  {index:PermissionIndex.vote_reference, name:'Reference', description:'Set Vote reference', module: 'vote'},
@@ -131,7 +143,7 @@ export const PermissionInfo : PermissionInfoType[] = [
131
143
  {index:PermissionIndex.vote_lock_deadline, name:'Lock deadline', description:'Set Vote deadline immutable', module: 'vote'},
132
144
  {index:PermissionIndex.vote_expand_deadline, name:'Expand deadline', description:'Expand Vote deadline', module: 'vote'},
133
145
  {index:PermissionIndex.vote_lock_guard, name:'Lock Guard', description:'Set Vote guards immutable', module: 'vote'},
134
-
146
+ */
135
147
  {index:PermissionIndex.service, name:'Service', description:'Launch new Service', module: 'service'},
136
148
  {index:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: 'service'},
137
149
  {index:PermissionIndex.service_price, name:'Price', description:'Set Service item price', module: 'service'},
@@ -147,12 +159,13 @@ export const PermissionInfo : PermissionInfoType[] = [
147
159
  {index:PermissionIndex.service_buyer_guard, name:'Buyer Guard', description:'Set Guard of buying for Service', module: 'service'},
148
160
  {index:PermissionIndex.service_machine, name:'Machine', description:'Set Machine for Service', module: 'service'},
149
161
  {index:PermissionIndex.service_endpoint, name:'Endpoint', description:'Set Service endpoint', module: 'service'},
150
- {index:PermissionIndex.service_publish, name:'Publish', description:'Publish Service', module: 'service'},
162
+ {index:PermissionIndex.service_publish, name:'Publish', description:'Allowing the creation of Order', module: 'service'},
151
163
  {index:PermissionIndex.service_clone, name:'Clone', description:'Clone Service', module: 'service'},
152
164
  {index:PermissionIndex.service_customer_required, name:'Buyer info', description:'Set Service buyer info required', module: 'service'},
153
165
  //{index:PermissionIndex.service_change_order_required_pubkey, name:'Order pubkey', description:'Update Serivce order pubkey', module: 'service'},
154
166
  {index:PermissionIndex.service_pause, name:'Pause', description:'Pause/Unpause Service', module: 'service'},
155
-
167
+ {index:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: 'service'},
168
+ /*
156
169
  {index:PermissionIndex.reward, name:'reward', description:'Launch new reward', module: 'reward'},
157
170
  {index:PermissionIndex.reward_refund, name:'Refund', description:'Refund from reward', module: 'reward'},
158
171
  {index:PermissionIndex.reward_expand_time, name:'Expand deadline', description:'Expand reward deadline', module: 'reward'},
@@ -161,7 +174,7 @@ export const PermissionInfo : PermissionInfoType[] = [
161
174
  {index:PermissionIndex.reward_lock_guards, name:'Lock Guard', description:'Set reward guard immutable', module: 'reward'},
162
175
  {index:PermissionIndex.reward_claim_repeatably, name:'Claim repeatably', description:'Allow claimming repeatably', module: 'reward'},
163
176
  {index:PermissionIndex.reward_allow_claiming, name:'Allow claiming', description:'Allow claiming', module: 'reward'},
164
-
177
+ */
165
178
  {index:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: 'demand'},
166
179
  {index:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: 'demand'},
167
180
  {index:PermissionIndex.demand_expand_time, name:'Expand deadline', description:'Expand Demand deadline', module: 'demand'},
@@ -176,7 +189,7 @@ export const PermissionInfo : PermissionInfoType[] = [
176
189
  {index:PermissionIndex.machine_node, name: 'Node', description:'Set Machine nodes', module: 'machine'},
177
190
  {index:PermissionIndex.machine_endpoint, name: 'Endpoint', description:'Set Machine endpoint', module: 'machine'},
178
191
  {index:PermissionIndex.machine_pause, name: 'Pause', description:'Pause/Unpause Machine', module: 'machine'},
179
- {index:PermissionIndex.machine_publish, name: 'Publish', description:'Publish Machine', module: 'machine'},
192
+ {index:PermissionIndex.machine_publish, name: 'Publish', description:'Allowing the creation of Progress', module: 'machine'},
180
193
 
181
194
  {index:PermissionIndex.progress, name: 'Progress', description:'Launch new Progress', module: 'progress'},
182
195
  {index:PermissionIndex.progress_namedOperator, name: 'Operator', description:'Set Progress operators', module: 'progress'},
@@ -192,6 +205,18 @@ export const PermissionInfo : PermissionInfoType[] = [
192
205
  {index:PermissionIndex.treasury_withdraw_guard, name: 'Withdraw Guard', description:'Add/Remove Treasury withdraw guard', module: 'treasury'},
193
206
  {index:PermissionIndex.treasury_withdraw_mode, name: 'Withdraw mode', description:'Set Treasury withdraw mode', module: 'treasury'},
194
207
  {index:PermissionIndex.treasury_deposit_guard, name: 'Deposit Guard', description:'Set Treasury deposit guard', module: 'treasury'},
208
+ {index:PermissionIndex.treasury_descritption, name: 'Description', description:'Set Treasury description', module: 'treasury'},
209
+
210
+ {index:PermissionIndex.arbitration, name: 'Arbitration', description:'Launch new Arbitration', module: 'arbitration'},
211
+ {index:PermissionIndex.arbitration_description, name: 'Description', description:'Set Arbitration description', module: 'arbitration'},
212
+ {index:PermissionIndex.arbitration_endpoint, name: 'Endpoint', description:'Set Arbitration endpoint', module: 'arbitration'},
213
+ {index:PermissionIndex.arbitration_fee, name: 'Fee', description:'Set Arbitration fee', module: 'arbitration'},
214
+ {index:PermissionIndex.arbitration_guard, name: 'Guard', description:'Set Guard to apply for arbitration', module: 'arbitration'},
215
+ {index:PermissionIndex.arbitration_arbitration, name: 'Arbitrate', description:'Determine the outcome of arbitration', module: 'arbitration'},
216
+ {index:PermissionIndex.arbitration_pause, name: 'Pause', description:'Allowing/forbidding the creation of Arb', module: 'arbitration'},
217
+ {index:PermissionIndex.arbitration_voting_guard, name: 'Voting Guard', description:'Add/Remove voting Guard', module: 'arbitration'},
218
+ {index:PermissionIndex.arbitration_vote, name: 'Vote', description:'Vote on the application for arbitration', module: 'arbitration'},
219
+ {index:PermissionIndex.arbitration_withdraw, name: 'Withdraw', description:'Withdraw the arbitration fee', module: 'arbitration'},
195
220
  ]
196
221
 
197
222
  export type PermissionIndexType = PermissionIndex | number;
package/src/protocol.ts CHANGED
@@ -24,6 +24,8 @@ export enum MODULES {
24
24
  wowok = 'wowok',
25
25
  treasury = 'treasury',
26
26
  payment = 'payment',
27
+ arbitration = 'arbitration',
28
+ arb = 'arb',
27
29
  }
28
30
 
29
31
  export type PermissionAddress = TransactionResult;
@@ -39,28 +41,33 @@ export type DemandAddress = TransactionResult;
39
41
  export type DemandObject = TransactionResult | string | TransactionArgument;
40
42
  export type ServiceObject = TransactionResult | string | TransactionArgument;
41
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;
42
48
  export type ProgressObject = TransactionResult | string | TransactionArgument;
43
49
  export type ProgressAddress = TransactionResult;
44
- export type RewardObject = TransactionResult | string | TransactionArgument;
45
- export type RewardAddress = TransactionResult;
50
+ export type TreasuryObject = TransactionResult | string | TransactionArgument;
51
+ export type TreasuryAddress = TransactionResult;
52
+ //export type RewardObject = TransactionResult | string | TransactionArgument;
53
+ //export type RewardAddress = TransactionResult;
46
54
  export type OrderObject = TransactionResult | string | TransactionArgument;
47
55
  export type OrderAddress = TransactionResult;
48
56
  export type DiscountObject = TransactionResult | string | TransactionArgument;
49
57
  export type CoinObject = TransactionResult | string | TransactionArgument;
50
- export type VoteObject = TransactionResult | string | TransactionArgument;
51
- export type VoteAddress = TransactionResult;
58
+ //export type VoteObject = TransactionResult | string | TransactionArgument;
59
+ //export type VoteAddress = TransactionResult;
52
60
  export type ResourceObject = TransactionResult | string | TransactionArgument;
53
61
  export type ResourceAddress = TransactionResult;
54
62
  export type EntityObject = TransactionResult | string | TransactionArgument;
55
63
  export type EntityAddress = TransactionResult;
56
- export type TreasuryAddress = TransactionResult;
57
64
  export type PaymentObject = TransactionResult | string | TransactionArgument;
58
65
  export type PaymentAddress = TransactionResult;
59
66
  export type ReceivedObject = TransactionResult | string | TransactionArgument;
60
67
  export type CoinWrapperObject = TransactionResult;
61
68
 
62
69
  export type TxbObject = string | TransactionResult | TransactionArgument | GuardObject | RepositoryObject | PermissionObject | MachineObject | PassportObject |
63
- DemandObject | ServiceObject | RewardObject | OrderObject | DiscountObject | VoteObject | DemandObject | ResourceObject | EntityObject;
70
+ DemandObject | ServiceObject | OrderObject | DiscountObject | DemandObject | ResourceObject | EntityObject | ArbitrationObject | ArbObject | TreasuryObject;
64
71
 
65
72
  export type WowokObject = TransactionResult;
66
73
  export type FnCallType = `${string}::${string}::${string}`;
@@ -213,16 +220,21 @@ const TESTNET = {
213
220
  }
214
221
  */
215
222
  const TESTNET = {
216
- wowok: "0x93a47e2e77b150258877b31a49d6e2dbda58c7840f14a99aeb658bddb3d0d021",
217
- wowok_origin:'0x93a47e2e77b150258877b31a49d6e2dbda58c7840f14a99aeb658bddb3d0d021' ,
223
+ wowok: "0x10a543f1d692c9813d3dfebea75d9ead46a1927c4fbb2d6e646f1aaa3b9ee6bb",
224
+ wowok_origin:'0x10a543f1d692c9813d3dfebea75d9ead46a1927c4fbb2d6e646f1aaa3b9ee6bb' ,
218
225
  base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
219
- wowok_object: '0xdc4f31084f0f0ceb8c59feb78a361091fa84d54d562e28302f2b02b1d22e2905',
220
- entity_object: '0xbf547b1185c458a2498baf7235ce9824740e4c2fce27440354f342f9ccc79de0',
226
+ base_origin: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
227
+
228
+ wowok_object: '0x08c8a98236e0f1dd233722391a8178336ea5615498fe2b459daa11e8d4a01367',
229
+ entity_object: '0x5fc1554d71c5f2fe3a3101200dd19a0e51869ddd6379fd7e8f8ef72339cfd021',
221
230
  treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
222
231
  }
223
232
  const MAINNET = {
224
233
  wowok: "",
234
+ wowok_origin:"",
225
235
  base:"",
236
+ base_origin:"",
237
+
226
238
  wowok_object: '',
227
239
  entity_object: '',
228
240
  treasury_cap:'',
@@ -270,6 +282,7 @@ export class Protocol {
270
282
  this.package.set('wowok', TESTNET.wowok);
271
283
  this.package.set('base', TESTNET.base);
272
284
  this.package.set('wowok_origin', TESTNET.wowok_origin); //@ orgin package!!!
285
+ this.package.set('base_origin', TESTNET.base_origin);
273
286
  this.wowok_object = TESTNET.wowok_object;
274
287
  this.entity_object= TESTNET.entity_object;
275
288
  this.treasury_cap = TESTNET.treasury_cap;
@@ -278,6 +291,8 @@ export class Protocol {
278
291
  case ENTRYPOINT.mainnet:
279
292
  this.package.set('wowok', MAINNET.wowok);
280
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);
281
296
  this.wowok_object = MAINNET.wowok_object;
282
297
  this.entity_object= MAINNET.entity_object;
283
298
  this.treasury_cap = MAINNET.treasury_cap;
@@ -324,7 +339,9 @@ export class Protocol {
324
339
  PaymentFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.payment}::${fn}`};
325
340
  GuardFn = (fn: any) => { return `${this.package.get('base')}::${MODULES.guard}::${fn}`};
326
341
  MintFn = (fn: any) => { return `${this.package.get('base')}::${MODULES.wowok}::${fn}`};
327
-
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
+
328
345
  Query = async (objects: Query_Param[], options:SuiObjectDataOptions={showContent:true}) : Promise<SuiObjectResponse[]> => {
329
346
  const client = new SuiClient({ url: this.NetworkUrl() });
330
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} from './protocol';
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, endpoint?:string, passport?:PassportObject) : Service {
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), ep, Protocol.TXB_OBJECT(txb, permission)],
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), ep, Protocol.TXB_OBJECT(txb, permission)],
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
  }