From 3a00ef0b0dbf84eede8e60179534b8ec7de9a068 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 26 May 2020 16:42:45 +0300 Subject: [PATCH] transaction cleanup --- package-lock.json | 30 ++------------- package.json | 2 +- src/components/organisms/ConsumedList.tsx | 47 ++++++++++++++--------- src/components/organisms/JobsList.tsx | 2 +- 4 files changed, 33 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e0e5e9cb..e9ba1d25a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3397,38 +3397,14 @@ "integrity": "sha512-915dcnzCHEuvsmRKqVj0RxHT3T386lSJh8WREe4dsnrXHsi1ULNYxX0Ts/cvalv6bRL+aqyaZ6gN3l3nkfwEDg==" }, "@oceanprotocol/react": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.9.tgz", - "integrity": "sha512-wCaBAHufEhhWApWHZucOXgEjyEUnuGG6OdBdkQjoPpLatkNs8X8tEpqMN6pZQoTIXyC6rYnnBPnrURiFW1RDHg==", + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.10.tgz", + "integrity": "sha512-tkNmKTFvHgZC1cU8JiZ85z+msGjc5lzO1kbcgYCLHtuqAhSKFkMZl6j87XpM147hBqJBg3mE5J5OrRrbN5SedA==", "requires": { "@oceanprotocol/squid": "^2.2.0", "axios": "^0.19.2", "react": "^16.13.1", "web3connect": "^1.0.0-beta.33" - }, - "dependencies": { - "@oceanprotocol/squid": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-2.2.0.tgz", - "integrity": "sha512-ISI+8mGl5lCPqLw/YPS/e0PhaqgexuGiwxKcCGAMSo1p8sgunr6FOrMVoYhYr52QpfodxOY8Iiy3zv4HC8O2Mg==", - "requires": { - "@ethereum-navigator/navigator": "^0.5.0", - "@oceanprotocol/keeper-contracts": "^0.13.2", - "@oceanprotocol/secret-store-client": "^0.0.15", - "bignumber.js": "^9.0.0", - "deprecated-decorator": "^0.1.6", - "node-fetch": "^2.6.0", - "save-file": "^2.3.1", - "uuid": "^8.0.0", - "web3": "^1.2.6", - "whatwg-url": "^8.0.0" - } - }, - "uuid": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.0.0.tgz", - "integrity": "sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==" - } } }, "@oceanprotocol/secret-store-client": { diff --git a/package.json b/package.json index 22be63655..498a658d8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@oceanprotocol/art": "^2.2.0", - "@oceanprotocol/react": "0.0.9", + "@oceanprotocol/react": "0.0.10", "@oceanprotocol/squid": "^2.2.0", "@oceanprotocol/typographies": "^0.1.0", "@sindresorhus/slugify": "^1.0.0", diff --git a/src/components/organisms/ConsumedList.tsx b/src/components/organisms/ConsumedList.tsx index 8fb00fd73..c5847dd4f 100644 --- a/src/components/organisms/ConsumedList.tsx +++ b/src/components/organisms/ConsumedList.tsx @@ -1,11 +1,18 @@ import React, { useEffect, useState } from 'react' import Loader from '../atoms/Loader' -import { useWeb3, useOcean, OceanConnectionStatus } from '@oceanprotocol/react' +import { + useOcean, + OceanConnectionStatus, + useSearch +} from '@oceanprotocol/react' import Table from '../atoms/Table' import Price from '../atoms/Price' import { fromWei } from 'web3-utils' import DateCell from '../atoms/Table/DateCell' import DdoLinkCell from '../atoms/Table/DdoLinkCell' +import { DDO, MetaDataMain } from '@oceanprotocol/squid' +import { findServiceByType } from '../../utils' +import { config } from '../../config/ocean' const consumedColumns = [ { @@ -35,9 +42,9 @@ const consumedColumns = [ ] export default function ConsumedList() { - const { account } = useWeb3() - const { ocean, status } = useOcean() + const { ocean, status, accountId, account } = useOcean() const [consumedList, setConsumedList] = useState([]) + const { getConsumedList } = useSearch() const [isLoading, setIsLoading] = useState(false) useEffect(() => { @@ -46,10 +53,11 @@ export default function ConsumedList() { return setIsLoading(true) - // const consumedItems = await getConsumedList() - - // TODO: test this before updating react lib and after backend workd properly + 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) @@ -65,20 +73,21 @@ export default function ConsumedList() { // ) // const consumedItems = (consumedItemss.filter(value => typeof value !== 'undefined')) as DDO[] // console.log('consumedss', consumedItems) + if (!consumedItems) return - // const data = consumedItems.map((ddo) => { - // const { attributes } = findServiceByType(ddo, 'metadata') - // const { name, price, datePublished } = attributes.main as MetaDataMain - // return { - // published: datePublished, - // name: name, - // 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 } - ] + const data = consumedItems.map(ddo => { + const { attributes } = findServiceByType(ddo, 'metadata') + const { name, price, datePublished } = attributes.main as MetaDataMain + return { + published: datePublished, + name: name, + 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) } diff --git a/src/components/organisms/JobsList.tsx b/src/components/organisms/JobsList.tsx index 6e6bfed89..71719354c 100644 --- a/src/components/organisms/JobsList.tsx +++ b/src/components/organisms/JobsList.tsx @@ -74,7 +74,7 @@ export default function JobsList() { setUserAgreed(true) try { const computeItems = await getComputeItems() - + if (!computeItems) return const data = computeItems.map(item => { const { attributes } = findServiceByType(item.ddo, 'metadata') const { name, price } = attributes.main as MetaDataMain