@seljs/checker 1.3.0-beta.14 → 1.3.0-beta.17
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.
|
@@ -78,11 +78,17 @@ const registerSolidityTypes = (env) => {
|
|
|
78
78
|
for (const sig of entry.castSignatures) env.registerFunction(sig, (value) => new Ctor(value));
|
|
79
79
|
}
|
|
80
80
|
env.registerFunction("parseUnits(string, int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
81
|
+
env.registerFunction("parseUnits(string, sol_int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
81
82
|
env.registerFunction("parseUnits(int, int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
83
|
+
env.registerFunction("parseUnits(int, sol_int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
82
84
|
env.registerFunction("parseUnits(double, int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
85
|
+
env.registerFunction("parseUnits(double, sol_int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
83
86
|
env.registerFunction("parseUnits(sol_int, int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
87
|
+
env.registerFunction("parseUnits(sol_int, sol_int): sol_int", (value, decimals) => (0, _seljs_types.parseUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
84
88
|
env.registerFunction("formatUnits(sol_int, int): double", (value, decimals) => (0, _seljs_types.formatUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
89
|
+
env.registerFunction("formatUnits(sol_int, sol_int): double", (value, decimals) => (0, _seljs_types.formatUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
85
90
|
env.registerFunction("formatUnits(int, int): double", (value, decimals) => (0, _seljs_types.formatUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
91
|
+
env.registerFunction("formatUnits(int, sol_int): double", (value, decimals) => (0, _seljs_types.formatUnitsValue)(value, Number((0, _seljs_types.toBigInt)(decimals))));
|
|
86
92
|
env.registerFunction("min(sol_int, sol_int): sol_int", (a, b) => (0, _seljs_types.toBigInt)(a) <= (0, _seljs_types.toBigInt)(b) ? toSolInt(a) : toSolInt(b));
|
|
87
93
|
env.registerFunction("min(sol_int, int): sol_int", (a, b) => (0, _seljs_types.toBigInt)(a) <= (0, _seljs_types.toBigInt)(b) ? toSolInt(a) : toSolInt(b));
|
|
88
94
|
env.registerFunction("min(int, sol_int): sol_int", (a, b) => (0, _seljs_types.toBigInt)(a) <= (0, _seljs_types.toBigInt)(b) ? toSolInt(a) : toSolInt(b));
|
|
@@ -102,6 +108,18 @@ const registerSolidityTypes = (env) => {
|
|
|
102
108
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
103
109
|
env.registerFunction("isZeroAddress(sol_address): bool", (addr) => (0, _seljs_types.toAddress)(addr) === ZERO_ADDRESS);
|
|
104
110
|
env.registerFunction("isZeroAddress(string): bool", (addr) => (0, _seljs_types.toAddress)(addr) === ZERO_ADDRESS);
|
|
111
|
+
class SelNamespace {}
|
|
112
|
+
const selFields = {};
|
|
113
|
+
const selValues = {};
|
|
114
|
+
for (const constant of _seljs_types.EVM_CONSTANTS) {
|
|
115
|
+
selFields[constant.name] = constant.type;
|
|
116
|
+
selValues[constant.name] = constant.type === "sol_int" ? new _seljs_types.SolidityIntTypeWrapper(constant.value) : new _seljs_types.SolidityAddressTypeWrapper(constant.value);
|
|
117
|
+
}
|
|
118
|
+
env.registerType("SelNamespace", {
|
|
119
|
+
ctor: SelNamespace,
|
|
120
|
+
fields: selFields
|
|
121
|
+
});
|
|
122
|
+
env.registerConstant("sel", "SelNamespace", Object.assign(new SelNamespace(), selValues));
|
|
105
123
|
};
|
|
106
124
|
//#endregion
|
|
107
125
|
exports.registerSolidityTypes = registerSolidityTypes;
|
|
@@ -6,7 +6,7 @@ import { Environment } from "@marcbachmann/cel-js";
|
|
|
6
6
|
* Mirrors the parameter signatures from Environment but drops the return type
|
|
7
7
|
* to void — registerSolidityTypes never chains the return value.
|
|
8
8
|
*/
|
|
9
|
-
type SolidityTypeHost = { [K in "registerType" | "registerOperator" | "registerFunction"]: (...args: Parameters<Environment[K]>) => void };
|
|
9
|
+
type SolidityTypeHost = { [K in "registerType" | "registerOperator" | "registerFunction" | "registerConstant"]: (...args: Parameters<Environment[K]>) => void };
|
|
10
10
|
/**
|
|
11
11
|
* Register all Solidity primitive types on a CEL Environment.
|
|
12
12
|
*/
|
|
@@ -6,7 +6,7 @@ import { Environment } from "@marcbachmann/cel-js";
|
|
|
6
6
|
* Mirrors the parameter signatures from Environment but drops the return type
|
|
7
7
|
* to void — registerSolidityTypes never chains the return value.
|
|
8
8
|
*/
|
|
9
|
-
type SolidityTypeHost = { [K in "registerType" | "registerOperator" | "registerFunction"]: (...args: Parameters<Environment[K]>) => void };
|
|
9
|
+
type SolidityTypeHost = { [K in "registerType" | "registerOperator" | "registerFunction" | "registerConstant"]: (...args: Parameters<Environment[K]>) => void };
|
|
10
10
|
/**
|
|
11
11
|
* Register all Solidity primitive types on a CEL Environment.
|
|
12
12
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SOLIDITY_TYPES, SolidityIntTypeWrapper, formatUnitsValue, parseUnitsValue, toAddress, toBigInt } from "@seljs/types";
|
|
1
|
+
import { EVM_CONSTANTS, SOLIDITY_TYPES, SolidityAddressTypeWrapper, SolidityIntTypeWrapper, formatUnitsValue, parseUnitsValue, toAddress, toBigInt } from "@seljs/types";
|
|
2
2
|
//#region src/environment/register-types.ts
|
|
3
3
|
/**
|
|
4
4
|
* Try to register an operator, silently ignoring "already registered" errors.
|
|
@@ -77,11 +77,17 @@ const registerSolidityTypes = (env) => {
|
|
|
77
77
|
for (const sig of entry.castSignatures) env.registerFunction(sig, (value) => new Ctor(value));
|
|
78
78
|
}
|
|
79
79
|
env.registerFunction("parseUnits(string, int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
80
|
+
env.registerFunction("parseUnits(string, sol_int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
80
81
|
env.registerFunction("parseUnits(int, int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
82
|
+
env.registerFunction("parseUnits(int, sol_int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
81
83
|
env.registerFunction("parseUnits(double, int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
84
|
+
env.registerFunction("parseUnits(double, sol_int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
82
85
|
env.registerFunction("parseUnits(sol_int, int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
86
|
+
env.registerFunction("parseUnits(sol_int, sol_int): sol_int", (value, decimals) => parseUnitsValue(value, Number(toBigInt(decimals))));
|
|
83
87
|
env.registerFunction("formatUnits(sol_int, int): double", (value, decimals) => formatUnitsValue(value, Number(toBigInt(decimals))));
|
|
88
|
+
env.registerFunction("formatUnits(sol_int, sol_int): double", (value, decimals) => formatUnitsValue(value, Number(toBigInt(decimals))));
|
|
84
89
|
env.registerFunction("formatUnits(int, int): double", (value, decimals) => formatUnitsValue(value, Number(toBigInt(decimals))));
|
|
90
|
+
env.registerFunction("formatUnits(int, sol_int): double", (value, decimals) => formatUnitsValue(value, Number(toBigInt(decimals))));
|
|
85
91
|
env.registerFunction("min(sol_int, sol_int): sol_int", (a, b) => toBigInt(a) <= toBigInt(b) ? toSolInt(a) : toSolInt(b));
|
|
86
92
|
env.registerFunction("min(sol_int, int): sol_int", (a, b) => toBigInt(a) <= toBigInt(b) ? toSolInt(a) : toSolInt(b));
|
|
87
93
|
env.registerFunction("min(int, sol_int): sol_int", (a, b) => toBigInt(a) <= toBigInt(b) ? toSolInt(a) : toSolInt(b));
|
|
@@ -101,6 +107,18 @@ const registerSolidityTypes = (env) => {
|
|
|
101
107
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
102
108
|
env.registerFunction("isZeroAddress(sol_address): bool", (addr) => toAddress(addr) === ZERO_ADDRESS);
|
|
103
109
|
env.registerFunction("isZeroAddress(string): bool", (addr) => toAddress(addr) === ZERO_ADDRESS);
|
|
110
|
+
class SelNamespace {}
|
|
111
|
+
const selFields = {};
|
|
112
|
+
const selValues = {};
|
|
113
|
+
for (const constant of EVM_CONSTANTS) {
|
|
114
|
+
selFields[constant.name] = constant.type;
|
|
115
|
+
selValues[constant.name] = constant.type === "sol_int" ? new SolidityIntTypeWrapper(constant.value) : new SolidityAddressTypeWrapper(constant.value);
|
|
116
|
+
}
|
|
117
|
+
env.registerType("SelNamespace", {
|
|
118
|
+
ctor: SelNamespace,
|
|
119
|
+
fields: selFields
|
|
120
|
+
});
|
|
121
|
+
env.registerConstant("sel", "SelNamespace", Object.assign(new SelNamespace(), selValues));
|
|
104
122
|
};
|
|
105
123
|
//#endregion
|
|
106
124
|
export { registerSolidityTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seljs/checker",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.17",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/abinnovision/seljs"
|
|
6
6
|
},
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@marcbachmann/cel-js": "^7.5.3",
|
|
53
|
-
"@seljs/common": "1.3.0-beta.
|
|
53
|
+
"@seljs/common": "1.3.0-beta.17",
|
|
54
54
|
"@seljs/schema": "1.2.0",
|
|
55
|
-
"@seljs/types": "1.3.0-beta.
|
|
55
|
+
"@seljs/types": "1.3.0-beta.17",
|
|
56
56
|
"debug": "^4.4.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|