Remove pedantic check for new keyword which broke some platforms for inheritance (#2860, #2861).

This commit is contained in:
Richard Moore 2022-05-12 16:16:26 -04:00
parent fc1e006575
commit 32b7373456
16 changed files with 0 additions and 34 deletions

@ -33,7 +33,6 @@ export class AbiCoder {
readonly coerceFunc: CoerceFunc; readonly coerceFunc: CoerceFunc;
constructor(coerceFunc?: CoerceFunc) { constructor(coerceFunc?: CoerceFunc) {
logger.checkNew(new.target, AbiCoder);
defineReadOnly(this, "coerceFunc", coerceFunc || null); defineReadOnly(this, "coerceFunc", coerceFunc || null);
} }

@ -90,8 +90,6 @@ export class Interface {
readonly _isInterface: boolean; readonly _isInterface: boolean;
constructor(fragments: string | ReadonlyArray<Fragment | JsonFragment | string>) { constructor(fragments: string | ReadonlyArray<Fragment | JsonFragment | string>) {
logger.checkNew(new.target, Interface);
let abi: ReadonlyArray<Fragment | JsonFragment | string> = [ ]; let abi: ReadonlyArray<Fragment | JsonFragment | string> = [ ];
if (typeof(fragments) === "string") { if (typeof(fragments) === "string") {
abi = JSON.parse(fragments); abi = JSON.parse(fragments);

@ -341,7 +341,6 @@ export class VoidSigner extends Signer implements TypedDataSigner {
readonly address: string; readonly address: string;
constructor(address: string, provider?: Provider) { constructor(address: string, provider?: Provider) {
logger.checkNew(new.target, VoidSigner);
super(); super();
defineReadOnly(this, "address", address); defineReadOnly(this, "address", address);
defineReadOnly(this, "provider", provider || null); defineReadOnly(this, "provider", provider || null);

@ -43,8 +43,6 @@ export class BigNumber implements Hexable {
readonly _isBigNumber: boolean; readonly _isBigNumber: boolean;
constructor(constructorGuard: any, hex: string) { constructor(constructorGuard: any, hex: string) {
logger.checkNew(new.target, BigNumber);
if (constructorGuard !== _constructorGuard) { if (constructorGuard !== _constructorGuard) {
logger.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { logger.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "new (BigNumber)" operation: "new (BigNumber)"

@ -202,8 +202,6 @@ export class FixedNumber {
readonly _isFixedNumber: boolean; readonly _isFixedNumber: boolean;
constructor(constructorGuard: any, hex: string, value: string, format?: FixedFormat) { constructor(constructorGuard: any, hex: string, value: string, format?: FixedFormat) {
logger.checkNew(new.target, FixedNumber);
if (constructorGuard !== _constructorGuard) { if (constructorGuard !== _constructorGuard) {
logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { logger.throwError("cannot use FixedNumber constructor; use FixedNumber.from", Logger.errors.UNSUPPORTED_OPERATION, {
operation: "new FixedFormat" operation: "new FixedFormat"

@ -657,8 +657,6 @@ export class BaseContract {
_wrappedEmits: { [ eventTag: string ]: (...args: Array<any>) => void }; _wrappedEmits: { [ eventTag: string ]: (...args: Array<any>) => void };
constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider?: Signer | Provider) { constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider?: Signer | Provider) {
logger.checkNew(new.target, Contract);
// @TODO: Maybe still check the addressOrName looks like a valid address or name? // @TODO: Maybe still check the addressOrName looks like a valid address or name?
//address = getAddress(address); //address = getAddress(address);
defineReadOnly(this, "interface", getStatic<InterfaceFunc>(new.target, "getInterface")(contractInterface)); defineReadOnly(this, "interface", getStatic<InterfaceFunc>(new.target, "getInterface")(contractInterface));

@ -2,10 +2,6 @@
import { ethers } from "ethers"; import { ethers } from "ethers";
import { version } from "./_version";
const logger = new ethers.utils.Logger(version);
// @TODO: Keep a per-NonceManager pool of sent but unmined transactions for // @TODO: Keep a per-NonceManager pool of sent but unmined transactions for
// rebroadcasting, in case we overrun the transaction pool // rebroadcasting, in case we overrun the transaction pool
@ -16,7 +12,6 @@ export class NonceManager extends ethers.Signer {
_deltaCount: number; _deltaCount: number;
constructor(signer: ethers.Signer) { constructor(signer: ethers.Signer) {
logger.checkNew(new.target, NonceManager);
super(); super();
this._deltaCount = 0; this._deltaCount = 0;
ethers.utils.defineReadOnly(this, "signer", signer); ethers.utils.defineReadOnly(this, "signer", signer);

@ -97,8 +97,6 @@ export class HDNode implements ExternallyOwnedAccount {
* - fromSeed * - fromSeed
*/ */
constructor(constructorGuard: any, privateKey: string, publicKey: string, parentFingerprint: string, chainCode: string, index: number, depth: number, mnemonicOrPath: Mnemonic | string) { constructor(constructorGuard: any, privateKey: string, publicKey: string, parentFingerprint: string, chainCode: string, index: number, depth: number, mnemonicOrPath: Mnemonic | string) {
logger.checkNew(new.target, HDNode);
/* istanbul ignore if */ /* istanbul ignore if */
if (constructorGuard !== _constructorGuard) { if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly"); throw new Error("HDNode constructor cannot be called directly");

@ -738,8 +738,6 @@ export class BaseProvider extends Provider implements EnsProvider {
*/ */
constructor(network: Networkish | Promise<Network>) { constructor(network: Networkish | Promise<Network>) {
logger.checkNew(new.target, Provider);
super(); super();
// Events being listened to // Events being listened to

@ -163,8 +163,6 @@ export class EtherscanProvider extends BaseProvider{
readonly apiKey: string; readonly apiKey: string;
constructor(network?: Networkish, apiKey?: string) { constructor(network?: Networkish, apiKey?: string) {
logger.checkNew(new.target, EtherscanProvider);
super(network); super(network);
defineReadOnly(this, "baseUrl", this.getBaseUrl()); defineReadOnly(this, "baseUrl", this.getBaseUrl());

@ -410,8 +410,6 @@ export class FallbackProvider extends BaseProvider {
_highestBlockNumber: number; _highestBlockNumber: number;
constructor(providers: Array<Provider | FallbackProviderConfig>, quorum?: number) { constructor(providers: Array<Provider | FallbackProviderConfig>, quorum?: number) {
logger.checkNew(new.target, FallbackProvider);
if (providers.length === 0) { if (providers.length === 0) {
logger.throwArgumentError("missing providers", "providers", providers); logger.throwArgumentError("missing providers", "providers", providers);
} }

@ -31,7 +31,6 @@ export class Formatter {
readonly formats: Formats; readonly formats: Formats;
constructor() { constructor() {
logger.checkNew(new.target, Formatter);
this.formats = this.getDefaultFormats(); this.formats = this.getDefaultFormats();
} }

@ -16,8 +16,6 @@ export class IpcProvider extends JsonRpcProvider {
readonly path: string; readonly path: string;
constructor(path: string, network?: Networkish) { constructor(path: string, network?: Networkish) {
logger.checkNew(new.target, IpcProvider);
if (path == null) { if (path == null) {
logger.throwError("missing path", Logger.errors.MISSING_ARGUMENT, { arg: "path" }); logger.throwError("missing path", Logger.errors.MISSING_ARGUMENT, { arg: "path" });
} }

@ -144,8 +144,6 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
_address: string; _address: string;
constructor(constructorGuard: any, provider: JsonRpcProvider, addressOrIndex?: string | number) { constructor(constructorGuard: any, provider: JsonRpcProvider, addressOrIndex?: string | number) {
logger.checkNew(new.target, JsonRpcSigner);
super(); super();
if (constructorGuard !== _constructorGuard) { if (constructorGuard !== _constructorGuard) {
@ -354,8 +352,6 @@ export class JsonRpcProvider extends BaseProvider {
} }
constructor(url?: ConnectionInfo | string, network?: Networkish) { constructor(url?: ConnectionInfo | string, network?: Networkish) {
logger.checkNew(new.target, JsonRpcProvider);
let networkOrReady: Networkish | Promise<Network> = network; let networkOrReady: Networkish | Promise<Network> = network;
// The network is unknown, query the JSON-RPC for it // The network is unknown, query the JSON-RPC for it

@ -123,8 +123,6 @@ export class Web3Provider extends JsonRpcProvider {
readonly jsonRpcFetchFunc: JsonRpcFetchFunc; readonly jsonRpcFetchFunc: JsonRpcFetchFunc;
constructor(provider: ExternalProvider | JsonRpcFetchFunc, network?: Networkish) { constructor(provider: ExternalProvider | JsonRpcFetchFunc, network?: Networkish) {
logger.checkNew(new.target, Web3Provider);
if (provider == null) { if (provider == null) {
logger.throwArgumentError("missing provider", "provider", provider); logger.throwArgumentError("missing provider", "provider", provider);
} }

@ -38,8 +38,6 @@ export class Wallet extends Signer implements ExternallyOwnedAccount, TypedDataS
readonly _mnemonic: () => Mnemonic; readonly _mnemonic: () => Mnemonic;
constructor(privateKey: BytesLike | ExternallyOwnedAccount | SigningKey, provider?: Provider) { constructor(privateKey: BytesLike | ExternallyOwnedAccount | SigningKey, provider?: Provider) {
logger.checkNew(new.target, Wallet);
super(); super();
if (isAccount(privateKey)) { if (isAccount(privateKey)) {