Skip to content

Commit 6be6489

Browse files
authored
Merge branch 'master' into async_api
2 parents 486e28f + 0617444 commit 6be6489

28 files changed

+192
-197
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 5.0.0-alpha.2
2+
current_version = 5.0.0-alpha.3
33
commit = True
44
tag = True
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<stage>[^.]*)\.(?P<devnum>\d+))?

docs/gas_price.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,6 @@ Available gas price strategies
112112
w3 = Web3()
113113
w3.eth.setGasPriceStrategy(medium_gas_price_strategy)
114114
115-
w3.middleware_stack.add(middleware.time_based_cache_middleware)
116-
w3.middleware_stack.add(middleware.latest_block_based_cache_middleware)
117-
w3.middleware_stack.add(middleware.simple_cache_middleware)
115+
w3.middleware_onion.add(middleware.time_based_cache_middleware)
116+
w3.middleware_onion.add(middleware.latest_block_based_cache_middleware)
117+
w3.middleware_onion.add(middleware.simple_cache_middleware)

docs/internals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ middleware performs the following translations for requests and responses.
197197
* Numeric responses will be converted from their hexadecimal representations to
198198
their integer representations.
199199

200-
The ``RequestManager`` object exposes the ``middleware_stack`` object to manage middlewares. It
200+
The ``RequestManager`` object exposes the ``middleware_onion`` object to manage middlewares. It
201201
is also exposed on the ``Web3`` object for convenience. That API is detailed in
202202
:ref:`Modifying_Middleware`.
203203

docs/middleware.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ to the request inside the innermost layer of the onion. Here is a (simplified) d
142142
Returned value in Web3.py
143143
144144
145-
The middlewares are maintained in ``Web3.middleware_stack``. See
145+
The middlewares are maintained in ``Web3.middleware_onion``. See
146146
below for the API.
147147

148148
When specifying middlewares in a list, or retrieving the list of middlewares, they will
149149
be returned in the order of outermost layer first and innermost layer last. In the above
150-
example, that means that ``list(w3.middleware_stack)`` would return the middlewares in
150+
example, that means that ``list(w3.middleware_onion)`` would return the middlewares in
151151
the order of: ``[2, 1, 0]``.
152152

153153
See "Internals: :ref:`internals__middlewares`" for a deeper dive to how middlewares work.
@@ -157,7 +157,7 @@ Middleware Stack API
157157

158158
To add or remove items in different layers, use the following API:
159159

160-
.. py:method:: Web3.middleware_stack.add(middleware, name=None)
160+
.. py:method:: Web3.middleware_onion.add(middleware, name=None)
161161
162162
Middleware will be added to the outermost layer. That means the new middleware will modify the
163163
request first, and the response last. You can optionally name it with any hashable object,
@@ -166,27 +166,27 @@ To add or remove items in different layers, use the following API:
166166
.. code-block:: python
167167
168168
>>> w3 = Web3(...)
169-
>>> w3.middleware_stack.add(web3.middleware.pythonic_middleware)
169+
>>> w3.middleware_onion.add(web3.middleware.pythonic_middleware)
170170
# or
171-
>>> w3.middleware_stack.add(web3.middleware.pythonic_middleware, 'pythonic')
171+
>>> w3.middleware_onion.add(web3.middleware.pythonic_middleware, 'pythonic')
172172
173-
.. py:method:: Web3.middleware_stack.inject(middleware, name=None, layer=None)
173+
.. py:method:: Web3.middleware_onion.inject(middleware, name=None, layer=None)
174174
175175
Inject a named middleware to an arbitrary layer.
176176

177177
The current implementation only supports injection at the innermost or
178178
outermost layers. Note that injecting to the outermost layer is equivalent to calling
179-
:meth:`Web3.middleware_stack.add` .
179+
:meth:`Web3.middleware_onion.add` .
180180

181181
.. code-block:: python
182182
183183
# Either of these will put the pythonic middleware at the innermost layer
184184
>>> w3 = Web3(...)
185-
>>> w3.middleware_stack.inject(web3.middleware.pythonic_middleware, layer=0)
185+
>>> w3.middleware_onion.inject(web3.middleware.pythonic_middleware, layer=0)
186186
# or
187-
>>> w3.middleware_stack.inject(web3.middleware.pythonic_middleware, 'pythonic', layer=0)
187+
>>> w3.middleware_onion.inject(web3.middleware.pythonic_middleware, 'pythonic', layer=0)
188188
189-
.. py:method:: Web3.middleware_stack.remove(middleware)
189+
.. py:method:: Web3.middleware_onion.remove(middleware)
190190
191191
Middleware will be removed from whatever layer it was in. If you added the middleware with
192192
a name, use the name to remove it. If you added the middleware as an object, use the object
@@ -195,11 +195,11 @@ To add or remove items in different layers, use the following API:
195195
.. code-block:: python
196196
197197
>>> w3 = Web3(...)
198-
>>> w3.middleware_stack.remove(web3.middleware.pythonic_middleware)
198+
>>> w3.middleware_onion.remove(web3.middleware.pythonic_middleware)
199199
# or
200-
>>> w3.middleware_stack.remove('pythonic')
200+
>>> w3.middleware_onion.remove('pythonic')
201201
202-
.. py:method:: Web3.middleware_stack.replace(old_middleware, new_middleware)
202+
.. py:method:: Web3.middleware_onion.replace(old_middleware, new_middleware)
203203
204204
Middleware will be replaced from whatever layer it was in. If the middleware was named, it will
205205
continue to have the same name. If it was un-named, then you will now reference it with the new
@@ -210,25 +210,25 @@ To add or remove items in different layers, use the following API:
210210
>>> from web3.middleware import pythonic_middleware, attrdict_middleware
211211
>>> w3 = Web3(...)
212212
213-
>>> w3.middleware_stack.replace(pythonic_middleware, attrdict_middleware)
213+
>>> w3.middleware_onion.replace(pythonic_middleware, attrdict_middleware)
214214
# this is now referenced by the new middleware object, so to remove it:
215-
>>> w3.middleware_stack.remove(attrdict_middleware)
215+
>>> w3.middleware_onion.remove(attrdict_middleware)
216216
217217
# or, if it was named
218218
219-
>>> w3.middleware_stack.replace('pythonic', attrdict_middleware)
219+
>>> w3.middleware_onion.replace('pythonic', attrdict_middleware)
220220
# this is still referenced by the original name, so to remove it:
221-
>>> w3.middleware_stack.remove('pythonic')
221+
>>> w3.middleware_onion.remove('pythonic')
222222
223-
.. py:method:: Web3.middleware_stack.clear()
223+
.. py:method:: Web3.middleware_onion.clear()
224224
225225
Empty all the middlewares, including the default ones.
226226

227227
.. code-block:: python
228228
229229
>>> w3 = Web3(...)
230-
>>> w3.middleware_stack.clear()
231-
>>> assert len(w3.middleware_stack) == 0
230+
>>> w3.middleware_onion.clear()
231+
>>> assert len(w3.middleware_onion) == 0
232232
233233
234234
Optional Middleware
@@ -244,7 +244,7 @@ Web3 ships with non-default middleware, for your custom use. In addition to the
244244
.. warning::
245245
This will
246246
*replace* the default middlewares. To keep the default functionality,
247-
either use ``middleware_stack.add()`` from above, or add the default middlewares to your list of
247+
either use ``middleware_onion.add()`` from above, or add the default middlewares to your list of
248248
new middlewares.
249249

250250
Below is a list of built-in middleware, which is not enabled by default.
@@ -266,7 +266,7 @@ Stalecheck
266266
.. code-block:: python
267267
268268
two_day_stalecheck = make_stalecheck_middleware(60 * 60 * 24 * 2)
269-
web3.middleware_stack.add(two_day_stalecheck)
269+
web3.middleware_onion.add(two_day_stalecheck)
270270
271271
If the latest block in the blockchain is older than 2 days in this example, then the
272272
middleware will raise a ``StaleBlockchain`` exception on every call except
@@ -352,7 +352,7 @@ unique IPC location and loads the middleware:
352352
>>> from web3.middleware import geth_poa_middleware
353353
354354
# inject the poa compatibility middleware to the innermost layer
355-
>>> w3.middleware_stack.inject(geth_poa_middleware, layer=0)
355+
>>> w3.middleware_onion.inject(geth_poa_middleware, layer=0)
356356
357357
# confirm that the connection succeeded
358358
>>> w3.version.node
@@ -383,7 +383,7 @@ retrieved using JSON-RPC endpoints that don't rely on server state.
383383
>>> from web3 import Web3, EthereumTesterProvider
384384
>>> w3 = Web3(EthereumTesterProvider)
385385
>>> from web3.middleware import local_filter_middleware
386-
>>> w3.middleware_stack.add(local_filter_middleware())
386+
>>> w3.middleware_onion.add(local_filter_middleware())
387387
388388
# Normal block and log filter apis behave as before.
389389
>>> block_filter = w3.eth.filter("latest")
@@ -412,6 +412,6 @@ This middleware automatically captures transactions, signs them, and sends them
412412
>>> from web3.middleware import construct_sign_and_send_raw_middleware
413413
>>> from eth_account import Account
414414
>>> acct = Account.create('KEYSMASH FJAFJKLDSKF7JKFDJ 1530')
415-
>>> w3.middleware_stack.add(construct_sign_and_send_raw_middleware(acct))
415+
>>> w3.middleware_onion.add(construct_sign_and_send_raw_middleware(acct))
416416
>>> w3.eth.defaultAccount = acct.address
417417
# Now you can send a tx from acct.address without having to build and sign each raw transaction

docs/providers.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ Web3 attempts to connect to nodes in the following order, using the first
9595
succesful connection it can make:
9696

9797
1. The connection specified by an environment variable, see :ref:`provider_uri`
98-
2. :class:`~web3.providers.ipc.IPCProvider`, which looks for several IPC file locations
98+
2. :class:`~web3.providers.ipc.IPCProvider`, which looks for several IPC file locations.
99+
`IPCProvider` will not automatically detect a testnet connection, it is suggested that the
100+
user instead uses a `w3` instance from `web3.auto.infura` (eg.
101+
`from web3.auto.infura.ropsten import w3`) if they want to auto-detect a testnet.
99102
3. :class:`~web3.providers.rpc.HTTPProvider`, which attempts to connect to "http://localhost:8545"
100103
4. None - if no providers are successful, you can still use Web3 APIs
101104
that do not require a connection, like:

docs/releases.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
11
Release Notes
22
=============
33

4+
5+
v5.0.0-alpha.3
6+
--------------
7+
8+
Released January 15th, 2019
9+
10+
- Breaking Changes
11+
12+
- Remove ``web3.miner.hashrate`` and ``web3.version.network``
13+
- `#1198 <https://github.com/ethereum/web3.py/pull/1198>`_
14+
- Remove ``web3.providers.tester.EthereumTesterProvider``
15+
and ``web3.providers.tester.TestRPCProvider``
16+
- `#1199 <https://github.com/ethereum/web3.py/pull/1199>`_
17+
- Change ``manager.providers`` from list to single ``manager.provider``
18+
- `#1200 <https://github.com/ethereum/web3.py/pull/1200>`_
19+
- Replace deprecated ``web3.sha3`` method with ``web3.keccak`` method
20+
- `#1207 <https://github.com/ethereum/web3.py/pull/1207>`_
21+
- Drop auto detect testnets for IPCProvider
22+
- `#1206 <https://github.com/ethereum/web3.py/pull/1206>`_
23+
24+
- Bugfixes
25+
26+
- Add check to make sure blockHash exists
27+
- `#1158 <https://github.com/ethereum/web3.py/pull/1158>`_
28+
29+
- Misc
30+
31+
- Remove some unreachable code in `providers/base.py`
32+
- `#1160 <https://github.com/ethereum/web3.py/pull/1160>`_
33+
- Migrate tester provider results from middleware to defaults
34+
- `#1188 <https://github.com/ethereum/web3.py/pull/1188>`_
35+
- Fix doc formatting for build_filter method
36+
- `#1187 <https://github.com/ethereum/web3.py/pull/1187>`_
37+
- Add ERC20 example in docs
38+
- `#1178 <https://github.com/ethereum/web3.py/pull/1178>`_
39+
- Code style improvements
40+
- `#1194 <https://github.com/ethereum/web3.py/pull/1194>`_
41+
& `#1191 <https://github.com/ethereum/web3.py/pull/1191>`_
42+
- Convert Web3 instance variables to w3
43+
- `#1186 <https://github.com/ethereum/web3.py/pull/1186>`_
44+
- Update eth-utils dependencies and clean up other dependencies
45+
- `#1195 <https://github.com/ethereum/web3.py/pull/1195>`_
46+
47+
448
v5.0.0-alpha.2
549
--------------
650

docs/web3.eth.account.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,5 +302,5 @@ To sign a transaction locally that will invoke a smart contract:
302302
>>> w3.eth.sendRawTransaction(signed_txn.rawTransaction) # doctest: +SKIP
303303

304304
# When you run sendRawTransaction, you get the same result as the hash of the transaction:
305-
>>> w3.toHex(w3.sha3(signed_txn.rawTransaction))
305+
>>> w3.toHex(w3.keccak(signed_txn.rawTransaction))
306306
'0x4795adc6a719fa64fa21822630c0218c04996e2689ded114b6553cef1ae36618'

ens/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def customize_web3(w3):
6262
from web3.contract import ConciseContract
6363
from web3.middleware import make_stalecheck_middleware
6464

65-
w3.middleware_stack.remove('name_to_address')
66-
w3.middleware_stack.add(
65+
w3.middleware_onion.remove('name_to_address')
66+
w3.middleware_onion.add(
6767
make_stalecheck_middleware(ACCEPTABLE_STALE_HOURS * 3600),
6868
name='stalecheck',
6969
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
setup(
6060
name='web3',
6161
# *IMPORTANT*: Don't manually change the version here. Use the 'bumpversion' utility.
62-
version='5.0.0-alpha.2',
62+
version='5.0.0-alpha.3',
6363
description="""Web3.py""",
6464
long_description_markdown_filename='README.md',
6565
author='Piper Merriam',

tests/core/eth-module/test_poa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_long_extra_data(web3):
1414
return_block_with_long_extra_data = construct_fixture_middleware({
1515
'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 33},
1616
})
17-
web3.middleware_stack.inject(return_block_with_long_extra_data, layer=0)
17+
web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0)
1818
with pytest.raises(ValidationError):
1919
web3.eth.getBlock('latest')
2020

@@ -23,7 +23,7 @@ def test_full_extra_data(web3):
2323
return_block_with_long_extra_data = construct_fixture_middleware({
2424
'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 32},
2525
})
26-
web3.middleware_stack.inject(return_block_with_long_extra_data, layer=0)
26+
web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0)
2727
block = web3.eth.getBlock('latest')
2828
assert block.extraData == b'\xff' * 32
2929

@@ -32,8 +32,8 @@ def test_geth_proof_of_authority(web3):
3232
return_block_with_long_extra_data = construct_fixture_middleware({
3333
'eth_getBlockByNumber': {'extraData': '0x' + 'ff' * 33},
3434
})
35-
web3.middleware_stack.inject(geth_poa_middleware, layer=0)
36-
web3.middleware_stack.inject(return_block_with_long_extra_data, layer=0)
35+
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
36+
web3.middleware_onion.inject(return_block_with_long_extra_data, layer=0)
3737
block = web3.eth.getBlock('latest')
3838
assert 'extraData' not in block
3939
assert block.proofOfAuthorityData == b'\xff' * 33

0 commit comments

Comments
 (0)