Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types back-port from 2.x with changes to match the 1.x logic #3132

Merged
merged 126 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from 125 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
05ee451
docs: update readme to contain TS usage
joshstevens19 Oct 15, 2019
5e58e55
feat: learna dtslint
joshstevens19 Oct 15, 2019
9bf6bdd
feat: types for `web3` module
joshstevens19 Oct 15, 2019
e62daff
feat: `web3` module install dtslint
joshstevens19 Oct 15, 2019
321fc59
docs: readme web3 module types
joshstevens19 Oct 15, 2019
073d112
feat: `web3-core` types
joshstevens19 Oct 15, 2019
943fe29
docs: update readme for `web3-core` for types
joshstevens19 Oct 15, 2019
7cfd476
feat: install type dependencies for `web3-core`
joshstevens19 Oct 15, 2019
ba08495
feat: `web3-core-helper` types
joshstevens19 Oct 15, 2019
a49b021
feat: install type dependency for `web3-core-helpers`
joshstevens19 Oct 15, 2019
44dc1e9
docs: update readme for typings
joshstevens19 Oct 15, 2019
0229985
fix: remove @types/node from `web3-core-helpers`
joshstevens19 Oct 15, 2019
f6d7888
feat: `web3-core-method` types
joshstevens19 Oct 15, 2019
64b74ec
feat: install type dependencies for `web3-core-method`
joshstevens19 Oct 15, 2019
e1d37ac
docs: update types for `web3-core-method` in readme
joshstevens19 Oct 15, 2019
4ca1cf8
feat: `web3-eth` typings
joshstevens19 Oct 15, 2019
eb9b819
feat: install type dependencies for `web3-eth`
joshstevens19 Oct 15, 2019
6a34aaf
docs: update readme for `web3-eth`
joshstevens19 Oct 15, 2019
e4f085f
feat: `web3-eth-abi` typings
joshstevens19 Oct 15, 2019
7800a02
feat: install type dependencies for `web3-eth-abi`
joshstevens19 Oct 15, 2019
06245fa
docs: update readme for `web3-eth-abi`
joshstevens19 Oct 15, 2019
4af7781
feat: `web3-eth-accounts` typings
joshstevens19 Oct 15, 2019
27fe1d0
feat: install type dependencies for `web3-eth-accounts`
joshstevens19 Oct 15, 2019
704d7e2
docs: update readme for `web3-eth-accounts`
joshstevens19 Oct 15, 2019
c3b750f
feat: `web3-eth-contract` typings
joshstevens19 Oct 15, 2019
261dbd8
feat: `web3-eth-contract` tests
joshstevens19 Oct 15, 2019
136378a
feat: install types dependencies for `web3-eth-contract`
joshstevens19 Oct 15, 2019
c224ed3
docs: update readme for `web3-eth-contract`
joshstevens19 Oct 15, 2019
ff8fadb
feat: `web3-eth-ens` typings
joshstevens19 Oct 15, 2019
dc87499
test: `web3-eth-ens` tests
joshstevens19 Oct 15, 2019
44ed5b5
feat: install type dependencies for `web3-eth-ens`
joshstevens19 Oct 15, 2019
9e5b7dd
docs: update readme for `web3-eth-ens`
joshstevens19 Oct 15, 2019
7c29e8c
feat: `web3-eth-iban` typings
joshstevens19 Oct 15, 2019
be66042
test: `web3-eth-iban` typing tests
joshstevens19 Oct 15, 2019
6c4a5e7
feat: install `web3-eth-iban` typings dependencies
joshstevens19 Oct 15, 2019
9f582de
docs: update readme for `web3-eth-iban`
joshstevens19 Oct 15, 2019
d0eede1
feat: `web3-eth-personal` typings
joshstevens19 Oct 15, 2019
f994986
test: `web3-eth-personal` typings tests
joshstevens19 Oct 15, 2019
b8fca8e
feat: install dependencies for `web3-eth-personal`
joshstevens19 Oct 15, 2019
6465b13
docs: update readme `web3-eth-personal`
joshstevens19 Oct 15, 2019
fdc8f25
feat: `web3-net` typings
joshstevens19 Oct 15, 2019
578db9e
fix: remove dev dependencies which are not relavant
joshstevens19 Oct 15, 2019
025cf2b
test: `web3-net` typings tests
joshstevens19 Oct 15, 2019
83db6d7
docs: update readme for `web3-net`
joshstevens19 Oct 15, 2019
5d239fc
feat: install dev dependencies for `web3-net`
joshstevens19 Oct 15, 2019
03af50f
feat: `web3-shh` typings
joshstevens19 Oct 15, 2019
a7ac6a2
test: `web3-shh` typings tests
joshstevens19 Oct 15, 2019
ab79404
docs: update `web3-shh` readme
joshstevens19 Oct 15, 2019
0ddfc9d
feat: install dev dependencies in `web3-shh`
joshstevens19 Oct 15, 2019
e4bf89a
feat: web3-utils type config files
joshstevens19 Oct 15, 2019
ac81f79
feat: ascii to hex typings test
joshstevens19 Oct 15, 2019
f124871
feat: bytes to hex typings test
joshstevens19 Oct 15, 2019
95665de
feat: check address checksum typings test
joshstevens19 Oct 15, 2019
49f224c
feat: from ascii typings test
joshstevens19 Oct 15, 2019
1c8ae3b
feat: from decimal typings test
joshstevens19 Oct 15, 2019
d253427
feat: from utf8 typings test
joshstevens19 Oct 15, 2019
b4e61b8
feat: from wei typings test
joshstevens19 Oct 15, 2019
7330ea7
feat: get signature params typings test
joshstevens19 Oct 15, 2019
1baf6ca
feat: get unit value typings test
joshstevens19 Oct 15, 2019
ea4887b
feat: hex to ascii typings test
joshstevens19 Oct 15, 2019
2b9ccd6
feat: hex to bytes typings test
joshstevens19 Oct 15, 2019
176c71c
feat: hex to number string typings test
joshstevens19 Oct 15, 2019
77b24b3
feat: hex to number typings test
joshstevens19 Oct 15, 2019
99b4d5a
feat: hex to string typings test
joshstevens19 Oct 15, 2019
a7fb673
feat: hex to utf8 typings test
joshstevens19 Oct 15, 2019
a1b076d
feat: is address typings test
joshstevens19 Oct 15, 2019
f133c65
feat: is big number typings test
joshstevens19 Oct 15, 2019
f3b1669
feat: is bloom typings test
joshstevens19 Oct 15, 2019
e10127a
feat: is bn typings test
joshstevens19 Oct 15, 2019
be485db
feat: is hex strict typings test
joshstevens19 Oct 15, 2019
c31dabe
feat: is hex typings test
joshstevens19 Oct 15, 2019
47157b0
feat: is topic typings test
joshstevens19 Oct 15, 2019
ba3720d
feat: json interface method to string typings test
joshstevens19 Oct 15, 2019
a7f6dac
feat: keccak256 typings test
joshstevens19 Oct 15, 2019
4cddce2
feat: left pad typings test
joshstevens19 Oct 15, 2019
5b54cd0
feat: number to hex typings test
joshstevens19 Oct 15, 2019
235a586
feat: utils type tests
joshstevens19 Oct 15, 2019
1047a11
feat: add types in package.json
joshstevens19 Oct 15, 2019
549dc7c
feat: new lock files for all packages
joshstevens19 Oct 15, 2019
c64df7a
feat: new lock files for web3-eth-account
joshstevens19 Oct 15, 2019
83be2a4
feat: new lock file for web3-provider.ws
joshstevens19 Oct 15, 2019
147e1fb
feat: install new dev dependencies for typings on root
joshstevens19 Oct 15, 2019
1e97246
feat: export the typings in the package.json
joshstevens19 Oct 15, 2019
4787389
feat: web3 typings tests to reference web3-core
joshstevens19 Oct 15, 2019
217649a
feat: reference web3-core over web3-providers
joshstevens19 Oct 15, 2019
cd2468f
feat: typings moved around due to different approach in 2.x
joshstevens19 Oct 15, 2019
a6f20de
feat: web3-bzz types
joshstevens19 Oct 15, 2019
b46a13f
feat: web3-bzz dependencies
joshstevens19 Oct 15, 2019
adad8a1
test: web3 bzz types
joshstevens19 Oct 15, 2019
d384e91
fix: resolve dtslint typing tests fails
joshstevens19 Oct 15, 2019
e1eb225
feat: web3-provider-http types
joshstevens19 Oct 15, 2019
39c469e
test: web3-provider-http tests
joshstevens19 Oct 15, 2019
4d337cd
refactor: rename to `tests`
joshstevens19 Oct 15, 2019
efb3157
docs: add author to the http provider
joshstevens19 Oct 15, 2019
c68ae46
feat: install web3-provider-ipc new dev dependencies
joshstevens19 Oct 15, 2019
2e087c3
docs: update readme for web3-provider-ipc
joshstevens19 Oct 15, 2019
22d2b0d
feat: `web3-providers-ipc` typings
joshstevens19 Oct 15, 2019
1f770f3
test: web3-provider-ipc test typings
joshstevens19 Oct 15, 2019
68ecb15
feat: typings for web3-providers-ipc
joshstevens19 Oct 15, 2019
cf826c4
fix: remove file comment
joshstevens19 Oct 15, 2019
6637cf6
fix: resolve index.d.ts file
joshstevens19 Oct 15, 2019
72539d0
feat: install type dependencies for web3-provider-ws
joshstevens19 Oct 15, 2019
0d90928
feat: `web-providers-ws` typings
joshstevens19 Oct 15, 2019
5b76c0a
feat: web3-providers-ws ts files
joshstevens19 Oct 15, 2019
eaf43d3
test: web3-provider-ws-tests
joshstevens19 Oct 15, 2019
82e69d7
fix: remove batch request from web3-bzz
joshstevens19 Oct 15, 2019
68d46e7
feat: export errors from web3-core-helpers
joshstevens19 Oct 15, 2019
77c02bd
fix: remove options from `web3.shh`
joshstevens19 Oct 15, 2019
10b423e
fix: define callback in the filter methods
joshstevens19 Oct 15, 2019
4b97122
feat: remove `TransactionSigner`
joshstevens19 Oct 15, 2019
d792268
docs: add web3-eth-personal docs
joshstevens19 Oct 15, 2019
79e98c9
fix: resolve typings 1.0 from pr comments
joshstevens19 Oct 15, 2019
849f4e6
types updated
nivida Oct 16, 2019
a269880
Merge branch '1.x' into types/back-port-from-2.x
joshstevens19 Oct 16, 2019
f09a1c7
ci script updated
nivida Oct 16, 2019
cc77659
Merge branch 'types/back-port-from-2.x' of github.com:joshstevens19/w…
nivida Oct 16, 2019
747a00b
global install of typescript for CI added
nivida Oct 16, 2019
3712104
installation of typescript moved to before_script
nivida Oct 16, 2019
85e53fc
lerna-debug.log added to gitignore
nivida Oct 16, 2019
a983c12
lerna-debug removed
nivida Oct 16, 2019
b0e4c10
getNodeInfo added to types and documentation
nivida Oct 16, 2019
fa841bd
getChainId to types added
nivida Oct 16, 2019
30d1523
travis.yml fixed
nivida Oct 16, 2019
0234d69
global install of typescript removed and just added as dependency to …
nivida Oct 16, 2019
151a2b7
fix: dtslint to version `0.4.2`
joshstevens19 Oct 16, 2019
2468c71
fix: remove repeating typings
joshstevens19 Oct 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ bower_components
.vscode/
dist/
packages/web3/dist/
lerna-debug.log
!./dist/web3.min.js
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
This is the Ethereum [JavaScript API][docs]
which connects to the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec.


You need to run a local or remote [Ethereum](https://www.ethereum.org/) node to use this library.

Please read the [documentation][docs] for more.
Expand All @@ -31,15 +30,15 @@ yarn add web3

### Meteor

*Note*: works only in the Browser for now. (PR welcome).
_Note_: works only in the Browser for now. (PR welcome).

```bash
meteor add ethereum:web3
```

### In the Browser

Use the prebuild ``dist/web3.min.js``, or
Use the prebuild `dist/web3.min.js`, or
build using the [web3.js][repo] repository:

```bash
Expand Down Expand Up @@ -76,40 +75,39 @@ web3.setProvider(new Web3.providers.WebsocketProvider('ws://localhost:8546'));
There you go, now you can use it:

```js
web3.eth.getAccounts()
.then(console.log);
web3.eth.getAccounts().then(console.log);
```

### Usage with TypeScript

Type definitions are maintained at [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) by others. You can install them with:

```bash
npm install --dev @types/web3.js
```

You might need to install type definitions for `bignumber.js` and `lodash` too.
We support types within the repo itself. Please open an issue here if you find any wrong types.

And then use `web3.js` as follows:
You can use `web3.js` as follows:

```typescript
import Web3 = require("web3"); // Note the special syntax! Copy this line when in doubt!
const web3 = new Web3("ws://localhost:8546");
import Web3 from 'web3';
const web3 = new Web3('ws://localhost:8546');
```

**Please note:** We do not support TypeScript ourselves. If you have any issue with TypeScript and `web3.js` do not create an issue here. Go over to DefinitelyTyped and do it there.
If you are using the types in a `commonjs` module like for example a node app you just have to enable `esModuleInterop` in your `tsconfig` compile option, also enable `allowSyntheticDefaultImports` for typesystem compatibility:

```js
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
....
```

## Documentation

Documentation can be found at [read the docs][docs].


## Building

### Requirements

* [Node.js](https://nodejs.org)
* [npm](https://www.npmjs.com/)
- [Node.js](https://nodejs.org)
- [npm](https://www.npmjs.com/)

```bash
sudo apt-get update
Expand All @@ -133,7 +131,6 @@ npm run-script build-all

This will put all the browser build files into the `dist` folder.


### Testing (mocha)

```bash
Expand All @@ -142,22 +139,22 @@ npm test

### Contributing

- All contributions have to go into develop, or the 1.0 branch
- Please follow the code style of the other files, we use 4 spaces as tabs.
- All contributions have to go into develop, or the 1.0 branch
- Please follow the code style of the other files, we use 4 spaces as tabs.

### Community
- [Gitter](https://gitter.im/ethereum/web3.js?source=orgpage)
- [Forum](https://forum.ethereum.org/categories/ethereum-js)

- [Gitter](https://gitter.im/ethereum/web3.js?source=orgpage)
- [Forum](https://forum.ethereum.org/categories/ethereum-js)

### Similar libraries in other languages
- Python - [Web3.py](https://github.com/ethereum/web3.py)
- Haskell - [hs-web3](https://github.com/airalab/hs-web3)
- Java - [web3j](https://github.com/web3j/web3j)
- Scala - [web3j-scala](https://github.com/mslinn/web3j-scala)
- Purescript - [purescript-web3](https://github.com/f-o-a-m/purescript-web3)
- PHP - [web3.php](https://github.com/sc0Vu/web3.php)

- Python - [Web3.py](https://github.com/ethereum/web3.py)
- Haskell - [hs-web3](https://github.com/airalab/hs-web3)
- Java - [web3j](https://github.com/web3j/web3j)
- Scala - [web3j-scala](https://github.com/mslinn/web3j-scala)
- Purescript - [purescript-web3](https://github.com/f-o-a-m/purescript-web3)
- PHP - [web3.php](https://github.com/sc0Vu/web3.php)

[repo]: https://github.com/ethereum/web3.js
[docs]: http://web3js.readthedocs.io/
Expand Down
170 changes: 168 additions & 2 deletions docs/web3-eth-personal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,54 @@ Example

------------------------------------------------------------------------------

sendTransaction
=====================

.. code-block:: javascript

web3.eth.personal.sendTransaction(transactionOptions, password [, callback])

This method sends a transaction over the management API.

.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure.

----------
Parameters
----------


1. ``Object`` - The transaction options
2. ``String`` - The passphrase for the current account
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.


-------
Returns
-------


``Promise<string>`` - The transaction hash.


-------
Example
-------


.. code-block:: javascript

web3.eth.sendTransaction({
from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0",
gasPrice: "20000000000",
gas: "21000",
to: '0x3535353535353535353535353535353535353535',
value: "1000000000000000000",
data: ""
}, 'MyPassword!').then(console.log);
> '0xda3be87732110de6c1354c83770aae630ede9ac308d9f7b399ecfba23d923384'

------------------------------------------------------------------------------


unlockAccount
=====================
Expand Down Expand Up @@ -271,6 +319,124 @@ Example
.then(console.log('Account unlocked!'));
> "Account unlocked!"

// TODO
------------------------------------------------------------------------------

lockAccount
=====================

.. code-block:: javascript

web3.eth.personal.lockAccount(address [, callback])

Locks the given account.

.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure.

----------
Parameters
----------


1. ``address`` - ``String``: The account address.
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.


-------
Returns
-------


``Promise<boolean>``


-------
Example
-------


.. code-block:: javascript

web3.eth.personal.lockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe")
.then(console.log('Account locked!'));
> "Account locked!"

------------------------------------------------------------------------------

.. _personal-getaccounts:

getAccounts
=====================

.. code-block:: javascript

web3.eth.personal.getAccounts([callback])

Returns a list of accounts the node controls by using the provider and calling
the RPC method ``personal_listAccounts``. Using :ref:`web3.eth.accounts.create() <accounts-create>`
will not add accounts into this list. For that use
:ref:`web3.eth.personal.newAccount() <personal-newaccount>`.

The results are the same as :ref:`web3.eth.getAccounts() <eth-getaccounts>` except that calls
the RPC method ``eth_accounts``.

-------
Returns
-------


``Promise<Array>`` - An array of addresses controlled by node.

-------
Example
-------


.. code-block:: javascript

web3.eth.personal.getAccounts()
.then(console.log);
> ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"]

------------------------------------------------------------------------------

importRawKey
=====================

.. code-block:: javascript

web3.eth.personal.importRawKey(privateKey, password)

Imports the given private key into the key store, encrypting it with the passphrase.

Returns the address of the new account.

.. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure.

----------
Parameters
----------


1. ``privateKey`` - ``String`` - An unencrypted private key (hex string).
2. ``password`` - ``String`` - The password of the account.


-------
Returns
-------


``Promise<string>`` - The address of the account.

-------
Example
-------


.. code-block:: javascript

web3.eth.personal.importRawKey("cd3376bb711cb332ee3fb2ca04c6a8b9f70c316fcdf7a1f44ef4c7999483295e", "password1234")
.then(console.log);
> "0x8f337bf484b2fc75e4b0436645dcc226ee2ac531"


getAccounts, lockAccount, sendTransaction
27 changes: 27 additions & 0 deletions docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1558,3 +1558,30 @@ Example
> 61

------------------------------------------------------------------------------

.. _eth-getNodeInfo:

getNodeInfo
===========

.. code-block:: javascript

web3.eth.getNodeInfo([callback])

-------
Returns
-------

``Promise<String>`` - The current client version.

-------
Example
-------


.. code-block:: javascript

web3.eth.getNodeInfo().then(console.log);
> "Mist/v0.9.3/darwin/go1.4.1"

------------------------------------------------------------------------------
Loading