|
1 | | -# React + TypeScript + Vite |
| 1 | +# Etherlink SSI Governance Dashboard |
2 | 2 |
|
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
| 3 | +The client-side application for the Etherlink SSI Governance Platform. This dashboard provides two distinct portals: one for the **Trust Anchor** (Governance & Administration) and one for **Companies** (Identity Onboarding & Revocation Management). |
4 | 4 |
|
5 | | -Currently, two official plugins are available: |
| 5 | +## 📋 Prerequisites |
6 | 6 |
|
7 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh |
8 | | -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
| 7 | +Before running the frontend, ensure the following requirements are met: |
9 | 8 |
|
10 | | -## React Compiler |
| 9 | +1. **Local Blockchain Node:** A Hardhat node must be running. |
| 10 | +2. **Deployed Contracts:** The `CompanyCRSet` module must be deployed to the local network. |
| 11 | +3. **Environment Variables:** Create a `.env` file in this directory with your contract addresses and Pinata keys. |
11 | 12 |
|
12 | | -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). |
| 13 | +```bash |
| 14 | +cp .env.example .env |
13 | 15 |
|
14 | | -## Expanding the ESLint configuration |
| 16 | +``` |
15 | 17 |
|
16 | | -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: |
| 18 | +**Required Variables:** |
17 | 19 |
|
18 | | -```js |
19 | | -export default defineConfig([ |
20 | | - globalIgnores(['dist']), |
21 | | - { |
22 | | - files: ['**/*.{ts,tsx}'], |
23 | | - extends: [ |
24 | | - // Other configs... |
| 20 | +```env |
25 | 21 |
|
26 | | - // Remove tseslint.configs.recommended and replace with this |
27 | | - tseslint.configs.recommendedTypeChecked, |
28 | | - // Alternatively, use this for stricter rules |
29 | | - tseslint.configs.strictTypeChecked, |
30 | | - // Optionally, add this for stylistic rules |
31 | | - tseslint.configs.stylisticTypeChecked, |
| 22 | +VITE_TRUST_ANCHOR_ADDRESS=0x... |
| 23 | +VITE_REGISTRY_ADDRESS=0x... |
| 24 | +VITE_CRSET_REGISTRY_ADDRESS=0x... |
| 25 | +VITE_PINATA_JWT=your_pinata_jwt_token |
32 | 26 |
|
33 | | - // Other configs... |
34 | | - ], |
35 | | - languageOptions: { |
36 | | - parserOptions: { |
37 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
38 | | - tsconfigRootDir: import.meta.dirname, |
39 | | - }, |
40 | | - // other options... |
41 | | - }, |
42 | | - }, |
43 | | -]) |
44 | 27 | ``` |
45 | 28 |
|
46 | | -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: |
47 | | - |
48 | | -```js |
49 | | -// eslint.config.js |
50 | | -import reactX from 'eslint-plugin-react-x' |
51 | | -import reactDom from 'eslint-plugin-react-dom' |
52 | | - |
53 | | -export default defineConfig([ |
54 | | - globalIgnores(['dist']), |
55 | | - { |
56 | | - files: ['**/*.{ts,tsx}'], |
57 | | - extends: [ |
58 | | - // Other configs... |
59 | | - // Enable lint rules for React |
60 | | - reactX.configs['recommended-typescript'], |
61 | | - // Enable lint rules for React DOM |
62 | | - reactDom.configs.recommended, |
63 | | - ], |
64 | | - languageOptions: { |
65 | | - parserOptions: { |
66 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
67 | | - tsconfigRootDir: import.meta.dirname, |
68 | | - }, |
69 | | - // other options... |
70 | | - }, |
71 | | - }, |
72 | | -]) |
| 29 | +--- |
| 30 | + |
| 31 | +## 🐳 Docker Setup (Recommended) |
| 32 | + |
| 33 | +You can containerize this application using the included Dockerfile (Nginx + Alpine). |
| 34 | + |
| 35 | +### 1. Build the Image |
| 36 | + |
| 37 | +*Note: The build process bakes the `.env` variables into the static files. Ensure your `.env` file is correct before building.* |
| 38 | + |
| 39 | +```bash |
| 40 | +docker build -t ssi-frontend . |
| 41 | + |
73 | 42 | ``` |
| 43 | + |
| 44 | +### 2. Run the Container |
| 45 | + |
| 46 | +Map port 80 of the container to port 8080 on your host. |
| 47 | + |
| 48 | +```bash |
| 49 | +docker run -d -p 8080:80 --name ssi-app ssi-frontend |
| 50 | + |
| 51 | +``` |
| 52 | + |
| 53 | +Access the application at: **[http://localhost:8080](https://www.google.com/search?q=http://localhost:8080)** |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## 💻 Local Development |
| 58 | + |
| 59 | +To run the application in development mode with Hot Module Replacement (HMR): |
| 60 | + |
| 61 | +```bash |
| 62 | +# Install dependencies |
| 63 | +npm install |
| 64 | + |
| 65 | +# Start Dev Server |
| 66 | +npm run dev |
| 67 | + |
| 68 | +``` |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## 📖 Usage Guide |
| 73 | + |
| 74 | +The application supports two distinct user roles. Use MetaMask to switch between wallets to simulate these roles. |
| 75 | + |
| 76 | +### 🏛️ Role 1: Trust Anchor (Administrator) |
| 77 | + |
| 78 | +*Use the wallet address that deployed the contracts (Account #0).* |
| 79 | + |
| 80 | +1. **Dashboard Overview:** |
| 81 | +* Navigate to `/trust-anchor`. |
| 82 | +* View real-time governance stats, quorum thresholds, and active proposals. |
| 83 | + |
| 84 | + |
| 85 | +2. **Registering Companies:** |
| 86 | +* Go to **Companies**. |
| 87 | +* Search for a company's DID address (Wallet Address). |
| 88 | +* If the company is "Not Managed", wait for them to delegate control. |
| 89 | +* If they have delegated (Yellow status), scroll down to **"CRSet Admins"**. |
| 90 | +* Paste the company's address and click **Add**. This completes the registration immediately (no proposal required). |
| 91 | + |
| 92 | + |
| 93 | +3. **Governance:** |
| 94 | +* Go to **Governance**. |
| 95 | +* Propose adding/removing admins or updating the multi-sig quorum threshold. |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +### 🏢 Role 2: Company (User) |
| 100 | + |
| 101 | +*Use any other wallet address (Account #1, #2, etc.).* |
| 102 | + |
| 103 | +1. **Onboarding:** |
| 104 | +* Navigate to `/company/onboarding`. |
| 105 | +* **Step 1 (Delegate):** Sign the transaction to transfer identity ownership to the Trust Anchor. |
| 106 | +* **Step 2 (Verification):** Wait for the Trust Anchor to approve your registration and add you as a CRSet Admin. |
| 107 | +* **Step 3 (Complete):** Once verified, the dashboard will unlock. |
| 108 | + |
| 109 | + |
| 110 | +2. **Revocation Management:** |
| 111 | +* Navigate to `/company/revocations`. |
| 112 | +* **Upload:** Drag & Drop a W3C-compliant JSON revocation list. |
| 113 | +* **Publish:** The app uploads the file to IPFS (via Pinata) and updates the smart contract with the new CID. |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## 🛠 Tech Stack |
| 120 | + |
| 121 | +* **Framework:** React + Vite |
| 122 | +* **Language:** TypeScript |
| 123 | +* **Web3 Integration:** Wagmi v2, Viem, TanStack Query |
| 124 | +* **Styling:** Tailwind CSS, Lucide Icons |
| 125 | +* **Deployment:** Docker, Nginx |
0 commit comments