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=="
|
||||
},
|
||||
"@oceanprotocol/react": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.10.tgz",
|
||||
"integrity": "sha512-tkNmKTFvHgZC1cU8JiZ85z+msGjc5lzO1kbcgYCLHtuqAhSKFkMZl6j87XpM147hBqJBg3mE5J5OrRrbN5SedA==",
|
||||
"version": "0.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.11.tgz",
|
||||
"integrity": "sha512-uve2rxkqD83lNo77COSzw3/38JtUkxwfTtZHmMjLfOcvn0UD98RDS6oP1+BDzqH9K2AuDvIeTwu/YGAISskL/w==",
|
||||
"requires": {
|
||||
"@oceanprotocol/squid": "^2.2.0",
|
||||
"axios": "^0.19.2",
|
||||
|
@ -19,7 +19,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/art": "^2.2.0",
|
||||
"@oceanprotocol/react": "0.0.10",
|
||||
"@oceanprotocol/react": "0.0.11",
|
||||
"@oceanprotocol/squid": "^2.2.0",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@sindresorhus/slugify": "^1.0.0",
|
||||
|
@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
title: 'Data Marketplace',
|
||||
title: 'Ocean Market',
|
||||
description: `A marketplace to find and publish open data sets in the Ocean Network.`,
|
||||
url: 'https://dexfreight.oceanprotocol.com',
|
||||
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'
|
||||
|
||||
export default function DateCell({ date }: { date: any }) {
|
||||
console.log(date)
|
||||
return date && <Time date={date} />
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ export function transformPublishFormToMetadata(
|
||||
termsAndConditions,
|
||||
supportName,
|
||||
supportEmail,
|
||||
access: 'Download'
|
||||
access: access || 'Download'
|
||||
},
|
||||
// ------- curation -------
|
||||
curation: AssetModel.curation
|
||||
@ -155,10 +155,10 @@ const PublishForm: React.FC<PublishFormProps> = () => {
|
||||
)
|
||||
services = [computeService]
|
||||
}
|
||||
|
||||
console.log(metadata as MetaData)
|
||||
try {
|
||||
const asset = await ocean.assets.create(
|
||||
(transformPublishFormToMetadata(formData) as unknown) as MetaData,
|
||||
metadata as MetaData,
|
||||
account,
|
||||
services
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
import styles from './Compute.module.css'
|
||||
import Button from '../atoms/Button'
|
||||
import Input from '../atoms/Input/Input'
|
||||
import { LoggerInstance, LogLevel } from '@oceanprotocol/squid/dist/node/utils/Logger'
|
||||
|
||||
export default function Compute({
|
||||
ddo,
|
||||
@ -27,6 +28,8 @@ export default function Compute({
|
||||
ocean: Ocean | null
|
||||
}) {
|
||||
if (!ddo) return null
|
||||
|
||||
|
||||
const { compute, isLoading, computeStepText, computeError } = useCompute()
|
||||
const [isJobStarting, setIsJobStarting] = useState(false)
|
||||
const [, setError] = useState('')
|
||||
@ -57,7 +60,7 @@ export default function Compute({
|
||||
!isTermsAgreed
|
||||
|
||||
useEffect(() => {
|
||||
console.log(Logger)
|
||||
|
||||
setIsBalanceSufficient(
|
||||
isFree ||
|
||||
(balance !== null &&
|
||||
@ -88,7 +91,7 @@ export default function Compute({
|
||||
setError('')
|
||||
|
||||
await compute(ddo.id, algorithmRawCode, computeContainer)
|
||||
|
||||
|
||||
setIsPublished(true)
|
||||
setFile(null)
|
||||
} catch (error) {
|
||||
|
@ -49,30 +49,12 @@ export default function ConsumedList() {
|
||||
|
||||
useEffect(() => {
|
||||
async function getConsumed() {
|
||||
if (!account || !ocean || status !== OceanConnectionStatus.CONNECTED)
|
||||
if (!accountId || !ocean || status !== OceanConnectionStatus.CONNECTED)
|
||||
return
|
||||
|
||||
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 = (consumedItemss.filter(value => typeof value !== 'undefined')) as DDO[]
|
||||
// console.log('consumedss', consumedItems)
|
||||
const consumedItems = await getConsumedList()
|
||||
|
||||
if (!consumedItems) return
|
||||
|
||||
const data = consumedItems.map(ddo => {
|
||||
@ -84,15 +66,12 @@ export default function ConsumedList() {
|
||||
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)
|
||||
setIsLoading(false)
|
||||
}
|
||||
getConsumed()
|
||||
}, [account, ocean, status])
|
||||
}, [accountId, ocean, status])
|
||||
|
||||
return isLoading ? (
|
||||
<Loader />
|
||||
|
@ -13,9 +13,11 @@ import { fromWei } from 'web3-utils'
|
||||
import { findServiceByType } from '../../utils'
|
||||
import Table from '../atoms/Table'
|
||||
import Button from '../atoms/Button'
|
||||
import { MetaDataMain } from '@oceanprotocol/squid'
|
||||
import { MetaDataMain, Logger } from '@oceanprotocol/squid'
|
||||
import DateCell from '../atoms/Table/DateCell'
|
||||
import DdoLinkCell from '../atoms/Table/DdoLinkCell'
|
||||
import { config } from '../../config/ocean'
|
||||
import shortid from 'shortid'
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@ -61,7 +63,7 @@ const columns = [
|
||||
]
|
||||
|
||||
export default function JobsList() {
|
||||
const { ocean, status, account } = useOcean()
|
||||
const { ocean, status, accountId, account } = useOcean()
|
||||
|
||||
const [jobList, setJobList] = useState<any[]>([])
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
@ -69,11 +71,52 @@ export default function JobsList() {
|
||||
const { getComputeItems } = useSearch()
|
||||
|
||||
const getJobs = async () => {
|
||||
if (!account || !ocean || status !== OceanConnectionStatus.CONNECTED) return
|
||||
if (!accountId || !ocean || status !== OceanConnectionStatus.CONNECTED) return
|
||||
setIsLoading(true)
|
||||
setUserAgreed(true)
|
||||
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
|
||||
const data = computeItems.map(item => {
|
||||
const { attributes } = findServiceByType(item.ddo, 'metadata')
|
||||
@ -84,13 +127,15 @@ export default function JobsList() {
|
||||
status: item.job.statusText,
|
||||
name: name,
|
||||
price: price,
|
||||
id: item.ddo.id
|
||||
did: item.ddo.id,
|
||||
id: shortid.generate()
|
||||
}
|
||||
})
|
||||
|
||||
setJobList(data)
|
||||
setIsLoading(false)
|
||||
} catch (err) {
|
||||
Logger.error(err)
|
||||
// TODO: no error handling
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
@ -99,19 +144,19 @@ export default function JobsList() {
|
||||
|
||||
return isLoading ? (
|
||||
<Loader />
|
||||
) : account && ocean ? (
|
||||
) : accountId && ocean ? (
|
||||
userAgreed ? (
|
||||
<Table data={jobList} columns={columns} />
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<Button primary onClick={getJobs}>
|
||||
Sign to retrieve jobs
|
||||
<>
|
||||
<div>
|
||||
<Button primary onClick={getJobs}>
|
||||
Sign to retrieve jobs
|
||||
</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
|
||||
|
||||
const { web3, account } = useWeb3()
|
||||
|
||||
const { ocean, balanceInOcean } = useOcean()
|
||||
const { datePublished } = attributes.main
|
||||
const {
|
||||
|
@ -15,20 +15,34 @@ export interface OceanConfig extends Config {
|
||||
ratingUri: string
|
||||
}
|
||||
|
||||
export const config: Partial<OceanConfig> = {
|
||||
nodeUri: process.env.NODE_URI || 'https://pacific.oceanprotocol.com',
|
||||
// why is this partial?
|
||||
// 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:
|
||||
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',
|
||||
brizoUri: 'https://brizo.marketplace.oceanprotocol.com',
|
||||
brizoAddress: '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704',
|
||||
secretStoreUri: 'https://secret-store.oceanprotocol.com',
|
||||
faucetUri: 'https://faucet.oceanprotocol.com',
|
||||
ratingUri: 'https://rating.pacific.dexfreight.dev-ocean.com',
|
||||
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) {
|
||||
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 {
|
||||
title: 'Not a DID',
|
||||
error:
|
||||
'The provided DID in the URL is not a valid DID. Please check your URL.'
|
||||
title: 'No DID provided',
|
||||
error: 'No DID provided. Please check your URL.'
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user