Skip to content

Conversation

squadgazzz
Copy link
Contributor

#1011 PR doesn't cover a case where SC bindings are generated from an ABI json, where the root SC depends on other interfaces that also generated from the same file. As a result, the compilation fails. This PR fixes that.

@squadgazzz
Copy link
Contributor Author

I was able to reproduce it locally using this abi:
https://github.com/cowprotocol/services/blob/main/crates/contracts/artifacts/BalancerV2Vault.json
But for some reason, this test still passes with the abi above even without my fix:

// https://etherscan.io/address/0xBA12222222228d8Ba445958a75a0704d566BF2C8#code
sol!(
#![sol(all_derives)]
BalancerV2Vault,
"../json-abi/tests/abi/BalancerV2Vault.json"
);
// Handle contract **array** types in JSON ABI
// https://github.com/alloy-rs/core/issues/585
#[test]
fn balancer_v2_vault() {
let _ = BalancerV2Vault::PoolBalanceChanged {
poolId: B256::ZERO,
liquidityProvider: Address::ZERO,
tokens: vec![Address::ZERO],
deltas: vec![I256::ZERO],
protocolFeeAmounts: vec![U256::ZERO],
};
assert_eq!(
BalancerV2Vault::PoolBalanceChanged::SIGNATURE,
"PoolBalanceChanged(bytes32,address,address[],int256[],uint256[])"
);
}

I am still trying to understand why I can't reproduce it in the alloy repo.

@squadgazzz squadgazzz marked this pull request as ready for review September 25, 2025 08:45
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 08:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a compilation issue where smart contract bindings generated from ABI JSON fail when the root smart contract depends on other interfaces from the same file. The fix ensures that derive attributes are properly propagated to internal contracts.

  • Extracts all_derives and extra_derives attributes from sol attributes for propagation
  • Applies these derive attributes to internal contracts during code generation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-project-automation github-project-automation bot moved this to Reviewed in Alloy Sep 26, 2025
@DaniPopes DaniPopes changed the title Fix internal SC derives fix(sol-macro): internal SC derives Sep 26, 2025
@DaniPopes DaniPopes merged commit d624bec into alloy-rs:main Sep 26, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants