wowok 1.0.5 → 1.0.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.
package/dist/passport.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.query_cmd_fn = exports.destroy = exports.verify = exports.passport_queries = exports.MAX_GUARD_COUNT = void 0;
3
+ exports.graphql_query_objects = exports.rpc_query_cmd_fn = exports.destroy = exports.add_context_address = exports.verify = exports.passport_queries = exports.MAX_GUARD_COUNT = void 0;
4
4
  const transactions_1 = require("@mysten/sui.js/transactions");
5
5
  const protocol_1 = require("./protocol");
6
- const util_1 = require("./util");
6
+ const utils_1 = require("./utils");
7
7
  const guard_1 = require("./guard");
8
+ const bcs_1 = require("@mysten/bcs");
8
9
  exports.MAX_GUARD_COUNT = 8;
9
10
  // passport verify for some guards, MUST be in ONE pxb:
10
11
  // 0. construct Guard_Query_Objects(passport_quries) from queries for guards of objects
@@ -16,50 +17,62 @@ exports.MAX_GUARD_COUNT = 8;
16
17
  // 6. destroy passport
17
18
  const passport_queries = async (guards) => {
18
19
  let sense_objects = guards.map((value) => {
19
- return { objectid: value, callback: guard_1.sense_objects_fn, data: [] };
20
+ return { objectid: value, callback: guard_1.rpc_sense_objects_fn, data: [] };
20
21
  });
21
22
  await protocol_1.PROTOCOL.Query(sense_objects); // objects need quering in guards
22
23
  let sense_objects_result = [];
23
24
  sense_objects.forEach((value) => {
24
25
  sense_objects_result = sense_objects_result.concat(value.data);
25
26
  });
26
- sense_objects_result = (0, util_1.array_unique)(sense_objects_result);
27
- console.log(sense_objects_result);
27
+ sense_objects_result = (0, utils_1.array_unique)(sense_objects_result); // objects in guards
28
+ // console.log(sense_objects_result);
28
29
  let queries = sense_objects_result.map((value) => {
29
- return { objectid: value, callback: exports.query_cmd_fn };
30
+ return { objectid: value, callback: exports.rpc_query_cmd_fn, data: [] };
30
31
  });
31
32
  await protocol_1.PROTOCOL.Query(queries, { 'showType': true }); // queries for passport verifing
32
- return queries.map((value) => {
33
- return value.data;
33
+ let res = [];
34
+ sense_objects.forEach((guard) => {
35
+ res = res.concat(guard.data.map((object) => {
36
+ let data = queries.filter((v) => {
37
+ return v.objectid == object;
38
+ });
39
+ if (!data) {
40
+ console.error('error find data');
41
+ console.log(queries);
42
+ console.log(object);
43
+ return;
44
+ }
45
+ return data[0].data;
46
+ }));
34
47
  });
48
+ return res;
35
49
  };
36
50
  exports.passport_queries = passport_queries;
37
- // return passport object for using
38
- function verify(txb, passport_queries) {
39
- if (passport_queries.length == 0 || passport_queries.length > exports.MAX_GUARD_COUNT) {
51
+ // return passport object used
52
+ function verify(txb, guards, passport_queries) {
53
+ if (!guards || passport_queries.length == 0 || passport_queries.length > exports.MAX_GUARD_COUNT) {
40
54
  return false;
41
55
  }
42
- let guard_ids = passport_queries.map((value) => value.id);
43
56
  var passport = txb.moveCall({
44
57
  target: protocol_1.PROTOCOL.PassportFn('new'),
45
- arguments: [txb.object(guard_ids[0]), txb.object(protocol_1.CLOCK_OBJECT)]
58
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, guards[0])]
46
59
  });
47
60
  // add others guards, if any
48
- for (let i = 1; i < guard_ids.length; i++) {
61
+ for (let i = 1; i < guards.length; i++) {
49
62
  txb.moveCall({
50
63
  target: protocol_1.PROTOCOL.PassportFn('guard_add'),
51
- arguments: [passport, txb.object(guard_ids[i])]
64
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, guards[i])]
52
65
  });
53
66
  }
54
67
  // rules: 'verify' & 'query' in turns;'verify' at final end.
55
68
  for (let i = 0; i < passport_queries.length; i++) {
56
- txb.moveCall({
69
+ let res = txb.moveCall({
57
70
  target: protocol_1.PROTOCOL.PassportFn('passport_verify'),
58
- arguments: [passport]
71
+ arguments: [passport, txb.object(protocol_1.CLOCK_OBJECT),]
59
72
  });
60
73
  txb.moveCall({
61
74
  target: passport_queries[i].target,
62
- arguments: [txb.object(passport_queries[i].object), passport],
75
+ arguments: [txb.object(passport_queries[i].object), passport, res],
63
76
  typeArguments: passport_queries[i].types,
64
77
  });
65
78
  }
@@ -70,6 +83,16 @@ function verify(txb, passport_queries) {
70
83
  return passport;
71
84
  }
72
85
  exports.verify = verify;
86
+ function add_context_address(txb, passport, type, value, witness) {
87
+ if (!(0, protocol_1.IsValidAddress)(value) || !(0, protocol_1.IsValidAddress)(witness))
88
+ return false;
89
+ txb.moveCall({
90
+ target: protocol_1.PROTOCOL.PassportFn('context_add_address'),
91
+ arguments: [passport, txb.pure(type, bcs_1.BCS.U8), txb.pure(value, bcs_1.BCS.ADDRESS), txb.pure(witness, bcs_1.BCS.ADDRESS)]
92
+ });
93
+ return true;
94
+ }
95
+ exports.add_context_address = add_context_address;
73
96
  function destroy(txb, passport) {
74
97
  txb.moveCall({
75
98
  target: protocol_1.PROTOCOL.PassportFn('destroy'),
@@ -79,20 +102,39 @@ function destroy(txb, passport) {
79
102
  }
80
103
  exports.destroy = destroy;
81
104
  // construct Guard_Query_Object of wowok objects for passport verify
82
- const query_cmd_fn = (response, param, option) => {
105
+ const rpc_query_cmd_fn = (response, param, option) => {
83
106
  if (!response.error && response.data?.objectId == param.objectid && response.data?.type) {
84
- for (let k = 0; k < protocol_1.OBJECTS_TYPE.length; k++) {
85
- if (response?.data?.type.includes(protocol_1.OBJECTS_TYPE[k])) { // type: pack::m::Object<...>
86
- param.data = { target: protocol_1.OBJECTS_TYPE_PREFIX[k] + 'guard_query',
107
+ for (let k = 0; k < (0, protocol_1.OBJECTS_TYPE)().length; k++) {
108
+ if (response?.data?.type.includes((0, protocol_1.OBJECTS_TYPE)()[k])) { // type: pack::m::Object<...>
109
+ param.data = { target: (0, protocol_1.OBJECTS_TYPE_PREFIX)()[k] + 'guard_query',
87
110
  object: transactions_1.Inputs.SharedObjectRef({
88
- objectId: param.objectid,
111
+ objectId: response.data.objectId,
89
112
  mutable: false,
90
113
  initialSharedVersion: response.data.version,
91
114
  }),
92
- types: (0, util_1.parse_object_type)(response?.data?.type),
115
+ types: (0, utils_1.parse_object_type)(response?.data?.type),
93
116
  id: param.objectid, };
94
117
  }
95
118
  }
96
119
  }
97
120
  };
98
- exports.query_cmd_fn = query_cmd_fn;
121
+ exports.rpc_query_cmd_fn = rpc_query_cmd_fn;
122
+ const graphql_query_objects = (nodes) => {
123
+ let ret = [];
124
+ nodes.forEach((node) => {
125
+ for (let k = 0; k < (0, protocol_1.OBJECTS_TYPE)().length; k++) {
126
+ if (node?.asMoveObject?.contents?.type?.repr?.includes((0, protocol_1.OBJECTS_TYPE)()[k])) { // type: pack::m::Object<...>
127
+ ret.push({ target: (0, protocol_1.OBJECTS_TYPE_PREFIX)()[k] + 'guard_query',
128
+ object: transactions_1.Inputs.SharedObjectRef({
129
+ objectId: node.address,
130
+ mutable: false,
131
+ initialSharedVersion: node.version,
132
+ }),
133
+ types: (0, utils_1.parse_object_type)(node.asMoveObject.contents.type.repr),
134
+ id: node.address, });
135
+ }
136
+ }
137
+ });
138
+ return ret;
139
+ };
140
+ exports.graphql_query_objects = graphql_query_objects;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.change_owner = exports.remove_admin = exports.add_admin = exports.set_description = exports.remove_entity = exports.remove_index = exports.set_guard = exports.add_entity = exports.destroy = exports.launch = exports.permission = exports.IsValidPermissionIndex = exports.IsValidUserDefinedIndex = exports.PermissionIndex = exports.MAX_PERMISSION_INDEX_COUNT = exports.MAX_ENTITY_COUNT = exports.MAX_ADMIN_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
- const util_1 = require("./util");
6
+ const utils_1 = require("./utils");
7
7
  exports.MAX_ADMIN_COUNT = 64;
8
8
  exports.MAX_ENTITY_COUNT = 2000;
9
9
  exports.MAX_PERMISSION_INDEX_COUNT = 200;
@@ -208,7 +208,7 @@ function remove_index(txb, permission, entity_address, index) {
208
208
  return false;
209
209
  txb.moveCall({
210
210
  target: protocol_1.PROTOCOL.PermissionFn('remove_index'),
211
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(entity_address, bcs_1.BCS.ADDRESS), txb.pure((0, util_1.array_unique)(index), 'vector<u64>')]
211
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(entity_address, bcs_1.BCS.ADDRESS), txb.pure((0, utils_1.array_unique)(index), 'vector<u64>')]
212
212
  });
213
213
  return true;
214
214
  }
@@ -220,7 +220,7 @@ function remove_entity(txb, permission, entity_address) {
220
220
  return false;
221
221
  txb.moveCall({
222
222
  target: protocol_1.PROTOCOL.PermissionFn('remove'),
223
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, util_1.array_unique)(entity_address), 'vector<address>')]
223
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, utils_1.array_unique)(entity_address), 'vector<address>')]
224
224
  });
225
225
  return true;
226
226
  }
@@ -244,7 +244,7 @@ function add_admin(txb, permission, admin) {
244
244
  return false;
245
245
  txb.moveCall({
246
246
  target: protocol_1.PROTOCOL.PermissionFn('admin_add_batch'),
247
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, util_1.array_unique)(admin), 'vector<address>')]
247
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, utils_1.array_unique)(admin), 'vector<address>')]
248
248
  });
249
249
  return true;
250
250
  }
@@ -265,7 +265,7 @@ function remove_admin(txb, permission, admin, removeall) {
265
265
  else if (admin) {
266
266
  txb.moveCall({
267
267
  target: protocol_1.PROTOCOL.PermissionFn('admin_remove_batch'),
268
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, util_1.array_unique)(admin), 'vector<address>')]
268
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure((0, utils_1.array_unique)(admin), 'vector<address>')]
269
269
  });
270
270
  }
271
271
  return true;
package/dist/progress.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hold = exports.next = exports.progress_unhold = exports.progress_set_context_repository = exports.progress_bind_task = exports.progress_set_namedOperator = exports.destroy = exports.launch_as_child = exports.launch = exports.progress = exports.MAX_NAMED_OPERATOR_COUNT = void 0;
3
+ exports.hold = exports.next = exports.progress_parent = exports.progress_unhold = exports.progress_set_context_repository = exports.progress_bind_task = exports.progress_set_namedOperator = exports.destroy = exports.launch_as_child = exports.launch = exports.progress = exports.MAX_NAMED_OPERATOR_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
- const util_1 = require("./util");
6
+ const utils_1 = require("./utils");
7
7
  exports.MAX_NAMED_OPERATOR_COUNT = 100;
8
8
  function progress(txb, machine, permission, passport) {
9
9
  if (!(0, protocol_1.IsValidObjects)([machine, permission]))
@@ -64,14 +64,14 @@ function progress_set_namedOperator(txb, machine, permission, progress, name, ad
64
64
  if (passport) {
65
65
  txb.moveCall({
66
66
  target: protocol_1.PROTOCOL.ProgressFn('namedOperator_set_with_passport'),
67
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), txb.pure(name), txb.pure((0, util_1.array_unique)(addresses), 'vector<address>'),
67
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), txb.pure(name), txb.pure((0, utils_1.array_unique)(addresses), 'vector<address>'),
68
68
  (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
69
69
  });
70
70
  }
71
71
  else {
72
72
  txb.moveCall({
73
73
  target: protocol_1.PROTOCOL.ProgressFn('namedOperator_set'),
74
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), txb.pure(name), txb.pure((0, util_1.array_unique)(addresses), 'vector<address>'),
74
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), txb.pure(name), txb.pure((0, utils_1.array_unique)(addresses), 'vector<address>'),
75
75
  (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
76
76
  });
77
77
  }
@@ -132,41 +132,90 @@ function progress_set_context_repository(txb, machine, permission, progress, rep
132
132
  return true;
133
133
  }
134
134
  exports.progress_set_context_repository = progress_set_context_repository;
135
- function progress_unhold(txb, machine, permission, progress, next) {
135
+ function progress_unhold(txb, machine, permission, progress, next, passport) {
136
136
  if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
137
137
  return false;
138
138
  if (!IsValidProgressNext(next))
139
139
  return false;
140
- txb.moveCall({
141
- target: protocol_1.PROTOCOL.ProgressFn('unhold'),
142
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
143
- });
140
+ if (passport) {
141
+ txb.moveCall({
142
+ target: protocol_1.PROTOCOL.ProgressFn('unhold_with_passport'),
143
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
144
+ });
145
+ }
146
+ else {
147
+ txb.moveCall({
148
+ target: protocol_1.PROTOCOL.ProgressFn('unhold'),
149
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
150
+ });
151
+ }
144
152
  return true;
145
153
  }
146
154
  exports.progress_unhold = progress_unhold;
155
+ function progress_parent(txb, machine, permission, progress, parent_progress, passport) {
156
+ if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
157
+ return false;
158
+ if (parent_progress && (!(0, protocol_1.IsValidAddress)(parent_progress.parent_progress_id) || !(0, protocol_1.IsValidInt)(parent_progress.parent_session_id)))
159
+ return false;
160
+ if (passport) {
161
+ if (parent_progress) {
162
+ txb.moveCall({
163
+ target: protocol_1.PROTOCOL.ProgressFn('parent_set_with_passport'),
164
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(parent_progress.parent_progress_id, bcs_1.BCS.ADDRESS),
165
+ txb.pure(parent_progress.parent_session_id, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
166
+ });
167
+ }
168
+ else {
169
+ txb.moveCall({
170
+ target: protocol_1.PROTOCOL.ProgressFn('parent_none_with_passport'),
171
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
172
+ });
173
+ }
174
+ }
175
+ else {
176
+ if (parent_progress) {
177
+ txb.moveCall({
178
+ target: protocol_1.PROTOCOL.ProgressFn('parent_set'),
179
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(parent_progress.parent_progress_id, bcs_1.BCS.ADDRESS),
180
+ txb.pure(parent_progress.parent_session_id, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
181
+ });
182
+ }
183
+ else {
184
+ txb.moveCall({
185
+ target: protocol_1.PROTOCOL.ProgressFn('parent_none'),
186
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
187
+ });
188
+ }
189
+ }
190
+ return true;
191
+ }
192
+ exports.progress_parent = progress_parent;
147
193
  function IsValidProgressNext(next) {
148
194
  return (0, protocol_1.IsValidName)(next.forward) && (0, protocol_1.IsValidName)(next.next_node_name);
149
195
  }
150
- function next(txb, machine, permission, progress, next, deliverables_address, passport) {
196
+ function next(txb, machine, permission, progress, next, deliverables_address, sub_progress_id, passport) {
151
197
  if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
152
198
  return false;
153
199
  if (!IsValidProgressNext(next))
154
200
  return false;
155
201
  if (deliverables_address && !(0, protocol_1.IsValidAddress)(deliverables_address))
156
202
  return false;
157
- let diliverable = deliverables_address ? txb.pure(util_1.BCS_CONVERT.ser_option_address(deliverables_address)) : (0, protocol_1.OptionNone)(txb);
203
+ if (sub_progress_id && !(0, protocol_1.IsValidAddress)(sub_progress_id))
204
+ return false;
205
+ let diliverable = deliverables_address ? txb.pure(utils_1.BCS_CONVERT.ser_option_address(deliverables_address)) : (0, protocol_1.OptionNone)(txb);
206
+ let sub = sub_progress_id ? txb.pure(utils_1.BCS_CONVERT.ser_option_address(sub_progress_id)) : (0, protocol_1.OptionNone)(txb);
158
207
  if (passport) {
159
208
  txb.moveCall({
160
- target: protocol_1.PROTOCOL.ProgressFn('run_with_passport'),
161
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name),
162
- txb.pure(next.forward), diliverable, (0, protocol_1.TXB_OBJECT)(txb, permission)],
209
+ target: protocol_1.PROTOCOL.ProgressFn('next_with_passport'),
210
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name, bcs_1.BCS.STRING),
211
+ txb.pure(next.forward, bcs_1.BCS.STRING), diliverable, sub, (0, protocol_1.TXB_OBJECT)(txb, permission)],
163
212
  });
164
213
  }
165
214
  else {
166
215
  txb.moveCall({
167
- target: protocol_1.PROTOCOL.ProgressFn('run'),
168
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name),
169
- txb.pure(next.forward), diliverable, (0, protocol_1.TXB_OBJECT)(txb, permission)],
216
+ target: protocol_1.PROTOCOL.ProgressFn('next'),
217
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name, bcs_1.BCS.STRING),
218
+ txb.pure(next.forward, bcs_1.BCS.STRING), diliverable, sub, (0, protocol_1.TXB_OBJECT)(txb, permission)],
170
219
  });
171
220
  }
172
221
  return true;
package/dist/protocol.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.PROTOCOL = exports.Protocol = exports.ENTRYPOINT = exports.ContextType = exports.OperatorType = exports.ValueType = exports.CLOCK_OBJECT = exports.TXB_OBJECT = exports.MODULES = exports.IsValidObjects = exports.IsValidArray = exports.IsValidPercent = exports.IsValidInt = exports.IsValidUint = exports.IsValidArgType = exports.IsValidAddress = exports.IsValidEndpoint = exports.IsValidName_AllowEmpty = exports.IsValidName = exports.IsValidDesription = exports.OptionNone = exports.MAX_ENDPOINT_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_DESCRIPTION_LENGTH = void 0;
3
+ exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.WOWOK_TYPE = exports.SUI_TYPE = exports.PROTOCOL = exports.Protocol = exports.ENTRYPOINT = exports.ContextType = exports.OperatorType = exports.ValueType = exports.CLOCK_OBJECT = exports.TXB_OBJECT = exports.MODULES = exports.IsValidObjects = exports.IsValidArray = exports.IsValidPercent = exports.IsValidInt = exports.IsValidUint = exports.IsValidArgType = exports.IsValidAddress = exports.IsValidEndpoint = exports.IsValidName_AllowEmpty = exports.IsValidName = exports.IsValidDesription = exports.OptionNone = exports.MAX_ENDPOINT_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_DESCRIPTION_LENGTH = void 0;
4
4
  const client_1 = require("@mysten/sui.js/client");
5
5
  const ed25519_1 = require("@mysten/sui.js/keypairs/ed25519");
6
6
  const bcs_1 = require("@mysten/bcs");
7
7
  const transactions_1 = require("@mysten/sui.js/transactions");
8
- const util_1 = require("./util");
8
+ const utils_1 = require("./utils");
9
9
  exports.MAX_DESCRIPTION_LENGTH = 1024;
10
10
  exports.MAX_NAME_LENGTH = 64;
11
11
  exports.MAX_ENDPOINT_LENGTH = 1024;
@@ -97,6 +97,8 @@ var ValueType;
97
97
  var OperatorType;
98
98
  (function (OperatorType) {
99
99
  OperatorType[OperatorType["TYPE_DYNAMIC_QUERY"] = 1] = "TYPE_DYNAMIC_QUERY";
100
+ OperatorType[OperatorType["TYPE_FUTURE_ORDER_DYNAMIC_QUERY"] = 2] = "TYPE_FUTURE_ORDER_DYNAMIC_QUERY";
101
+ OperatorType[OperatorType["TYPE_FUTURE_PROGRESS_DYNAMIC_QUERY"] = 3] = "TYPE_FUTURE_PROGRESS_DYNAMIC_QUERY";
100
102
  OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_GREATER"] = 11] = "TYPE_LOGIC_OPERATOR_U128_GREATER";
101
103
  OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL"] = 12] = "TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL";
102
104
  OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_LESSER"] = 13] = "TYPE_LOGIC_OPERATOR_U128_LESSER";
@@ -109,8 +111,8 @@ var OperatorType;
109
111
  var ContextType;
110
112
  (function (ContextType) {
111
113
  ContextType[ContextType["TYPE_CONTEXT_SIGNER"] = 60] = "TYPE_CONTEXT_SIGNER";
112
- ContextType[ContextType["TYPE_CONTEXT_CURRENT_PROGRESS"] = 61] = "TYPE_CONTEXT_CURRENT_PROGRESS";
113
- ContextType[ContextType["TYPE_CONTEXT_CURRENT_CLOCK"] = 62] = "TYPE_CONTEXT_CURRENT_CLOCK";
114
+ ContextType[ContextType["TYPE_CONTEXT_CLOCK"] = 61] = "TYPE_CONTEXT_CLOCK";
115
+ ContextType[ContextType["TYPE_CONTEXT_FUTURE_ID"] = 62] = "TYPE_CONTEXT_FUTURE_ID";
114
116
  })(ContextType || (exports.ContextType = ContextType = {}));
115
117
  var ENTRYPOINT;
116
118
  (function (ENTRYPOINT) {
@@ -124,6 +126,7 @@ class Protocol {
124
126
  package = '';
125
127
  signer = '';
126
128
  everyone_guard = '';
129
+ graphql = '';
127
130
  constructor(network = ENTRYPOINT.localnet, signer = "0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f") {
128
131
  this.signer = signer;
129
132
  this.UseNetwork(network);
@@ -138,8 +141,9 @@ class Protocol {
138
141
  case ENTRYPOINT.devnet:
139
142
  break;
140
143
  case ENTRYPOINT.testnet:
141
- this.package = "0x717b14e0fb287594ce9aed4ee5fb87323469c79d15c1f82c676cf55c338bfb76";
144
+ this.package = "0x82b70ca54720b7e22d82b6c8c9a1601a228ccdb2a8bd70804a690ca8ea59777f";
142
145
  this.everyone_guard = "0x78a41fcc4f566360839613f6b917fb101ae015e56b43143f496f265b6422fddc";
146
+ this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
143
147
  break;
144
148
  case ENTRYPOINT.mainnet:
145
149
  break;
@@ -148,6 +152,7 @@ class Protocol {
148
152
  }
149
153
  Package() { return this.package; }
150
154
  EveryoneGuard() { return this.everyone_guard; }
155
+ GraphqlUrl() { return this.graphql; }
151
156
  NetworkUrl() {
152
157
  switch (this.network) {
153
158
  case ENTRYPOINT.localnet:
@@ -205,5 +210,10 @@ class Protocol {
205
210
  }
206
211
  exports.Protocol = Protocol;
207
212
  exports.PROTOCOL = new Protocol();
208
- exports.OBJECTS_TYPE_PREFIX = Object.keys(MODULES).map((key) => { return exports.PROTOCOL.Package() + '::' + key + '::'; });
209
- exports.OBJECTS_TYPE = Object.keys(MODULES).map((key) => { let i = exports.PROTOCOL.Package() + '::' + key + '::'; return i + (0, util_1.capitalize)(key); });
213
+ exports.SUI_TYPE = '0x2::coin::Coin<0x2::sui::SUI>';
214
+ const WOWOK_TYPE = () => { '0x2::coin::Coin<' + exports.PROTOCOL.Package() + '::wowok::WOWOK'; };
215
+ exports.WOWOK_TYPE = WOWOK_TYPE;
216
+ const OBJECTS_TYPE_PREFIX = () => Object.keys(MODULES).map((key) => { return exports.PROTOCOL.Package() + '::' + key + '::'; });
217
+ exports.OBJECTS_TYPE_PREFIX = OBJECTS_TYPE_PREFIX;
218
+ const OBJECTS_TYPE = () => Object.keys(MODULES).map((key) => { let i = exports.PROTOCOL.Package() + '::' + key + '::'; return i + (0, utils_1.capitalize)(key); });
219
+ exports.OBJECTS_TYPE = OBJECTS_TYPE;
@@ -4,7 +4,7 @@ exports.change_permission = exports.repository_set_policy_permission = exports.r
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
6
  const permission_1 = require("./permission");
7
- const util_1 = require("./util");
7
+ const utils_1 = require("./utils");
8
8
  exports.MAX_POLICY_COUNT = 1000;
9
9
  exports.MAX_KEY_LENGTH = 128;
10
10
  exports.MAX_VALUE_LENGTH = 204800;
@@ -13,15 +13,7 @@ const IsValidKey = (key) => {
13
13
  };
14
14
  exports.IsValidKey = IsValidKey;
15
15
  const IsValidValue = (value) => {
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
- }
16
+ return value.length < exports.MAX_VALUE_LENGTH;
25
17
  };
26
18
  exports.IsValidValue = IsValidValue;
27
19
  var Repository_Policy_Mode;
@@ -68,15 +60,6 @@ function destroy(txb, repository) {
68
60
  return true;
69
61
  }
70
62
  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
- }
80
63
  function add_data(txb, repository, permission, data) {
81
64
  if (!(0, protocol_1.IsValidObjects)([repository, permission]))
82
65
  return false;
@@ -84,7 +67,9 @@ function add_data(txb, repository, permission, data) {
84
67
  return false;
85
68
  let bValid = true;
86
69
  data.data.forEach((value) => {
87
- if (!(0, protocol_1.IsValidAddress)(value.address) || !(0, exports.IsValidValue)(value.value))
70
+ if (!(0, protocol_1.IsValidAddress)(value.address))
71
+ bValid = false;
72
+ if (!(0, exports.IsValidValue)(value.bcsBytes))
88
73
  bValid = false;
89
74
  });
90
75
  if (!bValid)
@@ -96,7 +81,7 @@ function add_data(txb, repository, permission, data) {
96
81
  txb.pure(d.address, bcs_1.BCS.ADDRESS),
97
82
  txb.pure(data.key),
98
83
  txb.pure(data.value_type, bcs_1.BCS.U8),
99
- txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
84
+ txb.pure([...d.bcsBytes], 'vector<u8>'),
100
85
  (0, protocol_1.TXB_OBJECT)(txb, permission),
101
86
  ],
102
87
  }));
@@ -107,7 +92,7 @@ function add_data(txb, repository, permission, data) {
107
92
  arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
108
93
  txb.pure(d.address, bcs_1.BCS.ADDRESS),
109
94
  txb.pure(data.key),
110
- txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
95
+ txb.pure([...d.bcsBytes], 'vector<u8>'),
111
96
  (0, protocol_1.TXB_OBJECT)(txb, permission),
112
97
  ],
113
98
  }));
@@ -146,7 +131,7 @@ function repository_add_policies(txb, repository, permission, policies, passport
146
131
  if (!bValid)
147
132
  return false;
148
133
  policies.forEach((policy) => {
149
- let permission_index = policy?.permission ? txb.pure(util_1.BCS_CONVERT.ser_option_u64(policy.permission)) : txb.pure([0], bcs_1.BCS.U8);
134
+ let permission_index = policy?.permission ? txb.pure(utils_1.BCS_CONVERT.ser_option_u64(policy.permission)) : txb.pure([0], bcs_1.BCS.U8);
150
135
  if (passport) {
151
136
  txb.moveCall({
152
137
  target: protocol_1.PROTOCOL.RepositoryFn('policy_add_with_passport'),
@@ -186,11 +171,9 @@ function repository_remove_policies(txb, repository, permission, policy_keys, re
186
171
  });
187
172
  }
188
173
  else {
189
- (0, util_1.array_unique)(policy_keys).forEach((key) => {
190
- txb.moveCall({
191
- target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
192
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure((0, util_1.array_unique)(key)), (0, protocol_1.TXB_OBJECT)(txb, permission)]
193
- });
174
+ txb.moveCall({
175
+ target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
176
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(utils_1.BCS_CONVERT.ser_vector_string((0, utils_1.array_unique)(policy_keys))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
194
177
  });
195
178
  }
196
179
  }
@@ -202,11 +185,9 @@ function repository_remove_policies(txb, repository, permission, policy_keys, re
202
185
  });
203
186
  }
204
187
  else {
205
- policy_keys.forEach((key) => {
206
- txb.moveCall({
207
- target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
208
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(key), (0, protocol_1.TXB_OBJECT)(txb, permission)]
209
- });
188
+ txb.moveCall({
189
+ target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
190
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(utils_1.BCS_CONVERT.ser_vector_string((0, utils_1.array_unique)(policy_keys))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
210
191
  });
211
192
  }
212
193
  }
@@ -281,7 +262,7 @@ function repository_set_policy_permission(txb, repository, permission, policy, p
281
262
  if (permission_index) {
282
263
  if (!(0, permission_1.IsValidPermissionIndex)(permission_index))
283
264
  return false;
284
- index = txb.pure(util_1.BCS_CONVERT.ser_option_u64(permission_index));
265
+ index = txb.pure(utils_1.BCS_CONVERT.ser_option_u64(permission_index));
285
266
  }
286
267
  if (passport) {
287
268
  txb.moveCall({
package/dist/reward.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.change_permission = exports.deposit = exports.claim = exports.reward_lock_guards = exports.reward_set_description = exports.allow_repeat_claim = exports.reward_remove_guard = exports.reward_add_guard = exports.reward_expand_time = exports.reward_refund = exports.destroy = exports.launch = exports.reward = void 0;
3
+ exports.change_permission = exports.deposit = exports.claim = exports.reward_lock_guards = exports.reward_set_description = exports.allow_repeat_claim = exports.reward_remove_guard = exports.reward_add_guard = exports.reward_expand_time = exports.reward_refund = exports.destroy = exports.launch = exports.reward = exports.MAX_PORTIONS_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
- const util_1 = require("./util");
6
+ const utils_1 = require("./utils");
7
+ exports.MAX_PORTIONS_COUNT = 255;
7
8
  function reward(reward_type, txb, permission, description, minutes_duration, passport) {
8
9
  if (!(0, protocol_1.IsValidObjects)([permission]))
9
10
  return false;
@@ -110,7 +111,7 @@ function reward_add_guard(reward_type, txb, reward, permission, gurads, passport
110
111
  return false;
111
112
  let bValid = true;
112
113
  gurads.forEach((v) => {
113
- if (!(0, protocol_1.IsValidUint)(v.portions))
114
+ if (!(0, protocol_1.IsValidUint)(v.portions) || v.portions > exports.MAX_PORTIONS_COUNT)
114
115
  bValid = false;
115
116
  if (!(0, protocol_1.IsValidObjects)([v.guard]))
116
117
  bValid = false;
@@ -120,14 +121,14 @@ function reward_add_guard(reward_type, txb, reward, permission, gurads, passport
120
121
  if (passport) {
121
122
  gurads.forEach((guard) => txb.moveCall({
122
123
  target: protocol_1.PROTOCOL.RewardFn('guard_add_with_passport'),
123
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
124
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
124
125
  typeArguments: [reward_type]
125
126
  }));
126
127
  }
127
128
  else {
128
129
  gurads.forEach((guard) => txb.moveCall({
129
130
  target: protocol_1.PROTOCOL.RewardFn('guard_add'),
130
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
131
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
131
132
  typeArguments: [reward_type]
132
133
  }));
133
134
  }
@@ -154,7 +155,7 @@ function reward_remove_guard(reward_type, txb, reward, permission, guards, remov
154
155
  else {
155
156
  txb.moveCall({
156
157
  target: protocol_1.PROTOCOL.RewardFn('guard_remove_with_passport'),
157
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure((0, util_1.array_unique)(guards), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
158
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure((0, utils_1.array_unique)(guards), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
158
159
  typeArguments: [reward_type]
159
160
  });
160
161
  }
@@ -192,7 +193,7 @@ function allow_repeat_claim(reward_type, txb, reward, permission, allow_repeat_c
192
193
  }
193
194
  else {
194
195
  txb.moveCall({
195
- target: protocol_1.PROTOCOL.RewardFn('allow_repeat_claim_with_passport'),
196
+ target: protocol_1.PROTOCOL.RewardFn('allow_repeat_claim'),
196
197
  arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(allow_repeat_claim, bcs_1.BCS.BOOL)],
197
198
  typeArguments: [reward_type]
198
199
  });
@@ -277,7 +278,7 @@ function deposit(reward_type, txb, reward, rewards) {
277
278
  return false;
278
279
  txb.moveCall({
279
280
  target: protocol_1.PROTOCOL.RewardFn('deposit'),
280
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.makeMoveVec({ objects: (0, util_1.array_unique)(rewards) })],
281
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.makeMoveVec({ objects: (0, utils_1.array_unique)(rewards) })],
281
282
  typeArguments: [reward_type]
282
283
  });
283
284
  return true;