-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(react-components)!: rework network dropdown and network config #109
Conversation
Deploying ui-kit with Cloudflare Pages
|
packages/react-components/README.md
Outdated
rpc: ['https://main.rpc.agoric.net'], | ||
}, | ||
}; | ||
|
||
const NetworkSelect = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this example looks a little silly now. Consider making it more realistic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added some props so it's less trivial. I didn't want to show all the agoricNetworkConfigs
and AgoricProvider
again because this section references agoricNetworkConfigs
and the top section mentions this component already.
label, | ||
maxHeight, | ||
size = 'md', | ||
appearance = 'bold', | ||
}: NetworkDropdownProps) => { | ||
const { networkConfig, setNetworkConfig } = useAgoricNetwork(); | ||
const { networkConfig, setNetworkConfig, agoricNetworkConfigs } = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this component mixing agoricNetwork
from chain-registry and this useAgoricNetwork
hook? I'd expect useAgoricNetwork
to abstract all network selection.
Same for nameForNetwork
and iconForNetwork
.
Is that reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just for display purposes, because NetworkConfig
doesn't require a chain name or icon:
I see what you mean, but I'd rather not store all that state in NetworkContext
just for displaying in the NetworkDropdown
. The data in NetworkConfig
is sufficient for selecting and connecting to the network, but the NetworkDropdown
needs more data to display the options.
fixes #96
Overview
Removes the
defaultNetworkConfig
prop fromAgoricProvider
in favor of:agoricNetworkConfigs
for specifying the available networks.defaultChainName
for selecting the default network.Now, instead of passing in
networkConfigs
to the network dropdown component, it just reads fromagoricNetworkConfigs
.Testing
Built successfully and linked locally with dapp-offer-up, tested the new API and switching between multiple networks.