Implement Discriminator trait for generated instructions
Access to the discriminators is useful when doing instruction introspection where you may want to determine the type of other instructions for your program.
This commit is contained in:
parent
2058b6461c
commit
b52f236146
|
@ -138,6 +138,11 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
|
|||
let sighash_tts: proc_macro2::TokenStream =
|
||||
format!("{:?}", sighash_arr).parse().unwrap();
|
||||
quote! {
|
||||
impl anchor_lang::Discriminator for #ix_name_camel {
|
||||
fn discriminator() -> [u8; 8] {
|
||||
#sighash_tts
|
||||
}
|
||||
}
|
||||
impl anchor_lang::InstructionData for #ix_name_camel {
|
||||
fn data(&self) -> Vec<u8> {
|
||||
let mut d = #sighash_tts.to_vec();
|
||||
|
|
Loading…
Reference in New Issue