33from dydx3 .constants import NETWORK_ID_MAINNET
44from dydx3 .eth_signing import SignWithWeb3
55from dydx3 .eth_signing import SignWithKey
6+ from dydx3 .helpers .requests import _RequestManager
67from dydx3 .modules .api_keys import ApiKeys
78from dydx3 .modules .eth import Eth
89from dydx3 .modules .private import Private
1415)
1516
1617
17- class Client (object ):
18+ class Client (_RequestManager ):
1819
1920 def __init__ (
2021 self ,
2122 host ,
22- api_timeout = 3000 , # TODO: Actually use this.
23+ api_timeout = 3000 ,
2324 default_ethereum_address = None ,
2425 eth_private_key = None ,
2526 eth_send_options = None ,
@@ -73,7 +74,12 @@ def __init__(
7374
7475 # Initialize the public module. Other modules are initialized on
7576 # demand, if the necessary configuration options were provided.
77+
78+ self ._set_session ()
79+
7680 self ._public = Public (host )
81+ self ._public ._session = self ._session
82+ self ._public .api_timeout = self .api_timeout
7783 self ._private = None
7884 self ._api_keys = None
7985 self ._eth = None
@@ -140,6 +146,8 @@ def private(self):
140146 default_address = self .default_address ,
141147 api_key_credentials = self .api_key_credentials ,
142148 )
149+ self ._private ._session = self ._session
150+ self ._private .api_timeout = self .api_timeout
143151 else :
144152 raise Exception (
145153 'Private endpoints not supported ' +
@@ -161,6 +169,8 @@ def api_keys(self):
161169 network_id = self .network_id ,
162170 default_address = self .default_address ,
163171 )
172+ self ._api_keys ._session = self ._session
173+ self ._api_keys .api_timeout = self .api_timeout
164174 else :
165175 raise Exception (
166176 'API keys module is not supported since no Ethereum ' +
@@ -187,6 +197,8 @@ def onboarding(self):
187197 self .stark_public_key_y_coordinate
188198 ),
189199 )
200+ self ._onboarding ._session = self ._session
201+ self ._onboarding .api_timeout = self .api_timeout
190202 else :
191203 raise Exception (
192204 'Onboarding is not supported since no Ethereum ' +
@@ -218,3 +230,13 @@ def eth(self):
218230 'eth_private_key nor web3_account was provided' ,
219231 )
220232 return self ._eth
233+
234+
235+ class TorClient (Client ):
236+
237+ def _set_session (self ):
238+ super ()._set_session ()
239+ self ._session .proxies = {
240+ 'http' : 'socks5://127.0.0.1:9050' ,
241+ 'https' : 'socks5://127.0.0.1:9050'
242+ }
0 commit comments