@seljs/env 1.3.0-beta.19 → 1.3.0-beta.21

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/builder.cjs CHANGED
@@ -238,8 +238,10 @@ const buildSchema = (config) => {
238
238
  version: "1.0.0",
239
239
  contracts,
240
240
  variables: [...contextVariables, ...featureVariables],
241
+ constants: require_builtins.CEL_BUILTIN_CONSTANTS,
241
242
  types: [
242
243
  ...require_builtins.SOLIDITY_PRIMITIVE_TYPES,
244
+ require_builtins.SEL_NAMESPACE_TYPE,
243
245
  ...acc.types,
244
246
  ...featureTypes
245
247
  ],
package/dist/builder.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
1
+ import { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
2
2
  import { getFeatureDefinition } from "./feature-registry.mjs";
3
3
  import { structTypeName } from "@seljs/common";
4
4
  import { mapSolidityTypeToCEL } from "@seljs/types";
@@ -238,8 +238,10 @@ const buildSchema = (config) => {
238
238
  version: "1.0.0",
239
239
  contracts,
240
240
  variables: [...contextVariables, ...featureVariables],
241
+ constants: CEL_BUILTIN_CONSTANTS,
241
242
  types: [
242
243
  ...SOLIDITY_PRIMITIVE_TYPES,
244
+ SEL_NAMESPACE_TYPE,
243
245
  ...acc.types,
244
246
  ...featureTypes
245
247
  ],
package/dist/builtins.cjs CHANGED
@@ -149,27 +149,27 @@ const CEL_BUILTIN_FUNCTIONS = [
149
149
  },
150
150
  {
151
151
  name: "parseUnits",
152
- signature: "parseUnits(string|int|double|sol_int, int): sol_int",
153
- description: "Scales a human-readable value by 10^decimals, producing a sol_int. Mirrors viem/ethers parseUnits.",
152
+ signature: "parseUnits(string|int|double|sol_int, int|sol_int): sol_int",
153
+ description: "Scales a human-readable value by 10^decimals, producing a sol_int. Mirrors viem/ethers parseUnits. The decimals argument accepts either a plain int or a sol_int (e.g. the return of token.decimals()).",
154
154
  params: [{
155
155
  name: "value",
156
156
  type: "string|int|double|sol_int"
157
157
  }, {
158
158
  name: "decimals",
159
- type: "int"
159
+ type: "int|sol_int"
160
160
  }],
161
161
  returns: "sol_int"
162
162
  },
163
163
  {
164
164
  name: "formatUnits",
165
- signature: "formatUnits(sol_int|int, int): double",
166
- description: "Scales a sol_int down by 10^decimals, producing a double for readable comparisons.",
165
+ signature: "formatUnits(sol_int|int, int|sol_int): double",
166
+ description: "Scales a sol_int down by 10^decimals, producing a double for readable comparisons. The decimals argument accepts either a plain int or a sol_int (e.g. the return of token.decimals()).",
167
167
  params: [{
168
168
  name: "value",
169
169
  type: "sol_int|int"
170
170
  }, {
171
171
  name: "decimals",
172
- type: "int"
172
+ type: "int|sol_int"
173
173
  }],
174
174
  returns: "double"
175
175
  },
@@ -227,6 +227,49 @@ const CEL_BUILTIN_FUNCTIONS = [
227
227
  }],
228
228
  returns: "bool"
229
229
  },
230
+ {
231
+ name: "hexBytes",
232
+ signature: "hexBytes(string): bytes",
233
+ description: "Decodes a 0x-prefixed hex string into a bytes value. For pasting pre-computed hashes, role constants, merkle roots, signatures.",
234
+ params: [{
235
+ name: "hex",
236
+ type: "string"
237
+ }],
238
+ returns: "bytes"
239
+ },
240
+ {
241
+ name: "hexBytes",
242
+ signature: "hexBytes(string, int): bytes",
243
+ description: "Decodes a hex string and asserts the result is exactly N bytes. Use when a bytesN ABI parameter requires a specific length (bytes4 selectors, bytes32 namehashes / EIP-712 digests, bytes65 signatures).",
244
+ params: [{
245
+ name: "hex",
246
+ type: "string"
247
+ }, {
248
+ name: "length",
249
+ type: "int"
250
+ }],
251
+ returns: "bytes"
252
+ },
253
+ {
254
+ name: "keccak256",
255
+ signature: "keccak256(string): bytes",
256
+ description: "Keccak-256 hash of the UTF-8 encoded string. Use for role identifiers (e.g. keccak256(\"MINTER_ROLE\")), event topic hashes, and EIP-712 type hashes.",
257
+ params: [{
258
+ name: "value",
259
+ type: "string"
260
+ }],
261
+ returns: "bytes"
262
+ },
263
+ {
264
+ name: "keccak256",
265
+ signature: "keccak256(bytes): bytes",
266
+ description: "Keccak-256 hash of the bytes value.",
267
+ params: [{
268
+ name: "value",
269
+ type: "bytes"
270
+ }],
271
+ returns: "bytes"
272
+ },
230
273
  {
231
274
  name: "timestamp",
232
275
  signature: "timestamp(string): timestamp",
@@ -375,7 +418,36 @@ const SOLIDITY_PRIMITIVE_TYPES = [
375
418
  description: "32-byte fixed array"
376
419
  }
377
420
  ];
421
+ /**
422
+ * Struct type backing the `sel.*` namespace — one field per entry in
423
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
424
+ * `schema.types` lets editor autocomplete populate member completions on
425
+ * dot-access against `sel`.
426
+ */
427
+ const SEL_NAMESPACE_TYPE = {
428
+ name: "SelNamespace",
429
+ kind: "struct",
430
+ description: "Namespace for SEL library-provided conveniences.",
431
+ fields: _seljs_types.EVM_CONSTANTS.map((c) => ({
432
+ name: c.name,
433
+ type: c.type,
434
+ description: c.description
435
+ }))
436
+ };
437
+ /**
438
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
439
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
440
+ * path doesn't try to re-register what `registerSolidityTypes` already
441
+ * bound via `registerConstant`.
442
+ */
443
+ const CEL_BUILTIN_CONSTANTS = [{
444
+ name: "sel",
445
+ type: "SelNamespace",
446
+ description: "SEL library-provided conveniences: scaling factors, fixed-point divisors, and sentinel addresses."
447
+ }];
378
448
  //#endregion
449
+ exports.CEL_BUILTIN_CONSTANTS = CEL_BUILTIN_CONSTANTS;
379
450
  exports.CEL_BUILTIN_FUNCTIONS = CEL_BUILTIN_FUNCTIONS;
380
451
  exports.CEL_BUILTIN_MACROS = CEL_BUILTIN_MACROS;
452
+ exports.SEL_NAMESPACE_TYPE = SEL_NAMESPACE_TYPE;
381
453
  exports.SOLIDITY_PRIMITIVE_TYPES = SOLIDITY_PRIMITIVE_TYPES;
@@ -1,4 +1,4 @@
1
- import { FunctionSchema, MacroSchema, TypeSchema } from "@seljs/schema";
1
+ import { FunctionSchema, MacroSchema, TypeSchema, VariableSchema } from "@seljs/schema";
2
2
 
3
3
  //#region src/builtins.d.ts
4
4
  /**
@@ -16,5 +16,19 @@ declare const CEL_BUILTIN_MACROS: MacroSchema[];
16
16
  * These are the basic type building blocks for the schema.
17
17
  */
18
18
  declare const SOLIDITY_PRIMITIVE_TYPES: TypeSchema[];
19
+ /**
20
+ * Struct type backing the `sel.*` namespace — one field per entry in
21
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
22
+ * `schema.types` lets editor autocomplete populate member completions on
23
+ * dot-access against `sel`.
24
+ */
25
+ declare const SEL_NAMESPACE_TYPE: TypeSchema;
26
+ /**
27
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
28
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
29
+ * path doesn't try to re-register what `registerSolidityTypes` already
30
+ * bound via `registerConstant`.
31
+ */
32
+ declare const CEL_BUILTIN_CONSTANTS: VariableSchema[];
19
33
  //#endregion
20
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES };
34
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES };
@@ -1,4 +1,4 @@
1
- import { FunctionSchema, MacroSchema, TypeSchema } from "@seljs/schema";
1
+ import { FunctionSchema, MacroSchema, TypeSchema, VariableSchema } from "@seljs/schema";
2
2
 
3
3
  //#region src/builtins.d.ts
4
4
  /**
@@ -16,5 +16,19 @@ declare const CEL_BUILTIN_MACROS: MacroSchema[];
16
16
  * These are the basic type building blocks for the schema.
17
17
  */
18
18
  declare const SOLIDITY_PRIMITIVE_TYPES: TypeSchema[];
19
+ /**
20
+ * Struct type backing the `sel.*` namespace — one field per entry in
21
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
22
+ * `schema.types` lets editor autocomplete populate member completions on
23
+ * dot-access against `sel`.
24
+ */
25
+ declare const SEL_NAMESPACE_TYPE: TypeSchema;
26
+ /**
27
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
28
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
29
+ * path doesn't try to re-register what `registerSolidityTypes` already
30
+ * bound via `registerConstant`.
31
+ */
32
+ declare const CEL_BUILTIN_CONSTANTS: VariableSchema[];
19
33
  //#endregion
20
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES };
34
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES };
package/dist/builtins.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { SOLIDITY_TYPES } from "@seljs/types";
1
+ import { EVM_CONSTANTS, SOLIDITY_TYPES } from "@seljs/types";
2
2
  //#region src/builtins.ts
3
3
  /**
4
4
  * Built-in CEL functions available in SEL expressions.
@@ -149,27 +149,27 @@ const CEL_BUILTIN_FUNCTIONS = [
149
149
  },
150
150
  {
151
151
  name: "parseUnits",
152
- signature: "parseUnits(string|int|double|sol_int, int): sol_int",
153
- description: "Scales a human-readable value by 10^decimals, producing a sol_int. Mirrors viem/ethers parseUnits.",
152
+ signature: "parseUnits(string|int|double|sol_int, int|sol_int): sol_int",
153
+ description: "Scales a human-readable value by 10^decimals, producing a sol_int. Mirrors viem/ethers parseUnits. The decimals argument accepts either a plain int or a sol_int (e.g. the return of token.decimals()).",
154
154
  params: [{
155
155
  name: "value",
156
156
  type: "string|int|double|sol_int"
157
157
  }, {
158
158
  name: "decimals",
159
- type: "int"
159
+ type: "int|sol_int"
160
160
  }],
161
161
  returns: "sol_int"
162
162
  },
163
163
  {
164
164
  name: "formatUnits",
165
- signature: "formatUnits(sol_int|int, int): double",
166
- description: "Scales a sol_int down by 10^decimals, producing a double for readable comparisons.",
165
+ signature: "formatUnits(sol_int|int, int|sol_int): double",
166
+ description: "Scales a sol_int down by 10^decimals, producing a double for readable comparisons. The decimals argument accepts either a plain int or a sol_int (e.g. the return of token.decimals()).",
167
167
  params: [{
168
168
  name: "value",
169
169
  type: "sol_int|int"
170
170
  }, {
171
171
  name: "decimals",
172
- type: "int"
172
+ type: "int|sol_int"
173
173
  }],
174
174
  returns: "double"
175
175
  },
@@ -227,6 +227,49 @@ const CEL_BUILTIN_FUNCTIONS = [
227
227
  }],
228
228
  returns: "bool"
229
229
  },
230
+ {
231
+ name: "hexBytes",
232
+ signature: "hexBytes(string): bytes",
233
+ description: "Decodes a 0x-prefixed hex string into a bytes value. For pasting pre-computed hashes, role constants, merkle roots, signatures.",
234
+ params: [{
235
+ name: "hex",
236
+ type: "string"
237
+ }],
238
+ returns: "bytes"
239
+ },
240
+ {
241
+ name: "hexBytes",
242
+ signature: "hexBytes(string, int): bytes",
243
+ description: "Decodes a hex string and asserts the result is exactly N bytes. Use when a bytesN ABI parameter requires a specific length (bytes4 selectors, bytes32 namehashes / EIP-712 digests, bytes65 signatures).",
244
+ params: [{
245
+ name: "hex",
246
+ type: "string"
247
+ }, {
248
+ name: "length",
249
+ type: "int"
250
+ }],
251
+ returns: "bytes"
252
+ },
253
+ {
254
+ name: "keccak256",
255
+ signature: "keccak256(string): bytes",
256
+ description: "Keccak-256 hash of the UTF-8 encoded string. Use for role identifiers (e.g. keccak256(\"MINTER_ROLE\")), event topic hashes, and EIP-712 type hashes.",
257
+ params: [{
258
+ name: "value",
259
+ type: "string"
260
+ }],
261
+ returns: "bytes"
262
+ },
263
+ {
264
+ name: "keccak256",
265
+ signature: "keccak256(bytes): bytes",
266
+ description: "Keccak-256 hash of the bytes value.",
267
+ params: [{
268
+ name: "value",
269
+ type: "bytes"
270
+ }],
271
+ returns: "bytes"
272
+ },
230
273
  {
231
274
  name: "timestamp",
232
275
  signature: "timestamp(string): timestamp",
@@ -375,5 +418,32 @@ const SOLIDITY_PRIMITIVE_TYPES = [
375
418
  description: "32-byte fixed array"
376
419
  }
377
420
  ];
421
+ /**
422
+ * Struct type backing the `sel.*` namespace — one field per entry in
423
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
424
+ * `schema.types` lets editor autocomplete populate member completions on
425
+ * dot-access against `sel`.
426
+ */
427
+ const SEL_NAMESPACE_TYPE = {
428
+ name: "SelNamespace",
429
+ kind: "struct",
430
+ description: "Namespace for SEL library-provided conveniences.",
431
+ fields: EVM_CONSTANTS.map((c) => ({
432
+ name: c.name,
433
+ type: c.type,
434
+ description: c.description
435
+ }))
436
+ };
437
+ /**
438
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
439
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
440
+ * path doesn't try to re-register what `registerSolidityTypes` already
441
+ * bound via `registerConstant`.
442
+ */
443
+ const CEL_BUILTIN_CONSTANTS = [{
444
+ name: "sel",
445
+ type: "SelNamespace",
446
+ description: "SEL library-provided conveniences: scaling factors, fixed-point divisors, and sentinel addresses."
447
+ }];
378
448
  //#endregion
379
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES };
449
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES };
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_builtins = require("./builtins.cjs");
3
3
  const require_builder = require("./builder.cjs");
4
+ exports.CEL_BUILTIN_CONSTANTS = require_builtins.CEL_BUILTIN_CONSTANTS;
4
5
  exports.CEL_BUILTIN_FUNCTIONS = require_builtins.CEL_BUILTIN_FUNCTIONS;
5
6
  exports.CEL_BUILTIN_MACROS = require_builtins.CEL_BUILTIN_MACROS;
7
+ exports.SEL_NAMESPACE_TYPE = require_builtins.SEL_NAMESPACE_TYPE;
6
8
  exports.SOLIDITY_PRIMITIVE_TYPES = require_builtins.SOLIDITY_PRIMITIVE_TYPES;
7
9
  exports.buildSchema = require_builder.buildSchema;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { ContractInput, SchemaBuilderConfig, buildSchema } from "./builder.cjs";
2
- import { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.cjs";
3
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, ContractInput, SOLIDITY_PRIMITIVE_TYPES, SchemaBuilderConfig, buildSchema };
2
+ import { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.cjs";
3
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, ContractInput, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES, SchemaBuilderConfig, buildSchema };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { ContractInput, SchemaBuilderConfig, buildSchema } from "./builder.mjs";
2
- import { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
3
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, ContractInput, SOLIDITY_PRIMITIVE_TYPES, SchemaBuilderConfig, buildSchema };
2
+ import { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
3
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, ContractInput, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES, SchemaBuilderConfig, buildSchema };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
1
+ import { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES } from "./builtins.mjs";
2
2
  import { buildSchema } from "./builder.mjs";
3
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES, buildSchema };
3
+ export { CEL_BUILTIN_CONSTANTS, CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SEL_NAMESPACE_TYPE, SOLIDITY_PRIMITIVE_TYPES, buildSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seljs/env",
3
- "version": "1.3.0-beta.19",
3
+ "version": "1.3.0-beta.21",
4
4
  "repository": {
5
5
  "url": "https://github.com/abinnovision/seljs"
6
6
  },
@@ -48,9 +48,9 @@
48
48
  ]
49
49
  },
50
50
  "dependencies": {
51
- "@seljs/common": "1.3.0-beta.19",
51
+ "@seljs/common": "1.3.0-beta.21",
52
52
  "@seljs/schema": "1.2.0",
53
- "@seljs/types": "1.3.0-beta.19",
53
+ "@seljs/types": "1.3.0-beta.21",
54
54
  "abitype": "^1.2.3",
55
55
  "viem": "^2.47.6"
56
56
  },