11//! Instruction decoding using official Solana interface crates.
22
33use super :: types:: * ;
4+ use crate :: intent:: AuthorizeType ;
45use solana_compute_budget_interface:: ComputeBudgetInstruction ;
56use solana_stake_interface:: instruction:: StakeInstruction ;
67use solana_system_interface:: instruction:: SystemInstruction ;
@@ -155,8 +156,10 @@ fn decode_stake_instruction(ctx: InstructionContext) -> ParsedInstruction {
155156 // Accounts: [0] stake, [1] clock, [2] authority, [3] optional custodian
156157 if ctx. accounts . len ( ) >= 3 {
157158 let auth_type = match stake_authorize {
158- solana_stake_interface:: state:: StakeAuthorize :: Staker => "Staker" ,
159- solana_stake_interface:: state:: StakeAuthorize :: Withdrawer => "Withdrawer" ,
159+ solana_stake_interface:: state:: StakeAuthorize :: Staker => AuthorizeType :: Staker ,
160+ solana_stake_interface:: state:: StakeAuthorize :: Withdrawer => {
161+ AuthorizeType :: Withdrawer
162+ }
160163 } ;
161164 let custodian = if ctx. accounts . len ( ) >= 4 {
162165 Some ( ctx. accounts [ 3 ] . clone ( ) )
@@ -167,7 +170,7 @@ fn decode_stake_instruction(ctx: InstructionContext) -> ParsedInstruction {
167170 staking_address : ctx. accounts [ 0 ] . clone ( ) ,
168171 old_authorize_address : ctx. accounts [ 2 ] . clone ( ) ,
169172 new_authorize_address : new_authority. to_string ( ) ,
170- authorize_type : auth_type. to_string ( ) ,
173+ authorize_type : auth_type,
171174 custodian_address : custodian,
172175 } )
173176 } else {
@@ -178,8 +181,10 @@ fn decode_stake_instruction(ctx: InstructionContext) -> ParsedInstruction {
178181 // Accounts: [0] stake, [1] clock, [2] authority, [3] new_authority (signer), [4] optional custodian
179182 if ctx. accounts . len ( ) >= 4 {
180183 let auth_type = match stake_authorize {
181- solana_stake_interface:: state:: StakeAuthorize :: Staker => "Staker" ,
182- solana_stake_interface:: state:: StakeAuthorize :: Withdrawer => "Withdrawer" ,
184+ solana_stake_interface:: state:: StakeAuthorize :: Staker => AuthorizeType :: Staker ,
185+ solana_stake_interface:: state:: StakeAuthorize :: Withdrawer => {
186+ AuthorizeType :: Withdrawer
187+ }
183188 } ;
184189 let custodian = if ctx. accounts . len ( ) >= 5 {
185190 Some ( ctx. accounts [ 4 ] . clone ( ) )
@@ -190,7 +195,7 @@ fn decode_stake_instruction(ctx: InstructionContext) -> ParsedInstruction {
190195 staking_address : ctx. accounts [ 0 ] . clone ( ) ,
191196 old_authorize_address : ctx. accounts [ 2 ] . clone ( ) ,
192197 new_authorize_address : ctx. accounts [ 3 ] . clone ( ) ,
193- authorize_type : auth_type. to_string ( ) ,
198+ authorize_type : auth_type,
194199 custodian_address : custodian,
195200 } )
196201 } else {
0 commit comments