Stake Interface v0.2.2: Explicit Whitelist Entry Parameter
Summary
Updated delegate_stake() to accept the validator whitelist entry as an explicit 4th parameter instead of deriving it internally. This improves API clarity and test flexibility while maintaining backward compatibility through wrapper functions.
Changes
API Update:
// Before (v0.2.1)
pub fn delegate_stake(
stake_pubkey: &Pubkey,
authorized_pubkey: &Pubkey,
vote_pubkey: &Pubkey,
) -> Instruction
// After (v0.2.2)
pub fn delegate_stake(
stake_pubkey: &Pubkey,
authorized_pubkey: &Pubkey,
vote_pubkey: &Pubkey,
whitelist_entry_pubkey: &Pubkey, // ← New explicit parameter
) -> InstructionWhy This Change:
- Tests can now control which whitelist entry to pass (edge case testing)
- API is explicit about required accounts (better developer experience)
- Fixes test failures where implicit derivation caused wrong error paths
Backward Compatibility:
- Wrapper functions (
create_account_and_delegate_stake, etc.) auto-derive the whitelist entry - 99% of existing code uses wrappers → no changes needed
- Instruction format unchanged (still 7 accounts) → validator unaffected
Files Changed
Interface:
interface/src/instruction.rs: Updateddelegate_stake()signature and wrappers
Tests:
program/tests/stake_instruction.rs: Added 4th param to 2 test callsprogram/tests/program_test.rs: Simplified helper functionprogram/tests/interface.rs: Simplified test call
Workspace:
Cargo.toml: Version bump 0.2.1 → 0.2.2
Testing
✅ All stake program tests passing (56 tests)
cargo test -p spherenet-stake-program