mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Changed query_account_balances return type (#2455)
This commit is contained in:
@@ -951,7 +951,7 @@ impl_runtime_apis! {
|
||||
AccountId,
|
||||
> for Runtime
|
||||
{
|
||||
fn query_account_balances(account: AccountId) -> Result<Vec<xcm::latest::MultiAsset>, assets_common::runtime_api::FungiblesAccessError> {
|
||||
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedMultiAssets, assets_common::runtime_api::FungiblesAccessError> {
|
||||
use assets_common::fungible_conversion::{convert, convert_balance};
|
||||
Ok([
|
||||
// collect pallet_balance
|
||||
@@ -976,7 +976,7 @@ impl_runtime_apis! {
|
||||
.filter(|(_, balance)| balance > &0)
|
||||
)?,
|
||||
// collect ... e.g. other tokens
|
||||
].concat())
|
||||
].concat().into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,11 @@ fn test_assets_balances_api_works() {
|
||||
0
|
||||
);
|
||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0);
|
||||
assert!(Runtime::query_account_balances(AccountId::from(ALICE)).unwrap().is_empty());
|
||||
assert!(Runtime::query_account_balances(AccountId::from(ALICE))
|
||||
.unwrap()
|
||||
.try_as::<MultiAssets>()
|
||||
.unwrap()
|
||||
.is_none());
|
||||
|
||||
// Drip some balance
|
||||
use frame_support::traits::fungible::Mutate;
|
||||
@@ -437,24 +441,27 @@ fn test_assets_balances_api_works() {
|
||||
);
|
||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency);
|
||||
|
||||
let result = Runtime::query_account_balances(AccountId::from(ALICE)).unwrap();
|
||||
let result: MultiAssets = Runtime::query_account_balances(AccountId::from(ALICE))
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
assert_eq!(result.len(), 3);
|
||||
|
||||
// check currency
|
||||
assert!(result.iter().any(|asset| asset.eq(
|
||||
assert!(result.inner().iter().any(|asset| asset.eq(
|
||||
&assets_common::fungible_conversion::convert_balance::<KsmLocation, Balance>(
|
||||
some_currency
|
||||
)
|
||||
.unwrap()
|
||||
)));
|
||||
// check trusted asset
|
||||
assert!(result.iter().any(|asset| asset.eq(&(
|
||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap(),
|
||||
minimum_asset_balance
|
||||
)
|
||||
.into())));
|
||||
// check foreign asset
|
||||
assert!(result.iter().any(|asset| asset.eq(&(
|
||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||
Identity::reverse_ref(foreign_asset_id_multilocation).unwrap(),
|
||||
6 * foreign_asset_minimum_asset_balance
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user