diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 0d46163984..dba0937a39 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -9,16 +9,13 @@ permissions: id-token: write contents: read -env: - REACT_APP_INCLUDE_TESTNET: true - jobs: build-and-deploy: uses: Cerebellum-Network/reusable-workflows/.github/workflows/deploy-to-cloudfront.yaml@master with: build_container: 'node:16-buster' install_packages_command: 'yarn' - build_command: 'yarn run build' + build_command: 'export REACT_APP_INCLUDE_TESTNET=true; yarn run build' path_to_static_files_to_upload: 'build' aws_account_id: ${{ vars.DEV_NETWORK_AWS_ACCOUNT_ID }} s3_bucket_name: "staking-dev.network-dev.aws.cere.io" \ No newline at end of file diff --git a/.github/workflows/prod.yaml b/.github/workflows/prod.yaml index 6a1946f1fb..f7da26ecbc 100644 --- a/.github/workflows/prod.yaml +++ b/.github/workflows/prod.yaml @@ -9,16 +9,13 @@ permissions: id-token: write contents: read -env: - REACT_APP_INCLUDE_TESTNET: false - jobs: build-and-deploy: uses: Cerebellum-Network/reusable-workflows/.github/workflows/deploy-to-cloudfront.yaml@master with: build_container: 'node:16-buster' install_packages_command: 'yarn' - build_command: 'yarn run build' + build_command: 'export REACT_APP_INCLUDE_TESTNET=false; yarn run build' path_to_static_files_to_upload: 'build' aws_account_id: ${{ vars.PRD_NETWORK_AWS_ACCOUNT_ID }} s3_bucket_name: "staking.network.aws.cere.io" diff --git a/.github/workflows/stage.yaml b/.github/workflows/stage.yaml index 534b82997c..eeeffc2297 100644 --- a/.github/workflows/stage.yaml +++ b/.github/workflows/stage.yaml @@ -10,16 +10,13 @@ permissions: id-token: write contents: read -env: - REACT_APP_INCLUDE_TESTNET: true - jobs: build-and-deploy: uses: Cerebellum-Network/reusable-workflows/.github/workflows/deploy-to-cloudfront.yaml@master with: build_container: 'node:16-buster' install_packages_command: 'yarn' - build_command: 'yarn run build' + build_command: 'export REACT_APP_INCLUDE_TESTNET=false; yarn run build' path_to_static_files_to_upload: 'build' aws_account_id: ${{ vars.STG_NETWORK_AWS_ACCOUNT_ID }} s3_bucket_name: "staking-stg.network-stage.aws.cere.io" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bcb6e2d27..6b21dda577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2023-05-18 + +## Added + +- Improved network initialization and error handling. Prevents application crashes caused by incorrect localStorage network. Added default network for this scenario. + +### Changed + +- Improved workflow for deploying to development, staging, and production environments. Fixed issue with `REACT_APP_INCLUDE_TESTNET` variable. +- Set the `REACT_APP_INCLUDE_TESTNET` environment variable to `false` for the Stage environment. + ## [1.0.0] - 2023-05-17 ### Added diff --git a/package.json b/package.json index d02f771c13..39ce3729b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkadot-staking-dashboard", - "version": "1.0.0", + "version": "1.0.1", "license": "apache-2.0", "private": false, "dependencies": { diff --git a/src/contexts/Api/index.tsx b/src/contexts/Api/index.tsx index d9fe0f5d86..1a9d7915b3 100644 --- a/src/contexts/Api/index.tsx +++ b/src/contexts/Api/index.tsx @@ -12,6 +12,7 @@ import { API_ENDPOINTS, MAX_ELECTING_VOTERS, EXPECTED_BLOCK_TIME, + DEFAULT_NETWORK, } from 'consts'; import { NETWORKS } from 'config/networks'; import { @@ -37,12 +38,16 @@ export const APIProvider = ({ children }: { children: React.ReactNode }) => { const [api, setApi] = useState(null); // network state - const _name: NetworkName = - (localStorage.getItem('network') as NetworkName) ?? NetworkName.Polkadot; + const _name = localStorage.getItem('network') as NetworkName; + const initialMeta = NETWORKS[_name] || NETWORKS[DEFAULT_NETWORK]; + + if (!_name || !NETWORKS[_name]) { + localStorage.setItem('network', DEFAULT_NETWORK); + } const [network, setNetwork] = useState({ - name: _name, - meta: NETWORKS[localStorage.getItem('network') as NetworkName], + name: _name || DEFAULT_NETWORK, + meta: initialMeta, }); // constants state