From 1cd3c6055da34e1ce97d5a623595aa22cf497a43 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 19 Oct 2020 13:39:14 +0200 Subject: [PATCH] publish tweaks --- src/hooks/useConsume/useConsume.ts | 1 + src/hooks/usePublish/README.md | 12 +++++------- src/hooks/usePublish/usePublish.ts | 11 ++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/hooks/useConsume/useConsume.ts b/src/hooks/useConsume/useConsume.ts index c46215a..8e2677a 100644 --- a/src/hooks/useConsume/useConsume.ts +++ b/src/hooks/useConsume/useConsume.ts @@ -57,6 +57,7 @@ function useConsume(): UseConsume { setConsumeError('Not enough datatokens') } else { setStep(1) + ocean.datatokens.generateDtName() const tokenTransfer = await ocean.assets.order( did as string, serviceType, diff --git a/src/hooks/usePublish/README.md b/src/hooks/usePublish/README.md index 1acab0b..b985aae 100644 --- a/src/hooks/usePublish/README.md +++ b/src/hooks/usePublish/README.md @@ -1,6 +1,6 @@ # `usePublish` -Create datatoken and publish data sets +Publish data sets and create datatokens for them. ## Usage @@ -10,7 +10,7 @@ import { useOcean, usePublish } from '@oceanprotocol/react' import { Metadata } from '@oceanprotocol/lib' export default function MyComponent() { - const { accountId } = useOcean() + const { ocean, accountId } = useOcean() // Publish helpers const { publish, publishStep } = usePublish() @@ -24,12 +24,10 @@ export default function MyComponent() { } } - const dataTokenOptions = { - - } - async function handlePublish() { - const ddo = await publish(metadata, 'access', dataTokenOptions) + const ddo = await publish(metadata, 'access') + // Heads Up! You should now create pricing for your data set + // with the `usePricing()` hook in another step. } return ( diff --git a/src/hooks/usePublish/usePublish.ts b/src/hooks/usePublish/usePublish.ts index 2f37b7f..e87c76a 100644 --- a/src/hooks/usePublish/usePublish.ts +++ b/src/hooks/usePublish/usePublish.ts @@ -14,7 +14,7 @@ interface UsePublish { publish: ( asset: Metadata, serviceConfigs: ServiceType, - dataTokenOptions: DataTokenOptions, + dataTokenOptions?: DataTokenOptions, timeout?: number, providerUri?: string ) => Promise @@ -25,7 +25,7 @@ interface UsePublish { } function usePublish(): UsePublish { - const { ocean, status, account, accountId, config } = useOcean() + const { ocean, status, account } = useOcean() const [isLoading, setIsLoading] = useState(false) const [publishStep, setPublishStep] = useState() const [publishStepText, setPublishStepText] = useState() @@ -46,7 +46,7 @@ function usePublish(): UsePublish { async function publish( asset: Metadata, serviceType: ServiceType, - dataTokenOptions: DataTokenOptions, + dataTokenOptions?: DataTokenOptions, timeout?: number, providerUri?: string ): Promise { @@ -57,10 +57,9 @@ function usePublish(): UsePublish { try { const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z' - let timeout = 0 const services: Service[] = [] - const price = '1' + switch (serviceType) { case 'access': { if (!timeout) timeout = 0 @@ -142,8 +141,6 @@ function usePublish(): UsePublish { .next(setStep) Logger.log('ddo created', ddo) setStep(7) - // await createPricing(priceOptions, ddo.dataToken, tokensToMint) - // setStep(8) return ddo } catch (error) { setPublishError(error.message)