Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ark930 committed Aug 27, 2021
1 parent 021b61f commit a2a8371
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 62 deletions.
59 changes: 7 additions & 52 deletions runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use core::convert::TryInto;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, match_type, parameter_types,
traits::{Everything, InstanceFilter, IsInVec, LockIdentifier, MaxEncodedLen, Randomness},
traits::{Everything, InstanceFilter, IsInVec, LockIdentifier, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight,
Expand Down Expand Up @@ -84,7 +84,7 @@ use bifrost_runtime_common::{
},
SlowAdjustingFeeUpdate,
};
use codec::{Decode, Encode};
use codec::{Decode, Encode, MaxEncodedLen};
use constants::{currency::*, time::*};
use cumulus_primitives_core::ParaId as CumulusParaId;
use frame_support::{
Expand All @@ -102,9 +102,7 @@ use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
use static_assertions::const_assert;
use xcm::v0::{
BodyId, Junction, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId, Xcm,
};
use xcm::v0::{BodyId, Junction, Junction::*, MultiLocation, MultiLocation::*, NetworkId};
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, ParentAsSuperuser,
Expand Down Expand Up @@ -1081,7 +1079,6 @@ parameter_types! {
impl zenlink_protocol::Config for Runtime {
type Conversion = ZenlinkLocationToAccountId;
type Event = Event;
type GetExchangeFee = GetExchangeFee;
type MultiAssetsHandler = MultiAssets;
type PalletId = ZenlinkPalletId;
type SelfParaId = SelfParaId;
Expand Down Expand Up @@ -1405,6 +1402,10 @@ impl_runtime_apis! {
Grandpa::grandpa_authorities()
}

fn current_set_id() -> fg_primitives::SetId {
Grandpa::current_set_id()
}

fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: fg_primitives::EquivocationProof<
<Block as BlockT>::Hash,
Expand Down Expand Up @@ -1488,10 +1489,6 @@ impl_runtime_apis! {

// zenlink runtime outer apis
impl zenlink_protocol_runtime_api::ZenlinkProtocolApi<Block, AccountId> for Runtime {
fn get_assets() -> Vec<AssetId> {
ZenlinkProtocol::get_assets()
}

fn get_balance(
asset_id: AssetId,
owner: AccountId
Expand All @@ -1505,54 +1502,12 @@ impl_runtime_apis! {
ZenlinkProtocol::get_sovereigns_info(&asset_id)
}

fn get_all_pairs() -> Vec<PairInfo<AccountId, AssetBalance>> {
ZenlinkProtocol::get_all_pairs()
}

fn get_owner_pairs(
owner: AccountId
) -> Vec<PairInfo<AccountId, AssetBalance>> {
ZenlinkProtocol::get_owner_pairs(&owner)
}

fn get_pair_by_asset_id(
asset_0: AssetId,
asset_1: AssetId
) -> Option<PairInfo<AccountId, AssetBalance>> {
ZenlinkProtocol::get_pair_by_asset_id(asset_0, asset_1)
}

fn get_amount_in_price(
supply: AssetBalance,
path: Vec<AssetId>
) -> AssetBalance {
ZenlinkProtocol::desired_in_amount(supply, path)
}

fn get_amount_out_price(
supply: AssetBalance,
path: Vec<AssetId>
) -> AssetBalance {
ZenlinkProtocol::supply_out_amount(supply, path)
}

fn get_estimate_lptoken(
token_0: AssetId,
token_1: AssetId,
amount_0_desired: AssetBalance,
amount_1_desired: AssetBalance,
amount_0_min: AssetBalance,
amount_1_min: AssetBalance,
) -> AssetBalance{
ZenlinkProtocol::get_estimate_lptoken(
token_0,
token_1,
amount_0_desired,
amount_1_desired,
amount_0_min,
amount_1_min
)
}
}

// benchmarks for asgard modules
Expand Down
22 changes: 12 additions & 10 deletions xcm-support/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn encode_xcm(message: Xcm<()>, message_kind: MessageKind) -> Vec<u8> {
match message_kind {
MessageKind::Ump | MessageKind::Dmp => VersionedXcm::<()>::from(message).encode(),
MessageKind::Xcmp => {
let fmt = cumulus_pallet_xcmp_queue::XcmpMessageFormat::ConcatenatedVersionedXcm;
let fmt = polkadot_parachain::primitives::XcmpMessageFormat::ConcatenatedVersionedXcm;
let mut outbound = fmt.encode();

let encoded = VersionedXcm::<()>::from(message).encode();
Expand Down Expand Up @@ -304,7 +304,7 @@ pub type ParachainPalletXcm = pallet_xcm::Pallet<para::Runtime>;
pub mod para {
use frame_support::{
construct_runtime, parameter_types,
traits::All,
traits::Everything,
weights::{constants::WEIGHT_PER_SECOND, Weight},
};
use frame_system::EnsureRoot;
Expand Down Expand Up @@ -427,7 +427,7 @@ pub mod para {
XcmCurrencyAdapter<Balances, IsConcrete<KsmLocation>, LocationToAccountId, AccountId, ()>;

pub type XcmRouter = crate::mock::ParachainXcmRouter<ParachainInfo>;
pub type Barrier = AllowUnpaidExecutionFrom<All<MultiLocation>>;
pub type Barrier = AllowUnpaidExecutionFrom<Everything>;

pub struct XcmConfig;
impl Config for XcmConfig {
Expand Down Expand Up @@ -466,11 +466,12 @@ pub mod para {
impl pallet_xcm::Config for Runtime {
type Event = Event;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type LocationInverter = LocationInverter<Ancestry>;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type XcmExecuteFilter = All<(MultiLocation, Xcm<Call>)>;
type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = Everything;
type XcmRouter = XcmRouter;
type XcmTeleportFilter = ();
}
Expand Down Expand Up @@ -502,7 +503,7 @@ pub mod relay {
use cumulus_primitives_core::ParaId;
use frame_support::{
construct_runtime, parameter_types,
traits::{All, OnUnbalanced},
traits::{Everything, OnUnbalanced},
weights::{Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial},
};
use pallet_balances::NegativeImbalance;
Expand All @@ -511,7 +512,7 @@ pub mod relay {
use smallvec::smallvec;
use sp_core::H256;
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32, Perbill};
use xcm::v0::{MultiAsset, MultiLocation, NetworkId};
use xcm::v0::{MultiLocation, NetworkId};
use xcm_builder::{
AccountId32Aliases, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
Expand Down Expand Up @@ -632,7 +633,7 @@ pub mod relay {
}

pub type XcmRouter = crate::mock::RelayChainXcmRouter;
pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom<All<MultiLocation>>);
pub type Barrier = (TakeWeightCredit, AllowTopLevelPaidExecutionFrom<Everything>);

pub struct XcmConfig;
impl Config for XcmConfig {
Expand All @@ -656,13 +657,14 @@ pub mod relay {
type Event = Event;
// Anyone can execute XCM messages locally...
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type LocationInverter = LocationInverter<Ancestry>;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type XcmExecuteFilter = ();
type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmReserveTransferFilter = Everything;
type XcmRouter = XcmRouter;
type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
type XcmTeleportFilter = Everything;
}

parameter_types! {
Expand Down

0 comments on commit a2a8371

Please sign in to comment.