Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/build-envio/src/build-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down
28 changes: 10 additions & 18 deletions packages/cli/src/config_parsing/entity_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
})),
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/config_parsing/field_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,4 @@ pub struct Field {
pub is_nullable: bool,
pub is_array: bool,
pub field_type: Primitive,
pub res_schema_code: String,
}
19 changes: 4 additions & 15 deletions packages/cli/src/hbs_templating/codegen_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<field_types::Field>,
pub composite_indices: Vec<Vec<CompositeIndexFieldTemplate>>,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
}
};
Expand Down Expand Up @@ -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(),
});
Expand All @@ -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(),
});
Expand Down Expand Up @@ -901,7 +893,6 @@ struct SelectedFieldTemplate {
res_name: String,
res_type: String,
ts_type: String,
default_value_rescript: String,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -1633,8 +1624,6 @@ type handlerContext = {{
//**CONTRACTS**
//*************

open RescriptSchema

module Transaction = {{
type t = {transaction_module_type}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading
Loading