From 192591f38b4f2b0bdaf6debeb222891f2afd8b2d Mon Sep 17 00:00:00 2001 From: Robert Chu Date: Thu, 22 Aug 2024 13:20:43 -0700 Subject: [PATCH] Improves error during output encoding errors. --- src/mock-contract.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mock-contract.ts b/src/mock-contract.ts index 6bc5275..c626eb3 100644 --- a/src/mock-contract.ts +++ b/src/mock-contract.ts @@ -76,10 +76,17 @@ export const deployMock = async ( // 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(