Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balances Fetching Service #3463

Open
cor opened this issue Jan 8, 2025 · 0 comments
Open

Balances Fetching Service #3463

cor opened this issue Jan 8, 2025 · 0 comments
Assignees

Comments

@cor
Copy link
Contributor

cor commented Jan 8, 2025

Problem

There is no standardized way to fetch balances from chains for assets. For EVM assets, there are multiple custom APIs that are extensions of normal RPC endpoints: https://github.com/unionlabs/union/blob/main/app/src/lib/queries/balance/index.ts

These do not have a uniform interface, and differ per provider.

There is also no cross-ecosystem standardized way for fetching balances. For EVM, Cosmos, and Move we have different methods of fetching balances.

We currently handle all of these in the frontend, but this has several disadvantages:

  1. When working with the TypeScript SDK and GraphQL API, devs do not have access to this core functionality.
  2. Because the logic of fetching these balances happens on the frontend, we have no way of monitoring and alerting if requests are successful (they frequently broke on testnet-8)
  3. The frontend needs to write adapters for different kind of responses and make them uniform across ecosystems, something that's better done on the backend
  4. if the app user has a slow internet connection, then the loop of "try provider 1, if it does not work, go to provider 2" is slow.

Solution

We move this logic into a simple Rust service that we can monitor.

The api will be something like

GET /balances/<chain_id>/<address>

and return [ { denom: 0xabc..., amount: 140n, decimals: 18, symbols: 4n, supported: true } ]

in a uniform manner, regardless of execution environment and underlying provider used.

Optionally, we can add a batch request GET /all_balances/<evm_address>/<cosmos_address>/<move_address>

to in 1 request get all sendable balances.

Hasura integration for v2

Through hasuras remote schemas this can be directly integrated into graphql.union.buid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants