diff --git a/.env.example b/.env.example index 60a85927b..9fca81994 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ - #NEXT_PUBLIC_INFURA_PROJECT_ID="xxx" #NEXT_PUBLIC_MARKET_FEE_ADDRESS="0xxx" #NEXT_PUBLIC_PUBLISHER_MARKET_ORDER_FEE="1" @@ -8,11 +7,6 @@ #NEXT_PUBLIC_CONSUME_MARKET_POOL_SWAP_FEE="1" #NEXT_PUBLIC_CONSUME_MARKET_FIXED_SWAP_FEE="1" - - -#NEXT_PUBLIC_PORTIS_ID="xxx" - - # # ADVANCED SETTINGS # diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fda9b1700..65a7f324e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,7 +17,6 @@ jobs: - run: npm run build env: 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 env: diff --git a/app.config.js b/app.config.js index 284628695..a8b439129 100644 --- a/app.config.js +++ b/app.config.js @@ -75,9 +75,6 @@ module.exports = { storageKey: 'oceanDarkMode' }, - // Wallets - portisId: process.env.NEXT_PUBLIC_PORTIS_ID || 'xxx', - // Used to show or hide the fixed, dynamic or free price options // tab to publishers during the price creation. allowFixedPricing: process.env.NEXT_PUBLIC_ALLOW_FIXED_PRICING || 'true', diff --git a/content/site.json b/content/site.json index 78ee99ef2..db26be565 100644 --- a/content/site.json +++ b/content/site.json @@ -14,7 +14,7 @@ "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": { "ctd": "Compute-to-Data is still in a testing phase, please use it only on test networks." } diff --git a/package-lock.json b/package-lock.json index 65fcf939e..91107224f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "@oceanprotocol/art": "^3.2.0", "@oceanprotocol/lib": "^1.1.2", "@oceanprotocol/typographies": "^0.1.0", - "@portis/web3": "^4.0.7", "@tippyjs/react": "^4.2.6", "@urql/exchange-refocus": "^0.2.5", "@walletconnect/web3-provider": "^1.7.8", @@ -5239,17 +5238,6 @@ "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": { "version": "9.4.5", "resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz", @@ -33516,11 +33504,6 @@ "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": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -33616,48 +33599,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": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz", @@ -44984,6 +44925,7 @@ "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", "decimal.js": "^10.3.1", + "web3": "^1.7.3", "web3-core": "^1.7.1", "web3-eth-contract": "^1.7.1" } @@ -45035,6 +44977,7 @@ "integrity": "sha512-rmVKYEsKzurfRU0xJz+iHelbi1LGlihIWZ7Qvmb/CBz1EkhL7nOkW4SVXmG2dA5Ce0si2gr88i6q4eBOMRNJ1w==", "dev": true, "requires": { + "@oclif/config": "^1.18.2", "@oclif/errors": "^1.3.5", "@oclif/help": "^1.0.1", "@oclif/parser": "^3.8.6", @@ -45463,17 +45406,6 @@ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.5.tgz", "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": { "version": "9.4.5", "resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.4.5.tgz", @@ -67517,11 +67449,6 @@ "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": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -67590,46 +67517,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": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/polished/-/polished-4.2.2.tgz", diff --git a/package.json b/package.json index 6d4e438ed..ae0d5dde8 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "@oceanprotocol/art": "^3.2.0", "@oceanprotocol/lib": "^1.1.2", "@oceanprotocol/typographies": "^0.1.0", - "@portis/web3": "^4.0.7", "@tippyjs/react": "^4.2.6", "@urql/exchange-refocus": "^0.2.5", "@walletconnect/web3-provider": "^1.7.8", diff --git a/src/@context/MarketMetadata/_types.ts b/src/@context/MarketMetadata/_types.ts index c51218edc..1be2cb03f 100644 --- a/src/@context/MarketMetadata/_types.ts +++ b/src/@context/MarketMetadata/_types.ts @@ -18,7 +18,6 @@ export interface AppConfig { consumeMarketPoolSwapFee: string consumeMarketFixedSwapFee: string currencies: string[] - portisId: string allowFixedPricing: string allowDynamicPricing: string allowFreePricing: string diff --git a/src/@context/Web3.tsx b/src/@context/Web3.tsx index a97df6812..c7a7732a5 100644 --- a/src/@context/Web3.tsx +++ b/src/@context/Web3.tsx @@ -9,7 +9,7 @@ import React, { } from 'react' import Web3 from 'web3' 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 { LoggerInstance } from '@oceanprotocol/lib' import { isBrowser } from '@utils/index' @@ -58,12 +58,6 @@ const providerOptions = isBrowser walletconnect: { package: WalletConnectProvider, options: { infuraId } - }, - portis: { - package: require('@portis/web3'), - options: { - id: portisId - } } // torus: { // package: require('@toruslabs/torus-embed') diff --git a/src/@utils/accessDetailsAndPricing.ts b/src/@utils/accessDetailsAndPricing.ts index 7cbf86a97..612c77978 100644 --- a/src/@utils/accessDetailsAndPricing.ts +++ b/src/@utils/accessDetailsAndPricing.ts @@ -12,8 +12,7 @@ import { Asset, LoggerInstance, ProviderFees, - ProviderInstance, - unitsToAmount + ProviderInstance } from '@oceanprotocol/lib' import { AssetExtended } from 'src/@types/AssetExtended' import { calcInGivenOut } from './pool' @@ -174,22 +173,21 @@ function getAccessDetailsFromTokenPrice( ): AccessDetails { const accessDetails = {} as AccessDetails - if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 0) { + if (tokenPrice?.orders?.length > 0) { const order = tokenPrice.orders[0] - const reusedOrder = - order && order.reuses && order.reuses.length > 0 ? order.reuses[0] : null + const reusedOrder = 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 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 - accessDetails.validOrderTx = reusedOrder ? reusedOrder.tx : order.tx + accessDetails.validOrderTx = reusedOrder?.tx || order?.tx } // TODO: fetch order fee from sub query - accessDetails.publisherMarketOrderFee = tokenPrice.publishMarketFeeAmount + accessDetails.publisherMarketOrderFee = tokenPrice?.publishMarketFeeAmount // free is always the best price - if (tokenPrice.dispensers && tokenPrice.dispensers.length > 0) { + if (tokenPrice?.dispensers?.length > 0) { const dispenser = tokenPrice.dispensers[0] accessDetails.type = 'free' accessDetails.addressOrId = dispenser.token.id @@ -204,10 +202,7 @@ function getAccessDetailsFromTokenPrice( } // checking for fixed price - if ( - tokenPrice.fixedRateExchanges && - tokenPrice.fixedRateExchanges.length > 0 - ) { + if (tokenPrice?.fixedRateExchanges?.length > 0) { const fixed = tokenPrice.fixedRateExchanges[0] accessDetails.type = 'fixed' accessDetails.addressOrId = fixed.exchangeId @@ -228,7 +223,7 @@ function getAccessDetailsFromTokenPrice( } // checking for pools - if (tokenPrice.pools && tokenPrice.pools.length > 0) { + if (tokenPrice?.pools?.length > 0) { const pool = tokenPrice.pools[0] accessDetails.type = 'dynamic' accessDetails.addressOrId = pool.id @@ -257,7 +252,6 @@ function getAccessDetailsFromTokenPrice( * @return {Promise} */ export async function getOrderPriceAndFees( - web3: Web3, asset: AssetExtended, accountId?: string, paramsForPool?: CalcInGivenOutParams, @@ -284,10 +278,10 @@ export async function getOrderPriceAndFees( !providerFees && (await ProviderInstance.initialize( asset?.id, - asset.services[0].id, + asset?.services[0].id, 0, accountId, - asset.services[0].serviceEndpoint + asset?.services[0].serviceEndpoint )) orderPriceAndFee.providerFee = providerFees || initializeData.providerFee diff --git a/src/@utils/aquarius.ts b/src/@utils/aquarius.ts index 9eea10c6b..8eb6208c9 100644 --- a/src/@utils/aquarius.ts +++ b/src/@utils/aquarius.ts @@ -180,7 +180,7 @@ export async function getAssetsFromDidList( didList: string[], chainIds: number[], cancelToken: CancelToken -): Promise { +): Promise { try { if (!(didList.length > 0)) return diff --git a/src/@utils/compute.ts b/src/@utils/compute.ts index 9a7eaf9a2..a47caf898 100644 --- a/src/@utils/compute.ts +++ b/src/@utils/compute.ts @@ -21,7 +21,6 @@ import { } from './aquarius' import { fetchDataForMultipleChains } from './subgraph' import { getServiceById, getServiceByName } from './ddo' -import { getOceanConfig } from './ocean' import { SortTermOptions } from 'src/@types/aquarius/SearchQuery' import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection' import { transformAssetToAssetSelection } from './assetConvertor' @@ -93,6 +92,7 @@ export async function isOrderable( ): Promise { const datasetService: Service = getServiceById(asset, serviceId) if (!datasetService) return false + if (datasetService.type === 'compute') { if (algorithm.meta) { // check if raw algo is allowed @@ -149,7 +149,7 @@ export async function getComputeEnviroment( } } -export function getQuerryString( +export function getQueryString( trustedAlgorithmList: PublisherTrustedAlgorithm[], chainId?: number ): SearchQuery { @@ -182,7 +182,7 @@ export async function getAlgorithmsForAsset( algorithms = [] } else { const gueryResults = await queryMetadata( - getQuerryString(publisherTrustedAlgorithms, asset.chainId), + getQueryString(publisherTrustedAlgorithms, asset.chainId), token ) algorithms = gueryResults?.results diff --git a/src/@utils/ddo.ts b/src/@utils/ddo.ts index 11a56e8a9..0bc817e4f 100644 --- a/src/@utils/ddo.ts +++ b/src/@utils/ddo.ts @@ -1,13 +1,8 @@ import { Asset, DDO, Service } from '@oceanprotocol/lib' -interface Consumable { - status: number - message: string - result: boolean -} export function getServiceByName( ddo: Asset | DDO, - name: 'access' | 'compute' | 'metadata' + name: 'access' | 'compute' ): Service { if (!ddo) return diff --git a/src/@utils/fixedRateExchange.ts b/src/@utils/fixedRateExchange.ts index 30abb2f2d..e8d1b1360 100644 --- a/src/@utils/fixedRateExchange.ts +++ b/src/@utils/fixedRateExchange.ts @@ -3,7 +3,6 @@ import { AccessDetails } from 'src/@types/Price' import Web3 from 'web3' import { getOceanConfig } from './ocean' import { consumeMarketPoolSwapFee } from '../../app.config' - import { getDummyWeb3 } from './web3' /** diff --git a/src/@utils/nft.ts b/src/@utils/nft.ts index 166a447e0..d75518d74 100644 --- a/src/@utils/nft.ts +++ b/src/@utils/nft.ts @@ -112,17 +112,6 @@ export async function setNftMetadata( // theoretically used by aquarius or provider, not implemented yet, will remain hardcoded 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( asset.nftAddress, accountId, diff --git a/src/@utils/order.ts b/src/@utils/order.ts index 464521f65..665e39318 100644 --- a/src/@utils/order.ts +++ b/src/@utils/order.ts @@ -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 * @param web3 * @param asset + * @param orderPriceAndFees * @param accountId - * @param computeEnv - * @param computeValidUntil + * @param providerFees * @param computeConsumerAddress * @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 * @param web3 * @param asset + * @param orderPriceAndFees * @param accountId - * @param computeEnv - * @param computeValidUntil + * @param hasDatatoken + * @param initializeData * @param computeConsumerAddress * @returns {Promise} tx id */ @@ -186,12 +187,16 @@ export async function handleComputeOrder( initializeData.providerFee && initializeData.providerFee.providerFeeAmount !== '0' ) { + const baseToken = + asset?.accessDetails?.type === 'free' + ? getOceanConfig(asset.chainId).oceanTokenAddress + : asset?.accessDetails?.baseToken?.address const txApproveWei = await approveWei( web3, accountId, - asset.accessDetails.baseToken.address, - asset.accessDetails.datatoken.address, - initializeData.providerFee.providerFeeAmount + baseToken, + asset?.accessDetails?.datatoken?.address, + initializeData?.providerFee?.providerFeeAmount ) if (!txApproveWei) { toast.error('Failed to approve provider fees!') diff --git a/src/@utils/provider.ts b/src/@utils/provider.ts index 91ee9c2b9..358361bb4 100644 --- a/src/@utils/provider.ts +++ b/src/@utils/provider.ts @@ -8,7 +8,6 @@ import { ProviderComputeInitializeResults, ProviderInstance } from '@oceanprotocol/lib' -import { toast } from 'react-toastify' import { AssetExtended } from 'src/@types/AssetExtended' import Web3 from 'web3' import { getValidUntilTime } from './compute' diff --git a/src/@utils/subgraph.ts b/src/@utils/subgraph.ts index 2972980dd..7b32da86b 100644 --- a/src/@utils/subgraph.ts +++ b/src/@utils/subgraph.ts @@ -15,7 +15,7 @@ import { import { OrdersData_orders as OrdersData } from '../@types/subgraph/OrdersData' import { UserSalesQuery as UsersSalesList } from '../@types/subgraph/UserSalesQuery' import { OpcFeesQuery as OpcFeesData } from '../@types/subgraph/OpcFeesQuery' -import { calcSingleOutGivenPoolIn, getLiquidityByShares } from './pool' +import { calcSingleOutGivenPoolIn } from './pool' import Decimal from 'decimal.js' import { MAX_DECIMALS } from './constants' diff --git a/src/components/@shared/AnnouncementBanner/index.module.css b/src/components/@shared/AnnouncementBanner/index.module.css index 987a45de0..751ee3fcc 100644 --- a/src/components/@shared/AnnouncementBanner/index.module.css +++ b/src/components/@shared/AnnouncementBanner/index.module.css @@ -24,10 +24,6 @@ display: inline-block; } -.banner button { - font-size: calc(var(--font-size-small) / 1.1); -} - .text { font-size: var(--font-size-small); font-weight: var(--font-weight-bold); @@ -41,6 +37,13 @@ text-decoration: underline; } +.link { + color: inherit; + text-decoration: underline; + text-transform: inherit; + font-size: var(--font-size-small); +} + .text p:last-child { margin-bottom: 0; } diff --git a/src/components/@shared/AnnouncementBanner/index.tsx b/src/components/@shared/AnnouncementBanner/index.tsx index 2e1e532b9..ae28231c8 100644 --- a/src/components/@shared/AnnouncementBanner/index.tsx +++ b/src/components/@shared/AnnouncementBanner/index.tsx @@ -35,7 +35,12 @@ export default function AnnouncementBanner({
{text && } {action && ( - )} diff --git a/src/components/@shared/ButtonBuy/index.module.css b/src/components/@shared/ButtonBuy/index.module.css index b89ee14f8..99516295e 100644 --- a/src/components/@shared/ButtonBuy/index.module.css +++ b/src/components/@shared/ButtonBuy/index.module.css @@ -4,7 +4,7 @@ } .actionsCenter { - margin: auto !important; + margin: auto; display: block; } diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index e9eb4580a..dff602cab 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -19,11 +19,26 @@ export default function App({ const { siteContent, appConfig } = useMarketMetadata() const { accountId } = useWeb3() const { isInPurgatory, purgatoryData } = useAccountPurgatory(accountId) + function openInNewTab() { + window + .open( + 'https://blog.oceanprotocol.com/how-to-publish-a-data-nft-f58ad2a622a9', + '_blank' + ) + .focus() + } return (
{siteContent?.announcement !== '' && ( - + )}
diff --git a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx index bbe7ff168..94c0ee88d 100644 --- a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx @@ -80,9 +80,11 @@ export default function FormStartCompute({ validUntil?: string }): ReactElement { const { siteContent } = useMarketMetadata() + const { accountId, balance } = useWeb3() const { isValid, values }: FormikContextType<{ algorithm: string }> = useFormikContext() const { asset, isAssetNetwork } = useAsset() + const [totalPrice, setTotalPrice] = useState('0') const [datasetOrderPrice, setDatasetOrderPrice] = useState( asset?.accessDetails?.price @@ -91,7 +93,6 @@ export default function FormStartCompute({ selectedAlgorithmAsset?.accessDetails?.price ) const [isBalanceSufficient, setIsBalanceSufficient] = useState(false) - const { accountId, balance, isSupportedOceanNetwork } = useWeb3() function getAlgorithmAsset(algorithmId: string): Asset { let assetDdo = null @@ -102,7 +103,8 @@ export default function FormStartCompute({ } useEffect(() => { - if (!values.algorithm || !isConsumable) return + if (!values.algorithm || !accountId || !isConsumable) return + async function fetchAlgorithmAssetExtended() { const algorithmAsset = getAlgorithmAsset(values.algorithm) const accessDetails = await getAccessDetails( @@ -165,15 +167,16 @@ export default function FormStartCompute({ hasDatatokenSelectedComputeAsset, datasetOrderPriceAndFees, algoOrderPriceAndFees, - selectedAlgorithmAsset + providerFeeAmount ]) useEffect(() => { - if (!totalPrice || !balance.ocean || !dtBalance) return + if (!totalPrice || !balance?.ocean || !dtBalance) return + setIsBalanceSufficient( compareAsBN(balance.ocean, `${totalPrice}`) || Number(dtBalance) >= 1 ) - }, [totalPrice, balance.ocean, dtBalance]) + }, [totalPrice, balance?.ocean, dtBalance]) return (
@@ -217,7 +220,7 @@ export default function FormStartCompute({ !isValid || !isBalanceSufficient || !isAssetNetwork || - !selectedAlgorithmAsset?.accessDetails.isPurchasable + !selectedAlgorithmAsset?.accessDetails?.isPurchasable } hasPreviousOrder={hasPreviousOrder} hasDatatoken={hasDatatoken} diff --git a/src/components/Asset/AssetActions/Compute/PriceOutput.module.css b/src/components/Asset/AssetActions/Compute/PriceOutput.module.css index d9e7780f9..413f2f859 100644 --- a/src/components/Asset/AssetActions/Compute/PriceOutput.module.css +++ b/src/components/Asset/AssetActions/Compute/PriceOutput.module.css @@ -39,7 +39,6 @@ display: grid; grid-template-columns: 5% 1fr auto; column-gap: calc(var(--spacer) / 10); - /* justify-content: space-between; */ } .priceRow:last-child { diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index 2730cb891..2294e7208 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, ReactElement, useEffect, useCallback } from 'react' +import React, { useState, ReactElement, useEffect } from 'react' import { Asset, DDO, @@ -36,7 +36,6 @@ import AlgorithmDatasetsListForCompute from './AlgorithmDatasetsListForCompute' import AssetActionHistoryTable from '../AssetActionHistoryTable' import ComputeJobs from '../../../Profile/History/ComputeJobs' import { useCancelToken } from '@hooks/useCancelToken' -// import { useIsMounted } from '@hooks/useIsMounted' import { Decimal } from 'decimal.js' import { useAbortController } from '@hooks/useAbortController' import { getOrderPriceAndFees } from '@utils/accessDetailsAndPricing' @@ -55,42 +54,35 @@ export default function Compute({ dtBalance, file, fileIsLoading, - isConsumable, consumableFeedback }: { asset: AssetExtended dtBalance: string file: FileInfo fileIsLoading?: boolean - isConsumable?: boolean consumableFeedback?: string }): ReactElement { const { accountId, web3 } = useWeb3() - - const [isJobStarting, setIsJobStarting] = useState(false) - const [error, setError] = useState() + const { getOpcFeeForToken } = useMarketMetadata() + const { poolData } = usePool() const newAbortController = useAbortController() + const newCancelToken = useCancelToken() + + const [isOrdering, setIsOrdering] = useState(false) + const [isOrdered, setIsOrdered] = useState(false) + const [error, setError] = useState() const [algorithmList, setAlgorithmList] = useState() const [ddoAlgorithmList, setDdoAlgorithmList] = useState() const [selectedAlgorithmAsset, setSelectedAlgorithmAsset] = useState() const [hasAlgoAssetDatatoken, setHasAlgoAssetDatatoken] = useState() - const [isPublished, setIsPublished] = useState(false) const [algorithmDTBalance, setAlgorithmDTBalance] = useState() - // const [isOwned, setIsOwned] = useState(false) const [validOrderTx, setValidOrderTx] = useState('') - // const [isAlgorithmOwned, setIsAlgorithmOwned] = useState(false) 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 [isAlgoConsumablePrice, setIsAlgoConsumablePrice] = useState(true) const [computeStatusText, setComputeStatusText] = useState('') const [computeEnv, setComputeEnv] = useState() const [initializedProviderResponse, setInitializedProviderResponse] = @@ -99,19 +91,18 @@ export default function Compute({ const [computeValidUntil, setComputeValidUntil] = useState('0') const [datasetOrderPriceAndFees, setDatasetOrderPriceAndFees] = useState() - const [isRequestingDataseOrderPrice, setIsRequestingDataseOrderPrice] = - useState(false) const [algoOrderPriceAndFees, setAlgoOrderPriceAndFees] = useState() const [isRequestingAlgoOrderPrice, setIsRequestingAlgoOrderPrice] = useState(false) - const [refatchJobs, setRefatchJobs] = useState(false) - // const [isProviderFeeValid, setIsProviderFeeValid] = useState(false) + const [refetchJobs, setRefetchJobs] = useState(false) + + const hasDatatoken = Number(dtBalance) >= 1 const isComputeButtonDisabled = - isJobStarting === true || + isOrdering === true || file === null || (!validOrderTx && !hasDatatoken && !isConsumablePrice) || - (!validAlgorithmOrderTx && !hasAlgoAssetDatatoken && !isAlgoConsumablePrice) + (!validAlgorithmOrderTx && !hasAlgoAssetDatatoken) async function checkAssetDTBalance(asset: DDO): Promise { if (!asset?.services[0].datatokenAddress) return @@ -168,8 +159,8 @@ export default function Compute({ ) { setComputeStatusText( getComputeFeedback( - asset.accessDetails.baseToken?.symbol, - asset.accessDetails.datatoken?.symbol, + asset.accessDetails?.baseToken?.symbol, + asset.accessDetails?.datatoken?.symbol, asset.metadata.type )[0] ) @@ -220,7 +211,7 @@ export default function Compute({ if (selectedAlgorithmAsset?.accessDetails?.type === 'dynamic') { const response = await getPoolData( selectedAlgorithmAsset.chainId, - selectedAlgorithmAsset.accessDetails.addressOrId, + selectedAlgorithmAsset.accessDetails?.addressOrId, selectedAlgorithmAsset?.nft.owner, accountId || '' ) @@ -304,8 +295,8 @@ export default function Compute({ async function startJob(): Promise { try { - setIsJobStarting(true) - setIsPublished(false) // would be nice to rename this + setIsOrdering(true) + setIsOrdered(false) // would be nice to rename this setError(undefined) const computeService = getServiceByName(asset, 'compute') const computeAlgorithm: ComputeAlgorithm = { @@ -413,14 +404,14 @@ export default function Compute({ return } LoggerInstance.log('[compute] Starting compute job response: ', response) - setIsPublished(true) - setRefatchJobs(!refatchJobs) + setIsOrdered(true) + setRefetchJobs(!refetchJobs) initPriceAndFees() } catch (error) { setError('Failed to start job!') LoggerInstance.error('[compute] Failed to start job: ', error.message) } finally { - setIsJobStarting(false) + setIsOrdering(false) } } @@ -457,11 +448,7 @@ export default function Compute({ ddoListAlgorithms={ddoAlgorithmList} selectedAlgorithmAsset={selectedAlgorithmAsset} setSelectedAlgorithm={setSelectedAlgorithmAsset} - isLoading={ - isJobStarting || - isRequestingDataseOrderPrice || - isRequestingAlgoOrderPrice - } + isLoading={isOrdering || isRequestingAlgoOrderPrice} isComputeButtonDisabled={isComputeButtonDisabled} hasPreviousOrder={validOrderTx !== undefined} hasDatatoken={hasDatatoken} @@ -482,7 +469,6 @@ export default function Compute({ selectedAlgorithmAsset?.datatokens[0]?.symbol } dtBalanceSelectedComputeAsset={algorithmDTBalance} - selectedComputeAssetLowPoolLiquidity={!isAlgoConsumablePrice} selectedComputeAssetType="algorithm" selectedComputeAssetTimeout={secondsToString( selectedAlgorithmAsset?.services[0]?.timeout @@ -500,7 +486,7 @@ export default function Compute({ )}
- {isPublished && ( + {isOrdered && ( )}
@@ -508,8 +494,8 @@ export default function Compute({ )} diff --git a/src/components/Asset/AssetActions/Download.tsx b/src/components/Asset/AssetActions/Download.tsx index 13bd993c3..d0d44a5e5 100644 --- a/src/components/Asset/AssetActions/Download.tsx +++ b/src/components/Asset/AssetActions/Download.tsx @@ -83,7 +83,6 @@ export default function Download({ consumeMarketSwapFee: '0' } const _orderPriceAndFees = await getOrderPriceAndFees( - web3, asset, ZERO_ADDRESS, paramsForPool diff --git a/src/components/Asset/Edit/index.tsx b/src/components/Asset/Edit/index.tsx index 59145bde6..40d144254 100644 --- a/src/components/Asset/Edit/index.tsx +++ b/src/components/Asset/Edit/index.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useState, useEffect } from 'react' -import { LoggerInstance } from '@oceanprotocol/lib' import { useAsset } from '@context/Asset' import styles from './index.module.css' import Tabs from '@shared/atoms/Tabs' diff --git a/src/components/Header/Wallet/Details.tsx b/src/components/Header/Wallet/Details.tsx index a786570ae..bd042f946 100644 --- a/src/components/Header/Wallet/Details.tsx +++ b/src/components/Header/Wallet/Details.tsx @@ -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 { useUserPreferences } from '@context/UserPreferences' import Button from '@shared/atoms/Button' @@ -7,11 +7,9 @@ import Conversion from '@shared/Price/Conversion' import { useWeb3 } from '@context/Web3' import { getOceanConfig } from '@utils/ocean' import styles from './Details.module.css' -import InputElement from '@shared/FormInput/InputElement' export default function Details(): ReactElement { const { - web3Provider, web3ProviderInfo, web3Modal, connect, @@ -27,7 +25,6 @@ export default function Details(): ReactElement { address: string symbol: string }>() - const [portisNetwork, setPortisNetwork] = useState() useEffect(() => { if (!networkId) return @@ -45,16 +42,6 @@ export default function Details(): ReactElement { }) }, [networkData, networkId]) - // Handle network change for Portis - async function handlePortisNetworkChange(e: ChangeEvent) { - 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 (
    @@ -76,16 +63,6 @@ export default function Details(): ReactElement { {web3ProviderInfo?.name} - {web3ProviderInfo?.name === 'Portis' && ( - - )} {web3ProviderInfo?.name === 'MetaMask' && (

    - {web3ProviderInfo?.name === 'Portis' && ( - - )}

diff --git a/src/components/Profile/History/ComputeJobs/index.tsx b/src/components/Profile/History/ComputeJobs/index.tsx index 3d33c65c7..d104c9f3e 100644 --- a/src/components/Profile/History/ComputeJobs/index.tsx +++ b/src/components/Profile/History/ComputeJobs/index.tsx @@ -71,20 +71,21 @@ const columns = [ export default function ComputeJobs({ minimal, - assetChainId, - refatchJobs + assetChainIds, + refetchJobs }: { minimal?: boolean - assetChainId?: number[] - refatchJobs?: boolean + assetChainIds?: number[] + refetchJobs?: boolean }): ReactElement { const { accountId } = useWeb3() const { asset } = useAsset() const { chainIds } = useUserPreferences() - const [isLoading, setIsLoading] = useState(false) - const [jobs, setJobs] = useState([]) const isMounted = useIsMounted() const newCancelToken = useCancelToken() + + const [isLoading, setIsLoading] = useState(false) + const [jobs, setJobs] = useState([]) const [columnsMinimal] = useState([columns[4], columns[5], columns[3]]) const fetchJobs = useCallback(async () => { @@ -96,7 +97,7 @@ export default function ComputeJobs({ try { setIsLoading(true) const jobs = await getComputeJobs( - assetChainId || chainIds, + assetChainIds || chainIds, accountId, asset, newCancelToken() @@ -106,15 +107,11 @@ export default function ComputeJobs({ } catch (error) { LoggerInstance.error(error.message) } - }, [chainIds, accountId, asset, isMounted]) + }, [chainIds, accountId, asset, isMounted, assetChainIds, newCancelToken]) useEffect(() => { fetchJobs() - }, [fetchJobs]) - - useEffect(() => { - fetchJobs() - }, [refatchJobs]) + }, [fetchJobs, refetchJobs]) return accountId ? ( <>