mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix fileinfo fetching without wallet connected (#803)
This commit is contained in:
parent
6e3a9bc8b6
commit
a82ad003e2
@ -14,10 +14,11 @@ import { useWeb3 } from '../../../providers/Web3'
|
|||||||
import Web3Feedback from '../../molecules/Web3Feedback'
|
import Web3Feedback from '../../molecules/Web3Feedback'
|
||||||
import { getFileInfo } from '../../../utils/provider'
|
import { getFileInfo } from '../../../utils/provider'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { getOceanConfig } from '../../../utils/ocean'
|
||||||
|
|
||||||
export default function AssetActions(): ReactElement {
|
export default function AssetActions(): ReactElement {
|
||||||
const { accountId, balance } = useWeb3()
|
const { accountId, balance } = useWeb3()
|
||||||
const { ocean, config, account } = useOcean()
|
const { ocean, account } = useOcean()
|
||||||
const { price, ddo, isAssetNetwork } = useAsset()
|
const { price, ddo, isAssetNetwork } = useAsset()
|
||||||
|
|
||||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>()
|
||||||
@ -46,7 +47,8 @@ export default function AssetActions(): ReactElement {
|
|||||||
}, [accountId, isAssetNetwork, ddo, ocean])
|
}, [accountId, isAssetNetwork, ddo, ocean])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!config) return
|
const oceanConfig = getOceanConfig(ddo.chainId)
|
||||||
|
if (!oceanConfig) return
|
||||||
|
|
||||||
const source = axios.CancelToken.source()
|
const source = axios.CancelToken.source()
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ export default function AssetActions(): ReactElement {
|
|||||||
try {
|
try {
|
||||||
const fileInfo = await getFileInfo(
|
const fileInfo = await getFileInfo(
|
||||||
DID.parse(`${ddo.id}`),
|
DID.parse(`${ddo.id}`),
|
||||||
config.providerUri,
|
oceanConfig.providerUri,
|
||||||
source.token
|
source.token
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ export default function AssetActions(): ReactElement {
|
|||||||
return () => {
|
return () => {
|
||||||
source.cancel()
|
source.cancel()
|
||||||
}
|
}
|
||||||
}, [config, ddo])
|
}, [ddo])
|
||||||
|
|
||||||
// Get and set user DT balance
|
// Get and set user DT balance
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user