1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-12-22 17:23:32 +01:00
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
mihaisc 2020-10-26 16:37:23 +02:00
parent 9791450b48
commit 76a5953caf
No known key found for this signature in database
GPG Key ID: 4FB0C2329B4C6E29
3 changed files with 31 additions and 15 deletions

View File

@ -7,21 +7,30 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Trade() {
const { ocean, accountId } = useOcean()
const { createPricing,buyDT,sellDT,mint,pricingStep,pricingStepText,pricingIsLoading, pricingError} = usePricing()
const {
createPricing,
buyDT,
sellDT,
mint,
pricingStep,
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
const [datatoken, setDatatoken] = useState<string | undefined>()
const handleBuy = async () => {
const tx = await buyDT(datatoken,'1')
const tx = await buyDT(datatoken, '1')
console.log(tx)
}
const handleSell = async () => {
const tx = await buyDT(datatoken,'1')
console.log(tx)
const tx = await buyDT(datatoken, '1')
console.log(tx)
}
const handleChange = (e: any) => {
setDatatoken(e.target.value)
}
const handlePostForSale = async () => {
if(datatoken){
if (datatoken) {
const priceOptions = {
price: 7,
dtAmount: 10,
@ -29,7 +38,7 @@ export function Trade() {
weightOnDataToken: '',
swapFee: ''
}
const tx = await createPricing(datatoken,priceOptions)
const tx = await createPricing(datatoken, priceOptions)
console.log(tx)
}
}
@ -51,7 +60,6 @@ export function Trade() {
<div>
IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText}
</div>
</>
)
}

View File

@ -6,7 +6,13 @@ 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 {
createPricing,
pricingStep,
pricingStepText,
pricingIsLoading,
pricingError
} = usePricing()
const [ddo, setDdo] = useState<DDO | undefined | null>()
const asset = {
@ -31,16 +37,12 @@ export function Publish() {
}
const publishAsset = async () => {
const datatokenOptions = {
}
const datatokenOptions = {}
const ddo = await publish(asset as Metadata, 'access', datatokenOptions)
console.log(ddo)
setDdo(ddo)
}
return (
<>
<div>Publish</div>
@ -51,7 +53,6 @@ export function Publish() {
IsLoading: {isLoading.toString()} || Status: {publishStepText}
</div>
<div>DID: {ddo && ddo.id} </div>
</>
)
}

View File

@ -201,7 +201,14 @@ function usePricing(ddo: DDO): UsePricing {
): Promise<TransactionReceipt | void> {
if (!ocean || !accountId || !dtSymbol) return
const { type, dtAmount,oceanAmount, price, weightOnDataToken, swapFee } = priceOptions
const {
type,
dtAmount,
oceanAmount,
price,
weightOnDataToken,
swapFee
} = priceOptions
const isPool = type === 'dynamic'
if (!isPool && !config.fixedRateExchangeAddress) {