diff --git a/concordium-cis2/CHANGELOG.md b/concordium-cis2/CHANGELOG.md index 8701d286..2482b216 100644 --- a/concordium-cis2/CHANGELOG.md +++ b/concordium-cis2/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased changes - Bump MSRV to 1.72 +- Fix `SchemaType` implementation of `OnReceivingCis2DataParams` so that it matches `Serial` and `Deserial` implementations. ## concordium-cis2 6.1.0 (2024-02-22) @@ -31,7 +32,7 @@ ## concordium-cis2 4.0.0 (2023-06-16) - Bump concordium-std to version 7. -p + ## concordium-cis2 3.1.0 (2023-05-08) - Derive `PartialEq` and `Eq` for the `MetadataUrl` from the CIS2 library. diff --git a/concordium-cis2/src/lib.rs b/concordium-cis2/src/lib.rs index 2db2c00b..75dbad3d 100644 --- a/concordium-cis2/src/lib.rs +++ b/concordium-cis2/src/lib.rs @@ -36,7 +36,7 @@ mod cis2_client; pub use cis2_client::{Cis2Client, Cis2ClientError}; -use concordium_std::{collections::BTreeMap, *}; +use concordium_std::{collections::BTreeMap, schema::SchemaType, *}; // Re-export for backward compatibility. pub use concordium_std::MetadataUrl; #[cfg(not(feature = "std"))] @@ -1254,7 +1254,7 @@ pub struct OnReceivingCis2Params { /// with a specific type D for the AdditionalData. // Note: For the serialization to be derived according to the CIS2 // specification, the order of the fields cannot be changed. -#[derive(Debug, SchemaType)] +#[derive(Debug)] pub struct OnReceivingCis2DataParams { /// The ID of the token received. pub token_id: T, @@ -1292,6 +1292,19 @@ impl Serial for OnReceivingCis2DataParams. +impl SchemaType for OnReceivingCis2DataParams { + fn get_type() -> schema::Type { + schema::Type::Struct(schema::Fields::Named(vec![ + (String::from("token_id"), T::get_type()), + (String::from("amount"), A::get_type()), + (String::from("from"), Address::get_type()), + // The data field is serialized the same as AdditionalData. + (String::from("data"), AdditionalData::get_type()), + ])) + } +} + /// Identifier for a smart contract standard. /// Consists of a string of ASCII characters up to a length of 255. ///