Open ngundotra opened 1 year ago
Ideally, shank
would expose a macro that allowed me to redeploy my program with instructions to manage an on-chain IDL.
#[derive(ShankInstruction, ShankIdlDeploy)]
pub enum MyProgramInstruction {
...
}
// now if you fail to handle ShankIdlDeployParse -> fail in compiler
// ShankIdlDeployParse
// now you add the following...
processor::parse_shank_idl_parse(program_id, &accounts, program_data)
// which then does the following
pub fn ....() {
let disc: ShankIdlInnerInstruction = parse(data)?;
match disc {
ShankIdlInnerInstruction::CreateIdl =>
shank::idl::create(program_id, &accounts, program_data)?
ShankIdlInnerInstruction::CreateBuffer =>
shank::idl::create_buffer(program_id, &accounts, program_data)?
ShankIdlInnerInstruction::WriteIdl =>
shank::idl::write(program_id, &accounts, program_data)?
ShankIdlInnerInstruction::SetAuthority =>
shank::idl::set_authority(program_id, &accounts, program_data)?
ShankIdlInnerInstruction::SetBuffer =>
shank::idl::set_buffer(program_id, &accounts, program_data)?
}
}
Anchor idl account is is derived via
const [key, bump] = PublicKey.findProgramAddressSync([], PROGRAM_ID);
PublicKey.createWithSeed(key, 'anchor:idl')
I think Shank would just need to feature flag the following code from
anchor
:https://github.com/coral-xyz/anchor/blob/fa1249836e2b8a73d3cb9fb525634e789290f251/lang/syn/src/codegen/program/handlers.rs#L19