Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web3 types #2123

Merged
merged 12 commits into from
Dec 17, 2018
2 changes: 2 additions & 0 deletions packages/web3-core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class AbstractWeb3Module {
readonly defaultBlock: string | number;
readonly defaultAccount: string | null;
readonly currentProvider: AbstractProviderAdapter;
readonly providers: Providers;
readonly givenProvider: provider | null;
setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean;
isSameProvider(provider: AbstractProviderAdapter | provider): boolean;
clearSubscriptions(): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Eth extends AbstractWeb3Module {
setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean;
readonly providers: Providers;
readonly givenProvider: provider | null;
BatchRequest(): BatchRequest;
BatchRequest: new () => BatchRequest;
getProtocolVersion(callback?: (error: Error, protocolVersion: string) => void): Promise<string>;
isSyncing(callback?: (error: Error, syncing: Syncing) => void): Promise<Syncing | boolean>;
getCoinbase(callback?: (error: Error, coinbaseAddress: string) => void): Promise<string>;
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth/types/tests/eth.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ eth.providers;
eth.givenProvider;

// $ExpectType BatchRequest
eth.BatchRequest();
new eth.BatchRequest();

// $ExpectType string | null
eth.defaultAccount
Expand Down
1 change: 1 addition & 0 deletions packages/web3-providers/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class SocketProviderAdapter extends AbstractProviderAdapter {
}

export class BatchRequest {
constructor();
constructor(provider: provider, jsonRpcMapper: JsonRpcMapper, jsonRpcResponseValidator: JsonRpcResponseValidator);
joshstevens19 marked this conversation as resolved.
Show resolved Hide resolved
add(request: any): void;
execute(): void;
Expand Down
49 changes: 48 additions & 1 deletion packages/web3-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,60 @@ export function jsonInterfaceMethodToString(abiItem: ABIItem): string;
export function soliditySha3(...val: Mixed[]): string;
export function getUnitValue(unit: Unit): string;
export function unitMap(): Units;

// bloom types
export function testAddress(bloom: string, address: string): boolean;
export function testTopic(bloom: string, topic: string): boolean;

// interfaces

export interface Utils {
isBN(value: string | number): boolean;
isBigNumber(value: BN): boolean;
toBN(value: number | string): BN;
toTwosComplement(value: number | string | BN): string;
isAddress(address: string): boolean;
isHex(hex: Hex): boolean;
isHexStrict(hex: Hex): boolean;
asciiToHex(string: string): string;
hexToAscii(string: string): string;
toAscii(string: string): string;
bytesToHex(bytes: number[]): string;
numberToHex(value: number | string | BN): string;
checkAddressChecksum(address: string): boolean;
fromAscii(string: string): string;
fromDecimal(value: string | number): string;
fromUtf8(string: string): string;
fromWei(value: BN, unit?: Unit): BN | string;
hexToBytes(hex: Hex): number[];
hexToNumber(hex: Hex): number;
hexToNumberString(hex: Hex): string;
hexToString(hex: Hex): string;
hexToUtf8(string: string): string;
keccak256(value: string | BN): string;
padLeft(value: string | number, characterAmount: number, sign?: string): string;
leftPad(string: string | number, characterAmount: number, sign?: string): string;
rightPad(string: string | number, characterAmount: number, sign?: string): string;
padRight(string: string | number, characterAmount: number, sign?: string): string;
sha3(value: string | BN): string;
randomHex(bytesSize: number): string;
utf8ToHex(string: string): string;
stringToHex(string: string): string;
toChecksumAddress(address: string): string;
toDecimal(hex: Hex): number;
toHex(value: number | string | BN): string;
toUtf8(string: string): string;
toWei(value: number | string | BN, unit?: Unit): string | BN;
isBloom(bloom: string): boolean;
isTopic(topic: string): boolean;
jsonInterfaceMethodToString(abiItem: ABIItem): string;
soliditySha3(...val: Mixed[]): string;
getUnitValue(unit: Unit): string;
unitMap(): Units;
// bloom types
testAddress(bloom: string, address: string): boolean;
testTopic(bloom: string, topic: string): boolean;
}

export interface Units {
noether: string;
wei: string;
Expand Down
Loading