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
8 changes: 6 additions & 2 deletions tokens/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ where
}
}

fn asset_exists(_asset: Self::AssetId) -> bool {
false
fn asset_exists(asset: Self::AssetId) -> bool {
if TestKey::contains(&asset) {
true
} else {
B::asset_exists(asset)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,8 @@ impl<T: Config> fungibles::Inspect<T::AccountId> for Pallet<T> {
Self::withdraw_consequence(who, asset_id, amount, &Self::accounts(who, asset_id))
}

fn asset_exists(_asset: Self::AssetId) -> bool {
false
fn asset_exists(asset: Self::AssetId) -> bool {
TotalIssuance::<T>::contains_key(asset)
}
}

Expand Down
9 changes: 8 additions & 1 deletion tokens/src/tests_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ fn fungibles_inspect_trait_should_work() {
);
assert_ok!(<Tokens as fungibles::Inspect<_>>::can_deposit(DOT, &ALICE, 1, false).into_result());
assert_ok!(<Tokens as fungibles::Inspect<_>>::can_withdraw(DOT, &ALICE, 1).into_result());

assert!(<Tokens as fungibles::Inspect<_>>::asset_exists(DOT));
assert!(!<Tokens as fungibles::Inspect<_>>::asset_exists(BTC));
});
}

Expand Down Expand Up @@ -283,7 +286,7 @@ fn fungibles_inspect_convert_should_work() {
>;

ExtBuilder::default()
.balances(vec![(ALICE, DOT, 100), (BOB, DOT, 100)])
.balances(vec![(ALICE, DOT, 100), (BOB, DOT, 100), (BOB, BTC, 100)])
.build()
.execute_with(|| {
assert_eq!(
Expand All @@ -294,6 +297,10 @@ fn fungibles_inspect_convert_should_work() {
<RebaseTokens as fungibles::Inspect<AccountId>>::total_issuance(DOT),
20000
);

assert!(<Tokens as fungibles::Inspect<_>>::asset_exists(DOT));
assert!(<Tokens as fungibles::Inspect<_>>::asset_exists(BTC));
assert!(!<Tokens as fungibles::Inspect<_>>::asset_exists(ETH));
});
}

Expand Down