Fix network switch mechanism

This commit is contained in:
natsoni 2024-04-03 16:09:30 +09:00
parent 32383b0bc2
commit e9c40692a6
No known key found for this signature in database
GPG Key ID: C65917583181743B

View File

@ -262,22 +262,10 @@ export class StateService {
// /^\/ starts with a forward slash... // /^\/ starts with a forward slash...
// (?:[a-z]{2}(?:-[A-Z]{2})?\/)? optional locale prefix (non-capturing) // (?:[a-z]{2}(?:-[A-Z]{2})?\/)? optional locale prefix (non-capturing)
// (?:preview\/)? optional "preview" prefix (non-capturing) // (?:preview\/)? optional "preview" prefix (non-capturing)
// (testnet|liquidtestnet|liquid|signet)/ network string (captured as networkMatches[1]) // (testnet|signet)/ network string (captured as networkMatches[1])
// ($|\/) network string must end or end with a slash // ($|\/) network string must end or end with a slash
const networkMatches = url.match(/^\/(?:[a-z]{2}(?:-[A-Z]{2})?\/)?(?:preview\/)?(testnet|liquidtestnet|liquid|signet)($|\/)/); const networkMatches = url.match(/^\/(?:[a-z]{2}(?:-[A-Z]{2})?\/)?(?:preview\/)?(testnet|signet)($|\/)/);
switch (networkMatches && networkMatches[1]) { switch (networkMatches && networkMatches[1]) {
case 'liquid':
if (this.network !== 'liquid') {
this.network = 'liquid';
this.networkChanged$.next('liquid');
}
return;
case 'liquidtestnet':
if (this.network !== 'liquidtestnet') {
this.network = 'liquidtestnet';
this.networkChanged$.next('liquidtestnet');
}
return;
case 'signet': case 'signet':
if (this.network !== 'signet') { if (this.network !== 'signet') {
this.network = 'signet'; this.network = 'signet';
@ -285,7 +273,7 @@ export class StateService {
} }
return; return;
case 'testnet': case 'testnet':
if (this.network !== 'testnet') { if (this.network !== 'testnet' && this.network !== 'liquidtestnet') {
if (this.env.BASE_MODULE === 'liquid') { if (this.env.BASE_MODULE === 'liquid') {
this.network = 'liquidtestnet'; this.network = 'liquidtestnet';
this.networkChanged$.next('liquidtestnet'); this.networkChanged$.next('liquidtestnet');