mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Merge pull request #960 from oceanprotocol/fix/issue948-remove-dependency
Integrate provider isValidUrl()
This commit is contained in:
commit
9e315a71f1
@ -1,7 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { consumeFeedback } from '@utils/feedback'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { useOcean } from '@context/Ocean'
|
||||
import { useWeb3 } from '@context/Web3'
|
||||
|
||||
interface UseConsume {
|
||||
@ -66,7 +65,7 @@ function useConsume(): UseConsume {
|
||||
// null,
|
||||
// false
|
||||
// )
|
||||
// LoggerInstance.log('order created', orderId)
|
||||
// LoggerInstance.log('ordercreated', orderId)
|
||||
// setStep(2)
|
||||
// } catch (error) {
|
||||
// setConsumeError(error.message)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||
import { DID, LoggerInstance } from '@oceanprotocol/lib'
|
||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||
|
||||
export interface FileMetadata {
|
||||
index: number
|
||||
@ -31,15 +31,12 @@ export async function getEncryptedFileUrls(
|
||||
}
|
||||
|
||||
export async function getFileInfo(
|
||||
url: string | DID,
|
||||
url: string,
|
||||
providerUrl: string,
|
||||
cancelToken: CancelToken
|
||||
): Promise<FileMetadata[]> {
|
||||
let postBody
|
||||
try {
|
||||
if (url instanceof DID) postBody = { did: url.getDid() }
|
||||
else postBody = { url }
|
||||
|
||||
const postBody = { url }
|
||||
const response: AxiosResponse<FileMetadata[]> = await axios.post(
|
||||
`${providerUrl}/api/v1/services/fileinfo`,
|
||||
postBody,
|
||||
|
@ -1,24 +1,22 @@
|
||||
import React, { ReactElement, useState } from 'react'
|
||||
import { ErrorMessage, useField } from 'formik'
|
||||
import UrlInput from '../URLInput'
|
||||
import { useOcean } from '@context/Ocean'
|
||||
import { InputProps } from '@shared/FormInput'
|
||||
import FileInfo from '../FilesInput/Info'
|
||||
import styles from './index.module.css'
|
||||
import Button from '@shared/atoms/Button'
|
||||
import { initialValues } from 'src/components/Publish/_constants'
|
||||
import { ProviderInstance } from '@oceanprotocol/lib'
|
||||
|
||||
export default function CustomProvider(props: InputProps): ReactElement {
|
||||
const [field, meta, helpers] = useField(props.name)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const { ocean, config } = useOcean()
|
||||
|
||||
async function validateProvider(url: string) {
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
// TODO: #948 Remove ocean.provider.isValidProvider dependency.
|
||||
const isValid = await ocean.provider.isValidProvider(url)
|
||||
const isValid = await ProviderInstance.isValidProvider(url, fetch)
|
||||
helpers.setValue({ url, valid: isValid })
|
||||
helpers.setError(undefined)
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user