wowok 1.0.3 → 1.0.4

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/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.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) {
@@ -84,9 +84,15 @@ class Bcs {
84
84
  ser_option_u64(data) {
85
85
  return this.bcs.ser('Option<u64>', { 'some': data }).toBytes();
86
86
  }
87
+ ser_option_address(data) {
88
+ return this.bcs.ser('Option<address>', { 'some': data }).toBytes();
89
+ }
87
90
  ser_vector_string(data) {
88
91
  return this.bcs.ser('vector<string>', data).toBytes();
89
92
  }
93
+ ser_vector_vector_u8(data) {
94
+ return this.bcs.ser('vector<vector<u8>>', data).toBytes();
95
+ }
90
96
  ser_vector_u64(data) {
91
97
  return this.bcs.ser('vector<u64>', data).toBytes();
92
98
  }
@@ -129,3 +135,12 @@ const objectids_from_response = (response, concat_result) => {
129
135
  return ret;
130
136
  };
131
137
  exports.objectids_from_response = objectids_from_response;
138
+ function stringToUint8Array(str) {
139
+ var arr = [];
140
+ for (var i = 0, j = str.length; i < j; ++i) {
141
+ arr.push(str.charCodeAt(i));
142
+ }
143
+ var tmpUint8Array = new Uint8Array(arr);
144
+ return tmpUint8Array;
145
+ }
146
+ exports.stringToUint8Array = stringToUint8Array;
package/dist/vote.js CHANGED
@@ -1,104 +1,140 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.change_permission = exports.agree = exports.vote_lock_guard = exports.vote_expand_deadline = exports.vote_lock_deadline = exports.vote_open_voting = exports.vote_set_max_choice_count = exports.vote_remove_option = exports.vote_add_option = exports.vote_remove_guard = exports.vote_add_guard = exports.vote_set_reference = exports.vote_set_description = exports.destroy = exports.launch = exports.vote = void 0;
3
+ exports.change_permission = exports.agree = exports.vote_lock_guard = exports.vote_expand_deadline = exports.vote_lock_deadline = exports.vote_open_voting = exports.vote_set_max_choice_count = exports.vote_remove_option = exports.vote_add_option = exports.vote_remove_guard = exports.vote_add_guard = exports.vote_set_reference = exports.vote_set_description = exports.destroy = exports.launch = exports.vote = exports.MAX_CHOICE_COUNT = exports.MAX_AGREES_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
+ const util_1 = require("./util");
7
+ exports.MAX_AGREES_COUNT = 200;
8
+ exports.MAX_CHOICE_COUNT = 200;
6
9
  function vote(txb, permission, description, minutes_duration, max_choice_count, reference_address, passport) {
7
- let reference = txb.pure([], bcs_1.BCS.U8);
8
- if (reference_address) {
9
- reference = txb.pure(reference_address, bcs_1.BCS.ADDRESS);
10
- }
10
+ if (!(0, protocol_1.IsValidObjects)([permission]))
11
+ return false;
12
+ if (!(0, protocol_1.IsValidDesription)(description))
13
+ return false;
14
+ if (!(0, protocol_1.IsValidUint)(minutes_duration))
15
+ return false;
16
+ if (max_choice_count && !(0, protocol_1.IsValidUint)(max_choice_count))
17
+ return false;
18
+ if (max_choice_count && max_choice_count > exports.MAX_CHOICE_COUNT)
19
+ return false;
20
+ if (reference_address && !(0, protocol_1.IsValidAddress)(reference_address))
21
+ return false;
22
+ let reference = reference_address ? txb.pure(util_1.BCS_CONVERT.ser_option_address(reference_address)) : (0, protocol_1.OptionNone)(txb);
23
+ let choice_count = max_choice_count ? max_choice_count : 1;
11
24
  if (passport) {
12
25
  return txb.moveCall({
13
26
  target: protocol_1.PROTOCOL.VoteFn('new_with_passport'),
14
- arguments: [passport, txb.pure((0, protocol_1.description_data)(description)), reference, txb.pure(protocol_1.CLOCK_OBJECT),
15
- txb.pure(minutes_duration, bcs_1.BCS.U64), txb.pure(max_choice_count, bcs_1.BCS.U8), permission]
27
+ arguments: [passport, txb.pure(description), reference, txb.pure(protocol_1.CLOCK_OBJECT),
28
+ txb.pure(minutes_duration, bcs_1.BCS.U64), txb.pure(choice_count, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)]
16
29
  });
17
30
  }
18
31
  else {
19
32
  return txb.moveCall({
20
33
  target: protocol_1.PROTOCOL.VoteFn('new'),
21
- arguments: [txb.pure((0, protocol_1.description_data)(description)), reference, txb.pure(protocol_1.CLOCK_OBJECT),
22
- txb.pure(minutes_duration, bcs_1.BCS.U64), txb.pure(max_choice_count, bcs_1.BCS.U8), permission]
34
+ arguments: [txb.pure(description), reference, txb.pure(protocol_1.CLOCK_OBJECT),
35
+ txb.pure(minutes_duration, bcs_1.BCS.U64), txb.pure(choice_count, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)]
23
36
  });
24
37
  }
25
38
  }
26
39
  exports.vote = vote;
27
40
  function launch(txb, vote) {
41
+ if (!(0, protocol_1.IsValidObjects)([vote]))
42
+ return false;
28
43
  return txb.moveCall({
29
44
  target: protocol_1.PROTOCOL.VoteFn('create'),
30
- arguments: [vote]
45
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote)]
31
46
  });
32
47
  }
33
48
  exports.launch = launch;
34
49
  function destroy(txb, vote) {
50
+ if (!(0, protocol_1.IsValidObjects)([vote]))
51
+ return false;
35
52
  txb.moveCall({
36
53
  target: protocol_1.PROTOCOL.VoteFn('destroy'),
37
- arguments: [vote]
54
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote)]
38
55
  });
56
+ return true;
39
57
  }
40
58
  exports.destroy = destroy;
41
59
  function vote_set_description(txb, vote, permission, description, passport) {
60
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
61
+ return false;
62
+ if (!(0, protocol_1.IsValidDesription)(description))
63
+ return false;
42
64
  if (passport) {
43
65
  txb.moveCall({
44
66
  target: protocol_1.PROTOCOL.VoteFn('description_set_with_passport'),
45
- arguments: [passport, vote, txb.pure((0, protocol_1.description_data)(description)), permission]
67
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
46
68
  });
47
69
  }
48
70
  else {
49
71
  txb.moveCall({
50
72
  target: protocol_1.PROTOCOL.VoteFn('description_set'),
51
- arguments: [vote, txb.pure((0, protocol_1.description_data)(description)), permission]
73
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
52
74
  });
53
75
  }
76
+ return true;
54
77
  }
55
78
  exports.vote_set_description = vote_set_description;
56
79
  function vote_set_reference(txb, vote, permission, reference_address, passport) {
57
- let reference = txb.pure([], bcs_1.BCS.U8);
58
- if (reference_address) {
59
- reference = txb.pure(reference_address, bcs_1.BCS.ADDRESS);
60
- }
80
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
81
+ return false;
82
+ if (reference_address && !(0, protocol_1.IsValidAddress)(reference_address))
83
+ return false;
84
+ let reference = reference_address ? txb.pure(util_1.BCS_CONVERT.ser_option_address(reference_address)) : (0, protocol_1.OptionNone)(txb);
61
85
  if (passport) {
62
86
  txb.moveCall({
63
87
  target: protocol_1.PROTOCOL.VoteFn('reference_set_with_passport'),
64
- arguments: [passport, vote, reference, permission]
88
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), reference, (0, protocol_1.TXB_OBJECT)(txb, permission)]
65
89
  });
66
90
  }
67
91
  else {
68
92
  txb.moveCall({
69
93
  target: protocol_1.PROTOCOL.VoteFn('reference_set'),
70
- arguments: [vote, reference, permission]
94
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), reference, (0, protocol_1.TXB_OBJECT)(txb, permission)]
71
95
  });
72
96
  }
97
+ return true;
73
98
  }
74
99
  exports.vote_set_reference = vote_set_reference;
75
100
  function vote_add_guard(txb, vote, permission, guard, vote_weight, passport) {
101
+ if (!(0, protocol_1.IsValidObjects)([vote, permission, guard]))
102
+ return false;
103
+ if (!(0, protocol_1.IsValidUint)(vote_weight))
104
+ return false;
76
105
  if (passport) {
77
106
  txb.moveCall({
78
107
  target: protocol_1.PROTOCOL.VoteFn('guard_add_with_passport'),
79
- arguments: [passport, vote, guard, txb.pure(vote_weight, bcs_1.BCS.U64), permission]
108
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, guard), txb.pure(vote_weight, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)]
80
109
  });
81
110
  }
82
111
  else {
83
112
  txb.moveCall({
84
113
  target: protocol_1.PROTOCOL.VoteFn('guard_add'),
85
- arguments: [vote, guard, txb.pure(vote_weight, bcs_1.BCS.U64), permission]
114
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, guard), txb.pure(vote_weight, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)]
86
115
  });
87
116
  }
117
+ return true;
88
118
  }
89
119
  exports.vote_add_guard = vote_add_guard;
90
120
  function vote_remove_guard(txb, vote, permission, guard_address, removeall, passport) {
121
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
122
+ return false;
123
+ if (!removeall && !guard_address)
124
+ return false;
125
+ if (guard_address && !(0, protocol_1.IsValidArray)(guard_address, protocol_1.IsValidAddress))
126
+ return false;
91
127
  if (passport) {
92
128
  if (removeall) {
93
129
  txb.moveCall({
94
130
  target: protocol_1.PROTOCOL.VoteFn('guard_remove_all_with_passport'),
95
- arguments: [passport, vote, permission]
131
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
96
132
  });
97
133
  }
98
134
  else {
99
135
  txb.moveCall({
100
136
  target: protocol_1.PROTOCOL.VoteFn('guard_remove_with_passport'),
101
- arguments: [passport, vote, txb.pure(guard_address, 'vector<address>'), permission]
137
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)]
102
138
  });
103
139
  }
104
140
  }
@@ -106,53 +142,69 @@ function vote_remove_guard(txb, vote, permission, guard_address, removeall, pass
106
142
  if (removeall) {
107
143
  txb.moveCall({
108
144
  target: protocol_1.PROTOCOL.VoteFn('guard_remove_all'),
109
- arguments: [vote, permission]
145
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
110
146
  });
111
147
  }
112
148
  else {
113
149
  txb.moveCall({
114
150
  target: protocol_1.PROTOCOL.VoteFn('guard_remove'),
115
- arguments: [vote, txb.pure(guard_address, 'vector<address>'), permission]
151
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure((0, util_1.array_unique)(guard_address), 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)]
116
152
  });
117
153
  }
118
154
  }
155
+ return true;
119
156
  }
120
157
  exports.vote_remove_guard = vote_remove_guard;
121
158
  function vote_add_option(txb, vote, permission, options, passport) {
159
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
160
+ return false;
161
+ if (!options)
162
+ return false;
163
+ let bValid = true;
164
+ options.forEach((v) => {
165
+ if (!(0, protocol_1.IsValidName)(v.name))
166
+ bValid = false;
167
+ if (v?.reference_address && (0, protocol_1.IsValidAddress)(v.reference_address))
168
+ bValid = false;
169
+ });
170
+ if (!bValid)
171
+ return false;
122
172
  options.forEach((option) => {
123
- let reference = txb.pure([], bcs_1.BCS.U8);
124
- if (option.reference_address) {
125
- reference = txb.pure(option.reference_address, bcs_1.BCS.ADDRESS);
126
- }
173
+ let reference = option?.reference_address ? txb.pure(util_1.BCS_CONVERT.ser_option_address(option.reference_address)) : (0, protocol_1.OptionNone)(txb);
127
174
  if (passport) {
128
175
  txb.moveCall({
129
176
  target: protocol_1.PROTOCOL.VoteFn('agrees_add_with_passport'),
130
- arguments: [passport, vote, txb.pure((0, protocol_1.name_data)(option.name)), reference, permission]
177
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(option.name), reference, (0, protocol_1.TXB_OBJECT)(txb, permission)]
131
178
  });
132
179
  }
133
180
  else {
134
181
  txb.moveCall({
135
182
  target: protocol_1.PROTOCOL.VoteFn('agrees_add'),
136
- arguments: [vote, txb.pure((0, protocol_1.name_data)(option.name)), reference, permission]
183
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(option.name), reference, (0, protocol_1.TXB_OBJECT)(txb, permission)]
137
184
  });
138
185
  }
139
186
  });
187
+ return true;
140
188
  }
141
189
  exports.vote_add_option = vote_add_option;
142
190
  function vote_remove_option(txb, vote, permission, options, removeall, passport) {
191
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
192
+ return false;
193
+ if (!removeall && !options)
194
+ return false;
195
+ if (options && !(0, protocol_1.IsValidArray)(options, protocol_1.IsValidAddress))
196
+ return false;
143
197
  if (passport) {
144
198
  if (removeall) {
145
199
  txb.moveCall({
146
200
  target: protocol_1.PROTOCOL.VoteFn('agrees_remove_all_with_passport'),
147
- arguments: [passport, vote, permission]
201
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
148
202
  });
149
203
  }
150
204
  else {
151
- options.forEach((option) => {
152
- txb.moveCall({
153
- target: protocol_1.PROTOCOL.VoteFn('agrees_remove_with_passport'),
154
- arguments: [passport, vote, txb.pure((0, protocol_1.name_data)(option)), permission]
155
- });
205
+ txb.moveCall({
206
+ target: protocol_1.PROTOCOL.VoteFn('agrees_remove_with_passport'),
207
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(options))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
156
208
  });
157
209
  }
158
210
  }
@@ -160,114 +212,140 @@ function vote_remove_option(txb, vote, permission, options, removeall, passport)
160
212
  if (removeall) {
161
213
  txb.moveCall({
162
214
  target: protocol_1.PROTOCOL.VoteFn('agrees_remove_all'),
163
- arguments: [vote, permission]
215
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
164
216
  });
165
217
  }
166
218
  else {
167
- options.forEach((option) => {
168
- txb.moveCall({
169
- target: protocol_1.PROTOCOL.VoteFn('agrees_remove'),
170
- arguments: [vote, txb.pure((0, protocol_1.name_data)(option)), permission]
171
- });
219
+ txb.moveCall({
220
+ target: protocol_1.PROTOCOL.VoteFn('agrees_remove'),
221
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(options))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
172
222
  });
173
223
  }
174
224
  }
225
+ return true;
175
226
  }
176
227
  exports.vote_remove_option = vote_remove_option;
177
228
  function vote_set_max_choice_count(txb, vote, permission, max_choice_count, passport) {
229
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
230
+ return false;
231
+ if (!(0, protocol_1.IsValidUint)(max_choice_count) || max_choice_count > exports.MAX_CHOICE_COUNT)
232
+ return false;
178
233
  if (passport) {
179
234
  txb.moveCall({
180
235
  target: protocol_1.PROTOCOL.VoteFn('max_choice_count_set_with_passport'),
181
- arguments: [passport, vote, txb.pure(max_choice_count, bcs_1.BCS.U8), permission]
236
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(max_choice_count, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)]
182
237
  });
183
238
  }
184
239
  else {
185
240
  txb.moveCall({
186
241
  target: protocol_1.PROTOCOL.VoteFn('max_choice_count_set'),
187
- arguments: [vote, txb.pure(max_choice_count, bcs_1.BCS.U8), permission]
242
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(max_choice_count, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)]
188
243
  });
189
244
  }
245
+ return true;
190
246
  }
191
247
  exports.vote_set_max_choice_count = vote_set_max_choice_count;
192
248
  function vote_open_voting(txb, vote, permission, passport) {
249
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
250
+ return false;
193
251
  if (passport) {
194
252
  txb.moveCall({
195
253
  target: protocol_1.PROTOCOL.VoteFn('options_locked_for_voting_with_passport'),
196
- arguments: [passport, vote, permission]
254
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
197
255
  });
198
256
  }
199
257
  else {
200
258
  txb.moveCall({
201
259
  target: protocol_1.PROTOCOL.VoteFn('options_locked_for_voting'),
202
- arguments: [vote, permission]
260
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
203
261
  });
204
262
  }
263
+ return true;
205
264
  }
206
265
  exports.vote_open_voting = vote_open_voting;
207
266
  function vote_lock_deadline(txb, vote, permission, passport) {
267
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
268
+ return false;
208
269
  if (passport) {
209
270
  txb.moveCall({
210
271
  target: protocol_1.PROTOCOL.VoteFn('deadline_locked_with_passport'),
211
- arguments: [passport, vote, txb.object(protocol_1.CLOCK_OBJECT), permission]
272
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)]
212
273
  });
213
274
  }
214
275
  else {
215
276
  txb.moveCall({
216
277
  target: protocol_1.PROTOCOL.VoteFn('deadline_locked'),
217
- arguments: [vote, txb.object(protocol_1.CLOCK_OBJECT), permission]
278
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)]
218
279
  });
219
280
  }
281
+ return true;
220
282
  }
221
283
  exports.vote_lock_deadline = vote_lock_deadline;
222
284
  function vote_expand_deadline(txb, vote, permission, minutes_expand, passport) {
285
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
286
+ return false;
287
+ if (!(0, protocol_1.IsValidUint)(minutes_expand))
288
+ return false;
223
289
  if (passport) {
224
290
  txb.moveCall({
225
291
  target: protocol_1.PROTOCOL.VoteFn('deadline_expand_with_passport'),
226
- arguments: [passport, vote, txb.pure(minutes_expand, bcs_1.BCS.U64), permission]
292
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(minutes_expand, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)]
227
293
  });
228
294
  }
229
295
  else {
230
296
  txb.moveCall({
231
297
  target: protocol_1.PROTOCOL.VoteFn('deadline_expand'),
232
- arguments: [vote, txb.pure(minutes_expand, bcs_1.BCS.U64), permission]
298
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(minutes_expand, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)]
233
299
  });
234
300
  }
301
+ return true;
235
302
  }
236
303
  exports.vote_expand_deadline = vote_expand_deadline;
237
304
  function vote_lock_guard(txb, vote, permission, passport) {
305
+ if (!(0, protocol_1.IsValidObjects)([vote, permission]))
306
+ return false;
238
307
  if (passport) {
239
308
  txb.moveCall({
240
309
  target: protocol_1.PROTOCOL.VoteFn('guard_lock_with_passport'),
241
- arguments: [passport, vote, permission]
310
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
242
311
  });
243
312
  }
244
313
  else {
245
314
  txb.moveCall({
246
315
  target: protocol_1.PROTOCOL.VoteFn('guard_lock'),
247
- arguments: [vote, permission]
316
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, permission)]
248
317
  });
249
318
  }
319
+ return true;
250
320
  }
251
321
  exports.vote_lock_guard = vote_lock_guard;
252
322
  function agree(txb, vote, options, passport) {
323
+ if (!(0, protocol_1.IsValidObjects)([vote]))
324
+ return false;
325
+ if (!options || options.length > exports.MAX_CHOICE_COUNT)
326
+ return false;
253
327
  if (passport) {
254
328
  txb.moveCall({
255
329
  target: protocol_1.PROTOCOL.VoteFn('vote_with_passport'),
256
- arguments: [passport, vote, txb.pure(options, 'vector<string>')]
330
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(options)))]
257
331
  });
258
332
  }
259
333
  else {
260
334
  txb.moveCall({
261
335
  target: protocol_1.PROTOCOL.VoteFn('vote'),
262
- arguments: [vote, txb.pure(options, 'vector<string>')]
336
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(options)))]
263
337
  });
264
338
  }
339
+ return true;
265
340
  }
266
341
  exports.agree = agree;
267
342
  function change_permission(txb, vote, old_permission, new_permission) {
343
+ if (!(0, protocol_1.IsValidObjects)([vote, old_permission, new_permission]))
344
+ return false;
268
345
  txb.moveCall({
269
346
  target: protocol_1.PROTOCOL.VoteFn('permission_set'),
270
- arguments: [vote, old_permission, new_permission],
347
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, vote), (0, protocol_1.TXB_OBJECT)(txb, old_permission), (0, protocol_1.TXB_OBJECT)(txb, new_permission)],
271
348
  });
349
+ return true;
272
350
  }
273
351
  exports.change_permission = change_permission;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wowok",
3
- "version": "1.0.3",
4
- "description": "",
3
+ "version": "1.0.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",
7
7
  "module": "node",
@@ -11,12 +11,11 @@
11
11
  },
12
12
  "keywords": [],
13
13
  "author": "",
14
- "license": "ISC",
14
+ "license": "Apache License",
15
15
  "dependencies": {
16
- "@digitak/esrun": "^3.2.26",
17
16
  "@mysten/bcs": "^0.11.1",
18
17
  "@mysten/sui.js": "^0.50.1",
19
- "esrun": "^3.2.26"
18
+ "graphql": "^16.8.1"
20
19
  },
21
20
  "devDependencies": {
22
21
  "tsx": "^4.7.1"
File without changes