feat: expose token balance API

This commit is contained in:
Anthony Laibe 2023-12-15 09:19:40 +01:00
parent 6d77fb771a
commit 8cbdc80758
1 changed files with 11 additions and 0 deletions

View File

@ -65,6 +65,17 @@ func (api *API) GetWalletToken(ctx context.Context, addresses []common.Address)
return api.reader.GetWalletToken(ctx, addresses)
}
// GetBalancesByChain return a map with key as chain id and value as map of account address and map of token address and balance
// [chainID][account][token]balance
func (api *API) GetBalancesByChain(ctx context.Context, chainIDs []uint64, addresses, tokens []common.Address) (map[uint64]map[common.Address]map[common.Address]*hexutil.Big, error) {
clients, err := api.s.rpcClient.EthClients(chainIDs)
if err != nil {
return nil, err
}
return api.s.tokenManager.GetBalancesByChain(ctx, clients, addresses, tokens)
}
func (api *API) GetCachedWalletTokensWithoutMarketData(ctx context.Context) (map[common.Address][]Token, error) {
return api.reader.GetCachedWalletTokensWithoutMarketData()
}