Move common types out of web3 types
This commit is contained in:
		
							
								
								
									
										305
									
								
								packages/typescript-typings/types/web3/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										305
									
								
								packages/typescript-typings/types/web3/index.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,21 @@ | ||||
| declare module 'web3' { | ||||
|     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; | ||||
|  | ||||
| @@ -22,10 +38,10 @@ declare module 'web3' { | ||||
|         public fromAscii(ascii: string, padding?: number): string; | ||||
|         public toDecimal(hex: string): number; | ||||
|         public fromDecimal(value: number | string): string; | ||||
|         public fromWei(value: number | string, unit: Web3.Unit): string; | ||||
|         public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; | ||||
|         public toWei(amount: number | string, unit: Web3.Unit): string; | ||||
|         public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; | ||||
|         public fromWei(value: number | string, unit: Unit): string; | ||||
|         public fromWei(value: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber; | ||||
|         public toWei(amount: number | string, unit: Unit): string; | ||||
|         public toWei(amount: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber; | ||||
|         public toBigNumber(value: number | string): BigNumber.BigNumber; | ||||
|         public isAddress(address: string): boolean; | ||||
|         public isChecksumAddress(address: string): boolean; | ||||
| @@ -36,71 +52,16 @@ declare module 'web3' { | ||||
|         class HttpProvider implements Web3.Provider { | ||||
|             constructor(url?: string, timeout?: number, username?: string, password?: string); | ||||
|             public sendAsync( | ||||
|                 payload: Web3.JSONRPCRequestPayload, | ||||
|                 callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void, | ||||
|                 payload: JSONRPCRequestPayload, | ||||
|                 callback: (err: Error, result: JSONRPCResponsePayload) => void, | ||||
|             ): void; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     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 { | ||||
|             address: string; | ||||
|             abi: Web3.ContractAbi; | ||||
|             abi: ContractAbi; | ||||
|             [name: string]: any; | ||||
|         } | ||||
|  | ||||
| @@ -110,66 +71,12 @@ declare module 'web3' { | ||||
|             '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 { | ||||
|             get(callback: () => void): void; | ||||
|             watch(callback: (err: Error, result: LogEntryEvent) => 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 { | ||||
|             sendAsync( | ||||
|                 payload: JSONRPCRequestPayload, | ||||
| @@ -189,7 +96,7 @@ declare module 'web3' { | ||||
|             accounts: string[]; | ||||
|             blockNumber: number; | ||||
|             defaultAccount?: string; | ||||
|             defaultBlock: Web3.BlockParam; | ||||
|             defaultBlock: BlockParam; | ||||
|             syncing: Web3.SyncingResult; | ||||
|             compile: { | ||||
|                 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; | ||||
|             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( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 callback: (err: Error, blockObj: BlockWithoutTransactionData) => void, | ||||
|             ): void; | ||||
|             getBlock( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 returnTransactionObjects: true, | ||||
|             ): Web3.BlockWithTransactionData; | ||||
|             ): BlockWithTransactionData; | ||||
|             getBlock( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 returnTransactionObjects: true, | ||||
|                 callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void, | ||||
|                 callback: (err: Error, blockObj: BlockWithTransactionData) => void, | ||||
|             ): void; | ||||
|  | ||||
|             getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number; | ||||
|             getBlockTransactionCount(hashStringOrBlockNumber: string | BlockParam): number; | ||||
|             getBlockTransactionCount( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 callback: (err: Error, blockTransactionCount: number) => void, | ||||
|             ): void; | ||||
|  | ||||
|             // TODO returnTransactionObjects | ||||
|             getUncle(hashStringOrBlockNumber: string | BlockParam, uncleNumber: number): BlockWithoutTransactionData; | ||||
|             getUncle( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 uncleNumber: number, | ||||
|             ): Web3.BlockWithoutTransactionData; | ||||
|             getUncle( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 uncleNumber: number, | ||||
|                 callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void, | ||||
|                 callback: (err: Error, uncle: BlockWithoutTransactionData) => void, | ||||
|             ): void; | ||||
|  | ||||
|             getTransaction(transactionHash: string): Web3.Transaction; | ||||
|             getTransaction( | ||||
|                 transactionHash: string, | ||||
|                 callback: (err: Error, transaction: Web3.Transaction) => void, | ||||
|             ): void; | ||||
|             getTransaction(transactionHash: string): Transaction; | ||||
|             getTransaction(transactionHash: string, callback: (err: Error, transaction: Transaction) => void): void; | ||||
|  | ||||
|             getTransactionFromBlock(hashStringOrBlockNumber: string | BlockParam, indexNumber: number): Transaction; | ||||
|             getTransactionFromBlock( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 hashStringOrBlockNumber: string | BlockParam, | ||||
|                 indexNumber: number, | ||||
|             ): Web3.Transaction; | ||||
|             getTransactionFromBlock( | ||||
|                 hashStringOrBlockNumber: string | Web3.BlockParam, | ||||
|                 indexNumber: number, | ||||
|                 callback: (err: Error, transaction: Web3.Transaction) => void, | ||||
|                 callback: (err: Error, transaction: Transaction) => void, | ||||
|             ): void; | ||||
|  | ||||
|             contract(abi: Web3.AbiDefinition[]): Web3.Contract<any>; | ||||
|             contract(abi: AbiDefinition[]): Web3.Contract<any>; | ||||
|  | ||||
|             // TODO block param | ||||
|             getBalance(addressHexString: string): BigNumber.BigNumber; | ||||
| @@ -264,10 +162,10 @@ declare module 'web3' { | ||||
|             getCode(addressHexString: string): string; | ||||
|             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: Web3.TxData, callback: (err: Error, value: string) => void): void; | ||||
|             sendTransaction(txData: TxData): string; | ||||
|             sendTransaction(txData: TxData, callback: (err: Error, value: string) => void): void; | ||||
|  | ||||
|             sendRawTransaction(rawTxData: string): string; | ||||
|             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, callback: (err: Error, signature: string) => void): void; | ||||
|  | ||||
|             getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null; | ||||
|             getTransactionReceipt(txHash: string): TransactionReceipt | null; | ||||
|             getTransactionReceipt( | ||||
|                 txHash: string, | ||||
|                 callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void, | ||||
|                 callback: (err: Error, receipt: TransactionReceipt | null) => void, | ||||
|             ): void; | ||||
|  | ||||
|             // TODO block param | ||||
|             call(callData: Web3.CallData): string; | ||||
|             call(callData: Web3.CallData, callback: (err: Error, result: string) => void): void; | ||||
|             call(callData: CallData): string; | ||||
|             call(callData: CallData, callback: (err: Error, result: string) => void): void; | ||||
|  | ||||
|             estimateGas(callData: Web3.CallData): number; | ||||
|             estimateGas(callData: Web3.CallData, callback: (err: Error, gas: number) => void): void; | ||||
|             estimateGas(callData: CallData): number; | ||||
|             estimateGas(callData: CallData, callback: (err: Error, gas: number) => void): void; | ||||
|  | ||||
|             // TODO defaultBlock | ||||
|             getTransactionCount(address: string): number; | ||||
| @@ -321,25 +219,6 @@ declare module 'web3' { | ||||
|             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 { | ||||
|             startingBlock: number; | ||||
|             currentBlock: number; | ||||
| @@ -351,88 +230,6 @@ declare module 'web3' { | ||||
|             addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): 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 */ | ||||
|     export = Web3; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user