Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(macros): Provide full import paths in light_accounts macro #1063

Merged
merged 4 commits into from
Aug 13, 2024

Conversation

vadorovsky
Copy link
Contributor

Before this change, using #[light_accounts] macro required adding necessary imports manually, e.g.

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.

@vadorovsky vadorovsky mentioned this pull request Aug 7, 2024
@vadorovsky vadorovsky force-pushed the vadorovsky/discriminator-macro branch from d430382 to e62d138 Compare August 8, 2024 04:35
@vadorovsky vadorovsky force-pushed the vadorovsky/macro-light-accounts branch from 1ee22b0 to d2e0e46 Compare August 8, 2024 04:39
@vadorovsky vadorovsky force-pushed the vadorovsky/discriminator-macro branch from e62d138 to 2bfc047 Compare August 8, 2024 05:04
@vadorovsky vadorovsky force-pushed the vadorovsky/macro-light-accounts branch 2 times, most recently from de5d56d to 1d7e40f Compare August 8, 2024 12:37
@SwenSchaeferjohann
Copy link
Contributor

SwenSchaeferjohann commented Aug 8, 2024

thanks! Can you adjust the usage in token-escrow to make use of this?

same for #1069

Base automatically changed from vadorovsky/discriminator-macro to main August 8, 2024 22:05
@vadorovsky vadorovsky force-pushed the vadorovsky/macro-light-accounts branch from 4205cb6 to c3cd6fc Compare August 9, 2024 09:51
#compressed_sol_pda_field
}
fn get_compression_recipient(&self) -> Option<&UncheckedAccount<'info>> {
fn get_compression_recipient(&self) -> Option<&::anchor_lang::prelude::UncheckedAccount<'info>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we change the traits to return AccountInfo<'info> or Option<AccountInfo<'info> instead of &UncheckedAccount and Option<UncheckedAccount? To use these in the cpi function we will need to unwrap and do .to_account_info()` to transfer ownership since cpi invocations need to own all data involved and don't work with references.

Copy link
Contributor

Choose a reason for hiding this comment

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

see traits in my registry pr for reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

vadorovsky and others added 4 commits August 13, 2024 13:40
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.
Before this change, using `#[derive(LightTraits)]` macro required adding
necessary imports manually, e.g.

```rust
use light_sdk::traits::{InvokeAccounts, SignerAccounts};
```

Which might've been annoying for developers.

This change uses full paths for all foreign types used inside macros,
so no additional imports are needed.
Also, remove unnecessary imports.
@vadorovsky vadorovsky force-pushed the vadorovsky/macro-light-accounts branch from 64e4f0e to 478f848 Compare August 13, 2024 12:20
@SwenSchaeferjohann SwenSchaeferjohann merged commit 4926032 into main Aug 13, 2024
13 checks passed
@vadorovsky vadorovsky deleted the vadorovsky/macro-light-accounts branch August 13, 2024 18:36
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.

3 participants