diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-10 21:02:32 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-10 23:47:38 +0800 |
commit | 7eb9444458f8c86cbc9c7be47879802c52ece57a (patch) | |
tree | 749c90f1bc547dfb7795057bc2b6aadf709b7319 /packages/base-contract/src/index.ts | |
parent | ebc296ea3150672c6998fcbdefbbb18433030719 (diff) | |
download | dexon-sol-tools-7eb9444458f8c86cbc9c7be47879802c52ece57a.tar.gz dexon-sol-tools-7eb9444458f8c86cbc9c7be47879802c52ece57a.tar.zst dexon-sol-tools-7eb9444458f8c86cbc9c7be47879802c52ece57a.zip |
Remove _applyDefaultsToDeployTxDataAsync
Diffstat (limited to 'packages/base-contract/src/index.ts')
-rw-r--r-- | packages/base-contract/src/index.ts | 23 |
1 files changed, 4 insertions, 19 deletions
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<T extends Partial<TxData | TxDataPayable>>( + protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>( txData: T, defaults: Partial<TxData>, estimateGasAsync?: (txData: T) => Promise<number>, ): Promise<TxData> { - 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<T extends Partial<TxData | TxDataPayable>>( - txData: T, - estimateGasAsync?: (txData: T) => Promise<number>, - ): Promise<TxData> { // 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; |