From fe3b3fa1aded67827fec1131931d95d8153d8f32 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 10 Mar 2020 19:02:53 +0100 Subject: [PATCH] Renamed properties based on community recommendations; estimate to estimateGas and addressPromise to resovledAddress. --- packages/contracts/src.ts/index.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts index 81f0be9ff..b251b99d7 100644 --- a/packages/contracts/src.ts/index.ts +++ b/packages/contracts/src.ts/index.ts @@ -161,10 +161,10 @@ function runMethod(contract: Contract, functionName: string, options: RunOptions // If the contract was just deployed, wait until it is minded if (contract.deployTransaction != null) { tx.to = contract._deployed(blockTag).then(() => { - return contract.addressPromise; + return contract.resolvedAddress; }); } else { - tx.to = contract.addressPromise; + tx.to = contract.resolvedAddress; } return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then((params) => { @@ -433,14 +433,14 @@ export class Contract { readonly functions: Bucket; readonly callStatic: Bucket; - readonly estimate: Bucket<(...params: Array) => Promise>; + readonly estimateGas: Bucket<(...params: Array) => Promise>; readonly populateTransaction: Bucket<(...params: Array) => Promise>; readonly filters: Bucket<(...params: Array) => EventFilter>; readonly [ name: string ]: ContractFunction | any; - readonly addressPromise: Promise; + readonly resolvedAddress: Promise; // This is only set if the contract was created with a call to deploy readonly deployTransaction: TransactionResponse; @@ -471,7 +471,7 @@ export class Contract { } defineReadOnly(this, "callStatic", { }); - defineReadOnly(this, "estimate", { }); + defineReadOnly(this, "estimateGas", { }); defineReadOnly(this, "functions", { }); defineReadOnly(this, "populateTransaction", { }); @@ -506,7 +506,7 @@ export class Contract { defineReadOnly(this, "address", addressOrName); if (this.provider) { - defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then((address) => { + defineReadOnly(this, "resolvedAddress", this.provider.resolveName(addressOrName).then((address) => { if (address == null) { throw new Error("name not found"); } return address; }).catch((error: Error) => { @@ -515,7 +515,7 @@ export class Contract { })); } else { try { - defineReadOnly(this, "addressPromise", Promise.resolve(((this.interface.constructor)).getAddress(addressOrName))); + defineReadOnly(this, "resolvedAddress", Promise.resolve(((this.interface.constructor)).getAddress(addressOrName))); } catch (error) { // Without a provider, we cannot use ENS names logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); @@ -545,8 +545,8 @@ export class Contract { defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true })); } - if (this.estimate[name] == null) { - defineReadOnly(this.estimate, name, runMethod(this, name, { estimate: true })); + if (this.estimateGas[name] == null) { + defineReadOnly(this.estimateGas, name, runMethod(this, name, { estimate: true })); } if (!uniqueFunctions[fragment.name]) { uniqueFunctions[fragment.name] = [ ]; } @@ -567,7 +567,7 @@ export class Contract { defineReadOnly(this.functions, name, this.functions[signatures[0]]); defineReadOnly(this.callStatic, name, this.callStatic[signatures[0]]); defineReadOnly(this.populateTransaction, name, this.populateTransaction[signatures[0]]); - defineReadOnly(this.estimate, name, this.estimate[signatures[0]]); + defineReadOnly(this.estimateGas, name, this.estimateGas[signatures[0]]); }); } @@ -634,7 +634,7 @@ export class Contract { logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }) }); - tx.to = this.addressPromise; + tx.to = this.resolvedAddress; return this.deployed().then(() => { return this.signer.sendTransaction(tx); });