Skip to content

Commit

Permalink
Add user notice of errors originating from a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMieskoski committed Mar 8, 2021
1 parent c23ac8c commit 0c90868
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Add a current instance cache for transaction hashes to prevent multiple send attempts
- Add notice when malformed response is received from mobile
- Add a current instance timer to stop checking for transaction hash after 60 minutes
- Add user notice of errors originating from a transaction


### Release 2.1.23-beta.3
Expand Down
6 changes: 5 additions & 1 deletion src/connectProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,11 @@ export default class Integration extends EventEmitter {
);
}
});

eventHub.on(EventNames.ERROR_NOTIFY, err => {
if(err && err.message){
this.popUpHandler.showNotice(err.message);
}
})
eventHub.on(EventNames.SHOW_MSG_CONFIRM_MODAL, (msg, resolve) => {
if (!state.wallet) {
this.popUpHandler.showNoticePersistentEnter(
Expand Down
3 changes: 2 additions & 1 deletion src/connectProvider/web3Provider/web3-provider/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export default {
SHOW_TX_CONFIRM_MODAL: 'showTxConfirmModal',
SHOW_MSG_CONFIRM_MODAL: 'showMessageConfirmModal',
SHOW_TX_SIGN_MODAL: 'showTxSignModal',
WALLET_NOT_CONNECTED: 'walletNotConnected'
WALLET_NOT_CONNECTED: 'walletNotConnected',
ERROR_NOTIFY: 'errorNotify'
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import EthCalls from '../web3Calls';
import EventNames from '../events';
import { toPayload, toError } from '../jsonrpc';
Expand Down Expand Up @@ -58,6 +59,7 @@ export default async (
: tx.gasPrice;
tx.chainId = !tx.chainId ? store.state.network.type.chainID : tx.chainId;
} catch (e) {
eventHub.emit(EventNames.ERROR_NOTIFY, e)
debugErrors(e);
res(e);
return;
Expand Down Expand Up @@ -106,6 +108,7 @@ export default async (
}
})
.catch(err => {
eventHub.emit(EventNames.ERROR_NOTIFY, err)
_promiObj.emit('error', err);
});
}, 1000);
Expand All @@ -114,6 +117,7 @@ export default async (
res(null, toPayload(payload.id, hash));
})
.on('error', err => {
eventHub.emit(EventNames.ERROR_NOTIFY, err)
debugErrors('Error: eth_sendTransaction', err);
res(err);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default async (
});
})
.catch(e => {
eventHub.emit(EventNames.ERROR_NOTIFY, e)
debugErrors('Error: eth_signTransaction', e);
res(e);
});
Expand Down
5 changes: 5 additions & 0 deletions src/connectWindow/messageCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export function getMessage(text, extra) {
}
}

const regEx = new RegExp(/^Returned error:/)
if(regEx.test(text)){
return text;
}

if (!text) {
return messages.defaultMessage;
}
Expand Down
2 changes: 0 additions & 2 deletions test/clients/receiverV1.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ export default class MewConnectReceiver extends EventEmitter {
}

async setKeys(publicKey, privateKey, connId) {
console.log(privateKey); // todo remove dev item
this.publicKey = publicKey
this.privateKey = privateKey
this.connId = connId
this.signed = CryptoUtils.signMessage(this.privateKey, this.privateKey)
console.log(this.signed); // todo remove dev item
}

isJSON(arg) {
Expand Down

0 comments on commit 0c90868

Please sign in to comment.