@seljs/checker 1.3.0-beta.21 → 1.3.0-beta.24
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _seljs_common = require("@seljs/common");
|
|
2
3
|
let _seljs_types = require("@seljs/types");
|
|
3
4
|
let viem = require("viem");
|
|
4
5
|
//#region src/environment/register-types.ts
|
|
@@ -28,12 +29,12 @@ const registerIntegerOperators = (env) => {
|
|
|
28
29
|
env.registerOperator("sol_int * sol_int", (a, b) => toSolInt((0, _seljs_types.toBigInt)(a) * (0, _seljs_types.toBigInt)(b)));
|
|
29
30
|
env.registerOperator("sol_int / sol_int", (a, b) => {
|
|
30
31
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
31
|
-
if (divisor === 0n) throw new
|
|
32
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("division by zero");
|
|
32
33
|
return toSolInt((0, _seljs_types.toBigInt)(a) / divisor);
|
|
33
34
|
});
|
|
34
35
|
env.registerOperator("sol_int % sol_int", (a, b) => {
|
|
35
36
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
36
|
-
if (divisor === 0n) throw new
|
|
37
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("modulo by zero");
|
|
37
38
|
return toSolInt((0, _seljs_types.toBigInt)(a) % divisor);
|
|
38
39
|
});
|
|
39
40
|
env.registerOperator("-sol_int", (a) => toSolInt(-(0, _seljs_types.toBigInt)(a)));
|
|
@@ -47,12 +48,12 @@ const registerIntegerOperators = (env) => {
|
|
|
47
48
|
tryRegisterOperator(env, "sol_int * int", (a, b) => toSolInt((0, _seljs_types.toBigInt)(a) * (0, _seljs_types.toBigInt)(b)));
|
|
48
49
|
tryRegisterOperator(env, "sol_int / int", (a, b) => {
|
|
49
50
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
50
|
-
if (divisor === 0n) throw new
|
|
51
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("division by zero");
|
|
51
52
|
return toSolInt((0, _seljs_types.toBigInt)(a) / divisor);
|
|
52
53
|
});
|
|
53
54
|
tryRegisterOperator(env, "sol_int % int", (a, b) => {
|
|
54
55
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
55
|
-
if (divisor === 0n) throw new
|
|
56
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("modulo by zero");
|
|
56
57
|
return toSolInt((0, _seljs_types.toBigInt)(a) % divisor);
|
|
57
58
|
});
|
|
58
59
|
tryRegisterOperator(env, "int + sol_int: sol_int", (a, b) => toSolInt((0, _seljs_types.toBigInt)(a) + (0, _seljs_types.toBigInt)(b)));
|
|
@@ -60,12 +61,12 @@ const registerIntegerOperators = (env) => {
|
|
|
60
61
|
tryRegisterOperator(env, "int * sol_int: sol_int", (a, b) => toSolInt((0, _seljs_types.toBigInt)(a) * (0, _seljs_types.toBigInt)(b)));
|
|
61
62
|
tryRegisterOperator(env, "int / sol_int: sol_int", (a, b) => {
|
|
62
63
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
63
|
-
if (divisor === 0n) throw new
|
|
64
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("division by zero");
|
|
64
65
|
return toSolInt((0, _seljs_types.toBigInt)(a) / divisor);
|
|
65
66
|
});
|
|
66
67
|
tryRegisterOperator(env, "int % sol_int: sol_int", (a, b) => {
|
|
67
68
|
const divisor = (0, _seljs_types.toBigInt)(b);
|
|
68
|
-
if (divisor === 0n) throw new
|
|
69
|
+
if (divisor === 0n) throw new _seljs_common.SELEvaluationError("modulo by zero");
|
|
69
70
|
return toSolInt((0, _seljs_types.toBigInt)(a) % divisor);
|
|
70
71
|
});
|
|
71
72
|
tryRegisterOperator(env, "sol_int == int", (a, b) => (0, _seljs_types.toBigInt)(a) === (0, _seljs_types.toBigInt)(b));
|
|
@@ -126,7 +127,7 @@ const registerSolidityTypes = (env) => {
|
|
|
126
127
|
env.registerFunction("hexBytes(string, int): bytes", (hex, length) => {
|
|
127
128
|
const out = (0, _seljs_types.hexToBytes)(hex);
|
|
128
129
|
const expected = Number((0, _seljs_types.toBigInt)(length));
|
|
129
|
-
if (out.length !== expected) throw new
|
|
130
|
+
if (out.length !== expected) throw new _seljs_common.SELEvaluationError(`hexBytes: expected ${String(expected)} bytes, got ${String(out.length)}`);
|
|
130
131
|
return out;
|
|
131
132
|
});
|
|
132
133
|
env.registerFunction("keccak256(string): bytes", (value) => (0, _seljs_types.hexToBytes)((0, viem.keccak256)((0, viem.toBytes)(value))));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SELEvaluationError } from "@seljs/common";
|
|
1
2
|
import { EVM_CONSTANTS, SOLIDITY_TYPES, SolidityAddressTypeWrapper, SolidityIntTypeWrapper, formatUnitsValue, hexToBytes, parseUnitsValue, toAddress, toBigInt } from "@seljs/types";
|
|
2
3
|
import { keccak256, toBytes } from "viem";
|
|
3
4
|
//#region src/environment/register-types.ts
|
|
@@ -27,12 +28,12 @@ const registerIntegerOperators = (env) => {
|
|
|
27
28
|
env.registerOperator("sol_int * sol_int", (a, b) => toSolInt(toBigInt(a) * toBigInt(b)));
|
|
28
29
|
env.registerOperator("sol_int / sol_int", (a, b) => {
|
|
29
30
|
const divisor = toBigInt(b);
|
|
30
|
-
if (divisor === 0n) throw new
|
|
31
|
+
if (divisor === 0n) throw new SELEvaluationError("division by zero");
|
|
31
32
|
return toSolInt(toBigInt(a) / divisor);
|
|
32
33
|
});
|
|
33
34
|
env.registerOperator("sol_int % sol_int", (a, b) => {
|
|
34
35
|
const divisor = toBigInt(b);
|
|
35
|
-
if (divisor === 0n) throw new
|
|
36
|
+
if (divisor === 0n) throw new SELEvaluationError("modulo by zero");
|
|
36
37
|
return toSolInt(toBigInt(a) % divisor);
|
|
37
38
|
});
|
|
38
39
|
env.registerOperator("-sol_int", (a) => toSolInt(-toBigInt(a)));
|
|
@@ -46,12 +47,12 @@ const registerIntegerOperators = (env) => {
|
|
|
46
47
|
tryRegisterOperator(env, "sol_int * int", (a, b) => toSolInt(toBigInt(a) * toBigInt(b)));
|
|
47
48
|
tryRegisterOperator(env, "sol_int / int", (a, b) => {
|
|
48
49
|
const divisor = toBigInt(b);
|
|
49
|
-
if (divisor === 0n) throw new
|
|
50
|
+
if (divisor === 0n) throw new SELEvaluationError("division by zero");
|
|
50
51
|
return toSolInt(toBigInt(a) / divisor);
|
|
51
52
|
});
|
|
52
53
|
tryRegisterOperator(env, "sol_int % int", (a, b) => {
|
|
53
54
|
const divisor = toBigInt(b);
|
|
54
|
-
if (divisor === 0n) throw new
|
|
55
|
+
if (divisor === 0n) throw new SELEvaluationError("modulo by zero");
|
|
55
56
|
return toSolInt(toBigInt(a) % divisor);
|
|
56
57
|
});
|
|
57
58
|
tryRegisterOperator(env, "int + sol_int: sol_int", (a, b) => toSolInt(toBigInt(a) + toBigInt(b)));
|
|
@@ -59,12 +60,12 @@ const registerIntegerOperators = (env) => {
|
|
|
59
60
|
tryRegisterOperator(env, "int * sol_int: sol_int", (a, b) => toSolInt(toBigInt(a) * toBigInt(b)));
|
|
60
61
|
tryRegisterOperator(env, "int / sol_int: sol_int", (a, b) => {
|
|
61
62
|
const divisor = toBigInt(b);
|
|
62
|
-
if (divisor === 0n) throw new
|
|
63
|
+
if (divisor === 0n) throw new SELEvaluationError("division by zero");
|
|
63
64
|
return toSolInt(toBigInt(a) / divisor);
|
|
64
65
|
});
|
|
65
66
|
tryRegisterOperator(env, "int % sol_int: sol_int", (a, b) => {
|
|
66
67
|
const divisor = toBigInt(b);
|
|
67
|
-
if (divisor === 0n) throw new
|
|
68
|
+
if (divisor === 0n) throw new SELEvaluationError("modulo by zero");
|
|
68
69
|
return toSolInt(toBigInt(a) % divisor);
|
|
69
70
|
});
|
|
70
71
|
tryRegisterOperator(env, "sol_int == int", (a, b) => toBigInt(a) === toBigInt(b));
|
|
@@ -125,7 +126,7 @@ const registerSolidityTypes = (env) => {
|
|
|
125
126
|
env.registerFunction("hexBytes(string, int): bytes", (hex, length) => {
|
|
126
127
|
const out = hexToBytes(hex);
|
|
127
128
|
const expected = Number(toBigInt(length));
|
|
128
|
-
if (out.length !== expected) throw new
|
|
129
|
+
if (out.length !== expected) throw new SELEvaluationError(`hexBytes: expected ${String(expected)} bytes, got ${String(out.length)}`);
|
|
129
130
|
return out;
|
|
130
131
|
});
|
|
131
132
|
env.registerFunction("keccak256(string): bytes", (value) => hexToBytes(keccak256(toBytes(value))));
|
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.24",
|
|
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.24",
|
|
54
54
|
"@seljs/schema": "1.2.0",
|
|
55
|
-
"@seljs/types": "1.3.0-beta.
|
|
55
|
+
"@seljs/types": "1.3.0-beta.24",
|
|
56
56
|
"debug": "^4.4.3",
|
|
57
57
|
"viem": "^2.47.6"
|
|
58
58
|
},
|