From 24c01070365cbfcfc52d6cddad73d866bbbcf0dc Mon Sep 17 00:00:00 2001 From: Thebora Kompanioni Date: Fri, 22 Jul 2022 11:55:47 +0200 Subject: [PATCH 1/9] fix: spacing in jar overlay header and `onKeyDown` (#421) * fix: spacing in jar overlay header * fix: onKeyDown handling in jar overlay --- .../DisplayAccountsOverlay.module.css | 4 +- src/components/DisplayAccountsOverlay.tsx | 47 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/components/DisplayAccountsOverlay.module.css b/src/components/DisplayAccountsOverlay.module.css index ad30788ff..0f8da7c4e 100644 --- a/src/components/DisplayAccountsOverlay.module.css +++ b/src/components/DisplayAccountsOverlay.module.css @@ -16,8 +16,8 @@ .accounts-overlay-header-title { display: inline-flex; - justify-content: space-between; - width: 8ch; + justify-content: center; + min-width: 8ch; margin: 0 0.5rem; } diff --git a/src/components/DisplayAccountsOverlay.tsx b/src/components/DisplayAccountsOverlay.tsx index 1ed17d5e6..c2f161089 100644 --- a/src/components/DisplayAccountsOverlay.tsx +++ b/src/components/DisplayAccountsOverlay.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react' +import React, { useEffect, useMemo, useState, useCallback } from 'react' import * as rb from 'react-bootstrap' import { useTranslation } from 'react-i18next' import { DisplayBranchHeader, DisplayBranchBody } from './DisplayBranch' @@ -26,33 +26,36 @@ export function DisplayAccountsOverlay({ accounts, selectedAccountIndex = 0, sho setAccountIndex(selectedAccountIndex) }, [selectedAccountIndex]) - const nextAccount = () => { - const currentIndex = account === null ? 0 : accounts.indexOf(account) - setAccountIndex(currentIndex + 1 >= accounts.length ? 0 : currentIndex + 1) - } - const previousAccount = () => { - const currentIndex = account === null ? 0 : accounts.indexOf(account) - setAccountIndex(currentIndex - 1 < 0 ? accounts.length - 1 : currentIndex - 1) - } + const nextAccount = useCallback( + () => setAccountIndex((current) => (current + 1 >= accounts.length ? 0 : current + 1)), + [accounts] + ) + const previousAccount = useCallback( + () => setAccountIndex((current) => (current - 1 < 0 ? accounts.length - 1 : current - 1)), + [accounts] + ) - const onKeyDown = (e: KeyboardEvent) => { - if (e.code === 'ArrowLeft') previousAccount() - else if (e.code === 'ArrowRight') nextAccount() - } + const onKeyDown = useCallback( + (e: KeyboardEvent) => { + if (e.code === 'ArrowLeft') previousAccount() + else if (e.code === 'ArrowRight') nextAccount() + }, + [previousAccount, nextAccount] + ) + + useEffect(() => { + if (!show) return + + document.addEventListener('keydown', onKeyDown) + return () => document.removeEventListener('keydown', onKeyDown) + }, [show, onKeyDown]) if (!account) { return <> } return ( - +
@@ -70,7 +73,7 @@ export function DisplayAccountsOverlay({ accounts, selectedAccountIndex = 0, sho
- {t('current_wallet_advanced.account')} {account.account} + {t('current_wallet_advanced.account')} #{account.account}
Date: Fri, 22 Jul 2022 11:58:33 +0200 Subject: [PATCH 2/9] fix: do not display freeze info when all utxos have been selected (#420) --- src/components/fb/FidelityBondSteps.tsx | 42 ++++++++++++++----------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/components/fb/FidelityBondSteps.tsx b/src/components/fb/FidelityBondSteps.tsx index 61c5a6cf0..25cf64acd 100644 --- a/src/components/fb/FidelityBondSteps.tsx +++ b/src/components/fb/FidelityBondSteps.tsx @@ -209,26 +209,30 @@ const FreezeUtxos = ({ walletInfo, jar, utxos, selectedUtxos, isLoading = false isSelected={true} /> ))} - {fb.utxo.allAreFrozen(utxosToFreeze) ? ( -
- {t('earn.fidelity_bond.freeze_utxos.description_unselected_utxos')} -
- ) : ( -
- {t('earn.fidelity_bond.freeze_utxos.description_unselected_utxos')}{' '} - {t('earn.fidelity_bond.freeze_utxos.description_selected_utxos_to_freeze', { jar })} -
+ {utxosToFreeze.length > 0 && ( + <> + {fb.utxo.allAreFrozen(utxosToFreeze) ? ( +
+ {t('earn.fidelity_bond.freeze_utxos.description_unselected_utxos')} +
+ ) : ( +
+ {t('earn.fidelity_bond.freeze_utxos.description_unselected_utxos')}{' '} + {t('earn.fidelity_bond.freeze_utxos.description_selected_utxos_to_freeze', { jar })} +
+ )} + {utxosToFreeze.map((utxo, index) => ( + + ))} + )} - {utxosToFreeze.map((utxo, index) => ( - - ))}
) } From 47aab8046707fc631345c80afd36ffab807401f9 Mon Sep 17 00:00:00 2001 From: Thebora Kompanioni Date: Tue, 26 Jul 2022 09:16:37 +0200 Subject: [PATCH 3/9] refactor: move filtering for Fidelity Bonds to WalletContext (#418) --- src/components/CurrentWalletAdvanced.tsx | 9 +++------ src/components/Earn.jsx | 14 +++----------- src/components/fb/CreateFidelityBond.jsx | 2 +- src/context/WalletContext.tsx | 14 ++++++++++++++ src/hooks/BalanceSummary.test.tsx | 3 +++ 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/components/CurrentWalletAdvanced.tsx b/src/components/CurrentWalletAdvanced.tsx index 2a9d5c9e1..101a2ac7b 100644 --- a/src/components/CurrentWalletAdvanced.tsx +++ b/src/components/CurrentWalletAdvanced.tsx @@ -39,12 +39,9 @@ export default function CurrentWalletAdvanced() { reloadCurrentWalletInfo({ signal: abortCtrl.signal }) .then((info) => { - if (info && !abortCtrl.signal.aborted) { - const unspentOutputs = info.data.utxos.utxos - setUtxos(unspentOutputs) - - const fbOutputs = unspentOutputs.filter((utxo) => utxo.locktime) - setFidelityBonds(fbOutputs) + if (!abortCtrl.signal.aborted) { + setFidelityBonds(info.fidelityBondSummary.fbOutputs) + setUtxos(info.data.utxos.utxos) } }) .catch((err) => { diff --git a/src/components/Earn.jsx b/src/components/Earn.jsx index cf6762997..05219caf1 100644 --- a/src/components/Earn.jsx +++ b/src/components/Earn.jsx @@ -157,10 +157,8 @@ export default function Earn() { const reloadingServiceInfo = reloadServiceInfo({ signal: abortCtrl.signal }) const reloadingCurrentWalletInfo = reloadCurrentWalletInfo({ signal: abortCtrl.signal }).then((info) => { - if (info && !abortCtrl.signal.aborted) { - const unspentOutputs = info.data.utxos.utxos - const fbOutputs = unspentOutputs.filter((utxo) => utxo.locktime) - setFidelityBonds(fbOutputs) + if (!abortCtrl.signal.aborted) { + setFidelityBonds(info.fidelityBondSummary.fbOutputs) } }) @@ -206,13 +204,7 @@ export default function Earn() { resolve(reloadCurrentWalletInfo({ signal: abortCtrl.signal })) }, delay) }) - .then((info) => { - if (info) { - const unspentOutputs = info.data.utxos.utxos - const fbOutputs = unspentOutputs.filter((utxo) => utxo.locktime) - setFidelityBonds(fbOutputs) - } - }) + .then((info) => setFidelityBonds(info.fidelityBondSummary.fbOutputs)) .catch((err) => { setAlert({ variant: 'danger', message: err.message }) }) diff --git a/src/components/fb/CreateFidelityBond.jsx b/src/components/fb/CreateFidelityBond.jsx index 041977126..b25112a35 100644 --- a/src/components/fb/CreateFidelityBond.jsx +++ b/src/components/fb/CreateFidelityBond.jsx @@ -178,7 +178,7 @@ const CreateFidelityBond = ({ otherFidelityBondExists, accountBalances, totalBal // Note that two fidelity bonds with the same locktime will end up on the same address. // Therefore, this might not actually be the UTXO we just created. // Since we're using it only for displaying locktime and address, this should be fine though. - const fbUtxo = walletInfo.data.utxos.utxos.find((utxo) => utxo.address === timelockedAddress) + const fbUtxo = walletInfo.fidelityBondSummary.fbOutputs.find((utxo) => utxo.address === timelockedAddress) if (fbUtxo !== undefined) { setCreatedFidelityBondUtxo(fbUtxo) diff --git a/src/context/WalletContext.tsx b/src/context/WalletContext.tsx index 00794e631..8fa506b63 100644 --- a/src/context/WalletContext.tsx +++ b/src/context/WalletContext.tsx @@ -83,8 +83,13 @@ type AddressSummary = { [key: Api.BitcoinAddress]: AddressInfo } +type FidenlityBondSummary = { + fbOutputs: Utxos +} + export interface WalletInfo { addressSummary: AddressSummary + fidelityBondSummary: FidenlityBondSummary data: CombinedRawWalletData } @@ -106,6 +111,13 @@ const toAddressSummary = (data: CombinedRawWalletData): AddressSummary => { }, {} as AddressSummary) } +const toFidelityBondSummary = (data: CombinedRawWalletData): FidenlityBondSummary => { + const fbOutputs = data.utxos.utxos.filter((utxo) => utxo.locktime) + return { + fbOutputs, + } +} + const WalletContext = createContext(undefined) const restoreWalletFromSession = (): CurrentWallet | null => { @@ -140,9 +152,11 @@ const loadWalletInfoData = async ({ const toWalletInfo = (data: CombinedRawWalletData): WalletInfo => { const addressSummary = toAddressSummary(data) + const fidelityBondSummary = toFidelityBondSummary(data) return { addressSummary, + fidelityBondSummary, data, } } diff --git a/src/hooks/BalanceSummary.test.tsx b/src/hooks/BalanceSummary.test.tsx index f54569dee..9b44f1c5c 100644 --- a/src/hooks/BalanceSummary.test.tsx +++ b/src/hooks/BalanceSummary.test.tsx @@ -37,6 +37,7 @@ describe('BalanceSummary', () => { balanceSummary = setup( { addressSummary: {}, + fidelityBondSummary: { fbOutputs: [] }, data: { utxos: { utxos: [], @@ -67,6 +68,7 @@ describe('BalanceSummary', () => { balanceSummary = setup( { addressSummary: {}, + fidelityBondSummary: { fbOutputs: [] }, data: { utxos: { utxos: [ @@ -129,6 +131,7 @@ describe('BalanceSummary', () => { balanceSummary = setup( { addressSummary: {}, + fidelityBondSummary: { fbOutputs: [] }, data: { utxos: { utxos: [ From b41f21532bbc6aaec760188e2f6d56cf43e12485 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:20:12 +0200 Subject: [PATCH 4/9] build(deps): bump terser from 5.10.0 to 5.14.2 (#415) Bumps [terser](https://github.com/terser/terser) from 5.10.0 to 5.14.2. - [Release notes](https://github.com/terser/terser/releases) - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) - [Commits](https://github.com/terser/terser/commits) --- updated-dependencies: - dependency-name: terser dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 148 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index f60884570..1aa157df6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2634,6 +2634,64 @@ "@types/yargs-parser": "*" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz", + "integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -17383,13 +17441,14 @@ } }, "node_modules/terser": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.10.0.tgz", - "integrity": "sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==", + "version": "5.14.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.14.2.tgz", + "integrity": "sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==", "dev": true, "dependencies": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", "source-map-support": "~0.5.20" }, "bin": { @@ -17397,14 +17456,6 @@ }, "engines": { "node": ">=10" - }, - "peerDependencies": { - "acorn": "^8.5.0" - }, - "peerDependenciesMeta": { - "acorn": { - "optional": true - } } }, "node_modules/terser-webpack-plugin": { @@ -17465,15 +17516,6 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, - "node_modules/terser/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", @@ -20885,6 +20927,55 @@ } } }, + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true + }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.14", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz", + "integrity": "sha512-bJWEfQ9lPTvm3SneWwRFVLzrh6nhjwqw7TUFFBEMzwvg7t7PCDenf2lDwqo4NQXzdpgBXyFgDWnQA+2vkruksQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -31926,13 +32017,14 @@ } }, "terser": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.10.0.tgz", - "integrity": "sha512-AMmF99DMfEDiRJfxfY5jj5wNH/bYO09cniSqhfoyxc8sFoYIgkJy86G04UoZU5VjlpnplVu0K6Tx6E9b5+DlHA==", + "version": "5.14.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.14.2.tgz", + "integrity": "sha512-oL0rGeM/WFQCUd0y2QrWxYnq7tfSuKBiqTjRPWrRgB46WD/kiwHwF8T23z78H6Q6kGCuuHcPB+KULHRdxvVGQA==", "dev": true, "requires": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", "source-map-support": "~0.5.20" }, "dependencies": { @@ -31941,12 +32033,6 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true - }, - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true } } }, From 95def422550030fb80fbfe3d5f4f77c4cdfaa802 Mon Sep 17 00:00:00 2001 From: Thebora Kompanioni Date: Tue, 26 Jul 2022 12:29:08 +0200 Subject: [PATCH 5/9] refactor: move BalanceSummary to WalletContext (#419) --- src/components/CurrentWalletMagic.jsx | 10 +- src/components/Earn.jsx | 8 +- src/components/Jam.jsx | 6 +- src/components/Navbar.jsx | 4 +- src/components/Receive.jsx | 14 +- src/components/Send.jsx | 16 +- src/components/fb/FidelityBondSteps.tsx | 2 +- src/context/BalanceSummary.test.tsx | 188 +++++++++++++++++++ src/context/BalanceSummary.ts | 124 ++++++++++++ src/context/WalletContext.tsx | 7 +- src/hooks/BalanceSummary.test.tsx | 238 ------------------------ src/hooks/BalanceSummary.ts | 143 -------------- 12 files changed, 343 insertions(+), 417 deletions(-) create mode 100644 src/context/BalanceSummary.test.tsx create mode 100644 src/context/BalanceSummary.ts delete mode 100644 src/hooks/BalanceSummary.test.tsx delete mode 100644 src/hooks/BalanceSummary.ts diff --git a/src/components/CurrentWalletMagic.jsx b/src/components/CurrentWalletMagic.jsx index 92e0bf4b9..7f7920244 100644 --- a/src/components/CurrentWalletMagic.jsx +++ b/src/components/CurrentWalletMagic.jsx @@ -10,7 +10,6 @@ import { walletDisplayName } from '../utils' import styles from './CurrentWalletMagic.module.css' import { ExtendedLink } from './ExtendedLink' import { routes } from '../constants/routes' -import { useBalanceSummary } from '../hooks/BalanceSummary' import { DisplayAccountsOverlay } from './DisplayAccountsOverlay' import { Jars } from './Jars' @@ -50,7 +49,6 @@ export default function CurrentWalletMagic() { const settingsDispatch = useSettingsDispatch() const currentWallet = useCurrentWallet() const currentWalletInfo = useCurrentWalletInfo() - const balanceSummary = useBalanceSummary(currentWalletInfo) const reloadCurrentWalletInfo = useReloadCurrentWalletInfo() const [alert, setAlert] = useState(null) @@ -66,7 +64,7 @@ export default function CurrentWalletMagic() { const onJarClicked = (accountIndex) => { if (accountIndex === 0) { - const isEmpty = Number(balanceSummary?.accountBalances[accountIndex]?.totalBalance) === 0 + const isEmpty = Number(currentWalletInfo?.balanceSummary.accountBalances[accountIndex]?.totalBalance) === 0 if (isEmpty) { navigate(routes.receive, { state: { account: accountIndex } }) @@ -115,7 +113,7 @@ export default function CurrentWalletMagic() { settingsDispatch({ showBalance: !settings.showBalance })} style={{ cursor: 'pointer' }}> ) : ( )} diff --git a/src/components/Earn.jsx b/src/components/Earn.jsx index 05219caf1..6114b48bc 100644 --- a/src/components/Earn.jsx +++ b/src/components/Earn.jsx @@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next' import { useSettings } from '../context/SettingsContext' import { useCurrentWallet, useCurrentWalletInfo, useReloadCurrentWalletInfo } from '../context/WalletContext' import { useServiceInfo, useReloadServiceInfo } from '../context/ServiceInfoContext' -import { useBalanceSummary } from '../hooks/BalanceSummary' import Sprite from './Sprite' import PageTitle from './PageTitle' import SegmentedTabs from './SegmentedTabs' @@ -91,7 +90,6 @@ export default function Earn() { const reloadCurrentWalletInfo = useReloadCurrentWalletInfo() const serviceInfo = useServiceInfo() const reloadServiceInfo = useReloadServiceInfo() - const balanceSummary = useBalanceSummary(currentWalletInfo) const [showAdvancedSettings, setShowAdvancedSettings] = useState(false) const [alert, setAlert] = useState(null) @@ -308,11 +306,11 @@ export default function Earn() { {!serviceInfo?.makerRunning && !isWaitingMakerStart && !isWaitingMakerStop && - (!isLoading && balanceSummary ? ( + (!isLoading && currentWalletInfo ? ( 0} - accountBalances={balanceSummary?.accountBalances} - totalBalance={balanceSummary?.totalBalance} + accountBalances={currentWalletInfo.balanceSummary.accountBalances} + totalBalance={currentWalletInfo.balanceSummary.totalBalance} wallet={currentWallet} walletInfo={currentWalletInfo} onDone={() => reloadFidelityBonds({ delay: RELOAD_FIDELITY_BONDS_DELAY_MS })} diff --git a/src/components/Jam.jsx b/src/components/Jam.jsx index 10e017ef8..5cd7b9186 100644 --- a/src/components/Jam.jsx +++ b/src/components/Jam.jsx @@ -7,7 +7,6 @@ import { useSettings } from '../context/SettingsContext' import { useServiceInfo, useReloadServiceInfo } from '../context/ServiceInfoContext' import { useCurrentWallet, useCurrentWalletInfo, useReloadCurrentWalletInfo } from '../context/WalletContext' import { isDebugFeatureEnabled } from '../constants/debugFeatures' -import { useBalanceSummary } from '../hooks/BalanceSummary' import { COINJOIN_PRECONDITIONS, useCoinjoinPreconditionSummary } from '../hooks/CoinjoinPrecondition' import PageTitle from './PageTitle' import ToggleSwitch from './ToggleSwitch' @@ -46,7 +45,6 @@ export default function Jam() { const reloadServiceInfo = useReloadServiceInfo() const wallet = useCurrentWallet() const walletInfo = useCurrentWalletInfo() - const balanceSummary = useBalanceSummary(walletInfo) const reloadCurrentWalletInfo = useReloadCurrentWalletInfo() const [alert, setAlert] = useState(null) @@ -315,7 +313,7 @@ export default function Jam() { - {!collaborativeOperationRunning && balanceSummary && ( + {!collaborativeOperationRunning && walletInfo && ( <>
@@ -329,7 +327,7 @@ export default function Jam() {
<> diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index aa00da0f9..5099470bc 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -10,7 +10,6 @@ import { useCurrentWallet, useCurrentWalletInfo } from '../context/WalletContext import { useServiceInfo, useSessionConnectionError } from '../context/ServiceInfoContext' import { walletDisplayName } from '../utils' import { routes } from '../constants/routes' -import { useBalanceSummary } from '../hooks/BalanceSummary' const WalletPreview = ({ wallet, totalBalance, unit, showBalance }) => { return ( @@ -131,7 +130,6 @@ export default function Navbar() { const settings = useSettings() const currentWallet = useCurrentWallet() const currentWalletInfo = useCurrentWalletInfo() - const balanceSummary = useBalanceSummary(currentWalletInfo) const serviceInfo = useServiceInfo() const sessionConnectionError = useSessionConnectionError() @@ -206,7 +204,7 @@ export default function Navbar() { <> diff --git a/src/components/Receive.jsx b/src/components/Receive.jsx index d2623dcfc..9277f00e2 100644 --- a/src/components/Receive.jsx +++ b/src/components/Receive.jsx @@ -5,7 +5,6 @@ import { useTranslation } from 'react-i18next' import { useSettings } from '../context/SettingsContext' import { useCurrentWallet, useCurrentWalletInfo } from '../context/WalletContext' -import { useBalanceSummary } from '../hooks/BalanceSummary' import * as Api from '../libs/JmWalletApi' import { BitcoinQR } from './BitcoinQR' @@ -22,7 +21,6 @@ export default function Receive() { const settings = useSettings() const currentWallet = useCurrentWallet() const walletInfo = useCurrentWalletInfo() - const balanceSummary = useBalanceSummary(walletInfo) const [validated, setValidated] = useState(false) const [alert, setAlert] = useState(null) const [isLoading, setIsLoading] = useState(false) @@ -33,9 +31,11 @@ export default function Receive() { const [showSettings, setShowSettings] = useState(false) const sortedAccountBalances = useMemo(() => { - if (!balanceSummary) return [] - return Object.values(balanceSummary.accountBalances).sort((lhs, rhs) => lhs.accountIndex - rhs.accountIndex) - }, [balanceSummary]) + if (!walletInfo) return [] + return Object.values(walletInfo.balanceSummary.accountBalances).sort( + (lhs, rhs) => lhs.accountIndex - rhs.accountIndex + ) + }, [walletInfo]) useEffect(() => { const abortCtrl = new AbortController() @@ -119,7 +119,7 @@ export default function Receive() { {showSettings && (
- {!balanceSummary || sortedAccountBalances.length === 0 ? ( + {!walletInfo || sortedAccountBalances.length === 0 ? ( @@ -132,7 +132,7 @@ export default function Receive() { balance={it.totalBalance} isSelectable={true} isSelected={it.accountIndex === selectedJarIndex} - fillLevel={calculateFillLevel(it.totalBalance, balanceSummary.totalBalance)} + fillLevel={calculateFillLevel(it.totalBalance, walletInfo.balanceSummary.totalBalance)} onClick={() => setSelectedJarIndex(it.accountIndex)} /> ))} diff --git a/src/components/Send.jsx b/src/components/Send.jsx index da5eea15f..a96fe0763 100644 --- a/src/components/Send.jsx +++ b/src/components/Send.jsx @@ -13,7 +13,6 @@ import { useReloadCurrentWalletInfo, useCurrentWallet, useCurrentWalletInfo } fr import { useServiceInfo, useReloadServiceInfo } from '../context/ServiceInfoContext' import { useLoadConfigValue } from '../context/ServiceConfigContext' import { useSettings } from '../context/SettingsContext' -import { useBalanceSummary } from '../hooks/BalanceSummary' import { COINJOIN_PRECONDITIONS, useCoinjoinPreconditionSummary } from '../hooks/CoinjoinPrecondition' import * as Api from '../libs/JmWalletApi' @@ -309,10 +308,9 @@ export default function Send() { const [numCollaborators, setNumCollaborators] = useState(initialNumCollaborators(minNumCollaborators)) const [formIsValid, setFormIsValid] = useState(false) - const balanceSummary = useBalanceSummary(walletInfo) const accountBalanceOrNull = useMemo( - () => (balanceSummary && balanceSummary.accountBalances[account]) || null, - [balanceSummary, account] + () => (walletInfo && walletInfo.balanceSummary.accountBalances[account]) || null, + [walletInfo, account] ) const sourceJarUtxos = useMemo(() => { @@ -708,12 +706,12 @@ export default function Send() { )} - {!isLoading && balanceSummary && ( + {!isLoading && walletInfo && ( setDestinationJarPickerShown(false)} onConfirm={(selectedJar) => { @@ -755,8 +753,8 @@ export default function Send() { isInvalid={!isValidAccount(account)} disabled={isOperationDisabled} > - {balanceSummary && - Object.values(balanceSummary.accountBalances) + {walletInfo && + Object.values(walletInfo.balanceSummary.accountBalances) .sort((lhs, rhs) => lhs.accountIndex - rhs.accountIndex) .map(({ accountIndex, totalBalance, calculatedTotalBalanceInSats }) => (
-
+
Date: Tue, 26 Jul 2022 16:30:22 +0200 Subject: [PATCH 9/9] feat(cheatsheet): link to jamdocs.org (#429) --- src/components/Cheatsheet.tsx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/components/Cheatsheet.tsx b/src/components/Cheatsheet.tsx index 49a8b02c8..cf38db850 100644 --- a/src/components/Cheatsheet.tsx +++ b/src/components/Cheatsheet.tsx @@ -50,27 +50,15 @@ export default function Cheatsheet({ show = false, onHide }: CheatsheetProps) {
Follow the steps below to increase your financial privacy. It is advisable to switch from{' '} - + earning as a maker {' '} to{' '} - + sending as a taker {' '} back and forth.{' '} - + Learn more.