mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
update payment collector
This commit is contained in:
parent
010a63a0f5
commit
857f922e97
@ -23,6 +23,7 @@ import { useIsMounted } from '@hooks/useIsMounted'
|
||||
import { useMarketMetadata } from './MarketMetadata'
|
||||
import { assetStateToString } from '@utils/assetState'
|
||||
import { isValidDid } from '@utils/ddo'
|
||||
import { getDummyWeb3 } from '@utils/web3'
|
||||
|
||||
export interface AssetProviderValue {
|
||||
isInPurgatory: boolean
|
||||
@ -50,7 +51,7 @@ function AssetProvider({
|
||||
}): ReactElement {
|
||||
const { appConfig } = useMarketMetadata()
|
||||
|
||||
const { chainId, accountId, web3 } = useWeb3()
|
||||
const { chainId, accountId } = useWeb3()
|
||||
const [isInPurgatory, setIsInPurgatory] = useState(false)
|
||||
const [purgatoryData, setPurgatoryData] = useState<Purgatory>()
|
||||
const [asset, setAsset] = useState<AssetExtended>()
|
||||
@ -128,10 +129,13 @@ function AssetProvider({
|
||||
async function getInitialPaymentCollector() {
|
||||
if (!asset?.datatokens || !asset.datatokens[0]?.address) return
|
||||
try {
|
||||
const web3 = await getDummyWeb3(asset.chainId)
|
||||
const datatoken = new Datatoken(web3)
|
||||
console.log('datatoken', datatoken)
|
||||
const paymentCollector = await datatoken.getPaymentCollector(
|
||||
asset.datatokens[0].address
|
||||
)
|
||||
console.log('paymentCollector', paymentCollector)
|
||||
setAsset((prevState) => ({
|
||||
...prevState,
|
||||
paymentCollector
|
||||
@ -141,7 +145,7 @@ function AssetProvider({
|
||||
}
|
||||
}
|
||||
getInitialPaymentCollector()
|
||||
}, [asset?.datatokens, web3])
|
||||
}, [asset?.chainId, asset?.datatokens])
|
||||
|
||||
// -----------------------------------
|
||||
// Helper: Get and set asset access details
|
||||
|
@ -3,33 +3,14 @@ import MetaItem from './MetaItem'
|
||||
import styles from './MetaFull.module.css'
|
||||
import Publisher from '@shared/Publisher'
|
||||
import { useAsset } from '@context/Asset'
|
||||
import { getDummyWeb3 } from '@utils/web3'
|
||||
import { Datatoken, LoggerInstance } from '@oceanprotocol/lib'
|
||||
|
||||
export default function MetaFull({
|
||||
ddo
|
||||
}: {
|
||||
ddo: AssetExtended
|
||||
}): ReactElement {
|
||||
const [paymentCollector, setPaymentCollector] = useState<string>()
|
||||
const { isInPurgatory, assetState } = useAsset()
|
||||
|
||||
useEffect(() => {
|
||||
async function getInitialPaymentCollector() {
|
||||
try {
|
||||
if (!ddo) return
|
||||
const web3 = await getDummyWeb3(ddo.chainId)
|
||||
const datatoken = new Datatoken(web3)
|
||||
setPaymentCollector(
|
||||
await datatoken.getPaymentCollector(ddo.datatokens[0].address)
|
||||
)
|
||||
} catch (error) {
|
||||
LoggerInstance.error('[MetaFull: getInitialPaymentCollector]', error)
|
||||
}
|
||||
}
|
||||
getInitialPaymentCollector()
|
||||
}, [ddo])
|
||||
|
||||
console.log('ddo', ddo)
|
||||
function DockerImage() {
|
||||
const containerInfo = ddo?.metadata?.algorithm?.container
|
||||
const { image, tag } = containerInfo
|
||||
@ -48,7 +29,7 @@ export default function MetaFull({
|
||||
{assetState !== 'Active' && (
|
||||
<MetaItem title="Asset State" content={assetState} />
|
||||
)}
|
||||
{paymentCollector && paymentCollector !== ddo?.nft?.owner && (
|
||||
{ddo?.paymentCollector && ddo?.paymentCollector !== ddo?.nft?.owner && (
|
||||
<MetaItem
|
||||
title="Revenue Sent To"
|
||||
content={<Publisher account={ddo?.paymentCollector} />}
|
||||
|
Loading…
Reference in New Issue
Block a user