Skip to content

Commit

Permalink
Better errors when junk passed as Contract target (#3947, #4053).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 18, 2023
1 parent f58990b commit 219b16d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src.ts/contract/contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Interface, Typed } from "../abi/index.js";
import { resolveAddress } from "../address/index.js";
import { isAddressable, resolveAddress } from "../address/index.js";
// import from provider.ts instead of index.ts to prevent circular dep
// from EtherscanProvider
import { copyRequest, Log, TransactionResponse } from "../providers/provider.js";
Expand Down Expand Up @@ -619,6 +619,9 @@ export class BaseContract implements Addressable, EventEmitterable<ContractEvent
readonly fallback!: null | WrappedFallback;

constructor(target: string | Addressable, abi: Interface | InterfaceAbi, runner?: null | ContractRunner, _deployTx?: null | TransactionResponse) {
assertArgument(typeof(target) === "string" || isAddressable(target),
"invalid value for Contract target", "target", target);

if (runner == null) { runner = null; }
const iface = Interface.from(abi);
defineProperties<BaseContract>(this, { target, runner, interface: iface });
Expand Down

0 comments on commit 219b16d

Please sign in to comment.