mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-14 23:19:24 +00:00
Add a non-canonical SCALE derivations feature
Enables representing IUMT within `StorageValues`. Applied to a variety of values. Fixes a bug where `Some([0; 32])` would be considered a valid block anchor.
This commit is contained in:
@@ -10,18 +10,10 @@ use crate::coin::{ExternalCoin, Coin};
|
||||
pub type AmountRepr = u64;
|
||||
|
||||
/// A wrapper used to represent amounts.
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Hash,
|
||||
Debug,
|
||||
Zeroize,
|
||||
BorshSerialize,
|
||||
BorshDeserialize,
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
pub struct Amount(pub AmountRepr);
|
||||
|
||||
@@ -48,6 +40,10 @@ impl Mul for Amount {
|
||||
|
||||
/// An ExternalCoin and an Amount, forming a balance for an external coin.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
pub struct ExternalBalance {
|
||||
/// The coin this is a balance for.
|
||||
pub coin: ExternalCoin,
|
||||
@@ -78,6 +74,10 @@ impl Mul<Amount> for ExternalBalance {
|
||||
|
||||
/// A Coin and an Amount, forming a balance for a coin.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
)]
|
||||
pub struct Balance {
|
||||
/// The coin this is a balance for.
|
||||
pub coin: Coin,
|
||||
|
||||
Reference in New Issue
Block a user