From fe61e586da60e06b9ab47021cf002d193830c4bd Mon Sep 17 00:00:00 2001 From: mihaisc Date: Mon, 11 May 2020 19:29:47 +0300 Subject: [PATCH] react hooks --- package-lock.json | 454 +++++++++++++++++- package.json | 5 +- .../molecules/PublishForm/PublishForm.tsx | 5 +- .../molecules/Web3Feedback/Wallet.tsx | 2 +- .../molecules/Web3Feedback/index.tsx | 17 +- src/components/organisms/Consume.tsx | 23 +- .../templates/AssetDetails/RatingAction.tsx | 3 +- .../templates/AssetDetails/index.tsx | 9 +- src/context/Web3Context.tsx | 19 - src/context/Web3Provider.tsx | 126 ----- src/hooks/useOcean.tsx | 82 ---- src/hooks/usePurchase.tsx | 46 -- src/hooks/useWeb3.tsx | 12 - src/pages/_app.tsx | 24 +- 14 files changed, 494 insertions(+), 333 deletions(-) delete mode 100644 src/context/Web3Context.tsx delete mode 100644 src/context/Web3Provider.tsx delete mode 100644 src/hooks/useOcean.tsx delete mode 100644 src/hooks/usePurchase.tsx delete mode 100644 src/hooks/useWeb3.tsx diff --git a/package-lock.json b/package-lock.json index 2b0a36b67..e2010012c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3012,6 +3012,434 @@ "resolved": "https://registry.npmjs.org/@oceanprotocol/keeper-contracts/-/keeper-contracts-0.13.2.tgz", "integrity": "sha512-915dcnzCHEuvsmRKqVj0RxHT3T386lSJh8WREe4dsnrXHsi1ULNYxX0Ts/cvalv6bRL+aqyaZ6gN3l3nkfwEDg==" }, + "@oceanprotocol/react": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@oceanprotocol/react/-/react-0.0.3.tgz", + "integrity": "sha512-oC/IYQlQDlMDcmF85yvwxLaC3Am8bYoka1bivtfW/LM3bxtm0Z5y0VZtjuigBNmZf7mXXuATVNQjamN9W5VO3A==", + "requires": { + "@oceanprotocol/squid": "^2.1.1", + "axios": "^0.19.2", + "react": "^16.13.1", + "web3connect": "^1.0.0-beta.33" + }, + "dependencies": { + "@ethereum-navigator/atlas": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@ethereum-navigator/atlas/-/atlas-0.7.1.tgz", + "integrity": "sha512-YV7tMVwpRcJbc+Kj/Rr0RzNV/2hHBEEM1/tMWDVLB15dGJfoQuRfPJpFt6uq+Ji6s3EkldIt9kZylEeG5ALKAA==" + }, + "@ethereum-navigator/navigator": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@ethereum-navigator/navigator/-/navigator-0.5.2.tgz", + "integrity": "sha512-agSE2xzLxOKKid8QiS4v8jPhnFXW5uSXsICZ4JmS437aCZ8L3SUAy3cDQKikHb2PPZ3AazJO05k8m8i6u77peQ==", + "requires": { + "@ethereum-navigator/atlas": "^0.7.1", + "web3": "^1.2.7" + }, + "dependencies": { + "web3": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.2.7.tgz", + "integrity": "sha512-jAAJHMfUlTps+jH2li1ckDFEpPrEEriU/ubegSTGRl3KRdNhEqT93+3kd7FHJTn3NgjcyURo2+f7Da1YcZL8Mw==", + "requires": { + "web3-bzz": "1.2.7", + "web3-core": "1.2.7", + "web3-eth": "1.2.7", + "web3-eth-personal": "1.2.7", + "web3-net": "1.2.7", + "web3-shh": "1.2.7", + "web3-utils": "1.2.7" + } + } + } + }, + "@oceanprotocol/squid": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-2.1.1.tgz", + "integrity": "sha512-aoZttkArQ3qKsAHcaQfv6kFLpaSeGFHUSDRdK/MllJ5UFzclkDkBJd4P7XIJ5lS8uXOOBrrvQPxDU8wvf2yyMQ==", + "requires": { + "@ethereum-navigator/navigator": "^0.5.0", + "@oceanprotocol/keeper-contracts": "^0.13.2", + "@oceanprotocol/secret-store-client": "^0.0.15", + "bignumber.js": "^9.0.0", + "deprecated-decorator": "^0.1.6", + "node-fetch": "^2.6.0", + "save-file": "^2.3.1", + "uuid": "^7.0.2", + "web3": "^1.2.6", + "whatwg-url": "^8.0.0" + } + }, + "@types/node": { + "version": "10.17.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.21.tgz", + "integrity": "sha512-PQKsydPxYxF1DsAFWmunaxd3sOi3iMt6Zmx/tgaagHYmwJ/9cRH91hQkeJZaUGWbvn0K5HlSVEXkn5U/llWPpQ==" + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + }, + "p-cancelable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", + "integrity": "sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw==" + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=" + }, + "swarm-js": { + "version": "0.1.40", + "resolved": "https://registry.npmjs.org/swarm-js/-/swarm-js-0.1.40.tgz", + "integrity": "sha512-yqiOCEoA4/IShXkY3WKwP5PvZhmoOOD8clsKA7EEcRILMkTEYHCQ21HDCAcVpmIxZq4LyZvWeRJ6quIyHk1caA==", + "requires": { + "bluebird": "^3.5.0", + "buffer": "^5.0.5", + "eth-lib": "^0.1.26", + "fs-extra": "^4.0.2", + "got": "^7.1.0", + "mime-types": "^2.1.16", + "mkdirp-promise": "^5.0.1", + "mock-fs": "^4.1.0", + "setimmediate": "^1.0.5", + "tar": "^4.0.2", + "xhr-request": "^1.0.1" + }, + "dependencies": { + "got": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/got/-/got-7.1.0.tgz", + "integrity": "sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw==", + "requires": { + "decompress-response": "^3.2.0", + "duplexer3": "^0.1.4", + "get-stream": "^3.0.0", + "is-plain-obj": "^1.1.0", + "is-retry-allowed": "^1.0.0", + "is-stream": "^1.0.0", + "isurl": "^1.0.0-alpha5", + "lowercase-keys": "^1.0.0", + "p-cancelable": "^0.3.0", + "p-timeout": "^1.1.1", + "safe-buffer": "^5.0.1", + "timed-out": "^4.0.0", + "url-parse-lax": "^1.0.0", + "url-to-options": "^1.0.1" + } + } + } + }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "requires": { + "prepend-http": "^1.0.1" + } + }, + "uuid": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", + "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==" + }, + "web3-bzz": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.2.7.tgz", + "integrity": "sha512-iTIWBR+Z+Bn09WprtKm46LmyNOasg2lUn++AjXkBTB8UNxlUybxtza84yl2ETTZUs0zuFzdSSAEgbjhygG+9oA==", + "requires": { + "@types/node": "^10.12.18", + "got": "9.6.0", + "swarm-js": "^0.1.40", + "underscore": "1.9.1" + } + }, + "web3-core": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.2.7.tgz", + "integrity": "sha512-QA0MTae0gXcr3KHe3cQ4x56+Wh43ZKWfMwg1gfCc3NNxPRM1jJ8qudzyptCAUcxUGXWpDG8syLIn1APDz5J8BQ==", + "requires": { + "@types/bn.js": "^4.11.4", + "@types/node": "^12.6.1", + "bignumber.js": "^9.0.0", + "web3-core-helpers": "1.2.7", + "web3-core-method": "1.2.7", + "web3-core-requestmanager": "1.2.7", + "web3-utils": "1.2.7" + }, + "dependencies": { + "@types/node": { + "version": "12.12.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz", + "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==" + } + } + }, + "web3-core-helpers": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.2.7.tgz", + "integrity": "sha512-bdU++9QATGeCetVrMp8pV97aQtVkN5oLBf/TWu/qumC6jK/YqrvLlBJLdwbz0QveU8zOSap6GCvJbqKvmmbV2A==", + "requires": { + "underscore": "1.9.1", + "web3-eth-iban": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-core-method": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.2.7.tgz", + "integrity": "sha512-e1TI0QUnByDMbQ8QHwnjxfjKw0LIgVRY4TYrlPijET9ebqUJU1HCayn/BHIMpV6LKyR1fQj9EldWyT64wZQXkg==", + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.7", + "web3-core-promievent": "1.2.7", + "web3-core-subscriptions": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-core-promievent": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.2.7.tgz", + "integrity": "sha512-jNmsM/czCeMGQqKKwM9/HZVTJVIF96hdMVNN/V9TGvp+EEE7vDhB4pUocDnc/QF9Z/5QFBCVmvNWttlRgZmU0A==", + "requires": { + "eventemitter3": "3.1.2" + } + }, + "web3-core-requestmanager": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.2.7.tgz", + "integrity": "sha512-HJb/txjHixu1dxIebiZQKBoJCaNu4gsh7mq/uj6Z/w6tIHbybL90s/7ADyMED353yyJ2tDWtYJqeMVAR+KtdaA==", + "requires": { + "underscore": "1.9.1", + "web3-core-helpers": "1.2.7", + "web3-providers-http": "1.2.7", + "web3-providers-ipc": "1.2.7", + "web3-providers-ws": "1.2.7" + } + }, + "web3-core-subscriptions": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.2.7.tgz", + "integrity": "sha512-W/CzQYOUawdMDvkgA/fmLsnG5aMpbjrs78LZMbc0MFXLpH3ofqAgO2by4QZrrTShUUTeWS0ZuEkFFL/iFrSObw==", + "requires": { + "eventemitter3": "3.1.2", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.7" + } + }, + "web3-eth": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.2.7.tgz", + "integrity": "sha512-ljLd0oB4IjWkzFGVan4HkYhJXhSXgn9iaSaxdJixKGntZPgWMJfxeA+uLwTrlxrWzhvy4f+39WnT7wCh5e9TGg==", + "requires": { + "underscore": "1.9.1", + "web3-core": "1.2.7", + "web3-core-helpers": "1.2.7", + "web3-core-method": "1.2.7", + "web3-core-subscriptions": "1.2.7", + "web3-eth-abi": "1.2.7", + "web3-eth-accounts": "1.2.7", + "web3-eth-contract": "1.2.7", + "web3-eth-ens": "1.2.7", + "web3-eth-iban": "1.2.7", + "web3-eth-personal": "1.2.7", + "web3-net": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-eth-abi": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.2.7.tgz", + "integrity": "sha512-4FnlT1q+D0XBkxSMXlIb/eG337uQeMaUdtVQ4PZ3XzxqpcoDuMgXm4o+3NRxnWmr4AMm6QKjM+hcC7c0mBKcyg==", + "requires": { + "ethers": "4.0.0-beta.3", + "underscore": "1.9.1", + "web3-utils": "1.2.7" + } + }, + "web3-eth-accounts": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.2.7.tgz", + "integrity": "sha512-AE7QWi/iIQIjXwlAPtlMabm/OPFF0a1PhxT1EiTckpYNP8fYs6jW7lYxEtJPPJIKqfMjoi1xkEqTVR1YZQ88lg==", + "requires": { + "@web3-js/scrypt-shim": "^0.1.0", + "crypto-browserify": "3.12.0", + "eth-lib": "^0.2.8", + "ethereumjs-common": "^1.3.2", + "ethereumjs-tx": "^2.1.1", + "underscore": "1.9.1", + "uuid": "3.3.2", + "web3-core": "1.2.7", + "web3-core-helpers": "1.2.7", + "web3-core-method": "1.2.7", + "web3-utils": "1.2.7" + }, + "dependencies": { + "eth-lib": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz", + "integrity": "sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } + } + }, + "web3-eth-contract": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.2.7.tgz", + "integrity": "sha512-uW23Y0iL7XroRNbf9fWZ1N6OYhEYTJX8gTuYASuRnpYrISN5QGiQML6pq/NCzqypR1bl5E0fuINZQSK/xefIVw==", + "requires": { + "@types/bn.js": "^4.11.4", + "underscore": "1.9.1", + "web3-core": "1.2.7", + "web3-core-helpers": "1.2.7", + "web3-core-method": "1.2.7", + "web3-core-promievent": "1.2.7", + "web3-core-subscriptions": "1.2.7", + "web3-eth-abi": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-eth-ens": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-ens/-/web3-eth-ens-1.2.7.tgz", + "integrity": "sha512-SPRnvUNWQ0CnnTDBteGIJkvFWEizJcAHlVsrFLICwcwFZu+appjX1UOaoGu2h3GXWtc/XZlu7B451Gi+Os2cTg==", + "requires": { + "eth-ens-namehash": "2.0.8", + "underscore": "1.9.1", + "web3-core": "1.2.7", + "web3-core-helpers": "1.2.7", + "web3-core-promievent": "1.2.7", + "web3-eth-abi": "1.2.7", + "web3-eth-contract": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-eth-iban": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.2.7.tgz", + "integrity": "sha512-2NrClz1PoQ3nSJBd+91ylCOVga9qbTxjRofq/oSCoHVAEvz3WZyttx9k5DC+0rWqwJF1h69ufFvdHAAlmN/4lg==", + "requires": { + "bn.js": "4.11.8", + "web3-utils": "1.2.7" + } + }, + "web3-eth-personal": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.2.7.tgz", + "integrity": "sha512-2OAa1Spz0uB29dwCM8+1y0So7E47A4gKznjBEwXIYEcUIsvwT5X7ofFhC2XxyRpqlIWZSQAxRSSJFyupRRXzyw==", + "requires": { + "@types/node": "^12.6.1", + "web3-core": "1.2.7", + "web3-core-helpers": "1.2.7", + "web3-core-method": "1.2.7", + "web3-net": "1.2.7", + "web3-utils": "1.2.7" + }, + "dependencies": { + "@types/node": { + "version": "12.12.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz", + "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==" + } + } + }, + "web3-net": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.2.7.tgz", + "integrity": "sha512-j9qeZrS1FNyCeA0BfdLojkxOZQz3FKa1DJI+Dw9fEVhZS68vLOFANu2RB96gR9BoPHo5+k5D3NsKOoxt1gw3Gg==", + "requires": { + "web3-core": "1.2.7", + "web3-core-method": "1.2.7", + "web3-utils": "1.2.7" + } + }, + "web3-providers-http": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.2.7.tgz", + "integrity": "sha512-vazGx5onuH/zogrwkUaLFJwFcJ6CckP65VFSHoiV+GTQdkOqgoDIha7StKkslvDz4XJ2FuY/zOZHbtuOYeltXQ==", + "requires": { + "web3-core-helpers": "1.2.7", + "xhr2-cookies": "1.1.0" + } + }, + "web3-providers-ipc": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.2.7.tgz", + "integrity": "sha512-/zc0y724H2zbkV4UbGGMhsEiLfafjagIzfrsWZnyTZUlSB0OGRmmFm2EkLJAgtXrLiodaHHyXKM0vB8S24bxdA==", + "requires": { + "oboe": "2.1.4", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.7" + } + }, + "web3-providers-ws": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.2.7.tgz", + "integrity": "sha512-b5XzqDpRkNVe6MFs5K6iqOEyjQikHtg3KuU2/ClCDV37hm0WN4xCRVMC0LwegulbDXZej3zT9+1CYzGaGFREzA==", + "requires": { + "@web3-js/websocket": "^1.0.29", + "eventemitter3": "^4.0.0", + "underscore": "1.9.1", + "web3-core-helpers": "1.2.7" + }, + "dependencies": { + "eventemitter3": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.3.tgz", + "integrity": "sha512-HyaFeyfTa18nYjft59vEPsvuq6ZVcrCC1rBw6Fx8ZV9NcuUITBNCnTOyr0tHHkkHn//d+lzhsL1YybgtLQ7lng==" + } + } + }, + "web3-shh": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-shh/-/web3-shh-1.2.7.tgz", + "integrity": "sha512-f6PAgcpG0ZAo98KqCmeHoDEx5qzm3d5plet18DkT4U6WIeYowKdec8vZaLPRR7c2XreXFJ2gQf45CB7oqR7U/w==", + "requires": { + "web3-core": "1.2.7", + "web3-core-method": "1.2.7", + "web3-core-subscriptions": "1.2.7", + "web3-net": "1.2.7" + } + }, + "web3-utils": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.2.7.tgz", + "integrity": "sha512-FBh/CPJND+eiPeUF9KVbTyTZtXNWxPWtByBaWS6e2x4ACazPX711EeNaZaChIOGSLGe6se2n7kg6wnawe/MjuQ==", + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethereum-bloom-filters": "^1.0.6", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randombytes": "^2.1.0", + "underscore": "1.9.1", + "utf8": "3.0.0" + }, + "dependencies": { + "eth-lib": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", + "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + } + } + } + } + }, "@oceanprotocol/secret-store-client": { "version": "0.0.15", "resolved": "https://registry.npmjs.org/@oceanprotocol/secret-store-client/-/secret-store-client-0.0.15.tgz", @@ -21804,9 +22232,9 @@ } }, "react": { - "version": "16.12.0", - "resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz", - "integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", + "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", @@ -22078,14 +22506,25 @@ } }, "react-dom": { - "version": "16.12.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.12.0.tgz", - "integrity": "sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz", + "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2", - "scheduler": "^0.18.0" + "scheduler": "^0.19.1" + }, + "dependencies": { + "scheduler": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", + "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + } } }, "react-dotdotdot": { @@ -23204,6 +23643,7 @@ "version": "0.18.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.18.0.tgz", "integrity": "sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ==", + "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1" diff --git a/package.json b/package.json index 2f73395d2..8d57e959a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "storybook:build": "build-storybook -c .storybook -o public/storybook" }, "dependencies": { + "@oceanprotocol/react": "0.0.3", "@oceanprotocol/squid": "2.0.0-beta.4", "axios": "^0.19.2", "date-fns": "^2.11.0", @@ -29,9 +30,9 @@ "next-svgr": "^0.0.2", "nprogress": "^0.2.0", "numeral": "^2.0.6", - "react": "^16.12.0", + "react": "^16.13.1", "react-datepicker": "^2.14.0", - "react-dom": "^16.12.0", + "react-dom": "^16.13.1", "react-dotdotdot": "^1.3.1", "react-jsonschema-form": "^1.8.1", "react-markdown": "^4.3.1", diff --git a/src/components/molecules/PublishForm/PublishForm.tsx b/src/components/molecules/PublishForm/PublishForm.tsx index 774c42000..17914ca73 100644 --- a/src/components/molecules/PublishForm/PublishForm.tsx +++ b/src/components/molecules/PublishForm/PublishForm.tsx @@ -8,8 +8,6 @@ import { } from '../../../models/PublishForm' import useStoredValue from '../../../hooks/useStoredValue' import { MetaDataDexFreight } from '../../../@types/MetaData' -import useOcean from '../../../hooks/useOcean' -import useWeb3 from '../../../hooks/useWeb3' import { File, MetaData } from '@oceanprotocol/squid' import { isBrowser, toStringNoMS } from '../../../utils' import { toast } from 'react-toastify' @@ -17,6 +15,7 @@ import { useRouter } from 'next/router' import styles from './PublishForm.module.css' import utils from 'web3-utils' import AssetModel from '../../../models/Asset' +import { useWeb3, useOcean } from '@oceanprotocol/react' declare type PublishFormProps = {} @@ -105,7 +104,7 @@ export function transformPublishFormToMetadata( const PublishForm: React.FC = () => { const [buttonDisabled, setButtonDisabled] = useState(false) const { web3, web3Connect } = useWeb3() - const { ocean } = useOcean(web3) + const { ocean } = useOcean() const router = useRouter() const [data, updateData] = useStoredValue( PUBLISH_FORM_LOCAL_STORAGE_KEY, diff --git a/src/components/molecules/Web3Feedback/Wallet.tsx b/src/components/molecules/Web3Feedback/Wallet.tsx index 67860691d..7c68baac9 100644 --- a/src/components/molecules/Web3Feedback/Wallet.tsx +++ b/src/components/molecules/Web3Feedback/Wallet.tsx @@ -1,8 +1,8 @@ import React from 'react' import styles from './Wallet.module.css' import Button from '../../atoms/Button' -import useWeb3 from '../../../hooks/useWeb3' import { formatNumber } from '../../../utils' +import { useWeb3 } from '@oceanprotocol/react' const Wallet = ({ balanceOcean }: { balanceOcean: string }) => { const { account, balance, web3Connect } = useWeb3() diff --git a/src/components/molecules/Web3Feedback/index.tsx b/src/components/molecules/Web3Feedback/index.tsx index e61142a04..d928245af 100644 --- a/src/components/molecules/Web3Feedback/index.tsx +++ b/src/components/molecules/Web3Feedback/index.tsx @@ -1,10 +1,8 @@ import React from 'react' -import useOcean, { OceanConnectionStatus } from '../../../hooks/useOcean' -import { InjectedProviderStatus } from '../../../context/Web3Context' import Status from '../../atoms/Status' import Wallet from './Wallet' import styles from './index.module.css' -import useWeb3 from '../../../hooks/useWeb3' +import { useWeb3, useOcean, InjectedProviderStatus, OceanConnectionStatus } from '@oceanprotocol/react' export declare type Web3Error = { status: 'error' | 'warning' | 'success' @@ -17,20 +15,19 @@ export default function Web3Feedback({ }: { isBalanceInsufficient?: boolean }) { - const { web3, ethProviderStatus } = useWeb3() - const { oceanConnectionStatus, balance } = useOcean(web3) - + const { ethProviderStatus } = useWeb3() + const { status, balanceInOcean } = useOcean() const isEthProviderAbsent = ethProviderStatus === InjectedProviderStatus.NOT_AVAILABLE const isEthProviderDisconnected = ethProviderStatus === InjectedProviderStatus.NOT_CONNECTED const isOceanDisconnected = - oceanConnectionStatus === OceanConnectionStatus.NOT_CONNECTED + status === OceanConnectionStatus.NOT_CONNECTED const isOceanConnectionError = - oceanConnectionStatus === OceanConnectionStatus.OCEAN_CONNECTION_ERROR + status === OceanConnectionStatus.OCEAN_CONNECTION_ERROR const hasSuccess = ethProviderStatus === InjectedProviderStatus.CONNECTED && - oceanConnectionStatus === OceanConnectionStatus.CONNECTED + status === OceanConnectionStatus.CONNECTED const state = isEthProviderAbsent ? 'error' @@ -73,7 +70,7 @@ export default function Web3Feedback({ {!isEthProviderAbsent && (
- +
)} diff --git a/src/components/organisms/Consume.tsx b/src/components/organisms/Consume.tsx index 14eebc0fa..529803de2 100644 --- a/src/components/organisms/Consume.tsx +++ b/src/components/organisms/Consume.tsx @@ -6,35 +6,26 @@ import compareAsBN, { Comparisson } from '../../utils/compareAsBN' import Button from '../atoms/Button' import File from '../atoms/File' import Price from '../atoms/Price' -import usePurchase from '../../hooks/usePurchase' import { MetaDataDexFreight } from '../../@types/MetaData' import Web3Feedback from '../molecules/Web3Feedback' -import useOcean from '../../hooks/useOcean' -import useWeb3 from '../../hooks/useWeb3' import styles from './Consume.module.css' import Loader from '../atoms/Loader' +import { useWeb3, useOcean, useConsume } from '@oceanprotocol/react' + -export const feedback: { [key in number]: string } = { - 99: 'Decrypting file URL...', - 0: '1/3 Asking for agreement signature...', - 1: '1/3 Agreement initialized.', - 2: '2/3 Asking for two payment confirmations...', - 3: '2/3 Payment confirmed. Requesting access...', - 4: '3/3 Access granted. Consuming file...' -} export default function Consume({ ddo }: { ddo: DDO | undefined }) { if (!ddo) return null const { web3 } = useWeb3() - const { ocean, balance } = useOcean(web3) - const { purchaseAsset, isLoading, feedbackStep } = usePurchase() + const { ocean, balanceInOcean } = useOcean() + const { consume,consumeStepText,isLoading } = useConsume() const { attributes } = findServiceByType(ddo, 'metadata') const { price } = attributes.main const file = (attributes as MetaDataDexFreight).main.files[0] const isFree = price === '0' const isBalanceSufficient = - isFree || compareAsBN(balance, Web3.utils.fromWei(price), Comparisson.gte) + isFree || compareAsBN(balanceInOcean, Web3.utils.fromWei(price), Comparisson.gte) const isDisabled = !ocean || !isBalanceSufficient || isLoading const PurchaseButton = () => { @@ -43,11 +34,11 @@ export default function Consume({ ddo }: { ddo: DDO | undefined }) { } return isLoading ? ( - + ) : (