-
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: added banner for network-config notices #104
Conversation
Deploying dapp-econ-gov with Cloudflare Pages
|
43116b0
to
0869749
Compare
The branch was having issues creating a build. |
Cloudflare deployment logs are available here |
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 see there's no issue, I'm just wondering so I can understand the goals better, is there somewhere where this is written down like a doc or something? Most PRs especially features should have issues.
The CF build failed because react-components requires node 18 and it was set up to use 16. I just changed the setting and it builds successfully. However, the test workflow is failing, you just need to run prettier with yarn format
(or set up your IDE to run prettier automatically on-save).
The bundle size isn't great. That's why I thought importing react-components might be heavy-handed. How did you allot more memory to the node process? In the UI tutorial it suggests to do so with max-old-space-size
. But, it's easier to justify when an app is making full use of the AgoricProvider
and leap elements. For this I'm tempted to suggest just copying the component into this project because it's pretty simple. That's why I was wondering about an issue, because if the only goal was to add a banner to this dapp I think that approach would've been fine.
tailwind.config.cjs
Outdated
content: [ | ||
'./src/**/*.{js,jsx,ts,tsx}', | ||
'./public/index.html', | ||
'./node_modules/@agoric/react-components/**/*.{ts,tsx,mjs}', |
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.
We don't want to do this. It only works because there's no custom variables or themes in the banner component, so the default tailwind stuff provided in this project's config happens to work.
It should be:
import '@agoric/react-components/dist/style.css';
in src/App.tsx
, as documented in https://github.com/Agoric/ui-kit/tree/main/packages/react-components#integrating
src/config.ts
Outdated
@@ -50,3 +50,30 @@ export const rpcUrl = agoricNetSubdomain => | |||
*/ | |||
export const archivingAlternative = (chainName: string, defaultRpc: string) => | |||
chainName === 'agoric-3' ? 'https://main-a.rpc.agoric.net:443' : defaultRpc; | |||
|
|||
export const networkConfigs = { |
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 should be unnecessary after addressing the other comments
src/utils/networkConfig.ts
Outdated
notices?: NetworkNotice[]; | ||
}; | ||
|
||
export const loadNetworkConfig = (url: string): Promise<MinimalNetworkConfig> => |
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.
We already load the network config in suggestChain. I'd suggest moving that fetch into makeChainKit before suggestChain
is called, and changing suggestChain
to accept the loaded network config instead of doing the fetch itself. Then, add the loaded network config to the return value of makeChainKit
.
@@ -0,0 +1,16 @@ | |||
type NetworkNotice = { |
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.
These types should be imported from @agoric/react-components
src/App.tsx
Outdated
@@ -79,8 +82,11 @@ const App = (_props: Props) => { | |||
|
|||
const address = walletUtils.getWalletAddress(); | |||
|
|||
const config = useAtomValue(loadable(networkConfigPAtom)); |
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 new atom should be unnecessary with the other comments, the config should be accessible from:
const { chainKit } = useContext(WalletContext);
const config = chainKit.networkConfig; // Assuming you add this to chainKit as mentioned
src/store/app.ts
Outdated
@@ -32,3 +34,12 @@ export const displayFunctionsAtom = atom(get => { | |||
|
|||
/** Experimental feature flag. */ | |||
export const previewEnabledAtom = atom(_get => false); | |||
|
|||
const networkConfigAtom = atomWithStorage( |
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.
These new atoms should be unnecessary with other related suggestions
After @samsiegart's comments. made the following updates to the PR:
|
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.
Looks great thanks!
This PR adds the
NoticeBanner
in@agoric/react-components