Skip to content

Commit

Permalink
refactor: ensure consistent ABI iteration order in build files (#131)
Browse files Browse the repository at this point in the history
Previously, build files iterated through ABIs in an inconsistent order, causing unwanted changes when the build was rerun, as the iteration order would differ. This commit resolves the issue by sorting ABIs by name, ensuring consistent formatting and preventing unintended changes in future commits.

Co-authored-by: zizou <[email protected]>
  • Loading branch information
zizou0x and zizou0x authored Jan 10, 2025
1 parent 6caafff commit 5f319a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
9 changes: 7 additions & 2 deletions substreams/ethereum-balancer-v2/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ fn main() -> Result<()> {
let abi_folder = "abi";
let output_folder = "src/abi";

let files = fs::read_dir(abi_folder)?;
let abis = fs::read_dir(abi_folder)?;

let mut files = abis.collect::<Result<Vec<_>, _>>()?;

// Sort the files by their name
files.sort_by_key(|a| a.file_name());

let mut mod_rs_content = String::new();
mod_rs_content.push_str("#![allow(clippy::all)]\n");

for file in files {
let file = file?;
let file_name = file.file_name();
let file_name = file_name.to_string_lossy();

Expand Down
12 changes: 6 additions & 6 deletions substreams/ethereum-balancer-v2/src/abi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![allow(clippy::all)]
pub mod composable_stable_pool_factory;
pub mod erc_linear_pool_factory;
pub mod euler_linear_pool_factory;
pub mod gearbox_linear_pool_factory;
pub mod weighted_pool_tokens_factory;
pub mod vault;
pub mod yearn_linear_pool_factory;
pub mod managed_pool_factory;
pub mod silo_linear_pool_factory;
pub mod vault;
pub mod weighted_pool_factory_v1;
pub mod euler_linear_pool_factory;
pub mod weighted_pool_factory_v2;
pub mod weighted_pool_factory_v3;
pub mod weighted_pool_factory_v4;
pub mod silo_linear_pool_factory;
pub mod composable_stable_pool_factory;
pub mod weighted_pool_tokens_factory;
pub mod yearn_linear_pool_factory;
9 changes: 7 additions & 2 deletions substreams/ethereum-curve/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ fn main() -> Result<()> {
let abi_folder = "abi";
let output_folder = "src/abi";

let files = fs::read_dir(abi_folder)?;
let abis = fs::read_dir(abi_folder)?;

let mut files = abis.collect::<Result<Vec<_>, _>>()?;

// Sort the files by their name
files.sort_by_key(|a| a.file_name());
let mut mod_rs_content = String::new();
mod_rs_content.push_str("#![allow(clippy::all)]\n");

for file in files {
let file = file?;
let file = file;
let file_name = file.file_name();
let file_name = file_name.to_string_lossy();

Expand Down
4 changes: 2 additions & 2 deletions substreams/ethereum-curve/src/abi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(clippy::all)]
pub mod crypto_pool_factory;
pub mod erc20;
pub mod crypto_swap_ng_factory;
pub mod erc20;
pub mod meta_pool_factory;
pub mod meta_registry;
pub mod stableswap_factory;
pub mod tricrypto_factory;
pub mod twocrypto_factory;
pub mod meta_pool_factory;

0 comments on commit 5f319a6

Please sign in to comment.