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

Provide a default list of network configs for developers to use #95

Open
LuqiPan opened this issue Mar 13, 2024 · 2 comments
Open

Provide a default list of network configs for developers to use #95

LuqiPan opened this issue Mar 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@LuqiPan
Copy link

LuqiPan commented Mar 13, 2024

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

@LuqiPan LuqiPan added the enhancement New feature or request label Mar 13, 2024
@samsiegart
Copy link
Contributor

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.

@dckc
Copy link
Member

dckc commented Mar 18, 2024

@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 ).

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

No branches or pull requests

3 participants