Browse Source

FIX: all wallets are refreshed when app launches

icloud
Overtorment 6 years ago
committed by Igor Korsakov
parent
commit
801807ac46
  1. 9
      screen/selftest.js
  2. 21
      screen/wallets/list.js

9
screen/selftest.js

@ -252,6 +252,15 @@ export default class Selftest extends Component {
if (!hd2.validateMnemonic()) {
throw new Error('mnemonic phrase validation not ok');
}
//
let hd3 = new HDSegwitP2SHWallet();
hd3._xpub = 'ypub6XRSuTABFst6pd8BuTmjSwkDya7HrCRqmtsNmtrh1gyrEZwe24GcjJf6jk6nhhenZpLsm6sDHx2BXwnCQQtjF63FbpNyVEkmngKFQF11aph';
await hd3.fetchBalance();
if (hd3.getBalance() !== 0.00026) throw new Error('Could not fetch HD balance');
await hd3.fetchTransactions();
if (hd3.transactions.length !== 7) throw new Error('Could not fetch HD transactions');
} else {
console.warn('skipping RN-specific test');
}

21
screen/wallets/list.js

@ -11,6 +11,7 @@ let A = require('../../analytics');
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
let BlueElectrum = require('../../BlueElectrum');
export default class WalletsList extends Component {
static navigationOptions = ({ navigation }) => ({
@ -46,6 +47,26 @@ export default class WalletsList extends Component {
componentDidMount() {
this.redrawScreen();
// the idea is that upon wallet launch we will refresh
// all balances and all transactions here:
InteractionManager.runAfterInteractions(async () => {
let noErr = true;
try {
await BlueElectrum.waitTillConnected();
let balanceStart = +new Date();
await BlueApp.fetchWalletBalances();
let balanceEnd = +new Date();
console.log('fetch all wallet balances took', (balanceEnd - balanceStart) / 1000, 'sec');
let start = +new Date();
await BlueApp.fetchWalletTransactions();
let end = +new Date();
console.log('fetch all wallet txs took', (end - start) / 1000, 'sec');
} catch (_) {
noErr = false;
}
if (noErr) this.redrawScreen();
});
}
/**

Loading…
Cancel
Save