coral-xyz / anchor

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

lang: Fix using defined types in instruction parameters with `declare_program!` #2959

Closed acheroncrypto closed 1 month ago

acheroncrypto commented 1 month ago

Problem

Using the generated IDL from the following instruction

pub fn defined(ctx: Context<Defined>, my_type: MyType) -> Result<()> {
    Ok(())
}

with declare_program! results in a compilation error due to MyType not being imported in the generated cpi module.

Summary of changes

Globally import accounts, events and types modules in necessary places to not run into compilation errors which are difficult to debug.

vercel[bot] commented 1 month ago

@acheroncrypto 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

Thank you for this PR! This is a blocker for us, as it means we can't use declare_program! in our codebase even though we'd love to. Do you plan to release this patch as a minor release? Or will we have to wait for the next major release for this?

acheroncrypto commented 1 month ago

We'll most likely make a patch release, but there are a couple more fixes/improvements queued up that I'd like to get in before then.