wowok 1.1.5 → 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 (67) hide show
  1. package/README.md +7 -2
  2. package/dist/demand.d.ts +0 -2
  3. package/dist/demand.d.ts.map +1 -1
  4. package/dist/demand.js +0 -8
  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 +65 -52
  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 +0 -2
  18. package/dist/machine.d.ts.map +1 -1
  19. package/dist/machine.js +0 -7
  20. package/dist/passport.d.ts +13 -9
  21. package/dist/passport.d.ts.map +1 -1
  22. package/dist/passport.js +60 -55
  23. package/dist/permission.d.ts +0 -2
  24. package/dist/permission.d.ts.map +1 -1
  25. package/dist/permission.js +0 -7
  26. package/dist/progress.d.ts +0 -2
  27. package/dist/progress.d.ts.map +1 -1
  28. package/dist/progress.js +9 -7
  29. package/dist/protocol.d.ts +15 -8
  30. package/dist/protocol.d.ts.map +1 -1
  31. package/dist/protocol.js +29 -26
  32. package/dist/repository.d.ts +0 -2
  33. package/dist/repository.d.ts.map +1 -1
  34. package/dist/repository.js +10 -9
  35. package/dist/resource.d.ts +2 -5
  36. package/dist/resource.d.ts.map +1 -1
  37. package/dist/resource.js +4 -30
  38. package/dist/reward.d.ts +0 -2
  39. package/dist/reward.d.ts.map +1 -1
  40. package/dist/reward.js +9 -7
  41. package/dist/service.d.ts +0 -2
  42. package/dist/service.d.ts.map +1 -1
  43. package/dist/service.js +10 -8
  44. package/dist/utils.d.ts +1 -0
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/utils.js +10 -0
  47. package/dist/vote.d.ts +0 -2
  48. package/dist/vote.d.ts.map +1 -1
  49. package/dist/vote.js +0 -7
  50. package/dist/wowok.d.ts +12 -0
  51. package/dist/wowok.d.ts.map +1 -0
  52. package/dist/wowok.js +48 -0
  53. package/package.json +10 -3
  54. package/src/demand.ts +1 -10
  55. package/src/entity.ts +27 -1
  56. package/src/guard.ts +55 -55
  57. package/src/index.ts +11 -8
  58. package/src/machine.ts +0 -8
  59. package/src/passport.ts +69 -65
  60. package/src/permission.ts +0 -8
  61. package/src/progress.ts +2 -2
  62. package/src/protocol.ts +28 -28
  63. package/src/repository.ts +2 -2
  64. package/src/resource.ts +3 -35
  65. package/src/reward.ts +2 -2
  66. package/src/service.ts +2 -2
  67. package/src/vote.ts +0 -8
package/src/protocol.ts CHANGED
@@ -4,7 +4,7 @@ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
4
4
  import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
5
5
  import { TransactionBlock, Inputs, TransactionResult, TransactionArgument } from '@mysten/sui.js/transactions';
6
6
  import { capitalize, IsValidArray } from './utils'
7
- import { GuardVariable } from './guard';
7
+ import { GuardConstant } from './guard';
8
8
 
9
9
 
10
10
  export enum MODULES {
@@ -106,38 +106,39 @@ export const IsValidValueType = (type:number) => { return ValueTypeArray.include
106
106
  interface ValueTypeString {
107
107
  type: ValueType;
108
108
  name: string;
109
+ description: string;
109
110
  }
110
111
 
111
112
  export const SER_VALUE: ValueTypeString[] = [
112
- {type: ValueType.TYPE_BOOL, name: 'bool'},
113
- {type: ValueType.TYPE_ADDRESS, name: 'address'},
114
- {type: ValueType.TYPE_U64, name: 'u64'},
115
- {type: ValueType.TYPE_U8, name: 'u8'},
116
- {type: ValueType.TYPE_VEC_U8, name: 'vector<u8>'},
117
- {type: ValueType.TYPE_U128, name: 'u128'},
118
- {type: ValueType.TYPE_VEC_ADDRESS, name: 'vector<address>'},
119
- {type: ValueType.TYPE_VEC_BOOL, name: 'vector<bool>'},
120
- {type: ValueType.TYPE_VEC_VEC_U8, name: 'vector<vector<u8>>'},
121
- {type: ValueType.TYPE_VEC_U64, name: 'vector<u64>'},
122
- {type: ValueType.TYPE_VEC_U128, name: 'vector<u128>'},
123
- {type: ValueType.TYPE_OPTION_ADDRESS, name: 'Option<address>'},
124
- {type: ValueType.TYPE_OPTION_BOOL, name: 'Option<bool>'},
125
- {type: ValueType.TYPE_OPTION_U8, name: 'Option<u8>'},
126
- {type: ValueType.TYPE_OPTION_U64, name: 'Option<u64>'},
127
- {type: ValueType.TYPE_OPTION_U128, name: 'Option<u128>'},
128
- {type: ValueType.TYPE_OPTION_U256, name: 'Option<u256>'},
129
- {type: ValueType.TYPE_VEC_U256, name: 'vector<u256>'},
130
- {type: ValueType.TYPE_U256, name: 'u256'},
113
+ {type: ValueType.TYPE_BOOL, name: 'bool', description:'boolean. eg:true or false'},
114
+ {type: ValueType.TYPE_ADDRESS, name: 'address', description:'address or object-id. eg:0x6789af'},
115
+ {type: ValueType.TYPE_U64, name: 'number', description:'unsigned-64 number. eg:23870233'},
116
+ {type: ValueType.TYPE_U8, name: 'number', description:'unsigned-8 number. eg:255'},
117
+ {type: ValueType.TYPE_VEC_U8, name: '[number]', description:'unsigned-8 number array. eg:"wowok"'},
118
+ {type: ValueType.TYPE_U128, name: 'number', description:'unsigned-8 number. eg:12348900999'},
119
+ {type: ValueType.TYPE_VEC_ADDRESS, name: '[address]', description:'address array. eg:[0x2277f2, 0x3344af]'},
120
+ {type: ValueType.TYPE_VEC_BOOL, name: '[bool]', description:'boolean array. eg:[true, false, true]'},
121
+ {type: ValueType.TYPE_VEC_VEC_U8, name: '[[number]]', description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},
122
+ {type: ValueType.TYPE_VEC_U64, name: '[number]', description:'unsigned-64 number array. eg:[123, 778888, 42312]'},
123
+ {type: ValueType.TYPE_VEC_U128, name: '[number]', description:'unsigned-128 number array. eg:[123, 778888, 42312]'},
124
+ {type: ValueType.TYPE_OPTION_ADDRESS, name: 'option', description:'option of address. eg:none or address'},
125
+ {type: ValueType.TYPE_OPTION_BOOL, name: 'option', description:'option of bool. eg:none or boolean value'},
126
+ {type: ValueType.TYPE_OPTION_U8, name: 'option', description:'option of u8. eg:none or u8 value'},
127
+ {type: ValueType.TYPE_OPTION_U64, name: 'option', description:'option of u64. eg:none or u64 value'},
128
+ {type: ValueType.TYPE_OPTION_U128, name: 'option', description:'option of u128. eg:none or u128 value'},
129
+ {type: ValueType.TYPE_OPTION_U256, name: 'option', description:'option of u256. eg:none or u256 value'},
130
+ {type: ValueType.TYPE_VEC_U256, name: '[number]', description:'unsigned-256 number array. eg:[123, 778888, 42312]'},
131
+ {type: ValueType.TYPE_U256, name: 'number', description:'unsigned-256 number. eg:12345678901233'},
131
132
  ]
132
133
 
133
134
  export enum ContextType {
134
135
  TYPE_SIGNER = 60,
135
136
  TYPE_CLOCK = 61,
136
137
  TYPE_WITNESS_ID = 62,
137
- TYPE_VARIABLE = 80,
138
+ TYPE_CONSTANT = 80,
138
139
  }
139
140
 
140
- export type VariableType = ValueType | ContextType.TYPE_WITNESS_ID;
141
+ export type ConstantType = ValueType | ContextType.TYPE_WITNESS_ID;
141
142
  export type Data_Type = ValueType | OperatorType | ContextType;
142
143
 
143
144
  export enum ENTRYPOINT {
@@ -164,14 +165,13 @@ export class Protocol {
164
165
  this.network = network;
165
166
  switch(network) {
166
167
  case ENTRYPOINT.localnet:
167
- this.package = "0xe9721254e97dd074e06c5efe5c57be169b64b39ae48939d89c00bf2f62b19e10";
168
168
  break;
169
169
  case ENTRYPOINT.devnet:
170
170
  break;
171
171
  case ENTRYPOINT.testnet:
172
- this.package = "0x9a7fc338ab9fd0a8f4c108e2f3dbe53393b83529263eb31a391120997d962400";
173
- this.wowok_object = '';
174
- this.entity_object= '';
172
+ this.package = "0x2ac00805aa0ec3c62b575e412108bb295389bbfc86202fd7b73c69dbbb80769a";
173
+ this.wowok_object = '0x49d49fb41c63c3f6c838fca20c25741f20aa74a176391685446794bdaa9b7934';
174
+ this.entity_object= '0xd21d8d76f553b2db6c6d28a8b2ae3405bec92f2a300676d80fcc004ca40b0a77';
175
175
  this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
176
176
  break;
177
177
  case ENTRYPOINT.mainnet:
@@ -335,7 +335,7 @@ export class RpcResultParser {
335
335
  export type Query_Param = {
336
336
  objectid: string;
337
337
  callback: (protocol:Protocol, response:SuiObjectResponse, param:Query_Param, option:SuiObjectDataOptions)=>void;
338
- parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array, variable?:GuardVariable) => boolean;
338
+ parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array, constant?:GuardConstant) => boolean;
339
339
  data?: any; // response data filted by callback
340
- variables?: GuardVariable;
340
+ constants?: GuardConstant;
341
341
  };
package/src/repository.ts CHANGED
@@ -82,7 +82,7 @@ export class Repository {
82
82
  arguments: [Protocol.TXB_OBJECT(txb, this.object)],
83
83
  })
84
84
  }
85
-
85
+ /* move to: Entity.mark
86
86
  mark(like:'like' | 'unlike', resource:Resource) {
87
87
  if (!Protocol.IsValidObjects([this.object])) return false;
88
88
  let txb = this.protocol.CurrentSession();
@@ -91,7 +91,7 @@ export class Repository {
91
91
  arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
92
92
  })
93
93
  }
94
-
94
+ */
95
95
  add_data(data:Repository_Policy_Data) {
96
96
  if (!Repository.IsValidName(data.key)) {
97
97
  ERROR(Errors.IsValidName)
package/src/resource.ts CHANGED
@@ -25,39 +25,6 @@ export class Resource {
25
25
  return r
26
26
  }
27
27
 
28
- static New(protocol:Protocol, description:string) : Resource {
29
- if (!IsValidDesription(description)) {
30
- ERROR(Errors.IsValidDesription)
31
- }
32
-
33
- let r = new Resource(protocol);
34
- let txb = protocol.CurrentSession();
35
-
36
- r.object = txb.moveCall({
37
- target:protocol.ResourceFn('new') as FnCallType,
38
- arguments:[txb.pure(description)],
39
- })
40
-
41
- return r
42
- }
43
-
44
- launch() : ResourceAddress {
45
- let txb = this.protocol.CurrentSession();
46
- return txb.moveCall({
47
- target:this.protocol.ResourceFn('create') as FnCallType,
48
- arguments:[Protocol.TXB_OBJECT(txb, this.object)],
49
- })
50
- }
51
-
52
- destroy() {
53
- if (!Protocol.IsValidObjects([this.object])) return false;
54
- let txb = this.protocol.CurrentSession();
55
- txb.moveCall({
56
- target:this.protocol.ResourceFn('destroy') as FnCallType,
57
- arguments: [Protocol.TXB_OBJECT(txb, this.object)],
58
- })
59
- }
60
-
61
28
  add(name:string, object:string) {
62
29
  if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: add');
63
30
  if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: add');
@@ -69,8 +36,9 @@ export class Resource {
69
36
  });
70
37
  }
71
38
 
72
- remove(name:string, object:string, removeall?:boolean) {
39
+ remove(name:string, object?:string, removeall?:boolean) {
73
40
  if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: remove');
41
+ if (!object && !removeall) ERROR(Errors.InvalidParam, 'Resource: remove, BOTH param undefined');
74
42
 
75
43
  let txb = this.protocol.CurrentSession();
76
44
  if (removeall) {
@@ -78,7 +46,7 @@ export class Resource {
78
46
  target:this.protocol.ResourceFn('remove_all') as FnCallType,
79
47
  arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING)]
80
48
  });
81
- } else {
49
+ } else if(object) {
82
50
  if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove');
83
51
 
84
52
  txb.moveCall({
package/src/reward.ts CHANGED
@@ -82,7 +82,7 @@ export class Reward {
82
82
  arguments: [Protocol.TXB_OBJECT(txb, this.object)],
83
83
  })
84
84
  }
85
-
85
+ /*
86
86
  mark(like:'like' | 'unlike', resource:Resource) {
87
87
  let txb = this.protocol.CurrentSession();
88
88
  txb.moveCall({
@@ -90,7 +90,7 @@ export class Reward {
90
90
  arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
91
91
  })
92
92
  }
93
-
93
+ */
94
94
  refund(passport?:PassportObject) {
95
95
  let txb = this.protocol.CurrentSession();
96
96
  if (passport) {
package/src/service.ts CHANGED
@@ -130,7 +130,7 @@ export class Service {
130
130
  typeArguments:[this.pay_token_type]
131
131
  })
132
132
  }
133
-
133
+ /* move to: Entity.mark
134
134
  mark(like:'like' | 'unlike', resource:Resource) {
135
135
  let txb = this.protocol.CurrentSession();
136
136
  txb.moveCall({
@@ -139,7 +139,7 @@ export class Service {
139
139
  typeArguments:[this.pay_token_type]
140
140
  })
141
141
  }
142
-
142
+ */
143
143
  set_description(description:string, passport?:PassportObject) {
144
144
  if (!IsValidDesription(description)) {
145
145
  ERROR(Errors.IsValidDesription)
package/src/vote.ts CHANGED
@@ -86,14 +86,6 @@ export class Vote {
86
86
  })
87
87
  }
88
88
 
89
- mark(like:'like' | 'unlike', resource:Resource) {
90
- let txb = this.protocol.CurrentSession();
91
- txb.moveCall({
92
- target:this.protocol.VoteFn(like) as FnCallType,
93
- arguments:[Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)]
94
- })
95
- }
96
-
97
89
  set_description(description:string, passport?:PassportObject) {
98
90
  if (!IsValidDesription(description)) {
99
91
  ERROR(Errors.IsValidDesription)