From 1740ea2f2cc757e88a7964c0edae43c8ffa654b8 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Tue, 15 Oct 2024 23:55:39 +0400 Subject: [PATCH] move account_utils to account crate (#3174) * move account_utils to account crate * remove superfluous import --- Cargo.lock | 2 ++ programs/sbf/Cargo.lock | 1 + sdk/account/Cargo.toml | 4 +++- sdk/account/src/lib.rs | 2 ++ sdk/{src/account_utils.rs => account/src/state_traits.rs} | 6 +++--- sdk/src/lib.rs | 6 +++++- 6 files changed, 16 insertions(+), 5 deletions(-) rename sdk/{src/account_utils.rs => account/src/state_traits.rs} (93%) diff --git a/Cargo.lock b/Cargo.lock index ab43b132ce8135..2c94a4d9d482e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5652,8 +5652,10 @@ dependencies = [ "solana-account", "solana-frozen-abi", "solana-frozen-abi-macro", + "solana-instruction", "solana-logger", "solana-program", + "solana-pubkey", ] [[package]] diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index b3fac0dc9df73e..da726ceaeca3a8 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4712,6 +4712,7 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", + "solana-instruction", "solana-program", ] diff --git a/sdk/account/Cargo.toml b/sdk/account/Cargo.toml index 015736eebe08c4..62d35391142d64 100644 --- a/sdk/account/Cargo.toml +++ b/sdk/account/Cargo.toml @@ -17,14 +17,16 @@ serde_bytes = { workspace = true, optional = true } serde_derive = { workspace = true, optional = true } solana-frozen-abi = { workspace = true, optional = true } solana-frozen-abi-macro = { workspace = true, optional = true } +solana-instruction = { workspace = true, optional = true } solana-logger = { workspace = true, optional = true } solana-program = { workspace = true } [dev-dependencies] solana-account = { path = ".", features = ["dev-context-only-utils"] } +solana-pubkey = { workspace = true } [features] -bincode = ["dep:bincode", "serde"] +bincode = ["dep:bincode", "dep:solana-instruction", "serde"] dev-context-only-utils = ["bincode", "dep:qualifier_attr"] frozen-abi = [ "dep:solana-frozen-abi", diff --git a/sdk/account/src/lib.rs b/sdk/account/src/lib.rs index 762e41a5dd5abf..0d6df6ac6d8da4 100644 --- a/sdk/account/src/lib.rs +++ b/sdk/account/src/lib.rs @@ -29,6 +29,8 @@ use { sync::Arc, }, }; +#[cfg(feature = "bincode")] +pub mod state_traits; /// An Account with data that is stored on chain #[repr(C)] diff --git a/sdk/src/account_utils.rs b/sdk/account/src/state_traits.rs similarity index 93% rename from sdk/src/account_utils.rs rename to sdk/account/src/state_traits.rs index 7338d64cc33498..9b44e43eab159e 100644 --- a/sdk/src/account_utils.rs +++ b/sdk/account/src/state_traits.rs @@ -1,9 +1,9 @@ //! Useful extras for `Account` state. use { - crate::instruction::InstructionError, + crate::{Account, AccountSharedData}, bincode::ErrorKind, - solana_account::{Account, AccountSharedData}, + solana_instruction::error::InstructionError, std::cell::Ref, }; @@ -64,7 +64,7 @@ where #[cfg(test)] mod tests { - use {super::*, crate::pubkey::Pubkey, solana_account::AccountSharedData}; + use {super::*, solana_pubkey::Pubkey}; #[test] fn test_account_state() { diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index ed07e8c7806b57..e1d9503a75de20 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -58,7 +58,6 @@ pub use solana_program::{ }; #[cfg(feature = "borsh")] pub use solana_program::{borsh, borsh0_10, borsh1}; -pub mod account_utils; pub mod client; pub mod commitment_config; pub mod compute_budget; @@ -108,6 +107,11 @@ pub mod wasm; #[deprecated(since = "2.1.0", note = "Use `solana-account` crate instead")] pub use solana_account as account; +#[deprecated( + since = "2.1.0", + note = "Use `solana_account::state_traits` crate instead" +)] +pub use solana_account::state_traits as account_utils; #[deprecated(since = "2.1.0", note = "Use `solana-bn254` crate instead")] pub use solana_bn254 as alt_bn128; #[deprecated(since = "2.1.0", note = "Use `solana-decode-error` crate instead")]