Skip to content

Commit

Permalink
Avoid BUFFER_OVERRUN for unsupported revert reason #165 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
spilin authored Jan 24, 2022
1 parent 2ae0a39 commit 2ada767
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ export function parseEVMRevertReason(reason: Uint8Array): string | Uint8Array {
if (reason.length > 0) {
// only for valid decoded revert reason
const coder = new ethers.utils.AbiCoder();
const result = coder.decode(['string'], reason.slice(4));
return result.toString();
try {
return coder.decode(['string'], reason.slice(4)).toString();
} catch {
return reason;
}
}
return reason;
}

0 comments on commit 2ada767

Please sign in to comment.