aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/web3-typescript-typings/LICENSE13
-rw-r--r--packages/web3-typescript-typings/README.md56
-rw-r--r--packages/web3-typescript-typings/package.json58
-rw-r--r--packages/web3-typescript-typings/tslint.json4
-rw-r--r--packages/web3-typescript-typings/web3/index.d.ts150
-rw-r--r--yarn.lock16
6 files changed, 171 insertions, 126 deletions
diff --git a/packages/web3-typescript-typings/LICENSE b/packages/web3-typescript-typings/LICENSE
deleted file mode 100644
index fcdd2b880..000000000
--- a/packages/web3-typescript-typings/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2017 ZeroEx Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/packages/web3-typescript-typings/README.md b/packages/web3-typescript-typings/README.md
index 8d92aa681..e26bf87e4 100644
--- a/packages/web3-typescript-typings/README.md
+++ b/packages/web3-typescript-typings/README.md
@@ -1,25 +1,49 @@
-Web3 Typescript Type Definition
--------------------------------
+## web3-typescript-typings
-There currently isn't an official [Web3][Web3]
-type definition included in the [DefinitelyTyped][DefinitelyTyped] project.
+There currently isn't an official [Web3][web3]
+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].
+If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped].
-[Web3]: https://github.com/ethereum/web3.js/
-[DefinitelyTyped]: https://github.com/DefinitelyTyped/DefinitelyTyped
+[web3]: https://github.com/ethereum/web3.js/
+[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped
-# Installation
-Using npm:
-```
-npm install --save-dev web3-typescript-typings
+## Installation
+
+```bash
+yarn add -D web3-typescript-typings
```
-Using yarn:
+
+## Usage
+
+Add the following lines to compilerOptions section of your `tsconfig.json`
+
+```json
+"typeRoots": ["node_modules/@types", "node_modules/web3-typescript-typings"]
```
-yarn add web3-typescript-typings -D
+
+## 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
```
-Also don't forget to manually include the definitions within the `typeRoots` section of your `tsconfig.json`
+
+Then install dependencies
+
+```bash
+yarn install
```
-"typeRoots": ["node_modules/@types", "node_modules/web3-typescript-typings"]
+
+### Lint
+
+```bash
+yarn lint
```
-And you're ready to go to a bright type-safe and distributed future!
diff --git a/packages/web3-typescript-typings/package.json b/packages/web3-typescript-typings/package.json
index 29bcb964c..f93382fc7 100644
--- a/packages/web3-typescript-typings/package.json
+++ b/packages/web3-typescript-typings/package.json
@@ -1,32 +1,30 @@
{
- "name": "web3-typescript-typings",
- "version": "0.9.0",
- "description": "Typescript type definitions for web3",
- "main": "web3/index.d.ts",
- "types": "web3/index.d.ts",
- "scripts": {
- "lint": "tslint web3/index.d.ts"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/0xProject/web3-typescript-typings.git"
- },
- "author": "Fabio Berger",
- "contributors": [
- "Leonid Logvinov <logvinov.leon@gmail.com>"
- ],
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/web3-typescript-typings/issues"
- },
- "homepage": "https://github.com/0xProject/web3-typescript-typings#readme",
- "devDependencies": {
- "@types/bignumber.js": "^4.0.2",
- "tslint": "^5.5.0",
- "tslint-config-0xproject": "^0.0.2",
- "typescript": "^2.4.2"
- },
- "dependencies": {
- "bignumber.js": "^4.0.2"
- }
+ "name": "web3-typescript-typings",
+ "version": "0.9.0",
+ "description": "Typescript type definitions for web3",
+ "main": "web3/index.d.ts",
+ "types": "web3/index.d.ts",
+ "scripts": {
+ "lint": "tslint web3/index.d.ts"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/0xProject/web3-typescript-typings.git"
+ },
+ "author": "Fabio Berger",
+ "contributors": ["Leonid Logvinov <logvinov.leon@gmail.com>"],
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/web3-typescript-typings/issues"
+ },
+ "homepage": "https://github.com/0xProject/web3-typescript-typings#readme",
+ "devDependencies": {
+ "@types/bignumber.js": "^4.0.2",
+ "tslint": "^5.5.0",
+ "tslint-config-0xproject": "^0.0.2",
+ "typescript": "^2.4.2"
+ },
+ "dependencies": {
+ "bignumber.js": "~4.1.0"
+ }
}
diff --git a/packages/web3-typescript-typings/tslint.json b/packages/web3-typescript-typings/tslint.json
index 5842a872a..9a93a1f74 100644
--- a/packages/web3-typescript-typings/tslint.json
+++ b/packages/web3-typescript-typings/tslint.json
@@ -1,5 +1,3 @@
{
- "extends": [
- "tslint-config-0xproject"
- ]
+ "extends": ["tslint-config-0xproject"]
}
diff --git a/packages/web3-typescript-typings/web3/index.d.ts b/packages/web3-typescript-typings/web3/index.d.ts
index 8ecb8420f..6fd126d2a 100644
--- a/packages/web3-typescript-typings/web3/index.d.ts
+++ b/packages/web3-typescript-typings/web3/index.d.ts
@@ -1,8 +1,7 @@
declare module 'web3' {
-
import * as BigNumber from 'bignumber.js';
- type MixedData = string|number|object|any[]|BigNumber.BigNumber;
+ type MixedData = string | number | object | any[] | BigNumber.BigNumber;
class Web3 {
public static providers: typeof providers;
@@ -22,12 +21,12 @@ declare module 'web3' {
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: Web3.Unit): string;
+ public fromDecimal(value: number | string): string;
+ public fromWei(value: number | string, unit: Web3.Unit): string;
public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber;
- public toWei(amount: number|string, unit: Web3.Unit): string;
+ public toWei(amount: number | string, unit: Web3.Unit): string;
public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber;
- public toBigNumber(value: number|string): 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;
@@ -46,9 +45,9 @@ declare module 'web3' {
namespace Web3 {
type ContractAbi = AbiDefinition[];
- type AbiDefinition = FunctionAbi|EventAbi;
+ type AbiDefinition = FunctionAbi | EventAbi;
- type FunctionAbi = MethodAbi|ConstructorAbi|FallbackAbi;
+ type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
enum AbiType {
Function = 'function',
@@ -112,13 +111,13 @@ declare module 'web3' {
}
interface FilterObject {
- fromBlock?: number|string;
- toBlock?: number|string;
+ fromBlock?: number | string;
+ toBlock?: number | string;
address?: string;
topics?: LogTopic[];
}
- type LogTopic = null|string|string[];
+ type LogTopic = null | string | string[];
interface DecodedLogEntry<A> extends LogEntry {
event: string;
@@ -174,7 +173,7 @@ declare module 'web3' {
defaultBlock: Web3.BlockParam;
syncing: Web3.SyncingResult;
compile: {
- solidity(sourceString: string, cb?: (err: Error, result: any) => void): object,
+ 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;
@@ -184,32 +183,53 @@ declare module 'web3' {
getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void;
isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing;
- getBlock(hashStringOrBlockNumber: string|Web3.BlockParam): Web3.BlockWithoutTransactionData;
- getBlock(hashStringOrBlockNumber: string|Web3.BlockParam,
- callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void): void;
- getBlock(hashStringOrBlockNumber: string|Web3.BlockParam,
- returnTransactionObjects: true): Web3.BlockWithTransactionData;
- getBlock(hashStringOrBlockNumber: string|Web3.BlockParam, returnTransactionObjects: true,
- callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void): void;
+ getBlock(hashStringOrBlockNumber: string | Web3.BlockParam): Web3.BlockWithoutTransactionData;
+ getBlock(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void,
+ ): void;
+ getBlock(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ returnTransactionObjects: true,
+ ): Web3.BlockWithTransactionData;
+ getBlock(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ returnTransactionObjects: true,
+ callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void,
+ ): void;
- getBlockTransactionCount(hashStringOrBlockNumber: string|Web3.BlockParam): number;
- getBlockTransactionCount(hashStringOrBlockNumber: string|Web3.BlockParam,
- callback: (err: Error, blockTransactionCount: number) => void): void;
+ getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number;
+ getBlockTransactionCount(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ callback: (err: Error, blockTransactionCount: number) => void,
+ ): void;
// TODO returnTransactionObjects
- getUncle(hashStringOrBlockNumber: string|Web3.BlockParam,
- uncleNumber: number): Web3.BlockWithoutTransactionData;
- getUncle(hashStringOrBlockNumber: string|Web3.BlockParam, uncleNumber: number,
- callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void): void;
+ getUncle(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ uncleNumber: number,
+ ): Web3.BlockWithoutTransactionData;
+ getUncle(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ uncleNumber: number,
+ callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void,
+ ): void;
getTransaction(transactionHash: string): Web3.Transaction;
- getTransaction(transactionHash: string,
- callback: (err: Error, transaction: Web3.Transaction) => void): void;
+ getTransaction(
+ transactionHash: string,
+ callback: (err: Error, transaction: Web3.Transaction) => void,
+ ): void;
- getTransactionFromBlock(hashStringOrBlockNumber: string|Web3.BlockParam,
- indexNumber: number): Web3.Transaction;
- getTransactionFromBlock(hashStringOrBlockNumber: string|Web3.BlockParam, indexNumber: number,
- callback: (err: Error, transaction: Web3.Transaction) => void): void;
+ getTransactionFromBlock(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ indexNumber: number,
+ ): Web3.Transaction;
+ getTransactionFromBlock(
+ hashStringOrBlockNumber: string | Web3.BlockParam,
+ indexNumber: number,
+ callback: (err: Error, transaction: Web3.Transaction) => void,
+ ): void;
contract(abi: Web3.AbiDefinition[]): Web3.Contract<any>;
@@ -225,7 +245,7 @@ declare module 'web3' {
getCode(addressHexString: string): string;
getCode(addressHexString: string, callback: (err: Error, code: string) => void): void;
- filter(value: string|Web3.FilterObject): Web3.FilterResult;
+ filter(value: string | Web3.FilterObject): Web3.FilterResult;
sendTransaction(txData: Web3.TxData): string;
sendTransaction(txData: Web3.TxData, callback: (err: Error, value: string) => void): void;
@@ -237,8 +257,10 @@ declare module 'web3' {
sign(address: string, data: string, callback: (err: Error, signature: string) => void): void;
getTransactionReceipt(txHash: string): Web3.TransactionReceipt;
- getTransactionReceipt(txHash: string,
- callback: (err: Error, receipt: Web3.TransactionReceipt) => void): void;
+ getTransactionReceipt(
+ txHash: string,
+ callback: (err: Error, receipt: Web3.TransactionReceipt) => void,
+ ): void;
// TODO block param
call(callData: Web3.CallData): string;
@@ -280,17 +302,31 @@ declare module 'web3' {
getPeerCount(cd: (err: Error, peerCount: number) => void): void;
}
- type BlockParam = number|'earliest'|'latest'|'pending';
-
- type Unit = 'kwei'|'ada'|'mwei'|'babbage'|'gwei'|'shannon'|'szabo'|'finney'|
- 'ether'|'kether'|'grand'|'einstein'|'mether'|'gether'|'tether';
+ type BlockParam = number | 'earliest' | 'latest' | 'pending';
+
+ type Unit =
+ | 'kwei'
+ | 'ada'
+ | 'mwei'
+ | 'babbage'
+ | 'gwei'
+ | 'shannon'
+ | 'szabo'
+ | 'finney'
+ | 'ether'
+ | 'kether'
+ | 'grand'
+ | 'einstein'
+ | 'mether'
+ | 'gether'
+ | 'tether';
interface SyncingState {
startingBlock: number;
currentBlock: number;
highestBlock: number;
}
- type SyncingResult = false|SyncingState;
+ type SyncingResult = false | SyncingState;
interface IsSyncing {
addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void;
@@ -298,12 +334,12 @@ declare module 'web3' {
}
interface AbstractBlock {
- number: number|null;
- hash: string|null;
+ number: number | null;
+ hash: string | null;
parentHash: string;
- nonce: string|null;
+ nonce: string | null;
sha3Uncles: string;
- logsBloom: string|null;
+ logsBloom: string | null;
transactionsRoot: string;
stateRoot: string;
miner: string;
@@ -326,11 +362,11 @@ declare module 'web3' {
interface Transaction {
hash: string;
nonce: number;
- blockHash: string|null;
- blockNumber: number|null;
- transactionIndex: number|null;
+ blockHash: string | null;
+ blockNumber: number | null;
+ transactionIndex: number | null;
from: string;
- to: string|null;
+ to: string | null;
value: BigNumber.BigNumber;
gasPrice: BigNumber.BigNumber;
gas: number;
@@ -339,9 +375,9 @@ declare module 'web3' {
interface CallTxDataBase {
to?: string;
- value?: number|string|BigNumber.BigNumber;
- gas?: number|string|BigNumber.BigNumber;
- gasPrice?: number|string|BigNumber.BigNumber;
+ value?: number | string | BigNumber.BigNumber;
+ gas?: number | string | BigNumber.BigNumber;
+ gasPrice?: number | string | BigNumber.BigNumber;
data?: string;
nonce?: number;
}
@@ -361,19 +397,19 @@ declare module 'web3' {
transactionIndex: number;
from: string;
to: string;
- status: null|string|0|1;
+ status: null | string | 0 | 1;
cumulativeGasUsed: number;
gasUsed: number;
- contractAddress: string|null;
+ contractAddress: string | null;
logs: LogEntry[];
}
interface LogEntry {
- logIndex: number|null;
- transactionIndex: number|null;
+ logIndex: number | null;
+ transactionIndex: number | null;
transactionHash: string;
- blockHash: string|null;
- blockNumber: number|null;
+ blockHash: string | null;
+ blockNumber: number | null;
address: string;
data: string;
topics: string[];
diff --git a/yarn.lock b/yarn.lock
index e7d64bbcc..38c7ca23c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6,6 +6,10 @@
version "0.4.1"
resolved "https://registry.yarnpkg.com/@types/accounting/-/accounting-0.4.1.tgz#865d9f5694fd7c438fba34eb4bc82eec6f34cdd5"
+"@types/bignumber.js@^4.0.2":
+ version "4.0.3"
+ resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-4.0.3.tgz#e8ce5f28c3025a01c6af7fc6d944494903a9e348"
+
"@types/bintrees@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/bintrees/-/bintrees-1.0.2.tgz#0dfdce4eeebdf90427bd35b0e79dc248b3d157a6"
@@ -8951,7 +8955,7 @@ tslint-react@^3.0.0, tslint-react@^3.2.0:
dependencies:
tsutils "^2.8.0"
-tslint@5.8.0:
+tslint@5.8.0, tslint@^5.5.0:
version "5.8.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.8.0.tgz#1f49ad5b2e77c76c3af4ddcae552ae4e3612eb13"
dependencies:
@@ -9064,6 +9068,10 @@ typescript@2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc"
+typescript@^2.4.2:
+ version "2.6.2"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
+
typescript@~2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.1.tgz#ef39cdea27abac0b500242d6726ab90e0c846631"
@@ -9450,12 +9458,6 @@ web3-typescript-typings@^0.7.2:
dependencies:
bignumber.js "^4.0.2"
-web3-typescript-typings@^0.9.0:
- version "0.9.0"
- resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.9.0.tgz#c658db3c84427d9c05a93613e35e6d8147c931c4"
- dependencies:
- bignumber.js "^4.0.2"
-
web3-utils@^1.0.0-beta.26:
version "1.0.0-beta.26"
resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.0.0-beta.26.tgz#f04ad8c144b1781c6b20c2818e0532cb9e6dca15"