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/free-colts-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codama/renderers-rust': minor
---

extract entrypoint and error from solana-program
2 changes: 2 additions & 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.

2 changes: 2 additions & 0 deletions packages/renderers-rust/e2e/anchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ 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-program-entrypoint = "2.2.1"
solana-program-error = "2.2.1"
solana-instruction = "2.2.1"
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }
solana-client = { version = "~1.18", optional = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum WenTransferGuardError {
MintAssignedTransferHookProgramIsNotThisOne = 0x1777,
}

impl solana_program::program_error::PrintProgramError for WenTransferGuardError {
impl solana_program_error::PrintProgramError for WenTransferGuardError {
fn print<E>(&self) {
solana_program::msg!(&self.to_string());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,21 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -364,7 +364,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(*self.guard.key, false));
accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, true));
Expand Down Expand Up @@ -584,15 +584,15 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let args = CreateGuardInstructionArgs {
name: self.instruction.name.clone().expect("name is not set"),
symbol: self.instruction.symbol.clone().expect("symbol is not set"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,21 @@ impl<'a, 'b> ExecuteCpi<'a, 'b> {
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -297,7 +297,7 @@ impl<'a, 'b> ExecuteCpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.source_account.key,
Expand Down Expand Up @@ -479,15 +479,15 @@ impl<'a, 'b> ExecuteCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let args = ExecuteInstructionArgs {
amount: self.instruction.amount.clone().expect("amount is not set"),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,21 @@ impl<'a, 'b> InitializeCpi<'a, 'b> {
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -253,7 +253,7 @@ impl<'a, 'b> InitializeCpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.extra_metas_account.key,
Expand Down Expand Up @@ -406,15 +406,15 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let instruction = InitializeCpi {
__program: self.instruction.__program,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,21 @@ impl<'a, 'b> UpdateGuardCpi<'a, 'b> {
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -299,7 +299,7 @@ impl<'a, 'b> UpdateGuardCpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(*self.guard.key, false));
accounts.push(solana_instruction::AccountMeta::new_readonly(
Expand Down Expand Up @@ -480,15 +480,15 @@ impl<'a, 'b> UpdateGuardCpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let args = UpdateGuardInstructionArgs {
cpi_rule: self.instruction.cpi_rule.clone(),
transfer_amount_rule: self.instruction.transfer_amount_rule.clone(),
Expand Down
2 changes: 2 additions & 0 deletions packages/renderers-rust/e2e/dummy/Cargo.lock

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

2 changes: 2 additions & 0 deletions packages/renderers-rust/e2e/dummy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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-program-entrypoint = "2.2.1"
solana-program-error = "2.2.1"
solana-instruction = "2.2.1"
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }
serde-big-array = { version = "^0.5", optional = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ impl<'a, 'b> Instruction1Cpi<'a, 'b> {
Self { __program: program }
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -121,7 +121,7 @@ impl<'a, 'b> Instruction1Cpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(remaining_accounts.len());
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
Expand Down Expand Up @@ -196,15 +196,15 @@ impl<'a, 'b> Instruction1CpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let instruction = Instruction1Cpi {
__program: self.instruction.__program,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ impl<'a, 'b> Instruction2Cpi<'a, 'b> {
Self { __program: program }
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
Expand All @@ -121,7 +121,7 @@ impl<'a, 'b> Instruction2Cpi<'a, 'b> {
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(remaining_accounts.len());
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
Expand Down Expand Up @@ -196,15 +196,15 @@ impl<'a, 'b> Instruction2CpiBuilder<'a, 'b> {
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
) -> solana_program_entrypoint::ProgramResult {
let instruction = Instruction2Cpi {
__program: self.instruction.__program,
};
Expand Down
Loading