@@ -3,6 +3,7 @@ import { defaultAbiCoder as abi } from "@ethersproject/abi";
3
3
import { equalsBytes } from "@nomicfoundation/ethereumjs-util" ;
4
4
import semver from "semver" ;
5
5
6
+ import { ErrorInferrer as ErrorInferrerRs } from "@nomicfoundation/edr" ;
6
7
import { assertHardhatInvariant } from "../../core/errors" ;
7
8
import { AbiHelpers } from "../../util/abi-helpers" ;
8
9
import { ReturnData } from "../provider/return-data" ;
@@ -178,70 +179,7 @@ export class ErrorInferrer {
178
179
public filterRedundantFrames (
179
180
stacktrace : SolidityStackTrace
180
181
) : SolidityStackTrace {
181
- return stacktrace . filter ( ( frame , i ) => {
182
- if ( i + 1 === stacktrace . length ) {
183
- return true ;
184
- }
185
-
186
- const nextFrame = stacktrace [ i + 1 ] ;
187
-
188
- // we can only filter frames if we know their sourceReference
189
- // and the one from the next frame
190
- if (
191
- frame . sourceReference === undefined ||
192
- nextFrame . sourceReference === undefined
193
- ) {
194
- return true ;
195
- }
196
-
197
- // look TWO frames ahead to determine if this is a specific occurrence of
198
- // a redundant CALLSTACK_ENTRY frame observed when using Solidity 0.8.5:
199
- if (
200
- frame . type === StackTraceEntryType . CALLSTACK_ENTRY &&
201
- i + 2 < stacktrace . length &&
202
- stacktrace [ i + 2 ] . sourceReference !== undefined &&
203
- stacktrace [ i + 2 ] . type === StackTraceEntryType . RETURNDATA_SIZE_ERROR
204
- ) {
205
- // ! below for tsc. we confirmed existence in the enclosing conditional.
206
- const thatSrcRef = stacktrace [ i + 2 ] . sourceReference ;
207
- if (
208
- thatSrcRef !== undefined &&
209
- frame . sourceReference . range [ 0 ] === thatSrcRef . range [ 0 ] &&
210
- frame . sourceReference . range [ 1 ] === thatSrcRef . range [ 1 ] &&
211
- frame . sourceReference . line === thatSrcRef . line
212
- ) {
213
- return false ;
214
- }
215
- }
216
-
217
- // constructors contain the whole contract, so we ignore them
218
- if (
219
- frame . sourceReference . function === "constructor" &&
220
- nextFrame . sourceReference . function !== "constructor"
221
- ) {
222
- return true ;
223
- }
224
-
225
- // this is probably a recursive call
226
- if (
227
- i > 0 &&
228
- frame . type === nextFrame . type &&
229
- frame . sourceReference . range [ 0 ] === nextFrame . sourceReference . range [ 0 ] &&
230
- frame . sourceReference . range [ 1 ] === nextFrame . sourceReference . range [ 1 ] &&
231
- frame . sourceReference . line === nextFrame . sourceReference . line
232
- ) {
233
- return true ;
234
- }
235
-
236
- if (
237
- frame . sourceReference . range [ 0 ] <= nextFrame . sourceReference . range [ 0 ] &&
238
- frame . sourceReference . range [ 1 ] >= nextFrame . sourceReference . range [ 1 ]
239
- ) {
240
- return false ;
241
- }
242
-
243
- return true ;
244
- } ) ;
182
+ return ErrorInferrerRs . filterRedundantFrames ( stacktrace ) ;
245
183
}
246
184
247
185
// Heuristics
0 commit comments