1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-12-22 17:23:32 +01:00

updates for new version of lib

This commit is contained in:
mihaisc 2020-09-29 15:29:05 +03:00
parent e71b2849dc
commit 8943aa0639
No known key found for this signature in database
GPG Key ID: BE522BB8C3A5E2E4
7 changed files with 11248 additions and 309 deletions

View File

@ -8,7 +8,7 @@ module.exports = function override(config, env) {
alias: { alias: {
...config.resolve.alias, ...config.resolve.alias,
react: path.resolve('../node_modules/react'), react: path.resolve('../node_modules/react'),
"@oceanprotocol/lib": path.resolve('../node_modules/@oceanprotocol/lib') '@oceanprotocol/lib': path.resolve('../node_modules/@oceanprotocol/lib')
} }
} }
} }

View File

@ -7,25 +7,20 @@ import shortid from 'shortid'
import { MetadataExample } from './MetadataExample' import { MetadataExample } from './MetadataExample'
export function AllDdos() { export function AllDdos() {
const { chainId, account, ocean } = useOcean() const { chainId, account, accountId, ocean } = useOcean()
const [ddos, setDdos] = useState<DDO[] | undefined>() const [ddos, setDdos] = useState<DDO[] | undefined>()
useEffect(() => { useEffect(() => {
async function init() { async function init() {
if (!ocean || !account) return if (!ocean || !account || !accountId) return
const assets = await ocean.assets.query({ const assets = await ocean.assets.ownerAssets(accountId)
page: 1,
offset: 10,
query: {},
sort: { created: -1 }
})
setDdos(assets.results.slice(0, 4)) setDdos(assets.results.slice(0, 4))
} }
init() init()
}, [ocean, account, chainId]) }, [ocean, account, chainId, accountId])
return ( return (
<> <>

View File

@ -3,13 +3,13 @@ import './App.css'
import { OceanProvider } from '@oceanprotocol/react' import { OceanProvider } from '@oceanprotocol/react'
import { Wallet } from './Wallet' import { Wallet } from './Wallet'
import { Publish } from './Publish' import { Publish } from './Publish'
import { ConfigHelper } from '@oceanprotocol/lib' import { ConfigHelper, Logger } from '@oceanprotocol/lib'
import { AllDdos } from './AllDdos' import { AllDdos } from './AllDdos'
import { ConsumeDdo } from './ConsumeDdo' import { ConsumeDdo } from './ConsumeDdo'
import { NetworkMonitor } from './NetworkMonitor' import { NetworkMonitor } from './NetworkMonitor'
import { LogLevel } from '@oceanprotocol/lib/dist/node/utils'
const configRinkeby = new ConfigHelper().getConfig('rinkeby') const configRinkeby = new ConfigHelper().getConfig('rinkeby')
const providerOptions = {} const providerOptions = {}
export const web3ModalOpts = { export const web3ModalOpts = {
@ -19,6 +19,7 @@ export const web3ModalOpts = {
function App() { function App() {
console.log(configRinkeby) console.log(configRinkeby)
Logger.setLevel(LogLevel.Verbose)
const init = async () => {} const init = async () => {}
useEffect(() => { useEffect(() => {

View File

@ -7,12 +7,12 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Publish() { export function Publish() {
const { publish, publishStepText, isLoading } = usePublish() const { publish, publishStepText, isLoading } = usePublish()
const [ddo, setDdo] = useState<DDO | undefined|null>() const [ddo, setDdo] = useState<DDO | undefined | null>()
const asset = { const asset = {
main: { main: {
type: 'dataset', type: 'dataset',
name: 'test-dataset', name: 'test-dataset - ' + new Date().toISOString(),
dateCreated: new Date(Date.now()).toISOString().split('.')[0] + 'Z', // remove milliseconds dateCreated: new Date(Date.now()).toISOString().split('.')[0] + 'Z', // remove milliseconds
author: 'oceanprotocol-team', author: 'oceanprotocol-team',
license: 'MIT', license: 'MIT',

11510
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@
"dist/" "dist/"
], ],
"dependencies": { "dependencies": {
"@oceanprotocol/lib": "^0.3.1", "@oceanprotocol/lib": "file:../ocean-lib-js",
"axios": "^0.20.0", "axios": "^0.20.0",
"decimal.js": "^10.2.0", "decimal.js": "^10.2.0",
"web3": "^1.3.0", "web3": "^1.3.0",

View File

@ -107,7 +107,7 @@ function usePublish(): UsePublish {
const timeout = 0 const timeout = 0
const services: Service[] = [] const services: Service[] = []
const price = ocean.datatokens.toWei('1') const price = '1'
switch (serviceType) { switch (serviceType) {
case 'access': { case 'access': {
const accessService = await ocean.assets.createAccessServiceAttributes( const accessService = await ocean.assets.createAccessServiceAttributes(
@ -170,16 +170,15 @@ function usePublish(): UsePublish {
Logger.log('services created', services) Logger.log('services created', services)
const ddo = await ocean.assets const ddo = await ocean.assets.create(
.create( asset,
asset, account,
account, services,
services, dataTokenOptions?.cap,
dataTokenOptions?.cap, dataTokenOptions?.name,
dataTokenOptions?.name, dataTokenOptions?.symbol
dataTokenOptions?.symbol )
) // .next(setStep)
.next(setStep)
Logger.log('ddo created', ddo) Logger.log('ddo created', ddo)
setStep(7) setStep(7)
await mint(ddo.dataToken, tokensToMint) await mint(ddo.dataToken, tokensToMint)