Skip to content

Commit

Permalink
Improve missing global contract error message (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
DZakh authored Jul 11, 2024
1 parent a2037d3 commit c4324e1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions codegenerator/cli/npm/envio/evm.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
]
}
},
"additionalProperties": false,
"required": [
"name",
"networks"
Expand Down
1 change: 1 addition & 0 deletions codegenerator/cli/npm/envio/fuel.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
]
}
},
"additionalProperties": false,
"required": [
"name",
"ecosystem",
Expand Down
4 changes: 4 additions & 0 deletions codegenerator/cli/src/config_parsing/human_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{borrow::Cow, path::PathBuf};
type NetworkId = u64;

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct GlobalContract<T> {
pub name: String,
#[serde(flatten)]
Expand Down Expand Up @@ -45,6 +46,7 @@ impl JsonSchema for Addresses {
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct NetworkContract<T> {
pub name: String,
pub address: Addresses,
Expand All @@ -68,6 +70,7 @@ pub mod evm {
title = "Envio Config Schema",
description = "Schema for a YAML config for an envio indexer"
)]
#[serde(deny_unknown_fields)]
pub struct HumanConfig {
#[schemars(description = "Name of the project")]
pub name: String,
Expand Down Expand Up @@ -375,6 +378,7 @@ pub mod fuel {
title = "Envio Config Schema",
description = "Schema for a YAML config for an envio indexer"
)]
#[serde(deny_unknown_fields)]
pub struct HumanConfig {
#[schemars(description = "Name of the project")]
pub name: String,
Expand Down
3 changes: 2 additions & 1 deletion codegenerator/cli/src/config_parsing/system_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ impl SystemConfig {
//there is no config
if !contracts.get(&contract.name).is_some() {
Err(anyhow!(
"Expected a local network config definition or a global definition"
"Failed to find contract '{}' in global contract config. If you don't use global contracts for multiple networks support, please specify events and handler for the contract.",
contract.name
))?;
}
}
Expand Down

0 comments on commit c4324e1

Please sign in to comment.