From e92c813a23773ccf9e55ddf9c0280b0b705ac5bf Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Sat, 18 Feb 2023 00:36:58 +0530 Subject: [PATCH 1/2] Handled API not working in UI --- index.html | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index cda512c..4142dd7 100644 --- a/index.html +++ b/index.html @@ -712,16 +712,15 @@ } }); getExchangeRate() - .then(() => { + .catch(e => { + console.error(e) + getRef('currency_selector').classList.add('hidden') + }).finally(() => { routeTo(window.location.hash) setTimeout(() => { getRef('loading_page').animate([ - { - transform: 'translateY(0)', - }, - { - transform: 'translateY(-100%)', - } + { transform: 'translateY(0)', }, + { transform: 'translateY(-100%)', } ], { duration: 300, fill: 'forwards', @@ -731,10 +730,6 @@ } }, 500); }) - .catch(e => { - console.error(e) - notify('Error fetching exchange rate', 'error') - }) selectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc' getRef('currency_selector').value = selectedCurrency getRef('add_sender').click(); @@ -1311,8 +1306,8 @@ }) globalExchangeRate.btc = 1 resolve(globalExchangeRate) - }).catch(err => console.log(err)) - }).catch(err => console.log(err)) + }).catch(err => reject(err)) + }).catch(err => reject(err)) }) } function getConvertedAmount(amount) { @@ -1535,6 +1530,9 @@

*Exact fee will be calculated after you fill all the required fields

`) + }).catch(e => { + getRef('fees_selector').children[1].click(); + getRef('fees_selector').classList.add('hidden') }) } getRef('fees_section').classList.remove('hidden') From 07a3384eba5ae67ede8725647aa127da79e0e7e1 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Sat, 18 Feb 2023 01:06:03 +0530 Subject: [PATCH 2/2] bug fix --- index.html | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 4142dd7..deedea5 100644 --- a/index.html +++ b/index.html @@ -1375,8 +1375,6 @@ }); function retrieveBtcAddr() { let wif = getRef('retrieve_btc_addr_field').value.trim(); - // addressForm['legacy'].value = btcOperator.address(wif); - // addressForm['segwit'].value = btcOperator.segwitAddress(wif); getRef('recovered_btc_addr_wrapper').classList.remove('hidden') getRef('recovered_btc_addr').value = btcOperator.bech32Address(wif); } @@ -1553,14 +1551,20 @@ } function calculateApproxFee() { return new Promise((resolve, reject) => { - fetch('https://bitcoiner.live/api/fees/estimates/latest').then(res => res.json()).then(data => { - const satPerByte = data.estimates['60'].sat_per_vbyte; - const legacyBytes = 200; - const segwitBytes = 77; - resolve((legacyBytes * satPerByte + (0.25 * satPerByte) * segwitBytes) / Math.pow(10, 8)); - }).catch(e => { - reject(e) - }) + fetch('https://bitcoiner.live/api/fees/estimates/latest') + .then(res => { + res.json() + .then(data => { + const satPerByte = data.estimates['60'].sat_per_vbyte; + const legacyBytes = 200; + const segwitBytes = 77; + resolve((legacyBytes * satPerByte + (0.25 * satPerByte) * segwitBytes) / Math.pow(10, 8)); + }).catch(e => { + reject(e) + }) + }).catch(e => { + reject(e) + }) }) } function calculateExactFee() {