coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

fix: Fix optional accounts in `declare_program!` #2967

Closed cryptopapi997 closed 1 month ago

cryptopapi997 commented 1 month ago

When using optional accounts with declare_program! the generated code results in the account being set to crate::ID when the account is None. This means we get two scenarios:

Both of these are the wrong thing to happen, but the fix is easy - just pass in super::__ID instead, which is what this PR does.

vercel[bot] commented 1 month ago

@cryptopapi997 is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

cryptopapi997 commented 1 month ago

wdyt @acheroncrypto

cryptopapi997 commented 1 month ago

Thanks for merging! Do you already have an ETA for the next patch release that will include these?

acheroncrypto commented 1 month ago

ETA is early next month, but you can already use it from git if you don't publish crates:

[dependencies]
anchor-lang = { git = "https://github.com/coral-xyz/anchor", rev = "b76d1bf" }

and in Anchor.toml:

anchor_version = "0.30.0-b76d1bf"