File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -114,17 +114,21 @@ def ws_uri(self) -> Optional[str]:
114
114
def connection_str (self ) -> str :
115
115
return self .uri
116
116
117
- @property
118
- def _needs_poa_middleware (self ) -> bool :
119
- if self ._web3 is None :
120
- return False
121
-
122
117
def connect (self ):
123
118
session = _get_session ()
124
119
session .auth = ("" , api_secret )
125
-
126
120
http_provider = HTTPProvider (self .uri , session = session )
127
- self ._web3 = Web3 (http_provider )
121
+ self ._web3 = _create_web3 (http_provider )
122
+
123
+ if self ._needs_poa_middleware :
124
+ self ._web3 .middleware_onion .inject (geth_poa_middleware , layer = 0 )
125
+
126
+ self ._web3 .eth .set_gas_price_strategy (rpc_gas_price_strategy )
127
+
128
+ @property
129
+ def _needs_poa_middleware (self ) -> bool :
130
+ if self ._web3 is None :
131
+ return False
128
132
129
133
# Any chain that *began* as PoA needs the middleware for pre-merge blocks
130
134
optimism = (10 , 420 )
Original file line number Diff line number Diff line change 2
2
3
3
import pytest
4
4
import websocket # type: ignore
5
- from ape import networks
6
5
from ape .utils import ZERO_ADDRESS
7
6
from web3 .exceptions import ExtraDataLengthError
8
7
from web3 .middleware import geth_poa_middleware
9
8
10
- from ape_infura .provider import _WEBSOCKET_CAPABLE_ECOSYSTEMS , Infura
9
+ from ape_infura .provider import _WEBSOCKET_CAPABLE_ECOSYSTEMS , Infura , _get_session
11
10
12
11
13
12
def test_infura_http (provider ):
@@ -111,8 +110,6 @@ def test_dynamic_poa_check(mocker):
111
110
112
111
def test_api_secret ():
113
112
os .environ ["WEB3_INFURA_PROJECT_SECRET" ] = "123"
114
- mainnet = networks .ethereum .mainnet
115
- infura = Infura (name = "infura" , network = mainnet )
116
113
session = _get_session ()
117
114
assert session .auth == ("" , "123" )
118
115
del os .environ ["WEB3_INFURA_PROJECT_SECRET" ]
You can’t perform that action at this time.
0 commit comments