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

Use bgipfs for upload #1039

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Use bgipfs for upload #1039

wants to merge 17 commits into from

Conversation

azf20
Copy link

@azf20 azf20 commented Jan 25, 2025

Description

To upload a site to BuidlGuidl's IPFS node, in the nextjs package:

yarn ipfs:init
yarn ipfs

These commands wrap initialisation and upload commands from bgipfs. This uses a default proxy endpoint (no auth required at this time)

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

This is great Adam!! was just testing and while running yarn ipfs I got the below error:

ipfs error
󰂃 6% ❯ yarn ipfs
  ▲ Next.js 14.2.11

   Creating an optimized production build ...

🌼   daisyUI 4.12.10
├─ ✔︎ 2 themes added             https://daisyui.com/docs/themes
╰─ ❤︎ Support daisyUI project:   https://opencollective.com/daisyui

 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
   Generating static pages (0/8)  [=   ](node:6527) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6534) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6536) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6535) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6537) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6533) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 ✓ Generating static pages (8/8)
 ✓ Collecting build traces
   Finalizing page optimization  ..(node:6609) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 ✓ Finalizing page optimization

Route (app)                                                                  Size     First Load JS
┌ ○ /                                                                        1.65 kB         432 kB
├ ○ /_not-found                                                              879 B          89.7 kB
├ ○ /blockexplorer                                                           1.4 kB          435 kB
├ ● /blockexplorer/address/[address]                                         235 B           434 kB
├   └ /blockexplorer/address/0x0000000000000000000000000000000000000000
├ ● /blockexplorer/transaction/[txHash]                                      1.42 kB         432 kB
├   └ /blockexplorer/transaction/0x0000000000000000000000000000000000000000
└ ○ /debug                                                                   7.35 kB         438 kB
+ First Load JS shared by all                                                88.8 kB
  ├ chunks/7023-38a60bcaec288bbe.js                                          31.9 kB
  ├ chunks/fd9d1056-805ccda7fca25131.js                                      53.6 kB
  └ other shared chunks (total)                                              3.32 kB


○  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses getStaticProps)

IPFS add error: {
  error: HTTPError: Request Entity Too Large

  FUNCTION_PAYLOAD_TOO_LARGE

  bom1::vhn88-1737877490716-8ee1864a251b

      at Object.errorHandler [as handleError] (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/lib/core.js:81:17)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async Client.fetch (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/lib/http.js:80:21)
      at async KuboRPCClient.addAll (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/add-all.js:21:25)
      at async Object.directory (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/ipfs-uploader/dist/NodeUploader.js:90:42)
      at async UploadCommand.run (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/bgipfs/dist/commands/upload/index.js:50:19)
      at async UploadCommand._run (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/command.js:312:22)
      at async Config.runCommand (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/config/config.js:435:25)
      at async run (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/main.js:96:16)
      at async file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/bgipfs/bin/run.js:5:1 {
    response: Response {
      status: 413,
      statusText: 'Request Entity Too Large',
      headers: Headers {
        'cache-control': 'public, max-age=0, must-revalidate',
        'content-length': '93',
        'content-type': 'text/plain; charset=utf-8',
        date: 'Sun, 26 Jan 2025 07:44:52 GMT',
        server: 'Vercel',
        'strict-transport-security': 'max-age=63072000',
        'x-matched-path': '/api/ipfs-proxy/add',
        'x-vercel-error': 'FUNCTION_PAYLOAD_TOO_LARGE',
        'x-vercel-id': 'bom1::vhn88-1737877490716-8ee1864a251b'
      },
      body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true },
      bodyUsed: true,
      ok: false,
      redirected: false,
      type: 'basic',
      url: 'https://www.bgipfs.com/api/ipfs-proxy/add?stream-channels=true&wrap-with-directory=true&cid-version=1&progress=false'
    }
  },
  message: 'Request Entity Too Large\n' +
    '\n' +
    'FUNCTION_PAYLOAD_TOO_LARGE\n' +
    '\n' +
    'bom1::vhn88-1737877490716-8ee1864a251b\n',
  stack: 'HTTPError: Request Entity Too Large\n' +
    '\n' +
    'FUNCTION_PAYLOAD_TOO_LARGE\n' +
    '\n' +
    'bom1::vhn88-1737877490716-8ee1864a251b\n' +
    '\n' +
    '    at Object.errorHandler [as handleError] (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/lib/core.js:81:17)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n' +
    '    at async Client.fetch (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/lib/http.js:80:21)\n' +
    '    at async KuboRPCClient.addAll (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/kubo-rpc-client/dist/src/add-all.js:21:25)\n' +
    '    at async Object.directory (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/ipfs-uploader/dist/NodeUploader.js:90:42)\n' +
    '    at async UploadCommand.run (file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/bgipfs/dist/commands/upload/index.js:50:19)\n' +
    '    at async UploadCommand._run (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/command.js:312:22)\n' +
    '    at async Config.runCommand (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/config/config.js:435:25)\n' +
    '    at async run (/Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/@oclif/core/lib/main.js:96:16)\n' +
    '    at async file:///Users/shivbhonde/Desktop/github/scaffold-eth-2/packages/nextjs/node_modules/bgipfs/bin/run.js:5:1'
}
{
  success: false,
  cid: '',
  error: 'Request Entity Too Large\n' +
    '\n' +
    'FUNCTION_PAYLOAD_TOO_LARGE\n' +
    '\n' +
    'bom1::vhn88-1737877490716-8ee1864a251b\n'
}
 ›   Error: Upload failed: Upload failed

@azf20
Copy link
Author

azf20 commented Jan 26, 2025

thanks @technophile-04! that's hitting a vercel function size limit, pushed a new approach which is using a cf worker

@portdeveloper
Copy link
Contributor

Everything works great! Amazing work @azf20 !!!

This is a lot faster than my code and it is cleaner as well!

Here is the link to my app deployed with Adam's code: https://bafybeiduwahy6nmpkpvcebtctyplxmdgjvlrpwkcnrzi6zqaizse64muna.ipfs.gateway.bgipfs.com/

And here it is after adding it to my ens records: https://pallas-athena.eth.limo/

And it just works!

@technophile-04
Copy link
Collaborator

THanks for the updates!! Yes works great now!!

Can you run yarn install once and push those commits? Because when I switch to this branch and do yarn isntall it gives me this changes:

changes image

Screenshot 2025-01-27 at 5 10 53 PM

Also a question, is there a way we could make this just on command? Instead of it developer needing to run two separate commands? Like just yarn ipfs should do it all?

Maybe we just un-gitignore the ipfs-upload.config.json? and ship that file with SE-2 directly? Since I see there is no app specific config init and seems same config for all app? (I am sure I am missing something)

Small improvement nitpicks:

While logging the link from bigipfs CLI can we log the whole link in the end?

Screenshot 2025-01-27 at 5 05 06 PM

So that the developer doesn't need to construct the whole link himself manually?

Another nitpick maybe we could handle it in future not at all necessary now:

Unfurl are not resolving:

Screenshot 2025-01-27 at 5 16 54 PM

App link: https://bafybeihijk22a4rnuxrv26ulacy3r3qzkjcbnt25atg7aqnlwqmyddblk4.ipfs.gateway.bgipfs.com/

@azf20
Copy link
Author

azf20 commented Jan 28, 2025

OK great! Been making some changes to the underlying infrastructure so let's coordinate when this rolls out!

Copy link
Collaborator

@Pabl0cks Pabl0cks left a comment

Choose a reason for hiding this comment

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

Great job @azf20! This is really awesome 🔥🙏

I hate to be the "Windows guy" here... tried to run yarn install and is throwing some errors :

Error on Git Bash when trying to `yarn install`
➤ YN0001: │ Error: ENOENT: no such file or directory, open
    at Object.open (node:fs:565:11)
    at Object.writeFile (node:fs:2309:6)
    at node:internal/util:442:7
    at new Promise (<anonymous>)
    at Object.writeFile (node:internal/util:428:12)
    at xze (E:\GitHub\scaffold-eth-2\.yarn\releases\yarn-3.2.3.cjs:236:193779)
    at async Promise.all (index 0)
    at async UL (E:\GitHub\scaffold-eth-2\.yarn\releases\yarn-3.2.3.cjs:236:1927
49)
    at async Gze (E:\GitHub\scaffold-eth-2\.yarn\releases\yarn-3.2.3.cjs:710:128
75)
    at async Oze (E:\GitHub\scaffold-eth-2\.yarn\releases\yarn-3.2.3.cjs:710:118
46)
➤ YN0000: └ Completed in 30s 834ms
➤ YN0000: Failed with errors in 38s 447ms

If I try to install bgipfs package manually, I get these error logs:

2025-02-02T18_17_04_844Z-debug-0.log

When I use WSL on my Windows machine, yarn install + yarn ipfs are working out of the box 👌:

✓ Configuration file initialized successfully.
✓ File uploaded. CID: bafybeidxejqgov2pso47erm4uzjxa2ddo2jao7ge2ews22mvwdi5m2jepi
🚀 Upload complete! Your site is now available at: https://gateway.bgipfs.com/ipfs/${cid}

Just as nitpicks:

  • cid is not getting replaced (maybe is a WSL issue)
  • The gateway url doesn't seem to work when I try to open it on chrome/brave

@azf20
Copy link
Author

azf20 commented Feb 3, 2025

hey thanks so much @Pabl0cks! Good catch, the gateway url hadn't been updated, and it was just printing {cid} which I agree is less friendly than it might be - pushed a fix for both of those things. I'm not sure what is required for better Windows support

@portdeveloper
Copy link
Contributor

I believe that we should focus only on WSL for windows support as everyone is moving away from git bash to WSL.

@carletex
Copy link
Member

carletex commented Feb 4, 2025

I believe that we should focus only on WSL for windows support as everyone is moving away from git bash to WSL.

I'm not against this! Seems like a pretty common practice and will save us from a lot of trouble. We'd just to state it clearly in the Docs.

Let's see what others think too

@technophile-04 technophile-04 changed the base branch from feat/ipfs-manual to main February 6, 2025 11:43
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are not using this flie right? Lets remove it

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

Works like a charm! Thanks @azf20! Just requested a small changes at https://github.com/scaffold-eth/scaffold-eth-2/pull/1039/files#r1944592425 but other than that everything looks great!

I'm not against this! Seems like a pretty common practice and will save us from a lot of trouble. We'd just to state it clearly in the Docs.

Yup I think mentioning in docs should be sufficient 🙌

Copy link
Member

@rin-st rin-st left a comment

Choose a reason for hiding this comment

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

Works great for me too!

I'm not against this! Seems like a pretty common practice and will save us from a lot of trouble. We'd just to state it clearly in the Docs.

Agree!

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.

6 participants