Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,5 @@ zenlink-protocol-runtime-api = { git = "ssh://[email protected]/bifrost-finance/Zen
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "650ef607d023e4537d3f2932baa5e50bc3a349cb" }
orml-currencies = {git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "650ef607d023e4537d3f2932baa5e50bc3a349cb" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "650ef607d023e4537d3f2932baa5e50bc3a349cb" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "650ef607d023e4537d3f2932baa5e50bc3a349cb" }
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "650ef607d023e4537d3f2932baa5e50bc3a349cb" }
9 changes: 7 additions & 2 deletions runtime/asgard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ bifrost-salp = { path = "../../pallets/salp", default-features = false }
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }
xcm-support = { path = "../../xcm-support", default-features = false }

# orml
orml-currencies = { version = "0.4.1-dev", default-features = false }
orml-tokens = { version = "0.4.1-dev", default-features = false }
orml-traits = { version = "0.4.1-dev", default-features = false }
xcm-support = { path = "../../xcm-support", default-features = false }
orml-xtokens = { version = "0.4.1-dev", default-features = false }
orml-xcm-support = { version = "0.4.1-dev", default-features = false }


zenlink-protocol = { version = "*", default-features = false }
zenlink-protocol-runtime-api = { version = "*", default-features = false }
Expand Down Expand Up @@ -170,10 +173,12 @@ std = [
"bifrost-salp/std",
"bifrost-vsbond-auction/std",
"bifrost-vtoken-mint/std",
"xcm-support/std",
"orml-currencies/std",
"orml-traits/std",
"orml-tokens/std",
"xcm-support/std",
"orml-xtokens/std",
"orml-xcm-support/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
]
Expand Down
22 changes: 20 additions & 2 deletions runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ use sp_std::{marker::PhantomData, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm_support::Get;

/// Constant values used within the runtime.
pub mod constants;
use bifrost_flexible_fee::fee_dealer::FixedCurrencyFeeRate;
use bifrost_runtime_common::xcm_impl::{
BifrostAssetMatcher, BifrostCurrencyIdConvert, BifrostFilteredAssets, BifrostXcmTransactFilter,
BifrostAccountIdToMultiLocation, BifrostAssetMatcher, BifrostCurrencyIdConvert,
BifrostFilteredAssets, BifrostXcmTransactFilter,
};
use codec::{Decode, Encode};
use constants::{currency::*, time::*};
Expand Down Expand Up @@ -1144,6 +1146,22 @@ impl orml_currencies::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub SelfLocation: MultiLocation = X2(Parent, Parachain(ParachainInfo::get().into()));
}

impl orml_xtokens::Config for Runtime {
type Event = Event;
type Balance = Balance;
type CurrencyId = CurrencyId;
type CurrencyIdConvert = BifrostCurrencyIdConvert<ParachainInfo>;
type AccountIdToMultiLocation = BifrostAccountIdToMultiLocation;
type SelfLocation = SelfLocation;
type XcmExecutor = XcmExecutor<XcmConfig>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type BaseXcmWeight = XcmWeight;
}

// orml runtime end

construct_runtime! {
Expand Down Expand Up @@ -1200,7 +1218,7 @@ construct_runtime! {

// Third party modules
ZenlinkProtocol: zenlink_protocol::{Pallet, Call, Storage, Event<T>} = 61,
// XTokens: orml_xtokens::{Pallet, Storage, Call, Event<T>} = 70,
XTokens: orml_xtokens::{Pallet, Call, Event<T>} = 70,
Tokens: orml_tokens::{Pallet, Call, Storage, Event<T>, Config<T>} = 71,
Currencies: orml_currencies::{Pallet, Call, Event<T>} = 72,

Expand Down
17 changes: 12 additions & 5 deletions runtime/common/src/xcm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ fn native_currency_location(id: CurrencyId, para_id: ParaId) -> MultiLocation {
pub struct BifrostCurrencyIdConvert<T>(sp_std::marker::PhantomData<T>);
impl<T: Get<ParaId>> Convert<CurrencyId, Option<MultiLocation>> for BifrostCurrencyIdConvert<T> {
fn convert(id: CurrencyId) -> Option<MultiLocation> {
use CurrencyId::Token;
use CurrencyId::{Native, Token};
match id {
Token(TokenSymbol::KSM) | Token(TokenSymbol::DOT) => Some(X1(Parent)),
Token(TokenSymbol::ASG) | Token(TokenSymbol::BNC) =>
Token(TokenSymbol::KSM) => Some(X1(Parent)),
Native(TokenSymbol::ASG) | Native(TokenSymbol::BNC) =>
Some(native_currency_location(id, T::get())),
_ => None,
}
}
}
impl<T: Get<ParaId>> Convert<MultiLocation, Option<CurrencyId>> for BifrostCurrencyIdConvert<T> {
fn convert(location: MultiLocation) -> Option<CurrencyId> {
use CurrencyId::Token;
use CurrencyId::{Native, Token};
use TokenSymbol::*;
match location {
X1(Parent) => Some(Token(KSM)),
Expand All @@ -136,7 +136,7 @@ impl<T: Get<ParaId>> Convert<MultiLocation, Option<CurrencyId>> for BifrostCurre
if let Ok(currency_id) = CurrencyId::decode(&mut &key[..]) {
// check `currency_id` is cross-chain asset
match currency_id {
Token(TokenSymbol::ASG) | Token(TokenSymbol::BNC) => Some(currency_id),
Native(TokenSymbol::ASG) | Native(TokenSymbol::BNC) => Some(currency_id),
_ => None,
}
} else {
Expand All @@ -156,3 +156,10 @@ impl<T: Get<ParaId>> Convert<MultiAsset, Option<CurrencyId>> for BifrostCurrency
}
}
}

pub struct BifrostAccountIdToMultiLocation;
impl Convert<AccountId, MultiLocation> for BifrostAccountIdToMultiLocation {
fn convert(account: AccountId) -> MultiLocation {
X1(AccountId32 { network: NetworkId::Any, id: account.into() })
}
}
8 changes: 6 additions & 2 deletions runtime/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ bifrost-salp = { path = "../../pallets/salp", default-features = false }
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }
xcm-support = { path = "../../xcm-support", default-features = false }

# orml
orml-currencies = { version = "0.4.1-dev", default-features = false }
orml-tokens = { version = "0.4.1-dev", default-features = false }
orml-traits = { version = "0.4.1-dev", default-features = false }
xcm-support = { path = "../../xcm-support", default-features = false }
orml-xtokens = { version = "0.4.1-dev", default-features = false }
orml-xcm-support = { version = "0.4.1-dev", default-features = false }

zenlink-protocol = { version = "*", default-features = false }
zenlink-protocol-runtime-api = { version = "*", default-features = false }
Expand Down Expand Up @@ -172,10 +174,12 @@ std = [
"bifrost-salp/std",
"bifrost-vsbond-auction/std",
"bifrost-vtoken-mint/std",
"xcm-support/std",
"orml-currencies/std",
"orml-traits/std",
"orml-tokens/std",
"xcm-support/std",
"orml-xtokens/std",
"orml-xcm-support/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
]
Expand Down
22 changes: 20 additions & 2 deletions runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ use sp_std::{marker::PhantomData, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm_support::Get;

/// Constant values used within the runtime.
pub mod constants;
use bifrost_flexible_fee::fee_dealer::FixedCurrencyFeeRate;
use bifrost_runtime_common::xcm_impl::{
BifrostAssetMatcher, BifrostCurrencyIdConvert, BifrostFilteredAssets, BifrostXcmTransactFilter,
BifrostAccountIdToMultiLocation, BifrostAssetMatcher, BifrostCurrencyIdConvert,
BifrostFilteredAssets, BifrostXcmTransactFilter,
};
use codec::{Decode, Encode};
use constants::{currency::*, time::*};
Expand Down Expand Up @@ -1115,6 +1117,22 @@ impl orml_currencies::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub SelfLocation: MultiLocation = X2(Parent, Parachain(ParachainInfo::get().into()));
}

impl orml_xtokens::Config for Runtime {
type Event = Event;
type Balance = Balance;
type CurrencyId = CurrencyId;
type CurrencyIdConvert = BifrostCurrencyIdConvert<ParachainInfo>;
type AccountIdToMultiLocation = BifrostAccountIdToMultiLocation;
type SelfLocation = SelfLocation;
type XcmExecutor = XcmExecutor<XcmConfig>;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type BaseXcmWeight = XcmWeight;
}

// orml runtime end

construct_runtime! {
Expand Down Expand Up @@ -1167,7 +1185,7 @@ construct_runtime! {

// Third party modules
ZenlinkProtocol: zenlink_protocol::{Pallet, Call, Storage, Event<T>} = 61,
// XTokens: orml_xtokens::{Pallet, Storage, Call, Event<T>} = 70,
XTokens: orml_xtokens::{Pallet, Call, Event<T>} = 70,
Tokens: orml_tokens::{Pallet, Call, Storage, Event<T>, Config<T>} = 71,
Currencies: orml_currencies::{Pallet, Call, Event<T>} = 72,

Expand Down