From d937668dc1d39cc293f64bbd30b99b29614d1607 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 12 Feb 2021 18:58:28 -0500 Subject: [PATCH] Prevent unhandled rejections when passing nullish into Contract constructor (#1234). --- packages/contracts/src.ts/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts index 96a3ca369..cbce2af49 100644 --- a/packages/contracts/src.ts/index.ts +++ b/packages/contracts/src.ts/index.ts @@ -658,6 +658,10 @@ export class Contract { defineReadOnly(this, "_runningEvents", { }); defineReadOnly(this, "_wrappedEmits", { }); + if (addressOrName == null) { + logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName); + } + defineReadOnly(this, "address", addressOrName); if (this.provider) { defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName));