diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-10 19:44:15 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-04-12 18:50:38 +0800 |
commit | f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1 (patch) | |
tree | 98ff3c9137cdce1a44b65dc7dc89a7a72f70b9de /packages/base-contract/src/index.ts | |
parent | ed0c64fdcf5c180107f54ad916c11c4901a4c01c (diff) | |
download | dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.gz dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.bz2 dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.lz dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.xz dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.tar.zst dexon-sol-tools-f2f9bd2e7ac1372073644a4e30a5d99e8c57fbb1.zip |
Revert "Merge pull request #493 from hysz/features/deployer/multipleCodebaseSupport"
This reverts commit 70d403e6f8c56bc70e6d3471a770b9bbff5d72e7, reversing
changes made to 073bf738ddb271b6b4158798baf4cac3cb0608e9.
Diffstat (limited to 'packages/base-contract/src/index.ts')
-rw-r--r-- | packages/base-contract/src/index.ts | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index bfa99fac1..bba686f8b 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -1,26 +1,13 @@ -import { - AbiDefinition, - AbiType, - ContractAbi, - DataItem, - MethodAbi, - Provider, - TxData, - TxDataPayable, -} from '@0xproject/types'; -import { abiUtils, BigNumber } from '@0xproject/utils'; +import { ContractAbi, DataItem, Provider, TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as ethersContracts from 'ethers-contracts'; import * as _ from 'lodash'; import { formatABIDataItem } from './utils'; -export interface EthersInterfaceByFunctionSignature { - [key: string]: ethersContracts.Interface; -} - export class BaseContract { - protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature; + protected _ethersInterface: ethersContracts.Interface; protected _web3Wrapper: Web3Wrapper; public abi: ContractAbi; public address: string; @@ -62,37 +49,10 @@ export class BaseContract { } return txDataWithDefaults; } - protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface { - const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature]; - if (_.isUndefined(ethersInterface)) { - throw new Error(`Failed to lookup method with function signature '${functionSignature}'`); - } - return ethersInterface; - } - protected _lookupAbi(functionSignature: string): MethodAbi { - const methodAbi = _.find(this.abi, (abiDefinition: AbiDefinition) => { - if (abiDefinition.type !== AbiType.Function) { - return false; - } - const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition); - if (abiFunctionSignature === functionSignature) { - return true; - } - return false; - }) as MethodAbi; - return methodAbi; - } constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) { this._web3Wrapper = new Web3Wrapper(provider, defaults); this.abi = abi; this.address = address; - const methodAbis = this.abi.filter( - (abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Function, - ) as MethodAbi[]; - this._ethersInterfacesByFunctionSignature = {}; - _.each(methodAbis, methodAbi => { - const functionSignature = abiUtils.getFunctionSignature(methodAbi); - this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]); - }); + this._ethersInterface = new ethersContracts.Interface(abi); } } |