Skip to content

Commit

Permalink
Better errors when junk passed as Contract target (ethers-io#3947, et…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent 9b05776 commit b663917
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 b663917

Please sign in to comment.