Co #10719: Use into_account_truncating (#4947)

* Use into_account_truncating

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* more truncating

* more truncating

* more

* clean up parachain primitives

* more truncating

* update lockfile for {"substrate"}

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2022-05-17 23:53:14 +02:00
committed by GitHub
parent 2907a7aeae
commit 157b5186ba
15 changed files with 279 additions and 236 deletions
@@ -60,7 +60,7 @@ impl From<Error> for XcmError {
/// /// Our relay chain's location.
/// parameter_types! {
/// pub RelayChain: MultiLocation = Parent.into();
/// pub CheckingAccount: AccountId = PalletId(*b"checking").into_account();
/// pub CheckingAccount: AccountId = PalletId(*b"checking").into_account_truncating();
/// }
///
/// /// Some items that implement `Convert<MultiLocation, AccountId>`. Can be more, but for now we just assume we accept
@@ -70,7 +70,7 @@ impl<ParaId: From<u32> + Into<u32> + AccountIdConversion<AccountId>, AccountId:
fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
match location.borrow() {
MultiLocation { parents: 0, interior: X1(Parachain(id)) } =>
Ok(ParaId::from(*id).into_account()),
Ok(ParaId::from(*id).into_account_truncating()),
_ => Err(()),
}
}
@@ -91,7 +91,7 @@ impl<ParaId: From<u32> + Into<u32> + AccountIdConversion<AccountId>, AccountId:
fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
match location.borrow() {
MultiLocation { parents: 1, interior: X1(Parachain(id)) } =>
Ok(ParaId::from(*id).into_account()),
Ok(ParaId::from(*id).into_account_truncating()),
_ => Err(()),
}
}
+6 -6
View File
@@ -41,7 +41,7 @@ fn buy_execution<C>() -> Instruction<C> {
/// Asserts that the parachain accounts are updated as expected.
#[test]
fn withdraw_and_deposit_works() {
let para_acc: AccountId = ParaId::from(PARA_ID).into_account();
let para_acc: AccountId = ParaId::from(PARA_ID).into_account_truncating();
let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)];
kusama_like_with_balances(balances).execute_with(|| {
let other_para_id = 3000;
@@ -61,7 +61,7 @@ fn withdraw_and_deposit_works() {
weight,
);
assert_eq!(r, Outcome::Complete(weight));
let other_para_acc: AccountId = ParaId::from(other_para_id).into_account();
let other_para_acc: AccountId = ParaId::from(other_para_id).into_account_truncating();
assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - amount);
assert_eq!(Balances::free_balance(other_para_acc), amount);
});
@@ -108,7 +108,7 @@ fn transfer_asset_works() {
#[test]
fn query_holding_works() {
use xcm::opaque::latest::prelude::*;
let para_acc: AccountId = ParaId::from(PARA_ID).into_account();
let para_acc: AccountId = ParaId::from(PARA_ID).into_account_truncating();
let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)];
kusama_like_with_balances(balances).execute_with(|| {
let other_para_id = 3000;
@@ -169,7 +169,7 @@ fn query_holding_works() {
weight,
);
assert_eq!(r, Outcome::Complete(weight));
let other_para_acc: AccountId = ParaId::from(other_para_id).into_account();
let other_para_acc: AccountId = ParaId::from(other_para_id).into_account_truncating();
assert_eq!(Balances::free_balance(other_para_acc), amount);
assert_eq!(Balances::free_balance(para_acc), INITIAL_BALANCE - 2 * amount);
assert_eq!(
@@ -197,7 +197,7 @@ fn query_holding_works() {
#[test]
fn teleport_to_statemine_works() {
use xcm::opaque::latest::prelude::*;
let para_acc: AccountId = ParaId::from(PARA_ID).into_account();
let para_acc: AccountId = ParaId::from(PARA_ID).into_account_truncating();
let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)];
kusama_like_with_balances(balances).execute_with(|| {
let statemine_id = 1000;
@@ -287,7 +287,7 @@ fn teleport_to_statemine_works() {
#[test]
fn reserve_based_transfer_works() {
use xcm::opaque::latest::prelude::*;
let para_acc: AccountId = ParaId::from(PARA_ID).into_account();
let para_acc: AccountId = ParaId::from(PARA_ID).into_account_truncating();
let balances = vec![(ALICE, INITIAL_BALANCE), (para_acc.clone(), INITIAL_BALANCE)];
kusama_like_with_balances(balances).execute_with(|| {
let other_para_id = 3000;