diff --git a/CLAUDE.md b/CLAUDE.md index df962edd7..63b6bdff1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -27,7 +27,7 @@ Prefer Public module API for testing. -Verify that tests pass by running a compiler `pnpm rescript-legacy` and tests `pnpm vitest run`. +Verify that tests pass by running a compiler `pnpm rescript` and tests `pnpm vitest run`. ## ReScript diff --git a/packages/build-envio/src/build-artifact.ts b/packages/build-envio/src/build-artifact.ts index 5167d4ff8..b46c6c474 100644 --- a/packages/build-envio/src/build-artifact.ts +++ b/packages/build-envio/src/build-artifact.ts @@ -93,9 +93,9 @@ export function buildPackageJson( */ export function compileRescript(envioDir: string): void { console.log("Compiling ReScript..."); - // Use the rescript-legacy binary directly to avoid pnpm workspace detection issues. + // Use the rescript binary directly to avoid pnpm workspace detection issues. // With pnpm's default isolated layout, the bin is in envio's own node_modules. - execSync("./node_modules/.bin/rescript-legacy", { + execSync("./node_modules/.bin/rescript", { cwd: envioDir, stdio: "inherit", }); diff --git a/packages/cli/src/config_parsing/entity_parsing.rs b/packages/cli/src/config_parsing/entity_parsing.rs index 222a6cfc2..5f1f09003 100644 --- a/packages/cli/src/config_parsing/entity_parsing.rs +++ b/packages/cli/src/config_parsing/entity_parsing.rs @@ -9,7 +9,7 @@ use crate::{ constants::project_paths::DEFAULT_SCHEMA_PATH, hbs_templating::codegen_templates::DerivedFieldTemplate, project_paths::{path_utils, ParsedProjectPaths}, - type_schema::{SchemaMode, TypeIdent}, + type_schema::TypeIdent, utils::{text::Capitalize, unique_hashmap}, }; use alloy_dyn_abi::DynSolType; @@ -865,23 +865,15 @@ impl Field { FieldType::RegularField { field_type: gql_field_type, .. - } => { - let res_type = self - .field_type - .to_rescript_type(schema) - .context("Failed getting rescript type")?; - - Ok(Some(PGField { - field_name: self.name.clone(), - field_type: gql_field_type.to_underlying_postgres_primitive(schema)?, - is_array: gql_field_type.is_array(), - is_index: self.is_indexed_field(entity), - linked_entity: gql_field_type.get_linked_entity(schema)?, - is_primary_key: self.is_primary_key(), - is_nullable: gql_field_type.is_optional(), - res_schema_code: res_type.to_rescript_schema(&SchemaMode::ForDb), - })) - } + } => Ok(Some(PGField { + field_name: self.name.clone(), + field_type: gql_field_type.to_underlying_postgres_primitive(schema)?, + is_array: gql_field_type.is_array(), + is_index: self.is_indexed_field(entity), + linked_entity: gql_field_type.get_linked_entity(schema)?, + is_primary_key: self.is_primary_key(), + is_nullable: gql_field_type.is_optional(), + })), } } diff --git a/packages/cli/src/config_parsing/field_types.rs b/packages/cli/src/config_parsing/field_types.rs index 295a8d419..5096b457b 100644 --- a/packages/cli/src/config_parsing/field_types.rs +++ b/packages/cli/src/config_parsing/field_types.rs @@ -72,5 +72,4 @@ pub struct Field { pub is_nullable: bool, pub is_array: bool, pub field_type: Primitive, - pub res_schema_code: String, } diff --git a/packages/cli/src/hbs_templating/codegen_templates.rs b/packages/cli/src/hbs_templating/codegen_templates.rs index da0ea37f7..e7d396f88 100644 --- a/packages/cli/src/hbs_templating/codegen_templates.rs +++ b/packages/cli/src/hbs_templating/codegen_templates.rs @@ -19,7 +19,7 @@ use crate::{ persisted_state::{PersistedState, PersistedStateJsonString}, project_paths::{path_utils::add_leading_relative_dot, ParsedProjectPaths}, template_dirs::TemplateDirs, - type_schema::{RecordField, SchemaMode, TypeExpr, TypeIdent}, + type_schema::{RecordField, TypeExpr, TypeIdent}, utils::text::{Capitalize, CapitalizedOptions, CaseOptions}, }; use anyhow::{anyhow, Context, Result}; @@ -194,7 +194,6 @@ impl CompositeIndexFieldTemplate { pub struct EntityRecordTypeTemplate { pub name: CapitalizedOptions, pub type_code: String, - pub schema_code: String, pub get_where_filter_code: String, pub postgres_fields: Vec, pub composite_indices: Vec>, @@ -236,9 +235,7 @@ impl EntityRecordTypeTemplate { entity.name ))?; - let type_expr = TypeExpr::Record(record_fields); - let type_code = type_expr.to_string(); - let schema_code = type_expr.to_rescript_schema(&"t".to_string(), &SchemaMode::ForDb); + let type_code = TypeExpr::Record(record_fields).to_string(); let postgres_fields = entity .get_fields() @@ -292,7 +289,6 @@ impl EntityRecordTypeTemplate { name: entity.name.to_capitalized_options(), postgres_fields, type_code, - schema_code, get_where_filter_code, derived_fields, composite_indices, @@ -656,10 +652,8 @@ impl ContractTemplate { // template literal. format!( "let abi = FuelSDK.transpileAbi((await \ - Utils.importPathWithJson(`../{}`))[\"default\"])\n{}\n{}", - abi.path_relative_to_root, - all_abi_type_declarations, - all_abi_type_declarations.to_rescript_schema(&SchemaMode::ForDb) + Utils.importPathWithJson(`../{}`))[\"default\"])\n{}", + abi.path_relative_to_root, all_abi_type_declarations, ) } }; @@ -847,7 +841,6 @@ impl FieldSelection { block_field_templates.push(SelectedFieldTemplate { name: name.clone(), res_name, - default_value_rescript: field.data_type.get_default_value_rescript(), ts_type: field.data_type.to_ts_type_string(), res_type: field.data_type.to_string(), }); @@ -865,7 +858,6 @@ impl FieldSelection { transaction_field_templates.push(SelectedFieldTemplate { name: name.clone(), res_name, - default_value_rescript: field.data_type.get_default_value_rescript(), ts_type: field.data_type.to_ts_type_string(), res_type: field.data_type.to_string(), }); @@ -901,7 +893,6 @@ struct SelectedFieldTemplate { res_name: String, res_type: String, ts_type: String, - default_value_rescript: String, } #[derive(Serialize)] @@ -1633,8 +1624,6 @@ type handlerContext = {{ //**CONTRACTS** //************* -open RescriptSchema - module Transaction = {{ type t = {transaction_module_type} }} diff --git a/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_generates_correct_types_and_values.snap b/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_generates_correct_types_and_values.snap index 36039def3..9054a8020 100644 --- a/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_generates_correct_types_and_values.snap +++ b/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_generates_correct_types_and_values.snap @@ -6,8 +6,6 @@ expression: project_template.indexer_code //**CONTRACTS** //************* -open RescriptSchema - module Transaction = { type t = { @deprecated("Not selected for this event. To enable, add to config.yaml:\nevents:\n - event: global\n field_selection:\n transaction_fields:\n - transactionIndex") diff --git a/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_multiple_chains.snap b/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_multiple_chains.snap index 9f63a6d1d..59dec7aba 100644 --- a/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_multiple_chains.snap +++ b/packages/cli/src/hbs_templating/snapshots/envio__hbs_templating__codegen_templates__test__indexer_code_multiple_chains.snap @@ -6,8 +6,6 @@ expression: project_template.indexer_code //**CONTRACTS** //************* -open RescriptSchema - module Transaction = { type t = { @deprecated("Not selected for this event. To enable, add to config.yaml:\nevents:\n - event: global\n field_selection:\n transaction_fields:\n - transactionIndex") diff --git a/packages/cli/src/type_schema.rs b/packages/cli/src/type_schema.rs index 8782a6cbc..963410028 100644 --- a/packages/cli/src/type_schema.rs +++ b/packages/cli/src/type_schema.rs @@ -6,16 +6,10 @@ use anyhow::{anyhow, Result}; use core::fmt; use itertools::Itertools; use serde::Serialize; -use std::{collections::HashSet, fmt::Display}; +use std::fmt::Display; pub struct TypeDeclMulti(Vec); -#[derive(Debug, PartialEq, Clone)] -pub enum SchemaMode { - ForDb, - ForFieldSelection, -} - impl TypeDeclMulti { pub fn type_declarations(&self) -> &[TypeDecl] { &self.0 @@ -29,46 +23,6 @@ impl TypeDeclMulti { Self(type_declarations) } - pub fn to_rescript_schema(&self, mode: &SchemaMode) -> String { - let mut sorted: Vec = vec![]; - let mut registered: HashSet = HashSet::new(); - - let type_decls_with_deps: Vec<(TypeDecl, Vec)> = self - .0 - .iter() - .map(|decl| { - let deps = decl.type_expr.dependencies(); - (decl.clone(), deps) - }) - .collect(); - - // Not the most optimised algorithm, but it's simple and works: - // Iterate over the type declarations and add them to - // the sorted list if all their dependencies already added - repeat - while sorted.len() < type_decls_with_deps.len() { - for (decl, deps) in &type_decls_with_deps { - if !registered.contains(&decl.name) - && deps.iter().all(|dep| registered.contains(dep)) - { - sorted.push(decl.clone()); - registered.insert(decl.name.clone()); - } - } - } - - sorted - .iter() - .map(|decl| { - format!( - "let {}Schema = {}", - decl.name, - decl.to_rescript_schema(&decl.name, mode) - ) - }) - .collect::>() - .join("\n") - } - fn to_string_internal(&self) -> String { match self.0.as_slice() { [single_decl] => single_decl.to_string(), @@ -159,31 +113,6 @@ impl TypeDecl { ) } - pub fn to_rescript_schema(&self, type_name: &String, mode: &SchemaMode) -> String { - if self.parameters.is_empty() { - self.type_expr.to_rescript_schema(type_name, mode) - } else { - let params = self - .parameters - .iter() - .map(|param| format!("_{param}Schema: S.t<'{param}>")) - .collect::>() - .join(", "); - let type_name = format!( - "{type_name}<{}>", - self.parameters - .iter() - .map(|param| format!("'{}", param)) - .join(", ") - ); - format!( - "({}) => {}", - params, - self.type_expr.to_rescript_schema(&type_name, mode) - ) - } - } - /// Renders a TypeScript type declaration with namespace-qualified references. /// Mirrors `to_string_no_type_keyword()` but for TS namespace syntax. pub fn to_ts_type_decl(&self, ns: &str) -> String { @@ -257,56 +186,6 @@ impl TypeExpr { } } - pub fn to_rescript_schema(&self, type_name: &String, mode: &SchemaMode) -> String { - match self { - Self::Identifier(type_ident) => type_ident.to_rescript_schema(mode), - Self::Variant(items) => { - let item_schemas = items - .iter() - .map(|item| { - format!( - r#"S.object((s): {type_name} => -{{ - s.tag("case", "{}") - {}({{payload: s.field("payload", {})}}) -}})"#, - item.name, - item.name, - item.payload.to_rescript_schema(mode) - ) - }) - .collect::>() - .join(", "); - format!("S.union([{}])", item_schemas) - } - Self::Record(fields) => { - if fields.is_empty() { - format!("S.object((_): {} => {{}})", type_name) - } else { - let inner_str = fields - .iter() - .map(|field| { - format!( - "{}: s.field(\"{}\", {})", - &field.name, - // For raw events we keep the ReScript name, - // if we need to serialize to the original name, - // then it'll require a flag in the args - field - .as_name - .as_ref() - .map_or(field.name.as_str(), |name| name.as_str()), - field.type_ident.to_rescript_schema(mode) - ) - }) - .collect::>() - .join(", "); - format!("S.object((s): {type_name} => {{{inner_str}}})") - } - } - } - } - /// Renders TypeScript with type references qualified by namespace (e.g., `FuelTypes.Greeter.type5`). pub fn to_ts_type_string_with_namespace(&self, ns: &str) -> String { match self { @@ -381,20 +260,6 @@ impl TypeExpr { .join(" | "), } } - - pub fn dependencies(&self) -> Vec { - match self { - Self::Identifier(type_ident) => type_ident.dependencies(), - Self::Variant(items) => items - .iter() - .flat_map(|item| item.payload.dependencies()) - .collect(), - Self::Record(fields) => fields - .iter() - .flat_map(|field| field.type_ident.dependencies()) - .collect(), - } - } } #[derive(Debug, PartialEq, Eq, Hash, Clone)] @@ -713,128 +578,6 @@ impl TypeIdent { } } - pub fn to_rescript_schema(&self, mode: &SchemaMode) -> String { - match self { - Self::Unit => "S.literal(%raw(`null`))->S.shape(_ => ())".to_string(), - Self::Int => "S.int".to_string(), - Self::Unknown => "S.unknown".to_string(), - Self::Float => "S.float".to_string(), - Self::BigInt => match mode { - SchemaMode::ForDb => "Utils.BigInt.schema".to_string(), - SchemaMode::ForFieldSelection => "Utils.BigInt.nativeSchema".to_string(), - }, - Self::BigDecimal => "BigDecimal.schema".to_string(), - Self::Address => "Address.schema".to_string(), - Self::String => "S.string".to_string(), - Self::Json => "S.json(~validate=false)".to_string(), - Self::ID => "S.string".to_string(), - Self::Bool => "S.bool".to_string(), - Self::Timestamp => "Utils.Schema.dbDate".to_string(), - Self::Array(inner_type) => { - format!("S.array({})", inner_type.to_rescript_schema(mode)) - } - Self::Option(inner_type) => { - let schema = match mode { - SchemaMode::ForDb => "S.null".to_string(), - SchemaMode::ForFieldSelection => "S.nullable".to_string(), - }; - format!("{schema}({})", inner_type.to_rescript_schema(mode)) - } - Self::Tuple(inner_types) => { - let inner_str = inner_types - .iter() - .enumerate() - .map(|(index, inner_type)| { - format!("s.item({index}, {})", inner_type.to_rescript_schema(mode)) - }) - .collect::>() - .join(", "); - format!("S.tuple(s => ({}))", inner_str) - } - // Inline records render as ReScript JS object types - // (`{"funder": Address.t, ...}`), so the schema callback must - // return a matching JS object literal with quoted keys — - // mirroring how `to_string_internal` and - // `get_default_value_rescript` emit them. - Self::Record(fields) => { - if fields.is_empty() { - unreachable!( - "TypeIdent::Record with zero fields — Solidity forbids zero-component structs" - ) - } - let inline_type = self.to_string(); - let inner = fields - .iter() - .map(|f| { - let key = f.as_name.as_ref().map_or(f.name.as_str(), |s| s.as_str()); - format!( - "\"{}\": s.field(\"{}\", {})", - key, - key, - f.type_ident.to_rescript_schema(mode) - ) - }) - .join(", "); - format!("S.object((s): {inline_type} => {{{inner}}})") - } - Self::SchemaEnum(enum_name) => { - format!("Enums.{}.config.schema", &enum_name.capitalized) - } - // TODO: ensure these are defined - Self::GenericParam(name) => { - format!("_{name}Schema") - } - Self::TypeApplication { name, type_params } if type_params.is_empty() => { - format!("{name}Schema") - } - Self::TypeApplication { - name, - type_params: params, - } => { - let param_schemas_joined = - params.iter().map(|p| p.to_rescript_schema(mode)).join(", "); - format!("{name}Schema({param_schemas_joined})") - } - } - } - - pub fn dependencies(&self) -> Vec { - match self { - Self::Unit - | Self::Int - | Self::Float - | Self::BigInt - | Self::BigDecimal - | Self::Address - | Self::String - | Self::Unknown - | Self::ID - | Self::Bool - | Self::Timestamp - | Self::Json - | Self::SchemaEnum(_) - | Self::GenericParam(_) => vec![], - Self::TypeApplication { - name, type_params, .. - } => { - let mut deps = vec![name.clone()]; - for param in type_params { - deps.extend(param.dependencies()); - } - deps - } - Self::Array(inner_type) | Self::Option(inner_type) => inner_type.dependencies(), - Self::Tuple(inner_types) => inner_types - .iter() - .flat_map(|inner_type| inner_type.dependencies()) - .collect(), - Self::Record(fields) => fields - .iter() - .flat_map(|f| f.type_ident.dependencies()) - .collect(), - } - } - pub fn get_default_value_rescript(&self) -> String { match self { Self::Unit => "()".to_string(), @@ -1040,141 +783,6 @@ mod tests { use super::*; use pretty_assertions::assert_eq; - #[test] - fn test_to_rescript_schema() { - assert_eq!( - TypeExpr::Identifier(TypeIdent::Bool) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.bool".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::Int) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.int".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::Float) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.float".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::Unit) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.literal(%raw(`null`))->S.shape(_ => ())".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::BigInt) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "Utils.BigInt.schema".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::BigInt) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForFieldSelection), - "Utils.BigInt.nativeSchema".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::BigDecimal) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "BigDecimal.schema".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::Address) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "Address.schema".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::String) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.string".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::ID) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.string".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::array(TypeIdent::Int)) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.array(S.int)".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::option(TypeIdent::BigInt)) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.null(Utils.BigInt.schema)".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::option(TypeIdent::BigInt)) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForFieldSelection), - "S.nullable(Utils.BigInt.nativeSchema)".to_string() - ); - assert_eq!( - TypeExpr::Identifier(TypeIdent::Tuple(vec![TypeIdent::Int, TypeIdent::Bool])) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.tuple(s => (s.item(0, S.int), s.item(1, S.bool)))".to_string() - ); - assert_eq!( - TypeExpr::Variant(vec![ - VariantConstr::new("ConstrA".to_string(), TypeIdent::Int), - VariantConstr::new("ConstrB".to_string(), TypeIdent::Bool), - ]) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - r#"S.union([S.object((s): eventArgs => -{ - s.tag("case", "ConstrA") - ConstrA({payload: s.field("payload", S.int)}) -}), S.object((s): eventArgs => -{ - s.tag("case", "ConstrB") - ConstrB({payload: s.field("payload", S.bool)}) -})])"# - .to_string() - ); - assert_eq!( - TypeExpr::Record(vec![ - RecordField::new("fieldA".to_string(), TypeIdent::Int), - RecordField::new("fieldB".to_string(), TypeIdent::Bool), - ]) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.object((s): eventArgs => {fieldA: s.field(\"fieldA\", S.int), fieldB: \ - s.field(\"fieldB\", S.bool)})" - .to_string() - ); - assert_eq!( - TypeExpr::Record(vec![]) - .to_rescript_schema(&"eventArgs".to_string(), &SchemaMode::ForDb), - "S.object((_): eventArgs => {})".to_string() - ); - // Inline TypeIdent::Record renders as a JS object schema with quoted - // keys, matching how `to_string_internal` and - // `get_default_value_rescript` emit them. Verifies the schema-side - // implementation that replaces a stale unreachable!() — see CodeRabbit - // review on PR #1096. - assert_eq!( - TypeIdent::Record(vec![ - RecordField::new("funder".to_string(), TypeIdent::Address), - RecordField::new("amount".to_string(), TypeIdent::BigInt), - ]) - .to_rescript_schema(&SchemaMode::ForDb), - "S.object((s): {\"funder\": Address.t, \"amount\": bigint} => \ - {\"funder\": s.field(\"funder\", Address.schema), \"amount\": s.field(\"amount\", \ - Utils.BigInt.schema)})" - .to_string() - ); - // Original keys with `as_name` (e.g. unnamed slots `"1"` from mixed - // tuples) round-trip to quoted keys via `as_name.unwrap_or(name)`. - assert_eq!( - TypeIdent::Record(vec![ - RecordField::new("label".to_string(), TypeIdent::String), - RecordField::new("1".to_string(), TypeIdent::BigInt), - ]) - .to_rescript_schema(&SchemaMode::ForDb), - "S.object((s): {\"label\": string, \"1\": bigint} => \ - {\"label\": s.field(\"label\", S.string), \"1\": s.field(\"1\", \ - Utils.BigInt.schema)})" - .to_string() - ); - } - #[test] fn type_decl_to_string_primitive() { let type_decl = TypeDecl { @@ -1391,31 +999,6 @@ mod tests { assert_eq!(type_decl_multi.to_string(), expected); } - #[test] - fn test_recursive_type_application_dependencies() { - let type19 = TypeIdent::TypeApplication { - name: "type19".to_string(), - type_params: vec![TypeIdent::TypeApplication { - name: "type18".to_string(), - type_params: vec![TypeIdent::TypeApplication { - name: "type17".to_string(), - type_params: vec![], - }], - }], - }; - - let deps = type19.dependencies(); - - assert_eq!( - deps, - vec![ - "type19".to_string(), - "type18".to_string(), - "type17".to_string() - ] - ); - } - // TypeScript type string tests #[test] diff --git a/packages/cli/templates/dynamic/init_templates/shared/package.json.hbs b/packages/cli/templates/dynamic/init_templates/shared/package.json.hbs index 120fac068..ed2d7d9f9 100644 --- a/packages/cli/templates/dynamic/init_templates/shared/package.json.hbs +++ b/packages/cli/templates/dynamic/init_templates/shared/package.json.hbs @@ -4,9 +4,9 @@ "type": "module", "scripts": { {{#if is_rescript}} - "clean": "rescript-legacy clean", - "build": "rescript-legacy", - "watch": "rescript-legacy -w", + "clean": "rescript clean", + "build": "rescript", + "watch": "rescript watch", {{/if}} "codegen": "envio codegen", "dev": "{{#if is_rescript}}pnpm build && {{/if}}envio dev", diff --git a/packages/cli/templates/static/blank_template/rescript/rescript.json b/packages/cli/templates/static/blank_template/rescript/rescript.json index 04b9b3daf..d85a80c81 100644 --- a/packages/cli/templates/static/blank_template/rescript/rescript.json +++ b/packages/cli/templates/static/blank_template/rescript/rescript.json @@ -1,6 +1,5 @@ { "name": "EnvioIndexer", - "version": "0.1.0", "sources": [ { "dir": "src", @@ -15,5 +14,5 @@ "version": 4 }, "suffix": ".res.mjs", - "bs-dependencies": ["envio", "rescript-schema"] + "dependencies": ["envio"] } diff --git a/packages/envio/package.json b/packages/envio/package.json index b554a6bf6..0566546cb 100644 --- a/packages/envio/package.json +++ b/packages/envio/package.json @@ -12,7 +12,7 @@ "url": "git+https://github.com/enviodev/hyperindex.git" }, "scripts": { - "watch": "rescript-legacy -w" + "watch": "rescript watch" }, "author": "envio contributors ", "license": "GPL-3.0", diff --git a/packages/envio/rescript.json b/packages/envio/rescript.json index eed222ea5..be5f960c7 100644 --- a/packages/envio/rescript.json +++ b/packages/envio/rescript.json @@ -15,8 +15,8 @@ "jsx": { "version": 4 }, - "bs-dependencies": ["rescript-schema", "@rescript/react"], - "bsc-flags": ["-open RescriptSchema"], + "dependencies": ["rescript-schema", "@rescript/react"], + "compiler-flags": ["-open RescriptSchema"], "warnings": { "error": "+3" } diff --git a/packages/envio/src/Utils.res b/packages/envio/src/Utils.res index 97f280add..0515ed3e1 100644 --- a/packages/envio/src/Utils.res +++ b/packages/envio/src/Utils.res @@ -787,8 +787,6 @@ module BigInt = { }, serializer: bigint => bigint->BigInt.toString, }) - - let nativeSchema = S.bigint } module Promise = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3739198f2..c26d49ebd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,7 +29,7 @@ importers: version: 22.19.7 envio: specifier: file:../../packages/envio - version: file:packages/envio(react-dom@19.2.3(react@19.2.3))(rescript@12.2.0)(typescript@5.9.3) + version: link:../envio tsx: specifier: ^4.19.0 version: 4.21.0 @@ -158,13 +158,10 @@ importers: dependencies: envio: specifier: file:../../packages/envio - version: link:../../packages/envio + version: file:packages/envio(react-dom@19.2.3(react@19.2.3))(rescript@12.2.0)(typescript@5.9.3) rescript: specifier: 12.2.0 version: 12.2.0 - rescript-schema: - specifier: 9.5.1 - version: 9.5.1(rescript@12.2.0) ts-expect: specifier: 1.3.0 version: 1.3.0 @@ -215,9 +212,6 @@ importers: rescript: specifier: 12.2.0 version: 12.2.0 - rescript-schema: - specifier: 9.5.1 - version: 9.5.1(rescript@12.2.0) devDependencies: '@types/node': specifier: ^24.10.1 diff --git a/scenarios/fuel_test/package.json b/scenarios/fuel_test/package.json index ac4ece7e1..d030b0a2c 100644 --- a/scenarios/fuel_test/package.json +++ b/scenarios/fuel_test/package.json @@ -3,12 +3,12 @@ "version": "0.1.0", "type": "module", "scripts": { - "res:clean": "rescript-legacy clean", - "res:build": "rescript-legacy", - "res:watch": "rescript-legacy -w", + "res:clean": "rescript clean", + "res:build": "rescript", + "res:watch": "rescript watch", "codegen": "envio codegen", "dev": "envio dev", - "test": "rescript-legacy && tsc --noEmit && vitest run", + "test": "rescript && tsc --noEmit && vitest run", "start": "envio start" }, "devDependencies": { @@ -19,7 +19,6 @@ }, "dependencies": { "envio": "file:../../packages/envio", - "rescript-schema": "9.5.1", "ts-expect": "1.3.0", "rescript": "12.2.0" }, diff --git a/scenarios/fuel_test/rescript.json b/scenarios/fuel_test/rescript.json index 4fd29a1ca..8085f8e77 100644 --- a/scenarios/fuel_test/rescript.json +++ b/scenarios/fuel_test/rescript.json @@ -18,5 +18,5 @@ "module": "esmodule", "in-source": true }, - "bs-dependencies": ["envio", "rescript-schema"] + "dependencies": ["envio"] } diff --git a/scenarios/fuel_test/src/Indexer.res b/scenarios/fuel_test/src/Indexer.res index 3de0eda93..ca804c18e 100644 --- a/scenarios/fuel_test/src/Indexer.res +++ b/scenarios/fuel_test/src/Indexer.res @@ -2,8 +2,6 @@ //**CONTRACTS** //************* -open RescriptSchema - module Transaction = { type t = { id: string, @@ -147,69 +145,6 @@ type rec type0 = (type27, type22) and type27 = bigint and type28 = int @@warning("+30") -let type5Schema = (_tSchema: S.t<'t>, _eSchema: S.t<'e>) => S.union([S.object((s): type5<'t, 'e> => -{ - s.tag("case", "Ok") - Ok({payload: s.field("payload", _tSchema)}) -}), S.object((s): type5<'t, 'e> => -{ - s.tag("case", "Err") - Err({payload: s.field("payload", _eSchema)}) -})]) -let type8Schema = Utils.BigInt.schema -let type14Schema = S.unknown -let type17Schema = S.string -let type19Schema = (_tSchema: S.t<'t>) => S.array(_tSchema) -let type20Schema = S.literal(%raw(`null`))->S.shape(_ => ()) -let type21Schema = S.string -let type22Schema = S.bool -let type23Schema = S.string -let type24Schema = S.int -let type25Schema = Utils.BigInt.schema -let type26Schema = S.int -let type27Schema = Utils.BigInt.schema -let type28Schema = S.int -let type0Schema = S.tuple(s => (s.item(0, type27Schema), s.item(1, type22Schema))) -let type1Schema = S.array(type28Schema) -let type4Schema = (_tSchema: S.t<'t>) => S.union([S.object((s): type4<'t> => -{ - s.tag("case", "None") - None({payload: s.field("payload", type20Schema)}) -}), S.object((s): type4<'t> => -{ - s.tag("case", "Some") - Some({payload: s.field("payload", _tSchema)}) -})]) -let type9Schema = S.object((s): type9 => {f1: s.field("f1", type26Schema)}) -let type10Schema = S.object((s): type10 => {f1: s.field("f1", type26Schema), f2: s.field("f2", type4Schema(type26Schema))}) -let type11Schema = S.object((s): type11 => {reason: s.field("reason", type26Schema)}) -let type12Schema = S.object((s): type12 => {tags: s.field("tags", type4Schema(type19Schema(type17Schema)))}) -let type13Schema = S.object((s): type13 => {bits: s.field("bits", type21Schema)}) -let type15Schema = S.object((s): type15 => {ptr: s.field("ptr", type8Schema), cap: s.field("cap", type27Schema)}) -let type16Schema = S.object((s): type16 => {bits: s.field("bits", type21Schema)}) -let type18Schema = (_tSchema: S.t<'t>) => S.object((s): type18<'t> => {ptr: s.field("ptr", type8Schema), cap: s.field("cap", type27Schema)}) -let type2Schema = S.union([S.object((s): type2 => -{ - s.tag("case", "Pending") - Pending({payload: s.field("payload", type20Schema)}) -}), S.object((s): type2 => -{ - s.tag("case", "Completed") - Completed({payload: s.field("payload", type26Schema)}) -}), S.object((s): type2 => -{ - s.tag("case", "Failed") - Failed({payload: s.field("payload", type11Schema)}) -})]) -let type3Schema = S.union([S.object((s): type3 => -{ - s.tag("case", "Address") - Address({payload: s.field("payload", type13Schema)}) -}), S.object((s): type3 => -{ - s.tag("case", "ContractId") - ContractId({payload: s.field("payload", type16Schema)}) -})]) let contractName = "AllEvents" module UnitLog = { @@ -1069,31 +1004,6 @@ type rec type0 = string and type8 = unit and type9 = string @@warning("+30") -let type0Schema = S.string -let type7Schema = S.object((s): type7 => {bits: s.field("bits", type0Schema)}) -let type8Schema = S.literal(%raw(`null`))->S.shape(_ => ()) -let type9Schema = S.string -let type1Schema = S.union([S.object((s): type1 => -{ - s.tag("case", "InvalidContractSender") - InvalidContractSender({payload: s.field("payload", type8Schema)}) -}), S.object((s): type1 => -{ - s.tag("case", "ToThrow") - ToThrow({payload: s.field("payload", type8Schema)}) -})]) -let type2Schema = (_tSchema: S.t<'t>) => S.union([S.object((s): type2<'t> => -{ - s.tag("case", "None") - None({payload: s.field("payload", type8Schema)}) -}), S.object((s): type2<'t> => -{ - s.tag("case", "Some") - Some({payload: s.field("payload", _tSchema)}) -})]) -let type4Schema = S.object((s): type4 => {user: s.field("user", type7Schema)}) -let type5Schema = S.object((s): type5 => {value: s.field("value", type9Schema)}) -let type6Schema = S.object((s): type6 => {user: s.field("user", type7Schema), greeting: s.field("greeting", type5Schema)}) let contractName = "Greeter" module NewGreeting = { diff --git a/scenarios/helpers/package.json b/scenarios/helpers/package.json index a3764b9f0..ef064bba2 100644 --- a/scenarios/helpers/package.json +++ b/scenarios/helpers/package.json @@ -4,9 +4,9 @@ "type": "module", "namespace": "Helpers", "scripts": { - "build": "rescript-legacy", - "clean": "rescript-legacy clean", - "watch": "rescript-legacy -w" + "build": "rescript", + "clean": "rescript clean", + "watch": "rescript watch" }, "keywords": [ "rescript" diff --git a/scenarios/svm_test/package.json b/scenarios/svm_test/package.json index 26b963c6b..e7dfbdce0 100644 --- a/scenarios/svm_test/package.json +++ b/scenarios/svm_test/package.json @@ -3,12 +3,12 @@ "version": "0.1.0", "type": "module", "scripts": { - "res:clean": "rescript-legacy clean", - "res:build": "rescript-legacy", - "res:watch": "rescript-legacy -w", + "res:clean": "rescript clean", + "res:build": "rescript", + "res:watch": "rescript watch", "codegen": "envio codegen", "dev": "envio dev", - "test": "rescript-legacy && tsc --noEmit && vitest run", + "test": "rescript && tsc --noEmit && vitest run", "start": "envio start" }, "devDependencies": { @@ -18,7 +18,6 @@ }, "dependencies": { "envio": "file:../../packages/envio", - "rescript-schema": "9.5.1", "rescript": "12.2.0" }, "optionalDependencies": { diff --git a/scenarios/svm_test/rescript.json b/scenarios/svm_test/rescript.json index 3e88ca411..1e385484c 100644 --- a/scenarios/svm_test/rescript.json +++ b/scenarios/svm_test/rescript.json @@ -18,5 +18,5 @@ "module": "esmodule", "in-source": true }, - "bs-dependencies": ["envio", "rescript-schema"] + "dependencies": ["envio"] } diff --git a/scenarios/test_codegen/package.json b/scenarios/test_codegen/package.json index 3f9e7e185..7d54035b2 100644 --- a/scenarios/test_codegen/package.json +++ b/scenarios/test_codegen/package.json @@ -3,9 +3,9 @@ "version": "0.1.0", "type": "module", "scripts": { - "build": "rescript-legacy", - "watch": "rescript-legacy -w", - "test": "rescript-legacy && tsc --noEmit && vitest run", + "build": "rescript", + "watch": "rescript watch", + "test": "rescript && tsc --noEmit && vitest run", "test:update-log-snapshots": "ENVIO_TEST_LOGGING_FORMAT=1 node scripts/update-log-snapshots.mjs", "codegen": "envio codegen", "docker-up": "envio local docker up", diff --git a/scenarios/test_codegen/rescript.json b/scenarios/test_codegen/rescript.json index 4bb391ded..c9c13646a 100644 --- a/scenarios/test_codegen/rescript.json +++ b/scenarios/test_codegen/rescript.json @@ -1,6 +1,5 @@ { "name": "gravatar", - "version": "0.1.0", "sources": [ { "dir": "src", @@ -19,11 +18,10 @@ "jsx": { "version": 4 }, - "bs-dependencies": [ - "@rescript/react", + "dependencies": [ "rescript-schema", "helpers", "envio" ], - "bsc-flags": ["-open RescriptSchema"] + "compiler-flags": ["-open RescriptSchema"] } diff --git a/scenarios/test_codegen/src/Indexer.res b/scenarios/test_codegen/src/Indexer.res index 5542d98a4..9040b8c75 100644 --- a/scenarios/test_codegen/src/Indexer.res +++ b/scenarios/test_codegen/src/Indexer.res @@ -2,8 +2,6 @@ //**CONTRACTS** //************* -open RescriptSchema - module Transaction = { type t = { transactionIndex: int,