coral-xyz / anchor

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

lang: add `INIT_SPACE_INCL_DISC` #3069

Closed cryptopapi997 closed 2 days ago

cryptopapi997 commented 2 days ago

INIT_SPACE is very useful, but I'd wager in 80%+ of cases what you really want is INIT_SPACE + 8 to include the discrimator. This PR adds INIT_SPACE_INCL_DISC, which is exactly that. Saves a bit of typing & removes the need to remember "magic numbers" (at least for devs who might not be as familiar with what the discriminator exactly is).

vercel[bot] commented 2 days 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 2 days ago

Might also make sense to export the DISCRIMINATOR_SIZE const from this PR, just ran across https://solana.stackexchange.com/questions/9522/is-there-an-inbuilt-constant-for-anchor-discriminator-size. Wdyt @acheroncrypto ?

acheroncrypto commented 2 days ago

Thanks for the PR, but dynamic discriminators are coming soonish, please see https://github.com/coral-xyz/anchor/issues/3005#issuecomment-2149285238.

cryptopapi997 commented 2 days ago

Didn't see this, my bad!