diff --git a/packages/abi/src.ts/interface.ts b/packages/abi/src.ts/interface.ts index 54b54bcc4..73de0f0c1 100644 --- a/packages/abi/src.ts/interface.ts +++ b/packages/abi/src.ts/interface.ts @@ -55,7 +55,7 @@ export class Interface { readonly _abiCoder: AbiCoder; - static _isInterface: boolean; + readonly _isInterface: boolean; constructor(fragments: string | Array) { logger.checkNew(new.target, Interface); @@ -87,7 +87,7 @@ export class Interface { logger.warn("duplicate definition - constructor"); return; } - defineReadOnly(this, "deploy", fragment); + defineReadOnly(this, "deploy", fragment); return; case "function": bucket = this.functions; diff --git a/packages/asm/src.ts/assembler.ts b/packages/asm/src.ts/assembler.ts index fe2cf7212..c415a6936 100644 --- a/packages/asm/src.ts/assembler.ts +++ b/packages/asm/src.ts/assembler.ts @@ -155,7 +155,7 @@ export abstract class Node { ethers.utils.defineReadOnly(this, "warnings", [ ]); for (const key in options) { - ethers.utils.defineReadOnly(this, key, options[key]); + ethers.utils.defineReadOnly(this, key, options[key]); } } @@ -702,11 +702,11 @@ class Assembler { readonly defines: { [ name: string ]: any }; - private _stack: Array; - private _parents: { [ tag: string ]: Node }; - private _script: Script; + _stack: Array; + _parents: { [ tag: string ]: Node }; + _script: Script; - private _changed: boolean; + _changed: boolean; constructor(root: Node, options: AssemblerOptions) { ethers.utils.defineReadOnly(this, "positionIndependentCode", !!options.positionIndependentCode); @@ -718,7 +718,7 @@ class Assembler { const nodes: { [ tag: string ]: NodeState } = { }; - const labels: { [ name: string ]: Node } = { }; + const labels: { [ name: string ]: LabelledNode } = { }; const parents: { [ tag: string ]: Node } = { }; // Link labels to their target node diff --git a/packages/basex/src.ts/index.ts b/packages/basex/src.ts/index.ts index a99e9905b..6f93a33d6 100644 --- a/packages/basex/src.ts/index.ts +++ b/packages/basex/src.ts/index.ts @@ -45,8 +45,8 @@ export class BaseX { readonly alphabet: string; readonly base: number; - private _alphabetMap: { [ character: string ]: number }; - private _leader: string; + _alphabetMap: { [ character: string ]: number }; + _leader: string; constructor(alphabet: string) { defineReadOnly(this, "alphabet", alphabet); diff --git a/packages/cli/src.ts/bin/ethers-ens.ts b/packages/cli/src.ts/bin/ethers-ens.ts index 59e4de410..739804005 100644 --- a/packages/cli/src.ts/bin/ethers-ens.ts +++ b/packages/cli/src.ts/bin/ethers-ens.ts @@ -241,18 +241,12 @@ abstract class AccountPlugin extends EnsPlugin { } async _setValue(key: string, value: string): Promise { - ethers.utils.defineReadOnly(this, key, value); + ethers.utils.defineReadOnly(this, key, value); if (key === "name") { await this._setValue("nodehash", ethers.utils.namehash(value)); } } - async prepareOptions(argParser: ArgParser): Promise { - await super.prepareOptions(argParser); - - ethers.utils.defineReadOnly(this, "_wait", argParser.consumeFlag("wait")); - } - async prepareArgs(args: Array): Promise { await super.prepareArgs(args); diff --git a/packages/cli/src.ts/cli.ts b/packages/cli/src.ts/cli.ts index 605a89a83..2b4c89118 100644 --- a/packages/cli/src.ts/cli.ts +++ b/packages/cli/src.ts/cli.ts @@ -491,7 +491,7 @@ export abstract class Plugin { network: ethers.providers.Network; provider: ethers.providers.Provider; - accounts: Array; + accounts: ReadonlyArray; mnemonicPassword: boolean; _xxxMnemonicPasswordHard: boolean; diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts index b365ab9d0..5c00ba2b1 100644 --- a/packages/contracts/src.ts/index.ts +++ b/packages/contracts/src.ts/index.ts @@ -477,7 +477,7 @@ export class Contract { const uniqueFilters: { [ name: string ]: Array } = { }; Object.keys(this.interface.events).forEach((eventSignature) => { const event = this.interface.events[eventSignature]; - defineReadOnly(this.filters, eventSignature, (...args: Array) => { + defineReadOnly(this.filters, eventSignature, (...args: Array) => { return { address: this.address, topics: this.interface.encodeFilterTopics(event, args) @@ -526,7 +526,7 @@ export class Contract { const run = runMethod(this, name, { }); if (this[name] == null) { - defineReadOnly(this, name, run); + defineReadOnly(this, name, run); } if (this.functions[name] == null) { diff --git a/packages/properties/src.ts/index.ts b/packages/properties/src.ts/index.ts index 1ad3991c3..408f01997 100644 --- a/packages/properties/src.ts/index.ts +++ b/packages/properties/src.ts/index.ts @@ -4,7 +4,7 @@ import { Logger } from "@ethersproject/logger"; import { version } from "./_version"; const logger = new Logger(version); -export function defineReadOnly(object: any, name: string, value: any): void { +export function defineReadOnly(object: T, name: K, value: T[K]): void { Object.defineProperty(object, name, { enumerable: true, value: value, diff --git a/packages/providers/src.ts/fallback-provider.ts b/packages/providers/src.ts/fallback-provider.ts index d2227eda1..1da90f0c1 100644 --- a/packages/providers/src.ts/fallback-provider.ts +++ b/packages/providers/src.ts/fallback-provider.ts @@ -298,7 +298,7 @@ function getRunner(provider: Provider, method: string, params: { [ key: string]: } export class FallbackProvider extends BaseProvider { - readonly providerConfigs: Array; + readonly providerConfigs: ReadonlyArray; readonly quorum: number; // Due to teh highly asyncronous nature of the blockchain, we need diff --git a/packages/providers/src.ts/url-json-rpc-provider.ts b/packages/providers/src.ts/url-json-rpc-provider.ts index 6c20f0c4f..b57259d1c 100644 --- a/packages/providers/src.ts/url-json-rpc-provider.ts +++ b/packages/providers/src.ts/url-json-rpc-provider.ts @@ -1,3 +1,4 @@ + "use strict"; import { Network, Networkish } from "@ethersproject/networks"; @@ -30,7 +31,7 @@ export abstract class UrlJsonRpcProvider extends JsonRpcProvider { defineReadOnly(this, "apiKey", apiKey); } else if (apiKey != null) { Object.keys(apiKey).forEach((key) => { - defineReadOnly(this, key, apiKey[key]); + defineReadOnly(this, key, apiKey[key]); }); } } diff --git a/packages/wallet/src.ts/index.ts b/packages/wallet/src.ts/index.ts index 7a04937b0..c8187ddfd 100644 --- a/packages/wallet/src.ts/index.ts +++ b/packages/wallet/src.ts/index.ts @@ -67,7 +67,6 @@ export class Wallet extends Signer implements ExternallyOwnedAccount { } } else { defineReadOnly(this, "_mnemonic", (): Mnemonic => null); - defineReadOnly(this, "path", null); } @@ -82,7 +81,6 @@ export class Wallet extends Signer implements ExternallyOwnedAccount { defineReadOnly(this, "_signingKey", () => signingKey); } defineReadOnly(this, "_mnemonic", (): Mnemonic => null); - defineReadOnly(this, "path", null); defineReadOnly(this, "address", computeAddress(this.publicKey)); }