mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
get the providerUri for file validation based on user network
* closes #756
This commit is contained in:
parent
3a130c364b
commit
605f77e055
@ -6,22 +6,27 @@ import FileInfo from './Info'
|
||||
import FileInput from './Input'
|
||||
import { InputProps } from '../../../atoms/Input'
|
||||
import { fileinfo } from '../../../../utils/provider'
|
||||
import { useWeb3 } from '../../../../providers/Web3'
|
||||
import { getOceanConfig } from '../../../../utils/ocean'
|
||||
|
||||
export default function FilesInput(props: InputProps): ReactElement {
|
||||
const [field, meta, helpers] = useField(props.name)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [fileUrl, setFileUrl] = useState<string>()
|
||||
const { chainId } = useWeb3()
|
||||
|
||||
function loadFileInfo() {
|
||||
const source = axios.CancelToken.source()
|
||||
const config = getOceanConfig(chainId || 1)
|
||||
|
||||
async function validateUrl() {
|
||||
// TODO: #756 get the providerUri
|
||||
const providerUri = ''
|
||||
|
||||
try {
|
||||
setIsLoading(true)
|
||||
const checkedFile = await fileinfo(fileUrl, providerUri, source.token)
|
||||
const checkedFile = await fileinfo(
|
||||
fileUrl,
|
||||
config?.providerUri,
|
||||
source.token
|
||||
)
|
||||
checkedFile && helpers.setValue([checkedFile])
|
||||
} catch (error) {
|
||||
toast.error('Could not fetch file info. Please check URL and try again')
|
||||
|
Loading…
Reference in New Issue
Block a user