Skip to content

Commit

Permalink
Merge branch '1.x' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
lbertenasco committed Oct 17, 2019
2 parents c72a78c + ba56fc6 commit 48918ba
Show file tree
Hide file tree
Showing 196 changed files with 15,668 additions and 2,229 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ bower_components
.npm/
.vscode/
dist/
packages/web3/dist/
lerna-debug.log
!./dist/web3.min.js
10 changes: 4 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Released with 1.0.0-beta.37 code base.
- getNetworkType method extended with Görli testnet (#3095)
- supportsSubscriptions method added to providers (#3116)
- Add `eth.getChainId` method (#3113)
- Minified file added to web3 package (#3131)
- The transaction confirmation workflow can now be configured (#3130)
- Emit `connected` event on subscription creation (#3028)

### Fixed

Expand All @@ -74,9 +77,4 @@ Released with 1.0.0-beta.37 code base.
- Gas check fixed (#2381)
- Signing issues #1998, #2033, and #1074 fixed (#3125)
- Fix hexToNumber and hexToNumberString prefix validation (#3086)

## [1.2.2]

### Added

- Emit `connected` event on subscription creation (#3028)
- The receipt will now returned on a EVM error (this got removed on beta.18) (#3129)
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
150 changes: 149 additions & 1 deletion docs/web3-eth-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,154 @@ Example
= Properties =
=========

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

.. _eth-contract-defaultaccount
defaultAccount
=====================

.. code-block:: javascript
web3.eth.Contract.defaultAccount
contract.defaultAccount // on contract instance
This default address is used as the default ``"from"`` property, if no ``"from"`` property is specified in for the following methods:

- :ref:`web3.eth.sendTransaction() <eth-sendtransaction>`
- :ref:`web3.eth.call() <eth-call>`
- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().call() <eth-contract-call>`
- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().send() <eth-contract-send>`

--------
Property
--------


``String`` - 20 Bytes: Any ethereum address. You should have the private key for that address in your node or keystore. (Default is ``undefined``)


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


.. code-block:: javascript
web3.eth.defaultAccount;
> undefined
// set the default account
web3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe';
------------------------------------------------------------------------------

.. _eth-contract-defaultblock:

defaultBlock
=====================

.. code-block:: javascript
web3.eth.Contract.defaultBlock
contract.defaultBlock // on contract instance
The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter.
The default value of it is "latest".

----------
Property
----------


Default block parameters can be one of the following:

- ``Number``: A block number
- ``"genesis"`` - ``String``: The genesis block
- ``"latest"`` - ``String``: The latest block (current head of the blockchain)
- ``"pending"`` - ``String``: The currently mined block (including pending transactions)

Default is ``"latest"``


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

.. code-block:: javascript
contract.defaultBlock;
> "latest"
// set the default block
contract.defaultBlock = 231;
------------------------------------------------------------------------------

.. _eth-contract-transactionblocktimeout:

transactionBlockTimeout
=====================

.. code-block:: javascript
web3.eth.Contract.transcationBlockTimeout
contract.transactionBlockTimeout // on contract instance
The ``transactionBlockTimeout`` will be used over a socket based connection. This option does define the amount of new blocks it should wait until the first confirmation happens.
This means the PromiEvent rejects with a timeout error when the timeout got exceeded.


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

``number``: The current value of transactionBlockTimeout (default: 50)

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

.. _eth-contract-module-transactionconfirmationblocks:

transactionConfirmationBlocks
=====================

.. code-block:: javascript
web3.eth.Contract.transactionConfirmationBlocks
contract.transactionConfirmationBlocks // on contract instance
This defines the number of blocks it requires until a transaction will be handled as confirmed.


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

``number``: The current value of transactionConfirmationBlocks (default: 24)

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

.. _eth-contract-module-transactionpollingtimeout:

transactionPollingTimeout
=====================

.. code-block:: javascript
web3.eth.Contract.transactionPollingTimeout
contract.transactionPollingTimeout // on contract instance
The ``transactionPollingTimeout`` will be used over a HTTP connection.
This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. NB: If this method times out, the transaction may still be pending.


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

``number``: The current value of transactionPollingTimeout (default: 750)

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

Expand Down Expand Up @@ -543,7 +691,7 @@ The **callback** will return the 32 bytes transaction hash.
- ``"transactionHash"`` returns ``String``: is fired right after the transaction is sent and a transaction hash is available.
- ``"receipt"`` returns ``Object``: is fired when the transaction *receipt* is available. Receipts from contracts will have no ``logs`` property, but instead an ``events`` property with event names as keys and events as properties. See :ref:`getPastEvents return values <contract-events-return>` for details about the returned event object.
- ``"confirmation"`` returns ``Number``, ``Object``: is fired for every confirmation up to the 24th confirmation. Receives the confirmation number as the first and the receipt as the second argument. Fired from confirmation 1 on, which is the block where it's minded.
- ``"error"`` returns ``Error``: is fired if an error occurs during sending. If a out of gas error, the second parameter is the receipt.
``"error"`` returns ``Error`` and ``Object|undefined``: Is fired if an error occurs during sending. If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.


-------
Expand Down
Loading

0 comments on commit 48918ba

Please sign in to comment.