1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-01-25 01:32:08 +01:00

publish tweaks

This commit is contained in:
Matthias Kretschmann 2020-10-19 13:39:14 +02:00
parent bc62cbc22e
commit 1cd3c6055d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 10 additions and 14 deletions

View File

@ -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,

View File

@ -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 (

View File

@ -14,7 +14,7 @@ interface UsePublish {
publish: (
asset: Metadata,
serviceConfigs: ServiceType,
dataTokenOptions: DataTokenOptions,
dataTokenOptions?: DataTokenOptions,
timeout?: number,
providerUri?: string
) => Promise<DDO | undefined | null>
@ -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<number | undefined>()
const [publishStepText, setPublishStepText] = useState<string | undefined>()
@ -46,7 +46,7 @@ function usePublish(): UsePublish {
async function publish(
asset: Metadata,
serviceType: ServiceType,
dataTokenOptions: DataTokenOptions,
dataTokenOptions?: DataTokenOptions,
timeout?: number,
providerUri?: string
): Promise<DDO | undefined | null> {
@ -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)