Skip to content

Commit

Permalink
fix(ui): 💄 showErrorDialog on sendTx failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Mar 23, 2024
1 parent 55f6926 commit f49f053
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,13 @@ async function showErrorDialog(options) {
})

if (opts.type === 'dang') {
console.error('showErrorDialog', opts.msg)
console.error('showErrorDialog', opts)
} else {
console.log('showErrorDialog', opts)
}

let outputMsg = opts.msg?.response || opts.msg?.stack || opts.msg

await appDialogs.confirmAction?.render({
name: opts.title,
actionTxt: 'Report Issue',
Expand All @@ -503,10 +505,10 @@ async function showErrorDialog(options) {
${state.header(state)}
<article class="px-3 col flex-fill ta-left mh-75">
<strong>
<!-- <strong>
Looks like we encountered an error.
</strong>
<pre class="of-auto flex-fill">${opts.msg}</pre>
</strong> -->
<pre class="of-auto flex-fill">${outputMsg}</pre>
</article>
${state.footer(state)}
Expand Down Expand Up @@ -636,7 +638,7 @@ async function main() {
mainApp, appDialogs, appState, appTools,
store, userInfo, contactsList, walletFunds,
setupDialog, deriveWalletData, getAddrsWithFunds,
sendTx, updateAllFunds,
sendTx, updateAllFunds, showErrorDialog,
})

appDialogs.requestQr = await requestQrRig({
Expand Down
17 changes: 13 additions & 4 deletions src/rigs/send-confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export let sendConfirmRig = (async function (globals) {

let {
mainApp, setupDialog, appDialogs, appState, appTools,
sendTx, store, userInfo, contactsList,
sendTx, store, userInfo, contactsList, showErrorDialog,
} = globals

let sendConfirm = await setupDialog(
Expand Down Expand Up @@ -150,9 +150,18 @@ export let sendConfirmRig = (async function (globals) {
}

if (state.tx) {
txRes = await sendTx(
state.tx,
)
try {
txRes = await sendTx(
state.tx,
)
} catch(err) {
return await showErrorDialog({
type: 'dang',
title: 'Failed to send transaction',
msg: err,
showActBtn: false,
})
}
}

if (txRes && addressIndex !== undefined) {
Expand Down

0 comments on commit f49f053

Please sign in to comment.