mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Update ocean.js (#1013)
* update * merge pr #1012 * fix header * fix * abort controller * up next.8 * build fix * update lock * fix * another fix * ssh fix * another ssh fix * remove optional
This commit is contained in:
parent
409f0c51fb
commit
487bcad8b4
23608
package-lock.json
generated
23608
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
"@coingecko/cryptoformat": "^0.4.4",
|
||||
"@loadable/component": "^5.15.2",
|
||||
"@oceanprotocol/art": "^3.2.0",
|
||||
"@oceanprotocol/lib": "^1.0.0-next.6",
|
||||
"@oceanprotocol/lib": "^1.0.0-next.8",
|
||||
"@oceanprotocol/typographies": "^0.1.0",
|
||||
"@portis/web3": "^4.0.6",
|
||||
"@tippyjs/react": "^4.2.6",
|
||||
|
17
src/@hooks/useAbortController.ts
Normal file
17
src/@hooks/useAbortController.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { useRef, useEffect, useCallback } from 'react'
|
||||
export const useAbortController = (): (() => AbortSignal) => {
|
||||
const axiosSource = useRef(null)
|
||||
const newAbortController = useCallback(() => {
|
||||
axiosSource.current = new AbortController()
|
||||
return axiosSource.current.signal
|
||||
}, [])
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (axiosSource.current) axiosSource.current.abort()
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
return newAbortController
|
||||
}
|
@ -1,28 +1,18 @@
|
||||
import axios, { CancelToken, AxiosResponse, Method } from 'axios'
|
||||
import {
|
||||
FileMetadata,
|
||||
LoggerInstance,
|
||||
ProviderInstance
|
||||
} from '@oceanprotocol/lib'
|
||||
|
||||
// TODO: Why do we have these functions ?!?!?!
|
||||
export async function getEncryptedFiles(
|
||||
files: FileMetadata[],
|
||||
providerUrl: string
|
||||
): Promise<string> {
|
||||
try {
|
||||
// https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint
|
||||
const response = await ProviderInstance.encrypt(
|
||||
files,
|
||||
providerUrl,
|
||||
(httpMethod: Method, url: string, body: string, headers: any) => {
|
||||
return axios(url, {
|
||||
method: httpMethod,
|
||||
data: body,
|
||||
headers: headers
|
||||
})
|
||||
}
|
||||
)
|
||||
return response.data
|
||||
const response = await ProviderInstance.encrypt(files, providerUrl)
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error('Error parsing json: ' + error.message)
|
||||
}
|
||||
@ -33,17 +23,7 @@ export async function getFileInfo(
|
||||
providerUrl: string
|
||||
): Promise<FileMetadata[]> {
|
||||
try {
|
||||
const response = await ProviderInstance.checkFileUrl(
|
||||
url,
|
||||
providerUrl,
|
||||
(method: Method, path: string, body: string) => {
|
||||
return fetch(path, {
|
||||
method: method,
|
||||
body: body,
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
}
|
||||
)
|
||||
const response = await ProviderInstance.checkFileUrl(url, providerUrl)
|
||||
return response
|
||||
} catch (error) {
|
||||
LoggerInstance.error(error.message)
|
||||
|
@ -16,7 +16,7 @@ export default function CustomProvider(props: InputProps): ReactElement {
|
||||
setIsLoading(true)
|
||||
|
||||
try {
|
||||
const isValid = await ProviderInstance.isValidProvider(url, fetch)
|
||||
const isValid = await ProviderInstance.isValidProvider(url)
|
||||
helpers.setValue({ url, valid: isValid })
|
||||
helpers.setError(undefined)
|
||||
} catch (error) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {
|
||||
approve,
|
||||
Config,
|
||||
DDO,
|
||||
Erc20CreateParams,
|
||||
@ -226,16 +227,16 @@ export async function createTokensAndPricing(
|
||||
// TODO: discuss swapFeeLiquidityProvider, swapFeeMarketPlaceRunner
|
||||
const poolParams: PoolCreationParams = {
|
||||
ssContract: config.sideStakingAddress,
|
||||
basetokenAddress: config.oceanTokenAddress,
|
||||
basetokenSender: config.erc721FactoryAddress,
|
||||
baseTokenAddress: config.oceanTokenAddress,
|
||||
baseTokenSender: config.erc721FactoryAddress,
|
||||
publisherAddress: accountId,
|
||||
marketFeeCollector: marketFeeAddress,
|
||||
poolTemplateAddress: config.poolTemplateAddress,
|
||||
rate: values.pricing.price.toString(),
|
||||
basetokenDecimals: 18,
|
||||
baseTokenDecimals: 18,
|
||||
vestingAmount: '0',
|
||||
vestedBlocks: 2726000,
|
||||
initialBasetokenLiquidity: values.pricing.amountOcean.toString(),
|
||||
initialBaseTokenLiquidity: values.pricing.amountOcean.toString(),
|
||||
swapFeeLiquidityProvider: 1e15,
|
||||
swapFeeMarketRunner: 1e15
|
||||
}
|
||||
@ -247,7 +248,8 @@ export async function createTokensAndPricing(
|
||||
|
||||
// the spender in this case is the erc721Factory because we are delegating
|
||||
const pool = new Pool(web3, LoggerInstance)
|
||||
const txApprove = await pool.approve(
|
||||
const txApprove = await approve(
|
||||
web3,
|
||||
accountId,
|
||||
config.oceanTokenAddress,
|
||||
config.erc721FactoryAddress,
|
||||
@ -277,7 +279,7 @@ export async function createTokensAndPricing(
|
||||
owner: accountId,
|
||||
marketFeeCollector: marketFeeAddress,
|
||||
baseTokenDecimals: 18,
|
||||
dataTokenDecimals: 18,
|
||||
datatokenDecimals: 18,
|
||||
fixedRate: values.pricing.price.toString(),
|
||||
marketFee: 1e15,
|
||||
withMint: true
|
||||
|
@ -22,10 +22,9 @@ import {
|
||||
DDO
|
||||
} from '@oceanprotocol/lib'
|
||||
import { useSiteMetadata } from '@hooks/useSiteMetadata'
|
||||
import axios, { Method } from 'axios'
|
||||
import { useCancelToken } from '@hooks/useCancelToken'
|
||||
import { getOceanConfig } from '@utils/ocean'
|
||||
import { validationSchema } from './_validation'
|
||||
import { useAbortController } from '@hooks/useAbortController'
|
||||
|
||||
// TODO: restore FormikPersist, add back clear form action
|
||||
const formName = 'ocean-publish-form'
|
||||
@ -41,7 +40,7 @@ export default function PublishPage({
|
||||
const scrollToRef = useRef()
|
||||
const { appConfig } = useSiteMetadata()
|
||||
const nftFactory = useNftFactory()
|
||||
const newCancelToken = useCancelToken()
|
||||
const newAbortController = useAbortController()
|
||||
|
||||
const [feedback, setFeedback] = useState<PublishFeedback>(
|
||||
initialPublishFeedback
|
||||
@ -137,16 +136,9 @@ export default function PublishPage({
|
||||
const encryptedResponse = await ProviderInstance.encrypt(
|
||||
ddo,
|
||||
values.services[0].providerUrl.url,
|
||||
(httpMethod: Method, url: string, body: string, headers: any) => {
|
||||
return axios(url, {
|
||||
method: httpMethod,
|
||||
data: body,
|
||||
headers: headers,
|
||||
cancelToken: newCancelToken()
|
||||
})
|
||||
}
|
||||
newAbortController()
|
||||
)
|
||||
const encryptedDdo = encryptedResponse.data
|
||||
const encryptedDdo = encryptedResponse
|
||||
_encryptedDdo = encryptedDdo
|
||||
LoggerInstance.log('[publish] Got encrypted DDO', encryptedDdo)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user