diff --git a/crates/redeem/src/types.rs b/crates/redeem/src/types.rs index 0e74f60144..f3d473d52c 100644 --- a/crates/redeem/src/types.rs +++ b/crates/redeem/src/types.rs @@ -9,8 +9,6 @@ use btc_relay::BtcAddress; use codec::{Decode, Encode, MaxEncodedLen}; use currency::Amount; use frame_support::{pallet_prelude::OptionQuery, traits::Get, Blake2_128Concat}; -#[cfg(feature = "std")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; use sp_core::H256; /// Storage version. @@ -33,7 +31,6 @@ mod v0 { >; #[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)] - #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] pub struct RedeemRequest { /// the vault associated with this redeem request pub vault: VaultId, @@ -41,28 +38,12 @@ mod v0 { pub opentime: BlockNumber, /// the redeem period when this request was opened pub period: BlockNumber, - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] /// total redeem fees - taken from request amount pub fee: Balance, - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] /// amount the vault should spend on the bitcoin inclusion fee - taken from request amount pub transfer_fee_btc: Balance, - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] /// total amount of BTC for the vault to send pub amount_btc: Balance, - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] /// premium redeem amount in collateral pub premium: Balance, /// the account redeeming tokens (for BTC) @@ -75,20 +56,6 @@ mod v0 { pub status: RedeemRequestStatus, } - #[cfg(feature = "std")] - fn serialize_as_string(t: &T, serializer: S) -> Result { - serializer.serialize_str(&t.to_string()) - } - - #[cfg(feature = "std")] - fn deserialize_from_string<'de, D: Deserializer<'de>, T: std::str::FromStr>( - deserializer: D, - ) -> Result { - let s = String::deserialize(deserializer)?; - s.parse::() - .map_err(|_| serde::de::Error::custom("Parse from string failed")) - } - #[frame_support::storage_alias] pub(super) type RedeemRequests = StorageMap, Blake2_128Concat, H256, DefaultRedeemRequest, OptionQuery>;