1
 let stake = try_from_slice_unchecked::<StakePool>(&stake_pool.data.borrow())?;

i have tried try_from, try_from_slice,unchecheked and with schema as well, but I get this same error,

the trait bound `spl_stake_pool::state::StakePool: BorshDeserialize` is not satisfied
the following other types implement trait `BorshDeserialize`:

Can anyone help me on this?

1 Answer 1

2

This is saying you don't have the BorshDeserialize trait in scope/are using the wrong try_from_slice_unchecked. Unfortunately solana_program exports a bunch of borsh versions that all work with a different combination of types. Anyway:

If you're using spl_stake_pool 1.0.0 the correct import is:

use spl_stake_pool::{solana_program::borsh0_10::try_from_slice_unchecked, state::StakePool};

...
let stake = try_from_slice_unchecked::<StakePool>(&bytes).unwrap();

If you're using spl_stake_pool 2.0.0 the correct import is (notice the difference in the borsh import!):

use spl_stake_pool::{solana_program::borsh1::try_from_slice_unchecked, state::StakePool};

...
let stake = try_from_slice_unchecked::<StakePool>(&bytes).unwrap();
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.