Skip to content

Commit

Permalink
added node offering
Browse files Browse the repository at this point in the history
  • Loading branch information
CoNETProject committed Dec 17, 2023
1 parent bccd86d commit f29005b
Show file tree
Hide file tree
Showing 25 changed files with 1,561 additions and 754 deletions.
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@
"@conet.project/seguro-worker-lib": "0.13.9",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.19",
"@mui/material": "^5.14.19",
"@mui/base": "5.0.0-beta.25",
"@mui/material-next": "^6.0.0-alpha.111",
"@mui/lab": "^5.0.0-alpha.154",
"@mui/icons-material": "^5.15.0",
"@mui/material": "^5.15.0",
"@mui/base": "^5.0.0-beta.27",
"@mui/material-next": "^6.0.0-alpha.113",
"@mui/lab": "^5.0.0-alpha.156",
"primereact": "^10.2.1",
"@react-icons/all-files": "^4.1.0",
"@tippyjs/react": "^4.2.6",
"dayjs": "^1.11.10",
"framer-motion": "^10.16.10",
"framer-motion": "^10.16.16",
"get-port": "^7.0.0",
"react-draggable": "^4.4.6",
"react-hot-toast": "^2.4.1",
"react-loader-spinner": "^5.4.5",
"react-loader-spinner": "^6.1.0",
"react-lottie-player": "^1.5.5",
"react-router-dom": "^6.20.0",
"react-router-dom": "^6.21.0",
"uuid": "^9.0.1",
"web-vitals": "^3.5.0",
"country-flag-icons": "^1.5.9",
Expand All @@ -59,30 +59,30 @@
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-brands-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@reduxjs/toolkit": "^1.9.7",
"@storybook/addon-actions": "^7.6.3",
"@storybook/addon-essentials": "^7.6.3",
"@storybook/addon-links": "^7.6.3",
"@storybook/node-logger": "^7.6.3",
"@storybook/preset-create-react-app": "^7.6.3",
"@storybook/react": "^7.6.3",
"@reduxjs/toolkit": "^2.0.1",
"@storybook/addon-actions": "^7.6.5",
"@storybook/addon-essentials": "^7.6.5",
"@storybook/addon-links": "^7.6.5",
"@storybook/node-logger": "^7.6.5",
"@storybook/preset-create-react-app": "^7.6.5",
"@storybook/react": "^7.6.5",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.1",
"@types/react": "^18.2.39",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.4",
"@types/react": "^18.2.45",
"@types/react-document-meta": "^3.0.5",
"@types/react-dom": "^18.2.17",
"@types/react-dom": "^18.2.18",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.32",
"@types/styled-components": "^5.1.34",
"@types/uuid": "^9.0.7",
"@types/react-swipeable-views": "^0.13.5",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.2",
"buffer": "^6.0.3",
"cors": "^2.8.5",
"electron":"^27.1.3",
"electron":"^28.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.18.2",
"modern-normalize": "^2.0.0",
Expand All @@ -91,12 +91,12 @@
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"react-intl": "^6.5.5",
"react-redux": "^8.1.3",
"react-redux": "^9.0.4",
"react-scripts": "^5.0.1",
"styled-components": "^6.1.1",
"typescript": "^5.3.2",
"typescript": "^5.3.3",
"wait-on": "^7.2.0",
"caniuse-lite": "^1.0.30001565",
"caniuse-lite": "^1.0.30001570",
"react-swipeable-views": "^0.14.0",
"react-d3-speedometer": "^1.1.0",
"react-gauge-chart": "^0.4.1",
Expand Down
89 changes: 68 additions & 21 deletions src/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {v4} from 'uuid'
import {logger} from '../components/App/logger'
import useAppState from "../store/appState/useAppState"
import store from '../store/store'

type WorkerCommandErrorType = 'NOT_READY'|'INVALID_DATA'|
'NO_UUID'|'INVALID_COMMAND'|'OPENPGP_RUNNING_ERROR'|
Expand All @@ -12,7 +13,8 @@ type WorkerCommandType = 'READY'|'encrypt_TestPasscode'|'getCONETBalance'|'getRe
'newProfile'|'storeProfile'|'invitation'|'WORKER_MESSAGE'|'startProxy'|
'isAddress'|'getFaucet'|'syncAsset'|'sendAsset'|'getUSDCPrice'|
'buyUSDC'|'mintCoNETCash'|'getSINodes'|'getRecipientCoNETCashAddress'|
'getUserProfile'|'sendMessage'|'setRegion'|'ipaddress'
'getUserProfile'|'sendMessage'|'setRegion'|'ipaddress'|'startLiveness'|'stopLiveness'|
'isLivenessRunning'

export type WorkerCallStatus = 'SUCCESS' | 'NOT_READY' | 'UNKNOWN_COMMAND' |
'TIME_OUT' | 'SYSTEM_ERROR'
Expand All @@ -29,7 +31,7 @@ export type SeguroNetworkStatus = WorkerCallStatus |



const ver = '0.0.12'
const ver = '0.0.13'



Expand Down Expand Up @@ -170,7 +172,6 @@ export const postPasscode: (passcode: string) => Promise<null|boolean|WorkerComm
}

export const testLocalServer = async () => {

const result = await postUrl(`http://localhost:3001/ver`, '', false)
if (result) {
if (result.ver === ver) {
Expand All @@ -183,16 +184,16 @@ export const testLocalServer = async () => {
return null
}

const postMessage = (cmd: WorkerCommand, resolve: (value: StartWorkerResolveForAPI | PromiseLike<StartWorkerResolveForAPI>) => void) => {
const postMessage = (cmd: WorkerCommand, close: boolean, resolve: any, Callback?:(err: string, data: string[]) => void) => {

const channel = new BroadcastChannel(channelWrokerListenName)
const listenChannel = new BroadcastChannel(cmd.uuid)

const kk = (e: any) => {
listeningChannel(e.data, cmd.uuid, resolve)
listeningChannel(e.data, cmd.uuid)
}

const listeningChannel = (data: any, uuid: string, resolve: (value: StartWorkerResolveForAPI | PromiseLike<StartWorkerResolveForAPI>) => void) => {
const listeningChannel = (data: any, uuid: string) => {
let cmd: WorkerCommand

try{
Expand All @@ -201,14 +202,28 @@ const postMessage = (cmd: WorkerCommand, resolve: (value: StartWorkerResolveFor
// 'searchPage.tsx', 'checkLinkedUrl ifram is NULL'
return logger ('class CONET_Platfrom_API', `listeningChannel JSON.parse(data) Error`)
}

listenChannel.close()
if (close) {
listenChannel.close()
}


if (cmd.err) {
return resolve(['SYSTEM_ERROR', cmd.data])
if (resolve) {
return resolve(['SYSTEM_ERROR', cmd.data])
}
if (Callback) {
return Callback('SYSTEM_ERROR', [])
}
return console.log (`postMessage Callback && resolve all null`, cmd.err)
}
if ( resolve ) {
return resolve(['SUCCESS', cmd.data])
}
if (Callback) {
return Callback('', cmd.data)
}
return console.log (`postMessage Callback && resolve all null`, cmd.data)

return resolve(['SUCCESS', cmd.data])
}

listenChannel.addEventListener('message', kk)
Expand All @@ -223,7 +238,7 @@ export const faucet: () => Promise < StartWorkerResolveForAPI > = () => {
data: [],
uuid: v4()
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -233,7 +248,7 @@ export const getCONETBalance: () => Promise < StartWorkerResolveForAPI > = () =>
cmd: 'getCONETBalance',
uuid: v4()
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -244,7 +259,7 @@ export const setRegion: (region: regionType) => Promise < StartWorkerResolveForA
uuid: v4(),
data: [region]
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -255,7 +270,7 @@ export const startProxy: () => Promise < StartWorkerResolveForAPI > = () => {
uuid: v4(),
data: []
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -266,7 +281,7 @@ export const getRegiestNodes : () => Promise < StartWorkerResolveForAPI > = () =
uuid: v4(),
data: []
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -278,7 +293,7 @@ export const createPasscode : (passcord: string, local: string) => Promise < Sta
uuid: v4(),
data: [passcord, local]
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -289,7 +304,7 @@ export const getIPaddress: () => Promise < StartWorkerResolveForAPI > = () => {
uuid: v4(),
data: []
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

Expand All @@ -301,16 +316,48 @@ export const encrypt_deletePasscode : () => Promise < StartWorkerResolveForAPI >
uuid: v4(),
data: []
}
return postMessage (cmd, resolve)
return postMessage (cmd, true, resolve)
})
}

export const startLiveness: (callback: (err: string, data: string[]) => void) => void = (callback) => {

const cmd: WorkerCommand = {
cmd: 'startLiveness',
uuid: v4(),
data: []
}
return postMessage (cmd, false, null, (err, data) => {
if (err) {
return callback (err, [])
}

return callback ('', data)
})
}

export const checkLocaldemond: () => Promise < StartWorkerResolveForAPI > = () => {
return new Promise(resolve => {
export const stopLiveness: () => Promise < StartWorkerResolveForAPI > = () => {

})
return new Promise(resolve => {
const cmd: WorkerCommand = {
cmd: 'stopLiveness',
uuid: v4(),
data: []
}
return postMessage (cmd, true, resolve)
})
}

export const isLivenessRunning: () => Promise < StartWorkerResolveForAPI > = () => {

return new Promise(resolve => {
const cmd: WorkerCommand = {
cmd: 'isLivenessRunning',
uuid: v4(),
data: []
}
return postMessage (cmd, true, resolve)
})
}


1 change: 1 addition & 0 deletions src/assets/logo/metaMask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ const App = () => {


useEffect(() => {

const testDeamon = async() => {
const _palette = await generateThemeScheme()
setPalette(_palette)
const test = await testLocalServer ()

if (test === true) {
setlocalDaemon(true)
}
await dAPPInitialize()

}

testDeamon().catch((ex) => {
console.log(`APP useEffect testDeamon error`, ex)
})
const fetchData = async ()=> {
if (!active) {
return
}
const _palette = await generateThemeScheme()
setPalette(_palette)
const test = await testLocalServer ()

if (test === true) {
setlocalDaemon(true)
}
await dAPPInitialize()
}

let active = true
fetchData()
return () => { active = false }
}, [])


Expand Down
14 changes: 7 additions & 7 deletions src/components/App/Apps/CONET-Proxy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ const regions: regionType = {
}

const ChromeImg = styled.img`
width: 80%;
width: 50%;
`

const IOSImg = styled.img`
width: 100%;
`


const OneLineText = styled.span`
`
interface TabPanelProps {
Expand Down Expand Up @@ -583,15 +584,14 @@ const LaunchPage = () => {

const {
locale,
isProxyStart,
setlocalDaemon
} = useAppState()

const intl = useIntl()

useEffect(() => {

const testDeamon = async() => {
const fetchData = async() => {

const test = await testLocalServer ()

Expand All @@ -601,9 +601,9 @@ const LaunchPage = () => {

}

testDeamon().catch((ex) => {
console.log(`APP useEffect testDeamon error`, ex)
})
let active = true
fetchData()
return () => { active = false }

}, [])
//
Expand Down Expand Up @@ -632,7 +632,7 @@ const LaunchPage = () => {
{ intl.formatMessage({id:'platform.proxy.FeatureArea5.moreDetail'})}
</Typography>
</Link>
<Link target="_blank" href={'https://github.com/CoNET-project/CONET-Proxy/issues'}>
<Link target="_blank" href={'https://github.com/CoNET-project/seguro-platform/issues'}>
<Typography variant="subtitle1" sx={{ color: '#2e7d32'}}>
{ intl.formatMessage({id:'platform.proxy.issueReport'})}
</Typography>
Expand Down
Loading

0 comments on commit f29005b

Please sign in to comment.