wowok 1.0.4 → 1.0.5

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/dist/guard.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sense_objects_fn = exports.description_fn = exports.parse_sense_bsc = exports.SenseMaker = exports.Sense_Cmd = exports.signer_guard = exports.launch = exports.Guard_Sense_Binder = exports.MAX_SENSE_COUNT = void 0;
3
+ exports.sense_objects_fn = exports.description_fn = exports.parse_sense_bsc = exports.SenseMaker = exports.QUERIES = exports.everyone_guard = exports.signer_guard = exports.launch = exports.Guard_Sense_Binder = exports.MAX_SENSE_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
6
  const util_1 = require("./util");
@@ -17,7 +17,7 @@ function launch(txb, creation) {
17
17
  return false;
18
18
  let bValid = true;
19
19
  creation.senses.forEach((v) => {
20
- if (v.input.length == 0)
20
+ if (!v.input || v.input.length == 0)
21
21
  bValid = false;
22
22
  });
23
23
  if (!bValid)
@@ -45,16 +45,29 @@ function signer_guard(txb) {
45
45
  txb.moveCall({
46
46
  target: protocol_1.PROTOCOL.GuardFn('signer_guard'),
47
47
  arguments: []
48
- }); // { kind: 'Result', index: 0 }, ref to address could used by PTB
48
+ });
49
49
  return true;
50
50
  }
51
51
  exports.signer_guard = signer_guard;
52
- exports.Sense_Cmd = [[protocol_1.MODULES.permission, 'creator', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
52
+ function everyone_guard(txb) {
53
+ txb.moveCall({
54
+ target: protocol_1.PROTOCOL.GuardFn('everyone_guard'),
55
+ arguments: []
56
+ });
57
+ return true;
58
+ }
59
+ exports.everyone_guard = everyone_guard;
60
+ exports.QUERIES = [
61
+ // module, 'name', 'id', [input], output
62
+ [protocol_1.MODULES.permission, 'builder', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
53
63
  [protocol_1.MODULES.permission, 'is_admin', 2, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
54
64
  [protocol_1.MODULES.permission, 'has_rights', 3, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
55
65
  [protocol_1.MODULES.permission, 'contains_address', 4, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
56
66
  [protocol_1.MODULES.permission, 'contains_index', 5, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
57
67
  [protocol_1.MODULES.permission, 'contains_guard', 6, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
68
+ [protocol_1.MODULES.permission, 'contains_guard', 7, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_address],
69
+ [protocol_1.MODULES.permission, 'entity_count', 8, [], protocol_1.ValueType.TYPE_STATIC_u64],
70
+ [protocol_1.MODULES.permission, 'admin_count', 9, [], protocol_1.ValueType.TYPE_STATIC_u64],
58
71
  [protocol_1.MODULES.repository, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
59
72
  [protocol_1.MODULES.repository, 'policy_contains', 2, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
60
73
  [protocol_1.MODULES.repository, 'policy_has_permission_index', 3, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
@@ -66,6 +79,102 @@ exports.Sense_Cmd = [[protocol_1.MODULES.permission, 'creator', 1, [], protocol_
66
79
  [protocol_1.MODULES.repository, 'value', 9, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_vec_u8],
67
80
  [protocol_1.MODULES.repository, 'type', 10, [], protocol_1.ValueType.TYPE_STATIC_u8],
68
81
  [protocol_1.MODULES.repository, 'policy_mode', 11, [], protocol_1.ValueType.TYPE_STATIC_u8],
82
+ [protocol_1.MODULES.machine, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
83
+ [protocol_1.MODULES.machine, 'has_paused', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
84
+ [protocol_1.MODULES.machine, 'has_published', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
85
+ [protocol_1.MODULES.machine, 'consensus_repositories_contains', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
86
+ [protocol_1.MODULES.machine, 'has_endpoint', 6, [], protocol_1.ValueType.TYPE_STATIC_bool],
87
+ [protocol_1.MODULES.machine, 'endpoint', 7, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
88
+ [protocol_1.MODULES.progress, 'machine', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
89
+ [protocol_1.MODULES.progress, 'current', 2, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
90
+ [protocol_1.MODULES.progress, 'has_parent', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
91
+ [protocol_1.MODULES.progress, 'parent', 4, [], protocol_1.ValueType.TYPE_STATIC_address],
92
+ [protocol_1.MODULES.progress, 'has_task', 5, [], protocol_1.ValueType.TYPE_STATIC_bool],
93
+ [protocol_1.MODULES.progress, 'task', 6, [], protocol_1.ValueType.TYPE_STATIC_address],
94
+ [protocol_1.MODULES.progress, 'has_namedOperator', 7, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
95
+ [protocol_1.MODULES.progress, 'namedOperator_contains', 8, [protocol_1.ValueType.TYPE_STATIC_vec_u8, protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
96
+ [protocol_1.MODULES.progress, 'has_context_repository', 9, [], protocol_1.ValueType.TYPE_STATIC_bool],
97
+ [protocol_1.MODULES.progress, 'context_repository', 10, [], protocol_1.ValueType.TYPE_STATIC_address],
98
+ [protocol_1.MODULES.demand, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
99
+ [protocol_1.MODULES.demand, 'has_time_expire', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
100
+ [protocol_1.MODULES.demand, 'time_expire', 3, [], protocol_1.ValueType.TYPE_STATIC_u64],
101
+ [protocol_1.MODULES.demand, 'earnest_count', 4, [], protocol_1.ValueType.TYPE_STATIC_u64],
102
+ [protocol_1.MODULES.demand, 'has_guard', 5, [], protocol_1.ValueType.TYPE_STATIC_bool],
103
+ [protocol_1.MODULES.demand, 'guard', 6, [], protocol_1.ValueType.TYPE_STATIC_address],
104
+ [protocol_1.MODULES.demand, 'has_yes', 7, [], protocol_1.ValueType.TYPE_STATIC_bool],
105
+ [protocol_1.MODULES.demand, 'yes', 8, [], protocol_1.ValueType.TYPE_STATIC_address],
106
+ [protocol_1.MODULES.demand, 'presenters_count', 9, [], protocol_1.ValueType.TYPE_STATIC_u64],
107
+ [protocol_1.MODULES.demand, 'has_presenter', 10, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
108
+ [protocol_1.MODULES.demand, 'persenter', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_address],
109
+ [protocol_1.MODULES.order, 'amount', 1, [], protocol_1.ValueType.TYPE_STATIC_u64],
110
+ [protocol_1.MODULES.order, 'payer', 2, [], protocol_1.ValueType.TYPE_STATIC_address],
111
+ [protocol_1.MODULES.order, 'service', 3, [], protocol_1.ValueType.TYPE_STATIC_address],
112
+ [protocol_1.MODULES.order, 'has_progress', 4, [], protocol_1.ValueType.TYPE_STATIC_bool],
113
+ [protocol_1.MODULES.order, 'progress', 5, [], protocol_1.ValueType.TYPE_STATIC_address],
114
+ [protocol_1.MODULES.order, 'has_requred_info', 6, [], protocol_1.ValueType.TYPE_STATIC_bool],
115
+ [protocol_1.MODULES.order, 'requred_info_service_pubkey', 7, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
116
+ [protocol_1.MODULES.order, 'requred_info_customer_pubkey', 8, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
117
+ [protocol_1.MODULES.order, 'requred_info_info', 9, [], protocol_1.ValueType.TYPE_STATIC_vec_vec_u8],
118
+ [protocol_1.MODULES.order, 'has_discount', 10, [], protocol_1.ValueType.TYPE_STATIC_bool],
119
+ [protocol_1.MODULES.order, 'discount', 11, [], protocol_1.ValueType.TYPE_STATIC_address],
120
+ [protocol_1.MODULES.order, 'balance', 12, [], protocol_1.ValueType.TYPE_STATIC_u64],
121
+ [protocol_1.MODULES.order, 'bRefunded', 13, [], protocol_1.ValueType.TYPE_STATIC_u8],
122
+ [protocol_1.MODULES.order, 'bWithdrawed', 14, [], protocol_1.ValueType.TYPE_STATIC_u8],
123
+ [protocol_1.MODULES.service, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
124
+ [protocol_1.MODULES.service, 'payee', 2, [], protocol_1.ValueType.TYPE_STATIC_address],
125
+ [protocol_1.MODULES.service, 'has_buy_guard', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
126
+ [protocol_1.MODULES.service, 'buy_guard', 4, [], protocol_1.ValueType.TYPE_STATIC_address],
127
+ [protocol_1.MODULES.service, 'repository_contains', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
128
+ [protocol_1.MODULES.service, 'has_withdraw_guard', 6, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
129
+ [protocol_1.MODULES.service, 'withdraw_guard_percent', 7, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
130
+ [protocol_1.MODULES.service, 'has_refund_guard', 8, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
131
+ [protocol_1.MODULES.service, 'refund_guard_percent', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
132
+ [protocol_1.MODULES.service, 'has_sale', 10, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
133
+ [protocol_1.MODULES.service, 'sale_price', 11, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
134
+ [protocol_1.MODULES.service, 'sale_stock', 12, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
135
+ [protocol_1.MODULES.service, 'has_machine', 13, [], protocol_1.ValueType.TYPE_STATIC_bool],
136
+ [protocol_1.MODULES.service, 'machine', 14, [], protocol_1.ValueType.TYPE_STATIC_address],
137
+ [protocol_1.MODULES.service, 'bPaused', 15, [], protocol_1.ValueType.TYPE_STATIC_bool],
138
+ [protocol_1.MODULES.service, 'bPublished', 16, [], protocol_1.ValueType.TYPE_STATIC_bool],
139
+ [protocol_1.MODULES.service, 'has_required', 17, [], protocol_1.ValueType.TYPE_STATIC_bool],
140
+ [protocol_1.MODULES.service, 'requrired_pubkey', 18, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
141
+ [protocol_1.MODULES.service, 'requrired_info', 19, [], protocol_1.ValueType.TYPE_STATIC_vec_vec_u8],
142
+ [protocol_1.MODULES.reward, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
143
+ [protocol_1.MODULES.reward, 'rewards_count_remain', 2, [], protocol_1.ValueType.TYPE_STATIC_u64],
144
+ [protocol_1.MODULES.reward, 'rewards_count_supplied', 3, [], protocol_1.ValueType.TYPE_STATIC_u64],
145
+ [protocol_1.MODULES.reward, 'guard_count', 4, [], protocol_1.ValueType.TYPE_STATIC_u64],
146
+ [protocol_1.MODULES.reward, 'has_guard', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
147
+ [protocol_1.MODULES.reward, 'guard_portions', 6, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
148
+ [protocol_1.MODULES.reward, 'time_expire', 7, [], protocol_1.ValueType.TYPE_STATIC_u64],
149
+ [protocol_1.MODULES.reward, 'has_claimed', 8, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
150
+ [protocol_1.MODULES.reward, 'claimed', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
151
+ [protocol_1.MODULES.reward, 'has_claimed_count', 10, [], protocol_1.ValueType.TYPE_STATIC_u64],
152
+ [protocol_1.MODULES.reward, 'is_sponsor', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
153
+ [protocol_1.MODULES.reward, 'sponsor', 12, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
154
+ [protocol_1.MODULES.reward, 'sponsor_count', 13, [], protocol_1.ValueType.TYPE_STATIC_u64],
155
+ [protocol_1.MODULES.reward, 'bAllowRepeatClaim', 14, [], protocol_1.ValueType.TYPE_STATIC_bool],
156
+ [protocol_1.MODULES.vote, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
157
+ [protocol_1.MODULES.vote, 'bOptions_locked_for_voting', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
158
+ [protocol_1.MODULES.vote, 'bdeadline_locked', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
159
+ [protocol_1.MODULES.vote, 'bLockedGuard', 4, [], protocol_1.ValueType.TYPE_STATIC_bool],
160
+ [protocol_1.MODULES.vote, 'max_choice_count', 5, [], protocol_1.ValueType.TYPE_STATIC_u8],
161
+ [protocol_1.MODULES.vote, 'deadline', 6, [], protocol_1.ValueType.TYPE_STATIC_u64],
162
+ [protocol_1.MODULES.vote, 'has_reference', 7, [], protocol_1.ValueType.TYPE_STATIC_bool],
163
+ [protocol_1.MODULES.vote, 'reference', 8, [], protocol_1.ValueType.TYPE_STATIC_address],
164
+ [protocol_1.MODULES.vote, 'has_guard', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
165
+ [protocol_1.MODULES.vote, 'guard', 10, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
166
+ [protocol_1.MODULES.vote, 'voted', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
167
+ [protocol_1.MODULES.vote, 'voted_weight', 12, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
168
+ [protocol_1.MODULES.vote, 'has_agree', 13, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
169
+ [protocol_1.MODULES.vote, 'agree_has_object', 14, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
170
+ [protocol_1.MODULES.vote, 'agree_object', 15, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_address],
171
+ [protocol_1.MODULES.vote, 'agree_count', 16, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
172
+ [protocol_1.MODULES.vote, 'agree_votes', 17, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
173
+ [protocol_1.MODULES.vote, 'voted_count', 18, [], protocol_1.ValueType.TYPE_STATIC_u64],
174
+ [protocol_1.MODULES.vote, 'top1_name_by_count', 19, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
175
+ [protocol_1.MODULES.vote, 'top1_count', 20, [], protocol_1.ValueType.TYPE_STATIC_u64],
176
+ [protocol_1.MODULES.vote, 'top1_name_by_votes', 21, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
177
+ [protocol_1.MODULES.vote, 'top1_votes', 22, [], protocol_1.ValueType.TYPE_STATIC_u64],
69
178
  ];
70
179
  class SenseMaker {
71
180
  data = [];
@@ -97,7 +206,7 @@ class SenseMaker {
97
206
  break;
98
207
  case protocol_1.ValueType.TYPE_STATIC_vec_u8:
99
208
  this.data.push(bcs.ser(bcs_1.BCS.U8, type).toBytes());
100
- this.data.push(bcs.ser("vector<u8>", param).toBytes());
209
+ this.data.push(bcs.ser(bcs_1.BCS.STRING, param).toBytes());
101
210
  this.type_validator.push(type);
102
211
  // this.data[this.data.length-1].forEach((item : number) => console.log(item))
103
212
  break;
@@ -119,24 +228,34 @@ class SenseMaker {
119
228
  ;
120
229
  return true;
121
230
  }
122
- add_cmd(object_address, sense_index) {
123
- if (!object_address || sense_index >= exports.Sense_Cmd.length) {
231
+ query_index(module, query_name) {
232
+ for (let i = 0; i < exports.QUERIES.length; i++) {
233
+ if (exports.QUERIES[i][0] == module && exports.QUERIES[i][1] == query_name) {
234
+ return i;
235
+ }
236
+ }
237
+ return -1;
238
+ }
239
+ // query_index: index(from 0) of array QUERIES
240
+ add_query(object_address, module, query_name) {
241
+ let query_index = this.query_index(module, query_name);
242
+ if (!object_address || query_index == -1) {
124
243
  return false;
125
244
  }
126
- let offset = this.type_validator.length - exports.Sense_Cmd[sense_index][3].length;
245
+ let offset = this.type_validator.length - exports.QUERIES[query_index][3].length;
127
246
  if (offset < 0) {
128
247
  return false;
129
248
  }
130
249
  let types = this.type_validator.slice(offset);
131
- if (!(0, util_1.array_equal)(types, exports.Sense_Cmd[sense_index][3])) { // type validate
250
+ if (!(0, util_1.array_equal)(types, exports.QUERIES[query_index][3])) { // type validate
132
251
  return false;
133
252
  }
134
253
  const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
135
254
  this.data.push(bcs.ser(bcs_1.BCS.U8, protocol_1.OperatorType.TYPE_DYNAMIC_QUERY).toBytes()); // TYPE
136
255
  this.data.push(bcs.ser(bcs_1.BCS.ADDRESS, object_address).toBytes()); // object address
137
- this.data.push(bcs.ser(bcs_1.BCS.U8, exports.Sense_Cmd[sense_index][2]).toBytes()); // cmd
138
- this.type_validator.splice(offset, exports.Sense_Cmd[sense_index][3].length); // delete type stack
139
- this.type_validator.push(exports.Sense_Cmd[sense_index][4]); // add the return value type to type stack
256
+ this.data.push(bcs.ser(bcs_1.BCS.U8, exports.QUERIES[query_index][2]).toBytes()); // cmd
257
+ this.type_validator.splice(offset, exports.QUERIES[query_index][3].length); // delete type stack
258
+ this.type_validator.push(exports.QUERIES[query_index][4]); // add the return value type to type stack
140
259
  // console.log(this.type_validator)
141
260
  return true;
142
261
  }
@@ -172,10 +291,11 @@ class SenseMaker {
172
291
  this.type_validator.push(protocol_1.ValueType.TYPE_STATIC_bool); // add bool to type stack
173
292
  return true;
174
293
  }
175
- make(bNotAfterSense, binder) {
294
+ make(bNotAfterSense = false, binder = Guard_Sense_Binder.AND) {
176
295
  //console.log(this.type_validator);
177
296
  //this.data.forEach((value:Uint8Array) => console.log(value));
178
297
  if (this.type_validator.length != 1 || this.type_validator[0] != protocol_1.ValueType.TYPE_STATIC_bool) {
298
+ // console.log(this.type_validator)
179
299
  return false;
180
300
  } // ERROR
181
301
  let input = (0, util_1.concatenate)(Uint8Array, ...this.data);
@@ -185,9 +305,9 @@ class SenseMaker {
185
305
  }
186
306
  exports.SenseMaker = SenseMaker;
187
307
  function match_u128(type) {
188
- if (type == protocol_1.ValueType.TYPE_STATIC_option_u8 ||
189
- type == protocol_1.ValueType.TYPE_STATIC_option_u64 ||
190
- type == protocol_1.ValueType.TYPE_STATIC_option_u128) {
308
+ if (type == protocol_1.ValueType.TYPE_STATIC_u8 ||
309
+ type == protocol_1.ValueType.TYPE_STATIC_u64 ||
310
+ type == protocol_1.ValueType.TYPE_STATIC_u128) {
191
311
  return true;
192
312
  }
193
313
  return false;
package/dist/machine.js CHANGED
@@ -123,7 +123,7 @@ exports.machine_remove_node = machine_remove_node;
123
123
  function machine(txb, permission, description, endpoint, passport) {
124
124
  if (!(0, protocol_1.IsValidObjects)([permission]))
125
125
  return false;
126
- if ((0, protocol_1.IsValidDesription)(description))
126
+ if (!(0, protocol_1.IsValidDesription)(description))
127
127
  return false;
128
128
  if (endpoint && !(0, protocol_1.IsValidEndpoint)(endpoint))
129
129
  return false;
@@ -91,9 +91,11 @@ const IsValidUserDefinedIndex = (index) => {
91
91
  };
92
92
  exports.IsValidUserDefinedIndex = IsValidUserDefinedIndex;
93
93
  const IsValidPermissionIndex = (index) => {
94
+ //console.log(index)
94
95
  if (Object.values(PermissionIndex).includes(index)) {
95
96
  return true;
96
97
  }
98
+ //console.log(Object.keys(PermissionIndex))
97
99
  return (0, exports.IsValidUserDefinedIndex)(index);
98
100
  };
99
101
  exports.IsValidPermissionIndex = IsValidPermissionIndex;
@@ -132,10 +134,14 @@ function add_entity(txb, permission, entities) {
132
134
  return false;
133
135
  let bValid = true;
134
136
  let e = entities.forEach((v) => {
135
- if (!(0, protocol_1.IsValidArray)(v.permissions, exports.IsValidPermissionIndex))
136
- bValid = false;
137
137
  if (!(0, protocol_1.IsValidAddress)(v.entity_address))
138
138
  bValid = false;
139
+ v.permissions.forEach((p) => {
140
+ if (!(0, exports.IsValidPermissionIndex)(p.index))
141
+ bValid = false;
142
+ if (p?.guard && !(0, protocol_1.IsValidObjects)([p.guard]))
143
+ bValid = false;
144
+ });
139
145
  });
140
146
  if (!bValid)
141
147
  return false;
package/dist/protocol.js CHANGED
@@ -17,7 +17,7 @@ const IsValidName = (name) => { return name.length <= exports.MAX_NAME_LENGTH &&
17
17
  exports.IsValidName = IsValidName;
18
18
  const IsValidName_AllowEmpty = (name) => { return name.length <= exports.MAX_NAME_LENGTH; };
19
19
  exports.IsValidName_AllowEmpty = IsValidName_AllowEmpty;
20
- const IsValidEndpoint = (endpoint) => { return endpoint.length <= exports.MAX_DESCRIPTION_LENGTH; };
20
+ const IsValidEndpoint = (endpoint) => { return endpoint.length <= exports.MAX_ENDPOINT_LENGTH; };
21
21
  exports.IsValidEndpoint = IsValidEndpoint;
22
22
  const IsValidAddress = (address) => { return address.length != 0; };
23
23
  exports.IsValidAddress = IsValidAddress;
@@ -138,8 +138,8 @@ class Protocol {
138
138
  case ENTRYPOINT.devnet:
139
139
  break;
140
140
  case ENTRYPOINT.testnet:
141
- this.package = "0x27ab80fa4fed1755508558ed430453ee9aa36f9c9f0982cf8bbe94a5aac8543b";
142
- this.everyone_guard = "0xafc6ddc2509f17afb9b0617aebb38208218cf48cff39cd04ef4a127b1ea3bec0";
141
+ this.package = "0x717b14e0fb287594ce9aed4ee5fb87323469c79d15c1f82c676cf55c338bfb76";
142
+ this.everyone_guard = "0x78a41fcc4f566360839613f6b917fb101ae015e56b43143f496f265b6422fddc";
143
143
  break;
144
144
  case ENTRYPOINT.mainnet:
145
145
  break;
@@ -192,7 +192,7 @@ class Protocol {
192
192
  Sign_Excute = async (exes, priv_key, param, options = { showObjectChanges: true }) => {
193
193
  const client = new client_1.SuiClient({ url: exports.PROTOCOL.NetworkUrl() });
194
194
  const txb = new transactions_1.TransactionBlock();
195
- exes(txb, param);
195
+ exes.forEach((e) => { e(txb, param); });
196
196
  const privkey = (0, bcs_1.fromHEX)(priv_key);
197
197
  const keypair = ed25519_1.Ed25519Keypair.fromSecretKey(privkey);
198
198
  const response = await client.signAndExecuteTransactionBlock({
@@ -13,7 +13,15 @@ const IsValidKey = (key) => {
13
13
  };
14
14
  exports.IsValidKey = IsValidKey;
15
15
  const IsValidValue = (value) => {
16
- return value.length < exports.MAX_VALUE_LENGTH;
16
+ if (typeof (value === 'number')) {
17
+ return (0, protocol_1.IsValidInt)(value);
18
+ }
19
+ else if (typeof (value === 'string')) {
20
+ return value.length < exports.MAX_VALUE_LENGTH;
21
+ }
22
+ else {
23
+ return value.length < exports.MAX_VALUE_LENGTH;
24
+ }
17
25
  };
18
26
  exports.IsValidValue = IsValidValue;
19
27
  var Repository_Policy_Mode;
@@ -60,6 +68,15 @@ function destroy(txb, repository) {
60
68
  return true;
61
69
  }
62
70
  exports.destroy = destroy;
71
+ function to_uint8Array(value) {
72
+ if (typeof (value === 'number')) {
73
+ return (0, util_1.numToUint8Array)(value);
74
+ }
75
+ else if (typeof (value === 'string')) {
76
+ return (0, util_1.stringToUint8Array)(value);
77
+ }
78
+ return value;
79
+ }
63
80
  function add_data(txb, repository, permission, data) {
64
81
  if (!(0, protocol_1.IsValidObjects)([repository, permission]))
65
82
  return false;
@@ -67,9 +84,8 @@ function add_data(txb, repository, permission, data) {
67
84
  return false;
68
85
  let bValid = true;
69
86
  data.data.forEach((value) => {
70
- if (!(0, exports.IsValidValue)(value.value) || !(0, protocol_1.IsValidAddress)(value.address)) {
87
+ if (!(0, protocol_1.IsValidAddress)(value.address) || !(0, exports.IsValidValue)(value.value))
71
88
  bValid = false;
72
- }
73
89
  });
74
90
  if (!bValid)
75
91
  return false;
@@ -80,7 +96,7 @@ function add_data(txb, repository, permission, data) {
80
96
  txb.pure(d.address, bcs_1.BCS.ADDRESS),
81
97
  txb.pure(data.key),
82
98
  txb.pure(data.value_type, bcs_1.BCS.U8),
83
- txb.pure([...d.value], 'vector<u8>'),
99
+ txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
84
100
  (0, protocol_1.TXB_OBJECT)(txb, permission),
85
101
  ],
86
102
  }));
@@ -91,7 +107,7 @@ function add_data(txb, repository, permission, data) {
91
107
  arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
92
108
  txb.pure(d.address, bcs_1.BCS.ADDRESS),
93
109
  txb.pure(data.key),
94
- txb.pure([...d.value], 'vector<u8>'),
110
+ txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
95
111
  (0, protocol_1.TXB_OBJECT)(txb, permission),
96
112
  ],
97
113
  }));
package/dist/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringToUint8Array = exports.objectids_from_response = exports.Object_Type_Extra = exports.BCS_CONVERT = exports.Bcs = exports.parse_object_type = exports.capitalize = exports.array_unique = exports.array_equal = exports.concatenate = exports.ulebDecode = void 0;
3
+ exports.numToUint8Array = exports.stringToUint8Array = exports.objectids_from_response = exports.Object_Type_Extra = exports.BCS_CONVERT = exports.Bcs = exports.parse_object_type = exports.capitalize = exports.array_unique = exports.array_equal = exports.concatenate = exports.ulebDecode = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
6
  function ulebDecode(arr) {
@@ -144,3 +144,12 @@ function stringToUint8Array(str) {
144
144
  return tmpUint8Array;
145
145
  }
146
146
  exports.stringToUint8Array = stringToUint8Array;
147
+ function numToUint8Array(num) {
148
+ let arr = new Uint8Array(8);
149
+ for (let i = 0; i < 8; i++) {
150
+ arr[i] = num % 256;
151
+ num = Math.floor(num / 256);
152
+ }
153
+ return arr;
154
+ }
155
+ exports.numToUint8Array = numToUint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wowok",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "AI-oriented web3 collaboration protocol, driving innovaion and making it more likely to happen.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,13 +9,18 @@
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
- "keywords": [],
13
- "author": "",
12
+ "keywords": [
13
+ "web3",
14
+ "AI",
15
+ "wowok",
16
+ "sui"
17
+ ],
18
+ "author": "wowo",
14
19
  "license": "Apache License",
15
20
  "dependencies": {
16
21
  "@mysten/bcs": "^0.11.1",
17
22
  "@mysten/sui.js": "^0.50.1",
18
- "graphql": "^16.8.1"
23
+ "graphql-tag": "^2.12.6"
19
24
  },
20
25
  "devDependencies": {
21
26
  "tsx": "^4.7.1"
package/src/demand.ts CHANGED
@@ -191,13 +191,13 @@ export function present(earnest_type:string, service_type:string, txb:Transactio
191
191
  if (passport) {
192
192
  txb.moveCall({
193
193
  target:PROTOCOL.DemandFn('present_with_passport') as FnCallType,
194
- arguments:[passport, TXB_OBJECT(txb, demand), TXB_OBJECT(txb, service), txb.pure(tips), ],
194
+ arguments:[passport, TXB_OBJECT(txb, demand), TXB_OBJECT(txb, service), txb.pure(tips, BCS.STRING), ],
195
195
  typeArguments:[earnest_type, service_type],
196
196
  })
197
197
  } else {
198
198
  txb.moveCall({
199
199
  target:PROTOCOL.DemandFn('present') as FnCallType,
200
- arguments:[TXB_OBJECT(txb, demand), TXB_OBJECT(txb, service), txb.pure(tips), ],
200
+ arguments:[TXB_OBJECT(txb, demand), TXB_OBJECT(txb, service), txb.pure(tips, BCS.STRING), ],
201
201
  typeArguments:[earnest_type, service_type],
202
202
  })
203
203
  }
package/src/graphql.ts ADDED
@@ -0,0 +1,103 @@
1
+ import { gql } from "graphql-tag";
2
+
3
+ export const GRAPHQL_OBJECTS_TYPE = gql(`
4
+ query objects_type_version($filter:ObjectFilter!) {
5
+ objects(filter:$filter) {
6
+ nodes {
7
+ address
8
+ version
9
+ asMoveObject {
10
+ contents {
11
+ type {
12
+ repr
13
+ }
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ `);
20
+
21
+ export const GRAPHQL_OBJECT = gql(`
22
+ query object($ObjectID:SuiAddress!) {
23
+ object(address:$ObjectID) {
24
+ address
25
+ asMoveObject {
26
+ contents {
27
+ json
28
+ type {
29
+ repr
30
+ }
31
+ }
32
+ }
33
+ dynamicFields {
34
+ pageInfo {
35
+ hasNextPage
36
+ endCursor
37
+ }
38
+ nodes {
39
+ name {
40
+ json
41
+ }
42
+ value {
43
+ ... on MoveValue {
44
+ json
45
+ }
46
+ ... on MoveObject {
47
+ contents {
48
+ json
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ `);
57
+
58
+ export const GRAPHQL_OWNER = gql(`
59
+ query owner($ObjectID:SuiAddress!) {
60
+ owner (address: $ObjectID) {
61
+ address
62
+ dynamicFields {
63
+ pageInfo {
64
+ hasNextPage
65
+ endCursor
66
+ }
67
+ nodes {
68
+ name {
69
+ json
70
+ }
71
+ value {
72
+ ... on MoveValue {
73
+ json
74
+ }
75
+ ... on MoveObject {
76
+ contents {
77
+ json
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ `);
86
+
87
+ export const GRAPHQL_OBJECTS = gql(`
88
+ query objects($filter:ObjectFilter!){
89
+ objects(filter:$filter) {
90
+ nodes {
91
+ address
92
+ asMoveObject {
93
+ contents {
94
+ json
95
+ type {
96
+ repr
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
103
+ `);