From e44a28532f4b5f830a4a0d847e3f99e60e231a1b Mon Sep 17 00:00:00 2001 From: "Justin R. Evans" <330911+jurevans@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:52:11 +0000 Subject: [PATCH] Extension: Update to Firefox docs (#1398) * fix: make even more explicit instructions for FF * docs: add environment details * fix: accept REVISION as env var, specify in instructions * fix: update CI to provide revision env var, docs * fix: update .env overrides --- .github/workflows/release-wallet.yml | 23 ++-- apps/extension/.env.sample | 7 +- apps/extension/FIREFOX_README.md | 100 +++++++++++++----- apps/extension/package.json | 12 ++- .../src/App/Common/AppHeaderNavigation.tsx | 2 +- apps/extension/webpack.config.js | 8 +- packages/chains/src/chains/namada.ts | 2 +- 7 files changed, 100 insertions(+), 54 deletions(-) diff --git a/.github/workflows/release-wallet.yml b/.github/workflows/release-wallet.yml index d89a077050..8965f188a6 100644 --- a/.github/workflows/release-wallet.yml +++ b/.github/workflows/release-wallet.yml @@ -6,15 +6,12 @@ on: required: true type: string default: "main" - NAMADA_INTERFACE_NAMADA_CHAIN_ID: - required: true - type: string env: CI: false jobs: setup: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 outputs: VERSION: ${{ steps.set-environment-variables.outputs.VERSION }} steps: @@ -37,7 +34,7 @@ jobs: build-extension-chrome: needs: setup - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v3 @@ -61,9 +58,7 @@ jobs: - name: Build the extension working-directory: ./apps/extension - run: yarn build:chrome - env: - NAMADA_INTERFACE_NAMADA_CHAIN_ID: ${{ inputs.NAMADA_INTERFACE_NAMADA_CHAIN_ID }} + run: REVISION=$SHA yarn build:chrome - uses: actions/upload-artifact@v3 with: @@ -72,7 +67,7 @@ jobs: build-extension-firefox: needs: setup - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v3 @@ -96,9 +91,7 @@ jobs: - name: Build the extension working-directory: ./apps/extension - run: yarn build:firefox - env: - NAMADA_INTERFACE_NAMADA_CHAIN_ID: ${{ inputs.NAMADA_INTERFACE_NAMADA_CHAIN_ID }} + run: REVISION=$SHA yarn build:firefox - uses: actions/upload-artifact@v3 with: @@ -107,7 +100,7 @@ jobs: release: needs: [setup, build-extension-chrome, build-extension-firefox] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Download Chrome extension build uses: actions/download-artifact@v3 @@ -129,9 +122,9 @@ jobs: - name: Make release body text run: | - echo "NAMADA_INTERFACE_NAMADA_CHAIN_ID: $NAMADA_INTERFACE_NAMADA_CHAIN_ID" >> RELEASE + echo "REVISION: $REVISION" >> RELEASE env: - NAMADA_INTERFACE_NAMADA_CHAIN_ID: ${{ inputs.NAMADA_INTERFACE_NAMADA_CHAIN_ID }} + REVISION: ${{ github.sha }} - name: Create release id: create-release diff --git a/apps/extension/.env.sample b/apps/extension/.env.sample index da8cd0ee75..5697203643 100644 --- a/apps/extension/.env.sample +++ b/apps/extension/.env.sample @@ -1,5 +1,8 @@ -# Specify the following if you wish to override the defaults defined in @namada/chains: +# Specify the following if you wish to override the defaults: -# NAMADA +# Override default approved signing chain ID NAMADA_INTERFACE_NAMADA_CHAIN_ID=namada-testnet.ddf12d74622ca25f3ad6fe14 +# Override revision - useful if building source outside of a git repo +NAMADA_INTERFACE_REVISION=8916680a2bcd43f1ef54b47e2d0213d1d02abbfb + diff --git a/apps/extension/FIREFOX_README.md b/apps/extension/FIREFOX_README.md index 9482230b4f..783c98913c 100644 --- a/apps/extension/FIREFOX_README.md +++ b/apps/extension/FIREFOX_README.md @@ -1,43 +1,27 @@ # NOTICE FOR FIREFOX ADD-ON REVIEWERS -This is the monorepo which contains the source code for Namada Extension. +This is the monorepo which contains the source code for Namada Extension. Please follow the instructions +exactly as they are described below. -## Source code +## Table of Contents -The main extension source code is located in `apps/extension/src`. We also use -several local packages; their sources are in: - -- `packages/chains/src` -- `packages/components/src` -- `packages/hooks/src` -- `packages/sdk/src` -- `packages/storage/src` -- `packages/types/src` -- `packages/utils/src` -- `packages/shared/lib` (shared package Rust code compiled to WebAssembly) -- `packages/shared/src` (shared package TypeScript glue code) -- `packages/crypto/lib` (crypto package Rust code compiled to WebAssembly) -- `packages/crypto/src` (crypto package TypeScript glue code) +- [Build Instructions](#build-instructions) +- [Notes](#notes) + - [Environment](#environment) + - [Setting up Node & NPM](#setting-up-node-and-npm) + - [Source Code](#source-code) ## Build instructions -If you don't already have Node v20 LTS and NPM v10, install now via `nvm`: - -```bash -wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash - -# Enable nvm in current shell -export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +**NOTE**: You _must_ use `yarn` to install dependencies! This is due to the fact that this is configured as a monorepo +using yarn workspaces. If you install via `npm install` or `npm i`, it will not resolve dependencies correctly. -# Install v20 LTS -nvm install v20.9.0 -``` +If you don't already have Node v22 LTS and NPM v10, please follow these [instructions](#setting-up-node-and-npm) These instructions should work for the default reviewer build environment. ```bash -sudo apt install protobuf-compiler build-essential curl pkg-config libssl-dev binaryen +sudo apt install protobuf-compiler build-essential curl pkg-config libssl-dev binaryen -y curl https://sh.rustup.rs -sSf | sh # Proceed with standard installation when prompted @@ -45,17 +29,77 @@ curl https://sh.rustup.rs -sSf | sh # Make sure to pull cargo into your current environment: . "$HOME/.cargo/env" +# You must use yarn to install dependencies: npm install -g yarn export PUPPETEER_SKIP_DOWNLOAD=true + +# Run yarn to install dependencies yarn + +# Move into extension app directory cd apps/extension + +# Build wasm dependency: yarn wasm:build ``` Then, issue the final build command for the Firefox add-on: ```bash +# Build the addon: yarn build:firefox ``` The resulting extension is the ZIP file in `apps/extension/build/firefox`. + +[ [Table of Contents](#table-of-contents) ] + +## Notes + +### Environment + +This build was produced using the following environment: + +- Ubuntu 24.04 LTS (Desktop edition) +- 10GB of system memory (RAM) +- 6 cores of vCPU +- Node 22 LTS and npm 10 +- 35GB of storage + +Please ensure that this matches your environment! + +[ [Table of Contents](#table-of-contents) ] + +### Setting up Node and NPM + +```bash +wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + +# Enable nvm in current shell +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +# Install v22 LTS +nvm install v22.0.0 +``` + +[ [Table of Contents](#table-of-contents) ] + +### Source code + +The main extension source code is located in `apps/extension/src`. We also use +several local packages; their sources are in: + +- `packages/chains/src` +- `packages/components/src` +- `packages/hooks/src` +- `packages/sdk/src` +- `packages/storage/src` +- `packages/types/src` +- `packages/utils/src` +- `packages/shared/lib` (shared package Rust code compiled to WebAssembly) +- `packages/shared/src` (shared package TypeScript glue code) +- `packages/crypto/lib` (crypto package Rust code compiled to WebAssembly) +- `packages/crypto/src` (crypto package TypeScript glue code) + +[ [Table of Contents](#table-of-contents) ] diff --git a/apps/extension/package.json b/apps/extension/package.json index 3ffdbde716..87f3ee5267 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -16,17 +16,19 @@ "clean:chrome": "rimraf ./build/chrome", "clean:firefox": "rimraf ./build/firefox", "build": "yarn wasm:build && yarn clean && yarn build:chrome && yarn build:firefox", - "build:chrome": "yarn clean:chrome && NODE_ENV=production TARGET=chrome REVISION=$(git rev-parse HEAD) webpack-cli && yarn run web-ext build --s ./build/chrome -a ./build/chrome", + "build:chrome": "yarn clean:chrome && NODE_ENV=production TARGET=chrome webpack-cli && yarn run web-ext build --s ./build/chrome -a ./build/chrome", + "build:chrome:revision": "NAMADA_INTERFACE_REVISION=$(git rev-parse HEAD) yarn build:chrome", "build:chrome:beta": "yarn clean:chrome && NODE_ENV=production BETA_RELEASE=true TARGET=chrome REVISION=$(git rev-parse HEAD) webpack-cli && yarn run web-ext build --s ./build/chrome -a ./build/chrome", - "build:firefox": "yarn clean:firefox && NODE_ENV=production TARGET=firefox REVISION=$(git rev-parse HEAD) webpack-cli && yarn run web-ext build --s ./build/firefox -a ./build/firefox", - "build:firefox:beta": "yarn clean:firefox && NODE_ENV=production BETA_RELEASE=true TARGET=firefox REVISION=$(git rev-parse HEAD) webpack-cli && yarn run web-ext build --s ./build/firefox -a ./build/firefox", + "build:firefox": "yarn clean:firefox && NODE_ENV=production TARGET=firefox webpack-cli && yarn run web-ext build --s ./build/firefox -a ./build/firefox", + "build:firefox:revision": "NAMADA_INTERFACE_REVISION=$(git rev-parse HEAD) yarn build:firefox", + "build:firefox:beta": "yarn clean:firefox && NODE_ENV=production BETA_RELEASE=true TARGET=firefox webpack-cli && yarn run web-ext build --s ./build/firefox -a ./build/firefox", "lint": "eslint src --ext .ts,.tsx", "lint:fix": "yarn lint -- --fix", "lint:ci": "yarn lint --max-warnings 0", "start": "yarn start:chrome", - "start:chrome": "yarn clean:chrome && NODE_ENV=development TARGET=chrome REVISION=$(git rev-parse HEAD) yarn watch", + "start:chrome": "yarn clean:chrome && NODE_ENV=development TARGET=chrome NAMADA_INTERFACE_REVISION=$(git rev-parse HEAD) yarn watch", "start:chrome:proxy": "NAMADA_INTERFACE_PROXY=true yarn start:chrome", - "start:firefox": "yarn clean:firefox && NODE_ENV=development TARGET=firefox REVISION=$(git rev-parse HEAD) yarn watch", + "start:firefox": "yarn clean:firefox && NODE_ENV=development TARGET=firefox NAMADA_INTERFACE_REVISION=$(git rev-parse HEAD) yarn watch", "start:firefox:proxy": "NAMADA_INTERFACE_PROXY=true yarn start:firefox", "test": "yarn wasm:build:test && yarn jest --coverage", "test:only": "yarn jest --coverage", diff --git a/apps/extension/src/App/Common/AppHeaderNavigation.tsx b/apps/extension/src/App/Common/AppHeaderNavigation.tsx index 34c42ae5a8..55b06019e4 100644 --- a/apps/extension/src/App/Common/AppHeaderNavigation.tsx +++ b/apps/extension/src/App/Common/AppHeaderNavigation.tsx @@ -8,7 +8,7 @@ import { useNavigate } from "react-router-dom"; import sdkPackage from "../../../../../packages/sdk/package.json"; import extensionPackage from "../../../package.json"; -const { REVISION: revision = "" } = process.env; +const { NAMADA_INTERFACE_REVISION: revision = "" } = process.env; type AppHeaderNavigationProps = { open: boolean; diff --git a/apps/extension/webpack.config.js b/apps/extension/webpack.config.js index ef7c0a8478..26e242d706 100644 --- a/apps/extension/webpack.config.js +++ b/apps/extension/webpack.config.js @@ -13,7 +13,12 @@ const { getProcessEnv } = require("@namada/config/webpack.js"); // Load .env from namadillo: require("dotenv").config({ path: "./.env" }); -const { NODE_ENV, TARGET, BUNDLE_ANALYZE, BETA_RELEASE: isBeta } = process.env; +const { + NODE_ENV, + TARGET, + BUNDLE_ANALYZE, + BETA_RELEASE: isBeta, +} = process.env; const OUTPUT_PATH = resolve(__dirname, `./build/${TARGET}`); const MANIFEST_VERSION = TARGET === "firefox" ? "v2" : "v3"; @@ -106,7 +111,6 @@ const plugins = [ env: JSON.stringify( getProcessEnv("NAMADA_INTERFACE", [ "TARGET", - "REVISION", "NODE_ENV", "npm_package_version", ]) diff --git a/packages/chains/src/chains/namada.ts b/packages/chains/src/chains/namada.ts index b73aa4619e..dad8b63baf 100644 --- a/packages/chains/src/chains/namada.ts +++ b/packages/chains/src/chains/namada.ts @@ -2,7 +2,7 @@ import { BridgeType, Chain, Extensions } from "@namada/types"; import { ProxyMappings } from "../types"; const DEFAULT_ALIAS = "Namada"; -const DEFAULT_CHAIN_ID = "public-testnet-15.0dacadb8d663"; +const DEFAULT_CHAIN_ID = "namada.5f5de2dd1b88cba30586420"; const DEFAULT_RPC = "https://proxy.heliax.click/public-testnet-15.0dacadb8d663"; const DEFAULT_BECH32_PREFIX = "tnam";