From 7d750cadf42467d222d2b276dc0f4587c53381c7 Mon Sep 17 00:00:00 2001 From: juliopavila Date: Fri, 12 Jul 2024 12:14:21 -0300 Subject: [PATCH 01/17] feat: libs migration and use vite --- .github/workflows/dev-cd.yaml | 22 +- .github/workflows/prod-release-deploy.yaml | 26 +- .gitignore | 1 + .prettierignore | 5 + packages/app/.env.sample | 22 +- packages/app/.eslintrc.cjs | 19 + packages/app/.prettierrc | 7 +- packages/app/{public => }/index.html | 7 +- packages/app/package.json | 66 +- packages/app/src/components/ActionButton.tsx | 40 +- packages/app/src/components/CircleStep.tsx | 2 +- packages/app/src/components/Collapsable.tsx | 41 +- packages/app/src/components/MultiSelect.tsx | 68 +- .../app/src/components/MultiSelectBlock.tsx | 74 +- .../app/src/components/ethereum/Address.tsx | 4 +- .../src/components/ethereum/AddressChip.tsx | 28 +- .../ethereum/AddressExplorerButton.tsx | 12 +- .../components/ethereum/ContractQueryForm.tsx | 3 +- .../app/src/components/ethereum/HashInfo.tsx | 1 - .../src/components/ethereum/ParamInput.tsx | 50 +- .../app/src/components/icons/LoadingIcon.tsx | 2 +- .../app/src/components/icons/RemoveIcon.tsx | 18 +- .../src/components/input/ArbitratorSelect.tsx | 3 +- .../app/src/components/input/Checkbox.tsx | 24 +- .../src/components/input/CollateralSelect.tsx | 1 - .../app/src/components/input/DisplayField.tsx | 30 +- packages/app/src/components/input/Radio.tsx | 19 +- .../app/src/components/input/TimeSelect.tsx | 100 +- .../app/src/components/layout/AppLayout.tsx | 56 +- packages/app/src/components/layout/Column.tsx | 20 +- packages/app/src/components/layout/Grow.tsx | 8 +- packages/app/src/components/layout/Row.tsx | 22 +- packages/app/src/hooks/useContractQuery.ts | 41 +- .../src/hooks/useSafeAppsSDKWithProvider.ts | 13 +- packages/app/src/index.tsx | 37 +- packages/app/src/services/ens.ts | 84 +- packages/app/src/services/helpers.ts | 8 +- packages/app/src/services/index.ts | 423 +- packages/app/src/services/ipfs.ts | 54 +- packages/app/src/services/reality-eth.ts | 22 +- packages/app/src/services/snapshot.ts | 22 +- packages/app/src/store/modules/helpers.ts | 124 +- packages/app/src/store/modules/index.ts | 53 +- packages/app/src/store/modules/middleware.ts | 48 +- packages/app/src/store/modules/models.ts | 74 +- .../src/store/transactionBuilder/helpers.tsx | 27 +- .../store/transactionBuilder/middleware.ts | 19 +- .../src/store/transactionBuilder/models.ts | 28 +- packages/app/src/utils/contracts.ts | 87 +- packages/app/src/utils/explorers.ts | 189 +- packages/app/src/utils/modulesValidation.ts | 30 +- packages/app/src/utils/networks.ts | 54 +- .../app/src/views/AddModule/ModuleButton.tsx | 37 +- packages/app/src/views/AddModule/index.tsx | 151 +- .../wizards/AMBModuleModal/AMBModuleModal.tsx | 62 +- .../ConnextModule/ConnextModuleModal.tsx | 56 +- .../CustomModule/CustomModuleModal.tsx | 57 +- .../wizards/DelayModule/DelayModuleModal.tsx | 42 +- .../wizards/ExitModule/ExitModuleModal.tsx | 42 +- .../KlerosRealityModuleModal.tsx | 432 +- .../OptimisticGovernorModuleModal.tsx | 5 +- .../AddModule/wizards/OzGovernor/index.tsx | 167 +- .../OzGovernor/sections/Governor/index.tsx | 124 +- .../OzGovernor/sections/Review/index.tsx | 99 +- .../OzGovernor/sections/Token/index.tsx | 168 +- .../OzGovernor/service/moduleDeployment.ts | 94 +- .../OzGovernor/service/tokenValidation.ts | 51 +- .../AddModule/wizards/RealityModule/index.tsx | 159 +- .../sections/Monitoring/index.tsx | 254 +- .../components/OracleTemplate/index.tsx | 126 +- .../RealityModule/sections/Oracle/index.tsx | 200 +- .../ProposalStatus/ProposalDetailsModal.tsx | 119 +- .../RealityModule/sections/Proposal/index.tsx | 8 +- .../RealityModule/sections/Review/index.tsx | 221 +- .../RealityModule/service/moduleDeployment.ts | 71 +- .../RealityModule/service/monitoring.ts | 82 +- .../service/setupService.test.ts | 196 +- .../RealityModule/service/setupService.ts | 99 +- .../service/snapshot-space-pinning.ts | 2 +- .../RealityModuleOldModal.tsx | 10 +- .../services/moduleDeploymentOld.ts | 106 +- .../RolesModifier/RolesV1ModifierModal.tsx | 54 +- .../RolesModifier/RolesV2ModifierModal.tsx | 70 +- .../TellorModule/TellorModuleModal.tsx | 93 +- .../wizards/components/AddModuleModal.tsx | 84 +- packages/app/src/views/Header/index.tsx | 109 +- .../ModuleDetails/ModuleDetailHeader.tsx | 75 +- .../ModuleDetails/ModuleInteractions.tsx | 24 +- .../views/ModuleDetails/ModuleNoAvailable.tsx | 29 +- .../ModulePendingTransaction.tsx | 76 +- .../contract/ContractFunctionHeader.tsx | 45 +- .../contract/ContractFunctionPreviewBlock.tsx | 2 +- .../contract/ContractFunctionQueryBlock.tsx | 91 +- .../contract/ContractFunctionResult.tsx | 54 +- .../contract/ContractInteractions.tsx | 72 +- .../contract/ContractInteractionsPreview.tsx | 39 +- .../contract/ContractReadFunctionsList.tsx | 45 +- .../transaction/AddTransactionBlock.tsx | 156 +- .../transaction/TransactionField.tsx | 4 +- packages/app/src/views/Panel/ModuleList.tsx | 59 +- .../src/views/Panel/PendingModuleStates.tsx | 49 +- packages/app/src/views/Panel/index.tsx | 47 +- .../app/src/views/Panel/item/PanelItem.tsx | 74 +- .../components/TransactionBlockFields.tsx | 34 +- .../components/TransactionBuilderList.tsx | 119 +- .../src/views/TransactionBuilder/index.tsx | 123 +- packages/app/tsconfig.json | 36 +- packages/app/vite.config.ts | 45 + packages/app/yarn.lock | 19257 ++++++---------- 109 files changed, 10663 insertions(+), 15780 deletions(-) create mode 100644 .prettierignore create mode 100644 packages/app/.eslintrc.cjs rename packages/app/{public => }/index.html (72%) create mode 100644 packages/app/vite.config.ts diff --git a/.github/workflows/dev-cd.yaml b/.github/workflows/dev-cd.yaml index 3dd9a287..f6999327 100644 --- a/.github/workflows/dev-cd.yaml +++ b/.github/workflows/dev-cd.yaml @@ -5,16 +5,16 @@ on: branches: master env: - REACT_APP_INFURA_ID: ${{ secrets.REACT_APP_INFURA_ID }} - REACT_APP_ETHERSCAN_KEY: ${{ secrets.REACT_APP_ETHERSCAN_KEY }} - REACT_APP_GNOSISSCAN_KEY: ${{ secrets.REACT_APP_GNOSISSCAN_KEY }} - REACT_APP_POLYGONSCAN_KEY: ${{ secrets.REACT_APP_POLYGONSCAN_KEY }} - REACT_APP_BSCSCAN_KEY: ${{ secrets.REACT_APP_BSCSCAN_KEY }} - REACT_APP_OPTIMISTIC_ETHERSCAN_KEY: ${{ secrets.REACT_APP_OPTIMISTIC_ETHERSCAN_KEY }} - REACT_APP_ARBISCAN_KEY: ${{ secrets.REACT_APP_ARBISCAN_KEY }} - REACT_APP_SNOWTRACE_KEY: ${{ secrets.REACT_APP_SNOWTRACE_KEY }} - REACT_APP_MULTI_SEND_CONTRACT: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761" - REACT_APP_BACKEND_API_URL: "https://api.dev.zodiac.gnosisguild.org/api" + VITE_INFURA_ID: ${{ secrets.VITE_INFURA_ID }} + VITE_ETHERSCAN_KEY: ${{ secrets.VITE_ETHERSCAN_KEY }} + VITE_GNOSISSCAN_KEY: ${{ secrets.VITE_GNOSISSCAN_KEY }} + VITE_POLYGONSCAN_KEY: ${{ secrets.VITE_POLYGONSCAN_KEY }} + VITE_BSCSCAN_KEY: ${{ secrets.VITE_BSCSCAN_KEY }} + VITE_OPTIMISTIC_ETHERSCAN_KEY: ${{ secrets.VITE_OPTIMISTIC_ETHERSCAN_KEY }} + VITE_ARBISCAN_KEY: ${{ secrets.VITE_ARBISCAN_KEY }} + VITE_SNOWTRACE_KEY: ${{ secrets.VITE_SNOWTRACE_KEY }} + VITE_MULTI_SEND_CONTRACT: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761" + VITE_BACKEND_API_URL: "https://api.dev.zodiac.gnosisguild.org/api" jobs: deploy: @@ -37,7 +37,7 @@ jobs: uses: anantaramdas/ipfs-pinata-deploy-action@39bbda1ce1fe24c69c6f57861b8038278d53688d with: pin-name: Zodiac Safe App - Latest — ${ GITHUB_SHA } - path: "./packages/app/build" + path: "./packages/app/dist" pinata-api-key: ${{ secrets.PINATA_API_KEY }} pinata-secret-api-key: ${{ secrets.PINATA_API_SECRET_KEY }} diff --git a/.github/workflows/prod-release-deploy.yaml b/.github/workflows/prod-release-deploy.yaml index e36adb4c..80d29610 100644 --- a/.github/workflows/prod-release-deploy.yaml +++ b/.github/workflows/prod-release-deploy.yaml @@ -5,17 +5,17 @@ on: types: created env: - REACT_APP_INFURA_ID: ${{ secrets.REACT_APP_INFURA_ID }} - REACT_APP_MULTI_SEND_CONTRACT: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761" - REACT_APP_BACKEND_API_URL: "https://api.zodiac.gnosisguild.org/api" - REACT_APP_ETHERSCAN_KEY: ${{ secrets.REACT_APP_ETHERSCAN_KEY }} - REACT_APP_GNOSISSCAN_KEY: ${{ secrets.REACT_APP_GNOSISSCAN_KEY }} - REACT_APP_POLYGONSCAN_KEY: ${{ secrets.REACT_APP_POLYGONSCAN_KEY }} - REACT_APP_BSCSCAN_KEY: ${{ secrets.REACT_APP_BSCSCAN_KEY }} - REACT_APP_OPTIMISTIC_ETHERSCAN_KEY: ${{ secrets.REACT_APP_OPTIMISTIC_ETHERSCAN_KEY }} - REACT_APP_ARBISCAN_KEY: ${{ secrets.REACT_APP_ARBISCAN_KEY }} - REACT_APP_SNOWTRACE_KEY: ${{ secrets.REACT_APP_SNOWTRACE_KEY }} - REACT_APP_BASESCAN_KEY: ${{ secrets.REACT_APP_BASESCAN_KEY }} + VITE_INFURA_ID: ${{ secrets.VITE_INFURA_ID }} + VITE_MULTI_SEND_CONTRACT: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761" + VITE_BACKEND_API_URL: "https://api.zodiac.gnosisguild.org/api" + VITE_ETHERSCAN_KEY: ${{ secrets.VITE_ETHERSCAN_KEY }} + VITE_GNOSISSCAN_KEY: ${{ secrets.VITE_GNOSISSCAN_KEY }} + VITE_POLYGONSCAN_KEY: ${{ secrets.VITE_POLYGONSCAN_KEY }} + VITE_BSCSCAN_KEY: ${{ secrets.VITE_BSCSCAN_KEY }} + VITE_OPTIMISTIC_ETHERSCAN_KEY: ${{ secrets.VITE_OPTIMISTIC_ETHERSCAN_KEY }} + VITE_ARBISCAN_KEY: ${{ secrets.VITE_ARBISCAN_KEY }} + VITE_SNOWTRACE_KEY: ${{ secrets.VITE_SNOWTRACE_KEY }} + VITE_BASESCAN_KEY: ${{ secrets.VITE_BASESCAN_KEY }} jobs: deploy: @@ -38,7 +38,7 @@ jobs: uses: anantaramdas/ipfs-pinata-deploy-action@39bbda1ce1fe24c69c6f57861b8038278d53688d with: pin-name: Zodiac Safe App - Prod — ${ GITHUB_SHA } - path: "./packages/app/build" + path: "./packages/app/dist" pinata-api-key: ${{ secrets.PINATA_API_KEY }} pinata-secret-api-key: ${{ secrets.PINATA_API_SECRET_KEY }} @@ -88,7 +88,7 @@ jobs: uses: JamesIves/github-pages-deploy-action@v4.3.3 with: branch: gh-pages # The branch the action should deploy to. - folder: packages/app/build + folder: packages/app/dist # Deploys a production instance of the backend api to vercel - name: Install Vercel CLI diff --git a/.gitignore b/.gitignore index a9b7a362..3c0148b8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ coverage # production build +dist # misc .DS_Store diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b5971906 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ + +out/ +dist/ +build/ +node_modules/ \ No newline at end of file diff --git a/packages/app/.env.sample b/packages/app/.env.sample index 0da673ad..e762e816 100644 --- a/packages/app/.env.sample +++ b/packages/app/.env.sample @@ -1,15 +1,15 @@ PORT=3000 HTTPS=true -REACT_APP_INFURA_ID= -REACT_APP_MULTI_SEND_CONTRACT=0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761 -REACT_APP_BACKEND_API_URL=http://localhost:3001/api +VITE_INFURA_ID= +VITE_MULTI_SEND_CONTRACT=0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761 +VITE_BACKEND_API_URL=http://localhost:3001/api # Blockchain explorers -REACT_APP_ETHERSCAN_KEY= -REACT_APP_GNOSISSCAN_KEY= -REACT_APP_POLYGONSCAN_KEY= -REACT_APP_BSCSCAN_KEY= -REACT_APP_OPTIMISTIC_ETHERSCAN_KEY= -REACT_APP_ARBISCAN_KEY= -REACT_APP_SNOWTRACE_KEY= -REACT_APP_BASESCAN_KEY= +VITE_ETHERSCAN_KEY= +VITE_GNOSISSCAN_KEY= +VITE_POLYGONSCAN_KEY= +VITE_BSCSCAN_KEY= +VITE_OPTIMISTIC_ETHERSCAN_KEY= +VITE_ARBISCAN_KEY= +VITE_SNOWTRACE_KEY= +VITE_BASESCAN_KEY= diff --git a/packages/app/.eslintrc.cjs b/packages/app/.eslintrc.cjs new file mode 100644 index 00000000..fc8d761d --- /dev/null +++ b/packages/app/.eslintrc.cjs @@ -0,0 +1,19 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + 'prettier' + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/packages/app/.prettierrc b/packages/app/.prettierrc index 070e7fae..0c998bd4 100644 --- a/packages/app/.prettierrc +++ b/packages/app/.prettierrc @@ -1,6 +1,9 @@ { - "printWidth": 90, + "printWidth": 100, "trailingComma": "all", "semi": false, - "singleQuote": false + "useTabs": false, + "tabWidth": 2, + "singleQuote": true, + "jsxSingleQuote": true } diff --git a/packages/app/public/index.html b/packages/app/index.html similarity index 72% rename from packages/app/public/index.html rename to packages/app/index.html index 8eda54e2..9684babe 100644 --- a/packages/app/public/index.html +++ b/packages/app/index.html @@ -2,18 +2,19 @@ - + - - + + Zodiac - Safe App
+