wowok 1.7.32 → 1.8.0
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/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +2 -1
- package/dist/exception.js.map +1 -1
- package/dist/guard.d.ts +13 -4
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +57 -30
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/machine.d.ts +6 -7
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +30 -25
- package/dist/machine.js.map +1 -1
- package/dist/passport.d.ts +5 -5
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +17 -13
- package/dist/passport.js.map +1 -1
- package/dist/progress.d.ts +3 -8
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +10 -29
- package/dist/progress.js.map +1 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +9 -9
- package/dist/protocol.js.map +1 -1
- package/dist/service.d.ts +6 -6
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +12 -12
- package/dist/service.js.map +1 -1
- package/dist/utils.d.ts +2 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +29 -36
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/exception.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare enum Errors {
|
|
|
10
10
|
IsValidInt = "invalid int",
|
|
11
11
|
IsValidU64 = "invalid u64",
|
|
12
12
|
IsValidU8 = "invalid u8",
|
|
13
|
-
|
|
13
|
+
IsValidU16 = "invalid u16",
|
|
14
|
+
IsValidRate = "invalid rate[0-10000]",
|
|
14
15
|
IsValidArray = "invalid array",
|
|
15
16
|
IsValidObjects = "invalid objects",
|
|
16
17
|
AllInvalid = "one valid at least",
|
package/dist/exception.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,0BAA0B;IACxC,gBAAgB,uBAAuB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,SAAS,eAAe;IACxB,
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,0BAA0B;IACxC,gBAAgB,uBAAuB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,SAAS,eAAe;IACxB,UAAU,gBAAgB;IAC1B,WAAW,0BAA0B;IACrC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;IAC1C,cAAc,gBAAgB;IAC9B,yBAAyB,4CAA4C;IACrE,cAAc,qBAAqB;IACnC,sBAAsB,8BAA8B;IACpD,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,YAAY,kBAAkB;IAC9B,YAAY,kBAAkB;IAC9B,gBAAgB,uBAAuB;IACvC,eAAe,qBAAqB;IACpC,cAAc,mCAAmC;IACjD,kBAAkB,yBAAyB;CAE9C;AAED,eAAO,MAAM,KAAK,GAAI,OAAM,MAAM,EAAE,OAAM,GAAG,UAG5C,CAAA"}
|
package/dist/exception.js
CHANGED
|
@@ -11,7 +11,8 @@ export var Errors;
|
|
|
11
11
|
Errors["IsValidInt"] = "invalid int";
|
|
12
12
|
Errors["IsValidU64"] = "invalid u64";
|
|
13
13
|
Errors["IsValidU8"] = "invalid u8";
|
|
14
|
-
Errors["
|
|
14
|
+
Errors["IsValidU16"] = "invalid u16";
|
|
15
|
+
Errors["IsValidRate"] = "invalid rate[0-10000]";
|
|
15
16
|
Errors["IsValidArray"] = "invalid array";
|
|
16
17
|
Errors["IsValidObjects"] = "invalid objects";
|
|
17
18
|
Errors["AllInvalid"] = "one valid at least";
|
package/dist/exception.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"exception.js","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,MAmCX;AAnCD,WAAY,MAAM;IACd,mDAAyC,CAAA;IACzC,sCAA4B,CAAA;IAC5B,iDAAuC,CAAA;IACvC,8CAAoC,CAAA;IACpC,4CAAkC,CAAA;IAClC,kDAAwC,CAAA;IACxC,iDAAuC,CAAA;IACvC,sCAA4B,CAAA;IAC5B,oCAA0B,CAAA;IAC1B,oCAA0B,CAAA;IAC1B,kCAAwB,CAAA;IACxB,oCAA0B,CAAA;IAC1B,+CAAqC,CAAA;IACrC,wCAA8B,CAAA;IAC9B,4CAAkC,CAAA;IAClC,2CAAiC,CAAA;IACjC,4CAAmC,CAAA;IACnC,6DAAmD,CAAA;IACnD,oCAA0B,CAAA;IAC1B,uBAAa,CAAA;IACb,oDAA0C,CAAA;IAC1C,wCAA8B,CAAA;IAC9B,+EAAqE,CAAA;IACrE,6CAAmC,CAAA;IACnC,8DAAoD,CAAA;IACpD,+CAAqC,CAAA;IACrC,6DAAmD,CAAA;IACnD,wCAA8B,CAAA;IAC9B,wCAA8B,CAAA;IAC9B,iDAAuC,CAAA;IACvC,8CAAoC,CAAA;IACpC,2DAAiD,CAAA;IACjD,qDAA2C,CAAA;AAE/C,CAAC,EAnCW,MAAM,KAAN,MAAM,QAmCjB;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAY,EAAE,IAAS,EAAE,EAAE;IAC7C,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxD,MAAM,CAAC,CAAC;AACZ,CAAC,CAAA"}
|
package/dist/guard.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject,
|
|
1
|
+
import { GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject, WitnessType } from './protocol.js';
|
|
2
2
|
import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
3
3
|
export type GuardConstant = Map<number, Guard_Variable>;
|
|
4
4
|
export interface Guard_Variable {
|
|
5
5
|
type: ValueType;
|
|
6
6
|
value?: Uint8Array;
|
|
7
7
|
bWitness: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GuardIdentifer extends Guard_Variable {
|
|
11
|
+
identifier: number;
|
|
12
|
+
module_name?: string;
|
|
13
|
+
de_value?: number | string | boolean | string[] | number[] | boolean[] | unknown;
|
|
8
14
|
}
|
|
9
15
|
export interface Guard_Options {
|
|
10
16
|
from: 'query' | 'type';
|
|
@@ -16,7 +22,7 @@ export interface Guard_Options {
|
|
|
16
22
|
export interface GuardAnswer {
|
|
17
23
|
txb: TransactionBlock;
|
|
18
24
|
err?: string;
|
|
19
|
-
identifiers:
|
|
25
|
+
identifiers: GuardIdentifer[];
|
|
20
26
|
}
|
|
21
27
|
export type OnQueryAnswer = (answer: GuardAnswer) => void;
|
|
22
28
|
export interface GuardQuery {
|
|
@@ -47,7 +53,10 @@ export declare class Guard {
|
|
|
47
53
|
static New(txb: TransactionBlock, description: string, maker: GuardMaker): Guard;
|
|
48
54
|
launch(): GuardAddress;
|
|
49
55
|
static everyone_guard(txb: TransactionBlock): GuardAddress;
|
|
50
|
-
static
|
|
56
|
+
static MAX_LOGIC_COUNT: number;
|
|
57
|
+
static IsValidLogicCount(count: number | undefined): boolean;
|
|
58
|
+
static QueryAddressIdentifiers(guard: string): Promise<GuardIdentifer[] | undefined>;
|
|
59
|
+
static AddressIdentifiersImp(content: any): GuardIdentifer[] | undefined;
|
|
51
60
|
static BoolCmd: GuardQuery[];
|
|
52
61
|
static IsBoolCmd: (cmd: number) => boolean;
|
|
53
62
|
static CmdFilter: (retType: ValueType) => GuardQuery[];
|
|
@@ -80,7 +89,7 @@ export declare class GuardMaker {
|
|
|
80
89
|
private static getConstIndex;
|
|
81
90
|
static IsValidIndentifier: (identifier: number) => boolean;
|
|
82
91
|
constructor();
|
|
83
|
-
add_constant(type: ValueType, value?: any, identifier?: number, bNeedSerialize?: boolean): number;
|
|
92
|
+
add_constant(type: ValueType, value?: any, identifier?: number, bNeedSerialize?: boolean, description?: string): number;
|
|
84
93
|
add_param(type: ValueType | ContextType, param?: any): GuardMaker;
|
|
85
94
|
add_query(module: MODULES, query_name: string, object_address_from: string | number): GuardMaker;
|
|
86
95
|
add_query2(query_id: number, object_address_from: string | number): GuardMaker;
|
package/dist/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WA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AM,CAAC,UAAU,CAAC,IAAI,EAAC,MAAM,GAAI,OAAO;IAGxC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAC,MAAM,GAAI,OAAO;IAiB/C,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAI,MAAM;CAclE"}
|
package/dist/guard.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Protocol, LogicsInfo, MODULES, ContextType, ValueType, OperatorType, WitnessForModule } from './protocol.js';
|
|
2
|
-
import { concatenate, array_equal, IsValidU8, IsValidDesription, Bcs, IsValidAddress, FirstLetterUppercase, insertAtHead } from './utils.js';
|
|
2
|
+
import { concatenate, array_equal, IsValidU8, IsValidDesription, Bcs, IsValidAddress, FirstLetterUppercase, insertAtHead, IsValidName } from './utils.js';
|
|
3
3
|
import { ERROR, Errors } from './exception.js';
|
|
4
|
-
import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
5
4
|
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
-
// commands for check guard (repository data query)
|
|
7
|
-
export const CMD_CHECK_GUARD = [
|
|
5
|
+
// NOTIC: commands for check guard (repository data query)
|
|
6
|
+
export const CMD_CHECK_GUARD = [117, 118, 119, 120, 121, 122, 123];
|
|
8
7
|
export const GUARD_QUERIES = [
|
|
9
8
|
// module, 'name', 'id', [input], output
|
|
10
9
|
{ module: MODULES.permission, query_name: 'Owner', query_id: 1, parameters: [], return: ValueType.TYPE_ADDRESS, description: "Owner's address." },
|
|
@@ -69,9 +68,9 @@ export const GUARD_QUERIES = [
|
|
|
69
68
|
{ module: MODULES.service, query_name: 'Buying Guard', query_id: 403, parameters: [], return: ValueType.TYPE_ADDRESS, description: 'Buying guard, that Purchase only if you meet the conditions of the guard.', },
|
|
70
69
|
{ module: MODULES.service, query_name: 'Contains Repository', query_id: 404, parameters: [ValueType.TYPE_ADDRESS], return: ValueType.TYPE_BOOL, description: "Is a certain repository one of the service's consensus repositories?", parameters_description: ['address'] },
|
|
71
70
|
{ module: MODULES.service, query_name: 'Has Withdrawing Guard', query_id: 405, parameters: [ValueType.TYPE_ADDRESS], return: ValueType.TYPE_BOOL, description: 'Whether a certain guard is set when withdrawing money?', parameters_description: ['address'] },
|
|
72
|
-
{ module: MODULES.service, query_name: 'Withdrawing Guard
|
|
71
|
+
{ module: MODULES.service, query_name: 'Withdrawing Guard Rate', query_id: 406, parameters: [ValueType.TYPE_ADDRESS], return: ValueType.TYPE_U16, description: 'The rate (in basis points) of withdrawals allowed by a certain withdrawal guard. 100 basis points = 1%.', parameters_description: ['address'] },
|
|
73
72
|
{ module: MODULES.service, query_name: 'Has Refunding Guard', query_id: 407, parameters: [ValueType.TYPE_ADDRESS], return: ValueType.TYPE_BOOL, description: 'Whether a certain guard is set when refunding money?', parameters_description: ['address'] },
|
|
74
|
-
{ module: MODULES.service, query_name: 'Refunding Guard
|
|
73
|
+
{ module: MODULES.service, query_name: 'Refunding Guard Rate', query_id: 408, parameters: [ValueType.TYPE_ADDRESS], return: ValueType.TYPE_U16, description: 'The rate (in basis points) of refund allowed by a certain refund guard. 100 basis points = 1%.', parameters_description: ['address'] },
|
|
75
74
|
{ module: MODULES.service, query_name: 'Has Sales Item', query_id: 409, parameters: [ValueType.TYPE_STRING], return: ValueType.TYPE_BOOL, description: 'Is there a sales item for the service?', parameters_description: ['the item name'] },
|
|
76
75
|
{ module: MODULES.service, query_name: 'Sale Item Price', query_id: 410, parameters: [ValueType.TYPE_STRING], return: ValueType.TYPE_U64, description: 'What is the price of a certain sale item?', parameters_description: ['the item name'] },
|
|
77
76
|
{ module: MODULES.service, query_name: 'Sale Item Inventory', query_id: 411, parameters: [ValueType.TYPE_STRING], return: ValueType.TYPE_U64, description: 'How much inventory is there for a certain sales item?', parameters_description: ['the item name'] },
|
|
@@ -307,7 +306,9 @@ export class Guard {
|
|
|
307
306
|
if (v.value && v.bWitness)
|
|
308
307
|
ERROR(Errors.InvalidParam, 'Guard.New.constants.value & bWiteness');
|
|
309
308
|
if (v.value === undefined && !v.bWitness)
|
|
310
|
-
ERROR(Errors.InvalidParam, 'Guard.New.constants.value');
|
|
309
|
+
ERROR(Errors.InvalidParam, 'Guard.New.constants.value invalid when not bWiteness');
|
|
310
|
+
if (v.description && !IsValidName(v.description))
|
|
311
|
+
ERROR(Errors.IsValidName, `Guard.New.constants.description too long:${v.description}`);
|
|
311
312
|
});
|
|
312
313
|
let input = new Uint8Array(bcs_input); // copy new uint8array to reserve!
|
|
313
314
|
// reserve the bytes for guard
|
|
@@ -322,14 +323,14 @@ export class Guard {
|
|
|
322
323
|
n.set([v.type], 0);
|
|
323
324
|
txb.moveCall({
|
|
324
325
|
target: Protocol.Instance().guardFn("constant_add"),
|
|
325
|
-
arguments: [Protocol.TXB_OBJECT(txb, g.object), txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.
|
|
326
|
+
arguments: [Protocol.TXB_OBJECT(txb, g.object), txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.option('string', v.description)]
|
|
326
327
|
});
|
|
327
328
|
}
|
|
328
329
|
else {
|
|
329
330
|
const n = insertAtHead(v.value, v.type);
|
|
330
331
|
txb.moveCall({
|
|
331
332
|
target: Protocol.Instance().guardFn("constant_add"),
|
|
332
|
-
arguments: [Protocol.TXB_OBJECT(txb, g.object), txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.
|
|
333
|
+
arguments: [Protocol.TXB_OBJECT(txb, g.object), txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.option('string', v.description)]
|
|
333
334
|
});
|
|
334
335
|
}
|
|
335
336
|
});
|
|
@@ -347,26 +348,44 @@ export class Guard {
|
|
|
347
348
|
arguments: []
|
|
348
349
|
});
|
|
349
350
|
}
|
|
350
|
-
static
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
static IsValidLogicCount(count) {
|
|
352
|
+
return count !== undefined && count >= 2 && count <= Guard.MAX_LOGIC_COUNT;
|
|
353
|
+
}
|
|
354
|
+
static async QueryAddressIdentifiers(guard) {
|
|
355
|
+
if (IsValidAddress(guard)) {
|
|
356
|
+
const r = await Protocol.Client().getObject({ id: guard, options: { showContent: true, showType: true } });
|
|
357
|
+
if (r?.data?.content && r?.data?.type) {
|
|
358
|
+
const t = Protocol.Instance().object_name_from_type_repr(r?.data?.type);
|
|
359
|
+
if (t !== 'Guard')
|
|
360
|
+
return;
|
|
361
|
+
return Guard.AddressIdentifiersImp(r?.data?.content?.fields);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
static AddressIdentifiersImp(content) {
|
|
366
|
+
const id_description = content?.id_description?.fields?.contents?.map((v) => {
|
|
367
|
+
return { id: parseInt(v?.fields?.key), description: v?.fields?.value };
|
|
355
368
|
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
369
|
+
return content?.constants?.map((v) => {
|
|
370
|
+
const raw = Uint8Array.from(v?.fields?.value);
|
|
371
|
+
let value_type;
|
|
372
|
+
let value;
|
|
373
|
+
let de_value;
|
|
374
|
+
if (raw.length >= 1) {
|
|
375
|
+
value_type = raw[0];
|
|
376
|
+
if (raw.length > 1) {
|
|
377
|
+
value = raw.slice(1);
|
|
378
|
+
de_value = Bcs.getInstance().de(value_type, value);
|
|
379
|
+
}
|
|
360
380
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
console.log(e);
|
|
365
|
-
onQueryAnswer({ err: e, txb: txb, identifiers: [] });
|
|
381
|
+
return { identifier: v?.fields?.identifier, bWitness: v?.fields?.bWitness, value_type: value_type,
|
|
382
|
+
value: value, description: id_description?.find((d) => { return d.id === v?.fields?.identifier; })?.description,
|
|
383
|
+
module_name: v?.fields?.module_name ?? undefined, de_value: de_value };
|
|
366
384
|
});
|
|
367
385
|
}
|
|
368
386
|
}
|
|
369
387
|
Guard.MAX_INPUT_LENGTH = 10240;
|
|
388
|
+
Guard.MAX_LOGIC_COUNT = 6;
|
|
370
389
|
Guard.BoolCmd = GUARD_QUERIES.filter(q => q.return === ValueType.TYPE_BOOL);
|
|
371
390
|
Guard.IsBoolCmd = (cmd) => { return Guard.BoolCmd.some((q) => { return q.query_id == cmd; }); };
|
|
372
391
|
Guard.CmdFilter = (retType) => { return GUARD_QUERIES.filter((q) => q.return === retType); };
|
|
@@ -472,7 +491,10 @@ export class GuardMaker {
|
|
|
472
491
|
this.constant = new Map();
|
|
473
492
|
}
|
|
474
493
|
// undefined value means witness
|
|
475
|
-
add_constant(type, value, identifier, bNeedSerialize = true) {
|
|
494
|
+
add_constant(type, value, identifier, bNeedSerialize = true, description) {
|
|
495
|
+
if (description && !IsValidName(description)) {
|
|
496
|
+
ERROR(Errors.IsValidName, 'add_constant.description too long: ' + description);
|
|
497
|
+
}
|
|
476
498
|
if (identifier === undefined) {
|
|
477
499
|
if (value === undefined)
|
|
478
500
|
identifier = GuardMaker.GetWitnessIndex();
|
|
@@ -484,7 +506,12 @@ export class GuardMaker {
|
|
|
484
506
|
if (bNeedSerialize && value !== undefined) {
|
|
485
507
|
value = Bcs.getInstance().ser(type, value);
|
|
486
508
|
}
|
|
487
|
-
this.constant.set(identifier, { type: type, value: value === undefined ? undefined : value, bWitness: value === undefined ? true : false });
|
|
509
|
+
this.constant.set(identifier, { type: type, value: value === undefined ? undefined : value, bWitness: value === undefined ? true : false, description: description });
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
if (v.bWitness && value !== undefined) {
|
|
513
|
+
ERROR(Errors.InvalidParam, 'add_constant. witness value can not be overwritten:' + identifier);
|
|
514
|
+
}
|
|
488
515
|
}
|
|
489
516
|
return identifier;
|
|
490
517
|
}
|
|
@@ -674,7 +701,7 @@ export class GuardMaker {
|
|
|
674
701
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
675
702
|
case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
|
|
676
703
|
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
677
|
-
if (!logic_count
|
|
704
|
+
if (!Guard.IsValidLogicCount(logic_count))
|
|
678
705
|
ERROR(Errors.Fail, 'logic param invalid:' + e);
|
|
679
706
|
splice_len = logic_count;
|
|
680
707
|
if (this.type_validator.length < splice_len) {
|
|
@@ -687,7 +714,7 @@ export class GuardMaker {
|
|
|
687
714
|
}
|
|
688
715
|
break;
|
|
689
716
|
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
690
|
-
if (!logic_count
|
|
717
|
+
if (!Guard.IsValidLogicCount(logic_count))
|
|
691
718
|
ERROR(Errors.Fail, 'logic param invalid:' + e);
|
|
692
719
|
splice_len = logic_count;
|
|
693
720
|
if (this.type_validator.length < splice_len) {
|
|
@@ -700,7 +727,7 @@ export class GuardMaker {
|
|
|
700
727
|
}
|
|
701
728
|
break;
|
|
702
729
|
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
703
|
-
if (!logic_count
|
|
730
|
+
if (!Guard.IsValidLogicCount(logic_count))
|
|
704
731
|
ERROR(Errors.Fail, 'logic param invalid:' + e);
|
|
705
732
|
splice_len = logic_count;
|
|
706
733
|
if (this.type_validator.length < splice_len) {
|
|
@@ -772,7 +799,7 @@ export class GuardMaker {
|
|
|
772
799
|
break;
|
|
773
800
|
case OperatorType.TYPE_LOGIC_AND:
|
|
774
801
|
case OperatorType.TYPE_LOGIC_OR: //@ logics count
|
|
775
|
-
if (!logic_count
|
|
802
|
+
if (!Guard.IsValidLogicCount(logic_count))
|
|
776
803
|
ERROR(Errors.Fail, 'logic param invalid:' + e);
|
|
777
804
|
splice_len = logic_count;
|
|
778
805
|
if (this.type_validator.length < splice_len) {
|
|
@@ -789,7 +816,7 @@ export class GuardMaker {
|
|
|
789
816
|
case OperatorType.TYPE_NUMBER_MULTIPLY:
|
|
790
817
|
case OperatorType.TYPE_NUMBER_SUBTRACT:
|
|
791
818
|
case OperatorType.TYPE_NUMBER_MOD:
|
|
792
|
-
if (!logic_count
|
|
819
|
+
if (!Guard.IsValidLogicCount(logic_count))
|
|
793
820
|
ERROR(Errors.Fail, 'logic param invalid:' + e);
|
|
794
821
|
splice_len = logic_count;
|
|
795
822
|
if (this.type_validator.length < splice_len) {
|