diff --git a/.env.example b/.env.example deleted file mode 100644 index 9f2cf6a..0000000 --- a/.env.example +++ /dev/null @@ -1,23 +0,0 @@ -# General -NEXT_PUBLIC_DAO_ADDRESS=0x768A2d62781368AD3475F80D234778adb461aB47 -NEXT_PUBLIC_TOKEN_ADDRESS=0xBF7105C7f1cB7CB556Ad2754636f8C8D9707029e -NEXT_PUBLIC_PWN_TOKEN_ADDRESS=0x0FE826395b1971d80A94543613E56a8b2fDF3d11 -NEXT_PUBLIC_PWN_EPOCH_CLOCK_ADDRESS=0x19e3293196aee99BB3080f28B9D3b4ea7F232b8d - -# Plugin addresses -NEXT_PUBLIC_TOKEN_VOTING_PLUGIN_ADDRESS=0xED79E70122E06bB036EB6668e772FaCE4566a4cC -NEXT_PUBLIC_DUAL_GOVERNANCE_PLUGIN_ADDRESS=0x017c1EBb09340a00Af1861C96bcaAD0Ddd37AC18 # PWNOptimisticGovernanaPlugin address - -NEXT_PUBLIC_STEWARD_SAFE_MULTISIG_ADDRESS=0x282D9663815b1F9929a3C84a9a1290BE882E125f - -# Network and services -NEXT_PUBLIC_CHAIN_NAME="TODO (either 'sepolia' or 'mainnet')" -NEXT_PUBLIC_RPC_URL="TODO (can be also tenderly virtual testnet)" - -NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID="TODO" - -NEXT_PUBLIC_IPFS_ENDPOINTS=https://ipfs.io/ipfs,https://api-staging.pwn.xyz/ipfs,https://gateway.pinata.cloud/ipfs,https://dweb.link/ipfs,https://4everland.io/ipfs - -NEXT_PUBLIC_WEB3_STORAGE_KEY="TODO" - -NEXT_PUBLIC_ETHERSCAN_API_KEY="TODO" diff --git a/.github/workflows/app-build.yml b/.github/workflows/app-build.yml deleted file mode 100644 index bf99aeb..0000000 --- a/.github/workflows/app-build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Pull request build -on: - pull_request: - -jobs: - run-build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - uses: oven-sh/setup-bun@v1 - - run: bun install - - name: Build - run: bun run build - env: - # NEXT_PUBLIC_DAO_ADDRESS: ${{secrets.DAO_ADDRESS}} - NEXT_PUBLIC_DAO_ADDRESS: "0x1234567890123456789012345678901234567890" - NEXT_PUBLIC_TOKEN_ADDRESS: "0x1234567890123456789012345678901234567890" - NEXT_PUBLIC_DELEGATION_ANNOUNCEMENTS_START_BLOCK: 1234567 - NEXT_PUBLIC_TOKEN_VOTING_PLUGIN_ADDRESS: "0x1234567890123456789012345678901234567890" - NEXT_PUBLIC_DELEGATION_CONTRACT_ADDRESS: "0x1234567890123456789012345678901234567890" - NEXT_PUBLIC_DUAL_GOVERNANCE_PLUGIN_ADDRESS: "0x1234567890123456789012345678901234567890" - NEXT_PUBLIC_CHAIN_NAME: sepolia - NEXT_PUBLIC_RPC_URL: x - NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: x - NEXT_PUBLIC_IPFS_ENDPOINT: https://ipfs/ - NEXT_PUBLIC_IPFS_API_KEY: x - NEXT_PUBLIC_ETHERSCAN_API_KEY: x - NODE_ENV: production diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..ea2ede1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,109 @@ +name: Deploy app +on: + workflow_call: + pull_request: + push: + branches: + - "master" + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Determine environment file + shell: bash + run: | + if [ "$BRANCH_NAME" = "master" ]; then + echo "ENV_FILE=.env.app.production" >> $GITHUB_ENV + echo "BUILD_COMMAND=bun run build-prod" >> $GITHUB_ENV + echo "ENABLED_CHAIN_IDS=1" >> $GITHUB_ENV + echo "PREFERRED_CHAIN_ID=1" >> $GITHUB_ENV + else + echo "ENV_FILE=.env.app.development" >> $GITHUB_ENV + echo "BUILD_COMMAND=bun run build-dev" >> $GITHUB_ENV + echo "ENABLED_CHAIN_IDS=1,11155111" >> $GITHUB_ENV + echo "PREFERRED_CHAIN_ID=11155111" >> $GITHUB_ENV + fi + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + + - uses: oven-sh/setup-bun@v2 + + - uses: actions/cache@v4 + with: + path: | + ~/.bun/install/cache + key: | + ${{ runner.os }}-${{ matrix.bun }}-bun-${{ hashFiles('**/bun.lockb') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.bun }}-bun- + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Fill env values with secrets + uses: Langsdorf/env-replace@v1.0.7 + with: + file: "env/${{ env.ENV_FILE }}" + replace-all: | + NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID }} + NEXT_PUBLIC_ETHEREUM_RPC_URL=${{ secrets.NEXT_PUBLIC_ETHEREUM_RPC_URL }} + NEXT_PUBLIC_SEPOLIA_RPC_URL=${{ secrets.NEXT_PUBLIC_SEPOLIA_RPC_URL }} + NEXT_PUBLIC_WEB3_STORAGE_KEY=${{ secrets.NEXT_PUBLIC_WEB3_STORAGE_KEY }} + NEXT_PUBLIC_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_ETHERSCAN_API_KEY }} + NEXT_PUBLIC_IPFS_ENDPOINTS=https://ipfs.io/ipfs,https://api-staging.pwn.xyz/ipfs,https://gateway.pinata.cloud/ipfs,https://dweb.link/ipfs,https://4everland.io/ipfs + NEXT_PUBLIC_PREFERRED_CHAIN_ID=${{ env.PREFERRED_CHAIN_ID }} + NEXT_PUBLIC_ENABLED_CHAIN_IDS=${{ env.ENABLED_CHAIN_IDS }} + upsert: true + + - name: Build + run: ${{ env.BUILD_COMMAND }} + + - name: Deploy to Cloudflare + id: deploy-cloudflare + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + command: pages deploy out --project-name=pwn-voting-ui --branch=${{ env.BRANCH_NAME }} --commit-hash=${{ github.sha }} + + - name: Add comment to PR with deployed URL + if: github.event_name == 'pull_request' + uses: thollander/actions-comment-pull-request@v3 + with: + message: | + Deployed on <${{ steps.deploy-cloudflare.outputs.pages-deployment-alias-url }}>! + comment-tag: execution + + # TODO make this work! + # - name: Deploy to IPFS + # if: ${{ env.BRANCH_NAME }} == 'master' + # uses: web3-storage/add-to-web3@v3 + # id: deploy-ipfs + # with: + # path_to_add: '.output/public' + # proof: './delegation.car' + # secret_key: ${{ secrets.WEB3_STORAGE_KEY }} + + # - name: Update DNSLink + # if: ${{ env.BRANCH_NAME }} == 'master' + # env: + # CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + # CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} + # RECORD_DOMAIN: "pwn.xyz" + # RECORD_NAME: "_dnslink.staking" + # uses: PabiGamito/cloudflare-update-dnslink@master + # with: + # cid: ${{ steps.deploy-ipfs.outputs.cid }} + + diff --git a/.gitignore b/.gitignore index 47f58cb..aacf6f2 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ next-env.d.ts # editor .vscode + +# https://github.com/nektos/act +bin/* diff --git a/README.md b/README.md index 44c939c..fcaa081 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Steps for testing -1. In your wallet, set the RPC URL for Sepolia network to https://virtual.sepolia.rpc.tenderly.co/f8099806-f215-4c8a-bd88-aa34015f6b34 . This makes sure that we use the forked Sepolia network, where we can e.g. move forward time to test accepting proposals and other scenarios easily without needing to wait x days. +1. In your wallet, set the RPC URL for Sepolia network to Tenderly fork. This makes sure that we use the forked Sepolia network, where we can e.g. move forward time to test accepting proposals and other scenarios easily without needing to wait x days. ### Gaining voting power @@ -9,7 +9,7 @@ ### Optimistic (stewards) proposals -1. For testing creating optimistic proposals, you can import our shared dev EOA account from the pwn_secrets KeePass file to your wallet. After that go to app.safe.global, connect this imported wallet and select this safe on Sepolia 0x282D9663815b1F9929a3C84a9a1290BE882E125f . With this safe connect to the Voting UI via WalletConnect. +1. For testing creating optimistic proposals, you can import our shared dev EOA account. After that go to app.safe.global, connect this imported wallet and select this safe on Sepolia 0x282D9663815b1F9929a3C84a9a1290BE882E125f . With this safe connect to the Voting UI via WalletConnect. 2. Now you should be able to create optimistic proposals. # Governance App Template diff --git a/bun.lockb b/bun.lockb index 5e28483..8db78b4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/WalletContainer.tsx b/components/WalletContainer.tsx index 5012ad3..e498f03 100644 --- a/components/WalletContainer.tsx +++ b/components/WalletContainer.tsx @@ -1,28 +1,26 @@ -import { PUB_CHAIN, PUB_RPC_URL } from "@/constants"; +import { PUB_RPC_URL } from "@/constants"; import { formatHexString } from "@/utils/evm"; -import { useWeb3Modal } from "@web3modal/wagmi/react"; +import { useAppKit } from "@reown/appkit/react"; import classNames from "classnames"; -import { useEffect } from "react"; import { createClient, http } from "viem"; -import { createConfig, useAccount, useEnsName, useSwitchChain } from "wagmi"; +import { createConfig, useAccount, useEnsName } from "wagmi"; import { mainnet } from "wagmi/chains"; const config = createConfig({ - chains: [PUB_CHAIN], + chains: [mainnet], ssr: true, client({ chain }) { return createClient({ chain, - transport: http(PUB_RPC_URL, { batch: true }), + transport: http(PUB_RPC_URL[1], { batch: true }), }); }, }); // TODO: update with ODS wallet module - [https://linear.app/aragon/issue/RD-198/create-ods-walletmodule] const WalletContainer = () => { - const { open } = useWeb3Modal(); - const { address, isConnected, chainId } = useAccount(); - const { switchChain } = useSwitchChain(); + const { open } = useAppKit(); + const { address, isConnected } = useAccount(); const { data: ensName } = useEnsName({ config, @@ -30,13 +28,6 @@ const WalletContainer = () => { address: address, }); - useEffect(() => { - if (!chainId) return; - else if (chainId === PUB_CHAIN.id) return; - - switchChain({ chainId: PUB_CHAIN.id }); - }, [chainId]); - return (