@@ -13,7 +13,7 @@ export function supportRevertedWith(Assertion: Chai.AssertionStatic) {
13
13
) ;
14
14
15
15
const onSuccess = ( value : any ) => {
16
- if ( 'wait' in value ) {
16
+ if ( value && 'wait' in value ) {
17
17
// Sending the transaction succeeded, but we wait to see if it will revert on-chain.
18
18
return value . wait ( ) . then ( ( newValue : any ) => {
19
19
assertNotReverted ( ) ;
@@ -80,12 +80,28 @@ export function supportRevertedWith(Assertion: Chai.AssertionStatic) {
80
80
const decodeHardhatError = ( error : any ) => {
81
81
const tryDecode = ( error : any ) => {
82
82
const errorString = String ( error ) ;
83
- const regexp = new RegExp ( 'VM Exception while processing transaction: reverted with reason string \'(.*)\'' ) ;
84
- const matches = regexp . exec ( errorString ) ;
85
- if ( ! matches ) {
86
- return undefined ;
83
+ {
84
+ const regexp = new RegExp ( 'VM Exception while processing transaction: reverted with reason string \'(.*)\'' ) ;
85
+ const matches = regexp . exec ( errorString ) ;
86
+ if ( matches && matches . length >= 1 ) {
87
+ return matches [ 1 ] ;
88
+ }
89
+ }
90
+ {
91
+ const regexp = new RegExp ( 'VM Exception while processing transaction: reverted with panic code ([a-zA-Z0-9]*)' ) ;
92
+ const matches = regexp . exec ( errorString ) ;
93
+ if ( matches && matches . length >= 1 ) {
94
+ return 'panic code ' + matches [ 1 ] ;
95
+ }
96
+ }
97
+ {
98
+ const regexp = new RegExp ( 'Error: Transaction reverted: (.*)' ) ;
99
+ const matches = regexp . exec ( errorString ) ;
100
+ if ( matches && matches . length >= 1 ) {
101
+ return matches [ 1 ] ;
102
+ }
87
103
}
88
- return matches [ 1 ] ;
104
+ return undefined ;
89
105
} ;
90
106
91
107
return tryDecode ( error ) ?? tryDecode ( error . error ) ; // the error may be wrapped
0 commit comments