Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/whole-poets-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codama/renderers-rust': minor
---

extract `solana-account-info` from `solana-program` & `solana-account` from `solana-sdk`
1 change: 1 addition & 0 deletions packages/renderers-rust/e2e/anchor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/renderers-rust/e2e/anchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ num-derive = "^0.3"
num-traits = "^0.2"
serde = { version = "^1.0", features = ["derive"], optional = true }
serde_with = { version = "^3.0", optional = true }
solana-account-info = "2.2.1"
solana-program = "2.2.1"
solana-instruction = "2.2.1"
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ impl GuardV1 {
}
}

impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for GuardV1 {
impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for GuardV1 {
type Error = std::io::Error;

fn try_from(
account_info: &solana_program::account_info::AccountInfo<'a>,
) -> Result<Self, Self::Error> {
fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
let mut data: &[u8] = &(*account_info.data).borrow();
Self::deserialize(&mut data)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,50 +279,50 @@ impl CreateGuardBuilder {

/// `create_guard` CPI accounts.
pub struct CreateGuardCpiAccounts<'a, 'b> {
pub guard: &'b solana_program::account_info::AccountInfo<'a>,
pub guard: &'b solana_account_info::AccountInfo<'a>,

pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_account_info::AccountInfo<'a>,

pub mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_token_account: &'b solana_account_info::AccountInfo<'a>,

pub guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub guard_authority: &'b solana_account_info::AccountInfo<'a>,

pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_account_info::AccountInfo<'a>,

pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,

pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,

pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
}

/// `create_guard` CPI instruction.
pub struct CreateGuardCpi<'a, 'b> {
/// The program to invoke.
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub __program: &'b solana_account_info::AccountInfo<'a>,

pub guard: &'b solana_program::account_info::AccountInfo<'a>,
pub guard: &'b solana_account_info::AccountInfo<'a>,

pub mint: &'b solana_program::account_info::AccountInfo<'a>,
pub mint: &'b solana_account_info::AccountInfo<'a>,

pub mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
pub mint_token_account: &'b solana_account_info::AccountInfo<'a>,

pub guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub guard_authority: &'b solana_account_info::AccountInfo<'a>,

pub payer: &'b solana_program::account_info::AccountInfo<'a>,
pub payer: &'b solana_account_info::AccountInfo<'a>,

pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,

pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub token_program: &'b solana_account_info::AccountInfo<'a>,

pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
/// The arguments for the instruction.
pub __args: CreateGuardInstructionArgs,
}

impl<'a, 'b> CreateGuardCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
program: &'b solana_account_info::AccountInfo<'a>,
accounts: CreateGuardCpiAccounts<'a, 'b>,
args: CreateGuardInstructionArgs,
) -> Self {
Expand All @@ -346,11 +346,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
Expand All @@ -367,11 +363,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(*self.guard.key, false));
Expand Down Expand Up @@ -453,7 +445,7 @@ pub struct CreateGuardCpiBuilder<'a, 'b> {
}

impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(CreateGuardCpiBuilderInstruction {
__program: program,
guard: None,
Expand All @@ -475,56 +467,56 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
Self { instruction }
}
#[inline(always)]
pub fn guard(&mut self, guard: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
pub fn guard(&mut self, guard: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.guard = Some(guard);
self
}
#[inline(always)]
pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.mint = Some(mint);
self
}
#[inline(always)]
pub fn mint_token_account(
&mut self,
mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
mint_token_account: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.mint_token_account = Some(mint_token_account);
self
}
#[inline(always)]
pub fn guard_authority(
&mut self,
guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
guard_authority: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.guard_authority = Some(guard_authority);
self
}
#[inline(always)]
pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.payer = Some(payer);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
associated_token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn token_program(
&mut self,
token_program: &'b solana_program::account_info::AccountInfo<'a>,
token_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn system_program(
&mut self,
system_program: &'b solana_program::account_info::AccountInfo<'a>,
system_program: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
Expand Down Expand Up @@ -568,7 +560,7 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: &'b solana_program::account_info::AccountInfo<'a>,
account: &'b solana_account_info::AccountInfo<'a>,
is_writable: bool,
is_signer: bool,
) -> &mut Self {
Expand All @@ -584,11 +576,7 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> &mut Self {
self.instruction
.__remaining_accounts
Expand Down Expand Up @@ -661,25 +649,21 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {

#[derive(Clone, Debug)]
struct CreateGuardCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
guard: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
mint_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
guard_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__program: &'b solana_account_info::AccountInfo<'a>,
guard: Option<&'b solana_account_info::AccountInfo<'a>>,
mint: Option<&'b solana_account_info::AccountInfo<'a>>,
mint_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
guard_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
payer: Option<&'b solana_account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
name: Option<String>,
symbol: Option<String>,
uri: Option<String>,
cpi_rule: Option<CpiRule>,
transfer_amount_rule: Option<TransferAmountRule>,
additional_fields_rule: Option<Vec<MetadataAdditionalFieldRule>>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}
Loading