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

add generateStaticParams to blockexplorer address and txHash #825

Merged
merged 6 commits into from
Apr 25, 2024

Conversation

technophile-04
Copy link
Collaborator

Description

An alternate solution to #824 (which doesn't require manual work)

As the error mentioned in #785 :

Error: Page "/blockexplorer/transaction/[txHash]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.

Therefore used generateStaticParams from NextJs.

export function generateStaticParams() {
  return [{ address: "0x0000000000000000000000000000000000000000" }];
}

having the above code in blockexplorers /[address] & /[txHash], when NextJs build the prod version it will generate 2 static dummy pages and won't fail.


Does having generateStaticParams break the blockexplorer when tinkering around on localnetwork ?

No, since dynamicPramas are enabled by default it should generate that page on demand.

So TLDR; nothing breaks (at least In my testing) there is no side effect to current version of SE-2 and also having output:export in next.config.ts works out of the box.

The downside of the above thing, lol we have to add very hacky code in our codebase.


Side quest :

Also an difference which I noticed on vercel deployment:

Main This Branch
Screenshot 2024-04-23 at 11 59 53 PM Screenshot 2024-04-24 at 12 01 01 AM

Notice how on main branch is explicitly mentioned it spun up serverless functions for handling /blockexplorer page but didn't mention about it on this branch deployment.

Since dynamicParams are enabled are by default it ideally should have shown right ?

If I go to logs of request I made, it shows their that its using serverless functions :

Demo image:

Screenshot 2024-04-24 at 12 01 33 AM

@technophile-04
Copy link
Collaborator Author

Just asking for a review to know what you guys think 🙌, also we can completely close this if it feels too hacky !

Need to update component name, and maybe having other default txHash instead of using address as txHash? Will update it later

@rin-st
Copy link
Member

rin-st commented Apr 23, 2024

btw we have next:build script in package.json but don't have next:serve. Probably it's worth to add it

@rin-st
Copy link
Member

rin-st commented Apr 23, 2024

Side quest :
Notice how on main branch is explicitly mentioned it spun up serverless functions for handling /blockexplorer page but didn't mention about it on this branch deployment.
Since dynamicParams are enabled are by default it ideally should have shown right ?

As I understand it's moved to ISR block
image

@technophile-04
Copy link
Collaborator Author

technophile-04 commented Apr 24, 2024

btw we have next:build script in package.json but don't have next:serve. Probably it's worth to add it

Yup, makes sense! updated it, Thanks Rinat !

@rin-st
Copy link
Member

rin-st commented Apr 24, 2024

Thanks @technophile-04 , gj! Yes, looking a bit hacky but a much better solution than #824

Copy link
Member

@carletex carletex left a comment

Choose a reason for hiding this comment

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

I like this approach too. Yes, a bit hacky, but the hacky code is on the blockexplorer, a component that people are not usually going to modify.

@technophile-04
Copy link
Collaborator Author

Merging this! Thanks all for reviews and suggestion !

@technophile-04 technophile-04 merged commit 377ec51 into main Apr 25, 2024
1 check passed
@technophile-04 technophile-04 deleted the generateStaticParam-blockexplorer branch April 25, 2024 11: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.

3 participants