From ca1defd3a890c0e91b23834cd092ad367daffad8 Mon Sep 17 00:00:00 2001 From: Fernando Falci Date: Mon, 22 Apr 2024 15:58:17 +0200 Subject: [PATCH] chore(ci): publish to GH Pages --- .github/workflows/ci.yml | 57 +++++++++++++++++++++++++++++++++ README.md | 69 +++++++++++++++++++++++++++++++++++++--- docs/CNAME | 1 - docs/index.html | 1 - package.json | 2 +- 5 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 docs/CNAME delete mode 100644 docs/index.html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c78c21e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: Deploy static content to Pages + +on: + push: + branches: ['main'] + + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: 'pages' + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + cache: 'yarn' + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Install deps + run: yarn + + - name: Build + run: yarn build + + - name: CNAME + run: cp ./CNAME ./dist + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: './dist' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index f768e33..532685e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,67 @@ -# React + Vite +# Wallet.id -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +This is a white label template for [hns.id](https://hns.id). You can fork and modify to be used with any staked TLD -Currently, two official plugins are available: +## Customization -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh +Basic customization are in the [`constants.js`](./src/constants.js) file and the [`src/assets`](./src/assets/) folder, more specifically `avatar.png` and `brand.png`, as well as `public/favicon.svg`. + +For more advanced customization, any component can be updated. + +## Contracts + +The contracts addresses are also in the [constants.js](/src/constants.js#L17-L23) file. First is the testnet (Optimism Sepolia), and second the mainnet (Optimism). + +## Data + +This project can be deployed as static website. All the data needed comes from smart contracts. + +Handling the communication with the contracts can be done with 2 React hooks: + +### useDomainStatus() + +```jsx +const { data } = useDomainStatus({ label: 'my-sld' }); + +/* Returns: +{ + "isAvailable": true, + "labelValid": true, + "publicRegistrationOpen": false, + "isPremium": false, + "priceInDollars": "5.00", + "priceInWei": "2500000000000000", + "label": "my-sld" +} +/* +``` + +### useRegister() + +```jsx +const register = useRegister({ + label: 'my-sld', + priceInWei: '2500000000000000', +}); + +; +``` + +`register` is an async function that will invoke Metamask (or any other wallet the user choose) and will be resolved once the user signs the transaction. + +## Running locally + +It uses yarn, so... + +``` +yarn install +yarn dev +``` + +... should do the magic. + +## GitHub Pages + +As mentioned about, this project can be deployed as a static webpage, with no need for a backend like NodeJS or even Vercel, making it a great fit for GitHub pages. + +After forking the project, enable **Pages** in the repository settings and update the [`CNAME`](./CNAME) file. diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 7b71cbf..0000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -wallet.id \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 71fb7fc..0000000 --- a/docs/index.html +++ /dev/null @@ -1 +0,0 @@ -wallet.id diff --git a/package.json b/package.json index aa4e373..4014421 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build --outDir docs", + "build": "vite build --outDir dist", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview" },