Skip to content

Commit 44e71cd

Browse files
authored
interface: Remove all usage of solana-program (#54)
* interface: Remove all usage of solana-program #### Problem The docs and tests still use solana-program in the system interface. #### Summary of changes Remove the usage in favor of solana_example_mocks, solana_sysvar, and solana_sysvar_id. * Remove solana-program from top-level
1 parent ae67559 commit 44e71cd

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ solana-instruction = "2.2.1"
2323
solana-logger = "2.2.1"
2424
solana-nonce = "2.2.1"
2525
solana-msg = "2.2.1"
26-
solana-program = { version = "2.2.1", default-features = false }
2726
solana-program-entrypoint = "2.2.1"
2827
solana-program-error = "2.2.1"
2928
solana-pubkey = { version = "2.2.1", default-features = false }
29+
solana-sysvar = { version = "2.2.1", features = ["bincode"] }
30+
solana-sysvar-id = "2.2.1"

interface/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ solana-account-info = { workspace = true }
3838
solana-cpi = { workspace = true }
3939
solana-example-mocks = { workspace = true }
4040
solana-nonce = { workspace = true }
41-
solana-program = { workspace = true, default-features = false }
4241
solana-program-entrypoint = { workspace = true }
4342
solana-program-error = { workspace = true, features = ["borsh"] }
4443
solana-pubkey = { workspace = true, features = ["std"] }
4544
solana-system-interface = { path = ".", features = ["bincode"] }
45+
solana-sysvar = { workspace = true }
46+
solana-sysvar-id = { workspace = true }
4647
static_assertions = "1.1.0"
4748
strum = "0.24"
4849
strum_macros = "0.24"

interface/src/instruction.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub enum SystemInstruction {
279279
/// The `payer` and `new_account` are signers.
280280
///
281281
/// ```
282-
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
282+
/// # use solana_example_mocks::{solana_sdk, solana_rpc_client};
283283
/// use solana_rpc_client::rpc_client::RpcClient;
284284
/// use solana_sdk::{
285285
/// signature::{Keypair, Signer},
@@ -338,11 +338,11 @@ pub enum SystemInstruction {
338338
/// use borsh::{BorshDeserialize, BorshSerialize};
339339
/// use solana_account_info::{next_account_info, AccountInfo};
340340
/// use solana_cpi::invoke_signed;
341-
/// use solana_program::sysvar::{rent::Rent, Sysvar};
342341
/// use solana_program_entrypoint::entrypoint;
343342
/// use solana_program_error::ProgramResult;
344343
/// use solana_pubkey::Pubkey;
345344
/// use solana_system_interface::{instruction, program};
345+
/// use solana_sysvar::{rent::Rent, Sysvar};
346346
///
347347
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
348348
/// pub struct CreateAccountInstruction {
@@ -481,7 +481,7 @@ pub fn create_account_with_seed(
481481
/// The `payer` and `new_account` are signers.
482482
///
483483
/// ```
484-
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
484+
/// # use solana_example_mocks::{solana_sdk, solana_rpc_client};
485485
/// use solana_rpc_client::rpc_client::RpcClient;
486486
/// use solana_pubkey::Pubkey;
487487
/// use solana_sdk::{
@@ -553,11 +553,11 @@ pub fn create_account_with_seed(
553553
/// use borsh::{BorshDeserialize, BorshSerialize};
554554
/// use solana_account_info::{next_account_info, AccountInfo};
555555
/// use solana_cpi::invoke_signed;
556-
/// use solana_program::sysvar::{rent::Rent, Sysvar};
557556
/// use solana_program_entrypoint::entrypoint;
558557
/// use solana_program_error::ProgramResult;
559558
/// use solana_pubkey::Pubkey;
560559
/// use solana_system_interface::{instruction, program};
560+
/// use solana_sysvar::{rent::Rent, Sysvar};
561561
///
562562
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
563563
/// pub struct CreateAccountInstruction {
@@ -674,7 +674,7 @@ pub fn assign_with_seed(
674674
/// The `payer` and `new_account` are signers.
675675
///
676676
/// ```
677-
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
677+
/// # use solana_example_mocks::{solana_sdk, solana_rpc_client};
678678
/// use solana_rpc_client::rpc_client::RpcClient;
679679
/// use solana_pubkey::Pubkey;
680680
/// use solana_sdk::{
@@ -746,11 +746,11 @@ pub fn assign_with_seed(
746746
/// # use borsh::{BorshDeserialize, BorshSerialize};
747747
/// use solana_account_info::{next_account_info, AccountInfo};
748748
/// use solana_cpi::invoke_signed;
749-
/// use solana_program::sysvar::{rent::Rent, Sysvar};
750749
/// use solana_program_entrypoint::entrypoint;
751750
/// use solana_program_error::ProgramResult;
752751
/// use solana_pubkey::Pubkey;
753752
/// use solana_system_interface::{instruction, program};
753+
/// use solana_sysvar::{rent::Rent, Sysvar};
754754
///
755755
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
756756
/// # #[borsh(crate = "borsh")]
@@ -873,7 +873,7 @@ pub fn transfer_with_seed(
873873
/// The `payer` and `new_account` are signers.
874874
///
875875
/// ```
876-
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
876+
/// # use solana_example_mocks::{solana_sdk, solana_rpc_client};
877877
/// use solana_rpc_client::rpc_client::RpcClient;
878878
/// use solana_pubkey::Pubkey;
879879
/// use solana_sdk::{
@@ -945,11 +945,11 @@ pub fn transfer_with_seed(
945945
/// use borsh::{BorshDeserialize, BorshSerialize};
946946
/// use solana_account_info::{next_account_info, AccountInfo};
947947
/// use solana_cpi::invoke_signed;
948-
/// use solana_program::sysvar::{rent::Rent, Sysvar};
949948
/// use solana_program_entrypoint::entrypoint;
950949
/// use solana_program_error::ProgramResult;
951950
/// use solana_pubkey::Pubkey;
952951
/// use solana_system_interface::{instruction, program};
952+
/// use solana_sysvar::{rent::Rent, Sysvar};
953953
///
954954
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
955955
/// pub struct CreateAccountInstruction {
@@ -1059,7 +1059,7 @@ pub fn allocate_with_seed(
10591059
/// This example performs multiple transfers in a single transaction.
10601060
///
10611061
/// ```
1062-
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
1062+
/// # use solana_example_mocks::{solana_sdk, solana_rpc_client};
10631063
/// use solana_rpc_client::rpc_client::RpcClient;
10641064
/// use solana_pubkey::Pubkey;
10651065
/// use solana_sdk::{
@@ -1394,9 +1394,9 @@ pub fn create_nonce_account(
13941394
/// Create and sign a transaction with a durable nonce:
13951395
///
13961396
/// ```
1397-
/// # use solana_program::example_mocks::solana_sdk;
1398-
/// # use solana_program::example_mocks::solana_rpc_client;
1399-
/// # use solana_program::example_mocks::solana_rpc_client_nonce_utils;
1397+
/// # use solana_example_mocks::solana_sdk;
1398+
/// # use solana_example_mocks::solana_rpc_client;
1399+
/// # use solana_example_mocks::solana_rpc_client_nonce_utils;
14001400
/// # use solana_sdk::account::Account;
14011401
/// use solana_rpc_client::rpc_client::RpcClient;
14021402
/// use solana_pubkey::Pubkey;
@@ -1515,8 +1515,8 @@ pub fn advance_nonce_account(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey)
15151515
/// # Examples
15161516
///
15171517
/// ```
1518-
/// # use solana_program::example_mocks::solana_sdk;
1519-
/// # use solana_program::example_mocks::solana_rpc_client;
1518+
/// # use solana_example_mocks::solana_sdk;
1519+
/// # use solana_example_mocks::solana_rpc_client;
15201520
/// use solana_rpc_client::rpc_client::RpcClient;
15211521
/// use solana_pubkey::Pubkey;
15221522
/// use solana_sdk::{
@@ -1599,8 +1599,8 @@ pub fn withdraw_nonce_account(
15991599
/// # Examples
16001600
///
16011601
/// ```
1602-
/// # use solana_program::example_mocks::solana_sdk;
1603-
/// # use solana_program::example_mocks::solana_rpc_client;
1602+
/// # use solana_example_mocks::solana_sdk;
1603+
/// # use solana_example_mocks::solana_rpc_client;
16041604
/// use solana_rpc_client::rpc_client::RpcClient;
16051605
/// use solana_pubkey::Pubkey;
16061606
/// use solana_sdk::{
@@ -1670,7 +1670,7 @@ pub fn upgrade_nonce_account(nonce_pubkey: Pubkey) -> Instruction {
16701670
#[cfg(test)]
16711671
mod tests {
16721672
use super::*;
1673-
use solana_program::sysvar::SysvarId;
1673+
use solana_sysvar_id::SysvarId;
16741674

16751675
fn get_keys(instruction: &Instruction) -> Vec<Pubkey> {
16761676
instruction.accounts.iter().map(|x| x.pubkey).collect()
@@ -1682,11 +1682,11 @@ mod tests {
16821682
// Ensure that the constants are in sync with the solana program.
16831683
assert_eq!(
16841684
RECENT_BLOCKHASHES_ID,
1685-
solana_program::sysvar::recent_blockhashes::RecentBlockhashes::id(),
1685+
solana_sysvar::recent_blockhashes::RecentBlockhashes::id(),
16861686
);
16871687

16881688
// Ensure that the constants are in sync with the solana rent.
1689-
assert_eq!(RENT_ID, solana_program::sysvar::rent::Rent::id());
1689+
assert_eq!(RENT_ID, solana_sysvar::rent::Rent::id());
16901690
}
16911691

16921692
#[test]

0 commit comments

Comments
 (0)