diff --git a/tokens/src/impls.rs b/tokens/src/impls.rs index dca977509..ff8c16f2a 100644 --- a/tokens/src/impls.rs +++ b/tokens/src/impls.rs @@ -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) + } } } diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs index ffea8a501..18333052a 100644 --- a/tokens/src/lib.rs +++ b/tokens/src/lib.rs @@ -1750,8 +1750,8 @@ impl fungibles::Inspect for Pallet { 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::::contains_key(asset) } } diff --git a/tokens/src/tests_fungibles.rs b/tokens/src/tests_fungibles.rs index d5a6ec5ef..600897fe2 100644 --- a/tokens/src/tests_fungibles.rs +++ b/tokens/src/tests_fungibles.rs @@ -22,6 +22,9 @@ fn fungibles_inspect_trait_should_work() { ); assert_ok!(>::can_deposit(DOT, &ALICE, 1, false).into_result()); assert_ok!(>::can_withdraw(DOT, &ALICE, 1).into_result()); + + assert!(>::asset_exists(DOT)); + assert!(!>::asset_exists(BTC)); }); } @@ -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!( @@ -294,6 +297,10 @@ fn fungibles_inspect_convert_should_work() { >::total_issuance(DOT), 20000 ); + + assert!(>::asset_exists(DOT)); + assert!(>::asset_exists(BTC)); + assert!(!>::asset_exists(ETH)); }); }