From 6608c04186c06c06a45b56a0c16f51dc8eeb1e0f Mon Sep 17 00:00:00 2001 From: finned-palmer Date: Thu, 1 Jul 2021 11:39:12 -0500 Subject: [PATCH] Cleanup walletModal, transaction, invoice --- .../src/js/components/lib/invoice.js | 27 +++++-------------- .../src/js/components/lib/transactions.js | 2 +- .../src/js/components/lib/walletModal.js | 6 +---- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/pkg/btc-wallet/src/js/components/lib/invoice.js b/pkg/btc-wallet/src/js/components/lib/invoice.js index 4d9c6563c1..9b843d617e 100644 --- a/pkg/btc-wallet/src/js/components/lib/invoice.js +++ b/pkg/btc-wallet/src/js/components/lib/invoice.js @@ -1,4 +1,4 @@ -import React, { useRef, useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import { Box, Icon, @@ -57,7 +57,6 @@ const Invoice = ({ stopSending, payee, satsAmount }) => { const [ready, setReady] = useState(false); const [localError, setLocalError] = useState(error); const [broadcasting, setBroadcasting] = useState(false); - const invoiceRef = useRef(); useEffect(() => { if (broadcasting && localError !== '') { @@ -65,17 +64,6 @@ const Invoice = ({ stopSending, payee, satsAmount }) => { } }, [error, broadcasting, setBroadcasting]); - const clickDismiss = (e) => { - if (invoiceRef && !invoiceRef.contains(e.target)) { - stopSending(); - } - }; - - useEffect(() => { - document.addEventListener('click', clickDismiss); - return () => document.removeEventListener('click', clickDismiss); - }, []); - const broadCastTx = (psbtHex) => { let command = { 'broadcast-tx': psbtHex, @@ -90,6 +78,7 @@ const Invoice = ({ stopSending, payee, satsAmount }) => { ticket, ship: parseInt(patp2dec('~' + window.ship)), }).then((urbitWallet) => { + // this wasn't being used, not clear why it was pulled out. // const { xpub } = // network === 'testnet' // ? urbitWallet.bitcoinTestnet.keys @@ -127,11 +116,11 @@ const Invoice = ({ stopSending, payee, satsAmount }) => { }); }; - const checkTicket = (e) => { + const checkTicket = ({ target: { value } }) => { // TODO: port over bridge ticket validation logic - setMasterTicket(e.target.value); - setReady(isValidPatq(e.target.value)); - setLocalError(isValidPatq(e.target.value) ? '' : 'invalid-master-ticket'); + setMasterTicket(value); + setReady(isValidPatq(value)); + setLocalError(isValidPatq(value) ? '' : 'invalid-master-ticket'); }; let inputColor = 'black'; @@ -168,13 +157,11 @@ const Invoice = ({ stopSending, payee, satsAmount }) => { ) : ( stopSending()} > { color={inputColor} backgroundColor={inputBg} borderColor={inputBorder} - onChange={() => checkTicket()} + onChange={(e) => checkTicket(e)} /> {error !== '' && ( diff --git a/pkg/btc-wallet/src/js/components/lib/transactions.js b/pkg/btc-wallet/src/js/components/lib/transactions.js index 2bd7619956..c968320bcd 100644 --- a/pkg/btc-wallet/src/js/components/lib/transactions.js +++ b/pkg/btc-wallet/src/js/components/lib/transactions.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React from 'react'; import { Box, Text, Col } from '@tlon/indigo-react'; import Transaction from './transaction.js'; import { useSettings } from '../../hooks/useSettings.js'; diff --git a/pkg/btc-wallet/src/js/components/lib/walletModal.js b/pkg/btc-wallet/src/js/components/lib/walletModal.js index a34a596c03..be0bc6ef07 100644 --- a/pkg/btc-wallet/src/js/components/lib/walletModal.js +++ b/pkg/btc-wallet/src/js/components/lib/walletModal.js @@ -39,11 +39,7 @@ const WalletModal = () => { } }; - const checkXPub = ({ - event: { - target: { value: xpubGiven }, - }, - }) => { + const checkXPub = ({ target: { value: xpubGiven } }) => { setXpub(xpubGiven); setReadyToSubmit(xpubGiven.length > 0); };