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

feat: added banner for network-config notices #104

Merged
merged 5 commits into from
Jun 4, 2024

Conversation

frazarshad
Copy link
Contributor

@frazarshad frazarshad commented May 29, 2024

This PR adds the NoticeBanner in @agoric/react-components

image

Copy link

cloudflare-workers-and-pages bot commented May 30, 2024

Deploying dapp-econ-gov with  Cloudflare Pages  Cloudflare Pages

Latest commit: e6d9ee4
Status: ✅  Deploy successful!
Preview URL: https://b81ff2c2.dapp-econ-gov.pages.dev
Branch Preview URL: https://feat-add-notice-banner.dapp-econ-gov.pages.dev

View logs

@frazarshad frazarshad force-pushed the feat/add-notice-banner branch from 43116b0 to 0869749 Compare May 31, 2024 12:17
@frazarshad
Copy link
Contributor Author

The branch was having issues creating a build.
When tested on my machine, the node process ran out of memory, when i allotted more memory to it, the build passed but the chunk size has increased drastically
@samsiegart
image

@frazarshad frazarshad requested a review from samsiegart May 31, 2024 13:43
@frazarshad frazarshad marked this pull request as ready for review May 31, 2024 13:43
Copy link

github-actions bot commented May 31, 2024

Cloudflare deployment logs are available here

Copy link
Contributor

@samsiegart samsiegart left a 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.

content: [
'./src/**/*.{js,jsx,ts,tsx}',
'./public/index.html',
'./node_modules/@agoric/react-components/**/*.{ts,tsx,mjs}',
Copy link
Contributor

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 = {
Copy link
Contributor

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

notices?: NetworkNotice[];
};

export const loadNetworkConfig = (url: string): Promise<MinimalNetworkConfig> =>
Copy link
Contributor

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 = {
Copy link
Contributor

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));
Copy link
Contributor

@samsiegart samsiegart May 31, 2024

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(
Copy link
Contributor

@samsiegart samsiegart May 31, 2024

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

@frazarshad
Copy link
Contributor Author

After @samsiegart's comments. made the following updates to the PR:

  • removed dependancy on react-components since it drastically increased the build size
  • used networkConfig that was already being fetched in chainKit

@frazarshad frazarshad requested a review from samsiegart June 3, 2024 13:40
Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great thanks!

@frazarshad frazarshad merged commit 0f710bd into main Jun 4, 2024
3 checks passed
@frazarshad frazarshad deleted the feat/add-notice-banner branch June 4, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants