Open samsiegart opened 1 year ago
After attempting to implement this I believe it would be too difficult for me to accomplish without guidance from the Keplr team.
My current understanding is as follows - there's this view which renders the user's available assets in a list as depicted:
There is a ChainStore
which has a list of chainInfos
, which are key-value stores for each registered chain in the extension. Each chainInfo
has a currencies list which contains all the user's known currencies on the chain. The view collates all these currencies together with their balances to show the final list.
How is that currencies list populated? From what I gather there's multiple pieces. Some currencies are hardcoded from the suggestChain API. There's also a service that appears to let you add tokens from a cosmwasm contract as depicted:
There's also a service that seems to query each chain in the background and find assets in the user's bank that aren't currently stored in the ChainStore
.
It's possible that we could add another service that queries published.wallet.<address>.current
, checks the user's purses, queries agoricNames.brand
and boardAux.<boardId>
for each new brand, and stores the display info in the ChainStore
. However, doing that initial query for every chain might be too expensive, so maybe there could be a new parameter in suggestChain
to signal that such a query is necessary.
And, that's just for registering the currencies. For getting the balances, the extension seems to use this service which iterates over all the registered currencies and queries their balances. The queries are implemented in another package, for example this is the implementation for querying the balance of a cosmwasm token. For ERTP assets, all balances would come from a single query published.wallet.<address>.current
, so we'd probably want to add special handling for that in huge-queries.
Also, NFT assets cannot be displayed the same way as other AppCurrency
s, and aren't compatible with the "send" or "ibc transfer" features, so the interface and UI would have to be adapted to accommodate this.
All this complexity has deterred me from getting an implementation working, as I have low confidence I would come up with the right pattern without guidance from the Keplr team. It's possible that they would suggest a different approach altogether, for example sequestering NFTs in their own separate view. After talking with @turadg we decided I should unassign this for now and we should consult Keplr before moving forward.
What is the Problem Being Solved?
https://github.com/Agoric/agoric-sdk/issues/8201 but for the web extension