diff --git a/native/Cargo.lock b/native/Cargo.lock index 871501dc..e8fbd964 100644 --- a/native/Cargo.lock +++ b/native/Cargo.lock @@ -360,7 +360,7 @@ dependencies = [ [[package]] name = "build_utils" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?branch=dev#d21c6d7fcba39a686f5f6ff00c76a662f311e05a" +source = "git+https://github.com/zingolabs/zingolib?branch=dev#44a371caa3cf9f0c076e927cf35a103fb96666fb" [[package]] name = "bumpalo" @@ -401,9 +401,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.84" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -2356,9 +2356,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "ffb93593068e9babdad10e4fce47dc9b3ac25315a72a59766ffd9e9a71996a04" dependencies = [ "bitflags 2.4.1", "errno", @@ -3133,9 +3133,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", @@ -3144,9 +3144,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -3722,7 +3722,7 @@ dependencies = [ [[package]] name = "zingo-memo" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?branch=dev#d21c6d7fcba39a686f5f6ff00c76a662f311e05a" +source = "git+https://github.com/zingolabs/zingolib?branch=dev#44a371caa3cf9f0c076e927cf35a103fb96666fb" dependencies = [ "zcash_address", "zcash_client_backend", @@ -3734,7 +3734,7 @@ dependencies = [ [[package]] name = "zingoconfig" version = "0.1.0" -source = "git+https://github.com/zingolabs/zingolib?branch=dev#d21c6d7fcba39a686f5f6ff00c76a662f311e05a" +source = "git+https://github.com/zingolabs/zingolib?branch=dev#44a371caa3cf9f0c076e927cf35a103fb96666fb" dependencies = [ "dirs", "http", @@ -3747,7 +3747,7 @@ dependencies = [ [[package]] name = "zingolib" version = "0.2.0" -source = "git+https://github.com/zingolabs/zingolib?branch=dev#d21c6d7fcba39a686f5f6ff00c76a662f311e05a" +source = "git+https://github.com/zingolabs/zingolib?branch=dev#44a371caa3cf9f0c076e927cf35a103fb96666fb" dependencies = [ "append-only-vec", "base58", diff --git a/public/index.html b/public/index.html index 160c0359..8e3171e5 100644 --- a/public/index.html +++ b/public/index.html @@ -29,6 +29,7 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Zingo PC + diff --git a/src/components/loadingscreen/LoadingScreen.tsx b/src/components/loadingscreen/LoadingScreen.tsx index d4f267d4..044b1826 100644 --- a/src/components/loadingscreen/LoadingScreen.tsx +++ b/src/components/loadingscreen/LoadingScreen.tsx @@ -1,16 +1,16 @@ import React, { Component } from "react"; -import { Redirect, RouteComponentProps, withRouter } from "react-router"; +import { RouteComponentProps, withRouter } from "react-router"; import TextareaAutosize from "react-textarea-autosize"; import request from "request"; import progress from "progress-stream"; import native from "../../native.node"; -import routes from "../../constants/routes.json"; import { RPCConfig, Info, Server } from "../appstate"; import RPC from "../../rpc/rpc"; import cstyles from "../common/Common.module.css"; import styles from "./LoadingScreen.module.css"; import { ContextApp } from "../../context/ContextAppState"; -import serverUris from "../../utils/serverUris"; +import serverUrisList from "../../utils/serverUrisList"; +import { Logo } from "../logo"; const { ipcRenderer } = window.require("electron"); const fs = window.require("fs"); @@ -81,9 +81,9 @@ type LoadingScreenProps = { setRescanning: (rescan: boolean, prevSyncId: number) => void; setInfo: (info: Info) => void; openServerSelectModal: () => void; - logo: string; setReadOnly: (readOnly: boolean) => void; setServerUris: (serverUris: Server[]) => void; + navigateToDashboard: () => void; }; class LoadingScreen extends Component { @@ -103,7 +103,9 @@ class LoadingScreen extends Component s.uri === server) + const serverInList = serverUrisList().filter((s: Server) => s.uri === server) if (!settings.serverchain_name) { chain_name = 'main'; if (serverInList && serverInList.length === 1) { @@ -229,8 +231,8 @@ class LoadingScreen extends Component s.latency !== null).sort((a, b) => (a.latency ? a.latency : Infinity) - (b.latency ? b.latency : Infinity)); + this.setState({ currentStatus: "Checking " + serverUrisList().length + " servers to connect..." }); + servers = this.calculateServerLatency(serverUrisList()).filter(s => s.latency !== null).sort((a, b) => (a.latency ? a.latency : Infinity) - (b.latency ? b.latency : Infinity)); server = servers[0].uri; chain_name = servers[0].chain_name; await ipcRenderer.invoke("saveSettings", { key: "serveruri", value: server }); @@ -418,9 +420,9 @@ class LoadingScreen extends Component let's go to dashboard if (ss.sync_id > prevSyncId || !ss.in_progress || ss.batch_num >= 25) { // First, save the wallet so we don't lose the just-synced data - if (!ss.last_error) { - RPC.doSave(); - } + //if (!ss.last_error) { + // RPC.doSave(); + //} // Set the info object, so the sidebar will show //console.log("Object info\n"); @@ -450,11 +452,11 @@ class LoadingScreen extends Component= myThis.state.nextSaveBatch) { - console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&& save wallet', ss.batch_num, myThis.state.nextSaveBatch); - RPC.doSave(); - myThis.setState({ nextSaveBatch: ss.batch_num + 2}); - } + //if (ss.batch_num >= myThis.state.nextSaveBatch) { + // console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&& save wallet', ss.batch_num, myThis.state.nextSaveBatch); + // RPC.doSave(); + // myThis.setState({ nextSaveBatch: ss.batch_num + 2}); + //} let base = 0; if (ss.batch_total) { @@ -600,37 +602,97 @@ class LoadingScreen extends Component this.props.navigateToDashboard(), 500); + } + // If still loading, show the status - if (!loadingDone) { - return ( -
- {walletScreen === 0 && ( -
-
-
Zingo PC v1.0.4
- Logo + return ( +
+
+ +
+ {walletScreen === 0 && ( +
+
{currentStatus}
+ {currentStatusIsError && ( +
+ + +
-
{currentStatus}
- {currentStatusIsError && ( -
- + )} +
+ )} + + {walletScreen === 1 && ( +
+
+
+
Create A New Wallet
+
+ Creates a new wallet with a new randomly generated seed phrase. Please save the seed phrase + carefully, it’s the only way to restore your wallet. +
+
+ +
+
+
+
Restore Wallet From Seed
+
+ If you already have a seed phrase, you can restore it to this wallet. This will rescan the + blockchain for all transactions from the seed phrase. +
+
- )} -
- )} - - {walletScreen === 1 && ( -
-
-
Zingo PC v1.0.4
- Logo
-
-
-
Create A New Wallet
-
- Creates a new wallet with a new randomly generated seed phrase. Please save the seed phrase - carefully, it’s the only way to restore your wallet. -
-
- - -
-
-
-
Restore Wallet From Seed
-
- If you already have a seed phrase, you can restore it to this wallet. This will rescan the - blockchain for all transactions from the seed phrase. -
-
- -
+
+
Restore Wallet From Viewing Key
+
+ If you already have a Unified Full Viewing Key, you can restore it to this wallet. This will rescan the + blockchain for all transactions from the UFVK.
-
-
Restore Wallet From Viewing Key
-
- If you already have a Unified Full Viewing Key, you can restore it to this wallet. This will rescan the - blockchain for all transactions from the UFVK. -
-
- -
+
+
- )} - - {walletScreen === 2 && ( -
-
-
Zingo PC v1.0.4
- Logo -
-
-
- {newWalletError && ( -
-
Error Creating New Wallet
-
There was an error creating a new wallet
-
-
{newWalletError}
-
-
- -
+
+ )} + + {walletScreen === 2 && ( +
+
+
+ {newWalletError && ( +
+
Error Creating New Wallet
+
There was an error creating a new wallet
+
+
{newWalletError}
+
+
+
- )} - - {!newWalletError && ( -
-
Your New Wallet
-
- This is your new wallet. Below is your seed phrase. PLEASE STORE IT CAREFULLY! The seed phrase - is the only way to recover your funds and transactions. -
-
-
{seed}
-
-
- -
+
+ )} + + {!newWalletError && ( +
+
Your New Wallet
+
+ This is your new wallet. Below is your seed phrase. PLEASE STORE IT CAREFULLY! The seed phrase + is the only way to recover your funds and transactions.
- )} -
+
+
{seed}
+
+
+ +
+
+ )}
- )} - - {walletScreen === 3 && ( -
-
-
Zingo PC v1.0.4
- Logo -
-
-
- {newWalletError && ( -
-
Error Restoring Wallet
-
There was an error restoring your seed phrase
-
-
{newWalletError}
-
-
- -
+
+ )} + + {walletScreen === 3 && ( +
+
+
+ {newWalletError && ( +
+
Error Restoring Wallet
+
There was an error restoring your seed phrase
+
+
{newWalletError}
+
+
+ +
+
+ )} + + {!newWalletError && ( +
+
Please enter your seed phrase
+ this.updateSeed(e)} + /> + +
+ Wallet Birthday. If you don’t know this, it is OK to enter ‘0’
- )} - - {!newWalletError && ( -
-
Please enter your seed phrase
- this.updateSeed(e)} - /> - -
- Wallet Birthday. If you don’t know this, it is OK to enter ‘0’ -
- this.updateBirthday(e)} - /> - -
- - -
+ this.updateBirthday(e)} + /> + +
+ +
- )} -
+
+ )}
- )} - - {walletScreen === 4 && ( -
-
-
Zingo PC v4
- Logo -
-
-
- {newWalletError && ( -
-
Error Restoring Wallet
-
There was an error restoring your Viewing Key
-
-
{newWalletError}
-
-
- -
+
+ )} + + {walletScreen === 4 && ( +
+
+
+ {newWalletError && ( +
+
Error Restoring Wallet
+
There was an error restoring your Viewing Key
+
+
{newWalletError}
+
+
+ +
+
+ )} + + {!newWalletError && ( +
+
Please enter your Unified Full Viewing Key
+ this.updateUfvk(e)} + /> + +
+ Wallet Birthday. If you don’t know this, it is OK to enter ‘0’
- )} - - {!newWalletError && ( -
-
Please enter your Unified Full Viewing Key
- this.updateUfvk(e)} - /> - -
- Wallet Birthday. If you don’t know this, it is OK to enter ‘0’ -
- this.updateBirthday(e)} - /> - -
- - -
+ this.updateBirthday(e)} + /> + +
+ +
- )} -
+
+ )}
- )} -
- ); - } +
+ )} +
+ ); - return ; } } diff --git a/src/components/logo/Logo.tsx b/src/components/logo/Logo.tsx new file mode 100644 index 00000000..40fde841 --- /dev/null +++ b/src/components/logo/Logo.tsx @@ -0,0 +1,24 @@ +import logo from "../../assets/img/logobig.png"; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faSnowflake } from '@fortawesome/free-solid-svg-icons'; + +type LogoProps = { + readOnly: boolean; +} + +const Logo = ({ readOnly }: LogoProps) => { + + return ( + <> +
Zingo PC v1.0.4
+
+ logo + {readOnly && ( + + )} +
+ + ); +} + +export default Logo; \ No newline at end of file diff --git a/src/components/logo/index.ts b/src/components/logo/index.ts new file mode 100644 index 00000000..586b1e73 --- /dev/null +++ b/src/components/logo/index.ts @@ -0,0 +1,3 @@ +import Logo from "./Logo"; + +export { Logo }; \ No newline at end of file diff --git a/src/components/serverselectmodal/ServerSelectModal.tsx b/src/components/serverselectmodal/ServerSelectModal.tsx index 998f0110..6d895255 100644 --- a/src/components/serverselectmodal/ServerSelectModal.tsx +++ b/src/components/serverselectmodal/ServerSelectModal.tsx @@ -3,7 +3,7 @@ import React, { useCallback, useContext, useEffect, useState } from "react"; import cstyles from "../common/Common.module.css"; import { ContextApp } from "../../context/ContextAppState"; import { Server } from "../appstate"; -import serverUris from "../../utils/serverUris"; +import serverUrisList from "../../utils/serverUrisList"; const { ipcRenderer } = window.require("electron"); type ModalProps = { @@ -13,7 +13,7 @@ type ModalProps = { export default function ServerSelectModal({ closeModal, openErrorModal }: ModalProps) { const context = useContext(ContextApp); - const { serverSelectState, serverUris: serverUrisContext } = context; + const { serverSelectState, serverUris } = context; const { modalIsOpen } = serverSelectState; const [selectedServer, setSelectedServer] = useState(""); @@ -28,7 +28,7 @@ export default function ServerSelectModal({ closeModal, openErrorModal }: ModalP const [customChain, setCustomChain] = useState<'main' | 'test' | 'regtest' | ''>(""); //const [listChain, setListChain] = useState<'main' | 'test' | 'regtest' | ''>(""); - const [servers, setServers] = useState(serverUrisContext.length > 0 ? serverUrisContext : serverUris()); + const [servers, setServers] = useState(serverUris.length > 0 ? serverUris : serverUrisList()); const chains = { "main": "Mainnet", @@ -70,7 +70,7 @@ export default function ServerSelectModal({ closeModal, openErrorModal }: ModalP useEffect(() => { (async () => { - const servers: Server[] = serverUrisContext.length > 0 ? serverUrisContext : serverUris(); + const servers: Server[] = serverUris.length > 0 ? serverUris : serverUrisList(); const settings = await ipcRenderer.invoke("loadSettings"); //console.log('modal server settings', settings); @@ -83,7 +83,7 @@ export default function ServerSelectModal({ closeModal, openErrorModal }: ModalP setSelectedSelection(currSelection); setServers(servers); })(); - }, [initialServerValue, serverUrisContext]); + }, [initialServerValue, serverUris]); const switchServer = async () => { const serveruri: string = selectedServer; diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx index bb4abeda..8b0e881e 100644 --- a/src/components/sidebar/Sidebar.tsx +++ b/src/components/sidebar/Sidebar.tsx @@ -4,7 +4,7 @@ import { RouteComponentProps, withRouter } from "react-router"; import styles from "./Sidebar.module.css"; import cstyles from "../common/Common.module.css"; import routes from "../../constants/routes.json"; -import { Address, Info, Transaction, TxDetail } from "../appstate"; +import { Address, Info, Server, Transaction, TxDetail } from "../appstate"; import Utils from "../../utils/utils"; import RPC from "../../rpc/rpc"; import { parseZcashURI, ZcashURITarget } from "../../utils/uris"; @@ -14,9 +14,7 @@ import ImportPrivKeyModal from "./components/ImportPrivKeyModal"; import ExportPrivKeyModal from "./components/ExportPrivKeyModal"; import SidebarMenuItem from "./components/SidebarMenuItem"; import { ContextApp } from "../../context/ContextAppState"; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faSnowflake } from '@fortawesome/free-solid-svg-icons'; -import serverUris from "../../utils/serverUris"; +import { Logo } from "../logo"; const { ipcRenderer, remote } = window.require("electron"); const fs = window.require("fs"); @@ -40,7 +38,7 @@ type SidebarProps = { encryptWallet: (p: string) => Promise; decryptWallet: (p: string) => Promise; updateWalletSettings: () => Promise; - logo: string; + navigateToLoadingScreen: (b: boolean, c: string, s: Server[]) => void; }; type SidebarState = { @@ -199,7 +197,6 @@ class Sidebar extends PureComponent { - const s = serverUris; // To change to another wallet, we reset the wallet loading // and redirect to the loading screen clearTimers(); @@ -207,14 +204,7 @@ class Sidebar extends PureComponent { - const s = serverUris; // To rescan, we reset the wallet loading // So set info the default, and redirect to the loading screen clearTimers(); @@ -344,12 +333,7 @@ class Sidebar extends PureComponent { - const { importPrivKeys, openErrorModal, setInfo, clearTimers, setRescanning, history } = this.props; - const { info } = this.context; + const { importPrivKeys, openErrorModal, setInfo, clearTimers, setRescanning } = this.props; + const { info, serverUris } = this.context; if (key) { let keys: string[] = key.split(new RegExp("[\\n\\r]+")); @@ -467,7 +451,6 @@ class Sidebar extends PureComponent
-
Zingo PC v1.0.4
-
- logo - {readOnly && ( - - )} -
+
diff --git a/src/root/Routes.tsx b/src/root/Routes.tsx index 9fca0656..f611def9 100644 --- a/src/root/Routes.tsx +++ b/src/root/Routes.tsx @@ -41,8 +41,6 @@ import PasswordModal from "../components/passwordmodal/PasswordModal"; import ServerSelectModal from "../components/serverselectmodal/ServerSelectModal"; import { ContextAppProvider, defaultAppState } from "../context/ContextAppState"; -import Logo from "../assets/img/logobig.png"; - type Props = {}; class Routes extends React.Component { @@ -496,11 +494,20 @@ class Routes extends React.Component { return result; } - navigateToLoadingScreen = () => { - this.props.history.push({ - pathname: routes.LOADING, + navigateToDashboard = () => { + this.props.history.replace({ + pathname: routes.DASHBOARD, + state: {}, + }); + }; + + navigateToLoadingScreen = (currentStatusIsError: boolean, currentStatus: string, serverUris: Server[]) => { + this.props.history.replace({ + pathname: routes.LOADING, state: { - serverUris: this.state.serverUris, + currentStatusIsError, + currentStatus, + serverUris, }, }); }; @@ -525,7 +532,7 @@ class Routes extends React.Component { />
- {this.props.location.pathname !== "/" && ( + {this.props.location.pathname !== "/" && !this.props.location.pathname.includes("zingo") && (
{ openPassword={this.openPassword} clearTimers={this.clearTimers} updateWalletSettings={this.updateWalletSettings} - logo={Logo} + navigateToLoadingScreen={this.navigateToLoadingScreen} {...standardProps} />
@@ -620,9 +627,9 @@ class Routes extends React.Component { setRescanning={this.setRescanning} setInfo={this.setInfo} openServerSelectModal={this.openServerSelectModal} - logo={Logo} setReadOnly={this.setReadOnly} setServerUris={this.setServerUris} + navigateToDashboard={this.navigateToDashboard} /> )} /> diff --git a/src/rpc/rpc.ts b/src/rpc/rpc.ts index 77204758..1bf22104 100644 --- a/src/rpc/rpc.ts +++ b/src/rpc/rpc.ts @@ -66,7 +66,7 @@ export default class RPC { // trying to sync this.refresh(false); // I need to save the wallet every 30 seconds Just in case. - RPC.doSave(); + //RPC.doSave(); // I need to fetch the ZEC price in USD. this.getZecPrice(); }, 30 * 1000); // 30 sec @@ -82,7 +82,7 @@ export default class RPC { // Immediately call the refresh after configure to update the UI this.refresh(true); this.updateData(); - RPC.doSave(); + //RPC.doSave(); } clearTimers() { @@ -118,10 +118,11 @@ export default class RPC { return syncstr; } - static async doSave() { - const savestr: string = await native.zingolib_execute_async("save", ""); - console.log(`Save status: ${savestr}`); - } + // deprecated in zingolib + //static async doSave() { + // const savestr: string = await native.zingolib_execute_async("save", ""); + // console.log(`Save status: ${savestr}`); + //} static deinitialize() { const str: string = native.zingolib_deinitialize(); @@ -235,7 +236,7 @@ export default class RPC { this.lastBlockHeight = latestBlockHeight; // Save the wallet - RPC.doSave(); + //RPC.doSave(); // All done console.log(`Finished (blocks) full refresh at server: ${latestBlockHeight} & wallet: ${walletHeight}`); @@ -260,7 +261,7 @@ export default class RPC { this.lastBlockHeight = latestBlockHeight; // Save the wallet - RPC.doSave(); + //RPC.doSave(); // All done console.log(`Finished (in_progress) full refresh at ${latestBlockHeight} & wallet: ${walletHeight}`); @@ -400,7 +401,7 @@ export default class RPC { static async setWalletSettingOption(name: string, value: string): Promise { const r: string = await native.zingolib_execute_async("setoption", `${name}=${value}`); - RPC.doSave(); + //RPC.doSave(); return r; } @@ -1083,7 +1084,7 @@ export default class RPC { this.fetchInfo(); // And save the wallet - RPC.doSave(); + //RPC.doSave(); return resultJSON.result === "success"; } @@ -1096,7 +1097,7 @@ export default class RPC { this.fetchInfo(); // And save the wallet - RPC.doSave(); + //RPC.doSave(); return resultJSON.result === "success"; } diff --git a/src/utils/serverUris.ts b/src/utils/serverUrisList.ts similarity index 96% rename from src/utils/serverUris.ts rename to src/utils/serverUrisList.ts index 3983d31d..b48baf13 100644 --- a/src/utils/serverUris.ts +++ b/src/utils/serverUrisList.ts @@ -1,6 +1,6 @@ import { Server } from "../components/appstate"; -const serverUris = (): Server[] => { +const serverUrisList = (): Server[] => { return [ { uri: 'https://mainnet.lightwalletd.com:9067', @@ -89,4 +89,4 @@ const serverUris = (): Server[] => { ]; }; -export default serverUris; +export default serverUrisList;