wowok 1.2.5 → 1.2.8

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 (51) 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 +20 -4
  13. package/dist/permission.d.ts.map +1 -1
  14. package/dist/permission.js +146 -13
  15. package/dist/protocol.d.ts +30 -6
  16. package/dist/protocol.d.ts.map +1 -1
  17. package/dist/protocol.js +124 -17
  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 +6 -3
  28. package/dist/service.d.ts.map +1 -1
  29. package/dist/service.js +76 -44
  30. package/dist/utils.d.ts +15 -1
  31. package/dist/utils.d.ts.map +1 -1
  32. package/dist/utils.js +150 -13
  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 +26 -12
  38. package/src/entity.ts +33 -6
  39. package/src/exception.ts +3 -1
  40. package/src/guard.ts +2 -2
  41. package/src/machine.ts +207 -55
  42. package/src/permission.ts +168 -41
  43. package/src/progress.ts +101 -43
  44. package/src/protocol.ts +129 -20
  45. package/src/repository.ts +160 -53
  46. package/src/resource.ts +75 -24
  47. package/src/reward.ts +53 -32
  48. package/src/service.ts +109 -74
  49. package/src/utils.ts +174 -22
  50. package/src/vote.ts +30 -33
  51. package/src/wowok.ts +2 -2
package/src/vote.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BCS } from '@mysten/bcs';
2
2
  import { FnCallType, PassportObject, PermissionObject, GuardObject, VoteAddress, Protocol, TxbObject} from './protocol';
3
- import { IsValidDesription, IsValidUint, IsValidAddress, OptionNone, Bcs, array_unique, IsValidArray, IsValidName } from './utils';
3
+ import { IsValidDesription, IsValidUintLarge, IsValidAddress, OptionNone, Bcs, array_unique, IsValidArray, IsValidName } from './utils';
4
4
  import { ERROR, Errors } from './exception';
5
5
  import { ValueType } from './protocol';
6
6
 
@@ -28,7 +28,7 @@ export class Vote {
28
28
  v.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object)
29
29
  return v
30
30
  }
31
- static New(protocol:Protocol, permission:PermissionObject, description:string, minutes_duration:number,
31
+ static New(protocol:Protocol, permission:PermissionObject, description:string, minutes_duration:boolean, time:number,
32
32
  max_choice_count?:number, reference_address?:string, passport?:PassportObject) : Vote {
33
33
  if (!Protocol.IsValidObjects([permission])) {
34
34
  ERROR(Errors.IsValidObjects, 'permission')
@@ -36,10 +36,10 @@ export class Vote {
36
36
  if (!IsValidDesription(description)) {
37
37
  ERROR(Errors.IsValidDesription)
38
38
  }
39
- if (!IsValidUint(minutes_duration)) {
40
- ERROR(Errors.IsValidUint, 'minutes_duration')
39
+ if (!IsValidUintLarge(time)) {
40
+ ERROR(Errors.IsValidUint, 'time')
41
41
  }
42
- if (max_choice_count && !IsValidUint(max_choice_count)) {
42
+ if (max_choice_count && !IsValidUintLarge(max_choice_count)) {
43
43
  ERROR(Errors.IsValidUint, 'max_choice_count')
44
44
  }
45
45
  if (max_choice_count && max_choice_count > MAX_CHOICE_COUNT) {
@@ -57,14 +57,14 @@ export class Vote {
57
57
  if (passport) {
58
58
  v.object = txb.moveCall({
59
59
  target:protocol.VoteFn('new_with_passport') as FnCallType,
60
- arguments:[passport, txb.pure(description), reference, txb.pure(Protocol.CLOCK_OBJECT),
61
- txb.pure(minutes_duration, BCS.U64), txb.pure(choice_count, BCS.U8), Protocol.TXB_OBJECT(txb, permission)]
60
+ arguments:[passport, txb.pure(description), reference, txb.pure(Protocol.CLOCK_OBJECT), txb.pure(minutes_duration, BCS.BOOL),
61
+ txb.pure(time, BCS.U64), txb.pure(choice_count, BCS.U8), Protocol.TXB_OBJECT(txb, permission)]
62
62
  })
63
63
  } else {
64
64
  v.object = txb.moveCall({
65
65
  target:protocol.VoteFn('new') as FnCallType,
66
- arguments:[txb.pure(description), reference, txb.pure(Protocol.CLOCK_OBJECT),
67
- txb.pure(minutes_duration, BCS.U64), txb.pure(choice_count, BCS.U8), Protocol.TXB_OBJECT(txb, permission)]
66
+ arguments:[txb.pure(description), reference, txb.pure(Protocol.CLOCK_OBJECT), txb.pure(minutes_duration, BCS.BOOL),
67
+ txb.pure(time, BCS.U64), txb.pure(choice_count, BCS.U8), Protocol.TXB_OBJECT(txb, permission)]
68
68
  })
69
69
  }
70
70
  return v
@@ -128,10 +128,10 @@ export class Vote {
128
128
  }
129
129
  add_guard(guard:GuardObject, weight:number, passport?:PassportObject) {
130
130
  if (!Protocol.IsValidObjects([guard])) {
131
- ERROR(Errors.IsValidObjects, 'guard')
131
+ ERROR(Errors.IsValidObjects, 'add_guard')
132
132
  }
133
- if (!IsValidUint(weight)) {
134
- ERROR(Errors.IsValidUint, 'weight')
133
+ if (!IsValidUintLarge(weight)) {
134
+ ERROR(Errors.IsValidUint, 'add_guard')
135
135
  }
136
136
 
137
137
  let txb = this.protocol.CurrentSession();
@@ -151,12 +151,10 @@ export class Vote {
151
151
  }
152
152
 
153
153
  remove_guard(guard_address:string[], removeall?:boolean, passport?:PassportObject) {
154
- if (!removeall && !guard_address) {
155
- ERROR(Errors.AllInvalid, 'guard_address & removeall')
156
- }
154
+ if (!removeall && guard_address.length===0) return;
157
155
 
158
- if (guard_address && !IsValidArray(guard_address, IsValidAddress)) {
159
- ERROR(Errors.IsValidArray, 'guard_address')
156
+ if (!IsValidArray(guard_address, IsValidAddress)) {
157
+ ERROR(Errors.IsValidArray, 'remove_guard')
160
158
  }
161
159
 
162
160
  let txb = this.protocol.CurrentSession();
@@ -191,9 +189,7 @@ export class Vote {
191
189
  }
192
190
 
193
191
  add_option(options:VoteOption[], passport?:PassportObject) {
194
- if (!options) {
195
- ERROR(Errors.InvalidParam, 'options')
196
- }
192
+ if (options.length === 0) return ;
197
193
 
198
194
  let bValid = true;
199
195
  options.forEach((v) => {
@@ -226,11 +222,11 @@ export class Vote {
226
222
  })
227
223
  }
228
224
  remove_option(options:string[], removeall?:boolean, passport?:PassportObject) {
229
- if (!removeall && !options) {
230
- ERROR(Errors.AllInvalid, 'options & removeall')
225
+ if (!removeall && options.length===0) {
226
+ return
231
227
  }
232
228
  if (options && !IsValidArray(options, IsValidAddress)) {
233
- ERROR(Errors.IsValidArray, 'options')
229
+ ERROR(Errors.IsValidArray, 'remove_option')
234
230
  }
235
231
 
236
232
  let txb = this.protocol.CurrentSession();
@@ -265,7 +261,7 @@ export class Vote {
265
261
  }
266
262
  }
267
263
  set_max_choice_count(max_choice_count:number, passport?:PassportObject) {
268
- if (!IsValidUint(max_choice_count) || max_choice_count > MAX_CHOICE_COUNT) {
264
+ if (!IsValidUintLarge(max_choice_count) || max_choice_count > MAX_CHOICE_COUNT) {
269
265
  ERROR(Errors.InvalidParam, 'max_choice_count')
270
266
  }
271
267
 
@@ -314,23 +310,23 @@ export class Vote {
314
310
  }
315
311
  }
316
312
 
317
- expand_deadline(minutes_expand:number, passport?:PassportObject) {
318
- if (!IsValidUint(minutes_expand)) {
319
- ERROR(Errors.IsValidUint, 'minutes_expand')
313
+ expand_deadline(ms_expand:boolean, time:number, passport?:PassportObject) {
314
+ if (!IsValidUintLarge(time)) {
315
+ ERROR(Errors.IsValidUint, 'time')
320
316
  }
321
317
 
322
318
  let txb = this.protocol.CurrentSession();
323
319
  if (passport) {
324
320
  txb.moveCall({
325
321
  target:this.protocol.VoteFn('deadline_expand_with_passport') as FnCallType,
326
- arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
327
- txb.pure(minutes_expand, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)]
322
+ arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(ms_expand, BCS.BOOL),
323
+ txb.pure(time, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)]
328
324
  })
329
325
  } else {
330
326
  txb.moveCall({
331
327
  target:this.protocol.VoteFn('deadline_expand') as FnCallType,
332
- arguments:[Protocol.TXB_OBJECT(txb, this.object),
333
- txb.pure(minutes_expand, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)]
328
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(ms_expand, BCS.BOOL),
329
+ txb.pure(time, BCS.U64), Protocol.TXB_OBJECT(txb, this.permission)]
334
330
  })
335
331
  }
336
332
 
@@ -351,8 +347,9 @@ export class Vote {
351
347
  }
352
348
 
353
349
  agree(options:string[], passport?:PassportObject) {
354
- if (!options || options.length > MAX_CHOICE_COUNT) {
355
- ERROR(Errors.InvalidParam, 'options')
350
+ if (options.length === 0) return;
351
+ if (options.length > MAX_CHOICE_COUNT) {
352
+ ERROR(Errors.InvalidParam, 'agree')
356
353
  }
357
354
 
358
355
  let txb = this.protocol.CurrentSession();
package/src/wowok.ts CHANGED
@@ -28,7 +28,7 @@ export class Wowok {
28
28
  let txb = this.protocol.CurrentSession();
29
29
  txb.moveCall({
30
30
  target:this.protocol.WowokFn('grantor_register') as FnCallType,
31
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING), txb.object(Protocol.CLOCK_OBJECT),
31
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name), txb.object(Protocol.CLOCK_OBJECT),
32
32
  Protocol.TXB_OBJECT(txb, grantee_permission)]
33
33
  })
34
34
  }
@@ -49,7 +49,7 @@ export class Wowok {
49
49
  let txb = this.protocol.CurrentSession();
50
50
  txb.moveCall({
51
51
  target:this.protocol.WowokFn('grantor_time_expand_1year') as FnCallType,
52
- arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(new_name, BCS.STRING)]
52
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(new_name)]
53
53
  })
54
54
  }
55
55
  }