Skip to content

Commit

Permalink
fixes after update
Browse files Browse the repository at this point in the history
  • Loading branch information
vklachkov committed Jan 29, 2025
1 parent 58e611c commit f26c8c9
Show file tree
Hide file tree
Showing 35 changed files with 71 additions and 69 deletions.
8 changes: 4 additions & 4 deletions asset-registry/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use sp_std::prelude::*;
use xcm::VersionedLocation;
use xcm::{
v3,
v4::{prelude::*, Weight as XcmWeight},
v5::{prelude::*, Weight as XcmWeight},
};
use xcm_builder::TakeRevenue;
use xcm_executor::{traits::WeightTrader, AssetsInHolding};
Expand Down Expand Up @@ -188,7 +188,7 @@ impl<T: Config> Inspect for Pallet<T> {
type StringLimit = T::StringLimit;

fn asset_id(location: &Location) -> Option<Self::AssetId> {
Pallet::<T>::location_to_asset_id(v3::Location::try_from(location.clone()).ok()?)
Pallet::<T>::location_to_asset_id(v3::Location::try_from(location.clone().into_versioned()).ok()?)
}

fn metadata(id: &Self::AssetId) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
Expand All @@ -198,11 +198,11 @@ impl<T: Config> Inspect for Pallet<T> {
fn metadata_by_location(
location: &Location,
) -> Option<AssetMetadata<Self::Balance, Self::CustomMetadata, Self::StringLimit>> {
Pallet::<T>::fetch_metadata_by_location(&v3::Location::try_from(location.clone()).ok()?)
Pallet::<T>::fetch_metadata_by_location(&v3::Location::try_from(location.clone().into_versioned()).ok()?)
}

fn location(asset_id: &Self::AssetId) -> Result<Option<Location>, DispatchError> {
Pallet::<T>::location(asset_id).map(|l| l.and_then(|l| l.try_into().ok()))
Pallet::<T>::location(asset_id).map(|l| l.and_then(|l| l.into_versioned().try_into().ok()))
}
}

Expand Down
10 changes: 5 additions & 5 deletions asset-registry/src/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use sp_io::TestExternalities;
use sp_runtime::{traits::Convert, AccountId32, BuildStorage};
use xcm::{
v3,
v4::{Asset, Location},
v5::{Asset, Location},
};
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};

Expand Down Expand Up @@ -109,12 +109,12 @@ impl Convert<CurrencyId, Option<Location>> for CurrencyIdConvert {
),
CurrencyId::RegisteredAsset(id) => AssetRegistry::location(&id).unwrap_or_default(),
};
loc.and_then(|l| l.try_into().ok())
loc.and_then(|l| l.into_versioned().try_into().ok())
}
}
impl Convert<Location, Option<CurrencyId>> for CurrencyIdConvert {
fn convert(l: Location) -> Option<CurrencyId> {
use xcm::v4::Junction::*;
use xcm::v5::Junction::*;

let a: Vec<u8> = "A".into();
let a1: Vec<u8> = "A1".into();
Expand Down Expand Up @@ -147,14 +147,14 @@ impl Convert<Location, Option<CurrencyId>> for CurrencyIdConvert {
_ => None,
};
currency_id.or_else(|| {
let loc = v3::Location::try_from(l.clone()).ok()?;
let loc = v3::Location::try_from(l.into_versioned()).ok()?;
AssetRegistry::location_to_asset_id(&loc).map(CurrencyId::RegisteredAsset)
})
}
}
impl Convert<Asset, Option<CurrencyId>> for CurrencyIdConvert {
fn convert(a: Asset) -> Option<CurrencyId> {
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;
if let Asset {
fun: Fungible(_),
id: AssetId(id),
Expand Down
6 changes: 4 additions & 2 deletions asset-registry/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sp_runtime::{
traits::{AccountIdConversion, Convert, IdentityLookup},
AccountId32,
};
use xcm::v4::{prelude::*, Weight};
use xcm::v5::{prelude::*, Weight};
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
Expand Down Expand Up @@ -55,6 +55,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxFreezes = ();
type DoneSlashHandler = ();
}

use orml_asset_registry::impls::ExistentialDeposits as AssetRegistryExistentialDeposits;
Expand Down Expand Up @@ -193,7 +194,8 @@ pub type AssetRegistryWeightTrader =
pub struct MyFixedConversionRateProvider;
impl FixedConversionRateProvider for MyFixedConversionRateProvider {
fn get_fee_per_second(location: &Location) -> Option<u128> {
let metadata = AssetRegistry::fetch_metadata_by_location(&location.clone().try_into().unwrap())?;
let metadata =
AssetRegistry::fetch_metadata_by_location(&location.clone().into_versioned().try_into().unwrap())?;
Some(metadata.additional.fee_per_second)
}
}
Expand Down
3 changes: 2 additions & 1 deletion asset-registry/src/mock/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use polkadot_runtime_parachains::{
origin, shared,
};
use sp_runtime::{traits::IdentityLookup, AccountId32};
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia,
FixedWeightBounds, FungibleAdapter, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32,
Expand Down Expand Up @@ -45,6 +45,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxFreezes = ();
type DoneSlashHandler = ();
}

impl shared::Config for Runtime {
Expand Down
23 changes: 1 addition & 22 deletions asset-registry/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@ use sp_runtime::{
traits::{AccountIdConversion, BadOrigin, Dispatchable},
AccountId32,
};
use xcm::{v3, v4::prelude::*, VersionedLocation};
use xcm::{v3, v5::prelude::*, VersionedLocation};
use xcm_simulator::TestExt;

#[allow(deprecated)]
type OldLocation = xcm::v2::MultiLocation;
#[allow(deprecated)]
type OldJunctions = xcm::v2::Junctions;
#[allow(deprecated)]
type OldJunction = xcm::v2::Junction;

fn treasury_account() -> AccountId32 {
TreasuryAccount::get()
}
Expand Down Expand Up @@ -585,20 +578,6 @@ fn test_asset_authority() {
});
}

#[test]
fn test_v2_to_v3_incompatible_multilocation() {
// Assert that V2 and V3 Location both are encoded differently

#[allow(deprecated)]
let old_location = OldLocation::new(
0,
OldJunctions::X1(OldJunction::GeneralKey(vec![0].try_into().unwrap())),
);
assert!(
old_location.encode() != Location::new(0, [Junction::from(BoundedVec::try_from(vec![0]).unwrap())]).encode()
);
}

#[test]
fn test_decode_bounded_vec() {
TestNet::reset();
Expand Down
4 changes: 2 additions & 2 deletions authority/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ pub mod module {
#[pallet::call_index(0)]
#[pallet::weight({
let info = call.get_dispatch_info();
(T::WeightInfo::dispatch_as().saturating_add(info.weight), info.class)
(T::WeightInfo::dispatch_as().saturating_add(info.total_weight()), info.class)
})]
pub fn dispatch_as(origin: OriginFor<T>, as_origin: T::AsOriginId, call: Box<CallOf<T>>) -> DispatchResult {
as_origin.check_dispatch_from(origin)?;
Expand Down Expand Up @@ -508,7 +508,7 @@ pub mod module {
ensure!(who == caller, Error::<T>::TriggerCallNotPermitted);
}
ensure!(
call_weight_bound.all_gte(call.get_dispatch_info().weight),
call_weight_bound.all_gte(call.get_dispatch_info().total_weight()),
Error::<T>::WrongCallWeightBound
);
let result = call.dispatch(OriginFor::<T>::root());
Expand Down
4 changes: 2 additions & 2 deletions authority/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ fn trigger_call_works() {
});
let hash = <Runtime as frame_system::Config>::Hashing::hash_of(&call);

let call_weight_bound = call.get_dispatch_info().weight;
let call_weight_bound = call.get_dispatch_info().total_weight();

// call not authorized yet
assert_noop!(
Expand Down Expand Up @@ -617,7 +617,7 @@ fn trigger_call_should_be_free_and_operational() {
ratio: Perbill::from_percent(50),
});
let hash = <Runtime as frame_system::Config>::Hashing::hash_of(&call);
let call_weight_bound = call.get_dispatch_info().weight;
let call_weight_bound = call.get_dispatch_info().total_weight();
let trigger_call = RuntimeCall::Authority(authority::Call::trigger_call {
hash,
call_weight_bound,
Expand Down
4 changes: 2 additions & 2 deletions benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,8 @@ pub fn show_benchmark_debug_info(
components: &[(BenchmarkParameter, u32)],
verify: &bool,
error_message: &str,
) -> sp_runtime::RuntimeString {
sp_runtime::format_runtime_string!(
) -> String {
format!(
"\n* Pallet: {}\n\
* Benchmark: {}\n\
* Components: {:?}\n\
Expand Down
1 change: 1 addition & 0 deletions currencies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxFreezes = ();
type DoneSlashHandler = ();
}

parameter_type_with_key! {
Expand Down
2 changes: 1 addition & 1 deletion gradually-update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Laminar Developers <hello@laminar.one>"]
edition = "2021"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["max-encoded-len"] }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion oracle/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Runtime API module for orml-oracle."
repository = "https://github.com/open-web3-stack/open-runtime-module-library"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] }
sp-api = { workspace = true }
sp-std = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion parameters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Acala Developers"]
edition = "2021"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["max-encoded-len"] }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
serde = { workspace = true, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Acala Developers"]
edition = "2021"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["max-encoded-len"] }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion tokens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Laminar Developers <hello@laminar.one>"]
edition = "2021"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["max-encoded-len"] }
log = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion tokens/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Runtime API module for orml-tokens."
repository = "https://github.com/open-web3-stack/open-runtime-module-library"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] }
frame-support = { workspace = true }
sp-api = { workspace = true }
sp-runtime = { workspace = true }
Expand Down
18 changes: 16 additions & 2 deletions tokens/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use frame_support::{
construct_runtime, derive_impl, parameter_types,
traits::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ChangeMembers, ConstU32, ConstU64, ContainsLengthBound, SortedMembers,
ChangeMembers, ConstU32, ConstU64,
},
PalletId,
};
use orml_traits::parameter_type_with_key;
use sp_runtime::{
traits::{AccountIdConversion, IdentityLookup},
traits::{AccountIdConversion, BlockNumberProvider, IdentityLookup},
AccountId32, BuildStorage, Permill,
};
use sp_std::cell::RefCell;
Expand Down Expand Up @@ -65,6 +65,19 @@ parameter_types! {
}

pub type MockCurrencyAdapter = CurrencyAdapter<Runtime, GetTokenId>;

parameter_types! {
pub static MockBlockNumberProvider: u64 = 0;
}

impl BlockNumberProvider for MockBlockNumberProvider {
type BlockNumber = u64;

fn current_block_number() -> BlockNumberFor<Runtime> {
Self::get()
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = MockCurrencyAdapter;
Expand All @@ -85,6 +98,7 @@ impl pallet_treasury::Config for Runtime {
type PayoutPeriod = ConstU64<10>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type BlockNumberProvider = MockBlockNumberProvider;
}

thread_local! {
Expand Down
2 changes: 1 addition & 1 deletion traits/src/asset_registry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use frame_support::pallet_prelude::*;
use sp_runtime::DispatchResult;
use sp_std::fmt::Debug;
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;
use xcm::VersionedLocation;

pub trait WeightToFeeConverter {
Expand Down
2 changes: 1 addition & 1 deletion traits/src/location.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sp_core::{bounded::BoundedVec, ConstU32};
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;

pub trait Parse {
/// Returns the "chain" location part. It could be parent, sibling
Expand Down
2 changes: 1 addition & 1 deletion traits/src/multi_asset.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sp_core::{bounded::BoundedVec, ConstU32};
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;

use crate::location::RelativeLocations;

Expand Down
2 changes: 1 addition & 1 deletion traits/src/xcm_transfer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
use xcm::{
v4::{prelude::*, Weight},
v5::{prelude::*, Weight},
VersionedAsset, VersionedAssets, VersionedLocation,
};
pub struct Transferred<AccountId> {
Expand Down
2 changes: 1 addition & 1 deletion unknown-tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use frame_support::pallet_prelude::*;
use sp_std::vec::Vec;
use xcm::v4::prelude::*;
use xcm::v5::prelude::*;

use orml_xcm_support::UnknownAsset;

Expand Down
4 changes: 2 additions & 2 deletions utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2021"

[dependencies]
scale-info = { workspace = true }
serde = { version = "1.0.136", optional = true, features = ["derive"] }
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
serde = { workspace = true, optional = true, features = ["derive"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["derive"] }

frame-support = { workspace = true }
sp-runtime = { workspace = true, features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion vesting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Laminar Developers <hello@laminar.one>"]
edition = "2021"

[dependencies]
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] }
parity-scale-codec = { workspace = true, default-features = false, features = ["max-encoded-len"] }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }

Expand Down
1 change: 1 addition & 0 deletions vesting/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = [u8; 8];
type MaxFreezes = ();
type DoneSlashHandler = ();
}

pub struct EnsureAliceOrBob;
Expand Down
2 changes: 1 addition & 1 deletion xcm-mock-message-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use parity_scale_codec::{Decode, Encode};
use polkadot_parachain_primitives::primitives::DmpMessageHandler;
use sp_std::prelude::*;
use xcm::{
v4::{prelude::*, Weight},
v5::{prelude::*, Weight},
VersionedXcm,
};

Expand Down
2 changes: 1 addition & 1 deletion xcm-support/src/currency_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use sp_std::{
result,
};

use xcm::v4::{prelude::*, Asset, Error as XcmError, Location, Result};
use xcm::v5::{prelude::*, Asset, Error as XcmError, Location, Result};
use xcm_executor::{
traits::{ConvertLocation, MatchesFungible, TransactAsset},
AssetsInHolding,
Expand Down
Loading

0 comments on commit f26c8c9

Please sign in to comment.