From bd9b4abb1591c8bd535ff85f15fd527f61966028 Mon Sep 17 00:00:00 2001 From: Marian Vanderka Date: Thu, 12 Oct 2023 22:48:59 +0200 Subject: [PATCH] add support for u128 & U256 conversion to/from balance --- tokens/Cargo.toml | 2 +- tokens/src/lib.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tokens/Cargo.toml b/tokens/Cargo.toml index acebe6e55..011fc091c 100644 --- a/tokens/Cargo.toml +++ b/tokens/Cargo.toml @@ -16,6 +16,7 @@ serde = { version = "1.0.136", optional = true } frame-support = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false , branch = "develop" } frame-system = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false , branch = "develop" } sp-arithmetic = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false , branch = "develop" } +sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false, branch = "develop" } sp-runtime = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false , branch = "develop" } sp-std = { git = "https://github.com/mangata-finance/polkadot-sdk", default-features = false , branch = "develop" } frame-benchmarking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop", default-features = false, optional = true } @@ -25,7 +26,6 @@ orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = fa [dev-dependencies] pallet-elections-phragmen = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } pallet-treasury = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } -sp-core = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } sp-io = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } sp-staking = { git = "https://github.com/mangata-finance/polkadot-sdk", branch = "develop" } diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index e61ff858e..5422fc2da 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -59,6 +59,7 @@ use frame_support::{ }; use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; use scale_info::TypeInfo; +use sp_core::U256; use sp_runtime::{ traits::{ AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Saturating, @@ -199,6 +200,8 @@ pub mod module { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The balance type + /// use Into<128> to supportd current impl of mangata-node pallets which + /// rely on U256::from(value: u128) for arithemtics type Balance: Parameter + Member + AtLeast32BitUnsigned @@ -207,7 +210,9 @@ pub mod module { + MaybeSerializeDeserialize + MaxEncodedLen + TypeInfo - + FixedPointOperand; + + FixedPointOperand + + Into + + TryFrom; /// The amount type, should be signed version of `Balance` type Amount: Signed