Skip to content

Commit

Permalink
move BorrowedAccountMeta and BorrowedInstruction to instruction crate (
Browse files Browse the repository at this point in the history
…#3693)

* move BorrowedAccountMeta and BorrowedInstruction to solana-instruction crate

* update doc comments

Co-authored-by: Jon C <[email protected]>

---------

Co-authored-by: Jon C <[email protected]>
  • Loading branch information
kevinheavey and joncinque authored Nov 18, 2024
1 parent 73f54a0 commit e3954be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
20 changes: 20 additions & 0 deletions sdk/instruction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,23 @@ pub struct ProcessedSiblingInstruction {
/// Number of AccountMeta structures
pub accounts_len: u64,
}

/// Borrowed version of `AccountMeta`.
///
/// This struct is used by the runtime when constructing the instructions sysvar. It is not
/// useful to Solana programs.
pub struct BorrowedAccountMeta<'a> {
pub pubkey: &'a Pubkey,
pub is_signer: bool,
pub is_writable: bool,
}

/// Borrowed version of `Instruction`.
///
/// This struct is used by the runtime when constructing the instructions sysvar. It is not
/// useful to Solana programs.
pub struct BorrowedInstruction<'a> {
pub program_id: &'a Pubkey,
pub accounts: Vec<BorrowedAccountMeta<'a>>,
pub data: &'a [u8],
}
23 changes: 2 additions & 21 deletions sdk/program/src/sysvar/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#[cfg(feature = "dev-context-only-utils")]
use qualifier_attr::qualifiers;
#[deprecated(since = "2.2.0", note = "Use solana-instruction crate instead")]
pub use solana_instruction::{BorrowedAccountMeta, BorrowedInstruction};
pub use solana_sdk_ids::sysvar::instructions::{check_id, id, ID};
#[cfg(not(target_os = "solana"))]
use {
Expand All @@ -42,7 +44,6 @@ use {
account_info::AccountInfo,
instruction::{AccountMeta, Instruction},
program_error::ProgramError,
pubkey::Pubkey,
serialize_utils::{read_pubkey, read_slice, read_u16, read_u8},
},
solana_sanitize::SanitizeError,
Expand Down Expand Up @@ -74,26 +75,6 @@ pub fn construct_instructions_data(instructions: &[BorrowedInstruction]) -> Vec<
data
}

/// Borrowed version of `AccountMeta`.
///
/// This struct is used by the runtime when constructing the sysvar. It is not
/// useful to Solana programs.
pub struct BorrowedAccountMeta<'a> {
pub pubkey: &'a Pubkey,
pub is_signer: bool,
pub is_writable: bool,
}

/// Borrowed version of `Instruction`.
///
/// This struct is used by the runtime when constructing the sysvar. It is not
/// useful to Solana programs.
pub struct BorrowedInstruction<'a> {
pub program_id: &'a Pubkey,
pub accounts: Vec<BorrowedAccountMeta<'a>>,
pub data: &'a [u8],
}

#[cfg(not(target_os = "solana"))]
bitflags! {
struct InstructionsSysvarAccountMeta: u8 {
Expand Down

0 comments on commit e3954be

Please sign in to comment.