diff --git a/sdk/pinocchio/src/instruction.rs b/sdk/pinocchio/src/instruction.rs index 371dc88..889ac2c 100644 --- a/sdk/pinocchio/src/instruction.rs +++ b/sdk/pinocchio/src/instruction.rs @@ -1,6 +1,6 @@ //! Instruction types. -use core::marker::PhantomData; +use core::{marker::PhantomData, mem::MaybeUninit}; use crate::{account_info::AccountInfo, pubkey::Pubkey}; @@ -211,3 +211,20 @@ impl<'a, 'b> From<&'b [Seed<'a>]> for Signer<'a, 'b> { } } } + +impl<'a, 'b> Signer<'a, 'b> { + pub fn from_slice(seeds: &'b [&'a [u8]; SEEDS]) -> Self { + const UNINIT: MaybeUninit = core::mem::MaybeUninit::uninit(); + let mut signer_seeds = [UNINIT; SEEDS]; + + seeds.iter().enumerate().for_each(|(i, seed)| { + signer_seeds[i].write(Seed::from(*seed)); + }); + + Self { + seeds: signer_seeds.as_ptr() as *const Seed, + len: SEEDS as u64, + _seeds: PhantomData::<&'b [Seed<'a>]>, + } + } +}