Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fd61047
update codeowners (#138)
giurgiur99 Oct 20, 2025
b3fa76f
add phase 2 announcement
Oct 24, 2025
246e24e
add link class
Oct 24, 2025
b7516f5
update total nodes title
Oct 24, 2025
9f5a70b
add link class
Oct 24, 2025
b1ee124
Merge pull request #142 from oceanprotocol/feat/phase-2-announcement
andreip136 Oct 24, 2025
e49fa19
update label
bogdanfazakas Oct 24, 2025
14c077c
p2p poc
denisiuriet Oct 29, 2025
ce60d6e
refactor libp2p implementation
denisiuriet Oct 30, 2025
1561a45
create a version using CDN to use the connection directly on the dash…
denisiuriet Oct 31, 2025
c0e91ba
add discovery peer, set retry on dial, adjustments
denisiuriet Oct 31, 2025
c6ed86a
remove unnecessary code, refactor
denisiuriet Nov 2, 2025
5c9fa8f
remove unnecessary implementation
denisiuriet Nov 3, 2025
bb465ea
remove old nodeService implementation
denisiuriet Nov 3, 2025
c660a4f
remove unnecessary file
denisiuriet Nov 3, 2025
dc0ad3b
refactor
denisiuriet Nov 3, 2025
649312e
fix name mismatch
denisiuriet Nov 3, 2025
eddf3a4
remove CDN implementation, add a nodeJS test file
denisiuriet Nov 4, 2025
dacb8ee
add manually the addresses to peerStore
denisiuriet Nov 4, 2025
09c7b76
initialize the node only once adn refactor
denisiuriet Nov 4, 2025
68203dc
update bootstrap nodes
denisiuriet Nov 4, 2025
00f4c22
working version, removed connectionGater
denisiuriet Nov 5, 2025
05102c9
improvements, add types
denisiuriet Nov 5, 2025
e6e3ddf
remove any
denisiuriet Nov 5, 2025
4fea16f
branch cleanup
denisiuriet Nov 5, 2025
b199f1d
fixed conflicts
denisiuriet Nov 11, 2025
5ad185f
fix conflicts
denisiuriet Nov 11, 2025
cca4b76
add yarnrc
denisiuriet Nov 11, 2025
55d7f0d
fix package-lock
denisiuriet Nov 11, 2025
a413d1f
remove test page
denisiuriet Nov 11, 2025
128c2d3
add yarn.lock
denisiuriet Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @alexcos20 @bogdanfazakas @jamiehewitt15 @mariacarmina @paulo-ocean @mihaisc
* @alexcos20 @bogdanfazakas @mihaisc @giurgiur99 @denisiuriet @ndrpp @andreip136
12 changes: 11 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config) {
webpack(config, { isServer }) {
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
dgram: false,
dns: false
}
}
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
Expand Down
9,081 changes: 6,416 additions & 2,665 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"build": "NODE_ENV=production next build",
"start": "next start",
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx .",
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix"
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix",
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^15.1.0",
"@chainsafe/libp2p-yamux": "^6.0.2",
"@multiformats/multiaddr": "^12",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@mui/icons-material": "^7.3.4",
Expand All @@ -30,7 +34,16 @@
"normalize.css": "^8.0.1",
"react": "^18",
"react-dom": "^18",
"recharts": "^3.3.0"
"recharts": "^3.3.0",
"libp2p": "^1.8.0",
"it-pipe": "^3.0.1",
"@libp2p/bootstrap": "^10.1.1",
"@libp2p/identify": "^2.1.1",
"@libp2p/kad-dht": "^12.1.1",
"@libp2p/peer-id": "^4.1.4",
"@libp2p/ping": "^1.1.1",
"@libp2p/websockets": "^8.1.1",
"uint8arrays": "^4.0.6"
},
"devDependencies": {
"@svgr/webpack": "^8.1.0",
Expand All @@ -49,5 +62,8 @@
"prettier-plugin-organize-imports": "^4.3.0",
"typescript": "^5"
},
"overrides": {
"@multiformats/multiaddr": "^12"
},
"packageManager": "[email protected]+sha512.341db9396b6e289fecc30cd7ab3af65060e05ebff4b3b47547b278b9e67b08f485ecd8c79006b405446262142c7a38154445ef7f17c1d5d1de7d90bf9ce7054d"
}
93 changes: 93 additions & 0 deletions src/contexts/P2PContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import React, { createContext, useContext, useEffect, useState, useCallback } from 'react'
import { Libp2p } from 'libp2p'
import { initializeNode, sendCommandToPeer, getNodeEnvs } from '@/services/nodeService'
import { OCEAN_BOOTSTRAP_NODES } from '@/shared/consts/bootstrapNodes'

interface P2PContextType {
node: Libp2p | null
isReady: boolean
error: string | null
sendCommand: (peerId: string, command: any, protocol?: string) => Promise<any>
getEnvs: (peerId: string) => Promise<any>
}

const P2PContext = createContext<P2PContextType | undefined>(undefined)

export function P2PProvider({ children }: { children: React.ReactNode }) {
const [node, setNode] = useState<Libp2p | null>(null)
const [isReady, setIsReady] = useState(false)
const [error, setError] = useState<string | null>(null)

useEffect(() => {
let mounted = true
let peerCountInterval: NodeJS.Timeout

async function init() {
try {
console.log('P2PContext: Initializing libp2p node in background...')

const nodeInstance = await initializeNode(OCEAN_BOOTSTRAP_NODES)

if (mounted) {
setNode(nodeInstance)
setIsReady(true)

console.log('P2PContext: Node ready')
}
} catch (err: any) {
console.error('P2PContext: Failed to initialize node:', err)
if (mounted) {
setError(err.message)
}
}
}

init()

return () => {
mounted = false
}
}, [])

const sendCommand = useCallback(
async (peerId: string, command: any, protocol?: string) => {
if (!isReady || !node) {
throw new Error('Node not ready')
}
return sendCommandToPeer(peerId, command, protocol)
},
[isReady, node]
)

const getEnvs = useCallback(
async (peerId: string) => {
if (!isReady || !node) {
throw new Error('Node not ready')
}
return getNodeEnvs(peerId)
},
[isReady, node]
)

return (
<P2PContext.Provider
value={{
node,
isReady,
error,
sendCommand,
getEnvs
}}
>
{children}
</P2PContext.Provider>
)
}

export function useP2P() {
const context = useContext(P2PContext)
if (!context) {
throw new Error('useP2P must be used within P2PProvider')
}
return context
}
9 changes: 6 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import RootLayout from '@/components/Layout';
import { AppKit } from '@/context/app-kit';
import { StatsProvider } from '@/context/stats-context';
import { P2PProvider } from '@/contexts/P2PContext';
import '@/styles/globals.css';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import cx from 'classnames';
Expand Down Expand Up @@ -37,9 +38,11 @@ export default function App({ Component, pageProps }: AppProps) {
<QueryClientProvider client={queryClientRef.current}>
<StatsProvider>
<AppKit>
<RootLayout>
<Component {...pageProps} />
</RootLayout>
<P2PProvider>
<RootLayout>
<Component {...pageProps} />
</RootLayout>
</P2PProvider>
</AppKit>
</StatsProvider>
</QueryClientProvider>
Expand Down
Loading