mirror of
https://github.com/oceanprotocol/react.git
synced 2025-01-03 18:35:18 +01:00
update example
This commit is contained in:
parent
822cf9aabc
commit
b6ddcf069f
@ -10,7 +10,7 @@ export function Trade() {
|
|||||||
const { createPricing, buyDT, sellDT, pricingStep, pricingStepText, isLoading: pricingIsLoading, pricingError} = usePricing()
|
const { createPricing, buyDT, sellDT, pricingStep, pricingStepText, isLoading: pricingIsLoading, pricingError} = usePricing()
|
||||||
const [did, setDid] = useState<string | undefined>()
|
const [did, setDid] = useState<string | undefined>()
|
||||||
const ActionBuy = async () => {
|
const ActionBuy = async () => {
|
||||||
if (!did) return
|
if (!did) { console.error("No DID"); return}
|
||||||
const ddo = await ocean.assets.resolve(did)
|
const ddo = await ocean.assets.resolve(did)
|
||||||
if(ddo){
|
if(ddo){
|
||||||
const tx = await buyDT(ddo.dataToken,'1')
|
const tx = await buyDT(ddo.dataToken,'1')
|
||||||
@ -21,7 +21,7 @@ export function Trade() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const ActionSell = async () => {
|
const ActionSell = async () => {
|
||||||
if (!did) return
|
if (!did) { console.error("No DID"); return}
|
||||||
const ddo = await ocean.assets.resolve(did)
|
const ddo = await ocean.assets.resolve(did)
|
||||||
if(ddo){
|
if(ddo){
|
||||||
const tx = await buyDT(ddo.dataToken,'1')
|
const tx = await buyDT(ddo.dataToken,'1')
|
||||||
@ -31,9 +31,15 @@ export function Trade() {
|
|||||||
console.error("Publish the asset first and create a pricing")
|
console.error("Publish the asset first and create a pricing")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const handleChange = (e: any) => {
|
||||||
|
setDid(e.target.value)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div>Trade Datatoken</div>
|
<div>Trade Datatoken</div>
|
||||||
|
<div>
|
||||||
|
DID <input onChange={handleChange}></input>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button onClick={ActionBuy}>Buy 1 DT</button>
|
<button onClick={ActionBuy}>Buy 1 DT</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user