I can imagine an XCM-based runtime API that receives an input MultiAsset
and an account id as input, and returns all of the assets belonging to that user account, and matches to that MultiAsset
. If the MultiAsset
is a wildcard, it would mean “give me all of the tokens belonging to this user”.
What I wonder is about the return type of this API. Should it still be the super generic XCM types like MultiAsset
? probably no, and we’d only use MultiAsset
as the query input. Instead, we need a more detailed return type that fulfills details such as:
- ticker
- decimals
- name
- …
Generally, I think abstracting balances behind XCM makes a lot of sense for transfers, but I am bit worried if it is reasonable for read-only operations. All we need is a standard return type and an API like:
fn tokens_of(who: AccountId) -> Vec<StandardBalanceType> {}
Not sure what values XCM can add to this (beyond the filtering, which I am not quite sure if it is actually sensible).
Regardless of with or without XCM: we can actually implement this first-hand on Polkadot. Historically, if you were to deposit your funds in crowdloans, it would be lost in your wallets. Nowadays, most wallets have implemented fix. Soon, nomination pools will have a very similar mechanism. Once you deposit funds into a pool, it will disappear from most wallets until they tediously fix it manually. Hopefully we can standardize this soon that nomination pools would be implemented in the more scalable way.
The TS-based project that I have started to tackle this in the short term is: GitHub - substrate-portfolio/polkadot-portfolio: Simple UI to find all your bags of tokens in the highly complicated world of Polkadot Ecosystem 🔴