@seljs/env 1.3.0-beta.14 → 1.3.0-beta.18

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
  },
@@ -375,7 +375,36 @@ const SOLIDITY_PRIMITIVE_TYPES = [
375
375
  description: "32-byte fixed array"
376
376
  }
377
377
  ];
378
+ /**
379
+ * Struct type backing the `sel.*` namespace — one field per entry in
380
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
381
+ * `schema.types` lets editor autocomplete populate member completions on
382
+ * dot-access against `sel`.
383
+ */
384
+ const SEL_NAMESPACE_TYPE = {
385
+ name: "SelNamespace",
386
+ kind: "struct",
387
+ description: "Namespace for SEL library-provided conveniences.",
388
+ fields: _seljs_types.EVM_CONSTANTS.map((c) => ({
389
+ name: c.name,
390
+ type: c.type,
391
+ description: c.description
392
+ }))
393
+ };
394
+ /**
395
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
396
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
397
+ * path doesn't try to re-register what `registerSolidityTypes` already
398
+ * bound via `registerConstant`.
399
+ */
400
+ const CEL_BUILTIN_CONSTANTS = [{
401
+ name: "sel",
402
+ type: "SelNamespace",
403
+ description: "SEL library-provided conveniences: scaling factors, fixed-point divisors, and sentinel addresses."
404
+ }];
378
405
  //#endregion
406
+ exports.CEL_BUILTIN_CONSTANTS = CEL_BUILTIN_CONSTANTS;
379
407
  exports.CEL_BUILTIN_FUNCTIONS = CEL_BUILTIN_FUNCTIONS;
380
408
  exports.CEL_BUILTIN_MACROS = CEL_BUILTIN_MACROS;
409
+ exports.SEL_NAMESPACE_TYPE = SEL_NAMESPACE_TYPE;
381
410
  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
  },
@@ -375,5 +375,32 @@ const SOLIDITY_PRIMITIVE_TYPES = [
375
375
  description: "32-byte fixed array"
376
376
  }
377
377
  ];
378
+ /**
379
+ * Struct type backing the `sel.*` namespace — one field per entry in
380
+ * `EVM_CONSTANTS` (e.g. `sel.WAD`, `sel.ZERO_ADDRESS`). Surfacing this in
381
+ * `schema.types` lets editor autocomplete populate member completions on
382
+ * dot-access against `sel`.
383
+ */
384
+ const SEL_NAMESPACE_TYPE = {
385
+ name: "SelNamespace",
386
+ kind: "struct",
387
+ description: "Namespace for SEL library-provided conveniences.",
388
+ fields: EVM_CONSTANTS.map((c) => ({
389
+ name: c.name,
390
+ type: c.type,
391
+ description: c.description
392
+ }))
393
+ };
394
+ /**
395
+ * Runtime-registered identifiers exposed by every SEL environment. Kept
396
+ * in a dedicated bucket (not `schema.variables`) so the schema-hydration
397
+ * path doesn't try to re-register what `registerSolidityTypes` already
398
+ * bound via `registerConstant`.
399
+ */
400
+ const CEL_BUILTIN_CONSTANTS = [{
401
+ name: "sel",
402
+ type: "SelNamespace",
403
+ description: "SEL library-provided conveniences: scaling factors, fixed-point divisors, and sentinel addresses."
404
+ }];
378
405
  //#endregion
379
- export { CEL_BUILTIN_FUNCTIONS, CEL_BUILTIN_MACROS, SOLIDITY_PRIMITIVE_TYPES };
406
+ 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.14",
3
+ "version": "1.3.0-beta.18",
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.14",
51
+ "@seljs/common": "1.3.0-beta.18",
52
52
  "@seljs/schema": "1.2.0",
53
- "@seljs/types": "1.3.0-beta.14",
53
+ "@seljs/types": "1.3.0-beta.18",
54
54
  "abitype": "^1.2.3",
55
55
  "viem": "^2.47.6"
56
56
  },