Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Introduce 128-bit shim for u128/i128 and use it for Balance #163

Merged
merged 4 commits into from
May 24, 2018

Conversation

gavofyork
Copy link
Member

@gavofyork gavofyork commented May 15, 2018

On ice until after we tag poc-1.

@gavofyork gavofyork added the A0-please_review Pull request needs code review. label May 15, 2018
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 {
Copy link
Contributor

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?

Copy link
Member Author

@gavofyork gavofyork May 17, 2018

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.)

Copy link
Contributor

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?

Copy link
Member Author

@gavofyork gavofyork May 17, 2018

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@arkpar arkpar added A8-looksgood and removed A0-please_review Pull request needs code review. labels May 24, 2018
@rphmeier rphmeier merged commit 39bd39e into master May 24, 2018
@gavofyork gavofyork deleted the gav-u128-shim branch May 24, 2018 14:45
JoshOrndorff added a commit to moonbeam-foundation/substrate that referenced this pull request Apr 21, 2021
liuchengxu added a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
liuchengxu added a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
* 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]>
helin6 pushed a commit to boolnetwork/substrate that referenced this pull request Jul 25, 2023
* Revert contracts put_code test to pure code (not using the macro)

* Test contract instantiate

* Fmt
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants