From 9691e3f690039dc272efdf7ece16b79aac8a1024 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Mon, 30 Jan 2023 14:38:21 +0200 Subject: [PATCH] Fix basetoken related issues on in publish and asset detail pages (#1859) * Avoiding getInitialPaymentCollector failure (#1816) * early return is no web3 or ddo * Creating test for MetaFull * adding test: src/components/Asset/AssetContent/MetaSecondary.test.tsx * Adding test for bookmarks * Adding test for displaying payment collector * Removing comments * Renaming assetAquarius * Renaming assetWithAccessDetails * Ensuring that the payment collector is shown even without a wallet connected * Removing broken test * Using getDummyWeb3 for fetching the payment collector address * google validation (#1835) * Updating validation to exclude any google link * Updating Yup validation * Checking if domain includes google.com * Updating isGoogleUrl function * Moving isGoogleUrl into @utils/url/index file * isGoogleUrl function * Updating tests * Adding additional tests for other google domains * Updating tests * Updating isGoogleUrl file path * Updating pricing message (#1842) * Bump @storybook/addon-essentials from 6.5.13 to 6.5.15 (#1841) Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.5.13 to 6.5.15. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.15/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.5.15/addons/essentials) --- updated-dependencies: - dependency-name: "@storybook/addon-essentials" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/jest from 29.2.3 to 29.2.5 (#1840) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.2.3 to 29.2.5. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump prettier from 2.8.0 to 2.8.1 (#1837) Bumps [prettier](https://github.com/prettier/prettier) from 2.8.0 to 2.8.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.0...2.8.1) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump react-select from 5.6.1 to 5.7.0 (#1839) Bumps [react-select](https://github.com/JedWatson/react-select) from 5.6.1 to 5.7.0. - [Release notes](https://github.com/JedWatson/react-select/releases) - [Changelog](https://github.com/JedWatson/react-select/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/JedWatson/react-select/compare/react-select@5.6.1...react-select@5.7.0) --- updated-dependencies: - dependency-name: react-select dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump react-tabs from 5.1.0 to 6.0.0 (#1838) Bumps [react-tabs](https://github.com/reactjs/react-tabs) from 5.1.0 to 6.0.0. - [Release notes](https://github.com/reactjs/react-tabs/releases) - [Commits](https://github.com/reactjs/react-tabs/compare/v5.1.0...v6.0.0) --- updated-dependencies: - dependency-name: react-tabs dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix asset route (#1836) * updating the buy button message for free assets * Updating pricing text for compute and algorithms * Updating tests * Adding a seperate sentence about paying gas fees for network charges with free assets * Fixing tests Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mihaisc * Showing hosting type in File Info (#1846) * Bump @storybook/addon-essentials from 6.5.13 to 6.5.15 (#1841) Bumps [@storybook/addon-essentials](https://github.com/storybookjs/storybook/tree/HEAD/addons/essentials) from 6.5.13 to 6.5.15. - [Release notes](https://github.com/storybookjs/storybook/releases) - [Changelog](https://github.com/storybookjs/storybook/blob/v6.5.15/CHANGELOG.md) - [Commits](https://github.com/storybookjs/storybook/commits/v6.5.15/addons/essentials) --- updated-dependencies: - dependency-name: "@storybook/addon-essentials" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @types/jest from 29.2.3 to 29.2.5 (#1840) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.2.3 to 29.2.5. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump prettier from 2.8.0 to 2.8.1 (#1837) Bumps [prettier](https://github.com/prettier/prettier) from 2.8.0 to 2.8.1. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.0...2.8.1) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump react-select from 5.6.1 to 5.7.0 (#1839) Bumps [react-select](https://github.com/JedWatson/react-select) from 5.6.1 to 5.7.0. - [Release notes](https://github.com/JedWatson/react-select/releases) - [Changelog](https://github.com/JedWatson/react-select/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/JedWatson/react-select/compare/react-select@5.6.1...react-select@5.7.0) --- updated-dependencies: - dependency-name: react-select dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump react-tabs from 5.1.0 to 6.0.0 (#1838) Bumps [react-tabs](https://github.com/reactjs/react-tabs) from 5.1.0 to 6.0.0. - [Release notes](https://github.com/reactjs/react-tabs/releases) - [Commits](https://github.com/reactjs/react-tabs/compare/v5.1.0...v6.0.0) --- updated-dependencies: - dependency-name: react-tabs dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix asset route (#1836) * Adding hosting type to the file info component * Writting smart contract hosting type across two lines Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mihaisc * add initial price value for not supported price assets (#1851) * Fix compute basetoken issue (#1829) * fix lint * add dynamic provider fees * fixes * cleanup and more fixes * bump oceanlib to 2.6.0 * fix 404 styling (#1850) * set not supported and fix footer display * fix basetoken after network switch and price preview * removed log * fix free assets display --------- Signed-off-by: dependabot[bot] Co-authored-by: Jamie Hewitt Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mihaisc Co-authored-by: Jamie Hewitt Co-authored-by: EnzoVezzaro --- src/components/@shared/Price/index.tsx | 7 ++++--- .../Asset/AssetActions/AssetStats/index.tsx | 4 ++-- .../Asset/AssetActions/ButtonBuy/index.tsx | 1 - src/components/Asset/AssetActions/Download.tsx | 5 ++++- src/components/Publish/Pricing/index.tsx | 17 ----------------- src/components/Publish/Steps.tsx | 17 ++++++++++++++++- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/components/@shared/Price/index.tsx b/src/components/@shared/Price/index.tsx index f555f484e..6dff88ec5 100644 --- a/src/components/@shared/Price/index.tsx +++ b/src/components/@shared/Price/index.tsx @@ -15,17 +15,18 @@ export default function Price({ size?: 'small' | 'mini' | 'large' }): ReactElement { const isSupported = - accessDetails?.type === 'fixed' || accessDetails?.type === 'free' + (accessDetails?.type === 'fixed' || accessDetails?.type === 'free') && + accessDetails?.baseToken?.symbol const price = `${orderPriceAndFees?.price || accessDetails?.price}` return isSupported ? ( ) : null } diff --git a/src/components/Asset/AssetActions/AssetStats/index.tsx b/src/components/Asset/AssetActions/AssetStats/index.tsx index 4d02d0352..cc414890c 100644 --- a/src/components/Asset/AssetActions/AssetStats/index.tsx +++ b/src/components/Asset/AssetActions/AssetStats/index.tsx @@ -39,9 +39,9 @@ export default function AssetStats() { ) : null} {!asset?.stats || asset?.stats?.orders < 0 ? ( - 'N/A' + N/A ) : asset?.stats?.orders === 0 ? ( - 'No sales yet' + No sales yet ) : ( {asset.stats.orders} sale diff --git a/src/components/Asset/AssetActions/ButtonBuy/index.tsx b/src/components/Asset/AssetActions/ButtonBuy/index.tsx index 50d1b0935..6bd77e2dc 100644 --- a/src/components/Asset/AssetActions/ButtonBuy/index.tsx +++ b/src/components/Asset/AssetActions/ButtonBuy/index.tsx @@ -153,7 +153,6 @@ function getComputeAssetHelpText( let computeHelpText = `${computeAssetHelpText} ${computeAlgoHelpText} ${providerFeeHelpText}` computeHelpText = computeHelpText.replace(/^\s+/, '') - console.log('computeHelpText', computeHelpText) return computeHelpText } diff --git a/src/components/Asset/AssetActions/Download.tsx b/src/components/Asset/AssetActions/Download.tsx index 7c1daab6e..f47238d49 100644 --- a/src/components/Asset/AssetActions/Download.tsx +++ b/src/components/Asset/AssetActions/Download.tsx @@ -50,7 +50,10 @@ export default function Download({ useState() const [retry, setRetry] = useState(false) - const isUnsupportedPricing = asset?.accessDetails?.type === 'NOT_SUPPORTED' + const isUnsupportedPricing = + asset?.accessDetails?.type === 'NOT_SUPPORTED' || + (asset?.accessDetails?.type === 'fixed' && + !asset?.accessDetails?.baseToken?.symbol) useEffect(() => { Number(asset?.nft.state) === 4 && setIsOrderDisabled(true) diff --git a/src/components/Publish/Pricing/index.tsx b/src/components/Publish/Pricing/index.tsx index 1f8678d21..eae2a2fa6 100644 --- a/src/components/Publish/Pricing/index.tsx +++ b/src/components/Publish/Pricing/index.tsx @@ -22,23 +22,6 @@ export default function PricingFields(): ReactElement { token.name.toLowerCase().includes('ocean') ) || approvedBaseTokens?.[0] - const isBaseTokenSet = !!approvedBaseTokens?.find( - (token) => token?.address === values?.pricing?.baseToken?.address - ) - - useEffect(() => { - if (!approvedBaseTokens?.length) return - if (isBaseTokenSet) return - setFieldValue('pricing.baseToken', defaultBaseToken) - }, [ - approvedBaseTokens, - chainId, - defaultBaseToken, - isBaseTokenSet, - setFieldValue, - values.pricing.baseToken - ]) - // Switch type value upon tab change function handleTabChange(tabName: string) { const type = tabName.toLowerCase() diff --git a/src/components/Publish/Steps.tsx b/src/components/Publish/Steps.tsx index 78a1b81c6..eb81ded36 100644 --- a/src/components/Publish/Steps.tsx +++ b/src/components/Publish/Steps.tsx @@ -10,7 +10,7 @@ export function Steps({ }: { feedback: PublishFeedback }): ReactElement { - const { chainId, accountId } = useWeb3() + const { chainId, accountId, approvedBaseTokens } = useWeb3() const { values, setFieldValue, touched, setTouched } = useFormikContext() @@ -24,6 +24,21 @@ export function Steps({ setFieldValue('user.accountId', accountId) }, [chainId, accountId, setFieldValue]) + useEffect(() => { + if (!approvedBaseTokens?.length) return + + const defaultBaseToken = + approvedBaseTokens?.find((token) => + token.name.toLowerCase().includes('ocean') + ) || approvedBaseTokens?.[0] + const isBaseTokenSet = !!approvedBaseTokens?.find( + (token) => token?.address === values?.pricing?.baseToken?.address + ) + if (isBaseTokenSet) return + + setFieldValue('pricing.baseToken', defaultBaseToken) + }, [approvedBaseTokens]) + // auto-sync publish feedback into form data values useEffect(() => { setFieldValue('feedback', feedback)