anchor icon indicating copy to clipboard operation
anchor copied to clipboard

New Idl generation fails when seeds are generated using an external function

Open Bhargavamacha opened this issue 10 months ago • 3 comments

Consider the following example:

#[account(
    init,
    seeds = [
        CONSTANT_SEED,
        external_function(ix_param).as_slice()
    ],
    bump,
    space = 8 + size,
    payer = payer
)]

IDL generation fails saying ix_param not found.

Bhargavamacha avatar Apr 12 '24 21:04 Bhargavamacha

Yeah, it's because the new IDL generation stores PDA seeds in the IDL by default, but there is no way to store external_function in the IDL.

acheroncrypto avatar Apr 13 '24 00:04 acheroncrypto

Is there a way to fix it?

Bhargavamacha avatar Apr 13 '24 00:04 Bhargavamacha

The client needs to be able to derive the address from the information based on the program's IDL to make it work. This depends on what you do inside your external_function, but most of the time, you should be able to do that inline instead of calling a function.

You can also disable account resolution in Anchor.toml:

[features]
resolution = false

acheroncrypto avatar Apr 13 '24 12:04 acheroncrypto