Skip to content

Commit

Permalink
Fixes in types definition (#1139)
Browse files Browse the repository at this point in the history
* Fixes in types definition

* Fix Provider type: implement 'empty' variables to the other providers interfaces to make a OR between them
  • Loading branch information
icaroharry authored and frozeman committed Nov 13, 2017
1 parent 06d6005 commit fdb40ab
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/web3/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ declare class Web3 {

}

export = Web3
export default Web3
47 changes: 39 additions & 8 deletions packages/web3/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber } from 'bignumber.js' // TODO change to BN
import { BigNumber } from 'bn.js'
import * as us from 'underscore'


Expand All @@ -18,9 +18,6 @@ export declare interface JsonRPCResponse {

type Callback<T> = (error: Error, result: T) => void
type ABIDataTypes = "uint256" | "boolean" | "string" | "bytes" | string // TODO complete list
export declare interface Provider {
send(payload: JsonRPCRequest, callback: (e: Error, val: JsonRPCResponse) => void)
}
type PromiEventType = "transactionHash" | "receipt" | "confirmation" | "error"
export declare interface PromiEvent<T> extends Promise<T> {
once(type: "transactionHash", handler: (receipt: string) => void): PromiEvent<T>
Expand Down Expand Up @@ -232,9 +229,44 @@ export declare interface Tx {
gasPrice?: string | number

}
export declare interface WebsocketProvider extends Provider { }
export declare interface HttpProvider extends Provider { }
export declare interface IpcProvider extends Provider { }
export declare interface IProvider {
send(payload: JsonRPCRequest, callback: (e: Error, val: JsonRPCResponse) => void)
}
export declare interface WebsocketProvider extends IProvider {
responseCallbacks: object
notificationCallbacks: [() => any]
connection: {
onclose(e: any): void,
onmessage(e: any): void,
onerror(e?: any): void
}
addDefaultEvents: () => void
on(type: string, callback: () => any): void
removeListener(type: string, callback: () => any): void
removeAllListeners(type: string): void
reset(): void
}
export declare interface HttpProvider extends IProvider {
responseCallbacks: undefined
notificationCallbacks: undefined
connection: undefined
addDefaultEvents: undefined
on(type: string, callback: () => any): undefined
removeListener(type: string, callback: () => any): undefined
removeAllListeners(type: string): undefined
reset(): undefined
}
export declare interface IpcProvider extends IProvider {
responseCallbacks: undefined
notificationCallbacks: undefined
connection: undefined
addDefaultEvents: undefined
on(type: string, callback: () => any): undefined
removeListener(type: string, callback: () => any): undefined
removeAllListeners(type: string): undefined
reset(): undefined
}
export type Provider = WebsocketProvider | IpcProvider | HttpProvider;
type Unit = "kwei" | "femtoether" | "babbage" | "mwei" | "picoether" | "lovelace" | "qwei" | "nanoether" | "shannon" | "microether" | "szabo" | "nano" | "micro" | "milliether" | "finney" | "milli" | "ether" | "kether" | "grand" | "mether" | "gether" | "tether"
export type BlockType = "latest" | "pending" | "genesis" | number
export declare interface Iban { }
Expand Down Expand Up @@ -424,4 +456,3 @@ export declare class BatchRequest {
add(request: Request): void //
execute(): void
}

0 comments on commit fdb40ab

Please sign in to comment.