1
1
import { bytesToHex as bufferToHex } from "@nomicfoundation/ethereumjs-util" ;
2
2
3
+ import { ReturnData } from "../provider/return-data" ;
3
4
import { panicErrorCodeToMessage } from "./panic-errors" ;
4
5
import {
5
6
CONSTRUCTOR_FUNCTION_NAME ,
@@ -259,23 +260,22 @@ function getMessageFromLastStackTraceEntry(
259
260
260
261
case StackTraceEntryType . UNRECOGNIZED_CREATE_ERROR :
261
262
case StackTraceEntryType . UNRECOGNIZED_CONTRACT_ERROR :
262
- if ( stackTraceEntry . message . isErrorReturnData ( ) ) {
263
- return `VM Exception while processing transaction: reverted with reason string '${ stackTraceEntry . message . decodeError ( ) } '` ;
263
+ let returnData = new ReturnData ( stackTraceEntry . returnData ) ;
264
+ if ( returnData . isErrorReturnData ( ) ) {
265
+ return `VM Exception while processing transaction: reverted with reason string '${ new ReturnData (
266
+ stackTraceEntry . returnData
267
+ ) . decodeError ( ) } '`;
264
268
}
265
269
266
- if ( stackTraceEntry . message . isPanicReturnData ( ) ) {
267
- const message = panicErrorCodeToMessage (
268
- stackTraceEntry . message . decodePanic ( )
269
- ) ;
270
+ if ( returnData . isPanicReturnData ( ) ) {
271
+ const message = panicErrorCodeToMessage ( returnData . decodePanic ( ) ) ;
270
272
return `VM Exception while processing transaction: ${ message } ` ;
271
273
}
272
274
273
- if ( ! stackTraceEntry . message . isEmpty ( ) ) {
274
- const returnData = Buffer . from ( stackTraceEntry . message . value ) . toString (
275
- "hex"
276
- ) ;
275
+ if ( ! returnData . isEmpty ( ) ) {
276
+ const buffer = Buffer . from ( returnData . value ) . toString ( "hex" ) ;
277
277
278
- return `VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x${ returnData } )` ;
278
+ return `VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x${ buffer } )` ;
279
279
}
280
280
281
281
if ( stackTraceEntry . isInvalidOpcodeError ) {
@@ -285,8 +285,9 @@ function getMessageFromLastStackTraceEntry(
285
285
return "Transaction reverted without a reason string" ;
286
286
287
287
case StackTraceEntryType . REVERT_ERROR :
288
- if ( stackTraceEntry . message . isErrorReturnData ( ) ) {
289
- return `VM Exception while processing transaction: reverted with reason string '${ stackTraceEntry . message . decodeError ( ) } '` ;
288
+ returnData = new ReturnData ( stackTraceEntry . returnData ) ;
289
+ if ( returnData . isErrorReturnData ( ) ) {
290
+ return `VM Exception while processing transaction: reverted with reason string '${ returnData . decodeError ( ) } '` ;
290
291
}
291
292
292
293
if ( stackTraceEntry . isInvalidOpcodeError ) {
0 commit comments