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
1,356 changes: 1,099 additions & 257 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,30 @@ bytemuck = "1.20.0"
num-derive = "0.4"
num-traits = "0.2"
num_enum = "0.7.3"
solana-program = "2.1.0"
solana-account-info = "2.2.0"
solana-cpi = "2.2.0"
solana-decode-error = "2.2.0"
solana-instruction = "2.2.0"
solana-msg = "2.2.0"
solana-program-entrypoint = "2.2.0"
solana-program-error = "2.2.0"
solana-program-memory = "2.2.0"
solana-program-option = "2.2.0"
solana-program-pack = "2.2.0"
solana-pubkey = { version = "2.2.0", features = ["bytemuck"] }
solana-rent = "2.2.0"
solana-sdk-ids = "2.2.0"
solana-sysvar = { version = "2.2.0", features = ["bincode"] }
thiserror = "2.0"

[dev-dependencies]
lazy_static = "1.5.0"
mollusk-svm = { version = "0.0.13", git = "https://github.com/buffalojoec/mollusk.git" }
mollusk-svm = "0.1.0"
proptest = "1.5"
serial_test = "3.2.0"
solana-sdk = "2.1.0"
solana-clock = "2.2.1"
solana-native-token = "2.2.1"
solana-sdk = "2.2.1"

[lib]
crate-type = ["cdylib", "lib"]
Expand Down
9 changes: 4 additions & 5 deletions program/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

use {
crate::{error::TokenError, processor::Processor},
solana_program::{
account_info::AccountInfo, entrypoint::ProgramResult, program_error::PrintProgramError,
pubkey::Pubkey,
},
solana_account_info::AccountInfo,
solana_program_error::{PrintProgramError, ProgramResult},
solana_pubkey::Pubkey,
};

solana_program::entrypoint!(process_instruction);
solana_program_entrypoint::entrypoint!(process_instruction);
fn process_instruction(
program_id: &Pubkey,
accounts: &[AccountInfo],
Expand Down
8 changes: 3 additions & 5 deletions program/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
use {
num_derive::FromPrimitive,
solana_program::{
decode_error::DecodeError,
msg,
program_error::{PrintProgramError, ProgramError},
},
solana_decode_error::DecodeError,
solana_msg::msg,
solana_program_error::{PrintProgramError, ProgramError},
thiserror::Error,
};

Expand Down
12 changes: 5 additions & 7 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

use {
crate::{check_program_account, error::TokenError},
solana_program::{
instruction::{AccountMeta, Instruction},
program_error::ProgramError,
program_option::COption,
pubkey::Pubkey,
sysvar,
},
solana_instruction::{AccountMeta, Instruction},
solana_program_error::ProgramError,
solana_program_option::COption,
solana_pubkey::Pubkey,
solana_sdk_ids::sysvar,
std::{convert::TryInto, mem::size_of},
};

Expand Down
33 changes: 28 additions & 5 deletions program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,33 @@ pub mod state;
#[cfg(not(feature = "no-entrypoint"))]
mod entrypoint;

// Export current sdk types for downstream users building with a different sdk
// version
pub use solana_program;
use solana_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};
/// Export current sdk types for downstream users building with a different sdk
/// version
pub mod solana_program {
#![allow(missing_docs)]
pub mod entrypoint {
pub use solana_program_error::ProgramResult;
}
pub mod instruction {
pub use solana_instruction::{AccountMeta, Instruction};
}
pub mod program_error {
pub use solana_program_error::{PrintProgramError, ProgramError};
}
pub mod program_option {
pub use solana_program_option::COption;
}
pub mod program_pack {
pub use solana_program_pack::{IsInitialized, Pack, Sealed};
}
pub mod pubkey {
pub use solana_pubkey::{Pubkey, PUBKEY_BYTES};
}
}
Comment on lines +16 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is needed? With the crates now split up and following semver, I hope that we can stop doing these re-exports in program crates generally.

We can do a new major version for spl-token no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still like to break fewer things in a major release. This way hopefully very few people will need to change code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough! We can revisit then

use {
solana_program_error::{ProgramError, ProgramResult},
solana_pubkey::Pubkey,
};

/// Convert the UI representation of a token amount (using the decimals field
/// defined in its mint) to the raw amount
Expand Down Expand Up @@ -82,7 +105,7 @@ pub fn try_ui_amount_into_amount(ui_amount: String, decimals: u8) -> Result<u64,
.map_err(|_| ProgramError::InvalidArgument)
}

solana_program::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
solana_pubkey::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

/// Checks that the supplied program ID is the correct one for SPL-token
pub fn check_program_account(spl_token_program_id: &Pubkey) -> ProgramResult {
Expand Down
4 changes: 2 additions & 2 deletions program/src/native_mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
pub const DECIMALS: u8 = 9;

// The Mint for native SOL Token accounts
solana_program::declare_id!("So11111111111111111111111111111111111111112");
solana_pubkey::declare_id!("So11111111111111111111111111111111111111112");

#[cfg(test)]
mod tests {
use {super::*, solana_program::native_token::*};
use {super::*, solana_native_token::*};

#[test]
fn test_decimals() {
Expand Down
31 changes: 15 additions & 16 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ use {
state::{Account, AccountState, Mint, Multisig},
try_ui_amount_into_amount,
},
solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
msg,
program::set_return_data,
program_error::ProgramError,
program_memory::sol_memcmp,
program_option::COption,
program_pack::{IsInitialized, Pack},
pubkey::{Pubkey, PUBKEY_BYTES},
system_program,
sysvar::{rent::Rent, Sysvar},
},
solana_account_info::{next_account_info, AccountInfo},
solana_cpi::set_return_data,
solana_msg::msg,
solana_program_error::{ProgramError, ProgramResult},
solana_program_memory::sol_memcmp,
solana_program_option::COption,
solana_program_pack::{IsInitialized, Pack},
solana_pubkey::{Pubkey, PUBKEY_BYTES},
solana_rent::Rent,
solana_sdk_ids::system_program,
solana_sysvar::Sysvar,
};

/// Program state handler.
Expand Down Expand Up @@ -695,7 +693,7 @@ impl Processor {
authority_info,
account_info_iter.as_slice(),
)?;
} else if !solana_program::incinerator::check_id(destination_account_info.key) {
} else if !solana_sdk_ids::incinerator::check_id(destination_account_info.key) {
return Err(ProgramError::InvalidAccountData);
}

Expand Down Expand Up @@ -1027,7 +1025,7 @@ fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
account_info.assign(&system_program::id());
let mut account_data = account_info.data.borrow_mut();
let data_len = account_data.len();
solana_program::program_memory::sol_memset(*account_data, 0, data_len);
solana_program_memory::sol_memset(*account_data, 0, data_len);
Ok(())
}

Expand All @@ -1042,7 +1040,8 @@ fn delete_account(account_info: &AccountInfo) -> Result<(), ProgramError> {
mod tests {
use {
super::*,
solana_program::{clock::Epoch, program_error::PrintProgramError},
solana_clock::Epoch,
solana_program_error::PrintProgramError,
std::sync::{Arc, RwLock},
};

Expand Down
14 changes: 6 additions & 8 deletions program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use {
crate::instruction::MAX_SIGNERS,
arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs},
num_enum::TryFromPrimitive,
solana_program::{
program_error::ProgramError,
program_option::COption,
program_pack::{IsInitialized, Pack, Sealed},
pubkey::{Pubkey, PUBKEY_BYTES},
},
solana_program_error::ProgramError,
solana_program_option::COption,
solana_program_pack::{IsInitialized, Pack, Sealed},
solana_pubkey::{Pubkey, PUBKEY_BYTES},
};

/// Mint data.
Expand Down Expand Up @@ -120,8 +118,8 @@ impl Account {
/// Checks if a token Account's owner is the `system_program` or the
/// incinerator
pub fn is_owned_by_system_program_or_incinerator(&self) -> bool {
solana_program::system_program::check_id(&self.owner)
|| solana_program::incinerator::check_id(&self.owner)
solana_sdk_ids::system_program::check_id(&self.owner)
|| solana_sdk_ids::incinerator::check_id(&self.owner)
}
}
impl Sealed for Account {}
Expand Down
12 changes: 6 additions & 6 deletions program/tests/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3833,7 +3833,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
&program_id,
&incinerator_account_key,
&mint_key,
&solana_program::incinerator::id(),
&solana_sdk_ids::incinerator::id(),
)
.unwrap(),
vec![&mut incinerator_account, &mut mint_account],
Expand All @@ -3845,7 +3845,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
&program_id,
&system_account_key,
&mint_key,
&solana_program::system_program::id(),
&solana_sdk_ids::system_program::id(),
)
.unwrap(),
vec![&mut system_account, &mut mint_account],
Expand Down Expand Up @@ -3906,7 +3906,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
close_account(
&program_id,
&incinerator_account_key,
&solana_program::incinerator::id(),
&solana_sdk_ids::incinerator::id(),
&owner_key,
&[]
)
Expand All @@ -3925,7 +3925,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
close_account(
&program_id,
&system_account_key,
&solana_program::incinerator::id(),
&solana_sdk_ids::incinerator::id(),
&owner_key,
&[]
)
Expand Down Expand Up @@ -4022,7 +4022,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
close_account(
&program_id,
&incinerator_account_key,
&solana_program::incinerator::id(),
&solana_sdk_ids::incinerator::id(),
&owner_key,
&[],
)
Expand All @@ -4040,7 +4040,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() {
close_account(
&program_id,
&system_account_key,
&solana_program::incinerator::id(),
&solana_sdk_ids::incinerator::id(),
&owner_key,
&[],
)
Expand Down
1 change: 1 addition & 0 deletions scripts/solana.dic
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ staker/S
APY
codama
autogenerated
sdk
Loading