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
17 changes: 17 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
orml-currencies = {git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "8d5432c3458702a7df14b374bddde43a2a20aa43" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "8d5432c3458702a7df14b374bddde43a2a20aa43" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "8d5432c3458702a7df14b374bddde43a2a20aa43" }
orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "8d5432c3458702a7df14b374bddde43a2a20aa43" }
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "8d5432c3458702a7df14b374bddde43a2a20aa43" }
2 changes: 2 additions & 0 deletions runtime/asgard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ 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 }
orml-xtokens = { version = "0.4.1-dev", default-features = false }
orml-unknown-tokens = { 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 }
Expand Down Expand Up @@ -182,6 +183,7 @@ std = [
"orml-traits/std",
"orml-tokens/std",
"orml-xtokens/std",
"orml-unknown-tokens/std",
"orml-xcm-support/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
Expand Down
15 changes: 11 additions & 4 deletions runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ use node_primitives::{
// orml imports
use orml_currencies::BasicCurrencyAdapter;
use orml_traits::MultiCurrency;
use orml_xcm_support::MultiCurrencyAdapter;
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
Expand All @@ -106,10 +107,10 @@ use xcm_builder::{
EnsureXcmOrigin, FixedRateOfConcreteFungible, FixedWeightBounds, IsConcrete, LocationInverter,
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, UsingComponents,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{Config, XcmExecutor};
use xcm_support::{BifrostCurrencyAdapter, BifrostXcmAdaptor};
use xcm_support::BifrostXcmAdaptor;
// zenlink imports
use zenlink_protocol::{
make_x2_location, AssetBalance, AssetId, LocalAssetHandler, MultiAssetsHandler, PairInfo,
Expand Down Expand Up @@ -758,8 +759,9 @@ pub type Barrier = (
BifrostXcmTransactFilter<Everything>,
);

pub type BifrostAssetTransactor = BifrostCurrencyAdapter<
Tokens,
pub type BifrostAssetTransactor = MultiCurrencyAdapter<
Currencies,
UnknownTokens,
BifrostAssetMatcher<CurrencyId, BifrostCurrencyIdConvert<SelfParaChainId>>,
AccountId,
LocationToAccountId,
Expand Down Expand Up @@ -1265,6 +1267,10 @@ impl orml_xtokens::Config for Runtime {
type BaseXcmWeight = XcmWeight;
}

impl orml_unknown_tokens::Config for Runtime {
type Event = Event;
}

// orml runtime end

construct_runtime! {
Expand Down Expand Up @@ -1324,6 +1330,7 @@ construct_runtime! {
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,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 73,

// Bifrost modules
VtokenMint: bifrost_vtoken_mint::{Pallet, Call, Storage, Event<T>, Config<T>} = 101,
Expand Down
4 changes: 3 additions & 1 deletion runtime/bifrost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ xcm-support = { path = "../../xcm-support", default-features = false }
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 }
orml-xcm-support = { version = "0.4.1-dev", default-features = false }
orml-xtokens = { version = "0.4.1-dev", default-features = false }
orml-unknown-tokens = { version = "0.4.1-dev", default-features = false }
orml-xcm-support = { version = "0.4.1-dev", default-features = false }

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
Expand Down Expand Up @@ -155,6 +156,7 @@ std = [
"orml-traits/std",
"orml-tokens/std",
"orml-xtokens/std",
"orml-unknown-tokens/std",
"orml-xcm-support/std",
"bifrost-runtime-common/std",
"bifrost-flexible-fee/std",
Expand Down
19 changes: 13 additions & 6 deletions runtime/bifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ use frame_support::{
use frame_system::{EnsureOneOf, EnsureRoot, RawOrigin};
use hex_literal::hex;
use node_primitives::{
Amount, CurrencyId, Moment, Nonce, ParaId, ParachainDerivedProxyAccountType,
Amount, CurrencyId, Moment, Nonce, ParachainDerivedProxyAccountType,
ParachainTransactProxyType, ParachainTransactType, TokenSymbol, TransferOriginType,
XcmBaseWeight,
};
// orml imports
use orml_currencies::BasicCurrencyAdapter;
use orml_traits::MultiCurrency;
use orml_xcm_support::MultiCurrencyAdapter;
use pallet_xcm::XcmPassthrough;
// XCM imports
use polkadot_parachain::primitives::Sibling;
Expand All @@ -99,10 +100,10 @@ use xcm_builder::{
EnsureXcmOrigin, FixedRateOfConcreteFungible, FixedWeightBounds, IsConcrete, LocationInverter,
ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, UsingComponents,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{Config, XcmExecutor};
use xcm_support::{BifrostCurrencyAdapter, BifrostXcmAdaptor, Get};
use xcm_support::{BifrostXcmAdaptor, Get};

// Weights used in the runtime.
mod weights;
Expand Down Expand Up @@ -670,8 +671,9 @@ pub type Barrier = (
BifrostXcmTransactFilter<Everything>,
);

pub type BifrostAssetTransactor = BifrostCurrencyAdapter<
Tokens,
pub type BifrostAssetTransactor = MultiCurrencyAdapter<
Currencies,
UnknownTokens,
BifrostAssetMatcher<CurrencyId, BifrostCurrencyIdConvert<SelfParaChainId>>,
AccountId,
LocationToAccountId,
Expand Down Expand Up @@ -884,6 +886,10 @@ impl orml_xtokens::Config for Runtime {
type BaseXcmWeight = XcmWeight;
}

impl orml_unknown_tokens::Config for Runtime {
type Event = Event;
}

// orml runtime end

// Bifrost modules start
Expand Down Expand Up @@ -1062,9 +1068,10 @@ construct_runtime! {
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 62,
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 63,

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>} = 71,
Currencies: orml_currencies::{Pallet, Call, Event<T>} = 72,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 73,

// Bifrost modules
FlexibleFee: bifrost_flexible_fee::{Pallet, Call, Storage, Event<T>} = 100,
Expand Down
38 changes: 21 additions & 17 deletions runtime/common/src/xcm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,44 +114,48 @@ 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::{Native, Stable, Token};
use CurrencyId::{Native, Token};
match id {
Token(TokenSymbol::KSM) => Some(X1(Parent)),
Native(TokenSymbol::ASG) | Native(TokenSymbol::BNC) =>
Some(native_currency_location(id, T::get())),
// Karura currencyId types
Token(TokenSymbol::KAR) | Stable(TokenSymbol::KUSD) =>
Some(X3(Parent, Parachain(2000), GeneralKey(id.encode()))),
Token(TokenSymbol::KAR) =>
Some(X3(Parent, Parachain(2000), GeneralKey([0, 128].to_vec()))),
Token(TokenSymbol::KUSD) =>
Some(X3(Parent, Parachain(2000), GeneralKey([0, 129].to_vec()))),
_ => None,
}
}
}
impl<T: Get<ParaId>> Convert<MultiLocation, Option<CurrencyId>> for BifrostCurrencyIdConvert<T> {
fn convert(location: MultiLocation) -> Option<CurrencyId> {
use CurrencyId::{Native, Stable, Token};
use CurrencyId::{Native, Token};
use TokenSymbol::*;
match location {
X1(Parent) => Some(Token(KSM)),
X3(Parent, Junction::Parachain(id), GeneralKey(key)) => {
// decode the general key
if let Ok(currency_id) = CurrencyId::decode(&mut &key[..]) {
// check `currency_id` is cross-chain asset
if ParaId::from(id) == T::get() {
// check `currency_id` is cross-chain asset
if ParaId::from(id) == T::get() {
// decode the general key
if let Ok(currency_id) = CurrencyId::decode(&mut &key[..]) {
match currency_id {
Native(TokenSymbol::ASG) | Native(TokenSymbol::BNC) =>
Some(currency_id),
_ => None,
}
// Kurara CurrencyId types
} else if id == 2000 {
match currency_id {
Token(TokenSymbol::KAR) | Stable(TokenSymbol::KUSD) =>
Some(currency_id),
Native(TokenSymbol::ASG) => Some(Native(TokenSymbol::ASG)),
Native(TokenSymbol::BNC) => Some(Native(TokenSymbol::BNC)),
_ => None,
}
} else {
None
}
// Kurara CurrencyId types
} else if id == 2000 {
if key == [0, 128].to_vec() {
Some(Token(TokenSymbol::KAR))
} else if key == [0, 129].to_vec() {
Some(Token(TokenSymbol::KUSD))
} else {
None
}
} else {
None
}
Expand Down
1 change: 1 addition & 0 deletions runtime/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ 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 }
orml-xtokens = { version = "0.4.1-dev", default-features = false }
orml-unknown-tokens = { 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 }
Expand Down
13 changes: 10 additions & 3 deletions runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ use node_primitives::{
// orml imports
use orml_currencies::BasicCurrencyAdapter;
use orml_traits::MultiCurrency;
use orml_xcm_support::MultiCurrencyAdapter;
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
Expand All @@ -112,7 +113,7 @@ use xcm_builder::{
UsingComponents,
};
use xcm_executor::{Config, XcmExecutor};
use xcm_support::{BifrostCurrencyAdapter, BifrostXcmAdaptor};
use xcm_support::BifrostXcmAdaptor;
// zenlink imports
use zenlink_protocol::{
make_x2_location, AssetBalance, AssetId, LocalAssetHandler, MultiAssetsHandler, PairInfo,
Expand Down Expand Up @@ -757,8 +758,9 @@ pub type Barrier = (
BifrostXcmTransactFilter<Everything>,
);

pub type BifrostAssetTransactor = BifrostCurrencyAdapter<
Tokens,
pub type BifrostAssetTransactor = MultiCurrencyAdapter<
Currencies,
UnknownTokens,
BifrostAssetMatcher<CurrencyId, BifrostCurrencyIdConvert<SelfParaChainId>>,
AccountId,
LocationToAccountId,
Expand Down Expand Up @@ -1199,6 +1201,10 @@ impl orml_xtokens::Config for Runtime {
type BaseXcmWeight = XcmWeight;
}

impl orml_unknown_tokens::Config for Runtime {
type Event = Event;
}

// orml runtime end

construct_runtime! {
Expand Down Expand Up @@ -1254,6 +1260,7 @@ construct_runtime! {
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,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 73,

// Bifrost modules
VtokenMint: bifrost_vtoken_mint::{Pallet, Call, Storage, Event<T>, Config<T>} = 101,
Expand Down
Loading