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

Anchor version 0.25.0 gives error with lifetime specifier #70

Open
anoushk1234 opened this issue Nov 21, 2022 · 1 comment
Open

Anchor version 0.25.0 gives error with lifetime specifier #70

anoushk1234 opened this issue Nov 21, 2022 · 1 comment

Comments

@anoushk1234
Copy link

Cargo.toml

[dependencies]
anchor-lang = "0.25.0"
switchboard-v2 = "0.1.16"

lib.rs

pub fn initialize(ctx: Context<GetResult>) -> Result<()> {
        let aggregator = &ctx.accounts.aggregator_feed;
        let val: u64 = AggregatorAccountData::new(aggregator)?
            .get_result()?
            .try_into()?;
        Ok(())
    }

AggregatorAccountData::new(aggregator) throws an error saying

lifetime may not live long enough
argument requires that `'1` must outlive `'2`
@anoushk1234
Copy link
Author

anoushk1234 commented Nov 22, 2022

Ok so since I see the program has been updated to use AccountLoad instead of AccountInfo i think the examples and docs should be updated

  let aggregator = &ctx.accounts.aggregator_feed.load()?;
        let val:f64 = aggregator
            .get_result()?
            .try_into()?;

Happy to make the necessary changes across programs

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

No branches or pull requests

2 participants
@anoushk1234 and others