From 96efec19d89d383fb167e8b499df4ce45648391c Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Tue, 9 Mar 2021 15:59:36 +0300 Subject: [PATCH] REF: use route params walletID, instead of fromWallet for SendDetails screen --- class/deeplink-schema-match.js | 5 ++--- screen/send/coinControl.js | 4 ++-- screen/send/details.js | 6 +++--- screen/wallets/transactions.js | 5 ++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/class/deeplink-schema-match.js b/class/deeplink-schema-match.js index f33cc58cd..d079e9c1e 100644 --- a/class/deeplink-schema-match.js +++ b/class/deeplink-schema-match.js @@ -47,7 +47,6 @@ class DeeplinkSchemaMatch { if (context.wallets.length >= 0) { const wallet = context.wallets[0]; const action = event.url.split('widget?action=')[1]; - const secret = wallet.getSecret(); if (wallet.chain === Chain.ONCHAIN) { if (action === 'openSend') { completionHandler([ @@ -55,7 +54,7 @@ class DeeplinkSchemaMatch { { screen: 'SendDetails', params: { - secret, + walletID: wallet.getID(), }, }, ]); @@ -322,7 +321,7 @@ class DeeplinkSchemaMatch { screen: 'SendDetails', params: { uri: uri.bitcoin, - fromWallet: wallet, + walletID: wallet.getID(), }, }, ]; diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index 8b06fe320..7b28f5df9 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -265,9 +265,9 @@ const CoinControl = () => { const { colors } = useTheme(); const navigation = useNavigation(); const { width } = useWindowDimensions(); - const { walletId, onUTXOChoose } = useRoute().params; + const { walletID, onUTXOChoose } = useRoute().params; const { wallets, saveToDisk, sleep } = useContext(BlueStorageContext); - const wallet = wallets.find(w => w.getID() === walletId); + const wallet = wallets.find(w => w.getID() === walletID); // sort by height ascending, txid , vout ascending const utxo = wallet.getUtxo(true).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout); const [output, setOutput] = useState(); diff --git a/screen/send/details.js b/screen/send/details.js index 4fc07ea80..11dfad498 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -55,7 +55,7 @@ const btcAddressRx = /^[a-zA-Z0-9]{26,35}$/; const SendDetails = () => { const { wallets, setSelectedWallet, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext); const navigation = useNavigation(); - const { name, params: routeParams } = useRoute(); // FIXME refactor to use walletID + const { name, params: routeParams } = useRoute(); const scrollView = useRef(); const { colors } = useTheme(); @@ -126,7 +126,7 @@ const SendDetails = () => { navigation.goBack(); return; } - const wallet = routeParams.fromWallet || suitable[0]; + const wallet = (routeParams.walletID && wallets.find(w => w.getID() === routeParams.walletID)) || suitable[0]; setWallet(wallet); setFeeUnit(wallet.getPreferredBalanceUnit()); setAmountUnit(wallet.preferredBalanceUnit); // default for whole screen @@ -778,7 +778,7 @@ const SendDetails = () => { const handleCoinControl = () => { setOptionsVisible(false); navigation.navigate('CoinControl', { - walletId: wallet.getID(), + walletID: wallet.getID(), onUTXOChoose: utxo => setUtxo(utxo), }); }; diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 852670b92..24e60996b 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -422,7 +422,7 @@ const WalletTransactions = () => { params: { memo: loc.lnd.refill_lnd_balance, address: toAddress, - fromWallet: selectedWallet, + walletID: selectedWallet.getID(), }, }); } @@ -431,7 +431,7 @@ const WalletTransactions = () => { navigate('SendDetailsRoot', { screen: 'SendDetails', params: { - fromWallet: wallet, + walletID: wallet.getID(), }, }); }; @@ -444,7 +444,6 @@ const WalletTransactions = () => { const params = { walletID: wallet.getID(), uri: ret.data ? ret.data : ret, - fromWallet: wallet, }; if (wallet.chain === Chain.ONCHAIN) { navigate('SendDetailsRoot', { screen: 'SendDetails', params });