From 34c1134b55c202b47ac4672a4c9025e4be9e21b4 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 26 Feb 2018 17:03:09 -0800 Subject: Create ethers-typescript-typings --- packages/0x.js/src/globals.d.ts | 29 ------------- packages/contracts/globals.d.ts | 29 ------------- packages/ethers-typescript-typings/.npmignore | 3 ++ packages/ethers-typescript-typings/CHANGELOG.md | 5 +++ packages/ethers-typescript-typings/README.md | 49 ++++++++++++++++++++++ packages/ethers-typescript-typings/index.d.ts | 29 +++++++++++++ packages/ethers-typescript-typings/package.json | 28 +++++++++++++ .../scripts/postpublish.js | 5 +++ packages/ethers-typescript-typings/tslint.json | 3 ++ packages/utils/src/globals.d.ts | 28 ------------- 10 files changed, 122 insertions(+), 86 deletions(-) create mode 100644 packages/ethers-typescript-typings/.npmignore create mode 100644 packages/ethers-typescript-typings/CHANGELOG.md create mode 100644 packages/ethers-typescript-typings/README.md create mode 100644 packages/ethers-typescript-typings/index.d.ts create mode 100644 packages/ethers-typescript-typings/package.json create mode 100644 packages/ethers-typescript-typings/scripts/postpublish.js create mode 100644 packages/ethers-typescript-typings/tslint.json delete mode 100644 packages/utils/src/globals.d.ts diff --git a/packages/0x.js/src/globals.d.ts b/packages/0x.js/src/globals.d.ts index 505f9b933..0e103d057 100644 --- a/packages/0x.js/src/globals.d.ts +++ b/packages/0x.js/src/globals.d.ts @@ -41,32 +41,3 @@ declare module 'truffle-hdwallet-provider' { } export = HDWalletProvider; } - -declare module 'ethers-contracts' { - export interface TransactionDescription { - name: string; - signature: string; - sighash: string; - data: string; - } - export interface CallDescription extends TransactionDescription { - parse: (...args: any[]) => any; - } - export interface FunctionDescription { - (...params: any[]): TransactionDescription | CallDescription; - inputs: { names: string[]; types: string[] }; - outputs: { names: string[]; types: string[] }; - } - export interface EventDescription { - inputs: { names: string[]; types: string[] }; - signature: string; - topic: string; - } - // tslint:disable-next-line:max-classes-per-file - export class Interface { - public functions: { [functionName: string]: FunctionDescription }; - public events: { [eventName: string]: EventDescription }; - public static decodeParams(types: string[], data: string): any[]; - constructor(abi: any); - } -} diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts index beb3bfd8c..0e6586a4b 100644 --- a/packages/contracts/globals.d.ts +++ b/packages/contracts/globals.d.ts @@ -32,32 +32,3 @@ declare module 'ethereumjs-abi' { const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; const methodID: (name: string, types: string[]) => Buffer; } - -declare module 'ethers-contracts' { - export interface TransactionDescription { - name: string; - signature: string; - sighash: string; - data: string; - } - export interface CallDescription extends TransactionDescription { - parse: (...args: any[]) => any; - } - export interface FunctionDescription { - (...params: any[]): TransactionDescription | CallDescription; - inputs: { names: string[]; types: string[] }; - outputs: { names: string[]; types: string[] }; - } - export interface EventDescription { - inputs: { names: string[]; types: string[] }; - signature: string; - topic: string; - } - // tslint:disable-next-line:max-classes-per-file - export class Interface { - public functions: { [functionName: string]: FunctionDescription }; - public events: { [eventName: string]: EventDescription }; - public static decodeParams(types: string[], data: string): any[]; - constructor(abi: any); - } -} diff --git a/packages/ethers-typescript-typings/.npmignore b/packages/ethers-typescript-typings/.npmignore new file mode 100644 index 000000000..104d718ed --- /dev/null +++ b/packages/ethers-typescript-typings/.npmignore @@ -0,0 +1,3 @@ +.* +yarn-error.log +/scripts/ diff --git a/packages/ethers-typescript-typings/CHANGELOG.md b/packages/ethers-typescript-typings/CHANGELOG.md new file mode 100644 index 000000000..d67d5c73d --- /dev/null +++ b/packages/ethers-typescript-typings/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## v0.0.1 - _TBD, 2018_ + + * Initial types (#413) diff --git a/packages/ethers-typescript-typings/README.md b/packages/ethers-typescript-typings/README.md new file mode 100644 index 000000000..56ce5f138 --- /dev/null +++ b/packages/ethers-typescript-typings/README.md @@ -0,0 +1,49 @@ +## ethers-typescript-typings + +There currently isn't an official [Ethers][ethers] +type definition included in the [DefinitelyTyped][definitelytyped] project. +Until that happens, we will continue to improve our own type definition. +If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped]. + +[ethers]: https://github.com/ethers-io/ethers.js +[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped + +## Installation + +```bash +yarn add -D ethers-typescript-typings +``` + +## Usage + +Add the following line within an `include` section of your `tsconfig.json` + +```json +"./node_modules/ethers-typescript-typings/index.d.ts" +``` + +## Contributing + +We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Lint + +```bash +yarn lint +``` diff --git a/packages/ethers-typescript-typings/index.d.ts b/packages/ethers-typescript-typings/index.d.ts new file mode 100644 index 000000000..f4f99b890 --- /dev/null +++ b/packages/ethers-typescript-typings/index.d.ts @@ -0,0 +1,29 @@ +declare module 'ethers-contracts' { + export interface TransactionDescription { + name: string; + signature: string; + sighash: string; + data: string; + } + export interface CallDescription extends TransactionDescription { + parse: (...args: any[]) => any; + } + export interface FunctionDescription { + (...params: any[]): TransactionDescription | CallDescription; + inputs: { names: string[]; types: string[] }; + outputs: { names: string[]; types: string[] }; + } + export interface EventDescription { + parse: (...args: any[]) => any; + inputs: { names: string[]; types: string[] }; + signature: string; + topic: string; + } + // tslint:disable-next-line:max-classes-per-file + export class Interface { + public functions: { [functionName: string]: FunctionDescription }; + public events: { [eventName: string]: EventDescription }; + public static decodeParams(types: string[], data: string): any[]; + constructor(abi: any); + } +} diff --git a/packages/ethers-typescript-typings/package.json b/packages/ethers-typescript-typings/package.json new file mode 100644 index 000000000..0e6f517c8 --- /dev/null +++ b/packages/ethers-typescript-typings/package.json @@ -0,0 +1,28 @@ +{ + "name": "ethers-typescript-typings", + "version": "0.0.1", + "description": "Typescript type definitions for ethers.js", + "main": "index.d.ts", + "types": "index.d.ts", + "scripts": { + "lint": "tslint index.d.ts" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/0xProject/0x.js.git" + }, + "author": "Fabio Berger", + "contributors": [ + "Leonid Logvinov " + ], + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x.js/issues" + }, + "homepage": "https://github.com/0xProject/0x.js/packages/ethers-typescript-typings#readme", + "devDependencies": { + "tslint": "5.8.0", + "tslint-config-0xproject": "^0.0.2", + "typescript": "2.7.1" + } +} diff --git a/packages/ethers-typescript-typings/scripts/postpublish.js b/packages/ethers-typescript-typings/scripts/postpublish.js new file mode 100644 index 000000000..b3e5407c8 --- /dev/null +++ b/packages/ethers-typescript-typings/scripts/postpublish.js @@ -0,0 +1,5 @@ +const postpublish_utils = require('../../../scripts/postpublish_utils'); +const packageJSON = require('../package.json'); + +const subPackageName = packageJSON.name; +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/ethers-typescript-typings/tslint.json b/packages/ethers-typescript-typings/tslint.json new file mode 100644 index 000000000..9a93a1f74 --- /dev/null +++ b/packages/ethers-typescript-typings/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["tslint-config-0xproject"] +} diff --git a/packages/utils/src/globals.d.ts b/packages/utils/src/globals.d.ts deleted file mode 100644 index 951ef6ea2..000000000 --- a/packages/utils/src/globals.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -declare module 'ethers-contracts' { - export interface TransactionDescription { - name: string; - signature: string; - sighash: string; - data: string; - } - export interface CallDescription extends TransactionDescription { - parse: (...args: any[]) => any; - } - export interface FunctionDescription { - (...params: any[]): TransactionDescription | CallDescription; - inputs: { names: string[]; types: string[] }; - outputs: { names: string[]; types: string[] }; - } - export interface EventDescription { - parse: (...args: any[]) => any; - inputs: { names: string[]; types: string[] }; - signature: string; - topic: string; - } - // tslint:disable-next-line:max-classes-per-file - export class Interface { - public functions: { [functionName: string]: FunctionDescription }; - public events: { [eventName: string]: EventDescription }; - constructor(abi: any); - } -} -- cgit v1.2.3