Skip to content

Commit d937668

Browse files
committed
Prevent unhandled rejections when passing nullish into Contract constructor (#1234).
1 parent 8279120 commit d937668

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/contracts/src.ts/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ export class Contract {
658658
defineReadOnly(this, "_runningEvents", { });
659659
defineReadOnly(this, "_wrappedEmits", { });
660660

661+
if (addressOrName == null) {
662+
logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName);
663+
}
664+
661665
defineReadOnly(this, "address", addressOrName);
662666
if (this.provider) {
663667
defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName));

0 commit comments

Comments
 (0)