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,11 @@ 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
7782 self ._private = None
7883 self ._api_keys = None
7984 self ._eth = None
@@ -140,6 +145,7 @@ def private(self):
140145 default_address = self .default_address ,
141146 api_key_credentials = self .api_key_credentials ,
142147 )
148+ self ._private ._session = self ._session
143149 else :
144150 raise Exception (
145151 'Private endpoints not supported ' +
@@ -161,6 +167,7 @@ def api_keys(self):
161167 network_id = self .network_id ,
162168 default_address = self .default_address ,
163169 )
170+ self ._api_keys ._session = self ._session
164171 else :
165172 raise Exception (
166173 'API keys module is not supported since no Ethereum ' +
@@ -187,6 +194,7 @@ def onboarding(self):
187194 self .stark_public_key_y_coordinate
188195 ),
189196 )
197+ self ._onboarding ._session = self ._session
190198 else :
191199 raise Exception (
192200 'Onboarding is not supported since no Ethereum ' +
@@ -218,3 +226,13 @@ def eth(self):
218226 'eth_private_key nor web3_account was provided' ,
219227 )
220228 return self ._eth
229+
230+
231+ class TorClient (Client ):
232+
233+ def _set_session (self ):
234+ super ()._set_session ()
235+ self ._session .proxies = {
236+ 'http' : 'socks5://127.0.0.1:9050' ,
237+ 'https' : 'socks5://127.0.0.1:9050'
238+ }
0 commit comments