Adapt to create_program_address changes
This commit is contained in:
parent
d87d056e61
commit
b9bb2f2c48
|
@ -11,7 +11,7 @@ use num_traits::FromPrimitive;
|
|||
#[cfg(not(target_arch = "bpf"))]
|
||||
use solana_sdk::instruction::Instruction;
|
||||
#[cfg(target_arch = "bpf")]
|
||||
use solana_sdk::program::{create_program_address, invoke_signed};
|
||||
use solana_sdk::program::invoke_signed;
|
||||
use solana_sdk::{
|
||||
account_info::next_account_info, account_info::AccountInfo, decode_error::DecodeError,
|
||||
entrypoint::ProgramResult, info, program_error::PrintProgramError, program_error::ProgramError,
|
||||
|
@ -80,7 +80,7 @@ impl State {
|
|||
|
||||
/// Calculates the authority id by generating a program address.
|
||||
pub fn authority_id(program_id: &Pubkey, my_info: &Pubkey) -> Result<Pubkey, Error> {
|
||||
create_program_address(&[&my_info.to_bytes()[..32]], program_id)
|
||||
Pubkey::create_program_address(&[&my_info.to_bytes()[..32]], program_id)
|
||||
.or(Err(Error::InvalidProgramAddress))
|
||||
}
|
||||
/// Issue a spl_token `Burn` instruction.
|
||||
|
@ -460,7 +460,7 @@ pub fn invoke_signed<'a>(
|
|||
if meta.pubkey == *account_info.key {
|
||||
let mut new_account_info = account_info.clone();
|
||||
for seeds in signers_seeds.iter() {
|
||||
let signer = create_program_address(seeds, &SWAP_PROGRAM_ID).unwrap();
|
||||
let signer = Pubkey::create_program_address(seeds, &SWAP_PROGRAM_ID).unwrap();
|
||||
if *account_info.key == signer {
|
||||
new_account_info.is_signer = true;
|
||||
}
|
||||
|
@ -476,26 +476,6 @@ pub fn invoke_signed<'a>(
|
|||
)
|
||||
}
|
||||
|
||||
/// TODO: Remove this stub function once solana-sdk exports it
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
pub fn create_program_address(
|
||||
seeds: &[&[u8]],
|
||||
program_id: &Pubkey,
|
||||
) -> Result<Pubkey, solana_sdk::pubkey::PubkeyError> {
|
||||
let mut hasher = solana_sdk::hash::Hasher::default();
|
||||
for seed in seeds.iter() {
|
||||
if seed.len() > solana_sdk::pubkey::MAX_SEED_LEN {
|
||||
return Err(solana_sdk::pubkey::PubkeyError::MaxSeedLengthExceeded);
|
||||
}
|
||||
hasher.hash(seed);
|
||||
}
|
||||
hasher.hashv(&[program_id.as_ref(), "ProgramDerivedAddress".as_ref()]);
|
||||
|
||||
Ok(Pubkey::new(
|
||||
solana_sdk::hash::hash(hasher.result().as_ref()).as_ref(),
|
||||
))
|
||||
}
|
||||
|
||||
impl PrintProgramError for Error {
|
||||
fn print<E>(&self)
|
||||
where
|
||||
|
|
Loading…
Reference in New Issue