From 4d9029bb0e3b215efdf165704c80d3bacef0e85a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 28 Mar 2018 11:05:36 +0200 Subject: Add metacoin example project --- packages/typescript-typings/types/bn.js/index.d.ts | 57 ++++++++++++ .../types/chai-bignumber/index.d.ts | 1 + packages/typescript-typings/types/chai/index.d.ts | 5 +- .../typescript-typings/types/dirty-chai/index.d.ts | 1 + .../types/ethereumjs-abi/index.d.ts | 5 + .../types/ethereumjs-tx/index.d.ts | 14 +++ .../types/ethereumjs-util/index.d.ts | 101 +++++++++++++++++++++ packages/typescript-typings/types/solc/index.d.ts | 38 ++++++++ .../types/truffle-hdwalet-provider/index.d.ts | 12 +++ .../types/web3-eth-abi/index.d.ts | 3 + .../types/web3-provider-engine/index.d.ts | 11 +++ 11 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 packages/typescript-typings/types/bn.js/index.d.ts create mode 100644 packages/typescript-typings/types/chai-bignumber/index.d.ts create mode 100644 packages/typescript-typings/types/dirty-chai/index.d.ts create mode 100644 packages/typescript-typings/types/ethereumjs-abi/index.d.ts create mode 100644 packages/typescript-typings/types/ethereumjs-tx/index.d.ts create mode 100644 packages/typescript-typings/types/ethereumjs-util/index.d.ts create mode 100644 packages/typescript-typings/types/solc/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-provider-engine/index.d.ts (limited to 'packages/typescript-typings') diff --git a/packages/typescript-typings/types/bn.js/index.d.ts b/packages/typescript-typings/types/bn.js/index.d.ts new file mode 100644 index 000000000..f59b74bad --- /dev/null +++ b/packages/typescript-typings/types/bn.js/index.d.ts @@ -0,0 +1,57 @@ +declare module 'bn.js' { + import { Buffer } from 'buffer'; + + type Endianness = 'le' | 'be'; + + class BN { + constructor(num: number | string | number[] | Buffer, base?: number, endian?: Endianness); + public clone(): BN; + public toString(base?: number, length?: number): string; + public toNumber(): number; + public toJSON(): string; + public toArray(endian?: Endianness, length?: number): number[]; + public toBuffer(endian?: Endianness, length?: number): Buffer; + public bitLength(): number; + public zeroBits(): number; + public byteLength(): number; + public isNeg(): boolean; + public isEven(): boolean; + public isOdd(): boolean; + public isZero(): boolean; + public cmp(b: any): number; + public lt(b: any): boolean; + public lte(b: any): boolean; + public gt(b: any): boolean; + public gte(b: any): boolean; + public eq(b: any): boolean; + public isBN(b: any): boolean; + + public neg(): BN; + public abs(): BN; + public add(b: BN): BN; + public sub(b: BN): BN; + public mul(b: BN): BN; + public sqr(): BN; + public pow(b: BN): BN; + public div(b: BN): BN; + public mod(b: BN): BN; + public divRound(b: BN): BN; + + public or(b: BN): BN; + public and(b: BN): BN; + public xor(b: BN): BN; + public setn(b: number): BN; + public shln(b: number): BN; + public shrn(b: number): BN; + public testn(b: number): boolean; + public maskn(b: number): BN; + public bincn(b: number): BN; + public notn(w: number): BN; + + public gcd(b: BN): BN; + public egcd(b: BN): { a: BN; b: BN; gcd: BN }; + public invm(b: BN): BN; + } + + export = BN; +} 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 index 8b3e4c079..3bde1f27c 100644 --- a/packages/typescript-typings/types/chai/index.d.ts +++ b/packages/typescript-typings/types/chai/index.d.ts @@ -114,6 +114,9 @@ declare namespace Chai { 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; } @@ -148,7 +151,7 @@ declare namespace Chai { } interface NumberComparer { - (value: number, message?: string): Assertion; + (value: number | object, message?: string): Assertion; } interface TypeComparison { 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/ethereumjs-abi/index.d.ts b/packages/typescript-typings/types/ethereumjs-abi/index.d.ts new file mode 100644 index 000000000..e3d660a4a --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-abi/index.d.ts @@ -0,0 +1,5 @@ +declare module 'ethereumjs-abi' { + const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; + const soliditySHA256: (argTypes: string[], args: any[]) => Buffer; + const methodID: (name: string, types: string[]) => Buffer; +} diff --git a/packages/typescript-typings/types/ethereumjs-tx/index.d.ts b/packages/typescript-typings/types/ethereumjs-tx/index.d.ts new file mode 100644 index 000000000..1b99d06d9 --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-tx/index.d.ts @@ -0,0 +1,14 @@ +declare module 'ethereumjs-tx' { + class EthereumTx { + public raw: Buffer[]; + public r: Buffer; + public s: Buffer; + public v: Buffer; + public nonce: Buffer; + public serialize(): Buffer; + public sign(buffer: Buffer): void; + public getSenderAddress(): Buffer; + constructor(txParams: any); + } + export = EthereumTx; +} 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..fae55c418 --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-util/index.d.ts @@ -0,0 +1,101 @@ +declare module 'ethereumjs-util' { + import { Buffer } from 'buffer'; + 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/solc/index.d.ts b/packages/typescript-typings/types/solc/index.d.ts new file mode 100644 index 000000000..fcef24b9f --- /dev/null +++ b/packages/typescript-typings/types/solc/index.d.ts @@ -0,0 +1,38 @@ +declare module 'solc' { + 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 SolcInstance { + compile( + sources: InputSources, + optimizerEnabled: number, + findImports: (importPath: string) => ImportContents, + ): CompilationResult; + } + export function loadRemoteVersion(versionName: string, cb: (err: Error | null, res?: SolcInstance) => void): void; + export function setupMethods(solcBin: any): SolcInstance; +} 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..f2b002233 --- /dev/null +++ b/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts @@ -0,0 +1,12 @@ +declare module 'truffle-hdwallet-provider' { + import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; + import * as Web3 from 'web3'; + class HDWalletProvider implements Web3.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-provider-engine/index.d.ts b/packages/typescript-typings/types/web3-provider-engine/index.d.ts new file mode 100644 index 000000000..f30b06873 --- /dev/null +++ b/packages/typescript-typings/types/web3-provider-engine/index.d.ts @@ -0,0 +1,11 @@ +declare module 'web3-provider-engine' { + class Web3ProviderEngine { + public on(event: string, handler: () => void): void; + public send(payload: any): void; + public sendAsync(payload: any, callback: (error: any, response: any) => void): void; + public addProvider(provider: any): void; + public start(): void; + public stop(): void; + } + export = Web3ProviderEngine; +} -- cgit v1.2.3