Skip to content

Commit

Permalink
dusk-core: added serde support
Browse files Browse the repository at this point in the history
  • Loading branch information
d-sonuga committed Feb 10, 2025
1 parent d2bad0a commit 75f2c23
Show file tree
Hide file tree
Showing 7 changed files with 1,459 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add `METADATA::PUBLIC_SENDER` [#3341]
- Add `abi::public_sender` host fn [#3341]
- Add serde implementations for `StakeEvent`, `SlashEvent`, `Reward`, `WithdrawEvent`, `ConvertEvent`, `DepositEvent`,
`ContractToContractEvent`, `ContractToAccountEvent`, `PhoenixTransactionEvent` and `MoonlightTransactionEvent`

## [1.0.0] - 2025-01-23

Expand Down
13 changes: 13 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ ark-bn254 = { workspace = true, features = ["curve"], optional = true }
ark-relations = { workspace = true, optional = true }
ark-serialize = { workspace = true, optional = true }

# serde support dependencies
serde = { workspace = true, features = ["derive"], optional = true }
base64 = { workspace = true, optional = true }

[dev-dependencies]
rand = { workspace = true, features = ["std", "std_rng"] }
serde_json = { workspace = true }

[features]
parallel = [
Expand Down Expand Up @@ -67,3 +72,11 @@ groth16 = [

# Enables std feature for dusk-plonk
std = ["dusk-plonk/std"]

serde = [
"dep:serde",
"base64",
"piecrust-uplink/serde",
"bls12_381-bls/serde",
"phoenix-core/serde",
]
4 changes: 2 additions & 2 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

test:
cargo test --release --features zk
cargo test --release --features zk,serde
cargo test --release --no-run

clippy: ## Run clippy
@cargo clippy --release -- -D warnings
@cargo clippy --release --features serde -- -D warnings
@cargo clippy --no-default-features --release -- -D warnings

doc: ## Run doc gen
Expand Down
10 changes: 10 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub use error::Error;
mod dusk;
pub use dusk::{dusk, from_dusk, Dusk, LUX};

#[cfg(feature = "serde")]
mod serde_support;

// elliptic curve types
pub use dusk_bls12_381::BlsScalar;
pub use dusk_jubjub::{
Expand Down Expand Up @@ -135,3 +138,10 @@ fn read_arr<const N: usize>(buf: &mut &[u8]) -> Result<[u8; N], BytesError> {
*buf = &buf[N..];
Ok(a)
}

#[cfg(test)]
mod tests {
// the `unused_crate_dependencies` lint complains for dev-dependencies that
// are only used in integration tests, so adding this work-around here
use serde_json as _;
}
Loading

0 comments on commit 75f2c23

Please sign in to comment.