Skip to content

Commit c817f56

Browse files
committed
primitives - UnifiedMap to BalancesMap in given precision
1 parent a4c46f9 commit c817f56

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

primitives/src/balances_map.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ pub type BalancesMap = Map<Address, BigNum>;
1717
#[serde(transparent)]
1818
pub struct Map<K: Ord, V>(BTreeMap<K, V>);
1919

20+
impl Map<Address, UnifiedNum> {
21+
pub fn to_precision(&self, precision: u8) -> BalancesMap {
22+
self.iter()
23+
.map(|(address, unified_num)| (*address, unified_num.to_precision(precision)))
24+
.collect()
25+
}
26+
}
27+
2028
impl<K: Ord, V> Default for Map<K, V> {
2129
fn default() -> Self {
2230
Map(BTreeMap::default())

0 commit comments

Comments
 (0)