Skip to content

Commit

Permalink
Merge branch 'main' into issue-644-crash-stream-reset
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Sep 2, 2024
2 parents 31b3787 + a221025 commit 0ea4d7c
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 139 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ We recommend the following minimum requirements, although you may be be able to

## Option 1: Running Ocean Nodes in Docker (recommended)

[This readme](deployment/README.md) is the recommended way to host a node and be eligible for incentives.
The other options are more recommended towards deleveopers that want to tinker.
[This readme](docs/dockerDeployment.md) is the recommended way to host a node and be eligible for incentives.
The other options are more recommended towards developers that want to tinker.

## Option 2: Running local build of Ocean Nodes in Docker

Build and run the node using Docker:
Run the following script to deploy node:

```bash
docker build -t ocean-node:mybuild . # Build the Docker image
# Make sure you include 0x at the start of the private key
docker run -e PRIVATE_KEY=0x_your_private_key_here ocean-node:mybuild # Start container
scripts/ocean-node-quickstart.sh
# OR
npm run quickstart
```

This command will run you through the process of setting up the environmental variables for your node.

## Option 3: Running Ocean Nodes with PM2

PM2 is a process manager that makes it easy to manage and monitor your Node.js applications.
Expand All @@ -40,13 +42,29 @@ PM2 is a process manager that makes it easy to manage and monitor your Node.js a
npm install -g pm2
```

2. Start the Ocean Node with PM2
2. Setup the environmental variables

Either use the script:

```
npm run envSetup
```

or setup the required environment variables manually:

```bash
export PRIVATE_KEY="0x_your_private_key_here"
```

The `PRIVATE_KEY` is the only mandatory environmental variable, you must include the `0x` at the front of your private key. Additional configurations can be set as needed. For all available configurations, refer to the [Environment Variables](docs/env.md) documentation.

3. Quick start the Ocean Node with PM2

```bash
pm2 start npm --name "ocean-node" -- run start
```

3. Monitor and Manage the Node
4. Monitor and Manage the Node

You can use the following PM2 commands to manage your Ocean Node:

Expand Down Expand Up @@ -119,3 +137,4 @@ Your node is now running, the dashboard will be available at `http://localhost:8
- [Network Configuration](docs/networking.md)
- [Logging & accessing logs](docs/networking.md)
- [Dashboard: Local development](dashboard/README.md)
- [Docker Deployment Guide](docs/dockerDeployment.md)
178 changes: 178 additions & 0 deletions dashboard/src/components/Admin/TransferFees.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import React, { useState } from 'react'
import {
TextField,
Button,
Alert,
Snackbar,
Dialog,
DialogTitle,
DialogContent,
DialogContentText,
DialogActions
} from '@mui/material'
import { useAdminContext } from '@context/AdminProvider'
import styles from './index.module.css'

export default function TransferFees() {
const [showChainInput, setShowTransferInput] = useState(false)
const [isLoading, setLoading] = useState(false)
const [chainId, setChainId] = useState<string>('')
const [tokenAddress, setTokenAddress] = useState<string>('')
const [tokenAmount, setTokenAmount] = useState<string>('')
const [destinationAddress, setDestinationAddress] = useState<string>('')
const { signature, expiryTimestamp } = useAdminContext()
const [error, setError] = useState<string | null>(null)
const [snackbarOpen, setSnackbarOpen] = useState(false)
const [dialogOpen, setDialogOpen] = useState(false)
const [responseMessage, setResponseMessage] = useState<string | null>(null)
const [txHash, setTxHash] = useState<string | null>(null)

const validateInputs = () => {
if (!chainId || !tokenAddress || !tokenAmount || !destinationAddress) {
setError('All fields are required.')
return false
}
if (isNaN(Number(tokenAmount))) {
setError('Token amount must be a number.')
return false
}
setError(null)
return true
}

async function transferFees() {
if (!validateInputs()) return

setLoading(true)
try {
const apiUrl = '/directCommand'
const response = await fetch(apiUrl, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({
command: 'collectFees',
chainId,
tokenAddress,
tokenAmount,
destinationAddress,
expiryTimestamp,
signature
})
})

if (response.status === 200) {
const jobData = await response.json()
if (jobData?.tx && jobData?.message) {
setTxHash(jobData.tx)
setResponseMessage(jobData.message)
setDialogOpen(true)
setSnackbarOpen(true)
setShowTransferInput(false)
}
} else {
setError('Error transferring fees. Please try again.')
}
} catch (error) {
console.error('error', error)
setError('Error transferring fees. Please try again.')
} finally {
setLoading(false)
}
}

const handleDialogClose = () => {
setDialogOpen(false)
}

return (
<div className={styles.column}>
<Button variant="text" onClick={() => setShowTransferInput(!showChainInput)}>
Transfer Fees
</Button>

{showChainInput && (
<div className={styles.filters}>
<TextField
label="Chain ID"
value={chainId}
onChange={(e) => setChainId(e.target.value)}
fullWidth
margin="normal"
variant="outlined"
type="number"
/>
<TextField
label="Token Address"
value={tokenAddress}
onChange={(e) => setTokenAddress(e.target.value)}
fullWidth
margin="normal"
variant="outlined"
/>
<TextField
label="Token Amount"
value={tokenAmount}
onChange={(e) => setTokenAmount(e.target.value)}
fullWidth
margin="normal"
variant="outlined"
type="number"
/>
<TextField
label="Destination Address"
value={destinationAddress}
onChange={(e) => setDestinationAddress(e.target.value)}
fullWidth
margin="normal"
variant="outlined"
/>
{error && <Alert severity="error">{error}</Alert>}
<Button
type="button"
onClick={transferFees}
variant="outlined"
disabled={isLoading}
fullWidth
>
Transfer Fees
</Button>
</div>
)}
<Snackbar
open={snackbarOpen}
autoHideDuration={6000}
onClose={() => setSnackbarOpen(false)}
message="Fees successfully transferred!"
/>
<Dialog
open={dialogOpen}
onClose={handleDialogClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{'Transfer Successful'}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
{responseMessage && (
<span>
{responseMessage} <br />
<strong style={{ marginTop: '10px', display: 'block' }}>
Transaction Hash:
</strong>{' '}
{txHash}
</span>
)}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={handleDialogClose} autoFocus>
Close
</Button>
</DialogActions>
</Dialog>
</div>
)
}
2 changes: 2 additions & 0 deletions dashboard/src/components/Admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ConnectButton } from '@rainbow-me/rainbowkit'
import Stack from '@mui/material/Stack'
import ReIndexChain from './ReindexChain'
import ReIndexTransaction from './ReindexTransaction'
import TransferFees from './TransferFees'

export default function AdminActions() {
const { generateSignature, signature, validTimestamp, admin } = useAdminContext()
Expand All @@ -31,6 +32,7 @@ export default function AdminActions() {
<DownloadLogs />
<ReIndexChain />
<ReIndexTransaction />
<TransferFees />
<StopNode />
</Stack>
)}
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/JobStatusPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getStatusColors } from '@/shared/utils/jobs'
import Alert from '@mui/material/Alert'

export default function JobStatusPanel(props: any) {
console.log('PROPS: ', props)
const color: string = props.job ? getStatusColors(props.job.status) : 'black'
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion dist/dashboard/404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><link rel="preload" href="/_next/static/css/28e16ff29a58442c.css" as="style" crossorigin=""/><link rel="stylesheet" href="/_next/static/css/28e16ff29a58442c.css" crossorigin="" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" crossorigin="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-fe817b75e2ea8908.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/framework-ca706bf673a13738.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/main-66d85fc6f7952338.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_app-8a605b014f26ab32.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_error-e4216aab802f5810.js" defer="" crossorigin=""></script><script src="/_next/static/TKOP_tQWDQuagCxlBxyhs/_buildManifest.js" defer="" crossorigin=""></script><script src="/_next/static/TKOP_tQWDQuagCxlBxyhs/_ssgManifest.js" defer="" crossorigin=""></script></head><body><div id="__next"><div data-rk=""><style>[data-rk]{--rk-blurs-modalOverlay:blur(0px);--rk-fonts-body:SFRounded, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--rk-radii-actionButton:9999px;--rk-radii-connectButton:12px;--rk-radii-menuButton:12px;--rk-radii-modal:24px;--rk-radii-modalMobile:28px;--rk-colors-accentColor:#0E76FD;--rk-colors-accentColorForeground:#FFF;--rk-colors-actionButtonBorder:rgba(0, 0, 0, 0.04);--rk-colors-actionButtonBorderMobile:rgba(0, 0, 0, 0.06);--rk-colors-actionButtonSecondaryBackground:rgba(0, 0, 0, 0.06);--rk-colors-closeButton:rgba(60, 66, 66, 0.8);--rk-colors-closeButtonBackground:rgba(0, 0, 0, 0.06);--rk-colors-connectButtonBackground:#FFF;--rk-colors-connectButtonBackgroundError:#FF494A;--rk-colors-connectButtonInnerBackground:linear-gradient(0deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.06));--rk-colors-connectButtonText:#25292E;--rk-colors-connectButtonTextError:#FFF;--rk-colors-connectionIndicator:#30E000;--rk-colors-downloadBottomCardBackground:linear-gradient(126deg, rgba(255, 255, 255, 0) 9.49%, rgba(171, 171, 171, 0.04) 71.04%), #FFFFFF;--rk-colors-downloadTopCardBackground:linear-gradient(126deg, rgba(171, 171, 171, 0.2) 9.49%, rgba(255, 255, 255, 0) 71.04%), #FFFFFF;--rk-colors-error:#FF494A;--rk-colors-generalBorder:rgba(0, 0, 0, 0.06);--rk-colors-generalBorderDim:rgba(0, 0, 0, 0.03);--rk-colors-menuItemBackground:rgba(60, 66, 66, 0.1);--rk-colors-modalBackdrop:rgba(0, 0, 0, 0.3);--rk-colors-modalBackground:#FFF;--rk-colors-modalBorder:transparent;--rk-colors-modalText:#25292E;--rk-colors-modalTextDim:rgba(60, 66, 66, 0.3);--rk-colors-modalTextSecondary:rgba(60, 66, 66, 0.6);--rk-colors-profileAction:#FFF;--rk-colors-profileActionHover:rgba(255, 255, 255, 0.5);--rk-colors-profileForeground:rgba(60, 66, 66, 0.06);--rk-colors-selectedOptionBorder:rgba(60, 66, 66, 0.1);--rk-colors-standby:#FFD641;--rk-shadows-connectButton:0px 4px 12px rgba(0, 0, 0, 0.1);--rk-shadows-dialog:0px 8px 32px rgba(0, 0, 0, 0.32);--rk-shadows-profileDetailsAction:0px 2px 6px rgba(37, 41, 46, 0.04);--rk-shadows-selectedOption:0px 2px 6px rgba(0, 0, 0, 0.24);--rk-shadows-selectedWallet:0px 2px 6px rgba(0, 0, 0, 0.12);--rk-shadows-walletLogo:0px 2px 16px rgba(0, 0, 0, 0.16);}</style><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"TKOP_tQWDQuagCxlBxyhs","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><link rel="preload" href="/_next/static/css/28e16ff29a58442c.css" as="style" crossorigin=""/><link rel="stylesheet" href="/_next/static/css/28e16ff29a58442c.css" crossorigin="" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" crossorigin="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-fe817b75e2ea8908.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/framework-ca706bf673a13738.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/main-66d85fc6f7952338.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_app-8a605b014f26ab32.js" defer="" crossorigin=""></script><script src="/_next/static/chunks/pages/_error-e4216aab802f5810.js" defer="" crossorigin=""></script><script src="/_next/static/TKOP_tQWDQuagCxlBxyhs/_buildManifest.js" defer="" crossorigin=""></script><script src="/_next/static/TKOP_tQWDQuagCxlBxyhs/_ssgManifest.js" defer="" crossorigin=""></script></head><body><div id="__next"><div data-rk=""><style>[data-rk]{--rk-blurs-modalOverlay:blur(0px);--rk-fonts-body:SFRounded, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--rk-radii-actionButton:9999px;--rk-radii-connectButton:12px;--rk-radii-menuButton:12px;--rk-radii-modal:24px;--rk-radii-modalMobile:28px;--rk-colors-accentColor:#0E76FD;--rk-colors-accentColorForeground:#FFF;--rk-colors-actionButtonBorder:rgba(0, 0, 0, 0.04);--rk-colors-actionButtonBorderMobile:rgba(0, 0, 0, 0.06);--rk-colors-actionButtonSecondaryBackground:rgba(0, 0, 0, 0.06);--rk-colors-closeButton:rgba(60, 66, 66, 0.8);--rk-colors-closeButtonBackground:rgba(0, 0, 0, 0.06);--rk-colors-connectButtonBackground:#FFF;--rk-colors-connectButtonBackgroundError:#FF494A;--rk-colors-connectButtonInnerBackground:linear-gradient(0deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.06));--rk-colors-connectButtonText:#25292E;--rk-colors-connectButtonTextError:#FFF;--rk-colors-connectionIndicator:#30E000;--rk-colors-downloadBottomCardBackground:linear-gradient(126deg, rgba(255, 255, 255, 0) 9.49%, rgba(171, 171, 171, 0.04) 71.04%), #FFFFFF;--rk-colors-downloadTopCardBackground:linear-gradient(126deg, rgba(171, 171, 171, 0.2) 9.49%, rgba(255, 255, 255, 0) 71.04%), #FFFFFF;--rk-colors-error:#FF494A;--rk-colors-generalBorder:rgba(0, 0, 0, 0.06);--rk-colors-generalBorderDim:rgba(0, 0, 0, 0.03);--rk-colors-menuItemBackground:rgba(60, 66, 66, 0.1);--rk-colors-modalBackdrop:rgba(0, 0, 0, 0.3);--rk-colors-modalBackground:#FFF;--rk-colors-modalBorder:transparent;--rk-colors-modalText:#25292E;--rk-colors-modalTextDim:rgba(60, 66, 66, 0.3);--rk-colors-modalTextSecondary:rgba(60, 66, 66, 0.6);--rk-colors-profileAction:#FFF;--rk-colors-profileActionHover:rgba(255, 255, 255, 0.5);--rk-colors-profileForeground:rgba(60, 66, 66, 0.06);--rk-colors-selectedOptionBorder:rgba(60, 66, 66, 0.1);--rk-colors-standby:#FFD641;--rk-shadows-connectButton:0px 4px 12px rgba(0, 0, 0, 0.1);--rk-shadows-dialog:0px 8px 32px rgba(0, 0, 0, 0.32);--rk-shadows-profileDetailsAction:0px 2px 6px rgba(37, 41, 46, 0.04);--rk-shadows-selectedOption:0px 2px 6px rgba(0, 0, 0, 0.24);--rk-shadows-selectedWallet:0px 2px 6px rgba(0, 0, 0, 0.12);--rk-shadows-walletLogo:0px 2px 16px rgba(0, 0, 0, 0.16);}</style><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">This page could not be found<!-- -->.</h2></div></div></div></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"TKOP_tQWDQuagCxlBxyhs","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
96 changes: 0 additions & 96 deletions dist/dashboard/_next/static/chunks/2477-ff31ed06ca3bb6b0.js

This file was deleted.

96 changes: 96 additions & 0 deletions dist/dashboard/_next/static/chunks/9130-ea274ad49571671c.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
self.__SSG_MANIFEST=new Set,self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB();
Loading

0 comments on commit 0ea4d7c

Please sign in to comment.