-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Introduce 128-bit shim for u128/i128 and use it for Balance #163
Conversation
impl_as!($f, $i: u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); | ||
}; | ||
( $f:ident, $i:ty : $t:ty $(, $rest:ty)* ) => { | ||
impl As<$t> for $f { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just From
and Into
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's designed to work to convert between all numerics; From
/Into
don't do that. (try compiling fn main() -> u8 { 69u32.into() }
on playground.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, this As
trait is just From + Into
, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it is used a bit like From
and Into
. But in terms of what it does, it can convert between numeric types like the as
keyword. From
and Into
can't be implemented to convert between numeric types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it's just an escape hatch around the orphan rules for primitives? it could be that TryFrom/TryInto
will be implemented for all pairs in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
* move balances&transaction-payment into chainx * fix assets * fix gateway * fix xcontracts * add transfer_with_memo in pallet-balances * add debug in pallet-transaction-payment * fix bug for `TotalAssetBalance` * add assets test * Balances migration for Mining and DEX (paritytech#162) * Add sketch of generic-reserves * Introduce NativeReservedType * Add move_reserved_asset() * Only record NativeReservedType in generic-reserves * Change storage item name to NativeReserves * Replace xpallet_assets with Currency * Impl Staking issue and move_balance * LockableCurrency is required * Test mint_should_work() * Impl bond_reserve() * Finish balances migration for Staking * Remove xpallet-assets in Staking * Replace T::Balance with BalanceOf<T> in DEX * Impl native reserves * Pass partial DEX tests * Do not silence the asset error * Curreny in assets has be Reserable and Lockable * Use Currency from assets if neccesary * Migrate mining/asset * Add StakingInterface in mining/asset * Fix a fatal storage naming error * Pass mining/asset tests * Pass DEX tests * Fix runtime migration * Fix balances genesis The balances has duplicated items which are problematic. * finish xassets tests * add doc for rpc Co-authored-by: Liu-Cheng Xu <[email protected]>
* Revert contracts put_code test to pure code (not using the macro) * Test contract instantiate * Fmt
On ice until after we tag poc-1.