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/reward.js CHANGED
@@ -1,106 +1,160 @@
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.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 = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
+ const util_1 = require("./util");
6
7
  function reward(reward_type, txb, permission, description, minutes_duration, passport) {
8
+ if (!(0, protocol_1.IsValidObjects)([permission]))
9
+ return false;
10
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
11
+ return false;
12
+ if (!(0, protocol_1.IsValidDesription)(description))
13
+ return false;
14
+ if (!(0, protocol_1.IsValidUint)(minutes_duration))
15
+ return false;
7
16
  if (passport) {
8
17
  return txb.moveCall({
9
18
  target: protocol_1.PROTOCOL.RewardFn('new_with_passport'),
10
- arguments: [passport, txb.pure((0, protocol_1.description_data)(description)), txb.pure(minutes_duration, bcs_1.BCS.U64),
11
- txb.object(protocol_1.CLOCK_OBJECT), permission],
19
+ arguments: [passport, txb.pure(description), txb.pure(minutes_duration, bcs_1.BCS.U64),
20
+ txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
12
21
  typeArguments: [reward_type]
13
22
  });
14
23
  }
15
24
  else {
16
25
  return txb.moveCall({
17
26
  target: protocol_1.PROTOCOL.RewardFn('new'),
18
- arguments: [txb.pure((0, protocol_1.description_data)(description)), txb.pure(minutes_duration, bcs_1.BCS.U64),
19
- txb.object(protocol_1.CLOCK_OBJECT), permission],
27
+ arguments: [txb.pure(description), txb.pure(minutes_duration, bcs_1.BCS.U64),
28
+ txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
20
29
  typeArguments: [reward_type]
21
30
  });
22
31
  }
23
32
  }
24
33
  exports.reward = reward;
25
34
  function launch(reward_type, txb, reward) {
35
+ if (!(0, protocol_1.IsValidObjects)([reward]))
36
+ return false;
37
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
38
+ return false;
26
39
  return txb.moveCall({
27
40
  target: protocol_1.PROTOCOL.RewardFn('create'),
28
- arguments: [reward],
41
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward)],
29
42
  typeArguments: [reward_type]
30
43
  });
31
44
  }
32
45
  exports.launch = launch;
33
46
  function destroy(reward_type, txb, reward) {
34
- return txb.moveCall({
47
+ if (!(0, protocol_1.IsValidObjects)([reward]))
48
+ return false;
49
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
50
+ return false;
51
+ txb.moveCall({
35
52
  target: protocol_1.PROTOCOL.RewardFn('destroy'),
36
- arguments: [reward],
53
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward)],
37
54
  });
55
+ return true;
38
56
  }
39
57
  exports.destroy = destroy;
40
58
  function reward_refund(reward_type, txb, reward, permission, passport) {
59
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
60
+ return false;
61
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
62
+ return false;
41
63
  if (passport) {
42
64
  txb.moveCall({
43
65
  target: protocol_1.PROTOCOL.RewardFn('refund_with_passport'),
44
- arguments: [passport, reward, txb.object(protocol_1.CLOCK_OBJECT), permission],
66
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
45
67
  typeArguments: [reward_type]
46
68
  });
47
69
  }
48
70
  else {
49
71
  txb.moveCall({
50
72
  target: protocol_1.PROTOCOL.RewardFn('refund'),
51
- arguments: [reward, txb.object(protocol_1.CLOCK_OBJECT), permission],
73
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
52
74
  typeArguments: [reward_type]
53
75
  });
54
76
  }
77
+ return true;
55
78
  }
56
79
  exports.reward_refund = reward_refund;
57
80
  function reward_expand_time(reward_type, txb, reward, permission, minutes_expand, passport) {
81
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
82
+ return false;
83
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
84
+ return false;
85
+ if (!(0, protocol_1.IsValidUint)(minutes_expand))
86
+ return false;
58
87
  if (passport) {
59
88
  txb.moveCall({
60
89
  target: protocol_1.PROTOCOL.RewardFn('time_expand_with_passport'),
61
- arguments: [passport, reward, txb.pure(minutes_expand, bcs_1.BCS.U64), permission],
90
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure(minutes_expand, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
62
91
  typeArguments: [reward_type]
63
92
  });
64
93
  }
65
94
  else {
66
95
  txb.moveCall({
67
96
  target: protocol_1.PROTOCOL.RewardFn('time_expand'),
68
- arguments: [reward, txb.pure(minutes_expand, bcs_1.BCS.U64), permission],
97
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure(minutes_expand, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
69
98
  typeArguments: [reward_type]
70
99
  });
71
100
  }
101
+ return true;
72
102
  }
73
103
  exports.reward_expand_time = reward_expand_time;
74
104
  function reward_add_guard(reward_type, txb, reward, permission, gurads, passport) {
105
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
106
+ return false;
107
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
108
+ return false;
109
+ if (!gurads)
110
+ return false;
111
+ let bValid = true;
112
+ gurads.forEach((v) => {
113
+ if (!(0, protocol_1.IsValidUint)(v.portions))
114
+ bValid = false;
115
+ if (!(0, protocol_1.IsValidObjects)([v.guard]))
116
+ bValid = false;
117
+ });
118
+ if (!bValid)
119
+ return false;
75
120
  if (passport) {
76
121
  gurads.forEach((guard) => txb.moveCall({
77
122
  target: protocol_1.PROTOCOL.RewardFn('guard_add_with_passport'),
78
- arguments: [passport, reward, guard.guard, txb.pure(guard.portions, bcs_1.BCS.U64), permission],
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)],
79
124
  typeArguments: [reward_type]
80
125
  }));
81
126
  }
82
127
  else {
83
128
  gurads.forEach((guard) => txb.moveCall({
84
129
  target: protocol_1.PROTOCOL.RewardFn('guard_add'),
85
- arguments: [reward, guard.guard, txb.pure(guard.portions, bcs_1.BCS.U64), permission],
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)],
86
131
  typeArguments: [reward_type]
87
132
  }));
88
133
  }
134
+ return true;
89
135
  }
90
136
  exports.reward_add_guard = reward_add_guard;
91
137
  function reward_remove_guard(reward_type, txb, reward, permission, guards, removeall, passport) {
138
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
139
+ return false;
140
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
141
+ return false;
142
+ if (!removeall && !guards)
143
+ return false;
144
+ if (guards && !(0, protocol_1.IsValidArray)(guards, protocol_1.IsValidAddress))
145
+ return false;
92
146
  if (passport) {
93
147
  if (removeall) {
94
148
  txb.moveCall({
95
149
  target: protocol_1.PROTOCOL.RewardFn('guard_remove_all_with_passport'),
96
- arguments: [passport, reward, permission],
150
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
97
151
  typeArguments: [reward_type]
98
152
  });
99
153
  }
100
154
  else {
101
155
  txb.moveCall({
102
156
  target: protocol_1.PROTOCOL.RewardFn('guard_remove_with_passport'),
103
- arguments: [passport, reward, txb.pure(guards, 'vector<address>'), permission],
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)],
104
158
  typeArguments: [reward_type]
105
159
  });
106
160
  }
@@ -109,84 +163,136 @@ function reward_remove_guard(reward_type, txb, reward, permission, guards, remov
109
163
  if (removeall) {
110
164
  txb.moveCall({
111
165
  target: protocol_1.PROTOCOL.RewardFn('guard_remove_all'),
112
- arguments: [reward, permission],
166
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
113
167
  typeArguments: [reward_type]
114
168
  });
115
169
  }
116
170
  else {
117
171
  txb.moveCall({
118
172
  target: protocol_1.PROTOCOL.RewardFn('guard_remove'),
119
- arguments: [reward, txb.pure(guards, 'vector<address>'), permission],
173
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure(guards, 'vector<address>'), (0, protocol_1.TXB_OBJECT)(txb, permission)],
120
174
  typeArguments: [reward_type]
121
175
  });
122
176
  }
123
177
  }
178
+ return true;
124
179
  }
125
180
  exports.reward_remove_guard = reward_remove_guard;
181
+ function allow_repeat_claim(reward_type, txb, reward, permission, allow_repeat_claim, passport) {
182
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
183
+ return false;
184
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
185
+ return false;
186
+ if (passport) {
187
+ txb.moveCall({
188
+ target: protocol_1.PROTOCOL.RewardFn('allow_repeat_claim_with_passport'),
189
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(allow_repeat_claim, bcs_1.BCS.BOOL)],
190
+ typeArguments: [reward_type]
191
+ });
192
+ }
193
+ else {
194
+ txb.moveCall({
195
+ target: protocol_1.PROTOCOL.RewardFn('allow_repeat_claim_with_passport'),
196
+ 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
+ typeArguments: [reward_type]
198
+ });
199
+ }
200
+ return true;
201
+ }
202
+ exports.allow_repeat_claim = allow_repeat_claim;
126
203
  function reward_set_description(reward_type, txb, reward, permission, description, passport) {
204
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
205
+ return false;
206
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
207
+ return false;
208
+ if (!(0, protocol_1.IsValidDesription)(description))
209
+ return false;
127
210
  if (passport) {
128
211
  txb.moveCall({
129
212
  target: protocol_1.PROTOCOL.RewardFn('description_set_with_passport'),
130
- arguments: [passport, reward, txb.pure((0, protocol_1.description_data)(description)), permission],
213
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
131
214
  typeArguments: [reward_type]
132
215
  });
133
216
  }
134
217
  else {
135
218
  txb.moveCall({
136
219
  target: protocol_1.PROTOCOL.RewardFn('description_set'),
137
- arguments: [reward, txb.pure((0, protocol_1.description_data)(description)), permission],
220
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
138
221
  typeArguments: [reward_type]
139
222
  });
140
223
  }
224
+ return true;
141
225
  }
142
226
  exports.reward_set_description = reward_set_description;
143
227
  function reward_lock_guards(reward_type, txb, reward, permission, passport) {
228
+ if (!(0, protocol_1.IsValidObjects)([reward, permission]))
229
+ return false;
230
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
231
+ return false;
144
232
  if (passport) {
145
233
  txb.moveCall({
146
234
  target: protocol_1.PROTOCOL.RewardFn('guard_lock_with_passport'),
147
- arguments: [passport, reward, permission],
235
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
148
236
  typeArguments: [reward_type]
149
237
  });
150
238
  }
151
239
  else {
152
240
  txb.moveCall({
153
241
  target: protocol_1.PROTOCOL.RewardFn('guard_lock'),
154
- arguments: [reward, permission],
242
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
155
243
  typeArguments: [reward_type]
156
244
  });
157
245
  }
246
+ return true;
158
247
  }
159
248
  exports.reward_lock_guards = reward_lock_guards;
160
249
  function claim(reward_type, txb, reward, passport) {
250
+ if (!(0, protocol_1.IsValidObjects)([reward]))
251
+ return false;
252
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
253
+ return false;
161
254
  if (passport) {
162
255
  txb.moveCall({
163
256
  target: protocol_1.PROTOCOL.RewardFn('claim_with_passport'),
164
- arguments: [passport, reward, txb.object(protocol_1.CLOCK_OBJECT)],
257
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), txb.object(protocol_1.CLOCK_OBJECT)],
165
258
  typeArguments: [reward_type]
166
259
  });
167
260
  }
168
261
  else {
169
262
  txb.moveCall({
170
- target: protocol_1.PROTOCOL.RewardFn('claim_with_passport'),
171
- arguments: [reward, txb.object(protocol_1.CLOCK_OBJECT)],
263
+ target: protocol_1.PROTOCOL.RewardFn('claim'),
264
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.object(protocol_1.CLOCK_OBJECT)],
172
265
  typeArguments: [reward_type]
173
266
  });
174
267
  }
268
+ return true;
175
269
  }
176
270
  exports.claim = claim;
177
- function deposit(reward_type, txb, reward, reward_objects) {
271
+ function deposit(reward_type, txb, reward, rewards) {
272
+ if (!(0, protocol_1.IsValidObjects)([reward]))
273
+ return false;
274
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
275
+ return false;
276
+ if (!rewards && !(0, protocol_1.IsValidObjects)(rewards))
277
+ return false;
178
278
  txb.moveCall({
179
279
  target: protocol_1.PROTOCOL.RewardFn('deposit'),
180
- arguments: [reward, txb.makeMoveVec({ objects: reward_objects })],
280
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), txb.makeMoveVec({ objects: (0, util_1.array_unique)(rewards) })],
181
281
  typeArguments: [reward_type]
182
282
  });
283
+ return true;
183
284
  }
184
285
  exports.deposit = deposit;
185
286
  function change_permission(reward_type, txb, reward, old_permission, new_permission) {
287
+ if (!(0, protocol_1.IsValidObjects)([reward, old_permission, new_permission]))
288
+ return false;
289
+ if (!(0, protocol_1.IsValidArgType)(reward_type))
290
+ return false;
186
291
  txb.moveCall({
187
292
  target: protocol_1.PROTOCOL.RewardFn('permission_set'),
188
- arguments: [reward, old_permission, new_permission],
293
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, old_permission), (0, protocol_1.TXB_OBJECT)(txb, new_permission)],
189
294
  typeArguments: [reward_type]
190
295
  });
296
+ return true;
191
297
  }
192
298
  exports.change_permission = change_permission;