From 824a7c2feb5a7d51605ee0797fea6b8eb6d4d7d2 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Wed, 21 Oct 2020 07:57:00 -0700 Subject: [PATCH 1/3] add sleep --- src/hooks/usePublish/usePublish.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hooks/usePublish/usePublish.ts b/src/hooks/usePublish/usePublish.ts index fbd5055..dd4d992 100644 --- a/src/hooks/usePublish/usePublish.ts +++ b/src/hooks/usePublish/usePublish.ts @@ -35,6 +35,11 @@ function usePublish(): UsePublish { setPublishStep(index) index && setPublishStepText(publishFeedback[index]) } + function sleep(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) + } /** * Publish an asset.It also creates the datatoken, mints tokens and gives the market allowance * @param {Metadata} asset The metadata of the asset. @@ -141,6 +146,7 @@ function usePublish(): UsePublish { ) .next(setStep) Logger.log('ddo created', ddo) + await sleep(20000) setStep(7) return ddo } catch (error) { From 658f432873a9b3e0db099afce9b066e561c35f66 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Wed, 21 Oct 2020 08:00:33 -0700 Subject: [PATCH 2/3] refactor --- src/hooks/usePublish/usePublish.ts | 9 ++------- src/utils/index.ts | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/hooks/usePublish/usePublish.ts b/src/hooks/usePublish/usePublish.ts index dd4d992..2fc88ee 100644 --- a/src/hooks/usePublish/usePublish.ts +++ b/src/hooks/usePublish/usePublish.ts @@ -8,7 +8,7 @@ import { useState } from 'react' import { DataTokenOptions } from './DataTokenOptions' import { useOcean } from 'providers' import ProviderStatus from 'providers/OceanProvider/ProviderStatus' -import { publishFeedback } from 'utils' +import { publishFeedback , sleep } from 'utils' interface UsePublish { publish: ( @@ -35,11 +35,6 @@ function usePublish(): UsePublish { setPublishStep(index) index && setPublishStepText(publishFeedback[index]) } - function sleep(ms: number) { - return new Promise((resolve) => { - setTimeout(resolve, ms) - }) - } /** * Publish an asset.It also creates the datatoken, mints tokens and gives the market allowance * @param {Metadata} asset The metadata of the asset. @@ -146,7 +141,7 @@ function usePublish(): UsePublish { ) .next(setStep) Logger.log('ddo created', ddo) - await sleep(20000) + await sleep(15000) setStep(7) return ddo } catch (error) { diff --git a/src/utils/index.ts b/src/utils/index.ts index d3114b6..5483e6c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -39,3 +39,9 @@ export const publishFeedback: { [key in number]: string } = { } export * from './web3' + +export function sleep(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +} From 2dd83a6502339edc3416c7188d0751649a69ec67 Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Wed, 21 Oct 2020 08:02:36 -0700 Subject: [PATCH 3/3] fix lint --- src/hooks/usePublish/usePublish.ts | 2 +- src/utils/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/usePublish/usePublish.ts b/src/hooks/usePublish/usePublish.ts index 2fc88ee..de99aa7 100644 --- a/src/hooks/usePublish/usePublish.ts +++ b/src/hooks/usePublish/usePublish.ts @@ -8,7 +8,7 @@ import { useState } from 'react' import { DataTokenOptions } from './DataTokenOptions' import { useOcean } from 'providers' import ProviderStatus from 'providers/OceanProvider/ProviderStatus' -import { publishFeedback , sleep } from 'utils' +import { publishFeedback, sleep } from 'utils' interface UsePublish { publish: ( diff --git a/src/utils/index.ts b/src/utils/index.ts index 5483e6c..5106ca7 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -40,7 +40,7 @@ export const publishFeedback: { [key in number]: string } = { export * from './web3' -export function sleep(ms: number) { +export function sleep(ms: number): Promise { return new Promise((resolve) => { setTimeout(resolve, ms) })