Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
303 stars 191 forks source link

Orchestration Account - Query Balances #9610

Open 0xpatrickdev opened 2 days ago

0xpatrickdev commented 2 days ago

What is the Problem Being Solved?

This ticket captures three related items:

  1. CosmosOrchestrationAccount and LocalOrchestrationAccount do not have the getBalances interface implemented (only getBalance).

  2. LocalOrchestrationAccount uses the getBalance method from vats/localchain.js, which calls out to vbank. This presents a challenge if the caller is trying to work with an asset that's not recognized by vbank: https://github.com/Agoric/agoric-sdk/blob/b5cf8bd51585df36a72b65d7a1d66babd358b316/packages/vats/src/localchain.js#L113-L117 Also, it doesn't seem Bank (vbank) has an interface for enumerating purses. The implementation may require iterating over every known asset, which is not ideal.

  3. ChainAccount has getBalances and getBalance on its interface, but both of these are unimplemented.

Description of the Design

  1. getBalances() should be implemented on CosmosOrchestrationAccount and LocalOrchestrationAccount

  2. TBD. A potential path is to rename the current getBalance -> getPurseBalance and have the LOA use the LCA's .query method to make cosmos level queries.

  3. TBD. From a layering perspective, I'd argue that ChainAccount should not implement these interfaces. It should only be responsible for the Connection/Channel lifecycle and sending / receiving messages. Figuring out balances (a specific message to send) should be part of OrchestrationAccount layer.

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations