From 80f4edebd15dab09803a9e9a36a377cec84a84f1 Mon Sep 17 00:00:00 2001 From: Oleg Yankovich <@> Date: Wed, 17 May 2023 16:43:02 +0200 Subject: [PATCH 1/5] Fix passing env variable --- .github/workflows/dev.yaml | 5 +---- .github/workflows/prod.yaml | 5 +---- .github/workflows/stage.yaml | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) 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..cbd7b8438b 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=true; 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 From fcbccc03ddfca05d233aaa7c17a910ea863094a7 Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 18 May 2023 11:08:46 +0400 Subject: [PATCH 2/5] Set REACT_APP_INCLUDE_TESTNET to false for Stage env --- .github/workflows/stage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stage.yaml b/.github/workflows/stage.yaml index cbd7b8438b..eeeffc2297 100644 --- a/.github/workflows/stage.yaml +++ b/.github/workflows/stage.yaml @@ -16,7 +16,7 @@ jobs: with: build_container: 'node:16-buster' install_packages_command: 'yarn' - build_command: 'export REACT_APP_INCLUDE_TESTNET=true; 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 From 7af3bbfb796b83ff92e96317b811e74f74a11bff Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 18 May 2023 11:20:20 +0400 Subject: [PATCH 3/5] Set 1.0.1 Version --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bcb6e2d27..baa9085641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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 + +### Changed + +- Fixed Workflow for Dev, Stage and Prod +- Set `REACT_APP_INCLUDE_TESTNET` env variable to `false` for Stage + ## [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": { From a4abeca2023870343e6fd3ba6c04fc4bc8007db8 Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 18 May 2023 11:36:02 +0400 Subject: [PATCH 4/5] fix: Improve network state initialization and error handling --- CHANGELOG.md | 3 +++ src/contexts/Api/index.tsx | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baa9085641..9b23abab53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.0.1] - 2023-05-18 +## Added +- Improved network state initialization and error handling + ### Changed - Fixed Workflow for Dev, Stage and Prod 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 From f2497d65e0e5a1bca4483d7e47aa58eac96b57d1 Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 18 May 2023 14:06:17 +0400 Subject: [PATCH 5/5] Make CHANGELOG changes more meaningful --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b23abab53..6b21dda577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.0.1] - 2023-05-18 ## Added -- Improved network state initialization and error handling + +- Improved network initialization and error handling. Prevents application crashes caused by incorrect localStorage network. Added default network for this scenario. ### Changed -- Fixed Workflow for Dev, Stage and Prod -- Set `REACT_APP_INCLUDE_TESTNET` env variable to `false` for Stage +- 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