diff --git a/Cargo.lock b/Cargo.lock index c6ead351294b2b..3f29948c6bc08b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7051,6 +7051,7 @@ dependencies = [ "solana-logger", "solana-msg", "solana-program-memory", + "solana-program-option", "solana-sanitize", "solana-sdk-macro", "solana-secp256k1-recover", @@ -7071,6 +7072,10 @@ dependencies = [ "solana-define-syscall", ] +[[package]] +name = "solana-program-option" +version = "2.1.0" + [[package]] name = "solana-program-runtime" version = "2.1.0" diff --git a/Cargo.toml b/Cargo.toml index 32d6b501a93fe2..acfdb1904f2808 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,6 +113,7 @@ members = [ "sdk/package-metadata-macro", "sdk/program", "sdk/program-memory", + "sdk/program-option", "sdk/serde-varint", "sdk/sha256-hasher", "send-transaction-service", @@ -415,6 +416,7 @@ solana-poh = { path = "poh", version = "=2.1.0" } solana-poseidon = { path = "poseidon", version = "=2.1.0" } solana-program = { path = "sdk/program", version = "=2.1.0", default-features = false } solana-program-memory = { path = "sdk/program-memory", version = "=2.1.0" } +solana-program-option = { path = "sdk/program-option", version = "=2.1.0" } solana-program-runtime = { path = "program-runtime", version = "=2.1.0" } solana-program-test = { path = "program-test", version = "=2.1.0" } solana-pubsub-client = { path = "pubsub-client", version = "=2.1.0" } diff --git a/ci/nits.sh b/ci/nits.sh index 856a4d323cddf0..764881a475dcad 100755 --- a/ci/nits.sh +++ b/ci/nits.sh @@ -29,7 +29,7 @@ declare print_free_tree=( ':sdk/**.rs' ':^sdk/cargo-build-sbf/**.rs' ':^sdk/msg/src/lib.rs' - ':^sdk/program/src/program_option.rs' + ':^sdk/program-option/src/lib.rs' ':^sdk/program/src/program_stubs.rs' ':programs/**.rs' ':^**bin**.rs' diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 370659316da19e..faebc28f2b3e2f 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -5455,6 +5455,7 @@ dependencies = [ "solana-hash", "solana-msg", "solana-program-memory", + "solana-program-option", "solana-sanitize", "solana-sdk-macro", "solana-secp256k1-recover", @@ -5473,6 +5474,10 @@ dependencies = [ "solana-define-syscall", ] +[[package]] +name = "solana-program-option" +version = "2.1.0" + [[package]] name = "solana-program-runtime" version = "2.1.0" diff --git a/sdk/program-option/Cargo.toml b/sdk/program-option/Cargo.toml new file mode 100644 index 00000000000000..d078d12d82636c --- /dev/null +++ b/sdk/program-option/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "solana-program-option" +description = "A C representation of Rust's Option, used in Solana programs." +documentation = "https://docs.rs/solana-program-option" +version = { workspace = true } +authors = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +edition = { workspace = true } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/sdk/program/src/program_option.rs b/sdk/program-option/src/lib.rs similarity index 99% rename from sdk/program/src/program_option.rs rename to sdk/program-option/src/lib.rs index 3496e5c282a804..bde0e60f6e546f 100644 --- a/sdk/program/src/program_option.rs +++ b/sdk/program-option/src/lib.rs @@ -172,7 +172,7 @@ impl COption { /// ``` /// /// ```should_panic - /// # use solana_program::program_option::COption; + /// # use solana_program_option::COption; /// let x: COption<&str> = COption::None; /// x.expect("the world is ending"); // panics with `the world is ending` /// ``` @@ -205,7 +205,7 @@ impl COption { /// ``` /// /// ```should_panic - /// # use solana_program::program_option::COption; + /// # use solana_program_option::COption; /// let x: COption<&str> = COption::None; /// assert_eq!(x.unwrap(), "air"); // fails /// ``` diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index f293283f9dff3e..3b8eeba0d567fc 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -43,6 +43,7 @@ solana-hash = { workspace = true, features = [ ] } solana-msg = { workspace = true } solana-program-memory = { workspace = true } +solana-program-option = { workspace = true } solana-sanitize = { workspace = true } solana-sdk-macro = { workspace = true } solana-secp256k1-recover = { workspace = true } diff --git a/sdk/program/src/lib.rs b/sdk/program/src/lib.rs index 9cf1fc64083e50..f1ab379034df89 100644 --- a/sdk/program/src/lib.rs +++ b/sdk/program/src/lib.rs @@ -508,7 +508,6 @@ pub mod native_token; pub mod nonce; pub mod program; pub mod program_error; -pub mod program_option; pub mod program_pack; pub mod program_stubs; pub mod program_utils; @@ -540,7 +539,7 @@ pub use solana_serde_varint as serde_varint; pub use solana_short_vec as short_vec; #[cfg(target_arch = "wasm32")] pub use wasm_bindgen::prelude::wasm_bindgen; -pub use {solana_clock as clock, solana_msg::msg}; +pub use {solana_clock as clock, solana_msg::msg, solana_program_option as program_option}; /// The [config native program][np]. ///