wowok 1.5.36 → 1.5.39
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/package.json +3 -2
- package/src/arbitration.ts +516 -0
- package/src/guard.ts +14 -26
- package/src/index.ts +3 -3
- package/src/payment.ts +1 -1
- package/src/permission.ts +12 -10
- package/src/protocol.ts +26 -11
- package/src/service.ts +94 -12
- package/src/treasury.ts +2 -3
- package/src/graphql.ts +0 -123
- package/src/reward.ts +0 -317
- package/src/vote.ts +0 -411
package/src/vote.ts
DELETED
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*****************
|
|
3
|
-
* depreacted
|
|
4
|
-
******************/
|
|
5
|
-
|
|
6
|
-
import { FnCallType, PassportObject, PermissionObject, GuardObject, VoteAddress, Protocol, TxbObject} from './protocol';
|
|
7
|
-
import { IsValidDesription, IsValidAddress, Bcs, array_unique, IsValidArray, IsValidName, IsValidU64, IsValidU256, IsValidU8 } from './utils';
|
|
8
|
-
import { ERROR, Errors } from './exception';
|
|
9
|
-
import { ValueType } from './protocol';
|
|
10
|
-
import { Transaction as TransactionBlock} from '@mysten/sui/transactions';
|
|
11
|
-
|
|
12
|
-
export type VoteOption = {
|
|
13
|
-
name:string;
|
|
14
|
-
reference_address?:string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type QueryVotedResult = {
|
|
18
|
-
who: string;
|
|
19
|
-
voted: number[]
|
|
20
|
-
weight: bigint;
|
|
21
|
-
error?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type VoteGuardWeight = {
|
|
25
|
-
guard: GuardObject;
|
|
26
|
-
weight: bigint;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type OnQueryVoted = (result: QueryVotedResult) => void;
|
|
30
|
-
export class Vote {
|
|
31
|
-
protected permission;
|
|
32
|
-
protected object : TxbObject;
|
|
33
|
-
protected txb;
|
|
34
|
-
|
|
35
|
-
get_object() { return this.object }
|
|
36
|
-
private constructor(txb:TransactionBlock, permission:PermissionObject) {
|
|
37
|
-
this.object = '';
|
|
38
|
-
this.txb = txb;
|
|
39
|
-
this.permission = permission;
|
|
40
|
-
}
|
|
41
|
-
static From(txb:TransactionBlock, permission:PermissionObject, object:TxbObject) : Vote {
|
|
42
|
-
let v = new Vote(txb, permission);
|
|
43
|
-
v.object = Protocol.TXB_OBJECT(txb, object)
|
|
44
|
-
return v
|
|
45
|
-
}
|
|
46
|
-
static New(txb:TransactionBlock, permission:PermissionObject, description:string, minutes_duration:boolean, time:number,
|
|
47
|
-
max_choice_count?:number, reference_address?:string, passport?:PassportObject) : Vote {
|
|
48
|
-
if (!Protocol.IsValidObjects([permission])) {
|
|
49
|
-
ERROR(Errors.IsValidObjects, 'permission')
|
|
50
|
-
}
|
|
51
|
-
if (!IsValidDesription(description)) {
|
|
52
|
-
ERROR(Errors.IsValidDesription)
|
|
53
|
-
}
|
|
54
|
-
if (!IsValidU64(time)) {
|
|
55
|
-
ERROR(Errors.IsValidUint, 'time')
|
|
56
|
-
}
|
|
57
|
-
if (max_choice_count && !IsValidU64(max_choice_count)) {
|
|
58
|
-
ERROR(Errors.IsValidUint, 'max_choice_count')
|
|
59
|
-
}
|
|
60
|
-
if (max_choice_count && max_choice_count > Vote.MAX_CHOICE_COUNT) {
|
|
61
|
-
ERROR(Errors.InvalidParam, 'max_choice_count')
|
|
62
|
-
}
|
|
63
|
-
if (reference_address && !IsValidAddress(reference_address)) {
|
|
64
|
-
ERROR(Errors.IsValidAddress, 'reference_address')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let v = new Vote(txb, permission);
|
|
68
|
-
|
|
69
|
-
let reference = txb.pure.option('address', reference_address ? reference_address : undefined);
|
|
70
|
-
let choice_count = max_choice_count ? max_choice_count : 1;
|
|
71
|
-
const clock = txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
72
|
-
if (passport) {
|
|
73
|
-
v.object = txb.moveCall({
|
|
74
|
-
target:Protocol.Instance().VoteFn('new_with_passport') as FnCallType,
|
|
75
|
-
arguments:[passport, txb.pure.string(description), reference, txb.object(clock), txb.pure.bool(minutes_duration),
|
|
76
|
-
txb.pure.u64(time), txb.pure.u8(choice_count), Protocol.TXB_OBJECT(txb, permission)]
|
|
77
|
-
})
|
|
78
|
-
} else {
|
|
79
|
-
v.object = txb.moveCall({
|
|
80
|
-
target:Protocol.Instance().VoteFn('new') as FnCallType,
|
|
81
|
-
arguments:[txb.pure.string(description), reference, txb.object(clock), txb.pure.bool(minutes_duration),
|
|
82
|
-
txb.pure.u64(time), txb.pure.u8(choice_count), Protocol.TXB_OBJECT(txb, permission)]
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
return v
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
launch() : VoteAddress {
|
|
89
|
-
return this.txb.moveCall({
|
|
90
|
-
target:Protocol.Instance().VoteFn('create') as FnCallType,
|
|
91
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
destroy() {
|
|
96
|
-
this.txb.moveCall({
|
|
97
|
-
target:Protocol.Instance().VoteFn('destroy') as FnCallType,
|
|
98
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
set_description(description:string, passport?:PassportObject) {
|
|
103
|
-
if (!IsValidDesription(description)) {
|
|
104
|
-
ERROR(Errors.IsValidDesription)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (passport) {
|
|
108
|
-
this.txb.moveCall({
|
|
109
|
-
target:Protocol.Instance().VoteFn('description_set_with_passport') as FnCallType,
|
|
110
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
this.txb.moveCall({
|
|
114
|
-
target:Protocol.Instance().VoteFn('description_set') as FnCallType,
|
|
115
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
set_reference(reference_address?:string|null, passport?:PassportObject) {
|
|
121
|
-
if (reference_address && !IsValidAddress(reference_address)) {
|
|
122
|
-
ERROR(Errors.IsValidAddress)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
let reference = this.txb.pure.option('address', reference_address ? reference_address : undefined);
|
|
126
|
-
if (passport) {
|
|
127
|
-
this.txb.moveCall({
|
|
128
|
-
target:Protocol.Instance().VoteFn('reference_set_with_passport') as FnCallType,
|
|
129
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), reference, Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
130
|
-
})
|
|
131
|
-
} else {
|
|
132
|
-
this.txb.moveCall({
|
|
133
|
-
target:Protocol.Instance().VoteFn('reference_set') as FnCallType,
|
|
134
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), reference, Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
add_guard(guards:VoteGuardWeight[], passport?:PassportObject) {
|
|
140
|
-
if (guards.length === 0) return;
|
|
141
|
-
let bValid = true;
|
|
142
|
-
guards.forEach((v) => {
|
|
143
|
-
if (!IsValidU64(v.weight) || v.weight === BigInt(0)) bValid = false;
|
|
144
|
-
if (!Protocol.IsValidObjects([v.guard])) bValid = false;
|
|
145
|
-
})
|
|
146
|
-
if (!bValid) {
|
|
147
|
-
ERROR(Errors.InvalidParam, 'add_guard.gurads')
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (passport) {
|
|
151
|
-
guards.forEach((guard) => {
|
|
152
|
-
this.txb.moveCall({
|
|
153
|
-
target:Protocol.Instance().VoteFn('guard_add_with_passport') as FnCallType,
|
|
154
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard),
|
|
155
|
-
this.txb.pure.u64(guard.weight), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
156
|
-
})
|
|
157
|
-
})
|
|
158
|
-
} else {
|
|
159
|
-
guards.forEach((guard) => {
|
|
160
|
-
this.txb.moveCall({
|
|
161
|
-
target:Protocol.Instance().VoteFn('guard_add') as FnCallType,
|
|
162
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard.guard),
|
|
163
|
-
this.txb.pure.u64(guard.weight), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
164
|
-
})
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
remove_guard(guard_address:string[], removeall?:boolean, passport?:PassportObject) {
|
|
170
|
-
if (!removeall && guard_address.length===0) return;
|
|
171
|
-
|
|
172
|
-
if (!IsValidArray(guard_address, IsValidAddress)) {
|
|
173
|
-
ERROR(Errors.IsValidArray, 'remove_guard')
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (passport) {
|
|
177
|
-
if (removeall) {
|
|
178
|
-
this.txb.moveCall({
|
|
179
|
-
target:Protocol.Instance().VoteFn('guard_remove_all_with_passport') as FnCallType,
|
|
180
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
181
|
-
})
|
|
182
|
-
} else {
|
|
183
|
-
this.txb.moveCall({
|
|
184
|
-
target:Protocol.Instance().VoteFn('guard_remove_with_passport') as FnCallType,
|
|
185
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
186
|
-
this.txb.pure.vector('address', array_unique(guard_address)), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
187
|
-
})
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
if (removeall) {
|
|
191
|
-
this.txb.moveCall({
|
|
192
|
-
target:Protocol.Instance().VoteFn('guard_remove_all') as FnCallType,
|
|
193
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
194
|
-
})
|
|
195
|
-
} else {
|
|
196
|
-
this.txb.moveCall({
|
|
197
|
-
target:Protocol.Instance().VoteFn('guard_remove') as FnCallType,
|
|
198
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
199
|
-
this.txb.pure.vector('address', array_unique(guard_address)),
|
|
200
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
add_option(options:VoteOption[], passport?:PassportObject) {
|
|
207
|
-
if (options.length === 0) return ;
|
|
208
|
-
|
|
209
|
-
let bValid = true;
|
|
210
|
-
options.forEach((v) => {
|
|
211
|
-
if (!IsValidName(v.name)) bValid = false;
|
|
212
|
-
if (v?.reference_address && !IsValidAddress(v.reference_address)) bValid = false;
|
|
213
|
-
})
|
|
214
|
-
if (!bValid) {
|
|
215
|
-
ERROR(Errors.InvalidParam, 'options')
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
options.forEach((option) => {
|
|
219
|
-
let reference = this.txb.pure.option('address', option?.reference_address) ;
|
|
220
|
-
|
|
221
|
-
if (passport) {
|
|
222
|
-
this.txb.moveCall({
|
|
223
|
-
target:Protocol.Instance().VoteFn('agrees_add_with_passport') as FnCallType,
|
|
224
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(option.name),
|
|
225
|
-
reference, Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
226
|
-
})
|
|
227
|
-
} else {
|
|
228
|
-
this.txb.moveCall({
|
|
229
|
-
target:Protocol.Instance().VoteFn('agrees_add') as FnCallType,
|
|
230
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(option.name),
|
|
231
|
-
reference, Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
})
|
|
235
|
-
}
|
|
236
|
-
remove_option(options:string[], removeall?:boolean, passport?:PassportObject) {
|
|
237
|
-
if (!removeall && options.length===0) {
|
|
238
|
-
return
|
|
239
|
-
}
|
|
240
|
-
if (!IsValidArray(options, IsValidName)) {
|
|
241
|
-
ERROR(Errors.IsValidArray, 'remove_option.options')
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (passport) {
|
|
245
|
-
if (removeall) {
|
|
246
|
-
this.txb.moveCall({
|
|
247
|
-
target:Protocol.Instance().VoteFn('agrees_remove_all_with_passport') as FnCallType,
|
|
248
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
249
|
-
})
|
|
250
|
-
} else {
|
|
251
|
-
this.txb.moveCall({
|
|
252
|
-
target:Protocol.Instance().VoteFn('agrees_remove_with_passport') as FnCallType,
|
|
253
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
254
|
-
this.txb.pure.vector('string', array_unique(options)),
|
|
255
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
256
|
-
})
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
if (removeall) {
|
|
260
|
-
this.txb.moveCall({
|
|
261
|
-
target:Protocol.Instance().VoteFn('agrees_remove_all') as FnCallType,
|
|
262
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
263
|
-
})
|
|
264
|
-
} else {
|
|
265
|
-
this.txb.moveCall({
|
|
266
|
-
target:Protocol.Instance().VoteFn('agrees_remove') as FnCallType,
|
|
267
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
268
|
-
this.txb.pure.vector('string', array_unique(options)),
|
|
269
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
set_max_choice_count(max_choice_count:number, passport?:PassportObject) {
|
|
275
|
-
if (!IsValidU64(max_choice_count) || max_choice_count > Vote.MAX_CHOICE_COUNT) {
|
|
276
|
-
ERROR(Errors.InvalidParam, 'max_choice_count')
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (passport) {
|
|
280
|
-
this.txb.moveCall({
|
|
281
|
-
target:Protocol.Instance().VoteFn('max_choice_count_set_with_passport') as FnCallType,
|
|
282
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
283
|
-
this.txb.pure.u8(max_choice_count), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
284
|
-
})
|
|
285
|
-
} else {
|
|
286
|
-
this.txb.moveCall({
|
|
287
|
-
target:Protocol.Instance().VoteFn('max_choice_count_set') as FnCallType,
|
|
288
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.u8(max_choice_count), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
open_voting(passport?:PassportObject) {
|
|
294
|
-
if (passport) {
|
|
295
|
-
this.txb.moveCall({
|
|
296
|
-
target:Protocol.Instance().VoteFn('options_locked_for_voting_with_passport') as FnCallType,
|
|
297
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
298
|
-
})
|
|
299
|
-
} else {
|
|
300
|
-
this.txb.moveCall({
|
|
301
|
-
target:Protocol.Instance().VoteFn('options_locked_for_voting') as FnCallType,
|
|
302
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
303
|
-
})
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
lock_deadline(passport?:PassportObject) {
|
|
308
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
309
|
-
if (passport) {
|
|
310
|
-
this.txb.moveCall({
|
|
311
|
-
target:Protocol.Instance().VoteFn('deadline_locked_with_passport') as FnCallType,
|
|
312
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
313
|
-
})
|
|
314
|
-
} else {
|
|
315
|
-
this.txb.moveCall({
|
|
316
|
-
target:Protocol.Instance().VoteFn('deadline_locked') as FnCallType,
|
|
317
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
318
|
-
})
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
expand_deadline(ms_expand:boolean, time:number, passport?:PassportObject) {
|
|
323
|
-
if (!IsValidU64(time)) {
|
|
324
|
-
ERROR(Errors.IsValidUint, 'time')
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (passport) {
|
|
328
|
-
this.txb.moveCall({
|
|
329
|
-
target:Protocol.Instance().VoteFn('deadline_expand_with_passport') as FnCallType,
|
|
330
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(ms_expand),
|
|
331
|
-
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
332
|
-
})
|
|
333
|
-
} else {
|
|
334
|
-
this.txb.moveCall({
|
|
335
|
-
target:Protocol.Instance().VoteFn('deadline_expand') as FnCallType,
|
|
336
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(ms_expand),
|
|
337
|
-
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
338
|
-
})
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
lock_guard(passport?:PassportObject) {
|
|
343
|
-
if (passport) {
|
|
344
|
-
this.txb.moveCall({
|
|
345
|
-
target:Protocol.Instance().VoteFn('guard_locked_with_passport') as FnCallType,
|
|
346
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
347
|
-
})
|
|
348
|
-
} else {
|
|
349
|
-
this.txb.moveCall({
|
|
350
|
-
target:Protocol.Instance().VoteFn('guard_locked') as FnCallType,
|
|
351
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
agree(options:number[], passport?:PassportObject) {
|
|
357
|
-
if (options.length === 0) return;
|
|
358
|
-
if (options.length > Vote.MAX_CHOICE_COUNT) {
|
|
359
|
-
ERROR(Errors.InvalidParam, 'agree.options')
|
|
360
|
-
}
|
|
361
|
-
if (!IsValidArray(options, (v:any) => {
|
|
362
|
-
return IsValidU8(v) && v <= Vote.MAX_AGREES_COUNT;
|
|
363
|
-
})) {
|
|
364
|
-
ERROR(Errors.IsValidArray, 'agree.options')
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
368
|
-
|
|
369
|
-
if (passport) {
|
|
370
|
-
this.txb.moveCall({
|
|
371
|
-
target:Protocol.Instance().VoteFn('vote_with_passport') as FnCallType,
|
|
372
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
373
|
-
this.txb.pure.vector('u8', array_unique(options)), this.txb.object(clock)]
|
|
374
|
-
})
|
|
375
|
-
} else {
|
|
376
|
-
this.txb.moveCall({
|
|
377
|
-
target:Protocol.Instance().VoteFn('vote') as FnCallType,
|
|
378
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
379
|
-
this.txb.pure.vector('u8', array_unique(options)), this.txb.object(clock)]
|
|
380
|
-
})
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
QueryVoted(address_queried:string, event:OnQueryVoted, sender?:string) {
|
|
384
|
-
Protocol.Client().devInspectTransactionBlock({sender:sender ?? address_queried, transactionBlock:this.txb}).then((res) => {
|
|
385
|
-
if (res.results && res.results[0].returnValues && res.results[0].returnValues.length !== 3 ) {
|
|
386
|
-
event({who:address_queried, error:'not match', voted:[], weight:BigInt(0)});
|
|
387
|
-
return
|
|
388
|
-
}
|
|
389
|
-
console.log((res.results as any)[0].returnValues);
|
|
390
|
-
|
|
391
|
-
}).catch((e) => {
|
|
392
|
-
console.log(e);
|
|
393
|
-
event({who:address_queried, error:'error', weight:BigInt(0), voted:[]});
|
|
394
|
-
})
|
|
395
|
-
}
|
|
396
|
-
change_permission(new_permission:PermissionObject) {
|
|
397
|
-
if (!Protocol.IsValidObjects([new_permission])) {
|
|
398
|
-
ERROR(Errors.IsValidObjects)
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
this.txb.moveCall({
|
|
402
|
-
target:Protocol.Instance().VoteFn('this.permission_set') as FnCallType,
|
|
403
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb,this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
|
|
404
|
-
})
|
|
405
|
-
this.permission = new_permission
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
static MAX_AGREES_COUNT = 100;
|
|
409
|
-
static MAX_CHOICE_COUNT = 100;
|
|
410
|
-
static MAX_GUARD_COUNT = 16;
|
|
411
|
-
}
|