@@ -11,26 +11,26 @@ import { type ContractDataOracle, type PxeDatabase } from '../index.js';
11
11
* @param err - The error to enrich.
12
12
*/
13
13
export async function enrichSimulationError ( err : SimulationError , db : PxeDatabase , logger : Logger ) {
14
- // Maps contract addresses to the set of functions selectors that were in error.
14
+ // Maps contract addresses to the set of function names that were in error.
15
15
// Map and Set do reference equality for their keys instead of value equality, so we store the string
16
16
// representation to get e.g. different contract address objects with the same address value to match.
17
17
const mentionedFunctions : Map < string , Set < string > > = new Map ( ) ;
18
18
19
- err . getCallStack ( ) . forEach ( ( { contractAddress, functionSelector } ) => {
19
+ err . getCallStack ( ) . forEach ( ( { contractAddress, functionName } ) => {
20
20
if ( ! mentionedFunctions . has ( contractAddress . toString ( ) ) ) {
21
21
mentionedFunctions . set ( contractAddress . toString ( ) , new Set ( ) ) ;
22
22
}
23
- mentionedFunctions . get ( contractAddress . toString ( ) ) ! . add ( functionSelector ?. toString ( ) ?? '' ) ;
23
+ mentionedFunctions . get ( contractAddress . toString ( ) ) ! . add ( functionName ?. toString ( ) ?? '' ) ;
24
24
} ) ;
25
25
26
26
await Promise . all (
27
- [ ...mentionedFunctions . entries ( ) ] . map ( async ( [ contractAddress , selectors ] ) => {
27
+ [ ...mentionedFunctions . entries ( ) ] . map ( async ( [ contractAddress , fnNames ] ) => {
28
28
const parsedContractAddress = AztecAddress . fromString ( contractAddress ) ;
29
29
const contract = await db . getContract ( parsedContractAddress ) ;
30
30
if ( contract ) {
31
31
err . enrichWithContractName ( parsedContractAddress , contract . name ) ;
32
- selectors . forEach ( selector => {
33
- const functionArtifact = contract . functions . find ( f => FunctionSelector . fromString ( selector ) . equals ( f ) ) ;
32
+ fnNames . forEach ( fnName => {
33
+ const functionArtifact = contract . functions . find ( f => fnName === f . name ) ;
34
34
if ( functionArtifact ) {
35
35
err . enrichWithFunctionName (
36
36
parsedContractAddress ,
@@ -39,7 +39,7 @@ export async function enrichSimulationError(err: SimulationError, db: PxeDatabas
39
39
) ;
40
40
} else {
41
41
logger . warn (
42
- `Could not function artifact in contract ${ contract . name } for selector ${ selector } when enriching error callstack` ,
42
+ `Could not function artifact in contract ${ contract . name } for function ' ${ fnName } ' when enriching error callstack` ,
43
43
) ;
44
44
}
45
45
} ) ;
0 commit comments