From c51243b7c070b0d1bdd37227e492d2c6255f1671 Mon Sep 17 00:00:00 2001 From: Ludovic Levalleux Date: Tue, 22 Nov 2022 10:16:05 +0100 Subject: [PATCH] chore: upgrade to protocol v2.1.0 (#457) * chore: upgrade to protocol v2.1.0 * chore: add script to link core-components local dependency * upgrade core-component version * Merge branch 'main' into upgrade-protocol-v2.1.0 --- package-lock.json | 84 ++++++++++++-------- package.json | 10 ++- scripts/link-to-local-core-components.js | 69 ++++++++++++++++ src/lib/utils/hooks/offer/useUpdateSeller.ts | 2 +- 4 files changed, 129 insertions(+), 36 deletions(-) create mode 100644 scripts/link-to-local-core-components.js diff --git a/package-lock.json b/package-lock.json index 74d37248b..b3dcd9ecd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "dependencies": { "@bosonprotocol/chat-sdk": "^1.2.1-alpha.4", - "@bosonprotocol/react-kit": "^0.15.0-alpha.0", + "@bosonprotocol/react-kit": "^0.15.0-alpha.1", "@davatar/react": "^1.10.4", "@ethersproject/address": "^5.6.1", "@ethersproject/units": "^5.6.1", @@ -95,6 +95,7 @@ "@types/styled-components": "^5.1.25", "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", + "commander": "^9.4.1", "cross-env": "^7.0.3", "customize-cra": "^1.0.0", "eslint-config-prettier": "^8.5.0", @@ -113,6 +114,7 @@ "prettier": "^2.7.1", "react-app-rewire-alias": "^1.1.7", "react-app-rewired": "^2.2.1", + "run-script-os": "^1.1.6", "styled-components": "^5.3.5", "typescript": "^4.7.4", "webpack-bundle-analyzer": "^4.6.1" @@ -1925,9 +1927,9 @@ } }, "node_modules/@bosonprotocol/common": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/common/-/common-1.20.0.tgz", - "integrity": "sha512-DF7s0FIk3T3Uq0QgTZDZ8ucvKZIT4h3G2cN9VjrYwmyvWB6XqcjFvR/pGs8jXU2oW9a5gYZV8NMeDXzhYr+AGA==", + "version": "1.20.1-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/common/-/common-1.20.1-alpha.0.tgz", + "integrity": "sha512-AgWs8RoNvZgiDmZE1Po/EVXhKVCveC7xTGPkwxlldIZX9rSn0O/EX3xUUb/ZcSksMrcVGg2D2zCwwjs4Dqim/w==", "dependencies": { "@bosonprotocol/metadata": "^1.8.0", "@ethersproject/abi": "^5.5.0", @@ -1939,11 +1941,11 @@ } }, "node_modules/@bosonprotocol/core-sdk": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/core-sdk/-/core-sdk-1.23.0.tgz", - "integrity": "sha512-PP+v7KZ78DS/PvEebvoFj8kDmogH8PWxp4RDmWVDtLYIAx3CKfOoKeElenBsrKvPX90jPDK70WOhZ2QizuO1WA==", + "version": "1.23.1-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/core-sdk/-/core-sdk-1.23.1-alpha.0.tgz", + "integrity": "sha512-9OQq7354QCEyAv7GYOIUWFu5+A/VHQoOD8HKbKmvvIYQR+bWcbUrG4faWfUOZHLv5s0xLB8rf8wAtWd/qCG34w==", "dependencies": { - "@bosonprotocol/common": "^1.20.0", + "@bosonprotocol/common": "^1.20.1-alpha.0", "@ethersproject/abi": "^5.5.0", "@ethersproject/address": "^5.5.0", "@ethersproject/bignumber": "^5.5.0", @@ -1958,11 +1960,11 @@ } }, "node_modules/@bosonprotocol/ethers-sdk": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/@bosonprotocol/ethers-sdk/-/ethers-sdk-1.10.2.tgz", - "integrity": "sha512-1Z+w2KqnreKit2apCAT2TwJ+qIK9pVzyc/4bPdXvlYueyW+iU6E+s4VrhohE0kATUL9xV1hyD0PEgoqxYpjk8A==", + "version": "1.10.3-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/ethers-sdk/-/ethers-sdk-1.10.3-alpha.0.tgz", + "integrity": "sha512-8bYPZvdtKgh72tW/A/DfgpldIdStC/GS6tyBW5x0P0Wl1r9ZJPdMM43cZ/i918r1gsMkHZ0bEEqsFg15VXsOhw==", "dependencies": { - "@bosonprotocol/common": "^1.20.0" + "@bosonprotocol/common": "^1.20.1-alpha.0" }, "peerDependencies": { "ethers": "^5.5.0" @@ -1988,12 +1990,12 @@ } }, "node_modules/@bosonprotocol/react-kit": { - "version": "0.15.0-alpha.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/react-kit/-/react-kit-0.15.0-alpha.0.tgz", - "integrity": "sha512-zCANIU0MR+tDVPhQ7zFZhpUMRONzzyp1T5fcEC6QIfeS375uJLYj/WAOvlh81zlYBXNpfZwjVd1t7OZZWOpGYg==", + "version": "0.15.0-alpha.1", + "resolved": "https://registry.npmjs.org/@bosonprotocol/react-kit/-/react-kit-0.15.0-alpha.1.tgz", + "integrity": "sha512-M7wNJ7anBUVsH+YaeTboLSGkZiYdQi6YO7mcgxlsTQjedBSSYUx725gaY6RDttJIwVZRAPA1A6ERnRE84m8GCQ==", "dependencies": { - "@bosonprotocol/core-sdk": "^1.23.0", - "@bosonprotocol/ethers-sdk": "^1.10.2", + "@bosonprotocol/core-sdk": "^1.23.1-alpha.0", + "@bosonprotocol/ethers-sdk": "^1.10.3-alpha.0", "@bosonprotocol/ipfs-storage": "^1.10.2", "@ethersproject/units": "^5.6.0", "@tippyjs/react": "^4.2.6", @@ -25680,6 +25682,16 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true, + "bin": { + "run-os": "index.js", + "run-script-os": "index.js" + } + }, "node_modules/rxjs": { "version": "7.5.7", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", @@ -30139,9 +30151,9 @@ } }, "@bosonprotocol/common": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/common/-/common-1.20.0.tgz", - "integrity": "sha512-DF7s0FIk3T3Uq0QgTZDZ8ucvKZIT4h3G2cN9VjrYwmyvWB6XqcjFvR/pGs8jXU2oW9a5gYZV8NMeDXzhYr+AGA==", + "version": "1.20.1-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/common/-/common-1.20.1-alpha.0.tgz", + "integrity": "sha512-AgWs8RoNvZgiDmZE1Po/EVXhKVCveC7xTGPkwxlldIZX9rSn0O/EX3xUUb/ZcSksMrcVGg2D2zCwwjs4Dqim/w==", "requires": { "@bosonprotocol/metadata": "^1.8.0", "@ethersproject/abi": "^5.5.0", @@ -30153,11 +30165,11 @@ } }, "@bosonprotocol/core-sdk": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/core-sdk/-/core-sdk-1.23.0.tgz", - "integrity": "sha512-PP+v7KZ78DS/PvEebvoFj8kDmogH8PWxp4RDmWVDtLYIAx3CKfOoKeElenBsrKvPX90jPDK70WOhZ2QizuO1WA==", + "version": "1.23.1-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/core-sdk/-/core-sdk-1.23.1-alpha.0.tgz", + "integrity": "sha512-9OQq7354QCEyAv7GYOIUWFu5+A/VHQoOD8HKbKmvvIYQR+bWcbUrG4faWfUOZHLv5s0xLB8rf8wAtWd/qCG34w==", "requires": { - "@bosonprotocol/common": "^1.20.0", + "@bosonprotocol/common": "^1.20.1-alpha.0", "@ethersproject/abi": "^5.5.0", "@ethersproject/address": "^5.5.0", "@ethersproject/bignumber": "^5.5.0", @@ -30172,11 +30184,11 @@ } }, "@bosonprotocol/ethers-sdk": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/@bosonprotocol/ethers-sdk/-/ethers-sdk-1.10.2.tgz", - "integrity": "sha512-1Z+w2KqnreKit2apCAT2TwJ+qIK9pVzyc/4bPdXvlYueyW+iU6E+s4VrhohE0kATUL9xV1hyD0PEgoqxYpjk8A==", + "version": "1.10.3-alpha.0", + "resolved": "https://registry.npmjs.org/@bosonprotocol/ethers-sdk/-/ethers-sdk-1.10.3-alpha.0.tgz", + "integrity": "sha512-8bYPZvdtKgh72tW/A/DfgpldIdStC/GS6tyBW5x0P0Wl1r9ZJPdMM43cZ/i918r1gsMkHZ0bEEqsFg15VXsOhw==", "requires": { - "@bosonprotocol/common": "^1.20.0" + "@bosonprotocol/common": "^1.20.1-alpha.0" } }, "@bosonprotocol/ipfs-storage": { @@ -30199,12 +30211,12 @@ } }, "@bosonprotocol/react-kit": { - "version": "0.15.0-alpha.0", - "resolved": "https://registry.npmjs.org/@bosonprotocol/react-kit/-/react-kit-0.15.0-alpha.0.tgz", - "integrity": "sha512-zCANIU0MR+tDVPhQ7zFZhpUMRONzzyp1T5fcEC6QIfeS375uJLYj/WAOvlh81zlYBXNpfZwjVd1t7OZZWOpGYg==", + "version": "0.15.0-alpha.1", + "resolved": "https://registry.npmjs.org/@bosonprotocol/react-kit/-/react-kit-0.15.0-alpha.1.tgz", + "integrity": "sha512-M7wNJ7anBUVsH+YaeTboLSGkZiYdQi6YO7mcgxlsTQjedBSSYUx725gaY6RDttJIwVZRAPA1A6ERnRE84m8GCQ==", "requires": { - "@bosonprotocol/core-sdk": "^1.23.0", - "@bosonprotocol/ethers-sdk": "^1.10.2", + "@bosonprotocol/core-sdk": "^1.23.1-alpha.0", + "@bosonprotocol/ethers-sdk": "^1.10.3-alpha.0", "@bosonprotocol/ipfs-storage": "^1.10.2", "@ethersproject/units": "^5.6.0", "@tippyjs/react": "^4.2.6", @@ -45192,6 +45204,12 @@ "queue-microtask": "^1.2.2" } }, + "run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true + }, "rxjs": { "version": "7.5.7", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", diff --git a/package.json b/package.json index a6b5e0a08..10dc1b2dc 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,11 @@ "upgrade:corec:latest": "npm install @bosonprotocol/common@latest @bosonprotocol/core-sdk@latest @bosonprotocol/ethers-sdk@latest @bosonprotocol/ipfs-storage@latest @bosonprotocol/react-kit@latest @bosonprotocol/widgets-sdk@latest", "upgrade:corec:alpha": "npm install @bosonprotocol/common@alpha @bosonprotocol/core-sdk@alpha @bosonprotocol/ethers-sdk@alpha @bosonprotocol/ipfs-storage@alpha @bosonprotocol/react-kit@alpha @bosonprotocol/widgets-sdk@alpha", "postinstall": "npx playwright install --with-deps chromium", - "generate": "graphql-codegen" + "generate": "graphql-codegen", + "clean-react-cache": "run-script-os", + "clean-react-cache:default": "rm -rf node_modules/.cache", + "clean-react-cache:win32": "rmdir /S /Q node_modules\\.cache", + "link-cc": "node ./scripts/link-to-local-core-components.js" }, "lint-staged": { "src/**/*.+(js|json|ts|tsx)": [ @@ -39,7 +43,7 @@ }, "dependencies": { "@bosonprotocol/chat-sdk": "^1.2.1-alpha.4", - "@bosonprotocol/react-kit": "^0.15.0-alpha.0", + "@bosonprotocol/react-kit": "^0.15.0-alpha.1", "@davatar/react": "^1.10.4", "@ethersproject/address": "^5.6.1", "@ethersproject/units": "^5.6.1", @@ -124,6 +128,7 @@ "@types/styled-components": "^5.1.25", "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", + "commander": "^9.4.1", "cross-env": "^7.0.3", "customize-cra": "^1.0.0", "eslint-config-prettier": "^8.5.0", @@ -142,6 +147,7 @@ "prettier": "^2.7.1", "react-app-rewire-alias": "^1.1.7", "react-app-rewired": "^2.2.1", + "run-script-os": "^1.1.6", "styled-components": "^5.3.5", "typescript": "^4.7.4", "webpack-bundle-analyzer": "^4.6.1" diff --git a/scripts/link-to-local-core-components.js b/scripts/link-to-local-core-components.js new file mode 100644 index 000000000..6f9464d3b --- /dev/null +++ b/scripts/link-to-local-core-components.js @@ -0,0 +1,69 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { program } = require("commander"); +const { symlinkSync, existsSync, rmSync, cpSync } = require("fs"); +const { resolve } = require("path"); + +program + .description( + "Link local Core-Components build directories to the current node_modules tree" + ) + .argument("", "Core Components local repository") + .option("--link", "Use symbolic links instead of hard copy") + .parse(process.argv); + +const [ccRepo] = program.args; +const opts = program.opts(); +const mode = opts.link ? "link" : "copy"; +const folders = ["src", "dist"]; + +const packages = [ + { path: "common", mode, folders }, + { path: "core-sdk", mode, folders }, + { path: "ethers-sdk", mode, folders }, + { path: "ipfs-storage", mode, folders }, + { path: "metadata", mode, folders }, + { path: "react-kit", mode: "copy", folders } // <-- react-kit symlink causes some problems +]; + +async function main() { + for (const package of packages) { + for (const folder of package.folders) { + const target = `${resolve(ccRepo, "packages", package.path, folder)}`; + if (!existsSync(target)) { + console.error(`Target ${target} does not exist.`); + continue; + } + const linkPath = `${resolve( + __dirname, + "..", + "node_modules/@bosonprotocol", + package.path, + folder + )}`; + while (existsSync(linkPath)) { + // remove linkPath first + rmSync(linkPath, { recursive: true }); + await new Promise((r) => setTimeout(r, 200)); + } + if (package.mode === "link") { + console.log(`Create link ${linkPath} --> ${target}`); + symlinkSync(target, linkPath, "junction"); + } + if (package.mode === "copy") { + console.log(`Copy ${target} into ${linkPath}`); + cpSync(target, linkPath, { + recursive: true, + force: true, + preserveTimestamps: true + }); + } + } + } +} + +main() + .then(() => console.log("success")) + .catch((e) => { + console.error(e); + process.exit(1); + }); diff --git a/src/lib/utils/hooks/offer/useUpdateSeller.ts b/src/lib/utils/hooks/offer/useUpdateSeller.ts index 38c72a63d..5a26083f1 100644 --- a/src/lib/utils/hooks/offer/useUpdateSeller.ts +++ b/src/lib/utils/hooks/offer/useUpdateSeller.ts @@ -43,7 +43,7 @@ async function updateSellerAccount( authTokenType: typeof authTokenTypes[keyof typeof authTokenTypes]; } ) { - await coreSDK.updateSeller({ + await coreSDK.updateSellerAndOptIn({ id: sellerId, admin: authTokenType === authTokenTypes.LENS