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;
constructor(coerceFunc?: CoerceFunc) {
logger.checkNew(new.target, AbiCoder);
defineReadOnly(this, "coerceFunc", coerceFunc || null);
}

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

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

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

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

@ -657,8 +657,6 @@ export class BaseContract {
_wrappedEmits: { [ eventTag: string ]: (...args: Array<any>) => void };
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?
//address = getAddress(address);
defineReadOnly(this, "interface", getStatic<InterfaceFunc>(new.target, "getInterface")(contractInterface));

@ -2,10 +2,6 @@
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
// rebroadcasting, in case we overrun the transaction pool
@ -16,7 +12,6 @@ export class NonceManager extends ethers.Signer {
_deltaCount: number;
constructor(signer: ethers.Signer) {
logger.checkNew(new.target, NonceManager);
super();
this._deltaCount = 0;
ethers.utils.defineReadOnly(this, "signer", signer);

@ -97,8 +97,6 @@ export class HDNode implements ExternallyOwnedAccount {
* - fromSeed
*/
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 */
if (constructorGuard !== _constructorGuard) {
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>) {
logger.checkNew(new.target, Provider);
super();
// Events being listened to

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

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

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

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

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

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

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