Agoric / ui-kit

Components and tools for building graphical UIs

Home Page:https://ui-kit-dwm.pages.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a default list of network configs for developers to use

LuqiPan opened this issue · comments

What is the Problem Being Solved?

Currently, in order to use the NetworkDropdown component, a developer would need to provide a list of network configs to the component, which can be quite a few lines of code. This would also create inconsistencies across different dapps because it is the developer's responsibility to find the rest/rpc endpoints, icon url, etc.

Ref: https://github.com/Agoric/ui-kit/tree/main/packages/react-components#network-dropdown

Description of the Design

One potential solution is to export consts with network configs for mainnet, emerynet, devnet, localchain, etc and a default list of network configs like const defaultNetworkConfigs = [mainnet, emerynet, devnet, localchain];

And the developer would only need to do

// import statements omitted

const NetworkSelect = () => {
  return <NetworkDropdown networkConfigs={defaultNetworkConfigs} />;
};

to use this component.

Security Considerations

This should help with security slightly as this repo would become the canonical place to provide network configs for all Agoric chains

Scaling Considerations

We should use load balanced DNS names, like https://main.api.agoric.net, to avoid overwhelming servers from a single validator

Test Plan

Open to any test plan

I considered this but didn't commit to it yet. I had a couple concerns but possibly they're not dealbreakers:

  • I'm uncertain about the stability of chain IDs for testnets. For example devnet is agoricdev-23 which implies 22 previous iterations. I'm not sure if we expect it to change more in the future, but if so we'd have to be on top of it, do a PR in ui-kit, and publish a new version to NPM each time.
  • For mainnet, cosmos-kit actually has some default RPCs that it gets from the chain registry. However, there's a lot of defunct/unreliable RPCs in that list, and it's similarly difficult to keep up-to-date. So, I made it so you have to specify your own RPCs which override the ones in the chain registry.

The dynamic nature of this info is the reason we have resources such as https://devnet.agoric.net/network-config, so it would probably be better to build something that works with a network-config URL. However, getting the chain info asynchronously in a static app is kinda messy with <ChainProvider>, I'm not sure how to approach it. Maybe in AgoricProvider we can render an empty AgoricContext.Provider until the the network config loads, then swap it out for the AgoricProviderLite when all the chain info is available.

@samsiegart the NetworkDropdown component in cosgov.org seems to address all that stuff.

I found it pretty nice to work with when playing around in https://github.com/agoric-labs/ag-power-tools/tree/dc-launchpad-ui , though I didn't use the exact code from cosgov... I tweaked it for explicit network access (#79 ).