aboutsummaryrefslogtreecommitdiffstats
path: root/packages/abi-gen
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-28 22:26:05 +0800
committerGitHub <noreply@github.com>2018-03-28 22:26:05 +0800
commit8926dac78c3ac8d75ad5ffd5b4febe36def4e53c (patch)
tree01c1b3f8dba486beb4e83e67ad0bc35c3da6a14e /packages/abi-gen
parent18cac3f0927a0424e3618fd56dba73fc9dfc0288 (diff)
parent01e27426d643b525661e044dbb8c8f27734329e7 (diff)
downloaddexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.gz
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.bz2
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.lz
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.xz
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.tar.zst
dexon-sol-tools-8926dac78c3ac8d75ad5ffd5b4febe36def4e53c.zip
Merge pull request #482 from 0xProject/feature/web3-types
Move common types out of web3 types
Diffstat (limited to 'packages/abi-gen')
-rw-r--r--packages/abi-gen/package.json2
-rw-r--r--packages/abi-gen/src/index.ts8
-rw-r--r--packages/abi-gen/src/types.ts6
-rw-r--r--packages/abi-gen/src/utils.ts11
4 files changed, 11 insertions, 16 deletions
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index 2fdf19320..3c20249dd 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -24,6 +24,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": {
"@0xproject/utils": "^0.4.3",
+ "@0xproject/types": "^0.4.1",
"@0xproject/typescript-typings": "^0.0.1",
"chalk": "^2.3.0",
"glob": "^7.1.2",
@@ -31,7 +32,6 @@
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"to-snake-case": "^1.0.0",
- "web3": "^0.20.0",
"yargs": "^10.0.3"
},
"devDependencies": {
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',