diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-27 21:19:23 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-27 23:56:21 +0800 |
commit | d72b7299c66ea6d63eb14595b06456c02b2ad99b (patch) | |
tree | e026f0af7f779c0c94ddc1261f630dd8ca923af5 /packages/abi-gen/src | |
parent | 066d13f5b7260d28b13195c4f9aed48b4ae96cc3 (diff) | |
download | dexon-0x-contracts-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.gz dexon-0x-contracts-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.zst dexon-0x-contracts-d72b7299c66ea6d63eb14595b06456c02b2ad99b.zip |
Move common types out of web3 types
Diffstat (limited to 'packages/abi-gen/src')
-rw-r--r-- | packages/abi-gen/src/index.ts | 8 | ||||
-rw-r--r-- | packages/abi-gen/src/types.ts | 6 | ||||
-rw-r--r-- | packages/abi-gen/src/utils.ts | 11 |
3 files changed, 10 insertions, 15 deletions
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index 8932e4045..942bb12db 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,5 +1,6 @@ #!/usr/bin/env node +import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types'; import { logUtils } from '@0xproject/utils'; import chalk from 'chalk'; import * as fs from 'fs'; @@ -10,7 +11,6 @@ import * as mkdirp from 'mkdirp'; import * as yargs from 'yargs'; import toSnakeCase = require('to-snake-case'); -import * as Web3 from 'web3'; import { ContextData, ContractsBackend, ParamKind } from './types'; import { utils } from './utils'; @@ -120,12 +120,12 @@ for (const abiFileName of abiFileNames) { process.exit(1); } - let ctor = ABI.find((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as Web3.ConstructorAbi; + let ctor = ABI.find((abi: AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as ConstructorAbi; if (_.isUndefined(ctor)) { ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition } - const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[]; + const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[]; const methodsData = _.map(methodAbis, methodAbi => { _.map(methodAbi.inputs, (input, i: number) => { if (_.isEmpty(input.name)) { @@ -142,7 +142,7 @@ for (const abiFileName of abiFileNames) { return methodData; }); - const eventAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_EVENT) as Web3.EventAbi[]; + const eventAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_EVENT) as EventAbi[]; const contextData = { contractName: namedContent.name, diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts index deddb1857..df5b1feaf 100644 --- a/packages/abi-gen/src/types.ts +++ b/packages/abi-gen/src/types.ts @@ -1,4 +1,4 @@ -import * as Web3 from 'web3'; +import { EventAbi, MethodAbi } from '@0xproject/types'; export enum ParamKind { Input = 'input', @@ -17,7 +17,7 @@ export enum ContractsBackend { Ethers = 'ethers', } -export interface Method extends Web3.MethodAbi { +export interface Method extends MethodAbi { singleReturnValue: boolean; hasReturnValue: boolean; } @@ -25,5 +25,5 @@ export interface Method extends Web3.MethodAbi { export interface ContextData { contractName: string; methods: Method[]; - events: Web3.EventAbi[]; + events: EventAbi[]; } diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts index c4520ade0..755fbc71a 100644 --- a/packages/abi-gen/src/utils.ts +++ b/packages/abi-gen/src/utils.ts @@ -1,17 +1,12 @@ +import { ConstructorAbi, DataItem } from '@0xproject/types'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; -import * as Web3 from 'web3'; import { AbiType, ContractsBackend, ParamKind } from './types'; export const utils = { - solTypeToTsType( - paramKind: ParamKind, - backend: ContractsBackend, - solType: string, - components?: Web3.DataItem[], - ): string { + solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string { const trailingArrayRegex = /\[\d*\]$/; if (solType.match(trailingArrayRegex)) { const arrayItemSolType = solType.replace(trailingArrayRegex, ''); @@ -89,7 +84,7 @@ export const utils = { throw new Error(`Failed to read ${filename}: ${err}`); } }, - getEmptyConstructor(): Web3.ConstructorAbi { + getEmptyConstructor(): ConstructorAbi { return { type: AbiType.Constructor, stateMutability: 'nonpayable', |