1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-06-29 00:57:49 +02:00

update example

This commit is contained in:
alexcos20 2020-10-16 00:48:17 -07:00
parent 822cf9aabc
commit b6ddcf069f

View File

@ -10,7 +10,7 @@ export function Trade() {
const { createPricing, buyDT, sellDT, pricingStep, pricingStepText, isLoading: pricingIsLoading, pricingError} = usePricing()
const [did, setDid] = useState<string | undefined>()
const ActionBuy = async () => {
if (!did) return
if (!did) { console.error("No DID"); return}
const ddo = await ocean.assets.resolve(did)
if(ddo){
const tx = await buyDT(ddo.dataToken,'1')
@ -21,7 +21,7 @@ export function Trade() {
}
}
const ActionSell = async () => {
if (!did) return
if (!did) { console.error("No DID"); return}
const ddo = await ocean.assets.resolve(did)
if(ddo){
const tx = await buyDT(ddo.dataToken,'1')
@ -31,9 +31,15 @@ export function Trade() {
console.error("Publish the asset first and create a pricing")
}
}
const handleChange = (e: any) => {
setDid(e.target.value)
}
return (
<>
<div>Trade Datatoken</div>
<div>
DID <input onChange={handleChange}></input>
</div>
<div>
<button onClick={ActionBuy}>Buy 1 DT</button>
</div>