Skip to content

Introduce a new getAssetBalance to RPC's Server to fetch any asset balance #1285

@Shaptic

Description

@Shaptic

Is your feature request related to a problem? Please describe.
Retrieving balances is unintuitive for users, because contract balances are represented in contract storage of the SAC, whereas account balances are represented in a trustline. While there are methods for each of these (getSACBalance and getTrustline, respectively), unifying them into a single method that works on both would be a better developer experience.

Describe the solution you'd like
A new method on rpc.Server:

class Server {
  public async getAssetBalance(for: string, of: Asset): Promise<Api.BalanceEntry>
}

where for is either a contract ID (C...), in which case you'd fetch the SAC's balance entry (via getSACBalance), or an account ID (G...), in which case you'd fetch the trustline entry (via getTrustline).

Describe alternatives you've considered
You can use the individual methods for each address type.

Additional context
#1282, discussion

Metadata

Metadata

Assignees

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions