Skip to content

Commit

Permalink
refactor: use ForeignChainAndAsset (#4536)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlastairHolmes authored Feb 16, 2024
1 parent 8a9d7d8 commit b0bb520
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 @@ -1225,23 +1225,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 b0bb520

Please sign in to comment.