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