-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
bugSomething isn't workingSomething isn't workingidlrelated to the IDL, either program or client siderelated to the IDL, either program or client side
Description
Problem
When multiple crates exists in an Anchor program (e.g. by including a tests integration folder), the IDL file generated by anchor build will have an empty address property.
Expected Behavior
The IDL JSON file for the program is generated with the correct address property.
Actual Behavior
The address property in the IDL file is empty.
Environment
| Component | Version |
|---|---|
| Anchor | 0.30.1 |
| Solana CLI | 1.18.26 |
Reproduction Steps
# 1. Generate a new Anchor project
anchor init idl-multi-crate-bug
cd idl-multi-crate-bug
# 2. Run a build to confirm the IDL file includes a program address
anchor build
grep address target/idl/idl_multi_crate_bug.json # => e.g. "address": "7RuRMKRpVsW7A9BBxLfJVijbfNc1F1xAaSHNhEgJRNP4",
# 3. Add a dummy Rust integration test folder
mkdir programs/idl-multi-crate-bug/tests
touch programs/idl-multi-crate-bug/tests/dummy-test.rs
# 4. Trigger another build
anchor build
# 5. Verify the address property in the IDL file is now empty
grep address target/idl/idl_multi_crate_bug.json # => "address": "", Analysis
It appears that when multiple crates exists in a package, the IDL build tool is confused and unable to insert the program address into the program's IDL file.
For example, if a binary crate is included in an Anchor program (e.g. by defining /src/main.rs), the same bug is triggered.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingidlrelated to the IDL, either program or client siderelated to the IDL, either program or client side