From d429787bb3b0d45487a965ded283259a8d68331b Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Thu, 15 Feb 2024 16:15:56 +0100 Subject: [PATCH] fixing errors with networks & index.html --- index.html | 2 +- package.json | 4 +- public/index.html | 95 ---------------------------------- src/Providers.tsx | 2 + src/config/ledger.ts | 2 +- src/config/networks.ts | 8 +-- src/consts.ts | 2 +- src/contexts/Network/index.tsx | 11 +++- src/modals/Connect/Ledger.tsx | 4 +- src/types/index.ts | 8 +-- 10 files changed, 26 insertions(+), 112 deletions(-) delete mode 100644 public/index.html diff --git a/index.html b/index.html index d5cb01207c..09726b6ee2 100644 --- a/index.html +++ b/index.html @@ -81,4 +81,4 @@
- \ No newline at end of file + diff --git a/package.json b/package.json index fe70fe2371..d64da79073 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,11 @@ "license": "GPL-3.0-only", "private": false, "scripts": { - "build": "tsc && vite build --base '/'", + "build": "tsc && vite build --base './'", "build:pages": "tsc && vite build --base '/polkadot-staking-dashboard/'", "clear": "rm -rf node_modules build tsconfig.tsbuildinfo", "deploy:pages": "yarn build:pages && gh-pages -d build", - "dev": "vite", + "dev": "vite --base './'", "lint": "eslint . --fix && npx prettier --write . && npx prettier --write ./.scripts && node ./.scripts/localeOrderKeys.cjs", "locale:order": "node ./.scripts/localeOrderKeys.cjs", "locale:validate": "node ./.scripts/localeValidate.cjs", diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 2db5a71a35..0000000000 --- a/public/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cere Staking Dashboard - - - - - - - - - - - -
- - - - - - - - diff --git a/src/Providers.tsx b/src/Providers.tsx index 7f1be0804d..51bca58a5d 100644 --- a/src/Providers.tsx +++ b/src/Providers.tsx @@ -53,6 +53,8 @@ import { CereStatsProvider } from './contexts/CereStats'; // Embed providers from hook. export const Providers = () => { + const networkAllData = useNetwork(); + console.warn(networkAllData); const { network, networkData: { ss58 }, diff --git a/src/config/ledger.ts b/src/config/ledger.ts index 01193ccd0f..0651a01126 100644 --- a/src/config/ledger.ts +++ b/src/config/ledger.ts @@ -6,7 +6,7 @@ import PolkadotSVG from 'img/appIcons/polkadot.svg?react'; export const LedgerApps: LedgerApp[] = [ { - network: 'Cere Mainnet', + network: 'cereMainnet', appName: 'Polkadot', Icon: PolkadotSVG, }, diff --git a/src/config/networks.ts b/src/config/networks.ts index 3d1948d883..f8f048bbb6 100644 --- a/src/config/networks.ts +++ b/src/config/networks.ts @@ -5,10 +5,10 @@ import CereLogoSvg from 'img/cere_logo.svg?react'; import type { NetworkName, Networks } from 'types'; import BigNumber from 'bignumber.js'; -const CereMainnet: NetworkName = 'Cere Mainnet'; -const CereTestnet: NetworkName = 'Cere Testnet'; -const CereDevnet: NetworkName = 'Cere Devnet'; -const CereQanet: NetworkName = 'Cere Qanet'; +const CereMainnet: NetworkName = 'cereMainnet'; +const CereTestnet: NetworkName = 'cereTestnet'; +const CereDevnet: NetworkName = 'cereDevnet'; +const CereQanet: NetworkName = 'cereQanet'; const cereMainnet = { name: CereMainnet, diff --git a/src/consts.ts b/src/consts.ts index 95c7f0156e..2d045a6da9 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -11,7 +11,7 @@ import type { Plugin } from 'types'; export const AppVersion = '1.0.8'; export const DappName = 'Cere Staking Dashboard'; export const CereUrl = 'https://cere.network'; -export const DefaultNetwork = 'Cere Mainnet'; +export const DefaultNetwork = 'cereMainnet'; export const ManualSigners = ['ledger', 'vault']; /* * Data Structure Helpers diff --git a/src/contexts/Network/index.tsx b/src/contexts/Network/index.tsx index c41711a351..70a72e2e91 100644 --- a/src/contexts/Network/index.tsx +++ b/src/contexts/Network/index.tsx @@ -10,6 +10,8 @@ import type { NetworkState } from 'contexts/Api/types'; import type { NetworkContextInterface } from './types'; import { defaultNetworkContext } from './defaults'; +console.log('Default network context'); +console.log(defaultNetworkContext); export const NetworkProvider = ({ children, }: { @@ -43,9 +45,12 @@ export const NetworkProvider = ({ // handle network switching const switchNetwork = (name: NetworkName) => { + console.warn(`Switching network to name: ${name}`); + console.warn(NetworkList); + setNetwork({ name, - meta: NetworkList[name], + meta: NetworkList.cereMainnet, }); // update url `n` if needed. @@ -54,9 +59,11 @@ export const NetworkProvider = ({ // Store the initial active network. const initialNetwork = getInitialNetwork(); + console.warn('Initial network'); + console.warn(NetworkList); const [network, setNetwork] = useState({ name: initialNetwork, - meta: NetworkList[initialNetwork], + meta: NetworkList.cereMainnet, }); return ( diff --git a/src/modals/Connect/Ledger.tsx b/src/modals/Connect/Ledger.tsx index f1d6dff560..7d43a96d6e 100644 --- a/src/modals/Connect/Ledger.tsx +++ b/src/modals/Connect/Ledger.tsx @@ -44,11 +44,11 @@ export const Ledger = (): React.ReactElement => {
diff --git a/src/types/index.ts b/src/types/index.ts index fa939af016..50e953a60c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -13,10 +13,10 @@ declare global { } export type NetworkName = - | 'Cere Mainnet' - | 'Cere Testnet' - | 'Cere Devnet' - | 'Cere Qanet'; + | 'cereMainnet' + | 'cereTestnet' + | 'cereDevnet' + | 'cereQanet'; export type Networks = Record;