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

Commit

Permalink
v1.8.8
Browse files Browse the repository at this point in the history
Add wallet spam options
  • Loading branch information
adityapk00 committed Sep 5, 2022
1 parent a1e65b0 commit 88fdd97
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/printversion.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
echo "VERSION=1.8.7" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VERSION=1.8.8" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
2 changes: 1 addition & 1 deletion bin/printversion.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
VERSION="1.8.7"
VERSION="1.8.8"
echo "VERSION=$VERSION" >> $GITHUB_ENV
2 changes: 1 addition & 1 deletion native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default-features = false
features = ["napi-6"]

[dependencies]
zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "0ab554fe66070a98b0cdd49f4e6fcc7cc41626b9" }
zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "fd5d11f0f28e0f1628ea8fdad0cce16d50e6bb98" }
#zecwalletlitelib = { path = "../../zecwallet-light-cli/lib" }
lazy_static = "1.4.0"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zecwallet-lite",
"productName": "Zecwallet Lite",
"version": "1.8.7",
"version": "1.8.8",
"private": true,
"description": "Zecwallet Lite",
"license": "MIT",
Expand Down
12 changes: 12 additions & 0 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ class MenuBuilder {
mainWindow.webContents.send("rescan");
},
},
{
label: "Wallet Settings",
click: () => {
this.mainWindow.webContents.send("walletSettings");
},
},
{
label: "Server info",
click: () => {
Expand Down Expand Up @@ -336,6 +342,12 @@ class MenuBuilder {
mainWindow.webContents.send("rescan");
},
},
{
label: "Wallet Settings",
click: () => {
this.mainWindow.webContents.send("walletSettings");
},
},
{
label: "Server info",
click: () => {
Expand Down
11 changes: 10 additions & 1 deletion src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import AppState, {
SendProgress,
AddressType,
AddressDetail,
WalletSettings,
} from "./components/AppState";
import RPC from "./rpc";
import Utils from "./utils/utils";
Expand Down Expand Up @@ -62,7 +63,8 @@ export default class RouteApp extends React.Component<Props, AppState> {
this.setTransactionList,
this.setAllAddresses,
this.setInfo,
this.setZecPrice
this.setZecPrice,
this.setWalletSettings
);
}

Expand Down Expand Up @@ -200,6 +202,10 @@ export default class RouteApp extends React.Component<Props, AppState> {
this.setState({ totalBalance });
};

setWalletSettings = (walletSettings: WalletSettings) => {
this.setState({ walletSettings });
};

setAddressesWithBalances = (addressesWithBalance: AddressBalance[]) => {
this.setState({ addressesWithBalance });

Expand Down Expand Up @@ -456,6 +462,7 @@ export default class RouteApp extends React.Component<Props, AppState> {
errorModalData,
serverSelectState,
passwordState,
walletSettings,
} = this.state;

const standardProps = {
Expand Down Expand Up @@ -506,6 +513,8 @@ export default class RouteApp extends React.Component<Props, AppState> {
decryptWallet={this.decryptWallet}
openPassword={this.openPassword}
clearTimers={this.clearTimers}
walletSettings={walletSettings}
setWalletSettings={this.setWalletSettings}
{...standardProps}
/>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/components/AppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ export class SendProgress {
}
}

export class WalletSettings {
download_memos: string;
spam_filter_threshold: number;

constructor() {
this.download_memos = "wallet";
this.spam_filter_threshold = 0;
}
}

export class AddressDetail {
address: string;
type: AddressType;
Expand Down Expand Up @@ -279,6 +289,8 @@ export default class AppState {
// getinfo and getblockchaininfo result
info: Info;

walletSettings: WalletSettings;

// Error modal data
errorModalData: ErrorModalData;

Expand Down Expand Up @@ -311,5 +323,6 @@ export default class AppState {
this.rescanning = false;
this.prevSyncId = -1;
this.passwordState = new PasswordState();
this.walletSettings = new WalletSettings();
}
}
4 changes: 2 additions & 2 deletions src/components/ServerSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default function ServerSelectModal({ modalIsOpen, closeModal, openErrorMo
overlayClassName={cstyles.modalOverlay}
>
<div className={[cstyles.verticalflex].join(" ")}>
<div className={cstyles.marginbottomlarge} style={{ textAlign: "center" }}>
Select LightwalletD server
<div className={cstyles.marginbottomlarge} style={{ textAlign: "left", marginLeft: 10 }}>
Switch LightwalletD server
</div>

<div className={[cstyles.well, cstyles.verticalflex].join(" ")}>
Expand Down
34 changes: 31 additions & 3 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import styles from "./Sidebar.module.css";
import cstyles from "./Common.module.css";
import routes from "../constants/routes.json";
import Logo from "../assets/img/logobig.png";
import { AddressDetail, Info, Transaction } from "./AppState";
import { AddressDetail, Info, Transaction, WalletSettings } from "./AppState";
import Utils from "../utils/utils";
import RPC from "../rpc";
import { parseZcashURI, ZcashURITarget } from "../utils/uris";
import WalletSettingsModal from "./WalletSettingsModal";

const { ipcRenderer, remote } = window.require("electron");
const fs = window.require("fs");
Expand Down Expand Up @@ -240,6 +241,8 @@ type Props = {
lockWallet: () => void;
encryptWallet: (p: string) => void;
decryptWallet: (p: string) => Promise<boolean>;
walletSettings: WalletSettings;
setWalletSettings: (walletSettings: WalletSettings) => void;
};

type State = {
Expand All @@ -249,6 +252,7 @@ type State = {
privKeyInputValue: string | null;
exportPrivKeysModalIsOpen: boolean;
exportedPrivKeys: string[];
walletSettingsModalIsOpen: boolean;
};

class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
Expand All @@ -261,6 +265,7 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
exportPrivKeysModalIsOpen: false,
exportedPrivKeys: [],
privKeyInputValue: null,
walletSettingsModalIsOpen: false,
};

this.setupMenuHandlers();
Expand All @@ -276,7 +281,7 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
openErrorModal(
"Zecwallet Lite",
<div className={cstyles.verticalflex}>
<div className={cstyles.margintoplarge}>Zecwallet Lite v1.8.7</div>
<div className={cstyles.margintoplarge}>Zecwallet Lite v1.8.8</div>
<div className={cstyles.margintoplarge}>Built with Electron. Copyright (c) 2018-2022, Aditya Kulkarni.</div>
<div className={cstyles.margintoplarge}>
The MIT License (MIT) Copyright (c) 2018-2022 Zecwallet
Expand Down Expand Up @@ -504,6 +509,11 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
history.push(routes.ZCASHD);
});

// Wallet Settings
ipcRenderer.on("walletSettings", () => {
this.setState({ walletSettingsModalIsOpen: true });
});

// Connect mobile app
ipcRenderer.on("connectmobile", () => {
history.push(routes.CONNECTMOBILE);
Expand Down Expand Up @@ -614,6 +624,16 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
this.setState({ uriModalIsOpen: false });
};

closeWalletSettingsModal = () => {
this.setState({ walletSettingsModalIsOpen: false });
};

setWalletSpamFilterThreshold = async (threshold: number) => {
// Call the RPC to set the threshold as an option
await RPC.setWalletSettingOption("spam_filter_threshold", threshold.toString());
// console.log("Setting spam filter threshold to", threshold);
};

payURI = (uri: string) => {
console.log(`Paying ${uri}`);
const { openErrorModal, setSendTo, history } = this.props;
Expand Down Expand Up @@ -644,14 +664,15 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
};

render() {
const { location, info } = this.props;
const { location, info, walletSettings } = this.props;
const {
uriModalIsOpen,
uriModalInputValue,
privKeyModalIsOpen,
//privKeyInputValue,
exportPrivKeysModalIsOpen,
exportedPrivKeys,
walletSettingsModalIsOpen,
} = this.state;

let state = "DISCONNECTED";
Expand Down Expand Up @@ -694,6 +715,13 @@ class Sidebar extends PureComponent<Props & RouteComponentProps, State> {
closeModal={this.closeExportPrivKeysModal}
/>

<WalletSettingsModal
modalIsOpen={walletSettingsModalIsOpen}
closeModal={this.closeWalletSettingsModal}
walletSettings={walletSettings}
setWalletSpamFilterThreshold={this.setWalletSpamFilterThreshold}
/>

<div className={[cstyles.center, styles.sidebarlogobg].join(" ")}>
<img src={Logo} width="70" alt="logo" />
</div>
Expand Down
76 changes: 76 additions & 0 deletions src/components/WalletSettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import Modal from "react-modal";
import React, { useEffect, useState } from "react";
import cstyles from "./Common.module.css";
import { WalletSettings } from "./AppState";

type ModalProps = {
walletSettings: WalletSettings;
modalIsOpen: boolean;
closeModal: () => void;
setWalletSpamFilterThreshold: (threshold: number) => void;
};

export default function WalletSettingsModal({
walletSettings,
modalIsOpen,
closeModal,
setWalletSpamFilterThreshold,
}: ModalProps) {
const [selected, setSelected] = useState("");

useEffect(() => {
if (walletSettings.spam_filter_threshold <= 0) {
setSelected("no_filter");
} else {
setSelected("filter");
}
}, [walletSettings]);

return (
<Modal
isOpen={modalIsOpen}
onRequestClose={closeModal}
className={cstyles.modal}
overlayClassName={cstyles.modalOverlay}
>
<div className={[cstyles.verticalflex].join(" ")}>
<div className={cstyles.marginbottomlarge} style={{ textAlign: "left", marginLeft: 10 }}>
Filter out Spam Transactions
</div>

<div className={[cstyles.well, cstyles.verticalflex].join(" ")}>
<div style={{ margin: "10px" }}>
<input
type="radio"
name="filter"
defaultChecked={selected === "filter"}
value="filter"
onClick={(e) => setWalletSpamFilterThreshold(50)}
/>
Don't scan spammy transactions
</div>

<div style={{ margin: "10px" }}>
<input
type="radio"
name="filter"
value="no_filter"
defaultChecked={selected === "no_filter"}
onClick={(e) => setWalletSpamFilterThreshold(0)}
/>
Scan all transactions
</div>
</div>

<div className={cstyles.buttoncontainer}>
<button type="button" className={cstyles.primarybutton} onClick={closeModal}>
Save
</button>
<button type="button" className={cstyles.primarybutton} onClick={closeModal}>
Close
</button>
</div>
</div>
</Modal>
);
}
Loading

0 comments on commit 88fdd97

Please sign in to comment.