-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves the system program into its own crate in "programs/system".
- Loading branch information
Showing
12 changed files
with
106 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "solana-system-program" | ||
description = "Solana System program" | ||
documentation = "https://docs.rs/solana-system-program" | ||
version = { workspace = true } | ||
authors = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
bincode = { workspace = true } | ||
log = { workspace = true } | ||
serde = { workspace = true } | ||
serde_derive = { workspace = true } | ||
solana-program-runtime = { workspace = true } | ||
solana-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
assert_matches = { workspace = true } | ||
solana-logger = { workspace = true } | ||
solana-runtime = { workspace = true } | ||
|
||
[lib] | ||
crate-type = ["lib"] | ||
name = "solana_system_program" | ||
|
||
[package.metadata.docs.rs] | ||
targets = ["x86_64-unknown-linux-gnu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#![allow(clippy::integer_arithmetic)] | ||
pub mod system_instruction; | ||
pub mod system_processor; | ||
|
||
use solana_sdk::{ | ||
account::{AccountSharedData, ReadableAccount}, | ||
account_utils::StateMut, | ||
nonce, system_program, | ||
}; | ||
|
||
pub use system_program::id; | ||
|
||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
pub enum SystemAccountKind { | ||
System, | ||
Nonce, | ||
} | ||
|
||
pub fn get_system_account_kind(account: &AccountSharedData) -> Option<SystemAccountKind> { | ||
if system_program::check_id(account.owner()) { | ||
if account.data().is_empty() { | ||
Some(SystemAccountKind::System) | ||
} else if account.data().len() == nonce::State::size() { | ||
let nonce_versions: nonce::state::Versions = account.state().ok()?; | ||
match nonce_versions.state() { | ||
nonce::State::Uninitialized => None, | ||
nonce::State::Initialized(_) => Some(SystemAccountKind::Nonce), | ||
} | ||
} else { | ||
None | ||
} | ||
} else { | ||
None | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters