Skip to content

Commit

Permalink
add support for u128 & U256 conversion to/from balance
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderian committed Oct 12, 2023
1 parent 7302a44 commit bd9b4ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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" }

Expand Down
7 changes: 6 additions & 1 deletion tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -199,6 +200,8 @@ pub mod module {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::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
Expand All @@ -207,7 +210,9 @@ pub mod module {
+ MaybeSerializeDeserialize
+ MaxEncodedLen
+ TypeInfo
+ FixedPointOperand;
+ FixedPointOperand
+ Into<u128>
+ TryFrom<U256>;

/// The amount type, should be signed version of `Balance`
type Amount: Signed
Expand Down

0 comments on commit bd9b4ab

Please sign in to comment.