1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-12-23 01:29:49 +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,7 +7,16 @@ import { Metadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Metadata'
export function Trade() { export function Trade() {
const { ocean, accountId } = useOcean() 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 [datatoken, setDatatoken] = useState<string | undefined>()
const handleBuy = async () => { const handleBuy = async () => {
const tx = await buyDT(datatoken, '1') const tx = await buyDT(datatoken, '1')
@ -51,7 +60,6 @@ export function Trade() {
<div> <div>
IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText} IsLoading: {pricingIsLoading.toString()} || Status: {pricingStepText}
</div> </div>
</> </>
) )
} }

View File

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

View File

@ -201,7 +201,14 @@ function usePricing(ddo: DDO): UsePricing {
): Promise<TransactionReceipt | void> { ): Promise<TransactionReceipt | void> {
if (!ocean || !accountId || !dtSymbol) return 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' const isPool = type === 'dynamic'
if (!isPool && !config.fixedRateExchangeAddress) { if (!isPool && !config.fixedRateExchangeAddress) {