From f7c30bea6427a24c557695ef861f218044330e71 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 22 Apr 2021 12:52:23 -0700 Subject: [PATCH] Move server names to Utils --- app/components/LoadingScreen.js | 16 ++++------------ app/components/ServerSelectModal.js | 5 +++-- app/utils/utils.js | 9 +++++++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/components/LoadingScreen.js b/app/components/LoadingScreen.js index cdd6416d..a0688260 100644 --- a/app/components/LoadingScreen.js +++ b/app/components/LoadingScreen.js @@ -18,6 +18,7 @@ import RPC from '../rpc'; import cstyles from './Common.module.css'; import styles from './LoadingScreen.module.css'; import Logo from '../assets/img/logobig.png'; +import Utils from '../utils/utils'; const locateZcashParamsDir = () => { if (os.platform() === 'darwin') { @@ -171,23 +172,14 @@ class LoadingScreen extends Component { return true; }; - // v1 LightwalletD - V1_LIGHTWALLETD: string = 'https://lightwalletd.zecwallet.co:1443'; - - // v2 LightwalletD - V2_LIGHTWALLETD: string = 'https://lwdv2.zecwallet.co:1443'; - - // v3 LightwalletD - V3_LIGHTWALLETD: string = 'https://lwdv3.zecwallet.co'; - loadServerURI = () => { // Try to read the default server const store = new Store(); - let server = store.get('lightd/serveruri', this.V3_LIGHTWALLETD); + let server = store.get('lightd/serveruri', Utils.V3_LIGHTWALLETD); // Automatically upgrade to v2 server if you had the previous v1 server. - if (server === this.V1_LIGHTWALLETD || server === this.V2_LIGHTWALLETD) { - server = this.V3_LIGHTWALLETD; + if (server === Utils.V1_LIGHTWALLETD || server === Utils.V2_LIGHTWALLETD) { + server = Utils.V3_LIGHTWALLETD; } const newstate = new LoadingScreenState(); diff --git a/app/components/ServerSelectModal.js b/app/components/ServerSelectModal.js index fc0cce2e..358a22f6 100644 --- a/app/components/ServerSelectModal.js +++ b/app/components/ServerSelectModal.js @@ -3,6 +3,7 @@ import Modal from 'react-modal'; import React, { useState } from 'react'; import Store from 'electron-store'; import cstyles from './Common.module.css'; +import Utils from '../utils/utils'; type ModalProps = { modalIsOpen: boolean, @@ -33,8 +34,8 @@ export default function ServerSelectModal({ modalIsOpen, closeModal, openErrorMo }; const servers = [ - { name: 'Zecwallet (Default)', uri: 'https://lwdv2.zecwallet.co:1443' }, - { name: 'Zecwallet (Backup)', uri: 'https://lightd-main.zecwallet.co:443' }, + { name: 'Zecwallet (Default)', uri: Utils.V3_LIGHTWALLETD }, + { name: 'Zecwallet (Backup)', uri: Utils.V2_LIGHTWALLETD }, { name: 'ZcashFR (Community)', uri: 'https://lightd-main.zcashfr.io:443' } ]; diff --git a/app/utils/utils.js b/app/utils/utils.js index bab5c120..00ee0735 100644 --- a/app/utils/utils.js +++ b/app/utils/utils.js @@ -4,6 +4,15 @@ export const NO_CONNECTION: string = 'Could not connect to zcashd'; export default class Utils { + // v1 LightwalletD + static V1_LIGHTWALLETD: string = 'https://lightwalletd.zecwallet.co:1443'; + + // v2 LightwalletD + static V2_LIGHTWALLETD: string = 'https://lwdv2.zecwallet.co:1443'; + + // v3 LightwalletD + static V3_LIGHTWALLETD: string = 'https://lwdv3.zecwallet.co'; + static isSapling(addr: string): boolean { if (!addr) return false; return new RegExp('^z[a-z0-9]{77}$').test(addr) || new RegExp('^ztestsapling[a-z0-9]{76}$').test(addr);