Merge pull request #1 from sairaj-mote/main
Error handling for exteral API not working
This commit is contained in:
commit
eb708fdb36
48
index.html
48
index.html
@ -712,16 +712,15 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
getExchangeRate()
|
getExchangeRate()
|
||||||
.then(() => {
|
.catch(e => {
|
||||||
|
console.error(e)
|
||||||
|
getRef('currency_selector').classList.add('hidden')
|
||||||
|
}).finally(() => {
|
||||||
routeTo(window.location.hash)
|
routeTo(window.location.hash)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRef('loading_page').animate([
|
getRef('loading_page').animate([
|
||||||
{
|
{ transform: 'translateY(0)', },
|
||||||
transform: 'translateY(0)',
|
{ transform: 'translateY(-100%)', }
|
||||||
},
|
|
||||||
{
|
|
||||||
transform: 'translateY(-100%)',
|
|
||||||
}
|
|
||||||
], {
|
], {
|
||||||
duration: 300,
|
duration: 300,
|
||||||
fill: 'forwards',
|
fill: 'forwards',
|
||||||
@ -731,10 +730,6 @@
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
|
||||||
console.error(e)
|
|
||||||
notify('Error fetching exchange rate', 'error')
|
|
||||||
})
|
|
||||||
selectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc'
|
selectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc'
|
||||||
getRef('currency_selector').value = selectedCurrency
|
getRef('currency_selector').value = selectedCurrency
|
||||||
getRef('add_sender').click();
|
getRef('add_sender').click();
|
||||||
@ -1311,8 +1306,8 @@
|
|||||||
})
|
})
|
||||||
globalExchangeRate.btc = 1
|
globalExchangeRate.btc = 1
|
||||||
resolve(globalExchangeRate)
|
resolve(globalExchangeRate)
|
||||||
}).catch(err => console.log(err))
|
}).catch(err => reject(err))
|
||||||
}).catch(err => console.log(err))
|
}).catch(err => reject(err))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function getConvertedAmount(amount) {
|
function getConvertedAmount(amount) {
|
||||||
@ -1380,8 +1375,6 @@
|
|||||||
});
|
});
|
||||||
function retrieveBtcAddr() {
|
function retrieveBtcAddr() {
|
||||||
let wif = getRef('retrieve_btc_addr_field').value.trim();
|
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_wrapper').classList.remove('hidden')
|
||||||
getRef('recovered_btc_addr').value = btcOperator.bech32Address(wif);
|
getRef('recovered_btc_addr').value = btcOperator.bech32Address(wif);
|
||||||
}
|
}
|
||||||
@ -1535,6 +1528,9 @@
|
|||||||
<p style="opacity: 0.8;">*Exact fee will be calculated after you fill all the required fields</p>
|
<p style="opacity: 0.8;">*Exact fee will be calculated after you fill all the required fields</p>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
|
}).catch(e => {
|
||||||
|
getRef('fees_selector').children[1].click();
|
||||||
|
getRef('fees_selector').classList.add('hidden')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
getRef('fees_section').classList.remove('hidden')
|
getRef('fees_section').classList.remove('hidden')
|
||||||
@ -1555,14 +1551,20 @@
|
|||||||
}
|
}
|
||||||
function calculateApproxFee() {
|
function calculateApproxFee() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fetch('https://bitcoiner.live/api/fees/estimates/latest').then(res => res.json()).then(data => {
|
fetch('https://bitcoiner.live/api/fees/estimates/latest')
|
||||||
const satPerByte = data.estimates['60'].sat_per_vbyte;
|
.then(res => {
|
||||||
const legacyBytes = 200;
|
res.json()
|
||||||
const segwitBytes = 77;
|
.then(data => {
|
||||||
resolve((legacyBytes * satPerByte + (0.25 * satPerByte) * segwitBytes) / Math.pow(10, 8));
|
const satPerByte = data.estimates['60'].sat_per_vbyte;
|
||||||
}).catch(e => {
|
const legacyBytes = 200;
|
||||||
reject(e)
|
const segwitBytes = 77;
|
||||||
})
|
resolve((legacyBytes * satPerByte + (0.25 * satPerByte) * segwitBytes) / Math.pow(10, 8));
|
||||||
|
}).catch(e => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
}).catch(e => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function calculateExactFee() {
|
function calculateExactFee() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user