mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Provider multichain (#1879)
* prepare for provider multi chain * use oceanjs pre-release version 2.7.0-next.0 * use oceanjs pre-release version 2.7.0-next.1 * fix isValid provider and isCompatible checks and use oceanjs pre-release version 2.7.0-next.2 * fix build * fix compute to data environments setting * fix build * bump oceanjs lib to 2.7.0
This commit is contained in:
parent
1ebfbca11e
commit
5b4a640476
14
package-lock.json
generated
14
package-lock.json
generated
@ -15,7 +15,7 @@
|
|||||||
"@coingecko/cryptoformat": "^0.5.4",
|
"@coingecko/cryptoformat": "^0.5.4",
|
||||||
"@loadable/component": "^5.15.2",
|
"@loadable/component": "^5.15.2",
|
||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^2.6.1",
|
"@oceanprotocol/lib": "^2.7.0",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@oceanprotocol/use-dark-mode": "^2.4.3",
|
"@oceanprotocol/use-dark-mode": "^2.4.3",
|
||||||
"@tippyjs/react": "^4.2.6",
|
"@tippyjs/react": "^4.2.6",
|
||||||
@ -4731,9 +4731,9 @@
|
|||||||
"integrity": "sha512-I6xoADZpP/8EyN3VWZ+dLYv24DbJj3xzmSDcYv0FolXeAUF3FluzminL5AgQtAaoyUtlHl1D3ij1B++KupWcQQ=="
|
"integrity": "sha512-I6xoADZpP/8EyN3VWZ+dLYv24DbJj3xzmSDcYv0FolXeAUF3FluzminL5AgQtAaoyUtlHl1D3ij1B++KupWcQQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@oceanprotocol/lib": {
|
"node_modules/@oceanprotocol/lib": {
|
||||||
"version": "2.6.1",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-2.7.0.tgz",
|
||||||
"integrity": "sha512-KkebGwOis8pJTqHAI+mDNLyAvcOJ9RIIs5uqyjsc3PGFFheNHeKak2tMYKIIZQSc95pdr+6erJbo6ZCkEL67wQ==",
|
"integrity": "sha512-mSisB8mOVQLg6CJ4Fjp2oa6NAr/zc+yh/2x8fdjSzzZPN23WlmpPkluHeCIKN5rQDqDIGHXCntfyCaVp5hGMnw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/contracts": "^1.1.8",
|
"@oceanprotocol/contracts": "^1.1.8",
|
||||||
"bignumber.js": "^9.1.0",
|
"bignumber.js": "^9.1.0",
|
||||||
@ -50601,9 +50601,9 @@
|
|||||||
"integrity": "sha512-I6xoADZpP/8EyN3VWZ+dLYv24DbJj3xzmSDcYv0FolXeAUF3FluzminL5AgQtAaoyUtlHl1D3ij1B++KupWcQQ=="
|
"integrity": "sha512-I6xoADZpP/8EyN3VWZ+dLYv24DbJj3xzmSDcYv0FolXeAUF3FluzminL5AgQtAaoyUtlHl1D3ij1B++KupWcQQ=="
|
||||||
},
|
},
|
||||||
"@oceanprotocol/lib": {
|
"@oceanprotocol/lib": {
|
||||||
"version": "2.6.1",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-2.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-2.7.0.tgz",
|
||||||
"integrity": "sha512-KkebGwOis8pJTqHAI+mDNLyAvcOJ9RIIs5uqyjsc3PGFFheNHeKak2tMYKIIZQSc95pdr+6erJbo6ZCkEL67wQ==",
|
"integrity": "sha512-mSisB8mOVQLg6CJ4Fjp2oa6NAr/zc+yh/2x8fdjSzzZPN23WlmpPkluHeCIKN5rQDqDIGHXCntfyCaVp5hGMnw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@oceanprotocol/contracts": "^1.1.8",
|
"@oceanprotocol/contracts": "^1.1.8",
|
||||||
"bignumber.js": "^9.1.0",
|
"bignumber.js": "^9.1.0",
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"jest": "jest -c .jest/jest.config.js",
|
"jest": "jest -c .jest/jest.config.js",
|
||||||
"jest:watch": "jest -c .jest/jest.config.js --watch",
|
"jest:watch": "jest -c .jest/jest.config.js --watch",
|
||||||
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
|
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
|
||||||
|
"lint:fix": "eslint --ignore-path .gitignore --ext .ts,.tsx . --fix",
|
||||||
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write",
|
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write",
|
||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"deploy:s3": "bash scripts/deploy-s3.sh",
|
"deploy:s3": "bash scripts/deploy-s3.sh",
|
||||||
@ -28,7 +29,7 @@
|
|||||||
"@coingecko/cryptoformat": "^0.5.4",
|
"@coingecko/cryptoformat": "^0.5.4",
|
||||||
"@loadable/component": "^5.15.2",
|
"@loadable/component": "^5.15.2",
|
||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^2.6.1",
|
"@oceanprotocol/lib": "^2.7.0",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@oceanprotocol/use-dark-mode": "^2.4.3",
|
"@oceanprotocol/use-dark-mode": "^2.4.3",
|
||||||
"@tippyjs/react": "^4.2.6",
|
"@tippyjs/react": "^4.2.6",
|
||||||
|
@ -143,8 +143,12 @@ export async function getComputeEnviroment(
|
|||||||
const computeEnvs = await ProviderInstance.getComputeEnvironments(
|
const computeEnvs = await ProviderInstance.getComputeEnvironments(
|
||||||
asset.services[0].serviceEndpoint
|
asset.services[0].serviceEndpoint
|
||||||
)
|
)
|
||||||
if (!computeEnvs[0]) return null
|
const computeEnv = Array.isArray(computeEnvs)
|
||||||
return computeEnvs[0]
|
? computeEnvs[0]
|
||||||
|
: computeEnvs[asset.chainId][0]
|
||||||
|
|
||||||
|
if (!computeEnv) return null
|
||||||
|
return computeEnv
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
LoggerInstance.error('[compute] Fetch compute enviroment: ', e.message)
|
LoggerInstance.error('[compute] Fetch compute enviroment: ', e.message)
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ export async function setNftMetadata(
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const encryptedDdo = await ProviderInstance.encrypt(
|
const encryptedDdo = await ProviderInstance.encrypt(
|
||||||
asset,
|
asset,
|
||||||
|
asset.chainId,
|
||||||
asset.services[0].serviceEndpoint,
|
asset.services[0].serviceEndpoint,
|
||||||
signal
|
signal
|
||||||
)
|
)
|
||||||
@ -138,6 +139,7 @@ export async function setNFTMetadataAndTokenURI(
|
|||||||
): Promise<TransactionReceipt> {
|
): Promise<TransactionReceipt> {
|
||||||
const encryptedDdo = await ProviderInstance.encrypt(
|
const encryptedDdo = await ProviderInstance.encrypt(
|
||||||
asset,
|
asset,
|
||||||
|
asset.chainId,
|
||||||
asset.services[0].serviceEndpoint,
|
asset.services[0].serviceEndpoint,
|
||||||
signal
|
signal
|
||||||
)
|
)
|
||||||
|
@ -66,6 +66,7 @@ export async function order(
|
|||||||
|
|
||||||
const filesEncrypted = await getEncryptedFiles(
|
const filesEncrypted = await getEncryptedFiles(
|
||||||
asset.services[0].files,
|
asset.services[0].files,
|
||||||
|
asset.chainId,
|
||||||
asset.services[0].serviceEndpoint
|
asset.services[0].serviceEndpoint
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,24 +13,12 @@ import {
|
|||||||
ProviderInstance,
|
ProviderInstance,
|
||||||
UrlFile
|
UrlFile
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
|
import { chainIds } from 'app.config'
|
||||||
import { QueryHeader } from '@shared/FormInput/InputElement/Headers'
|
import { QueryHeader } from '@shared/FormInput/InputElement/Headers'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { AbiItem } from 'web3-utils/types'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { getValidUntilTime } from './compute'
|
import { getValidUntilTime } from './compute'
|
||||||
|
|
||||||
export async function getEncryptedFiles(
|
|
||||||
files: any,
|
|
||||||
providerUrl: string
|
|
||||||
): Promise<string> {
|
|
||||||
try {
|
|
||||||
// https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint
|
|
||||||
const response = await ProviderInstance.encrypt(files, providerUrl)
|
|
||||||
return response
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error parsing json: ' + error.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function initializeProviderForCompute(
|
export async function initializeProviderForCompute(
|
||||||
dataset: AssetExtended,
|
dataset: AssetExtended,
|
||||||
algorithm: AssetExtended,
|
algorithm: AssetExtended,
|
||||||
@ -55,11 +43,6 @@ export async function initializeProviderForCompute(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filesEncrypted = await getEncryptedFiles(
|
|
||||||
dataset.services[0].files,
|
|
||||||
dataset.services[0].serviceEndpoint
|
|
||||||
)
|
|
||||||
|
|
||||||
return await ProviderInstance.initializeCompute(
|
return await ProviderInstance.initializeCompute(
|
||||||
[computeAsset],
|
[computeAsset],
|
||||||
computeAlgo,
|
computeAlgo,
|
||||||
@ -74,6 +57,21 @@ export async function initializeProviderForCompute(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Why do we have these one line functions ?!?!?!
|
||||||
|
export async function getEncryptedFiles(
|
||||||
|
files: any,
|
||||||
|
chainId: number,
|
||||||
|
providerUrl: string
|
||||||
|
): Promise<string> {
|
||||||
|
try {
|
||||||
|
// https://github.com/oceanprotocol/provider/blob/v4main/API.md#encrypt-endpoint
|
||||||
|
const response = await ProviderInstance.encrypt(files, chainId, providerUrl)
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing json: ' + error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function getFileDidInfo(
|
export async function getFileDidInfo(
|
||||||
did: string,
|
did: string,
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
composes: input from '@shared/FormInput/InputElement/index.module.css';
|
composes: input from '@shared/FormInput/InputElement/index.module.css';
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputMethod {
|
.inputMethod {
|
||||||
composes: input from '@shared/FormInput/InputElement/index.module.css';
|
composes: input from '@shared/FormInput/InputElement/index.module.css';
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
|
@ -40,10 +40,15 @@ export default function CustomProvider(props: InputProps): ReactElement {
|
|||||||
const providerResponse = await axios.get(field.value.url, {
|
const providerResponse = await axios.get(field.value.url, {
|
||||||
cancelToken: newCancelToken()
|
cancelToken: newCancelToken()
|
||||||
})
|
})
|
||||||
const providerChainId = providerResponse?.data?.chainId
|
|
||||||
const userChainId = chainId || 1
|
const userChainId = chainId || 1
|
||||||
|
const providerChain =
|
||||||
|
providerResponse?.data?.chainId || providerResponse?.data?.chainIds
|
||||||
|
|
||||||
if (providerChainId !== userChainId)
|
const isCompatible =
|
||||||
|
providerChain === userChainId
|
||||||
|
? true
|
||||||
|
: !!(providerChain.length > 0 && providerChain.includes(userChainId))
|
||||||
|
if (!isCompatible)
|
||||||
throw Error(
|
throw Error(
|
||||||
'✗ This provider is incompatible with the network your wallet is connected to.'
|
'✗ This provider is incompatible with the network your wallet is connected to.'
|
||||||
)
|
)
|
||||||
|
@ -47,7 +47,8 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.codemirror, .textarea {
|
.codemirror,
|
||||||
|
.textarea {
|
||||||
composes: input;
|
composes: input;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,7 @@ export default function Edit({
|
|||||||
|
|
||||||
const filesEncrypted = await getEncryptedFiles(
|
const filesEncrypted = await getEncryptedFiles(
|
||||||
file,
|
file,
|
||||||
|
asset.chainId,
|
||||||
asset.services[0].serviceEndpoint
|
asset.services[0].serviceEndpoint
|
||||||
)
|
)
|
||||||
updatedFiles = filesEncrypted
|
updatedFiles = filesEncrypted
|
||||||
|
@ -148,7 +148,7 @@ export async function transformPublishFormToDdo(
|
|||||||
!isPreview &&
|
!isPreview &&
|
||||||
files?.length &&
|
files?.length &&
|
||||||
files[0].valid &&
|
files[0].valid &&
|
||||||
(await getEncryptedFiles(file, providerUrl.url))
|
(await getEncryptedFiles(file, chainId, providerUrl.url))
|
||||||
|
|
||||||
const newService: Service = {
|
const newService: Service = {
|
||||||
id: getHash(datatokenAddress + filesEncrypted),
|
id: getHash(datatokenAddress + filesEncrypted),
|
||||||
|
@ -140,6 +140,7 @@ export default function PublishPage({
|
|||||||
|
|
||||||
const ddoEncrypted = await ProviderInstance.encrypt(
|
const ddoEncrypted = await ProviderInstance.encrypt(
|
||||||
ddo,
|
ddo,
|
||||||
|
ddo.chainId,
|
||||||
values.services[0].providerUrl.url,
|
values.services[0].providerUrl.url,
|
||||||
newAbortController()
|
newAbortController()
|
||||||
)
|
)
|
||||||
|
@ -131,7 +131,6 @@ ul li {
|
|||||||
color: var(--font-color-heading);
|
color: var(--font-color-heading);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
form,
|
form,
|
||||||
fieldset {
|
fieldset {
|
||||||
border: 0;
|
border: 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".", // This must be specified if "paths" is.
|
"baseUrl": ".", // This must be specified if "paths" is.
|
||||||
"target": "es2015",
|
"target": "es2015",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user