From 105343435cbe6ad2e3685a345e78d35c9d147e8d Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 16 Nov 2022 18:05:16 +0300 Subject: [PATCH] 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 && ( } />