wowok 1.2.4 → 1.2.7

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 (49) hide show
  1. package/dist/demand.d.ts +3 -2
  2. package/dist/demand.d.ts.map +1 -1
  3. package/dist/demand.js +21 -7
  4. package/dist/entity.d.ts +2 -1
  5. package/dist/entity.d.ts.map +1 -1
  6. package/dist/entity.js +23 -7
  7. package/dist/exception.d.ts +3 -1
  8. package/dist/exception.d.ts.map +1 -1
  9. package/dist/exception.js +3 -1
  10. package/dist/guard.js +1 -1
  11. package/dist/machine.js +2 -2
  12. package/dist/permission.d.ts +23 -7
  13. package/dist/permission.d.ts.map +1 -1
  14. package/dist/permission.js +149 -16
  15. package/dist/protocol.d.ts +35 -10
  16. package/dist/protocol.d.ts.map +1 -1
  17. package/dist/protocol.js +129 -21
  18. package/dist/repository.d.ts +6 -3
  19. package/dist/repository.d.ts.map +1 -1
  20. package/dist/repository.js +59 -40
  21. package/dist/resource.d.ts +20 -6
  22. package/dist/resource.d.ts.map +1 -1
  23. package/dist/resource.js +58 -21
  24. package/dist/reward.d.ts +6 -3
  25. package/dist/reward.d.ts.map +1 -1
  26. package/dist/reward.js +43 -19
  27. package/dist/service.d.ts +15 -9
  28. package/dist/service.d.ts.map +1 -1
  29. package/dist/service.js +94 -56
  30. package/dist/utils.d.ts +18 -4
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +218 -45
  33. package/dist/vote.d.ts +2 -2
  34. package/dist/vote.d.ts.map +1 -1
  35. package/dist/vote.js +14 -14
  36. package/package.json +1 -1
  37. package/src/demand.ts +22 -8
  38. package/src/entity.ts +25 -6
  39. package/src/exception.ts +3 -1
  40. package/src/guard.ts +1 -1
  41. package/src/machine.ts +2 -2
  42. package/src/permission.ts +168 -14
  43. package/src/protocol.ts +127 -17
  44. package/src/repository.ts +64 -44
  45. package/src/resource.ts +61 -20
  46. package/src/reward.ts +46 -23
  47. package/src/service.ts +100 -57
  48. package/src/utils.ts +186 -22
  49. package/src/vote.ts +14 -14
package/src/repository.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BCS } from '@mysten/bcs';
2
- import { Protocol, FnCallType, ValueType, RepositoryObject, RepositoryAddress, PermissionObject, PassportObject, TxbObject} from './protocol';
2
+ import { Protocol, FnCallType, ValueType, RepositoryValueType, RepositoryAddress, PermissionObject, PassportObject, TxbObject} from './protocol';
3
3
  import { PermissionIndexType, Permission } from './permission'
4
- import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, OptionNone, } from './utils';
4
+ import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, OptionNone, IsValidName, } from './utils';
5
5
  import { ERROR, Errors } from './exception';
6
6
  import { Resource } from './resource';
7
7
 
@@ -9,10 +9,12 @@ export enum Repository_Policy_Mode {
9
9
  POLICY_MODE_FREE = 0,
10
10
  POLICY_MODE_STRICT = 1,
11
11
  }
12
+
13
+
12
14
  export type Repository_Policy = {
13
15
  key:string;
14
16
  description: string;
15
- value_type: ValueType;
17
+ data_type: RepositoryValueType;
16
18
  permission?: PermissionIndexType; // PermissionIndex like, must be geater than 10000
17
19
  }
18
20
  export type Repository_Policy_Data = {
@@ -142,13 +144,13 @@ export class Repository {
142
144
  }
143
145
  add_reference(references:string[], passport?:PassportObject) {
144
146
  if (!references) {
145
- ERROR(Errors.InvalidParam, 'references')
147
+ ERROR(Errors.InvalidParam, 'add_reference')
146
148
  }
147
149
 
148
150
  if (!IsValidArray(references, IsValidAddress)) {
149
- ERROR(Errors.IsValidArray, 'references')
151
+ ERROR(Errors.IsValidArray, 'add_reference')
150
152
  }
151
-
153
+ console.log(array_unique(references))
152
154
  let txb = this.protocol.CurrentSession();
153
155
  if (passport) {
154
156
  txb.moveCall({
@@ -167,12 +169,12 @@ export class Repository {
167
169
  }
168
170
  }
169
171
  remove_reference(references:string[], removeall?:boolean, passport?:PassportObject) {
170
- if (!references) {
171
- ERROR(Errors.InvalidParam, 'references')
172
+ if (!references && !removeall) {
173
+ ERROR(Errors.InvalidParam, 'remove_reference')
172
174
  }
173
175
 
174
- if (!IsValidArray(references, IsValidAddress)) {
175
- ERROR(Errors.IsValidArray, 'references')
176
+ if (references && !IsValidArray(references, IsValidAddress)) {
177
+ ERROR(Errors.IsValidArray, 'remove_reference')
176
178
  }
177
179
 
178
180
  let txb = this.protocol.CurrentSession();
@@ -233,7 +235,7 @@ export class Repository {
233
235
  arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
234
236
  txb.pure(policy.key),
235
237
  txb.pure(policy.description),
236
- permission_index, txb.pure(policy.value_type, BCS.U8),
238
+ permission_index, txb.pure(policy.data_type, BCS.U8),
237
239
  Protocol.TXB_OBJECT(txb, this.permission)]
238
240
  })
239
241
  } else {
@@ -242,15 +244,15 @@ export class Repository {
242
244
  arguments:[Protocol.TXB_OBJECT(txb, this.object),
243
245
  txb.pure(policy.key),
244
246
  txb.pure(policy.description),
245
- permission_index, txb.pure(policy.value_type, BCS.U8),
247
+ permission_index, txb.pure(policy.data_type, BCS.U8),
246
248
  Protocol.TXB_OBJECT(txb, this.permission)]
247
249
  })
248
250
  }
249
251
  });
250
252
  }
251
253
 
252
- remove_policies(policy_keys:string[], removeall?:boolean, passport?:PassportObject) {
253
- if (!removeall && !policy_keys) {
254
+ remove_policies(policy_keys:string[], passport?:PassportObject) {
255
+ if (!policy_keys) {
254
256
  ERROR(Errors.AllInvalid, 'policy_keys & removeall')
255
257
  }
256
258
  if (policy_keys && !IsValidArray(policy_keys, Repository.IsValidName)){
@@ -259,36 +261,44 @@ export class Repository {
259
261
 
260
262
  let txb = this.protocol.CurrentSession();
261
263
  if (passport) {
262
- if (removeall) {
263
- txb.moveCall({
264
- target:this.protocol.RepositoryFn('policy_remove_all_with_passport') as FnCallType,
265
- arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)]
266
- })
267
- } else {
268
- txb.moveCall({
269
- target:this.protocol.RepositoryFn('policy_remove_with_passport') as FnCallType,
270
- arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
271
- txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
272
- Protocol.TXB_OBJECT(txb, this.permission)]
273
- })
274
- }
264
+ txb.moveCall({
265
+ target:this.protocol.RepositoryFn('policy_remove_with_passport') as FnCallType,
266
+ arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
267
+ txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
268
+ Protocol.TXB_OBJECT(txb, this.permission)]
269
+ })
275
270
  } else {
276
- if (removeall) {
277
- txb.moveCall({
278
- target:this.protocol.RepositoryFn('policy_remove_all') as FnCallType,
279
- arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)]
280
- })
281
- } else {
282
- txb.moveCall({
283
- target:this.protocol.RepositoryFn('policy_remove') as FnCallType,
284
- arguments:[Protocol.TXB_OBJECT(txb, this.object),
285
- txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
286
- Protocol.TXB_OBJECT(txb, this.permission)]
287
- })
288
- }
271
+ txb.moveCall({
272
+ target:this.protocol.RepositoryFn('policy_remove') as FnCallType,
273
+ arguments:[Protocol.TXB_OBJECT(txb, this.object),
274
+ txb.pure(Bcs.getInstance().ser(ValueType.TYPE_VEC_STRING, array_unique(policy_keys))),
275
+ Protocol.TXB_OBJECT(txb, this.permission)]
276
+ })
289
277
  }
290
-
291
278
  }
279
+ rename_policy(policy_key:string, new_policy_key:string, passport?:PassportObject) {
280
+ if (!IsValidName(policy_key) || !IsValidName(new_policy_key)) {
281
+ ERROR(Errors.IsValidName, 'change_policy')
282
+ }
283
+
284
+ let txb = this.protocol.CurrentSession();
285
+ if (passport) {
286
+ txb.moveCall({
287
+ target:this.protocol.RepositoryFn('policy_rename_with_passport') as FnCallType,
288
+ arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
289
+ txb.pure(policy_key, BCS.STRING), txb.pure(new_policy_key, BCS.STRING),
290
+ Protocol.TXB_OBJECT(txb, this.permission)]
291
+ })
292
+ } else {
293
+ txb.moveCall({
294
+ target:this.protocol.RepositoryFn('policy_rename') as FnCallType,
295
+ arguments:[Protocol.TXB_OBJECT(txb, this.object),
296
+ txb.pure(policy_key, BCS.STRING), txb.pure(new_policy_key, BCS.STRING),
297
+ Protocol.TXB_OBJECT(txb, this.permission)]
298
+ })
299
+ }
300
+ }
301
+
292
302
  // PermissionIndex.description_set
293
303
  set_description(description:string, passport?:PassportObject) {
294
304
  if (!IsValidDesription(description)){
@@ -347,7 +357,6 @@ export class Repository {
347
357
  Protocol.TXB_OBJECT(txb, this.permission)]
348
358
  })
349
359
  }
350
-
351
360
  }
352
361
 
353
362
  set_policy_permission(policy:string, permission_index?:number, passport?:PassportObject) {
@@ -376,7 +385,6 @@ export class Repository {
376
385
  arguments:[Protocol.TXB_OBJECT(txb, this.object), index, Protocol.TXB_OBJECT(txb, this.permission)]
377
386
  })
378
387
  }
379
-
380
388
  }
381
389
 
382
390
  change_permission(new_permission:PermissionObject) {
@@ -392,14 +400,26 @@ export class Repository {
392
400
  this.permission = new_permission
393
401
  }
394
402
 
395
- static MAX_POLICY_COUNT = 1000;
403
+ static MAX_POLICY_COUNT = 200;
396
404
  static MAX_KEY_LENGTH = 128;
397
405
  static MAX_VALUE_LENGTH = 204800;
406
+ static MAX_REFERENCE_COUNT = 100;
398
407
  static IsValidName = (key:string) => {
399
408
  return key.length <= Repository.MAX_KEY_LENGTH && key.length != 0;
400
409
  }
401
410
  static IsValidValue = (value:Uint8Array) => {
402
411
  return value.length < Repository.MAX_VALUE_LENGTH;
403
412
  }
413
+ static parseObjectType = (chain_type:string) : string => {
414
+ if (chain_type) {
415
+ const s = 'repository::Repository<'
416
+ const i = chain_type.indexOf(s);
417
+ if (i > 0) {
418
+ let r = chain_type.slice(i + s.length, chain_type.length-1);
419
+ return r
420
+ }
421
+ }
422
+ return '';
423
+ }
404
424
  }
405
425
 
package/src/resource.ts CHANGED
@@ -1,14 +1,25 @@
1
1
  import { BCS } from '@mysten/bcs';
2
2
  import { Protocol, FnCallType, TxbObject, ResourceAddress} from './protocol';
3
- import { IsValidDesription, IsValidAddress, IsValidName, } from './utils';
3
+ import { IsValidDesription, IsValidAddress, IsValidName, IsValidArray, } from './utils';
4
4
  import { ERROR, Errors } from './exception';
5
+ export interface Tags {
6
+ address: string;
7
+ nick: string;
8
+ tags: string[];
9
+ }
5
10
 
11
+ export interface ResourceData {
12
+ name: string;
13
+ address: string[];
14
+ }
6
15
 
7
16
  export class Resource {
8
- static MAX_WORDS_LEN = 102400;
9
- static IsValidWords(words:string) : boolean {
10
- return words.length <= Resource.MAX_WORDS_LEN
11
- }
17
+ static MAX_ADDRESS_COUNT = 600;
18
+ static MAX_TAGS = 8;
19
+
20
+ static LikeName = "like";
21
+ static DislikeName = "dislike";
22
+ static FavorName = "favor";
12
23
 
13
24
  protected object:TxbObject;
14
25
  protected protocol;
@@ -25,18 +36,31 @@ export class Resource {
25
36
  return r
26
37
  }
27
38
 
28
- add(name:string, object:string) {
29
- if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: add');
30
- if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: add');
39
+ add(name:string, object:string[]) {
40
+ if (!IsValidName(name)) ERROR(Errors.IsValidName, 'add');
41
+ if (!object) ERROR(Errors.InvalidParam, 'add')
42
+ if (!IsValidArray(object, IsValidAddress)) ERROR(Errors.IsValidArray, 'add');
31
43
 
32
44
  let txb = this.protocol.CurrentSession();
33
45
  txb.moveCall({
34
46
  target:this.protocol.ResourceFn('add') as FnCallType,
35
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING), txb.pure(object, BCS.ADDRESS)]
47
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING), txb.pure(object, 'vector<address>')]
48
+ });
49
+ }
50
+
51
+ add2(object:string, name:string[]) {
52
+ if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'add2');
53
+ if (!IsValidArray(name, IsValidName)) ERROR(Errors.IsValidArray, 'add2');
54
+ if (!name) return
55
+
56
+ let txb = this.protocol.CurrentSession();
57
+ txb.moveCall({
58
+ target:this.protocol.ResourceFn('add2') as FnCallType,
59
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(object, BCS.ADDRESS), txb.pure(name, 'vector<string>')]
36
60
  });
37
61
  }
38
62
 
39
- remove(name:string, object?:string, removeall?:boolean) {
63
+ remove(name:string, object?:string[], removeall?:boolean) {
40
64
  if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: remove');
41
65
  if (!object && !removeall) ERROR(Errors.InvalidParam, 'Resource: remove, BOTH param undefined');
42
66
 
@@ -47,15 +71,27 @@ export class Resource {
47
71
  arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING)]
48
72
  });
49
73
  } else if(object) {
50
- if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove');
74
+ if (!IsValidArray(object, IsValidAddress)) ERROR(Errors.IsValidArray, 'Resource: remove');
51
75
 
52
76
  txb.moveCall({
53
77
  target:this.protocol.ResourceFn('remove') as FnCallType,
54
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING), txb.pure(object, BCS.ADDRESS)]
78
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING), txb.pure(object, 'vector<address>')]
55
79
  });
56
80
  }
57
81
  }
58
82
 
83
+ remove2(object:string, name:string[]) {
84
+ if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove2');
85
+ if (!IsValidArray(name, IsValidName)) ERROR(Errors.InvalidParam, 'Resource: remove2');
86
+ if (!name) return
87
+
88
+ let txb = this.protocol.CurrentSession();
89
+ txb.moveCall({
90
+ target:this.protocol.ResourceFn('remove2') as FnCallType,
91
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(object, BCS.ADDRESS), txb.pure(name, 'vector<string>')]
92
+ });
93
+ }
94
+
59
95
  rename(old_name:string, new_name:string) {
60
96
  if (!IsValidName(new_name)) ERROR(Errors.IsValidName, 'Resource: rename');
61
97
 
@@ -66,23 +102,28 @@ export class Resource {
66
102
  });
67
103
  }
68
104
 
69
- add_words(object:string, words:string) {
70
- if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: add_words');
71
- if (!Resource.IsValidWords(words)) ERROR(Errors.Fail, 'Resource: add_words');
105
+ add_tags(object:string, nick:string, tags:string[]) {
106
+ if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'add_tags');
107
+ if (!nick || !tags) return;
108
+ if (!IsValidName(nick)) ERROR(Errors.IsValidName, 'add_tags');
109
+ if (!IsValidArray(tags, IsValidName)) ERROR(Errors.IsValidArray, 'add_tags');
110
+ if (tags.length > Resource.MAX_TAGS) ERROR(Errors.InvalidParam, 'add_tags');
72
111
 
73
112
  let txb = this.protocol.CurrentSession();
74
113
  txb.moveCall({
75
- target:this.protocol.ResourceFn('words_add') as FnCallType,
76
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(object, BCS.ADDRESS), txb.pure(words, BCS.STRING)]
114
+ target:this.protocol.ResourceFn('tags_add') as FnCallType,
115
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(object, BCS.ADDRESS), txb.pure(nick, BCS.STRING),
116
+ txb.pure(tags, 'vector<string>')
117
+ ]
77
118
  });
78
119
  }
79
120
 
80
- remove_words(object:string) {
81
- if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove_words');
121
+ remove_tags(object:string) {
122
+ if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove_tags');
82
123
 
83
124
  let txb = this.protocol.CurrentSession();
84
125
  txb.moveCall({
85
- target:this.protocol.ResourceFn('words_remove') as FnCallType,
126
+ target:this.protocol.ResourceFn('tags_remove') as FnCallType,
86
127
  arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(object, BCS.ADDRESS)]
87
128
  });
88
129
  }
package/src/reward.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TransactionBlock, type TransactionResult } from '@mysten/sui.js/transactions';
1
+ import { TransactionArgument, TransactionBlock, type TransactionResult } from '@mysten/sui.js/transactions';
2
2
  import { BCS} from '@mysten/bcs';
3
3
  import { FnCallType, GuardObject, PassportObject, PermissionObject, RewardAddress, Protocol, TxbObject, } from './protocol';
4
4
  import { array_unique, IsValidAddress, IsValidArgType, IsValidArray, IsValidDesription, IsValidUint, } from './utils';
@@ -31,7 +31,7 @@ export class Reward {
31
31
  return r
32
32
  }
33
33
  static New(protocol:Protocol, earnest_type:string, permission:PermissionObject, description:string,
34
- minutes_duration:number, passport?:PassportObject) : Reward {
34
+ ms_expand:boolean, time:number, passport?:PassportObject) : Reward {
35
35
  if (!Protocol.IsValidObjects([permission])) {
36
36
  ERROR(Errors.IsValidObjects, 'permission')
37
37
  }
@@ -41,8 +41,8 @@ export class Reward {
41
41
  if (!IsValidDesription(description)) {
42
42
  ERROR(Errors.IsValidDesription)
43
43
  }
44
- if (!IsValidUint(minutes_duration)) {
45
- ERROR(Errors.IsValidUint, 'minutes_duration')
44
+ if (!IsValidUint(time)) {
45
+ ERROR(Errors.IsValidUint, 'time')
46
46
  }
47
47
 
48
48
  let r = new Reward(protocol, earnest_type, permission);
@@ -51,14 +51,14 @@ export class Reward {
51
51
  if (passport) {
52
52
  r.object = txb.moveCall({
53
53
  target:protocol.RewardFn('new_with_passport') as FnCallType,
54
- arguments:[passport, txb.pure(description), txb.pure(minutes_duration, BCS.U64),
55
- txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, permission)],
54
+ arguments:[passport, txb.pure(description), txb.pure(ms_expand, BCS.BOOL), txb.pure(time, BCS.U64),
55
+ txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, permission)],
56
56
  typeArguments:[earnest_type]
57
57
  })
58
58
  } else {
59
59
  r.object = txb.moveCall({
60
60
  target:protocol.RewardFn('new') as FnCallType,
61
- arguments:[txb.pure(description), txb.pure(minutes_duration, BCS.U64),
61
+ arguments:[txb.pure(description), txb.pure(ms_expand, BCS.BOOL), txb.pure(time, BCS.U64),
62
62
  txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, permission)],
63
63
  typeArguments:[earnest_type]
64
64
  })
@@ -82,15 +82,7 @@ export class Reward {
82
82
  arguments: [Protocol.TXB_OBJECT(txb, this.object)],
83
83
  })
84
84
  }
85
- /*
86
- mark(like:'like' | 'unlike', resource:Resource) {
87
- let txb = this.protocol.CurrentSession();
88
- txb.moveCall({
89
- target:this.protocol.RewardFn(like) as FnCallType,
90
- arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
91
- })
92
- }
93
- */
85
+
94
86
  refund(passport?:PassportObject) {
95
87
  let txb = this.protocol.CurrentSession();
96
88
  if (passport) {
@@ -108,8 +100,8 @@ export class Reward {
108
100
  }
109
101
  }
110
102
 
111
- expand_time(minutes_expand:number, passport?:PassportObject) {
112
- if (!IsValidUint(minutes_expand)) {
103
+ expand_time(ms_expand:boolean, time:number, passport?:PassportObject) {
104
+ if (!IsValidUint(time)) {
113
105
  ERROR(Errors.IsValidUint, 'minutes_expand')
114
106
  }
115
107
 
@@ -117,13 +109,15 @@ export class Reward {
117
109
  if (passport) {
118
110
  txb.moveCall({
119
111
  target:this.protocol.RewardFn('time_expand_with_passport') as FnCallType,
120
- arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_expand, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)],
112
+ arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(ms_expand, BCS.BOOL),
113
+ txb.pure(time, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)],
121
114
  typeArguments:[this.earnest_type]
122
115
  })
123
116
  } else {
124
117
  txb.moveCall({
125
118
  target:this.protocol.RewardFn('time_expand') as FnCallType,
126
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_expand, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)],
119
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(ms_expand, BCS.BOOL),
120
+ txb.pure(time, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)],
127
121
  typeArguments:[this.earnest_type]
128
122
  })
129
123
  }
@@ -284,7 +278,8 @@ export class Reward {
284
278
  }
285
279
  ;
286
280
  }
287
- deposit(rewards:CoinReward[]) {
281
+ deposit(rewards:TransactionResult[]) {
282
+ console.log(rewards)
288
283
  if (!rewards || !Protocol.IsValidObjects(rewards)) {
289
284
  ERROR(Errors.IsValidArray)
290
285
  }
@@ -296,6 +291,23 @@ export class Reward {
296
291
  typeArguments:[this.earnest_type]
297
292
  })
298
293
  }
294
+ allow_claim(bAllowClaim: boolean, passport?:PassportObject) {
295
+ let txb = this.protocol.CurrentSession();
296
+ if (passport) {
297
+ txb.moveCall({
298
+ target:this.protocol.RewardFn('allow_claim_with_passport') as FnCallType,
299
+ arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission),
300
+ txb.pure(bAllowClaim, BCS.BOOL)],
301
+ typeArguments:[this.earnest_type]
302
+ })
303
+ } else {
304
+ txb.moveCall({
305
+ target:this.protocol.RewardFn('allow_claim') as FnCallType,
306
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), txb.pure(bAllowClaim, BCS.BOOL)],
307
+ typeArguments:[this.earnest_type]
308
+ })
309
+ }
310
+ }
299
311
 
300
312
  change_permission(new_permission:PermissionObject) {
301
313
  if (!Protocol.IsValidObjects([new_permission])) {
@@ -304,12 +316,23 @@ export class Reward {
304
316
 
305
317
  let txb = this.protocol.CurrentSession();
306
318
  txb.moveCall({
307
- target:this.protocol.RewardFn('this.permission_set') as FnCallType,
319
+ target:this.protocol.RewardFn('permission_set') as FnCallType,
308
320
  arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), Protocol.TXB_OBJECT(txb, new_permission)],
309
321
  typeArguments:[this.earnest_type]
310
322
  })
311
323
  this.permission = new_permission
312
324
  }
313
-
325
+ static parseObjectType = (chain_type:string) : string => {
326
+ if (chain_type) {
327
+ const s = 'reward::Reward<'
328
+ const i = chain_type.indexOf(s);
329
+ if (i > 0) {
330
+ let r = chain_type.slice(i + s.length, chain_type.length-1);
331
+ return r
332
+ }
333
+ }
334
+ return '';
335
+ }
314
336
  static MAX_PORTIONS_COUNT = 255;
337
+ static MAX_GUARD_COUNT = 16;
315
338
  }