This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -81,9 +81,22 @@ const reason = {
8181 return undefined ;
8282 }
8383 } else {
84- //we can't reasonably handle custom errors here
85- //(but we can probably assume it is one?)
86- return "Custom error (could not decode)" ;
84+ const bytesLength = ( rawData . length - 2 ) / 2 ; //length of raw data in bytes
85+ if ( bytesLength % 32 === 4 ) {
86+ //we can't reasonably handle custom errors here at present, sorry
87+ return "Custom error (could not decode)" ;
88+ } else {
89+ //if the length isn't 4 mod 32, just give up and return undefined.
90+ //the reason for this is that sometimes this function can accidentally get
91+ //called on a return value rather than an error (because the tx ran out of
92+ //gas or failed for a reason other than a revert, e.g., getting refused by
93+ //the user in MetaMask), meaning the eth_call rerun will *succeed*, potentially
94+ //resulting in a return value. We don't want to attach an additional
95+ //error message in that case, so we return undefined.
96+ //(What if e.g. the tx is refused by the user in MetaMask, but the rerun yields
97+ //a revert string...? Well, that's a problem for another time...)
98+ return undefined ;
99+ }
87100 }
88101 } ,
89102
You can’t perform that action at this time.
0 commit comments