Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testnet toggler now follows network state #152

Merged
merged 4 commits into from Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.template.html
Expand Up @@ -1152,8 +1152,8 @@ <h2 id="mnLastSeen" class="stake-balances" style="overflow-wrap: anywhere; top:
</div>

<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="tesnetToggler" onclick="MPW.toggleTestnet()">
<label class="custom-control-label" for="tesnetToggler">Testnet Mode</label>
<input type="checkbox" class="custom-control-input" id="testnetToggler" onclick="MPW.toggleTestnet()">
<label class="custom-control-label" for="testnetToggler">Testnet Mode</label>
</div>

</div>
Expand Down
1 change: 1 addition & 0 deletions scripts/global.js
Expand Up @@ -10,7 +10,7 @@
decryptWallet,
getNewAddress,
getDerivationPath,
LegacyMasterKey,

Check warning on line 13 in scripts/global.js

View workflow job for this annotation

GitHub Actions / ESLint

scripts/global.js#L13

'LegacyMasterKey' is defined but never used (@typescript-eslint/no-unused-vars)
} from './wallet.js';
import { getNetwork, HistoricalTxType } from './network.js';
import {
Expand Down Expand Up @@ -292,6 +292,7 @@
domDisplaySettingsBtn: document.getElementById('settingsDisplayBtn'),
domVersion: document.getElementById('version'),
domFlipdown: document.getElementById('flipdown'),
domTestnetToggler: document.getElementById('testnetToggler'),
};
await i18nStart();
await loadImages();
Expand Down
9 changes: 8 additions & 1 deletion scripts/settings.js
Expand Up @@ -386,8 +386,11 @@ async function setAnalytics(level, fSilent = false) {
}

export function toggleTestnet() {
if (fWalletLoaded)
if (fWalletLoaded) {
// Revert testnet toggle
doms.domTestnetToggler.checked = !doms.domTestnetToggler.checked;
return createAlert('warning', ALERTS.UNABLE_SWITCH_TESTNET, [], 3250);
}

// Update current chain config
cChainParams.current = cChainParams.current.isTestnet
Expand All @@ -403,6 +406,10 @@ export function toggleTestnet() {
doms.domGuiBalanceStakingTicker.innerText = cChainParams.current.TICKER;
doms.domPrefixNetwork.innerText =
cChainParams.current.PUBKEY_PREFIX.join(' or ');

// Update testnet toggle in settings
doms.domTestnetToggler.checked = cChainParams.current.isTestnet;

fillExplorerSelect();
fillNodeSelect();
getBalance(true);
Expand Down