Skip to content

Commit

Permalink
Improves error during output encoding errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
robotoer committed Aug 22, 2024
1 parent a5ba114 commit 192591f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/mock-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ export const deployMock = async <C extends BaseContract>(
// Encode function call data using ethers v6:
const iface = new Interface([call.abi]);
const fnSigHash = calculateFnSigHash(call);
const encodedOutputs = iface.encodeFunctionResult(
call.abi,
call.outputs,
);
let encodedOutputs: string;
try {
encodedOutputs = iface.encodeFunctionResult(
call.abi,
call.outputs,
);
} catch (e) {
const err = e as Error;
err.message = `[${call.abi.selector}]: ${err.message}`;
throw err;
}
// Use a mock function to return the expected return value
if (firstCall) {
await mockDeployed.__doppelganger__mockReturns(
Expand Down

0 comments on commit 192591f

Please sign in to comment.