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 { useMarketMetadata } from './MarketMetadata'
|
||||||
import { assetStateToString } from '@utils/assetState'
|
import { assetStateToString } from '@utils/assetState'
|
||||||
import { isValidDid } from '@utils/ddo'
|
import { isValidDid } from '@utils/ddo'
|
||||||
|
import { getDummyWeb3 } from '@utils/web3'
|
||||||
|
|
||||||
export interface AssetProviderValue {
|
export interface AssetProviderValue {
|
||||||
isInPurgatory: boolean
|
isInPurgatory: boolean
|
||||||
@ -50,7 +51,7 @@ function AssetProvider({
|
|||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { appConfig } = useMarketMetadata()
|
const { appConfig } = useMarketMetadata()
|
||||||
|
|
||||||
const { chainId, accountId, web3 } = useWeb3()
|
const { chainId, accountId } = useWeb3()
|
||||||
const [isInPurgatory, setIsInPurgatory] = useState(false)
|
const [isInPurgatory, setIsInPurgatory] = useState(false)
|
||||||
const [purgatoryData, setPurgatoryData] = useState<Purgatory>()
|
const [purgatoryData, setPurgatoryData] = useState<Purgatory>()
|
||||||
const [asset, setAsset] = useState<AssetExtended>()
|
const [asset, setAsset] = useState<AssetExtended>()
|
||||||
@ -128,10 +129,13 @@ function AssetProvider({
|
|||||||
async function getInitialPaymentCollector() {
|
async function getInitialPaymentCollector() {
|
||||||
if (!asset?.datatokens || !asset.datatokens[0]?.address) return
|
if (!asset?.datatokens || !asset.datatokens[0]?.address) return
|
||||||
try {
|
try {
|
||||||
|
const web3 = await getDummyWeb3(asset.chainId)
|
||||||
const datatoken = new Datatoken(web3)
|
const datatoken = new Datatoken(web3)
|
||||||
|
console.log('datatoken', datatoken)
|
||||||
const paymentCollector = await datatoken.getPaymentCollector(
|
const paymentCollector = await datatoken.getPaymentCollector(
|
||||||
asset.datatokens[0].address
|
asset.datatokens[0].address
|
||||||
)
|
)
|
||||||
|
console.log('paymentCollector', paymentCollector)
|
||||||
setAsset((prevState) => ({
|
setAsset((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
paymentCollector
|
paymentCollector
|
||||||
@ -141,7 +145,7 @@ function AssetProvider({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getInitialPaymentCollector()
|
getInitialPaymentCollector()
|
||||||
}, [asset?.datatokens, web3])
|
}, [asset?.chainId, asset?.datatokens])
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Helper: Get and set asset access details
|
// Helper: Get and set asset access details
|
||||||
|
@ -3,33 +3,14 @@ import MetaItem from './MetaItem'
|
|||||||
import styles from './MetaFull.module.css'
|
import styles from './MetaFull.module.css'
|
||||||
import Publisher from '@shared/Publisher'
|
import Publisher from '@shared/Publisher'
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
import { getDummyWeb3 } from '@utils/web3'
|
|
||||||
import { Datatoken, LoggerInstance } from '@oceanprotocol/lib'
|
|
||||||
|
|
||||||
export default function MetaFull({
|
export default function MetaFull({
|
||||||
ddo
|
ddo
|
||||||
}: {
|
}: {
|
||||||
ddo: AssetExtended
|
ddo: AssetExtended
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const [paymentCollector, setPaymentCollector] = useState<string>()
|
|
||||||
const { isInPurgatory, assetState } = useAsset()
|
const { isInPurgatory, assetState } = useAsset()
|
||||||
|
console.log('ddo', ddo)
|
||||||
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])
|
|
||||||
|
|
||||||
function DockerImage() {
|
function DockerImage() {
|
||||||
const containerInfo = ddo?.metadata?.algorithm?.container
|
const containerInfo = ddo?.metadata?.algorithm?.container
|
||||||
const { image, tag } = containerInfo
|
const { image, tag } = containerInfo
|
||||||
@ -48,7 +29,7 @@ export default function MetaFull({
|
|||||||
{assetState !== 'Active' && (
|
{assetState !== 'Active' && (
|
||||||
<MetaItem title="Asset State" content={assetState} />
|
<MetaItem title="Asset State" content={assetState} />
|
||||||
)}
|
)}
|
||||||
{paymentCollector && paymentCollector !== ddo?.nft?.owner && (
|
{ddo?.paymentCollector && ddo?.paymentCollector !== ddo?.nft?.owner && (
|
||||||
<MetaItem
|
<MetaItem
|
||||||
title="Revenue Sent To"
|
title="Revenue Sent To"
|
||||||
content={<Publisher account={ddo?.paymentCollector} />}
|
content={<Publisher account={ddo?.paymentCollector} />}
|
||||||
|
Loading…
Reference in New Issue
Block a user