wowok 1.3.9 → 1.3.11
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 +1 -1
- package/src/guard.ts +53 -28
- package/src/machine.ts +25 -2
- package/src/passport.ts +25 -1
- package/src/progress.ts +6 -5
- package/src/protocol.ts +17 -6
- package/src/wowok.ts +11 -1
package/package.json
CHANGED
package/src/guard.ts
CHANGED
|
@@ -109,14 +109,14 @@ export class Guard {
|
|
|
109
109
|
[MODULES.permission, 'Admin Count', 9, [], ValueType.TYPE_U64],
|
|
110
110
|
|
|
111
111
|
[MODULES.repository, 'Permission', 11, [], ValueType.TYPE_ADDRESS],
|
|
112
|
-
[MODULES.repository, 'Contains Policy', 12, [ValueType.
|
|
113
|
-
[MODULES.repository, 'Has Permission of Policy', 13, [ValueType.
|
|
114
|
-
[MODULES.repository, 'Permission of Policy', 14, [ValueType.
|
|
115
|
-
[MODULES.repository, 'Value Type of Policy', 15, [ValueType.
|
|
112
|
+
[MODULES.repository, 'Contains Policy', 12, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
113
|
+
[MODULES.repository, 'Has Permission of Policy', 13, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
114
|
+
[MODULES.repository, 'Permission of Policy', 14, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
115
|
+
[MODULES.repository, 'Value Type of Policy', 15, [ValueType.TYPE_STRING], ValueType.TYPE_U8],
|
|
116
116
|
[MODULES.repository, 'Contains Id', 16, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
117
|
-
[MODULES.repository, 'Contains Value', 17, [ValueType.TYPE_ADDRESS, ValueType.
|
|
118
|
-
[MODULES.repository, 'Value without Type', 18, [ValueType.TYPE_ADDRESS, ValueType.
|
|
119
|
-
[MODULES.repository, 'Value', 19, [ValueType.TYPE_ADDRESS, ValueType.
|
|
117
|
+
[MODULES.repository, 'Contains Value', 17, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
118
|
+
[MODULES.repository, 'Value without Type', 18, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_U8],
|
|
119
|
+
[MODULES.repository, 'Value', 19, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_U8],
|
|
120
120
|
[MODULES.repository, 'Type', 20, [], ValueType.TYPE_U8],
|
|
121
121
|
[MODULES.repository, 'Policy Mode', 21, [], ValueType.TYPE_U8],
|
|
122
122
|
[MODULES.repository, 'Reference Count', 22, [], ValueType.TYPE_U64],
|
|
@@ -127,19 +127,21 @@ export class Guard {
|
|
|
127
127
|
[MODULES.machine, 'Published', 33, [], ValueType.TYPE_BOOL],
|
|
128
128
|
[MODULES.machine, 'Is Consensus Repository', 34, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
129
129
|
[MODULES.machine, 'Has Endpoint', 35, [], ValueType.TYPE_BOOL],
|
|
130
|
-
[MODULES.machine, 'Endpoint', 36, [], ValueType.
|
|
130
|
+
[MODULES.machine, 'Endpoint', 36, [], ValueType.TYPE_STRING],
|
|
131
131
|
|
|
132
132
|
[MODULES.progress, 'Machine', 51, [], ValueType.TYPE_ADDRESS],
|
|
133
|
-
[MODULES.progress, 'Current Node', 52, [], ValueType.
|
|
133
|
+
[MODULES.progress, 'Current Node', 52, [], ValueType.TYPE_STRING],
|
|
134
134
|
[MODULES.progress, 'Has Parent', 53, [], ValueType.TYPE_BOOL],
|
|
135
135
|
[MODULES.progress, 'Parent', 54, [], ValueType.TYPE_ADDRESS],
|
|
136
136
|
[MODULES.progress, 'Has Task', 55, [], ValueType.TYPE_BOOL],
|
|
137
137
|
[MODULES.progress, 'Task', 56, [], ValueType.TYPE_ADDRESS],
|
|
138
|
-
[MODULES.progress, 'Has Operator', 57, [ValueType.
|
|
139
|
-
[MODULES.progress, 'Is Operator for Address', 58, [ValueType.
|
|
138
|
+
[MODULES.progress, 'Has Operator', 57, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
139
|
+
[MODULES.progress, 'Is Operator for Address', 58, [ValueType.TYPE_STRING, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
140
140
|
[MODULES.progress, 'Has Context Repository', 59, [], ValueType.TYPE_BOOL],
|
|
141
141
|
[MODULES.progress, 'Context Repository', 60, [], ValueType.TYPE_ADDRESS],
|
|
142
|
-
|
|
142
|
+
[MODULES.progress, 'Last session time', 61, [], ValueType.TYPE_U64],
|
|
143
|
+
[MODULES.progress, 'Session time', 62, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
144
|
+
|
|
143
145
|
[MODULES.demand, 'Permission', 71, [], ValueType.TYPE_ADDRESS],
|
|
144
146
|
[MODULES.demand, 'Has Deadline', 72, [], ValueType.TYPE_BOOL],
|
|
145
147
|
[MODULES.demand, 'Deadline', 73, [], ValueType.TYPE_U64],
|
|
@@ -173,16 +175,16 @@ export class Guard {
|
|
|
173
175
|
[MODULES.service, 'Withdraw-Guard Percent', 117, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
174
176
|
[MODULES.service, 'Has Refund-Guard', 118, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
175
177
|
[MODULES.service, 'Refund-Guard Percent', 119, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
176
|
-
[MODULES.service, 'Has Sale Item', 120, [ValueType.
|
|
177
|
-
[MODULES.service, 'Sale Item Price', 121, [ValueType.
|
|
178
|
-
[MODULES.service, 'Sale Item Inventory', 122, [ValueType.
|
|
178
|
+
[MODULES.service, 'Has Sale Item', 120, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
179
|
+
[MODULES.service, 'Sale Item Price', 121, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
180
|
+
[MODULES.service, 'Sale Item Inventory', 122, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
179
181
|
[MODULES.service, 'Has Machine', 123, [], ValueType.TYPE_BOOL],
|
|
180
182
|
[MODULES.service, 'Machine', 124, [], ValueType.TYPE_ADDRESS],
|
|
181
183
|
[MODULES.service, 'Paused', 125, [], ValueType.TYPE_BOOL],
|
|
182
184
|
[MODULES.service, 'Published', 126, [], ValueType.TYPE_BOOL],
|
|
183
185
|
[MODULES.service, 'Has Required Info', 127, [], ValueType.TYPE_BOOL],
|
|
184
|
-
[MODULES.service, 'Required Info of Service-Pubkey', 128, [], ValueType.
|
|
185
|
-
[MODULES.service, 'Required Info', 129, [], ValueType.
|
|
186
|
+
[MODULES.service, 'Required Info of Service-Pubkey', 128, [], ValueType.TYPE_STRING],
|
|
187
|
+
[MODULES.service, 'Required Info', 129, [], ValueType.TYPE_STRING],
|
|
186
188
|
|
|
187
189
|
[MODULES.reward, 'Permission', 151, [], ValueType.TYPE_ADDRESS],
|
|
188
190
|
[MODULES.reward, 'Reward Count Left', 152, [], ValueType.TYPE_U64],
|
|
@@ -212,15 +214,15 @@ export class Guard {
|
|
|
212
214
|
[MODULES.vote, 'Vote-Guard', 180, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
213
215
|
[MODULES.vote, 'Has Voted by Address', 181, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
214
216
|
[MODULES.vote, 'Voted Weight by Address', 182, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
215
|
-
[MODULES.vote, 'Has Option', 183, [ValueType.
|
|
216
|
-
[MODULES.vote, 'Has Object of Option', 184, [ValueType.
|
|
217
|
-
[MODULES.vote, 'Option Object', 185, [ValueType.
|
|
218
|
-
[MODULES.vote, 'Option Count', 186, [ValueType.
|
|
219
|
-
[MODULES.vote, 'Option Votes', 187, [ValueType.
|
|
217
|
+
[MODULES.vote, 'Has Option', 183, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
218
|
+
[MODULES.vote, 'Has Object of Option', 184, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL],
|
|
219
|
+
[MODULES.vote, 'Option Object', 185, [ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS],
|
|
220
|
+
[MODULES.vote, 'Option Count', 186, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
221
|
+
[MODULES.vote, 'Option Votes', 187, [ValueType.TYPE_STRING], ValueType.TYPE_U64],
|
|
220
222
|
[MODULES.vote, 'Address Count Voted', 188, [], ValueType.TYPE_U64],
|
|
221
|
-
[MODULES.vote, 'Top1 Option by Addresses', 189, [], ValueType.
|
|
223
|
+
[MODULES.vote, 'Top1 Option by Addresses', 189, [], ValueType.TYPE_STRING],
|
|
222
224
|
[MODULES.vote, 'Top1 Count by Addresses', 190, [], ValueType.TYPE_U64],
|
|
223
|
-
[MODULES.vote, 'Top1 Option by Votes', 191, [], ValueType.
|
|
225
|
+
[MODULES.vote, 'Top1 Option by Votes', 191, [], ValueType.TYPE_STRING],
|
|
224
226
|
[MODULES.vote, 'Top1 Count by Votes', 192, [], ValueType.TYPE_U64],
|
|
225
227
|
|
|
226
228
|
[MODULES.wowok, 'Builder', 210, [], ValueType.TYPE_ADDRESS],
|
|
@@ -228,7 +230,7 @@ export class Guard {
|
|
|
228
230
|
[MODULES.wowok, 'Object of Entities', 212, [], ValueType.TYPE_ADDRESS],
|
|
229
231
|
[MODULES.wowok, 'Grantor Count', 213, [], ValueType.TYPE_U64],
|
|
230
232
|
[MODULES.wowok, 'Has Grantor', 214, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
|
|
231
|
-
[MODULES.wowok, 'Grantor Name', 215, [ValueType.TYPE_ADDRESS], ValueType.
|
|
233
|
+
[MODULES.wowok, 'Grantor Name', 215, [ValueType.TYPE_ADDRESS], ValueType.TYPE_STRING],
|
|
232
234
|
[MODULES.wowok, 'Grantor Registration Time', 216, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
233
235
|
[MODULES.wowok, 'Grantor Expired Time', 217, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
|
|
234
236
|
[MODULES.wowok, 'Grantee Object for Grantor', 218, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS],
|
|
@@ -266,10 +268,17 @@ export class Guard {
|
|
|
266
268
|
}
|
|
267
269
|
static NumberOptions = () : Guard_Options[] => {
|
|
268
270
|
const r: Guard_Options[] = [...Guard.CmdFilter(ValueType.TYPE_U8), ...Guard.CmdFilter(ValueType.TYPE_U64),
|
|
269
|
-
...Guard.CmdFilter(ValueType.TYPE_U128), ...Guard.CmdFilter(ValueType.TYPE_U256)].map((v)=> {
|
|
271
|
+
...Guard.CmdFilter(ValueType.TYPE_U128), ...Guard.CmdFilter(ValueType.TYPE_U256)].map((v)=> {
|
|
272
|
+
return {from:'query', name:v[1], value:v[2], group:FirstLetterUppercase(v[0])}});
|
|
270
273
|
r.push({from:'type', name:'Txn Time', value:ContextType.TYPE_CLOCK, group:'Txn Functions'});
|
|
274
|
+
r.push({from:'type', name:'PositiveNumber Add (+)', value:OperatorType.TYPE_NUMBER_ADD, group:'Number Crunching'});
|
|
275
|
+
r.push({from:'type', name:'PositiveNumber Subtract (-)', value:OperatorType.TYPE_NUMBER_SUBTRACT, group:'Number Crunching'});
|
|
276
|
+
r.push({from:'type', name:'PositiveNumber Multiply (*)', value:OperatorType.TYPE_NUMBER_MULTIPLY, group:'Number Crunching'});
|
|
277
|
+
r.push({from:'type', name:'PositiveNumber Devide (/)', value:OperatorType.TYPE_NUMBER_DEVIDE, group:'Number Crunching'});
|
|
278
|
+
r.push({from:'type', name:'PositiveNumber Mod (%)', value:OperatorType.TYPE_NUMBER_MOD, group:'Number Crunching'});
|
|
271
279
|
return r;
|
|
272
280
|
}
|
|
281
|
+
|
|
273
282
|
static CommonOptions = (retType:ValueType) : Guard_Options[] => {
|
|
274
283
|
return Guard.CmdFilter(retType).map((v)=> {return {from:'query', name:v[1], value:v[2], group:FirstLetterUppercase(v[0])}});
|
|
275
284
|
}
|
|
@@ -443,9 +452,10 @@ export class GuardMaker {
|
|
|
443
452
|
case ValueType.TYPE_VEC_U256:
|
|
444
453
|
this.serValueParam(type, param);
|
|
445
454
|
break;
|
|
455
|
+
case ValueType.TYPE_STRING:
|
|
446
456
|
case ValueType.TYPE_VEC_U8:
|
|
447
457
|
if (!param) ERROR(Errors.InvalidParam, 'param');
|
|
448
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
458
|
+
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type)); //@ USE VEC-U8
|
|
449
459
|
if (typeof(param) == 'string') {
|
|
450
460
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_STRING, param));
|
|
451
461
|
} else {
|
|
@@ -538,6 +548,7 @@ export class GuardMaker {
|
|
|
538
548
|
|
|
539
549
|
add_logic(type:OperatorType) : GuardMaker {
|
|
540
550
|
let splice_len = 2;
|
|
551
|
+
let ret = ValueType.TYPE_BOOL;
|
|
541
552
|
switch (type) {
|
|
542
553
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
543
554
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL:
|
|
@@ -567,15 +578,29 @@ export class GuardMaker {
|
|
|
567
578
|
break;
|
|
568
579
|
case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
569
580
|
break;
|
|
581
|
+
case OperatorType.TYPE_NUMBER_ADD:
|
|
582
|
+
case OperatorType.TYPE_NUMBER_DEVIDE:
|
|
583
|
+
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
584
|
+
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
585
|
+
case OperatorType.TYPE_NUMBER_MOD:
|
|
586
|
+
if (this.type_validator.length < splice_len) { ERROR(Errors.Fail, 'type_validator.length') }
|
|
587
|
+
if (!GuardMaker.IsNumberType(this.type_validator[this.type_validator.length -1])) { ERROR(Errors.Fail, 'type_validator check') }
|
|
588
|
+
if (!GuardMaker.IsNumberType(this.type_validator[this.type_validator.length -2])) { ERROR(Errors.Fail, 'type_validator check') }
|
|
589
|
+
ret = ValueType.TYPE_U256;
|
|
590
|
+
break;
|
|
570
591
|
default:
|
|
571
592
|
ERROR(Errors.InvalidParam, 'add_logic type invalid' + type)
|
|
572
593
|
}
|
|
573
594
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type)); // TYPE
|
|
574
595
|
this.type_validator.splice(this.type_validator.length - splice_len); // delete type stack
|
|
575
|
-
this.type_validator.push(
|
|
596
|
+
this.type_validator.push(ret); // add bool to type stack
|
|
576
597
|
return this;
|
|
577
598
|
}
|
|
578
599
|
|
|
600
|
+
static IsNumberType(type:Data_Type) : boolean {
|
|
601
|
+
return (type === ValueType.TYPE_U8 || type === ValueType.TYPE_U64 || type === ValueType.TYPE_U128 || type === ValueType.TYPE_U256)
|
|
602
|
+
}
|
|
603
|
+
|
|
579
604
|
build(bNot = false) : GuardMaker {
|
|
580
605
|
//console.log(this.type_validator);
|
|
581
606
|
//this.data.forEach((value:Uint8Array) => console.log(value));
|
package/src/machine.ts
CHANGED
|
@@ -424,9 +424,32 @@ export class Machine {
|
|
|
424
424
|
this.add_node2([n], passport);
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
remove_pair(node_prior:string, node_name:string, passport?:PassportObject) {
|
|
428
|
+
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'remove_pair');
|
|
429
|
+
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'remove_pair');
|
|
430
|
+
let n : any;
|
|
431
|
+
if (passport) {
|
|
432
|
+
n = this.txb.moveCall({
|
|
433
|
+
target:Protocol.Instance().MachineFn('node_fetch_with_passport') as FnCallType,
|
|
434
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
} else {
|
|
438
|
+
n = this.txb.moveCall({
|
|
439
|
+
target:Protocol.Instance().MachineFn('node_fetch') as FnCallType,
|
|
440
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(node_name), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
this.txb.moveCall({
|
|
444
|
+
target:Protocol.Instance().MachineFn('pair_remove') as FnCallType,
|
|
445
|
+
arguments:[n, this.txb.pure.string(node_prior)],
|
|
446
|
+
})
|
|
447
|
+
this.add_node2([n], passport);
|
|
448
|
+
}
|
|
449
|
+
|
|
427
450
|
remove_forward(node_prior:string, node_name:string, foward_name: string, passport?:PassportObject) {
|
|
428
|
-
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, '
|
|
429
|
-
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, '
|
|
451
|
+
if (!IsValidName_AllowEmpty(node_prior)) ERROR(Errors.IsValidName_AllowEmpty, 'remove_forward');
|
|
452
|
+
if (!IsValidName(node_name)) ERROR(Errors.IsValidName, 'remove_forward');
|
|
430
453
|
|
|
431
454
|
let n : any;
|
|
432
455
|
if (passport) {
|
package/src/passport.ts
CHANGED
|
@@ -126,6 +126,11 @@ export class GuardParser {
|
|
|
126
126
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
127
127
|
case OperatorType.TYPE_LOGIC_AND:
|
|
128
128
|
case OperatorType.TYPE_LOGIC_OR:
|
|
129
|
+
case OperatorType.TYPE_NUMBER_ADD:
|
|
130
|
+
case OperatorType.TYPE_NUMBER_DEVIDE:
|
|
131
|
+
case OperatorType.TYPE_NUMBER_MOD:
|
|
132
|
+
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
133
|
+
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
129
134
|
break;
|
|
130
135
|
case ContextType.TYPE_CONSTANT:
|
|
131
136
|
identifier = arr.shift()! as number; // identifier
|
|
@@ -305,7 +310,19 @@ export class GuardParser {
|
|
|
305
310
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
306
311
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
|
|
307
312
|
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
308
|
-
|
|
313
|
+
case OperatorType.TYPE_NUMBER_ADD:
|
|
314
|
+
case OperatorType.TYPE_NUMBER_DEVIDE:
|
|
315
|
+
case OperatorType.TYPE_NUMBER_MOD:
|
|
316
|
+
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
317
|
+
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
318
|
+
if (current.type === OperatorType.TYPE_LOGIC_AS_U256_GREATER || current.type === OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL ||
|
|
319
|
+
current.type === OperatorType.TYPE_LOGIC_AS_U256_LESSER || current.type === OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL ||
|
|
320
|
+
current.type === OperatorType.TYPE_LOGIC_AS_U256_EQUAL) {
|
|
321
|
+
current.ret_type = ValueType.TYPE_BOOL;
|
|
322
|
+
} else {
|
|
323
|
+
current.ret_type = ValueType.TYPE_U256;
|
|
324
|
+
}
|
|
325
|
+
|
|
309
326
|
if (stack.length < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
310
327
|
for (let i = 0; i < 2; ++i) {
|
|
311
328
|
let p = stack.pop() as DeGuardData;
|
|
@@ -322,6 +339,7 @@ export class GuardParser {
|
|
|
322
339
|
current.ret_type = ValueType.TYPE_BOOL;
|
|
323
340
|
if (stack.length < 2) ERROR(Errors.Fail, 'ResolveData: ' + current.type);
|
|
324
341
|
var p1 = stack.pop() as DeGuardData; var p2 = stack.pop() as DeGuardData;
|
|
342
|
+
console.log(p1); console.log(p2)
|
|
325
343
|
if (!p1.ret_type || !p2.ret_type) ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' INVALID param type');
|
|
326
344
|
if (p1.ret_type != p2.ret_type) ERROR(Errors.Fail, 'ResolveData: ' + current.type + ' param type not match');
|
|
327
345
|
|
|
@@ -392,6 +410,7 @@ export class GuardParser {
|
|
|
392
410
|
case ValueType.TYPE_OPTION_U256:
|
|
393
411
|
case ValueType.TYPE_OPTION_U64:
|
|
394
412
|
case ValueType.TYPE_OPTION_U8:
|
|
413
|
+
case ValueType.TYPE_STRING:
|
|
395
414
|
current.ret_type = current.type;
|
|
396
415
|
stack.push(current);
|
|
397
416
|
return;
|
|
@@ -542,6 +561,11 @@ export class GuardParser {
|
|
|
542
561
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
543
562
|
case OperatorType.TYPE_LOGIC_AND:
|
|
544
563
|
case OperatorType.TYPE_LOGIC_OR:
|
|
564
|
+
case OperatorType.TYPE_NUMBER_ADD:
|
|
565
|
+
case OperatorType.TYPE_NUMBER_DEVIDE:
|
|
566
|
+
case OperatorType.TYPE_NUMBER_MOD:
|
|
567
|
+
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
568
|
+
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
545
569
|
break;
|
|
546
570
|
case ContextType.TYPE_CONSTANT:
|
|
547
571
|
arr.splice(0, 1); // identifier of constant
|
package/src/progress.ts
CHANGED
|
@@ -268,22 +268,23 @@ export class Progress {
|
|
|
268
268
|
ERROR(Errors.IsValidAddress, 'sub_id');
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
const diliverable = this.txb.pure.option('address', deliverables_address ? deliverables_address : undefined);
|
|
272
|
+
const sub = this.txb.pure.option('address', sub_id ? sub_id : undefined);
|
|
273
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
274
|
+
|
|
274
275
|
if (passport) {
|
|
275
276
|
this.txb.moveCall({
|
|
276
277
|
target:Protocol.Instance().ProgressFn('next_with_passport') as FnCallType,
|
|
277
278
|
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.machine),
|
|
278
279
|
this.txb.pure.string(next.next_node_name),
|
|
279
280
|
this.txb.pure.string(next.forward), diliverable, sub,
|
|
280
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
281
|
+
Protocol.TXB_OBJECT(this.txb, this.permission), this.txb.object(clock)],
|
|
281
282
|
})
|
|
282
283
|
} else {
|
|
283
284
|
this.txb.moveCall({
|
|
284
285
|
target:Protocol.Instance().ProgressFn('next') as FnCallType,
|
|
285
286
|
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.machine), this.txb.pure.string(next.next_node_name),
|
|
286
|
-
this.txb.pure.string(next.forward), diliverable, sub, Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
287
|
+
this.txb.pure.string(next.forward), diliverable, sub, Protocol.TXB_OBJECT(this.txb, this.permission), this.txb.object(clock)],
|
|
287
288
|
})
|
|
288
289
|
}
|
|
289
290
|
}
|
package/src/protocol.ts
CHANGED
|
@@ -62,6 +62,11 @@ export type FnCallType = `${string}::${string}::${string}`;
|
|
|
62
62
|
|
|
63
63
|
export enum OperatorType {
|
|
64
64
|
TYPE_QUERY = 1, // query wowok object
|
|
65
|
+
TYPE_NUMBER_ADD = 2,
|
|
66
|
+
TYPE_NUMBER_SUBTRACT = 3,
|
|
67
|
+
TYPE_NUMBER_MULTIPLY = 4,
|
|
68
|
+
TYPE_NUMBER_DEVIDE = 5,
|
|
69
|
+
TYPE_NUMBER_MOD = 6,
|
|
65
70
|
|
|
66
71
|
TYPE_LOGIC_AS_U256_GREATER = 11,
|
|
67
72
|
TYPE_LOGIC_AS_U256_GREATER_EQUAL = 12,
|
|
@@ -156,8 +161,8 @@ export const SER_VALUE: ValueTypeString[] = [
|
|
|
156
161
|
{type: ValueType.TYPE_BOOL, name: 'bool', description:'boolean. eg:true or false', validator:(value:any) => { return (value === true || value === false)}},
|
|
157
162
|
{type: ValueType.TYPE_ADDRESS, name: 'address', description:'address or object-id. eg:0x6789af', validator:IsValidAddress},
|
|
158
163
|
{type: ContextType.TYPE_WITNESS_ID, name: 'future address', description:"eg: machine's future progress, service's future order", validator:IsValidAddress},
|
|
159
|
-
{type: ContextType.TYPE_SIGNER, name: 'txn signer', description:"signer address of the transaction, "
|
|
160
|
-
{type: ContextType.TYPE_CLOCK, name: 'txn time', description:"unsigned-64 number for the transaction time"
|
|
164
|
+
{type: ContextType.TYPE_SIGNER, name: 'txn signer', description:"signer address of the transaction, "},
|
|
165
|
+
{type: ContextType.TYPE_CLOCK, name: 'txn time', description:"unsigned-64 number for the transaction time"},
|
|
161
166
|
{type: ValueType.TYPE_U64, name: 'number', description:'unsigned-64 number. eg:23870233', validator:IsValidU64},
|
|
162
167
|
{type: ValueType.TYPE_U8, name: 'number', description:'unsigned-8 number. eg:255', validator:IsValidU8},
|
|
163
168
|
{type: ValueType.TYPE_VEC_U8, name: 'string', description:'string or unsigned-8 number array. eg:"[1,2,3]"'},
|
|
@@ -191,15 +196,17 @@ export enum ENTRYPOINT {
|
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
const TESTNET = {
|
|
194
|
-
package: "
|
|
195
|
-
wowok_object: '
|
|
196
|
-
entity_object: '
|
|
199
|
+
package: "0xbd3d0929072f7647e521bf72851ccdc7e2169052b22bfdc5b49439c48cfb119a",
|
|
200
|
+
wowok_object: '0xb0a521a287e9d5e08932b3984dbe6ce159e836179c41bd08c556ef77ecdb7439',
|
|
201
|
+
entity_object: '0x16aab98920e7341d1dc19631031253234b2b71fc2ab8c32d65ee3ded8072acef',
|
|
202
|
+
treasury_cap:'0xb75a2ca2f651755c134ad521175f33f9e3f9008ad44340f76b3229e1f30cfdff',
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
const MAINNET = {
|
|
200
206
|
package: "",
|
|
201
207
|
wowok_object: '',
|
|
202
208
|
entity_object: '',
|
|
209
|
+
treasury_cap:'',
|
|
203
210
|
}
|
|
204
211
|
|
|
205
212
|
export interface CoinTypeInfo {
|
|
@@ -214,6 +221,7 @@ export class Protocol {
|
|
|
214
221
|
protected signer = '';
|
|
215
222
|
protected wowok_object = '';
|
|
216
223
|
protected entity_object = '';
|
|
224
|
+
protected treasury_cap = '';
|
|
217
225
|
protected graphql = '';
|
|
218
226
|
protected txb: TransactionBlock | undefined;
|
|
219
227
|
static _instance: any;
|
|
@@ -243,19 +251,22 @@ export class Protocol {
|
|
|
243
251
|
this.package = TESTNET.package;
|
|
244
252
|
this.wowok_object = TESTNET.wowok_object;
|
|
245
253
|
this.entity_object= TESTNET.entity_object;
|
|
254
|
+
this.treasury_cap = TESTNET.treasury_cap;
|
|
246
255
|
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
247
256
|
break;
|
|
248
257
|
case ENTRYPOINT.mainnet:
|
|
249
258
|
this.package = MAINNET.package;
|
|
250
259
|
this.wowok_object = MAINNET.wowok_object;
|
|
251
260
|
this.entity_object= MAINNET.entity_object;
|
|
261
|
+
this.treasury_cap = MAINNET.treasury_cap;
|
|
252
262
|
this.graphql = 'https://sui-mainnet.mystenlabs.com/graphql';
|
|
253
263
|
break;
|
|
254
264
|
};
|
|
255
265
|
}
|
|
256
|
-
|
|
266
|
+
Package(): string { return this.package }
|
|
257
267
|
WowokObject(): string { return this.wowok_object }
|
|
258
268
|
EntityObject(): string { return this.entity_object }
|
|
269
|
+
TreasuryCap() : string { return this.treasury_cap }
|
|
259
270
|
GraphqlUrl() : string { return this.graphql }
|
|
260
271
|
|
|
261
272
|
NetworkUrl() : string {
|
package/src/wowok.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Protocol, FnCallType, TxbObject, ResourceAddress, PermissionObject} from './protocol';
|
|
2
|
-
import { IsValidDesription, IsValidAddress, IsValidName, IsValidArray, } from './utils';
|
|
2
|
+
import { IsValidDesription, IsValidAddress, IsValidName, IsValidArray, IsValidU64, } from './utils';
|
|
3
3
|
import { ERROR, Errors } from './exception';
|
|
4
4
|
import { Transaction as TransactionBlock} from '@mysten/sui/transactions';
|
|
5
5
|
|
|
@@ -47,5 +47,15 @@ export class Wowok {
|
|
|
47
47
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(new_name)]
|
|
48
48
|
})
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
mint(amount: string, recipient: string) {
|
|
52
|
+
if (!IsValidAddress(recipient)) ERROR(Errors.IsValidAddress, 'mint');
|
|
53
|
+
if (!IsValidU64(amount)) ERROR(Errors.IsValidU64, 'mint');
|
|
54
|
+
this.txb.moveCall({
|
|
55
|
+
target:Protocol.Instance().WowokFn('mint') as FnCallType,
|
|
56
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, Protocol.Instance().TreasuryCap()), this.txb.pure.u64(amount),
|
|
57
|
+
this.txb.pure.address(recipient)]
|
|
58
|
+
})
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
61
|
|