Move common types out of web3 types

This commit is contained in:
Leonid Logvinov 2018-03-27 15:19:23 +02:00
parent 066d13f5b7
commit d72b7299c6
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
54 changed files with 489 additions and 512 deletions

View File

@ -1,4 +1,4 @@
import { BlockParamLiteral, LogWithDecodedArgs, RawLog } from '@0xproject/types'; import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types';
import { AbiDecoder, intervalUtils } from '@0xproject/utils'; import { AbiDecoder, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream'; import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream';
@ -35,7 +35,7 @@ export class ContractWrapper {
private _abiDecoder?: AbiDecoder; private _abiDecoder?: AbiDecoder;
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer; private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
private _filters: { [filterToken: string]: Web3.FilterObject }; private _filters: { [filterToken: string]: FilterObject };
private _filterCallbacks: { private _filterCallbacks: {
[filterToken: string]: EventCallback<ContractEventArgs>; [filterToken: string]: EventCallback<ContractEventArgs>;
}; };
@ -75,7 +75,7 @@ export class ContractWrapper {
address: string, address: string,
eventName: ContractEvents, eventName: ContractEvents,
indexFilterValues: IndexedFilterValues, indexFilterValues: IndexedFilterValues,
abi: Web3.ContractAbi, abi: ContractAbi,
callback: EventCallback<ArgsType>, callback: EventCallback<ArgsType>,
): string { ): string {
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi); const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
@ -92,7 +92,7 @@ export class ContractWrapper {
eventName: ContractEvents, eventName: ContractEvents,
blockRange: BlockRange, blockRange: BlockRange,
indexFilterValues: IndexedFilterValues, indexFilterValues: IndexedFilterValues,
abi: Web3.ContractAbi, abi: ContractAbi,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> { ): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange); const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange);
const logs = await this._web3Wrapper.getLogsAsync(filter); const logs = await this._web3Wrapper.getLogsAsync(filter);
@ -100,7 +100,7 @@ export class ContractWrapper {
return logsWithDecodedArguments; return logsWithDecodedArguments;
} }
protected _tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>( protected _tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>(
log: Web3.LogEntry, log: LogEntry,
): LogWithDecodedArgs<ArgsType> | RawLog { ): LogWithDecodedArgs<ArgsType> | RawLog {
if (_.isUndefined(this._abiDecoder)) { if (_.isUndefined(this._abiDecoder)) {
throw new Error(InternalZeroExError.NoAbiDecoder); throw new Error(InternalZeroExError.NoAbiDecoder);
@ -111,7 +111,7 @@ export class ContractWrapper {
protected async _getContractAbiAndAddressFromArtifactsAsync( protected async _getContractAbiAndAddressFromArtifactsAsync(
artifact: Artifact, artifact: Artifact,
addressIfExists?: string, addressIfExists?: string,
): Promise<[Web3.ContractAbi, string]> { ): Promise<[ContractAbi, string]> {
let contractAddress: string; let contractAddress: string;
if (_.isUndefined(addressIfExists)) { if (_.isUndefined(addressIfExists)) {
if (_.isUndefined(artifact.networks[this._networkId])) { if (_.isUndefined(artifact.networks[this._networkId])) {
@ -125,7 +125,7 @@ export class ContractWrapper {
if (!doesContractExist) { if (!doesContractExist) {
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]); throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]);
} }
const abiAndAddress: [Web3.ContractAbi, string] = [artifact.abi, contractAddress]; const abiAndAddress: [ContractAbi, string] = [artifact.abi, contractAddress];
return abiAndAddress; return abiAndAddress;
} }
protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string { protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string {
@ -139,8 +139,8 @@ export class ContractWrapper {
return addressIfExists; return addressIfExists;
} }
} }
private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: Web3.LogEntry): void { private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: LogEntry): void {
_.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => { _.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) { if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>; const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
const logEvent = { const logEvent = {

View File

@ -3,6 +3,7 @@ import {
BlockParamLiteral, BlockParamLiteral,
DecodedLogArgs, DecodedLogArgs,
ECSignature, ECSignature,
LogEntry,
LogWithDecodedArgs, LogWithDecodedArgs,
Order, Order,
SignedOrder, SignedOrder,
@ -10,7 +11,6 @@ import {
import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
import { artifacts } from '../artifacts'; import { artifacts } from '../artifacts';
import { import {
@ -863,7 +863,7 @@ export class ExchangeWrapper extends ContractWrapper {
* Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure. * Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure.
* @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync` * @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync`
*/ */
public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>): void { public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>): void {
const errLog = _.find(logs, { const errLog = _.find(logs, {
event: ExchangeEvents.LogError, event: ExchangeEvents.LogError,
}); });

View File

@ -37,12 +37,13 @@ declare module 'ethereumjs-abi' {
// truffle-hdwallet-provider declarations // truffle-hdwallet-provider declarations
declare module 'truffle-hdwallet-provider' { declare module 'truffle-hdwallet-provider' {
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
class HDWalletProvider implements Web3.Provider { class HDWalletProvider implements Web3.Provider {
constructor(mnemonic: string, rpcUrl: string); constructor(mnemonic: string, rpcUrl: string);
public sendAsync( public sendAsync(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void, callback: (err: Error, result: JSONRPCResponsePayload) => void,
): void; ): void;
} }
export = HDWalletProvider; export = HDWalletProvider;

View File

@ -16,7 +16,6 @@ export {
MethodOpts, MethodOpts,
OrderTransactionOpts, OrderTransactionOpts,
TransactionOpts, TransactionOpts,
FilterObject,
LogEvent, LogEvent,
DecodedLogEvent, DecodedLogEvent,
EventWatcherCallback, EventWatcherCallback,
@ -28,6 +27,7 @@ export {
export { export {
BlockParamLiteral, BlockParamLiteral,
FilterObject,
BlockParam, BlockParam,
ContractEventArg, ContractEventArg,
LogWithDecodedArgs, LogWithDecodedArgs,

View File

@ -1,9 +1,7 @@
import { BlockParamLiteral, LogEntry } from '@0xproject/types';
import { intervalUtils } from '@0xproject/utils'; import { intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
import { BlockParamLiteral } from '@0xproject/types';
import { EventWatcherCallback, ZeroExError } from '../types'; import { EventWatcherCallback, ZeroExError } from '../types';
import { assert } from '../utils/assert'; import { assert } from '../utils/assert';
@ -23,7 +21,7 @@ export class EventWatcher {
private _web3Wrapper: Web3Wrapper; private _web3Wrapper: Web3Wrapper;
private _pollingIntervalMs: number; private _pollingIntervalMs: number;
private _intervalIdIfExists?: NodeJS.Timer; private _intervalIdIfExists?: NodeJS.Timer;
private _lastEvents: Web3.LogEntry[] = []; private _lastEvents: LogEntry[] = [];
constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined | number) { constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined | number) {
this._web3Wrapper = web3Wrapper; this._web3Wrapper = web3Wrapper;
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
@ -69,7 +67,7 @@ export class EventWatcher {
await this._emitDifferencesAsync(newEvents, LogEventState.Added, callback); await this._emitDifferencesAsync(newEvents, LogEventState.Added, callback);
this._lastEvents = pendingEvents; this._lastEvents = pendingEvents;
} }
private async _getEventsAsync(): Promise<Web3.LogEntry[]> { private async _getEventsAsync(): Promise<LogEntry[]> {
const eventFilter = { const eventFilter = {
fromBlock: BlockParamLiteral.Pending, fromBlock: BlockParamLiteral.Pending,
toBlock: BlockParamLiteral.Pending, toBlock: BlockParamLiteral.Pending,
@ -78,7 +76,7 @@ export class EventWatcher {
return events; return events;
} }
private async _emitDifferencesAsync( private async _emitDifferencesAsync(
logs: Web3.LogEntry[], logs: LogEntry[],
logEventState: LogEventState, logEventState: LogEventState,
callback: EventWatcherCallback, callback: EventWatcherCallback,
): Promise<void> { ): Promise<void> {

View File

@ -3,7 +3,10 @@ import { BigNumber } from '@0xproject/utils';
import { import {
BlockParam, BlockParam,
BlockParamLiteral, BlockParamLiteral,
ContractAbi,
ContractEventArg, ContractEventArg,
FilterObject,
LogEntryEvent,
LogWithDecodedArgs, LogWithDecodedArgs,
Order, Order,
SignedOrder, SignedOrder,
@ -48,7 +51,7 @@ export type OrderAddresses = [string, string, string, string, string];
export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]; export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
export type LogEvent = Web3.LogEntryEvent; export type LogEvent = LogEntryEvent;
export interface DecodedLogEvent<ArgsType> { export interface DecodedLogEvent<ArgsType> {
isRemoved: boolean; isRemoved: boolean;
log: LogWithDecodedArgs<ArgsType>; log: LogWithDecodedArgs<ArgsType>;
@ -197,7 +200,7 @@ export type ArtifactContractName = 'ZRX' | 'TokenTransferProxy' | 'TokenRegistry
export interface Artifact { export interface Artifact {
contract_name: ArtifactContractName; contract_name: ArtifactContractName;
abi: Web3.ContractAbi; abi: ContractAbi;
networks: { networks: {
[networkId: number]: { [networkId: number]: {
address: string; address: string;
@ -222,7 +225,7 @@ export interface ValidateOrderFillableOpts {
* flag when running Parity). * flag when running Parity).
*/ */
export interface MethodOpts { export interface MethodOpts {
defaultBlock?: Web3.BlockParam; defaultBlock?: BlockParam;
} }
/* /*
@ -242,8 +245,6 @@ export interface OrderTransactionOpts extends TransactionOpts {
shouldValidate?: boolean; shouldValidate?: boolean;
} }
export type FilterObject = Web3.FilterObject;
export enum TradeSide { export enum TradeSide {
Maker = 'maker', Maker = 'maker',
Taker = 'taker', Taker = 'taker',

View File

@ -1,8 +1,16 @@
import {
ConstructorAbi,
ContractAbi,
EventAbi,
FallbackAbi,
FilterObject,
LogEntry,
MethodAbi,
} from '@0xproject/types';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import * as jsSHA3 from 'js-sha3'; import * as jsSHA3 from 'js-sha3';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as uuid from 'uuid/v4'; import * as uuid from 'uuid/v4';
import * as Web3 from 'web3';
import { BlockRange, ContractEvents, IndexedFilterValues } from '../types'; import { BlockRange, ContractEvents, IndexedFilterValues } from '../types';
@ -16,15 +24,15 @@ export const filterUtils = {
address: string, address: string,
eventName: ContractEvents, eventName: ContractEvents,
indexFilterValues: IndexedFilterValues, indexFilterValues: IndexedFilterValues,
abi: Web3.ContractAbi, abi: ContractAbi,
blockRange?: BlockRange, blockRange?: BlockRange,
): Web3.FilterObject { ): FilterObject {
const eventAbi = _.find(abi, { name: eventName }) as Web3.EventAbi; const eventAbi = _.find(abi, { name: eventName }) as EventAbi;
const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName); const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName);
const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature)); const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature));
const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues); const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues);
const topics = [topicForEventSignature, ...topicsForIndexedArgs]; const topics = [topicForEventSignature, ...topicsForIndexedArgs];
let filter: Web3.FilterObject = { let filter: FilterObject = {
address, address,
topics, topics,
}; };
@ -36,12 +44,12 @@ export const filterUtils = {
} }
return filter; return filter;
}, },
getEventSignatureFromAbiByName(eventAbi: Web3.EventAbi, eventName: ContractEvents): string { getEventSignatureFromAbiByName(eventAbi: EventAbi, eventName: ContractEvents): string {
const types = _.map(eventAbi.inputs, 'type'); const types = _.map(eventAbi.inputs, 'type');
const signature = `${eventAbi.name}(${types.join(',')})`; const signature = `${eventAbi.name}(${types.join(',')})`;
return signature; return signature;
}, },
getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> { getTopicsForIndexedArgs(abi: EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
const topics: Array<string | null> = []; const topics: Array<string | null> = [];
for (const eventInput of abi.inputs) { for (const eventInput of abi.inputs) {
if (!eventInput.indexed) { if (!eventInput.indexed) {
@ -60,7 +68,7 @@ export const filterUtils = {
} }
return topics; return topics;
}, },
matchesFilter(log: Web3.LogEntry, filter: Web3.FilterObject): boolean { matchesFilter(log: LogEntry, filter: FilterObject): boolean {
if (!_.isUndefined(filter.address) && log.address !== filter.address) { if (!_.isUndefined(filter.address) && log.address !== filter.address) {
return false; return false;
} }

View File

@ -1,4 +1,5 @@
import { web3Factory } from '@0xproject/dev-utils'; import { web3Factory } from '@0xproject/dev-utils';
import { LogEntry } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai'; import * as chai from 'chai';
import * as _ from 'lodash'; import * as _ from 'lodash';
@ -21,7 +22,7 @@ describe('EventWatcher', () => {
let stubs: Sinon.SinonStub[] = []; let stubs: Sinon.SinonStub[] = [];
let eventWatcher: EventWatcher; let eventWatcher: EventWatcher;
let web3Wrapper: Web3Wrapper; let web3Wrapper: Web3Wrapper;
const logA: Web3.LogEntry = { const logA: LogEntry = {
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5', address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
blockHash: null, blockHash: null,
blockNumber: null, blockNumber: null,
@ -31,7 +32,7 @@ describe('EventWatcher', () => {
transactionHash: '0x004881d38cd4a8f72f1a0d68c8b9b8124504706041ff37019c1d1ed6bfda8e17', transactionHash: '0x004881d38cd4a8f72f1a0d68c8b9b8124504706041ff37019c1d1ed6bfda8e17',
transactionIndex: 0, transactionIndex: 0,
}; };
const logB: Web3.LogEntry = { const logB: LogEntry = {
address: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819', address: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
blockHash: null, blockHash: null,
blockNumber: null, blockNumber: null,
@ -41,7 +42,7 @@ describe('EventWatcher', () => {
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25', transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
transactionIndex: 0, transactionIndex: 0,
}; };
const logC: Web3.LogEntry = { const logC: LogEntry = {
address: '0x1d271f8b174adef58f1587ce68f8f27271ac4ca5', address: '0x1d271f8b174adef58f1587ce68f8f27271ac4ca5',
blockHash: null, blockHash: null,
blockNumber: null, blockNumber: null,
@ -64,7 +65,7 @@ describe('EventWatcher', () => {
eventWatcher.unsubscribe(); eventWatcher.unsubscribe();
}); });
it('correctly emits initial log events', (done: DoneCallback) => { it('correctly emits initial log events', (done: DoneCallback) => {
const logs: Web3.LogEntry[] = [logA, logB]; const logs: LogEntry[] = [logA, logB];
const expectedLogEvents = [ const expectedLogEvents = [
{ {
removed: false, removed: false,
@ -89,8 +90,8 @@ describe('EventWatcher', () => {
eventWatcher.subscribe(callback); eventWatcher.subscribe(callback);
}); });
it('correctly computes the difference and emits only changes', (done: DoneCallback) => { it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
const initialLogs: Web3.LogEntry[] = [logA, logB]; const initialLogs: LogEntry[] = [logA, logB];
const changedLogs: Web3.LogEntry[] = [logA, logC]; const changedLogs: LogEntry[] = [logA, logC];
const expectedLogEvents = [ const expectedLogEvents = [
{ {
removed: false, removed: false,

View File

@ -24,6 +24,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": { "dependencies": {
"@0xproject/utils": "^0.4.3", "@0xproject/utils": "^0.4.3",
"@0xproject/types": "^0.4.1",
"@0xproject/typescript-typings": "^0.0.1", "@0xproject/typescript-typings": "^0.0.1",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"glob": "^7.1.2", "glob": "^7.1.2",
@ -31,7 +32,6 @@
"lodash": "^4.17.4", "lodash": "^4.17.4",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"to-snake-case": "^1.0.0", "to-snake-case": "^1.0.0",
"web3": "^0.20.0",
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,6 @@
#!/usr/bin/env node #!/usr/bin/env node
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types';
import { logUtils } from '@0xproject/utils'; import { logUtils } from '@0xproject/utils';
import chalk from 'chalk'; import chalk from 'chalk';
import * as fs from 'fs'; import * as fs from 'fs';
@ -10,7 +11,6 @@ import * as mkdirp from 'mkdirp';
import * as yargs from 'yargs'; import * as yargs from 'yargs';
import toSnakeCase = require('to-snake-case'); import toSnakeCase = require('to-snake-case');
import * as Web3 from 'web3';
import { ContextData, ContractsBackend, ParamKind } from './types'; import { ContextData, ContractsBackend, ParamKind } from './types';
import { utils } from './utils'; import { utils } from './utils';
@ -120,12 +120,12 @@ for (const abiFileName of abiFileNames) {
process.exit(1); 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)) { if (_.isUndefined(ctor)) {
ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition 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 => { const methodsData = _.map(methodAbis, methodAbi => {
_.map(methodAbi.inputs, (input, i: number) => { _.map(methodAbi.inputs, (input, i: number) => {
if (_.isEmpty(input.name)) { if (_.isEmpty(input.name)) {
@ -142,7 +142,7 @@ for (const abiFileName of abiFileNames) {
return methodData; 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 = { const contextData = {
contractName: namedContent.name, contractName: namedContent.name,

View File

@ -1,4 +1,4 @@
import * as Web3 from 'web3'; import { EventAbi, MethodAbi } from '@0xproject/types';
export enum ParamKind { export enum ParamKind {
Input = 'input', Input = 'input',
@ -17,7 +17,7 @@ export enum ContractsBackend {
Ethers = 'ethers', Ethers = 'ethers',
} }
export interface Method extends Web3.MethodAbi { export interface Method extends MethodAbi {
singleReturnValue: boolean; singleReturnValue: boolean;
hasReturnValue: boolean; hasReturnValue: boolean;
} }
@ -25,5 +25,5 @@ export interface Method extends Web3.MethodAbi {
export interface ContextData { export interface ContextData {
contractName: string; contractName: string;
methods: Method[]; methods: Method[];
events: Web3.EventAbi[]; events: EventAbi[];
} }

View File

@ -1,17 +1,12 @@
import { ConstructorAbi, DataItem } from '@0xproject/types';
import * as fs from 'fs'; import * as fs from 'fs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as path from 'path'; import * as path from 'path';
import * as Web3 from 'web3';
import { AbiType, ContractsBackend, ParamKind } from './types'; import { AbiType, ContractsBackend, ParamKind } from './types';
export const utils = { export const utils = {
solTypeToTsType( solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string {
paramKind: ParamKind,
backend: ContractsBackend,
solType: string,
components?: Web3.DataItem[],
): string {
const trailingArrayRegex = /\[\d*\]$/; const trailingArrayRegex = /\[\d*\]$/;
if (solType.match(trailingArrayRegex)) { if (solType.match(trailingArrayRegex)) {
const arrayItemSolType = solType.replace(trailingArrayRegex, ''); const arrayItemSolType = solType.replace(trailingArrayRegex, '');
@ -89,7 +84,7 @@ export const utils = {
throw new Error(`Failed to read ${filename}: ${err}`); throw new Error(`Failed to read ${filename}: ${err}`);
} }
}, },
getEmptyConstructor(): Web3.ConstructorAbi { getEmptyConstructor(): ConstructorAbi {
return { return {
type: AbiType.Constructor, type: AbiType.Constructor,
stateMutability: 'nonpayable', stateMutability: 'nonpayable',

View File

@ -34,8 +34,7 @@
"@0xproject/web3-wrapper": "^0.3.1", "@0xproject/web3-wrapper": "^0.3.1",
"@0xproject/typescript-typings": "^0.0.1", "@0xproject/typescript-typings": "^0.0.1",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4"
"web3": "^0.20.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -1,16 +1,15 @@
import { TxData, TxDataPayable } from '@0xproject/types'; import { ContractAbi, DataItem, TxData, TxDataPayable } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts'; import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
export class BaseContract { export class BaseContract {
protected _ethersInterface: ethersContracts.Interface; protected _ethersInterface: ethersContracts.Interface;
protected _web3Wrapper: Web3Wrapper; protected _web3Wrapper: Web3Wrapper;
public abi: Web3.ContractAbi; public abi: ContractAbi;
public address: string; public address: string;
protected static _transformABIData( protected static _transformABIData(
abis: Web3.DataItem[], abis: DataItem[],
values: any[], values: any[],
transformation: (type: string, value: any) => any, transformation: (type: string, value: any) => any,
): any { ): any {
@ -46,20 +45,20 @@ export class BaseContract {
// 2. Global config passed in at library instantiation // 2. Global config passed in at library instantiation
// 3. Gas estimate calculation + safety margin // 3. Gas estimate calculation + safety margin
const removeUndefinedProperties = _.pickBy; const removeUndefinedProperties = _.pickBy;
const txDataWithDefaults = { const txDataWithDefaults = ({
to: this.address, to: this.address,
...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()), ...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()),
...removeUndefinedProperties(txData as any), ...removeUndefinedProperties(txData as any),
// HACK: TS can't prove that T is spreadable. // HACK: TS can't prove that T is spreadable.
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged // Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
}; } as any) as TxData;
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) { if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
const estimatedGas = await estimateGasAsync(txData); const estimatedGas = await estimateGasAsync(txData);
txDataWithDefaults.gas = estimatedGas; txDataWithDefaults.gas = estimatedGas;
} }
return txDataWithDefaults; return txDataWithDefaults;
} }
constructor(web3Wrapper: Web3Wrapper, abi: Web3.ContractAbi, address: string) { constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
this._web3Wrapper = web3Wrapper; this._web3Wrapper = web3Wrapper;
this.abi = abi; this.abi = abi;
this.address = address; this.address = address;

View File

@ -5,7 +5,7 @@
// tslint:disable:no-consecutive-blank-lines // tslint:disable:no-consecutive-blank-lines
// tslint:disable-next-line:no-unused-variable // tslint:disable-next-line:no-unused-variable
import { BaseContract } from '@0xproject/base-contract'; import { BaseContract } from '@0xproject/base-contract';
import { TxData, TxDataPayable } from '@0xproject/types'; import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, TxData, TxDataPayable } from '@0xproject/types';
import { BigNumber, classUtils, promisify } from '@0xproject/utils'; import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts'; import * as ethersContracts from 'ethers-contracts';
@ -40,7 +40,7 @@ export class {{contractName}}Contract extends BaseContract {
{{> tx contractName=../contractName}} {{> tx contractName=../contractName}}
{{/this.constant}} {{/this.constant}}
{{/each}} {{/each}}
constructor(web3Wrapper: Web3Wrapper, abi: Web3.ContractAbi, address: string) { constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
super(web3Wrapper, abi, address); super(web3Wrapper, abi, address);
classUtils.bindAll(this, ['_ethersInterface', 'address', 'abi', '_web3Wrapper']); classUtils.bindAll(this, ['_ethersInterface', 'address', 'abi', '_web3Wrapper']);
} }

View File

@ -1,27 +1,22 @@
{{#hasReturnValue}} {{#hasReturnValue}}
async callAsync( async callAsync(
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
{{#this.payable}} callData: Partial<CallData> = {},
txData: TxDataPayable = {}, defaultBlock?: BlockParam,
{{/this.payable}}
{{^this.payable}}
txData: TxData = {},
{{/this.payable}}
defaultBlock?: Web3.BlockParam,
): Promise<{{> return_type outputs=outputs}}> { ): Promise<{{> return_type outputs=outputs}}> {
const self = this as {{contractName}}Contract; const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs; const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const encodedData = self._ethersInterface.functions.{{this.name}}( const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data; ).data;
const callData = await self._applyDefaultsToTxDataAsync( const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ {
data: encodedData, data: encodedData,
} }
) )
const rawCallResult = await self._web3Wrapper.callAsync(callData, defaultBlock); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
const outputAbi = _.find(this.abi, {name: '{{this.name}}'}).outputs as Web3.DataItem[]; const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs as DataItem[];
const outputParamsTypes = _.map(outputAbi, 'type'); const outputParamsTypes = _.map(outputAbi, 'type');
let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any; let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
resultArray = BaseContract._transformABIData(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); resultArray = BaseContract._transformABIData(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));

View File

@ -2,16 +2,16 @@ public {{this.name}} = {
async sendTransactionAsync( async sendTransactionAsync(
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
{{#this.payable}} {{#this.payable}}
txData: TxDataPayable = {}, txData: Partial<TxDataPayable> = {},
{{/this.payable}} {{/this.payable}}
{{^this.payable}} {{^this.payable}}
txData: TxData = {}, txData: Partial<TxData> = {},
{{/this.payable}} {{/this.payable}}
): Promise<string> { ): Promise<string> {
const self = this as {{contractName}}Contract; const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs; const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const encodedData = this._ethersInterface.functions.{{this.name}}( const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@ -24,17 +24,17 @@ public {{this.name}} = {
{{> params inputs=inputs}} {{> params inputs=inputs}}
), ),
); );
const txHash = await this._web3Wrapper.sendTransactionAsync(txDataWithDefaults); const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash; return txHash;
}, },
async estimateGasAsync( async estimateGasAsync(
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
txData: TxData = {}, txData: Partial<TxData> = {},
): Promise<number> { ): Promise<number> {
const self = this as {{contractName}}Contract; const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs; const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
const encodedData = this._ethersInterface.functions.{{this.name}}( const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@ -43,17 +43,16 @@ public {{this.name}} = {
data: encodedData, data: encodedData,
} }
); );
const gas = await this._web3Wrapper.estimateGasAsync(txDataWithDefaults); const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas; return gas;
}, },
getABIEncodedTransactionData( getABIEncodedTransactionData(
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
txData: TxData = {},
): string { ): string {
const self = this as {{contractName}}Contract; const self = this as {{contractName}}Contract;
const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs; const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const abiEncodedTransactionData = this._ethersInterface.functions.{{this.name}}( const abiEncodedTransactionData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data
return abiEncodedTransactionData; return abiEncodedTransactionData;

View File

@ -1,3 +1,4 @@
import { AbiDefinition, MethodAbi } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import ABI = require('ethereumjs-abi'); import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util'); import ethUtil = require('ethereumjs-util');
@ -10,8 +11,8 @@ import { TransactionDataParams } from './types';
export class MultiSigWrapper { export class MultiSigWrapper {
private _multiSig: MultiSigWalletContract; private _multiSig: MultiSigWalletContract;
public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) { public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]) {
const abiEntity = _.find(abi, { name }) as Web3.MethodAbi; const abiEntity = _.find(abi, { name }) as MethodAbi;
if (_.isUndefined(abiEntity)) { if (_.isUndefined(abiEntity)) {
throw new Error(`Did not find abi entry for name: ${name}`); throw new Error(`Did not find abi entry for name: ${name}`);
} }

View File

@ -1,5 +1,5 @@
import { AbiDefinition, ContractAbi } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as Web3 from 'web3';
export interface BalancesByOwner { export interface BalancesByOwner {
[ownerAddress: string]: { [ownerAddress: string]: {
@ -51,7 +51,7 @@ export interface DefaultOrderParams {
export interface TransactionDataParams { export interface TransactionDataParams {
name: string; name: string;
abi: Web3.AbiDefinition[]; abi: AbiDefinition[];
args: any[]; args: any[];
} }
@ -105,7 +105,7 @@ export interface Artifact {
contract_name: ContractName; contract_name: ContractName;
networks: { networks: {
[networkId: number]: { [networkId: number]: {
abi: Web3.ContractAbi; abi: ContractAbi;
solc_version: string; solc_version: string;
keccak256: string; keccak256: string;
optimizer_enabled: number; optimizer_enabled: number;

View File

@ -1,3 +1,4 @@
import { ContractAbi } from '@0xproject/types';
import { logUtils, promisify } from '@0xproject/utils'; import { logUtils, promisify } from '@0xproject/utils';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import * as fs from 'fs'; import * as fs from 'fs';
@ -7,7 +8,6 @@ import * as path from 'path';
import * as requireFromString from 'require-from-string'; import * as requireFromString from 'require-from-string';
import * as semver from 'semver'; import * as semver from 'semver';
import solc = require('solc'); import solc = require('solc');
import * as Web3 from 'web3';
import { binPaths } from './solc/bin_paths'; import { binPaths } from './solc/bin_paths';
import { import {
@ -189,7 +189,7 @@ export class Compiler {
`Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`, `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`,
); );
} }
const abi: Web3.ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface); const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`; const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`;
const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`; const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`;
const sourceMap = compiled.contracts[contractIdentifier].srcmap; const sourceMap = compiled.contracts[contractIdentifier].srcmap;

View File

@ -1,4 +1,4 @@
import { AbiType, TxData } from '@0xproject/types'; import { AbiType, ConstructorAbi, ContractAbi, TxData } from '@0xproject/types';
import { logUtils } from '@0xproject/utils'; import { logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash'; import * as _ from 'lodash';
@ -71,7 +71,7 @@ export class Deployer {
gas, gas,
}; };
const abi = contractNetworkDataIfExists.abi; const abi = contractNetworkDataIfExists.abi;
const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as Web3.ConstructorAbi; const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as ConstructorAbi;
const constructorArgs = _.isUndefined(constructorAbi) ? [] : constructorAbi.inputs; const constructorArgs = _.isUndefined(constructorAbi) ? [] : constructorAbi.inputs;
if (constructorArgs.length !== args.length) { if (constructorArgs.length !== args.length) {
const constructorSignature = `constructor(${_.map(constructorArgs, arg => `${arg.type} ${arg.name}`).join( const constructorSignature = `constructor(${_.map(constructorArgs, arg => `${arg.type} ${arg.name}`).join(
@ -107,7 +107,7 @@ export class Deployer {
* @param txData Tx options used for deployment. * @param txData Tx options used for deployment.
* @return Promise that resolves to a web3 contract instance. * @return Promise that resolves to a web3 contract instance.
*/ */
private async _deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> { private async _deployFromAbiAsync(abi: ContractAbi, args: any[], txData: TxData): Promise<any> {
const contract: Web3.Contract<Web3.ContractInstance> = this.web3Wrapper.getContractFromAbi(abi); const contract: Web3.Contract<Web3.ContractInstance> = this.web3Wrapper.getContractFromAbi(abi);
const deployPromise = new Promise((resolve, reject) => { const deployPromise = new Promise((resolve, reject) => {
/** /**

View File

@ -2,7 +2,6 @@ declare module 'dirty-chai';
// tslint:disable:completed-docs // tslint:disable:completed-docs
declare module 'solc' { declare module 'solc' {
import * as Web3 from 'web3';
export interface ContractCompilationResult { export interface ContractCompilationResult {
srcmap: string; srcmap: string;
srcmapRuntime: string; srcmapRuntime: string;

View File

@ -1,4 +1,5 @@
import { schemas, SchemaValidator } from '@0xproject/json-schemas'; import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import { ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types';
import { promisify } from '@0xproject/utils'; import { promisify } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@ -7,14 +8,14 @@ import { AbiType } from './types';
export class Contract implements Web3.ContractInstance { export class Contract implements Web3.ContractInstance {
public address: string; public address: string;
public abi: Web3.ContractAbi; public abi: ContractAbi;
private _contract: Web3.ContractInstance; private _contract: Web3.ContractInstance;
private _defaults: Partial<Web3.TxData>; private _defaults: Partial<TxData>;
private _validator: SchemaValidator; private _validator: SchemaValidator;
// This class instance is going to be populated with functions and events depending on the ABI // 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 // and we don't know their types in advance
[name: string]: any; [name: string]: any;
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<Web3.TxData>) { constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
this._contract = web3ContractInstance; this._contract = web3ContractInstance;
this.address = web3ContractInstance.address; this.address = web3ContractInstance.address;
this.abi = web3ContractInstance.abi; this.abi = web3ContractInstance.abi;
@ -24,8 +25,8 @@ export class Contract implements Web3.ContractInstance {
this._validator = new SchemaValidator(); this._validator = new SchemaValidator();
} }
private _populateFunctions(): void { private _populateFunctions(): void {
const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function) as Web3.FunctionAbi[]; const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function) as FunctionAbi[];
_.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => { _.forEach(functionsAbi, (functionAbi: MethodAbi) => {
if (functionAbi.constant) { if (functionAbi.constant) {
const cbStyleCallFunction = this._contract[functionAbi.name].call; const cbStyleCallFunction = this._contract[functionAbi.name].call;
this[functionAbi.name] = promisify(cbStyleCallFunction, this._contract); this[functionAbi.name] = promisify(cbStyleCallFunction, this._contract);
@ -42,8 +43,8 @@ export class Contract implements Web3.ContractInstance {
}); });
} }
private _populateEvents(): void { private _populateEvents(): void {
const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event) as Web3.EventAbi[]; const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event) as EventAbi[];
_.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => { _.forEach(eventsAbi, (eventAbi: EventAbi) => {
this[eventAbi.name] = this._contract[eventAbi.name]; this[eventAbi.name] = this._contract[eventAbi.name];
}); });
} }
@ -51,7 +52,7 @@ export class Contract implements Web3.ContractInstance {
const promisifiedWithDefaultParams = async (...args: any[]) => { const promisifiedWithDefaultParams = async (...args: any[]) => {
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
const lastArg = args[args.length - 1]; const lastArg = args[args.length - 1];
let txData: Partial<Web3.TxData> = {}; let txData: Partial<TxData> = {};
if (this._isTxData(lastArg)) { if (this._isTxData(lastArg)) {
txData = args.pop(); txData = args.pop();
} }

View File

@ -1,15 +1,15 @@
import { AbiDefinition, ContractAbi, DataItem } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as web3Abi from 'web3-eth-abi'; import * as web3Abi from 'web3-eth-abi';
import { AbiType } from './types'; import { AbiType } from './types';
export const encoder = { export const encoder = {
encodeConstructorArgsFromAbi(args: any[], abi: Web3.ContractAbi): string { encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string {
const constructorTypes: string[] = []; const constructorTypes: string[] = [];
_.each(abi, (element: Web3.AbiDefinition) => { _.each(abi, (element: AbiDefinition) => {
if (element.type === AbiType.Constructor) { if (element.type === AbiType.Constructor) {
_.each(element.inputs, (input: Web3.DataItem) => { _.each(element.inputs, (input: DataItem) => {
constructorTypes.push(input.type); constructorTypes.push(input.type);
}); });
} }

View File

@ -1,4 +1,4 @@
import { TxData } from '@0xproject/types'; import { ContractAbi, TxData } from '@0xproject/types';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
import * as yargs from 'yargs'; import * as yargs from 'yargs';
@ -23,7 +23,7 @@ export interface ContractNetworkData {
optimizer_enabled: boolean; optimizer_enabled: boolean;
keccak256: string; keccak256: string;
source_tree_hash: string; source_tree_hash: string;
abi: Web3.ContractAbi; abi: ContractAbi;
bytecode: string; bytecode: string;
runtime_bytecode: string; runtime_bytecode: string;
address?: string; address?: string;

View File

@ -1,6 +1,7 @@
{ {
"extends": "../../tsconfig", "extends": "../../tsconfig",
"compilerOptions": { "compilerOptions": {
"typeRoots": ["node_modules/@types"],
"outDir": "lib" "outDir": "lib"
}, },
"include": ["./src/**/*"] "include": ["./src/**/*"]

View File

@ -46,26 +46,25 @@ const docsInfoConfig: DocsInfoConfig = {
typeConfigs: { typeConfigs: {
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
// currently no way to extract the re-exported types from index.ts via TypeDoc :( // currently no way to extract the re-exported types from index.ts via TypeDoc :(
publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'], publicTypes: [
'TxData',
'TransactionReceipt',
'RawLogEntry',
'BlockParam',
'ContractAbi',
'FilterObject',
'LogEntry',
'BlockWithoutTransactionData',
'CallData',
'LogEntryEvent',
],
typeNameToExternalLink: { typeNameToExternalLink: {
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API', Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150', Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127', BigNumber: 'http://mikemcl.github.io/bignumber.js',
LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
BlockWithoutTransactionData:
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
}, },
typeNameToPrefix: { typeNameToPrefix: {
Provider: 'Web3', Provider: 'Web3',
CallData: 'Web3',
BlockWithoutTransactionData: 'Web3',
LogEntry: 'Web3',
FilterObject: 'Web3',
}, },
typeNameToDocSection: { typeNameToDocSection: {
Web3Wrapper: docSections.web3Wrapper, Web3Wrapper: docSections.web3Wrapper,

View File

@ -39,8 +39,9 @@
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": { "dependencies": {
"@0xproject/subproviders": "^0.8.2", "@0xproject/subproviders": "^0.8.2",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.3",
"@0xproject/typescript-typings": "^0.0.1", "@0xproject/typescript-typings": "^0.0.1",
"@0xproject/types": "^0.4.1",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"glob": "^7.1.2", "glob": "^7.1.2",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
@ -48,8 +49,7 @@
"semaphore-async-await": "^1.5.1", "semaphore-async-await": "^1.5.1",
"solidity-coverage": "^0.4.10", "solidity-coverage": "^0.4.10",
"solidity-parser-antlr": "^0.2.7", "solidity-parser-antlr": "^0.2.7",
"solidity-parser-sc": "^0.4.4", "solidity-parser-sc": "^0.4.4"
"web3": "^0.20.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14", "@0xproject/monorepo-scripts": "^0.1.14",
@ -67,8 +67,7 @@
"sinon": "^4.0.0", "sinon": "^4.0.0",
"tslint": "5.8.0", "tslint": "5.8.0",
"typedoc": "0xProject/typedoc", "typedoc": "0xProject/typedoc",
"typescript": "2.7.1", "typescript": "2.7.1"
"web3-typescript-typings": "^0.9.11"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -1,14 +1,14 @@
import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0xproject/subproviders'; import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0xproject/subproviders';
import { BlockParam, CallData, JSONRPCRequestPayload, TransactionTrace, TxData } from '@0xproject/types';
import { promisify } from '@0xproject/utils'; import { promisify } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { Lock } from 'semaphore-async-await'; import { Lock } from 'semaphore-async-await';
import * as Web3 from 'web3';
import { constants } from './constants'; import { constants } from './constants';
import { CoverageManager } from './coverage_manager'; import { CoverageManager } from './coverage_manager';
import { TraceInfoExistingContract, TraceInfoNewContract } from './types'; import { TraceInfoExistingContract, TraceInfoNewContract } from './types';
interface MaybeFakeTxData extends Web3.TxData { interface MaybeFakeTxData extends TxData {
isFakeTransaction?: boolean; isFakeTransaction?: boolean;
} }
@ -58,7 +58,7 @@ export class CoverageSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:prefer-function-over-method // tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: Web3.JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) { public handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
switch (payload.method) { switch (payload.method) {
case 'eth_sendTransaction': case 'eth_sendTransaction':
const txData = payload.params[0]; const txData = payload.params[0];
@ -110,8 +110,8 @@ export class CoverageSubprovider extends Subprovider {
cb(); cb();
} }
private async _onCallExecutedAsync( private async _onCallExecutedAsync(
callData: Partial<Web3.CallData>, callData: Partial<CallData>,
blockNumber: Web3.BlockParam, blockNumber: BlockParam,
err: Error | null, err: Error | null,
callResult: string, callResult: string,
cb: Callback, cb: Callback,
@ -125,7 +125,7 @@ export class CoverageSubprovider extends Subprovider {
params: [txHash, { disableMemory: true, disableStack: true, disableStorage: true }], // TODO For now testrpc just ignores those parameters https://github.com/trufflesuite/ganache-cli/issues/489 params: [txHash, { disableMemory: true, disableStack: true, disableStorage: true }], // TODO For now testrpc just ignores those parameters https://github.com/trufflesuite/ganache-cli/issues/489
}; };
const jsonRPCResponsePayload = await this.emitPayloadAsync(payload); const jsonRPCResponsePayload = await this.emitPayloadAsync(payload);
const trace: Web3.TransactionTrace = jsonRPCResponsePayload.result; const trace: TransactionTrace = jsonRPCResponsePayload.result;
const coveredPcs = _.map(trace.structLogs, log => log.pc); const coveredPcs = _.map(trace.structLogs, log => log.pc);
if (address === constants.NEW_CONTRACT) { if (address === constants.NEW_CONTRACT) {
const traceInfo: TraceInfoNewContract = { const traceInfo: TraceInfoNewContract = {
@ -147,7 +147,7 @@ export class CoverageSubprovider extends Subprovider {
this._coverageManager.appendTraceInfo(traceInfo); this._coverageManager.appendTraceInfo(traceInfo);
} }
} }
private async _recordCallTraceAsync(callData: Partial<Web3.CallData>, blockNumber: Web3.BlockParam): Promise<void> { private async _recordCallTraceAsync(callData: Partial<CallData>, blockNumber: BlockParam): Promise<void> {
// We don't want other transactions to be exeucted during snashotting period, that's why we lock the // We don't want other transactions to be exeucted during snashotting period, that's why we lock the
// transaction execution for all transactions except our fake ones. // transaction execution for all transactions except our fake ones.
await this._lock.acquire(); await this._lock.acquire();

View File

@ -73,11 +73,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider; export = Subprovider;
} }
declare module 'web3-provider-engine/subproviders/rpc' { declare module 'web3-provider-engine/subproviders/rpc' {
import * as Web3 from 'web3'; import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider { class RpcSubprovider {
constructor(options: { rpcUrl: string }); constructor(options: { rpcUrl: string });
public handleRequest( public handleRequest(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: () => void, next: () => void,
end: (err: Error | null, data?: any) => void, end: (err: Error | null, data?: any) => void,
): void; ): void;
@ -102,11 +102,11 @@ declare module 'web3-provider-engine/util/rpc-cache-utils' {
export = ProviderEngineRpcUtils; export = ProviderEngineRpcUtils;
} }
declare module 'web3-provider-engine/subproviders/fixture' { declare module 'web3-provider-engine/subproviders/fixture' {
import * as Web3 from 'web3'; import { JSONRPCRequestPayload } from '@0xproject/types';
class FixtureSubprovider { class FixtureSubprovider {
constructor(staticResponses: any); constructor(staticResponses: any);
public handleRequest( public handleRequest(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: () => void, next: () => void,
end: (err: Error | null, data?: any) => void, end: (err: Error | null, data?: any) => void,
): void; ): void;

View File

@ -1,5 +1,6 @@
import Eth from '@ledgerhq/hw-app-eth'; import Eth from '@ledgerhq/hw-app-eth';
import TransportU2F from '@ledgerhq/hw-transport-u2f'; import TransportU2F from '@ledgerhq/hw-transport-u2f';
export { ECSignature } from '@0xproject/types';
import { LedgerEthereumClient } from './types'; import { LedgerEthereumClient } from './types';
@ -15,7 +16,6 @@ export {
Callback, Callback,
ErrorCallback, ErrorCallback,
NextCallback, NextCallback,
ECSignature,
LedgerWalletSubprovider, LedgerWalletSubprovider,
LedgerCommunicationClient, LedgerCommunicationClient,
NonceSubproviderErrors, NonceSubproviderErrors,

View File

@ -1,4 +1,4 @@
import * as Web3 from 'web3'; import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types'; import { Callback, ErrorCallback } from '../types';
@ -18,7 +18,7 @@ export class EmptyWalletSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:prefer-function-over-method // tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) { switch (payload.method) {
case 'eth_accounts': case 'eth_accounts':
end(null, []); end(null, []);

View File

@ -1,4 +1,4 @@
import * as Web3 from 'web3'; import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types'; import { Callback, ErrorCallback } from '../types';
@ -32,7 +32,7 @@ export class FakeGasEstimateSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:prefer-function-over-method // tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) { switch (payload.method) {
case 'eth_estimateGas': case 'eth_estimateGas':
end(null, this._constantGasAmount); end(null, this._constantGasAmount);

View File

@ -1,3 +1,4 @@
import { JSONRPCRequestPayload } from '@0xproject/types';
import * as Ganache from 'ganache-core'; import * as Ganache from 'ganache-core';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@ -28,7 +29,7 @@ export class GanacheSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:prefer-function-over-method // tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
this._ganacheProvider.sendAsync(payload, (err: Error | null, result: any) => { this._ganacheProvider.sendAsync(payload, (err: Error | null, result: any) => {
end(err, result && result.result); end(err, result && result.result);
}); });

View File

@ -1,3 +1,4 @@
import { JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@ -30,7 +31,7 @@ export class InjectedWeb3Subprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:prefer-function-over-method // tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) { public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) { switch (payload.method) {
case 'web3_clientVersion': case 'web3_clientVersion':
this._injectedWeb3.version.getNode(end); this._injectedWeb3.version.getNode(end);

View File

@ -1,11 +1,11 @@
import { assert } from '@0xproject/assert'; import { assert } from '@0xproject/assert';
import { JSONRPCRequestPayload } from '@0xproject/types';
import { addressUtils } from '@0xproject/utils'; import { addressUtils } from '@0xproject/utils';
import EthereumTx = require('ethereumjs-tx'); import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util'); import ethUtil = require('ethereumjs-util');
import HDNode = require('hdkey'); import HDNode = require('hdkey');
import * as _ from 'lodash'; import * as _ from 'lodash';
import { Lock } from 'semaphore-async-await'; import { Lock } from 'semaphore-async-await';
import * as Web3 from 'web3';
import { import {
Callback, Callback,
@ -208,7 +208,7 @@ export class LedgerSubprovider extends Subprovider {
*/ */
// tslint:disable-next-line:async-suffix // tslint:disable-next-line:async-suffix
public async handleRequest( public async handleRequest(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: Callback, next: Callback,
end: (err: Error | null, result?: any) => void, end: (err: Error | null, result?: any) => void,
) { ) {

View File

@ -1,9 +1,8 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { BlockParamLiteral } from '@0xproject/types'; import { BlockParamLiteral, JSONRPCRequestPayload } from '@0xproject/types';
import EthereumTx = require('ethereumjs-tx'); import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util'); import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
import providerEngineUtils = require('web3-provider-engine/util/rpc-cache-utils'); import providerEngineUtils = require('web3-provider-engine/util/rpc-cache-utils');
import { Callback, ErrorCallback, NextCallback, NonceSubproviderErrors } from '../types'; import { Callback, ErrorCallback, NextCallback, NonceSubproviderErrors } from '../types';
@ -19,7 +18,7 @@ const NONCE_TOO_LOW_ERROR_MESSAGE = 'Transaction nonce is too low';
*/ */
export class NonceTrackerSubprovider extends Subprovider { export class NonceTrackerSubprovider extends Subprovider {
private _nonceCache: { [address: string]: string } = {}; private _nonceCache: { [address: string]: string } = {};
private static _reconstructTransaction(payload: Web3.JSONRPCRequestPayload): EthereumTx { private static _reconstructTransaction(payload: JSONRPCRequestPayload): EthereumTx {
const raw = payload.params[0]; const raw = payload.params[0];
if (_.isUndefined(raw)) { if (_.isUndefined(raw)) {
throw new Error(NonceSubproviderErrors.EmptyParametersFound); throw new Error(NonceSubproviderErrors.EmptyParametersFound);
@ -28,7 +27,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const transaction = new EthereumTx(rawData); const transaction = new EthereumTx(rawData);
return transaction; return transaction;
} }
private static _determineAddress(payload: Web3.JSONRPCRequestPayload): string { private static _determineAddress(payload: JSONRPCRequestPayload): string {
let address: string; let address: string;
switch (payload.method) { switch (payload.method) {
case 'eth_getTransactionCount': case 'eth_getTransactionCount':
@ -55,11 +54,7 @@ export class NonceTrackerSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request. * @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/ */
// tslint:disable-next-line:async-suffix // tslint:disable-next-line:async-suffix
public async handleRequest( public async handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback): Promise<void> {
payload: Web3.JSONRPCRequestPayload,
next: NextCallback,
end: ErrorCallback,
): Promise<void> {
switch (payload.method) { switch (payload.method) {
case 'eth_getTransactionCount': case 'eth_getTransactionCount':
const requestDefaultBlock = providerEngineUtils.blockTagForPayload(payload); const requestDefaultBlock = providerEngineUtils.blockTagForPayload(payload);
@ -92,7 +87,7 @@ export class NonceTrackerSubprovider extends Subprovider {
return next(); return next();
} }
} }
private _handleSuccessfulTransaction(payload: Web3.JSONRPCRequestPayload): void { private _handleSuccessfulTransaction(payload: JSONRPCRequestPayload): void {
const address = NonceTrackerSubprovider._determineAddress(payload); const address = NonceTrackerSubprovider._determineAddress(payload);
const transaction = NonceTrackerSubprovider._reconstructTransaction(payload); const transaction = NonceTrackerSubprovider._reconstructTransaction(payload);
// Increment the nonce from the previous successfully submitted transaction // Increment the nonce from the previous successfully submitted transaction
@ -105,7 +100,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const nextPrefixedHexNonce = `0x${nextHexNonce}`; const nextPrefixedHexNonce = `0x${nextHexNonce}`;
this._nonceCache[address] = nextPrefixedHexNonce; this._nonceCache[address] = nextPrefixedHexNonce;
} }
private _handleSendTransactionError(payload: Web3.JSONRPCRequestPayload, err: Error): void { private _handleSendTransactionError(payload: JSONRPCRequestPayload, err: Error): void {
const address = NonceTrackerSubprovider._determineAddress(payload); const address = NonceTrackerSubprovider._determineAddress(payload);
if (this._nonceCache[address] && _.includes(err.message, NONCE_TOO_LOW_ERROR_MESSAGE)) { if (this._nonceCache[address] && _.includes(err.message, NONCE_TOO_LOW_ERROR_MESSAGE)) {
delete this._nonceCache[address]; delete this._nonceCache[address];

View File

@ -1,6 +1,6 @@
import { JSONRPCRequestPayload } from '@0xproject/types';
import { promisify } from '@0xproject/utils'; import { promisify } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { Callback } from '../types'; import { Callback } from '../types';
@ -16,7 +16,7 @@ export class RedundantRPCSubprovider extends Subprovider {
private _rpcs: RpcSubprovider[]; private _rpcs: RpcSubprovider[];
private static async _firstSuccessAsync( private static async _firstSuccessAsync(
rpcs: RpcSubprovider[], rpcs: RpcSubprovider[],
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: Callback, next: Callback,
): Promise<any> { ): Promise<any> {
let lastErr: Error | undefined; let lastErr: Error | undefined;
@ -55,7 +55,7 @@ export class RedundantRPCSubprovider extends Subprovider {
*/ */
// tslint:disable-next-line:async-suffix // tslint:disable-next-line:async-suffix
public async handleRequest( public async handleRequest(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: Callback, next: Callback,
end: (err: Error | null, data?: any) => void, end: (err: Error | null, data?: any) => void,
): Promise<void> { ): Promise<void> {

View File

@ -1,3 +1,4 @@
import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import promisify = require('es6-promisify'); import promisify = require('es6-promisify');
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@ -37,9 +38,7 @@ export class Subprovider {
* @param payload JSON RPC payload * @param payload JSON RPC payload
* @returns JSON RPC response payload * @returns JSON RPC response payload
*/ */
public async emitPayloadAsync( public async emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload> {
payload: Partial<JSONRPCRequestPayloadWithMethod>,
): Promise<Web3.JSONRPCResponsePayload> {
const finalPayload = Subprovider._createFinalPayload(payload); const finalPayload = Subprovider._createFinalPayload(payload);
const response = await promisify(this._engine.sendAsync, this._engine)(finalPayload); const response = await promisify(this._engine.sendAsync, this._engine)(finalPayload);
return response; return response;

View File

@ -1,8 +1,5 @@
import { ECSignature } from '@0xproject/types'; import { ECSignature, JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
export { ECSignature } from '@0xproject/types';
export interface LedgerCommunicationClient { export interface LedgerCommunicationClient {
close: () => Promise<void>; close: () => Promise<void>;
@ -116,6 +113,6 @@ export type Callback = () => void;
export type OnNextCompleted = (err: Error | null, result: any, cb: Callback) => void; export type OnNextCompleted = (err: Error | null, result: any, cb: Callback) => void;
export type NextCallback = (callback?: OnNextCompleted) => void; export type NextCallback = (callback?: OnNextCompleted) => void;
export interface JSONRPCRequestPayloadWithMethod extends Web3.JSONRPCRequestPayload { export interface JSONRPCRequestPayloadWithMethod extends JSONRPCRequestPayload {
method: string; method: string;
} }

View File

@ -1,3 +1,4 @@
import { JSONRPCResponsePayload } from '@0xproject/types';
import Eth from '@ledgerhq/hw-app-eth'; import Eth from '@ledgerhq/hw-app-eth';
// HACK: This depdency is optional and tslint skips optional depdencies // HACK: This depdency is optional and tslint skips optional depdencies
// tslint:disable-next-line:no-implicit-dependencies // tslint:disable-next-line:no-implicit-dependencies
@ -97,7 +98,7 @@ describe('LedgerSubprovider', () => {
params: [], params: [],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10); expect(response.result.length).to.be.equal(10);
done(); done();
@ -115,7 +116,7 @@ describe('LedgerSubprovider', () => {
params: [signer, messageHex], params: [signer, messageHex],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(132); expect(response.result.length).to.be.equal(132);
expect(response.result.substr(0, 2)).to.be.equal('0x'); expect(response.result.substr(0, 2)).to.be.equal('0x');
@ -135,7 +136,7 @@ describe('LedgerSubprovider', () => {
params: [messageHex, signer], params: [messageHex, signer],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(132); expect(response.result.length).to.be.equal(132);
expect(response.result.substr(0, 2)).to.be.equal('0x'); expect(response.result.substr(0, 2)).to.be.equal('0x');
@ -155,7 +156,7 @@ describe('LedgerSubprovider', () => {
params: [tx], params: [tx],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.raw.length).to.be.equal(206); expect(response.result.raw.length).to.be.equal(206);
expect(response.result.raw.substr(0, 2)).to.be.equal('0x'); expect(response.result.raw.substr(0, 2)).to.be.equal('0x');
@ -193,7 +194,7 @@ describe('LedgerSubprovider', () => {
params: [tx], params: [tx],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
const result = response.result; const result = response.result;
expect(result.length).to.be.equal(66); expect(result.length).to.be.equal(66);

View File

@ -1,3 +1,4 @@
import { JSONRPCResponsePayload } from '@0xproject/types';
import * as chai from 'chai'; import * as chai from 'chai';
import * as ethUtils from 'ethereumjs-util'; import * as ethUtils from 'ethereumjs-util';
import * as _ from 'lodash'; import * as _ from 'lodash';
@ -112,7 +113,7 @@ describe('LedgerSubprovider', () => {
params: [], params: [],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10); expect(response.result.length).to.be.equal(10);
expect(response.result[0]).to.be.equal(FAKE_ADDRESS); expect(response.result[0]).to.be.equal(FAKE_ADDRESS);
@ -128,7 +129,7 @@ describe('LedgerSubprovider', () => {
params: ['0x0000000000000000000000000000000000000000', messageHex], params: ['0x0000000000000000000000000000000000000000', messageHex],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result).to.be.equal( expect(response.result).to.be.equal(
'0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001', '0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001',
@ -145,7 +146,7 @@ describe('LedgerSubprovider', () => {
params: [messageHex, '0x0000000000000000000000000000000000000000'], params: [messageHex, '0x0000000000000000000000000000000000000000'],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result).to.be.equal( expect(response.result).to.be.equal(
'0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001', '0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001',
@ -168,7 +169,7 @@ describe('LedgerSubprovider', () => {
params: [tx], params: [tx],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.raw.length).to.be.equal(192); expect(response.result.raw.length).to.be.equal(192);
expect(response.result.raw.substr(0, 2)).to.be.equal('0x'); expect(response.result.raw.substr(0, 2)).to.be.equal('0x');
@ -186,7 +187,7 @@ describe('LedgerSubprovider', () => {
params: ['0x0000000000000000000000000000000000000000', nonHexMessage], params: ['0x0000000000000000000000000000000000000000', nonHexMessage],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null'); expect(err).to.not.be.a('null');
expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world');
done(); done();
@ -201,7 +202,7 @@ describe('LedgerSubprovider', () => {
params: [nonHexMessage, '0x0000000000000000000000000000000000000000'], params: [nonHexMessage, '0x0000000000000000000000000000000000000000'],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null'); expect(err).to.not.be.a('null');
expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world'); expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world');
done(); done();
@ -219,7 +220,7 @@ describe('LedgerSubprovider', () => {
params: [tx], params: [tx],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null'); expect(err).to.not.be.a('null');
expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied); expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied);
done(); done();
@ -238,7 +239,7 @@ describe('LedgerSubprovider', () => {
params: [tx], params: [tx],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null'); expect(err).to.not.be.a('null');
expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied); expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied);
done(); done();

View File

@ -1,3 +1,4 @@
import { JSONRPCResponsePayload } from '@0xproject/types';
import * as chai from 'chai'; import * as chai from 'chai';
import * as _ from 'lodash'; import * as _ from 'lodash';
import Web3 = require('web3'); import Web3 = require('web3');
@ -26,7 +27,7 @@ describe('RedundantRpcSubprovider', () => {
params: [], params: [],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10); expect(response.result.length).to.be.equal(10);
done(); done();
@ -46,7 +47,7 @@ describe('RedundantRpcSubprovider', () => {
params: [], params: [],
id: 1, id: 1,
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10); expect(response.result.length).to.be.equal(10);
done(); done();

View File

@ -1,6 +1,7 @@
{ {
"extends": "../../tsconfig", "extends": "../../tsconfig",
"compilerOptions": { "compilerOptions": {
"typeRoots": ["node_modules/@types"],
"outDir": "lib" "outDir": "lib"
}, },
"include": ["./rules/**/*", "./monorepo_scripts/**/*"] "include": ["./rules/**/*", "./monorepo_scripts/**/*"]

View File

@ -22,15 +22,14 @@
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14", "@0xproject/monorepo-scripts": "^0.1.14",
"@0xproject/tslint-config": "^0.4.12", "@0xproject/tslint-config": "^0.4.12",
"@types/node": "^8.0.53",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/typescript-typings": "^0.0.1", "bignumber.js": "~4.1.0"
"bignumber.js": "~4.1.0",
"web3": "^0.20.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -1,14 +1,195 @@
import { BigNumber } from 'bignumber.js'; import { BigNumber } from 'bignumber.js';
import * as Web3 from 'web3';
export interface TxData { export type ContractAbi = AbiDefinition[];
export type AbiDefinition = FunctionAbi | EventAbi;
export type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
export type ConstructorStateMutability = 'nonpayable' | 'payable';
export type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
export interface MethodAbi {
type: AbiType.Function;
name: string;
inputs: DataItem[];
outputs: DataItem[];
constant: boolean;
stateMutability: StateMutability;
payable: boolean;
}
export interface ConstructorAbi {
type: AbiType.Constructor;
inputs: DataItem[];
payable: boolean;
stateMutability: ConstructorStateMutability;
}
export interface FallbackAbi {
type: AbiType.Fallback;
payable: boolean;
}
export interface EventParameter extends DataItem {
indexed: boolean;
}
export interface EventAbi {
type: AbiType.Event;
name: string;
inputs: EventParameter[];
anonymous: boolean;
}
export interface DataItem {
name: string;
type: string;
components: DataItem[];
}
export type OpCode = string;
export interface StructLog {
depth: number;
error: string;
gas: number;
gasCost: number;
memory: string[];
op: OpCode;
pc: number;
stack: string[];
storage: { [location: string]: string };
}
export interface TransactionTrace {
gas: number;
returnValue: any;
structLogs: StructLog[];
}
export type Unit =
| 'kwei'
| 'ada'
| 'mwei'
| 'babbage'
| 'gwei'
| 'shannon'
| 'szabo'
| 'finney'
| 'ether'
| 'kether'
| 'grand'
| 'einstein'
| 'mether'
| 'gether'
| 'tether';
export interface JSONRPCRequestPayload {
params: any[];
method: string;
id: number;
jsonrpc: string;
}
export interface JSONRPCResponsePayload {
result: any;
id: number;
jsonrpc: string;
}
export interface AbstractBlock {
number: number | null;
hash: string | null;
parentHash: string;
nonce: string | null;
sha3Uncles: string;
logsBloom: string | null;
transactionsRoot: string;
stateRoot: string;
miner: string;
difficulty: BigNumber;
totalDifficulty: BigNumber;
extraData: string;
size: number;
gasLimit: number;
gasUsed: number;
timestamp: number;
uncles: string[];
}
export interface BlockWithoutTransactionData extends AbstractBlock {
transactions: string[];
}
export interface BlockWithTransactionData extends AbstractBlock {
transactions: Transaction[];
}
export interface Transaction {
hash: string;
nonce: number;
blockHash: string | null;
blockNumber: number | null;
transactionIndex: number | null;
from: string;
to: string | null;
value: BigNumber;
gasPrice: BigNumber;
gas: number;
input: string;
}
export interface CallTxDataBase {
to?: string;
value?: number | string | BigNumber;
gas?: number | string | BigNumber;
gasPrice?: number | string | BigNumber;
data?: string; data?: string;
from?: string;
gas?: number;
gasPrice?: BigNumber;
nonce?: number; nonce?: number;
} }
export interface TxData extends CallTxDataBase {
from: string;
}
export interface CallData extends CallTxDataBase {
from?: string;
}
export interface FilterObject {
fromBlock?: number | string;
toBlock?: number | string;
address?: string;
topics?: LogTopic[];
}
export type LogTopic = null | string | string[];
export interface DecodedLogEntry<A> extends LogEntry {
event: string;
args: A;
}
export interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
removed: boolean;
}
export interface LogEntryEvent extends LogEntry {
removed: boolean;
}
export interface LogEntry {
logIndex: number | null;
transactionIndex: number | null;
transactionHash: string;
blockHash: string | null;
blockNumber: number | null;
address: string;
data: string;
topics: string[];
}
export interface TxDataPayable extends TxData { export interface TxDataPayable extends TxData {
value?: BigNumber; value?: BigNumber;
} }
@ -20,11 +201,11 @@ export interface TransactionReceipt {
transactionIndex: number; transactionIndex: number;
from: string; from: string;
to: string; to: string;
status: null | 0 | 1; status: null | string | 0 | 1;
cumulativeGasUsed: number; cumulativeGasUsed: number;
gasUsed: number; gasUsed: number;
contractAddress: string | null; contractAddress: string | null;
logs: Web3.LogEntry[]; logs: LogEntry[];
} }
export enum AbiType { export enum AbiType {
@ -40,8 +221,8 @@ export interface DecodedLogArgs {
[argName: string]: ContractEventArg; [argName: string]: ContractEventArg;
} }
export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {} export interface LogWithDecodedArgs<ArgsType> extends DecodedLogEntry<ArgsType> {}
export type RawLog = Web3.LogEntry; export type RawLog = LogEntry;
export enum SolidityTypes { export enum SolidityTypes {
Address = 'address', Address = 'address',
Uint256 = 'uint256', Uint256 = 'uint256',
@ -50,7 +231,7 @@ export enum SolidityTypes {
} }
export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt { export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt {
logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>; logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>;
} }
// Earliest is omitted by design. It is simply an alias for the `0` constant and // Earliest is omitted by design. It is simply an alias for the `0` constant and

View File

@ -1,6 +1,7 @@
{ {
"extends": "../../tsconfig", "extends": "../../tsconfig",
"compilerOptions": { "compilerOptions": {
"typeRoots": ["node_modules/@types"],
"outDir": "lib" "outDir": "lib"
}, },
"include": ["./src/**/*"] "include": ["./src/**/*"]

View File

@ -20,6 +20,7 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/typescript-typings#readme", "homepage": "https://github.com/0xProject/0x-monorepo/packages/typescript-typings#readme",
"dependencies": { "dependencies": {
"@0xproject/types": "^0.4.1",
"bignumber.js": "~4.1.0" "bignumber.js": "~4.1.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,21 @@
declare module 'web3' { declare module 'web3' {
import * as BigNumber from 'bignumber.js'; import * as BigNumber from 'bignumber.js';
import {
AbiDefinition,
BlockWithTransactionData,
BlockWithoutTransactionData,
BlockParam,
CallData,
Unit,
TxData,
Transaction,
ContractAbi,
TransactionReceipt,
FilterObject,
LogEntryEvent,
JSONRPCRequestPayload,
JSONRPCResponsePayload,
} from '@0xproject/types';
type MixedData = string | number | object | any[] | BigNumber.BigNumber; type MixedData = string | number | object | any[] | BigNumber.BigNumber;
@ -22,10 +38,10 @@ declare module 'web3' {
public fromAscii(ascii: string, padding?: number): string; public fromAscii(ascii: string, padding?: number): string;
public toDecimal(hex: string): number; public toDecimal(hex: string): number;
public fromDecimal(value: number | string): string; public fromDecimal(value: number | string): string;
public fromWei(value: number | string, unit: Web3.Unit): string; public fromWei(value: number | string, unit: Unit): string;
public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; public fromWei(value: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber;
public toWei(amount: number | string, unit: Web3.Unit): string; public toWei(amount: number | string, unit: Unit): string;
public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; public toWei(amount: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber;
public toBigNumber(value: number | string): BigNumber.BigNumber; public toBigNumber(value: number | string): BigNumber.BigNumber;
public isAddress(address: string): boolean; public isAddress(address: string): boolean;
public isChecksumAddress(address: string): boolean; public isChecksumAddress(address: string): boolean;
@ -36,71 +52,16 @@ declare module 'web3' {
class HttpProvider implements Web3.Provider { class HttpProvider implements Web3.Provider {
constructor(url?: string, timeout?: number, username?: string, password?: string); constructor(url?: string, timeout?: number, username?: string, password?: string);
public sendAsync( public sendAsync(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void, callback: (err: Error, result: JSONRPCResponsePayload) => void,
): void; ): void;
} }
} }
namespace Web3 { namespace Web3 {
type ContractAbi = AbiDefinition[];
type AbiDefinition = FunctionAbi | EventAbi;
type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
enum AbiType {
Function = 'function',
Constructor = 'constructor',
Event = 'event',
Fallback = 'fallback',
}
type ConstructorStateMutability = 'nonpayable' | 'payable';
type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
interface MethodAbi {
type: AbiType.Function;
name: string;
inputs: DataItem[];
outputs: DataItem[];
constant: boolean;
stateMutability: StateMutability;
payable: boolean;
}
interface ConstructorAbi {
type: AbiType.Constructor;
inputs: DataItem[];
payable: boolean;
stateMutability: ConstructorStateMutability;
}
interface FallbackAbi {
type: AbiType.Fallback;
payable: boolean;
}
interface EventParameter extends DataItem {
indexed: boolean;
}
interface EventAbi {
type: AbiType.Event;
name: string;
inputs: EventParameter[];
anonymous: boolean;
}
interface DataItem {
name: string;
type: string;
components: DataItem[];
}
interface ContractInstance { interface ContractInstance {
address: string; address: string;
abi: Web3.ContractAbi; abi: ContractAbi;
[name: string]: any; [name: string]: any;
} }
@ -110,66 +71,12 @@ declare module 'web3' {
'new'(...args: any[]): A; 'new'(...args: any[]): A;
} }
interface FilterObject {
fromBlock?: number | string;
toBlock?: number | string;
address?: string;
topics?: LogTopic[];
}
type LogTopic = null | string | string[];
interface DecodedLogEntry<A> extends LogEntry {
event: string;
args: A;
}
interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
removed: boolean;
}
interface LogEntryEvent extends LogEntry {
removed: boolean;
}
interface FilterResult { interface FilterResult {
get(callback: () => void): void; get(callback: () => void): void;
watch(callback: (err: Error, result: LogEntryEvent) => void): void; watch(callback: (err: Error, result: LogEntryEvent) => void): void;
stopWatching(callback?: () => void): void; stopWatching(callback?: () => void): void;
} }
export interface JSONRPCRequestPayload {
params: any[];
method: string;
id: number;
jsonrpc: string;
}
export interface JSONRPCResponsePayload {
result: any;
id: number;
jsonrpc: string;
}
export type OpCode = string;
export interface StructLog {
depth: number;
error: string;
gas: number;
gasCost: number;
memory: string[];
op: OpCode;
pc: number;
stack: string[];
storage: { [location: string]: string };
}
export interface TransactionTrace {
gas: number;
returnValue: any;
structLogs: StructLog[];
}
interface Provider { interface Provider {
sendAsync( sendAsync(
payload: JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
@ -189,7 +96,7 @@ declare module 'web3' {
accounts: string[]; accounts: string[];
blockNumber: number; blockNumber: number;
defaultAccount?: string; defaultAccount?: string;
defaultBlock: Web3.BlockParam; defaultBlock: BlockParam;
syncing: Web3.SyncingResult; syncing: Web3.SyncingResult;
compile: { compile: {
solidity(sourceString: string, cb?: (err: Error, result: any) => void): object; solidity(sourceString: string, cb?: (err: Error, result: any) => void): object;
@ -202,55 +109,46 @@ declare module 'web3' {
getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void; getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void;
isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing; isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing;
getBlock(hashStringOrBlockNumber: string | Web3.BlockParam): Web3.BlockWithoutTransactionData; getBlock(hashStringOrBlockNumber: string | BlockParam): BlockWithoutTransactionData;
getBlock( getBlock(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void, callback: (err: Error, blockObj: BlockWithoutTransactionData) => void,
): void; ): void;
getBlock( getBlock(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
returnTransactionObjects: true, returnTransactionObjects: true,
): Web3.BlockWithTransactionData; ): BlockWithTransactionData;
getBlock( getBlock(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
returnTransactionObjects: true, returnTransactionObjects: true,
callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void, callback: (err: Error, blockObj: BlockWithTransactionData) => void,
): void; ): void;
getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number; getBlockTransactionCount(hashStringOrBlockNumber: string | BlockParam): number;
getBlockTransactionCount( getBlockTransactionCount(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
callback: (err: Error, blockTransactionCount: number) => void, callback: (err: Error, blockTransactionCount: number) => void,
): void; ): void;
// TODO returnTransactionObjects // TODO returnTransactionObjects
getUncle(hashStringOrBlockNumber: string | BlockParam, uncleNumber: number): BlockWithoutTransactionData;
getUncle( getUncle(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
uncleNumber: number, uncleNumber: number,
): Web3.BlockWithoutTransactionData; callback: (err: Error, uncle: BlockWithoutTransactionData) => void,
getUncle(
hashStringOrBlockNumber: string | Web3.BlockParam,
uncleNumber: number,
callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void,
): void; ): void;
getTransaction(transactionHash: string): Web3.Transaction; getTransaction(transactionHash: string): Transaction;
getTransaction( getTransaction(transactionHash: string, callback: (err: Error, transaction: Transaction) => void): void;
transactionHash: string,
callback: (err: Error, transaction: Web3.Transaction) => void,
): void;
getTransactionFromBlock(hashStringOrBlockNumber: string | BlockParam, indexNumber: number): Transaction;
getTransactionFromBlock( getTransactionFromBlock(
hashStringOrBlockNumber: string | Web3.BlockParam, hashStringOrBlockNumber: string | BlockParam,
indexNumber: number, indexNumber: number,
): Web3.Transaction; callback: (err: Error, transaction: Transaction) => void,
getTransactionFromBlock(
hashStringOrBlockNumber: string | Web3.BlockParam,
indexNumber: number,
callback: (err: Error, transaction: Web3.Transaction) => void,
): void; ): void;
contract(abi: Web3.AbiDefinition[]): Web3.Contract<any>; contract(abi: AbiDefinition[]): Web3.Contract<any>;
// TODO block param // TODO block param
getBalance(addressHexString: string): BigNumber.BigNumber; getBalance(addressHexString: string): BigNumber.BigNumber;
@ -264,10 +162,10 @@ declare module 'web3' {
getCode(addressHexString: string): string; getCode(addressHexString: string): string;
getCode(addressHexString: string, callback: (err: Error, code: string) => void): void; getCode(addressHexString: string, callback: (err: Error, code: string) => void): void;
filter(value: string | Web3.FilterObject): Web3.FilterResult; filter(value: string | FilterObject): Web3.FilterResult;
sendTransaction(txData: Web3.TxData): string; sendTransaction(txData: TxData): string;
sendTransaction(txData: Web3.TxData, callback: (err: Error, value: string) => void): void; sendTransaction(txData: TxData, callback: (err: Error, value: string) => void): void;
sendRawTransaction(rawTxData: string): string; sendRawTransaction(rawTxData: string): string;
sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void; sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void;
@ -275,18 +173,18 @@ declare module 'web3' {
sign(address: string, data: string): string; sign(address: string, data: string): string;
sign(address: string, data: string, callback: (err: Error, signature: string) => void): void; sign(address: string, data: string, callback: (err: Error, signature: string) => void): void;
getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null; getTransactionReceipt(txHash: string): TransactionReceipt | null;
getTransactionReceipt( getTransactionReceipt(
txHash: string, txHash: string,
callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void, callback: (err: Error, receipt: TransactionReceipt | null) => void,
): void; ): void;
// TODO block param // TODO block param
call(callData: Web3.CallData): string; call(callData: CallData): string;
call(callData: Web3.CallData, callback: (err: Error, result: string) => void): void; call(callData: CallData, callback: (err: Error, result: string) => void): void;
estimateGas(callData: Web3.CallData): number; estimateGas(callData: CallData): number;
estimateGas(callData: Web3.CallData, callback: (err: Error, gas: number) => void): void; estimateGas(callData: CallData, callback: (err: Error, gas: number) => void): void;
// TODO defaultBlock // TODO defaultBlock
getTransactionCount(address: string): number; getTransactionCount(address: string): number;
@ -321,25 +219,6 @@ declare module 'web3' {
getPeerCount(cd: (err: Error, peerCount: number) => void): void; getPeerCount(cd: (err: Error, peerCount: number) => void): void;
} }
type BlockParam = number | 'earliest' | 'latest' | 'pending';
type Unit =
| 'kwei'
| 'ada'
| 'mwei'
| 'babbage'
| 'gwei'
| 'shannon'
| 'szabo'
| 'finney'
| 'ether'
| 'kether'
| 'grand'
| 'einstein'
| 'mether'
| 'gether'
| 'tether';
interface SyncingState { interface SyncingState {
startingBlock: number; startingBlock: number;
currentBlock: number; currentBlock: number;
@ -351,88 +230,6 @@ declare module 'web3' {
addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void; addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void;
stopWatching(): void; stopWatching(): void;
} }
interface AbstractBlock {
number: number | null;
hash: string | null;
parentHash: string;
nonce: string | null;
sha3Uncles: string;
logsBloom: string | null;
transactionsRoot: string;
stateRoot: string;
miner: string;
difficulty: BigNumber.BigNumber;
totalDifficulty: BigNumber.BigNumber;
extraData: string;
size: number;
gasLimit: number;
gasUsed: number;
timestamp: number;
uncles: string[];
}
interface BlockWithoutTransactionData extends AbstractBlock {
transactions: string[];
}
interface BlockWithTransactionData extends AbstractBlock {
transactions: Transaction[];
}
interface Transaction {
hash: string;
nonce: number;
blockHash: string | null;
blockNumber: number | null;
transactionIndex: number | null;
from: string;
to: string | null;
value: BigNumber.BigNumber;
gasPrice: BigNumber.BigNumber;
gas: number;
input: string;
}
interface CallTxDataBase {
to?: string;
value?: number | string | BigNumber.BigNumber;
gas?: number | string | BigNumber.BigNumber;
gasPrice?: number | string | BigNumber.BigNumber;
data?: string;
nonce?: number;
}
interface TxData extends CallTxDataBase {
from: string;
}
interface CallData extends CallTxDataBase {
from?: string;
}
interface TransactionReceipt {
blockHash: string;
blockNumber: number;
transactionHash: string;
transactionIndex: number;
from: string;
to: string;
status: null | string | 0 | 1;
cumulativeGasUsed: number;
gasUsed: number;
contractAddress: string | null;
logs: LogEntry[];
}
interface LogEntry {
logIndex: number | null;
transactionIndex: number | null;
transactionHash: string;
blockHash: string | null;
blockNumber: number | null;
address: string;
data: string;
topics: string[];
}
} }
/* tslint:disable */ /* tslint:disable */
export = Web3; export = Web3;

View File

@ -1,13 +1,22 @@
import { AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes } from '@0xproject/types'; import {
AbiDefinition,
AbiType,
DecodedLogArgs,
EventAbi,
EventParameter,
LogEntry,
LogWithDecodedArgs,
RawLog,
SolidityTypes,
} from '@0xproject/types';
import * as ethersContracts from 'ethers-contracts'; import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3';
import { BigNumber } from './configured_bignumber'; import { BigNumber } from './configured_bignumber';
export class AbiDecoder { export class AbiDecoder {
private _savedABIs: Web3.AbiDefinition[] = []; private _savedABIs: AbiDefinition[] = [];
private _methodIds: { [signatureHash: string]: Web3.EventAbi } = {}; private _methodIds: { [signatureHash: string]: EventAbi } = {};
private static _padZeros(address: string) { private static _padZeros(address: string) {
let formatted = address; let formatted = address;
if (_.startsWith(formatted, '0x')) { if (_.startsWith(formatted, '0x')) {
@ -17,11 +26,11 @@ export class AbiDecoder {
formatted = _.padStart(formatted, 40, '0'); formatted = _.padStart(formatted, 40, '0');
return `0x${formatted}`; return `0x${formatted}`;
} }
constructor(abiArrays: Web3.AbiDefinition[][]) { constructor(abiArrays: AbiDefinition[][]) {
_.forEach(abiArrays, this._addABI.bind(this)); _.forEach(abiArrays, this._addABI.bind(this));
} }
// This method can only decode logs from the 0x & ERC20 smart contracts // This method can only decode logs from the 0x & ERC20 smart contracts
public tryToDecodeLogOrNoop<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { public tryToDecodeLogOrNoop<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
const methodId = log.topics[0]; const methodId = log.topics[0];
const event = this._methodIds[methodId]; const event = this._methodIds[methodId];
if (_.isUndefined(event)) { if (_.isUndefined(event)) {
@ -37,7 +46,7 @@ export class AbiDecoder {
const decodedData = ethersInterface.events[event.name].parse(log.data); const decodedData = ethersInterface.events[event.name].parse(log.data);
let failedToDecode = false; let failedToDecode = false;
_.forEach(event.inputs, (param: Web3.EventParameter, i: number) => { _.forEach(event.inputs, (param: EventParameter, i: number) => {
// Indexed parameters are stored in topics. Non-indexed ones in decodedData // Indexed parameters are stored in topics. Non-indexed ones in decodedData
let value: BigNumber | string | number = param.indexed ? log.topics[topicsIndex++] : decodedData[i]; let value: BigNumber | string | number = param.indexed ? log.topics[topicsIndex++] : decodedData[i];
if (_.isUndefined(value)) { if (_.isUndefined(value)) {
@ -64,12 +73,12 @@ export class AbiDecoder {
}; };
} }
} }
private _addABI(abiArray: Web3.AbiDefinition[]): void { private _addABI(abiArray: AbiDefinition[]): void {
if (_.isUndefined(abiArray)) { if (_.isUndefined(abiArray)) {
return; return;
} }
const ethersInterface = new ethersContracts.Interface(abiArray); const ethersInterface = new ethersContracts.Interface(abiArray);
_.map(abiArray, (abi: Web3.AbiDefinition) => { _.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) { if (abi.type === AbiType.Event) {
const topic = ethersInterface.events[abi.name].topic; const topic = ethersInterface.events[abi.name].topic;
this._methodIds[topic] = abi; this._methodIds[topic] = abi;

View File

@ -1,4 +1,16 @@
import { RawLogEntry, TransactionReceipt, TxData } from '@0xproject/types'; import {
BlockParam,
BlockWithoutTransactionData,
CallData,
ContractAbi,
FilterObject,
JSONRPCRequestPayload,
JSONRPCResponsePayload,
LogEntry,
RawLogEntry,
TransactionReceipt,
TxData,
} from '@0xproject/types';
import { BigNumber, promisify } from '@0xproject/utils'; import { BigNumber, promisify } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@ -157,8 +169,8 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The requested block without transaction data * @returns The requested block without transaction data
*/ */
public async getBlockAsync(blockParam: string | Web3.BlockParam): Promise<Web3.BlockWithoutTransactionData> { public async getBlockAsync(blockParam: string | BlockParam): Promise<BlockWithoutTransactionData> {
const block = await promisify<Web3.BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam); const block = await promisify<BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
return block; return block;
} }
/** /**
@ -166,7 +178,7 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral) * @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The block's timestamp * @returns The block's timestamp
*/ */
public async getBlockTimestampAsync(blockParam: string | Web3.BlockParam): Promise<number> { public async getBlockTimestampAsync(blockParam: string | BlockParam): Promise<number> {
const { timestamp } = await this.getBlockAsync(blockParam); const { timestamp } = await this.getBlockAsync(blockParam);
return timestamp; return timestamp;
} }
@ -214,7 +226,7 @@ export class Web3Wrapper {
* @param filter Parameters by which to filter which logs to retrieve * @param filter Parameters by which to filter which logs to retrieve
* @returns The corresponding log entries * @returns The corresponding log entries
*/ */
public async getLogsAsync(filter: Web3.FilterObject): Promise<Web3.LogEntry[]> { public async getLogsAsync(filter: FilterObject): Promise<LogEntry[]> {
let fromBlock = filter.fromBlock; let fromBlock = filter.fromBlock;
if (_.isNumber(fromBlock)) { if (_.isNumber(fromBlock)) {
fromBlock = this._web3.toHex(fromBlock); fromBlock = this._web3.toHex(fromBlock);
@ -243,7 +255,7 @@ export class Web3Wrapper {
* @param abi Smart contract ABI * @param abi Smart contract ABI
* @returns Web3 contract factory which can create Web3 Contract instances from the supplied ABI * @returns Web3 contract factory which can create Web3 Contract instances from the supplied ABI
*/ */
public getContractFromAbi(abi: Web3.ContractAbi): Web3.Contract<any> { public getContractFromAbi(abi: ContractAbi): Web3.Contract<any> {
const web3Contract = this._web3.eth.contract(abi); const web3Contract = this._web3.eth.contract(abi);
return web3Contract; return web3Contract;
} }
@ -252,7 +264,7 @@ export class Web3Wrapper {
* @param txData Transaction data * @param txData Transaction data
* @returns Estimated gas cost * @returns Estimated gas cost
*/ */
public async estimateGasAsync(txData: Partial<Web3.TxData>): Promise<number> { public async estimateGasAsync(txData: Partial<TxData>): Promise<number> {
const gas = await promisify<number>(this._web3.eth.estimateGas)(txData); const gas = await promisify<number>(this._web3.eth.estimateGas)(txData);
return gas; return gas;
} }
@ -262,7 +274,7 @@ export class Web3Wrapper {
* @param defaultBlock Block height at which to make the call. Defaults to `latest` * @param defaultBlock Block height at which to make the call. Defaults to `latest`
* @returns The raw call result * @returns The raw call result
*/ */
public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise<string> { public async callAsync(callData: CallData, defaultBlock?: BlockParam): Promise<string> {
const rawCallResult = await promisify<string>(this._web3.eth.call)(callData, defaultBlock); const rawCallResult = await promisify<string>(this._web3.eth.call)(callData, defaultBlock);
return rawCallResult; return rawCallResult;
} }
@ -271,13 +283,13 @@ export class Web3Wrapper {
* @param txData Transaction data * @param txData Transaction data
* @returns Transaction hash * @returns Transaction hash
*/ */
public async sendTransactionAsync(txData: Web3.TxData): Promise<string> { public async sendTransactionAsync(txData: TxData): Promise<string> {
const txHash = await promisify<string>(this._web3.eth.sendTransaction)(txData); const txHash = await promisify<string>(this._web3.eth.sendTransaction)(txData);
return txHash; return txHash;
} }
private async _sendRawPayloadAsync<A>(payload: Partial<Web3.JSONRPCRequestPayload>): Promise<A> { private async _sendRawPayloadAsync<A>(payload: Partial<JSONRPCRequestPayload>): Promise<A> {
const sendAsync = this._web3.currentProvider.sendAsync.bind(this._web3.currentProvider); const sendAsync = this._web3.currentProvider.sendAsync.bind(this._web3.currentProvider);
const response = await promisify<Web3.JSONRPCResponsePayload>(sendAsync)(payload); const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payload);
const result = response.result; const result = response.result;
return result; return result;
} }
@ -295,7 +307,7 @@ export class Web3Wrapper {
return status; return status;
} }
} }
private _formatLog(rawLog: RawLogEntry): Web3.LogEntry { private _formatLog(rawLog: RawLogEntry): LogEntry {
const formattedLog = { const formattedLog = {
...rawLog, ...rawLog,
logIndex: this._hexToDecimal(rawLog.logIndex), logIndex: this._hexToDecimal(rawLog.logIndex),

View File

@ -48,26 +48,25 @@ const docsInfoConfig: DocsInfoConfig = {
typeConfigs: { typeConfigs: {
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is // Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
// currently no way to extract the re-exported types from index.ts via TypeDoc :( // currently no way to extract the re-exported types from index.ts via TypeDoc :(
publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'], publicTypes: [
'TxData',
'TransactionReceipt',
'RawLogEntry',
'ContractAbi',
'BlockParam',
'FilterObject',
'LogEntry',
'BlockWithoutTransactionData',
'CallData',
'LogEntryEvent',
],
typeNameToExternalLink: { typeNameToExternalLink: {
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API', Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150', Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127', BigNumber: 'http://mikemcl.github.io/bignumber.js',
LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
BlockWithoutTransactionData:
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
}, },
typeNameToPrefix: { typeNameToPrefix: {
Provider: 'Web3', Provider: 'Web3',
CallData: 'Web3',
BlockWithoutTransactionData: 'Web3',
LogEntry: 'Web3',
FilterObject: 'Web3',
}, },
typeNameToDocSection: { typeNameToDocSection: {
Web3Wrapper: docSections.web3Wrapper, Web3Wrapper: docSections.web3Wrapper,

View File

@ -115,11 +115,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider; export = Subprovider;
} }
declare module 'web3-provider-engine/subproviders/rpc' { declare module 'web3-provider-engine/subproviders/rpc' {
import * as Web3 from 'web3'; import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider { class RpcSubprovider {
constructor(options: { rpcUrl: string }); constructor(options: { rpcUrl: string });
public handleRequest( public handleRequest(
payload: Web3.JSONRPCRequestPayload, payload: JSONRPCRequestPayload,
next: () => void, next: () => void,
end: (err: Error | null, data?: any) => void, end: (err: Error | null, data?: any) => void,
): void; ): void;

View File

@ -13,15 +13,6 @@
lodash "^4.17.4" lodash "^4.17.4"
tslint-react "^3.2.0" tslint-react "^3.2.0"
"@0xproject/utils@^0.3.4":
version "0.3.4"
resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.3.4.tgz#263ac7a5ef0b4c65ce893d3e6d1e9b1c2cf75b0b"
dependencies:
bignumber.js "~4.1.0"
js-sha3 "^0.7.0"
lodash "^4.17.4"
web3 "^0.20.0"
"@ledgerhq/hw-app-eth@^4.3.0": "@ledgerhq/hw-app-eth@^4.3.0":
version "4.7.3" version "4.7.3"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.7.3.tgz#d352e19658ae296532e522c53c8ec2a1a77b64e5" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.7.3.tgz#d352e19658ae296532e522c53c8ec2a1a77b64e5"
@ -12465,12 +12456,6 @@ web3-typescript-typings@^0.10.2:
dependencies: dependencies:
bignumber.js "~4.1.0" bignumber.js "~4.1.0"
web3-typescript-typings@^0.9.11:
version "0.9.11"
resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.9.11.tgz#2f5464e572843b0853f47a1a0801029d6dfb5793"
dependencies:
bignumber.js "~4.1.0"
web3-utils@1.0.0-beta.33: web3-utils@1.0.0-beta.33:
version "1.0.0-beta.33" version "1.0.0-beta.33"
resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.0.0-beta.33.tgz#e091b7994f09b714b0198a4057d3ad2eb8cbe238" resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.0.0-beta.33.tgz#e091b7994f09b714b0198a4057d3ad2eb8cbe238"