From 1d4917817aa01bb11d71d0bd117092e3b5e9d020 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 18 Oct 2021 13:02:36 +0100 Subject: [PATCH] remove everything we do not expose in our live market --- .env.example | 12 +- README.md | 26 ++- app.config.js | 10 +- docs/advancedSettings.md | 29 --- package-lock.json | 214 +++++++++--------- src/@types/Compute.d.ts | 14 ++ .../Form/FormFields/AdvancedSettings.tsx | 30 ++- src/components/@shared/Permission.tsx | 72 ------ .../@shared/atoms/Publisher/index.tsx | 6 +- src/components/App.tsx | 2 +- .../Edit/EditAdvancedSettings.tsx | 170 -------------- src/components/Asset/AssetActions/index.tsx | 5 +- src/components/Asset/AssetContent/index.tsx | 20 -- src/components/Header/Wallet/Details.tsx | 9 +- .../{Header.module.css => index.module.css} | 0 .../Header/{Header.tsx => index.tsx} | 2 +- src/components/Home/Home.tsx | 28 +-- src/components/Publish/index.tsx | 29 ++- src/components/Search/index.tsx | 5 +- src/context/Profile.tsx | 1 - src/hooks/useGraphSyncStatus.ts | 21 +- src/hooks/useSiteMetadata/_types.ts | 4 - src/hooks/useSiteMetadata/index.ts | 4 - src/pages/asset/index.tsx | 13 +- src/utils/compute.ts | 13 -- src/utils/rbac.ts | 36 --- 26 files changed, 208 insertions(+), 567 deletions(-) delete mode 100644 docs/advancedSettings.md delete mode 100644 src/components/@shared/Permission.tsx delete mode 100644 src/components/Asset/AssetActions/Edit/EditAdvancedSettings.tsx rename src/components/Header/{Header.module.css => index.module.css} (100%) rename src/components/Header/{Header.tsx => index.tsx} (83%) delete mode 100644 src/utils/rbac.ts diff --git a/.env.example b/.env.example index e38454faa..7a91c9a47 100644 --- a/.env.example +++ b/.env.example @@ -11,17 +11,7 @@ # Toggle pricing options presented during price creation #GATSBY_ALLOW_FIXED_PRICING="true" #GATSBY_ALLOW_DYNAMIC_PRICING="true" -#GATSBY_ALLOW_FREE_PRICING="false" - -# Define RBAC server URL to implement permission based restrictions -#GATSBY_RBAC_URL="http://localhost:3000" - -# Enables another asset editing button holder further advanced settings -#GATSBY_ALLOW_ADVANCED_SETTINGS="true" -#GATSBY_ALLOW_ADVANCED_PUBLISH_SETTINGS="true" - -# Allow/Deny Lists -#GATSBY_CREDENTIAL_TYPE="address" +#GATSBY_ALLOW_FREE_PRICING="true" # Privacy Preference Center #GATSBY_PRIVACY_PREFERENCE_CENTER="true" diff --git a/README.md b/README.md index cb6db5732..4873416c4 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,14 @@ - [⬆️ Deployment](#️-deployment) - [💖 Contributing](#-contributing) - [🍴 Forking](#-forking) -- [💻 Advanced Features](#-advanced-features) +- [💰 Pricing Options](#-pricing-options) + - [Dynamic Pricing](#dynamic-pricing) + - [Fixed Pricing](#fixed-pricing) + - [Free Pricing](#free-pricing) - [✅ GDPR Compliance](#-gdpr-compliance) - [Multi-Language Privacy Policies](#multi-language-privacy-policies) - [Privacy Preference Center](#privacy-preference-center) + - [Privacy Preference Center Styling](#privacy-preference-center-styling) - [🏛 License](#-license) ## 🏄 Get Started @@ -377,15 +381,21 @@ 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! -## 💻 Advanced Features +## 💰 Pricing Options -Ocean Market also includes a number of advanced features that are suitable for an enterprise data market, such as: +### Dynamic Pricing -- Role based access control -- Allow and deny lists -- Free pricing +To allow publishers to set pricing as "Dynamic" you need to add the following environmental variable to your .env file: `GATSBY_ALLOW_DYNAMIC_PRICING="true"` (default). -[See our seperate guide on advanced features](docs/advancedSettings.md) +### Fixed Pricing + +To allow publishers to set pricing as "Fixed" you need to add the following environmental variable to your .env file: `GATSBY_ALLOW_FIXED_PRICING="true"` (default). + +### Free Pricing + +To allow publishers to set pricing as "Free" you need to add the following environmental variable to your .env file: `GATSBY_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). ## ✅ GDPR Compliance @@ -428,7 +438,7 @@ cookies.map((cookie) => { }) ``` -#### Privacy Preference Centre Styling +#### Privacy Preference Center Styling The privacy preference centre has two styling options `default` and `small`. The default view shows all of the customization options on a full-height side banner. When the `small` setting is used, a much smaller banner is shown which only reveals all of the customization options when the user clicks "Customize". diff --git a/app.config.js b/app.config.js index 898396b6c..db828e73f 100644 --- a/app.config.js +++ b/app.config.js @@ -15,8 +15,6 @@ module.exports = { // List of all supported chainIds. Used to populate the Chains user preferences list. chainIdsSupported: [1, 3, 4, 137, 80001, 1287, 56, 2021000, 1285, 246], - rbacUrl: process.env.GATSBY_RBAC_URL || '', - infuraProjectId: process.env.GATSBY_INFURA_PROJECT_ID || 'xxx', // The ETH address the marketplace fee will be sent to. @@ -56,13 +54,7 @@ module.exports = { // tab to publishers during the price creation. allowFixedPricing: process.env.GATSBY_ALLOW_FIXED_PRICING || 'true', allowDynamicPricing: process.env.GATSBY_ALLOW_DYNAMIC_PRICING || 'true', - allowFreePricing: process.env.GATSBY_ALLOW_FREE_PRICING || 'false', - - // Used to show or hide advanced settings button in asset details page - allowAdvancedSettings: process.env.GATSBY_ALLOW_ADVANCED_SETTINGS || 'false', - allowAdvancedPublishSettings: - process.env.GATSBY_ALLOW_ADVANCED_PUBLISH_SETTINGS || 'false', - credentialType: process.env.GATSBY_CREDENTIAL_TYPE || 'address', + allowFreePricing: process.env.GATSBY_ALLOW_FREE_PRICING || 'true', // Set the default privacy policy to initially display // this should be the slug of your default policy markdown file diff --git a/docs/advancedSettings.md b/docs/advancedSettings.md deleted file mode 100644 index e7dde0af6..000000000 --- a/docs/advancedSettings.md +++ /dev/null @@ -1,29 +0,0 @@ -# Advanced Settings - -**Table of Contents** - -- [Role based Access Control](#rbac-settings) -- [Allow and Deny lists](#allow-and-deny-list-settings) -- [Free Pricing](#free-pricing-settings) - -## RBAC settings - -- Setup and host the Ocean role based access control (RBAC) server. Follow the instructions in the [RBAC repository](https://github.com/oceanprotocol/RBAC-Server) -- The RBAC server can store roles in [Keycloak](https://www.keycloak.org/) or a json file. -- In your .env file, set the value of the `GATSBY_RBAC_URL` environmental variable to the URL of the Ocean RBAC server that you have hosted, e.g. `GATSBY_RBAC_URL= "http://localhost:3000"` -- Users of your marketplace will now require the correct role ("user", "consumer", "publisher") to access features in your marketplace. The market will check the role that has been allocated to the user based on the address that they have connected to the market with. -- The following features have been wrapped in the `Permission` component and will be restricted once the `GATSBY_RBAC_URL` has been defined: - - Viewing or searching datasets requires the user to have permission to `browse` - - Purchasing or trading a datatoken, or adding liquidity to a pool require the user to have permission to `consume` - - Publishing a dataset requires the user to have permission to `publish` -- You can change the permission restrictions by either removing the `Permission` component or passing in a different eventType prop e.g. ``. - -## Allow and Deny List Settings - -- To enable allow and deny lists you need to add the following environmental variable to your .env file: `GATSBY_ALLOW_ADVANCED_SETTINGS="true"` -- Publishers in your market will now have the ability to restrict who can consume their datasets. - -## Free Pricing Settings - -- To allow publishers to set pricing as "Free" you need to add the following environmental variable to your .env file: `GATSBY_ALLOW_FREE_PRICING="true"` -- 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). diff --git a/package-lock.json b/package-lock.json index 12623995b..966c9f9a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@sindresorhus/slugify": "^2.1.0", "@tippyjs/react": "^4.2.5", "@urql/introspection": "^0.3.0", - "@walletconnect/web3-provider": "^1.6.5", + "@walletconnect/web3-provider": "^1.6.6", "axios": "^0.23.0", "chart.js": "^2.9.4", "classnames": "^2.3.1", @@ -12411,36 +12411,36 @@ } }, "node_modules/@walletconnect/browser-utils": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.6.5.tgz", - "integrity": "sha512-HLTysmlCkc2HN2OS6ewMG0v8E9oY2h9zNaDHe0BLN3ZxnsoMCVzkJxy7ryaXCemVdapmr6HgHFexGJoMbWaC4w==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.6.6.tgz", + "integrity": "sha512-E29xSHU7Akd4jaPehWVGx7ct+SsUzZbxcGc0fz+Pw6/j4Gh5tlfYZ9XuVixuYI4WPdQ2CmOraj8RrVOu5vba4w==", "dependencies": { "@walletconnect/safe-json": "1.0.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "@walletconnect/window-getters": "1.0.0", "@walletconnect/window-metadata": "1.0.0", "detect-browser": "5.2.0" } }, "node_modules/@walletconnect/client": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.6.5.tgz", - "integrity": "sha512-dRq1D3NEGwM2I3CpiwFsWy1rrdMKCMSfDUu3rCCXUE4zInx+pyq7IEFjYiSjtOEZzjRlUTqYwhjnYIezQZgh4w==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.6.6.tgz", + "integrity": "sha512-DDOrxagSmXCciIEr16hTf4gWZ7PG7GXribYTfOOsjtODLtPEODEEYj/AsmEALjh3ZBG4bN35Vj0F/ZA1D+90GQ==", "dependencies": { - "@walletconnect/core": "^1.6.5", - "@walletconnect/iso-crypto": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/core": "^1.6.6", + "@walletconnect/iso-crypto": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "node_modules/@walletconnect/core": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.6.5.tgz", - "integrity": "sha512-mmMTP8nZunjSCAy0ckafvt/JcdzcuSZPaAybqgKwx2rC9cc/3XWrdNsfiKMt8AFoQF87jGHem3905eFZYTqLXw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.6.6.tgz", + "integrity": "sha512-pSftIVPY6mYz2koZPBEYmeFeAjVf2MSnRHOM6+vx+iAsUEcfMZHkgeXX6GtM6Fjza+zSZu1qnmdgURVXpmKwtQ==", "dependencies": { - "@walletconnect/socket-transport": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/socket-transport": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "node_modules/@walletconnect/crypto": { @@ -12470,24 +12470,24 @@ "integrity": "sha512-4BwqyWy6KpSvkocSaV7WR3BlZfrxLbJSLkg+j7Gl6pTDE+U55lLhJvQaMuDVazXYxcjBsG09k7UlH7cGiUI5vQ==" }, "node_modules/@walletconnect/http-connection": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.6.5.tgz", - "integrity": "sha512-5kr6wZ3DnqaBiwkeA9iKdawvIb3bIJNf8WA8X89YHE5KOzbkAsymjniZWs8asdl9Y9+8ZHJMPXtylyrkpT8wXA==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.6.6.tgz", + "integrity": "sha512-V0UEnvMQPYBpD+8LAbuxN+i0dWVVfZ8XtmJymsBh2KyHLgKyHSsT5RwSCst132JGDV4/JP4HrHCs5t8KqSfEPw==", "dependencies": { - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "eventemitter3": "4.0.7", "xhr2-cookies": "1.1.0" } }, "node_modules/@walletconnect/iso-crypto": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.6.5.tgz", - "integrity": "sha512-145VRX1+gudhHrnT2s81lLW/BEu3QgFMMRCrkxx9Tsl5JiLGcGbWkMxAl8zjGTMqnHeuQngyjvY1mO+3z27a7A==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.6.6.tgz", + "integrity": "sha512-wRYgKvd8K3A9FVLn2c0cDh4+9OUHkqibKtwQJTJsz+ibPGgd+n5j1/FjnzDDRGb9T1+TtlwYF3ZswKyys3diVQ==", "dependencies": { "@walletconnect/crypto": "^1.0.1", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "node_modules/@walletconnect/jsonrpc-types": { @@ -12514,13 +12514,13 @@ "deprecated": "Deprecated in favor of dynamic registry available from: https://github.com/walletconnect/walletconnect-registry" }, "node_modules/@walletconnect/qrcode-modal": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.6.5.tgz", - "integrity": "sha512-XII/Pm7zS5pRxrakURuhbWO+SfwgOuLuvOBk/hr1ATK/y7R5p19P62mCSUrvSxHXca27IX1tZJRe9D161R0WgQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.6.6.tgz", + "integrity": "sha512-wZorjpOIm6OhXKNvyH1YtpxfCUVcnuJxS8YbUeKWckGjS3tDPqUTbXWPlzFdMpNBrpY3j0B2XjLgVVQ2aUDX0w==", "dependencies": { - "@walletconnect/browser-utils": "^1.6.5", + "@walletconnect/browser-utils": "^1.6.6", "@walletconnect/mobile-registry": "^1.4.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "copy-to-clipboard": "^3.3.1", "preact": "10.4.1", "qrcode": "1.4.4" @@ -12542,29 +12542,29 @@ "integrity": "sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg==" }, "node_modules/@walletconnect/socket-transport": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.6.5.tgz", - "integrity": "sha512-FRlgBr3EIxD3du5l/tuK6jdiva85YeRG+iZmo/RPnlVw4opy74WXb5JdCK9jXLcBEoDiY9Hz4j69aqnht6gIDQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.6.6.tgz", + "integrity": "sha512-mugCEoeKTx75ogb5ROg/+LA3yGTsuRNcrYgrApceo7WNU9Z4dG8l6ycMPqrrFcODcrasq3NmXVWUYDv/CvrzSw==", "dependencies": { - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "ws": "7.5.3" } }, "node_modules/@walletconnect/types": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.6.5.tgz", - "integrity": "sha512-S9DsODI35PbIDuOSkIiF8SzTstqCqX/4+kV7n18vyukEFPlpSSHwZMwJUfzo9yJ0pqsqLNZta+jvb88gJRuAaA==" + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.6.6.tgz", + "integrity": "sha512-op77cxexOmQQN36XB1sYouNTlBRV0Rup/2NYK8A1ffdwXa3a6HLHHdhBM7I/I9BVmRXoZ4+XoOnPKGGrYtlS3g==" }, "node_modules/@walletconnect/utils": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.6.5.tgz", - "integrity": "sha512-QB5rn/1s0PKVitAQ2/mgWbay2XfN21y3ob+5g6IhxtJRW31bbMoZw5YfO6s4ixLaZZez5LNQXstvQAclRzB7jQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.6.6.tgz", + "integrity": "sha512-s2X/cVXiMDSEoWV6i7HPMbP1obXlzP7KLMrBo9OMabiJKnQEh6HSZ39WLswB2PHnl8Hp1Sr4BdRvhM5kCcYWRw==", "dependencies": { - "@walletconnect/browser-utils": "^1.6.5", + "@walletconnect/browser-utils": "^1.6.6", "@walletconnect/encoding": "^1.0.0", "@walletconnect/jsonrpc-utils": "^1.0.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "bn.js": "4.11.8", "js-sha3": "0.8.0", "query-string": "6.13.5" @@ -12587,15 +12587,15 @@ } }, "node_modules/@walletconnect/web3-provider": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.6.5.tgz", - "integrity": "sha512-SeC7+1saHxvFn2wjt/3F0sTkDemHDNDbMkdZ3jtA7vjEw91Q0CmaYIuZk2UxyVM+tC1jL1l4yci/sgaFeAcXpQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.6.6.tgz", + "integrity": "sha512-8z4r9JCE0lKuZmVCPSdYnX114ckQ+oMfr9D8osRBtdyhvN9elwITMloUJfACDRelcuet94yEbXuDobQeBDDkkw==", "dependencies": { - "@walletconnect/client": "^1.6.5", - "@walletconnect/http-connection": "^1.6.5", - "@walletconnect/qrcode-modal": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/client": "^1.6.6", + "@walletconnect/http-connection": "^1.6.6", + "@walletconnect/qrcode-modal": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "web3-provider-engine": "16.0.1" } }, @@ -69541,36 +69541,36 @@ "requires": {} }, "@walletconnect/browser-utils": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.6.5.tgz", - "integrity": "sha512-HLTysmlCkc2HN2OS6ewMG0v8E9oY2h9zNaDHe0BLN3ZxnsoMCVzkJxy7ryaXCemVdapmr6HgHFexGJoMbWaC4w==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/browser-utils/-/browser-utils-1.6.6.tgz", + "integrity": "sha512-E29xSHU7Akd4jaPehWVGx7ct+SsUzZbxcGc0fz+Pw6/j4Gh5tlfYZ9XuVixuYI4WPdQ2CmOraj8RrVOu5vba4w==", "requires": { "@walletconnect/safe-json": "1.0.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "@walletconnect/window-getters": "1.0.0", "@walletconnect/window-metadata": "1.0.0", "detect-browser": "5.2.0" } }, "@walletconnect/client": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.6.5.tgz", - "integrity": "sha512-dRq1D3NEGwM2I3CpiwFsWy1rrdMKCMSfDUu3rCCXUE4zInx+pyq7IEFjYiSjtOEZzjRlUTqYwhjnYIezQZgh4w==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/client/-/client-1.6.6.tgz", + "integrity": "sha512-DDOrxagSmXCciIEr16hTf4gWZ7PG7GXribYTfOOsjtODLtPEODEEYj/AsmEALjh3ZBG4bN35Vj0F/ZA1D+90GQ==", "requires": { - "@walletconnect/core": "^1.6.5", - "@walletconnect/iso-crypto": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/core": "^1.6.6", + "@walletconnect/iso-crypto": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "@walletconnect/core": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.6.5.tgz", - "integrity": "sha512-mmMTP8nZunjSCAy0ckafvt/JcdzcuSZPaAybqgKwx2rC9cc/3XWrdNsfiKMt8AFoQF87jGHem3905eFZYTqLXw==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-1.6.6.tgz", + "integrity": "sha512-pSftIVPY6mYz2koZPBEYmeFeAjVf2MSnRHOM6+vx+iAsUEcfMZHkgeXX6GtM6Fjza+zSZu1qnmdgURVXpmKwtQ==", "requires": { - "@walletconnect/socket-transport": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/socket-transport": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "@walletconnect/crypto": { @@ -69600,24 +69600,24 @@ "integrity": "sha512-4BwqyWy6KpSvkocSaV7WR3BlZfrxLbJSLkg+j7Gl6pTDE+U55lLhJvQaMuDVazXYxcjBsG09k7UlH7cGiUI5vQ==" }, "@walletconnect/http-connection": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.6.5.tgz", - "integrity": "sha512-5kr6wZ3DnqaBiwkeA9iKdawvIb3bIJNf8WA8X89YHE5KOzbkAsymjniZWs8asdl9Y9+8ZHJMPXtylyrkpT8wXA==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/http-connection/-/http-connection-1.6.6.tgz", + "integrity": "sha512-V0UEnvMQPYBpD+8LAbuxN+i0dWVVfZ8XtmJymsBh2KyHLgKyHSsT5RwSCst132JGDV4/JP4HrHCs5t8KqSfEPw==", "requires": { - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "eventemitter3": "4.0.7", "xhr2-cookies": "1.1.0" } }, "@walletconnect/iso-crypto": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.6.5.tgz", - "integrity": "sha512-145VRX1+gudhHrnT2s81lLW/BEu3QgFMMRCrkxx9Tsl5JiLGcGbWkMxAl8zjGTMqnHeuQngyjvY1mO+3z27a7A==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/iso-crypto/-/iso-crypto-1.6.6.tgz", + "integrity": "sha512-wRYgKvd8K3A9FVLn2c0cDh4+9OUHkqibKtwQJTJsz+ibPGgd+n5j1/FjnzDDRGb9T1+TtlwYF3ZswKyys3diVQ==", "requires": { "@walletconnect/crypto": "^1.0.1", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5" + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6" } }, "@walletconnect/jsonrpc-types": { @@ -69643,13 +69643,13 @@ "integrity": "sha512-ZtKRio4uCZ1JUF7LIdecmZt7FOLnX72RPSY7aUVu7mj7CSfxDwUn6gBuK6WGtH+NZCldBqDl5DenI5fFSvkKYw==" }, "@walletconnect/qrcode-modal": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.6.5.tgz", - "integrity": "sha512-XII/Pm7zS5pRxrakURuhbWO+SfwgOuLuvOBk/hr1ATK/y7R5p19P62mCSUrvSxHXca27IX1tZJRe9D161R0WgQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/qrcode-modal/-/qrcode-modal-1.6.6.tgz", + "integrity": "sha512-wZorjpOIm6OhXKNvyH1YtpxfCUVcnuJxS8YbUeKWckGjS3tDPqUTbXWPlzFdMpNBrpY3j0B2XjLgVVQ2aUDX0w==", "requires": { - "@walletconnect/browser-utils": "^1.6.5", + "@walletconnect/browser-utils": "^1.6.6", "@walletconnect/mobile-registry": "^1.4.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "copy-to-clipboard": "^3.3.1", "preact": "10.4.1", "qrcode": "1.4.4" @@ -69671,29 +69671,29 @@ "integrity": "sha512-QJzp/S/86sUAgWY6eh5MKYmSfZaRpIlmCJdi5uG4DJlKkZrHEF7ye7gA+VtbVzvTtpM/gRwO2plQuiooIeXjfg==" }, "@walletconnect/socket-transport": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.6.5.tgz", - "integrity": "sha512-FRlgBr3EIxD3du5l/tuK6jdiva85YeRG+iZmo/RPnlVw4opy74WXb5JdCK9jXLcBEoDiY9Hz4j69aqnht6gIDQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/socket-transport/-/socket-transport-1.6.6.tgz", + "integrity": "sha512-mugCEoeKTx75ogb5ROg/+LA3yGTsuRNcrYgrApceo7WNU9Z4dG8l6ycMPqrrFcODcrasq3NmXVWUYDv/CvrzSw==", "requires": { - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "ws": "7.5.3" } }, "@walletconnect/types": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.6.5.tgz", - "integrity": "sha512-S9DsODI35PbIDuOSkIiF8SzTstqCqX/4+kV7n18vyukEFPlpSSHwZMwJUfzo9yJ0pqsqLNZta+jvb88gJRuAaA==" + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-1.6.6.tgz", + "integrity": "sha512-op77cxexOmQQN36XB1sYouNTlBRV0Rup/2NYK8A1ffdwXa3a6HLHHdhBM7I/I9BVmRXoZ4+XoOnPKGGrYtlS3g==" }, "@walletconnect/utils": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.6.5.tgz", - "integrity": "sha512-QB5rn/1s0PKVitAQ2/mgWbay2XfN21y3ob+5g6IhxtJRW31bbMoZw5YfO6s4ixLaZZez5LNQXstvQAclRzB7jQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-1.6.6.tgz", + "integrity": "sha512-s2X/cVXiMDSEoWV6i7HPMbP1obXlzP7KLMrBo9OMabiJKnQEh6HSZ39WLswB2PHnl8Hp1Sr4BdRvhM5kCcYWRw==", "requires": { - "@walletconnect/browser-utils": "^1.6.5", + "@walletconnect/browser-utils": "^1.6.6", "@walletconnect/encoding": "^1.0.0", "@walletconnect/jsonrpc-utils": "^1.0.0", - "@walletconnect/types": "^1.6.5", + "@walletconnect/types": "^1.6.6", "bn.js": "4.11.8", "js-sha3": "0.8.0", "query-string": "6.13.5" @@ -69712,15 +69712,15 @@ } }, "@walletconnect/web3-provider": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.6.5.tgz", - "integrity": "sha512-SeC7+1saHxvFn2wjt/3F0sTkDemHDNDbMkdZ3jtA7vjEw91Q0CmaYIuZk2UxyVM+tC1jL1l4yci/sgaFeAcXpQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@walletconnect/web3-provider/-/web3-provider-1.6.6.tgz", + "integrity": "sha512-8z4r9JCE0lKuZmVCPSdYnX114ckQ+oMfr9D8osRBtdyhvN9elwITMloUJfACDRelcuet94yEbXuDobQeBDDkkw==", "requires": { - "@walletconnect/client": "^1.6.5", - "@walletconnect/http-connection": "^1.6.5", - "@walletconnect/qrcode-modal": "^1.6.5", - "@walletconnect/types": "^1.6.5", - "@walletconnect/utils": "^1.6.5", + "@walletconnect/client": "^1.6.6", + "@walletconnect/http-connection": "^1.6.6", + "@walletconnect/qrcode-modal": "^1.6.6", + "@walletconnect/types": "^1.6.6", + "@walletconnect/utils": "^1.6.6", "web3-provider-engine": "16.0.1" } }, diff --git a/src/@types/Compute.d.ts b/src/@types/Compute.d.ts index 3b0bea3eb..80110bec7 100644 --- a/src/@types/Compute.d.ts +++ b/src/@types/Compute.d.ts @@ -1,4 +1,5 @@ import { ComputeJob } from '@oceanprotocol/lib/dist/node/ocean/interfaces/Compute' +import { OrdersData_tokenOrders_datatokenId as OrdersDatatoken } from './apollo/OrdersData' // declaring into global scope to be able to use this as // ambiant types despite the above imports @@ -18,4 +19,17 @@ declare global { allowAllPublishedAlgorithms: boolean publisherTrustedAlgorithms: string[] } + + interface TokenOrder { + id: string + serviceId: number + datatokenId: OrdersDatatoken + tx: any + timestamp: number + } + + interface ComputeResults { + computeJobs: ComputeJobMetaData[] + isLoaded: boolean + } } diff --git a/src/components/@shared/Form/FormFields/AdvancedSettings.tsx b/src/components/@shared/Form/FormFields/AdvancedSettings.tsx index 7142ca53d..5b1ee1fc2 100644 --- a/src/components/@shared/Form/FormFields/AdvancedSettings.tsx +++ b/src/components/@shared/Form/FormFields/AdvancedSettings.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useState, FormEvent, ChangeEvent } from 'react' -import { useSiteMetadata } from '@hooks/useSiteMetadata' import Input from '@shared/Form/Input' import Button from '@shared/atoms/Button' import { Field } from 'formik' @@ -12,27 +11,24 @@ export default function AdvancedSettings(prop: { field: FormFieldProps ) => void }): ReactElement { - const { appConfig } = useSiteMetadata() - const [advancedSettings, setAdvancedSettings] = useState(false) + const [showAdvancedSettings, setShowAdvancedSettings] = + useState(false) + function toggleAdvancedSettings(e: FormEvent) { e.preventDefault() - advancedSettings === true - ? setAdvancedSettings(false) - : setAdvancedSettings(true) + setShowAdvancedSettings(!!showAdvancedSettings) } return ( <> - {appConfig.allowAdvancedPublishSettings === 'true' && ( - - )} - {advancedSettings === true && + + {showAdvancedSettings && prop.content.data.map( (field: FormFieldProps) => field.advanced === true && ( diff --git a/src/components/@shared/Permission.tsx b/src/components/@shared/Permission.tsx deleted file mode 100644 index b73b71198..000000000 --- a/src/components/@shared/Permission.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import React, { ReactElement, useEffect, useState } from 'react' -import { useWeb3 } from '@context/Web3' -import rbacRequest from '@utils/rbac' -import Alert from '@shared/atoms/Alert' -import Loader from '@shared/atoms/Loader' -import { useIsMounted } from '@hooks/useIsMounted' -import { useSiteMetadata } from '@hooks/useSiteMetadata' - -export default function Permission({ - eventType, - children -}: { - eventType: string - children: ReactElement -}): ReactElement { - const { appConfig } = useSiteMetadata() - const url = appConfig?.rbacUrl - const [data, updateData] = useState() - const [errorMessage, updateError] = useState() - const [messageState, updateMessageState] = - useState<'error' | 'warning' | 'info' | 'success'>() - const { accountId } = useWeb3() - const isMounted = useIsMounted() - - useEffect(() => { - if (url === '') return - - const controller = new AbortController() - const getData = async () => { - if (accountId === undefined) { - updateError('Please make sure your wallet is connected to proceed.') - updateMessageState('info') - } else { - const data = await rbacRequest(eventType, accountId, controller.signal) - if (!isMounted()) return - updateData(data) - if (data === 'ERROR') { - updateError( - 'There was an error verifying your permissions. Please refresh the page or conntact your network administrator' - ) - updateMessageState('error') - } else if (data === false) { - updateError( - `Sorry, you don't have permission to ${eventType}. Please make sure you have connected your registered address.` - ) - updateMessageState('warning') - } else if (data !== true) { - updateError( - 'An unkown error occured. Please conntact your network administrator' - ) - updateMessageState('error') - } - } - } - getData() - return () => { - controller.abort() - } - }, [eventType, accountId, url, isMounted]) - - if (url === '' || data === true) { - return <>{children} - } - - return ( - <> - -
- - - ) -} diff --git a/src/components/@shared/atoms/Publisher/index.tsx b/src/components/@shared/atoms/Publisher/index.tsx index af28ce1b5..6608453b5 100644 --- a/src/components/@shared/atoms/Publisher/index.tsx +++ b/src/components/@shared/atoms/Publisher/index.tsx @@ -8,6 +8,7 @@ import axios from 'axios' import Add from './Add' import { useWeb3 } from '@context/Web3' import { getEnsName } from '@utils/ens' +import { useIsMounted } from '@hooks/useIsMounted' const cx = classNames.bind(styles) @@ -21,6 +22,7 @@ export default function Publisher({ className?: string }): ReactElement { const { accountId } = useWeb3() + const isMounted = useIsMounted() const [profile, setProfile] = useState() const [name, setName] = useState(accountTruncate(account)) const [accountEns, setAccountEns] = useState() @@ -35,7 +37,7 @@ export default function Publisher({ async function getExternalName() { // ENS const accountEns = await getEnsName(account) - if (accountEns) { + if (accountEns && isMounted()) { setAccountEns(accountEns) setName(accountEns) } @@ -52,7 +54,7 @@ export default function Publisher({ return () => { source.cancel() } - }, [account]) + }, [account, isMounted]) const styleClasses = cx({ publisher: true, diff --git a/src/components/App.tsx b/src/components/App.tsx index ecae5a9aa..701eb35ce 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2,7 +2,7 @@ import React, { ReactElement } from 'react' import { graphql, PageProps, useStaticQuery } from 'gatsby' import Alert from '@shared/atoms/Alert' import Footer from './Footer/Footer' -import Header from './Header/Header' +import Header from './Header' import Styles from '../global/Styles' import { useWeb3 } from '@context/Web3' import { useSiteMetadata } from '@hooks/useSiteMetadata' diff --git a/src/components/Asset/AssetActions/Edit/EditAdvancedSettings.tsx b/src/components/Asset/AssetActions/Edit/EditAdvancedSettings.tsx deleted file mode 100644 index da40a5dee..000000000 --- a/src/components/Asset/AssetActions/Edit/EditAdvancedSettings.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { Formik } from 'formik' -import React, { ReactElement, useState } from 'react' -import { useAsset } from '@context/Asset' -import { useUserPreferences } from '@context/UserPreferences' -import styles from './index.module.css' -import { Logger, CredentialType, DDO } from '@oceanprotocol/lib' -import { graphql, useStaticQuery } from 'gatsby' -import { useWeb3 } from '@context/Web3' -import { useOcean } from '@context/Ocean' -// import FormAdvancedSettings from './FormAdvancedSettings' -import { useSiteMetadata } from '@hooks/useSiteMetadata' -import { setMinterToDispenser, setMinterToPublisher } from '@utils/freePrice' -import Web3Feedback from '@shared/Web3Feedback' -import { getInitialValues, validationSchema } from './_constants' -import MetadataFeedback from '../../../Publish/MetadataFeedback' - -const contentQuery = graphql` - query EditAvanceSettingsQuery { - content: allFile( - filter: { relativePath: { eq: "pages/editAdvancedSettings.json" } } - ) { - edges { - node { - childPagesJson { - description - form { - success - successAction - error - data { - name - placeholder - label - help - type - options - } - } - } - } - } - } - } -` - -function getDefaultCredentialType(credentialType: string): CredentialType { - switch (credentialType) { - case 'address': - return CredentialType.address - case 'credential3Box': - return CredentialType.credential3Box - default: - return CredentialType.address - } -} - -export default function EditAdvancedSettings({ - setShowEdit -}: { - setShowEdit: (show: boolean) => void -}): ReactElement { - const data = useStaticQuery(contentQuery) - const content = data.content.edges[0].node.childPagesJson - - const { debug } = useUserPreferences() - const { accountId } = useWeb3() - const { ocean } = useOcean() - const { isAssetNetwork, ddo, refreshDdo, price } = useAsset() - const [success, setSuccess] = useState() - const [error, setError] = useState() - const { appConfig } = useSiteMetadata() - - const hasFeedback = error || success - - const credentialType = getDefaultCredentialType(appConfig.credentialType) - - async function handleSubmit( - values: Partial, - resetForm: () => void - ) { - try { - if (price.type === 'free') { - const tx = await setMinterToPublisher( - ocean, - ddo.dataToken, - accountId, - setError - ) - if (!tx) return - } - - let newDdo: DDO - newDdo = await ocean.assets.updateCredentials( - ddo, - credentialType, - values.allow, - values.deny - ) - - newDdo = await ocean.assets.editMetadata(newDdo, { - status: { - isOrderDisabled: values.isOrderDisabled - } - }) - - const storedddo = await ocean.assets.updateMetadata(newDdo, accountId) - - if (!storedddo) { - setError(content.form.error) - Logger.error(content.form.error) - return - } else { - if (price.type === 'free') { - const tx = await setMinterToDispenser( - ocean, - ddo.dataToken, - accountId, - setError - ) - if (!tx) return - } - setSuccess(content.form.success) - resetForm() - } - } catch (error) { - Logger.error(error.message) - setError(error.message) - } - } - - return ( - { - window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) - await handleSubmit(values, resetForm) - }} - > - {({ isSubmitting, values }) => - isSubmitting || hasFeedback ? ( - { - await refreshDdo() - setShowEdit(false) - } - }} - /> - ) : ( - <> -

{content.description}

-
- {/* */} -
- - - ) - } -
- ) -} diff --git a/src/components/Asset/AssetActions/index.tsx b/src/components/Asset/AssetActions/index.tsx index 09ec0c196..e85903ee4 100644 --- a/src/components/Asset/AssetActions/index.tsx +++ b/src/components/Asset/AssetActions/index.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useState, useEffect } from 'react' -import Permission from '@shared/Permission' import Compute from './Compute' import Consume from './Consume' import { Logger, File as FileMetadata, DID } from '@oceanprotocol/lib' @@ -141,9 +140,7 @@ export default function AssetActions(): ReactElement { return ( <> - - - + ) diff --git a/src/components/Asset/AssetContent/index.tsx b/src/components/Asset/AssetContent/index.tsx index 906004d47..a3885edd5 100644 --- a/src/components/Asset/AssetContent/index.tsx +++ b/src/components/Asset/AssetContent/index.tsx @@ -17,7 +17,6 @@ import MetaMain from './MetaMain' import EditHistory from './EditHistory' import { useWeb3 } from '@context/Web3' import styles from './index.module.css' -import EditAdvancedSettings from '../AssetActions/Edit/EditAdvancedSettings' import { useSiteMetadata } from '@hooks/useSiteMetadata' import NetworkName from '@shared/atoms/NetworkName' @@ -78,17 +77,10 @@ export default function AssetContent(props: AssetContentProps): ReactElement { setShowEditCompute(true) } - function handleEditAdvancedSettingsButton() { - window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) - setShowEditAdvancedSettings(true) - } - return showEdit ? ( ) : showEditCompute ? ( - ) : showEditAdvancedSettings ? ( - ) : ( <>
@@ -127,18 +119,6 @@ export default function AssetContent(props: AssetContentProps): ReactElement { > Edit Metadata - {appConfig.allowAdvancedSettings === 'true' && ( - <> - | - - - )} {ddo.findServiceByType('compute') && type === 'dataset' && ( <> | diff --git a/src/components/Header/Wallet/Details.tsx b/src/components/Header/Wallet/Details.tsx index ff13e71e5..5f26a3d96 100644 --- a/src/components/Header/Wallet/Details.tsx +++ b/src/components/Header/Wallet/Details.tsx @@ -24,11 +24,10 @@ export default function Details(): ReactElement { const { locale } = useUserPreferences() const [mainCurrency, setMainCurrency] = useState() - const [oceanTokenMetadata, setOceanTokenMetadata] = - useState<{ - address: string - symbol: string - }>() + const [oceanTokenMetadata, setOceanTokenMetadata] = useState<{ + address: string + symbol: string + }>() // const [portisNetwork, setPortisNetwork] = useState() useEffect(() => { diff --git a/src/components/Header/Header.module.css b/src/components/Header/index.module.css similarity index 100% rename from src/components/Header/Header.module.css rename to src/components/Header/index.module.css diff --git a/src/components/Header/Header.tsx b/src/components/Header/index.tsx similarity index 83% rename from src/components/Header/Header.tsx rename to src/components/Header/index.tsx index 86696ed5e..88a9c5194 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/index.tsx @@ -1,6 +1,6 @@ import React, { ReactElement } from 'react' import Menu from './Menu' -import styles from './Header.module.css' +import styles from './index.module.css' export default function Header(): ReactElement { return ( diff --git a/src/components/Home/Home.tsx b/src/components/Home/Home.tsx index 789cd0053..0cc7fedf8 100644 --- a/src/components/Home/Home.tsx +++ b/src/components/Home/Home.tsx @@ -127,20 +127,19 @@ export default function HomePage(): ReactElement { }, [chainIds]) return ( - - <> -
-

Bookmarks

- -
+ <> +
+

Bookmarks

+ +
- {queryAndDids && ( - - )} + {queryAndDids && ( + + )} {queryLatest && ( )} -
+ + ) } diff --git a/src/components/Publish/index.tsx b/src/components/Publish/index.tsx index 4e3e68cf1..849271e39 100644 --- a/src/components/Publish/index.tsx +++ b/src/components/Publish/index.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useState, useEffect } from 'react' -import Permission from '@shared/Permission' import { Formik, FormikState } from 'formik' import { usePublish } from '@hooks/usePublish' import styles from './index.module.css' @@ -79,20 +78,18 @@ export default function PublishPage({ } return isInPurgatory && purgatoryData ? null : ( - - { - // kick off publishing - await handleSubmit(values, resetForm) - }} - > - {({ values }) => { - return <>Hello - }} - - + { + // kick off publishing + await handleSubmit(values, resetForm) + }} + > + {({ values }) => { + return <>Hello + }} + ) } diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 65594c252..eb60e9a11 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useState, useEffect, useCallback } from 'react' -import Permission from '@shared/Permission' import AssetList from '@shared/AssetList/AssetList' import queryString from 'query-string' import Filters from './Filters' @@ -78,8 +77,7 @@ export default function SearchPage({ }, [parsed, chainIds, newCancelToken, fetchAssets]) return ( - - <> + <>
- ) } diff --git a/src/context/Profile.tsx b/src/context/Profile.tsx index ae3c2e468..faf481976 100644 --- a/src/context/Profile.tsx +++ b/src/context/Profile.tsx @@ -17,7 +17,6 @@ import { PoolShares_poolShares as PoolShare } from '../@types/apollo/PoolShares' import { DDO, Logger } from '@oceanprotocol/lib' import { getDownloadAssets, getPublishedAssets } from '../utils/aquarius' import { useSiteMetadata } from '../hooks/useSiteMetadata' -import { Profile } from '../@types/Profile' import { accountTruncate } from '../utils/web3' import axios, { CancelToken } from 'axios' import ethereumAddress from 'ethereum-address' diff --git a/src/hooks/useGraphSyncStatus.ts b/src/hooks/useGraphSyncStatus.ts index b5db68928..3dc55fcfc 100644 --- a/src/hooks/useGraphSyncStatus.ts +++ b/src/hooks/useGraphSyncStatus.ts @@ -1,10 +1,10 @@ import { useState, useEffect } from 'react' -import fetch from 'cross-fetch' import { useOcean } from '../context/Ocean' import { useWeb3 } from '../context/Web3' import { Logger } from '@oceanprotocol/lib' import Web3 from 'web3' import { ConfigHelperConfig } from '@oceanprotocol/lib/dist/node/utils/ConfigHelper' +import axios, { AxiosResponse } from 'axios' const blockDifferenceThreshold = 30 const ethGraphUrl = `https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks` @@ -19,16 +19,15 @@ export interface UseGraphSyncStatus { blockGraph: number } -async function fetchGraph(url: string, queryBody: string): Promise { +async function fetchGraph( + url: string, + queryBody: string +): Promise { try { - const response = await fetch(url, { - method: 'POST', - body: queryBody - }) - - return await response.json() + const response = await axios.post(url, { ...JSON.parse(queryBody) }) + return response } catch (error) { - console.error('Error parsing json: ' + error.message) + Logger.error('Error parsing json: ' + error.message) } } @@ -36,7 +35,7 @@ async function getBlockHead(config: ConfigHelperConfig) { // for ETH main, get block from graph fetch if (config.network === 'mainnet') { const response: any = await fetchGraph(ethGraphUrl, ethGraphQuery) - return Number(response.data.blocks[0].number) + return Number(response?.data?.blocks[0].number) } // for everything else, create new web3 instance with infura @@ -50,7 +49,7 @@ async function getBlockSubgraph(subgraphUri: string) { `${subgraphUri}/subgraphs/name/oceanprotocol/ocean-subgraph`, graphQuery ) - const blockNumberGraph = Number(response.data._meta.block.number) + const blockNumberGraph = Number(response?.data?._meta?.block?.number) return blockNumberGraph } diff --git a/src/hooks/useSiteMetadata/_types.ts b/src/hooks/useSiteMetadata/_types.ts index 6cd1e6978..0b78f0e7b 100644 --- a/src/hooks/useSiteMetadata/_types.ts +++ b/src/hooks/useSiteMetadata/_types.ts @@ -28,12 +28,8 @@ export interface UseSiteMetadata { allowFixedPricing: string allowDynamicPricing: string allowFreePricing: string - allowAdvancedSettings: string - credentialType: string defaultPrivacyPolicySlug: string privacyPreferenceCenter: string - allowAdvancedPublishSettings: string - rbacUrl: string darkModeConfig: { classNameDark: string classNameLight: string diff --git a/src/hooks/useSiteMetadata/index.ts b/src/hooks/useSiteMetadata/index.ts index 8bfdee9ba..22fc2f2d0 100644 --- a/src/hooks/useSiteMetadata/index.ts +++ b/src/hooks/useSiteMetadata/index.ts @@ -33,12 +33,8 @@ const query = graphql` allowFixedPricing allowDynamicPricing allowFreePricing - allowAdvancedSettings - allowAdvancedPublishSettings - credentialType defaultPrivacyPolicySlug privacyPreferenceCenter - rbacUrl darkModeConfig { classNameDark classNameLight diff --git a/src/pages/asset/index.tsx b/src/pages/asset/index.tsx index 6d768ca7b..ea8a81c1a 100644 --- a/src/pages/asset/index.tsx +++ b/src/pages/asset/index.tsx @@ -1,5 +1,4 @@ import React, { ReactElement, useEffect, useState } from 'react' -import Permission from '@shared/Permission' import { PageProps } from 'gatsby' import PageTemplateAssetDetails from '../../components/Asset' import AssetProvider from '@context/Asset' @@ -13,12 +12,10 @@ export default function PageGatsbyAssetDetails(props: PageProps): ReactElement { }, [props.location.pathname]) return ( - - - - - - - + + + + + ) } diff --git a/src/utils/compute.ts b/src/utils/compute.ts index 9f360de42..5d2dc84ab 100644 --- a/src/utils/compute.ts +++ b/src/utils/compute.ts @@ -57,19 +57,6 @@ const getComputeOrdersByDatatokenAddress = gql` } ` -interface TokenOrder { - id: string - serviceId: number - datatokenId: OrdersDatatoken - tx: any - timestamp: number -} - -interface ComputeResults { - computeJobs: ComputeJobMetaData[] - isLoaded: boolean -} - async function getAssetMetadata( queryDtList: string[], cancelToken: CancelToken, diff --git a/src/utils/rbac.ts b/src/utils/rbac.ts deleted file mode 100644 index 89d9df083..000000000 --- a/src/utils/rbac.ts +++ /dev/null @@ -1,36 +0,0 @@ -import fetch from 'cross-fetch' -import appConfig from '../../app.config' - -export default async function rbacRequest( - eventType: string, - address: string, - signal?: AbortSignal -): Promise { - const url = appConfig.rbacUrl - if (url === '') { - return true - } else { - const data = { - component: 'market', - eventType, - authService: 'address', - credentials: { - address - } - } - try { - const response = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data), - signal: signal - }) - return await response.json() - } catch (error) { - console.error('Error parsing json: ' + error.message) - return 'ERROR' - } - } -}