From c5a9c90c0b6dbeb59eb4d8bb6ad20a1afdc2450f Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Wed, 6 Mar 2019 15:01:12 +0800 Subject: Add typescript definitions --- packages/typescript-typings/package.json | 2 +- .../typescript-typings/types/@ledgerhq/index.d.ts | 45 + .../types/async-child-process/index.d.ts | 1 + .../types/chai-as-promised/index.d.ts | 266 +++++ .../types/chai-bignumber/index.d.ts | 1 + packages/typescript-typings/types/chai/index.d.ts | 1257 ++++++++++++++++++++ .../typescript-typings/types/dirty-chai/index.d.ts | 1 + .../types/es6-promisify/index.d.ts | 1 + .../types/ethereumjs-abi/index.d.ts | 7 + .../types/ethereumjs-util/index.d.ts | 100 ++ .../types/json-rpc-error/index.d.ts | 8 + .../typescript-typings/types/keccak/index.d.ts | 1 + .../types/openapi-schema-validation/index.d.ts | 1 + .../types/promisify-child-process/index.d.ts | 1 + .../types/publish-release/index.d.ts | 1 + .../types/react-highlight/index.d.ts | 1 + .../types/react-popper/index.d.ts | 49 + .../types/react-tooltip/index.d.ts | 1 + .../types/react-typist/index.d.ts | 1 + .../types/request-promise-native/index.d.ts | 1 + .../typescript-typings/types/rollbar/index.d.ts | 1 + .../types/semver-diff/index.d.ts | 1 + .../types/semver-sort/index.d.ts | 3 + packages/typescript-typings/types/solc/index.d.ts | 105 ++ .../types/to-snake-case/index.d.ts | 4 + .../types/truffle-hdwalet-provider/index.d.ts | 11 + .../types/web3-eth-abi/index.d.ts | 3 + packages/typescript-typings/types/web3/index.d.ts | 231 ++++ 28 files changed, 2104 insertions(+), 1 deletion(-) create mode 100644 packages/typescript-typings/types/@ledgerhq/index.d.ts create mode 100644 packages/typescript-typings/types/async-child-process/index.d.ts create mode 100644 packages/typescript-typings/types/chai-as-promised/index.d.ts create mode 100644 packages/typescript-typings/types/chai-bignumber/index.d.ts create mode 100644 packages/typescript-typings/types/chai/index.d.ts create mode 100644 packages/typescript-typings/types/dirty-chai/index.d.ts create mode 100644 packages/typescript-typings/types/es6-promisify/index.d.ts create mode 100644 packages/typescript-typings/types/ethereumjs-abi/index.d.ts create mode 100644 packages/typescript-typings/types/ethereumjs-util/index.d.ts create mode 100644 packages/typescript-typings/types/json-rpc-error/index.d.ts create mode 100644 packages/typescript-typings/types/keccak/index.d.ts create mode 100644 packages/typescript-typings/types/openapi-schema-validation/index.d.ts create mode 100644 packages/typescript-typings/types/promisify-child-process/index.d.ts create mode 100644 packages/typescript-typings/types/publish-release/index.d.ts create mode 100644 packages/typescript-typings/types/react-highlight/index.d.ts create mode 100644 packages/typescript-typings/types/react-popper/index.d.ts create mode 100644 packages/typescript-typings/types/react-tooltip/index.d.ts create mode 100644 packages/typescript-typings/types/react-typist/index.d.ts create mode 100644 packages/typescript-typings/types/request-promise-native/index.d.ts create mode 100644 packages/typescript-typings/types/rollbar/index.d.ts create mode 100644 packages/typescript-typings/types/semver-diff/index.d.ts create mode 100644 packages/typescript-typings/types/semver-sort/index.d.ts create mode 100644 packages/typescript-typings/types/solc/index.d.ts create mode 100644 packages/typescript-typings/types/to-snake-case/index.d.ts create mode 100644 packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts create mode 100644 packages/typescript-typings/types/web3-eth-abi/index.d.ts create mode 100644 packages/typescript-typings/types/web3/index.d.ts (limited to 'packages/typescript-typings') diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index 209f12d9e..19ea88395 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -1,6 +1,6 @@ { "name": "@dexon-foundation/typescript-typings", - "version": "1.0.5", + "version": "4.0.1", "engines": { "node": ">=6.12" }, diff --git a/packages/typescript-typings/types/@ledgerhq/index.d.ts b/packages/typescript-typings/types/@ledgerhq/index.d.ts new file mode 100644 index 000000000..724dacb76 --- /dev/null +++ b/packages/typescript-typings/types/@ledgerhq/index.d.ts @@ -0,0 +1,45 @@ +// Ledgerco declarations +interface ECSignatureString { + v: string; + r: string; + s: string; +} +interface ECSignature { + v: number; + r: string; + s: string; +} + +interface LedgerTransport { + close(): Promise; +} + +declare module '@ledgerhq/hw-app-eth' { + class Eth { + public transport: LedgerTransport; + constructor(transport: LedgerTransport); + public getAddress( + path: string, + boolDisplay?: boolean, + boolChaincode?: boolean, + ): Promise<{ publicKey: string; address: string; chainCode: string }>; + public signTransaction(path: string, rawTxHex: string): Promise; + public getAppConfiguration(): Promise<{ arbitraryDataEnabled: number; version: string }>; + public signPersonalMessage(path: string, messageHex: string): Promise; + } + export default Eth; +} + +declare module '@ledgerhq/hw-transport-u2f' { + export default class TransportU2F implements LedgerTransport { + public static create(): Promise; + public close(): Promise; + } +} + +declare module '@ledgerhq/hw-transport-node-hid' { + export default class TransportNodeHid implements LedgerTransport { + public static create(): Promise; + public close(): Promise; + } +} diff --git a/packages/typescript-typings/types/async-child-process/index.d.ts b/packages/typescript-typings/types/async-child-process/index.d.ts new file mode 100644 index 000000000..f8ed46378 --- /dev/null +++ b/packages/typescript-typings/types/async-child-process/index.d.ts @@ -0,0 +1 @@ +declare module 'async-child-process'; diff --git a/packages/typescript-typings/types/chai-as-promised/index.d.ts b/packages/typescript-typings/types/chai-as-promised/index.d.ts new file mode 100644 index 000000000..6d5345755 --- /dev/null +++ b/packages/typescript-typings/types/chai-as-promised/index.d.ts @@ -0,0 +1,266 @@ +// Type definitions for chai-as-promised +// Project: https://github.com/domenic/chai-as-promised/ +// Definitions by: jt000 , Yuki Kokubun +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'chai-as-promised' { + function chaiAsPromised(chai: any, utils: any): void; + namespace chaiAsPromised {} + export = chaiAsPromised; +} + +// tslint:disable:no-namespace ban-types member-ordering +declare namespace Chai { + // For BDD API + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + eventually: PromisedAssertion; + fulfilled: PromisedAssertion; + become(expected: any): PromisedAssertion; + rejected(): PromisedAssertion; + rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + notify(fn: Function): PromisedAssertion; + } + + // Eventually does not have .then(), but PromisedAssertion have. + interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { + // From chai-as-promised + become(expected: PromiseLike): PromisedAssertion; + fulfilled: PromisedAssertion; + rejected: () => PromisedAssertion; + rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + notify(fn: Function): PromisedAssertion; + + // From chai + not: PromisedAssertion; + deep: PromisedDeep; + all: PromisedKeyFilter; + a: PromisedTypeComparison; + an: PromisedTypeComparison; + include: PromisedInclude; + contain: PromisedInclude; + ok: PromisedAssertion; + true: () => PromisedAssertion; + false: () => PromisedAssertion; + null: PromisedAssertion; + undefined: PromisedAssertion; + exist: PromisedAssertion; + empty: PromisedAssertion; + arguments: PromisedAssertion; + Arguments: PromisedAssertion; + equal: PromisedEqual; + equals: PromisedEqual; + eq: PromisedEqual; + eql: PromisedEqual; + eqls: PromisedEqual; + property: PromisedProperty; + ownProperty: PromisedOwnProperty; + haveOwnProperty: PromisedOwnProperty; + length: PromisedLength; + lengthOf: PromisedLength; + match(regexp: RegExp | string, message?: string): PromisedAssertion; + string(string: string, message?: string): PromisedAssertion; + keys: PromisedKeys; + key(string: string): PromisedAssertion; + throw: PromisedThrow; + throws: PromisedThrow; + Throw: PromisedThrow; + respondTo(method: string, message?: string): PromisedAssertion; + itself: PromisedAssertion; + satisfy(matcher: Function, message?: string): PromisedAssertion; + closeTo(expected: number, delta: number, message?: string): PromisedAssertion; + members: PromisedMembers; + } + + interface PromisedAssertion extends Eventually, PromiseLike {} + + interface PromisedLanguageChains { + eventually: Eventually; + + // From chai + to: PromisedAssertion; + be: PromisedAssertion; + been: PromisedAssertion; + is: PromisedAssertion; + that: PromisedAssertion; + which: PromisedAssertion; + and: PromisedAssertion; + has: PromisedAssertion; + have: PromisedAssertion; + with: PromisedAssertion; + at: PromisedAssertion; + of: PromisedAssertion; + same: PromisedAssertion; + } + + interface PromisedNumericComparison { + above: PromisedNumberComparer; + gt: PromisedNumberComparer; + greaterThan: PromisedNumberComparer; + least: PromisedNumberComparer; + gte: PromisedNumberComparer; + below: PromisedNumberComparer; + lt: PromisedNumberComparer; + lessThan: PromisedNumberComparer; + most: PromisedNumberComparer; + lte: PromisedNumberComparer; + within(start: number, finish: number, message?: string): PromisedAssertion; + } + + type PromisedNumberComparer = (value: number, message?: string) => PromisedAssertion; + + interface PromisedTypeComparison { + (type: string, message?: string): PromisedAssertion; + instanceof: PromisedInstanceOf; + instanceOf: PromisedInstanceOf; + } + + type PromisedInstanceOf = (constructor: Object, message?: string) => PromisedAssertion; + + interface PromisedDeep { + equal: PromisedEqual; + include: PromisedInclude; + property: PromisedProperty; + } + + interface PromisedKeyFilter { + keys: PromisedKeys; + } + + type PromisedEqual = (value: any, message?: string) => PromisedAssertion; + + type PromisedProperty = (name: string, value?: any, message?: string) => PromisedAssertion; + + type PromisedOwnProperty = (name: string, message?: string) => PromisedAssertion; + + interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { + (length: number, message?: string): PromisedAssertion; + } + + interface PromisedInclude { + (value: Object | string | number, message?: string): PromisedAssertion; + keys: PromisedKeys; + members: PromisedMembers; + all: PromisedKeyFilter; + } + + interface PromisedKeys { + (...keys: string[]): PromisedAssertion; + (keys: any[]): PromisedAssertion; + } + + interface PromisedThrow { + (): PromisedAssertion; + (expected: string | RegExp, message?: string): PromisedAssertion; + (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion; + } + + type PromisedMembers = (set: any[], message?: string) => PromisedAssertion; + + // For Assert API + interface Assert { + eventually: PromisedAssert; + isFulfilled(promise: PromiseLike, message?: string): PromiseLike; + becomes(promise: PromiseLike, expected: any, message?: string): PromiseLike; + doesNotBecome(promise: PromiseLike, expected: any, message?: string): PromiseLike; + isRejected(promise: PromiseLike, message?: string): PromiseLike; + isRejected(promise: PromiseLike, expected: any | RegExp, message?: string): PromiseLike; + notify(fn: Function): PromiseLike; + } + + export interface PromisedAssert { + fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike; + + ok(val: any, msg?: string): PromiseLike; + notOk(val: any, msg?: string): PromiseLike; + + equal(act: any, exp: any, msg?: string): PromiseLike; + notEqual(act: any, exp: any, msg?: string): PromiseLike; + + strictEqual(act: any, exp: any, msg?: string): PromiseLike; + notStrictEqual(act: any, exp: any, msg?: string): PromiseLike; + + deepEqual(act: any, exp: any, msg?: string): PromiseLike; + notDeepEqual(act: any, exp: any, msg?: string): PromiseLike; + + isTrue(val: any, msg?: string): PromiseLike; + isFalse(val: any, msg?: string): PromiseLike; + + isNull(val: any, msg?: string): PromiseLike; + isNotNull(val: any, msg?: string): PromiseLike; + + isUndefined(val: any, msg?: string): PromiseLike; + isDefined(val: any, msg?: string): PromiseLike; + + isFunction(val: any, msg?: string): PromiseLike; + isNotFunction(val: any, msg?: string): PromiseLike; + + isObject(val: any, msg?: string): PromiseLike; + isNotObject(val: any, msg?: string): PromiseLike; + + isArray(val: any, msg?: string): PromiseLike; + isNotArray(val: any, msg?: string): PromiseLike; + + isString(val: any, msg?: string): PromiseLike; + isNotString(val: any, msg?: string): PromiseLike; + + isNumber(val: any, msg?: string): PromiseLike; + isNotNumber(val: any, msg?: string): PromiseLike; + + isBoolean(val: any, msg?: string): PromiseLike; + isNotBoolean(val: any, msg?: string): PromiseLike; + + typeOf(val: any, type: string, msg?: string): PromiseLike; + notTypeOf(val: any, type: string, msg?: string): PromiseLike; + + instanceOf(val: any, type: Function, msg?: string): PromiseLike; + notInstanceOf(val: any, type: Function, msg?: string): PromiseLike; + + include(exp: string | any[], inc: any, msg?: string): PromiseLike; + + notInclude(exp: string | any[], inc: any, msg?: string): PromiseLike; + + match(exp: any, re: RegExp, msg?: string): PromiseLike; + notMatch(exp: any, re: RegExp, msg?: string): PromiseLike; + + property(obj: Object, prop: string, msg?: string): PromiseLike; + notProperty(obj: Object, prop: string, msg?: string): PromiseLike; + deepProperty(obj: Object, prop: string, msg?: string): PromiseLike; + notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike; + + propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + + lengthOf(exp: any, len: number, msg?: string): PromiseLike; + // alias frenzy + throw(fn: Function, msg?: string): PromiseLike; + throw(fn: Function, regExp: RegExp): PromiseLike; + throw(fn: Function, errType: Function, msg?: string): PromiseLike; + throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + throws(fn: Function, msg?: string): PromiseLike; + throws(fn: Function, regExp: RegExp): PromiseLike; + throws(fn: Function, errType: Function, msg?: string): PromiseLike; + throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + Throw(fn: Function, msg?: string): PromiseLike; + Throw(fn: Function, regExp: RegExp): PromiseLike; + Throw(fn: Function, errType: Function, msg?: string): PromiseLike; + Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + doesNotThrow(fn: Function, msg?: string): PromiseLike; + doesNotThrow(fn: Function, regExp: RegExp): PromiseLike; + doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + operator(val: any, operator: string, val2: any, msg?: string): PromiseLike; + closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike; + + sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + + ifError(val: any, msg?: string): PromiseLike; + } +} diff --git a/packages/typescript-typings/types/chai-bignumber/index.d.ts b/packages/typescript-typings/types/chai-bignumber/index.d.ts new file mode 100644 index 000000000..802b69795 --- /dev/null +++ b/packages/typescript-typings/types/chai-bignumber/index.d.ts @@ -0,0 +1 @@ +declare module 'chai-bignumber'; diff --git a/packages/typescript-typings/types/chai/index.d.ts b/packages/typescript-typings/types/chai/index.d.ts new file mode 100644 index 000000000..3bde1f27c --- /dev/null +++ b/packages/typescript-typings/types/chai/index.d.ts @@ -0,0 +1,1257 @@ +// Type definitions for chai 4.0.0 +// Project: http://chaijs.com/ +// Definitions by: Jed Mao , +// Bart van der Schoor , +// Andrew Brown , +// Olivier Chevet , +// Matt Wistrand , +// Josh Goldberg +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// + +// tslint:disable:no-namespace member-ordering ban-types unified-signatures variable-name callable-types +declare namespace Chai { + interface ChaiStatic { + expect: ExpectStatic; + should(): Should; + /** + * Provides a way to extend the internals of Chai + */ + use(fn: (chai: any, utils: any) => void): ChaiStatic; + assert: AssertStatic; + config: Config; + AssertionError: typeof AssertionError; + version: string; + } + + export interface ExpectStatic extends AssertionStatic { + fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; + } + + export interface AssertStatic extends Assert {} + + type AssertionStatic = (target: any, message?: string) => Assertion; + + export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; + + export type OperatorComparable = boolean | null | number | string | undefined | Date; + + interface ShouldAssertion { + equal(value1: any, value2: any, message?: string): void; + Throw: ShouldThrow; + throw: ShouldThrow; + exist(value: any, message?: string): void; + } + + interface Should extends ShouldAssertion { + not: ShouldAssertion; + fail(actual: any, expected: any, message?: string, operator?: Operator): void; + } + + interface ShouldThrow { + (actual: Function): void; + (actual: Function, expected: string | RegExp, message?: string): void; + (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void; + } + + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + not: Assertion; + deep: Deep; + nested: Nested; + any: KeyFilter; + all: KeyFilter; + a: TypeComparison; + an: TypeComparison; + include: Include; + includes: Include; + contain: Include; + contains: Include; + ok: Assertion; + true: () => Assertion; + false: () => Assertion; + null: () => Assertion; + undefined: () => Assertion; + NaN: Assertion; + exist: Assertion; + empty: Assertion; + arguments: Assertion; + Arguments: Assertion; + equal: Equal; + equals: Equal; + eq: Equal; + eql: Equal; + eqls: Equal; + property: Property; + ownProperty: OwnProperty; + haveOwnProperty: OwnProperty; + ownPropertyDescriptor: OwnPropertyDescriptor; + haveOwnPropertyDescriptor: OwnPropertyDescriptor; + length: Length; + lengthOf: Length; + match: Match; + matches: Match; + string(string: string, message?: string): Assertion; + keys: Keys; + key(string: string): Assertion; + throw: (message?: string) => Assertion; + throws: Throw; + Throw: Throw; + respondTo: RespondTo; + respondsTo: RespondTo; + itself: Assertion; + satisfy: Satisfy; + satisfies: Satisfy; + closeTo: CloseTo; + approximately: CloseTo; + members: Members; + increase: PropertyChange; + increases: PropertyChange; + decrease: PropertyChange; + decreases: PropertyChange; + change: PropertyChange; + changes: PropertyChange; + extensible: Assertion; + sealed: Assertion; + frozen: Assertion; + bignumber: Assertion; + // HACK: In order to comply with chai-as-promised we make eventually a `PromisedAssertion` not an `Assertion` + eventually: PromisedAssertion; + oneOf(list: any[], message?: string): Assertion; + } + + interface LanguageChains { + to: Assertion; + be: Assertion; + been: Assertion; + is: Assertion; + that: Assertion; + which: Assertion; + and: Assertion; + has: Assertion; + have: Assertion; + with: Assertion; + at: Assertion; + of: Assertion; + same: Assertion; + } + + interface NumericComparison { + above: NumberComparer; + gt: NumberComparer; + greaterThan: NumberComparer; + least: NumberComparer; + gte: NumberComparer; + below: NumberComparer; + lt: NumberComparer; + lessThan: NumberComparer; + most: NumberComparer; + lte: NumberComparer; + within(start: number, finish: number, message?: string): Assertion; + } + + interface NumberComparer { + (value: number | object, message?: string): Assertion; + } + + interface TypeComparison { + (type: string, message?: string): Assertion; + instanceof: InstanceOf; + instanceOf: InstanceOf; + } + + interface InstanceOf { + (constructor: Object, message?: string): Assertion; + } + + interface CloseTo { + (expected: number, delta: number, message?: string): Assertion; + } + + interface Nested { + include: Include; + property: Property; + members: Members; + } + + interface Deep { + equal: Equal; + equals: Equal; + eq: Equal; + include: Include; + property: Property; + members: Members; + } + + interface KeyFilter { + keys: Keys; + } + + interface Equal { + (value: any, message?: string): Assertion; + } + + interface Property { + (name: string, value?: any, message?: string): Assertion; + } + + interface OwnProperty { + (name: string, message?: string): Assertion; + } + + interface OwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; + (name: string, message?: string): Assertion; + } + + interface Length extends LanguageChains, NumericComparison { + (length: number, message?: string): Assertion; + } + + interface Include { + (value: Object | string | number, message?: string): Assertion; + keys: Keys; + members: Members; + any: KeyFilter; + all: KeyFilter; + } + + interface Match { + (regexp: RegExp | string, message?: string): Assertion; + } + + interface Keys { + (...keys: string[]): Assertion; + (keys: any[]): Assertion; + (keys: Object): Assertion; + } + + interface Throw { + (): Assertion; + (expected: string, message?: string): Assertion; + (expected: RegExp, message?: string): Assertion; + (constructor: Error, expected?: string, message?: string): Assertion; + (constructor: Error, expected?: RegExp, message?: string): Assertion; + (constructor: Function, expected?: string, message?: string): Assertion; + (constructor: Function, expected?: RegExp, message?: string): Assertion; + } + + interface RespondTo { + (method: string, message?: string): Assertion; + } + + interface Satisfy { + (matcher: Function, message?: string): Assertion; + } + + interface Members { + (set: any[], message?: string): Assertion; + } + + interface PropertyChange { + (object: Object, property: string, message?: string): Assertion; + } + + export interface Assert { + /** + * @param expression Expression to test for truthiness. + * @param message Message to display on error. + */ + (expression: any, message?: string): void; + + /** + * Throws a failure. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + * @param operator Comparison operator, if not strict equality. + * @remarks Node.js assert module-compatible. + */ + fail(actual?: T, expected?: T, message?: string, operator?: Operator): void; + + /** + * Asserts that object is truthy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + isOk(value: T, message?: string): void; + + /** + * Asserts that object is truthy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + ok(value: T, message?: string): void; + + /** + * Asserts that object is falsy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + isNotOk(value: T, message?: string): void; + + /** + * Asserts that object is falsy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + notOk(value: T, message?: string): void; + + /** + * Asserts non-strict equality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + equal(actual: T, expected: T, message?: string): void; + + /** + * Asserts non-strict inequality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts strict equality (===) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + strictEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts strict inequality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notStrictEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts that actual is deeply equal to expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + deepEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts that actual is not deeply equal to expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notDeepEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts valueToCheck is strictly greater than (>) valueToBeAbove. + * + * @param valueToCheck Actual value. + * @param valueToBeAbove Minimum Potential expected value. + * @param message Message to display on error. + */ + isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void; + + /** + * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast. + * + * @param valueToCheck Actual value. + * @param valueToBeAtLeast Minimum Potential expected value. + * @param message Message to display on error. + */ + isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void; + + /** + * Asserts valueToCheck is strictly less than (<) valueToBeBelow. + * + * @param valueToCheck Actual value. + * @param valueToBeBelow Minimum Potential expected value. + * @param message Message to display on error. + */ + isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void; + + /** + * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost. + * + * @param valueToCheck Actual value. + * @param valueToBeAtMost Minimum Potential expected value. + * @param message Message to display on error. + */ + isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void; + + /** + * Asserts that value is true. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isTrue(value: T, message?: string): void; + + /** + * Asserts that value is false. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isFalse(value: T, message?: string): void; + + /** + * Asserts that value is not true. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotTrue(value: T, message?: string): void; + + /** + * Asserts that value is not false. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotFalse(value: T, message?: string): void; + + /** + * Asserts that value is null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNull(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNull(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNaN(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNaN(value: T, message?: string): void; + + /** + * Asserts that value is undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isUndefined(value: T, message?: string): void; + + /** + * Asserts that value is not undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isDefined(value: T, message?: string): void; + + /** + * Asserts that value is a function. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isFunction(value: T, message?: string): void; + + /** + * Asserts that value is not a function. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotFunction(value: T, message?: string): void; + + /** + * Asserts that value is an object of type 'Object' + * (as revealed by Object.prototype.toString). + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + * @remarks The assertion does not match subclassed objects. + */ + isObject(value: T, message?: string): void; + + /** + * Asserts that value is not an object of type 'Object' + * (as revealed by Object.prototype.toString). + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotObject(value: T, message?: string): void; + + /** + * Asserts that value is an array. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isArray(value: T, message?: string): void; + + /** + * Asserts that value is not an array. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotArray(value: T, message?: string): void; + + /** + * Asserts that value is a string. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isString(value: T, message?: string): void; + + /** + * Asserts that value is not a string. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotString(value: T, message?: string): void; + + /** + * Asserts that value is a number. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNumber(value: T, message?: string): void; + + /** + * Asserts that value is not a number. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNumber(value: T, message?: string): void; + + /** + * Asserts that value is a boolean. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isBoolean(value: T, message?: string): void; + + /** + * Asserts that value is not a boolean. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotBoolean(value: T, message?: string): void; + + /** + * Asserts that value's type is name, as determined by Object.prototype.toString. + * + * @type T Type of value. + * @param value Actual value. + * @param name Potential expected type name of value. + * @param message Message to display on error. + */ + typeOf(value: T, name: string, message?: string): void; + + /** + * Asserts that value's type is not name, as determined by Object.prototype.toString. + * + * @type T Type of value. + * @param value Actual value. + * @param name Potential expected type name of value. + * @param message Message to display on error. + */ + notTypeOf(value: T, name: string, message?: string): void; + + /** + * Asserts that value is an instance of constructor. + * + * @type T Type of value. + * @param value Actual value. + * @param constructor Potential expected contructor of value. + * @param message Message to display on error. + */ + instanceOf(value: T, constructor: Function, message?: string): void; + + /** + * Asserts that value is not an instance of constructor. + * + * @type T Type of value. + * @param value Actual value. + * @param constructor Potential expected contructor of value. + * @param message Message to display on error. + */ + notInstanceOf(value: T, type: Function, message?: string): void; + + /** + * Asserts that haystack includes needle. + * + * @param haystack Container string. + * @param needle Potential expected substring of haystack. + * @param message Message to display on error. + */ + include(haystack: string, needle: string, message?: string): void; + + /** + * Asserts that haystack includes needle. + * + * @type T Type of values in haystack. + * @param haystack Container array. + * @param needle Potential value contained in haystack. + * @param message Message to display on error. + */ + include(haystack: T[], needle: T, message?: string): void; + + /** + * Asserts that haystack does not include needle. + * + * @param haystack Container string. + * @param needle Potential expected substring of haystack. + * @param message Message to display on error. + */ + notInclude(haystack: string, needle: any, message?: string): void; + + /** + * Asserts that haystack does not include needle. + * + * @type T Type of values in haystack. + * @param haystack Container array. + * @param needle Potential value contained in haystack. + * @param message Message to display on error. + */ + notInclude(haystack: any[], needle: any, message?: string): void; + + /** + * Asserts that value matches the regular expression regexp. + * + * @param value Actual value. + * @param regexp Potential match of value. + * @param message Message to display on error. + */ + match(value: string, regexp: RegExp, message?: string): void; + + /** + * Asserts that value does not match the regular expression regexp. + * + * @param value Actual value. + * @param regexp Potential match of value. + * @param message Message to display on error. + */ + notMatch(expected: any, regexp: RegExp, message?: string): void; + + /** + * Asserts that object has a property named by property. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + property(object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that object has a property named by property. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + notProperty(object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that object has a property named by property, which can be a string + * using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + deepProperty(object: T, property: string, message?: string): void; + + /** + * Asserts that object does not have a property named by property, which can be a + * string using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + notDeepProperty(object: T, property: string, message?: string): void; + + /** + * Asserts that object has a property named by property with value given by value. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + propertyVal(object: T, property: string /* keyof T */, value: V, message?: string): void; + + /** + * Asserts that object has a property named by property with value given by value. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + propertyNotVal(object: T, property: string /* keyof T */, value: V, message?: string): void; + + /** + * Asserts that object has a property named by property, which can be a string + * using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + deepPropertyVal(object: T, property: string, value: V, message?: string): void; + + /** + * Asserts that object does not have a property named by property, which can be a + * string using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + deepPropertyNotVal(object: T, property: string, value: V, message?: string): void; + + /** + * Asserts that object has a length property with the expected value. + * + * @type T Type of object. + * @param object Container object. + * @param length Potential expected length of object. + * @param message Message to display on error. + */ + lengthOf(object: T, length: number, message?: string): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + throw(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + throw(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throw(fn: Function, constructor: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throw(fn: Function, constructor: Function, regExp: RegExp): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + throws(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + throws(fn: Function, regExp: RegExp, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throws(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throws(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + Throw(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + Throw(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + Throw(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + Throw(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Asserts that fn will not throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Compares two values using operator. + * + * @param val1 Left value during comparison. + * @param operator Comparison operator. + * @param val2 Right value during comparison. + * @param message Message to display on error. + */ + operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void; + + /** + * Asserts that the target is equal to expected, to within a +/- delta range. + * + * @param actual Actual value + * @param expected Potential expected value. + * @param delta Maximum differenced between values. + * @param message Message to display on error. + */ + closeTo(actual: number, expected: number, delta: number, message?: string): void; + + /** + * Asserts that the target is equal to expected, to within a +/- delta range. + * + * @param actual Actual value + * @param expected Potential expected value. + * @param delta Maximum differenced between values. + * @param message Message to display on error. + */ + approximately(act: number, exp: number, delta: number, message?: string): void; + + /** + * Asserts that set1 and set2 have the same members. Order is not take into account. + * + * @type T Type of set values. + * @param set1 Actual set of values. + * @param set2 Potential expected set of values. + * @param message Message to display on error. + */ + sameMembers(set1: T[], set2: T[], message?: string): void; + + /** + * Asserts that set1 and set2 have the same members using deep equality checking. + * Order is not take into account. + * + * @type T Type of set values. + * @param set1 Actual set of values. + * @param set2 Potential expected set of values. + * @param message Message to display on error. + */ + sameDeepMembers(set1: T[], set2: T[], message?: string): void; + + /** + * Asserts that subset is included in superset. Order is not take into account. + * + * @type T Type of set values. + * @param superset Actual set of values. + * @param subset Potential contained set of values. + * @param message Message to display on error. + */ + includeMembers(superset: T[], subset: T[], message?: string): void; + + /** + * Asserts that subset is included in superset using deep equality checking. + * Order is not take into account. + * + * @type T Type of set values. + * @param superset Actual set of values. + * @param subset Potential contained set of values. + * @param message Message to display on error. + */ + includeDeepMembers(superset: T[], subset: T[], message?: string): void; + + /** + * Asserts that non-object, non-array value inList appears in the flat array list. + * + * @type T Type of list values. + * @param inList Value expected to be in the list. + * @param list List of values. + * @param message Message to display on error. + */ + oneOf(inList: T, list: T[], message?: string): void; + + /** + * Asserts that a function changes the value of a property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be modified. + * @param message Message to display on error. + */ + changes(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not change the value of a property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be modified. + * @param message Message to display on error. + */ + doesNotChange(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function increases an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be increased. + * @param message Message to display on error. + */ + increases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not increase an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be increased. + * @param message Message to display on error. + */ + doesNotIncrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function decreases an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be decreased. + * @param message Message to display on error. + */ + decreases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not decrease an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be decreased. + * @param message Message to display on error. + */ + doesNotDecrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts if value is not a false value, and throws if it is a true value. + * + * @type T Type of object. + * @param object Actual value. + * @param message Message to display on error. + * @remarks This is added to allow for chai to be a drop-in replacement for + * Node’s assert class. + */ + ifError(object: T, message?: string): void; + + /** + * Asserts that object is extensible (can have new properties added to it). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isExtensible(object: T, message?: string): void; + + /** + * Asserts that object is extensible (can have new properties added to it). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + extensible(object: T, message?: string): void; + + /** + * Asserts that object is not extensible. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotExtensible(object: T, message?: string): void; + + /** + * Asserts that object is not extensible. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notExtensible(object: T, message?: string): void; + + /** + * Asserts that object is sealed (can have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isSealed(object: T, message?: string): void; + + /** + * Asserts that object is sealed (can have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + sealed(object: T, message?: string): void; + + /** + * Asserts that object is not sealed. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotSealed(object: T, message?: string): void; + + /** + * Asserts that object is not sealed. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notSealed(object: T, message?: string): void; + + /** + * Asserts that object is frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isFrozen(object: T, message?: string): void; + + /** + * Asserts that object is frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + frozen(object: T, message?: string): void; + + /** + * Asserts that object is not frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotFrozen(object: T, message?: string): void; + + /** + * Asserts that object is not frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notFrozen(object: T, message?: string): void; + } + + export interface Config { + /** + * Default: false + */ + includeStack: boolean; + + /** + * Default: true + */ + showDiff: boolean; + + /** + * Default: 40 + */ + truncateThreshold: number; + } + + export class AssertionError { + constructor(message: string, _props?: any, ssf?: Function); + public name: string; + public message: string; + public showDiff: boolean; + public stack: string; + } +} + +declare const chai: Chai.ChaiStatic; + +declare module 'chai' { + export = chai; +} + +interface Object { + should: Chai.Assertion; +} diff --git a/packages/typescript-typings/types/dirty-chai/index.d.ts b/packages/typescript-typings/types/dirty-chai/index.d.ts new file mode 100644 index 000000000..91ed2021e --- /dev/null +++ b/packages/typescript-typings/types/dirty-chai/index.d.ts @@ -0,0 +1 @@ +declare module 'dirty-chai'; diff --git a/packages/typescript-typings/types/es6-promisify/index.d.ts b/packages/typescript-typings/types/es6-promisify/index.d.ts new file mode 100644 index 000000000..f9c202fb0 --- /dev/null +++ b/packages/typescript-typings/types/es6-promisify/index.d.ts @@ -0,0 +1 @@ +declare module 'es6-promisify'; diff --git a/packages/typescript-typings/types/ethereumjs-abi/index.d.ts b/packages/typescript-typings/types/ethereumjs-abi/index.d.ts new file mode 100644 index 000000000..2d9fc9fcd --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-abi/index.d.ts @@ -0,0 +1,7 @@ +declare module 'ethereumjs-abi' { + export function soliditySHA3(argTypes: string[], args: any[]): Buffer; + export function soliditySHA256(argTypes: string[], args: any[]): Buffer; + export function methodID(name: string, types: string[]): Buffer; + export function simpleEncode(signature: string, ...args: any[]): Buffer; + export function rawDecode(signature: string[], data: Buffer): any[]; +} diff --git a/packages/typescript-typings/types/ethereumjs-util/index.d.ts b/packages/typescript-typings/types/ethereumjs-util/index.d.ts new file mode 100644 index 000000000..b1c521e18 --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-util/index.d.ts @@ -0,0 +1,100 @@ +declare module 'ethereumjs-util' { + import BN = require('bn.js'); + + interface Signature { + v: number; + r: Buffer; + s: Buffer; + } + + export const MAX_INTEGER: BN; + + export const TWO_POW256: BN; + + export const SHA3_NULL_S: string; + + export const SHA3_NULL: Buffer; + + export const SHA3_RLP_ARRAY_S: string; + + export const SHA3_RLP_ARRAY: Buffer; + + export const SHA3_RLP_S: string; + + export const SHA3_RLP: Buffer; + + export function zeros(bytes: number): Buffer; + + export function setLength(msg: Buffer, length: number, right: boolean): Buffer; + export function setLength(msg: number[], length: number, right: boolean): number[]; + + export function setLengthLeft(msg: Buffer, length: number, right?: boolean): Buffer; + export function setLengthLeft(msg: number[], length: number, right?: boolean): number[]; + + export function setLengthRight(msg: Buffer, length: number): Buffer; + export function setLengthRight(msg: number[], length: number): number[]; + + export function unpad(a: Buffer): Buffer; + export function unpad(a: number[]): number[]; + export function unpad(a: string): string; + + export function toBuffer(v: any): Buffer; + + export function bufferToInt(buf: Buffer): number; + + export function bufferToHex(buf: Buffer): string; + + export function fromSigned(num: Buffer): BN; + + export function toUnsigned(num: BN): Buffer; + + export function sha3(a: Buffer | string | number | number[], bits?: number): Buffer; + + export function sha256(a: Buffer | string | number | number[]): Buffer; + + export function ripemd160(a: Buffer | string | number | number[], padded?: boolean): Buffer; + + export function rlphash(a: Buffer | string | number | number[]): Buffer; + + export function isValidPrivate(privateKey: Buffer): boolean; + + export function isValidPublic(publicKey: Buffer, sanitize?: boolean): boolean; + + export function pubToAddress(publicKey: Buffer, sanitize?: boolean): Buffer; + export function publicToAddress(publicKey: Buffer, sanitize?: boolean): Buffer; + + export function privateToPublic(privateKey: Buffer): Buffer; + + export function importPublic(publicKey: Buffer): Buffer; + + export function ecsign(message: Buffer, privateKey: Buffer): Signature; + + export function hashPersonalMessage(message: Buffer | string): Buffer; + + export function ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer): Buffer; + + export function toRpcSig(v: number, r: Buffer, s: Buffer): string; + + export function fromRpcSig(sig: string): Signature; + + export function privateToAddress(privateKey: Buffer): Buffer; + + export function isValidAddress(address: string): boolean; + + export function toChecksumAddress(address: string): string; + + export function isValidChecksumAddress(address: string): boolean; + + export function generateAddress(from: Buffer | string, nonce: number | string | number[] | Buffer): Buffer; + + export function isPrecompiled(address: Buffer | string): boolean; + + export function addHexPrefix(str: string): string; + + export function stripHexPrefix(str: string): string; + + export function isValidSignature(v: number, r: Buffer | string, s: Buffer | string, homestead?: boolean): boolean; + + export function baToJSON(ba: Buffer): string; + export function baToJSON(ba: any[]): string[]; +} diff --git a/packages/typescript-typings/types/json-rpc-error/index.d.ts b/packages/typescript-typings/types/json-rpc-error/index.d.ts new file mode 100644 index 000000000..dfaf92167 --- /dev/null +++ b/packages/typescript-typings/types/json-rpc-error/index.d.ts @@ -0,0 +1,8 @@ +declare module 'json-rpc-error' { + export class InternalError extends Error { + constructor(err: Error | string); + } + export class MethodNotFound extends Error { + constructor(); + } +} diff --git a/packages/typescript-typings/types/keccak/index.d.ts b/packages/typescript-typings/types/keccak/index.d.ts new file mode 100644 index 000000000..0465f8faf --- /dev/null +++ b/packages/typescript-typings/types/keccak/index.d.ts @@ -0,0 +1 @@ +declare module 'keccak'; diff --git a/packages/typescript-typings/types/openapi-schema-validation/index.d.ts b/packages/typescript-typings/types/openapi-schema-validation/index.d.ts new file mode 100644 index 000000000..123a6bdb7 --- /dev/null +++ b/packages/typescript-typings/types/openapi-schema-validation/index.d.ts @@ -0,0 +1 @@ +declare module 'openapi-schema-validation'; diff --git a/packages/typescript-typings/types/promisify-child-process/index.d.ts b/packages/typescript-typings/types/promisify-child-process/index.d.ts new file mode 100644 index 000000000..55c041735 --- /dev/null +++ b/packages/typescript-typings/types/promisify-child-process/index.d.ts @@ -0,0 +1 @@ +declare module 'promisify-child-process'; diff --git a/packages/typescript-typings/types/publish-release/index.d.ts b/packages/typescript-typings/types/publish-release/index.d.ts new file mode 100644 index 000000000..680cc45c9 --- /dev/null +++ b/packages/typescript-typings/types/publish-release/index.d.ts @@ -0,0 +1 @@ +declare module 'publish-release'; diff --git a/packages/typescript-typings/types/react-highlight/index.d.ts b/packages/typescript-typings/types/react-highlight/index.d.ts new file mode 100644 index 000000000..875721533 --- /dev/null +++ b/packages/typescript-typings/types/react-highlight/index.d.ts @@ -0,0 +1 @@ +declare module 'react-highlight'; diff --git a/packages/typescript-typings/types/react-popper/index.d.ts b/packages/typescript-typings/types/react-popper/index.d.ts new file mode 100644 index 000000000..d7dbca17f --- /dev/null +++ b/packages/typescript-typings/types/react-popper/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for react-popper 1.0.0-beta.6 +// Project: https://github.com/gilbarbara/react-joyride + +declare module 'react-popper' { + import * as React from 'react'; + import * as PopperJS from 'popper.js'; + + interface ManagerProps { + children: React.ReactNode; + } + export class Manager extends React.Component {} + + type RefHandler = (ref: HTMLElement | null) => void; + + export interface ReferenceChildrenProps { + ref: RefHandler; + } + + export interface ReferenceProps { + children: (props: ReferenceChildrenProps) => React.ReactNode; + } + export class Reference extends React.Component {} + + export interface PopperArrowProps { + ref: RefHandler; + style: React.CSSProperties; + } + + export type Placement = PopperJS.Placement; + + export interface PopperChildrenProps { + arrowProps: PopperArrowProps; + outOfBoundaries: boolean | null; + placement: PopperJS.Placement; + ref: RefHandler; + scheduleUpdate: () => void; + style: React.CSSProperties; + } + + export interface PopperProps { + children: (props: PopperChildrenProps) => React.ReactNode; + eventsEnabled?: boolean; + modifiers?: PopperJS.Modifiers; + placement?: PopperJS.Placement; + positionFixed?: boolean; + referenceElement?: Element; + } + export class Popper extends React.Component {} +} diff --git a/packages/typescript-typings/types/react-tooltip/index.d.ts b/packages/typescript-typings/types/react-tooltip/index.d.ts new file mode 100644 index 000000000..98cb6d592 --- /dev/null +++ b/packages/typescript-typings/types/react-tooltip/index.d.ts @@ -0,0 +1 @@ +declare module 'react-tooltip'; diff --git a/packages/typescript-typings/types/react-typist/index.d.ts b/packages/typescript-typings/types/react-typist/index.d.ts new file mode 100644 index 000000000..692c596a5 --- /dev/null +++ b/packages/typescript-typings/types/react-typist/index.d.ts @@ -0,0 +1 @@ +declare module 'react-typist'; diff --git a/packages/typescript-typings/types/request-promise-native/index.d.ts b/packages/typescript-typings/types/request-promise-native/index.d.ts new file mode 100644 index 000000000..a86e99624 --- /dev/null +++ b/packages/typescript-typings/types/request-promise-native/index.d.ts @@ -0,0 +1 @@ +declare module 'request-promise-native'; diff --git a/packages/typescript-typings/types/rollbar/index.d.ts b/packages/typescript-typings/types/rollbar/index.d.ts new file mode 100644 index 000000000..c9bec447d --- /dev/null +++ b/packages/typescript-typings/types/rollbar/index.d.ts @@ -0,0 +1 @@ +declare module 'rollbar'; diff --git a/packages/typescript-typings/types/semver-diff/index.d.ts b/packages/typescript-typings/types/semver-diff/index.d.ts new file mode 100644 index 000000000..e4a14eeb2 --- /dev/null +++ b/packages/typescript-typings/types/semver-diff/index.d.ts @@ -0,0 +1 @@ +declare module 'semver-diff'; diff --git a/packages/typescript-typings/types/semver-sort/index.d.ts b/packages/typescript-typings/types/semver-sort/index.d.ts new file mode 100644 index 000000000..47310756a --- /dev/null +++ b/packages/typescript-typings/types/semver-sort/index.d.ts @@ -0,0 +1,3 @@ +declare module 'semver-sort' { + const desc: (versions: string[]) => string[]; +} diff --git a/packages/typescript-typings/types/solc/index.d.ts b/packages/typescript-typings/types/solc/index.d.ts new file mode 100644 index 000000000..fefad9f6a --- /dev/null +++ b/packages/typescript-typings/types/solc/index.d.ts @@ -0,0 +1,105 @@ +declare module 'solc' { + export { ErrorType, ErrorSeverity, SolcError, StandardContractOutput, StandardOutput } from 'ethereum-types'; + import { SolcError } from 'ethereum-types'; + export interface ContractCompilationResult { + srcmap: string; + srcmapRuntime: string; + bytecode: string; + runtimeBytecode: string; + interface: string; + } + export interface CompilationResult { + errors: string[]; + contracts: { + [contractIdentifier: string]: ContractCompilationResult; + }; + sources: { + [sourceName: string]: { + AST: any; + }; + }; + sourceList: string[]; + } + export interface ImportContents { + contents: string; + } + export interface InputSources { + sources: { + [fileName: string]: string; + }; + } + export interface BaseSource { + keccak256?: string; + } + export interface InMemorySource extends BaseSource { + content: string; + } + export interface UrlSource extends BaseSource { + urls: string[]; + } + export type Source = UrlSource | InMemorySource; + export type OutputField = + | '*' + | 'ast' + | 'legacyAST' + | 'abi' + | 'devdoc' + | 'userdoc' + | 'metadata' + | 'ir' + | 'evm.assembly' + | 'evm.legacyAssembly' + | 'evm.bytecode.object' + | 'evm.bytecode.opcodes' + | 'evm.bytecode.sourceMap' + | 'evm.bytecode.linkReferences' + | 'evm.deployedBytecode.object' + | 'evm.deployedBytecode.opcodes' + | 'evm.deployedBytecode.sourceMap' + | 'evm.deployedBytecode.linkReferences' + | 'evm.methodIdentifiers' + | 'evm.gasEstimates' + | 'ewasm.wast' + | 'ewasm.wasm'; + export interface CompilerSettings { + remappings?: string[]; + optimizer?: { + enabled: boolean; + runs?: number; + }; + evmVersion?: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; + metadata?: { + useLiteralContent: true; + }; + libraries?: { + [fileName: string]: { + [libName: string]: string; + }; + }; + outputSelection: { + [fileName: string]: { + [contractName: string]: OutputField[]; + }; + }; + } + export interface StandardInput { + language: 'Solidity' | 'serpent' | 'lll' | 'assembly'; + sources: { + [fileName: string]: Source; + }; + settings: CompilerSettings; + } + export interface SolcInstance { + compile( + sources: InputSources, + optimizerEnabled: number, + findImports: (importPath: string) => ImportContents, + ): CompilationResult; + compileStandardWrapper(input: string, findImports?: (importPath: string) => ImportContents): string; + } + export function loadRemoteVersion( + versionName: string, + cb: (err: SolcError | null, res?: SolcInstance) => void, + ): void; + export function setupMethods(solcBin: any): SolcInstance; +} diff --git a/packages/typescript-typings/types/to-snake-case/index.d.ts b/packages/typescript-typings/types/to-snake-case/index.d.ts new file mode 100644 index 000000000..39df3f852 --- /dev/null +++ b/packages/typescript-typings/types/to-snake-case/index.d.ts @@ -0,0 +1,4 @@ +declare function toSnakeCase(str: string): string; +declare module 'to-snake-case' { + export = toSnakeCase; +} diff --git a/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts b/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts new file mode 100644 index 000000000..007df61e0 --- /dev/null +++ b/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts @@ -0,0 +1,11 @@ +declare module 'truffle-hdwallet-provider' { + import { JSONRPCRequestPayload, JSONRPCResponsePayload, Provider } from 'ethereum-types'; + class HDWalletProvider implements Provider { + constructor(mnemonic: string, rpcUrl: string); + public sendAsync( + payload: JSONRPCRequestPayload, + callback: (err: Error, result: JSONRPCResponsePayload) => void, + ): void; + } + export = HDWalletProvider; +} diff --git a/packages/typescript-typings/types/web3-eth-abi/index.d.ts b/packages/typescript-typings/types/web3-eth-abi/index.d.ts new file mode 100644 index 000000000..5d2f46e04 --- /dev/null +++ b/packages/typescript-typings/types/web3-eth-abi/index.d.ts @@ -0,0 +1,3 @@ +declare module 'web3-eth-abi' { + export function encodeParameters(typesArray: string[], parameters: any[]): string; +} diff --git a/packages/typescript-typings/types/web3/index.d.ts b/packages/typescript-typings/types/web3/index.d.ts new file mode 100644 index 000000000..4085c71a7 --- /dev/null +++ b/packages/typescript-typings/types/web3/index.d.ts @@ -0,0 +1,231 @@ +declare module 'web3' { + import * as BigNumber from 'bignumber.js'; + import { + AbiDefinition, + BlockWithTransactionData, + BlockWithoutTransactionData, + BlockParam, + CallData, + Provider, + Unit, + TxData, + Transaction, + ContractAbi, + TransactionReceipt, + FilterObject, + LogEntryEvent, + JSONRPCRequestPayload, + JSONRPCResponsePayload, + } from 'ethereum-types'; + + type MixedData = string | number | object | any[] | BigNumber.BigNumber; + + class Web3 { + public static providers: typeof providers; + public currentProvider: Provider; + + public eth: Web3.EthApi; + public personal: Web3.PersonalApi | undefined; + public version: Web3.VersionApi; + public net: Web3.NetApi; + + public constructor(provider?: Provider); + + public isConnected(): boolean; + public setProvider(provider: Provider): void; + public reset(keepIsSyncing: boolean): void; + public toHex(data: MixedData): string; + public toAscii(hex: string): string; + public fromAscii(ascii: string, padding?: number): string; + public toDecimal(hex: string): number; + public fromDecimal(value: number | string): string; + 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; + public sha3(value: string, options?: Web3.Sha3Options): string; + } + + namespace providers { + class HttpProvider implements Provider { + constructor(url?: string, timeout?: number, username?: string, password?: string); + public sendAsync( + payload: JSONRPCRequestPayload, + callback: (err: Error, result: JSONRPCResponsePayload) => void, + ): void; + } + } + + namespace Web3 { + interface ContractInstance { + address: string; + abi: ContractAbi; + [name: string]: any; + } + + interface Contract { + at(address: string): A; + getData(...args: any[]): string; + 'new'(...args: any[]): A; + } + + interface FilterResult { + get(callback: () => void): void; + watch(callback: (err: Error, result: LogEntryEvent) => void): void; + stopWatching(callback?: () => void): void; + } + + interface Sha3Options { + encoding: 'hex'; + } + + interface EthApi { + coinbase: string; + mining: boolean; + hashrate: number; + gasPrice: BigNumber.BigNumber; + accounts: string[]; + blockNumber: number; + defaultAccount?: string; + defaultBlock: BlockParam; + syncing: Web3.SyncingResult; + compile: { + solidity(sourceString: string, cb?: (err: Error, result: any) => void): object; + }; + getMining(cd: (err: Error, mining: boolean) => void): void; + getHashrate(cd: (err: Error, hashrate: number) => void): void; + getGasPrice(cd: (err: Error, gasPrice: BigNumber.BigNumber) => void): void; + getAccounts(cd: (err: Error, accounts: string[]) => void): void; + getBlockNumber(callback: (err: Error, blockNumber: number) => void): void; + getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void; + isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing; + + getBlock(hashStringOrBlockNumber: string | BlockParam): BlockWithoutTransactionData; + getBlock( + hashStringOrBlockNumber: string | BlockParam, + callback: (err: Error, blockObj: BlockWithoutTransactionData) => void, + ): void; + getBlock( + hashStringOrBlockNumber: string | BlockParam, + returnTransactionObjects: true, + ): BlockWithTransactionData; + getBlock( + hashStringOrBlockNumber: string | BlockParam, + returnTransactionObjects: true, + callback: (err: Error, blockObj: BlockWithTransactionData) => void, + ): void; + + getBlockTransactionCount(hashStringOrBlockNumber: string | BlockParam): number; + getBlockTransactionCount( + hashStringOrBlockNumber: string | BlockParam, + callback: (err: Error, blockTransactionCount: number) => void, + ): void; + + // TODO returnTransactionObjects + getUncle(hashStringOrBlockNumber: string | BlockParam, uncleNumber: number): BlockWithoutTransactionData; + getUncle( + hashStringOrBlockNumber: string | BlockParam, + uncleNumber: number, + callback: (err: Error, uncle: BlockWithoutTransactionData) => 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 | BlockParam, + indexNumber: number, + callback: (err: Error, transaction: Transaction) => void, + ): void; + + contract(abi: AbiDefinition[]): Web3.Contract; + + // TODO block param + getBalance(addressHexString: string): BigNumber.BigNumber; + getBalance(addressHexString: string, callback: (err: Error, result: BigNumber.BigNumber) => void): void; + + // TODO block param + getStorageAt(address: string, position: number): string; + getStorageAt(address: string, position: number, callback: (err: Error, storage: string) => void): void; + + // TODO block param + getCode(addressHexString: string): string; + getCode(addressHexString: string, callback: (err: Error, code: string) => void): void; + + filter(value: string | FilterObject): Web3.FilterResult; + + 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; + + sign(address: string, data: string): string; + sign(address: string, data: string, callback: (err: Error, signature: string) => void): void; + + getTransactionReceipt(txHash: string): TransactionReceipt | null; + getTransactionReceipt( + txHash: string, + callback: (err: Error, receipt: TransactionReceipt | null) => void, + ): void; + + // TODO block param + call(callData: CallData): string; + call(callData: CallData, callback: (err: Error, result: string) => void): void; + + estimateGas(callData: CallData): number; + estimateGas(callData: CallData, callback: (err: Error, gas: number) => void): void; + + // TODO defaultBlock + getTransactionCount(address: string): number; + getTransactionCount(address: string, callback: (err: Error, count: number) => void): void; + } + + interface VersionApi { + api: string; + network: string; + node: string; + ethereum: string; + whisper: string; + getNetwork(cd: (err: Error, networkId: string) => void): void; + getNode(cd: (err: Error, nodeVersion: string) => void): void; + getEthereum(cd: (err: Error, ethereum: string) => void): void; + getWhisper(cd: (err: Error, whisper: string) => void): void; + } + + interface PersonalApi { + listAccounts: string[] | undefined; + newAccount(password?: string): string; + unlockAccount(address: string, password?: string, duration?: number): boolean; + lockAccount(address: string): boolean; + sign(message: string, account: string, password: string): string; + sign(hexMessage: string, account: string, callback: (error: Error, signature: string) => void): void; + } + + interface NetApi { + listening: boolean; + peerCount: number; + getListening(cd: (err: Error, listening: boolean) => void): void; + getPeerCount(cd: (err: Error, peerCount: number) => void): void; + } + + interface SyncingState { + startingBlock: number; + currentBlock: number; + highestBlock: number; + } + type SyncingResult = false | SyncingState; + + interface IsSyncing { + addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void; + stopWatching(): void; + } + } + /* tslint:disable */ + export = Web3; + /* tslint:enable */ +} -- cgit