Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move default impl to xcm-support. Cooments and fmt
Signed-off-by: Georgi Zlatarev <[email protected]>
  • Loading branch information
ghzlatarev committed May 31, 2022
commit c95109f77f12f920adf464d27a8ac32889d80aa1
10 changes: 0 additions & 10 deletions traits/src/get_by_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use xcm::v1::MultiLocation;

/// A trait for querying a value by a key.
pub trait GetByKey<Key, Value> {
/// Return the value.
Expand Down Expand Up @@ -57,11 +55,3 @@ mod tests {
assert_eq!(Test::get(&3), 2);
}
}

// Default implementation for xTokens::MinXcmFee
pub struct DisabledParachainFee;
impl GetByKey<MultiLocation, Option<u128>> for DisabledParachainFee {
fn get(_key: &MultiLocation) -> Option<u128> {
None
}
}
10 changes: 9 additions & 1 deletion xcm-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sp_std::{marker::PhantomData, prelude::*};
use xcm::latest::prelude::*;
use xcm_executor::traits::{FilterAssetLocation, MatchesFungible};

use orml_traits::location::Reserve;
use orml_traits::{location::Reserve, GetByKey};

pub use currency_adapter::{DepositToAlternative, MultiCurrencyAdapter, OnDepositFail};

Expand Down Expand Up @@ -78,3 +78,11 @@ impl UnknownAsset for () {
Err(DispatchError::Other(NO_UNKNOWN_ASSET_IMPL))
}
}

// Default implementation for xTokens::MinXcmFee
pub struct DisabledParachainFee;
impl GetByKey<MultiLocation, Option<u128>> for DisabledParachainFee {
fn get(_key: &MultiLocation) -> Option<u128> {
None
}
}
2 changes: 1 addition & 1 deletion xtokens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ parameter_type_with_key! {
}
```

If Parachain don't want have this case, can simply return None:
If Parachain don't want have this case, can simply return None. A default implementation is provided by `DisabledParachainFee` in `xcm-support`.

```rust
parameter_type_with_key! {
Expand Down