Right now wallet_getAssets will make a multicall request per asset, including metadata and balance.
|
let (balance, decimals, name, symbol) = chain_provider |
|
.multicall() |
|
.add(erc20.balanceOf(request.account)) |
|
.add(erc20.decimals()) |
|
.add(erc20.name()) |
|
.add(erc20.symbol()) |
|
.aggregate() |
|
.await?; |
However this could be greatly improved by batching assets into one/many multicalls just for balanceOf and then using the following to get each asset metadata:
|
/// Lookup asset info for a given chain and a list of assets. It first checks the cache, and if |
|
/// it cannot find it will query it from chain. |
|
/// |
|
/// # Note: |
|
/// Ensures that the returned map contains all the requested assets. |
|
pub async fn get_asset_info_list<P: Provider>( |
|
&self, |
|
provider: &P, |
|
assets: Vec<Asset>, |
|
) -> Result<HashMap<Asset, AssetWithInfo>, RelayError> { |
Right now
wallet_getAssetswill make a multicall request per asset, including metadata and balance.relay/src/rpc/relay.rs
Lines 2745 to 2752 in 07fa527
However this could be greatly improved by batching assets into one/many multicalls just for
balanceOfand then using the following to get each asset metadata:relay/src/asset.rs
Lines 62 to 71 in 07fa527