From 8903c9e08893f18260e7de014a51826a2348454f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 01:30:25 +0000 Subject: [PATCH 01/47] Bump eslint-plugin-jest from 27.2.1 to 27.2.3 Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 27.2.1 to 27.2.3. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v27.2.1...v27.2.3) --- updated-dependencies: - dependency-name: eslint-plugin-jest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index aac77a3a..9409c3a7 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "eslint-config-next": "13.1.1", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.2", - "eslint-plugin-jest": "^27.2.1", + "eslint-plugin-jest": "^27.2.3", "eslint-plugin-jest-dom": "^4.0.3", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react-hooks": "^4.6.0", diff --git a/yarn.lock b/yarn.lock index c50dfdd0..1fa9c588 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3491,10 +3491,10 @@ eslint-plugin-jest-dom@^4.0.3: "@testing-library/dom" "^8.11.1" requireindex "^1.2.0" -eslint-plugin-jest@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz#b85b4adf41c682ea29f1f01c8b11ccc39b5c672c" - integrity sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg== +eslint-plugin-jest@^27.2.3: + version "27.2.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.3.tgz#6f8a4bb2ca82c0c5d481d1b3be256ab001f5a3ec" + integrity sha512-sRLlSCpICzWuje66Gl9zvdF6mwD5X86I4u55hJyFBsxYOsBCmT5+kSUjf+fkFWVMMgpzNEupjW8WzUqi83hJAQ== dependencies: "@typescript-eslint/utils" "^5.10.0" From 82551728649581bcb7507338da5732bea3c1c356 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 01:22:15 +0000 Subject: [PATCH 02/47] Bump @types/node from 20.2.5 to 20.4.4 Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.2.5 to 20.4.4. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index aac77a3a..fcf97a9d 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@types/big.js": "^6.1.6", "@types/fs-extra": "^11.0.1", "@types/jest": "^29.5.1", - "@types/node": "^20.2.5", + "@types/node": "^20.4.4", "@types/react": "18.0.38", "@types/react-dom": "18.0.11", "@types/react-toastify": "^4.1.0", diff --git a/yarn.lock b/yarn.lock index c50dfdd0..af57c4c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1864,10 +1864,10 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.194.tgz#b71eb6f7a0ff11bff59fc987134a093029258a76" integrity sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g== -"@types/node@*", "@types/node@^20.2.5": - version "20.2.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.2.5.tgz#26d295f3570323b2837d322180dfbf1ba156fefb" - integrity sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ== +"@types/node@*", "@types/node@^20.4.4": + version "20.4.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.4.tgz#c79c7cc22c9d0e97a7944954c9e663bcbd92b0cb" + integrity sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew== "@types/node@^14.14.31": version "14.18.43" From be2e628bf6e107043e648aa90f7525104f89b86b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 01:29:40 +0000 Subject: [PATCH 03/47] Bump @mui/lab from 5.0.0-alpha.129 to 5.0.0-alpha.137 Bumps [@mui/lab](https://github.com/mui/material-ui/tree/HEAD/packages/mui-lab) from 5.0.0-alpha.129 to 5.0.0-alpha.137. - [Release notes](https://github.com/mui/material-ui/releases) - [Changelog](https://github.com/mui/material-ui/blob/master/CHANGELOG.md) - [Commits](https://github.com/mui/material-ui/commits/HEAD/packages/mui-lab) --- updated-dependencies: - dependency-name: "@mui/lab" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 121 +++++++++++++++++++++++++++++---------------------- 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index aac77a3a..e6449e0c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@emotion/server": "^11.10.0", "@emotion/styled": "^11.10.5", "@mui/icons-material": "^5.11.0", - "@mui/lab": "^5.0.0-alpha.123", + "@mui/lab": "^5.0.0-alpha.137", "@mui/material": "^5.11.4", "@next/font": "13.1.1", "@polkadot/api": "^10.4.1", diff --git a/yarn.lock b/yarn.lock index c50dfdd0..219d443e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -279,10 +279,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.20.2" -"@babel/runtime@^7.10.4", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": - version "7.21.5" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.5.tgz#8492dddda9644ae3bda3b45eabe87382caee7200" - integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q== +"@babel/runtime@^7.10.4", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.22.6", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" + integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== dependencies: regenerator-runtime "^0.13.11" @@ -389,7 +389,7 @@ source-map "^0.5.7" stylis "4.2.0" -"@emotion/cache@^11.10.5", "@emotion/cache@^11.10.8", "@emotion/cache@^11.11.0": +"@emotion/cache@^11.10.5", "@emotion/cache@^11.11.0": version "11.11.0" resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.11.0.tgz#809b33ee6b1cb1a625fef7a45bc568ccd9b8f3ff" integrity sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ== @@ -412,6 +412,13 @@ dependencies: "@emotion/memoize" "^0.8.0" +"@emotion/is-prop-valid@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz#23116cf1ed18bfeac910ec6436561ecb1a3885cc" + integrity sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw== + dependencies: + "@emotion/memoize" "^0.8.1" + "@emotion/memoize@^0.8.0": version "0.8.0" resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.0.tgz#f580f9beb67176fa57aae70b08ed510e1b18980f" @@ -814,6 +821,20 @@ prop-types "^15.8.1" react-is "^18.2.0" +"@mui/base@5.0.0-beta.8": + version "5.0.0-beta.8" + resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-beta.8.tgz#a0a9531ae9147be92d17e4f0e3b9accc57916841" + integrity sha512-b4vVjMZx5KzzEMf4arXKoeV5ZegAMOoPwoy1vfUBwhvXc2QtaaAyBp50U7OA2L06Leubc1A+lEp3eqwZoFn87g== + dependencies: + "@babel/runtime" "^7.22.6" + "@emotion/is-prop-valid" "^1.2.1" + "@mui/types" "^7.2.4" + "@mui/utils" "^5.14.1" + "@popperjs/core" "^2.11.8" + clsx "^1.2.1" + prop-types "^15.8.1" + react-is "^18.2.0" + "@mui/core-downloads-tracker@^5.12.3": version "5.12.3" resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.12.3.tgz#3dffe62dccc065ddd7338e97d7be4b917004287e" @@ -826,16 +847,16 @@ dependencies: "@babel/runtime" "^7.21.0" -"@mui/lab@^5.0.0-alpha.123": - version "5.0.0-alpha.129" - resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.129.tgz#e940aeef995175586e058cad36e801502730b670" - integrity sha512-niv2mFgSTgdrRJXbWoX9pIivhe80BaFXfdWajXe1bS8VYH3Y5WyJpk8KiU3rbHyJswbFEGd8N6EBBrq11X8yMA== +"@mui/lab@^5.0.0-alpha.137": + version "5.0.0-alpha.137" + resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.137.tgz#b8d2d4e63367929534c9ae6395df90316d454ac9" + integrity sha512-bHfcfti9/GnB657QpTdlK1fc9gjkP3SC+NrXyb9NCr0rT5Cq7TEkBGXyY5wGUSCyHR3CrMvchkIsfG5sH/NJ9A== dependencies: - "@babel/runtime" "^7.21.0" - "@mui/base" "5.0.0-alpha.128" - "@mui/system" "^5.12.3" + "@babel/runtime" "^7.22.6" + "@mui/base" "5.0.0-beta.8" + "@mui/system" "^5.14.1" "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.3" + "@mui/utils" "^5.14.1" clsx "^1.2.1" prop-types "^15.8.1" react-is "^18.2.0" @@ -858,35 +879,35 @@ react-is "^18.2.0" react-transition-group "^4.4.5" -"@mui/private-theming@^5.12.3": - version "5.12.3" - resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.12.3.tgz#f5e4704e25d9d91b906561cae573cda8f3801e10" - integrity sha512-o1e7Z1Bp27n4x2iUHhegV4/Jp6H3T6iBKHJdLivS5GbwsuAE/5l4SnZ+7+K+e5u9TuhwcAKZLkjvqzkDe8zqfA== +"@mui/private-theming@^5.13.7": + version "5.13.7" + resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.13.7.tgz#2f8ef5da066f3c6c6423bd4260d003a28d10b099" + integrity sha512-qbSr+udcij5F9dKhGX7fEdx2drXchq7htLNr2Qg2Ma+WJ6q0ERlEqGSBiPiVDJkptcjeVL4DGmcf1wl5+vD4EA== dependencies: - "@babel/runtime" "^7.21.0" - "@mui/utils" "^5.12.3" + "@babel/runtime" "^7.22.5" + "@mui/utils" "^5.13.7" prop-types "^15.8.1" -"@mui/styled-engine@^5.12.3": - version "5.12.3" - resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.12.3.tgz#3307643d52c81947a624cdd0437536cc8109c4f0" - integrity sha512-AhZtiRyT8Bjr7fufxE/mLS+QJ3LxwX1kghIcM2B2dvJzSSg9rnIuXDXM959QfUVIM3C8U4x3mgVoPFMQJvc4/g== +"@mui/styled-engine@^5.13.2": + version "5.13.2" + resolved "https://registry.yarnpkg.com/@mui/styled-engine/-/styled-engine-5.13.2.tgz#c87bd61c0ab8086d34828b6defe97c02bcd642ef" + integrity sha512-VCYCU6xVtXOrIN8lcbuPmoG+u7FYuOERG++fpY74hPpEWkyFQG97F+/XfTQVYzlR2m7nPjnwVUgATcTCMEaMvw== dependencies: "@babel/runtime" "^7.21.0" - "@emotion/cache" "^11.10.8" + "@emotion/cache" "^11.11.0" csstype "^3.1.2" prop-types "^15.8.1" -"@mui/system@^5.12.3": - version "5.12.3" - resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.12.3.tgz#306b3cdffa3046067640219c1e5dd7e3dae38ff9" - integrity sha512-JB/6sypHqeJCqwldWeQ1MKkijH829EcZAKKizxbU2MJdxGG5KSwZvTBa5D9qiJUA1hJFYYupjiuy9ZdJt6rV6w== +"@mui/system@^5.12.3", "@mui/system@^5.14.1": + version "5.14.1" + resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.14.1.tgz#ec8ae69f63963b5916dad4bca2f8a86a001a2392" + integrity sha512-u+xlsU34Jdkgx1CxmBnIC4Y08uPdVX5iEd3S/1dggDFtOGp+Lj8xmKRJAQ8PJOOJLOh8pDwaZx4AwXikL4l1QA== dependencies: - "@babel/runtime" "^7.21.0" - "@mui/private-theming" "^5.12.3" - "@mui/styled-engine" "^5.12.3" + "@babel/runtime" "^7.22.6" + "@mui/private-theming" "^5.13.7" + "@mui/styled-engine" "^5.13.2" "@mui/types" "^7.2.4" - "@mui/utils" "^5.12.3" + "@mui/utils" "^5.14.1" clsx "^1.2.1" csstype "^3.1.2" prop-types "^15.8.1" @@ -896,14 +917,14 @@ resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.2.4.tgz#b6fade19323b754c5c6de679a38f068fd50b9328" integrity sha512-LBcwa8rN84bKF+f5sDyku42w1NTxaPgPyYKODsh01U1fVstTClbUoSA96oyRBnSNyEiAVjKm6Gwx9vjR+xyqHA== -"@mui/utils@^5.12.3": - version "5.12.3" - resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.12.3.tgz#3fa3570dac7ec66bb9cc84ab7c16ab6e1b7200f2" - integrity sha512-D/Z4Ub3MRl7HiUccid7sQYclTr24TqUAQFFlxHQF8FR177BrCTQ0JJZom7EqYjZCdXhwnSkOj2ph685MSKNtIA== +"@mui/utils@^5.12.3", "@mui/utils@^5.13.7", "@mui/utils@^5.14.1": + version "5.14.1" + resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.14.1.tgz#29696371016552a6eb3af975bc7af429ec88b29a" + integrity sha512-39KHKK2JeqRmuUcLDLwM+c2XfVC136C5/yUyQXmO2PVbOb2Bol4KxtkssEqCbTwg87PSCG3f1Tb0keRsK7cVGw== dependencies: - "@babel/runtime" "^7.21.0" + "@babel/runtime" "^7.22.6" "@types/prop-types" "^15.7.5" - "@types/react-is" "^16.7.1 || ^17.0.0" + "@types/react-is" "^18.2.1" prop-types "^15.8.1" react-is "^18.2.0" @@ -1601,6 +1622,11 @@ resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.7.tgz#ccab5c8f7dc557a52ca3288c10075c9ccd37fff7" integrity sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw== +"@popperjs/core@^2.11.8": + version "2.11.8" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" + integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== + "@rushstack/eslint-patch@^1.1.3": version "1.2.0" resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.2.0.tgz#8be36a1f66f3265389e90b5f9c9962146758f728" @@ -1903,12 +1929,12 @@ dependencies: "@types/react" "*" -"@types/react-is@^16.7.1 || ^17.0.0": - version "17.0.4" - resolved "https://registry.yarnpkg.com/@types/react-is/-/react-is-17.0.4.tgz#3cccd02851f7f7a75b21d6e922da26bc7f8f44ad" - integrity sha512-FLzd0K9pnaEvKz4D1vYxK9JmgQPiGk1lu23o1kqGsLeT0iPbRSF7b76+S5T9fD8aRa0B8bY7I/3DebEj+1ysBA== +"@types/react-is@^18.2.1": + version "18.2.1" + resolved "https://registry.yarnpkg.com/@types/react-is/-/react-is-18.2.1.tgz#61d01c2a6fc089a53520c0b66996d458fdc46863" + integrity sha512-wyUkmaaSZEzFZivD8F2ftSyAfk6L+DfFliVj/mYdOXbVjRcS87fQJLTnhk6dRZPuJjI+9g6RZJO4PNCngUrmyw== dependencies: - "@types/react" "^17" + "@types/react" "*" "@types/react-syntax-highlighter@^15.5.6": version "15.5.6" @@ -1949,15 +1975,6 @@ "@types/scheduler" "*" csstype "^3.0.2" -"@types/react@^17": - version "17.0.58" - resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.58.tgz#c8bbc82114e5c29001548ebe8ed6c4ba4d3c9fb0" - integrity sha512-c1GzVY97P0fGxwGxhYq989j4XwlcHQoto6wQISOC2v6wm3h0PORRWJFHlkRjfGsiG3y1609WdQ+J+tKxvrEd6A== - dependencies: - "@types/prop-types" "*" - "@types/scheduler" "*" - csstype "^3.0.2" - "@types/scheduler@*": version "0.16.3" resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.3.tgz#cef09e3ec9af1d63d2a6cc5b383a737e24e6dcf5" From f832521046db8b17df390dd0cc8c74f34bd70436 Mon Sep 17 00:00:00 2001 From: 0xLucca <0xlucca.dev@gmail.com> Date: Wed, 2 Aug 2023 12:27:55 -0300 Subject: [PATCH 04/47] Update submodule --- ink-compiler-be | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ink-compiler-be b/ink-compiler-be index 9b74acff..a360b8f2 160000 --- a/ink-compiler-be +++ b/ink-compiler-be @@ -1 +1 @@ -Subproject commit 9b74acff2bb3425b39bc0fbc2dc6e16245bab4b9 +Subproject commit a360b8f2021683780c8604d4dc64690f779a544c From 654e53dfd9a1cb40a395daf045a514a40b9f5170 Mon Sep 17 00:00:00 2001 From: Johand Date: Thu, 10 Aug 2023 17:49:49 -0300 Subject: [PATCH 05/47] Adding workflow to build, push to ECR and deploy web & compiler-be images --- .github/workflows/build_compiler_be.yaml | 69 ++++++++++++++++++++++++ .github/workflows/build_web.yaml | 69 ++++++++++++++++++++++++ docker-compose.yml | 9 +--- 3 files changed, 140 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build_compiler_be.yaml create mode 100644 .github/workflows/build_web.yaml diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml new file mode 100644 index 00000000..30d5f51a --- /dev/null +++ b/.github/workflows/build_compiler_be.yaml @@ -0,0 +1,69 @@ +name: "Build, push to ECR and deploy to EC2 instance" + +on: + push: + tags: + - 'be-v*' + workflow_dispatch: + +jobs: + build_and_push_to_ECR: + name: Build & push polkadot-wizard image to ECR. + runs-on: ubuntu-latest + env: + # Secrets + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + SSH_KEY: ${{ secrets.SSH_KEY }} + + # Env variables + ACCOUNT_ID: 711012187398 + REPOSITORY: 'polkadot-contract-wizard-compiler-be' + DEPLOYMENT_SERVER_IP: '3.139.60.27' + + CONTAINER_BASE: "pkw" + DB_EXTERNAL_PORT: 27027 + BACKEND_EXTERNAL_PORT: 8000 + WEB_EXTERNAL_PORT: 3000 + WEB_ENVIRONMENT: "production" + BRANCH: "develop" + + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build compiler-be docker-image + id: build-compiler-be-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker build -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . + working-directory: polkadot-contract-wizard/ink-compiler-be + + - name: Set tag and push compiler-be image to Amazon ECR + id: push-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker tag ${{ env.REPOSITORY }}:$GITHUB_REF_NAME $ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + docker push $ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + + - name: Update Docker Compose Deployment + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + ssh -i $SSH_KEY ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml new file mode 100644 index 00000000..0290fa96 --- /dev/null +++ b/.github/workflows/build_web.yaml @@ -0,0 +1,69 @@ +name: "Build, push to ECR and deploy to EC2 instance" + +on: + push: + tags: + - 'web-v*' + workflow_dispatch: + +jobs: + build_and_push_to_ECR: + name: Build & push polkadot-wizard image to ECR. + runs-on: ubuntu-latest + env: + # Secrets + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_REGION }} + SSH_KEY: ${{ secrets.SSH_KEY }} + + # Env variables + ACCOUNT_ID: 711012187398 + REPOSITORY: 'polkadot-contract-wizard-web' + DEPLOYMENT_SERVER_IP: '3.139.60.27' + + CONTAINER_BASE: "pkw" + DB_EXTERNAL_PORT: 27027 + BACKEND_EXTERNAL_PORT: 8000 + WEB_EXTERNAL_PORT: 3000 + WEB_ENVIRONMENT: "production" + BRANCH: "develop" + + steps: + - name: Check out Git repository + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build web docker-image + id: build-web-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker build -f .docker/web/dev.Dockerfile -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . + working-directory: polkadot-contract-wizard + + - name: Set tag and push web image to Amazon ECR + id: push-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker tag ${{ env.REPOSITORY }}:$GITHUB_REF_NAME $ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + docker push $ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + + - name: Update Docker Compose Deployment + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + ssh -i $SSH_KEY ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + diff --git a/docker-compose.yml b/docker-compose.yml index cbfb8935..05220edb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,10 +7,7 @@ networks: services: web: container_name: ${CONTAINER_BASE}_web - build: - context: . - dockerfile: .docker/web/dev.Dockerfile - target: runner + image: ${WEB_IMAGE} ports: - ${WEB_EXTERNAL_PORT}:3000 environment: @@ -27,9 +24,7 @@ services: fi' compiler-be: container_name: ${CONTAINER_BASE}_backend - build: - context: ./ink-compiler-be - dockerfile: ./Dockerfile + image: ${COMPILER_BE_IMAGE} ports: - ${BACKEND_EXTERNAL_PORT}:8000 environment: From 38f9b61ce907595f151432d98347e581812109e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 09:46:48 -0300 Subject: [PATCH 06/47] Bump cypress from 12.16.0 to 12.17.3 (#162) Bumps [cypress](https://github.com/cypress-io/cypress) from 12.16.0 to 12.17.3. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](https://github.com/cypress-io/cypress/compare/v12.16.0...v12.17.3) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 54 +++++++++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index d88da331..369771cf 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@types/whatwg-url": "^11.0.0", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.61.0", - "cypress": "^12.16.0", + "cypress": "^12.17.3", "eslint": "^8.41.0", "eslint-config-next": "13.1.1", "eslint-config-prettier": "^8.6.0", diff --git a/yarn.lock b/yarn.lock index d79f77bc..8609f8fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -340,10 +340,10 @@ resolved "https://registry.yarnpkg.com/@ctrl/tinycolor/-/tinycolor-3.6.0.tgz#53fa5fe9c34faee89469e48f91d51a3766108bc8" integrity sha512-/Z3l6pXthq0JvMYdUFyX9j0MaCltlIn6mfh9jLyQwg5aPKxkyNa0PTHtU1AlFXLNk55ZuAeJRcpvq+tmLfKmaQ== -"@cypress/request@^2.88.10": - version "2.88.11" - resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.11.tgz#5a4c7399bc2d7e7ed56e92ce5acb620c8b187047" - integrity sha512-M83/wfQ1EkspjkE2lNWNV5ui2Cv7UCv1swW1DqljahbzLVWltcsexQh8jYtuS/vzFXP+HySntGM83ZXA9fn17w== +"@cypress/request@^2.88.11": + version "2.88.12" + resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590" + integrity sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA== dependencies: aws-sign2 "~0.7.0" aws4 "^1.8.0" @@ -360,7 +360,7 @@ performance-now "^2.1.0" qs "~6.10.3" safe-buffer "^5.1.2" - tough-cookie "~2.5.0" + tough-cookie "^4.1.3" tunnel-agent "^0.6.0" uuid "^8.3.2" @@ -1895,10 +1895,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.4.tgz#c79c7cc22c9d0e97a7944954c9e663bcbd92b0cb" integrity sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew== -"@types/node@^14.14.31": - version "14.18.43" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.43.tgz#679e000d9f1d914132ea295b4a1ffdf20370ec49" - integrity sha512-n3eFEaoem0WNwLux+k272P0+aq++5o05bA9CfiwKPdYPB5ZambWKdWoeHy7/OJiizMhzg27NLaZ6uzjLTzXceQ== +"@types/node@^16.18.39": + version "16.18.39" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.39.tgz#aa39a1a87a40ef6098ee69689a1acb0c1b034832" + integrity sha512-8q9ZexmdYYyc5/cfujaXb4YOucpQxAV4RMG0himLyDUOEr8Mr79VrqsFI+cQ2M2h89YIuy95lbxuYjxT4Hk4kQ== "@types/parse-json@^4.0.0": version "4.0.0" @@ -2991,14 +2991,14 @@ csstype@^3.0.2, csstype@^3.1.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b" integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ== -cypress@^12.16.0: - version "12.16.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.16.0.tgz#d0dcd0725a96497f4c60cf54742242259847924c" - integrity sha512-mwv1YNe48hm0LVaPgofEhGCtLwNIQEjmj2dJXnAkY1b4n/NE9OtgPph4TyS+tOtYp5CKtRmDvBzWseUXQTjbTg== +cypress@^12.17.3: + version "12.17.3" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.3.tgz#1e2b19037236fc60e4a4b3a14f0846be17a1fc0e" + integrity sha512-/R4+xdIDjUSLYkiQfwJd630S81KIgicmQOLXotFxVXkl+eTeVO+3bHXxdi5KBh/OgC33HWN33kHX+0tQR/ZWpg== dependencies: - "@cypress/request" "^2.88.10" + "@cypress/request" "^2.88.11" "@cypress/xvfb" "^1.2.4" - "@types/node" "^14.14.31" + "@types/node" "^16.18.39" "@types/sinonjs__fake-timers" "8.1.1" "@types/sizzle" "^2.3.2" arch "^2.2.0" @@ -3033,7 +3033,7 @@ cypress@^12.16.0: pretty-bytes "^5.6.0" proxy-from-env "1.0.0" request-progress "^3.0.0" - semver "^7.3.2" + semver "^7.5.3" supports-color "^8.1.1" tmp "~0.2.1" untildify "^4.0.0" @@ -6141,7 +6141,7 @@ proxy-from-env@1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" integrity sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A== -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -6527,10 +6527,10 @@ semver@^6.0.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.2, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0: - version "7.5.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.0.tgz#ed8c5dc8efb6c629c88b23d41dc9bf40c1d96cd0" - integrity sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA== +semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.0, semver@^7.5.3: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== dependencies: lru-cache "^6.0.0" @@ -7069,13 +7069,15 @@ tough-cookie@^4.1.2: universalify "^0.2.0" url-parse "^1.5.3" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== +tough-cookie@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" + integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== dependencies: - psl "^1.1.28" + psl "^1.1.33" punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" tr46@^3.0.0: version "3.0.0" From a24a8548b1b0729d8fe599e7eb806fe88a54bda7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 09:47:03 -0300 Subject: [PATCH 07/47] Bump @types/react-syntax-highlighter from 15.5.6 to 15.5.7 (#161) Bumps [@types/react-syntax-highlighter](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-syntax-highlighter) from 15.5.6 to 15.5.7. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-syntax-highlighter) --- updated-dependencies: - dependency-name: "@types/react-syntax-highlighter" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 369771cf..a7551981 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@polkadot/ui-keyring": "^3.2.1", "@polkadot/ui-settings": "^3.2.1", "@testing-library/user-event": "^14.4.3", - "@types/react-syntax-highlighter": "^15.5.6", + "@types/react-syntax-highlighter": "^15.5.7", "big.js": "^6.2.1", "bn.js": "^5.2.1", "copy-to-clipboard": "^3.3.3", diff --git a/yarn.lock b/yarn.lock index 8609f8fc..781d0b21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1936,10 +1936,10 @@ dependencies: "@types/react" "*" -"@types/react-syntax-highlighter@^15.5.6": - version "15.5.6" - resolved "https://registry.yarnpkg.com/@types/react-syntax-highlighter/-/react-syntax-highlighter-15.5.6.tgz#77c95e6b74d2be23208fcdcf187b93b47025f1b1" - integrity sha512-i7wFuLbIAFlabTeD2I1cLjEOrG/xdMa/rpx2zwzAoGHuXJDhSqp9BSfDlMHSh9JSuNfxHk9eEmMX6D55GiyjGg== +"@types/react-syntax-highlighter@^15.5.7": + version "15.5.7" + resolved "https://registry.yarnpkg.com/@types/react-syntax-highlighter/-/react-syntax-highlighter-15.5.7.tgz#bd29020ccb118543d88779848f99059b64b02d0f" + integrity sha512-bo5fEO5toQeyCp0zVHBeggclqf5SQ/Z5blfFmjwO5dkMVGPgmiwZsJh9nu/Bo5L7IHTuGWrja6LxJVE2uB5ZrQ== dependencies: "@types/react" "*" From e50819feeea1683135e8fab0418bacdac24b42cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 10:13:09 -0300 Subject: [PATCH 08/47] Bump @next/font from 13.1.1 to 13.4.12 (#160) Bumps [@next/font](https://github.com/vercel/next.js/tree/HEAD/packages/font) from 13.1.1 to 13.4.12. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/commits/v13.4.12/packages/font) --- updated-dependencies: - dependency-name: "@next/font" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a7551981..af48328b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@mui/icons-material": "^5.11.0", "@mui/lab": "^5.0.0-alpha.137", "@mui/material": "^5.11.4", - "@next/font": "13.1.1", + "@next/font": "13.4.12", "@polkadot/api": "^10.4.1", "@polkadot/api-contract": "^10.4.1", "@polkadot/extension-dapp": "^0.46.3", diff --git a/yarn.lock b/yarn.lock index 781d0b21..2e22aa94 100644 --- a/yarn.lock +++ b/yarn.lock @@ -940,10 +940,10 @@ dependencies: glob "7.1.7" -"@next/font@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/font/-/font-13.1.1.tgz#a0cb38bf8a181560f195d82f13f9f92fd0b0dd20" - integrity sha512-amygRorS05hYK1/XQRZo5qBl7l2fpHnezeKU/cNveWU5QJg+sg8gMGkUXHtvesNKpiKIJshBRH1TzvO+2sKpvQ== +"@next/font@13.4.12": + version "13.4.12" + resolved "https://registry.yarnpkg.com/@next/font/-/font-13.4.12.tgz#6b6f8f870241baaf9f7f4245e874cf3cf95e35ae" + integrity sha512-w/ygNFuscvvFKFTMoIqhU8Kaq1wM6x4XEu9bwzJaj8G7aloH866TUPeCgiKf+M/ACpMKfRahQa06REcg6T3CyA== "@next/swc-android-arm-eabi@13.1.1": version "13.1.1" From 41bae53a2988e9d7be88fce2083620e5486fb77a Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 11:07:31 -0300 Subject: [PATCH 09/47] Updating ssh connection string in workflows --- .github/workflows/build_compiler_be.yaml | 3 ++- .github/workflows/build_web.yaml | 3 ++- docker-compose.yml | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index 30d5f51a..645ac656 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -65,5 +65,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - ssh -i $SSH_KEY ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + echo $SSH_KEY > key.pem && chmod 400 key.pem + ssh -o "StrictHostKeyChecking no" -i key.pem ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 0290fa96..2b61434c 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -65,5 +65,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - ssh -i $SSH_KEY ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + echo $SSH_KEY > key.pem && chmod 400 key.pem + ssh -o "StrictHostKeyChecking no" -i key.pem ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" diff --git a/docker-compose.yml b/docker-compose.yml index 05220edb..c4947925 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,4 +46,3 @@ services: - polkadot-wizard - \ No newline at end of file From 2d66d2386c5d839777d0b21c6b9332929c261d55 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 15:52:46 -0300 Subject: [PATCH 10/47] Updating working-directory in workflows --- .github/workflows/build_compiler_be.yaml | 2 +- .github/workflows/build_web.yaml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index 645ac656..e484c1b5 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -50,7 +50,7 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | docker build -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . - working-directory: polkadot-contract-wizard/ink-compiler-be + working-directory: ./ink-compiler-be - name: Set tag and push compiler-be image to Amazon ECR id: push-image diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 2b61434c..9b846ac5 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -50,7 +50,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | docker build -f .docker/web/dev.Dockerfile -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . - working-directory: polkadot-contract-wizard - name: Set tag and push web image to Amazon ECR id: push-image From ab6262d95607cc328303dd10734cf19d1dc8f764 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 16:19:33 -0300 Subject: [PATCH 11/47] Copying .env file for web and updating working-directory for compiler-be --- .github/workflows/build_compiler_be.yaml | 3 ++- .github/workflows/build_web.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index e484c1b5..053a9bcf 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -49,8 +49,9 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | + pwd docker build -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . - working-directory: ./ink-compiler-be + working-directory: polkadot-contract-wizard/ink-compiler-be/ - name: Set tag and push compiler-be image to Amazon ECR id: push-image diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 9b846ac5..8ec9f853 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -49,6 +49,7 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | + cp .env.example .env docker build -f .docker/web/dev.Dockerfile -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . - name: Set tag and push web image to Amazon ECR From 051fa6f9a6bfd26adb65745f68431ec90e068833 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 17:06:25 -0300 Subject: [PATCH 12/47] Updating ssh connection string in workflows --- .github/workflows/build_compiler_be.yaml | 2 +- .github/workflows/build_web.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index 053a9bcf..c6267a50 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -67,5 +67,5 @@ jobs: run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME echo $SSH_KEY > key.pem && chmod 400 key.pem - ssh -o "StrictHostKeyChecking no" -i key.pem ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 8ec9f853..3531bddb 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -66,5 +66,5 @@ jobs: run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME echo $SSH_KEY > key.pem && chmod 400 key.pem - ssh -o "StrictHostKeyChecking no" -i key.pem ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" From 38edfeb59afa021c9bc4b17eb6fda866cb3f07e7 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 17:38:06 -0300 Subject: [PATCH 13/47] Updating working-directory for compiler-be --- .github/workflows/build_compiler_be.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index c6267a50..e7ad1d6d 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -51,7 +51,7 @@ jobs: run: | pwd docker build -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . - working-directory: polkadot-contract-wizard/ink-compiler-be/ + working-directory: ink-compiler-be/ - name: Set tag and push compiler-be image to Amazon ECR id: push-image From 2a741560ef1b0da1f1526d144d5d76b74f65dc86 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 17:42:59 -0300 Subject: [PATCH 14/47] Adding config to checkout submodules for compiler-be workflow --- .github/workflows/build_compiler_be.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index e7ad1d6d..ec967b37 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -32,6 +32,8 @@ jobs: steps: - name: Check out Git repository uses: actions/checkout@v3 + with: + submodules: 'true' - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v2 From 2a8d0c0c2e9845fc7fce8f56e42f1c983157129c Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 17:52:41 -0300 Subject: [PATCH 15/47] Updating ssh keys in workflows --- .github/workflows/build_compiler_be.yaml | 2 +- .github/workflows/build_web.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index ec967b37..15e8b7e1 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -68,6 +68,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - echo $SSH_KEY > key.pem && chmod 400 key.pem + echo $SSH_KEY | tr -d '\r' > key.pem && chmod 400 key.pem ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 3531bddb..442986cc 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -65,6 +65,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - echo $SSH_KEY > key.pem && chmod 400 key.pem + echo $SSH_KEY | tr -d '\r' > key.pem && chmod 400 key.pem ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" From 6e9bf5447ce9f039614368d09bf40bf927a55620 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 18:35:21 -0300 Subject: [PATCH 16/47] Updating setup for ssh key and ssh connection in web workflow --- .github/workflows/build_web.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 442986cc..bbc74fd5 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -64,7 +64,14 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | + #Setup ssh key + mkdir -p ~/.ssh + echo $SSH_KEY | tr -d '\r' > .ssh/private_key + chmod 600 ~/.ssh/private_key + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_rsa + ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts + #Export Image URI from ECR export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - echo $SSH_KEY | tr -d '\r' > key.pem && chmod 400 key.pem - ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + ssh ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" From 56df8437c645224660aec504f65b0e3d7f3eb057 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 18:43:18 -0300 Subject: [PATCH 17/47] Fixing typo in web workflow --- .github/workflows/build_web.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index bbc74fd5..c3914da8 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -66,7 +66,7 @@ jobs: run: | #Setup ssh key mkdir -p ~/.ssh - echo $SSH_KEY | tr -d '\r' > .ssh/private_key + echo $SSH_KEY | tr -d '\r' > ~/.ssh/private_key chmod 600 ~/.ssh/private_key eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa From ff2ee8648c3c68698d8a872b9acdf1bb4588a097 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 18:59:55 -0300 Subject: [PATCH 18/47] Fixing typo in web workflow --- .github/workflows/build_web.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index c3914da8..4a760a9a 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -69,7 +69,7 @@ jobs: echo $SSH_KEY | tr -d '\r' > ~/.ssh/private_key chmod 600 ~/.ssh/private_key eval "$(ssh-agent -s)" - ssh-add ~/.ssh/id_rsa + ssh-add ~/.ssh/private_key ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts #Export Image URI from ECR export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME From b90a16e5d7e6296c81ddde56f44eb150533ff9f3 Mon Sep 17 00:00:00 2001 From: Johand Date: Fri, 11 Aug 2023 19:25:01 -0300 Subject: [PATCH 19/47] Updating setup for ssh key and ssh connection in web workflow --- .github/workflows/build_web.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 4a760a9a..f0e4446d 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -66,12 +66,15 @@ jobs: run: | #Setup ssh key mkdir -p ~/.ssh - echo $SSH_KEY | tr -d '\r' > ~/.ssh/private_key + echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/private_key + more ~/.ssh/private_key chmod 600 ~/.ssh/private_key eval "$(ssh-agent -s)" ssh-add ~/.ssh/private_key ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts + more ~/.ssh/known_hosts #Export Image URI from ECR export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME + echo $IMAGE_URL ssh ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" From ca2676af472d5b79bf230b61db72a271dd0500b3 Mon Sep 17 00:00:00 2001 From: Johand Date: Sun, 13 Aug 2023 16:15:56 -0300 Subject: [PATCH 20/47] Updating docker-compose file --- .github/workflows/build_compiler_be.yaml | 2 +- .github/workflows/build_web.yaml | 2 -- docker-compose.yml | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index 15e8b7e1..a6d97b23 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -68,6 +68,6 @@ jobs: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - echo $SSH_KEY | tr -d '\r' > key.pem && chmod 400 key.pem + echo "$SSH_KEY" | tr -d '\r' > key.pem && chmod 400 key.pem ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/COMPILER_BE_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo COMPILER_BE_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index f0e4446d..2761419e 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -67,12 +67,10 @@ jobs: #Setup ssh key mkdir -p ~/.ssh echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/private_key - more ~/.ssh/private_key chmod 600 ~/.ssh/private_key eval "$(ssh-agent -s)" ssh-add ~/.ssh/private_key ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts - more ~/.ssh/known_hosts #Export Image URI from ECR export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME echo $IMAGE_URL diff --git a/docker-compose.yml b/docker-compose.yml index c4947925..45661b14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: - ${WEB_EXTERNAL_PORT}:3000 environment: - NODE_ENV=${WEB_ENVIRONMENT} + - NODE_OPTIONS='--max-old-space-size=2048' networks: - polkadot-wizard depends_on: @@ -44,5 +45,17 @@ services: image: mongo:5.0.16 networks: - polkadot-wizard - + volumes: + - /data/mongodb:/data/db + mongoexpress: + image: mongo-express:0.54.0 + ports: + - 8081:8081 + container_name: ${CONTAINER_BASE}_mongoexpress + environment: + - ME_CONFIG_MONGODB_SERVER=mongodb + networks: + - polkadot-wizard + depends_on: + - mongodb From 7b2a30fc6845b9f27a05305ff8a98a19eb0a619c Mon Sep 17 00:00:00 2001 From: Johand Date: Sun, 13 Aug 2023 16:57:14 -0300 Subject: [PATCH 21/47] Updating docker compose deployment step in workflow --- .github/workflows/build_web.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 2761419e..74a79ff7 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -64,15 +64,7 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | - #Setup ssh key - mkdir -p ~/.ssh - echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/private_key - chmod 600 ~/.ssh/private_key - eval "$(ssh-agent -s)" - ssh-add ~/.ssh/private_key - ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts - #Export Image URI from ECR export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME - echo $IMAGE_URL - ssh ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + echo "$SSH_KEY" | tr -d '\r' > key.pem && chmod 400 key.pem + ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$D From aa2840302a14581c9ba7d11b172f71b9429f4f6f Mon Sep 17 00:00:00 2001 From: Johand Date: Sun, 13 Aug 2023 17:01:24 -0300 Subject: [PATCH 22/47] Updating workflows --- .github/workflows/build_compiler_be.yaml | 1 - .github/workflows/build_web.yaml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_compiler_be.yaml b/.github/workflows/build_compiler_be.yaml index a6d97b23..1d22c07b 100644 --- a/.github/workflows/build_compiler_be.yaml +++ b/.github/workflows/build_compiler_be.yaml @@ -51,7 +51,6 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | - pwd docker build -t ${{ env.REPOSITORY }}:$GITHUB_REF_NAME . working-directory: ink-compiler-be/ diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index 74a79ff7..ddc8171f 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -66,5 +66,5 @@ jobs: run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME echo "$SSH_KEY" | tr -d '\r' > key.pem && chmod 400 key.pem - ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$D + ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" From 4be9124401f6870c39d89d6f274d1f689490f21c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:32:47 -0300 Subject: [PATCH 23/47] Bump @mui/icons-material from 5.11.16 to 5.14.7 (#180) Bumps [@mui/icons-material](https://github.com/mui/material-ui/tree/HEAD/packages/mui-icons-material) from 5.11.16 to 5.14.7. - [Release notes](https://github.com/mui/material-ui/releases) - [Changelog](https://github.com/mui/material-ui/blob/master/CHANGELOG.md) - [Commits](https://github.com/mui/material-ui/commits/v5.14.7/packages/mui-icons-material) --- updated-dependencies: - dependency-name: "@mui/icons-material" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index af48328b..3c52f51e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@emotion/react": "^11.11.0", "@emotion/server": "^11.10.0", "@emotion/styled": "^11.10.5", - "@mui/icons-material": "^5.11.0", + "@mui/icons-material": "^5.14.7", "@mui/lab": "^5.0.0-alpha.137", "@mui/material": "^5.11.4", "@next/font": "13.4.12", diff --git a/yarn.lock b/yarn.lock index 2e22aa94..ffe75ee4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -279,12 +279,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.20.2" -"@babel/runtime@^7.10.4", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.5", "@babel/runtime@^7.22.6", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": - version "7.22.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" - integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== +"@babel/runtime@^7.10.4", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.10", "@babel/runtime@^7.22.5", "@babel/runtime@^7.22.6", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": + version "7.22.11" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.11.tgz#7a9ba3bbe406ad6f9e8dd4da2ece453eb23a77a4" + integrity sha512-ee7jVNlWN09+KftVOu9n7S8gQzD/Z6hN/I8VBRXW4P1+Xe7kJGXMwu8vds4aGIMHZnNbdpSWCfZZtinytpcAvA== dependencies: - regenerator-runtime "^0.13.11" + regenerator-runtime "^0.14.0" "@babel/template@^7.20.7", "@babel/template@^7.3.3": version "7.20.7" @@ -840,12 +840,12 @@ resolved "https://registry.yarnpkg.com/@mui/core-downloads-tracker/-/core-downloads-tracker-5.12.3.tgz#3dffe62dccc065ddd7338e97d7be4b917004287e" integrity sha512-yiJZ+knaknPHuRKhRk4L6XiwppwkAahVal3LuYpvBH7GkA2g+D9WLEXOEnNYtVFUggyKf6fWGLGnx0iqzkU5YA== -"@mui/icons-material@^5.11.0": - version "5.11.16" - resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.11.16.tgz#417fa773c56672e39d6ccfed9ac55591985f0d38" - integrity sha512-oKkx9z9Kwg40NtcIajF9uOXhxiyTZrrm9nmIJ4UjkU2IdHpd4QVLbCc/5hZN/y0C6qzi2Zlxyr9TGddQx2vx2A== +"@mui/icons-material@^5.14.7": + version "5.14.7" + resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.14.7.tgz#d7f6bd188fe38adf35c89d9343b8a529c2306383" + integrity sha512-mWp4DwMa8c1Gx9yOEtPgxM4b+e6hAbtZyzfSubdBwrnEE6G5D2rbAJ5MB+If6kfI48JaYaJ5j8+zAdmZLuZc0A== dependencies: - "@babel/runtime" "^7.21.0" + "@babel/runtime" "^7.22.10" "@mui/lab@^5.0.0-alpha.137": version "5.0.0-alpha.137" @@ -6357,10 +6357,10 @@ refractor@^3.6.0: parse-entities "^2.0.0" prismjs "~1.27.0" -regenerator-runtime@^0.13.11: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45" + integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA== regexp.prototype.flags@^1.4.3, regexp.prototype.flags@^1.5.0: version "1.5.0" From 076ab9154aa868b2055d6f7ebb9d49a0adbecba9 Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Sun, 17 Sep 2023 20:23:28 -0300 Subject: [PATCH 24/47] Epic Change Network (#157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add wallet selector and account selector * fix typo errors * add chain/network selector * refactor code and add chains images * add some styles, remove unused code * add wallet disconnect and reconnect flow * modify tsconfig * replace useink/chains with dist * revert tsconfig * modify moduleResolution tsconfig * add api and chainInfo state properties * add chain typos and chains list details * add chain typos and chains list details * fix chain tslint typo error * refactor chains typos * error * fix error * move useink files to infrastructure folder, rename variables, refactor wallet logo selection * refactor installed and notinstalled list modal wallets * move attributes that are not functions inside the state interface * fix flow problem with api connection * Installing useink * move modal styles to his own file * Modal view wallets selector (#148) * add wallet selector and account selector * fix typo errors * add some styles, remove unused code * add wallet disconnect and reconnect flow * modify tsconfig * replace useink/chains with dist * revert tsconfig * modify moduleResolution tsconfig * add api and chainInfo state properties * add chain typos and chains list details * fix chain tslint typo error * refactor chains typos * move useink files to infrastructure folder, rename variables, refactor wallet logo selection * refactor installed and notinstalled list modal wallets * move attributes that are not functions inside the state interface * fix flow problem with api connection * move modal styles to his own file * fix connect wallet button * design improvements * fix styles * fix button width * add close icon to modal * Working * Fix prod implementation * Using one single point of Connected Account and network info --------- Co-authored-by: bogos Co-authored-by: Agustín Longoni --- package.json | 1 + pages/_app.tsx | 50 ++-- pages/index.tsx | 6 +- public/assets/chains/astar.png | Bin 0 -> 1709 bytes public/assets/chains/custom.png | Bin 0 -> 1146 bytes .../chains/rococo-contracts-testnet.png | Bin 0 -> 1384 bytes public/assets/chains/shibuya-testnet.png | Bin 0 -> 1238 bytes public/assets/chains/shiden-kusama.png | Bin 0 -> 1238 bytes src/constants/chainProperties.ts | 1 - src/constants/chains.ts | 47 +++ src/constants/config.ts | 6 + src/constants/images.ts | 1 + src/constants/wallets.ts | 23 ++ src/context/LocalDbContext.tsx | 27 ++ src/context/NetworkAccountsContext.tsx | 268 ++++++++++-------- src/context/StorageContractContext.tsx | 10 +- src/domain/CompileContractRepository.ts | 2 +- src/domain/DomainEvents.ts | 3 +- src/domain/repositories/INetworkRepository.ts | 6 + src/hooks/useCompileContract.ts | 2 +- src/hooks/useDelay.ts | 18 ++ src/hooks/useDeployContract.ts | 7 +- src/hooks/useNetworkApi.ts | 15 + src/hooks/useRecentlyClicked.ts | 9 +- .../LocalStorageNetworkRepository.ts | 28 ++ .../ApiCompileContractRepository.ts | 0 .../useink/chains/data/chaindata.ts | 103 +++++++ .../useink/chains/data/index.ts | 2 + .../useink/chains/data/testnet-chaindata.ts | 18 ++ .../useink/chains/data/types.ts | 44 +++ src/infrastructure/useink/chains/index.ts | 2 + src/infrastructure/useink/chains/types.ts | 13 + src/infrastructure/useink/walletTypes.ts | 66 +++++ src/types/arrays.ts | 1 + src/types/chain.ts | 8 + src/types/index.ts | 2 + src/utils/error.ts | 9 + src/utils/localStorage.ts | 13 +- src/view/components/ModalWallet/index.tsx | 112 ++++++++ src/view/components/ModalWallet/styled.tsx | 62 ++++ .../AccountSelect/index.tsx | 128 +++++++++ .../AccountSelect/styled.ts | 60 ++++ .../WalletConnectButton/AccountsSelect.tsx | 96 ------- .../WalletConnectButton/NetworkSelect.tsx | 94 ++++++ .../components/WalletConnectButton/index.tsx | 106 ++++--- src/view/wizardView/Step2Compile/index.tsx | 5 +- src/view/wizardView/Step3Deploy/index.tsx | 8 +- tsconfig.json | 18 +- yarn.lock | 9 +- 49 files changed, 1191 insertions(+), 318 deletions(-) create mode 100644 public/assets/chains/astar.png create mode 100644 public/assets/chains/custom.png create mode 100644 public/assets/chains/rococo-contracts-testnet.png create mode 100644 public/assets/chains/shibuya-testnet.png create mode 100644 public/assets/chains/shiden-kusama.png delete mode 100644 src/constants/chainProperties.ts create mode 100755 src/constants/chains.ts create mode 100644 src/constants/wallets.ts create mode 100644 src/context/LocalDbContext.tsx create mode 100644 src/domain/repositories/INetworkRepository.ts create mode 100644 src/hooks/useDelay.ts create mode 100644 src/hooks/useNetworkApi.ts create mode 100644 src/infrastructure/LocalStorageNetworkRepository.ts rename src/infrastructure/{ => backendApi}/ApiCompileContractRepository.ts (100%) create mode 100644 src/infrastructure/useink/chains/data/chaindata.ts create mode 100644 src/infrastructure/useink/chains/data/index.ts create mode 100644 src/infrastructure/useink/chains/data/testnet-chaindata.ts create mode 100644 src/infrastructure/useink/chains/data/types.ts create mode 100644 src/infrastructure/useink/chains/index.ts create mode 100644 src/infrastructure/useink/chains/types.ts create mode 100644 src/infrastructure/useink/walletTypes.ts create mode 100644 src/types/arrays.ts create mode 100644 src/types/chain.ts create mode 100644 src/view/components/ModalWallet/index.tsx create mode 100644 src/view/components/ModalWallet/styled.tsx create mode 100644 src/view/components/WalletConnectButton/AccountSelect/index.tsx create mode 100644 src/view/components/WalletConnectButton/AccountSelect/styled.ts delete mode 100644 src/view/components/WalletConnectButton/AccountsSelect.tsx create mode 100644 src/view/components/WalletConnectButton/NetworkSelect.tsx diff --git a/package.json b/package.json index 3c52f51e..ef7592ee 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "semver": "^7.3.8", "sharp": "^0.32.1", "simplebar-react": "^3.2.0", + "useink": "^1.13.0", "whatwg-url": "^13.0.0" }, "devDependencies": { diff --git a/pages/_app.tsx b/pages/_app.tsx index 4e6df037..4c113529 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -21,7 +21,10 @@ import { import { CustomSnackBar as AppNotification } from 'src/view/components/Snackbar' import { StorageContractsProvider } from '@/context' import { LocalStorageContractRepository } from '@/infrastructure/LocalStorageContractRepository' -import { DOMAIN } from '@/constants/config' +import { DAPP_CONFIG, DOMAIN } from '@/constants/config' +import { UseInkProvider } from 'useink' +import { CHAINS } from '@/constants/chains' +import { LocalDbProvider } from '@/context/LocalDbContext' type CustomAppProps = AppProps & { emotionCache: EmotionCache @@ -47,24 +50,33 @@ export default function App(props: CustomAppProps) { - - - - - {({ settings }) => { - return ( - - {getLayout()} - - ) - }} - - - - - + + + + + + + {({ settings }) => { + return ( + + {getLayout()} + + ) + }} + + + + + + + {' '} ) diff --git a/pages/index.tsx b/pages/index.tsx index 417e0a8c..a1de565e 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -15,9 +15,7 @@ const Token: Record = { } function Home() { - const { - state: { currentAccount } - } = useNetworkAccountsContext() + const { accountConnected } = useNetworkAccountsContext() const { contracts } = useStorageContractsContext() return ( @@ -59,7 +57,7 @@ function Home() { imgProps={{ width: 75, height: 65 }} /> - {currentAccount && } + {accountConnected && } ) } diff --git a/public/assets/chains/astar.png b/public/assets/chains/astar.png new file mode 100644 index 0000000000000000000000000000000000000000..6663c595707da083aacf7f9b11e25a81bb151854 GIT binary patch literal 1709 zcmV;e22%NnP)ifdFZV5~*nmRSRjWs;y`uP(u_TEk&qSstScj(5wi3 zgsOtJQWT{>Qq-rYXbEZ+Q~_3B30MUShaek2vJUZPcfH>C?!4!6*NBKm;7Fs<%-s8Z z=X~dUcL+WzjeHzU)h7?4_AXBS9?j1 zH1B5$eG~#Q;Wh!c3X)2J^u<7Q!hsoI)B(`~5K{wD6(GP%{OuifhU7k;;NkiaB9ez7 zQgkoMtTRlKx4=*}$b5Nou0$5bpJGBdE38djkAbz{qU-w&l1hM3VIl0`7H1=Q^GdSs z1AkyS3om#GKF`Gu3pDWd28R9{7LhgPhG2^e{|V2WzK-=~7U|{Rs zGh-|1uBST2)EvuvsDkMIi?>^%^rt`)0EsR@!A;12~0X|pDklH&H+%zU8I^IvCjt9XH8nE60 z#}kbmMBv%fJP_CYMeF2OmSC*2kQgQ`UjS?Ky(0T!^na|+9ucyv6COvnlJ#Z>*n35y z?Y*fzhU2D9P7w9{qj-XYccWMtL2eP4pFvoj8ON@t1e`6s!p!xLLrS(-z`+y(S4LlV zx$V$Hp@V#vgd-ouvrHGeAL6cehs1d~bETcKe|@DvrP)ugb#dVO6lgN_7k162Rj3dV zZeyN#tunE~D0Bg#>l-T@wvZZ|2!0uc~XEh1SIKIDxwv3tPv8?w^Nmw z;9@i1J0KXDuLu8RJ9rg&_OGxjahe2digQ;bpt%4X*MiSX6Z-(t)bHVGpJ85o=bu{5v zB-v@gXq2EjWxd}G?oyXppwqMHDa~9+xY~pn$$)9AzKf$vD_T>3^*vBnnzgu-1LHf4 z_B_pU0r(W%C{Fl4VRc6dTiiD-X3?IOHJh+ni1|K9Ge6wpdNo>_Ls&WoG4PsEspmw( zr-(&Kzp%)DjPFgPL)*^s@dYjfxy+*aJ8s0gnH5ZiOCiD$Wqh0)O4BGQ4tG%z+Efn3deKrj_dZj zUfZS&4ZPG`6G85c78;Gq2)y=lkc2+sJJ%v;9tktipAj;`jTkr4;NDr9h9K!TuMixQ z_k3em8UCBE_hDH#P*lZsP0`QRBW7_~5r>MjzOfSx&7RM1Ln*G|QrR3SEyE(0@iQl{dn)1=6Y>WRrh=<;rO) z`0fvuIt!>b=OML=(3{m(tlciJwu6~9P=6Z@#NF3+l9{m|nnT)B=N|pCeZHscK&X06 zG}r^M8uvmmyQeTvD^7>M|MrRZou=J5g?(8;)DH)09Ik3`BP1W(_16Al_?S>{Kb!VR z^?0cF-5REbxR>l4n?7|jp1CjgA%bq4#b{QN)WfzCLn9JLRg31@qWtqpBsNK+#%re~ z&l(8nszPu4(-l?PRYG%jOBO^cK8QdRa?t1(@M!!3KKMU)Z_MJseSxe#Qdc5_Wj(Ue z_+>qcvKB=}(@;}nG*k(7ey_K~#7Fg;i^4 z990zl&dhE%-I!XMz6?g=BdHIh+Ta6>Vw9w&A!)4;uwqdn1%-rGv53!zzkIgQw1Si( zqM#TA6%s>QQ?b?vrj^>1R{UWMX-m@D(&n+d^EmxxvO7E5-KJ+bd*_^c?sv|2?wvb= zIVAOlwu<6IJ}&TV0lu{aJ0ptzS(9SmaHJIXNV_BpVMrn8FEKgIT6KL!?Ro$&pHn7w{4Vi1jp_i@H4s%=deGp&uTO6QH~X!y>zEc z5~$U7V0-JSwbTc%p1}jgKTqjW+eNkQ0jHI8KMBB2>)mv0hOJA2zF5v8-*$9Y#&yjO z87Amp4vvc^!;N7j4I|@Z&`d>{f9z((2EqN&41A7nds?fbiJODGE`A6npx$m&?UH_G zY9{csN6)e`DjnixtJO+Y%V;gv5vN^8rpn+*oA0yKfE&3rV9T}X7I|&{##F5H_h33n z+$=3cSR9O}tK}p*p+&>6uqyD0c`C#}f=;+dP0pa$IP`?p@znIv8MkK{ly!8dk!9e1 z=D!UYwRK_E#!(F7V0LRz5o*tqjQG;vu^c8H1nQt<%@NdQ7D;8Ko145ns5qk*&yi_A zE-m5&WNoYtV-fqHvFa;1!JZ9~5<>b+xJyzM-NK5Gj!ka zfP6_TyiVN(%QbGscwb)-OdOLbD}my?Na4F+qOq|@{>n?>eQ|9n>KX>*cxKATjT2qdkIlS`9%Mf1(?ORui!sj6y-_#0Pz7q1A_C#geRI5q)S>P$)>#mkJ8D z6-1#{Yy|Z|Xh0DufkXr)wb;}?Rhncqw)wG5Hk<73%xguFfaya@dyrEUa3SX$h|w~{pNfa|TAlj&5?4pH&Ey2=c*g{5Gm{nQ&-F{7LNdoWKg1VD? z5Fa=Q@#15!lW{~cX*8cS!P3pxG4v$th8Q+>r_lLnJ0cwoc>0U&$VW6R8Y-5e6oxQg zF(*uU0)1pd#|(gd3YX-tz8!qLrCbEyIvAOd$d zIfLvb_O_!~pt>3jG{3VG|J2uE@Utn{nPvMBd=>%Fe1q52J%`2OG+ek3{5V| zjAlX(n~91_7S>4KKo*7iNV0e=9I;WE?3WEBa!8^wRbkQ4NUcdc-fv>5=;OwC5nuPu z&=#u4n{Tzikr{ruSi$M@72Lm-xQqAByYM)fhO86x6TY9LOC=jjsOt+F zAQA4CmP2j0HgpSLzVy+r z;f+rgz_-`o{rx(XFX4wt;Dbv*dlESIC_w$h&*Z4S3&Bt=uSXBr>o2j^+sp1(d^J>L zin&N5KdS_AYXOjOQsikL>5$ zG#6!B%@sP+w0J%zVp1^bcX#;GsQ?@+m)%Yr$W|bCxt^SJ%e0y;3Wt)AC0xH+D677C z?f{OnQyHnZ_LZ&t?v=qCxJKu$!%+T2v7TIWhivALtf*`yA<2vhy7s z5cn5$aLmu9VPo{IOTdAm!sBybU`U2fmaw-|!Q+(zJRS-DpaaV8A>v~p#N%=!bQc>= z1Z!AmNN{`Rmjq%l4|WnIoP8yXk>~yRpHSlNA6qa8rJUDsZajqOsOf~~wCNPKFFCts+8Pth=4 zDyW#dxdm0#@!?0K5N)mCg=`g>WCf|!5-O!5s09Ok=UjMmasW@(6clN`Oc-xmiSy-2 zaxmOLFd4A4n8RR9#+k8T8~Da*5i55UJebcR{pbKks)7An1<;u}KYBWd^+XxAfD5~n z6CMpta~u6|Zhr?_xBMW7DzW4I#V7C<+iP7~DaU8%`IQ zRh<^J-@q=3h@bVtpoIST&9Zr#K+tU_+A2E5e=z34-k#R@ly5rViE?>G=rz{nAhTJ- zjUSS*>3~hJ!y9s-@3b3E+1|45;o?4AE(tw7%_QCz>m@zM|M9bjqfV?XXPcWIEh+fv z>os^J2lXQ-B#Li%$cdik+~}pGTBVrdWT+8?nw3A(AiLRaCoaUW{-liMr960}Gfz+d zL)|V&ZW}z*IX_ee=1@~y5R?%^3a_~5x)>ct>!0X{}GjO+e;0@Zb zxn0IUJV4FPhfbnVQWxhlD5(tTOa%crgr_-EWW*{-K(nCAAvoitJ#RSZ$Q z^92ne5vH4BE;}V^5fp2shJ!;5ae6C~ROJ)zM-dL2G)|Jf+}5s7IQf<|a9BRVt($3+ zmNHd&q?cYCflJmQEF! zPE~1rQAxkVvr663wfg(4uvSTsPV*br8)irO5Aq*3k?@2P$N&HU07*qoM6N<$g0D0| ADF6Tf literal 0 HcmV?d00001 diff --git a/public/assets/chains/shiden-kusama.png b/public/assets/chains/shiden-kusama.png new file mode 100644 index 0000000000000000000000000000000000000000..562a58138ff575aebd1a17e369637f0613be7588 GIT binary patch literal 1238 zcmV;{1S$K8P)v=qCxJKu$!%+T2v7TIWhivALtf*`yA<2vhy7s z5cn5$aLmu9VPo{IOTdAm!sBybU`U2fmaw-|!Q+(zJRS-DpaaV8A>v~p#N%=!bQc>= z1Z!AmNN{`Rmjq%l4|WnIoP8yXk>~yRpHSlNA6qa8rJUDsZajqOsOf~~wCNPKFFCts+8Pth=4 zDyW#dxdm0#@!?0K5N)mCg=`g>WCf|!5-O!5s09Ok=UjMmasW@(6clN`Oc-xmiSy-2 zaxmOLFd4A4n8RR9#+k8T8~Da*5i55UJebcR{pbKks)7An1<;u}KYBWd^+XxAfD5~n z6CMpta~u6|Zhr?_xBMW7DzW4I#V7C<+iP7~DaU8%`IQ zRh<^J-@q=3h@bVtpoIST&9Zr#K+tU_+A2E5e=z34-k#R@ly5rViE?>G=rz{nAhTJ- zjUSS*>3~hJ!y9s-@3b3E+1|45;o?4AE(tw7%_QCz>m@zM|M9bjqfV?XXPcWIEh+fv z>os^J2lXQ-B#Li%$cdik+~}pGTBVrdWT+8?nw3A(AiLRaCoaUW{-liMr960}Gfz+d zL)|V&ZW}z*IX_ee=1@~y5R?%^3a_~5x)>ct>!0X{}GjO+e;0@Zb zxn0IUJV4FPhfbnVQWxhlD5(tTOa%crgr_-EWW*{-K(nCAAvoitJ#RSZ$Q z^92ne5vH4BE;}V^5fp2shJ!;5ae6C~ROJ)zM-dL2G)|Jf+}5s7IQf<|a9BRVt($3+ zmNHd&q?cYCflJmQEF! zPE~1rQAxkVvr663wfg(4uvSTsPV*br8)irO5Aq*3k?@2P$N&HU07*qoM6N<$g0D0| ADF6Tf literal 0 HcmV?d00001 diff --git a/src/constants/chainProperties.ts b/src/constants/chainProperties.ts deleted file mode 100644 index 03dbce6b..00000000 --- a/src/constants/chainProperties.ts +++ /dev/null @@ -1 +0,0 @@ -export const DEFAULT_DECIMALS = 12 diff --git a/src/constants/chains.ts b/src/constants/chains.ts new file mode 100755 index 00000000..eae227c3 --- /dev/null +++ b/src/constants/chains.ts @@ -0,0 +1,47 @@ +import { + Astar, + Chain, + ChainId, + RococoContractsTestnet, + ShibuyaTestnet, + ShidenKusama +} from '@/infrastructure/useink/chains' +import { ArrayOneOrMore, ChainExtended } from '@/types' +import { CHAINS_IMG_PATH } from './images' + +export const DEFAULT_DECIMALS = 12 + +export const CHAINS: ArrayOneOrMore = [ + Astar, + ShibuyaTestnet, + ShidenKusama, + RococoContractsTestnet +] + +export const CHAINS_ALLOWED: ChainExtended[] = CHAINS.map(chain => { + return { + ...chain, + logo: { + src: `${CHAINS_IMG_PATH}${chain.id ? chain.id : 'custom'}.png`, + alt: `${chain.name} img` + } + } +}) + +export const UNKNOWN_CHAIN = { + name: 'UNKNOWN', + id: 'unknown-network', + logo: { + src: `${CHAINS_IMG_PATH}custom.png`, + alt: `unknown chain img` + } +} + +export function getChain(chainId?: ChainId): ChainExtended { + if (!chainId) return UNKNOWN_CHAIN as ChainExtended + + return ( + CHAINS_ALLOWED.find(_chain => _chain.id === chainId) ?? + (UNKNOWN_CHAIN as ChainExtended) + ) +} diff --git a/src/constants/config.ts b/src/constants/config.ts index fa1e5d84..df16fca3 100644 --- a/src/constants/config.ts +++ b/src/constants/config.ts @@ -1,6 +1,12 @@ +import { Chain } from '@/infrastructure/useink/chains' + export const IS_PRODUCTION = process.env.NODE_ENV === ('production' as string) export const IS_DEVELOPMENT = process.env.NODE_ENV === ('development' as string) +export const DEFAULT_CHAIN: Chain['id'] = IS_DEVELOPMENT + ? 'shibuya-testnet' + : 'astar' + export const DOMAIN = process.env.NEXT_PUBLIC_DOMAIN as string export interface DappConfig { diff --git a/src/constants/images.ts b/src/constants/images.ts index ea92c120..7a13ad35 100644 --- a/src/constants/images.ts +++ b/src/constants/images.ts @@ -6,6 +6,7 @@ export const LOGO_PROTOFIRE = '/assets/protofire.svg' export const GIF_COMPILING = '/assets/compiling.gif' export const SVG_SUCCESSFULLY = '/assets/successfully.svg' export const SVG_AWESOME = '/assets/auto_awesome.svg' +export const CHAINS_IMG_PATH = `/assets/chains/` export const TOKEN_PATHS: Record = { psp22: '/assets/token.png', diff --git a/src/constants/wallets.ts b/src/constants/wallets.ts new file mode 100644 index 00000000..e0a4d1c2 --- /dev/null +++ b/src/constants/wallets.ts @@ -0,0 +1,23 @@ +import { WalletLogoProps } from '@/infrastructure/useink/walletTypes' + +export type WalletImg = { [name: string]: WalletLogoProps } +export type WalletKeys = keyof typeof WALLET_IMG_DETAILS + +export const WALLET_IMG_DETAILS: WalletImg = { + talisman: { + src: 'data:image/svg+xml,%3Csvg%20width%3D%2224%22%20hei…th-10-inside-1_4684_17034%29%22%2F%3E%3C%2Fsvg%3E', + alt: 'Talisman Logo' + }, + enkrypt: { + src: 'data:image/svg+xml,%3Csvg%20id%3D%22Layer_1%22%20d…44%2C0%2C0%2C1%2C58.84%2C44Z%22%2F%3E%3C%2Fsvg%3E', + alt: 'Enkrypt Logo' + }, + 'polkadot-js': { + alt: 'Polkadotjs Logo', + src: 'data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%20standalone%3D%22yes%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%20id%3D%22Layer_1%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%2215%2015%20140%20140%22%20style%3D%22enable-background%3Anew%200%200%20170%20170%3Bzoom%3A%201%3B%22%20xml%3Aspace%3D%22preserve%22%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E.bg0%7Bfill%3A%23FF8C00%7D%20.st0%7Bfill%3A%23FFFFFF%7D%3C%2Fstyle%3E%3Cg%3E%3Ccircle%20class%3D%22bg0%22%20cx%3D%2285%22%20cy%3D%2285%22%20r%3D%2270%22%3E%3C%2Fcircle%3E%3Cg%3E%3Cpath%20class%3D%22st0%22%20d%3D%22M85%2C34.7c-20.8%2C0-37.8%2C16.9-37.8%2C37.8c0%2C4.2%2C0.7%2C8.3%2C2%2C12.3c0.9%2C2.7%2C3.9%2C4.2%2C6.7%2C3.3c2.7-0.9%2C4.2-3.9%2C3.3-6.7%20c-1.1-3.1-1.6-6.4-1.5-9.7C58.1%2C57.6%2C69.5%2C46%2C83.6%2C45.3c15.7-0.8%2C28.7%2C11.7%2C28.7%2C27.2c0%2C14.5-11.4%2C26.4-25.7%2C27.2%20c0%2C0-5.3%2C0.3-7.9%2C0.7c-1.3%2C0.2-2.3%2C0.4-3%2C0.5c-0.3%2C0.1-0.6-0.2-0.5-0.5l0.9-4.4L81%2C73.4c0.6-2.8-1.2-5.6-4-6.2%20c-2.8-0.6-5.6%2C1.2-6.2%2C4c0%2C0-11.8%2C55-11.9%2C55.6c-0.6%2C2.8%2C1.2%2C5.6%2C4%2C6.2c2.8%2C0.6%2C5.6-1.2%2C6.2-4c0.1-0.6%2C1.7-7.9%2C1.7-7.9%20c1.2-5.6%2C5.8-9.7%2C11.2-10.4c1.2-0.2%2C5.9-0.5%2C5.9-0.5c19.5-1.5%2C34.9-17.8%2C34.9-37.7C122.8%2C51.6%2C105.8%2C34.7%2C85%2C34.7z%20M87.7%2C121.7%20c-3.4-0.7-6.8%2C1.4-7.5%2C4.9c-0.7%2C3.4%2C1.4%2C6.8%2C4.9%2C7.5c3.4%2C0.7%2C6.8-1.4%2C7.5-4.9C93.3%2C125.7%2C91.2%2C122.4%2C87.7%2C121.7z%22%3E%3C%2Fpath%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E' + }, + 'subwallet-js': { + src: 'data:image/svg+xml,%3Csvg%20width%3D%22134%22%20he…E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E', + alt: 'Subwallet Logo' + } +} diff --git a/src/context/LocalDbContext.tsx b/src/context/LocalDbContext.tsx new file mode 100644 index 00000000..b4cbcc8f --- /dev/null +++ b/src/context/LocalDbContext.tsx @@ -0,0 +1,27 @@ +import { INetworkRepository } from '@/domain/repositories/INetworkRepository' +import { LocalStorageNetworkRepository } from '@/infrastructure/LocalStorageNetworkRepository' +import React, { createContext, PropsWithChildren, useContext } from 'react' + +interface DbContext { + networkRepository: INetworkRepository +} + +const networkRepository = new LocalStorageNetworkRepository() + +const DbContext = createContext({ + networkRepository +}) + +export const LocalDbProvider: React.FC = ({ children }) => { + return ( + + {children} + + ) +} + +export const useLocalDbContext = () => useContext(DbContext) diff --git a/src/context/NetworkAccountsContext.tsx b/src/context/NetworkAccountsContext.tsx index 6c6719fe..5eefa42d 100644 --- a/src/context/NetworkAccountsContext.tsx +++ b/src/context/NetworkAccountsContext.tsx @@ -1,129 +1,105 @@ -import React, { createContext, useEffect, useState, useContext } from 'react' -import { ApiPromise, WsProvider } from '@polkadot/api' +import React, { + createContext, + useState, + useContext, + useEffect, + useCallback +} from 'react' +import { ApiPromise } from '@polkadot/api' import jsonrpc from '@polkadot/types/interfaces/jsonrpc' -import { keyring as KeyringUI, Keyring } from '@polkadot/ui-keyring' +import { WalletState, useAllWallets, useWallet } from 'useink' +import { WalletKeys } from '@/constants/wallets' -import { DAPP_CONFIG } from '@/constants/index' -import { WalletConnectionEvents } from '@/domain/DomainEvents' -import { accountsInPossession } from '@/domain/KeyringAccouns' -import { - getChainInfo, - ChainProperties -} from '@/infrastructure/NetworkAccountRepository' +import { ChainProperties } from '@/infrastructure/NetworkAccountRepository' +import { Wallet, WalletAccount } from '@/infrastructure/useink/walletTypes' +import { DEFAULT_CHAIN } from '../constants' +import { useLocalDbContext } from './LocalDbContext' +import { ChainId } from '@/infrastructure/useink/chains' +import { createNotImplementedWarning } from '@/utils/error' +import { WalletConnectionEvents } from '@/domain' type NetworkState = 'DISCONNECTED' | 'CONNECTING' | 'CONNECTED' | 'ERROR' +export const OPTION_FOR_DISCONNECTING = 'disconnect' export interface NetworkAccountsContextState { - currentAccount?: string jsonRpc: typeof jsonrpc - apiStatus: NetworkState api?: ApiPromise apiError?: string - accountStatus: NetworkState // keyring state - keyring?: Keyring chainInfo?: ChainProperties + accountStatus: NetworkState + currentWallet?: WalletState + allWallets?: Wallet[] + currentChain?: ChainId + walletKey?: WalletKeys + accounts?: WalletAccount[] } export const initialState: NetworkAccountsContextState = { jsonRpc: { ...jsonrpc }, - apiStatus: 'DISCONNECTED', accountStatus: 'DISCONNECTED' } -export const NetworkAccountsContext = createContext( - {} as { - state: NetworkAccountsContextState - setCurrentAccount: (account: string) => void - } -) - -// Connecting to the Substrate node -const connect = ( - state: NetworkAccountsContextState, - updateState: React.Dispatch> -) => { - if (state.apiStatus !== 'DISCONNECTED') return - - updateState(prev => ({ ...prev, apiStatus: 'CONNECTING' })) - console.info(`Connecting socket: ${DAPP_CONFIG.providerSocket}`) - - const provider = new WsProvider(DAPP_CONFIG.providerSocket) - const _api = new ApiPromise({ provider, rpc: jsonrpc }) - - // Set listeners for disconnection and reconnection event. - _api.on('connected', () => { - updateState(prev => ({ ...prev, api: _api })) - // `ready` event is not emitted upon reconnection and is checked explicitly here. - _api.isReady.then(async _api => { - const chainInfo = await getChainInfo(_api) - updateState(prev => ({ - ...prev, - apiStatus: 'CONNECTED', - api: _api, - chainInfo - })) - }) - }) - _api.on('ready', () => - updateState(prev => ({ ...prev, apiStatus: 'CONNECTED' })) - ) - _api.on('error', err => - updateState(prev => ({ ...prev, apiStatus: 'ERROR', apiError: err })) - ) +interface NetworkContextProps { + state: NetworkAccountsContextState + isConnected: boolean + accountConnected: WalletAccount | undefined + networkConnected: ChainId + setCurrentAccount: (account: WalletAccount) => void + setCurrentWallet: (wallet: Wallet) => void + setCurrentChain: (chain: ChainId) => void + connect: (walletName: string) => void + disconnectWallet: () => void } -let keyringLoadAll = false - -const loadAccounts = ( - state: NetworkAccountsContextState, - updateState: React.Dispatch> -) => { - const { api, apiStatus, accountStatus: keyringStatus, chainInfo } = state - if ( - apiStatus !== 'CONNECTED' || - keyringLoadAll || - keyringStatus !== 'DISCONNECTED' || - !chainInfo - ) - return - if (!api) { - throw Error('Api providers has an connection error') - } - - keyringLoadAll = true - updateState(prev => ({ ...prev, accountStatus: 'CONNECTING' })) - const { isDevelopment } = chainInfo - - const asyncLoadAccounts = async () => { - try { - const { web3Enable, web3Accounts } = await import( - '@polkadot/extension-dapp' - ) - await web3Enable(DAPP_CONFIG.name) - let allAccounts = await web3Accounts() - allAccounts = allAccounts.map(({ address, meta }) => ({ - address, - meta: { ...meta, name: `${meta.name} (${meta.source})` } - })) - - KeyringUI.loadAll({ isDevelopment }, allAccounts) - const accounts = accountsInPossession(KeyringUI) - const initialAddress = accounts.length > 0 ? accounts[0].address : '' - - updateState(prev => ({ - ...prev, - currentAccount: initialAddress, - accountStatus: 'CONNECTED', - keyring: KeyringUI - })) - } catch (e) { - console.error(e) - updateState(prev => ({ ...prev, accountStatus: 'ERROR' })) - } - } - - asyncLoadAccounts() -} +export const NetworkAccountsContext = createContext({ + state: initialState, + isConnected: false, + accountConnected: undefined, + networkConnected: DEFAULT_CHAIN, + setCurrentAccount: () => createNotImplementedWarning('setCurrentAccount'), + setCurrentWallet: () => createNotImplementedWarning('setCurrentWallet'), + setCurrentChain: () => createNotImplementedWarning('setCurrentChain'), + connect: () => createNotImplementedWarning('connect'), + disconnectWallet: () => createNotImplementedWarning('disconnectWallet') +}) + +// const connectApi = async ( +// state: NetworkAccountsContextState, +// updateState: React.Dispatch< +// React.SetStateAction +// >, +// wallet: Wallet +// ) => { +// if (state.accountStatus !== 'DISCONNECTED') return +// const defaultRpc = getChain(state.currentChain)?.rpcs[0] +// console.log(defaultRpc) +// console.info(`Connecting socket: ${DAPP_CONFIG.providerSocket}`) +// const provider = new WsProvider(DAPP_CONFIG.providerSocket) +// const _api = new ApiPromise({ provider, rpc: jsonrpc }) + +// _api.on('connected', () => { +// updateState(prev => ({ ...prev, api: _api })) +// _api.isReady.then(async _api => { +// const chainInfo = await getChainInfo(_api) +// const accounts = await wallet.getAccounts() +// updateState(prev => ({ +// ...prev, +// accountStatus: 'CONNECTED', +// // Select the fist account from the wallet by default +// currentAccount: accounts[0].address, +// walletKey: wallet.extensionName, +// api: _api, +// chainInfo +// })) +// }) +// }) +// _api.on('ready', () => +// updateState(prev => ({ ...prev, accountStatus: 'CONNECTED' })) +// ) +// _api.on('error', err => +// updateState(prev => ({ ...prev, accountStatus: 'ERROR', apiError: err })) +// ) +// } export function NetworkAccountsContextProvider({ children @@ -131,30 +107,84 @@ export function NetworkAccountsContextProvider({ children: React.ReactNode }) { const [state, setState] = useState(initialState) - connect(state, setState) + const allWallets = useAllWallets() + const { account, accounts, connect, disconnect, isConnected, setAccount } = + useWallet() + const { networkRepository } = useLocalDbContext() + const [networkId, setNetworkId] = useState(DEFAULT_CHAIN) + + const loadNetworkConnected = useCallback(() => { + const networkSelected = networkRepository.getNetworkSelected() + + setNetworkId(networkSelected.id) + }, [networkRepository]) + + useEffect(() => { + loadNetworkConnected() + }, [loadNetworkConnected]) useEffect(() => { - document.addEventListener(WalletConnectionEvents.walletConnectInit, () => - loadAccounts(state, setState) + document.addEventListener( + WalletConnectionEvents.networkChanged, + loadNetworkConnected ) return () => { document.removeEventListener( - WalletConnectionEvents.walletConnectInit, - () => loadAccounts(state, setState) + WalletConnectionEvents.networkChanged, + loadNetworkConnected ) } - }, [state]) + }, [loadNetworkConnected]) - function setCurrentAccount(account: string) { - setState(prev => ({ ...prev, currentAccount: account })) - document.dispatchEvent( - new CustomEvent(WalletConnectionEvents.changeAccountAddress) - ) + useEffect(() => { + setState(prev => ({ + ...prev, + allWallets + })) + }, [allWallets]) + + useEffect(() => { + setState(prev => ({ + ...prev, + accounts + })) + }, [accounts]) + + const setCurrentWallet = async (wallet: Wallet) => { + setState(prev => ({ + ...prev, + accountStatus: 'CONNECTING', + currentChain: networkRepository.getNetworkSelected().id + })) + connect(wallet.extensionName) } + const setCurrentChain = useCallback( + (chainId: ChainId) => { + networkRepository.setNetworkSelected(chainId) + + document.dispatchEvent( + new CustomEvent(WalletConnectionEvents.networkChanged) + ) + }, + [networkRepository] + ) + return ( - + {children} ) diff --git a/src/context/StorageContractContext.tsx b/src/context/StorageContractContext.tsx index 5447be47..cba3f419 100644 --- a/src/context/StorageContractContext.tsx +++ b/src/context/StorageContractContext.tsx @@ -28,15 +28,13 @@ export function StorageContractsProvider({ repository: StorageContractRepository }) { const [contracts, setContracts] = useState([]) - const { - state: { currentAccount } - } = useNetworkAccountsContext() + const { accountConnected } = useNetworkAccountsContext() const loadContractRepository = useCallback(() => { - if (!currentAccount) return + if (!accountConnected?.address) return - setContracts(repository.searchBy(currentAccount)) - }, [currentAccount, repository]) + setContracts(repository.searchBy(accountConnected.address)) + }, [accountConnected?.address, repository]) useEffect(() => { loadContractRepository() diff --git a/src/domain/CompileContractRepository.ts b/src/domain/CompileContractRepository.ts index ae9d4ae3..5556451e 100644 --- a/src/domain/CompileContractRepository.ts +++ b/src/domain/CompileContractRepository.ts @@ -1,5 +1,5 @@ import { ContractCompiled } from '@/infrastructure' -import { CompileContractBody } from '@/infrastructure/ApiCompileContractRepository' +import { CompileContractBody } from '@/infrastructure/backendApi/ApiCompileContractRepository' export interface CompileContractRepository { create: (compileContract: CompileContractBody) => Promise diff --git a/src/domain/DomainEvents.ts b/src/domain/DomainEvents.ts index ec042d2e..57c2f9c2 100644 --- a/src/domain/DomainEvents.ts +++ b/src/domain/DomainEvents.ts @@ -1,6 +1,7 @@ export const enum WalletConnectionEvents { walletConnectInit = 'walletConnectInit', - changeAccountAddress = 'changeAccountAddress' + changeAccountAddress = 'changeAccountAddress', + networkChanged = 'networkChanged' } export const enum AppNotificationEvents { diff --git a/src/domain/repositories/INetworkRepository.ts b/src/domain/repositories/INetworkRepository.ts new file mode 100644 index 00000000..2056a446 --- /dev/null +++ b/src/domain/repositories/INetworkRepository.ts @@ -0,0 +1,6 @@ +import { ChainExtended } from '@/types' + +export interface INetworkRepository { + getNetworkSelected(): ChainExtended + setNetworkSelected(chainId: string): void +} diff --git a/src/hooks/useCompileContract.ts b/src/hooks/useCompileContract.ts index 17cf9434..7c858bf6 100644 --- a/src/hooks/useCompileContract.ts +++ b/src/hooks/useCompileContract.ts @@ -3,7 +3,7 @@ import { useCallback, useState } from 'react' import { ApiCompileContractRepository, CompileContractBody -} from '@/infrastructure/ApiCompileContractRepository' +} from '@/infrastructure/backendApi/ApiCompileContractRepository' import { GetServiceData } from '@/types' import { TokenType, SecurityOfToken } from '@/domain' import { BACKEND_API } from '@/constants/index' diff --git a/src/hooks/useDelay.ts b/src/hooks/useDelay.ts new file mode 100644 index 00000000..3a552b52 --- /dev/null +++ b/src/hooks/useDelay.ts @@ -0,0 +1,18 @@ +import { useEffect, useState } from 'react' + +const DEFAULT_MS = 500 // 0.5 seg + +export function useDelay(delay: number = DEFAULT_MS): boolean { + const [isDelayFinished, setIsDelayFinished] = useState(false) + + useEffect(() => { + const timer = setTimeout(() => { + setIsDelayFinished(true) + }, delay) + + // Clean timer if component is unmounted + return () => clearTimeout(timer) + }, [delay]) + + return isDelayFinished +} diff --git a/src/hooks/useDeployContract.ts b/src/hooks/useDeployContract.ts index b85163e2..8689b1f9 100644 --- a/src/hooks/useDeployContract.ts +++ b/src/hooks/useDeployContract.ts @@ -19,6 +19,7 @@ import { transformUserInput } from '@/infrastructure/contractDryRun' import { useReportError } from './useReportError' +import { useNetworkApi } from '@/hooks/useNetworkApi' type ReturnValue = GetServiceData @@ -114,9 +115,9 @@ export const useDeployContract = (): ReturnValue & { const [error, setError] = useState() const { reportErrorWithToast } = useReportError() const { addContractToStorage } = useStorageContractsContext() - const { - state: { api, currentAccount } - } = useNetworkAccountsContext() + const { accountConnected } = useNetworkAccountsContext() + const currentAccount = accountConnected?.address + const { apiPromise: api } = useNetworkApi() const deployContract = useCallback( async ({ diff --git a/src/hooks/useNetworkApi.ts b/src/hooks/useNetworkApi.ts new file mode 100644 index 00000000..99f13770 --- /dev/null +++ b/src/hooks/useNetworkApi.ts @@ -0,0 +1,15 @@ +import { ApiPromise } from '@polkadot/api' +import { useApi } from 'useink' + +import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' + +export interface UseNetworkApi { + apiPromise: ApiPromise +} + +export function useNetworkApi() { + const { networkConnected } = useNetworkAccountsContext() + const api = useApi(networkConnected) + + return { apiPromise: api?.api, network: networkConnected } +} diff --git a/src/hooks/useRecentlyClicked.ts b/src/hooks/useRecentlyClicked.ts index 91e13a6a..bc6e817d 100644 --- a/src/hooks/useRecentlyClicked.ts +++ b/src/hooks/useRecentlyClicked.ts @@ -1,9 +1,14 @@ -import { useState, useRef, useEffect } from 'react' +import { useState, useRef, useEffect, MutableRefObject } from 'react' type RefType = HTMLButtonElement | null const ONE_SECOND = 1000 // ms -export function useRecentlyClicked(waitTime = ONE_SECOND) { +interface UseRecentlyClicked { + ref: MutableRefObject + recentlyClicked: boolean +} + +export function useRecentlyClicked(waitTime = ONE_SECOND): UseRecentlyClicked { const [clicked, setClicked] = useState(false) const ref = useRef(null) diff --git a/src/infrastructure/LocalStorageNetworkRepository.ts b/src/infrastructure/LocalStorageNetworkRepository.ts new file mode 100644 index 00000000..c4284b4c --- /dev/null +++ b/src/infrastructure/LocalStorageNetworkRepository.ts @@ -0,0 +1,28 @@ +import { + getLocalStorageState, + setLocalStorageState +} from '@/utils/localStorage' +import { ChainId } from '@/infrastructure/useink/chains/types' +import { getChain } from '@/constants/chains' +import { ChainExtended } from '@/types' +import { DEFAULT_CHAIN } from '../constants' +import { INetworkRepository } from '@/domain/repositories/INetworkRepository' + +type ReturnChainId = ChainId + +export class LocalStorageNetworkRepository implements INetworkRepository { + private readonly storageKey = 'networkSelected' + + getNetworkSelected(): ChainExtended { + const result = getLocalStorageState( + this.storageKey, + DEFAULT_CHAIN + ) as ChainId + + return getChain(result) as ChainExtended + } + + setNetworkSelected(networkId: ReturnChainId): void { + setLocalStorageState(this.storageKey, networkId) + } +} diff --git a/src/infrastructure/ApiCompileContractRepository.ts b/src/infrastructure/backendApi/ApiCompileContractRepository.ts similarity index 100% rename from src/infrastructure/ApiCompileContractRepository.ts rename to src/infrastructure/backendApi/ApiCompileContractRepository.ts diff --git a/src/infrastructure/useink/chains/data/chaindata.ts b/src/infrastructure/useink/chains/data/chaindata.ts new file mode 100644 index 00000000..593f1920 --- /dev/null +++ b/src/infrastructure/useink/chains/data/chaindata.ts @@ -0,0 +1,103 @@ +import { IChain } from './types' + +export const Astar: IChain<'astar'> = { + id: 'astar', + name: 'Astar', + account: '*25519', + subscanUrl: 'https://astar.subscan.io/', + chainspecQrUrl: 'https://metadata.novasama.io/qr/astar_specs.png', + latestMetadataQrUrl: + 'https://metadata.novasama.io/qr/astar_metadata_latest.apng', + rpcs: [ + 'wss://rpc.astar.network', + 'wss://astar.public.blastapi.io', + 'wss://astar-rpc.dwellir.com', + 'wss://astar.api.onfinality.io/public-ws', + 'wss://astar.public.curie.radiumblock.co/ws', + 'wss://public-rpc.pinknode.io/astar', + 'wss://1rpc.io/astr' + ], + paraId: 2006, + relay: { id: 'polkadot' }, + balanceModuleConfigs: { + 'substrate-assets': { + tokens: [ + { assetId: '4294969280', symbol: 'USDT', coingeckoId: 'tether' }, + { + assetId: '18446744073709551616', + symbol: 'ACA', + coingeckoId: 'acala' + }, + { + assetId: '18446744073709551617', + symbol: 'AUSD', + coingeckoId: 'acala-dollar' + }, + { + assetId: '18446744073709551618', + symbol: 'LDOT', + coingeckoId: 'liquid-staking-dot' + }, + { + assetId: '18446744073709551619', + symbol: 'GLMR', + coingeckoId: 'moonbeam' + }, + { + assetId: '18446744073709551620', + symbol: 'IBTC', + coingeckoId: 'interbtc' + }, + { + assetId: '18446744073709551621', + symbol: 'INTR', + coingeckoId: 'interlay' + }, + { assetId: '18446744073709551622', symbol: 'PHA', coingeckoId: 'pha' }, + { + assetId: '18446744073709551623', + symbol: 'BNC', + coingeckoId: 'bifrost-native-coin' + }, + { assetId: '18446744073709551624', symbol: 'VDOT' }, + { assetId: '18446744073709551625', symbol: 'CLV' }, + { assetId: '18446744073709551626', symbol: 'VSDOT' }, + { + assetId: '18446744073709551627', + symbol: 'RING', + coingeckoId: 'darwinia-network-native-token' + }, + { + assetId: '18446744073709551628', + symbol: 'EQ', + coingeckoId: 'equilibrium-token' + }, + { assetId: '18446744073709551629', symbol: 'EQD' }, + { + assetId: '340282366920938463463374607431768211455', + symbol: 'DOT', + coingeckoId: 'polkadot' + } + ] + } + } +} as const + +export const ShidenKusama: IChain<'shiden-kusama'> = { + id: 'shiden-kusama', + name: 'Shiden', + account: '*25519', + subscanUrl: 'https://shiden.subscan.io/', + chainspecQrUrl: 'https://metadata.novasama.io/qr/shiden_specs.png', + latestMetadataQrUrl: + 'https://metadata.novasama.io/qr/shiden_metadata_latest.apng', + rpcs: [ + 'wss://rpc.shiden.astar.network', + 'wss://shiden.public.blastapi.io', + 'wss://shiden-rpc.dwellir.com', + 'wss://shiden.api.onfinality.io/public-ws', + 'wss://public-rpc.pinknode.io/shiden' + ], + paraId: 2007, + relay: { id: 'kusama' } +} as const diff --git a/src/infrastructure/useink/chains/data/index.ts b/src/infrastructure/useink/chains/data/index.ts new file mode 100644 index 00000000..cda46bb1 --- /dev/null +++ b/src/infrastructure/useink/chains/data/index.ts @@ -0,0 +1,2 @@ +export * from './chaindata' +export * from './testnet-chaindata' diff --git a/src/infrastructure/useink/chains/data/testnet-chaindata.ts b/src/infrastructure/useink/chains/data/testnet-chaindata.ts new file mode 100644 index 00000000..2a4c4e9a --- /dev/null +++ b/src/infrastructure/useink/chains/data/testnet-chaindata.ts @@ -0,0 +1,18 @@ +import { IChain } from './types' + +export const RococoContractsTestnet: IChain<'rococo-contracts-testnet'> = { + id: 'rococo-contracts-testnet', + name: 'Contracts', + account: '*25519', + rpcs: ['wss://rococo-contracts-rpc.polkadot.io'], + paraId: 1002, + relay: { id: 'rococo-testnet' } +} as const + +export const ShibuyaTestnet: IChain<'shibuya-testnet'> = { + id: 'shibuya-testnet', + name: 'Shibuya', + account: '*25519', + subscanUrl: 'https://shibuya.subscan.io/', + rpcs: ['wss://rpc.shibuya.astar.network', 'wss://shibuya-rpc.dwellir.com'] +} as const diff --git a/src/infrastructure/useink/chains/data/types.ts b/src/infrastructure/useink/chains/data/types.ts new file mode 100644 index 00000000..f9451c01 --- /dev/null +++ b/src/infrastructure/useink/chains/data/types.ts @@ -0,0 +1,44 @@ +export type Account = '*25519' | 'secp256k1' | 'Sr25519' + +export type JsonString = string + +export interface Token { + symbol: string + decimals: number + // existentialDeposit is the minimum amount an account must hold to stay alive. + // Balances held below this amount will be removed from storage + existentialDeposit: string + // onChainId is the ID for a token in the pallet + onChainId: JsonString | number + coingeckoId?: string +} + +export interface TokenAsset { + assetId: string | number + symbol: string + coingeckoId?: string +} + +export type RpcUrl = `ws://${string}` | `wss://${string}` + +export interface IChain { + id: T + name: string + account: Account + subscanUrl?: string + overrideNativeTokenId?: string + chainspecQrUrl?: string + latestMetadataQrUrl?: string + rpcs: readonly RpcUrl[] + coingeckoId?: string | null + paraId?: number + relay?: { + id: string + } + balanceModuleConfigs?: { + [k: string]: { + disable?: boolean + tokens?: readonly (Token | TokenAsset)[] + } + } +} diff --git a/src/infrastructure/useink/chains/index.ts b/src/infrastructure/useink/chains/index.ts new file mode 100644 index 00000000..f5e31d15 --- /dev/null +++ b/src/infrastructure/useink/chains/index.ts @@ -0,0 +1,2 @@ +export * from './data/index' +export * from './types' diff --git a/src/infrastructure/useink/chains/types.ts b/src/infrastructure/useink/chains/types.ts new file mode 100644 index 00000000..14e421d8 --- /dev/null +++ b/src/infrastructure/useink/chains/types.ts @@ -0,0 +1,13 @@ +import * as AllChains from './data/chaindata' +import * as AllTestnets from './data/testnet-chaindata' + +type TestnetNetworkName = keyof typeof AllTestnets +export type TestnetChain = (typeof AllTestnets)[TestnetNetworkName] +export type TestnetId = TestnetChain['id'] + +type ProductionNetworkName = keyof typeof AllChains +export type ProductionChain = (typeof AllChains)[ProductionNetworkName] +export type ProductionChainId = ProductionChain['id'] + +export type ChainId = ProductionChainId | TestnetId +export type Chain = ProductionChain | TestnetChain diff --git a/src/infrastructure/useink/walletTypes.ts b/src/infrastructure/useink/walletTypes.ts new file mode 100644 index 00000000..b2d5085d --- /dev/null +++ b/src/infrastructure/useink/walletTypes.ts @@ -0,0 +1,66 @@ +export type SubscriptionFn = ( + accounts: WalletAccount[] | undefined +) => void | Promise + +export interface WalletLogoProps { + // Logo url + src: string + // Alt for the Logo url + alt: string +} + +export interface WalletAccount { + address: string + source: string + name?: string + wallet?: Wallet + signer?: unknown +} + +interface WalletData { + // The name of the wallet extension. Should match `WalletAccount.source` + extensionName: string + // Display name for the wallet extension + title: string + // Message to display if wallet extension is not installed + noExtensionMessage?: string + // The URL to install the wallet extension + installUrl: string + // The wallet logo + logo: WalletLogoProps +} + +interface WalletExtension { + installed: boolean | undefined + + // The raw extension object which will have everything a dapp developer needs. + // Refer to a specific wallet's extension documentation + // eslint-disable-next-line @typescript-eslint/no-explicit-any + extension: any + + // The raw signer object for convenience. Usually the implementer can derive this from the extension object. + // Refer to a specific wallet's extension documentation + // eslint-disable-next-line @typescript-eslint/no-explicit-any + signer: any +} + +interface Signer { + // Sign function + sign?: (address: string, payload: string) => unknown +} + +interface Connector { + enable: (dappName: string) => unknown + + // Get accounts function + getAccounts: (anyType?: boolean) => Promise + + // The subscribe to accounts function + subscribeAccounts: (callback: SubscriptionFn) => unknown +} + +export interface Wallet + extends WalletData, + WalletExtension, + Connector, + Signer {} diff --git a/src/types/arrays.ts b/src/types/arrays.ts new file mode 100644 index 00000000..af9ceb7a --- /dev/null +++ b/src/types/arrays.ts @@ -0,0 +1 @@ +export type ArrayOneOrMore = { 0: T } & Array diff --git a/src/types/chain.ts b/src/types/chain.ts new file mode 100644 index 00000000..e3a1e67b --- /dev/null +++ b/src/types/chain.ts @@ -0,0 +1,8 @@ +import { Chain } from '@/infrastructure/useink/chains' + +export type ChainExtended = Chain & { + logo: { + src: string + alt: string + } +} diff --git a/src/types/index.ts b/src/types/index.ts index f0f4def5..bbdbcbe7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,2 +1,4 @@ export * from './mui' export * from './services' +export * from './arrays' +export * from './chain' diff --git a/src/utils/error.ts b/src/utils/error.ts index d1c60bd6..f6e2dacb 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -26,3 +26,12 @@ function toErrorWithMessage(maybeError: unknown): ErrorWithMessage { export function getErrorMessage(error: unknown) { return toErrorWithMessage(error).message } + +/** Creates a console error message to warn that a function is not implemented. + * + * @example + * const myFunction = () => createNotImplementedWarning('myFunction'); + */ +export const createNotImplementedWarning = (methodName: string): void => { + console.error(`${methodName} is not implemented`) +} diff --git a/src/utils/localStorage.ts b/src/utils/localStorage.ts index afc0064e..2ed4966a 100644 --- a/src/utils/localStorage.ts +++ b/src/utils/localStorage.ts @@ -1,3 +1,5 @@ +const isString = (value: unknown) => typeof value === 'string' + export const getLocalStorageState = ( nameItem: string, defaultValue: T @@ -8,7 +10,7 @@ export const getLocalStorageState = ( const storedData: string | null = window.localStorage.getItem(nameItem) if (storedData) { - state = { ...JSON.parse(storedData) } + state = isString(storedData) ? storedData : { ...JSON.parse(storedData) } } else { state = defaultValue } @@ -19,6 +21,11 @@ export const getLocalStorageState = ( } } -export const setLocalStorageState = (nameItem: string, value: T) => { - window.localStorage.setItem(nameItem, JSON.stringify(value)) +export const setLocalStorageState = ( + nameItem: string, + value: T +) => { + const _value = isString(value) ? (value as string) : JSON.stringify(value) + + window.localStorage.setItem(nameItem, _value) } diff --git a/src/view/components/ModalWallet/index.tsx b/src/view/components/ModalWallet/index.tsx new file mode 100644 index 00000000..2e50174a --- /dev/null +++ b/src/view/components/ModalWallet/index.tsx @@ -0,0 +1,112 @@ +import React from 'react' +import { + Avatar, + Box, + Chip, + IconButton, + ListItem, + ListItemIcon, + ListItemText, + Modal +} from '@mui/material' +import CloseIcon from '@mui/icons-material/Close' +import { Wallet } from '@/infrastructure/useink/walletTypes' +import { + ModalStyled, + ModalStyledDivider, + ModalStyledList, + ModalStyledListItem, + ModalTypography +} from './styled' + +type Props = { + open: boolean + handleClose: () => void + wallets: Wallet[] + setCurrentWallet: (wallet: Wallet) => void +} +export function ModalWallet({ + open, + handleClose, + wallets, + setCurrentWallet +}: Props) { + const walletInstalled = wallets.filter(wallet => wallet.installed) + const walletNotInstalled = wallets.filter(wallet => !wallet.installed) + return ( + + + + Connect your wallet + + theme.palette.grey[500] + }} + > + + + + + {walletInstalled.map(w => ( + + <> + { + setCurrentWallet(w) + handleClose() + }} + > + + + + + + + + + ))} + + + + + + {walletNotInstalled.map(w => ( + + <> + { + setCurrentWallet(w) + handleClose() + }} + > + + + + + + + + + ))} + + + + + ) +} diff --git a/src/view/components/ModalWallet/styled.tsx b/src/view/components/ModalWallet/styled.tsx new file mode 100644 index 00000000..1bbb8169 --- /dev/null +++ b/src/view/components/ModalWallet/styled.tsx @@ -0,0 +1,62 @@ +import { + styled, + ListItemButton, + ListItemButtonProps, + Box, + BoxProps, + Typography, + TypographyProps, + Divider, + List, + ListProps +} from '@mui/material' + +export const ModalStyledList = styled(List)(() => ({ + margin: '0 auto', + width: '22rem', + + '&:hover': { + borderRadius: '1.8rem' + } +})) + +export const ModalStyledListItem = styled(ListItemButton)( + () => ({ + borderRadius: '1.8rem', + + '&:hover': { + borderRadius: '1.8rem', + backgroundColor: 'rgba(98, 98, 98, 0.26)' + } + }) +) + +export const ModalTypography = styled(Typography)(() => ({ + textAlign: 'center', + fontWeight: 'normal', + marginTop: '1rem', + marginBottom: '1.5rem' +})) + +export const ModalStyledDivider = styled(Divider)(() => ({ + margin: '1rem 0', + borderColor: 'rgba(255, 255, 255, 0.1)' +})) + +export const ModalStyled = styled(Box)(({}) => ({ + position: 'absolute' as const, + top: '50%', + left: '50%', + transform: 'translate(-50%, -50%)', + width: 680, + height: 500, + textAlign: 'justify', + backgroundColor: 'rgba(0, 0, 0, 1)', + border: '2px solid #000', + borderRadius: '2rem', + padding: '3rem 3rem 2.5rem 3rem', + boxShadow: '0px 4px 50px 0px rgba(255, 255, 255, 0.1);', + color: 'white', + display: 'flex', + flexDirection: 'column' +})) diff --git a/src/view/components/WalletConnectButton/AccountSelect/index.tsx b/src/view/components/WalletConnectButton/AccountSelect/index.tsx new file mode 100644 index 00000000..35f3d94f --- /dev/null +++ b/src/view/components/WalletConnectButton/AccountSelect/index.tsx @@ -0,0 +1,128 @@ +import { SelectChangeEvent, Stack, Avatar } from '@mui/material' +import { shortNameLonger, truncateAddress } from '@/utils/formatString' +import CircleIcon from '@mui/icons-material/Circle' +import PowerOffIcon from '@mui/icons-material/PowerOff' +import { OPTION_FOR_DISCONNECTING } from '@/context/NetworkAccountsContext' +import { + WalletAccount, + WalletLogoProps +} from '@/infrastructure/useink/walletTypes' +import { StyledMenuItem, StyledSelect } from './styled' + +interface AccountSelectProps { + accounts: WalletAccount[] | undefined + accountConnected: WalletAccount | undefined + setAccount: (account: WalletAccount) => void + disconnectWallet: () => void +} + +// {/* */} +export function AccountSelect({ + accounts, + accountConnected, + setAccount, + disconnectWallet +}: AccountSelectProps) { + const _handleChange = (event: SelectChangeEvent) => { + const address = event.target.value as string + + if (address === OPTION_FOR_DISCONNECTING) { + disconnectWallet() + return + } + const newAccount = accounts?.find(element => element.address === address) + if (!newAccount) { + console.error( + `Theres not an account with this address ${event.target.value}` + ) + return + } + setAccount(newAccount) + } + + const currentAccount = accountConnected?.address + + if (!accounts) + return ( + + ) + + if (!currentAccount) + return ( + + ) + + const allAccounts = [ + ...accounts, + { name: OPTION_FOR_DISCONNECTING, address: OPTION_FOR_DISCONNECTING } + ] + + return ( + + {allAccounts.map(a => ( + + {a.name !== OPTION_FOR_DISCONNECTING && ( + + + + {shortNameLonger(a.name as string)} +

{truncateAddress(a.address)}

+
+ +
+ )} + + {a.name === OPTION_FOR_DISCONNECTING && ( + <> + + + +

+ Disconect Wallet +

+
+
+ + )} +
+ ))} +
+ ) +} diff --git a/src/view/components/WalletConnectButton/AccountSelect/styled.ts b/src/view/components/WalletConnectButton/AccountSelect/styled.ts new file mode 100644 index 00000000..16b92b0a --- /dev/null +++ b/src/view/components/WalletConnectButton/AccountSelect/styled.ts @@ -0,0 +1,60 @@ +import { + MenuItem, + MenuItemProps, + Select, + SelectProps, + Typography, + TypographyProps, + styled +} from '@mui/material' + +export const StyledSelect = styled(Select)(() => ({ + color: 'white', + display: 'flex', + margin: '0.5rem 0', + padding: '0', + height: '2.88em', + borderRadius: '0.5rem', + + '& fieldset': { + top: '0' + }, + + '& span': { + fontSize: '0.8rem', + marginLeft: '1rem' + }, + + '& p': { + fontSize: '0.8rem', + marginLeft: '1rem', + fontWeight: '600', + lineHeight: '12px' + }, + + '& legend': { + display: 'none' + } +})) + +export const StyledMenuItem = styled(MenuItem)(() => ({ + color: 'white', + + '& span': { + fontSize: '0.8rem', + marginLeft: '1rem' + }, + + '& p': { + fontSize: '0.8rem', + marginLeft: '1rem', + fontWeight: '600', + lineHeight: '12px' + } +})) + +export const StyledTypography = styled(Typography)(() => ({ + marginLeft: '0', + height: '10px', + fontSize: '1rem' +})) diff --git a/src/view/components/WalletConnectButton/AccountsSelect.tsx b/src/view/components/WalletConnectButton/AccountsSelect.tsx deleted file mode 100644 index d12336db..00000000 --- a/src/view/components/WalletConnectButton/AccountsSelect.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - MenuItem, - MenuItemProps, - Select, - SelectProps, - SelectChangeEvent, - Stack, - styled -} from '@mui/material' -import { shortNameLonger, truncateAddress } from '@/utils/formatString' -import { KeyringAccount } from 'src/domain/KeyringAccouns' -import { AvatarAccount } from './AvatarAccount' - -const StyledSelect = styled(Select)(() => ({ - color: 'white', - display: 'flex', - margin: '0.5rem 0', - padding: '0', - height: '2.88em', - borderRadius: '0.5rem', - - '& fieldset': { - top: '0' - }, - - '& span': { - fontSize: '0.8rem', - marginLeft: '1rem' - }, - - '& p': { - fontSize: '0.8rem', - marginLeft: '1rem', - fontWeight: '600', - lineHeight: '12px' - }, - - '& legend': { - display: 'none' - } -})) - -const StyledMenuItem = styled(MenuItem)(() => ({ - color: 'white', - - '& span': { - fontSize: '0.8rem', - marginLeft: '1rem' - }, - - '& p': { - fontSize: '0.8rem', - marginLeft: '1rem', - fontWeight: '600', - lineHeight: '12px' - } -})) - -export function AccountSelect({ - accounts, - currentAccount, - onChange -}: { - accounts: KeyringAccount[] - currentAccount: string - onChange: (account: string) => void -}) { - const _handleChange = (event: SelectChangeEvent) => { - onChange(event.target.value as string) - } - - return ( - - {accounts.map(a => ( - - - - - {shortNameLonger(a.label)} -

{truncateAddress(a.address)}

-
-
-
- ))} -
- ) -} diff --git a/src/view/components/WalletConnectButton/NetworkSelect.tsx b/src/view/components/WalletConnectButton/NetworkSelect.tsx new file mode 100644 index 00000000..e231d92b --- /dev/null +++ b/src/view/components/WalletConnectButton/NetworkSelect.tsx @@ -0,0 +1,94 @@ +import { + MenuItem, + MenuItemProps, + Select, + SelectProps, + SelectChangeEvent, + Stack, + styled, + Avatar +} from '@mui/material' +import { CHAINS_ALLOWED, getChain } from '@/constants/chains' +import { ChainId } from '@/infrastructure/useink/chains/types' + +const StyledSelect = styled(Select)(() => ({ + color: 'white', + padding: '0', + margin: '0.5rem 0.5rem', + borderRadius: '0.5rem', + width: '202px', + height: '2.88em', + display: 'flex', + + '& fieldset': { + top: '0' + }, + + '& p': { + marginLeft: '0.5rem', + paddingTop: '0.5rem' + }, + + '& legend': { + display: 'none' + }, + + '& img': { + width: 'auto', + height: 'auto' + } +})) + +const StyledMenuItem = styled(MenuItem)(() => ({ + color: 'white', + '& p': { + marginLeft: '1rem', + paddingTop: '0.5rem' + }, + '& img': { + width: 'auto', + height: 'auto', + fontWeight: '600' + } +})) + +export function NetworkSelect({ + currentChain, + onChange +}: { + currentChain: ChainId + onChange: (chain: ChainId) => void +}) { + const chain = getChain(currentChain) + + const _handleChangeChain = (event: SelectChangeEvent) => { + const chainId = event.target.value as ChainId + onChange(chainId) + } + + return ( + <> + + {CHAINS_ALLOWED.map(option => ( + + + {' '} + +

{option.name}

+
+
+
+ ))} +
+ + ) +} diff --git a/src/view/components/WalletConnectButton/index.tsx b/src/view/components/WalletConnectButton/index.tsx index e9a0414b..a5ae19f9 100644 --- a/src/view/components/WalletConnectButton/index.tsx +++ b/src/view/components/WalletConnectButton/index.tsx @@ -4,59 +4,82 @@ import WarningIcon from '@mui/icons-material/Warning' import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' import { StyledButton, MyButtonProps } from '../Button' -import { WalletConnectionEvents } from 'src/domain/DomainEvents' -import { ModalMessage } from '@/components' -import { AccountSelect } from './AccountsSelect' -import { accountsInPossession } from 'src/domain/KeyringAccouns' -import { useOnceWhen } from 'src/hooks/useOnceWhen' +import { AccountSelect } from './AccountSelect' +import { ModalWallet } from '../ModalWallet' +import { Box } from '@mui/material' +import { NetworkSelect } from './NetworkSelect' +import CircleIcon from '@mui/icons-material/Circle' +import { WALLET_IMG_DETAILS } from '@/constants/wallets' +import { useRecentlyClicked } from '@/hooks/useRecentlyClicked' +import { useDelay } from '@/hooks/useDelay' export const ButtonConnection = styled(StyledButton)(() => ({ fontSize: '1rem', height: '2.5rem', - borderRadius: '0.5rem', - margin: '0.5rem 0' + borderRadius: '1.5rem', + margin: '0.5rem 0', + padding: '1.3rem', + textTransform: 'none' })) export const WalletConnectButton = () => { const { - state: { apiStatus, accountStatus, currentAccount, keyring }, - setCurrentAccount + state: { accountStatus, walletKey, allWallets, accounts }, + isConnected, + disconnectWallet, + accountConnected, + networkConnected, + setCurrentAccount, + setCurrentWallet, + setCurrentChain } = useNetworkAccountsContext() - const isLoading = apiStatus === 'CONNECTING' || accountStatus === 'CONNECTING' + const isDelayFinished = useDelay() const [openModal, setOpenModal] = useState(false) - const noAccounts = - apiStatus === 'CONNECTED' && - accountStatus === 'CONNECTED' && - !currentAccount - useOnceWhen({ - condition: noAccounts, - callback: () => setOpenModal(true) - }) - - const dispatchConnect = () => { - document.dispatchEvent( - new CustomEvent(WalletConnectionEvents.walletConnectInit) - ) - } + const noAccounts = accountStatus === 'CONNECTED' && accounts?.length === 0 + const { ref: buttonRef, recentlyClicked } = useRecentlyClicked() + const isLoading = recentlyClicked || !isDelayFinished + // console.log('__isConnected', isConnected, accountConnected) return ( <> - {accountStatus === 'DISCONNECTED' || accountStatus === 'CONNECTING' ? ( + {!isConnected || isLoading ? ( setOpenModal(true)} > - Connect + Connect your wallet{' '} + ) : ( - keyring && - currentAccount && ( - + accountConnected && ( + + {accountConnected && networkConnected && ( + + )} + + ) + ) )} @@ -69,10 +92,15 @@ export const WalletConnectButton = () => { No accounts )} - setOpenModal(!openModal)} - /> + + {allWallets && ( + setOpenModal(!openModal)} + wallets={allWallets} + setCurrentWallet={setCurrentWallet} + /> + )} ) } diff --git a/src/view/wizardView/Step2Compile/index.tsx b/src/view/wizardView/Step2Compile/index.tsx index c0b4481b..0327922d 100644 --- a/src/view/wizardView/Step2Compile/index.tsx +++ b/src/view/wizardView/Step2Compile/index.tsx @@ -17,9 +17,8 @@ const StyledCopyBlock = styled(Box)(() => ({ export default function Step2Compile({ tokenType }: { tokenType: TokenType }) { const { handleBack, handleNext, dataForm, setDataForm } = useStepsSCWizard() - const { - state: { currentAccount } - } = useNetworkAccountsContext() + const { accountConnected } = useNetworkAccountsContext() + const currentAccount = accountConnected?.address const isWalletConnected = useMemo( () => isValidAddress(currentAccount), [currentAccount] diff --git a/src/view/wizardView/Step3Deploy/index.tsx b/src/view/wizardView/Step3Deploy/index.tsx index d0abc04c..0eed3207 100755 --- a/src/view/wizardView/Step3Deploy/index.tsx +++ b/src/view/wizardView/Step3Deploy/index.tsx @@ -34,9 +34,7 @@ export default function Step3Deploy({ constructorFields?: ControlsToken<'Constructor'> onDeployContract: (deployedContract: ContractDeployed) => void }) { - const { - state: { chainInfo } - } = useNetworkAccountsContext() + const { networkConnected } = useNetworkAccountsContext() const { handleBack, handleNext, dataForm } = useStepsSCWizard() const [contractCompiled, setContractCompiled] = useState< ContractResponse | undefined @@ -103,7 +101,7 @@ export default function Step3Deploy({ const _handleDeploy = async ( constructorParams: ContractConstructorDataForm ) => { - if (!contractCompiled || !chainInfo) return + if (!contractCompiled || !networkConnected) return const result = await deployContract({ wasm: contractCompiled.wasm, @@ -111,7 +109,7 @@ export default function Step3Deploy({ argsForm: constructorParams, code_id: contractCompiled.code_id, tokenType, - blockchain: chainInfo.systemChain || 'unknown' + blockchain: networkConnected }) if (result) { diff --git a/tsconfig.json b/tsconfig.json index a117594b..21b068cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,7 @@ { "compilerOptions": { "target": "es2020", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -19,13 +15,7 @@ "jsx": "preserve", "incremental": true }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"], "extends": "./tsconfig.paths.json" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index ffe75ee4..c4a91852 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5585,7 +5585,7 @@ multipipe@^1.0.2: duplexer2 "^0.1.2" object-assign "^4.1.0" -nanoid@^3.3.4: +nanoid@3, nanoid@^3.3.4: version "3.3.6" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== @@ -7228,6 +7228,13 @@ url-parse@^1.5.3: querystringify "^2.1.1" requires-port "^1.0.0" +useink@^1.13.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/useink/-/useink-1.13.0.tgz#7865eb3e75bd9efdb00dbefcca25f400d39534d3" + integrity sha512-fBO0mdGUE6vKSyF+TtNNH2YeE2fIbrmHys+8x8kerha8GjK6zS0ENLVfAmWdVb56phJoPmS+qHfX2Aevk//GxA== + dependencies: + nanoid "3" + util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" From 81386272a19814e82ac51166717059f6e6bcf340 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:32:18 -0300 Subject: [PATCH 25/47] Bump eslint from 8.41.0 to 8.49.0 (#182) Bumps [eslint](https://github.com/eslint/eslint) from 8.41.0 to 8.49.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.41.0...v8.49.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 118 +++++++++++++++++++++++++++------------------------ 2 files changed, 64 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index ef7592ee..3f95ec43 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.61.0", "cypress": "^12.17.3", - "eslint": "^8.41.0", + "eslint": "^8.49.0", "eslint-config-next": "13.1.1", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.2", diff --git a/yarn.lock b/yarn.lock index c4a91852..51cd1587 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@aashutoshrathi/word-wrap@^1.2.3": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" + integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== + "@adobe/css-tools@^4.0.1": version "4.2.0" resolved "https://registry.yarnpkg.com/@adobe/css-tools/-/css-tools-4.2.0.tgz#e1a84fca468f4b337816fcb7f0964beb620ba855" @@ -518,19 +523,19 @@ dependencies: eslint-visitor-keys "^3.3.0" -"@eslint-community/regexpp@^4.4.0": - version "4.5.1" - resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" - integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== +"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.6.1": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.8.0.tgz#11195513186f68d42fbf449f9a7136b2c0c92005" + integrity sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg== -"@eslint/eslintrc@^2.0.3": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.3.tgz#4910db5505f4d503f27774bf356e3704818a0331" - integrity sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ== +"@eslint/eslintrc@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.2.tgz#c6936b4b328c64496692f76944e755738be62396" + integrity sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.5.2" + espree "^9.6.0" globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" @@ -538,15 +543,15 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.41.0": - version "8.41.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.41.0.tgz#080321c3b68253522f7646b55b577dd99d2950b3" - integrity sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA== +"@eslint/js@8.49.0": + version "8.49.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.49.0.tgz#86f79756004a97fa4df866835093f1df3d03c333" + integrity sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w== -"@humanwhocodes/config-array@^0.11.8": - version "0.11.8" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" - integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== +"@humanwhocodes/config-array@^0.11.11": + version "0.11.11" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.11.tgz#88a04c570dbbc7dd943e4712429c3df09bc32844" + integrity sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" @@ -2189,11 +2194,16 @@ acorn-walk@^8.0.2: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== -acorn@^8.1.0, acorn@^8.8.0, acorn@^8.8.1: +acorn@^8.1.0, acorn@^8.8.1: version "8.8.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== +acorn@^8.9.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + agent-base@6: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" @@ -2209,7 +2219,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv@^6.10.0, ajv@^6.12.4: +ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3578,40 +3588,40 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-scope@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.0.tgz#f21ebdafda02352f103634b96dd47d9f81ca117b" - integrity sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw== +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" -eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" - integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@^8.41.0: - version "8.41.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.41.0.tgz#3062ca73363b4714b16dbc1e60f035e6134b6f1c" - integrity sha512-WQDQpzGBOP5IrXPo4Hc0814r4/v2rrIsB0rhT7jtunIalgg6gYXWhRMOejVO8yH21T/FGaxjmFjBMNqcIlmH1Q== +eslint@^8.49.0: + version "8.49.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.49.0.tgz#09d80a89bdb4edee2efcf6964623af1054bf6d42" + integrity sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ== dependencies: "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.4.0" - "@eslint/eslintrc" "^2.0.3" - "@eslint/js" "8.41.0" - "@humanwhocodes/config-array" "^0.11.8" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.2" + "@eslint/js" "8.49.0" + "@humanwhocodes/config-array" "^0.11.11" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" - ajv "^6.10.0" + ajv "^6.12.4" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" doctrine "^3.0.0" escape-string-regexp "^4.0.0" - eslint-scope "^7.2.0" - eslint-visitor-keys "^3.4.1" - espree "^9.5.2" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -3621,7 +3631,6 @@ eslint@^8.41.0: globals "^13.19.0" graphemer "^1.4.0" ignore "^5.2.0" - import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" is-path-inside "^3.0.3" @@ -3631,17 +3640,16 @@ eslint@^8.41.0: lodash.merge "^4.6.2" minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.9.1" + optionator "^0.9.3" strip-ansi "^6.0.1" - strip-json-comments "^3.1.0" text-table "^0.2.0" -espree@^9.5.2: - version "9.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.2.tgz#e994e7dc33a082a7a82dceaf12883a829353215b" - integrity sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw== +espree@^9.6.0, espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== dependencies: - acorn "^8.8.0" + acorn "^8.9.0" acorn-jsx "^5.3.2" eslint-visitor-keys "^3.4.1" @@ -4377,7 +4385,7 @@ ignore@^5.2.0: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== -import-fresh@^3.0.0, import-fresh@^3.2.1: +import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -5821,17 +5829,17 @@ optionator@^0.8.1: type-check "~0.3.2" word-wrap "~1.2.3" -optionator@^0.9.1: - version "0.9.1" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" - integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== +optionator@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" + integrity sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg== dependencies: + "@aashutoshrathi/word-wrap" "^1.2.3" deep-is "^0.1.3" fast-levenshtein "^2.0.6" levn "^0.4.1" prelude-ls "^1.2.1" type-check "^0.4.0" - word-wrap "^1.2.3" ospath@^1.2.2: version "1.2.2" @@ -6873,7 +6881,7 @@ strip-indent@^3.0.0: dependencies: min-indent "^1.0.0" -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -7355,7 +7363,7 @@ which@^2.0.1: dependencies: isexe "^2.0.0" -word-wrap@^1.2.3, word-wrap@~1.2.3: +word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== From 2506eb23bce61fc86a40b0b3afbd10b00e40a8e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:32:48 -0300 Subject: [PATCH 26/47] Bump next-plausible from 3.7.2 to 3.11.1 (#179) Bumps [next-plausible](https://github.com/4lejandrito/next-plausible) from 3.7.2 to 3.11.1. - [Changelog](https://github.com/4lejandrito/next-plausible/blob/master/CHANGELOG.md) - [Commits](https://github.com/4lejandrito/next-plausible/compare/v3.7.2...v3.11.1) --- updated-dependencies: - dependency-name: next-plausible dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3f95ec43..37e40a4b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "dotenv": "^16.0.3", "lodash": "^4.17.21", "next": "13.1.1", - "next-plausible": "^3.7.2", + "next-plausible": "^3.11.1", "react": "18.2.0", "react-code-blocks": "^0.0.9-0", "react-device-detect": "^2.2.2", diff --git a/yarn.lock b/yarn.lock index 51cd1587..1a79c3ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5613,10 +5613,10 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -next-plausible@^3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/next-plausible/-/next-plausible-3.7.2.tgz#33eae204a00ad01b7851b319e115eab8e0815fa6" - integrity sha512-9PqFiVtD1kZO5gHFYTcgilHhg2WhMzD6I4NK/RUh9DGavD1N11IhNAvyGLFmvB3f4FtHC9IoAsauYDtQBt+riA== +next-plausible@^3.11.1: + version "3.11.1" + resolved "https://registry.yarnpkg.com/next-plausible/-/next-plausible-3.11.1.tgz#89c519cf71d80a573ee16eebe1f355b062362aaf" + integrity sha512-Gd+QU+XflVTx65yJ2cNZyrOQLrpz3uKjGLEG4ls+CIVqK3yjsVGCMsEWJcvv1LAeVfHUQtCyp1xyAltLn5Odcg== next@13.1.1: version "13.1.1" From d3b642563f37938fc6c09eefa955cfbfb3cdb01b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:33:01 -0300 Subject: [PATCH 27/47] Bump jest-environment-jsdom from 29.5.0 to 29.6.4 (#178) Bumps [jest-environment-jsdom](https://github.com/jestjs/jest/tree/HEAD/packages/jest-environment-jsdom) from 29.5.0 to 29.6.4. - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v29.6.4/packages/jest-environment-jsdom) --- updated-dependencies: - dependency-name: jest-environment-jsdom dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 116 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 77 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 37e40a4b..784e1c68 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "fs-extra": "^11.1.1", "husky": "^8.0.3", "jest": "^29.5.0", - "jest-environment-jsdom": "^29.5.0", + "jest-environment-jsdom": "^29.6.4", "lint-staged": "^13.1.0", "prettier": "^2.8.3", "stylelint-config-prettier": "^9.0.4", diff --git a/yarn.lock b/yarn.lock index 1a79c3ef..853790b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -629,15 +629,15 @@ slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/environment@^29.5.0": - version "29.5.0" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.5.0.tgz#9152d56317c1fdb1af389c46640ba74ef0bb4c65" - integrity sha512-5FXw2+wD29YU1d4I2htpRX7jYnAyTRjP2CsXQdo9SAM8g3ifxWPSV0HnClSn71xwctr0U3oZIIH+dtbfmnbXVQ== +"@jest/environment@^29.5.0", "@jest/environment@^29.6.4": + version "29.6.4" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.6.4.tgz#78ec2c9f8c8829a37616934ff4fea0c028c79f4f" + integrity sha512-sQ0SULEjA1XUTHmkBRl7A1dyITM9yb1yb3ZNKPX3KlTd6IG7mWUe3e2yfExtC2Zz1Q+mMckOLHmL/qLiuQJrBQ== dependencies: - "@jest/fake-timers" "^29.5.0" - "@jest/types" "^29.5.0" + "@jest/fake-timers" "^29.6.4" + "@jest/types" "^29.6.3" "@types/node" "*" - jest-mock "^29.5.0" + jest-mock "^29.6.3" "@jest/expect-utils@^29.5.0": version "29.5.0" @@ -654,17 +654,17 @@ expect "^29.5.0" jest-snapshot "^29.5.0" -"@jest/fake-timers@^29.5.0": - version "29.5.0" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.5.0.tgz#d4d09ec3286b3d90c60bdcd66ed28d35f1b4dc2c" - integrity sha512-9ARvuAAQcBwDAqOnglWq2zwNIRUDtk/SCkp/ToGEhFv5r86K21l+VEs0qNTaXtyiY0lEePl3kylijSYJQqdbDg== +"@jest/fake-timers@^29.5.0", "@jest/fake-timers@^29.6.4": + version "29.6.4" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.6.4.tgz#45a27f093c43d5d989362a3e7a8c70c83188b4f6" + integrity sha512-6UkCwzoBK60edXIIWb0/KWkuj7R7Qq91vVInOe3De6DSpaEiqjKcJw4F7XUet24Wupahj9J6PlR09JqJ5ySDHw== dependencies: - "@jest/types" "^29.5.0" + "@jest/types" "^29.6.3" "@sinonjs/fake-timers" "^10.0.2" "@types/node" "*" - jest-message-util "^29.5.0" - jest-mock "^29.5.0" - jest-util "^29.5.0" + jest-message-util "^29.6.3" + jest-mock "^29.6.3" + jest-util "^29.6.3" "@jest/globals@^29.5.0": version "29.5.0" @@ -713,6 +713,13 @@ dependencies: "@sinclair/typebox" "^0.25.16" +"@jest/schemas@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" + integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== + dependencies: + "@sinclair/typebox" "^0.27.8" + "@jest/source-map@^29.4.3": version "29.4.3" resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.4.3.tgz#ff8d05cbfff875d4a791ab679b4333df47951d20" @@ -763,12 +770,12 @@ slash "^3.0.0" write-file-atomic "^4.0.2" -"@jest/types@^29.5.0": - version "29.5.0" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.5.0.tgz#f59ef9b031ced83047c67032700d8c807d6e1593" - integrity sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog== +"@jest/types@^29.5.0", "@jest/types@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" + integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== dependencies: - "@jest/schemas" "^29.4.3" + "@jest/schemas" "^29.6.3" "@types/istanbul-lib-coverage" "^2.0.0" "@types/istanbul-reports" "^3.0.0" "@types/node" "*" @@ -1647,6 +1654,11 @@ resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718" integrity sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ== +"@sinclair/typebox@^0.27.8": + version "0.27.8" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" + integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== + "@sinonjs/commons@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-2.0.0.tgz#fd4ca5b063554307e8327b4564bd56d3b73924a3" @@ -4897,18 +4909,18 @@ jest-each@^29.5.0: jest-util "^29.5.0" pretty-format "^29.5.0" -jest-environment-jsdom@^29.5.0: - version "29.5.0" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.5.0.tgz#cfe86ebaf1453f3297b5ff3470fbe94739c960cb" - integrity sha512-/KG8yEK4aN8ak56yFVdqFDzKNHgF4BAymCx2LbPNPsUshUlfAl0eX402Xm1pt+eoG9SLZEUVifqXtX8SK74KCw== +jest-environment-jsdom@^29.6.4: + version "29.6.4" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.6.4.tgz#0daf44454041f9e1ef7fa82eb1bd43426a82eb1c" + integrity sha512-K6wfgUJ16DoMs02JYFid9lOsqfpoVtyJxpRlnTxUHzvZWBnnh2VNGRB9EC1Cro96TQdq5TtSjb3qUjNaJP9IyA== dependencies: - "@jest/environment" "^29.5.0" - "@jest/fake-timers" "^29.5.0" - "@jest/types" "^29.5.0" + "@jest/environment" "^29.6.4" + "@jest/fake-timers" "^29.6.4" + "@jest/types" "^29.6.3" "@types/jsdom" "^20.0.0" "@types/node" "*" - jest-mock "^29.5.0" - jest-util "^29.5.0" + jest-mock "^29.6.3" + jest-util "^29.6.3" jsdom "^20.0.0" jest-environment-node@^29.5.0: @@ -4980,14 +4992,29 @@ jest-message-util@^29.5.0: slash "^3.0.0" stack-utils "^2.0.3" -jest-mock@^29.5.0: - version "29.5.0" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.5.0.tgz#26e2172bcc71d8b0195081ff1f146ac7e1518aed" - integrity sha512-GqOzvdWDE4fAV2bWQLQCkujxYWL7RxjCnj71b5VhDAGOevB3qj3Ovg26A5NI84ZpODxyzaozXLOh2NCgkbvyaw== +jest-message-util@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.6.3.tgz#bce16050d86801b165f20cfde34dc01d3cf85fbf" + integrity sha512-FtzaEEHzjDpQp51HX4UMkPZjy46ati4T5pEMyM6Ik48ztu4T9LQplZ6OsimHx7EuM9dfEh5HJa6D3trEftu3dA== dependencies: - "@jest/types" "^29.5.0" + "@babel/code-frame" "^7.12.13" + "@jest/types" "^29.6.3" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" + graceful-fs "^4.2.9" + micromatch "^4.0.4" + pretty-format "^29.6.3" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-mock@^29.5.0, jest-mock@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.6.3.tgz#433f3fd528c8ec5a76860177484940628bdf5e0a" + integrity sha512-Z7Gs/mOyTSR4yPsaZ72a/MtuK6RnC3JYqWONe48oLaoEcYwEDxqvbXz85G4SJrm2Z5Ar9zp6MiHF4AlFlRM4Pg== + dependencies: + "@jest/types" "^29.6.3" "@types/node" "*" - jest-util "^29.5.0" + jest-util "^29.6.3" jest-pnp-resolver@^1.2.2: version "1.2.3" @@ -5106,12 +5133,12 @@ jest-snapshot@^29.5.0: pretty-format "^29.5.0" semver "^7.3.5" -jest-util@^29.5.0: - version "29.5.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.5.0.tgz#24a4d3d92fc39ce90425311b23c27a6e0ef16b8f" - integrity sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ== +jest-util@^29.5.0, jest-util@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.6.3.tgz#e15c3eac8716440d1ed076f09bc63ace1aebca63" + integrity sha512-QUjna/xSy4B32fzcKTSz1w7YYzgiHrjjJjevdRf61HYk998R5vVMMNmrHESYZVDS5DSWs+1srPLPKxXPkeSDOA== dependencies: - "@jest/types" "^29.5.0" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" ci-info "^3.2.0" @@ -6093,6 +6120,15 @@ pretty-format@^29.0.0, pretty-format@^29.5.0: ansi-styles "^5.0.0" react-is "^18.0.0" +pretty-format@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.6.3.tgz#d432bb4f1ca6f9463410c3fb25a0ba88e594ace7" + integrity sha512-ZsBgjVhFAj5KeK+nHfF1305/By3lechHQSMWCTl8iHSbfOm2TN5nHEtFc/+W7fAyUeCs2n5iow72gld4gW0xDw== + dependencies: + "@jest/schemas" "^29.6.3" + ansi-styles "^5.0.0" + react-is "^18.0.0" + prismjs@^1.27.0, prismjs@^1.8.4: version "1.29.0" resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12" From 43eec654ce960ac07febaf6fb1193d805183e4e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:33:16 -0300 Subject: [PATCH 28/47] Bump eslint-config-prettier from 8.8.0 to 9.0.0 (#177) Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.8.0 to 9.0.0. - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.8.0...v9.0.0) --- updated-dependencies: - dependency-name: eslint-config-prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 784e1c68..c2792fc4 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "cypress": "^12.17.3", "eslint": "^8.49.0", "eslint-config-next": "13.1.1", - "eslint-config-prettier": "^8.6.0", + "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-jest": "^27.2.3", "eslint-plugin-jest-dom": "^4.0.3", diff --git a/yarn.lock b/yarn.lock index 853790b5..01e377ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3465,10 +3465,10 @@ eslint-config-next@13.1.1: eslint-plugin-react "^7.31.7" eslint-plugin-react-hooks "^4.5.0" -eslint-config-prettier@^8.6.0: - version "8.8.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" - integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== +eslint-config-prettier@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz#eb25485946dd0c66cd216a46232dc05451518d1f" + integrity sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw== eslint-import-resolver-node@^0.3.6, eslint-import-resolver-node@^0.3.7: version "0.3.7" From 3d38b6a0fd81e0fa8bfc1685ea68d78f6eea1622 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:13:15 -0300 Subject: [PATCH 29/47] Bump @types/node from 20.4.4 to 20.6.2 (#183) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.4.4 to 20.6.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c2792fc4..82296546 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@types/big.js": "^6.1.6", "@types/fs-extra": "^11.0.1", "@types/jest": "^29.5.1", - "@types/node": "^20.4.4", + "@types/node": "^20.6.2", "@types/react": "18.0.38", "@types/react-dom": "18.0.11", "@types/react-toastify": "^4.1.0", diff --git a/yarn.lock b/yarn.lock index 01e377ee..898aa647 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1907,10 +1907,10 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.194.tgz#b71eb6f7a0ff11bff59fc987134a093029258a76" integrity sha512-r22s9tAS7imvBt2lyHC9B8AGwWnXaYb1tY09oyLkXDs4vArpYJzw09nj8MLx5VfciBPGIb+ZwG0ssYnEPJxn/g== -"@types/node@*", "@types/node@^20.4.4": - version "20.4.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.4.tgz#c79c7cc22c9d0e97a7944954c9e663bcbd92b0cb" - integrity sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew== +"@types/node@*", "@types/node@^20.6.2": + version "20.6.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.2.tgz#a065925409f59657022e9063275cd0b9bd7e1b12" + integrity sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw== "@types/node@^16.18.39": version "16.18.39" From 8572232d3e7dc5d4c157488c325a719e69cb544c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:13:31 -0300 Subject: [PATCH 30/47] Bump dotenv from 16.0.3 to 16.3.1 (#184) Bumps [dotenv](https://github.com/motdotla/dotenv) from 16.0.3 to 16.3.1. - [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md) - [Commits](https://github.com/motdotla/dotenv/compare/v16.0.3...v16.3.1) --- updated-dependencies: - dependency-name: dotenv dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 82296546..bb17d3db 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "big.js": "^6.2.1", "bn.js": "^5.2.1", "copy-to-clipboard": "^3.3.3", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "lodash": "^4.17.21", "next": "13.1.1", "next-plausible": "^3.11.1", diff --git a/yarn.lock b/yarn.lock index 898aa647..ecde5232 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3259,10 +3259,10 @@ domexception@^4.0.0: dependencies: webidl-conversions "^7.0.0" -dotenv@^16.0.3: - version "16.0.3" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07" - integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ== +dotenv@^16.3.1: + version "16.3.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" + integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== duplexer2@^0.1.2: version "0.1.4" From 28e55193b9b098b202b5e8b03132b052811760a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:13:51 -0300 Subject: [PATCH 31/47] Bump @next/font from 13.4.12 to 13.4.19 (#185) Bumps [@next/font](https://github.com/vercel/next.js/tree/HEAD/packages/font) from 13.4.12 to 13.4.19. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/commits/v13.4.19/packages/font) --- updated-dependencies: - dependency-name: "@next/font" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bb17d3db..e5bfa506 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@mui/icons-material": "^5.14.7", "@mui/lab": "^5.0.0-alpha.137", "@mui/material": "^5.11.4", - "@next/font": "13.4.12", + "@next/font": "13.4.19", "@polkadot/api": "^10.4.1", "@polkadot/api-contract": "^10.4.1", "@polkadot/extension-dapp": "^0.46.3", diff --git a/yarn.lock b/yarn.lock index ecde5232..39f93823 100644 --- a/yarn.lock +++ b/yarn.lock @@ -952,10 +952,10 @@ dependencies: glob "7.1.7" -"@next/font@13.4.12": - version "13.4.12" - resolved "https://registry.yarnpkg.com/@next/font/-/font-13.4.12.tgz#6b6f8f870241baaf9f7f4245e874cf3cf95e35ae" - integrity sha512-w/ygNFuscvvFKFTMoIqhU8Kaq1wM6x4XEu9bwzJaj8G7aloH866TUPeCgiKf+M/ACpMKfRahQa06REcg6T3CyA== +"@next/font@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/font/-/font-13.4.19.tgz#2b69aee760a3bbabf54873f80ae6d4b09b35d133" + integrity sha512-yOuSRYfqksWcaG/sATr1/DEGvvI8gnmAAnQCCZ0+L9p4Pio3/DMu71J56YHh9Hz84LDN4tMVzuux0ssCuM50sA== "@next/swc-android-arm-eabi@13.1.1": version "13.1.1" From 3053edc5b7b14c9cb2090154001e5b1a55fe7dbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:14:07 -0300 Subject: [PATCH 32/47] Bump next from 13.1.1 to 13.4.19 (#186) Bumps [next](https://github.com/vercel/next.js) from 13.1.1 to 13.4.19. - [Release notes](https://github.com/vercel/next.js/releases) - [Changelog](https://github.com/vercel/next.js/blob/canary/release.js) - [Commits](https://github.com/vercel/next.js/compare/v13.1.1...v13.4.19) --- updated-dependencies: - dependency-name: next dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 177 +++++++++++++++++++++++++++------------------------ 2 files changed, 94 insertions(+), 85 deletions(-) diff --git a/package.json b/package.json index e5bfa506..daa7d986 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "copy-to-clipboard": "^3.3.3", "dotenv": "^16.3.1", "lodash": "^4.17.21", - "next": "13.1.1", + "next": "13.4.19", "next-plausible": "^3.11.1", "react": "18.2.0", "react-code-blocks": "^0.0.9-0", diff --git a/yarn.lock b/yarn.lock index 39f93823..c6119868 100644 --- a/yarn.lock +++ b/yarn.lock @@ -940,10 +940,10 @@ prop-types "^15.8.1" react-is "^18.2.0" -"@next/env@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.1.1.tgz#6ff26488dc7674ef2bfdd1ca28fe43eed1113bea" - integrity sha512-vFMyXtPjSAiOXOywMojxfKIqE3VWN5RCAx+tT3AS3pcKjMLFTCJFUWsKv8hC+87Z1F4W3r68qTwDFZIFmd5Xkw== +"@next/env@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.19.tgz#46905b4e6f62da825b040343cbc233144e9578d3" + integrity sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ== "@next/eslint-plugin-next@13.1.1": version "13.1.1" @@ -957,70 +957,50 @@ resolved "https://registry.yarnpkg.com/@next/font/-/font-13.4.19.tgz#2b69aee760a3bbabf54873f80ae6d4b09b35d133" integrity sha512-yOuSRYfqksWcaG/sATr1/DEGvvI8gnmAAnQCCZ0+L9p4Pio3/DMu71J56YHh9Hz84LDN4tMVzuux0ssCuM50sA== -"@next/swc-android-arm-eabi@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.1.1.tgz#b5c3cd1f79d5c7e6a3b3562785d4e5ac3555b9e1" - integrity sha512-qnFCx1kT3JTWhWve4VkeWuZiyjG0b5T6J2iWuin74lORCupdrNukxkq9Pm+Z7PsatxuwVJMhjUoYz7H4cWzx2A== - -"@next/swc-android-arm64@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-13.1.1.tgz#e2ca9ccbba9ef770cb19fbe96d1ac00fe4cb330d" - integrity sha512-eCiZhTzjySubNqUnNkQCjU3Fh+ep3C6b5DCM5FKzsTH/3Gr/4Y7EiaPZKILbvnXmhWtKPIdcY6Zjx51t4VeTfA== - -"@next/swc-darwin-arm64@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.1.1.tgz#4af00877332231bbd5a3703435fdd0b011e74767" - integrity sha512-9zRJSSIwER5tu9ADDkPw5rIZ+Np44HTXpYMr0rkM656IvssowPxmhK0rTreC1gpUCYwFsRbxarUJnJsTWiutPg== - -"@next/swc-darwin-x64@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.1.1.tgz#bf4cb09e7e6ec6d91e031118dde2dd17078bcbbc" - integrity sha512-qWr9qEn5nrnlhB0rtjSdR00RRZEtxg4EGvicIipqZWEyayPxhUu6NwKiG8wZiYZCLfJ5KWr66PGSNeDMGlNaiA== - -"@next/swc-freebsd-x64@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.1.1.tgz#6933ea1264328e8523e28818f912cd53824382d4" - integrity sha512-UwP4w/NcQ7V/VJEj3tGVszgb4pyUCt3lzJfUhjDMUmQbzG9LDvgiZgAGMYH6L21MoyAATJQPDGiAMWAPKsmumA== +"@next/swc-darwin-arm64@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.19.tgz#77ad462b5ced4efdc26cb5a0053968d2c7dac1b6" + integrity sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ== -"@next/swc-linux-arm-gnueabihf@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.1.1.tgz#b5896967aaba3873d809c3ad2e2039e89acde419" - integrity sha512-CnsxmKHco9sosBs1XcvCXP845Db+Wx1G0qouV5+Gr+HT/ZlDYEWKoHVDgnJXLVEQzq4FmHddBNGbXvgqM1Gfkg== +"@next/swc-darwin-x64@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.19.tgz#aebe38713a4ce536ee5f2a291673e14b715e633a" + integrity sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw== -"@next/swc-linux-arm64-gnu@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.1.1.tgz#91b3e9ea8575b1ded421c0ea0739b7bccf228469" - integrity sha512-JfDq1eri5Dif+VDpTkONRd083780nsMCOKoFG87wA0sa4xL8LGcXIBAkUGIC1uVy9SMsr2scA9CySLD/i+Oqiw== +"@next/swc-linux-arm64-gnu@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.19.tgz#ec54db65b587939c7b94f9a84800f003a380f5a6" + integrity sha512-vdlnIlaAEh6H+G6HrKZB9c2zJKnpPVKnA6LBwjwT2BTjxI7e0Hx30+FoWCgi50e+YO49p6oPOtesP9mXDRiiUg== -"@next/swc-linux-arm64-musl@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.1.1.tgz#83149ea05d7d55f3664d608dbe004c0d125f9147" - integrity sha512-GA67ZbDq2AW0CY07zzGt07M5b5Yaq5qUpFIoW3UFfjOPgb0Sqf3DAW7GtFMK1sF4ROHsRDMGQ9rnT0VM2dVfKA== +"@next/swc-linux-arm64-musl@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.19.tgz#1f5e2c1ea6941e7d530d9f185d5d64be04279d86" + integrity sha512-aU0HkH2XPgxqrbNRBFb3si9Ahu/CpaR5RPmN2s9GiM9qJCiBBlZtRTiEca+DC+xRPyCThTtWYgxjWHgU7ZkyvA== -"@next/swc-linux-x64-gnu@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.1.1.tgz#d7d0777b56de0dd82b78055772e13e18594a15ca" - integrity sha512-nnjuBrbzvqaOJaV+XgT8/+lmXrSCOt1YYZn/irbDb2fR2QprL6Q7WJNgwsZNxiLSfLdv+2RJGGegBx9sLBEzGA== +"@next/swc-linux-x64-gnu@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.19.tgz#96b0882492a2f7ffcce747846d3680730f69f4d1" + integrity sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g== -"@next/swc-linux-x64-musl@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.1.1.tgz#41655722b127133cd95ab5bc8ca1473e9ab6876f" - integrity sha512-CM9xnAQNIZ8zf/igbIT/i3xWbQZYaF397H+JroF5VMOCUleElaMdQLL5riJml8wUfPoN3dtfn2s4peSr3azz/g== +"@next/swc-linux-x64-musl@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.19.tgz#f276b618afa321d2f7b17c81fc83f429fb0fd9d8" + integrity sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q== -"@next/swc-win32-arm64-msvc@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.1.1.tgz#f10da3dfc9b3c2bbd202f5d449a9b807af062292" - integrity sha512-pzUHOGrbgfGgPlOMx9xk3QdPJoRPU+om84hqVoe6u+E0RdwOG0Ho/2UxCgDqmvpUrMab1Deltlt6RqcXFpnigQ== +"@next/swc-win32-arm64-msvc@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.19.tgz#1599ae0d401da5ffca0947823dac577697cce577" + integrity sha512-bUfDevQK4NsIAHXs3/JNgnvEY+LRyneDN788W2NYiRIIzmILjba7LaQTfihuFawZDhRtkYCv3JDC3B4TwnmRJw== -"@next/swc-win32-ia32-msvc@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.1.1.tgz#4c0102b9b18ece15c818056d07e3917ee9dade78" - integrity sha512-WeX8kVS46aobM9a7Xr/kEPcrTyiwJqQv/tbw6nhJ4fH9xNZ+cEcyPoQkwPo570dCOLz3Zo9S2q0E6lJ/EAUOBg== +"@next/swc-win32-ia32-msvc@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.19.tgz#55cdd7da90818f03e4da16d976f0cb22045d16fd" + integrity sha512-Y5kikILFAr81LYIFaw6j/NrOtmiM4Sf3GtOc0pn50ez2GCkr+oejYuKGcwAwq3jiTKuzF6OF4iT2INPoxRycEA== -"@next/swc-win32-x64-msvc@13.1.1": - version "13.1.1" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.1.1.tgz#c209a37da13be27b722f9c40c40ab4b094866244" - integrity sha512-mVF0/3/5QAc5EGVnb8ll31nNvf3BWpPY4pBb84tk+BfQglWLqc5AC9q1Ht/YMWiEgs8ALNKEQ3GQnbY0bJF2Gg== +"@next/swc-win32-x64-msvc@13.4.19": + version "13.4.19" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.19.tgz#648f79c4e09279212ac90d871646ae12d80cdfce" + integrity sha512-YzA78jBDXMYiINdPdJJwGgPNT3YqBNNGhsthsDoWHL9p24tEJn9ViQf/ZqTbwSpX/RrkPupLfuuTH2sf73JBAw== "@noble/curves@1.0.0": version "1.0.0" @@ -1701,10 +1681,10 @@ resolved "https://registry.yarnpkg.com/@substrate/ss58-registry/-/ss58-registry-1.40.0.tgz#2223409c496271df786c1ca8496898896595441e" integrity sha512-QuU2nBql3J4KCnOWtWDw4n1K4JU0T79j54ZZvm/9nhsX6AIar13FyhsaBfs6QkJ2ixTQAnd7TocJIoJRWbqMZA== -"@swc/helpers@0.4.14": - version "0.4.14" - resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.14.tgz#1352ac6d95e3617ccb7c1498ff019654f1e12a74" - integrity sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw== +"@swc/helpers@0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.1.tgz#e9031491aa3f26bfcc974a67f48bd456c8a5357a" + integrity sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg== dependencies: tslib "^2.4.0" @@ -2643,6 +2623,13 @@ bundle-name@^3.0.0: dependencies: run-applescript "^5.0.0" +busboy@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" + integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== + dependencies: + streamsearch "^1.1.0" + cachedir@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/cachedir/-/cachedir-2.3.0.tgz#0c75892a052198f0b21c7c1804d8331edfcae0e8" @@ -4120,6 +4107,11 @@ glob-parent@^6.0.2: dependencies: is-glob "^4.0.3" +glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + glob@7.1.7: version "7.1.7" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" @@ -4207,7 +4199,7 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.9: +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -5645,30 +5637,29 @@ next-plausible@^3.11.1: resolved "https://registry.yarnpkg.com/next-plausible/-/next-plausible-3.11.1.tgz#89c519cf71d80a573ee16eebe1f355b062362aaf" integrity sha512-Gd+QU+XflVTx65yJ2cNZyrOQLrpz3uKjGLEG4ls+CIVqK3yjsVGCMsEWJcvv1LAeVfHUQtCyp1xyAltLn5Odcg== -next@13.1.1: - version "13.1.1" - resolved "https://registry.yarnpkg.com/next/-/next-13.1.1.tgz#42b825f650410649aff1017d203a088d77c80b5b" - integrity sha512-R5eBAaIa3X7LJeYvv1bMdGnAVF4fVToEjim7MkflceFPuANY3YyvFxXee/A+acrSYwYPvOvf7f6v/BM/48ea5w== +next@13.4.19: + version "13.4.19" + resolved "https://registry.yarnpkg.com/next/-/next-13.4.19.tgz#2326e02aeedee2c693d4f37b90e4f0ed6882b35f" + integrity sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw== dependencies: - "@next/env" "13.1.1" - "@swc/helpers" "0.4.14" + "@next/env" "13.4.19" + "@swc/helpers" "0.5.1" + busboy "1.6.0" caniuse-lite "^1.0.30001406" postcss "8.4.14" styled-jsx "5.1.1" + watchpack "2.4.0" + zod "3.21.4" optionalDependencies: - "@next/swc-android-arm-eabi" "13.1.1" - "@next/swc-android-arm64" "13.1.1" - "@next/swc-darwin-arm64" "13.1.1" - "@next/swc-darwin-x64" "13.1.1" - "@next/swc-freebsd-x64" "13.1.1" - "@next/swc-linux-arm-gnueabihf" "13.1.1" - "@next/swc-linux-arm64-gnu" "13.1.1" - "@next/swc-linux-arm64-musl" "13.1.1" - "@next/swc-linux-x64-gnu" "13.1.1" - "@next/swc-linux-x64-musl" "13.1.1" - "@next/swc-win32-arm64-msvc" "13.1.1" - "@next/swc-win32-ia32-msvc" "13.1.1" - "@next/swc-win32-x64-msvc" "13.1.1" + "@next/swc-darwin-arm64" "13.4.19" + "@next/swc-darwin-x64" "13.4.19" + "@next/swc-linux-arm64-gnu" "13.4.19" + "@next/swc-linux-arm64-musl" "13.4.19" + "@next/swc-linux-x64-gnu" "13.4.19" + "@next/swc-linux-x64-musl" "13.4.19" + "@next/swc-win32-arm64-msvc" "13.4.19" + "@next/swc-win32-ia32-msvc" "13.4.19" + "@next/swc-win32-x64-msvc" "13.4.19" nock@^13.3.1: version "13.3.1" @@ -6785,6 +6776,11 @@ store@^2.0.12: resolved "https://registry.yarnpkg.com/store/-/store-2.0.12.tgz#8c534e2a0b831f72b75fc5f1119857c44ef5d593" integrity sha512-eO9xlzDpXLiMr9W1nQ3Nfp9EzZieIQc10zPPMP5jsVV7bLOziSFFBP0XoDXACEIFtdI+rIz0NwWVA/QVJ8zJtw== +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== + string-argv@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6" @@ -7321,6 +7317,14 @@ walker@^1.0.8: dependencies: makeerror "1.0.12" +watchpack@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" + integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + web-streams-polyfill@^3.0.3: version "3.2.1" resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" @@ -7517,3 +7521,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zod@3.21.4: + version "3.21.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db" + integrity sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw== From 042bd0aa4a681f065ec3795125ee19cb8037c55e Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Mon, 25 Sep 2023 13:12:41 -0300 Subject: [PATCH 33/47] Using docker-compose.prod.yml instead of default development docker-compose file --- .github/workflows/build_web.yaml | 6 +++- docker-compose.prod.yml | 61 ++++++++++++++++++++++++++++++++ docker-compose.yml | 24 ++++--------- 3 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 docker-compose.prod.yml diff --git a/.github/workflows/build_web.yaml b/.github/workflows/build_web.yaml index ddc8171f..cbefbc98 100644 --- a/.github/workflows/build_web.yaml +++ b/.github/workflows/build_web.yaml @@ -66,5 +66,9 @@ jobs: run: | export IMAGE_URL=$ECR_REGISTRY/${{ env.REPOSITORY }}:$GITHUB_REF_NAME echo "$SSH_KEY" | tr -d '\r' > key.pem && chmod 400 key.pem - ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; docker-compose --env-file .docker/dev.docker.env down; sleep 5; docker-compose --env-file .docker/dev.docker.env up -d" + ssh -o "StrictHostKeyChecking no" -i "key.pem" ubuntu@$DEPLOYMENT_SERVER_IP "\ + export IMAGE_URL=$IMAGE_URL; sed -i '/WEB_IMAGE/d' /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; \ + echo WEB_IMAGE=$IMAGE_URL >> /home/ubuntu/polkadot-contract-wizard/.docker/dev.docker.env; cd polkadot-contract-wizard/; \ + docker-compose -f docker-compose.prod.yml --env-file .docker/dev.docker.env down; sleep 5; \ + docker-compose -f docker-compose.prod.yml --env-file .docker/dev.docker.env up -d" diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..45661b14 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,61 @@ +version: '3.8' + +networks: + polkadot-wizard: + name: polkadot-wizard + +services: + web: + container_name: ${CONTAINER_BASE}_web + image: ${WEB_IMAGE} + ports: + - ${WEB_EXTERNAL_PORT}:3000 + environment: + - NODE_ENV=${WEB_ENVIRONMENT} + - NODE_OPTIONS='--max-old-space-size=2048' + networks: + - polkadot-wizard + depends_on: + - compiler-be + command: + sh -c 'if [ "$WEB_ENVIRONMENT" = "development" ]; then + yarn dev; + else + yarn start; + fi' + compiler-be: + container_name: ${CONTAINER_BASE}_backend + image: ${COMPILER_BE_IMAGE} + ports: + - ${BACKEND_EXTERNAL_PORT}:8000 + environment: + - MONGOURI=mongodb://mongodb:27017 + networks: + - polkadot-wizard + depends_on: + - mongodb + mongodb: + ports: + - ${DB_EXTERNAL_PORT}:27017 + container_name: ${CONTAINER_BASE}_mongodb + restart: always + logging: + options: + max-size: 1g + image: mongo:5.0.16 + networks: + - polkadot-wizard + volumes: + - /data/mongodb:/data/db + mongoexpress: + image: mongo-express:0.54.0 + ports: + - 8081:8081 + container_name: ${CONTAINER_BASE}_mongoexpress + environment: + - ME_CONFIG_MONGODB_SERVER=mongodb + networks: + - polkadot-wizard + depends_on: + - mongodb + diff --git a/docker-compose.yml b/docker-compose.yml index 45661b14..a1341d1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,12 +7,14 @@ networks: services: web: container_name: ${CONTAINER_BASE}_web - image: ${WEB_IMAGE} + build: + context: . + dockerfile: .docker/web/dev.Dockerfile + target: runner ports: - ${WEB_EXTERNAL_PORT}:3000 environment: - NODE_ENV=${WEB_ENVIRONMENT} - - NODE_OPTIONS='--max-old-space-size=2048' networks: - polkadot-wizard depends_on: @@ -25,7 +27,9 @@ services: fi' compiler-be: container_name: ${CONTAINER_BASE}_backend - image: ${COMPILER_BE_IMAGE} + build: + context: ./ink-compiler-be + dockerfile: ./Dockerfile ports: - ${BACKEND_EXTERNAL_PORT}:8000 environment: @@ -45,17 +49,3 @@ services: image: mongo:5.0.16 networks: - polkadot-wizard - volumes: - - /data/mongodb:/data/db - mongoexpress: - image: mongo-express:0.54.0 - ports: - - 8081:8081 - container_name: ${CONTAINER_BASE}_mongoexpress - environment: - - ME_CONFIG_MONGODB_SERVER=mongodb - networks: - - polkadot-wizard - depends_on: - - mongodb - From f1fd673c53cd82e6b75ef48e2269c5b6a2c9e458 Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Mon, 25 Sep 2023 15:01:56 -0300 Subject: [PATCH 34/47] fix contracts deployed (#188) * Adding ApiDeploymentRepository * Adding ApiDeploymentReposiroty * Send to DB after deploy * Moving repository to a localDbContext * Replace global context with customHook * Using Dexie such as local DB with UserContractsDetails * Fixing loading rows * Adding isoToHumanReadable fn --- package.json | 1 + pages/_app.tsx | 23 +++--- pages/index.tsx | 9 ++- src/constants/config.ts | 4 +- src/context/LocalDbContext.tsx | 28 ++++++- src/context/NetworkAccountsContext.tsx | 32 +++----- src/context/StorageContractContext.tsx | 76 ------------------ src/context/index.ts | 1 - src/domain/CompileContractRepository.ts | 7 -- src/domain/Contract.ts | 4 +- src/domain/UserContractDetails.ts | 41 ++++++++++ src/domain/index.ts | 2 +- .../repositories/CompileContractRepository.ts | 4 + .../repositories/DeploymentRepository.ts | 18 +++++ .../repositories/IUserContractsRepository.ts | 16 ++++ src/domain/wizard/ContractTableItem.ts | 4 +- src/hooks/compileContract/index.ts | 2 + .../useCreateCompileContract.ts} | 54 ++----------- .../useSearchCompileContract.ts | 44 +++++++++++ .../useCreateContractsDeployments.ts | 41 ++++++++++ .../useListContractsDeployments.ts | 44 +++++++++++ src/hooks/index.ts | 2 +- src/hooks/useDeployContract.ts | 37 +++++---- src/hooks/useMultipleEventListener.ts | 10 ++- src/hooks/useOnceEffect.ts | 23 ++++++ .../userContracts/useAddUserContracts.ts | 21 +++++ .../userContracts/useListUserContracts.ts | 77 ++++++++++++++++++ src/infrastructure/DeploymentApiRepository.ts | 5 -- .../LocalStorageContractRepository.ts | 71 ----------------- .../ApiCompileContractRepository.ts | 28 +++++-- .../backendApi/ApiDeploymentRepository.ts | 71 +++++++++++++++++ src/infrastructure/{ => backendApi}/types.ts | 4 +- src/infrastructure/common/request.ts | 1 + src/infrastructure/deployContract.ts | 8 +- src/infrastructure/index.ts | 2 +- .../localDB/UserContractsRepository.ts | 51 ++++++++++++ src/infrastructure/localDB/index.ts | 17 ++++ src/utils/browserMethods.ts | 3 + src/utils/formatString.ts | 29 +++++++ .../ContractsTableWidget/ContractsTable.tsx | 79 ++++++------------- .../HomeView/ContractsTableWidget/index.tsx | 12 ++- .../HomeView/ContractsTableWidget/styled.ts | 24 ++++++ src/view/components/ModalWallet/index.tsx | 5 +- src/view/components/TokenIconSvg/index.tsx | 2 + .../components/WalletConnectButton/index.tsx | 5 +- src/view/wizardView/GridDeployInfo.tsx | 4 +- src/view/wizardView/Step3Deploy/index.tsx | 59 ++++++++------ src/view/wizardView/Step3Deploy/styled.ts | 11 +++ src/view/wizardView/index.tsx | 5 +- tests/utils/isoToReadableDate.test.ts | 32 ++++++++ tests/{ => utils}/utils.test.ts | 0 yarn.lock | 5 ++ 52 files changed, 771 insertions(+), 387 deletions(-) delete mode 100644 src/context/StorageContractContext.tsx delete mode 100644 src/domain/CompileContractRepository.ts mode change 100644 => 100755 src/domain/Contract.ts create mode 100644 src/domain/UserContractDetails.ts create mode 100644 src/domain/repositories/CompileContractRepository.ts create mode 100644 src/domain/repositories/DeploymentRepository.ts create mode 100644 src/domain/repositories/IUserContractsRepository.ts create mode 100644 src/hooks/compileContract/index.ts rename src/hooks/{useCompileContract.ts => compileContract/useCreateCompileContract.ts} (59%) create mode 100644 src/hooks/compileContract/useSearchCompileContract.ts create mode 100644 src/hooks/deployments/useCreateContractsDeployments.ts create mode 100644 src/hooks/deployments/useListContractsDeployments.ts create mode 100644 src/hooks/useOnceEffect.ts create mode 100644 src/hooks/userContracts/useAddUserContracts.ts create mode 100644 src/hooks/userContracts/useListUserContracts.ts delete mode 100644 src/infrastructure/DeploymentApiRepository.ts delete mode 100644 src/infrastructure/LocalStorageContractRepository.ts create mode 100644 src/infrastructure/backendApi/ApiDeploymentRepository.ts rename src/infrastructure/{ => backendApi}/types.ts (70%) create mode 100644 src/infrastructure/localDB/UserContractsRepository.ts create mode 100644 src/infrastructure/localDB/index.ts create mode 100644 src/utils/browserMethods.ts create mode 100644 src/view/HomeView/ContractsTableWidget/styled.ts create mode 100644 src/view/wizardView/Step3Deploy/styled.ts create mode 100644 tests/utils/isoToReadableDate.test.ts rename tests/{ => utils}/utils.test.ts (100%) diff --git a/package.json b/package.json index daa7d986..15e60319 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "big.js": "^6.2.1", "bn.js": "^5.2.1", "copy-to-clipboard": "^3.3.3", + "dexie": "^3.2.4", "dotenv": "^16.3.1", "lodash": "^4.17.21", "next": "13.4.19", diff --git a/pages/_app.tsx b/pages/_app.tsx index 4c113529..8111996e 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -19,8 +19,6 @@ import { StorageNotificationsRepository } from 'src/context/AppNotificationContext' import { CustomSnackBar as AppNotification } from 'src/view/components/Snackbar' -import { StorageContractsProvider } from '@/context' -import { LocalStorageContractRepository } from '@/infrastructure/LocalStorageContractRepository' import { DAPP_CONFIG, DOMAIN } from '@/constants/config' import { UseInkProvider } from 'useink' import { CHAINS } from '@/constants/chains' @@ -35,7 +33,6 @@ type CustomAppProps = AppProps & { const clientEmotionCache = buildEmotionCache() const repositoryAppNotification = new StorageNotificationsRepository() -const repositoryDeploys = new LocalStorageContractRepository() export default function App(props: CustomAppProps) { const { Component, emotionCache = clientEmotionCache, pageProps } = props @@ -61,17 +58,15 @@ export default function App(props: CustomAppProps) { - - - {({ settings }) => { - return ( - - {getLayout()} - - ) - }} - - + + {({ settings }) => { + return ( + + {getLayout()} + + ) + }} + diff --git a/pages/index.tsx b/pages/index.tsx index a1de565e..9c68a838 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -5,8 +5,8 @@ import { HomeButton } from '@/components' import { ROUTES, TOKEN_PATHS } from '@/constants/index' import { TokenType } from '@/domain' import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' -import { useStorageContractsContext } from '@/context' import { ContractsTableWidget } from '@/view/HomeView/ContractsTableWidget' +import { useListUserContracts } from '@/hooks/userContracts/useListUserContracts' const Token: Record = { psp22: 'psp22', @@ -15,8 +15,11 @@ const Token: Record = { } function Home() { - const { accountConnected } = useNetworkAccountsContext() - const { contracts } = useStorageContractsContext() + const { accountConnected, networkConnected } = useNetworkAccountsContext() + const { userContracts: contracts } = useListUserContracts( + accountConnected?.address, + networkConnected + ) return ( <> diff --git a/src/constants/config.ts b/src/constants/config.ts index df16fca3..c5bd68ff 100644 --- a/src/constants/config.ts +++ b/src/constants/config.ts @@ -26,8 +26,8 @@ const backendRouterApi = { pathName: 'deployments', method: 'POST' }, - ListDeployment: { - pathName: 'deployments', + listDeployment: { + pathName: 'deployments?user_address=', method: 'GET' }, createCompileContract: { diff --git a/src/context/LocalDbContext.tsx b/src/context/LocalDbContext.tsx index b4cbcc8f..64aa8c54 100644 --- a/src/context/LocalDbContext.tsx +++ b/src/context/LocalDbContext.tsx @@ -1,22 +1,46 @@ import { INetworkRepository } from '@/domain/repositories/INetworkRepository' import { LocalStorageNetworkRepository } from '@/infrastructure/LocalStorageNetworkRepository' +import { + ApiDeploymentRepository, + IApiDeploymentRepository +} from '@/infrastructure/backendApi/ApiDeploymentRepository' import React, { createContext, PropsWithChildren, useContext } from 'react' +import { BACKEND_API } from '../constants' +import { MyDatabase } from '@/infrastructure/localDB' +import { UserContractsRepository } from '@/infrastructure/localDB/UserContractsRepository' +import { IUserContractsRepository } from '@/domain/repositories/IUserContractsRepository' +import { + ApiCompileContractRepository, + IApiCompileContractRepository +} from '@/infrastructure/backendApi/ApiCompileContractRepository' interface DbContext { networkRepository: INetworkRepository + deploymentsRepository: IApiDeploymentRepository + userContractsRepository: IUserContractsRepository + compileContractRepository: IApiCompileContractRepository } const networkRepository = new LocalStorageNetworkRepository() +const deploymentsRepository = new ApiDeploymentRepository(BACKEND_API) +const compileContractRepository = new ApiCompileContractRepository(BACKEND_API) +const userContractsRepository = new UserContractsRepository(new MyDatabase()) const DbContext = createContext({ - networkRepository + networkRepository, + deploymentsRepository, + userContractsRepository, + compileContractRepository }) export const LocalDbProvider: React.FC = ({ children }) => { return ( {children} diff --git a/src/context/NetworkAccountsContext.tsx b/src/context/NetworkAccountsContext.tsx index 5eefa42d..63a005b1 100644 --- a/src/context/NetworkAccountsContext.tsx +++ b/src/context/NetworkAccountsContext.tsx @@ -123,20 +123,6 @@ export function NetworkAccountsContextProvider({ loadNetworkConnected() }, [loadNetworkConnected]) - useEffect(() => { - document.addEventListener( - WalletConnectionEvents.networkChanged, - loadNetworkConnected - ) - - return () => { - document.removeEventListener( - WalletConnectionEvents.networkChanged, - loadNetworkConnected - ) - } - }, [loadNetworkConnected]) - useEffect(() => { setState(prev => ({ ...prev, @@ -152,17 +138,21 @@ export function NetworkAccountsContextProvider({ }, [accounts]) const setCurrentWallet = async (wallet: Wallet) => { - setState(prev => ({ - ...prev, - accountStatus: 'CONNECTING', - currentChain: networkRepository.getNetworkSelected().id - })) connect(wallet.extensionName) } + const _setAccount = (account: WalletAccount) => { + setAccount(account) + + document.dispatchEvent( + new CustomEvent(WalletConnectionEvents.changeAccountAddress) + ) + } + const setCurrentChain = useCallback( - (chainId: ChainId) => { + async (chainId: ChainId) => { networkRepository.setNetworkSelected(chainId) + setNetworkId(chainId) document.dispatchEvent( new CustomEvent(WalletConnectionEvents.networkChanged) @@ -178,7 +168,7 @@ export function NetworkAccountsContextProvider({ isConnected, accountConnected: account, networkConnected: networkId, - setCurrentAccount: setAccount, + setCurrentAccount: _setAccount, setCurrentWallet, setCurrentChain, disconnectWallet: disconnect, diff --git a/src/context/StorageContractContext.tsx b/src/context/StorageContractContext.tsx deleted file mode 100644 index cba3f419..00000000 --- a/src/context/StorageContractContext.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { - createContext, - useCallback, - useContext, - useEffect, - useState -} from 'react' - -import { Contract, SmartContractEvents, isContractDeployed } from '@/domain' -import { StorageContractRepository } from '@/infrastructure/LocalStorageContractRepository' -import { useNetworkAccountsContext } from './NetworkAccountsContext' -import { useMultiEventListener } from '@/hooks/useMultipleEventListener' - -interface StorageContractContextValues { - contracts: Contract[] - addContractToStorage(accountAddress: string, smartContract: Contract): void -} - -const StorageContractsContext = createContext( - {} as StorageContractContextValues -) - -export function StorageContractsProvider({ - children, - repository -}: { - children: React.ReactNode - repository: StorageContractRepository -}) { - const [contracts, setContracts] = useState([]) - const { accountConnected } = useNetworkAccountsContext() - - const loadContractRepository = useCallback(() => { - if (!accountConnected?.address) return - - setContracts(repository.searchBy(accountConnected.address)) - }, [accountConnected?.address, repository]) - - useEffect(() => { - loadContractRepository() - }, [loadContractRepository, repository]) - - // update repository when events triggered - useMultiEventListener( - [ - SmartContractEvents.contractCompiled, - SmartContractEvents.contractInstatiate - ], - loadContractRepository - ) - - const save = useCallback( - (accountAddress: string, smartContract: Contract) => { - repository.save(accountAddress, smartContract) - - document.dispatchEvent( - new CustomEvent( - isContractDeployed(smartContract) - ? SmartContractEvents.contractInstatiate - : SmartContractEvents.contractCompiled - ) - ) - }, - [repository] - ) - - return ( - - {children} - - ) -} -export const useStorageContractsContext = () => - useContext(StorageContractsContext) diff --git a/src/context/index.ts b/src/context/index.ts index 313bb4c1..6534cb4f 100644 --- a/src/context/index.ts +++ b/src/context/index.ts @@ -1,3 +1,2 @@ export * from './StepsSmartContractWizard' -export * from './StorageContractContext' export * from './AppNotificationContext' diff --git a/src/domain/CompileContractRepository.ts b/src/domain/CompileContractRepository.ts deleted file mode 100644 index 5556451e..00000000 --- a/src/domain/CompileContractRepository.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ContractCompiled } from '@/infrastructure' -import { CompileContractBody } from '@/infrastructure/backendApi/ApiCompileContractRepository' - -export interface CompileContractRepository { - create: (compileContract: CompileContractBody) => Promise - search: (codeId: string) => Promise -} diff --git a/src/domain/Contract.ts b/src/domain/Contract.ts old mode 100644 new mode 100755 index 5665377f..1836e8ee --- a/src/domain/Contract.ts +++ b/src/domain/Contract.ts @@ -1,7 +1,7 @@ import { TokenType } from '@/domain/TokenType' -import { ContractResponse } from '@/infrastructure' +import { ContractCompiledRaw } from '@/infrastructure' -export type ContractMetadata = ContractResponse +export type ContractMetadata = ContractCompiledRaw interface ContractDetails { code_id: string diff --git a/src/domain/UserContractDetails.ts b/src/domain/UserContractDetails.ts new file mode 100644 index 00000000..13668f66 --- /dev/null +++ b/src/domain/UserContractDetails.ts @@ -0,0 +1,41 @@ +import { TokenType } from '@/domain/TokenType' +import { ContractCompiledRaw } from '@/infrastructure' + +export type ContractMetadata = ContractCompiledRaw + +export interface UserContractDetails { + userAddress: string + blockchain: string + address: string + txHash: string + codeHash: string + type?: TokenType + name: string + abi?: Record + date: string + external: boolean +} + +export type ContractCompiled = Pick< + UserContractDetails, + 'userAddress' | 'codeHash' | 'name' | 'name' +> & { + type: TokenType +} + +// export type ContractDeployed = Required & { +// status: 'deployed' +// } +// export type UserContracts = ContractCompiled | ContractDeployed + +// export function isContractCompiled( +// contract: UserContracts +// ): contract is ContractCompiled { +// return contract.status === 'compiled' +// } + +// export function isContractDeployed( +// contract: UserContracts +// ): contract is ContractDeployed { +// return contract.status === 'deployed' +// } diff --git a/src/domain/index.ts b/src/domain/index.ts index d128de99..f9087c00 100644 --- a/src/domain/index.ts +++ b/src/domain/index.ts @@ -1,4 +1,4 @@ -export * from './Contract' +export * from './UserContractDetails' export * from './DomainEvents' export * from './TokenType' export * from './WizardContractConfig' diff --git a/src/domain/repositories/CompileContractRepository.ts b/src/domain/repositories/CompileContractRepository.ts new file mode 100644 index 00000000..70d2e607 --- /dev/null +++ b/src/domain/repositories/CompileContractRepository.ts @@ -0,0 +1,4 @@ +export interface ICompileContractRepository { + create: (compileContract: RawFormat) => Promise + search: (codeId: string) => Promise +} diff --git a/src/domain/repositories/DeploymentRepository.ts b/src/domain/repositories/DeploymentRepository.ts new file mode 100644 index 00000000..5aa6a4fa --- /dev/null +++ b/src/domain/repositories/DeploymentRepository.ts @@ -0,0 +1,18 @@ +import { ChainId } from '@/infrastructure/useink/chains' +import { TokenType } from '../TokenType' + +// TODO implement on API +type ContractType = TokenType | 'custom' + +export interface DeploymentItem { + contractName: TokenType + contractAddress: string + network: ChainId + codeId: string + userAddress: string +} + +export interface IDeploymentsRepository { + add: (deployment: DeploymentItem) => Promise + findBy: (userAddress: string, networkId?: ChainId) => Promise +} diff --git a/src/domain/repositories/IUserContractsRepository.ts b/src/domain/repositories/IUserContractsRepository.ts new file mode 100644 index 00000000..0745ed13 --- /dev/null +++ b/src/domain/repositories/IUserContractsRepository.ts @@ -0,0 +1,16 @@ +import { ChainId } from '@/infrastructure/useink/chains' +import { UserContractDetails } from '../UserContractDetails' +import { DeploymentItem } from './DeploymentRepository' + +export interface IUserContractsRepository { + add: (deployment: UserContractDetails) => Promise + list: (userAddress: string) => Promise + searchBy: ( + userAddress: string, + networkId: ChainId + ) => Promise + bulkAddByUser( + userAddress: string, + deployments: DeploymentItem[] + ): Promise +} diff --git a/src/domain/wizard/ContractTableItem.ts b/src/domain/wizard/ContractTableItem.ts index c5b1907f..208e92d2 100644 --- a/src/domain/wizard/ContractTableItem.ts +++ b/src/domain/wizard/ContractTableItem.ts @@ -1,6 +1,6 @@ -import { Contract } from '@/domain/Contract' +import { UserContractDetails } from '@/domain/UserContractDetails' -export type ContractTableItem = Contract & { +export type ContractTableItem = UserContractDetails & { sourceJsonString?: string isDownloading?: boolean } diff --git a/src/hooks/compileContract/index.ts b/src/hooks/compileContract/index.ts new file mode 100644 index 00000000..1926ad44 --- /dev/null +++ b/src/hooks/compileContract/index.ts @@ -0,0 +1,2 @@ +export * from './useSearchCompileContract' +export * from './useCreateCompileContract' diff --git a/src/hooks/useCompileContract.ts b/src/hooks/compileContract/useCreateCompileContract.ts similarity index 59% rename from src/hooks/useCompileContract.ts rename to src/hooks/compileContract/useCreateCompileContract.ts index 7c858bf6..8acde2d8 100644 --- a/src/hooks/useCompileContract.ts +++ b/src/hooks/compileContract/useCreateCompileContract.ts @@ -7,9 +7,8 @@ import { import { GetServiceData } from '@/types' import { TokenType, SecurityOfToken } from '@/domain' import { BACKEND_API } from '@/constants/index' -import { AllowedFeatures, ContractResponse } from '@/infrastructure' +import { AllowedFeatures, ContractCompiledRaw } from '@/infrastructure' import { useAppNotificationContext } from '@/context/AppNotificationContext' -import { useStorageContractsContext } from '@/context' type ReturnValue = GetServiceData @@ -39,12 +38,11 @@ function getAllowedFeaturesApi( export const useCompileContract = (): ReturnValue & { compileContract: ( props: UseCreateCompilation - ) => Promise + ) => Promise } => { const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState() const { addNotification } = useAppNotificationContext() - const { addContractToStorage } = useStorageContractsContext() const compileContract = useCallback( async ({ @@ -53,7 +51,7 @@ export const useCompileContract = (): ReturnValue & { tokenType, security, isPausable - }: UseCreateCompilation): Promise => { + }: UseCreateCompilation): Promise => { setError(undefined) setIsLoading(true) @@ -64,48 +62,6 @@ export const useCompileContract = (): ReturnValue & { features: getAllowedFeaturesApi(tokenType, security, isPausable) }) - setIsLoading(false) - if (response.error) { - console.log(response.error.message) - throw Error(response.error.message) - } - addContractToStorage(address, { - code_id: response.data.code_id, - status: 'compiled', - type: tokenType - }) - return response['data'] - } catch (error) { - const _errorMsg = `An error occurred when trying to compile the smart contract on the server` - setError(_errorMsg) - addNotification({ - message: _errorMsg, - type: 'error' - }) - console.error(error) - } - }, - [addContractToStorage, addNotification] - ) - - return { compileContract, isLoading, error } -} - -export const useSearchCompileContract = (): ReturnValue & { - searchCompileContract: (codeId: string) => Promise -} => { - const [isLoading, setIsLoading] = useState(false) - const [error, setError] = useState() - const { addNotification } = useAppNotificationContext() - - const searchCompileContract = useCallback( - async (codeId: string): Promise => { - setError(undefined) - setIsLoading(true) - - try { - const response = await compileContractApi.search(codeId) - setIsLoading(false) if (response.error) { console.log(response.error.message) @@ -114,7 +70,7 @@ export const useSearchCompileContract = (): ReturnValue & { return response['data'] } catch (error) { - const _errorMsg = `An error occurred when trying to search compiled contract` + const _errorMsg = `An error occurred when trying to compile the smart contract on the server` setError(_errorMsg) addNotification({ message: _errorMsg, @@ -126,5 +82,5 @@ export const useSearchCompileContract = (): ReturnValue & { [addNotification] ) - return { searchCompileContract, isLoading, error } + return { compileContract, isLoading, error } } diff --git a/src/hooks/compileContract/useSearchCompileContract.ts b/src/hooks/compileContract/useSearchCompileContract.ts new file mode 100644 index 00000000..90c480c7 --- /dev/null +++ b/src/hooks/compileContract/useSearchCompileContract.ts @@ -0,0 +1,44 @@ +import { useAppNotificationContext } from '@/context' +import { useLocalDbContext } from '@/context/LocalDbContext' +import { ContractCompiledRaw } from '@/infrastructure' +import { GetServiceData } from '@/types' +import { useCallback, useState } from 'react' + +export const useSearchCompileContract = (): GetServiceData & { + searchCompileContract: (codeId: string) => Promise +} => { + const [isLoading, setIsLoading] = useState(false) + const [error, setError] = useState() + const { addNotification } = useAppNotificationContext() + const { compileContractRepository } = useLocalDbContext() + + const searchCompileContract = useCallback( + async (codeId: string): Promise => { + setError(undefined) + setIsLoading(true) + + try { + const response = await compileContractRepository.search(codeId) + + setIsLoading(false) + if (response.error) { + console.log(response.error.message) + throw Error(response.error.message) + } + + return response['data'] + } catch (error) { + const _errorMsg = `An error occurred when trying to search compiled contract` + setError(_errorMsg) + addNotification({ + message: _errorMsg, + type: 'error' + }) + console.error(error) + } + }, + [addNotification, compileContractRepository] + ) + + return { searchCompileContract, isLoading, error } +} diff --git a/src/hooks/deployments/useCreateContractsDeployments.ts b/src/hooks/deployments/useCreateContractsDeployments.ts new file mode 100644 index 00000000..fe66ed38 --- /dev/null +++ b/src/hooks/deployments/useCreateContractsDeployments.ts @@ -0,0 +1,41 @@ +import { useCallback, useState } from 'react' + +import { DeploymentItem } from '@/domain/repositories/DeploymentRepository' +import { useLocalDbContext } from '@/context/LocalDbContext' + +interface UseAddDeployment { + newDeployment: (deployment: DeploymentItem) => Promise + isLoading: boolean + error?: string +} + +export function useCreateContractDeployments(): UseAddDeployment { + const [isLoading, setIsLoading] = useState(false) + const [error, setError] = useState() + const { deploymentsRepository } = useLocalDbContext() + + const newDeployment = useCallback( + async (deployment: DeploymentItem): Promise => { + setError(undefined) + setIsLoading(true) + + try { + const response = await deploymentsRepository.add(deployment) + + setIsLoading(false) + if (response.error) { + console.log(response.error.message) + throw Error(response.error.message) + } + return response['data'] + } catch (error) { + const _errorMsg = `An error occurred when trying to compile the smart contract on the server` + setError(_errorMsg) + console.error(error) + } + }, + [deploymentsRepository] + ) + + return { newDeployment, isLoading, error } +} diff --git a/src/hooks/deployments/useListContractsDeployments.ts b/src/hooks/deployments/useListContractsDeployments.ts new file mode 100644 index 00000000..ec5b894b --- /dev/null +++ b/src/hooks/deployments/useListContractsDeployments.ts @@ -0,0 +1,44 @@ +import { useCallback, useState } from 'react' + +import { DeploymentItem } from '@/domain/repositories/DeploymentRepository' +import { useLocalDbContext } from '@/context/LocalDbContext' +import { getErrorMessage } from '@/utils/error' +import { ChainId } from '@/infrastructure/useink/chains' + +interface UseAddDeployment { + userContractsFromApi: ( + userAddress: string, + networkId?: ChainId + ) => Promise + isLoading: boolean + error?: string +} + +export function useListContractDeployments(): UseAddDeployment { + const [isLoading, setIsLoading] = useState(false) + const [error, setError] = useState() + const { deploymentsRepository } = useLocalDbContext() + + const userContractsFromApi = useCallback( + async (userAddress: string, networkId?: ChainId) => { + setIsLoading(true) + setError(undefined) + + try { + const deployments = await deploymentsRepository.findBy( + userAddress, + networkId + ) + + return deployments + } catch (e) { + setError(getErrorMessage(e)) + } finally { + setIsLoading(false) + } + }, + [deploymentsRepository] + ) + + return { userContractsFromApi, isLoading, error } +} diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 0b1d80be..c3f127df 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -2,7 +2,7 @@ export * from './useMatchDownSM' export * from './userThemeSettings' export * from './useClickOutside' export * from './useQueryToken' -export * from './useCompileContract' export * from './useCopyToClipboard' export * from './useOnceWhen' export * from './useFormInput' +export * from './compileContract' diff --git a/src/hooks/useDeployContract.ts b/src/hooks/useDeployContract.ts index 8689b1f9..13ac07f9 100644 --- a/src/hooks/useDeployContract.ts +++ b/src/hooks/useDeployContract.ts @@ -11,8 +11,7 @@ import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' import { BIG_ZERO_BN } from '@/constants/numbers' import { ContractConstructorDataForm } from '@/domain/wizard/step3DeployForm.types' import { deployContractService } from '@/infrastructure/deployContract' -import { useStorageContractsContext } from '@/context' -import { ContractDeployed, ContractMetadata, TokenType } from '@/domain' +import { ContractMetadata, TokenType, UserContractDetails } from '@/domain' import { genRanHex } from '@/utils/blockchain' import { contractDryRun, @@ -20,13 +19,15 @@ import { } from '@/infrastructure/contractDryRun' import { useReportError } from './useReportError' import { useNetworkApi } from '@/hooks/useNetworkApi' +import { ChainId } from '@/infrastructure/useink/chains' type ReturnValue = GetServiceData export type UseDeployContract = ContractMetadata & { argsForm: ContractConstructorDataForm tokenType: TokenType - blockchain: ContractDeployed['blockchain'] + blockchain: ChainId + successCallback?: (contractDeployed: UserContractDetails) => void } type UIStorageDeposit = { @@ -109,12 +110,13 @@ function createInstatiateTx( } export const useDeployContract = (): ReturnValue & { - deployContract: (props: UseDeployContract) => Promise + deployContract: ( + props: UseDeployContract + ) => Promise } => { const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState() const { reportErrorWithToast } = useReportError() - const { addContractToStorage } = useStorageContractsContext() const { accountConnected } = useNetworkAccountsContext() const currentAccount = accountConnected?.address const { apiPromise: api } = useNetworkApi() @@ -126,8 +128,9 @@ export const useDeployContract = (): ReturnValue & { argsForm, code_id, tokenType, - blockchain - }: UseDeployContract): Promise => { + blockchain, + successCallback + }: UseDeployContract): Promise => { if (!currentAccount || !api) return setIsLoading(true) setError(undefined) @@ -159,17 +162,19 @@ export const useDeployContract = (): ReturnValue & { ) const result = await deployContractService({ api, tx, currentAccount }) - const contractDeployed = { - code_id, - type: tokenType, - status: 'deployed' as const, - address: result.contractAddress, + const contractDeployed: UserContractDetails = { + userAddress: currentAccount, blockchain, - name: '', - txHash: result.txHash.toString() + txHash: result.txHash, + address: result.contractAddress, + codeHash: code_id, + name: tokenType, + abi: metadataAbi.json, + date: new Date().toISOString(), + external: false } - addContractToStorage(currentAccount, contractDeployed) + successCallback?.(contractDeployed) return contractDeployed } catch (error) { @@ -178,7 +183,7 @@ export const useDeployContract = (): ReturnValue & { setIsLoading(false) } }, - [addContractToStorage, api, currentAccount, reportErrorWithToast] + [api, currentAccount, reportErrorWithToast] ) return { isLoading, error, deployContract } diff --git a/src/hooks/useMultipleEventListener.ts b/src/hooks/useMultipleEventListener.ts index 42d293e8..b0950577 100644 --- a/src/hooks/useMultipleEventListener.ts +++ b/src/hooks/useMultipleEventListener.ts @@ -8,7 +8,7 @@ type EventNames = | keyof typeof SmartContractEvents export function useMultiEventListener( - events: EventNames[], // accept any array of strings as event names + events: EventNames[] | EventNames, // accept any array of strings as event names callback: EventCallback ): void { const callbackRef = useRef(callback) @@ -25,14 +25,16 @@ export function useMultiEventListener( callback() } - events.forEach(eventName => { + const _events = Array.isArray(events) ? events : [events] + + _events.forEach(eventName => { document.addEventListener(eventName, handleEvent) }) return () => { - events.forEach(eventName => { + _events.forEach(eventName => { document.removeEventListener(eventName, handleEvent) }) } - }, [callback, events]) + }, [events, callback]) } diff --git a/src/hooks/useOnceEffect.ts b/src/hooks/useOnceEffect.ts new file mode 100644 index 00000000..42c4b2d1 --- /dev/null +++ b/src/hooks/useOnceEffect.ts @@ -0,0 +1,23 @@ +import { useEffect, useRef, DependencyList } from 'react' + +export function useOnceEffect( + callback: () => void, + dependencies: TDeps +) { + const hasRun = useRef(false) + + useEffect(() => { + if (!hasRun.current) { + if (dependencies.every(dep => dep !== undefined && dep !== null)) { + callback() + hasRun.current = true + } + } + }, [callback, dependencies]) + + const reset = () => { + hasRun.current = false + } + + return { reset } +} diff --git a/src/hooks/userContracts/useAddUserContracts.ts b/src/hooks/userContracts/useAddUserContracts.ts new file mode 100644 index 00000000..0cf8e6af --- /dev/null +++ b/src/hooks/userContracts/useAddUserContracts.ts @@ -0,0 +1,21 @@ +import { useCallback } from 'react' + +import { useLocalDbContext } from '@/context/LocalDbContext' +import { UserContractDetails } from '@/domain' + +interface UseAddDeployment { + addUserContract: (deployment: UserContractDetails) => void +} + +export function useAddUserContracts(): UseAddDeployment { + const { userContractsRepository } = useLocalDbContext() + + const addUserContract = useCallback( + (deployment: UserContractDetails) => { + userContractsRepository.add(deployment) + }, + [userContractsRepository] + ) + + return { addUserContract } +} diff --git a/src/hooks/userContracts/useListUserContracts.ts b/src/hooks/userContracts/useListUserContracts.ts new file mode 100644 index 00000000..63cdff93 --- /dev/null +++ b/src/hooks/userContracts/useListUserContracts.ts @@ -0,0 +1,77 @@ +import { use, useCallback, useState } from 'react' + +import { useLocalDbContext } from '@/context/LocalDbContext' +import { UserContractDetails, WalletConnectionEvents } from '@/domain' +import { useListContractDeployments } from '../deployments/useListContractsDeployments' +import { useOnceEffect } from '../useOnceEffect' +import { useMultiEventListener } from '../useMultipleEventListener' +import { ChainId } from '@/infrastructure/useink/chains' + +interface UseAddDeployment { + userContracts: UserContractDetails[] + isLoading: boolean + error?: string +} + +export function useListUserContracts( + userAddress: string | undefined, + networkConnected: ChainId +): UseAddDeployment { + const [isLoading, setIsLoading] = useState(false) + const [error, setError] = useState() + const { userContractsRepository } = useLocalDbContext() + const { userContractsFromApi } = useListContractDeployments() + const [userContracts, setUserContracts] = useState([]) + + const readInitialData = useCallback(async () => { + if (!userAddress) return + setIsLoading(true) + const userContracts = await userContractsRepository.searchBy( + userAddress, + networkConnected + ) + + if (userContracts.length > 0) { + setUserContracts(userContracts) + setIsLoading(false) + return + } + + userContractsFromApi(userAddress, networkConnected).then( + async deployments => { + deployments && + (await userContractsRepository.bulkAddByUser( + userAddress, + deployments + )) + userContractsRepository + .searchBy(userAddress, networkConnected) + .then(setUserContracts) + } + ) + }, [ + networkConnected, + userAddress, + userContractsFromApi, + userContractsRepository + ]) + + const { reset } = useOnceEffect(() => { + readInitialData() + }, [ + userAddress, + networkConnected, + userContractsFromApi, + userContractsRepository + ]) + + useMultiEventListener( + [ + WalletConnectionEvents.changeAccountAddress, + WalletConnectionEvents.networkChanged + ], + () => reset() + ) + + return { userContracts, isLoading, error } +} diff --git a/src/infrastructure/DeploymentApiRepository.ts b/src/infrastructure/DeploymentApiRepository.ts deleted file mode 100644 index b35cbd0f..00000000 --- a/src/infrastructure/DeploymentApiRepository.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { BackendApiConfig } from '@/constants/config' - -export class DeploymentApiRepository { - constructor(private readonly backenApiConfig: BackendApiConfig) {} -} diff --git a/src/infrastructure/LocalStorageContractRepository.ts b/src/infrastructure/LocalStorageContractRepository.ts deleted file mode 100644 index 482a336d..00000000 --- a/src/infrastructure/LocalStorageContractRepository.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Contract } from '@/domain/Contract' - -export interface AccountContractsMap { - [account: string]: Array -} - -export interface StorageContractRepository { - searchBy(accountAddress: string): Contract[] - save(accountAddress: string, smartContract: Contract): void -} - -export class LocalStorageContractRepository - implements StorageContractRepository -{ - localStorageKey = 'repositoryContracts' - - search(): AccountContractsMap { - const mapContracts = localStorage.getItem(this.localStorageKey) - - if (!mapContracts) { - return {} - } - - return JSON.parse(mapContracts) as AccountContractsMap - } - - searchBy(accountAddress: string): Contract[] { - const mapContracts = this.search() - - if (!(accountAddress in mapContracts)) { - return [] - } - - return mapContracts[accountAddress] - } - - save(accountAddress: string, smartContract: Contract): void { - const accountContracts = this.searchBy(accountAddress) - - this.update({ - [accountAddress]: this.addOrReplaceContract( - accountContracts, - smartContract - ) - }) - } - - private update(accountContracts: AccountContractsMap): void { - const mapContracts = this.search() - - localStorage.setItem( - this.localStorageKey, - JSON.stringify({ ...mapContracts, ...accountContracts }) - ) - } - - private addOrReplaceContract(contracts: Contract[], newContract: Contract) { - const index = contracts.findIndex( - item => item.code_id === newContract.code_id - ) - - if (index === -1) { - return [...contracts, newContract] - } else { - const updatedList = [...contracts] - updatedList[index] = newContract - - return updatedList - } - } -} diff --git a/src/infrastructure/backendApi/ApiCompileContractRepository.ts b/src/infrastructure/backendApi/ApiCompileContractRepository.ts index 78c37b81..d29477cc 100644 --- a/src/infrastructure/backendApi/ApiCompileContractRepository.ts +++ b/src/infrastructure/backendApi/ApiCompileContractRepository.ts @@ -1,6 +1,10 @@ import { BackendApiConfig } from '@/constants/config' -import { CompileContractRepository } from '@/domain/CompileContractRepository' -import { AllowedFeatures, ContractCompiled, request } from '@/infrastructure' +import { ICompileContractRepository } from '@/domain/repositories/CompileContractRepository' +import { + AllowedFeatures, + ContractCompiledResponse, + request +} from '@/infrastructure' export interface CompileContractBody { address: string @@ -8,16 +12,23 @@ export interface CompileContractBody { features: AllowedFeatures[] } +export type IApiCompileContractRepository = ICompileContractRepository< + CompileContractBody, + ContractCompiledResponse +> + /* * Class that implements the Repository pattern for * handling contracts compiled via the backend REST API. */ -export class ApiCompileContractRepository implements CompileContractRepository { +export class ApiCompileContractRepository + implements IApiCompileContractRepository +{ constructor(private readonly backenApiConfig: BackendApiConfig) {} async create( compileContract: CompileContractBody - ): Promise { + ): Promise { return request(this.backenApiConfig.routes.createCompileContract.url, { method: this.backenApiConfig.routes.createCompileContract.method, body: JSON.stringify(this.filterNullSecurity(compileContract)) @@ -34,8 +45,11 @@ export class ApiCompileContractRepository implements CompileContractRepository { async search(codeId: string) { const { url, method } = this.backenApiConfig.routes.searchCompileContract - return request(`${url}${encodeURIComponent(codeId)}`, { - method: method - }) + return request( + `${url}${encodeURIComponent(codeId)}`, + { + method: method + } + ) } } diff --git a/src/infrastructure/backendApi/ApiDeploymentRepository.ts b/src/infrastructure/backendApi/ApiDeploymentRepository.ts new file mode 100644 index 00000000..476e2cc0 --- /dev/null +++ b/src/infrastructure/backendApi/ApiDeploymentRepository.ts @@ -0,0 +1,71 @@ +import { BackendApiConfig } from '@/constants/config' +import { + DeploymentItem, + IDeploymentsRepository +} from '@/domain/repositories/DeploymentRepository' +import { ChainId } from '@/infrastructure/useink/chains' +import { request } from '@/infrastructure/common/request' +import { RootApiResponse } from './types' + +interface DeploymentRaw { + contract_name: string + contract_address: string + network: ChainId + code_id: string + user_address: string +} + +export type IApiDeploymentRepository = IDeploymentsRepository< + RootApiResponse, + DeploymentItem[] +> + +function adaptDeployment(deploymentRaw: DeploymentRaw): DeploymentItem { + return { + contractName: deploymentRaw.contract_name as DeploymentItem['contractName'], + contractAddress: deploymentRaw.contract_address, + network: deploymentRaw.network, + codeId: deploymentRaw.code_id, + userAddress: deploymentRaw.user_address + } +} + +export class ApiDeploymentRepository implements IApiDeploymentRepository { + constructor(private readonly backenApiConfig: BackendApiConfig) {} + + async add(deployment: DeploymentItem): Promise> { + return request>( + this.backenApiConfig.routes.createDeployment.url, + { + method: this.backenApiConfig.routes.createCompileContract.method, + body: JSON.stringify({ + contract_name: deployment.contractName, + contract_address: deployment.contractAddress, + network: deployment.network, + code_id: deployment.codeId, + user_address: deployment.userAddress + }) + } + ) + } + + async findBy( + userAddress: string, + networkId?: ChainId | undefined + ): Promise { + const { url, method } = this.backenApiConfig.routes.listDeployment + + const suffixUrl = networkId + ? `&network=${encodeURIComponent(networkId)}` + : '' + + const { data } = await request>( + `${url}${encodeURIComponent(userAddress)}${suffixUrl}`, + { + method: method + } + ) + + return data.map(e => adaptDeployment(e)) + } +} diff --git a/src/infrastructure/types.ts b/src/infrastructure/backendApi/types.ts similarity index 70% rename from src/infrastructure/types.ts rename to src/infrastructure/backendApi/types.ts index c3985663..c86ddb63 100644 --- a/src/infrastructure/types.ts +++ b/src/infrastructure/backendApi/types.ts @@ -5,13 +5,13 @@ export interface RootApiResponse { error?: { message: string } } -export interface ContractResponse { +export interface ContractCompiledRaw { code_id: string metadata: string wasm: Uint8Array } -export type ContractCompiled = RootApiResponse +export type ContractCompiledResponse = RootApiResponse export type AllowedFeatures = | TokenType diff --git a/src/infrastructure/common/request.ts b/src/infrastructure/common/request.ts index f7ee38f7..719658ef 100644 --- a/src/infrastructure/common/request.ts +++ b/src/infrastructure/common/request.ts @@ -5,6 +5,7 @@ export async function request( config: RequestInit ): Promise { const response = await fetch(url, config) + return await response.json() } diff --git a/src/infrastructure/deployContract.ts b/src/infrastructure/deployContract.ts index 7e5c7d33..b6332e43 100644 --- a/src/infrastructure/deployContract.ts +++ b/src/infrastructure/deployContract.ts @@ -7,7 +7,8 @@ import { getErrorMessage } from '@/utils/error' export interface DeployContractService { contractAddress: string - txHash: number + txHash: string + blockNumber: number } type DeployContractParams = { @@ -79,8 +80,9 @@ export async function deployContractService({ unsub() return resolve({ - txHash: blockNumber, - contractAddress + txHash: tx.hash.toString(), + contractAddress, + blockNumber }) } } diff --git a/src/infrastructure/index.ts b/src/infrastructure/index.ts index 5de2f7e8..6d689925 100644 --- a/src/infrastructure/index.ts +++ b/src/infrastructure/index.ts @@ -1,2 +1,2 @@ -export * from './types' +export * from './backendApi/types' export * from './common/request' diff --git a/src/infrastructure/localDB/UserContractsRepository.ts b/src/infrastructure/localDB/UserContractsRepository.ts new file mode 100644 index 00000000..6fdba0a7 --- /dev/null +++ b/src/infrastructure/localDB/UserContractsRepository.ts @@ -0,0 +1,51 @@ +import { UserContractDetails } from '@/domain' +import { MyDatabase } from '.' +import { IUserContractsRepository } from '@/domain/repositories/IUserContractsRepository' +import { ChainId } from '../useink/chains' +import { DeploymentItem } from '@/domain/repositories/DeploymentRepository' + +export class UserContractsRepository implements IUserContractsRepository { + private db: MyDatabase + + constructor(db: MyDatabase) { + this.db = db + } + + async add(userContract: UserContractDetails): Promise { + return this.db.userContracts.add(userContract) + } + + async list(userAddress: string): Promise { + return await this.db.userContracts.where({ userAddress }).toArray() + } + + async searchBy( + userAddress: string, + blockchain: ChainId + ): Promise { + return await this.db.userContracts + .where({ userAddress, blockchain }) + .toArray() + } + + async bulkAddByUser( + userAddress: string, + deployments: DeploymentItem[] + ): Promise { + const data: UserContractDetails[] = deployments.map(d => ({ + userAddress: d.userAddress, + blockchain: d.network, + address: d.contractAddress, + txHash: '', + codeHash: d.codeId, + type: d.contractName, + name: d.contractName, + date: new Date().toISOString(), + external: false + })) + + await this.db.userContracts.bulkAdd(data) + + return await this.list(userAddress) + } +} diff --git a/src/infrastructure/localDB/index.ts b/src/infrastructure/localDB/index.ts new file mode 100644 index 00000000..0a7c0bf9 --- /dev/null +++ b/src/infrastructure/localDB/index.ts @@ -0,0 +1,17 @@ +import Dexie from 'dexie' + +import { UserContractDetails } from '@/domain' + +export class MyDatabase extends Dexie { + public userContracts: Dexie.Table + + constructor() { + super('MyDatabase') + + this.version(1).stores({ + userContracts: '[userAddress+blockchain+address],blockchain,external' + }) + + this.userContracts = this.table('userContracts') + } +} diff --git a/src/utils/browserMethods.ts b/src/utils/browserMethods.ts new file mode 100644 index 00000000..d4814dc6 --- /dev/null +++ b/src/utils/browserMethods.ts @@ -0,0 +1,3 @@ +export const openInNewTab = (url: string) => { + window.open(url, '_blank', 'noopener, noreferrer') +} diff --git a/src/utils/formatString.ts b/src/utils/formatString.ts index 983d052c..4a13ba92 100644 --- a/src/utils/formatString.ts +++ b/src/utils/formatString.ts @@ -93,3 +93,32 @@ export function emptyAsDash(value: string | undefined): string { export function takeFirstChars(str: string, nChars = 6): string { return str.slice(0, nChars) } + +/** + * Converts a Date or ISO date string to a human-readable format. + * + * @param {Date | string} lastUpdate - The date to be converted. + * @returns {string} A human-readable representation of the time elapsed since `lastUpdate`. + */ +export const isoToReadableDate = (lastUpdate: Date | string): string => { + const lastUpdateDate = + typeof lastUpdate === 'string' ? new Date(lastUpdate) : lastUpdate + + if (isNaN(lastUpdateDate.getTime())) { + throw new Error('Invalid date input') + } + + const currentDate = new Date() + const diffTime = currentDate.getTime() - lastUpdateDate.getTime() + const diffDays = Math.round(diffTime / (1000 * 3600 * 24)) + + if (diffDays === 0) { + return 'today' + } + + if (diffDays > 30) { + return 'more than a month ago' + } + + return `${diffDays} days ago` +} diff --git a/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx b/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx index 5967bbf9..57f23c99 100644 --- a/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx +++ b/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx @@ -5,46 +5,22 @@ import { Table, TableBody, TableCell, - TableContainer, - TableContainerProps, TableHead, TableRow, Typography, Stack, Tooltip } from '@mui/material' -import { styled } from '@mui/material/styles' import FileDownloadIcon from '@mui/icons-material/FileDownload' import HourglassBottomIcon from '@mui/icons-material/HourglassBottom' import { CopyToClipboardButton, TokenIconSvg } from '@/components' -import { capitalizeFirstLetter, truncateAddress } from '@/utils/formatString' -import { TokenType, isContractDeployed } from '@/domain' +import { isoToReadableDate, truncateAddress } from '@/utils/formatString' +import { TokenType } from '@/domain' import { ContractTableItem } from '@/domain/wizard/ContractTableItem' import { useRecentlyClicked } from 'src/hooks/useRecentlyClicked' import { MonoTypography } from '@/components' - -const StyledTableContainer = styled(TableContainer)( - ({ theme }) => ({ - [theme.breakpoints.down('md')]: { - /* styles here */ - }, - '& .MuiTable-root': { - margin: '2rem auto', - width: '80%' - }, - '& .MuiTableCell-root': { - color: theme.palette.secondary.light, - fontSize: '1.1rem', - fontFeatureSettings: '"ss01", "ss02"' - } - }) -) - -const TokenWrapper = styled(Stack)(() => ({ - flexDirection: 'row', - gap: '0.5rem' -})) +import { StyledTableContainer, TokenWrapper } from './styled' const typeMap: Record = { psp34: 'NFT', @@ -63,53 +39,42 @@ function ContractTableRow({ }: { contract: ContractTableItem } & Pick) { - const _isContractDeployed = isContractDeployed(contract) const { ref: refButton, recentlyClicked } = useRecentlyClicked() const isDownloading = recentlyClicked || contract.isDownloading + const type = contract.name as TokenType return ( - - {typeMap[contract.type]} + + {typeMap[type]} - {_isContractDeployed && contract.address && ( - - - {truncateAddress(contract.address, 4)} - - - - )} - - - + + + {truncateAddress(contract.address, 4)} + + + + {isoToReadableDate(contract.date)} onDownloadMeta(contract.code_id)} + disabled={isDownloading} + onClick={() => onDownloadMeta(contract.codeHash)} > {isDownloading ? ( ) : ( - + )} @@ -133,14 +98,14 @@ export function ContractsTable({ TYPE ADDRESS - STATUS + ADDED METADATA {contracts.map(contract => ( diff --git a/src/view/HomeView/ContractsTableWidget/index.tsx b/src/view/HomeView/ContractsTableWidget/index.tsx index e865962b..82426cb5 100644 --- a/src/view/HomeView/ContractsTableWidget/index.tsx +++ b/src/view/HomeView/ContractsTableWidget/index.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react' import { ContractsTable } from '@/view/HomeView/ContractsTableWidget/ContractsTable' import { useSearchCompileContract } from '@/hooks' -import { Contract } from '@/domain' +import { UserContractDetails } from '@/domain' import { ContractTableItem } from '@/domain/wizard/ContractTableItem' import { downloadMetadata } from '@/utils/downloadMetadata' @@ -13,7 +13,7 @@ function updateContractItem( 'isDownloading' | 'sourceJsonString' > ) { - const index = contractsItem.findIndex(item => item.code_id === codeId) + const index = contractsItem.findIndex(item => item.codeHash === codeId) if (index) { contractsItem[index] = { @@ -25,7 +25,11 @@ function updateContractItem( return contractsItem } -export function ContractsTableWidget({ contracts }: { contracts: Contract[] }) { +export function ContractsTableWidget({ + contracts +}: { + contracts: UserContractDetails[] +}) { const { searchCompileContract } = useSearchCompileContract() const [contractsItem, setContractsItem] = useState(contracts) @@ -46,7 +50,7 @@ export function ContractsTableWidget({ contracts }: { contracts: Contract[] }) { const searchMetadata = async (codeId: string): Promise => { const contractWithMeta = contractsItem.find( - contract => contract.code_id === codeId && contract.sourceJsonString + contract => contract.codeHash === codeId && contract.sourceJsonString ) if (contractWithMeta) return contractWithMeta.sourceJsonString diff --git a/src/view/HomeView/ContractsTableWidget/styled.ts b/src/view/HomeView/ContractsTableWidget/styled.ts new file mode 100644 index 00000000..47d5a6c6 --- /dev/null +++ b/src/view/HomeView/ContractsTableWidget/styled.ts @@ -0,0 +1,24 @@ +import { TableContainer, TableContainerProps, Stack } from '@mui/material' +import { styled } from '@mui/material/styles' + +export const StyledTableContainer = styled(TableContainer)( + ({ theme }) => ({ + [theme.breakpoints.down('md')]: { + /* styles here */ + }, + '& .MuiTable-root': { + margin: '2rem auto', + width: '80%' + }, + '& .MuiTableCell-root': { + color: theme.palette.secondary.light, + fontSize: '1.1rem', + fontFeatureSettings: '"ss01", "ss02"' + } + }) +) + +export const TokenWrapper = styled(Stack)(() => ({ + flexDirection: 'row', + gap: '0.5rem' +})) diff --git a/src/view/components/ModalWallet/index.tsx b/src/view/components/ModalWallet/index.tsx index 2e50174a..7282af8f 100644 --- a/src/view/components/ModalWallet/index.tsx +++ b/src/view/components/ModalWallet/index.tsx @@ -18,6 +18,7 @@ import { ModalStyledListItem, ModalTypography } from './styled' +import { openInNewTab } from '@/utils/browserMethods' type Props = { open: boolean @@ -33,6 +34,7 @@ export function ModalWallet({ }: Props) { const walletInstalled = wallets.filter(wallet => wallet.installed) const walletNotInstalled = wallets.filter(wallet => !wallet.installed) + return ( @@ -86,8 +88,7 @@ export function ModalWallet({ <> { - setCurrentWallet(w) - handleClose() + openInNewTab(w.installUrl) }} > diff --git a/src/view/components/TokenIconSvg/index.tsx b/src/view/components/TokenIconSvg/index.tsx index c3c4aeee..6616441d 100644 --- a/src/view/components/TokenIconSvg/index.tsx +++ b/src/view/components/TokenIconSvg/index.tsx @@ -31,6 +31,8 @@ const mapSmallIconSize: MapSmallIconSize = tokenTypes }, {} as MapSmallIconSize) export function TokenIconSvg({ label }: Props) { + if (!TITLE_MAP_TOKEN[label]) return null + const { title, imgPath } = TITLE_MAP_TOKEN[label] const { width, height } = mapSmallIconSize[label] diff --git a/src/view/components/WalletConnectButton/index.tsx b/src/view/components/WalletConnectButton/index.tsx index a5ae19f9..756c2ff5 100644 --- a/src/view/components/WalletConnectButton/index.tsx +++ b/src/view/components/WalletConnectButton/index.tsx @@ -9,7 +9,6 @@ import { ModalWallet } from '../ModalWallet' import { Box } from '@mui/material' import { NetworkSelect } from './NetworkSelect' import CircleIcon from '@mui/icons-material/Circle' -import { WALLET_IMG_DETAILS } from '@/constants/wallets' import { useRecentlyClicked } from '@/hooks/useRecentlyClicked' import { useDelay } from '@/hooks/useDelay' @@ -24,7 +23,7 @@ export const ButtonConnection = styled(StyledButton)(() => ({ export const WalletConnectButton = () => { const { - state: { accountStatus, walletKey, allWallets, accounts }, + state: { accountStatus, allWallets, accounts }, isConnected, disconnectWallet, accountConnected, @@ -38,7 +37,6 @@ export const WalletConnectButton = () => { const noAccounts = accountStatus === 'CONNECTED' && accounts?.length === 0 const { ref: buttonRef, recentlyClicked } = useRecentlyClicked() const isLoading = recentlyClicked || !isDelayFinished - // console.log('__isConnected', isConnected, accountConnected) return ( <> @@ -78,7 +76,6 @@ export const WalletConnectButton = () => { setAccount={setCurrentAccount} disconnectWallet={disconnectWallet} /> - ) ) )} diff --git a/src/view/wizardView/GridDeployInfo.tsx b/src/view/wizardView/GridDeployInfo.tsx index 4b76aca3..6ca9573b 100644 --- a/src/view/wizardView/GridDeployInfo.tsx +++ b/src/view/wizardView/GridDeployInfo.tsx @@ -2,9 +2,9 @@ import React from 'react' import { Box, BoxProps, Stack, Typography } from '@mui/material' import { styled } from '@mui/material/styles' -import { ContractDeployed } from '@/domain' import { emptyAsDash, truncateAddress } from '@/utils/formatString' import { CopyToClipboardButton, MonoTypography } from '@/components' +import { UserContractDetails } from '@/domain' const BoxGridStyled = styled(Box)(() => ({ display: 'grid', @@ -21,7 +21,7 @@ const BoxRow = styled(Box)(() => ({ export function GridDeployInfo({ deployedContract }: { - deployedContract: ContractDeployed | undefined + deployedContract: UserContractDetails | undefined }) { return ( diff --git a/src/view/wizardView/Step3Deploy/index.tsx b/src/view/wizardView/Step3Deploy/index.tsx index 0eed3207..9f56a911 100755 --- a/src/view/wizardView/Step3Deploy/index.tsx +++ b/src/view/wizardView/Step3Deploy/index.tsx @@ -1,10 +1,10 @@ import React, { useEffect, useMemo, useRef, useState } from 'react' -import { Grid, Stack, Typography } from '@mui/material' +import { Grid, Typography } from '@mui/material' import Image from 'next/image' import { useStepsSCWizard } from '@/context' import BackNextButton from '../BackNextButtons' -import { TokenType } from '@/domain' +import { TokenType, UserContractDetails } from '@/domain' import { ControlsToken, GIF_COMPILING, @@ -12,32 +12,37 @@ import { SVG_SUCCESSFULLY } from '@/constants/index' import { FormEvent } from '@/domain/common/FormEvent' -import { useCompileContract } from 'src/hooks/useCompileContract' -import { ContractResponse } from '@/infrastructure' +import { useCompileContract } from '@/hooks/compileContract' +import { ContractCompiledRaw } from '@/infrastructure' import { generateCode } from '../Step2Compile/generator' import { useDeployContract } from 'src/hooks/useDeployContract' import { ContractConstructorDataForm } from '@/domain/wizard/step3DeployForm.types' import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' -import { ContractDeployed } from '@/domain' import { useRecentlyClicked } from 'src/hooks/useRecentlyClicked' import { FormConstructorContract, ConstructorTokenFieldProps } from './FormConstructorContract' +import { useCreateContractDeployments } from '@/hooks/deployments/useCreateContractsDeployments' +import { ChainId } from '@/infrastructure/useink/chains' +import { StackStyled } from './styled' +import { useAddUserContracts } from '@/hooks/userContracts/useAddUserContracts' + +interface StepDeployProps { + tokenType: TokenType + constructorFields?: ControlsToken<'Constructor'> + onDeployContract: (deployedContract: UserContractDetails) => void +} export default function Step3Deploy({ constructorFields, tokenType, onDeployContract -}: { - tokenType: TokenType - constructorFields?: ControlsToken<'Constructor'> - onDeployContract: (deployedContract: ContractDeployed) => void -}) { - const { networkConnected } = useNetworkAccountsContext() +}: StepDeployProps) { + const { networkConnected, accountConnected } = useNetworkAccountsContext() const { handleBack, handleNext, dataForm } = useStepsSCWizard() const [contractCompiled, setContractCompiled] = useState< - ContractResponse | undefined + ContractCompiledRaw | undefined >() const hasMetadata = Boolean(dataForm.extensions.Metadata) const { compileContract } = useCompileContract() @@ -51,6 +56,8 @@ export default function Step3Deploy({ const { deployContract, isLoading: isDeploying } = useDeployContract() const { ref: refButton, recentlyClicked } = useRecentlyClicked(500) const _isDeploying = recentlyClicked || isDeploying + const { newDeployment } = useCreateContractDeployments() + const { addUserContract } = useAddUserContracts() useEffect(() => { if (!dataForm.currentAccount || !mustLoad.current) return @@ -101,7 +108,7 @@ export default function Step3Deploy({ const _handleDeploy = async ( constructorParams: ContractConstructorDataForm ) => { - if (!contractCompiled || !networkConnected) return + if (!contractCompiled || !networkConnected || !accountConnected) return const result = await deployContract({ wasm: contractCompiled.wasm, @@ -109,7 +116,17 @@ export default function Step3Deploy({ argsForm: constructorParams, code_id: contractCompiled.code_id, tokenType, - blockchain: networkConnected + blockchain: networkConnected, + successCallback: userContractsDetail => { + newDeployment({ + userAddress: accountConnected.address, + contractName: userContractsDetail.name as TokenType, + codeId: userContractsDetail.codeHash, + contractAddress: userContractsDetail.address, + network: userContractsDetail.blockchain as ChainId + }) + addUserContract(userContractsDetail) + } }) if (result) { @@ -122,17 +139,7 @@ export default function Step3Deploy({ <> - + {contractCompiledYour contract is being compiled by us.

)} -
+ {contractConstructorFields.length > 0 && ( (() => ({ + background: '#20222D', + borderRadius: '1rem', + alignItems: 'center', + maxWidth: '30rem', + margin: '2rem auto 3rem auto', + padding: '0 1rem', + flexDirection: 'row' +})) diff --git a/src/view/wizardView/index.tsx b/src/view/wizardView/index.tsx index 97dfd572..ca0d9028 100644 --- a/src/view/wizardView/index.tsx +++ b/src/view/wizardView/index.tsx @@ -11,7 +11,7 @@ import { factoryControlsToken, factoryOptionTokenValues } from 'src/domain/wizard/factoriesContract' -import { ContractDeployed, TokenType } from '@/domain' +import { TokenType, UserContractDetails } from '@/domain' import { StackCard } from '@/components' import { GridDeployInfo } from './GridDeployInfo' @@ -32,7 +32,8 @@ export default function FormWizard({ token: TokenType }): JSX.Element { const [activeStep, setActiveStep] = useState(0) - const [deployedContract, setDeployedContract] = useState() + const [deployedContract, setDeployedContract] = + useState() const { extensionFields, constructorFields } = useMemo(() => { return factoryControlsToken(token) }, [token]) diff --git a/tests/utils/isoToReadableDate.test.ts b/tests/utils/isoToReadableDate.test.ts new file mode 100644 index 00000000..70d6b0bb --- /dev/null +++ b/tests/utils/isoToReadableDate.test.ts @@ -0,0 +1,32 @@ +import { isoToReadableDate } from '@/utils/formatString' + +describe('isoToReadableDate', () => { + it('should return "today" when lastUpdate is today', () => { + const currentDate = new Date() + const result = isoToReadableDate(currentDate) + expect(result).toBe('today') + }) + + it('should return "more than a month ago" when lastUpdate is more than 30 days ago', () => { + const lastUpdate = new Date('2023-08-15T08:45:00Z') + const result = isoToReadableDate(lastUpdate) + expect(result).toBe('more than a month ago') + }) + + it('should return the correct number of days ago when lastUpdate is within 30 days', () => { + const currentDate = new Date() + const lastUpdate = new Date(currentDate.getTime() - 2 * 24 * 60 * 60 * 1000) // 2 days ago + const result = isoToReadableDate(lastUpdate) + expect(result).toBe('2 days ago') + }) + + it('should throw an error if lastUpdate is not a valid Date object or ISO date string', () => { + expect(() => isoToReadableDate('invalid date')).toThrow() + }) + + it('should accept a valid ISO date string and return the correct result', () => { + const currentDate = new Date() + const result = isoToReadableDate(currentDate.toISOString()) + expect(result).toBe('today') + }) +}) diff --git a/tests/utils.test.ts b/tests/utils/utils.test.ts similarity index 100% rename from tests/utils.test.ts rename to tests/utils/utils.test.ts diff --git a/yarn.lock b/yarn.lock index c6119868..9ba19229 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3200,6 +3200,11 @@ detect-newline@^3.0.0: resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== +dexie@^3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/dexie/-/dexie-3.2.4.tgz#b22a9729be1102acb2eee16102ea6e2bc76454cf" + integrity sha512-VKoTQRSv7+RnffpOJ3Dh6ozknBqzWw/F3iqMdsZg958R0AS8AnY9x9d1lbwENr0gzeGJHXKcGhAMRaqys6SxqA== + diff-sequences@^29.4.3: version "29.4.3" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.4.3.tgz#9314bc1fabe09267ffeca9cbafc457d8499a13f2" From 52ab0d9631b5b261088a44fbc19cfde639058e97 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:30:31 -0300 Subject: [PATCH 35/47] Bump @types/fs-extra from 11.0.1 to 11.0.2 (#191) Bumps [@types/fs-extra](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/fs-extra) from 11.0.1 to 11.0.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/fs-extra) --- updated-dependencies: - dependency-name: "@types/fs-extra" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 15e60319..335040fd 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@types/big.js": "^6.1.6", - "@types/fs-extra": "^11.0.1", + "@types/fs-extra": "^11.0.2", "@types/jest": "^29.5.1", "@types/node": "^20.6.2", "@types/react": "18.0.38", diff --git a/yarn.lock b/yarn.lock index 9ba19229..4872dedc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1800,10 +1800,10 @@ dependencies: "@types/node" "*" -"@types/fs-extra@^11.0.1": - version "11.0.1" - resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.1.tgz#f542ec47810532a8a252127e6e105f487e0a6ea5" - integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA== +"@types/fs-extra@^11.0.2": + version "11.0.2" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.2.tgz#23dc1ed7b2eba8ccd75568ac34e7a4e48aa2d087" + integrity sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ== dependencies: "@types/jsonfile" "*" "@types/node" "*" From a84cfd707cb6648d24651a40aeea7a37cef4e7cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:46:17 -0300 Subject: [PATCH 36/47] Bump @emotion/react from 11.11.0 to 11.11.1 (#193) Bumps [@emotion/react](https://github.com/emotion-js/emotion) from 11.11.0 to 11.11.1. - [Release notes](https://github.com/emotion-js/emotion/releases) - [Changelog](https://github.com/emotion-js/emotion/blob/main/CHANGELOG.md) - [Commits](https://github.com/emotion-js/emotion/compare/@emotion/react@11.11.0...@emotion/react@11.11.1) --- updated-dependencies: - dependency-name: "@emotion/react" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 335040fd..f34da37a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dependencies": { "@ant-design/colors": "^7.0.0", "@emotion/cache": "^11.10.5", - "@emotion/react": "^11.11.0", + "@emotion/react": "^11.11.1", "@emotion/server": "^11.10.0", "@emotion/styled": "^11.10.5", "@mui/icons-material": "^5.14.7", diff --git a/yarn.lock b/yarn.lock index 4872dedc..d029c4dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -434,10 +434,10 @@ resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.1.tgz#c1ddb040429c6d21d38cc945fe75c818cfb68e17" integrity sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA== -"@emotion/react@^11.11.0": - version "11.11.0" - resolved "https://registry.yarnpkg.com/@emotion/react/-/react-11.11.0.tgz#408196b7ef8729d8ad08fc061b03b046d1460e02" - integrity sha512-ZSK3ZJsNkwfjT3JpDAWJZlrGD81Z3ytNDsxw1LKq1o+xkmO5pnWfr6gmCC8gHEFf3nSSX/09YrG67jybNPxSUw== +"@emotion/react@^11.11.1": + version "11.11.1" + resolved "https://registry.yarnpkg.com/@emotion/react/-/react-11.11.1.tgz#b2c36afac95b184f73b08da8c214fdf861fa4157" + integrity sha512-5mlW1DquU5HaxjLkfkGN1GA/fvVGdyHURRiX/0FHl2cfIfRxSOfmxEH5YS43edp0OldZrZ+dkBKbngxcNCdZvA== dependencies: "@babel/runtime" "^7.18.3" "@emotion/babel-plugin" "^11.11.0" From d0558ef9a74b739e6593643cfa68c426f4a3fe33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:46:32 -0300 Subject: [PATCH 37/47] Bump @types/big.js from 6.1.6 to 6.2.0 (#192) Bumps [@types/big.js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/big.js) from 6.1.6 to 6.2.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/big.js) --- updated-dependencies: - dependency-name: "@types/big.js" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f34da37a..875b0533 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "devDependencies": { "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", - "@types/big.js": "^6.1.6", + "@types/big.js": "^6.2.0", "@types/fs-extra": "^11.0.2", "@types/jest": "^29.5.1", "@types/node": "^20.6.2", diff --git a/yarn.lock b/yarn.lock index d029c4dd..d2ef2581 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1788,10 +1788,10 @@ dependencies: "@babel/types" "^7.3.0" -"@types/big.js@^6.1.6": - version "6.1.6" - resolved "https://registry.yarnpkg.com/@types/big.js/-/big.js-6.1.6.tgz#3d417e758483d55345a03a087f7e0c87137ca444" - integrity sha512-0r9J+Zz9rYm2hOTwiMAVkm3XFQ4u5uTK37xrQMhc9bysn/sf/okzovWMYYIBMFTn/yrEZ11pusgLEaoarTlQbA== +"@types/big.js@^6.2.0": + version "6.2.0" + resolved "https://registry.yarnpkg.com/@types/big.js/-/big.js-6.2.0.tgz#e1f6a9a6ce64bc7c131137e71fbad34a5574f987" + integrity sha512-ubLURWoc4tCw/8Yds0P3CE9cBG5q+aoycwWBiXXx4gp7XPYZy9ch0L9+Pv6osSoSRgvuQNqJdlwEhP5QhKKl6w== "@types/bn.js@^5.1.1": version "5.1.1" From 9be515987644e5343553ccd4dd9c24cce01ebe9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 15:48:24 -0300 Subject: [PATCH 38/47] Bump cypress from 12.17.3 to 13.2.0 (#190) Bumps [cypress](https://github.com/cypress-io/cypress) from 12.17.3 to 13.2.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/CHANGELOG.md) - [Commits](https://github.com/cypress-io/cypress/compare/v12.17.3...v13.2.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 44 +++++++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 875b0533..d2a11ec3 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@types/whatwg-url": "^11.0.0", "@typescript-eslint/eslint-plugin": "^5.59.8", "@typescript-eslint/parser": "^5.61.0", - "cypress": "^12.17.3", + "cypress": "^13.2.0", "eslint": "^8.49.0", "eslint-config-next": "13.1.1", "eslint-config-prettier": "^9.0.0", diff --git a/yarn.lock b/yarn.lock index d2ef2581..e8f0660b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -345,10 +345,10 @@ resolved "https://registry.yarnpkg.com/@ctrl/tinycolor/-/tinycolor-3.6.0.tgz#53fa5fe9c34faee89469e48f91d51a3766108bc8" integrity sha512-/Z3l6pXthq0JvMYdUFyX9j0MaCltlIn6mfh9jLyQwg5aPKxkyNa0PTHtU1AlFXLNk55ZuAeJRcpvq+tmLfKmaQ== -"@cypress/request@^2.88.11": - version "2.88.12" - resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590" - integrity sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA== +"@cypress/request@^3.0.0": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@cypress/request/-/request-3.0.1.tgz#72d7d5425236a2413bd3d8bb66d02d9dc3168960" + integrity sha512-TWivJlJi8ZDx2wGOw1dbLuHJKUYX7bWySw377nlnGOW3hP9/MUKIsEdXT/YngWxVdgNCHRBmFlBipE+5/2ZZlQ== dependencies: aws-sign2 "~0.7.0" aws4 "^1.8.0" @@ -363,7 +363,7 @@ json-stringify-safe "~5.0.1" mime-types "~2.1.19" performance-now "^2.1.0" - qs "~6.10.3" + qs "6.10.4" safe-buffer "^5.1.2" tough-cookie "^4.1.3" tunnel-agent "^0.6.0" @@ -1892,10 +1892,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.2.tgz#a065925409f59657022e9063275cd0b9bd7e1b12" integrity sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw== -"@types/node@^16.18.39": - version "16.18.39" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.39.tgz#aa39a1a87a40ef6098ee69689a1acb0c1b034832" - integrity sha512-8q9ZexmdYYyc5/cfujaXb4YOucpQxAV4RMG0himLyDUOEr8Mr79VrqsFI+cQ2M2h89YIuy95lbxuYjxT4Hk4kQ== +"@types/node@^18.17.5": + version "18.17.19" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.17.19.tgz#80c9b8a89d3648d9e6098f4a7184e03833fee3c5" + integrity sha512-+pMhShR3Or5GR0/sp4Da7FnhVmTalWm81M6MkEldbwjETSaPalw138Z4KdpQaistvqQxLB7Cy4xwYdxpbSOs9Q== "@types/parse-json@^4.0.0": version "4.0.0" @@ -3000,14 +3000,14 @@ csstype@^3.0.2, csstype@^3.1.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b" integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ== -cypress@^12.17.3: - version "12.17.3" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.3.tgz#1e2b19037236fc60e4a4b3a14f0846be17a1fc0e" - integrity sha512-/R4+xdIDjUSLYkiQfwJd630S81KIgicmQOLXotFxVXkl+eTeVO+3bHXxdi5KBh/OgC33HWN33kHX+0tQR/ZWpg== +cypress@^13.2.0: + version "13.2.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.2.0.tgz#10f73d06a0764764ffbb903a31e96e2118dcfc1d" + integrity sha512-AvDQxBydE771GTq0TR4ZUBvv9m9ffXuB/ueEtpDF/6gOcvFR96amgwSJP16Yhqw6VhmwqspT5nAGzoxxB+D89g== dependencies: - "@cypress/request" "^2.88.11" + "@cypress/request" "^3.0.0" "@cypress/xvfb" "^1.2.4" - "@types/node" "^16.18.39" + "@types/node" "^18.17.5" "@types/sinonjs__fake-timers" "8.1.1" "@types/sizzle" "^2.3.2" arch "^2.2.0" @@ -3040,6 +3040,7 @@ cypress@^12.17.3: minimist "^1.2.8" ospath "^1.2.2" pretty-bytes "^5.6.0" + process "^0.11.10" proxy-from-env "1.0.0" request-progress "^3.0.0" semver "^7.5.3" @@ -6147,6 +6148,11 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== + prompts@^2.0.1: version "2.4.2" resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" @@ -6204,10 +6210,10 @@ pure-rand@^6.0.0: resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.2.tgz#a9c2ddcae9b68d736a8163036f088a2781c8b306" integrity sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ== -qs@~6.10.3: - version "6.10.5" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.5.tgz#974715920a80ff6a262264acd2c7e6c2a53282b4" - integrity sha512-O5RlPh0VFtR78y79rgcgKK4wbAI0C5zGVLztOIdpWX6ep368q5Hv6XRxDvXuZ9q3C6v+e3n8UfZZJw7IIG27eQ== +qs@6.10.4: + version "6.10.4" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.4.tgz#6a3003755add91c0ec9eacdc5f878b034e73f9e7" + integrity sha512-OQiU+C+Ds5qiH91qh/mg0w+8nwQuLjM4F4M/PbmhDOoYehPh+Fb0bDjtR1sOvy7YKxvj28Y/M0PhP5uVX0kB+g== dependencies: side-channel "^1.0.4" From 55f4036f215911340246abb3479b8523d516a3f1 Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Thu, 28 Sep 2023 10:59:34 -0300 Subject: [PATCH 39/47] Removing mui/lab (#196) * Removing paths * Moving pages * Using LoadingButton * Fixing /pages --- jest.config.js | 14 +- package.json | 3 +- src/context/settingsTheme.tsx | 2 +- src/hooks/useDeployContract.ts | 2 +- src/hooks/useNetworkApi.ts | 2 +- {pages => src/pages}/404.tsx | 2 +- {pages => src/pages}/_app.tsx | 13 +- {pages => src/pages}/_document.tsx | 0 {pages => src/pages}/docs/index.tsx | 0 {pages => src/pages}/index.tsx | 2 +- {pages => src/pages}/wizard/index.tsx | 6 +- src/themes/index.tsx | 2 +- .../ContractsTableWidget/ContractsTable.tsx | 3 +- src/view/components/Button/index.tsx | 39 --- src/view/components/LoadingButton/index.tsx | 56 ++++ src/view/components/LoadingButton/styled.tsx | 49 +++ src/view/components/Logo/index.tsx | 2 +- src/view/components/LogoMobile/index.tsx | 2 +- src/view/components/Snackbar/index.tsx | 2 +- .../components/WalletConnectButton/index.tsx | 24 +- src/view/components/index.ts | 3 +- src/view/layout/Header/MobileSection.tsx | 6 +- src/view/layout/MainDrawer/DrawerContent.tsx | 4 +- src/view/layout/MainDrawer/DrawerHeader.tsx | 2 +- src/view/layout/MainLayout.tsx | 2 +- src/view/wizardView/BackNextButtons.tsx | 6 +- src/view/wizardView/Step2Compile/index.tsx | 4 +- src/view/wizardView/Step3Deploy/index.tsx | 8 +- src/view/wizardView/index.tsx | 2 +- styles/Home.module.css | 278 ------------------ tsconfig.json | 16 +- tsconfig.paths.json | 64 ---- yarn.lock | 13 +- 33 files changed, 175 insertions(+), 458 deletions(-) rename {pages => src/pages}/404.tsx (95%) rename {pages => src/pages}/_app.tsx (86%) rename {pages => src/pages}/_document.tsx (100%) rename {pages => src/pages}/docs/index.tsx (100%) rename {pages => src/pages}/index.tsx (96%) rename {pages => src/pages}/wizard/index.tsx (76%) delete mode 100644 src/view/components/Button/index.tsx create mode 100644 src/view/components/LoadingButton/index.tsx create mode 100644 src/view/components/LoadingButton/styled.tsx delete mode 100644 styles/Home.module.css delete mode 100644 tsconfig.paths.json diff --git a/jest.config.js b/jest.config.js index 698fe1bf..33174dc9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,19 +9,7 @@ const customJestConfig = { testMatch: ['/tests/**/*.(test).(ts|tsx)'], moduleNameMapper: { '^@/tests/(.*)$': '/tests/$1', - '^@/pages/(.*)$': '/pages/$1', - '^@/view/(.*)$': '/src/view/$1', - '^@/utils/(.*)$': '/src/utils/$1', - '^@/constants/(.*)$': '/src/constants/$1', - '^@/context$': '/src/context', - '^@/context/(.*)$': '/src/context/$1', - '^@/components': '/src/view/components', - '^@/domain$': '/src/domain', - '^@/domain/(.*)$': '/src/domain/$1', - '^@/infrastructure$': '/src/infrastructure', - '^@/infrastructure/(.*)$': '/src/infrastructure/$1', - '^@/hooks': '/src/hooks', - '^@/hooks/(.*)$': '/src/hooks/$1' + '^@/components': '/src/view/components' } } module.exports = createJestConfig(customJestConfig) diff --git a/package.json b/package.json index d2a11ec3..5a750122 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "@mui/icons-material": "^5.14.7", "@mui/lab": "^5.0.0-alpha.137", "@mui/material": "^5.11.4", - "@next/font": "13.4.19", "@polkadot/api": "^10.4.1", "@polkadot/api-contract": "^10.4.1", "@polkadot/extension-dapp": "^0.46.3", @@ -81,7 +80,7 @@ "prettier": "^2.8.3", "stylelint-config-prettier": "^9.0.4", "stylelint-prettier": "^3.0.0", - "typescript": "5.0.4" + "typescript": "5.1.3" }, "lint-staged": { "src/**/*.{js,ts,jsx,tsx}": [ diff --git a/src/context/settingsTheme.tsx b/src/context/settingsTheme.tsx index 5b92a8e1..91125d1f 100644 --- a/src/context/settingsTheme.tsx +++ b/src/context/settingsTheme.tsx @@ -4,7 +4,7 @@ import { getLocalStorageState, setLocalStorageState } from '@/utils/localStorage' -import { Settings } from 'src/themes/types' +import { Settings } from '@/themes/types' const ITEM_LOCAL_STORAGE = 'settingsTheme' diff --git a/src/hooks/useDeployContract.ts b/src/hooks/useDeployContract.ts index 13ac07f9..24182f72 100644 --- a/src/hooks/useDeployContract.ts +++ b/src/hooks/useDeployContract.ts @@ -7,7 +7,7 @@ import { WeightV2 } from '@polkadot/types/interfaces' import { Bytes } from '@polkadot/types' import { GetServiceData } from '@/types' -import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' +import { useNetworkAccountsContext } from '@/context/NetworkAccountsContext' import { BIG_ZERO_BN } from '@/constants/numbers' import { ContractConstructorDataForm } from '@/domain/wizard/step3DeployForm.types' import { deployContractService } from '@/infrastructure/deployContract' diff --git a/src/hooks/useNetworkApi.ts b/src/hooks/useNetworkApi.ts index 99f13770..1dd6a7e4 100644 --- a/src/hooks/useNetworkApi.ts +++ b/src/hooks/useNetworkApi.ts @@ -1,7 +1,7 @@ import { ApiPromise } from '@polkadot/api' import { useApi } from 'useink' -import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' +import { useNetworkAccountsContext } from '@/context/NetworkAccountsContext' export interface UseNetworkApi { apiPromise: ApiPromise diff --git a/pages/404.tsx b/src/pages/404.tsx similarity index 95% rename from pages/404.tsx rename to src/pages/404.tsx index cfc833b8..c779ee2e 100644 --- a/pages/404.tsx +++ b/src/pages/404.tsx @@ -5,7 +5,7 @@ import { styled } from '@mui/material/styles' import Typography from '@mui/material/Typography' import Box, { BoxProps } from '@mui/material/Box' import Link from '@mui/material/Link' -import BlankLayout from 'src/view/layout/BlankLayout' +import BlankLayout from '@/view/layout/BlankLayout' const BoxWrapper = styled(Box)(({ theme }) => ({ [theme.breakpoints.down('md')]: { diff --git a/pages/_app.tsx b/src/pages/_app.tsx similarity index 86% rename from pages/_app.tsx rename to src/pages/_app.tsx index 8111996e..a211cb1f 100644 --- a/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -5,20 +5,19 @@ import Head from 'next/head' import { EmotionCache } from '@emotion/cache' import { CacheProvider } from '@emotion/react' import PlausibleProvider from 'next-plausible' -import '../styles/globals.css' -import '../public/fonts/inter.css' +import 'styles/globals.css' import 'react-toastify/dist/ReactToastify.css' import ThemeCustomization from '@/themes' -import { MainLayout } from 'src/view/layout' +import { MainLayout } from '@/view/layout' import { buildEmotionCache } from '@/utils/builderEmotionCache' -import { SettingsConsumer } from 'src/context/settingsTheme' -import { NetworkAccountsContextProvider } from 'src/context/NetworkAccountsContext' +import { SettingsConsumer } from '@/context/settingsTheme' +import { NetworkAccountsContextProvider } from '@/context/NetworkAccountsContext' import { AppNotificationContextProvider, StorageNotificationsRepository -} from 'src/context/AppNotificationContext' -import { CustomSnackBar as AppNotification } from 'src/view/components/Snackbar' +} from '@/context/AppNotificationContext' +import { CustomSnackBar as AppNotification } from '@/view/components/Snackbar' import { DAPP_CONFIG, DOMAIN } from '@/constants/config' import { UseInkProvider } from 'useink' import { CHAINS } from '@/constants/chains' diff --git a/pages/_document.tsx b/src/pages/_document.tsx similarity index 100% rename from pages/_document.tsx rename to src/pages/_document.tsx diff --git a/pages/docs/index.tsx b/src/pages/docs/index.tsx similarity index 100% rename from pages/docs/index.tsx rename to src/pages/docs/index.tsx diff --git a/pages/index.tsx b/src/pages/index.tsx similarity index 96% rename from pages/index.tsx rename to src/pages/index.tsx index 9c68a838..2cd389d3 100644 --- a/pages/index.tsx +++ b/src/pages/index.tsx @@ -4,7 +4,7 @@ import { Stack, Typography } from '@mui/material' import { HomeButton } from '@/components' import { ROUTES, TOKEN_PATHS } from '@/constants/index' import { TokenType } from '@/domain' -import { useNetworkAccountsContext } from 'src/context/NetworkAccountsContext' +import { useNetworkAccountsContext } from '@/context/NetworkAccountsContext' import { ContractsTableWidget } from '@/view/HomeView/ContractsTableWidget' import { useListUserContracts } from '@/hooks/userContracts/useListUserContracts' diff --git a/pages/wizard/index.tsx b/src/pages/wizard/index.tsx similarity index 76% rename from pages/wizard/index.tsx rename to src/pages/wizard/index.tsx index 10c81e9c..296b06f4 100644 --- a/pages/wizard/index.tsx +++ b/src/pages/wizard/index.tsx @@ -1,10 +1,10 @@ import { Box } from '@mui/material' import { useRouter } from 'next/router' -import FormWizard from 'src/view/wizardView' +import FormWizard from '@/view/wizardView' import { isOfTypeTokens } from '@/domain' -import LoadingSpinner from 'src/view/components/LoadingSpinner' -import { HeadLine } from 'src/view/components/HeadLine' +import LoadingSpinner from '@/view/components/LoadingSpinner' +import { HeadLine } from '@/view/components/HeadLine' export default function WizardPage() { const router = useRouter() diff --git a/src/themes/index.tsx b/src/themes/index.tsx index 0f1c91ec..cbdb684f 100644 --- a/src/themes/index.tsx +++ b/src/themes/index.tsx @@ -5,7 +5,7 @@ import { createTheme, ThemeProvider } from '@mui/material/styles' import Palette from './palette' import typographyOptions from './typography' import CustomShadows from './shadows' -import { Settings } from 'src/themes/types' +import { Settings } from '@/themes/types' import componentsOverride from './overrides' // ==============================|| DEFAULT THEME - MAIN ||============================== // diff --git a/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx b/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx index 57f23c99..fd3433e1 100644 --- a/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx +++ b/src/view/HomeView/ContractsTableWidget/ContractsTable.tsx @@ -1,7 +1,6 @@ import * as React from 'react' import { IconButton, - Chip, Table, TableBody, TableCell, @@ -18,7 +17,7 @@ import { CopyToClipboardButton, TokenIconSvg } from '@/components' import { isoToReadableDate, truncateAddress } from '@/utils/formatString' import { TokenType } from '@/domain' import { ContractTableItem } from '@/domain/wizard/ContractTableItem' -import { useRecentlyClicked } from 'src/hooks/useRecentlyClicked' +import { useRecentlyClicked } from '@/hooks/useRecentlyClicked' import { MonoTypography } from '@/components' import { StyledTableContainer, TokenWrapper } from './styled' diff --git a/src/view/components/Button/index.tsx b/src/view/components/Button/index.tsx deleted file mode 100644 index f3d573f7..00000000 --- a/src/view/components/Button/index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { styled } from '@mui/material/styles' -import { LoadingButton, LoadingButtonProps } from '@mui/lab' - -export type MyButtonProps = LoadingButtonProps - -export const StyledButton = styled(LoadingButton)( - ({ theme, loading }) => ({ - textTransform: 'uppercase', - color: theme.palette.primary.main, - fontSize: '1.4rem', - borderRadius: '5rem', - padding: '8px 16px', - minWidth: '11rem', - border: '1px solid', - backgroundColor: '#e6007b2f', - - '&:hover': { - backgroundColor: '#e6007b83', - color: 'white', - border: '1px solid #c00569 ' - }, - - ...(!loading && { - '&:disabled': { - color: theme.palette.grey[600] - } - }), - - '&.MuiButton-outlined': { - color: 'white', - borderColor: theme.palette.primary.main, - backgroundColor: 'transparent', - '&:hover': { - backgroundColor: theme.palette.primary.main, - border: '1px solid' - } - } - }) -) diff --git a/src/view/components/LoadingButton/index.tsx b/src/view/components/LoadingButton/index.tsx new file mode 100644 index 00000000..7c109c9c --- /dev/null +++ b/src/view/components/LoadingButton/index.tsx @@ -0,0 +1,56 @@ +import Box from '@mui/material/Box' +import { ButtonProps } from '@mui/material/Button' +import CircularProgress from '@mui/material/CircularProgress' +import * as React from 'react' +import { ReactNode } from 'react' +import { StyledButton } from './styled' + +export interface LoadingButtonProps + extends Pick< + ButtonProps, + 'ref' | 'onClick' | 'variant' | 'size' | 'children' | 'sx' | 'disabled' + > { + isLoading?: boolean + startIcon?: ReactNode + endIcon?: ReactNode +} + +export const LoadingButton: React.FC = React.forwardRef< + HTMLButtonElement, + LoadingButtonProps +>(function RefLoadingButton( + { isLoading, children, startIcon, endIcon, disabled, ...props }, + ref +) { + return ( + + + {children} + + {isLoading && ( + + )} + + ) +}) diff --git a/src/view/components/LoadingButton/styled.tsx b/src/view/components/LoadingButton/styled.tsx new file mode 100644 index 00000000..8f7990b8 --- /dev/null +++ b/src/view/components/LoadingButton/styled.tsx @@ -0,0 +1,49 @@ +import React from 'react' +import { styled } from '@mui/material/styles' +import { Button, ButtonProps } from '@mui/material' + +interface StyledButtonProps extends ButtonProps { + isLoading?: boolean +} + +export const StyledButtonWrapper = React.forwardRef< + HTMLButtonElement, + StyledButtonProps +>(function RefStyledButton({ isLoading, ...rest }, ref) { + return + + + + ) +} + +export default ConfirmationDialog diff --git a/src/view/components/WalletConnectButton/NetworkSelect.tsx b/src/view/components/WalletConnectButton/NetworkSelect.tsx index e231d92b..2b9edddc 100644 --- a/src/view/components/WalletConnectButton/NetworkSelect.tsx +++ b/src/view/components/WalletConnectButton/NetworkSelect.tsx @@ -10,6 +10,12 @@ import { } from '@mui/material' import { CHAINS_ALLOWED, getChain } from '@/constants/chains' import { ChainId } from '@/infrastructure/useink/chains/types' +import ConfirmationDialog from '../ConfirmationDialog' +import { useModalBehaviour } from '@/hooks/useModalBehaviour' +import { useCompareCurrentPath } from '@/hooks/useCompareCurrentPath' +import { ROUTES } from '@/constants' +import { useEffect, useState } from 'react' +import { useRouter } from 'next/router' const StyledSelect = styled(Select)(() => ({ color: 'white', @@ -60,10 +66,24 @@ export function NetworkSelect({ onChange: (chain: ChainId) => void }) { const chain = getChain(currentChain) + const { closeModal, isOpen, openModal } = useModalBehaviour() + const { isEqual: isCurrentPathHome } = useCompareCurrentPath(ROUTES.HOME) + const [newChainId, setNewChainId] = useState(currentChain) + const router = useRouter() + + useEffect(() => { + setNewChainId(currentChain) + }, [currentChain]) const _handleChangeChain = (event: SelectChangeEvent) => { const chainId = event.target.value as ChainId - onChange(chainId) + setNewChainId(chainId) + + if (isCurrentPathHome) { + onChange(chainId) + } else { + openModal() + } } return ( @@ -89,6 +109,15 @@ export function NetworkSelect({ ))} + { + closeModal() + router.replace(ROUTES.HOME) + onChange(newChainId) + }} + /> ) } From 3f2d32839e3c55d0c6e959f420e2d46211eba9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Mon, 2 Oct 2023 17:20:53 -0300 Subject: [PATCH 45/47] fix wallet connected indicator and disconnect icon (#208) --- .../AccountSelect/index.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/view/components/WalletConnectButton/AccountSelect/index.tsx b/src/view/components/WalletConnectButton/AccountSelect/index.tsx index 35f3d94f..e228768d 100644 --- a/src/view/components/WalletConnectButton/AccountSelect/index.tsx +++ b/src/view/components/WalletConnectButton/AccountSelect/index.tsx @@ -1,7 +1,7 @@ import { SelectChangeEvent, Stack, Avatar } from '@mui/material' import { shortNameLonger, truncateAddress } from '@/utils/formatString' import CircleIcon from '@mui/icons-material/Circle' -import PowerOffIcon from '@mui/icons-material/PowerOff' +import PowerSettingsNewRoundedIcon from '@mui/icons-material/PowerSettingsNewRounded' import { OPTION_FOR_DISCONNECTING } from '@/context/NetworkAccountsContext' import { WalletAccount, @@ -86,20 +86,22 @@ export function AccountSelect({ {shortNameLonger(a.name as string)}

{truncateAddress(a.address)}

- + {accountConnected.address === a.address && ( + + )} )} {a.name === OPTION_FOR_DISCONNECTING && ( <> - + - Disconect Wallet + Disconnect Wallet

From 30ae44c32d7e5aac1ca3b92f5194c8bd99f3894c Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Tue, 3 Oct 2023 10:17:05 -0300 Subject: [PATCH 46/47] Adding the date field to the deployed SC (#209) * Adding SmartContract date deployed * Using date Added on deployContract hook --- src/domain/repositories/DeploymentRepository.ts | 1 + src/infrastructure/backendApi/ApiDeploymentRepository.ts | 7 +++++-- src/infrastructure/contractDryRun.ts | 1 - src/view/wizardView/Step3Deploy/index.tsx | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/domain/repositories/DeploymentRepository.ts b/src/domain/repositories/DeploymentRepository.ts index 5aa6a4fa..ba390b3f 100644 --- a/src/domain/repositories/DeploymentRepository.ts +++ b/src/domain/repositories/DeploymentRepository.ts @@ -10,6 +10,7 @@ export interface DeploymentItem { network: ChainId codeId: string userAddress: string + date: string } export interface IDeploymentsRepository { diff --git a/src/infrastructure/backendApi/ApiDeploymentRepository.ts b/src/infrastructure/backendApi/ApiDeploymentRepository.ts index 476e2cc0..c10284a6 100644 --- a/src/infrastructure/backendApi/ApiDeploymentRepository.ts +++ b/src/infrastructure/backendApi/ApiDeploymentRepository.ts @@ -13,6 +13,7 @@ interface DeploymentRaw { network: ChainId code_id: string user_address: string + date: string } export type IApiDeploymentRepository = IDeploymentsRepository< @@ -26,7 +27,8 @@ function adaptDeployment(deploymentRaw: DeploymentRaw): DeploymentItem { contractAddress: deploymentRaw.contract_address, network: deploymentRaw.network, codeId: deploymentRaw.code_id, - userAddress: deploymentRaw.user_address + userAddress: deploymentRaw.user_address, + date: deploymentRaw.date } } @@ -43,7 +45,8 @@ export class ApiDeploymentRepository implements IApiDeploymentRepository { contract_address: deployment.contractAddress, network: deployment.network, code_id: deployment.codeId, - user_address: deployment.userAddress + user_address: deployment.userAddress, + date: deployment.date }) } ) diff --git a/src/infrastructure/contractDryRun.ts b/src/infrastructure/contractDryRun.ts index 93da7816..c0db0065 100644 --- a/src/infrastructure/contractDryRun.ts +++ b/src/infrastructure/contractDryRun.ts @@ -2,7 +2,6 @@ import { Abi } from '@polkadot/api-contract' import { AbiParam, AbiMessage } from '@polkadot/api-contract/types' import { ApiPromise } from '@polkadot/api' import { ContractInstantiateResult } from '@polkadot/types/interfaces' -import { Registry } from '@polkadot/types-codec/types' import { ContractConstructorDataForm } from '@/domain/wizard/step3DeployForm.types' import { BIG_ZERO_BN } from '@/constants/numbers' diff --git a/src/view/wizardView/Step3Deploy/index.tsx b/src/view/wizardView/Step3Deploy/index.tsx index cbc7df44..afd60a8b 100755 --- a/src/view/wizardView/Step3Deploy/index.tsx +++ b/src/view/wizardView/Step3Deploy/index.tsx @@ -123,7 +123,8 @@ export default function Step3Deploy({ contractName: userContractsDetail.name as TokenType, codeId: userContractsDetail.codeHash, contractAddress: userContractsDetail.address, - network: userContractsDetail.blockchain as ChainId + network: userContractsDetail.blockchain as ChainId, + date: userContractsDetail.date }) addUserContract(userContractsDetail) } From 3c2e6fa89f33512546b81a7f465489c65cc5474b Mon Sep 17 00:00:00 2001 From: Henry Palacios Date: Tue, 3 Oct 2023 10:20:14 -0300 Subject: [PATCH 47/47] Bump version 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab4a5e56..7eef9030 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkadot-contract-wizard", - "version": "0.3.1", + "version": "1.0.0", "private": true, "scripts": { "dev": "next dev",