mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Merge branch 'feature/v4-c2d' into fix/issue-1069-c2d-unsupported-networks
This commit is contained in:
commit
515eb19cbf
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#NEXT_PUBLIC_INFURA_PROJECT_ID="xxx"
|
#NEXT_PUBLIC_INFURA_PROJECT_ID="xxx"
|
||||||
#NEXT_PUBLIC_MARKET_FEE_ADDRESS="0xxx"
|
#NEXT_PUBLIC_MARKET_FEE_ADDRESS="0xxx"
|
||||||
#NEXT_PUBLIC_PUBLISHER_MARKET_ORDER_FEE="1"
|
#NEXT_PUBLIC_PUBLISHER_MARKET_ORDER_FEE="1"
|
||||||
@ -8,11 +7,6 @@
|
|||||||
#NEXT_PUBLIC_CONSUME_MARKET_POOL_SWAP_FEE="1"
|
#NEXT_PUBLIC_CONSUME_MARKET_POOL_SWAP_FEE="1"
|
||||||
#NEXT_PUBLIC_CONSUME_MARKET_FIXED_SWAP_FEE="1"
|
#NEXT_PUBLIC_CONSUME_MARKET_FIXED_SWAP_FEE="1"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#NEXT_PUBLIC_PORTIS_ID="xxx"
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# ADVANCED SETTINGS
|
# ADVANCED SETTINGS
|
||||||
#
|
#
|
||||||
|
1
.github/workflows/deploy.yml
vendored
1
.github/workflows/deploy.yml
vendored
@ -17,7 +17,6 @@ jobs:
|
|||||||
- run: npm run build
|
- run: npm run build
|
||||||
env:
|
env:
|
||||||
NEXT_PUBLIC_INFURA_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_INFURA_PROJECT_ID }}
|
NEXT_PUBLIC_INFURA_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_INFURA_PROJECT_ID }}
|
||||||
NEXT_PUBLIC_PORTIS_ID: ${{ secrets.NEXT_PUBLIC_PORTIS_ID }}
|
|
||||||
|
|
||||||
- run: npm run deploy:s3
|
- run: npm run deploy:s3
|
||||||
env:
|
env:
|
||||||
|
@ -75,9 +75,6 @@ module.exports = {
|
|||||||
storageKey: 'oceanDarkMode'
|
storageKey: 'oceanDarkMode'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Wallets
|
|
||||||
portisId: process.env.NEXT_PUBLIC_PORTIS_ID || 'xxx',
|
|
||||||
|
|
||||||
// Used to show or hide the fixed, dynamic or free price options
|
// Used to show or hide the fixed, dynamic or free price options
|
||||||
// tab to publishers during the price creation.
|
// tab to publishers during the price creation.
|
||||||
allowFixedPricing: process.env.NEXT_PUBLIC_ALLOW_FIXED_PRICING || 'true',
|
allowFixedPricing: process.env.NEXT_PUBLIC_ALLOW_FIXED_PRICING || 'true',
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"link": "/profile"
|
"link": "/profile"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"announcement": "Data NFTs, One-Sided Staking and more. [Explore OceanONDA V4](https://blog.oceanprotocol.com/oceanonda-v4-production-has-arrived-cb4fe8faaf39).",
|
"announcement": "Data NFTs, One-Sided Staking and more.",
|
||||||
"warning": {
|
"warning": {
|
||||||
"ctd": "Compute-to-Data is still in a testing phase, please use it only on test networks."
|
"ctd": "Compute-to-Data is still in a testing phase, please use it only on test networks."
|
||||||
}
|
}
|
||||||
|
117
package-lock.json
generated
117
package-lock.json
generated
@ -15,7 +15,6 @@
|
|||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^1.1.2",
|
"@oceanprotocol/lib": "^1.1.2",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@portis/web3": "^4.0.7",
|
|
||||||
"@tippyjs/react": "^4.2.6",
|
"@tippyjs/react": "^4.2.6",
|
||||||
"@urql/exchange-refocus": "^0.2.5",
|
"@urql/exchange-refocus": "^0.2.5",
|
||||||
"@walletconnect/web3-provider": "^1.7.8",
|
"@walletconnect/web3-provider": "^1.7.8",
|
||||||
@ -5239,17 +5238,6 @@
|
|||||||
"url": "https://opencollective.com/popperjs"
|
"url": "https://opencollective.com/popperjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@portis/web3": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@portis/web3/-/web3-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-efGssWqrwpYPzQyOupYPpWmjPU/WwcFGoPXzjLbjQ3Z4Z7Q4qqqwkMeE1mwMbxWudFKlHz/VxdpJrDA42Ufqrg==",
|
|
||||||
"dependencies": {
|
|
||||||
"ethereumjs-util": "5.2.0",
|
|
||||||
"penpal": "3.0.7",
|
|
||||||
"pocket-js-core": "0.0.3",
|
|
||||||
"web3-provider-engine": "16.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@react-spring/animated": {
|
"node_modules/@react-spring/animated": {
|
||||||
"version": "9.4.5",
|
"version": "9.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz",
|
"resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz",
|
||||||
@ -33516,11 +33504,6 @@
|
|||||||
"node": ">=0.12"
|
"node": ">=0.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/penpal": {
|
|
||||||
"version": "3.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/penpal/-/penpal-3.0.7.tgz",
|
|
||||||
"integrity": "sha512-WSXiq5HnEvzvY05SHhaXcsviUmCvh4Ze8AiIZzvmdzaaYAAx4rx8c6Xq6+MaVDG/Nfve3VmGD8HyRP3CkPvPbQ=="
|
|
||||||
},
|
|
||||||
"node_modules/performance-now": {
|
"node_modules/performance-now": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||||
@ -33616,48 +33599,6 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/pocket-js-core": {
|
|
||||||
"version": "0.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/pocket-js-core/-/pocket-js-core-0.0.3.tgz",
|
|
||||||
"integrity": "sha512-OUTEvEVutdjLT6YyldvAlSebpBueUUWg2XKxGNt5u3QqrmLpBOOBmdDnGMNJ+lEwXtko+JqgwFq+HTi4g1QDVg==",
|
|
||||||
"dependencies": {
|
|
||||||
"axios": "^0.18.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/pocket-js-core/node_modules/axios": {
|
|
||||||
"version": "0.18.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
|
||||||
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
|
||||||
"deprecated": "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410",
|
|
||||||
"dependencies": {
|
|
||||||
"follow-redirects": "1.5.10",
|
|
||||||
"is-buffer": "^2.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/pocket-js-core/node_modules/debug": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
|
||||||
"dependencies": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/pocket-js-core/node_modules/follow-redirects": {
|
|
||||||
"version": "1.5.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
|
||||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "=3.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/pocket-js-core/node_modules/ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
|
||||||
},
|
|
||||||
"node_modules/polished": {
|
"node_modules/polished": {
|
||||||
"version": "4.2.2",
|
"version": "4.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz",
|
||||||
@ -44984,6 +44925,7 @@
|
|||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"decimal.js": "^10.3.1",
|
"decimal.js": "^10.3.1",
|
||||||
|
"web3": "^1.7.3",
|
||||||
"web3-core": "^1.7.1",
|
"web3-core": "^1.7.1",
|
||||||
"web3-eth-contract": "^1.7.1"
|
"web3-eth-contract": "^1.7.1"
|
||||||
}
|
}
|
||||||
@ -45035,6 +44977,7 @@
|
|||||||
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
|
"integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
"@oclif/config": "^1.18.2",
|
||||||
"@oclif/errors": "^1.3.5",
|
"@oclif/errors": "^1.3.5",
|
||||||
"@oclif/help": "^1.0.1",
|
"@oclif/help": "^1.0.1",
|
||||||
"@oclif/parser": "^3.8.6",
|
"@oclif/parser": "^3.8.6",
|
||||||
@ -45463,17 +45406,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz",
|
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz",
|
||||||
"integrity": "sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw=="
|
"integrity": "sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw=="
|
||||||
},
|
},
|
||||||
"@portis/web3": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@portis/web3/-/web3-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-efGssWqrwpYPzQyOupYPpWmjPU/WwcFGoPXzjLbjQ3Z4Z7Q4qqqwkMeE1mwMbxWudFKlHz/VxdpJrDA42Ufqrg==",
|
|
||||||
"requires": {
|
|
||||||
"ethereumjs-util": "5.2.0",
|
|
||||||
"penpal": "3.0.7",
|
|
||||||
"pocket-js-core": "0.0.3",
|
|
||||||
"web3-provider-engine": "16.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@react-spring/animated": {
|
"@react-spring/animated": {
|
||||||
"version": "9.4.5",
|
"version": "9.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz",
|
"resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz",
|
||||||
@ -67517,11 +67449,6 @@
|
|||||||
"sha.js": "^2.4.8"
|
"sha.js": "^2.4.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"penpal": {
|
|
||||||
"version": "3.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/penpal/-/penpal-3.0.7.tgz",
|
|
||||||
"integrity": "sha512-WSXiq5HnEvzvY05SHhaXcsviUmCvh4Ze8AiIZzvmdzaaYAAx4rx8c6Xq6+MaVDG/Nfve3VmGD8HyRP3CkPvPbQ=="
|
|
||||||
},
|
|
||||||
"performance-now": {
|
"performance-now": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||||
@ -67590,46 +67517,6 @@
|
|||||||
"ts-pnp": "^1.1.6"
|
"ts-pnp": "^1.1.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pocket-js-core": {
|
|
||||||
"version": "0.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/pocket-js-core/-/pocket-js-core-0.0.3.tgz",
|
|
||||||
"integrity": "sha512-OUTEvEVutdjLT6YyldvAlSebpBueUUWg2XKxGNt5u3QqrmLpBOOBmdDnGMNJ+lEwXtko+JqgwFq+HTi4g1QDVg==",
|
|
||||||
"requires": {
|
|
||||||
"axios": "^0.18.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"axios": {
|
|
||||||
"version": "0.18.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
|
|
||||||
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
|
|
||||||
"requires": {
|
|
||||||
"follow-redirects": "1.5.10",
|
|
||||||
"is-buffer": "^2.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"version": "3.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
|
||||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
|
||||||
"requires": {
|
|
||||||
"ms": "2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"follow-redirects": {
|
|
||||||
"version": "1.5.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
|
||||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
|
||||||
"requires": {
|
|
||||||
"debug": "=3.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ms": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"polished": {
|
"polished": {
|
||||||
"version": "4.2.2",
|
"version": "4.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz",
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^1.1.2",
|
"@oceanprotocol/lib": "^1.1.2",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@portis/web3": "^4.0.7",
|
|
||||||
"@tippyjs/react": "^4.2.6",
|
"@tippyjs/react": "^4.2.6",
|
||||||
"@urql/exchange-refocus": "^0.2.5",
|
"@urql/exchange-refocus": "^0.2.5",
|
||||||
"@walletconnect/web3-provider": "^1.7.8",
|
"@walletconnect/web3-provider": "^1.7.8",
|
||||||
|
@ -18,7 +18,6 @@ export interface AppConfig {
|
|||||||
consumeMarketPoolSwapFee: string
|
consumeMarketPoolSwapFee: string
|
||||||
consumeMarketFixedSwapFee: string
|
consumeMarketFixedSwapFee: string
|
||||||
currencies: string[]
|
currencies: string[]
|
||||||
portisId: string
|
|
||||||
allowFixedPricing: string
|
allowFixedPricing: string
|
||||||
allowDynamicPricing: string
|
allowDynamicPricing: string
|
||||||
allowFreePricing: string
|
allowFreePricing: string
|
||||||
|
@ -9,7 +9,7 @@ import React, {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import Web3Modal, { getProviderInfo, IProviderInfo } from 'web3modal'
|
import Web3Modal, { getProviderInfo, IProviderInfo } from 'web3modal'
|
||||||
import { infuraProjectId as infuraId, portisId } from '../../app.config'
|
import { infuraProjectId as infuraId } from '../../app.config'
|
||||||
import WalletConnectProvider from '@walletconnect/web3-provider'
|
import WalletConnectProvider from '@walletconnect/web3-provider'
|
||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||||
import { isBrowser } from '@utils/index'
|
import { isBrowser } from '@utils/index'
|
||||||
@ -58,12 +58,6 @@ const providerOptions = isBrowser
|
|||||||
walletconnect: {
|
walletconnect: {
|
||||||
package: WalletConnectProvider,
|
package: WalletConnectProvider,
|
||||||
options: { infuraId }
|
options: { infuraId }
|
||||||
},
|
|
||||||
portis: {
|
|
||||||
package: require('@portis/web3'),
|
|
||||||
options: {
|
|
||||||
id: portisId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// torus: {
|
// torus: {
|
||||||
// package: require('@toruslabs/torus-embed')
|
// package: require('@toruslabs/torus-embed')
|
||||||
|
@ -12,8 +12,7 @@ import {
|
|||||||
Asset,
|
Asset,
|
||||||
LoggerInstance,
|
LoggerInstance,
|
||||||
ProviderFees,
|
ProviderFees,
|
||||||
ProviderInstance,
|
ProviderInstance
|
||||||
unitsToAmount
|
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import { AssetExtended } from 'src/@types/AssetExtended'
|
import { AssetExtended } from 'src/@types/AssetExtended'
|
||||||
import { calcInGivenOut } from './pool'
|
import { calcInGivenOut } from './pool'
|
||||||
@ -174,22 +173,21 @@ function getAccessDetailsFromTokenPrice(
|
|||||||
): AccessDetails {
|
): AccessDetails {
|
||||||
const accessDetails = {} as AccessDetails
|
const accessDetails = {} as AccessDetails
|
||||||
|
|
||||||
if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 0) {
|
if (tokenPrice?.orders?.length > 0) {
|
||||||
const order = tokenPrice.orders[0]
|
const order = tokenPrice.orders[0]
|
||||||
const reusedOrder =
|
const reusedOrder = order?.reuses?.length > 0 ? order.reuses[0] : null
|
||||||
order && order.reuses && order.reuses.length > 0 ? order.reuses[0] : null
|
|
||||||
// asset is owned if there is an order and asset has timeout 0 (forever) or if the condition is valid
|
// asset is owned if there is an order and asset has timeout 0 (forever) or if the condition is valid
|
||||||
accessDetails.isOwned =
|
accessDetails.isOwned =
|
||||||
timeout === 0 || Date.now() / 1000 - order.createdTimestamp < timeout
|
timeout === 0 || Date.now() / 1000 - order?.createdTimestamp < timeout
|
||||||
// the last valid order should be the last reuse order tx id if there is one
|
// the last valid order should be the last reuse order tx id if there is one
|
||||||
accessDetails.validOrderTx = reusedOrder ? reusedOrder.tx : order.tx
|
accessDetails.validOrderTx = reusedOrder?.tx || order?.tx
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fetch order fee from sub query
|
// TODO: fetch order fee from sub query
|
||||||
accessDetails.publisherMarketOrderFee = tokenPrice.publishMarketFeeAmount
|
accessDetails.publisherMarketOrderFee = tokenPrice?.publishMarketFeeAmount
|
||||||
|
|
||||||
// free is always the best price
|
// free is always the best price
|
||||||
if (tokenPrice.dispensers && tokenPrice.dispensers.length > 0) {
|
if (tokenPrice?.dispensers?.length > 0) {
|
||||||
const dispenser = tokenPrice.dispensers[0]
|
const dispenser = tokenPrice.dispensers[0]
|
||||||
accessDetails.type = 'free'
|
accessDetails.type = 'free'
|
||||||
accessDetails.addressOrId = dispenser.token.id
|
accessDetails.addressOrId = dispenser.token.id
|
||||||
@ -204,10 +202,7 @@ function getAccessDetailsFromTokenPrice(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checking for fixed price
|
// checking for fixed price
|
||||||
if (
|
if (tokenPrice?.fixedRateExchanges?.length > 0) {
|
||||||
tokenPrice.fixedRateExchanges &&
|
|
||||||
tokenPrice.fixedRateExchanges.length > 0
|
|
||||||
) {
|
|
||||||
const fixed = tokenPrice.fixedRateExchanges[0]
|
const fixed = tokenPrice.fixedRateExchanges[0]
|
||||||
accessDetails.type = 'fixed'
|
accessDetails.type = 'fixed'
|
||||||
accessDetails.addressOrId = fixed.exchangeId
|
accessDetails.addressOrId = fixed.exchangeId
|
||||||
@ -228,7 +223,7 @@ function getAccessDetailsFromTokenPrice(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checking for pools
|
// checking for pools
|
||||||
if (tokenPrice.pools && tokenPrice.pools.length > 0) {
|
if (tokenPrice?.pools?.length > 0) {
|
||||||
const pool = tokenPrice.pools[0]
|
const pool = tokenPrice.pools[0]
|
||||||
accessDetails.type = 'dynamic'
|
accessDetails.type = 'dynamic'
|
||||||
accessDetails.addressOrId = pool.id
|
accessDetails.addressOrId = pool.id
|
||||||
@ -257,7 +252,6 @@ function getAccessDetailsFromTokenPrice(
|
|||||||
* @return {Promise<OrdePriceAndFee>}
|
* @return {Promise<OrdePriceAndFee>}
|
||||||
*/
|
*/
|
||||||
export async function getOrderPriceAndFees(
|
export async function getOrderPriceAndFees(
|
||||||
web3: Web3,
|
|
||||||
asset: AssetExtended,
|
asset: AssetExtended,
|
||||||
accountId?: string,
|
accountId?: string,
|
||||||
paramsForPool?: CalcInGivenOutParams,
|
paramsForPool?: CalcInGivenOutParams,
|
||||||
@ -284,10 +278,10 @@ export async function getOrderPriceAndFees(
|
|||||||
!providerFees &&
|
!providerFees &&
|
||||||
(await ProviderInstance.initialize(
|
(await ProviderInstance.initialize(
|
||||||
asset?.id,
|
asset?.id,
|
||||||
asset.services[0].id,
|
asset?.services[0].id,
|
||||||
0,
|
0,
|
||||||
accountId,
|
accountId,
|
||||||
asset.services[0].serviceEndpoint
|
asset?.services[0].serviceEndpoint
|
||||||
))
|
))
|
||||||
orderPriceAndFee.providerFee = providerFees || initializeData.providerFee
|
orderPriceAndFee.providerFee = providerFees || initializeData.providerFee
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ export async function getAssetsFromDidList(
|
|||||||
didList: string[],
|
didList: string[],
|
||||||
chainIds: number[],
|
chainIds: number[],
|
||||||
cancelToken: CancelToken
|
cancelToken: CancelToken
|
||||||
): Promise<any> {
|
): Promise<PagedAssets> {
|
||||||
try {
|
try {
|
||||||
if (!(didList.length > 0)) return
|
if (!(didList.length > 0)) return
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
} from './aquarius'
|
} from './aquarius'
|
||||||
import { fetchDataForMultipleChains } from './subgraph'
|
import { fetchDataForMultipleChains } from './subgraph'
|
||||||
import { getServiceById, getServiceByName } from './ddo'
|
import { getServiceById, getServiceByName } from './ddo'
|
||||||
import { getOceanConfig } from './ocean'
|
|
||||||
import { SortTermOptions } from 'src/@types/aquarius/SearchQuery'
|
import { SortTermOptions } from 'src/@types/aquarius/SearchQuery'
|
||||||
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
||||||
import { transformAssetToAssetSelection } from './assetConvertor'
|
import { transformAssetToAssetSelection } from './assetConvertor'
|
||||||
@ -93,6 +92,7 @@ export async function isOrderable(
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const datasetService: Service = getServiceById(asset, serviceId)
|
const datasetService: Service = getServiceById(asset, serviceId)
|
||||||
if (!datasetService) return false
|
if (!datasetService) return false
|
||||||
|
|
||||||
if (datasetService.type === 'compute') {
|
if (datasetService.type === 'compute') {
|
||||||
if (algorithm.meta) {
|
if (algorithm.meta) {
|
||||||
// check if raw algo is allowed
|
// check if raw algo is allowed
|
||||||
@ -149,7 +149,7 @@ export async function getComputeEnviroment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getQuerryString(
|
export function getQueryString(
|
||||||
trustedAlgorithmList: PublisherTrustedAlgorithm[],
|
trustedAlgorithmList: PublisherTrustedAlgorithm[],
|
||||||
chainId?: number
|
chainId?: number
|
||||||
): SearchQuery {
|
): SearchQuery {
|
||||||
@ -182,7 +182,7 @@ export async function getAlgorithmsForAsset(
|
|||||||
algorithms = []
|
algorithms = []
|
||||||
} else {
|
} else {
|
||||||
const gueryResults = await queryMetadata(
|
const gueryResults = await queryMetadata(
|
||||||
getQuerryString(publisherTrustedAlgorithms, asset.chainId),
|
getQueryString(publisherTrustedAlgorithms, asset.chainId),
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
algorithms = gueryResults?.results
|
algorithms = gueryResults?.results
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
import { Asset, DDO, Service } from '@oceanprotocol/lib'
|
||||||
interface Consumable {
|
|
||||||
status: number
|
|
||||||
message: string
|
|
||||||
result: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getServiceByName(
|
export function getServiceByName(
|
||||||
ddo: Asset | DDO,
|
ddo: Asset | DDO,
|
||||||
name: 'access' | 'compute' | 'metadata'
|
name: 'access' | 'compute'
|
||||||
): Service {
|
): Service {
|
||||||
if (!ddo) return
|
if (!ddo) return
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import { AccessDetails } from 'src/@types/Price'
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { getOceanConfig } from './ocean'
|
import { getOceanConfig } from './ocean'
|
||||||
import { consumeMarketPoolSwapFee } from '../../app.config'
|
import { consumeMarketPoolSwapFee } from '../../app.config'
|
||||||
|
|
||||||
import { getDummyWeb3 } from './web3'
|
import { getDummyWeb3 } from './web3'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,17 +112,6 @@ export async function setNftMetadata(
|
|||||||
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
// theoretically used by aquarius or provider, not implemented yet, will remain hardcoded
|
||||||
const flags = '0x2'
|
const flags = '0x2'
|
||||||
|
|
||||||
const estGasSetMetadata = await nft.estGasSetMetadata(
|
|
||||||
asset.nftAddress,
|
|
||||||
accountId,
|
|
||||||
0,
|
|
||||||
asset.services[0].serviceEndpoint,
|
|
||||||
'',
|
|
||||||
flags,
|
|
||||||
encryptedDdo,
|
|
||||||
'0x' + metadataHash,
|
|
||||||
[]
|
|
||||||
)
|
|
||||||
const setMetadataTx = await nft.setMetadata(
|
const setMetadataTx = await nft.setMetadata(
|
||||||
asset.nftAddress,
|
asset.nftAddress,
|
||||||
accountId,
|
accountId,
|
||||||
|
@ -26,9 +26,9 @@ import { toast } from 'react-toastify'
|
|||||||
* For pool you need to buy the datatoken beforehand, this always assumes you want to order the first service
|
* For pool you need to buy the datatoken beforehand, this always assumes you want to order the first service
|
||||||
* @param web3
|
* @param web3
|
||||||
* @param asset
|
* @param asset
|
||||||
|
* @param orderPriceAndFees
|
||||||
* @param accountId
|
* @param accountId
|
||||||
* @param computeEnv
|
* @param providerFees
|
||||||
* @param computeValidUntil
|
|
||||||
* @param computeConsumerAddress
|
* @param computeConsumerAddress
|
||||||
* @returns {TransactionReceipt} receipt of the order
|
* @returns {TransactionReceipt} receipt of the order
|
||||||
*/
|
*/
|
||||||
@ -162,9 +162,10 @@ export async function reuseOrder(
|
|||||||
* - no validOrder -> we need to call order, to pay 1 DT & providerFees
|
* - no validOrder -> we need to call order, to pay 1 DT & providerFees
|
||||||
* @param web3
|
* @param web3
|
||||||
* @param asset
|
* @param asset
|
||||||
|
* @param orderPriceAndFees
|
||||||
* @param accountId
|
* @param accountId
|
||||||
* @param computeEnv
|
* @param hasDatatoken
|
||||||
* @param computeValidUntil
|
* @param initializeData
|
||||||
* @param computeConsumerAddress
|
* @param computeConsumerAddress
|
||||||
* @returns {Promise<string>} tx id
|
* @returns {Promise<string>} tx id
|
||||||
*/
|
*/
|
||||||
@ -186,12 +187,16 @@ export async function handleComputeOrder(
|
|||||||
initializeData.providerFee &&
|
initializeData.providerFee &&
|
||||||
initializeData.providerFee.providerFeeAmount !== '0'
|
initializeData.providerFee.providerFeeAmount !== '0'
|
||||||
) {
|
) {
|
||||||
|
const baseToken =
|
||||||
|
asset?.accessDetails?.type === 'free'
|
||||||
|
? getOceanConfig(asset.chainId).oceanTokenAddress
|
||||||
|
: asset?.accessDetails?.baseToken?.address
|
||||||
const txApproveWei = await approveWei(
|
const txApproveWei = await approveWei(
|
||||||
web3,
|
web3,
|
||||||
accountId,
|
accountId,
|
||||||
asset.accessDetails.baseToken.address,
|
baseToken,
|
||||||
asset.accessDetails.datatoken.address,
|
asset?.accessDetails?.datatoken?.address,
|
||||||
initializeData.providerFee.providerFeeAmount
|
initializeData?.providerFee?.providerFeeAmount
|
||||||
)
|
)
|
||||||
if (!txApproveWei) {
|
if (!txApproveWei) {
|
||||||
toast.error('Failed to approve provider fees!')
|
toast.error('Failed to approve provider fees!')
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
ProviderComputeInitializeResults,
|
ProviderComputeInitializeResults,
|
||||||
ProviderInstance
|
ProviderInstance
|
||||||
} from '@oceanprotocol/lib'
|
} from '@oceanprotocol/lib'
|
||||||
import { toast } from 'react-toastify'
|
|
||||||
import { AssetExtended } from 'src/@types/AssetExtended'
|
import { AssetExtended } from 'src/@types/AssetExtended'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { getValidUntilTime } from './compute'
|
import { getValidUntilTime } from './compute'
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData'
|
||||||
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
|
import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery'
|
||||||
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery'
|
||||||
import { calcSingleOutGivenPoolIn, getLiquidityByShares } from './pool'
|
import { calcSingleOutGivenPoolIn } from './pool'
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
import { MAX_DECIMALS } from './constants'
|
import { MAX_DECIMALS } from './constants'
|
||||||
|
|
||||||
|
@ -24,10 +24,6 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner button {
|
|
||||||
font-size: calc(var(--font-size-small) / 1.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
font-size: var(--font-size-small);
|
font-size: var(--font-size-small);
|
||||||
font-weight: var(--font-weight-bold);
|
font-weight: var(--font-weight-bold);
|
||||||
@ -41,6 +37,13 @@
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-transform: inherit;
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
.text p:last-child {
|
.text p:last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,12 @@ export default function AnnouncementBanner({
|
|||||||
<div className={styleClasses}>
|
<div className={styleClasses}>
|
||||||
{text && <Markdown className={styles.text} text={text} />}
|
{text && <Markdown className={styles.text} text={text} />}
|
||||||
{action && (
|
{action && (
|
||||||
<Button style="text" size="small" onClick={action.handleAction}>
|
<Button
|
||||||
|
style="text"
|
||||||
|
size="small"
|
||||||
|
className={styles.link}
|
||||||
|
onClick={action.handleAction}
|
||||||
|
>
|
||||||
{action.name}
|
{action.name}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.actionsCenter {
|
.actionsCenter {
|
||||||
margin: auto !important;
|
margin: auto;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,26 @@ export default function App({
|
|||||||
const { siteContent, appConfig } = useMarketMetadata()
|
const { siteContent, appConfig } = useMarketMetadata()
|
||||||
const { accountId } = useWeb3()
|
const { accountId } = useWeb3()
|
||||||
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
|
const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId)
|
||||||
|
function openInNewTab() {
|
||||||
|
window
|
||||||
|
.open(
|
||||||
|
'https://blog.oceanprotocol.com/how-to-publish-a-data-nft-f58ad2a622a9',
|
||||||
|
'_blank'
|
||||||
|
)
|
||||||
|
.focus()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.app}>
|
<div className={styles.app}>
|
||||||
{siteContent?.announcement !== '' && (
|
{siteContent?.announcement !== '' && (
|
||||||
<AnnouncementBanner text={siteContent?.announcement} />
|
<AnnouncementBanner
|
||||||
|
text={siteContent?.announcement}
|
||||||
|
action={{
|
||||||
|
name: 'Explore OceanONDA V4.',
|
||||||
|
style: 'link',
|
||||||
|
handleAction: openInNewTab
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
|
@ -80,9 +80,11 @@ export default function FormStartCompute({
|
|||||||
validUntil?: string
|
validUntil?: string
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { siteContent } = useMarketMetadata()
|
const { siteContent } = useMarketMetadata()
|
||||||
|
const { accountId, balance } = useWeb3()
|
||||||
const { isValid, values }: FormikContextType<{ algorithm: string }> =
|
const { isValid, values }: FormikContextType<{ algorithm: string }> =
|
||||||
useFormikContext()
|
useFormikContext()
|
||||||
const { asset, isAssetNetwork } = useAsset()
|
const { asset, isAssetNetwork } = useAsset()
|
||||||
|
|
||||||
const [totalPrice, setTotalPrice] = useState('0')
|
const [totalPrice, setTotalPrice] = useState('0')
|
||||||
const [datasetOrderPrice, setDatasetOrderPrice] = useState(
|
const [datasetOrderPrice, setDatasetOrderPrice] = useState(
|
||||||
asset?.accessDetails?.price
|
asset?.accessDetails?.price
|
||||||
@ -91,7 +93,6 @@ export default function FormStartCompute({
|
|||||||
selectedAlgorithmAsset?.accessDetails?.price
|
selectedAlgorithmAsset?.accessDetails?.price
|
||||||
)
|
)
|
||||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>(false)
|
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>(false)
|
||||||
const { accountId, balance, isSupportedOceanNetwork } = useWeb3()
|
|
||||||
|
|
||||||
function getAlgorithmAsset(algorithmId: string): Asset {
|
function getAlgorithmAsset(algorithmId: string): Asset {
|
||||||
let assetDdo = null
|
let assetDdo = null
|
||||||
@ -102,7 +103,8 @@ export default function FormStartCompute({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!values.algorithm || !isConsumable) return
|
if (!values.algorithm || !accountId || !isConsumable) return
|
||||||
|
|
||||||
async function fetchAlgorithmAssetExtended() {
|
async function fetchAlgorithmAssetExtended() {
|
||||||
const algorithmAsset = getAlgorithmAsset(values.algorithm)
|
const algorithmAsset = getAlgorithmAsset(values.algorithm)
|
||||||
const accessDetails = await getAccessDetails(
|
const accessDetails = await getAccessDetails(
|
||||||
@ -165,15 +167,16 @@ export default function FormStartCompute({
|
|||||||
hasDatatokenSelectedComputeAsset,
|
hasDatatokenSelectedComputeAsset,
|
||||||
datasetOrderPriceAndFees,
|
datasetOrderPriceAndFees,
|
||||||
algoOrderPriceAndFees,
|
algoOrderPriceAndFees,
|
||||||
selectedAlgorithmAsset
|
providerFeeAmount
|
||||||
])
|
])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!totalPrice || !balance.ocean || !dtBalance) return
|
if (!totalPrice || !balance?.ocean || !dtBalance) return
|
||||||
|
|
||||||
setIsBalanceSufficient(
|
setIsBalanceSufficient(
|
||||||
compareAsBN(balance.ocean, `${totalPrice}`) || Number(dtBalance) >= 1
|
compareAsBN(balance.ocean, `${totalPrice}`) || Number(dtBalance) >= 1
|
||||||
)
|
)
|
||||||
}, [totalPrice, balance.ocean, dtBalance])
|
}, [totalPrice, balance?.ocean, dtBalance])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form className={styles.form}>
|
<Form className={styles.form}>
|
||||||
@ -217,7 +220,7 @@ export default function FormStartCompute({
|
|||||||
!isValid ||
|
!isValid ||
|
||||||
!isBalanceSufficient ||
|
!isBalanceSufficient ||
|
||||||
!isAssetNetwork ||
|
!isAssetNetwork ||
|
||||||
!selectedAlgorithmAsset?.accessDetails.isPurchasable
|
!selectedAlgorithmAsset?.accessDetails?.isPurchasable
|
||||||
}
|
}
|
||||||
hasPreviousOrder={hasPreviousOrder}
|
hasPreviousOrder={hasPreviousOrder}
|
||||||
hasDatatoken={hasDatatoken}
|
hasDatatoken={hasDatatoken}
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 5% 1fr auto;
|
grid-template-columns: 5% 1fr auto;
|
||||||
column-gap: calc(var(--spacer) / 10);
|
column-gap: calc(var(--spacer) / 10);
|
||||||
/* justify-content: space-between; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.priceRow:last-child {
|
.priceRow:last-child {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, ReactElement, useEffect, useCallback } from 'react'
|
import React, { useState, ReactElement, useEffect } from 'react'
|
||||||
import {
|
import {
|
||||||
Asset,
|
Asset,
|
||||||
DDO,
|
DDO,
|
||||||
@ -36,7 +36,6 @@ import AlgorithmDatasetsListForCompute from './AlgorithmDatasetsListForCompute'
|
|||||||
import AssetActionHistoryTable from '../AssetActionHistoryTable'
|
import AssetActionHistoryTable from '../AssetActionHistoryTable'
|
||||||
import ComputeJobs from '../../../Profile/History/ComputeJobs'
|
import ComputeJobs from '../../../Profile/History/ComputeJobs'
|
||||||
import { useCancelToken } from '@hooks/useCancelToken'
|
import { useCancelToken } from '@hooks/useCancelToken'
|
||||||
// import { useIsMounted } from '@hooks/useIsMounted'
|
|
||||||
import { Decimal } from 'decimal.js'
|
import { Decimal } from 'decimal.js'
|
||||||
import { useAbortController } from '@hooks/useAbortController'
|
import { useAbortController } from '@hooks/useAbortController'
|
||||||
import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing'
|
import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing'
|
||||||
@ -55,42 +54,35 @@ export default function Compute({
|
|||||||
dtBalance,
|
dtBalance,
|
||||||
file,
|
file,
|
||||||
fileIsLoading,
|
fileIsLoading,
|
||||||
isConsumable,
|
|
||||||
consumableFeedback
|
consumableFeedback
|
||||||
}: {
|
}: {
|
||||||
asset: AssetExtended
|
asset: AssetExtended
|
||||||
dtBalance: string
|
dtBalance: string
|
||||||
file: FileInfo
|
file: FileInfo
|
||||||
fileIsLoading?: boolean
|
fileIsLoading?: boolean
|
||||||
isConsumable?: boolean
|
|
||||||
consumableFeedback?: string
|
consumableFeedback?: string
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId, web3 } = useWeb3()
|
const { accountId, web3 } = useWeb3()
|
||||||
|
const { getOpcFeeForToken } = useMarketMetadata()
|
||||||
const [isJobStarting, setIsJobStarting] = useState(false)
|
const { poolData } = usePool()
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
const newAbortController = useAbortController()
|
const newAbortController = useAbortController()
|
||||||
|
const newCancelToken = useCancelToken()
|
||||||
|
|
||||||
|
const [isOrdering, setIsOrdering] = useState(false)
|
||||||
|
const [isOrdered, setIsOrdered] = useState(false)
|
||||||
|
const [error, setError] = useState<string>()
|
||||||
|
|
||||||
const [algorithmList, setAlgorithmList] = useState<AssetSelectionAsset[]>()
|
const [algorithmList, setAlgorithmList] = useState<AssetSelectionAsset[]>()
|
||||||
const [ddoAlgorithmList, setDdoAlgorithmList] = useState<Asset[]>()
|
const [ddoAlgorithmList, setDdoAlgorithmList] = useState<Asset[]>()
|
||||||
const [selectedAlgorithmAsset, setSelectedAlgorithmAsset] =
|
const [selectedAlgorithmAsset, setSelectedAlgorithmAsset] =
|
||||||
useState<AssetExtended>()
|
useState<AssetExtended>()
|
||||||
const [hasAlgoAssetDatatoken, setHasAlgoAssetDatatoken] = useState<boolean>()
|
const [hasAlgoAssetDatatoken, setHasAlgoAssetDatatoken] = useState<boolean>()
|
||||||
const [isPublished, setIsPublished] = useState(false)
|
|
||||||
const [algorithmDTBalance, setAlgorithmDTBalance] = useState<string>()
|
const [algorithmDTBalance, setAlgorithmDTBalance] = useState<string>()
|
||||||
|
|
||||||
// const [isOwned, setIsOwned] = useState(false)
|
|
||||||
const [validOrderTx, setValidOrderTx] = useState('')
|
const [validOrderTx, setValidOrderTx] = useState('')
|
||||||
// const [isAlgorithmOwned, setIsAlgorithmOwned] = useState(false)
|
|
||||||
const [validAlgorithmOrderTx, setValidAlgorithmOrderTx] = useState('')
|
const [validAlgorithmOrderTx, setValidAlgorithmOrderTx] = useState('')
|
||||||
|
|
||||||
const hasDatatoken = Number(dtBalance) >= 1
|
|
||||||
// const isMounted = useIsMounted()
|
|
||||||
const { getOpcFeeForToken } = useMarketMetadata()
|
|
||||||
const { poolData } = usePool()
|
|
||||||
const newCancelToken = useCancelToken()
|
|
||||||
const [isConsumablePrice, setIsConsumablePrice] = useState(true)
|
const [isConsumablePrice, setIsConsumablePrice] = useState(true)
|
||||||
const [isAlgoConsumablePrice, setIsAlgoConsumablePrice] = useState(true)
|
|
||||||
const [computeStatusText, setComputeStatusText] = useState('')
|
const [computeStatusText, setComputeStatusText] = useState('')
|
||||||
const [computeEnv, setComputeEnv] = useState<ComputeEnvironment>()
|
const [computeEnv, setComputeEnv] = useState<ComputeEnvironment>()
|
||||||
const [initializedProviderResponse, setInitializedProviderResponse] =
|
const [initializedProviderResponse, setInitializedProviderResponse] =
|
||||||
@ -99,19 +91,18 @@ export default function Compute({
|
|||||||
const [computeValidUntil, setComputeValidUntil] = useState<string>('0')
|
const [computeValidUntil, setComputeValidUntil] = useState<string>('0')
|
||||||
const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] =
|
const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] =
|
||||||
useState<OrderPriceAndFees>()
|
useState<OrderPriceAndFees>()
|
||||||
const [isRequestingDataseOrderPrice, setIsRequestingDataseOrderPrice] =
|
|
||||||
useState(false)
|
|
||||||
const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] =
|
const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] =
|
||||||
useState<OrderPriceAndFees>()
|
useState<OrderPriceAndFees>()
|
||||||
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
|
const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] =
|
||||||
useState(false)
|
useState(false)
|
||||||
const [refatchJobs, setRefatchJobs] = useState(false)
|
const [refetchJobs, setRefetchJobs] = useState(false)
|
||||||
// const [isProviderFeeValid, setIsProviderFeeValid] = useState(false)
|
|
||||||
|
const hasDatatoken = Number(dtBalance) >= 1
|
||||||
const isComputeButtonDisabled =
|
const isComputeButtonDisabled =
|
||||||
isJobStarting === true ||
|
isOrdering === true ||
|
||||||
file === null ||
|
file === null ||
|
||||||
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
|
(!validOrderTx && !hasDatatoken && !isConsumablePrice) ||
|
||||||
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken && !isAlgoConsumablePrice)
|
(!validAlgorithmOrderTx && !hasAlgoAssetDatatoken)
|
||||||
|
|
||||||
async function checkAssetDTBalance(asset: DDO): Promise<boolean> {
|
async function checkAssetDTBalance(asset: DDO): Promise<boolean> {
|
||||||
if (!asset?.services[0].datatokenAddress) return
|
if (!asset?.services[0].datatokenAddress) return
|
||||||
@ -168,8 +159,8 @@ export default function Compute({
|
|||||||
) {
|
) {
|
||||||
setComputeStatusText(
|
setComputeStatusText(
|
||||||
getComputeFeedback(
|
getComputeFeedback(
|
||||||
asset.accessDetails.baseToken?.symbol,
|
asset.accessDetails?.baseToken?.symbol,
|
||||||
asset.accessDetails.datatoken?.symbol,
|
asset.accessDetails?.datatoken?.symbol,
|
||||||
asset.metadata.type
|
asset.metadata.type
|
||||||
)[0]
|
)[0]
|
||||||
)
|
)
|
||||||
@ -220,7 +211,7 @@ export default function Compute({
|
|||||||
if (selectedAlgorithmAsset?.accessDetails?.type === 'dynamic') {
|
if (selectedAlgorithmAsset?.accessDetails?.type === 'dynamic') {
|
||||||
const response = await getPoolData(
|
const response = await getPoolData(
|
||||||
selectedAlgorithmAsset.chainId,
|
selectedAlgorithmAsset.chainId,
|
||||||
selectedAlgorithmAsset.accessDetails.addressOrId,
|
selectedAlgorithmAsset.accessDetails?.addressOrId,
|
||||||
selectedAlgorithmAsset?.nft.owner,
|
selectedAlgorithmAsset?.nft.owner,
|
||||||
accountId || ''
|
accountId || ''
|
||||||
)
|
)
|
||||||
@ -304,8 +295,8 @@ export default function Compute({
|
|||||||
|
|
||||||
async function startJob(): Promise<string> {
|
async function startJob(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
setIsJobStarting(true)
|
setIsOrdering(true)
|
||||||
setIsPublished(false) // would be nice to rename this
|
setIsOrdered(false) // would be nice to rename this
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
const computeService = getServiceByName(asset, 'compute')
|
const computeService = getServiceByName(asset, 'compute')
|
||||||
const computeAlgorithm: ComputeAlgorithm = {
|
const computeAlgorithm: ComputeAlgorithm = {
|
||||||
@ -413,14 +404,14 @@ export default function Compute({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
LoggerInstance.log('[compute] Starting compute job response: ', response)
|
LoggerInstance.log('[compute] Starting compute job response: ', response)
|
||||||
setIsPublished(true)
|
setIsOrdered(true)
|
||||||
setRefatchJobs(!refatchJobs)
|
setRefetchJobs(!refetchJobs)
|
||||||
initPriceAndFees()
|
initPriceAndFees()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError('Failed to start job!')
|
setError('Failed to start job!')
|
||||||
LoggerInstance.error('[compute] Failed to start job: ', error.message)
|
LoggerInstance.error('[compute] Failed to start job: ', error.message)
|
||||||
} finally {
|
} finally {
|
||||||
setIsJobStarting(false)
|
setIsOrdering(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,11 +448,7 @@ export default function Compute({
|
|||||||
ddoListAlgorithms={ddoAlgorithmList}
|
ddoListAlgorithms={ddoAlgorithmList}
|
||||||
selectedAlgorithmAsset={selectedAlgorithmAsset}
|
selectedAlgorithmAsset={selectedAlgorithmAsset}
|
||||||
setSelectedAlgorithm={setSelectedAlgorithmAsset}
|
setSelectedAlgorithm={setSelectedAlgorithmAsset}
|
||||||
isLoading={
|
isLoading={isOrdering || isRequestingAlgoOrderPrice}
|
||||||
isJobStarting ||
|
|
||||||
isRequestingDataseOrderPrice ||
|
|
||||||
isRequestingAlgoOrderPrice
|
|
||||||
}
|
|
||||||
isComputeButtonDisabled={isComputeButtonDisabled}
|
isComputeButtonDisabled={isComputeButtonDisabled}
|
||||||
hasPreviousOrder={validOrderTx !== undefined}
|
hasPreviousOrder={validOrderTx !== undefined}
|
||||||
hasDatatoken={hasDatatoken}
|
hasDatatoken={hasDatatoken}
|
||||||
@ -482,7 +469,6 @@ export default function Compute({
|
|||||||
selectedAlgorithmAsset?.datatokens[0]?.symbol
|
selectedAlgorithmAsset?.datatokens[0]?.symbol
|
||||||
}
|
}
|
||||||
dtBalanceSelectedComputeAsset={algorithmDTBalance}
|
dtBalanceSelectedComputeAsset={algorithmDTBalance}
|
||||||
selectedComputeAssetLowPoolLiquidity={!isAlgoConsumablePrice}
|
|
||||||
selectedComputeAssetType="algorithm"
|
selectedComputeAssetType="algorithm"
|
||||||
selectedComputeAssetTimeout={secondsToString(
|
selectedComputeAssetTimeout={secondsToString(
|
||||||
selectedAlgorithmAsset?.services[0]?.timeout
|
selectedAlgorithmAsset?.services[0]?.timeout
|
||||||
@ -500,7 +486,7 @@ export default function Compute({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<footer className={styles.feedback}>
|
<footer className={styles.feedback}>
|
||||||
{isPublished && (
|
{isOrdered && (
|
||||||
<SuccessConfetti success="Your job started successfully! Watch the progress below or on your profile." />
|
<SuccessConfetti success="Your job started successfully! Watch the progress below or on your profile." />
|
||||||
)}
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
@ -508,8 +494,8 @@ export default function Compute({
|
|||||||
<AssetActionHistoryTable title="Your Compute Jobs">
|
<AssetActionHistoryTable title="Your Compute Jobs">
|
||||||
<ComputeJobs
|
<ComputeJobs
|
||||||
minimal
|
minimal
|
||||||
assetChainId={[asset?.chainId]}
|
assetChainIds={[asset?.chainId]}
|
||||||
refatchJobs={refatchJobs}
|
refetchJobs={refetchJobs}
|
||||||
/>
|
/>
|
||||||
</AssetActionHistoryTable>
|
</AssetActionHistoryTable>
|
||||||
)}
|
)}
|
||||||
|
@ -83,7 +83,6 @@ export default function Download({
|
|||||||
consumeMarketSwapFee: '0'
|
consumeMarketSwapFee: '0'
|
||||||
}
|
}
|
||||||
const _orderPriceAndFees = await getOrderPriceAndFees(
|
const _orderPriceAndFees = await getOrderPriceAndFees(
|
||||||
web3,
|
|
||||||
asset,
|
asset,
|
||||||
ZERO_ADDRESS,
|
ZERO_ADDRESS,
|
||||||
paramsForPool
|
paramsForPool
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { ReactElement, useState, useEffect } from 'react'
|
import React, { ReactElement, useState, useEffect } from 'react'
|
||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
|
||||||
import { useAsset } from '@context/Asset'
|
import { useAsset } from '@context/Asset'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import Tabs from '@shared/atoms/Tabs'
|
import Tabs from '@shared/atoms/Tabs'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ChangeEvent, ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import { formatCurrency } from '@coingecko/cryptoformat'
|
import { formatCurrency } from '@coingecko/cryptoformat'
|
||||||
import { useUserPreferences } from '@context/UserPreferences'
|
import { useUserPreferences } from '@context/UserPreferences'
|
||||||
import Button from '@shared/atoms/Button'
|
import Button from '@shared/atoms/Button'
|
||||||
@ -7,11 +7,9 @@ import Conversion from '@shared/Price/Conversion'
|
|||||||
import { useWeb3 } from '@context/Web3'
|
import { useWeb3 } from '@context/Web3'
|
||||||
import { getOceanConfig } from '@utils/ocean'
|
import { getOceanConfig } from '@utils/ocean'
|
||||||
import styles from './Details.module.css'
|
import styles from './Details.module.css'
|
||||||
import InputElement from '@shared/FormInput/InputElement'
|
|
||||||
|
|
||||||
export default function Details(): ReactElement {
|
export default function Details(): ReactElement {
|
||||||
const {
|
const {
|
||||||
web3Provider,
|
|
||||||
web3ProviderInfo,
|
web3ProviderInfo,
|
||||||
web3Modal,
|
web3Modal,
|
||||||
connect,
|
connect,
|
||||||
@ -27,7 +25,6 @@ export default function Details(): ReactElement {
|
|||||||
address: string
|
address: string
|
||||||
symbol: string
|
symbol: string
|
||||||
}>()
|
}>()
|
||||||
const [portisNetwork, setPortisNetwork] = useState<string>()
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!networkId) return
|
if (!networkId) return
|
||||||
@ -45,16 +42,6 @@ export default function Details(): ReactElement {
|
|||||||
})
|
})
|
||||||
}, [networkData, networkId])
|
}, [networkData, networkId])
|
||||||
|
|
||||||
// Handle network change for Portis
|
|
||||||
async function handlePortisNetworkChange(e: ChangeEvent<HTMLSelectElement>) {
|
|
||||||
setPortisNetwork(e.target.value)
|
|
||||||
const portisNetworkName = e.target.value.toLowerCase()
|
|
||||||
await web3Provider._portis.changeNetwork(portisNetworkName)
|
|
||||||
// TODO: using our connect initializes a new Portis instance,
|
|
||||||
// which then defaults back to initial network (Mainnet).
|
|
||||||
// await connect()
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.details}>
|
<div className={styles.details}>
|
||||||
<ul>
|
<ul>
|
||||||
@ -76,16 +63,6 @@ export default function Details(): ReactElement {
|
|||||||
<img className={styles.walletLogo} src={web3ProviderInfo?.logo} />
|
<img className={styles.walletLogo} src={web3ProviderInfo?.logo} />
|
||||||
{web3ProviderInfo?.name}
|
{web3ProviderInfo?.name}
|
||||||
</span>
|
</span>
|
||||||
{web3ProviderInfo?.name === 'Portis' && (
|
|
||||||
<InputElement
|
|
||||||
name="network"
|
|
||||||
type="select"
|
|
||||||
options={['Mainnet', 'Ropsten', 'Rinkeby']}
|
|
||||||
size="mini"
|
|
||||||
value={portisNetwork}
|
|
||||||
onChange={handlePortisNetworkChange}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{web3ProviderInfo?.name === 'MetaMask' && (
|
{web3ProviderInfo?.name === 'MetaMask' && (
|
||||||
<AddToken
|
<AddToken
|
||||||
address={oceanTokenMetadata?.address}
|
address={oceanTokenMetadata?.address}
|
||||||
@ -96,15 +73,6 @@ export default function Details(): ReactElement {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
{web3ProviderInfo?.name === 'Portis' && (
|
|
||||||
<Button
|
|
||||||
style="text"
|
|
||||||
size="small"
|
|
||||||
onClick={() => web3Provider._portis.showPortis()}
|
|
||||||
>
|
|
||||||
Show Portis
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
style="text"
|
style="text"
|
||||||
size="small"
|
size="small"
|
||||||
|
@ -98,12 +98,6 @@ export default function Details({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
<MetaItem title="Job ID" content={<code>{job.jobId}</code>} />
|
||||||
{/* {job.results[0]. && (
|
|
||||||
<MetaItem
|
|
||||||
title="Published Results DID"
|
|
||||||
content={<code>{job.resultsDid}</code>}
|
|
||||||
/>
|
|
||||||
)} */}
|
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
@ -71,20 +71,21 @@ const columns = [
|
|||||||
|
|
||||||
export default function ComputeJobs({
|
export default function ComputeJobs({
|
||||||
minimal,
|
minimal,
|
||||||
assetChainId,
|
assetChainIds,
|
||||||
refatchJobs
|
refetchJobs
|
||||||
}: {
|
}: {
|
||||||
minimal?: boolean
|
minimal?: boolean
|
||||||
assetChainId?: number[]
|
assetChainIds?: number[]
|
||||||
refatchJobs?: boolean
|
refetchJobs?: boolean
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const { accountId } = useWeb3()
|
const { accountId } = useWeb3()
|
||||||
const { asset } = useAsset()
|
const { asset } = useAsset()
|
||||||
const { chainIds } = useUserPreferences()
|
const { chainIds } = useUserPreferences()
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
|
||||||
const [jobs, setJobs] = useState<ComputeJobMetaData[]>([])
|
|
||||||
const isMounted = useIsMounted()
|
const isMounted = useIsMounted()
|
||||||
const newCancelToken = useCancelToken()
|
const newCancelToken = useCancelToken()
|
||||||
|
|
||||||
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
const [jobs, setJobs] = useState<ComputeJobMetaData[]>([])
|
||||||
const [columnsMinimal] = useState([columns[4], columns[5], columns[3]])
|
const [columnsMinimal] = useState([columns[4], columns[5], columns[3]])
|
||||||
|
|
||||||
const fetchJobs = useCallback(async () => {
|
const fetchJobs = useCallback(async () => {
|
||||||
@ -96,7 +97,7 @@ export default function ComputeJobs({
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const jobs = await getComputeJobs(
|
const jobs = await getComputeJobs(
|
||||||
assetChainId || chainIds,
|
assetChainIds || chainIds,
|
||||||
accountId,
|
accountId,
|
||||||
asset,
|
asset,
|
||||||
newCancelToken()
|
newCancelToken()
|
||||||
@ -106,15 +107,11 @@ export default function ComputeJobs({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
LoggerInstance.error(error.message)
|
LoggerInstance.error(error.message)
|
||||||
}
|
}
|
||||||
}, [chainIds, accountId, asset, isMounted])
|
}, [chainIds, accountId, asset, isMounted, assetChainIds, newCancelToken])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchJobs()
|
fetchJobs()
|
||||||
}, [fetchJobs])
|
}, [fetchJobs, refetchJobs])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
fetchJobs()
|
|
||||||
}, [refatchJobs])
|
|
||||||
|
|
||||||
return accountId ? (
|
return accountId ? (
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user