Skip to content

fix(declare-program): handle numeric instruction suffixes#4568

Open
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/4281-declare-program-underscore-number
Open

fix(declare-program): handle numeric instruction suffixes#4568
abhinavgautam01 wants to merge 1 commit into
otter-sec:masterfrom
abhinavgautam01:fix/4281-declare-program-underscore-number

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #4281

Summary

Fixes declare_program! account module re-exports for instruction names that contain an underscore before a numeric suffix, such as initialize_with_token_2022.

Previously, generated internal account modules normalized the instruction name through CamelCase and then snake_case, while the public client/CPI account re-exports used the raw IDL instruction name. That could make the re-export look for __cpi_client_accounts_initialize_with_token_2022 even though the generated module was named __cpi_client_accounts_initialize_with_token2022.

Changes

  • Normalize declare_program! client/CPI account re-export module names the same way as generated account modules.
  • Add a regression test for initialize_with_token_2022.
  • Add the matching instruction to the declare-program fixture IDL.

Testing

  • cargo +nightly fmt --check -p anchor-attribute-program
  • cargo test -p anchor-attribute-program test_gen_accounts_mod_name_matches_generated_accounts
  • cargo check -p declare-program --features cpi
  • cargo check -p external
  • cargo clippy -p anchor-attribute-program --all-targets -- -D warnings
  • git diff --check

Note: full workspace cargo +nightly fmt --check currently fails on an unrelated pre-existing import ordering diff in lang/src/lib.rs, which this PR does not touch...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

declare_program! fails to parse an IDL where an instruction name contains an underscore followed by a number

1 participant