From 96419b9ff4c0767dc28968abb499ed71d8a87cf3 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:13:30 +0000 Subject: [PATCH 01/13] fix `signTransaction` docs --- docs/web3-eth.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/web3-eth.rst b/docs/web3-eth.rst index 01342f35379..b1fdcb1ed42 100644 --- a/docs/web3-eth.rst +++ b/docs/web3-eth.rst @@ -1178,7 +1178,7 @@ signTransaction .. code-block:: javascript - web3.eth.signTransaction(transactionObject, address [, callback]) + web3.eth.signTransaction(transactionObject [, address] [, callback]) Signs a transaction. This account needs to be unlocked. @@ -1188,7 +1188,7 @@ Parameters 1. ``Object`` - The transaction data to sign :ref:`web3.eth.sendTransaction() ` for more. -2. ``String`` - Address to sign transaction with. +2. ``String`` - (optional) Address to sign transaction with. 3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. From c439da36daa3bbc4443c9ba47ff0e6efbe17ac96 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:13:46 +0000 Subject: [PATCH 02/13] web3-eth package.json with new types --- packages/web3-eth/package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/web3-eth/package.json b/packages/web3-eth/package.json index 759c31608ff..665f31406b3 100644 --- a/packages/web3-eth/package.json +++ b/packages/web3-eth/package.json @@ -11,8 +11,10 @@ "scripts": { "build": "rollup -c", "dev": "rollup -c -w", - "test": "jest" + "test": "jest", + "dtslint": "dtslint types" }, + "types": "types", "dependencies": { "web3-core": "1.0.0-beta.36", "web3-core-helpers": "1.0.0-beta.36", @@ -28,7 +30,11 @@ "web3-providers": "1.0.0-beta.36", "web3-utils": "1.0.0-beta.36" }, + "devDependencies": { + "dtslint": "^0.3.0" + }, "files": [ - "dist" + "dist", + "types/index.d.ts" ] } From f7a98b0bf6916c9bd512687a2a4f1478dd8d2989 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:13:54 +0000 Subject: [PATCH 03/13] web3-eth types --- packages/web3-eth/types/index.d.ts | 268 +++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 packages/web3-eth/types/index.d.ts diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts new file mode 100644 index 00000000000..77ee93c1d0c --- /dev/null +++ b/packages/web3-eth/types/index.d.ts @@ -0,0 +1,268 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Josh Stevens + * @date 2018 + */ + +import * as net from 'net'; +import {AbstractProviderAdapter, provider, BatchRequest} from 'web3-providers'; +import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; +import {Contract} from 'web3-eth-contract'; +import {Iban} from 'web3-eth-iban'; +import {Accounts} from "web3-eth-accounts"; +import {AbiCoder} from "web3-eth-abi"; +import {Network} from "web3-net"; + +export class Eth extends AbstractWeb3Module { + constructor( + provider: AbstractProviderAdapter | provider, + options?: Web3ModuleOptions + ); + Contract: Contract; + Iban: Iban; + personal: Personal; // change one personal types are written + accounts: Accounts; + ens: any; // change once ens types as written + abi: AbiCoder; + net: Network; + clearSubscriptions(): boolean + subscribe(type: "logs", options?: Logs): Promise>; + subscribe(type: "logs", callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: "logs", options?: Logs, callback?: (error: Error, result: Subscribe) => void): Promise>; + subscribe(type: "syncing", callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: "newBlockHeaders", callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: "pendingTransactions", callback?: (error: Error, result: Subscribe) => void): Promise> + setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; + readonly providers: Providers; + readonly givenProvider: AbstractProviderAdapter | provider | null; + BatchRequest(): BatchRequest; + extend(methods: Methods): any; + getProtocolVersion(callback?: (error: Error, protocolVersion: string) => void): Promise; + isSyncing(callback?: (error: Error, syncing: Syncing) => void): Promise; + getCoinbase(callback?: (error: Error, coinbaseAddress: string) => void): Promise; + isMining(callback?: (error: Error, mining: boolean) => void): Promise; + getHashrate(callback?: (error: Error, hashes: number) => void): Promise; + getGasPrice(callback?: (error: Error, gasPrice: string) => void): Promise; + getAccounts(callback?: (error: Error, accounts: string[]) => void): Promise; + getBlockNumber(callback?: (error: Error, blockNumber: number) => void): Promise; + getBalance(address: string): Promise; + getBalance(address: string, defaultBlock: string | number): Promise; + getBalance(address: string, callback?: (error: Error, balance: string) => void): Promise; + getBalance(address: string, defaultBlock: string | number, callback?: (error: Error, balance: string) => void): Promise; + getStorageAt(address: string, position: number): Promise; + getStorageAt(address: string, position: number, defaultBlock: number | string): Promise; + getStorageAt(address: string, position: number, callback?: (error: Error, storageAt: string) => void): Promise; + getStorageAt(address: string, position: number, defaultBlock: number | string, callback?: (error: Error, storageAt: string) => void): Promise; + getCode(address: string): Promise; + getCode(address: string, defaultBlock: string | number): Promise; + getCode(address: string, callback?: (error: Error, code: string) => void): Promise; + getCode(address: string, defaultBlock: string | number, callback?: (error: Error, code: string) => void): Promise; + getBlock(blockHashOrBlockNumber: string | number): Promise; + getBlock(blockHashOrBlockNumber: string | number, returnTransactionObjects: boolean): Promise; + getBlock(blockHashOrBlockNumber: string | number, callback?: (error: Error, block: Block) => void): Promise; + getBlock(blockHashOrBlockNumber: string | number, returnTransactionObjects: boolean, callback?: (error: Error, block: Block) => void): Promise; + getBlockTransactionCount(blockHashOrBlockNumber: string | number, callback?: (error: Error, numberOfTransactions: number) => void): Promise; + getUncle(blockHashOrBlockNumber: string | number, uncleIndex: number): Promise + getUncle(blockHashOrBlockNumber: string | number, uncleIndex: number, returnTransactionObjects: boolean): Promise + getUncle(blockHashOrBlockNumber: string | number, uncleIndex: number, callback?: (error: Error, uncle: {}) => void): Promise + getUncle(blockHashOrBlockNumber: string | number, uncleIndex: number, returnTransactionObjects: boolean, callback?: (error: Error, uncle: {}) => void): Promise + getTransaction(transactionHash: string, callback?: (error: Error, transaction: Transaction) => void): Promise; + getTransactionFromBlock(hashStringOrNumber: string | number, indexNumber: number, callback?: (error: Error, transaction: Transaction) => void): Promise; + getTransactionReceipt(hash: string, callback?: (error: Error, transactionReceipt: TransactionReceipt) => void): Promise; + getTransactionCount(address: string): Promise; + getTransactionCount(address: string, defaultBlock: number | string): Promise; + getTransactionCount(address: string, callback?: (error: Error, count: number) => void): Promise; + getTransactionCount(address: string, defaultBlock: number | string, callback?: (error: Error, count: number) => void): Promise; + sendTransaction(transaction: Transaction, callback?: (error: Error, hash: string) => void): PromiEvent; + sendSignedTransaction(signedTransactionData: string, callback?: (error: Error, gas: string) => void): PromiEvent + sign(dataToSign: string, address: string | number, callback?: (error: Error, signature: string) => void): Promise; + signTransaction(transaction: Transaction, callback?: (error: Error, signedTransaction: SignedTransaction) => void): Promise; + signTransaction(transaction: Transaction, address: string): Promise; + signTransaction(transaction: Transaction, address: string, callback: (error: Error, signedTransaction: SignedTransaction) => void): Promise; + call(transaction: Transaction): Promise; + call(transaction: Transaction, defaultBlock?: number | string): Promise; + call(transaction: Transaction, callback?: (error: Error, data: string) => void): Promise; + call(transaction: Transaction, defaultBlock: number | string, callback: (error: Error, data: string) => void): Promise; + estimateGas(transaction: Transaction, callback?: (error: Error, gas: number) => void): Promise; + getPastLogs(options: PastLogsOptions, callback?: (error: Error, logs: Log[]) => void): Promise; + getWork(callback?: (error: Error, result: string[]) => void): Promise; + submitWork(data: [string, string, string], callback?: (error: Error, result: boolean) => void): Promise; +} + +export interface Methods { + property?: string; + methods: Method[]; +} + +export interface Method { + name: string; + call: string; + params?: number; + inputFormatter?: Array<(() => void) | null>; + outputFormatter?: () => void; +} + +export interface Syncing { + startingBlock: number; + currentBlock: number; + highestBlock: number; + knownStates: number; + pulledStates: number; +} + +export interface BlockHeader { + number: number + hash: string + parentHash: string + nonce: string + sha3Uncles: string + logsBloom: string + transactionRoot: string + stateRoot: string + receiptRoot: string + miner: string + extraData: string + gasLimit: number + gasUsed: number + timestamp: number +} + +export interface Block extends BlockHeader { + transactions: Transaction[]; + size: number + difficulty: number + totalDifficulty: number + uncles: string[]; +} + +export interface SignedTransaction { + raw: string; + tx: Transaction; +} + +export interface PastLogsOptions { + fromBlock?: number | string; + toBlock?: number | string; + address: string | string[]; + topics?: Array; +} + +export interface Logs { + fromBlock?: number + address?: string + topics?: Array +} + +export interface Log { + address: string; + data: string; + topics: Array; + logIndex: number; + transactionIndex: number; + transactionHash: string; + blockHash: string; + blockNumber: number; +} + +export interface Subscribe { + subscription: { + id: string + subscribe(callback?: (error: Error, result: Subscribe) => void): Subscribe + unsubscribe(callback?: (error: Error, result: boolean) => void): void | boolean + arguments: object + } + on(type: "data", handler: (data: T) => void): void + on(type: "changed", handler: (data: T) => void): void + on(type: "error", handler: (data: Error) => void): void +} + +/** DELETE ONCE personal is complete */ + +export class Personal { + newAccount(password: string, callback?: (error: Error, result: boolean) => void): Promise + getAccounts(callback?: (error: Error, result: string[]) => void): Promise +} +/** END */ + +/** MOVE ALL BELOW TO WEB3-CORE ONCE TYPES COMPLETE FOR CLEAR UP !!! */ + +export interface PromiEvent extends Promise { + once(type: "transactionHash", handler: (receipt: string) => void): PromiEvent + once(type: "receipt", handler: (receipt: TransactionReceipt) => void): PromiEvent + once(type: "confirmation", handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent + once(type: "error", handler: (error: Error) => void): PromiEvent + once(type: "error" | "confirmation" | "receipt" | "transactionHash", handler: (error: Error | TransactionReceipt | string) => void): PromiEvent + on(type: "transactionHash", handler: (receipt: string) => void): PromiEvent + on(type: "receipt", handler: (receipt: TransactionReceipt) => void): PromiEvent + on(type: "confirmation", handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent + on(type: "error", handler: (error: Error) => void): PromiEvent + on(type: "error" | "confirmation" | "receipt" | "transactionHash", handler: (error: Error | TransactionReceipt | string) => void): PromiEvent +} + +export interface Transaction { + from?: string | number; + to?: string; + gasPrice?: string; + gas?: number | string; + value?: number | string; + chainId?: number; + data?: string; + nonce?: number; + v?: string; + r?: string; + s?: string; +} + +export interface SignedTransaction { + messageHash?: string; + r: string; + s: string; + v: string; + rawTransaction?: string; +} + +export interface Sign extends SignedTransaction { + message: string; +} + +export interface TransactionReceipt { + transactionHash: string + transactionIndex: number + blockHash: string + blockNumber: number + from: string + to: string + contractAddress: string + cumulativeGasUsed: number + gasUsed: number + logs?: Log[] + events?: { + [eventName: string]: EventLog + } +} + +export interface EventLog { + event: string + address: string + returnValues: object + logIndex: number + transactionIndex: number + transactionHash: string + blockHash: string + blockNumber: number + raw?: { data: string, topics: any[] } +} +/** END !!! */ From 7cf2fe4e7304823df4c822da2eb8d7e215f60ca8 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:14:02 +0000 Subject: [PATCH 04/13] web3-eth tsconfig.json --- packages/web3-eth/types/tsconfig.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 packages/web3-eth/types/tsconfig.json diff --git a/packages/web3-eth/types/tsconfig.json b/packages/web3-eth/types/tsconfig.json new file mode 100644 index 00000000000..82c7ac530ee --- /dev/null +++ b/packages/web3-eth/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": true, + "baseUrl": ".", + "paths": { + "web3-eth": ["."] + } + } +} From 8a9cf64b45c17e60daa103c605db5c5ede686a40 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:14:12 +0000 Subject: [PATCH 05/13] web3-eth tslint.json --- packages/web3-eth/types/tslint.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 packages/web3-eth/types/tslint.json diff --git a/packages/web3-eth/types/tslint.json b/packages/web3-eth/types/tslint.json new file mode 100644 index 00000000000..871d605704b --- /dev/null +++ b/packages/web3-eth/types/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false, + "unified-signatures": false + } +} From 91e85265b721a0031cf86cc62078b9d2d06abd2f Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:14:26 +0000 Subject: [PATCH 06/13] web3-eth tests --- packages/web3-eth/types/tests/eth.tests.ts | 414 +++++++++++++++++++++ 1 file changed, 414 insertions(+) create mode 100644 packages/web3-eth/types/tests/eth.tests.ts diff --git a/packages/web3-eth/types/tests/eth.tests.ts b/packages/web3-eth/types/tests/eth.tests.ts new file mode 100644 index 00000000000..bd8cf1c18e6 --- /dev/null +++ b/packages/web3-eth/types/tests/eth.tests.ts @@ -0,0 +1,414 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file eth-tests.ts + * @author Josh Stevens + * @date 2018 + */ + +import {Eth, Log, Subscribe, BlockHeader, Transaction, Syncing, Block, TransactionReceipt, SignedTransaction} from 'web3-eth'; + +const eth = new Eth('http://localhost:8545'); + +// $ExpectType Contract +eth.Contract; + +// $ExpectType Iban +eth.Iban; + +// $ExpectType Personal +eth.personal; + +// $ExpectType Accounts +eth.accounts; + +// $ExpectType any +eth.ens; + +// $ExpectType AbiCoder +eth.abi; + +// $ExpectType Network +eth.net; + +// $ExpectType boolean +eth.clearSubscriptions; + +// $ExpectType Promise> +eth.subscribe('logs'); +// $ExpectType Promise> +eth.subscribe('logs'); +// $ExpectType Promise> +eth.subscribe('logs', (error: Error, result: Subscribe) => {}); +// $ExpectType Promise> +eth.subscribe('logs', {}); +// $ExpectType Promise> +eth.subscribe('logs', {}, (error: Error, result: Subscribe) => {}); + +// $ExpectType Promise> +eth.subscribe('syncing'); +// $ExpectType Promise> +eth.subscribe('syncing', (error: Error, result: Subscribe) => {}); + +// $ExpectType Promise> +eth.subscribe('newBlockHeaders'); +// $ExpectType Promise> +eth.subscribe('newBlockHeaders', (error: Error, result: Subscribe) => {}); + +// $ExpectType Promise> +eth.subscribe('pendingTransactions'); +// $ExpectType Promise> +eth.subscribe('pendingTransactions', (error: Error, result: Subscribe) => {}); + +// $ExpectType Providers +eth.providers; + +// $ExpectType AbstractProviderAdapter | provider | null +eth.givenProvider; + +// $ExpectType BatchRequest +eth.BatchRequest(); + +// $ExpectType any +eth.extend({ + property: 'myModule', + methods: [{ + name: 'getBalance', + call: 'eth_getBalance', + params: 2, + inputFormatter: [() => {}], + outputFormatter: () => {} + },{ + name: 'getGasPriceSuperFunction', + call: 'eth_gasPriceSuper', + params: 2, + inputFormatter: [null, () => {}] + }] +}); + +// $ExpectType string | null +eth.defaultAccount + +// $ExpectType string | number +eth.defaultBlock + +// $ExpectType Promise +eth.getProtocolVersion(); +// $ExpectType Promise +eth.getProtocolVersion((error: Error, protocolVersion: string) => {}); + +// $ExpectType Promise +eth.isSyncing(); +// $ExpectType Promise +eth.isSyncing((error: Error, syncing: Syncing) => {}); + +// $ExpectType Promise +eth.getCoinbase(); +// $ExpectType Promise +eth.getCoinbase((error: Error, coinbaseAddress: string) => {}); + +// $ExpectType Promise +eth.isMining(); +// $ExpectType Promise +eth.isMining((error: Error, mining: boolean) => {}); + +// $ExpectType Promise +eth.getHashrate(); +// $ExpectType Promise +eth.getHashrate((error: Error, hashes: number) => {}); + +// $ExpectType Promise +eth.getGasPrice(); +// $ExpectType Promise +eth.getGasPrice((error: Error, gasPrice: string) => {}); + +// $ExpectType Promise +eth.getAccounts(); +// $ExpectType Promise +eth.getAccounts((error: Error, accounts: string[]) => {}); + +// $ExpectType Promise +eth.getBlockNumber(); +// $ExpectType Promise +eth.getBlockNumber((error: Error, blockNumber: number) => {}); + +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000', (error: Error, balance: string) => {}); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000, (error: Error, balance: string) => {}); + +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, '1000'); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, '1000', (error: Error, balance: string) => {}); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, 1000); +// $ExpectType Promise +eth.getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, 1000, (error: Error, balance: string) => {}); + +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000', (error: Error, balance: string) => {}); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000, (error: Error, balance: string) => {}); + +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getBlock(345); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', true); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', false); +// $ExpectType Promise +eth.getBlock(345); +// $ExpectType Promise +eth.getBlock(345, true); +// $ExpectType Promise +eth.getBlock(345, false); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock(345, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock(345, true, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock(345, false, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', true, (error: Error, block: Block) => {}); +// $ExpectType Promise +eth.getBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', false, (error: Error, block: Block) => {}); + +// $ExpectType Promise +eth.getBlockTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, numberOfTransactions: number) => {}); +// $ExpectType Promise +eth.getBlockTransactionCount(345); +// $ExpectType Promise +eth.getBlockTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, numberOfTransactions: number) => {}); +// $ExpectType Promise +eth.getBlockTransactionCount(345); + +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4); +// $ExpectType Promise +eth.getUncle(345, 4); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, true); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, false); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, true); +// $ExpectType Promise +eth.getUncle(345, 4, false); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, true, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 4, false, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, true, (error: Error, uncle: {}) => {}); +// $ExpectType Promise +eth.getUncle(345, 4, false, (error: Error, uncle: {}) => {}); + +// $ExpectType Promise +eth.getTransaction('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransaction('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, transaction: Transaction) => {}); + +// $ExpectType Promise +eth.getTransactionFromBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2); +// $ExpectType Promise +eth.getTransactionFromBlock(345, 2); +// $ExpectType Promise +eth.getTransactionFromBlock('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 2, (error: Error, transaction: Transaction) => {}); +// $ExpectType Promise +eth.getTransactionFromBlock(345, 2, (error: Error, transaction: Transaction) => {}); + +// $ExpectType Promise +eth.getTransactionReceipt('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransactionReceipt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, transactionReceipt: TransactionReceipt) => {}); + +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1'); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000'); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, count: number) => {}); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', (error: Error, count: number) => {}); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', 1000, (error: Error, count: number) => {}); +// $ExpectType Promise +eth.getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '1000', (error: Error, count: number) => {}); + +const code = '603d80600c6000396000f3007c0'; + +// $ExpectType PromiEvent +eth.sendTransaction({ + from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', + data: 'code' +}); +// $ExpectType PromiEvent +eth.sendTransaction({ + from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', + data: 'code' +}, (error: Error, hash: string) => {}); + +// $ExpectType PromiEvent +eth.sendSignedTransaction('0xf889808609184e72a0008227109'); +// $ExpectType PromiEvent +eth.sendSignedTransaction('0xf889808609184e72a0008227109', (error: Error, gas: string) => {}); + +// $ExpectType Promise +eth.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); +// $ExpectType Promise +eth.sign('Hello world', 3); +// $ExpectType Promise +eth.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', (error: Error, signature: string) => {}); +// $ExpectType Promise +eth.sign('Hello world', 3, (error: Error, signature: string) => {}); + +// $ExpectType Promise +eth.signTransaction({ + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' +}); +// $ExpectType Promise +eth.signTransaction({ + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' +}, '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0'); +// $ExpectType Promise +eth.signTransaction({ + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' +}, (error: Error, signedTransaction: SignedTransaction) => {}); +// $ExpectType Promise +eth.signTransaction({ + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' +}, '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', (error: Error, signedTransaction: SignedTransaction) => {}); + +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}); +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, 100); +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, '100'); +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, (error: Error, data: string) => {}); +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, '100', (error: Error, data: string) => {}); +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, 100, (error: Error, data: string) => {}); + +// $ExpectType Promise +eth.call({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, 100, (error: Error, data: string) => {}); + +// $ExpectType Promise +eth.estimateGas({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}); +// $ExpectType Promise +eth.estimateGas({ + to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", + data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" +}, (error: Error, gas: number) => {}); + +// $ExpectType Promise +eth.getPastLogs({ + address: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", + topics: ["0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"] +}); +// $ExpectType Promise +eth.getPastLogs({ + address: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", + topics: ["0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"] +}, (error: Error, logs: Log[]) => {}); + +// $ExpectType Promise +eth.getWork(); +// $ExpectType Promise +eth.getWork((error: Error, result: string[]) => {}); + +// $ExpectType Promise +eth.submitWork([ + "0x0000000000000001", + "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", + "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" +]); + +// $ExpectType Promise +eth.submitWork([ + "0x0000000000000001", + "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", + "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000" +], (error: Error, result: boolean) => {}); From d1e648444943a877441a69a535ec60dcf3d04e7d Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:14:49 +0000 Subject: [PATCH 07/13] fix `Transaction` interface types on web3-eth-accounts --- packages/web3-eth-accounts/types/index.d.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/web3-eth-accounts/types/index.d.ts b/packages/web3-eth-accounts/types/index.d.ts index ebe95299548..35f1868cd7e 100644 --- a/packages/web3-eth-accounts/types/index.d.ts +++ b/packages/web3-eth-accounts/types/index.d.ts @@ -83,14 +83,13 @@ export interface EncryptedKeystoreV3Json { } } -/** MOVE ALL BELOW TO WEB3-CORE !!! */ +/** MOVE ALL BELOW TO WEB3-CORE ONCE TYPES COMPLETE FOR CLEAR UP !!! */ export interface Transaction { from?: string | number; - to: string; + to?: string; gasPrice?: string; - gas: number; - // value: number | string | BN | BigNumber; should be this - value: number | string; + gas?: number | string; + value?: number | string; chainId?: number; data?: string; nonce?: number; From 6f7f0c1ea9a8ca1b6bb10e9622585426021f4750 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 10:21:08 +0000 Subject: [PATCH 08/13] fix to single quotes for everything --- packages/web3-eth/types/index.d.ts | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 77ee93c1d0c..91e58a3e598 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -22,9 +22,9 @@ import {AbstractProviderAdapter, provider, BatchRequest} from 'web3-providers'; import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; import {Contract} from 'web3-eth-contract'; import {Iban} from 'web3-eth-iban'; -import {Accounts} from "web3-eth-accounts"; -import {AbiCoder} from "web3-eth-abi"; -import {Network} from "web3-net"; +import {Accounts} from 'web3-eth-accounts'; +import {AbiCoder} from 'web3-eth-abi'; +import {Network} from 'web3-net'; export class Eth extends AbstractWeb3Module { constructor( @@ -39,12 +39,12 @@ export class Eth extends AbstractWeb3Module { abi: AbiCoder; net: Network; clearSubscriptions(): boolean - subscribe(type: "logs", options?: Logs): Promise>; - subscribe(type: "logs", callback?: (error: Error, result: Subscribe) => void): Promise> - subscribe(type: "logs", options?: Logs, callback?: (error: Error, result: Subscribe) => void): Promise>; - subscribe(type: "syncing", callback?: (error: Error, result: Subscribe) => void): Promise> - subscribe(type: "newBlockHeaders", callback?: (error: Error, result: Subscribe) => void): Promise> - subscribe(type: "pendingTransactions", callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: 'logs', options?: Logs): Promise>; + subscribe(type: 'logs', callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: 'logs', options?: Logs, callback?: (error: Error, result: Subscribe) => void): Promise>; + subscribe(type: 'syncing', callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: 'newBlockHeaders', callback?: (error: Error, result: Subscribe) => void): Promise> + subscribe(type: 'pendingTransactions', callback?: (error: Error, result: Subscribe) => void): Promise> setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; readonly providers: Providers; readonly givenProvider: AbstractProviderAdapter | provider | null; @@ -184,9 +184,9 @@ export interface Subscribe { unsubscribe(callback?: (error: Error, result: boolean) => void): void | boolean arguments: object } - on(type: "data", handler: (data: T) => void): void - on(type: "changed", handler: (data: T) => void): void - on(type: "error", handler: (data: Error) => void): void + on(type: 'data', handler: (data: T) => void): void + on(type: 'changed', handler: (data: T) => void): void + on(type: 'error', handler: (data: Error) => void): void } /** DELETE ONCE personal is complete */ @@ -200,16 +200,16 @@ export class Personal { /** MOVE ALL BELOW TO WEB3-CORE ONCE TYPES COMPLETE FOR CLEAR UP !!! */ export interface PromiEvent extends Promise { - once(type: "transactionHash", handler: (receipt: string) => void): PromiEvent - once(type: "receipt", handler: (receipt: TransactionReceipt) => void): PromiEvent - once(type: "confirmation", handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent - once(type: "error", handler: (error: Error) => void): PromiEvent - once(type: "error" | "confirmation" | "receipt" | "transactionHash", handler: (error: Error | TransactionReceipt | string) => void): PromiEvent - on(type: "transactionHash", handler: (receipt: string) => void): PromiEvent - on(type: "receipt", handler: (receipt: TransactionReceipt) => void): PromiEvent - on(type: "confirmation", handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent - on(type: "error", handler: (error: Error) => void): PromiEvent - on(type: "error" | "confirmation" | "receipt" | "transactionHash", handler: (error: Error | TransactionReceipt | string) => void): PromiEvent + once(type: 'transactionHash', handler: (receipt: string) => void): PromiEvent + once(type: 'receipt', handler: (receipt: TransactionReceipt) => void): PromiEvent + once(type: 'confirmation', handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent + once(type: 'error', handler: (error: Error) => void): PromiEvent + once(type: 'error' | 'confirmation' | 'receipt' | 'transactionHash', handler: (error: Error | TransactionReceipt | string) => void): PromiEvent + on(type: 'transactionHash', handler: (receipt: string) => void): PromiEvent + on(type: 'receipt', handler: (receipt: TransactionReceipt) => void): PromiEvent + on(type: 'confirmation', handler: (confNumber: number, receipt: TransactionReceipt) => void): PromiEvent + on(type: 'error', handler: (error: Error) => void): PromiEvent + on(type: 'error' | 'confirmation' | 'receipt' | 'transactionHash', handler: (error: Error | TransactionReceipt | string) => void): PromiEvent } export interface Transaction { From d979bc748af67725b11f633f3995d37d8d5a5a70 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 12:59:25 +0000 Subject: [PATCH 09/13] remove `extend` method from `web3-eth` --- docs/include_package-core.rst | 79 ---------------------- packages/web3-eth/types/index.d.ts | 1 - packages/web3-eth/types/tests/eth.tests.ts | 17 ----- 3 files changed, 97 deletions(-) diff --git a/docs/include_package-core.rst b/docs/include_package-core.rst index fcb0ea45ab9..57f6c62d4f7 100644 --- a/docs/include_package-core.rst +++ b/docs/include_package-core.rst @@ -206,82 +206,3 @@ Example ------------------------------------------------------------------------------ - -extend -===================== - -.. code-block:: javascript - - web3.extend(methods) - web3.eth.extend(methods) - web3.shh.extend(methods) - web3.bzz.extend(methods) - ... - -Allows extending the web3 modules. - -.. note:: You also have ``*.extend.formatters`` as additional formatter functions to be used for in and output formatting. Please see the `source file `_ for function details. - ----------- -Parameters ----------- - -1. ``methods`` - ``Object``: Extension object with array of methods description objects as follows: - - ``property`` - ``String``: (optional) The name of the property to add to the module. If no property is set it will be added to the module directly. - - ``methods`` - ``Array``: The array of method descriptions: - - ``name`` - ``String``: Name of the method to add. - - ``call`` - ``String``: The RPC method name. - - ``params`` - ``Number``: (optional) The number of parameters for that function. Default 0. - - ``inputFormatter`` - ``Array``: (optional) Array of inputformatter functions. Each array item responds to a function parameter, so if you want some parameters not to be formatted, add a ``null`` instead. - - ``outputFormatter - ``Function``: (optional) Can be used to format the output of the method. - - ----------- -Returns ----------- - -``Object``: The extended module. - -------- -Example -------- - -.. code-block:: javascript - - web3.extend({ - property: 'myModule', - methods: [{ - name: 'getBalance', - call: 'eth_getBalance', - params: 2, - inputFormatter: [web3.extend.formatters.inputAddressFormatter, web3.extend.formatters.inputDefaultBlockNumberFormatter], - outputFormatter: web3.utils.hexToNumberString - },{ - name: 'getGasPriceSuperFunction', - call: 'eth_gasPriceSuper', - params: 2, - inputFormatter: [null, web3.utils.numberToHex] - }] - }); - - web3.extend({ - methods: [{ - name: 'directCall', - call: 'eth_callForFun', - }] - }); - - console.log(web3); - > Web3 { - myModule: { - getBalance: function(){}, - getGasPriceSuperFunction: function(){} - }, - directCall: function(){}, - eth: Eth {...}, - bzz: Bzz {...}, - ... - } - - ------------------------------------------------------------------------------- diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 91e58a3e598..6bcec0276c3 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -49,7 +49,6 @@ export class Eth extends AbstractWeb3Module { readonly providers: Providers; readonly givenProvider: AbstractProviderAdapter | provider | null; BatchRequest(): BatchRequest; - extend(methods: Methods): any; getProtocolVersion(callback?: (error: Error, protocolVersion: string) => void): Promise; isSyncing(callback?: (error: Error, syncing: Syncing) => void): Promise; getCoinbase(callback?: (error: Error, coinbaseAddress: string) => void): Promise; diff --git a/packages/web3-eth/types/tests/eth.tests.ts b/packages/web3-eth/types/tests/eth.tests.ts index bd8cf1c18e6..44e62642a39 100644 --- a/packages/web3-eth/types/tests/eth.tests.ts +++ b/packages/web3-eth/types/tests/eth.tests.ts @@ -80,23 +80,6 @@ eth.givenProvider; // $ExpectType BatchRequest eth.BatchRequest(); -// $ExpectType any -eth.extend({ - property: 'myModule', - methods: [{ - name: 'getBalance', - call: 'eth_getBalance', - params: 2, - inputFormatter: [() => {}], - outputFormatter: () => {} - },{ - name: 'getGasPriceSuperFunction', - call: 'eth_gasPriceSuper', - params: 2, - inputFormatter: [null, () => {}] - }] -}); - // $ExpectType string | null eth.defaultAccount From 16a687a3ce2b1de2a419ec49fcbe147da90ad157 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 13:00:51 +0000 Subject: [PATCH 10/13] `eth.givenProvider` return type is `provider | null` --- packages/web3-eth/types/index.d.ts | 2 +- packages/web3-eth/types/tests/eth.tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 6bcec0276c3..10aeac32c05 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -47,7 +47,7 @@ export class Eth extends AbstractWeb3Module { subscribe(type: 'pendingTransactions', callback?: (error: Error, result: Subscribe) => void): Promise> setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; readonly providers: Providers; - readonly givenProvider: AbstractProviderAdapter | provider | null; + readonly givenProvider: provider | null; BatchRequest(): BatchRequest; getProtocolVersion(callback?: (error: Error, protocolVersion: string) => void): Promise; isSyncing(callback?: (error: Error, syncing: Syncing) => void): Promise; diff --git a/packages/web3-eth/types/tests/eth.tests.ts b/packages/web3-eth/types/tests/eth.tests.ts index 44e62642a39..943f1c478d2 100644 --- a/packages/web3-eth/types/tests/eth.tests.ts +++ b/packages/web3-eth/types/tests/eth.tests.ts @@ -74,7 +74,7 @@ eth.subscribe('pendingTransactions', (error: Error, result: Subscribe Date: Fri, 14 Dec 2018 13:03:16 +0000 Subject: [PATCH 11/13] remove `sign` as not even used --- packages/web3-eth/types/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 10aeac32c05..6a1f9d0d6f7 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -233,10 +233,6 @@ export interface SignedTransaction { rawTransaction?: string; } -export interface Sign extends SignedTransaction { - message: string; -} - export interface TransactionReceipt { transactionHash: string transactionIndex: number From 829035ef20a0e3a73582f466a3213cdb32821e66 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 13:06:17 +0000 Subject: [PATCH 12/13] fix `Subscribe` to take `options` --- packages/web3-eth/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 6a1f9d0d6f7..9479de76023 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -181,7 +181,7 @@ export interface Subscribe { id: string subscribe(callback?: (error: Error, result: Subscribe) => void): Subscribe unsubscribe(callback?: (error: Error, result: boolean) => void): void | boolean - arguments: object + options: {} } on(type: 'data', handler: (data: T) => void): void on(type: 'changed', handler: (data: T) => void): void From f770888db583a80a7bf4e652ae0e5efccc7f2c83 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 14 Dec 2018 13:15:01 +0000 Subject: [PATCH 13/13] remove repeated `SignedTransaction` and add `hash` to transaction --- packages/web3-eth/types/index.d.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/web3-eth/types/index.d.ts b/packages/web3-eth/types/index.d.ts index 9479de76023..f314477f544 100644 --- a/packages/web3-eth/types/index.d.ts +++ b/packages/web3-eth/types/index.d.ts @@ -147,11 +147,6 @@ export interface Block extends BlockHeader { uncles: string[]; } -export interface SignedTransaction { - raw: string; - tx: Transaction; -} - export interface PastLogsOptions { fromBlock?: number | string; toBlock?: number | string; @@ -223,6 +218,7 @@ export interface Transaction { v?: string; r?: string; s?: string; + hash?: string; } export interface SignedTransaction {