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
1 change: 1 addition & 0 deletions .cursor/worktrees.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"setup-worktree": [
"cd codegenerator/cli/npm/envio && pnpm install && pnpm rescript",
"cd scenarios/test_codegen && pnpm install",
"pnpm codegen",
"pnpm rescript",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
if: steps.changes.outputs.testChanges == 'true'
uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22.10.0

- name: test_codegen build
if: steps.changes.outputs.testChanges == 'true'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ jobs:
- name: Install node
uses: actions/setup-node@v4
with:
node-version: "18.16.0"
node-version: 22.10.0
registry-url: "https://registry.npmjs.org"

- name: Publish to NPM
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22.10.0
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: codegenerator/cli/npm/envio/pnpm-lock.yaml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/templates_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: 22.10.0
- name: Pre-pull docker-compose images
run: |
cd ../cli/templates/static/codegen # we use the docker-compose.yml in the static folder
Expand Down
22 changes: 17 additions & 5 deletions codegenerator/cli/npm/envio/evm.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
"type": "null"
}
]
},
"handlers": {
"description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -153,8 +160,11 @@
]
},
"handler": {
"description": "The relative path to a file where handlers are registered for the given contract",
"type": "string"
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
Expand All @@ -167,7 +177,6 @@
"additionalProperties": false,
"required": [
"name",
"handler",
"events"
]
},
Expand Down Expand Up @@ -611,8 +620,11 @@
]
},
"handler": {
"description": "The relative path to a file where handlers are registered for the given contract",
"type": "string"
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
Expand Down
22 changes: 17 additions & 5 deletions codegenerator/cli/npm/envio/fuel.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
"boolean",
"null"
]
},
"handlers": {
"description": "Optional relative path to handlers directory for auto-loading. Defaults to 'src/handlers' if not specified.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -90,8 +97,11 @@
"type": "string"
},
"handler": {
"description": "The relative path to a file where handlers are registered for the given contract",
"type": "string"
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
Expand All @@ -105,7 +115,6 @@
"required": [
"name",
"abi_file_path",
"handler",
"events"
]
},
Expand Down Expand Up @@ -238,8 +247,11 @@
"type": "string"
},
"handler": {
"description": "The relative path to a file where handlers are registered for the given contract",
"type": "string"
"description": "Optional relative path to a file where handlers are registered for the given contract. If not provided, handlers can be auto-loaded from src directory.",
"type": [
"string",
"null"
]
},
"events": {
"description": "A list of events that should be indexed on this contract",
Expand Down
3 changes: 3 additions & 0 deletions codegenerator/cli/npm/envio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"url": "https://github.com/enviodev/hyperindex/issues"
},
"homepage": "https://envio.dev",
"engines": {
"node": ">=22.0.0 <=22.10.0"
},
Comment on lines +22 to +24

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about this, why do we need <=22.10 again? I use v24 on my machine for eg

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mocha starts attempting to run tests in esm, which breaks in some cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning that this PR will go to v3.0.0-alpha.0, so it's fine to have the limitation, since one of the next alphas will bring ESM only mode, and lift the restriction of node.js <=22.10

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no problmes with running the indexer, only when running mocha

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool 👍🏼 so this will not be the latest version for some time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, until ESM support

"dependencies": {
"@clickhouse/client": "1.12.1",
"@envio-dev/hypersync-client": "0.6.6",
Expand Down
3 changes: 3 additions & 0 deletions codegenerator/cli/npm/envio/package.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"url": "https://github.com/enviodev/hyperindex/issues"
},
"homepage": "https://envio.dev",
"engines": {
"node": ">=22.0.0 <=22.10.0"
},
"optionalDependencies": {
"envio-linux-x64": "${version}",
"envio-linux-arm64": "${version}",
Expand Down
15 changes: 15 additions & 0 deletions codegenerator/cli/npm/envio/src/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ module UnsafeIntOperators = {
external \"-": (int, int) => int = "%subfloat"
}

type asyncIterator<'a>

module Array = {
let immutableEmpty: array<unknown> = []

Expand Down Expand Up @@ -360,6 +362,19 @@ Helper to check if a value exists in an array
external copy: array<'a> => array<'a> = "slice"

@send external at: (array<'a>, int) => option<'a> = "at"

/**
Converts an async iterator to an array by iterating through all values
*/
let fromAsyncIterator: asyncIterator<string> => promise<
array<string>,
> = %raw(`async (iterator) => {
const result = [];
for await (const item of iterator) {
result.push(item);
}
return result;
}`)
}

module String = {
Expand Down
2 changes: 0 additions & 2 deletions codegenerator/cli/npm/envio/src/db/InternalTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ module PersistedState = {
envio_version: string,
config_hash: string,
schema_hash: string,
handler_files_hash: string,
abi_files_hash: string,
}

Expand All @@ -368,7 +367,6 @@ module PersistedState = {
mkField("envio_version", String, ~fieldSchema=S.string),
mkField("config_hash", String, ~fieldSchema=S.string),
mkField("schema_hash", String, ~fieldSchema=S.string),
mkField("handler_files_hash", String, ~fieldSchema=S.string),
mkField("abi_files_hash", String, ~fieldSchema=S.string),
],
)
Expand Down
72 changes: 36 additions & 36 deletions codegenerator/cli/src/cli_args/init_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,38 @@ pub mod evm {
})
.collect();

let handler = init_config.language.get_event_handler_directory();

let config = if is_multi_chain_contract {
//Add the contract to global contract config and return none for local contract
//config
let global_contract = GlobalContract {
name: selected_contract.name.clone(),
config: ContractConfig {
abi_file_path: None,
handler,
events,
},
};

unique_hashmap::try_insert(
&mut global_contracts,
selected_contract.name.clone(),
global_contract,
)
.context(format!(
"Unexpected, failed to add global contract {}. Contract should have \
unique names",
selected_contract.name
))?;
None
} else {
//Return some for local contract config
Some(ContractConfig {
let config = if is_multi_chain_contract {
//Add the contract to global contract config and return none for local contract
//config
let global_contract = GlobalContract {
name: selected_contract.name.clone(),
config: ContractConfig {
abi_file_path: None,
handler,
events,
})
handler: None,
events: events.clone(),
},
};

unique_hashmap::try_insert(
&mut global_contracts,
selected_contract.name.clone(),
global_contract,
)
.context(format!(
"Unexpected, failed to add global contract {}. Contract should have \
unique names",
selected_contract.name
))?;
None
} else {
//Return some for local contract config
Some(ContractConfig {
abi_file_path: None,
handler: None,
events,
})
};

for selected_network in &selected_contract.networks {
let address = selected_network
.addresses
Expand Down Expand Up @@ -172,6 +170,7 @@ pub mod evm {
raw_events: None,
preload_handlers: Some(true),
address_format: None,
handlers: None,
})
}

Expand Down Expand Up @@ -282,11 +281,11 @@ pub mod fuel {
.map(|a| a.to_string())
.collect::<Vec<String>>()
.into(),
config: Some(ContractConfig {
abi_file_path: selected_contract.get_vendored_abi_file_path(),
handler: init_config.language.get_event_handler_directory(),
events: selected_contract.selected_events.clone(),
}),
config: Some(ContractConfig {
abi_file_path: selected_contract.get_vendored_abi_file_path(),
handler: None,
events: selected_contract.selected_events.clone(),
}),
start_block: None,
})
.collect(),
Expand All @@ -304,6 +303,7 @@ pub mod fuel {
raw_events: None,
preload_handlers: Some(true),
networks: network_configs,
handlers: None,
}
}
}
Expand Down
Loading