Skip to content

Commit

Permalink
extract deserialize-utils crate (solana-labs#3387)
Browse files Browse the repository at this point in the history
* extract deserialize-utils crate

* missing dev dep

* rename to solana-serde

* fix deprecated since
  • Loading branch information
kevinheavey authored Nov 14, 2024
1 parent 0b2b2a3 commit 9b29626
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ members = [
"sdk/sdk-ids",
"sdk/seed-derivable",
"sdk/seed-phrase",
"sdk/serde",
"sdk/serde-varint",
"sdk/serialize-utils",
"sdk/sha256-hasher",
Expand Down Expand Up @@ -506,6 +507,7 @@ solana-reward-info = { path = "sdk/reward-info", version = "=2.2.0" }
solana-sanitize = { path = "sdk/sanitize", version = "=2.2.0" }
solana-seed-derivable = { path = "sdk/seed-derivable", version = "=2.2.0" }
solana-seed-phrase = { path = "sdk/seed-phrase", version = "=2.2.0" }
solana-serde = { path = "sdk/serde", version = "=2.2.0" }
solana-serde-varint = { path = "sdk/serde-varint", version = "=2.2.0" }
solana-serialize-utils = { path = "sdk/serialize-utils", version = "=2.2.0" }
solana-sha256-hasher = { path = "sdk/sha256-hasher", version = "=2.2.0" }
Expand Down
8 changes: 8 additions & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ solana-sdk-macro = { workspace = true }
solana-secp256k1-recover = { workspace = true }
solana-seed-derivable = { workspace = true, optional = true }
solana-seed-phrase = { workspace = true, optional = true }
solana-serde = { workspace = true }
solana-serde-varint = { workspace = true }
solana-short-vec = { workspace = true }
solana-signature = { workspace = true, features = [
Expand Down
20 changes: 20 additions & 0 deletions sdk/serde/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "solana-serde"
description = "Solana serde helpers"
documentation = "https://docs.rs/solana-serde"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }

[dependencies]
serde = { workspace = true }

[dev-dependencies]
bincode = { workspace = true }
serde_derive = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
4 changes: 2 additions & 2 deletions sdk/src/deserialize_utils.rs → sdk/serde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub mod tests {

#[test]
fn test_default_on_eof() {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug, PartialEq, Eq)]
struct Foo {
bar: u16,
#[serde(deserialize_with = "default_on_eof")]
Expand Down Expand Up @@ -108,7 +108,7 @@ pub mod tests {
fn test_default_on_eof_additional_untagged_fields() {
// If later fields are not tagged `deserialize_with = "default_on_eof"`, deserialization
// will panic on any missing fields/data
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[derive(serde_derive::Serialize, serde_derive::Deserialize, Debug, PartialEq, Eq)]
struct Foo {
bar: u16,
#[serde(deserialize_with = "default_on_eof")]
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub use solana_program::{borsh, borsh0_10, borsh1};
pub use solana_signer::signers;
pub mod client;
pub mod compute_budget;
pub mod deserialize_utils;
pub mod entrypoint;
pub mod entrypoint_deprecated;
pub mod epoch_info;
Expand Down Expand Up @@ -191,6 +190,8 @@ pub use solana_sdk_macro::declare_id;
pub use solana_sdk_macro::pubkeys;
#[deprecated(since = "2.1.0", note = "Use `solana-secp256k1-recover` crate instead")]
pub use solana_secp256k1_recover as secp256k1_recover;
#[deprecated(since = "2.2.0", note = "Use `solana-serde` crate instead")]
pub use solana_serde as deserialize_utils;
#[deprecated(since = "2.1.0", note = "Use `solana-serde-varint` crate instead")]
pub use solana_serde_varint as serde_varint;
#[deprecated(since = "2.1.0", note = "Use `solana-short-vec` crate instead")]
Expand Down

0 comments on commit 9b29626

Please sign in to comment.