Skip to content

Commit

Permalink
Merge pull request #7 from Cerebellum-Network/hotfix/1.0.1
Browse files Browse the repository at this point in the history
Hotfix 1.0.1
  • Loading branch information
shamilkhan authored May 18, 2023
2 parents ab52f35 + f2497d6 commit 87b6081
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 1 addition & 4 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 1 addition & 4 deletions .github/workflows/stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-staking-dashboard",
"version": "1.0.0",
"version": "1.0.1",
"license": "apache-2.0",
"private": false,
"dependencies": {
Expand Down
13 changes: 9 additions & 4 deletions src/contexts/Api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
API_ENDPOINTS,
MAX_ELECTING_VOTERS,
EXPECTED_BLOCK_TIME,
DEFAULT_NETWORK,
} from 'consts';
import { NETWORKS } from 'config/networks';
import {
Expand All @@ -37,12 +38,16 @@ export const APIProvider = ({ children }: { children: React.ReactNode }) => {
const [api, setApi] = useState<ApiPromise | null>(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<NetworkState>({
name: _name,
meta: NETWORKS[localStorage.getItem('network') as NetworkName],
name: _name || DEFAULT_NETWORK,
meta: initialMeta,
});

// constants state
Expand Down

0 comments on commit 87b6081

Please sign in to comment.