@seljs/checker 1.3.0-beta.24 → 1.3.0-beta.27
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.
|
@@ -120,6 +120,39 @@ const registerSolidityTypes = (env) => {
|
|
|
120
120
|
const v = (0, _seljs_types.toBigInt)(a);
|
|
121
121
|
return toSolInt(v < 0n ? -v : v);
|
|
122
122
|
});
|
|
123
|
+
const registerListSolIntReducer = (name, handler) => {
|
|
124
|
+
env.registerFunction({
|
|
125
|
+
name,
|
|
126
|
+
receiverType: "list<sol_int>",
|
|
127
|
+
returnType: "sol_int",
|
|
128
|
+
params: []
|
|
129
|
+
}, handler);
|
|
130
|
+
};
|
|
131
|
+
registerListSolIntReducer("sum", (list) => {
|
|
132
|
+
let total = 0n;
|
|
133
|
+
for (const item of list) total += (0, _seljs_types.toBigInt)(item);
|
|
134
|
+
return toSolInt(total);
|
|
135
|
+
});
|
|
136
|
+
registerListSolIntReducer("min", (list) => {
|
|
137
|
+
const items = list;
|
|
138
|
+
if (items.length === 0) throw new Error("list<sol_int>.min(): list is empty");
|
|
139
|
+
let smallest = (0, _seljs_types.toBigInt)(items[0]);
|
|
140
|
+
for (let i = 1; i < items.length; i++) {
|
|
141
|
+
const v = (0, _seljs_types.toBigInt)(items[i]);
|
|
142
|
+
if (v < smallest) smallest = v;
|
|
143
|
+
}
|
|
144
|
+
return toSolInt(smallest);
|
|
145
|
+
});
|
|
146
|
+
registerListSolIntReducer("max", (list) => {
|
|
147
|
+
const items = list;
|
|
148
|
+
if (items.length === 0) throw new Error("list<sol_int>.max(): list is empty");
|
|
149
|
+
let largest = (0, _seljs_types.toBigInt)(items[0]);
|
|
150
|
+
for (let i = 1; i < items.length; i++) {
|
|
151
|
+
const v = (0, _seljs_types.toBigInt)(items[i]);
|
|
152
|
+
if (v > largest) largest = v;
|
|
153
|
+
}
|
|
154
|
+
return toSolInt(largest);
|
|
155
|
+
});
|
|
123
156
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
124
157
|
env.registerFunction("isZeroAddress(sol_address): bool", (addr) => (0, _seljs_types.toAddress)(addr) === ZERO_ADDRESS);
|
|
125
158
|
env.registerFunction("isZeroAddress(string): bool", (addr) => (0, _seljs_types.toAddress)(addr) === ZERO_ADDRESS);
|
|
@@ -119,6 +119,39 @@ const registerSolidityTypes = (env) => {
|
|
|
119
119
|
const v = toBigInt(a);
|
|
120
120
|
return toSolInt(v < 0n ? -v : v);
|
|
121
121
|
});
|
|
122
|
+
const registerListSolIntReducer = (name, handler) => {
|
|
123
|
+
env.registerFunction({
|
|
124
|
+
name,
|
|
125
|
+
receiverType: "list<sol_int>",
|
|
126
|
+
returnType: "sol_int",
|
|
127
|
+
params: []
|
|
128
|
+
}, handler);
|
|
129
|
+
};
|
|
130
|
+
registerListSolIntReducer("sum", (list) => {
|
|
131
|
+
let total = 0n;
|
|
132
|
+
for (const item of list) total += toBigInt(item);
|
|
133
|
+
return toSolInt(total);
|
|
134
|
+
});
|
|
135
|
+
registerListSolIntReducer("min", (list) => {
|
|
136
|
+
const items = list;
|
|
137
|
+
if (items.length === 0) throw new Error("list<sol_int>.min(): list is empty");
|
|
138
|
+
let smallest = toBigInt(items[0]);
|
|
139
|
+
for (let i = 1; i < items.length; i++) {
|
|
140
|
+
const v = toBigInt(items[i]);
|
|
141
|
+
if (v < smallest) smallest = v;
|
|
142
|
+
}
|
|
143
|
+
return toSolInt(smallest);
|
|
144
|
+
});
|
|
145
|
+
registerListSolIntReducer("max", (list) => {
|
|
146
|
+
const items = list;
|
|
147
|
+
if (items.length === 0) throw new Error("list<sol_int>.max(): list is empty");
|
|
148
|
+
let largest = toBigInt(items[0]);
|
|
149
|
+
for (let i = 1; i < items.length; i++) {
|
|
150
|
+
const v = toBigInt(items[i]);
|
|
151
|
+
if (v > largest) largest = v;
|
|
152
|
+
}
|
|
153
|
+
return toSolInt(largest);
|
|
154
|
+
});
|
|
122
155
|
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
123
156
|
env.registerFunction("isZeroAddress(sol_address): bool", (addr) => toAddress(addr) === ZERO_ADDRESS);
|
|
124
157
|
env.registerFunction("isZeroAddress(string): bool", (addr) => toAddress(addr) === ZERO_ADDRESS);
|
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.27",
|
|
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.27",
|
|
54
54
|
"@seljs/schema": "1.2.0",
|
|
55
|
-
"@seljs/types": "1.3.0-beta.
|
|
55
|
+
"@seljs/types": "1.3.0-beta.27",
|
|
56
56
|
"debug": "^4.4.3",
|
|
57
57
|
"viem": "^2.47.6"
|
|
58
58
|
},
|