diff --git a/examples/ethersv6-ts-esm/src/index.ts b/examples/ethersv6-ts-esm/src/index.ts index 1d11804f..d396fee8 100644 --- a/examples/ethersv6-ts-esm/src/index.ts +++ b/examples/ethersv6-ts-esm/src/index.ts @@ -16,6 +16,19 @@ async function testTheContract(contract:BaseContract, signerAddr?:string) assert( addr === ZeroAddress ); } + // Verifies that calling a function which does require(false,"ThisIsAnError") + // Will return the correct error message in the exception to Ethers + try { + await contract.getFunction("testViewRevert()").staticCall(); + assert(false); + } + catch(e:any) { + assert(e.code == 'CALL_EXCEPTION'); + assert(e.reason == 'ThisIsAnError'); + } + + // Verifies that calling a function which does revert CustomError(someInteger) + // Will return the correctly encoded custom error type to Ethers try { await contract.getFunction("testCustomRevert()").staticCall(); assert(false);