Skip to content

Commit

Permalink
fix: ethjsquery prefix missing space at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jul 13, 2022
1 parent cf41946 commit 7d57d06
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,8 @@ export default class TransactionController extends EventEmitter {
try {
txHash = await this.query.sendRawTransaction(rawTx);
} catch (error) {
const ethjsQueryErrorPrefix = "[ethjs-query] while formatting outputs from RPC";
const ethjsQueryErrorPrefix =
'[ethjs-query] while formatting outputs from RPC ';
if (error.message.toLowerCase().includes('known transaction')) {
txHash = keccak(toBuffer(addHexPrefix(rawTx), 'hex')).toString('hex');
txHash = addHexPrefix(txHash);
Expand All @@ -1464,8 +1465,14 @@ export default class TransactionController extends EventEmitter {
// https://github.com/ethjs/ethjs-query/blob/master/src/index.js#L78
let unwrapped;
try {
const withoutPrefix = error.message.replace(ethjsQueryErrorPrefix, "");
const errorJsonString = withoutPrefix.substring(1, withoutPrefix.length - 1);
const withoutPrefix = error.message.replace(
ethjsQueryErrorPrefix,
'',
);
const errorJsonString = withoutPrefix.substring(
1,
withoutPrefix.length - 1,
);
const errorJson = JSON.parse(errorJsonString);
unwrapped = new Error(errorJson.value.data.message);
unwrapped.code = errorJson.value.data.code;
Expand Down

0 comments on commit 7d57d06

Please sign in to comment.