Merge pull request #2 from oceanprotocol/fixes

fixes
This commit is contained in:
mihaisc 2022-10-18 10:17:40 +03:00 committed by GitHub
commit 9bca220c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
16

View File

@ -1,6 +1,7 @@
module.exports = {
statusApiUri: process.env.NEXT_STATUS_API_URI || 'http://localhost:8000',
statusApiUri:
process.env.NEXT_PUBLIC_STATUS_API_URI || 'http://localhost:8000',
availableNetworks:
process.env.NEXT_NETWORKS ||
process.env.NEXT_PUBLIC_NETWORKS ||
'["mainnet","polygon","bsc","moonriver","energyweb","mumbai","moonbase","goerli"]'
}

View File

@ -3,9 +3,11 @@ import { NetworkSummary, State, Status, Summary } from '../@types'
import { statusApiUri } from '../../app.config'
import { availableNetworks } from '../../app.config'
export async function getData(): Promise<Status[]> {
export async function getData(): Promise<Status[][]> {
try {
const response: AxiosResponse<Status[]> = await axios.get(`${statusApiUri}`)
const response: AxiosResponse<Status[][]> = await axios.get(
`${statusApiUri}`
)
if (!response || response.status !== 200 || !response.data)
console.log('ERROR: no data recieved')
@ -17,12 +19,13 @@ export async function getData(): Promise<Status[]> {
}
}
export function getSummary(network: string, data: Status[]): Summary[] {
export function getSummary(network: string, data: Status[][]): Summary[] {
try {
if (data) {
let status: Status
data.forEach((element) => {
if (element.network === network) return (status = element)
if (element[0].network === network) return (status = element[0])
})
const summary: Summary[] = [
@ -57,7 +60,7 @@ export function getSummary(network: string, data: Status[]): Summary[] {
}
}
export function getNetworkSUmmary(data: Status[]): NetworkSummary[] {
export function getNetworkSUmmary(data: Status[][]): NetworkSummary[] {
const networks: string[] = JSON.parse(availableNetworks)
const networkSummary: NetworkSummary[] = []
networks.forEach((network) => {