Skip to content

Commit

Permalink
Use ForeignChainAndAsset
Browse files Browse the repository at this point in the history
  • Loading branch information
AlastairHolmes committed Feb 15, 2024
1 parent 76ce86a commit 7121067
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,23 +1222,13 @@ impl_runtime_apis! {
}
}

fn cf_egress_dust_limit(asset: Asset) -> AssetAmount {
fn cf_egress_dust_limit(generic_asset: Asset) -> AssetAmount {
use pallet_cf_ingress_egress::EgressDustLimit;
use cf_chains::assets::{eth, dot, btc};

match ForeignChain::from(asset) {
ForeignChain::Ethereum => EgressDustLimit::<Runtime, EthereumInstance>::get(
eth::Asset::try_from(asset)
.expect("Conversion must succeed: ForeignChain checked in match clause.")
),
ForeignChain::Polkadot => EgressDustLimit::<Runtime, PolkadotInstance>::get(
dot::Asset::try_from(asset)
.expect("Conversion must succeed: ForeignChain checked in match clause.")
),
ForeignChain::Bitcoin => EgressDustLimit::<Runtime, BitcoinInstance>::get(
btc::Asset::try_from(asset)
.expect("Conversion must succeed: ForeignChain checked in match clause.")
),
match generic_asset.into() {
ForeignChainAndAsset::Ethereum(asset) => EgressDustLimit::<Runtime, EthereumInstance>::get(asset),
ForeignChainAndAsset::Polkadot(asset) => EgressDustLimit::<Runtime, PolkadotInstance>::get(asset),
ForeignChainAndAsset::Bitcoin(asset) => EgressDustLimit::<Runtime, BitcoinInstance>::get(asset),
}
}

Expand Down

0 comments on commit 7121067

Please sign in to comment.