From 45c32fcf466161e54cf8ac91c0803af3e861f972 Mon Sep 17 00:00:00 2001 From: CedarMist <134699267+CedarMist@users.noreply.github.com> Date: Mon, 19 Feb 2024 08:18:09 +0000 Subject: [PATCH 1/2] examples: added require() reversion message check to ethers v6 client --- examples/ethersv6-ts-esm/src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/ethersv6-ts-esm/src/index.ts b/examples/ethersv6-ts-esm/src/index.ts index 1d11804f..9e22fb62 100644 --- a/examples/ethersv6-ts-esm/src/index.ts +++ b/examples/ethersv6-ts-esm/src/index.ts @@ -16,6 +16,15 @@ async function testTheContract(contract:BaseContract, signerAddr?:string) assert( addr === ZeroAddress ); } + try { + await contract.getFunction("testViewRevert()").staticCall(); + assert(false); + } + catch(e:any) { + assert(e.code == 'CALL_EXCEPTION'); + assert(e.reason == 'ThisIsAnError'); + } + try { await contract.getFunction("testCustomRevert()").staticCall(); assert(false); From e3f7086b60749f2ae8bb5cf6cc7816afcc0b1ff4 Mon Sep 17 00:00:00 2001 From: CedarMist <134699267+CedarMist@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:47:41 +0000 Subject: [PATCH 2/2] examples: added docs to ethers v6 test --- examples/ethersv6-ts-esm/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/ethersv6-ts-esm/src/index.ts b/examples/ethersv6-ts-esm/src/index.ts index 9e22fb62..d396fee8 100644 --- a/examples/ethersv6-ts-esm/src/index.ts +++ b/examples/ethersv6-ts-esm/src/index.ts @@ -16,6 +16,8 @@ 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); @@ -25,6 +27,8 @@ async function testTheContract(contract:BaseContract, signerAddr?:string) 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);