Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Move server names to Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Apr 22, 2021
1 parent 99939f8 commit f7c30be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 4 additions & 12 deletions app/components/LoadingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -171,23 +172,14 @@ class LoadingScreen extends Component<Props, LoadingScreenState> {
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();
Expand Down
5 changes: 3 additions & 2 deletions app/components/ServerSelectModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' }
];

Expand Down
9 changes: 9 additions & 0 deletions app/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f7c30be

Please sign in to comment.