From dc4add5c70240e6b18fd04da2dd6d59dfbfb3ba8 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 9 Aug 2022 05:45:28 -0700 Subject: [PATCH 01/22] minor fixes (#1639) * minor fixes * error fix * add loading * add price loading * remove console.log Co-authored-by: Matthias Kretschmann --- src/@utils/order.ts | 4 ++- .../Asset/AssetActions/Download.tsx | 26 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/@utils/order.ts b/src/@utils/order.ts index a0bfde14b..418a2f603 100644 --- a/src/@utils/order.ts +++ b/src/@utils/order.ts @@ -57,7 +57,9 @@ export async function order( _consumeMarketFee: { consumeMarketFeeAddress: marketFeeAddress, consumeMarketFeeAmount: consumeMarketOrderFee, - consumeMarketFeeToken: asset.accessDetails.baseToken.address + consumeMarketFeeToken: + asset?.accessDetails?.baseToken?.address || + '0x0000000000000000000000000000000000000000' } } as OrderParams diff --git a/src/components/Asset/AssetActions/Download.tsx b/src/components/Asset/AssetActions/Download.tsx index 84efbaacc..ac9e3f1a5 100644 --- a/src/components/Asset/AssetActions/Download.tsx +++ b/src/components/Asset/AssetActions/Download.tsx @@ -16,6 +16,7 @@ import { toast } from 'react-toastify' import { useIsMounted } from '@hooks/useIsMounted' import { useMarketMetadata } from '@context/MarketMetadata' import Alert from '@shared/atoms/Alert' +import Loader from '@shared/atoms/Loader' export default function Download({ asset, @@ -41,6 +42,7 @@ export default function Download({ const [hasDatatoken, setHasDatatoken] = useState(false) const [statusText, setStatusText] = useState('') const [isLoading, setIsLoading] = useState(false) + const [isPriceLoading, setIsPriceLoading] = useState(false) const [isOwned, setIsOwned] = useState(false) const [validOrderTx, setValidOrderTx] = useState('') const [orderPriceAndFees, setOrderPriceAndFees] = @@ -64,8 +66,11 @@ export default function Download({ ) return + !orderPriceAndFees && setIsPriceLoading(true) + const _orderPriceAndFees = await getOrderPriceAndFees(asset, ZERO_ADDRESS) setOrderPriceAndFees(_orderPriceAndFees) + !orderPriceAndFees && setIsPriceLoading(false) } init() @@ -84,6 +89,7 @@ export default function Download({ useEffect(() => { if ( + (asset?.accessDetails?.type === 'fixed' && !orderPriceAndFees) || !isMounted || !accountId || !asset?.accessDetails || @@ -112,7 +118,8 @@ export default function Download({ hasDatatoken, accountId, isOwned, - isUnsupportedPricing + isUnsupportedPricing, + orderPriceAndFees ]) async function handleOrderOrDownload() { @@ -184,12 +191,17 @@ export default function Download({ /> ) : ( <> - + {isPriceLoading ? ( + + ) : ( + + )} + {!isInPurgatory && } )} From 27517faea2e4cab5041e10bf6b674b24261c94c0 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Fri, 12 Aug 2022 02:38:13 -0700 Subject: [PATCH 02/22] fix tag search (#1651) --- src/components/@shared/atoms/Tags/index.tsx | 4 +- src/components/Search/utils.ts | 139 +++++++++----------- 2 files changed, 66 insertions(+), 77 deletions(-) diff --git a/src/components/@shared/atoms/Tags/index.tsx b/src/components/@shared/atoms/Tags/index.tsx index a85216861..1f5c70943 100644 --- a/src/components/@shared/atoms/Tags/index.tsx +++ b/src/components/@shared/atoms/Tags/index.tsx @@ -15,9 +15,7 @@ const Tag = ({ tag, noLinks }: { tag: string; noLinks?: boolean }) => { return noLinks ? ( {tag} ) : ( - + {tag} diff --git a/src/components/Search/utils.ts b/src/components/Search/utils.ts index cbc2c900d..032bf5ace 100644 --- a/src/components/Search/utils.ts +++ b/src/components/Search/utils.ts @@ -35,7 +35,6 @@ export function getSearchQuery( text?: string, owner?: string, tags?: string, - categories?: string, page?: string, offset?: string, sort?: string, @@ -45,83 +44,77 @@ export function getSearchQuery( ): SearchQuery { text = escapeESReservedChars(text) const emptySearchTerm = text === undefined || text === '' + const filters: FilterTerm[] = [] + let searchTerm = text || '' + let nestedQuery + if (tags) { + filters.push(getFilterTerm('metadata.tags.keyword', tags)) + } else { + searchTerm = searchTerm.trim() + const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim() + const noSpaceSearchTerm = searchTerm.split(' ').join('').trim() - let searchTerm = owner - ? `(nft.owner:${owner})` - : tags - ? // eslint-disable-next-line no-useless-escape - `(metadata.tags:\"${tags}\")` - : // : categories - // ? // eslint-disable-next-line no-useless-escape - // `(service.attributes.additionalInformation.categories:\"${categories}\")` - text || '' + const prefixedSearchTerm = + emptySearchTerm && searchTerm + ? searchTerm + : !emptySearchTerm && searchTerm + ? '*' + searchTerm + '*' + : '**' + const searchFields = [ + 'id', + 'nft.owner', + 'datatokens.address', + 'datatokens.name', + 'datatokens.symbol', + 'metadata.name^10', + 'metadata.author', + 'metadata.description', + 'metadata.tags' + ] - searchTerm = searchTerm.trim() - const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim() - const noSpaceSearchTerm = searchTerm.split(' ').join('').trim() - - const prefixedSearchTerm = - emptySearchTerm && searchTerm - ? searchTerm - : !emptySearchTerm && searchTerm - ? '*' + searchTerm + '*' - : '**' - const searchFields = [ - 'id', - 'nft.owner', - 'datatokens.address', - 'datatokens.name', - 'datatokens.symbol', - 'metadata.name^10', - 'metadata.author', - 'metadata.description', - 'metadata.tags' - ] - - const nestedQuery = { - must: [ - { - bool: { - should: [ - { - query_string: { - query: `${modifiedSearchTerm}`, - fields: searchFields, - minimum_should_match: '2<75%', - phrase_slop: 2, - boost: 5 - } - }, - { - query_string: { - query: `${noSpaceSearchTerm}*`, - fields: searchFields, - boost: 5, - lenient: true - } - }, - { - match_phrase: { - content: { - query: `${searchTerm}`, - boost: 10 + nestedQuery = { + must: [ + { + bool: { + should: [ + { + query_string: { + query: `${modifiedSearchTerm}`, + fields: searchFields, + minimum_should_match: '2<75%', + phrase_slop: 2, + boost: 5 + } + }, + { + query_string: { + query: `${noSpaceSearchTerm}*`, + fields: searchFields, + boost: 5, + lenient: true + } + }, + { + match_phrase: { + content: { + query: `${searchTerm}`, + boost: 10 + } + } + }, + { + query_string: { + query: `${prefixedSearchTerm}`, + fields: searchFields, + default_operator: 'AND' } } - }, - { - query_string: { - query: `${prefixedSearchTerm}`, - fields: searchFields, - default_operator: 'AND' - } - } - ] + ] + } } - } - ] + ] + } } - - const filters: FilterTerm[] = [] accessType !== undefined && filters.push(getFilterTerm('services.type', accessType)) serviceType !== undefined && @@ -162,7 +155,6 @@ export async function getResults( text, owner, tags, - categories, page, offset, sort, @@ -176,7 +168,6 @@ export async function getResults( text, owner, tags, - categories, page, offset, sort, From 2f93d84e5f36f8f4f73b35903e1ce874dc0ea994 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Fri, 12 Aug 2022 12:38:56 +0300 Subject: [PATCH 03/22] Adding links to the docs on forking ocean market (#1649) --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 442ff7f25..f6257f80c 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,12 @@ Additionally, we would also advise that your retain the text saying "Powered by Everything else is made open according to the apache2 license. We look forward to seeing your data marketplace! +If you are looking to fork Ocean Market and create your own marketplace, you will find the following guides useful in our docs: + +- [Forking Ocean Market](https://docs.oceanprotocol.com/building-with-ocean/build-a-marketplace/forking-ocean-market) +- [Customising your Market](https://docs.oceanprotocol.com/building-with-ocean/build-a-marketplace/customising-your-market) +- [Deploying your Market](https://docs.oceanprotocol.com/building-with-ocean/build-a-marketplace/deploying-market) + ## 💰 Pricing Options ### Fixed Pricing From 4d119467a402bea7eba73904ef86bddea9189c8d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 12 Aug 2022 14:11:33 +0100 Subject: [PATCH 04/22] refactor price context to fetch multiple tokens (#1573) * refactor price context to fetch multiple tokens * fixes * move tokenIds to app config * make conversion work * conversion for all user tokens, hide if 0 * different user balance key tactic * remove NFT gas estimation * closes #1633 * small simplification in getCoingeckoTokenId logic * basic Prices provider test * mock some hooks * mock MarketMetadata in all tests --- .jest/__mocks__/MarketMetadata.ts | 73 +++++++++++++++++++ .jest/jest.setup.js | 5 ++ app.config.js | 4 + src/@context/MarketMetadata/_types.ts | 1 + src/@context/MarketMetadata/index.tsx | 6 ++ src/@context/Prices/_constants.ts | 13 ++++ src/@context/Prices/_types.ts | 9 +++ src/@context/Prices/_utils.ts | 23 ++++++ src/@context/Prices/index.test.tsx | 36 +++++++++ src/@context/{Prices.tsx => Prices/index.tsx} | 38 +++------- src/@context/Web3.tsx | 13 ++-- src/@types/TokenBalance.d.ts | 1 - .../@shared/FormFields/Nft/TxFee.tsx | 68 ----------------- .../@shared/FormFields/Nft/index.module.css | 2 +- .../@shared/FormFields/Nft/index.tsx | 3 - src/components/@shared/Price/Conversion.tsx | 34 +++++---- src/components/@shared/Price/PriceUnit.tsx | 2 +- .../Header/Wallet/Details.module.css | 10 ++- src/components/Header/Wallet/Details.tsx | 19 +++-- src/components/Profile/Header/Stats.tsx | 8 +- src/components/Publish/Pricing/CoinSelect.tsx | 1 - src/components/Publish/Pricing/Price.tsx | 6 +- 22 files changed, 243 insertions(+), 132 deletions(-) create mode 100644 .jest/__mocks__/MarketMetadata.ts create mode 100644 src/@context/Prices/_constants.ts create mode 100644 src/@context/Prices/_types.ts create mode 100644 src/@context/Prices/_utils.ts create mode 100644 src/@context/Prices/index.test.tsx rename src/@context/{Prices.tsx => Prices/index.tsx} (62%) delete mode 100644 src/components/@shared/FormFields/Nft/TxFee.tsx diff --git a/.jest/__mocks__/MarketMetadata.ts b/.jest/__mocks__/MarketMetadata.ts new file mode 100644 index 000000000..1f8f92728 --- /dev/null +++ b/.jest/__mocks__/MarketMetadata.ts @@ -0,0 +1,73 @@ +import siteContent from '../../content/site.json' +import appConfig from '../../app.config' + +export default { + getOpcFeeForToken: jest.fn(), + siteContent, + appConfig, + opcFees: [ + { + chainId: 1, + approvedTokens: [ + '0x0642026e7f0b6ccac5925b4e7fa61384250e1701', + '0x967da4048cd07ab37855c090aaf366e4ce1b9f48' + ], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 137, + approvedTokens: [ + '0x282d8efce846a88b159800bd4130ad77443fa1a1', + '0xc5248aa0629c0b2d6a02834a5f172937ac83cbd3' + ], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 56, + approvedTokens: ['0xdce07662ca8ebc241316a15b611c89711414dd1a'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 246, + approvedTokens: ['0x593122aae80a6fc3183b2ac0c4ab3336debee528'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 1285, + approvedTokens: ['0x99c409e5f62e4bd2ac142f17cafb6810b8f0baae'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 3, + approvedTokens: ['0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 4, + approvedTokens: [ + '0x8967bcf84170c91b0d24d4302c2376283b0b3a07', + '0xd92e713d051c37ebb2561803a3b5fbabc4962431' + ], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 80001, + approvedTokens: ['0xd8992ed72c445c35cb4a2be468568ed1079357c8'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + }, + { + chainId: 1287, + approvedTokens: ['0xf6410bf5d773c7a41ebff972f38e7463fa242477'], + swapApprovedFee: '0.001', + swapNotApprovedFee: '0.002' + } + ] +} diff --git a/.jest/jest.setup.js b/.jest/jest.setup.js index 46934ac6b..b8aad47ac 100644 --- a/.jest/jest.setup.js +++ b/.jest/jest.setup.js @@ -1,2 +1,7 @@ import '@testing-library/jest-dom/extend-expect' import './__mocks__/matchMedia' +import marketMetadataMock from './__mocks__/MarketMetadata' + +jest.mock('../../src/@context/MarketMetadata', () => ({ + useMarketMetadata: () => marketMetadataMock +})) diff --git a/app.config.js b/app.config.js index 39af889af..d2bcbb0eb 100644 --- a/app.config.js +++ b/app.config.js @@ -62,6 +62,10 @@ module.exports = { 'LINK' ], + // Tokens to fetch the spot prices from coingecko, against above currencies. + // Refers to Coingecko API tokenIds. + coingeckoTokenIds: ['ocean-protocol', 'h2o', 'ethereum', 'matic-network'], + // Config for https://github.com/donavon/use-dark-mode darkModeConfig: { classNameDark: 'dark', diff --git a/src/@context/MarketMetadata/_types.ts b/src/@context/MarketMetadata/_types.ts index edeca7226..62b61b5bc 100644 --- a/src/@context/MarketMetadata/_types.ts +++ b/src/@context/MarketMetadata/_types.ts @@ -16,6 +16,7 @@ export interface AppConfig { consumeMarketOrderFee: string consumeMarketFixedSwapFee: string currencies: string[] + coingeckoTokenIds: string[] allowFixedPricing: string allowFreePricing: string defaultPrivacyPolicySlug: string diff --git a/src/@context/MarketMetadata/index.tsx b/src/@context/MarketMetadata/index.tsx index 1117a269b..0d612e127 100644 --- a/src/@context/MarketMetadata/index.tsx +++ b/src/@context/MarketMetadata/index.tsx @@ -14,6 +14,7 @@ import { MarketMetadataProviderValue, OpcFee } from './_types' import siteContent from '../../../content/site.json' import appConfig from '../../../app.config' import { fetchData, getQueryContext } from '@utils/subgraph' +import { LoggerInstance } from '@oceanprotocol/lib' const MarketMetadataContext = createContext({} as MarketMetadataProviderValue) @@ -43,6 +44,11 @@ function MarketMetadataProvider({ swapNotApprovedFee: response.data?.opc.swapNonOceanFee } as OpcFee) } + LoggerInstance.log('[MarketMetadata] Got new data.', { + opcFees: opcData, + siteContent, + appConfig + }) setOpcFees(opcData) } getOpcData() diff --git a/src/@context/Prices/_constants.ts b/src/@context/Prices/_constants.ts new file mode 100644 index 000000000..ab21a99cc --- /dev/null +++ b/src/@context/Prices/_constants.ts @@ -0,0 +1,13 @@ +import { Prices } from './_types' +import { coingeckoTokenIds } from '../../../app.config' + +export const initialData: Prices = coingeckoTokenIds.map((tokenId) => ({ + [tokenId]: { + eur: 0.0, + usd: 0.0, + eth: 0.0, + btc: 0.0 + } +}))[0] + +export const refreshInterval = 120000 // 120 sec. diff --git a/src/@context/Prices/_types.ts b/src/@context/Prices/_types.ts new file mode 100644 index 000000000..31d323d3e --- /dev/null +++ b/src/@context/Prices/_types.ts @@ -0,0 +1,9 @@ +export interface Prices { + [key: string]: { + [key: string]: number + } +} + +export interface PricesValue { + prices: Prices +} diff --git a/src/@context/Prices/_utils.ts b/src/@context/Prices/_utils.ts new file mode 100644 index 000000000..67310f5eb --- /dev/null +++ b/src/@context/Prices/_utils.ts @@ -0,0 +1,23 @@ +// +// Deal with differences between token symbol & Coingecko API IDs +// +export function getCoingeckoTokenId(symbol: string) { + // can be OCEAN or mOCEAN + const isOcean = symbol?.toLowerCase().includes('ocean') + // can be H2O or H20 + const isH2o = symbol?.toLowerCase().includes('h2') + const isEth = symbol?.toLowerCase() === 'eth' + const isMatic = symbol?.toLowerCase() === 'matic' + + const priceTokenId = isOcean + ? 'ocean-protocol' + : isH2o + ? 'h2o' + : isEth + ? 'ethereum' + : isMatic + ? 'matic-network' + : symbol?.toLowerCase() + + return priceTokenId +} diff --git a/src/@context/Prices/index.test.tsx b/src/@context/Prices/index.test.tsx new file mode 100644 index 000000000..02e636d19 --- /dev/null +++ b/src/@context/Prices/index.test.tsx @@ -0,0 +1,36 @@ +import React, { ReactElement } from 'react' +import * as SWR from 'swr' +import { renderHook } from '@testing-library/react' +import { PricesProvider, usePrices, getCoingeckoTokenId } from '.' + +jest.spyOn(SWR, 'default').mockImplementation(() => ({ + useSWR: { data: { 'ocean-protocol': { eur: '2' } } }, + isValidating: false, + mutate: jest.fn() +})) + +const wrapper = ({ children }: { children: ReactElement }) => ( + {children} +) + +test('should correctly initialize data', async () => { + const { result } = renderHook(() => usePrices(), { wrapper }) + + expect(result.current.prices['ocean-protocol'].eur).toBeDefined() +}) + +test('useSWR is called', async () => { + const { result } = renderHook(() => usePrices(), { wrapper }) + expect(SWR.default).toHaveBeenCalled() + + // somehow the above spy seems to not fully work, but this assertion is the goal + // expect(result.current.prices['ocean-protocol'].eur).toBe('2') +}) + +test('should get correct Coingecko API ID for OCEAN', async () => { + const id1 = getCoingeckoTokenId('OCEAN') + expect(id1).toBe('ocean-protocol') + + const id2 = getCoingeckoTokenId('mOCEAN') + expect(id2).toBe('ocean-protocol') +}) diff --git a/src/@context/Prices.tsx b/src/@context/Prices/index.tsx similarity index 62% rename from src/@context/Prices.tsx rename to src/@context/Prices/index.tsx index 748f119d9..5e629d267 100644 --- a/src/@context/Prices.tsx +++ b/src/@context/Prices/index.tsx @@ -9,24 +9,10 @@ import React, { import { fetchData } from '@utils/fetch' import useSWR from 'swr' import { LoggerInstance } from '@oceanprotocol/lib' -import { useMarketMetadata } from './MarketMetadata' - -interface Prices { - [key: string]: number -} - -interface PricesValue { - prices: Prices -} - -const initialData: Prices = { - eur: 0.0, - usd: 0.0, - eth: 0.0, - btc: 0.0 -} - -const refreshInterval = 120000 // 120 sec. +import { useMarketMetadata } from '../MarketMetadata' +import { Prices, PricesValue } from './_types' +import { initialData, refreshInterval } from './_constants' +import { getCoingeckoTokenId } from './_utils' const PricesContext = createContext(null) @@ -36,23 +22,23 @@ export default function PricesProvider({ children: ReactNode }): ReactElement { const { appConfig } = useMarketMetadata() - const tokenId = 'ocean-protocol' const [prices, setPrices] = useState(initialData) - const [url, setUrl] = useState('') + const [url, setUrl] = useState() useEffect(() => { if (!appConfig) return - // comma-separated list + const currencies = appConfig.currencies.join(',') - const url = `https://api.coingecko.com/api/v3/simple/price?ids=${tokenId}&vs_currencies=${currencies}` + const tokenIds = appConfig.coingeckoTokenIds.join(',') + const url = `https://api.coingecko.com/api/v3/simple/price?ids=${tokenIds}&vs_currencies=${currencies}` setUrl(url) }, [appConfig]) - const onSuccess = async (data: { [tokenId]: Prices }) => { + const onSuccess = async (data: Prices) => { if (!data) return - LoggerInstance.log('[prices] Got new OCEAN spot prices.', data[tokenId]) - setPrices(data[tokenId]) + LoggerInstance.log('[prices] Got new spot prices.', data) + setPrices(data) } // Fetch new prices periodically with swr @@ -71,4 +57,4 @@ export default function PricesProvider({ // Helper hook to access the provider values const usePrices = (): PricesValue => useContext(PricesContext) -export { PricesProvider, usePrices } +export { PricesProvider, usePrices, getCoingeckoTokenId } diff --git a/src/@context/Web3.tsx b/src/@context/Web3.tsx index cc023c047..7dcf1dd38 100644 --- a/src/@context/Web3.tsx +++ b/src/@context/Web3.tsx @@ -160,12 +160,15 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement { // Helper: Get user balance // ----------------------------------- const getUserBalance = useCallback(async () => { - if (!accountId || !networkId || !web3) return + if (!accountId || !networkId || !web3 || !networkData) return try { - const balance: UserBalance = { - eth: web3.utils.fromWei(await web3.eth.getBalance(accountId, 'latest')) - } + const userBalance = web3.utils.fromWei( + await web3.eth.getBalance(accountId, 'latest') + ) + const key = networkData.nativeCurrency.symbol.toLowerCase() + const balance: UserBalance = { [key]: userBalance } + if (approvedBaseTokens?.length > 0) { await Promise.all( approvedBaseTokens.map(async (token) => { @@ -186,7 +189,7 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement { } catch (error) { LoggerInstance.error('[web3] Error: ', error.message) } - }, [accountId, approvedBaseTokens, networkId, web3]) + }, [accountId, approvedBaseTokens, networkId, web3, networkData]) // ----------------------------------- // Helper: Get user ENS name diff --git a/src/@types/TokenBalance.d.ts b/src/@types/TokenBalance.d.ts index 9d241c52d..d51e735d1 100644 --- a/src/@types/TokenBalance.d.ts +++ b/src/@types/TokenBalance.d.ts @@ -1,4 +1,3 @@ interface UserBalance { - eth: string [key: string]: string } diff --git a/src/components/@shared/FormFields/Nft/TxFee.tsx b/src/components/@shared/FormFields/Nft/TxFee.tsx deleted file mode 100644 index a5d452383..000000000 --- a/src/components/@shared/FormFields/Nft/TxFee.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import React, { ReactElement, useEffect, useState } from 'react' -import { usePrices } from '@context/Prices' -import { useWeb3 } from '@context/Web3' -import Web3 from 'web3' -import useNftFactory from '@hooks/contracts/useNftFactory' -import { NftFactory } from '@oceanprotocol/lib' -import Conversion from '@shared/Price/Conversion' -import { generateNftCreateData, NftMetadata } from '@utils/nft' - -const getEstGasFee = async ( - address: string, - nftFactory: NftFactory, - nftMetadata: NftMetadata, - ethToOceanConversionRate: number -): Promise => { - if (!address || !nftFactory || !nftMetadata || !ethToOceanConversionRate) - return - - const { web3 } = nftFactory - const nft = generateNftCreateData(nftMetadata, address) - - const gasPrice = await web3.eth.getGasPrice() - const gasLimit = await nftFactory?.estGasCreateNFT(address, nft) - const gasFeeEth = Web3.utils.fromWei( - (+gasPrice * +gasLimit).toString(), - 'ether' - ) - const gasFeeOcean = (+gasFeeEth / +ethToOceanConversionRate).toString() - return gasFeeOcean -} - -export default function TxFee({ - nftMetadata -}: { - nftMetadata: NftMetadata -}): ReactElement { - const { accountId } = useWeb3() - const { prices } = usePrices() - const nftFactory = useNftFactory() - const [gasFee, setGasFee] = useState('') - - useEffect(() => { - const calculateGasFee = async () => - setGasFee( - await getEstGasFee( - accountId, - nftFactory, - nftMetadata, - (prices as any)?.eth - ) - ) - calculateGasFee() - }, [accountId, nftFactory, nftMetadata, prices]) - - return gasFee ? ( -

- Gas fee estimation for this artwork - -

- ) : accountId ? ( -

- An error occurred while estimating the gas fee for this artwork, please - try again. -

- ) : ( -

Please connect your wallet to get a gas fee estimate for this artwork

- ) -} diff --git a/src/components/@shared/FormFields/Nft/index.module.css b/src/components/@shared/FormFields/Nft/index.module.css index 4a0fcb633..aba12b4e5 100644 --- a/src/components/@shared/FormFields/Nft/index.module.css +++ b/src/components/@shared/FormFields/Nft/index.module.css @@ -27,7 +27,7 @@ position: absolute; left: 0; bottom: 0; - padding: 0 calc(var(--spacer) / 4); + padding: calc(var(--spacer) / 4); display: flex; justify-content: space-between; align-items: center; diff --git a/src/components/@shared/FormFields/Nft/index.tsx b/src/components/@shared/FormFields/Nft/index.tsx index 61f6bd6ff..1258a8f0a 100644 --- a/src/components/@shared/FormFields/Nft/index.tsx +++ b/src/components/@shared/FormFields/Nft/index.tsx @@ -5,8 +5,6 @@ import { useField } from 'formik' import React, { ReactElement, useEffect } from 'react' import Refresh from '@images/refresh.svg' import styles from './index.module.css' -import Tooltip from '@shared/atoms/Tooltip' -import TxFee from './TxFee' export default function Nft(props: InputProps): ReactElement { const [field, meta, helpers] = useField(props.name) @@ -28,7 +26,6 @@ export default function Nft(props: InputProps): ReactElement {
- } />
- {conversion && } + {conversion && } )} diff --git a/src/components/Header/Wallet/Details.module.css b/src/components/Header/Wallet/Details.module.css index ef74715ea..4ba502c31 100644 --- a/src/components/Header/Wallet/Details.module.css +++ b/src/components/Header/Wallet/Details.module.css @@ -17,7 +17,7 @@ } .balance { - font-size: var(--font-size-base); + font-size: var(--font-size-small); font-weight: var(--font-weight-bold); color: var(--color-secondary); white-space: nowrap; @@ -32,6 +32,14 @@ margin-right: 0.4rem; } +.value { + color: var(--font-color-text); +} + +.conversion strong { + font-weight: var(--font-weight-base); +} + .actions { border-top: 1px solid var(--border-color); margin-top: calc(var(--spacer) / 2); diff --git a/src/components/Header/Wallet/Details.tsx b/src/components/Header/Wallet/Details.tsx index 4e32bb618..e6e55a36e 100644 --- a/src/components/Header/Wallet/Details.tsx +++ b/src/components/Header/Wallet/Details.tsx @@ -29,8 +29,7 @@ export default function Details(): ReactElement { useEffect(() => { if (!networkId) return - const symbol = - networkId === 2021000 ? 'GX' : networkData?.nativeCurrency.symbol + const symbol = networkData?.nativeCurrency.symbol setMainCurrency(symbol) const oceanConfig = getOceanConfig(networkId) @@ -49,11 +48,17 @@ export default function Details(): ReactElement {
  • {key === 'eth' ? mainCurrency : key.toUpperCase()} - {' '} - {formatCurrency(Number(value), '', locale, false, { - significantFigures: 4 - })} - {key === 'ocean' && } + + + {formatCurrency(Number(value), '', locale, false, { + significantFigures: 4 + })} + +
  • ))} diff --git a/src/components/Profile/Header/Stats.tsx b/src/components/Profile/Header/Stats.tsx index b3402c3ac..ac8ba10e6 100644 --- a/src/components/Profile/Header/Stats.tsx +++ b/src/components/Profile/Header/Stats.tsx @@ -42,7 +42,13 @@ export default function Stats({
    } + value={ + + } /> diff --git a/src/components/Publish/Pricing/CoinSelect.tsx b/src/components/Publish/Pricing/CoinSelect.tsx index 0b1137894..fd2662ae4 100644 --- a/src/components/Publish/Pricing/CoinSelect.tsx +++ b/src/components/Publish/Pricing/CoinSelect.tsx @@ -1,4 +1,3 @@ -import Input from '@shared/FormInput' import InputElement from '@shared/FormInput/InputElement' import { useFormikContext } from 'formik' import React, { ChangeEvent, ReactElement } from 'react' diff --git a/src/components/Publish/Pricing/Price.tsx b/src/components/Publish/Pricing/Price.tsx index 0ed7eb297..b3aac60d6 100644 --- a/src/components/Publish/Pricing/Price.tsx +++ b/src/components/Publish/Pricing/Price.tsx @@ -52,7 +52,11 @@ export default function Price({

    = 1 {dataTokenOptions.symbol}{' '} - +

    From f5514bbc1d914d2983059a110710f65c732dd9bb Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Mon, 15 Aug 2022 09:57:53 -0400 Subject: [PATCH 05/22] change label 'data set' with 'dataset' --- README.md | 16 ++++++++-------- content/pages/editComputeDataset.json | 6 +++--- content/pages/editMetadata.json | 8 ++++---- content/pages/profile.json | 2 +- content/price.json | 4 ++-- content/publish/form.json | 10 +++++----- content/publish/index.json | 2 +- content/purgatory.json | 4 ++-- content/site.json | 2 +- src/components/@shared/AssetType/index.tsx | 2 +- src/components/@shared/ButtonBuy/index.tsx | 2 +- .../Asset/AssetActions/Compute/index.tsx | 6 +++--- src/components/Asset/Edit/EditComputeDataset.tsx | 2 +- src/components/Home/Bookmarks.tsx | 2 +- src/components/Home/index.tsx | 2 +- .../Profile/History/ComputeJobs/index.tsx | 2 +- src/components/Profile/History/Downloads.tsx | 2 +- src/components/Search/Filters.tsx | 2 +- 18 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index f6257f80c..fa49e6354 100644 --- a/README.md +++ b/README.md @@ -103,12 +103,12 @@ cp .env.example .env ## 🦀 Data Sources -All displayed data in the app is presented around the concept of one data set, which is a combination of: +All displayed data in the app is presented around the concept of one dataset, which is a combination of: -- metadata about a data set -- the actual data set files -- the NFT which represents the data set -- the datatokens representing access rights to the data set files +- metadata about a dataset +- the actual dataset files +- the NFT which represents the dataset +- the datatokens representing access rights to the dataset files - financial data connected to these datatokens, either a fixed rate exchange contract or a dispenser for free assets - calculations and conversions based on financial data - metadata about publisher accounts @@ -117,7 +117,7 @@ All this data then comes from multiple sources: ### Aquarius -All initial data sets and their metadata (DDO) is retrieved client-side on run-time from the [Aquarius](https://github.com/oceanprotocol/aquarius) instance, defined in `app.config.js`. All app calls to Aquarius are done with 2 internal methods which mimic the same methods in ocean.js, but allow us: +All initial datasets and their metadata (DDO) is retrieved client-side on run-time from the [Aquarius](https://github.com/oceanprotocol/aquarius) instance, defined in `app.config.js`. All app calls to Aquarius are done with 2 internal methods which mimic the same methods in ocean.js, but allow us: - to cancel requests when components get unmounted in combination with [axios](https://github.com/axios/axios) - hit Aquarius as early as possible without relying on any ocean.js initialization @@ -159,7 +159,7 @@ function Component() { } ``` -For components within a single data set view the `useAsset()` hook can be used, which in the background gets the respective metadata from Aquarius. +For components within a single dataset view the `useAsset()` hook can be used, which in the background gets the respective metadata from Aquarius. ```tsx import { useAsset } from '@context/Asset' @@ -232,7 +232,7 @@ function Component() { ### Purgatory -Based on [list-purgatory](https://github.com/oceanprotocol/list-purgatory) some data sets get additional data. Within most components this can be done with the internal `useAsset()` hook which fetches data from the [market-purgatory](https://github.com/oceanprotocol/market-purgatory) endpoint in the background. +Based on [list-purgatory](https://github.com/oceanprotocol/list-purgatory) some datasets get additional data. Within most components this can be done with the internal `useAsset()` hook which fetches data from the [market-purgatory](https://github.com/oceanprotocol/market-purgatory) endpoint in the background. For asset purgatory: diff --git a/content/pages/editComputeDataset.json b/content/pages/editComputeDataset.json index 3d49b37de..92388dc1c 100644 --- a/content/pages/editComputeDataset.json +++ b/content/pages/editComputeDataset.json @@ -1,14 +1,14 @@ { "form": { "title": "Set allowed algorithms", - "description": "Only the algorithms selected here will be allowed to run on your data set. Uncheck all to remove any access to your data set.", + "description": "Only the algorithms selected here will be allowed to run on your dataset. Uncheck all to remove any access to your dataset.", "success": "🎉 Successfully updated. 🎉\n\nUpdates might not show up right away on your asset. In this case, wait some seconds and reload your asset details page in your browser.", "error": "Updating DDO failed.", "data": [ { "name": "publisherTrustedAlgorithms", "label": "Selected Algorithms", - "help": "Choose one or multiple algorithms you trust to allow them to run on this data set.", + "help": "Choose one or multiple algorithms you trust to allow them to run on this dataset.", "type": "assetSelectionMultiple", "multiple": true, "options": [], @@ -17,7 +17,7 @@ { "name": "allowAllPublishedAlgorithms", "label": "All Algorithms", - "help": "Allow any published algorithm to run on this data set.", + "help": "Allow any published algorithm to run on this dataset.", "type": "checkbox", "options": ["Allow any published algorithm"] } diff --git a/content/pages/editMetadata.json b/content/pages/editMetadata.json index 2b164d6a8..2b3c0d871 100644 --- a/content/pages/editMetadata.json +++ b/content/pages/editMetadata.json @@ -31,7 +31,7 @@ "name": "files", "label": "New file", "placeholder": "e.g. https://file.com/file.json", - "help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. Leaving this field empty will not remove the current value.", + "help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. Leaving this field empty will not remove the current value.", "prominentHelp": true, "type": "files" }, @@ -39,7 +39,7 @@ "name": "links", "label": "New sample file", "placeholder": "e.g. https://file.com/samplefile.json", - "help": "Please provide a URL to a sample of your data set file. This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** Leaving this field empty will not remove the current value.", + "help": "Please provide a URL to a sample of your dataset file. This file should reveal the data structure of your dataset, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** Leaving this field empty will not remove the current value.", "prominentHelp": true, "type": "files" }, @@ -47,7 +47,7 @@ { "name": "timeout", "label": "Timeout", - "help": "Define how long buyers should be able to download the data set again after the initial purchase.", + "help": "Define how long buyers should be able to download the dataset again after the initial purchase.", "type": "select", "options": ["Forever", "1 day", "1 week", "1 month", "1 year"], "sortOptions": false, @@ -57,7 +57,7 @@ "name": "author", "label": "New Author", "placeholder": "e.g. Mrs McJellyfish", - "help": "Give proper attribution for your data set.", + "help": "Give proper attribution for your dataset.", "required": false } ] diff --git a/content/pages/profile.json b/content/pages/profile.json index b1d2c8362..2da176dea 100644 --- a/content/pages/profile.json +++ b/content/pages/profile.json @@ -1,4 +1,4 @@ { "title": "Account", - "description": "Find the data sets and jobs that you previously accessed." + "description": "Find the datasets and jobs that you previously accessed." } diff --git a/content/price.json b/content/price.json index b9b7f4c51..91778c8bd 100644 --- a/content/price.json +++ b/content/price.json @@ -2,7 +2,7 @@ "create": { "fixed": { "title": "Fixed", - "info": "Set your price for accessing this data set. The datatoken for this data set will be worth the entered amount of the selected base token.", + "info": "Set your price for accessing this dataset. The datatoken for this dataset will be worth the entered amount of the selected base token.", "tooltips": { "communityFee": "Goes to Ocean DAO for teams to improve the tools, build apps, do outreach, and more. A small fraction is used to burn OCEAN. This fee is collected when downloading or using an asset in a compute job.", "marketplaceFee": "Goes to the marketplace owner that is hosting and providing the marketplace and is collected when downloading or using an asset in a compute job. In Ocean Market, it is treated as network revenue that goes to the Ocean community." @@ -10,7 +10,7 @@ }, "free": { "title": "Free", - "info": "Set your data set as free. The datatoken for this data set will be given for free via creating a faucet.", + "info": "Set your dataset as free. The datatoken for this dataset will be given for free via creating a faucet.", "fields": [ { "name": "freeAgreement", diff --git a/content/publish/form.json b/content/publish/form.json index 4a4474ca3..fef5b8d7b 100644 --- a/content/publish/form.json +++ b/content/publish/form.json @@ -33,7 +33,7 @@ "name": "author", "label": "Author", "placeholder": "e.g. Jelly McJellyfish", - "help": "Give proper attribution for your data set. You are welcome to use a pseudonym, and you can change your author name at any time. Please note that it will remain in the transaction history. For more information on how personal data is handled within the metadata, please refer to our [privacy policy](/privacy/en).", + "help": "Give proper attribution for your dataset. You are welcome to use a pseudonym, and you can change your author name at any time. Please note that it will remain in the transaction history. For more information on how personal data is handled within the metadata, please refer to our [privacy policy](/privacy/en).", "required": true }, { @@ -104,7 +104,7 @@ "name": "files", "label": "File", "placeholder": "e.g. https://file.com/file.json", - "help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ", + "help": "This URL will be stored encrypted after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.** For a compute dataset, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size. ", "prominentHelp": true, "type": "files", "required": true @@ -113,7 +113,7 @@ "name": "links", "label": "Sample file", "placeholder": "e.g. https://file.com/samplefile.json", - "help": "This file should reveal the data structure of your data set, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**", + "help": "This file should reveal the data structure of your dataset, e.g. by including the header and one line of a CSV file. This file URL will be publicly available after publishing. **Please make sure that the endpoint is accessible over the internet and is not protected by a firewall or by credentials.**", "prominentHelp": true, "type": "files" }, @@ -122,7 +122,7 @@ "label": "Algorithm Privacy", "type": "checkbox", "options": ["Keep my algorithm private"], - "help": "By default, your algorithm can be downloaded for free or a fixed price, in addition to running in compute jobs. Enabling this option will prevent downloading, so your algorithm can only be run as part of a compute job on a data set.", + "help": "By default, your algorithm can be downloaded for free or a fixed price, in addition to running in compute jobs. Enabling this option will prevent downloading, so your algorithm can only be run as part of a compute job on a dataset.", "required": false }, { @@ -138,7 +138,7 @@ { "name": "timeout", "label": "Timeout", - "help": "Define how long buyers should be able to download the data set again after the initial purchase.", + "help": "Define how long buyers should be able to download the dataset again after the initial purchase.", "type": "select", "options": ["Forever", "1 day", "1 week", "1 month", "1 year"], "sortOptions": false, diff --git a/content/publish/index.json b/content/publish/index.json index 65fc81d45..49971874d 100644 --- a/content/publish/index.json +++ b/content/publish/index.json @@ -1,6 +1,6 @@ { "title": "Publish", - "description": "Highlight the important features of your data set or algorithm to make it more discoverable and catch the interest of data consumers.", + "description": "Highlight the important features of your dataset or algorithm to make it more discoverable and catch the interest of data consumers.", "warning": "Publishing into a test network first is strongly recommended. Please familiarize yourself with [the market](https://oceanprotocol.com/technology/marketplaces), [the risks](https://blog.oceanprotocol.com/on-staking-on-data-in-ocean-market-3d8e09eb0a13), and the [Terms of Use](/terms).", "tooltipAvailableNetworks": "Assets are published to the network your wallet is connected to. These networks are currently supported:" } diff --git a/content/purgatory.json b/content/purgatory.json index ddd2a0cc7..2c1730530 100644 --- a/content/purgatory.json +++ b/content/purgatory.json @@ -1,7 +1,7 @@ { "asset": { - "title": "Data Set In Purgatory", - "description": "Except for removing liquidity, no further actions are permitted on this data set and it will not be returned in any search. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)." + "title": "Dataset In Purgatory", + "description": "Except for removing liquidity, no further actions are permitted on this dataset and it will not be returned in any search. For more details go to [list-purgatory](https://github.com/oceanprotocol/list-purgatory)." }, "account": { "title": "Account In Purgatory", diff --git a/content/site.json b/content/site.json index a6ada0ab3..0c231e412 100644 --- a/content/site.json +++ b/content/site.json @@ -1,6 +1,6 @@ { "siteTitle": "Ocean Market", - "siteTagline": "A marketplace to find, publish and trade data sets in the Ocean Network.", + "siteTagline": "A marketplace to find, publish and trade datasets in the Ocean Network.", "siteUrl": "https://market.oceanprotocol.com", "siteImage": "/share.png", "copyright": "All Rights Reserved. Powered by ", diff --git a/src/components/@shared/AssetType/index.tsx b/src/components/@shared/AssetType/index.tsx index 32e7c7489..565a87270 100644 --- a/src/components/@shared/AssetType/index.tsx +++ b/src/components/@shared/AssetType/index.tsx @@ -26,7 +26,7 @@ export default function AssetType({ )}
    - {type === 'dataset' ? 'data set' : 'algorithm'} + {type === 'dataset' ? 'dataset' : 'algorithm'}
    {totalSales ? ( diff --git a/src/components/@shared/ButtonBuy/index.tsx b/src/components/@shared/ButtonBuy/index.tsx index 9791f667f..5243dfd57 100644 --- a/src/components/@shared/ButtonBuy/index.tsx +++ b/src/components/@shared/ButtonBuy/index.tsx @@ -50,7 +50,7 @@ function getConsumeHelpText( : hasPreviousOrder ? `You bought this ${assetType} already allowing you to use it without paying again.` : hasDatatoken - ? `You own ${dtBalance} ${dtSymbol} allowing you to use this data set by spending 1 ${dtSymbol}, but without paying ${btSymbol} again.` + ? `You own ${dtBalance} ${dtSymbol} allowing you to use this dataset by spending 1 ${dtSymbol}, but without paying ${btSymbol} again.` : isBalanceSufficient === false ? `You do not have enough ${btSymbol} in your wallet to purchase this asset.` : `For using this ${assetType}, you will buy 1 ${dtSymbol} and immediately spend it back to the publisher.` diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index 3a45f7e38..34804bfe8 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -266,10 +266,10 @@ export default function Compute({ computeAlgorithm, selectedAlgorithmAsset ) - LoggerInstance.log('[compute] Is data set orderable?', allowed) + LoggerInstance.log('[compute] Is dataset orderable?', allowed) if (!allowed) throw new Error( - 'Data set is not orderable in combination with selected algorithm.' + 'Dataset is not orderable in combination with selected algorithm.' ) await initPriceAndFees() @@ -376,7 +376,7 @@ export default function Compute({ {asset.services[0].type === 'compute' && ( diff --git a/src/components/Asset/Edit/EditComputeDataset.tsx b/src/components/Asset/Edit/EditComputeDataset.tsx index 400ad5eb8..4563a5bf6 100644 --- a/src/components/Asset/Edit/EditComputeDataset.tsx +++ b/src/components/Asset/Edit/EditComputeDataset.tsx @@ -131,7 +131,7 @@ export default function EditComputeDataset({ {({ values, isSubmitting }) => isSubmitting || hasFeedback ? ( [] = [ { - name: 'Data Set', + name: 'Dataset', selector: (row) => { const { metadata } = row return diff --git a/src/components/Home/index.tsx b/src/components/Home/index.tsx index 26b27ad4d..8fdd86799 100644 --- a/src/components/Home/index.tsx +++ b/src/components/Home/index.tsx @@ -131,7 +131,7 @@ export default function HomePage(): ReactElement { query={queryLatest} action={ } /> diff --git a/src/components/Profile/History/ComputeJobs/index.tsx b/src/components/Profile/History/ComputeJobs/index.tsx index a395deede..405b50809 100644 --- a/src/components/Profile/History/ComputeJobs/index.tsx +++ b/src/components/Profile/History/ComputeJobs/index.tsx @@ -21,7 +21,7 @@ export function Status({ children }: { children: string }): ReactElement { const columns: TableOceanColumn[] = [ { - name: 'Data Set', + name: 'Dataset', selector: (row) => ( ) diff --git a/src/components/Profile/History/Downloads.tsx b/src/components/Profile/History/Downloads.tsx index dfd0bb8c5..85e1fc474 100644 --- a/src/components/Profile/History/Downloads.tsx +++ b/src/components/Profile/History/Downloads.tsx @@ -8,7 +8,7 @@ import { useUserPreferences } from '@context/UserPreferences' const columns: TableOceanColumn[] = [ { - name: 'Data Set', + name: 'Dataset', selector: (row) => }, { diff --git a/src/components/Search/Filters.tsx b/src/components/Search/Filters.tsx index 52c806c68..82c577e72 100644 --- a/src/components/Search/Filters.tsx +++ b/src/components/Search/Filters.tsx @@ -14,7 +14,7 @@ const cx = classNames.bind(styles) const clearFilters = [{ display: 'Clear', value: '' }] const serviceFilterItems = [ - { display: 'data sets', value: FilterByTypeOptions.Data }, + { display: 'datasets', value: FilterByTypeOptions.Data }, { display: 'algorithms', value: FilterByTypeOptions.Algorithm } ] From 587fd801937025f7bffced0083d7e7b83d993be2 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Wed, 17 Aug 2022 06:11:21 -0400 Subject: [PATCH 06/22] change dataset with asset in readme --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fa49e6354..c32d82481 100644 --- a/README.md +++ b/README.md @@ -103,12 +103,12 @@ cp .env.example .env ## 🦀 Data Sources -All displayed data in the app is presented around the concept of one dataset, which is a combination of: +All displayed data in the app is presented around the concept of one asset, which is a combination of: -- metadata about a dataset -- the actual dataset files -- the NFT which represents the dataset -- the datatokens representing access rights to the dataset files +- metadata about an asset +- the actual asset file +- the NFT which represents the asset +- the datatokens representing access rights to the asset file - financial data connected to these datatokens, either a fixed rate exchange contract or a dispenser for free assets - calculations and conversions based on financial data - metadata about publisher accounts @@ -117,7 +117,7 @@ All this data then comes from multiple sources: ### Aquarius -All initial datasets and their metadata (DDO) is retrieved client-side on run-time from the [Aquarius](https://github.com/oceanprotocol/aquarius) instance, defined in `app.config.js`. All app calls to Aquarius are done with 2 internal methods which mimic the same methods in ocean.js, but allow us: +All initial assets and their metadata (DDO) is retrieved client-side on run-time from the [Aquarius](https://github.com/oceanprotocol/aquarius) instance, defined in `app.config.js`. All app calls to Aquarius are done with 2 internal methods which mimic the same methods in ocean.js, but allow us: - to cancel requests when components get unmounted in combination with [axios](https://github.com/axios/axios) - hit Aquarius as early as possible without relying on any ocean.js initialization @@ -159,7 +159,7 @@ function Component() { } ``` -For components within a single dataset view the `useAsset()` hook can be used, which in the background gets the respective metadata from Aquarius. +For components within a single asset view the `useAsset()` hook can be used, which in the background gets the respective metadata from Aquarius. ```tsx import { useAsset } from '@context/Asset' @@ -232,7 +232,7 @@ function Component() { ### Purgatory -Based on [list-purgatory](https://github.com/oceanprotocol/list-purgatory) some datasets get additional data. Within most components this can be done with the internal `useAsset()` hook which fetches data from the [market-purgatory](https://github.com/oceanprotocol/market-purgatory) endpoint in the background. +Based on [list-purgatory](https://github.com/oceanprotocol/list-purgatory) some assets get additional data. Within most components this can be done with the internal `useAsset()` hook which fetches data from the [market-purgatory](https://github.com/oceanprotocol/market-purgatory) endpoint in the background. For asset purgatory: @@ -415,7 +415,7 @@ To allow publishers to set pricing as "Fixed" you need to add the following envi To allow publishers to set pricing as "Free" you need to add the following environmental variable to your .env file: `NEXT_PUBLIC_ALLOW_FREE_PRICING="true"` (default). -This allocates the datatokens to the [dispenser contract](https://github.com/oceanprotocol/contracts/blob/main/contracts/dispenser/Dispenser.sol) which dispenses data tokens to users for free. Publishers in your market will now be able to offer their datasets to users for free (excluding gas costs). +This allocates the datatokens to the [dispenser contract](https://github.com/oceanprotocol/contracts/blob/main/contracts/dispenser/Dispenser.sol) which dispenses data tokens to users for free. Publishers in your market will now be able to offer their assets to users for free (excluding gas costs). ## ✅ GDPR Compliance From f8a6edc3c6498a298dadbd0b5ea4f5c97730ebb8 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Tue, 23 Aug 2022 07:08:12 -0400 Subject: [PATCH 07/22] fix publishing when connecting wallet on publish form --- src/components/Publish/Steps.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/Publish/Steps.tsx b/src/components/Publish/Steps.tsx index 6ec733cab..c35d6a260 100644 --- a/src/components/Publish/Steps.tsx +++ b/src/components/Publish/Steps.tsx @@ -1,9 +1,14 @@ import { ReactElement, useEffect } from 'react' import { useFormikContext } from 'formik' -import { wizardSteps, initialPublishFeedback } from './_constants' +import { + wizardSteps, + initialPublishFeedback, + initialValues +} from './_constants' import { useWeb3 } from '@context/Web3' import { FormPublishData, PublishFeedback } from './_types' import { getOceanConfig } from '@utils/ocean' +import router from 'next/router' export function Steps({ feedback @@ -22,11 +27,15 @@ export function Steps({ setFieldValue('user.accountId', accountId) }, [chainId, accountId, setFieldValue]) - // Reset the selected baseToken on chainId change useEffect(() => { if (!chainId) return - setFieldValue('pricing.baseToken', null) + // Reset the pricing values on chainId change + // the user needs to update the pricing schema on network changes + if (values.pricing.price) { + setFieldValue('pricing', initialValues.pricing) + router.push(`/publish/3`) + } }, [chainId, setFieldValue]) // auto-sync publish feedback into form data values From 245ccfe5e4044c3c54ca64aa404f8a99d35f91ec Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Wed, 24 Aug 2022 06:22:57 -0400 Subject: [PATCH 08/22] fix reset pricing on tx execution --- src/components/Publish/Steps.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Publish/Steps.tsx b/src/components/Publish/Steps.tsx index c35d6a260..ece8d4607 100644 --- a/src/components/Publish/Steps.tsx +++ b/src/components/Publish/Steps.tsx @@ -30,9 +30,10 @@ export function Steps({ useEffect(() => { if (!chainId) return - // Reset the pricing values on chainId change - // the user needs to update the pricing schema on network changes - if (values.pricing.price) { + // Reset the pricing values on chainId change: + // - the user needs to update the pricing schema on network changes + // - if the tx has been started, don't restore pricing values + if (values.pricing.price && values.feedback[1].status === 'pending') { setFieldValue('pricing', initialValues.pricing) router.push(`/publish/3`) } From 419234ab64f1dc21af29c10aae4d585a5cd92bf6 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Wed, 24 Aug 2022 06:52:32 -0400 Subject: [PATCH 09/22] removed changing steps --- src/components/Publish/Steps.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/components/Publish/Steps.tsx b/src/components/Publish/Steps.tsx index ece8d4607..51a0fa753 100644 --- a/src/components/Publish/Steps.tsx +++ b/src/components/Publish/Steps.tsx @@ -27,18 +27,6 @@ export function Steps({ setFieldValue('user.accountId', accountId) }, [chainId, accountId, setFieldValue]) - useEffect(() => { - if (!chainId) return - - // Reset the pricing values on chainId change: - // - the user needs to update the pricing schema on network changes - // - if the tx has been started, don't restore pricing values - if (values.pricing.price && values.feedback[1].status === 'pending') { - setFieldValue('pricing', initialValues.pricing) - router.push(`/publish/3`) - } - }, [chainId, setFieldValue]) - // auto-sync publish feedback into form data values useEffect(() => { setFieldValue('feedback', feedback) From 7a3c7a992755d1d210e2c8c3f33482abad1a6122 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Wed, 24 Aug 2022 11:12:53 -0400 Subject: [PATCH 10/22] cleanup --- src/components/Publish/Steps.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/Publish/Steps.tsx b/src/components/Publish/Steps.tsx index 51a0fa753..4c3e2a338 100644 --- a/src/components/Publish/Steps.tsx +++ b/src/components/Publish/Steps.tsx @@ -1,14 +1,9 @@ import { ReactElement, useEffect } from 'react' import { useFormikContext } from 'formik' -import { - wizardSteps, - initialPublishFeedback, - initialValues -} from './_constants' +import { wizardSteps, initialPublishFeedback } from './_constants' import { useWeb3 } from '@context/Web3' import { FormPublishData, PublishFeedback } from './_types' import { getOceanConfig } from '@utils/ocean' -import router from 'next/router' export function Steps({ feedback From 2d7584648d8bdff3f4e4fe475496d9aa003239d2 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Mon, 29 Aug 2022 18:19:21 +0300 Subject: [PATCH 11/22] Fix headers (#1663) * test * test * test * test * test * test * test --- netlify.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 netlify.toml diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..f82df6dc8 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,11 @@ +[[headers]] + for = "/_next/image/*" + + [headers.values] + Content-Security-Policy= "upgrade-insecure-requests" + Strict-Transport-Security = "max-age=63072000; includeSubDomains; preload" + X-XSS-Protection = "1; mode=block" + X-Frame-Options = "DENY" + X-Content-Type-Options = "nosniff" + Referrer-Policy = "strict-origin-when-cross-origin" + Permissions-Policy= "accelerometer=(self), ambient-light-sensor=(self), autoplay=(self), battery=(self), camera=(self), cross-origin-isolated=(self), display-capture=(self), document-domain=(self), encrypted-media=(self), execution-while-not-rendered=(self), execution-while-out-of-viewport=(self), fullscreen=(self), geolocation=(self), gyroscope=(self), keyboard-map=(self), magnetometer=(self), microphone=(self), midi=(self), navigation-override=(self), payment=(self), picture-in-picture=(self), publickey-credentials-get=(self), screen-wake-lock=(self), sync-xhr=(self), usb=(self), web-share=(self), xr-spatial-tracking=(self), clipboard-read=(self), clipboard-write=(self), gamepad=(self), speaker-selection=(self), conversion-measurement=(self), focus-without-user-activation=(self), hid=(self), idle-detection=(self), interest-cohort=(self), serial=(self), sync-script=(self), trust-token-redemption=(self), window-placement=(self), vertical-scroll=(self)" From d7d1dabf4c063e17aff7b42653bde960d3d2e4e0 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Thu, 1 Sep 2022 17:13:28 +0300 Subject: [PATCH 12/22] remove link --- src/components/Header/Menu.tsx | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/components/Header/Menu.tsx b/src/components/Header/Menu.tsx index 03e5a8b4a..0f8e9ad5d 100644 --- a/src/components/Header/Menu.tsx +++ b/src/components/Header/Menu.tsx @@ -1,7 +1,6 @@ import React, { ReactElement } from 'react' import Link from 'next/link' import loadable from '@loadable/component' -import Badge from '@shared/atoms/Badge' import Logo from '@shared/atoms/Logo' import UserPreferences from './UserPreferences' import Networks from './UserPreferences/Networks' @@ -9,8 +8,6 @@ import SearchBar from './SearchBar' import styles from './Menu.module.css' import { useRouter } from 'next/router' import { useMarketMetadata } from '@context/MarketMetadata' -import Tooltip from '@shared/atoms/Tooltip' -import Caret from '@images/caret.svg' const Wallet = loadable(() => import('./Wallet')) declare type MenuItem = { @@ -34,7 +31,7 @@ function MenuLink({ item }: { item: MenuItem }) { } export default function Menu(): ReactElement { - const { appConfig, siteContent } = useMarketMetadata() + const { siteContent } = useMarketMetadata() return (