mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
compute and transactions fix
This commit is contained in:
parent
3a00ef0b0d
commit
77ea9d0432
6
package-lock.json
generated
6
package-lock.json
generated
@ -3397,9 +3397,9 @@
|
|||||||
"integrity": "sha512-915dcnzCHEuvsmRKqVj0RxHT3T386lSJh8WREe4dsnrXHsi1ULNYxX0Ts/cvalv6bRL+aqyaZ6gN3l3nkfwEDg=="
|
"integrity": "sha512-915dcnzCHEuvsmRKqVj0RxHT3T386lSJh8WREe4dsnrXHsi1ULNYxX0Ts/cvalv6bRL+aqyaZ6gN3l3nkfwEDg=="
|
||||||
},
|
},
|
||||||
"@oceanprotocol/react": {
|
"@oceanprotocol/react": {
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.11.tgz",
|
||||||
"integrity": "sha512-tkNmKTFvHgZC1cU8JiZ85z+msGjc5lzO1kbcgYCLHtuqAhSKFkMZl6j87XpM147hBqJBg3mE5J5OrRrbN5SedA==",
|
"integrity": "sha512-uve2rxkqD83lNo77COSzw3/38JtUkxwfTtZHmMjLfOcvn0UD98RDS6oP1+BDzqH9K2AuDvIeTwu/YGAISskL/w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@oceanprotocol/squid": "^2.2.0",
|
"@oceanprotocol/squid": "^2.2.0",
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/art": "^2.2.0",
|
"@oceanprotocol/art": "^2.2.0",
|
||||||
"@oceanprotocol/react": "0.0.10",
|
"@oceanprotocol/react": "0.0.11",
|
||||||
"@oceanprotocol/squid": "^2.2.0",
|
"@oceanprotocol/squid": "^2.2.0",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@sindresorhus/slugify": "^1.0.0",
|
"@sindresorhus/slugify": "^1.0.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
title: 'Data Marketplace',
|
title: 'Ocean Market',
|
||||||
description: `A marketplace to find and publish open data sets in the Ocean Network.`,
|
description: `A marketplace to find and publish open data sets in the Ocean Network.`,
|
||||||
url: 'https://dexfreight.oceanprotocol.com',
|
url: 'https://dexfreight.oceanprotocol.com',
|
||||||
copyright:
|
copyright:
|
||||||
|
6
src/components/atoms/BaseDialog.module.css
Normal file
6
src/components/atoms/BaseDialog.module.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.customOverlay {
|
||||||
|
|
||||||
|
}
|
||||||
|
.customModal {
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
33
src/components/atoms/BaseDiaog.tsx
Normal file
33
src/components/atoms/BaseDiaog.tsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import styles from './BaseDialog.module.css'
|
||||||
|
import { Modal } from "react-responsive-modal";
|
||||||
|
|
||||||
|
|
||||||
|
export default function BaseDialog({
|
||||||
|
open,
|
||||||
|
title,
|
||||||
|
onClose,
|
||||||
|
children,
|
||||||
|
disableClose,
|
||||||
|
actions,
|
||||||
|
...other }: {
|
||||||
|
open: boolean
|
||||||
|
title: string
|
||||||
|
onClose: () => void
|
||||||
|
children: React.ReactNode
|
||||||
|
disableClose?: boolean
|
||||||
|
actions?: any
|
||||||
|
}) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal open={open} onClose={onClose} classNames={{
|
||||||
|
overlay: 'customOverlay',
|
||||||
|
modal: 'customModal',
|
||||||
|
}} {...other}>
|
||||||
|
<h2>{title}</h2>
|
||||||
|
<p>
|
||||||
|
{children}
|
||||||
|
</p>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
@ -2,6 +2,5 @@ import React from 'react'
|
|||||||
import Time from '../Time'
|
import Time from '../Time'
|
||||||
|
|
||||||
export default function DateCell({ date }: { date: any }) {
|
export default function DateCell({ date }: { date: any }) {
|
||||||
console.log(date)
|
|
||||||
return date && <Time date={date} />
|
return date && <Time date={date} />
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ export function transformPublishFormToMetadata(
|
|||||||
termsAndConditions,
|
termsAndConditions,
|
||||||
supportName,
|
supportName,
|
||||||
supportEmail,
|
supportEmail,
|
||||||
access: 'Download'
|
access: access || 'Download'
|
||||||
},
|
},
|
||||||
// ------- curation -------
|
// ------- curation -------
|
||||||
curation: AssetModel.curation
|
curation: AssetModel.curation
|
||||||
@ -155,10 +155,10 @@ const PublishForm: React.FC<PublishFormProps> = () => {
|
|||||||
)
|
)
|
||||||
services = [computeService]
|
services = [computeService]
|
||||||
}
|
}
|
||||||
|
console.log(metadata as MetaData)
|
||||||
try {
|
try {
|
||||||
const asset = await ocean.assets.create(
|
const asset = await ocean.assets.create(
|
||||||
(transformPublishFormToMetadata(formData) as unknown) as MetaData,
|
metadata as MetaData,
|
||||||
account,
|
account,
|
||||||
services
|
services
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
import styles from './Compute.module.css'
|
import styles from './Compute.module.css'
|
||||||
import Button from '../atoms/Button'
|
import Button from '../atoms/Button'
|
||||||
import Input from '../atoms/Input/Input'
|
import Input from '../atoms/Input/Input'
|
||||||
|
import { LoggerInstance, LogLevel } from '@oceanprotocol/squid/dist/node/utils/Logger'
|
||||||
|
|
||||||
export default function Compute({
|
export default function Compute({
|
||||||
ddo,
|
ddo,
|
||||||
@ -27,6 +28,8 @@ export default function Compute({
|
|||||||
ocean: Ocean | null
|
ocean: Ocean | null
|
||||||
}) {
|
}) {
|
||||||
if (!ddo) return null
|
if (!ddo) return null
|
||||||
|
|
||||||
|
|
||||||
const { compute, isLoading, computeStepText, computeError } = useCompute()
|
const { compute, isLoading, computeStepText, computeError } = useCompute()
|
||||||
const [isJobStarting, setIsJobStarting] = useState(false)
|
const [isJobStarting, setIsJobStarting] = useState(false)
|
||||||
const [, setError] = useState('')
|
const [, setError] = useState('')
|
||||||
@ -57,7 +60,7 @@ export default function Compute({
|
|||||||
!isTermsAgreed
|
!isTermsAgreed
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(Logger)
|
|
||||||
setIsBalanceSufficient(
|
setIsBalanceSufficient(
|
||||||
isFree ||
|
isFree ||
|
||||||
(balance !== null &&
|
(balance !== null &&
|
||||||
|
@ -49,30 +49,12 @@ export default function ConsumedList() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getConsumed() {
|
async function getConsumed() {
|
||||||
if (!account || !ocean || status !== OceanConnectionStatus.CONNECTED)
|
if (!accountId || !ocean || status !== OceanConnectionStatus.CONNECTED)
|
||||||
return
|
return
|
||||||
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const consumedItems = await getConsumedList()
|
|
||||||
// console.log('react cosume',consumedItemsT)
|
|
||||||
// // TODO: test this before updating react lib and after backend workd properly
|
|
||||||
// const consumed = await ocean.assets.consumerAssets(accountId)
|
|
||||||
// console.log(consumed)
|
|
||||||
// const consumedItemss = await Promise.all(
|
|
||||||
// consumed.map(async (did) => {
|
|
||||||
// const ddo = await ocean.assets.resolve(did)
|
|
||||||
// if (ddo) {
|
|
||||||
// // Since we are getting assets from chain there might be
|
|
||||||
// // assets from other marketplaces. So return only those assets
|
|
||||||
// // whose serviceEndpoint contains the configured Aquarius URI.
|
|
||||||
// const { serviceEndpoint } = ddo.findServiceByType('metadata')
|
|
||||||
// if (serviceEndpoint?.includes(config.aquariusUri as string)) return ddo
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// )
|
const consumedItems = await getConsumedList()
|
||||||
// const consumedItems = (consumedItemss.filter(value => typeof value !== 'undefined')) as DDO[]
|
|
||||||
// console.log('consumedss', consumedItems)
|
|
||||||
if (!consumedItems) return
|
if (!consumedItems) return
|
||||||
|
|
||||||
const data = consumedItems.map(ddo => {
|
const data = consumedItems.map(ddo => {
|
||||||
@ -84,15 +66,12 @@ export default function ConsumedList() {
|
|||||||
price: price
|
price: price
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// const data = [
|
|
||||||
// { published: '2020-05-14T10:00:49Z', name: 'asdf', price: '0', id: 1 },
|
|
||||||
// { published: '2020-05-21T10:00:49Z', name: 'test', price: '0', id: 2 }
|
|
||||||
// ]
|
|
||||||
setConsumedList(data)
|
setConsumedList(data)
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
}
|
}
|
||||||
getConsumed()
|
getConsumed()
|
||||||
}, [account, ocean, status])
|
}, [accountId, ocean, status])
|
||||||
|
|
||||||
return isLoading ? (
|
return isLoading ? (
|
||||||
<Loader />
|
<Loader />
|
||||||
|
@ -13,9 +13,11 @@ import { fromWei } from 'web3-utils'
|
|||||||
import { findServiceByType } from '../../utils'
|
import { findServiceByType } from '../../utils'
|
||||||
import Table from '../atoms/Table'
|
import Table from '../atoms/Table'
|
||||||
import Button from '../atoms/Button'
|
import Button from '../atoms/Button'
|
||||||
import { MetaDataMain } from '@oceanprotocol/squid'
|
import { MetaDataMain, Logger } from '@oceanprotocol/squid'
|
||||||
import DateCell from '../atoms/Table/DateCell'
|
import DateCell from '../atoms/Table/DateCell'
|
||||||
import DdoLinkCell from '../atoms/Table/DdoLinkCell'
|
import DdoLinkCell from '../atoms/Table/DdoLinkCell'
|
||||||
|
import { config } from '../../config/ocean'
|
||||||
|
import shortid from 'shortid'
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
@ -61,7 +63,7 @@ const columns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export default function JobsList() {
|
export default function JobsList() {
|
||||||
const { ocean, status, account } = useOcean()
|
const { ocean, status, accountId, account } = useOcean()
|
||||||
|
|
||||||
const [jobList, setJobList] = useState<any[]>([])
|
const [jobList, setJobList] = useState<any[]>([])
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
@ -69,11 +71,52 @@ export default function JobsList() {
|
|||||||
const { getComputeItems } = useSearch()
|
const { getComputeItems } = useSearch()
|
||||||
|
|
||||||
const getJobs = async () => {
|
const getJobs = async () => {
|
||||||
if (!account || !ocean || status !== OceanConnectionStatus.CONNECTED) return
|
if (!accountId || !ocean || status !== OceanConnectionStatus.CONNECTED) return
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
setUserAgreed(true)
|
setUserAgreed(true)
|
||||||
try {
|
try {
|
||||||
const computeItems = await getComputeItems()
|
|
||||||
|
|
||||||
|
const jobList = await ocean.compute.status(account)
|
||||||
|
console.log(jobList)
|
||||||
|
const computeItemss = await Promise.all(
|
||||||
|
jobList.map(async (job) => {
|
||||||
|
if (!job) return
|
||||||
|
try {
|
||||||
|
|
||||||
|
const { did } = await ocean.keeper.agreementStoreManager.getAgreement(
|
||||||
|
job.agreementId
|
||||||
|
)
|
||||||
|
console.log(did)
|
||||||
|
if(did==='0x0000000000000000000000000000000000000000000000000000000000000000') return
|
||||||
|
const ddo = await ocean.assets.resolve(did)
|
||||||
|
if (ddo) {
|
||||||
|
|
||||||
|
// Since we are getting assets from chain there might be
|
||||||
|
// assets from other marketplaces. So return only those assets
|
||||||
|
// whose serviceEndpoint contains the configured Aquarius URI.
|
||||||
|
const metadata = findServiceByType(ddo,'metadata')
|
||||||
|
console.log(did,metadata)
|
||||||
|
if(!metadata) return
|
||||||
|
const { serviceEndpoint } = metadata
|
||||||
|
if (serviceEndpoint?.includes(config.aquariusUri)) {
|
||||||
|
return { job, ddo }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const computeItems = computeItemss.filter(
|
||||||
|
(value) => value !== undefined
|
||||||
|
) as ComputeItem[] | undefined
|
||||||
|
|
||||||
|
// const computeItems = await getComputeItems()
|
||||||
|
console.log('compute items', computeItems)
|
||||||
if (!computeItems) return
|
if (!computeItems) return
|
||||||
const data = computeItems.map(item => {
|
const data = computeItems.map(item => {
|
||||||
const { attributes } = findServiceByType(item.ddo, 'metadata')
|
const { attributes } = findServiceByType(item.ddo, 'metadata')
|
||||||
@ -84,13 +127,15 @@ export default function JobsList() {
|
|||||||
status: item.job.statusText,
|
status: item.job.statusText,
|
||||||
name: name,
|
name: name,
|
||||||
price: price,
|
price: price,
|
||||||
id: item.ddo.id
|
did: item.ddo.id,
|
||||||
|
id: shortid.generate()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
setJobList(data)
|
setJobList(data)
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Logger.error(err)
|
||||||
// TODO: no error handling
|
// TODO: no error handling
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
@ -99,19 +144,19 @@ export default function JobsList() {
|
|||||||
|
|
||||||
return isLoading ? (
|
return isLoading ? (
|
||||||
<Loader />
|
<Loader />
|
||||||
) : account && ocean ? (
|
) : accountId && ocean ? (
|
||||||
userAgreed ? (
|
userAgreed ? (
|
||||||
<Table data={jobList} columns={columns} />
|
<Table data={jobList} columns={columns} />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
<Button primary onClick={getJobs}>
|
<Button primary onClick={getJobs}>
|
||||||
Sign to retrieve jobs
|
Sign to retrieve jobs
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<div>Connect your wallet to see your compute jobs.</div>
|
<div>Connect your wallet to see your compute jobs.</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ const AssetDetailsPageMeta = ({
|
|||||||
}) => {
|
}) => {
|
||||||
if (!attributes) return null
|
if (!attributes) return null
|
||||||
|
|
||||||
const { web3, account } = useWeb3()
|
|
||||||
const { ocean, balanceInOcean } = useOcean()
|
const { ocean, balanceInOcean } = useOcean()
|
||||||
const { datePublished } = attributes.main
|
const { datePublished } = attributes.main
|
||||||
const {
|
const {
|
||||||
|
@ -15,20 +15,34 @@ export interface OceanConfig extends Config {
|
|||||||
ratingUri: string
|
ratingUri: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config: Partial<OceanConfig> = {
|
// why is this partial?
|
||||||
nodeUri: process.env.NODE_URI || 'https://pacific.oceanprotocol.com',
|
// export const config: Partial<OceanConfig> = {
|
||||||
|
// nodeUri: process.env.NODE_URI || 'https://pacific.oceanprotocol.com',
|
||||||
|
// aquariusUri:
|
||||||
|
// process.env.AQUARIUS_URI ||
|
||||||
|
// 'https://aquarius.marketplace.oceanprotocol.com',
|
||||||
|
// brizoUri:
|
||||||
|
// process.env.BRIZO_URI || 'https://brizo.marketplace.oceanprotocol.com',
|
||||||
|
// brizoAddress:
|
||||||
|
// process.env.BRIZO_ADDRESS || '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
||||||
|
// secretStoreUri:
|
||||||
|
// process.env.SECRET_STORE_URI || 'https://secret-store.oceanprotocol.com',
|
||||||
|
// faucetUri: process.env.FAUCET_URI || 'https://faucet.oceanprotocol.com',
|
||||||
|
// ratingUri:
|
||||||
|
// process.env.RATING_URI || 'https://rating.pacific.dexfreight.dev-ocean.com',
|
||||||
|
// verbose: 3
|
||||||
|
// }
|
||||||
|
|
||||||
|
// why is this partial?
|
||||||
|
export const config: OceanConfig = {
|
||||||
|
nodeUri: 'https://pacific.oceanprotocol.com',
|
||||||
aquariusUri:
|
aquariusUri:
|
||||||
process.env.AQUARIUS_URI ||
|
|
||||||
'https://aquarius.marketplace.oceanprotocol.com',
|
'https://aquarius.marketplace.oceanprotocol.com',
|
||||||
brizoUri:
|
brizoUri: 'https://brizo.marketplace.oceanprotocol.com',
|
||||||
process.env.BRIZO_URI || 'https://brizo.marketplace.oceanprotocol.com',
|
brizoAddress: '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
||||||
brizoAddress:
|
secretStoreUri: 'https://secret-store.oceanprotocol.com',
|
||||||
process.env.BRIZO_ADDRESS || '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
faucetUri: 'https://faucet.oceanprotocol.com',
|
||||||
secretStoreUri:
|
ratingUri: 'https://rating.pacific.dexfreight.dev-ocean.com',
|
||||||
process.env.SECRET_STORE_URI || 'https://secret-store.oceanprotocol.com',
|
|
||||||
faucetUri: process.env.FAUCET_URI || 'https://faucet.oceanprotocol.com',
|
|
||||||
ratingUri:
|
|
||||||
process.env.RATING_URI || 'https://rating.pacific.dexfreight.dev-ocean.com',
|
|
||||||
verbose: 3
|
verbose: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,13 +44,29 @@ const AssetDetails: NextPage<AssetDetailsPageProps> = (
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
export function normalizeDid(did: string): string {
|
||||||
|
if (did.length === 73) {
|
||||||
|
if (did.charAt(9) === '0' && did.charAt(10) === '0') {
|
||||||
|
return did.substr(0, 9) + did.substr(11)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return did
|
||||||
|
}
|
||||||
|
|
||||||
export async function getMetadata(did?: string) {
|
export async function getMetadata(did?: string) {
|
||||||
if (!did || !isDid(did)) {
|
if (did) {
|
||||||
|
did = normalizeDid(did)
|
||||||
|
if (!isDid(did)) {
|
||||||
|
return {
|
||||||
|
title: 'Not a DID',
|
||||||
|
error:
|
||||||
|
'The provided DID in the URL is not a valid DID. Please check your URL.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return {
|
return {
|
||||||
title: 'Not a DID',
|
title: 'No DID provided',
|
||||||
error:
|
error: 'No DID provided. Please check your URL.'
|
||||||
'The provided DID in the URL is not a valid DID. Please check your URL.'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user