From 11cf51d85beee02eec1217857ec22813063a040d Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Mon, 14 Nov 2022 17:54:37 +0300 Subject: [PATCH 01/15] Adding paymentCOllector to content/pages/editMetadata.json --- content/pages/editMetadata.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/pages/editMetadata.json b/content/pages/editMetadata.json index b70bd3737..173bd5885 100644 --- a/content/pages/editMetadata.json +++ b/content/pages/editMetadata.json @@ -66,6 +66,12 @@ "type": "tags", "placeholder": "e.g. logistics", "required": false + }, + { + "name": "paymentCollector", + "label": "Payment Collector Address", + "placeholder": "e.g. 0X123ABC...", + "required": false } ] } From cbdc81b836f87541a5136cbbe3fd5cf594292be1 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Mon, 14 Nov 2022 18:09:29 +0300 Subject: [PATCH 02/15] Checking if payment collector address is valid using form validation --- src/components/Asset/Edit/_validation.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Asset/Edit/_validation.ts b/src/components/Asset/Edit/_validation.ts index 8d81768fe..afc256153 100644 --- a/src/components/Asset/Edit/_validation.ts +++ b/src/components/Asset/Edit/_validation.ts @@ -1,5 +1,6 @@ import { FileInfo } from '@oceanprotocol/lib' import * as Yup from 'yup' +import web3 from 'web3' export const validationSchema = Yup.object().shape({ name: Yup.string() @@ -41,7 +42,14 @@ export const validationSchema = Yup.object().shape({ .nullable(), timeout: Yup.string().required('Required'), author: Yup.string().nullable(), - tags: Yup.array().nullable() + tags: Yup.array().nullable(), + paymentCollector: Yup.string().test( + 'ValidAddress', + 'Must be a valid Ethereum Address.', + (value) => { + return web3.utils.isAddress(value) + } + ) }) export const computeSettingsValidationSchema = Yup.object().shape({ From 9429af22e2720f699bab60eb6de231a4442b3e5a Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 10:05:12 +0300 Subject: [PATCH 03/15] Populating the edit form with the current payment collector --- src/components/Asset/Edit/EditMetadata.tsx | 1 + src/components/Asset/Edit/FormEditMetadata.tsx | 2 +- src/components/Asset/Edit/_constants.ts | 15 +++++++++++---- src/components/Asset/Edit/_types.ts | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index fa42718de..26639b0c3 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -145,6 +145,7 @@ export default function Edit({ { +): Promise> { + const paymentCollector = await getPaymentCollector(owner) return { name: metadata?.name, description: metadata?.description, @@ -15,7 +21,8 @@ export function getInitialValues( files: [{ url: '', type: '' }], timeout: secondsToString(timeout), author: metadata?.author, - tags: metadata?.tags + tags: metadata?.tags, + paymentCollector } } diff --git a/src/components/Asset/Edit/_types.ts b/src/components/Asset/Edit/_types.ts index f5a972cb6..923aabb5c 100644 --- a/src/components/Asset/Edit/_types.ts +++ b/src/components/Asset/Edit/_types.ts @@ -3,6 +3,7 @@ export interface MetadataEditForm { name: string description: string timeout: string + paymentCollector: string price?: string files: FileInfo[] links?: FileInfo[] From e22407ad43e1403f9626582fe6da0153501ac249 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 10:45:14 +0300 Subject: [PATCH 04/15] setting inital payment collector from EditMetadata --- src/components/Asset/Edit/EditMetadata.tsx | 29 +++++++++++++++++++--- src/components/Asset/Edit/_constants.ts | 16 +++++------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index 26639b0c3..f5eab1bdf 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -1,11 +1,12 @@ -import React, { ReactElement, useState } from 'react' +import React, { ReactElement, useState, useEffect } from 'react' import { Formik } from 'formik' import { LoggerInstance, Metadata, FixedRateExchange, Asset, - Service + Service, + Datatoken } from '@oceanprotocol/lib' import { validationSchema } from './_validation' import { getInitialValues } from './_constants' @@ -36,10 +37,30 @@ export default function Edit({ const { accountId, web3 } = useWeb3() const newAbortController = useAbortController() const [success, setSuccess] = useState() + const [paymentCollector, setPaymentCollector] = useState() const [error, setError] = useState() const isComputeType = asset?.services[0]?.type === 'compute' const hasFeedback = error || success + useEffect(() => { + async function getInitialPaymentCollector() { + let paymentCollector + try { + console.log('owner', asset?.nft.owner) + const datatoken = new Datatoken(web3) + console.log('datatoken', datatoken) + paymentCollector = await datatoken.getPaymentCollector( + asset?.datatokens[0].address + ) + console.log('paymentCollector', paymentCollector) + setPaymentCollector(paymentCollector) + } catch (error) { + console.log(error) + } + } + getInitialPaymentCollector() + }, [asset]) + async function updateFixedPrice(newPrice: string) { const config = getOceanConfig(asset.chainId) @@ -145,10 +166,10 @@ export default function Edit({ { diff --git a/src/components/Asset/Edit/_constants.ts b/src/components/Asset/Edit/_constants.ts index 703955330..35ba73258 100644 --- a/src/components/Asset/Edit/_constants.ts +++ b/src/components/Asset/Edit/_constants.ts @@ -1,18 +1,14 @@ -import { - Metadata, - ServiceComputeOptions, - getPaymentCollector -} from '@oceanprotocol/lib' +import { Metadata, ServiceComputeOptions, Datatoken } from '@oceanprotocol/lib' import { secondsToString } from '@utils/ddo' import { ComputeEditForm, MetadataEditForm } from './_types' +import Web3 from 'web3' -export async function getInitialValues( - owner: string, +export function getInitialValues( metadata: Metadata, timeout: number, - price: string -): Promise> { - const paymentCollector = await getPaymentCollector(owner) + price: string, + paymentCollector: string +): Partial { return { name: metadata?.name, description: metadata?.description, From fd30d5e138754949fcf384cce509561f2d07fe3d Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 11:38:43 +0300 Subject: [PATCH 05/15] Updating paymentCollector on submit --- src/components/Asset/Edit/EditMetadata.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index f5eab1bdf..664ccfe9f 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -46,20 +46,17 @@ export default function Edit({ async function getInitialPaymentCollector() { let paymentCollector try { - console.log('owner', asset?.nft.owner) const datatoken = new Datatoken(web3) - console.log('datatoken', datatoken) paymentCollector = await datatoken.getPaymentCollector( asset?.datatokens[0].address ) - console.log('paymentCollector', paymentCollector) setPaymentCollector(paymentCollector) } catch (error) { - console.log(error) + console.error(error) } } getInitialPaymentCollector() - }, [asset]) + }, [asset, web3]) async function updateFixedPrice(newPrice: string) { const config = getOceanConfig(asset.chainId) @@ -102,6 +99,15 @@ export default function Edit({ values.price !== asset.accessDetails.price && (await updateFixedPrice(values.price)) + if (values.paymentCollector !== paymentCollector) { + const datatoken = new Datatoken(web3) + await datatoken.setPaymentCollector( + asset?.datatokens[0].address, + accountId, + values.paymentCollector + ) + } + if (values.files[0]?.url) { const file = { nftAddress: asset.nftAddress, From 40f3335cfcf972b168709c26e9dc66e65ca76b3b Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 11:48:26 +0300 Subject: [PATCH 06/15] removing unused imports --- src/components/Asset/Edit/_constants.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/Asset/Edit/_constants.ts b/src/components/Asset/Edit/_constants.ts index 35ba73258..99e7b3cbd 100644 --- a/src/components/Asset/Edit/_constants.ts +++ b/src/components/Asset/Edit/_constants.ts @@ -1,7 +1,6 @@ -import { Metadata, ServiceComputeOptions, Datatoken } from '@oceanprotocol/lib' +import { Metadata, ServiceComputeOptions } from '@oceanprotocol/lib' import { secondsToString } from '@utils/ddo' import { ComputeEditForm, MetadataEditForm } from './_types' -import Web3 from 'web3' export function getInitialValues( metadata: Metadata, From 9fca971d77acb49990def970ab2fde3bca2f59b1 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 11:55:06 +0300 Subject: [PATCH 07/15] Adding placeholder for link to the docs --- content/pages/editMetadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/content/pages/editMetadata.json b/content/pages/editMetadata.json index 173bd5885..cd7161741 100644 --- a/content/pages/editMetadata.json +++ b/content/pages/editMetadata.json @@ -71,6 +71,7 @@ "name": "paymentCollector", "label": "Payment Collector Address", "placeholder": "e.g. 0X123ABC...", + "help": "This address will receive the revenue from all sales. More info available in our [docs](TODO: Update docs + Add link here).", "required": false } ] From 6776ffe34d734d650823522f8f4e36647ce4b9be Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 12:40:14 +0300 Subject: [PATCH 08/15] Adding inital outline for test --- .../Asset/Edit/FormEditMetadata.test.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/components/Asset/Edit/FormEditMetadata.test.tsx diff --git a/src/components/Asset/Edit/FormEditMetadata.test.tsx b/src/components/Asset/Edit/FormEditMetadata.test.tsx new file mode 100644 index 000000000..0d64e605f --- /dev/null +++ b/src/components/Asset/Edit/FormEditMetadata.test.tsx @@ -0,0 +1,22 @@ +import { render, screen } from '@testing-library/react' +import React from 'react' +import Formik, { useFormikContext } from 'formik' +import FormEditMetadata from './FormEditMetadata' +import content from '../../../../content/pages/editMetadata.json' + +jest.mock('formik') + +describe('src/components/Asset/Edit/FormEditMetadata.tsx', () => { + const useFormikContextMock = jest.spyOn(Formik, 'useFormikContext') + + it('renders fixed price', () => { + // render() + // (useFormikContext as jest.Mock). + // + expect(screen.getByText('New Title')).toBeInTheDocument() + }) +}) From c2514debf05dc46a1f3ee9da7bb4e27d4ea4fde9 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Tue, 15 Nov 2022 18:58:07 +0300 Subject: [PATCH 09/15] Adding test for FormActions --- .../Asset/Edit/FormActions.test.tsx | 15 ++++++++++ .../Asset/Edit/FormEditMetadata.test.tsx | 30 ++++++++++++------- 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 src/components/Asset/Edit/FormActions.test.tsx diff --git a/src/components/Asset/Edit/FormActions.test.tsx b/src/components/Asset/Edit/FormActions.test.tsx new file mode 100644 index 000000000..0f3899d7b --- /dev/null +++ b/src/components/Asset/Edit/FormActions.test.tsx @@ -0,0 +1,15 @@ +import { render, screen } from '@testing-library/react' +import React from 'react' +import { useFormikContext } from 'formik' +import FormActions from './FormActions' + +jest.mock('formik') + +describe('src/components/Asset/Edit/FormActions.tsx', () => { + it('renders fixed price', () => { + const isValid = true + ;(useFormikContext as jest.Mock).mockReturnValue([isValid]) + render() + expect(screen.getByText('Submit')).toBeInTheDocument() + }) +}) diff --git a/src/components/Asset/Edit/FormEditMetadata.test.tsx b/src/components/Asset/Edit/FormEditMetadata.test.tsx index 0d64e605f..0cf9441b1 100644 --- a/src/components/Asset/Edit/FormEditMetadata.test.tsx +++ b/src/components/Asset/Edit/FormEditMetadata.test.tsx @@ -1,22 +1,32 @@ import { render, screen } from '@testing-library/react' import React from 'react' -import Formik, { useFormikContext } from 'formik' +import Formik, { FormikErrors, FormikTouched, FormikState } from 'formik' import FormEditMetadata from './FormEditMetadata' import content from '../../../../content/pages/editMetadata.json' -jest.mock('formik') +let fieldMock = {} +const metaMock = {} +const helperMock = {} + +jest.mock('formik', () => ({ + ...jest.requireActual('formik'), + useField: jest.fn(() => { + return [fieldMock, metaMock, helperMock] + }) +})) describe('src/components/Asset/Edit/FormEditMetadata.tsx', () => { - const useFormikContextMock = jest.spyOn(Formik, 'useFormikContext') + // const useFormikContextMock = jest.spyOn(Formik, 'useFormikContext') it('renders fixed price', () => { - // render() - // (useFormikContext as jest.Mock). - // + fieldMock = { foo: 'bar' } + render( + + ) expect(screen.getByText('New Title')).toBeInTheDocument() }) }) From 36a88674b4723141d368bb79d599fcf058d0a351 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 16 Nov 2022 11:03:51 +0300 Subject: [PATCH 10/15] Deleting unused test --- .../Asset/Edit/FormEditMetadata.test.tsx | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/components/Asset/Edit/FormEditMetadata.test.tsx diff --git a/src/components/Asset/Edit/FormEditMetadata.test.tsx b/src/components/Asset/Edit/FormEditMetadata.test.tsx deleted file mode 100644 index 0cf9441b1..000000000 --- a/src/components/Asset/Edit/FormEditMetadata.test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { render, screen } from '@testing-library/react' -import React from 'react' -import Formik, { FormikErrors, FormikTouched, FormikState } from 'formik' -import FormEditMetadata from './FormEditMetadata' -import content from '../../../../content/pages/editMetadata.json' - -let fieldMock = {} -const metaMock = {} -const helperMock = {} - -jest.mock('formik', () => ({ - ...jest.requireActual('formik'), - useField: jest.fn(() => { - return [fieldMock, metaMock, helperMock] - }) -})) - -describe('src/components/Asset/Edit/FormEditMetadata.tsx', () => { - // const useFormikContextMock = jest.spyOn(Formik, 'useFormikContext') - - it('renders fixed price', () => { - fieldMock = { foo: 'bar' } - render( - - ) - expect(screen.getByText('New Title')).toBeInTheDocument() - }) -}) From c65a1070aadd0c2ada545e14ded5507668876bac Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 16 Nov 2022 14:29:33 +0300 Subject: [PATCH 11/15] Updating link to the docs --- content/pages/editMetadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/pages/editMetadata.json b/content/pages/editMetadata.json index cd7161741..15da8b4d6 100644 --- a/content/pages/editMetadata.json +++ b/content/pages/editMetadata.json @@ -71,7 +71,7 @@ "name": "paymentCollector", "label": "Payment Collector Address", "placeholder": "e.g. 0X123ABC...", - "help": "This address will receive the revenue from all sales. More info available in our [docs](TODO: Update docs + Add link here).", + "help": "This address will receive the revenue from all sales. More info available in our [docs](https://docs.oceanprotocol.com/core-concepts/datanft-and-datatoken#revenue).", "required": false } ] From 105343435cbe6ad2e3685a345e78d35c9d147e8d Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 16 Nov 2022 18:05:16 +0300 Subject: [PATCH 12/15] Showing revenue account on asset detail page if it is different to the owner account --- .../Asset/AssetContent/MetaFull.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/Asset/AssetContent/MetaFull.tsx b/src/components/Asset/AssetContent/MetaFull.tsx index d6dabd1d1..f2bbeaea9 100644 --- a/src/components/Asset/AssetContent/MetaFull.tsx +++ b/src/components/Asset/AssetContent/MetaFull.tsx @@ -1,12 +1,31 @@ -import React, { ReactElement } from 'react' +import React, { ReactElement, useState, useEffect } from 'react' import MetaItem from './MetaItem' import styles from './MetaFull.module.css' import Publisher from '@shared/Publisher' import { useAsset } from '@context/Asset' -import { Asset } from '@oceanprotocol/lib' +import { useWeb3 } from '@context/Web3' +import { Asset, Datatoken } from '@oceanprotocol/lib' export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { + const [paymentCollector, setPaymentCollector] = useState() const { isInPurgatory } = useAsset() + const { web3 } = useWeb3() + + useEffect(() => { + async function getInitialPaymentCollector() { + let paymentCollector + try { + const datatoken = new Datatoken(web3) + paymentCollector = await datatoken.getPaymentCollector( + ddo.datatokens[0].address + ) + setPaymentCollector(paymentCollector) + } catch (error) { + console.error(error) + } + } + getInitialPaymentCollector() + }, [ddo, web3]) function DockerImage() { const containerInfo = ddo?.metadata?.algorithm?.container @@ -23,6 +42,12 @@ export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { title="Owner" content={} /> + {paymentCollector !== ddo?.nft?.owner && ( + } + /> + )} {ddo?.metadata?.type === 'algorithm' && ddo?.metadata?.algorithm && ( } /> From 2265d750a547cef5349aa72a11f8fc6294a44da7 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 16 Nov 2022 18:08:59 +0300 Subject: [PATCH 13/15] Replacing console.error with loggerinstance.error --- src/components/Asset/AssetContent/MetaFull.tsx | 4 ++-- src/components/Asset/Edit/EditMetadata.tsx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Asset/AssetContent/MetaFull.tsx b/src/components/Asset/AssetContent/MetaFull.tsx index f2bbeaea9..038601ca6 100644 --- a/src/components/Asset/AssetContent/MetaFull.tsx +++ b/src/components/Asset/AssetContent/MetaFull.tsx @@ -4,7 +4,7 @@ import styles from './MetaFull.module.css' import Publisher from '@shared/Publisher' import { useAsset } from '@context/Asset' import { useWeb3 } from '@context/Web3' -import { Asset, Datatoken } from '@oceanprotocol/lib' +import { Asset, Datatoken, LoggerInstance } from '@oceanprotocol/lib' export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { const [paymentCollector, setPaymentCollector] = useState() @@ -21,7 +21,7 @@ export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { ) setPaymentCollector(paymentCollector) } catch (error) { - console.error(error) + LoggerInstance.error('[MetaFull: getInitialPaymentCollector]', error) } } getInitialPaymentCollector() diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index 664ccfe9f..b1b05d5ef 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -52,7 +52,10 @@ export default function Edit({ ) setPaymentCollector(paymentCollector) } catch (error) { - console.error(error) + LoggerInstance.error( + '[EditMetadata: getInitialPaymentCollector]', + error + ) } } getInitialPaymentCollector() From 5ab6b7dc66b62f88ecb275f26e82f5794df31cd4 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 17 Nov 2022 13:36:58 +0300 Subject: [PATCH 14/15] Setting payment collector inline --- src/components/Asset/AssetContent/MetaFull.tsx | 6 ++---- src/components/Asset/Edit/EditMetadata.tsx | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/Asset/AssetContent/MetaFull.tsx b/src/components/Asset/AssetContent/MetaFull.tsx index 038601ca6..f662fa374 100644 --- a/src/components/Asset/AssetContent/MetaFull.tsx +++ b/src/components/Asset/AssetContent/MetaFull.tsx @@ -13,13 +13,11 @@ export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { useEffect(() => { async function getInitialPaymentCollector() { - let paymentCollector try { const datatoken = new Datatoken(web3) - paymentCollector = await datatoken.getPaymentCollector( - ddo.datatokens[0].address + setPaymentCollector( + await datatoken.getPaymentCollector(ddo.datatokens[0].address) ) - setPaymentCollector(paymentCollector) } catch (error) { LoggerInstance.error('[MetaFull: getInitialPaymentCollector]', error) } diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index b1b05d5ef..ef727b591 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -47,10 +47,9 @@ export default function Edit({ let paymentCollector try { const datatoken = new Datatoken(web3) - paymentCollector = await datatoken.getPaymentCollector( - asset?.datatokens[0].address + setPaymentCollector( + await datatoken.getPaymentCollector(ddo.datatokens[0].address) ) - setPaymentCollector(paymentCollector) } catch (error) { LoggerInstance.error( '[EditMetadata: getInitialPaymentCollector]', From d51538a32f0498641d9166e39be2526c7efa1645 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 17 Nov 2022 13:39:49 +0300 Subject: [PATCH 15/15] Only showing payment collector if it is different to the owner --- src/components/Asset/AssetContent/MetaFull.tsx | 2 +- src/components/Asset/Edit/EditMetadata.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/Asset/AssetContent/MetaFull.tsx b/src/components/Asset/AssetContent/MetaFull.tsx index f662fa374..f01d71915 100644 --- a/src/components/Asset/AssetContent/MetaFull.tsx +++ b/src/components/Asset/AssetContent/MetaFull.tsx @@ -40,7 +40,7 @@ export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement { title="Owner" content={} /> - {paymentCollector !== ddo?.nft?.owner && ( + {paymentCollector && paymentCollector !== ddo?.nft?.owner && ( } diff --git a/src/components/Asset/Edit/EditMetadata.tsx b/src/components/Asset/Edit/EditMetadata.tsx index ef727b591..6ba94e35f 100644 --- a/src/components/Asset/Edit/EditMetadata.tsx +++ b/src/components/Asset/Edit/EditMetadata.tsx @@ -44,11 +44,10 @@ export default function Edit({ useEffect(() => { async function getInitialPaymentCollector() { - let paymentCollector try { const datatoken = new Datatoken(web3) setPaymentCollector( - await datatoken.getPaymentCollector(ddo.datatokens[0].address) + await datatoken.getPaymentCollector(asset?.datatokens[0].address) ) } catch (error) { LoggerInstance.error(