diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-08 21:13:24 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-10 23:46:57 +0800 |
commit | 96037aed5231aa9344e5037aa6cff3d01f4abdae (patch) | |
tree | c03ac734634156db5dfe1c71b979d0f14f0ef388 /packages/deployer/src/utils | |
parent | f9d80adaeeec827a8c2c81507d68d11e2681dcf3 (diff) | |
download | dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar.gz dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar.bz2 dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar.lz dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar.xz dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.tar.zst dexon-sol-tools-96037aed5231aa9344e5037aa6cff3d01f4abdae.zip |
Remove deployer
Diffstat (limited to 'packages/deployer/src/utils')
-rw-r--r-- | packages/deployer/src/utils/contract.ts | 80 | ||||
-rw-r--r-- | packages/deployer/src/utils/error_reporter.ts | 18 | ||||
-rw-r--r-- | packages/deployer/src/utils/types.ts | 27 |
3 files changed, 0 insertions, 125 deletions
diff --git a/packages/deployer/src/utils/contract.ts b/packages/deployer/src/utils/contract.ts deleted file mode 100644 index e8dd5218a..000000000 --- a/packages/deployer/src/utils/contract.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { schemas, SchemaValidator } from '@0xproject/json-schemas'; -import { AbiType, ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types'; -import { promisify } from '@0xproject/utils'; -import * as _ from 'lodash'; -import * as Web3 from 'web3'; - -export class Contract implements Web3.ContractInstance { - public address: string; - public abi: ContractAbi; - private _contract: Web3.ContractInstance; - private _defaults: Partial<TxData>; - private _validator: SchemaValidator; - // This class instance is going to be populated with functions and events depending on the ABI - // and we don't know their types in advance - [name: string]: any; - constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { - this._contract = web3ContractInstance; - this.address = web3ContractInstance.address; - this.abi = web3ContractInstance.abi; - this._defaults = defaults; - this._populateEvents(); - this._populateFunctions(); - this._validator = new SchemaValidator(); - } - private _populateFunctions(): void { - const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function) as FunctionAbi[]; - _.forEach(functionsAbi, (functionAbi: MethodAbi) => { - if (functionAbi.constant) { - const cbStyleCallFunction = this._contract[functionAbi.name].call; - this[functionAbi.name] = promisify(cbStyleCallFunction, this._contract); - this[functionAbi.name].call = promisify(cbStyleCallFunction, this._contract); - } else { - const cbStyleFunction = this._contract[functionAbi.name]; - const cbStyleCallFunction = this._contract[functionAbi.name].call; - const cbStyleEstimateGasFunction = this._contract[functionAbi.name].estimateGas; - this[functionAbi.name] = this._promisifyWithDefaultParams(cbStyleFunction); - this[functionAbi.name].estimateGasAsync = promisify(cbStyleEstimateGasFunction); - this[functionAbi.name].sendTransactionAsync = this._promisifyWithDefaultParams(cbStyleFunction); - this[functionAbi.name].call = promisify(cbStyleCallFunction, this._contract); - } - }); - } - private _populateEvents(): void { - const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event) as EventAbi[]; - _.forEach(eventsAbi, (eventAbi: EventAbi) => { - this[eventAbi.name] = this._contract[eventAbi.name]; - }); - } - private _promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise<any> { - const promisifiedWithDefaultParams = async (...args: any[]) => { - const promise = new Promise((resolve, reject) => { - const lastArg = args[args.length - 1]; - let txData: Partial<TxData> = {}; - if (this._isTxData(lastArg)) { - txData = args.pop(); - } - txData = { - ...this._defaults, - ...txData, - }; - const callback = (err: Error, data: any) => { - if (_.isNull(err)) { - resolve(data); - } else { - reject(err); - } - }; - args.push(txData); - args.push(callback); - fn.apply(this._contract, args); - }); - return promise; - }; - return promisifiedWithDefaultParams; - } - private _isTxData(lastArg: any): boolean { - const isValid = this._validator.isValid(lastArg, schemas.txDataSchema); - return isValid; - } -} diff --git a/packages/deployer/src/utils/error_reporter.ts b/packages/deployer/src/utils/error_reporter.ts deleted file mode 100644 index 4e73307f0..000000000 --- a/packages/deployer/src/utils/error_reporter.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { logUtils } from '@0xproject/utils'; - -/** - * Makes an async function no-throw printing errors to the console - * @param asyncFn async function to wrap - * @return Wrapped version of the passed function - */ -export function consoleReporter<T>(asyncFn: (arg: T) => Promise<void>): (arg: T) => Promise<void> { - const noThrowFnAsync = async (arg: T) => { - try { - const result = await asyncFn(arg); - return result; - } catch (err) { - logUtils.log(`${err}`); - } - }; - return noThrowFnAsync; -} diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index 19c27df67..b12a11b79 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -50,17 +50,6 @@ export interface SolcErrors { [key: string]: boolean; } -export interface CliOptions extends yargs.Arguments { - artifactsDir: string; - contractsDir: string; - jsonrpcUrl: string; - networkId: number; - gasPrice: string; - account?: string; - contract?: string; - args?: string; -} - export interface CompilerOptions { contractsDir?: string; artifactsDir?: string; @@ -68,22 +57,6 @@ export interface CompilerOptions { contracts?: string[] | '*'; } -export interface BaseDeployerOptions { - artifactsDir: string; - networkId: number; - defaults: Partial<TxData>; -} - -export interface ProviderDeployerOptions extends BaseDeployerOptions { - provider: Provider; -} - -export interface UrlDeployerOptions extends BaseDeployerOptions { - jsonrpcUrl: string; -} - -export type DeployerOptions = UrlDeployerOptions | ProviderDeployerOptions; - export interface ContractSourceData { [contractName: string]: ContractSpecificSourceData; } |