1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-22 01:37:03 +01:00

quick example fix

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
mihaisc 2020-11-16 17:10:52 +02:00
parent 6981863794
commit 2701b33b38
No known key found for this signature in database
GPG Key ID: 4FB0C2329B4C6E29
5 changed files with 1816 additions and 764 deletions

2549
example/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import React, { useEffect } from 'react'
import React, { useEffect, useState } from 'react'
import './App.css'
import { OceanProvider } from '@oceanprotocol/react'
import { Wallet } from './Wallet'
@ -8,7 +8,6 @@ import { AllDdos } from './AllDdos'
import { ConsumeDdo } from './ConsumeDdo'
import { NetworkMonitor } from './NetworkMonitor'
import { LogLevel } from '@oceanprotocol/lib/dist/node/utils'
import { Pricing } from './Pricing'
const configRinkeby = new ConfigHelper().getConfig('rinkeby')
const providerOptions = {}
@ -27,6 +26,8 @@ function App() {
init()
}, [])
const [did, setDid] = useState<string | undefined>()
return (
<OceanProvider initialConfig={configRinkeby} web3ModalOpts={web3ModalOpts}>
<div className="container">
@ -40,9 +41,6 @@ function App() {
<div>
<Publish />
</div>
<div>
<Pricing />
</div>
<div>
<ConsumeDdo />
</div>

View File

@ -6,13 +6,6 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Publish() {
const { publish, publishStepText, isLoading } = usePublish()
const {
createPricing,
pricingStep,
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
const [ddo, setDdo] = useState<DDO | undefined | null>()
const asset = {

View File

@ -1,5 +1,5 @@
import React from 'react'
import { useOcean, usePricing } from '@oceanprotocol/react'
import { PriceOptions, useOcean, usePricing } from '@oceanprotocol/react'
// import { useOcean, usePublish } from '@oceanprotocol/react'
import { DDO } from '@oceanprotocol/lib'
import { useState } from 'react'
@ -16,14 +16,16 @@ export function Trade() {
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
} = usePricing(new DDO())
const [datatoken, setDatatoken] = useState<string | undefined>()
const handleBuy = async () => {
const tx = await buyDT(datatoken, '1')
const tx = await buyDT('1')
console.log(tx)
}
const handleSell = async () => {
const tx = await buyDT(datatoken, '1')
const tx = await buyDT('1')
console.log(tx)
}
const handleChange = (e: any) => {
@ -37,8 +39,8 @@ export function Trade() {
type: 'fixed',
weightOnDataToken: '',
swapFee: ''
}
const tx = await createPricing(datatoken, priceOptions)
} as PriceOptions
const tx = await createPricing(priceOptions)
console.log(tx)
}
}

View File

@ -25,7 +25,7 @@
"dist/"
],
"dependencies": {
"@oceanprotocol/lib": "^0.9.12",
"@oceanprotocol/lib": "^0.9.14",
"axios": "^0.21.0",
"decimal.js": "^10.2.1",
"web3": "^1.3.0",