FIX: Watch-only Wallets we're not being synced to Watch app

This commit is contained in:
marcosrdz 2020-06-06 20:05:01 -04:00 committed by Overtorment
parent 419c4360f6
commit 5e8a62e363
2 changed files with 18 additions and 10 deletions

View file

@ -1,5 +1,6 @@
import * as Watch from 'react-native-watch-connectivity';
import { InteractionManager } from 'react-native';
import { Chain } from './models/bitcoinUnits';
const loc = require('./loc');
export default class WatchConnectivity {
isAppInstalled = false;
@ -71,18 +72,25 @@ export default class WatchConnectivity {
const wallets = [];
for (const wallet of allWallets) {
let receiveAddress = '';
if (wallet.allowReceive()) {
if (wallet.getAddressAsync) {
let receiveAddress;
if (wallet.getAddressAsync) {
if (wallet.chain === Chain.ONCHAIN) {
try {
receiveAddress = await wallet.getAddressAsync();
} catch (_) {}
if (!receiveAddress) {
// either sleep expired or getAddressAsync threw an exception
receiveAddress = wallet._getExternalAddressByIndex(wallet.next_free_address_index);
}
} else if (wallet.chain === Chain.OFFCHAIN) {
try {
await wallet.getAddressAsync();
receiveAddress = wallet.getAddress();
} catch (error) {
console.log(error);
} catch (_) {}
if (!receiveAddress) {
// either sleep expired or getAddressAsync threw an exception
receiveAddress = wallet.getAddress();
}
} else {
receiveAddress = wallet.getAddress();
}
}
const transactions = wallet.getTransactions(10);

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="15505" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="15705" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
<device id="watch44"/>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="15501"/>
</dependencies>
<scenes>
@ -18,7 +18,7 @@
<group key="rootItem" width="1" height="66.5" alignment="left" backgroundImage="walletHD" radius="8" id="H28-wi-Sks" customClass="WalletInformation" customModule="BlueWalletWatch_Extension">
<items>
<label width="6" alignment="left" id="RJV-QC-scb"/>
<group width="1" alignment="center" verticalAlignment="center" layout="vertical" id="UrU-xX-jYW">
<group width="0.90000000000000002" alignment="center" verticalAlignment="center" layout="vertical" id="UrU-xX-jYW">
<items>
<label width="1" alignment="left" text="Balance" minimumScaleFactor="0.5" id="QYx-3e-6zf">
<fontDescription key="font" style="UICTFontTextStyleHeadline"/>