From 7eb9444458f8c86cbc9c7be47879802c52ece57a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 May 2018 15:02:32 +0200 Subject: Remove _applyDefaultsToDeployTxDataAsync --- packages/base-contract/src/index.ts | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'packages/base-contract') diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index 8558bceea..2b39029d5 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -60,37 +60,22 @@ export class BaseContract { protected static _bnToBigNumber(type: string, value: any): any { return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value; } - protected static async _applyDefaultsToDeployTxDataAsync>( + protected static async _applyDefaultsToTxDataAsync>( txData: T, defaults: Partial, estimateGasAsync?: (txData: T) => Promise, - ): Promise { - const txDataWithDefaults: TxData = { - ...defaults, - ...(txData as any), - }; - if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) { - const estimatedGas = await estimateGasAsync(txData); - txDataWithDefaults.gas = estimatedGas; - } - return txDataWithDefaults; - } - protected async _applyDefaultsToTxDataAsync>( - txData: T, - estimateGasAsync?: (txData: T) => Promise, ): Promise { // Gas amount sourced with the following priorities: // 1. Optional param passed in to public method call // 2. Global config passed in at library instantiation // 3. Gas estimate calculation + safety margin const removeUndefinedProperties = _.pickBy; - const txDataWithDefaults = ({ - to: this.address, - ...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()), + const txDataWithDefaults: TxData = { + ...removeUndefinedProperties(defaults), ...removeUndefinedProperties(txData as any), // HACK: TS can't prove that T is spreadable. // Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged - } as any) as TxData; + } as any; if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) { const estimatedGas = await estimateGasAsync(txData); txDataWithDefaults.gas = estimatedGas; -- cgit v1.2.3