aboutsummaryrefslogtreecommitdiffstats
path: root/packages/base-contract
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-08 04:11:09 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-10 23:46:57 +0800
commit3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4 (patch)
tree5cff4a892b4094b972b59f119cb2998088fcea76 /packages/base-contract
parentc64ad1af28ef116e210aafb3ea6ad2138361cd7c (diff)
downloaddexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar.gz
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar.bz2
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar.lz
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar.xz
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.tar.zst
dexon-sol-tools-3d58b38e4e8565e7ee10e4d6c9f57cd745957ab4.zip
Remove deployer from metacoin and contract tests
Diffstat (limited to 'packages/base-contract')
-rw-r--r--packages/base-contract/src/index.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index e95b18db6..c362a882b 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -1,6 +1,7 @@
import {
AbiDefinition,
AbiType,
+ ConstructorAbi,
ContractAbi,
DataItem,
MethodAbi,
@@ -37,9 +38,40 @@ export class BaseContract {
protected static _bigNumberToString(type: string, value: any): any {
return _.isObject(value) && value.isBigNumber ? value.toString() : value;
}
+ protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
+ const constructorAbiIfExists = _.find(
+ abi,
+ (abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Constructor,
+ ) as ConstructorAbi | undefined;
+ if (!_.isUndefined(constructorAbiIfExists)) {
+ return constructorAbiIfExists;
+ } else {
+ return {
+ type: AbiType.Constructor,
+ stateMutability: 'nonpayable',
+ payable: false,
+ inputs: [],
+ };
+ }
+ }
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>>(
+ 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>,