Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions crates/iota-sdk-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ serde = [
"dep:serde_json",
"roaring/std",
]
schemars = ["serde", "dep:schemars", "dep:serde_json"]
rand = ["dep:rand_core"]
hash = ["dep:blake2"]
proptest = ["dep:proptest", "dep:test-strategy", "serde"]
Expand All @@ -53,9 +52,6 @@ serde_derive = { version = "1.0.210", optional = true }
serde_json = { version = "1.0.128", optional = true }
serde_with = { version = "3.9", default-features = false, features = ["alloc"], optional = true }

# JsonSchema definitions for types, useful for generating an OpenAPI Specificaiton.
schemars = { version = "0.8.21", optional = true }

# RNG support
rand_core = { version = "0.6.4", optional = true }

Expand All @@ -68,7 +64,6 @@ test-strategy = { version = "0.4", optional = true }

[dev-dependencies]
bcs = "0.1.6"
jsonschema = { version = "0.20", default-features = false }
num-bigint = "0.4.6"
paste = "1.0.15"
serde_json = "1.0.128"
Expand Down
30 changes: 0 additions & 30 deletions crates/iota-sdk-types/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,36 +251,6 @@ impl std::fmt::Display for AddressParseError {

impl std::error::Error for AddressParseError {}

#[cfg(feature = "schemars")]
impl schemars::JsonSchema for Address {
fn schema_name() -> String {
"Address".to_owned()
}

fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
use schemars::schema::{InstanceType, Metadata, SchemaObject, StringValidation};

let hex_length = Address::LENGTH * 2;
SchemaObject {
metadata: Some(Box::new(Metadata {
title: Some(Self::schema_name()),
description: Some("A 32-byte IOTA address, encoded as a hex string.".to_owned()),
examples: vec![serde_json::to_value(Address::TWO).unwrap()],
..Default::default()
})),
instance_type: Some(InstanceType::String.into()),
format: Some("hex".to_owned()),
string: Some(Box::new(StringValidation {
max_length: Some((hex_length + 2) as u32),
min_length: None,
pattern: Some(format!("0x[a-z0-9]{{1,{hex_length}}}")),
})),
..Default::default()
}
.into()
}
}

#[cfg(test)]
mod test {
use test_strategy::proptest;
Expand Down
31 changes: 2 additions & 29 deletions crates/iota-sdk-types/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ pub type ProtocolVersion = u64;
/// ecmh-live-object-set = %x00 digest
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "schemars",
derive(schemars::JsonSchema),
schemars(tag = "type", rename_all = "snake_case")
)]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub enum CheckpointCommitment {
/// An Elliptic Curve Multiset Hash attesting to the set of Objects that
Expand All @@ -56,7 +51,6 @@ pub enum CheckpointCommitment {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct EndOfEpochData {
/// The set of Validators that will be in the ValidatorCommittee for the
Expand All @@ -65,7 +59,6 @@ pub struct EndOfEpochData {

/// The protocol version that is in effect during the next epoch.
#[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
pub next_epoch_protocol_version: ProtocolVersion,

/// Commitments to epoch specific state (e.g. live object set)
Expand Down Expand Up @@ -116,20 +109,14 @@ pub struct EndOfEpochData {
/// bytes ; version_specific_data
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct CheckpointSummary {
/// Epoch that this checkpoint belongs to.
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
pub epoch: EpochId,

/// The height of this checkpoint.
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
pub sequence_number: CheckpointSequenceNumber,

/// Total number of transactions committed since genesis, including those in
/// this checkpoint.
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
pub network_total_transactions: u64,

/// The hash of the [`CheckpointContents`] for this checkpoint.
Expand All @@ -148,14 +135,10 @@ pub struct CheckpointSummary {
/// Checkpoint timestamps are monotonic, but not strongly monotonic -
/// subsequent checkpoints can have same timestamp if they originate
/// from the same underlining consensus commit
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
pub timestamp_ms: CheckpointTimestamp,

/// Commitments to checkpoint-specific state.
#[cfg_attr(
feature = "schemars",
schemars(with = "Option<Vec<CheckpointCommitment>>")
)]
/// Commitments to checkpoint-specific state (e.g. txns in checkpoint,
/// objects read/written in checkpoint).
pub checkpoint_commitments: Vec<CheckpointCommitment>,

/// Extra data only present in the final checkpoint of an epoch.
Expand All @@ -166,10 +149,6 @@ pub struct CheckpointSummary {
/// be added to CheckpointSummary, we allow opaque data to be added to
/// checkpoints which can be deserialized based on the current
/// protocol version.
#[cfg_attr(
feature = "schemars",
schemars(with = "Option<crate::_schemars::Base64>")
)]
pub version_specific_data: Vec<u8>,
}

Expand All @@ -178,7 +157,6 @@ pub struct CheckpointSummary {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct SignedCheckpointSummary {
pub checkpoint: CheckpointSummary,
Expand All @@ -204,7 +182,6 @@ pub struct SignedCheckpointSummary {
/// ; length as the vector of digests
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct CheckpointContents(
#[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
Expand All @@ -231,7 +208,6 @@ impl CheckpointContents {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct CheckpointTransactionInfo {
pub transaction: TransactionDigest,
Expand All @@ -245,7 +221,6 @@ pub struct CheckpointTransactionInfo {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct CheckpointData {
pub checkpoint_summary: SignedCheckpointSummary,
Expand All @@ -259,15 +234,13 @@ pub struct CheckpointData {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct CheckpointTransaction {
/// The input Transaction
#[cfg_attr(
feature = "serde",
serde(with = "::serde_with::As::<crate::_serde::SignedTransactionWithIntentMessage>")
)]
#[cfg_attr(feature = "schemars", schemars(with = "SignedTransaction"))]
pub transaction: SignedTransaction,
/// The effects produced by executing this transaction
pub effects: TransactionEffects,
Expand Down
4 changes: 0 additions & 4 deletions crates/iota-sdk-types/src/crypto/bls12381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Bls12381PublicKey(
#[cfg_attr(
Expand All @@ -32,7 +31,6 @@ pub struct Bls12381PublicKey(
with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array96, ::serde_with::Bytes>>"
)
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down Expand Up @@ -133,7 +131,6 @@ impl std::fmt::Debug for Bls12381PublicKey {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Bls12381Signature(
#[cfg_attr(
Expand All @@ -142,7 +139,6 @@ pub struct Bls12381Signature(
with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array48, [::serde_with::Same; 48]>>"
)
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down
4 changes: 0 additions & 4 deletions crates/iota-sdk-types/src/crypto/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Ed25519PublicKey(
#[cfg_attr(
feature = "serde",
serde(with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array32>>")
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down Expand Up @@ -126,7 +124,6 @@ impl std::fmt::Debug for Ed25519PublicKey {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Ed25519Signature(
#[cfg_attr(
Expand All @@ -135,7 +132,6 @@ pub struct Ed25519Signature(
with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array64, [::serde_with::Same; 64]>>"
)
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down
27 changes: 0 additions & 27 deletions crates/iota-sdk-types/src/crypto/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub enum MultisigMemberPublicKey {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct MultisigMember {
public_key: MultisigMemberPublicKey,
Expand Down Expand Up @@ -126,7 +125,6 @@ impl MultisigMember {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct MultisigCommittee {
/// A list of committee members and their corresponding weight.
Expand Down Expand Up @@ -219,7 +217,6 @@ impl MultisigCommittee {
/// See [here](https://github.com/RoaringBitmap/RoaringFormatSpec) for the specification for the
/// serialized format of RoaringBitmaps.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct MultisigAggregatedSignature {
/// The plain signature encoded with signature scheme.
Expand Down Expand Up @@ -439,25 +436,13 @@ mod serialization {
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[serde(tag = "scheme", rename_all = "lowercase")]
#[serde(rename = "MultisigMemberPublicKey")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
enum ReadableMemberPublicKey {
Ed25519 { public_key: Ed25519PublicKey },
Secp256k1 { public_key: Secp256k1PublicKey },
Secp256r1 { public_key: Secp256r1PublicKey },
ZkLogin(ZkLoginPublicIdentifier),
}

#[cfg(feature = "schemars")]
impl schemars::JsonSchema for MultisigMemberPublicKey {
fn schema_name() -> String {
ReadableMemberPublicKey::schema_name()
}

fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
ReadableMemberPublicKey::json_schema(gen)
}
}

impl Serialize for MultisigMemberPublicKey {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down Expand Up @@ -545,25 +530,13 @@ mod serialization {
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
#[serde(tag = "scheme", rename_all = "lowercase")]
#[serde(rename = "MultisigMemberSignature")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
enum ReadableMemberSignature {
Ed25519 { signature: Ed25519Signature },
Secp256k1 { signature: Secp256k1Signature },
Secp256r1 { signature: Secp256r1Signature },
ZkLogin(Box<ZkLoginAuthenticator>),
}

#[cfg(feature = "schemars")]
impl schemars::JsonSchema for MultisigMemberSignature {
fn schema_name() -> String {
ReadableMemberSignature::schema_name()
}

fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
ReadableMemberSignature::json_schema(gen)
}
}

impl Serialize for MultisigMemberSignature {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
12 changes: 0 additions & 12 deletions crates/iota-sdk-types/src/crypto/passkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,12 @@ mod serialization {

#[derive(serde::Deserialize)]
#[serde(rename = "PasskeyAuthenticator")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
struct Authenticator {
authenticator_data: Vec<u8>,
client_data_json: String,
signature: SimpleSignature,
}

#[cfg(feature = "schemars")]
impl schemars::JsonSchema for PasskeyAuthenticator {
fn schema_name() -> String {
Authenticator::schema_name()
}

fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
Authenticator::json_schema(gen)
}
}

impl Serialize for PasskeyAuthenticator {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
4 changes: 0 additions & 4 deletions crates/iota-sdk-types/src/crypto/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Secp256k1PublicKey(
#[cfg_attr(
Expand All @@ -27,7 +26,6 @@ pub struct Secp256k1PublicKey(
with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array33, [::serde_with::Same; 33]>>"
)
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down Expand Up @@ -128,7 +126,6 @@ impl std::fmt::Debug for Secp256k1PublicKey {
feature = "serde",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
pub struct Secp256k1Signature(
#[cfg_attr(
Expand All @@ -137,7 +134,6 @@ pub struct Secp256k1Signature(
with = "::serde_with::As::<::serde_with::IfIsHumanReadable<super::Base64Array64, [::serde_with::Same; 64]>>"
)
)]
#[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
[u8; Self::LENGTH],
);

Expand Down
Loading
Loading