Skip to content

Commit fabe2e0

Browse files
committed
Remove auto provider except for local geth dev
1 parent 81c2088 commit fabe2e0

26 files changed

+45
-431
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ output/*/index.html
4444
# Sphinx
4545
docs/_build
4646
docs/modules.rst
47-
docs/web3.auto.infura.rst
4847
docs/web3.auto.rst
4948
docs/web3.gas_strategies.rst
5049
docs/web3.middleware.rst

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"web3.rst",
8383
"modules.rst",
8484
"web3.auto.rst",
85-
"web3.auto.infura.rst",
8685
"web3.gas_strategies.rst",
8786
"web3.middleware.rst",
8887
"web3.providers.rst",

docs/contributing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ virtualenv for smoke testing:
380380
# smoke test the release
381381
$ pip install ipython
382382
$ ipython
383-
>>> from web3.auto import w3
383+
>>> from web3 import Web3, IPCProvider
384+
>>> w3 = Web3(IPCProvider(provider_url))
384385
>>> w3.is_connected()
385386
>>> ...
386387

docs/examples.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,10 @@ it as a ``Package`` instance.
422422

423423
.. code-block:: python3
424424
425-
from web3.auto.infura import w3
426-
427425
# Note. To use the web3.pm module, you will need to instantiate your w3 instance
428426
# with a web3 provider connected to the chain on which your registry lives.
427+
from web3 import Web3, IPCProvider
428+
w3 = Web3(IPCProvider(...))
429429
430430
# The ethPM module is still experimental and subject to change,
431431
# so for now we need to enable it via a temporary flag.
@@ -471,8 +471,7 @@ within an ethPM package.
471471
# connected to your provider of choice. Now your factories will automatically
472472
# deploy to this new chain, and the deployments available on a package will
473473
# be automatically filtered to those located on the new chain.
474-
from web3.auto.infura.goerli import w3 as goerli_w3
475-
goerli_registrar = ens_package.update_w3(goerli_w3)
474+
goerli_registrar = ens_package.update_w3(w3_instance)
476475
477476
478477
Working with an ERC20 Token Contract

docs/filters.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,21 @@ Filtering
88
99
.. note ::
1010
11-
Most one-liners below assume ``w3`` to be a :class:`web3.Web3` instance;
12-
obtainable, for example, with:
13-
14-
.. code-block:: python
15-
16-
from web3.auto import w3
11+
Most one-liners below assume ``w3`` to be a :class:`web3.Web3` instance.
1712
1813
The :meth:`web3.eth.Eth.filter` method can be used to set up filters for:
1914

20-
* Pending Transactions: ``web3.eth.filter('pending')``
15+
* Pending Transactions: ``w3.eth.filter("pending")``
2116

22-
* New Blocks ``web3.eth.filter('latest')``
17+
* New Blocks ``w3.eth.filter("latest")``
2318

2419
* Event Logs
2520

2621
Through the contract instance api:
2722

2823
.. code-block:: python
2924
30-
event_filter = mycontract.events.myEvent.create_filter(fromBlock='latest', argument_filters={'arg1':10})
25+
event_filter = mycontract.events.myEvent.create_filter(fromBlock="latest", argument_filters={"arg1":10})
3126
3227
Or built manually by supplying `valid filter params <https://github.com/ethereum/execution-apis/blob/bea0266c42919a2fb3ee524fb91e624a23bc17c5/src/schemas/filter.json#L28>`_:
3328

@@ -203,9 +198,12 @@ Synchronous
203198

204199
.. code-block:: python
205200
206-
from web3.auto import w3
201+
from web3 import Web3, IPCProvider
207202
import time
208203
204+
# instantiate Web3 instance
205+
w3 = Web3(IPCProvider(...))
206+
209207
def handle_event(event):
210208
print(event)
211209
@@ -242,9 +240,11 @@ entries to a handler.
242240

243241
.. code-block:: python
244242
245-
from web3.auto import w3
243+
from web3 import Web3, IPCProvider
246244
import asyncio
247245
246+
# instantiate Web3 instance
247+
w3 = Web3(IPCProvider(...))
248248
249249
def handle_event(event):
250250
print(event)
@@ -281,10 +281,12 @@ releasing the ``main`` function for other tasks.
281281

282282
.. code-block:: python
283283
284-
from web3.auto import w3
284+
from web3 import Web3, IPCProvider
285285
from threading import Thread
286286
import time
287287
288+
# instantiate Web3 instance
289+
w3 = Web3(IPCProvider(...))
288290
289291
def handle_event(event):
290292
print(event)

docs/middleware.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ The easiest way to connect to a default ``geth --dev`` instance which loads the
390390
391391
# confirm that the connection succeeded
392392
>>> w3.client_version
393-
'Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9'
393+
'Geth/v1.10.25-stable/linux-amd64/go1.16.7'
394394
395395
This example connects to a local ``geth --dev`` instance on Linux with a
396396
unique IPC location and loads the middleware:
@@ -409,7 +409,7 @@ unique IPC location and loads the middleware:
409409
410410
# confirm that the connection succeeded
411411
>>> w3.client_version
412-
'Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9'
412+
'Geth/v1.10.25-stable/linux-amd64/go1.16.7'
413413
414414
Why is ``geth_poa_middleware`` necessary?
415415
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

docs/providers.rst

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -65,86 +65,6 @@ Then you are ready to initialize your Web3 instance, like so:
6565
6666
Finally, you are ready to :ref:`get started with Web3.py<first_w3_use>`.
6767

68-
.. _automatic_provider:
69-
70-
Automatic vs Manual Providers
71-
-----------------------------
72-
73-
The ``Web3`` object will look for the Ethereum node in a few
74-
standard locations if no providers are specified. Auto-detection happens
75-
when you initialize like so:
76-
77-
.. code-block:: python
78-
79-
from web3.auto import w3
80-
81-
# which is equivalent to:
82-
83-
from web3 import Web3
84-
w3 = Web3()
85-
86-
Sometimes, web3 cannot automatically detect where your node is.
87-
88-
- If you are not sure which kind of connection method to use, see
89-
:ref:`choosing_provider`.
90-
- If you know the connection method, but not the other information
91-
needed to connect (like the path to the IPC file), you will need to look up
92-
that information in your node's configuration.
93-
- If you're not sure which node you are using, see :ref:`choosing_node`
94-
95-
For a deeper dive into how automated detection works, see:
96-
97-
.. _automatic_provider_detection:
98-
99-
How Automated Detection Works
100-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101-
102-
Web3 attempts to connect to nodes in the following order, using the first
103-
successful connection it can make:
104-
105-
1. The connection specified by an environment variable, see :ref:`provider_uri`
106-
2. :class:`~web3.providers.ipc.IPCProvider`, which looks for several IPC file locations.
107-
``IPCProvider`` will not automatically detect a testnet connection, it is suggested that the
108-
user instead uses a ``w3`` instance from ``web3.auto.infura`` (e.g.
109-
``from web3.auto.infura.goerli import w3``) if they want to auto-detect a testnet.
110-
3. :class:`~web3.providers.rpc.HTTPProvider`, which attempts to connect to "http://localhost:8545"
111-
4. ``None`` - if no providers are successful, you can still use Web3 APIs
112-
that do not require a connection, like:
113-
114-
- :ref:`overview_type_conversions`
115-
- :ref:`overview_currency_conversions`
116-
- :ref:`overview_addresses`
117-
- :ref:`eth-account`
118-
- etc.
119-
120-
.. _automatic_provider_detection_examples:
121-
122-
Examples Using Automated Detection
123-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124-
125-
Some nodes provide APIs beyond the standards. Sometimes the same information is provided
126-
in different ways across nodes. If you want to write code that works
127-
across multiple nodes, you may want to look up the node type you are connected to.
128-
129-
For example, the following retrieves the client enode endpoint for both geth and parity:
130-
131-
.. code-block:: python
132-
133-
from web3.auto import w3
134-
135-
connected = w3.is_connected()
136-
137-
if connected and w3.client_version.startswith('Parity'):
138-
enode = w3.parity.enode
139-
140-
elif connected and w3.client_version.startswith('Geth'):
141-
enode = w3.geth.admin.node_info['enode']
142-
143-
else:
144-
enode = None
145-
146-
.. _provider_uri:
147-
14868
Provider via Environment Variable
14969
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15070

@@ -164,31 +84,6 @@ Valid formats for this environment variable are:
16484
Auto-initialization Provider Shortcuts
16585
--------------------------------------
16686

167-
There are a couple auto-initialization shortcuts for common providers.
168-
169-
Infura Mainnet
170-
~~~~~~~~~~~~~~
171-
172-
To easily connect to the Infura Mainnet remote node, first register for a free
173-
project ID if you don't have one at https://infura.io/register .
174-
175-
Then set the environment variable ``WEB3_INFURA_PROJECT_ID`` with your Project ID::
176-
177-
$ export WEB3_INFURA_PROJECT_ID=YourProjectID
178-
179-
If you have checked the box in the Infura UI indicating that requests need
180-
an optional secret key, set the environment variable ``WEB3_INFURA_API_SECRET``::
181-
182-
$ export WEB3_INFURA_API_SECRET=YourProjectSecret
183-
184-
.. code-block:: python
185-
186-
>>> from web3.auto.infura import w3
187-
188-
# confirm that the connection succeeded
189-
>>> w3.is_connected()
190-
True
191-
19287
Geth dev Proof of Authority
19388
~~~~~~~~~~~~~~~~~~~~~~~~~~~
19489

@@ -353,16 +248,6 @@ EthereumTesterProvider
353248
and ``py-evm`` dependencies needed to do testing: e.g. ``pip install web3[tester]``
354249

355250

356-
357-
AutoProvider
358-
~~~~~~~~~~~~
359-
360-
:class:`~web3.providers.auto.AutoProvider` is the default used when initializing
361-
:class:`web3.Web3` without any providers. There's rarely a reason to use it
362-
explicitly.
363-
364-
365-
366251
AsyncHTTPProvider
367252
~~~~~~~~~~~~~~~~~
368253

docs/quickstart.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,6 @@ to this local node can be done as follows:
7676
>>> w3.is_connected()
7777
True
7878
79-
If you stick to the default ports or IPC file locations, you can utilize a
80-
:ref:`convenience method <automatic_provider>` to automatically detect the provider
81-
and save a few keystrokes:
82-
83-
.. code-block:: python
84-
85-
>>> from web3.auto import w3
86-
>>> w3.is_connected()
87-
True
88-
8979
9080
Remote Providers
9181
****************

docs/v5_migration.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ Testnet Changes
117117
~~~~~~~~~~~~~~~
118118

119119
Web3.py will no longer automatically look up a testnet connection
120-
in IPCProvider. Something like ``from web3.auto.infura.ropsten import w3``
121-
should be used instead.
120+
in IPCProvider.
122121

123122
ENS
124123
---

docs/web3.eth.account.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ Example ``account_test_script.py``
7878
import os
7979
from eth_account import Account
8080
from eth_account.signers.local import LocalAccount
81-
from web3.auto import w3
81+
from web3 import Web3, EthereumTesterProvider
8282
from web3.middleware import construct_sign_and_send_raw_middleware
83+
84+
w3 = Web3(EthereumTesterProvider())
8385
8486
private_key = os.environ.get("PRIVATE_KEY")
8587
assert private_key is not None, "You must set PRIVATE_KEY environment variable"
@@ -143,9 +145,10 @@ is provided by :meth:`w3.eth.sign() <web3.eth.Eth.sign>`.
143145

144146
.. doctest::
145147

146-
>>> from web3.auto import w3
148+
>>> from web3 import Web3, EthereumTesterProvider
147149
>>> from eth_account.messages import encode_defunct
148150

151+
>>> w3 = Web3(EthereumTesterProvider())
149152
>>> msg = "I♥SF"
150153
>>> private_key = b"\xb2\\}\xb3\x1f\xee\xd9\x12''\xbf\t9\xdcv\x9a\x96VK-\xe4\xc4rm\x03[6\xec\xf1\xe5\xb3d"
151154
>>> message = encode_defunct(text=msg)
@@ -334,7 +337,8 @@ To sign a transaction locally that will invoke a smart contract:
334337
# When running locally, execute the statements found in the file linked below to load the EIP20_ABI variable.
335338
# See: https://github.com/carver/ethtoken.py/blob/v0.0.1-alpha.4/ethtoken/abi.py
336339

337-
>>> from web3.auto import w3
340+
>>> from web3 import Web3, EthereumTesterProvider
341+
>>> w3 = Web3(EthereumTesterProvider())
338342

339343
>>> unicorns = w3.eth.contract(address="0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359", abi=EIP20_ABI)
340344

0 commit comments

Comments
 (0)