Skip to content

Commit

Permalink
fix(macros): Provide full import paths in light_accounts macro
Browse files Browse the repository at this point in the history
Before this change, using `#[light_accounts]` macro required adding
necessary imports manually, e.g.

```rust
use account_compression::program::AccountCompression;
use light_system_program::program::LightSystemProgram;
```

Which might've been annoying for developers.

This change uses full paths for all foregin types used inside macros,
so no additional imports are needed.
  • Loading branch information
vadorovsky committed Aug 8, 2024
1 parent 0233050 commit 1d7e40f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions macros/light/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ pub(crate) fn process_light_accounts(input: DeriveInput) -> Result<TokenStream>
if let Data::Struct(ref mut data_struct) = output.data {
if let Fields::Named(ref mut fields) = data_struct.fields {
let fields_to_add = [
("light_system_program", "Program<'info, LightSystemProgram>"),
(
"light_system_program",
"Program<'info, ::light_system_program::program::LightSystemProgram>",
),
("system_program", "Program<'info, System>"),
(
"account_compression_program",
"Program<'info, AccountCompression>",
"Program<'info, ::account_compression::program::AccountCompression>",
),
];
let fields_to_add_check = [
(
"registered_program_pda",
"Account<'info, RegisteredProgram>",
"Account<'info, ::account_compression::RegisteredProgram>",
),
("noop_program", "AccountInfo<'info>"),
("account_compression_authority", "AccountInfo<'info>"),
Expand Down

0 comments on commit 1d7e40f

Please sign in to comment.