diff --git a/types/ethereumjs-util/ethereumjs-util-tests.ts b/types/ethereumjs-util/ethereumjs-util-tests.ts new file mode 100644 index 0000000000..5159dcf758 --- /dev/null +++ b/types/ethereumjs-util/ethereumjs-util-tests.ts @@ -0,0 +1,4 @@ +import * as assert from "assert"; +import * as etherUtil from "ethereumjs-util"; + +assert.ok(etherUtil.isValidAddress("0x0bfe6d9a4d4a73857db6fac276669ba45ee69b48")); diff --git a/types/ethereumjs-util/index.d.ts b/types/ethereumjs-util/index.d.ts new file mode 100644 index 0000000000..7a29b38ff5 --- /dev/null +++ b/types/ethereumjs-util/index.d.ts @@ -0,0 +1,83 @@ +// Type definitions for ethereumjs-util 5.1 +// Project: https://github.com/ethereumjs/ethereumjs-util#readme +// Definitions by: Juan J. Jimenez-Anca +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +// TODO: import types for [`BN`](https://github.com/indutny/bn.js) +// TODO: MAX_INTEGER as type of BN +// TODO: import types for [`rlp`](https://github.com/ethereumjs/rlp) +// TODO: import types for [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/) + +export const SHA3_NULL_S: string; + +export const SHA3_RLP_ARRAY_S: string; + +export const SHA3_RLP_S: string; + +export function addHexPrefix(str: string): string; + +export function arrayContainsArray(superset: any, subset: any, some: any): any; + +export function baToJSON(ba: Buffer | string[]): Buffer | string[]; + +export function bufferToHex(buf: Buffer): string; + +export function bufferToInt(buf: Buffer): string; + +export function defineProperties(self: {[k: string]: any}, fields: string[], data: {[k: string]: any}): {[k: string]: any}; + +export function ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer): Buffer; + +export function ecsign(msgHash: Buffer, privateKey: Buffer): {[k: string]: any}; + +export function fromRpcSig(sig: string): {[k: string]: any}; + +export function fromSigned(num: Buffer): any; + +export function generateAddress(from: Buffer, nonce: Buffer): Buffer; + +export function hashPersonalMessage(message: string): Buffer; + +export function importPublic(publicKey: Buffer): Buffer; + +export function isValidAddress(address: string): boolean; + +export function isValidChecksumAddress(address: Buffer): boolean; + +export function isValidPrivate(privateKey: Buffer): boolean; + +export function isValidPublic(publicKey: Buffer, sanitize?: boolean): any; + +export function isValidSignature(v: Buffer, r: Buffer, s: Buffer, homestead?: boolean): boolean; + +export function privateToAddress(privateKey: Buffer): Buffer; + +export function privateToPublic(privateKey: Buffer): Buffer; + +export function pubToAddress(pubKey: Buffer, sanitize: boolean): Buffer; + +export function ripemd160(a: Buffer | any[] | string | number, padded: boolean): Buffer; + +export function rlphash(a: Buffer | any[] | string | number): Buffer; + +export function setLengthLeft(msg: Buffer | any[], length: number, right?: boolean): Buffer | any[]; + +export function setLengthRight(msg: Buffer | any[], length: number): Buffer | any[]; + +export function sha256(a: Buffer | any[] | string | number): Buffer; + +export function sha3(a: Buffer | any[] | string | number, bits?: number): Buffer; + +export function toBuffer(v: any): Buffer; + +export function toChecksumAddress(address: string): string; + +export function toRpcSig(v: number, r: Buffer, s: Buffer): string; + +export function toUnsigned(num: any): Buffer; + +export function unpad(a: T): T; + +export function zeros(bytes: number): Buffer; diff --git a/types/ethereumjs-util/tsconfig.json b/types/ethereumjs-util/tsconfig.json new file mode 100644 index 0000000000..53f8c15b5b --- /dev/null +++ b/types/ethereumjs-util/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ethereumjs-util-tests.ts" + ] +} \ No newline at end of file diff --git a/types/ethereumjs-util/tslint.json b/types/ethereumjs-util/tslint.json new file mode 100644 index 0000000000..4547f250b4 --- /dev/null +++ b/types/ethereumjs-util/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-empty-interface": false + } +}