mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
kick out getPaymentCollector completely, use wagmi hooks instead
This commit is contained in:
parent
074a6ccd13
commit
54c7d1ef1a
@ -30,17 +30,3 @@ export function getDevelopmentConfig(): Config {
|
||||
subgraphUri: 'https://v4.subgraph.goerli.oceanprotocol.com'
|
||||
} as Config
|
||||
}
|
||||
|
||||
/**
|
||||
* getPaymentCollector - returns the current paymentCollector
|
||||
* @param dtAddress datatoken address
|
||||
* @return {Promise<string>}
|
||||
*/
|
||||
export async function getPaymentCollector(
|
||||
dtAddress: string,
|
||||
provider: ethers.providers.Provider
|
||||
): Promise<string> {
|
||||
const dtContract = new ethers.Contract(dtAddress, abiDatatoken.abi, provider)
|
||||
const paymentCollector = await dtContract.getPaymentCollector()
|
||||
return paymentCollector
|
||||
}
|
||||
|
@ -1,37 +1,28 @@
|
||||
import React, { ReactElement, useState, useEffect } from 'react'
|
||||
import React, { ReactElement } from 'react'
|
||||
import MetaItem from './MetaItem'
|
||||
import styles from './MetaFull.module.css'
|
||||
import Publisher from '@shared/Publisher'
|
||||
import { useAsset } from '@context/Asset'
|
||||
import { Asset, LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { getPaymentCollector } from '@utils/ocean'
|
||||
import { useProvider } from 'wagmi'
|
||||
import { useContractRead } from 'wagmi'
|
||||
|
||||
import abiDatatoken from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json'
|
||||
|
||||
export default function MetaFull({ ddo }: { ddo: Asset }): ReactElement {
|
||||
const { isInPurgatory, assetState } = useAsset()
|
||||
const provider = useProvider()
|
||||
const { data: paymentCollector, error }: { data: string; error: Error } =
|
||||
useContractRead({
|
||||
address: ddo?.datatokens[0].address,
|
||||
abi: abiDatatoken.abi,
|
||||
functionName: 'getPaymentCollector'
|
||||
})
|
||||
|
||||
const [paymentCollector, setPaymentCollector] = useState<string>()
|
||||
|
||||
useEffect(() => {
|
||||
if (!ddo || !provider) return
|
||||
|
||||
async function getInitialPaymentCollector() {
|
||||
try {
|
||||
const paymentCollector = await getPaymentCollector(
|
||||
ddo.datatokens[0].address,
|
||||
provider
|
||||
)
|
||||
setPaymentCollector(paymentCollector)
|
||||
} catch (error) {
|
||||
LoggerInstance.error(
|
||||
'[MetaFull: getInitialPaymentCollector]',
|
||||
error.message
|
||||
)
|
||||
}
|
||||
}
|
||||
getInitialPaymentCollector()
|
||||
}, [ddo, provider])
|
||||
if (error) {
|
||||
LoggerInstance.error(
|
||||
'[MetaFull: getInitialPaymentCollector]',
|
||||
error.message
|
||||
)
|
||||
}
|
||||
|
||||
function DockerImage() {
|
||||
const containerInfo = ddo?.metadata?.algorithm?.container
|
||||
|
Loading…
Reference in New Issue
Block a user