Skip to content

Commit 915746c

Browse files
lcovarclaude
andcommitted
feat(wasm-solana): add AuthorizeChecked instruction decoding
- Add StakeInstruction::AuthorizeChecked variant handling - Add custodianAddress field to StakingAuthorizeParams - Include custodian in Authorize instruction as well Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 97a2e45 commit 915746c

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

packages/wasm-solana/src/instructions/decode.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,40 @@ fn decode_stake_instruction(ctx: InstructionContext) -> ParsedInstruction {
158158
solana_stake_interface::state::StakeAuthorize::Staker => "Staker",
159159
solana_stake_interface::state::StakeAuthorize::Withdrawer => "Withdrawer",
160160
};
161+
let custodian = if ctx.accounts.len() >= 4 {
162+
Some(ctx.accounts[3].clone())
163+
} else {
164+
None
165+
};
161166
ParsedInstruction::StakingAuthorize(StakingAuthorizeParams {
162167
staking_address: ctx.accounts[0].clone(),
163168
old_authorize_address: ctx.accounts[2].clone(),
164169
new_authorize_address: new_authority.to_string(),
165170
authorize_type: auth_type.to_string(),
171+
custodian_address: custodian,
172+
})
173+
} else {
174+
make_unknown(ctx)
175+
}
176+
}
177+
StakeInstruction::AuthorizeChecked(stake_authorize) => {
178+
// Accounts: [0] stake, [1] clock, [2] authority, [3] new_authority (signer), [4] optional custodian
179+
if ctx.accounts.len() >= 4 {
180+
let auth_type = match stake_authorize {
181+
solana_stake_interface::state::StakeAuthorize::Staker => "Staker",
182+
solana_stake_interface::state::StakeAuthorize::Withdrawer => "Withdrawer",
183+
};
184+
let custodian = if ctx.accounts.len() >= 5 {
185+
Some(ctx.accounts[4].clone())
186+
} else {
187+
None
188+
};
189+
ParsedInstruction::StakingAuthorize(StakingAuthorizeParams {
190+
staking_address: ctx.accounts[0].clone(),
191+
old_authorize_address: ctx.accounts[2].clone(),
192+
new_authorize_address: ctx.accounts[3].clone(),
193+
authorize_type: auth_type.to_string(),
194+
custodian_address: custodian,
166195
})
167196
} else {
168197
make_unknown(ctx)

packages/wasm-solana/src/instructions/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ pub struct StakingAuthorizeParams {
164164
pub new_authorize_address: String,
165165
#[serde(rename = "authorizeType")]
166166
pub authorize_type: String, // "Staker" or "Withdrawer"
167+
#[serde(rename = "custodianAddress", skip_serializing_if = "Option::is_none")]
168+
pub custodian_address: Option<String>,
167169
}
168170

169171
/// Intermediate type for StakeInstruction::Initialize

0 commit comments

Comments
 (0)