diff --git a/web/cashtab/src/components/Send/Send.js b/web/cashtab/src/components/Send/Send.js --- a/web/cashtab/src/components/Send/Send.js +++ b/web/cashtab/src/components/Send/Send.js @@ -113,8 +113,7 @@ gap: 1rem; `; -// Note jestBCH is only used for unit tests; BCHJS must be mocked for jest -const SendBCH = ({ jestBCH, passLoadingStatus }) => { +const SendBCH = ({ passLoadingStatus }) => { // use balance parameters from wallet.state object and not legacy balances parameter from walletState, if user has migrated wallet // this handles edge case of user with old wallet who has not opened latest Cashtab version yet @@ -123,7 +122,6 @@ const ContextValue = React.useContext(WalletContext); const location = useLocation(); const { - BCH, wallet, fiatPrice, apiError, @@ -138,7 +136,6 @@ const [opReturnMsg, setOpReturnMsg] = useState(false); const [isEncryptedOptionalOpReturnMsg, setIsEncryptedOptionalOpReturnMsg] = useState(false); - const [bchObj, setBchObj] = useState(false); // Get device window width // If this is less than 769, the page will open with QR scanner open @@ -206,14 +203,6 @@ passLoadingStatus(false); }, [balances.totalBalance]); - useEffect(() => { - // jestBCH is only ever specified for unit tests, otherwise app will use getBCH(); - const activeBCH = jestBCH ? jestBCH : BCH; - - // set the BCH instance to state, for other functions to reference - setBchObj(activeBCH); - }, [BCH]); - useEffect(() => { // Manually parse for txInfo object on page load when Send.js is loaded with a query string @@ -346,7 +335,6 @@ try { const link = await sendXec( - bchObj, chronik, wallet, slpBalancesAndUtxos.nonSlpUtxos, @@ -408,7 +396,6 @@ try { const link = await sendXec( - bchObj, chronik, wallet, slpBalancesAndUtxos.nonSlpUtxos, @@ -1036,7 +1023,6 @@ }; SendBCH.propTypes = { - jestBCH: PropTypes.object, passLoadingStatus: PropTypes.func, }; diff --git a/web/cashtab/src/components/Send/__tests__/Send.test.js b/web/cashtab/src/components/Send/__tests__/Send.test.js --- a/web/cashtab/src/components/Send/__tests__/Send.test.js +++ b/web/cashtab/src/components/Send/__tests__/Send.test.js @@ -3,7 +3,6 @@ import { ThemeProvider } from 'styled-components'; import { theme } from 'assets/styles/theme'; import Send from 'components/Send/Send'; -import BCHJS from '@psf/bch-js'; import { walletWithBalancesAndTokens, walletWithBalancesMock, @@ -32,12 +31,11 @@ }); test('Wallet without BCH balance', () => { - const testBCH = new BCHJS(); const component = renderer.create( - + , @@ -47,12 +45,11 @@ }); test('Wallet with BCH balances', () => { - const testBCH = new BCHJS(); const component = renderer.create( - + , @@ -62,12 +59,11 @@ }); test('Wallet with BCH balances and tokens', () => { - const testBCH = new BCHJS(); const component = renderer.create( - + , @@ -77,14 +73,13 @@ }); test('Wallet with BCH balances and tokens and state field', () => { - const testBCH = new BCHJS(); const component = renderer.create( - + , @@ -99,12 +94,11 @@ balances: { totalBalance: 0 }, loading: false, }; - const testBCH = new BCHJS(); const component = renderer.create( - + , diff --git a/web/cashtab/src/hooks/__tests__/useBCH.test.js b/web/cashtab/src/hooks/__tests__/useBCH.test.js --- a/web/cashtab/src/hooks/__tests__/useBCH.test.js +++ b/web/cashtab/src/hooks/__tests__/useBCH.test.js @@ -24,7 +24,6 @@ it('sends XEC correctly', async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); @@ -36,7 +35,6 @@ .mockResolvedValue({ txid: expectedTxId }); expect( await sendXec( - BCH, chronik, wallet, utxos, @@ -52,7 +50,6 @@ it('sends XEC correctly with an encrypted OP_RETURN message', async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); @@ -66,7 +63,6 @@ .mockResolvedValue({ txid: expectedTxId }); expect( await sendXec( - BCH, chronik, wallet, utxos, @@ -86,7 +82,6 @@ it('sends one to many XEC correctly', async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); @@ -104,7 +99,6 @@ .mockResolvedValue({ txid: expectedTxId }); expect( await sendXec( - BCH, chronik, wallet, utxos, @@ -118,7 +112,6 @@ it(`Throws error if called trying to send one base unit ${currency.ticker} more than available in utxo set`, async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); @@ -143,7 +136,6 @@ let errorThrown; try { await sendXec( - BCH, chronik, wallet, utxos, @@ -160,7 +152,6 @@ expect(errorThrown.message).toStrictEqual('Insufficient funds'); const nullValuesSendBch = sendXec( - BCH, chronik, wallet, utxos, @@ -178,13 +169,11 @@ it('Throws error on attempt to send one satoshi less than backend dust limit', async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); const { utxos, wallet, destinationAddress } = sendBCHMock; const failedSendBch = sendXec( - BCH, chronik, wallet, utxos, @@ -226,7 +215,6 @@ it('receives errors from the network and parses it', async () => { const { sendXec } = useBCH(); - const BCH = new BCHJS(); const chronik = new ChronikClient( 'https://FakeChronikUrlToEnsureMocksOnly.com', ); @@ -235,7 +223,6 @@ throw new Error('insufficient priority (code 66)'); }); const insufficientPriority = sendXec( - BCH, chronik, wallet, utxos, @@ -254,7 +241,6 @@ throw new Error('txn-mempool-conflict (code 18)'); }); const txnMempoolConflict = sendXec( - BCH, chronik, wallet, utxos, @@ -273,7 +259,6 @@ throw new Error('Network Error'); }); const networkError = sendXec( - BCH, chronik, wallet, utxos, @@ -294,7 +279,6 @@ }); const tooManyAncestorsMempool = sendXec( - BCH, chronik, wallet, utxos, diff --git a/web/cashtab/src/hooks/useBCH.js b/web/cashtab/src/hooks/useBCH.js --- a/web/cashtab/src/hooks/useBCH.js +++ b/web/cashtab/src/hooks/useBCH.js @@ -346,7 +346,6 @@ }; const sendXec = async ( - BCH, chronik, wallet, utxos,