Prevent unhandled rejections when passing nullish into Contract constructor (#1234).

This commit is contained in:
Richard Moore 2021-02-12 18:58:28 -05:00
parent 8279120e0a
commit d937668dc1
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

@ -658,6 +658,10 @@ export class Contract {
defineReadOnly(this, "_runningEvents", { }); defineReadOnly(this, "_runningEvents", { });
defineReadOnly(this, "_wrappedEmits", { }); defineReadOnly(this, "_wrappedEmits", { });
if (addressOrName == null) {
logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName);
}
defineReadOnly(this, "address", addressOrName); defineReadOnly(this, "address", addressOrName);
if (this.provider) { if (this.provider) {
defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName)); defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName));