Skip to content

Commit 4c84252

Browse files
authored
Bump Codama Rust renderer to v2 (#71)
1 parent 000d4ec commit 4c84252

22 files changed

Lines changed: 916 additions & 1224 deletions

Cargo.lock

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/rust/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ serde = ["dep:serde", "dep:serde_with", "kaigan/serde"]
1414

1515
[dependencies]
1616
borsh = "^0.10"
17-
kaigan = "^0.2"
17+
kaigan = "^0.3"
1818
num-derive = "^0.4"
1919
num-traits = "^0.2"
2020
serde = { version = "^1.0", features = ["derive"], optional = true }
@@ -23,3 +23,9 @@ solana-client = { version = "2.3.4", optional = true }
2323
solana-sdk = { version = "2.2.1", optional = true }
2424
solana-program = "2.2.1"
2525
thiserror = "^1.0"
26+
solana-account = "~2.2"
27+
solana-account-info = "~2.3"
28+
solana-instruction = "~2.3"
29+
solana-program-error = "~2.2"
30+
solana-pubkey = { version = "~2.4", features = ["curve25519", "borsh"] }
31+
solana-cpi = "~2.2"

clients/rust/src/generated/accounts/nonce.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::generated::types::NonceState;
99
use crate::generated::types::NonceVersion;
1010
use borsh::BorshDeserialize;
1111
use borsh::BorshSerialize;
12-
use solana_program::pubkey::Pubkey;
12+
use solana_pubkey::Pubkey;
1313

1414
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
1515
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@@ -39,12 +39,10 @@ impl Nonce {
3939
}
4040
}
4141

42-
impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Nonce {
42+
impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Nonce {
4343
type Error = std::io::Error;
4444

45-
fn try_from(
46-
account_info: &solana_program::account_info::AccountInfo<'a>,
47-
) -> Result<Self, Self::Error> {
45+
fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
4846
let mut data: &[u8] = &(*account_info.data).borrow();
4947
Self::deserialize(&mut data)
5048
}
@@ -53,7 +51,7 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Nonce {
5351
#[cfg(feature = "fetch")]
5452
pub fn fetch_nonce(
5553
rpc: &solana_client::rpc_client::RpcClient,
56-
address: &solana_program::pubkey::Pubkey,
54+
address: &solana_pubkey::Pubkey,
5755
) -> Result<crate::shared::DecodedAccount<Nonce>, std::io::Error> {
5856
let accounts = fetch_all_nonce(rpc, &[*address])?;
5957
Ok(accounts[0].clone())
@@ -62,7 +60,7 @@ pub fn fetch_nonce(
6260
#[cfg(feature = "fetch")]
6361
pub fn fetch_all_nonce(
6462
rpc: &solana_client::rpc_client::RpcClient,
65-
addresses: &[solana_program::pubkey::Pubkey],
63+
addresses: &[solana_pubkey::Pubkey],
6664
) -> Result<Vec<crate::shared::DecodedAccount<Nonce>>, std::io::Error> {
6765
let accounts = rpc
6866
.get_multiple_accounts(addresses)
@@ -87,7 +85,7 @@ pub fn fetch_all_nonce(
8785
#[cfg(feature = "fetch")]
8886
pub fn fetch_maybe_nonce(
8987
rpc: &solana_client::rpc_client::RpcClient,
90-
address: &solana_program::pubkey::Pubkey,
88+
address: &solana_pubkey::Pubkey,
9189
) -> Result<crate::shared::MaybeAccount<Nonce>, std::io::Error> {
9290
let accounts = fetch_all_maybe_nonce(rpc, &[*address])?;
9391
Ok(accounts[0].clone())
@@ -96,7 +94,7 @@ pub fn fetch_maybe_nonce(
9694
#[cfg(feature = "fetch")]
9795
pub fn fetch_all_maybe_nonce(
9896
rpc: &solana_client::rpc_client::RpcClient,
99-
addresses: &[solana_program::pubkey::Pubkey],
97+
addresses: &[solana_pubkey::Pubkey],
10098
) -> Result<Vec<crate::shared::MaybeAccount<Nonce>>, std::io::Error> {
10199
let accounts = rpc
102100
.get_multiple_accounts(addresses)

clients/rust/src/generated/errors/system.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,8 @@ pub enum SystemError {
3939
NonceUnexpectedBlockhashValue = 0x8,
4040
}
4141

42-
impl solana_program::program_error::PrintProgramError for SystemError {
43-
fn print<E>(&self) {
44-
solana_program::msg!(&self.to_string());
45-
}
46-
}
47-
48-
impl<T> solana_program::decode_error::DecodeError<T> for SystemError {
49-
fn type_of() -> &'static str {
50-
"SystemError"
42+
impl From<SystemError> for solana_program_error::ProgramError {
43+
fn from(e: SystemError) -> Self {
44+
solana_program_error::ProgramError::Custom(e as u32)
5145
}
5246
}

0 commit comments

Comments
 (0)