-
Notifications
You must be signed in to change notification settings - Fork 950
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
azf20
wants to merge
17
commits into
scaffold-eth:main
Choose a base branch
from
azf20:ipfs-bgipfs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,574
−152
Open
Use bgipfs for upload #1039
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3da1015
Add config for yarn ipfs
portdeveloper 5fef988
Show errors in yarn ipfs
portdeveloper 470f9c1
Fix formatting in next.config.js
portdeveloper 1547922
Update deploy-ipfs to use nifty ink
portdeveloper 6026051
Change deploy-ipfs.js to deploy-ipfs.mjs
portdeveloper f7cbc7c
Remove unused stuff from yarn.lock
portdeveloper 0c139a0
Fix build flag not getting detected
portdeveloper 8f06d03
Merge branch 'main' into feat/ipfs-manual
portdeveloper faa4150
Merge branch 'main' into feat/ipfs-manual
portdeveloper 247edb4
feat: bgipfs for upload
azf20 b8a3a53
using proxy instead of auth
azf20 9f56153
replace with community endpoint (uses cf worker)
azf20 3efe720
update + one command
azf20 0a8de9e
use latest endpoint
azf20 b215ff9
fix url & pass through cid
azf20 ea4d9a6
yarn install changes
technophile-04 aafd627
resolve merge conflict
technophile-04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ yarn-error.log* | |
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
ipfs-upload.config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
"start": "next dev", | ||
"vercel": "vercel --build-env YARN_ENABLE_IMMUTABLE_INSTALLS=false --build-env ENABLE_EXPERIMENTAL_COREPACK=1 --build-env VERCEL_TELEMETRY_DISABLED=1", | ||
"vercel:yolo": "vercel --build-env YARN_ENABLE_IMMUTABLE_INSTALLS=false --build-env ENABLE_EXPERIMENTAL_COREPACK=1 --build-env NEXT_PUBLIC_IGNORE_BUILD_ERROR=true --build-env VERCEL_TELEMETRY_DISABLED=1", | ||
"ipfs:init": "bgipfs upload config init -u https://www.bgipfs.com/api/ipfs-proxy", | ||
"ipfs": "NEXT_PUBLIC_IPFS_BUILD=true yarn build && yarn bgipfs upload out && echo '🚀 Upload complete! Your site is now available at: https://gateway.bgipfs.com/ipfs/${cid}'", | ||
"vercel:login": "vercel login" | ||
}, | ||
"dependencies": { | ||
|
@@ -23,6 +25,7 @@ | |
"blo": "^1.2.0", | ||
"burner-connector": "0.0.9", | ||
"daisyui": "4.12.10", | ||
"kubo-rpc-client": "^5.0.2", | ||
"next": "^14.2.11", | ||
"next-nprogress-bar": "^2.3.13", | ||
"next-themes": "^0.3.0", | ||
|
@@ -42,6 +45,7 @@ | |
"@types/react": "^18.3.5", | ||
"abitype": "1.0.6", | ||
"autoprefixer": "^10.4.20", | ||
"bgipfs": "^0.0.4", | ||
"eslint": "^8.57.1", | ||
"eslint-config-next": "^14.2.15", | ||
"eslint-config-prettier": "^8.10.0", | ||
|
@@ -54,4 +58,4 @@ | |
"vercel": "^39.1.3" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { create } from "kubo-rpc-client"; | ||
import { globSource } from "kubo-rpc-client"; | ||
import { dirname, join } from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const ipfsConfig = { | ||
host: "ipfs.nifty.ink", | ||
port: 3001, | ||
protocol: "https", | ||
timeout: 250000, | ||
}; | ||
|
||
async function addDirectoryToIpfs(path) { | ||
console.log("📦 Adding directory to IPFS via Nifty Ink..."); | ||
|
||
try { | ||
const ipfs = create(ipfsConfig); | ||
|
||
// Track the root directory CID | ||
let rootCid = null; | ||
|
||
// Add the entire directory to IPFS | ||
for await (const result of ipfs.addAll(globSource(path, "**/*"), { | ||
pin: true, | ||
wrapWithDirectory: true, // This is key - it wraps all files in a directory | ||
})) { | ||
if (result.path === "") { | ||
// This is the root directory entry | ||
rootCid = result.cid; | ||
} else { | ||
console.log(`Added ${result.path} - CID: ${result.cid}`); | ||
} | ||
} | ||
|
||
if (!rootCid) { | ||
throw new Error("Failed to get root directory CID"); | ||
} | ||
|
||
return rootCid.toString(); | ||
} catch (error) { | ||
console.error("Error adding directory to IPFS:", error); | ||
throw error; | ||
} | ||
} | ||
|
||
async function main() { | ||
// Get the path to the out directory | ||
const outDir = join(__dirname, "..", "out"); | ||
|
||
console.log("🚀 Uploading to Nifty Ink IPFS..."); | ||
const cid = await addDirectoryToIpfs(outDir); | ||
|
||
console.log("\n✨ Upload complete! Your site is now available at:"); | ||
console.log(`🔗 Nifty Ink Gateway: https://gateway.nifty.ink:42069/ipfs/${cid}`); | ||
console.log("\n💡 Note: Your content is being served through the Nifty Ink IPFS gateway"); | ||
} | ||
|
||
main().catch(err => { | ||
console.error("Error uploading to IPFS:", err); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are not using this flie right? Lets remove it