@@ -48,19 +48,18 @@ pub enum TransferHookInstruction {
48
48
/// by this type.
49
49
pub struct ExecuteInstruction ;
50
50
impl TlvDiscriminator for ExecuteInstruction {
51
- /// Please use this discriminator in your program when matching
52
- const TLV_DISCRIMINATOR : Discriminator = Discriminator :: new ( EXECUTE_DISCRIMINATOR ) ;
51
+ /// First 8 bytes of `hash::hashv(&["spl-transfer-hook-interface:execute"])`
52
+ const TLV_DISCRIMINATOR : Discriminator =
53
+ Discriminator :: new ( [ 105 , 37 , 101 , 197 , 75 , 251 , 102 , 26 ] ) ;
53
54
}
54
- /// First 8 bytes of `hash::hashv(&["spl-transfer-hook-interface:execute"])`
55
- const EXECUTE_DISCRIMINATOR : [ u8 ; Discriminator :: LENGTH ] = [ 105 , 37 , 101 , 197 , 75 , 251 , 102 , 26 ] ;
56
- // annoying, but needed to perform a match on the value
57
- const EXECUTE_DISCRIMINATOR_SLICE : & [ u8 ] = & EXECUTE_DISCRIMINATOR ;
55
+
58
56
/// First 8 bytes of `hash::hashv(&["spl-transfer-hook-interface:initialize-extra-account-metas"])`
59
57
const INITIALIZE_EXTRA_ACCOUNT_METAS_DISCRIMINATOR : & [ u8 ] = & [ 43 , 34 , 13 , 49 , 167 , 88 , 235 , 235 ] ;
60
58
61
59
impl TransferHookInstruction {
62
60
/// Unpacks a byte buffer into a [TransferHookInstruction](enum.TransferHookInstruction.html).
63
61
pub fn unpack ( input : & [ u8 ] ) -> Result < Self , ProgramError > {
62
+ const EXECUTE_DISCRIMINATOR_SLICE : & [ u8 ] = ExecuteInstruction :: TLV_DISCRIMINATOR . as_slice ( ) ;
64
63
if input. len ( ) < Discriminator :: LENGTH {
65
64
return Err ( ProgramError :: InvalidInstructionData ) ;
66
65
}
@@ -84,7 +83,7 @@ impl TransferHookInstruction {
84
83
let mut buf = vec ! [ ] ;
85
84
match self {
86
85
Self :: Execute { amount } => {
87
- buf. extend_from_slice ( EXECUTE_DISCRIMINATOR_SLICE ) ;
86
+ buf. extend_from_slice ( ExecuteInstruction :: TLV_DISCRIMINATOR . as_slice ( ) ) ;
88
87
buf. extend_from_slice ( & amount. to_le_bytes ( ) ) ;
89
88
}
90
89
Self :: InitializeExtraAccountMetas => {
0 commit comments