From 7a90acf90be136a152b6459d54b46a6393125a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=AB=EA=A6=B6=EA=A6=A4=EA=A6=BA=EA=A6=B4?= <62529025+spiritbroski@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:04:22 +0700 Subject: [PATCH] add meta code verify (#311) Add meta code verify to check integrity of dashboard --- .../workflows/ci-test-meta-code-verify.yml | 22 + package.json | 6 +- packages/apps/escrow-dashboard/README.md | 10 +- packages/apps/escrow-dashboard/index.html | 1 + packages/apps/escrow-dashboard/package.json | 6 + .../__tests__/generateMerkleTree.test.ts | 72 + .../scripts/generateMerkleTree.ts | 51 + packages/apps/escrow-dashboard/vite.config.ts | 75 +- packages/apps/meta-code-verify/.eslintrc.json | 21 + packages/apps/meta-code-verify/.gitignore | 5 + packages/apps/meta-code-verify/.prettierrc | 12 + packages/apps/meta-code-verify/README.md | 95 + .../_locales/en/messages.json | 116 + .../meta-code-verify/config/v2/manifest.json | 44 + .../meta-code-verify/config/v3/manifest.json | 42 + .../apps/meta-code-verify/images/check.svg | 5 + .../meta-code-verify/images/chevron-right.svg | 14 + .../images/circle-download-cta.svg | 14 + .../images/circle-exclamation-mark.svg | 14 + .../meta-code-verify/images/circle-info.svg | 14 + .../meta-code-verify/images/default_32.png | Bin 0 -> 1186 bytes .../meta-code-verify/images/default_64.png | Bin 0 -> 2563 bytes .../meta-code-verify/images/default_64@2x.png | Bin 0 -> 4532 bytes .../meta-code-verify/images/error-badge.svg | 16 + .../meta-code-verify/images/error-header.svg | 36 + .../meta-code-verify/images/failure_32.png | Bin 0 -> 945 bytes .../meta-code-verify/images/icon-badge.svg | 16 + .../images/loading-header.svg | 36 + .../meta-code-verify/images/menu-badge.svg | 14 + .../apps/meta-code-verify/images/risk_32.png | Bin 0 -> 1274 bytes .../images/temporary-extension-icon.svg | 3 + .../images/temporary-extension-icon128.png | Bin 0 -> 2176 bytes .../images/temporary-extension-icon32.png | Bin 0 -> 756 bytes .../images/temporary-extension-icon48.png | Bin 0 -> 1413 bytes .../images/validated-badge.svg | 16 + .../images/validated-header.svg | 36 + .../meta-code-verify/images/validated_32.png | Bin 0 -> 1180 bytes .../meta-code-verify/images/warning-badge.svg | 16 + .../images/warning-header.svg | 36 + packages/apps/meta-code-verify/images/x.svg | 14 + packages/apps/meta-code-verify/package.json | 46 + .../apps/meta-code-verify/rollup.config.ts | 70 + .../rollup-plugin-clean-once.ts | 45 + .../rollup-plugin-prettier-build-start.ts | 49 + .../rollup-plugin-static-files.ts | 52 + .../rollup-plugin-watch-additional.ts | 24 + .../meta-code-verify/rollup_scripts/utils.ts | 27 + .../apps/meta-code-verify/src/css/popup.css | 280 ++ .../apps/meta-code-verify/src/html/popup.html | 147 ++ .../src/js/__tests__/background.test.ts | 299 +++ .../src/js/__tests__/contentUtils.test.ts | 412 +++ .../js/__tests__/detectKvstoreMeta.test.ts | 14 + .../meta-code-verify/src/js/background.ts | 434 ++++ .../apps/meta-code-verify/src/js/config.ts | 148 ++ .../meta-code-verify/src/js/contentUtils.ts | 1115 ++++++++ .../src/js/detectKvstoreMeta.ts | 11 + .../apps/meta-code-verify/src/js/popup.ts | 355 +++ .../js/tab_state_tracker/FrameStateMachine.ts | 21 + .../src/js/tab_state_tracker/StateMachine.ts | 101 + .../js/tab_state_tracker/TabStateMachine.ts | 90 + .../js/tab_state_tracker/tabStateTracker.ts | 50 + packages/apps/meta-code-verify/tsconfig.json | 6 + .../apps/meta-code-verify/vitest.config.ts | 14 + .../apps/meta-code-verify/vitest.setup.ts | 103 + yarn.lock | 2242 ++++++++++++++++- 65 files changed, 6946 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/ci-test-meta-code-verify.yml create mode 100644 packages/apps/escrow-dashboard/scripts/__tests__/generateMerkleTree.test.ts create mode 100644 packages/apps/escrow-dashboard/scripts/generateMerkleTree.ts create mode 100644 packages/apps/meta-code-verify/.eslintrc.json create mode 100644 packages/apps/meta-code-verify/.gitignore create mode 100644 packages/apps/meta-code-verify/.prettierrc create mode 100644 packages/apps/meta-code-verify/README.md create mode 100644 packages/apps/meta-code-verify/_locales/en/messages.json create mode 100644 packages/apps/meta-code-verify/config/v2/manifest.json create mode 100644 packages/apps/meta-code-verify/config/v3/manifest.json create mode 100644 packages/apps/meta-code-verify/images/check.svg create mode 100644 packages/apps/meta-code-verify/images/chevron-right.svg create mode 100644 packages/apps/meta-code-verify/images/circle-download-cta.svg create mode 100644 packages/apps/meta-code-verify/images/circle-exclamation-mark.svg create mode 100644 packages/apps/meta-code-verify/images/circle-info.svg create mode 100755 packages/apps/meta-code-verify/images/default_32.png create mode 100755 packages/apps/meta-code-verify/images/default_64.png create mode 100755 packages/apps/meta-code-verify/images/default_64@2x.png create mode 100644 packages/apps/meta-code-verify/images/error-badge.svg create mode 100644 packages/apps/meta-code-verify/images/error-header.svg create mode 100755 packages/apps/meta-code-verify/images/failure_32.png create mode 100644 packages/apps/meta-code-verify/images/icon-badge.svg create mode 100644 packages/apps/meta-code-verify/images/loading-header.svg create mode 100644 packages/apps/meta-code-verify/images/menu-badge.svg create mode 100755 packages/apps/meta-code-verify/images/risk_32.png create mode 100644 packages/apps/meta-code-verify/images/temporary-extension-icon.svg create mode 100644 packages/apps/meta-code-verify/images/temporary-extension-icon128.png create mode 100644 packages/apps/meta-code-verify/images/temporary-extension-icon32.png create mode 100644 packages/apps/meta-code-verify/images/temporary-extension-icon48.png create mode 100644 packages/apps/meta-code-verify/images/validated-badge.svg create mode 100644 packages/apps/meta-code-verify/images/validated-header.svg create mode 100755 packages/apps/meta-code-verify/images/validated_32.png create mode 100644 packages/apps/meta-code-verify/images/warning-badge.svg create mode 100644 packages/apps/meta-code-verify/images/warning-header.svg create mode 100644 packages/apps/meta-code-verify/images/x.svg create mode 100644 packages/apps/meta-code-verify/package.json create mode 100644 packages/apps/meta-code-verify/rollup.config.ts create mode 100644 packages/apps/meta-code-verify/rollup_scripts/rollup-plugin-clean-once.ts create mode 100644 packages/apps/meta-code-verify/rollup_scripts/rollup-plugin-prettier-build-start.ts create mode 100644 packages/apps/meta-code-verify/rollup_scripts/rollup-plugin-static-files.ts create mode 100644 packages/apps/meta-code-verify/rollup_scripts/rollup-plugin-watch-additional.ts create mode 100644 packages/apps/meta-code-verify/rollup_scripts/utils.ts create mode 100644 packages/apps/meta-code-verify/src/css/popup.css create mode 100644 packages/apps/meta-code-verify/src/html/popup.html create mode 100644 packages/apps/meta-code-verify/src/js/__tests__/background.test.ts create mode 100644 packages/apps/meta-code-verify/src/js/__tests__/contentUtils.test.ts create mode 100644 packages/apps/meta-code-verify/src/js/__tests__/detectKvstoreMeta.test.ts create mode 100644 packages/apps/meta-code-verify/src/js/background.ts create mode 100644 packages/apps/meta-code-verify/src/js/config.ts create mode 100644 packages/apps/meta-code-verify/src/js/contentUtils.ts create mode 100644 packages/apps/meta-code-verify/src/js/detectKvstoreMeta.ts create mode 100644 packages/apps/meta-code-verify/src/js/popup.ts create mode 100644 packages/apps/meta-code-verify/src/js/tab_state_tracker/FrameStateMachine.ts create mode 100644 packages/apps/meta-code-verify/src/js/tab_state_tracker/StateMachine.ts create mode 100644 packages/apps/meta-code-verify/src/js/tab_state_tracker/TabStateMachine.ts create mode 100644 packages/apps/meta-code-verify/src/js/tab_state_tracker/tabStateTracker.ts create mode 100644 packages/apps/meta-code-verify/tsconfig.json create mode 100644 packages/apps/meta-code-verify/vitest.config.ts create mode 100644 packages/apps/meta-code-verify/vitest.setup.ts diff --git a/.github/workflows/ci-test-meta-code-verify.yml b/.github/workflows/ci-test-meta-code-verify.yml new file mode 100644 index 0000000000..2e03dd5a72 --- /dev/null +++ b/.github/workflows/ci-test-meta-code-verify.yml @@ -0,0 +1,22 @@ +name: meta-code-verify CI + +on: + push: + branches: + - "main" + pull_request: + workflow_dispatch: + +jobs: + meta-code-verify-test: + name: meta-code-verify Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm install --global yarn && yarn + name: Install dependencies + - run: yarn compile + name: Compile smart contracts + working-directory: ./packages/core + - run: yarn meta-code-verify:test + name: Run meta-code-verify test diff --git a/package.json b/package.json index b8a4f617f2..db6d41dcad 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,10 @@ "sdk:lint": "yarn workspace @human-protocol/sdk lint", "basemodels:test": "yarn workspace @human-protocol/basemodels test", "basemodels:lint": "yarn workspace @human-protocol/basemodels lint", - "test": "concurrently npm:core:test npm:subgraph:test npm:escrow-dashboard:test npm:fortune:test npm:sdk:test npm:basemodels:test npm:faucet-server:test", - "lint": "concurrently npm:core:lint npm:subgraph:lint npm:escrow-dashboard:lint npm:fortune:lint npm:sdk:lint npm:basemodels:lint npm:faucet-server:lint", + "meta-code-verify:test": "yarn workspace @human-protocol/meta-code-verify test", + "meta-code-verify:lint": "yarn workspace @human-protocol/meta-code-verify lint", + "test": "concurrently npm:core:test npm:subgraph:test npm:escrow-dashboard:test npm:fortune:test npm:sdk:test npm:basemodels:test npm:faucet-server:test npm:meta-code-verify:test", + "lint": "concurrently npm:core:lint npm:subgraph:lint npm:escrow-dashboard:lint npm:fortune:lint npm:sdk:lint npm:basemodels:lint npm:faucet-server:lint npm:meta-code-verify:lint", "prepare": "husky install" }, "workspaces": { diff --git a/packages/apps/escrow-dashboard/README.md b/packages/apps/escrow-dashboard/README.md index ccf89539ea..9fabd03730 100644 --- a/packages/apps/escrow-dashboard/README.md +++ b/packages/apps/escrow-dashboard/README.md @@ -18,7 +18,15 @@ You may also see any lint errors in the console. ### `yarn run build` -Builds the app for production to the `build` folder.\ +Before building you need to set environment variable in `.env`: + +``` +VITE_APP_NFT_STORAGE_API= +VITE_APP_FAUCET_SERVER_URL= +VITE_APP_WALLETCONNECT_PROJECT_ID= +``` + +Builds the app for production to the `dist` folder.\ It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes. diff --git a/packages/apps/escrow-dashboard/index.html b/packages/apps/escrow-dashboard/index.html index bb2dbacb77..6723031f36 100644 --- a/packages/apps/escrow-dashboard/index.html +++ b/packages/apps/escrow-dashboard/index.html @@ -30,5 +30,6 @@
+