Unified Get Account Balances Abstraction
Is your feature request related to a problem? Please describe. Wallets and dApps have traditionally needed account data from G addresses which makes the horizon sdk a good fit for their data source. More recently, discussions around support for contract accounts has been gaining traction. There are several problems with moving from a G account workflow to a G or C account workflow but one core issue is a missing abstraction for getting an account's balance wether it is a G or a C account.
Describe the solution you'd like An addition to the RPC sdk that allows a client to pass in a address(G or C) and get back the accounts balances for classic assets.
Describe alternatives you've considered Using a different library for balances in a post contract account implementation, like https://jsr.io/@creit-tech/stellar-assets-sdk
Additional context Conversation about dApp support for contract accounts https://discord.com/channels/897514728459468821/1357489706618847314
This may not need to be part of the rpc layer but the idea so far is that having an abstraction for getting classic asset balances for G and C accounts in the library that is likely already installed in dApps would make the transition to smart accounts more seamless.
You can learn what the balance is if you know the assets an account holds, either via rpc.getSACBalance or via getLedgerEntries, but if you don't know what they are, you don't know what to look up.
This is a product of Core's internal state: it's a key-value store, so you need to know the key in advance. RPC tries to avoid indexing data, hence its lack of understanding of what's being held. Unfortunately, too, because of the split in balances across trustlines vs. contracts, it's not trivial to determine and maintain from RPC's perspective at startup+run time. State archival makes this even more complicated. I don't think we can introduce asset tracking like this into RPC without a significant lift that makes it more Horizon-like.
However, I think it should be possible to provide something like holding: string[] which would be a list of assets of that the account holds (may hold? not sure, would have to think more). Then the user could fetch the balance values individually. Would that be a decent stop-gap?