wowok 1.1.4 → 1.2.0

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 (63) hide show
  1. package/README.md +7 -2
  2. package/dist/demand.d.ts +6 -6
  3. package/dist/demand.d.ts.map +1 -1
  4. package/dist/demand.js +38 -38
  5. package/dist/entity.d.ts +23 -0
  6. package/dist/entity.d.ts.map +1 -0
  7. package/dist/entity.js +71 -0
  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/guard.d.ts +12 -12
  12. package/dist/guard.d.ts.map +1 -1
  13. package/dist/guard.js +66 -58
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -0
  17. package/dist/machine.d.ts.map +1 -1
  18. package/dist/machine.js +1 -1
  19. package/dist/passport.d.ts +16 -9
  20. package/dist/passport.d.ts.map +1 -1
  21. package/dist/passport.js +69 -59
  22. package/dist/permission.d.ts.map +1 -1
  23. package/dist/permission.js +1 -1
  24. package/dist/progress.d.ts.map +1 -1
  25. package/dist/progress.js +10 -1
  26. package/dist/protocol.d.ts +19 -8
  27. package/dist/protocol.d.ts.map +1 -1
  28. package/dist/protocol.js +31 -26
  29. package/dist/repository.d.ts.map +1 -1
  30. package/dist/repository.js +11 -1
  31. package/dist/resource.d.ts +16 -0
  32. package/dist/resource.d.ts.map +1 -0
  33. package/dist/resource.js +83 -0
  34. package/dist/reward.d.ts.map +1 -1
  35. package/dist/reward.js +10 -1
  36. package/dist/service.d.ts.map +1 -1
  37. package/dist/service.js +11 -1
  38. package/dist/utils.d.ts +1 -0
  39. package/dist/utils.d.ts.map +1 -1
  40. package/dist/utils.js +10 -0
  41. package/dist/vote.d.ts.map +1 -1
  42. package/dist/vote.js +1 -1
  43. package/dist/wowok.d.ts +12 -0
  44. package/dist/wowok.d.ts.map +1 -0
  45. package/dist/wowok.js +48 -0
  46. package/package.json +10 -3
  47. package/src/demand.ts +42 -42
  48. package/src/entity.ts +83 -0
  49. package/src/exception.ts +1 -0
  50. package/src/guard.ts +71 -57
  51. package/src/index.ts +11 -8
  52. package/src/machine.ts +3 -2
  53. package/src/passport.ts +70 -65
  54. package/src/permission.ts +5 -4
  55. package/src/progress.ts +11 -3
  56. package/src/protocol.ts +41 -31
  57. package/src/repository.ts +12 -2
  58. package/src/resource.ts +90 -0
  59. package/src/reward.ts +11 -2
  60. package/src/service.ts +12 -1
  61. package/src/utils.ts +12 -1
  62. package/src/vote.ts +2 -1
  63. package/src/wowok.ts +56 -0
package/src/entity.ts ADDED
@@ -0,0 +1,83 @@
1
+ import { BCS } from '@mysten/bcs';
2
+ import { Protocol, FnCallType, TxbObject, ResourceAddress, PermissionObject, ResourceObject} from './protocol';
3
+ import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, Bcs, } from './utils';
4
+ import { ERROR, Errors } from './exception';
5
+ import { Resource } from './resource';
6
+
7
+ export interface Entity_Info {
8
+ name: string;
9
+ description?: string;
10
+ avatar?: string;
11
+ twitter?: string;
12
+ discord?: string;
13
+ homepage?: string;
14
+ }
15
+
16
+ export class Entity {
17
+
18
+ protected object:TxbObject;
19
+ protected protocol;
20
+
21
+ get_object() { return this.object }
22
+ private constructor(protocol:Protocol) {
23
+ this.protocol = protocol;
24
+ this.object = '';
25
+ }
26
+
27
+ static From(protocol:Protocol) : Entity {
28
+ let r = new Entity(protocol);
29
+ r.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), protocol.EntityObject());
30
+ return r
31
+ }
32
+
33
+ mark(resource:Resource, address:string, like:'like' | 'dislike') {
34
+ if (!IsValidAddress(address)) ERROR(Errors.IsValidAddress, like);
35
+
36
+ let txb = this.protocol.CurrentSession();
37
+ txb.moveCall({
38
+ target:this.protocol.EntityFn(like) as FnCallType,
39
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(address, BCS.ADDRESS)]
40
+ })
41
+ }
42
+
43
+ update(info: Entity_Info) {
44
+ if (!IsValidName(info.name)) ERROR(Errors.IsValidName, 'update');
45
+ if (info?.description && !IsValidDesription(info.description)) ERROR(Errors.IsValidDesription, 'update');
46
+ if (info?.avatar && !isValidHttpUrl(info.avatar)) ERROR(Errors.isValidHttpUrl, 'update:avatar');
47
+ if (info?.twitter && !IsValidName(info.twitter)) ERROR(Errors.IsValidName, 'update:twitter');
48
+ if (info?.homepage && !isValidHttpUrl(info.homepage)) ERROR(Errors.isValidHttpUrl, 'update:homepage');
49
+ if (info?.discord && !IsValidName(info.discord)) ERROR(Errors.IsValidName, 'update:discord');
50
+
51
+ let txb = this.protocol.CurrentSession();
52
+ txb.moveCall({
53
+ target:this.protocol.EntityFn('avatar_update') as FnCallType,
54
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(JSON.stringify(info), BCS.STRING)]
55
+ })
56
+ }
57
+
58
+ create_resource(description:string) : ResourceAddress {
59
+ if (!IsValidDesription(description)) ERROR(Errors.IsValidDesription, 'create_resource');
60
+ let txb = this.protocol.CurrentSession();
61
+ return txb.moveCall({
62
+ target:this.protocol.EntityFn('resource_create') as FnCallType,
63
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(description, BCS.STRING)]
64
+ })
65
+ }
66
+
67
+ destroy_resource(resource:Resource) {
68
+ let txb = this.protocol.CurrentSession();
69
+ return txb.moveCall({
70
+ target:this.protocol.EntityFn('resource_destroy') as FnCallType,
71
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object())]
72
+ })
73
+ }
74
+
75
+ transfer_resource(resource:Resource, new_address:string) {
76
+ if (!IsValidAddress(new_address)) ERROR(Errors.IsValidAddress, 'transfer_resource');
77
+ let txb = this.protocol.CurrentSession();
78
+ return txb.moveCall({
79
+ target:this.protocol.EntityFn('resource_transfer') as FnCallType,
80
+ arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(new_address, BCS.ADDRESS)]
81
+ })
82
+ }
83
+ }
package/src/exception.ts CHANGED
@@ -17,6 +17,7 @@ export enum Errors {
17
17
  IsValidKey = 'invalid key',
18
18
  Fail = 'fail',
19
19
  IsValidIndentifier = 'indentifier invalid',
20
+ isValidHttpUrl = 'invalid url',
20
21
  }
21
22
 
22
23
  export const ERROR = (error:Errors, info?:any) => {
package/src/guard.ts CHANGED
@@ -1,14 +1,14 @@
1
1
 
2
2
  import { BCS } from '@mysten/bcs';
3
- import { Protocol, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, VariableType, SER_VALUE} from './protocol';
3
+ import { Protocol, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, ConstantType, SER_VALUE} from './protocol';
4
4
  import { concatenate, array_equal } from './utils';
5
5
  import { IsValidDesription, Bcs, IsValidInt, IsValidAddress } from './utils';
6
6
  import { ERROR, Errors } from './exception';
7
7
 
8
- export type GuardVariable = Map<number, Guard_Vriable>;
8
+ export type GuardConstant = Map<number, Guard_Vriable>;
9
9
 
10
10
  export interface Guard_Vriable {
11
- type: VariableType ,
11
+ type: ConstantType ,
12
12
  value?: Uint8Array,
13
13
  witness?: Uint8Array,
14
14
  }
@@ -24,18 +24,18 @@ export class Guard {
24
24
  ERROR(Errors.IsValidDesription)
25
25
  }
26
26
  let bcs_input = maker.get_input()[0];
27
- let variables = maker.get_variable();
27
+ let constants = maker.get_constant();
28
28
  if (bcs_input.length == 0 || bcs_input.length > Guard.MAX_INPUT_LENGTH) {
29
29
  ERROR(Errors.InvalidParam, 'launch input')
30
30
  }
31
31
 
32
32
  let bValid = true;
33
- variables?.forEach((v, k) => {
34
- if (!GuardVariableHelper.IsValidIndentifier(k)) bValid = false;
33
+ constants?.forEach((v, k) => {
34
+ if (!GuardConstantHelper.IsValidIndentifier(k)) bValid = false;
35
35
  if (!v.value && !v.witness) bValid = false;
36
36
  })
37
37
  if (!bValid) {
38
- ERROR(Errors.InvalidParam, 'launch variables')
38
+ ERROR(Errors.InvalidParam, 'launch constants')
39
39
  }
40
40
 
41
41
  let txb = protocol.CurrentSession();
@@ -47,23 +47,23 @@ export class Guard {
47
47
  arguments: [txb.pure(description , BCS.STRING), txb.pure([].slice.call(input.reverse()))],
48
48
  });
49
49
 
50
- variables?.forEach((v, k) => {
50
+ constants?.forEach((v, k) => {
51
51
  if (v.type == ContextType.TYPE_WITNESS_ID) {
52
52
  if (!v.witness) {
53
- ERROR(Errors.InvalidParam, 'variables type')
53
+ ERROR(Errors.InvalidParam, 'constants type')
54
54
  }
55
55
 
56
56
  txb.moveCall({
57
- target:protocol.GuardFn("variable_add") as FnCallType,
57
+ target:protocol.GuardFn("constant_add") as FnCallType,
58
58
  arguments:[guard, txb.pure(k, BCS.U8), txb.pure(v.type, BCS.U8), txb.pure([].slice.call(v.witness)), txb.pure(true, BCS.BOOL)]
59
59
  })
60
60
  } else {
61
61
  if (!v.value) {
62
- ERROR(Errors.InvalidParam, 'variables type')
62
+ ERROR(Errors.InvalidParam, 'constants type')
63
63
  }
64
64
 
65
65
  txb.moveCall({
66
- target:protocol.GuardFn("variable_add") as FnCallType,
66
+ target:protocol.GuardFn("constant_add") as FnCallType,
67
67
  arguments:[guard, txb.pure(k, BCS.U8), txb.pure(v.type, BCS.U8), txb.pure([].slice.call(v.value)), txb.pure(true, BCS.BOOL)]
68
68
  })
69
69
  }
@@ -88,6 +88,7 @@ export class Guard {
88
88
  arguments: []
89
89
  });
90
90
  }
91
+
91
92
  static QUERIES:any[] = [
92
93
  // module, 'name', 'id', [input], output
93
94
  [MODULES.permission, 'builder', 1, [], ValueType.TYPE_ADDRESS],
@@ -217,53 +218,66 @@ export class Guard {
217
218
  [MODULES.vote, 'top1_count', 190, [], ValueType.TYPE_U64],
218
219
  [MODULES.vote, 'top1_name_by_votes', 191, [], ValueType.TYPE_VEC_U8],
219
220
  [MODULES.vote, 'top1_votes', 192, [], ValueType.TYPE_U64],
221
+
222
+ [MODULES.wowok, 'initor', 210, [], ValueType.TYPE_ADDRESS],
223
+ [MODULES.wowok, 'everyone_guard', 211, [], ValueType.TYPE_ADDRESS],
224
+ [MODULES.wowok, 'entities', 212, [], ValueType.TYPE_ADDRESS],
225
+ [MODULES.wowok, 'grantor_count', 213, [], ValueType.TYPE_U64],
226
+ [MODULES.wowok, 'has_grantor', 214, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
227
+ [MODULES.wowok, 'grantor_name', 215, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],
228
+ [MODULES.wowok, 'grantor_register_time', 216, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
229
+ [MODULES.wowok, 'grantor_expired_time', 217, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
230
+ [MODULES.wowok, 'grantor_grantee', 218, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS],
231
+
232
+ [MODULES.entity, 'has_entity', 230, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
233
+ [MODULES.entity, 'entity_like', 231, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
234
+ [MODULES.entity, 'entity_dislike', 232, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
235
+ [MODULES.entity, 'entity_infomation', 233, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],
220
236
  ];
221
237
  static BoolCmd = Guard.QUERIES.filter(q => q[4] == ValueType.TYPE_BOOL);
222
238
  static IsBoolCmd = (cmd:number) : boolean => { return Guard.BoolCmd.includes((q:any) => {return q[2] == cmd}) }
223
239
  static GetCmd = (cmd:number) : any => {
224
- let r = Guard.QUERIES.find((q:any) => {return q[2] == cmd}) ;
225
- if (!r) { ERROR(Errors.Fail, 'CmdParamCount: not found')};
226
- return r;
240
+ return Guard.QUERIES.find((q:any) => {return q[2] == cmd}) ;
227
241
  }
228
242
  }
229
243
 
230
- export class GuardVariableHelper {
244
+ export class GuardConstantHelper {
231
245
  static IsValidIndentifier = (identifier:number) : boolean => {
232
246
  if (!IsValidInt(identifier) || identifier > 255) return false;
233
247
  return true
234
248
  }
235
- static get_variable_value(variables:GuardVariable, identifier:number, type:VariableType) : Uint8Array | undefined {
236
- if (variables.has(identifier)) {
237
- let v = variables.get(identifier);
249
+ static get_constant_value(constants:GuardConstant, identifier:number, type:ConstantType) : Uint8Array | undefined {
250
+ if (constants.has(identifier)) {
251
+ let v = constants.get(identifier);
238
252
  if (v?.value && v.type == type) {
239
253
  return v.value;
240
254
  }
241
255
  }
242
256
  }
243
- static get_variable_witness(variables:GuardVariable, identifier:number) : Uint8Array | undefined {
244
- if (variables.has(identifier)) {
245
- let v = variables.get(identifier);
257
+ static get_constant_witness(constants:GuardConstant, identifier:number) : Uint8Array | undefined {
258
+ if (constants.has(identifier)) {
259
+ let v = constants.get(identifier);
246
260
  if (v?.witness && v.type == ContextType.TYPE_WITNESS_ID) {
247
261
  return v.witness;
248
262
  }
249
263
  }
250
264
  }
251
265
 
252
- static add_future_variable(variables:GuardVariable, identifier:number, witness:any, value?:any, bNeedSerialize=true) {
253
- if (!GuardVariableHelper.IsValidIndentifier(identifier)) ERROR(Errors.IsValidIndentifier, 'add_future_variable');
266
+ static add_future_constant(constants:GuardConstant, identifier:number, witness:any, value?:any, bNeedSerialize=true) {
267
+ if (!GuardConstantHelper.IsValidIndentifier(identifier)) ERROR(Errors.IsValidIndentifier, 'add_future_constant');
254
268
  if (!witness && !value) ERROR(Errors.InvalidParam, 'both witness and value invalid');
255
- let v = variables.get(identifier);
269
+ let v = constants.get(identifier);
256
270
  if (!v || v.type == ContextType.TYPE_WITNESS_ID) {
257
271
  if (bNeedSerialize) {
258
- variables.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value ? Bcs.getInstance().ser_address(value) : undefined, witness:witness ? Bcs.getInstance().ser_address(witness) : undefined})
272
+ constants.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value ? Bcs.getInstance().ser_address(value) : undefined, witness:witness ? Bcs.getInstance().ser_address(witness) : undefined})
259
273
  } else {
260
- variables.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value?value:undefined, witness:witness?witness:undefined});
274
+ constants.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value?value:undefined, witness:witness?witness:undefined});
261
275
  }
262
276
  }
263
277
  }
264
278
 
265
- static add_variable(variables:GuardVariable, identifier:number, type:ValueType, value:any, bNeedSerialize=true) {
266
- if (!GuardVariableHelper.IsValidIndentifier(identifier)) return false;
279
+ static add_constant(constants:GuardConstant, identifier:number, type:ValueType, value:any, bNeedSerialize=true) {
280
+ if (!GuardConstantHelper.IsValidIndentifier(identifier)) return false;
267
281
  if (!value) return false;
268
282
 
269
283
  switch (type) {
@@ -286,26 +300,26 @@ export class GuardVariableHelper {
286
300
  case ValueType.TYPE_VEC_U128:
287
301
  case ValueType.TYPE_VEC_U256:
288
302
  let ser = SER_VALUE.find(s=>s.type==type);
289
- if (!ser) ERROR(Errors.Fail, 'add_variable: invalid type');
290
- bNeedSerialize ? variables.set(identifier, {type:type, value:Bcs.getInstance().ser(ser!.name, value)}) :
291
- variables.set(identifier, {type:type, value:value})
303
+ if (!ser) ERROR(Errors.Fail, 'add_constant: invalid type');
304
+ bNeedSerialize ? constants.set(identifier, {type:type, value:Bcs.getInstance().ser(ser!.name, value)}) :
305
+ constants.set(identifier, {type:type, value:value})
292
306
  return
293
307
  case ValueType.TYPE_VEC_U8:
294
308
  if (typeof(value) === 'string') {
295
- variables.set(identifier, {type:type, value:Bcs.getInstance().ser_string(value)})
309
+ constants.set(identifier, {type:type, value:Bcs.getInstance().ser_string(value)})
296
310
  } else {
297
- variables.set(identifier, {type:type, value:value})
311
+ constants.set(identifier, {type:type, value:value})
298
312
  }
299
313
  return;
300
314
  default:
301
- ERROR(Errors.Fail, 'add_variable serialize not impl yet')
315
+ ERROR(Errors.Fail, 'add_constant serialize not impl yet')
302
316
  }
303
317
  }
304
318
  }
305
319
  export class GuardMaker {
306
320
  protected data : Uint8Array[] = [];
307
321
  protected type_validator : Data_Type[] = [];
308
- protected variable : GuardVariable = new Map();
322
+ protected constant : GuardConstant = new Map();
309
323
 
310
324
  private static index: number = 0;
311
325
  private static get_index() {
@@ -317,13 +331,13 @@ export class GuardMaker {
317
331
 
318
332
  constructor() { }
319
333
 
320
- add_variable(type:VariableType, value:any, bNeedSerialize=true) : number {
334
+ add_constant(type:ConstantType, value:any, bNeedSerialize=true) : number {
321
335
  let identifier = GuardMaker.get_index();
322
336
  if (type == ContextType.TYPE_WITNESS_ID) {
323
- // add witness to variable
324
- GuardVariableHelper.add_future_variable(this.variable, identifier, value, undefined, bNeedSerialize);
337
+ // add witness to constant
338
+ GuardConstantHelper.add_future_constant(this.constant, identifier, value, undefined, bNeedSerialize);
325
339
  } else {
326
- GuardVariableHelper.add_variable(this.variable, identifier, type, value, bNeedSerialize);
340
+ GuardConstantHelper.add_constant(this.constant, identifier, type, value, bNeedSerialize);
327
341
  }
328
342
  return identifier
329
343
  }
@@ -384,7 +398,7 @@ export class GuardMaker {
384
398
  this.data.push(Bcs.getInstance().ser_address(param));
385
399
  this.type_validator.push(ValueType.TYPE_ADDRESS);
386
400
  break;
387
- case ContextType.TYPE_VARIABLE:
401
+ case ContextType.TYPE_CONSTANT:
388
402
  if (!param) {
389
403
  ERROR(Errors.InvalidParam, 'param invalid');
390
404
  }
@@ -392,8 +406,8 @@ export class GuardMaker {
392
406
  ERROR(Errors.InvalidParam, 'add_param param');
393
407
  }
394
408
 
395
- var v = this.variable.get(param);
396
- if (!v) ERROR(Errors.Fail, 'identifier not in variable');
409
+ var v = this.constant.get(param);
410
+ if (!v) ERROR(Errors.Fail, 'identifier not in constant');
397
411
  this.type_validator.push(v!.type);
398
412
  this.data.push(Bcs.getInstance().ser_u8(type));
399
413
  this.data.push(Bcs.getInstance().ser_u8(param));
@@ -404,7 +418,7 @@ export class GuardMaker {
404
418
  return this;
405
419
  }
406
420
 
407
- // object_address_from: string for static address; number as identifier invariable
421
+ // object_address_from: string for static address; number as identifier inconstant
408
422
  add_query(module:MODULES, query_name:string, object_address_from:string | number, bWitness:boolean=false) : GuardMaker {
409
423
  let query_index = Guard.QUERIES.findIndex((q) => { return q[0] == module && q[1] == query_name})
410
424
  if (query_index == -1) {
@@ -412,7 +426,7 @@ export class GuardMaker {
412
426
  }
413
427
 
414
428
  if (typeof(object_address_from) == 'number' ) {
415
- if (!GuardVariableHelper.IsValidIndentifier(object_address_from)) {
429
+ if (!GuardConstantHelper.IsValidIndentifier(object_address_from)) {
416
430
  ERROR(Errors.InvalidParam, 'object_address_from');
417
431
  }
418
432
  } else {
@@ -437,11 +451,11 @@ export class GuardMaker {
437
451
  this.data.push(Bcs.getInstance().ser_u8(ValueType.TYPE_ADDRESS));
438
452
  this.data.push(Bcs.getInstance().ser_address(object_address_from)); // object address
439
453
  } else {
440
- let v = this.variable.get(object_address_from);
441
- if (!v) ERROR(Errors.Fail, 'object_address_from not in variable');
454
+ let v = this.constant.get(object_address_from);
455
+ if (!v) ERROR(Errors.Fail, 'object_address_from not in constant');
442
456
  if ((bWitness && v?.type == ContextType.TYPE_WITNESS_ID) || (!bWitness && v?.type == ValueType.TYPE_ADDRESS)) {
443
- this.data.push(Bcs.getInstance().ser_u8(ContextType.TYPE_VARIABLE));
444
- this.data.push(Bcs.getInstance().ser_u8(object_address_from)); // object identifer in variables
457
+ this.data.push(Bcs.getInstance().ser_u8(ContextType.TYPE_CONSTANT));
458
+ this.data.push(Bcs.getInstance().ser_u8(object_address_from)); // object identifer in constants
445
459
  } else {
446
460
  ERROR(Errors.Fail, 'type bWitness not match')
447
461
  }
@@ -509,17 +523,17 @@ export class GuardMaker {
509
523
  return this.type_validator.length == 1 && this.type_validator[0] == ValueType.TYPE_BOOL && this.data.length == 1;
510
524
  }
511
525
 
512
- combine(otherBuilt:GuardMaker, bAnd:boolean = true, bCombinVariable=false) : GuardMaker {
526
+ combine(otherBuilt:GuardMaker, bAnd:boolean = true, bCombinConstant=false) : GuardMaker {
513
527
  if (!otherBuilt.IsReady() || !this.IsReady()) { ERROR(Errors.Fail, 'both should built yet')};
514
528
  let maker = new GuardMaker();
515
- this.variable.forEach((v, k) => {
516
- maker.variable.set(k, {type:v.type, value:v.value, witness:v.witness});
529
+ this.constant.forEach((v, k) => {
530
+ maker.constant.set(k, {type:v.type, value:v.value, witness:v.witness});
517
531
  })
518
- otherBuilt.variable.forEach((v, k) => {
519
- if (maker.variable.has(k) && !bCombinVariable) {
520
- ERROR(Errors.Fail, 'variable identifier exist');
532
+ otherBuilt.constant.forEach((v, k) => {
533
+ if (maker.constant.has(k) && !bCombinConstant) {
534
+ ERROR(Errors.Fail, 'constant identifier exist');
521
535
  }
522
- maker.variable.set(k, {type:v.type, value:v.value, witness:v.witness});
536
+ maker.constant.set(k, {type:v.type, value:v.value, witness:v.witness});
523
537
  })
524
538
  let op = bAnd ? OperatorType.TYPE_LOGIC_AND : OperatorType.TYPE_LOGIC_OR;
525
539
  maker.data.push(concatenate(Uint8Array, ...this.data, ...otherBuilt.data, Bcs.getInstance().ser_u8(op)));
@@ -528,7 +542,7 @@ export class GuardMaker {
528
542
  return maker
529
543
  }
530
544
 
531
- get_variable() { return this.variable }
545
+ get_constant() { return this.constant }
532
546
  get_input() { return this.data }
533
547
 
534
548
  static input_combine(input1:Uint8Array, input2:Uint8Array, bAnd:boolean = true) : Uint8Array {
package/src/index.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  export * from './demand'
2
- export * from './progress'
3
- export * from './reward'
4
- export * from './utils'
5
- export * from './permission'
6
- export * from './guard'
7
- export * from './repository'
8
- export * from './vote'
2
+ export * from './progress'
3
+ export * from './reward'
4
+ export * from './utils'
5
+ export * from './permission'
6
+ export * from './guard'
7
+ export * from './repository'
8
+ export * from './vote'
9
9
  export * from './protocol'
10
10
  export * from './passport'
11
11
  export * from './machine'
12
12
  export * from './service'
13
- export * from './graphql'
13
+ export * from './graphql'
14
+ export * from './entity'
15
+ export * from './wowok'
16
+ export * from './resource'
package/src/machine.ts CHANGED
@@ -5,6 +5,7 @@ import { IsValidInt, IsValidUint, Bcs, array_unique, IsValidArray, IsValidAddres
5
5
  IsValidEndpoint, OptionNone, IsValidDesription} from './utils'
6
6
  import { Permission, PermissionIndexType } from './permission';
7
7
  import { Errors, ERROR} from './exception'
8
+ import { Resource } from './resource';
8
9
 
9
10
 
10
11
  export type MachineNodeObject = TransactionResult | String;
@@ -46,8 +47,6 @@ export class Machine {
46
47
  this.object = '';
47
48
  }
48
49
  static New(protocol:Protocol, permission:PermissionObject, description:string, endpoint?:string, passport?:PassportObject) : Machine {
49
- let m = new Machine(protocol, permission);
50
-
51
50
  if (!Protocol.IsValidObjects([permission])) {
52
51
  ERROR(Errors.IsValidObjects, 'permission')
53
52
  }
@@ -57,6 +56,8 @@ export class Machine {
57
56
  if (endpoint && !IsValidEndpoint(endpoint)) {
58
57
  ERROR(Errors.IsValidEndpoint)
59
58
  }
59
+
60
+ let m = new Machine(protocol, permission);
60
61
  let txb = protocol.CurrentSession();
61
62
  let ep = endpoint? txb.pure(Bcs.getInstance().ser_option_string(endpoint)) : OptionNone(txb);
62
63