Skip to content

Commit

Permalink
Prevent unhandled rejections when passing nullish into Contract const…
Browse files Browse the repository at this point in the history
…ructor (#1234).
  • Loading branch information
ricmoo committed Feb 12, 2021
1 parent 8279120 commit d937668
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/contracts/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d937668

Please sign in to comment.