Skip to content

Commit 14d2ef6

Browse files
committed
feat: update june 2024
1 parent 1aff65b commit 14d2ef6

File tree

13 files changed

+213
-99
lines changed

13 files changed

+213
-99
lines changed

cryptomarket/args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class OrderBy(Checker):
156156
CREATED_AT = 'created_at'
157157
UPDATED_AT = 'updated_at'
158158
LAST_ACTIVITY_UP = 'last_activity_up'
159+
ID = 'id'
159160

160161

161162
class Depth(Checker):
@@ -261,6 +262,9 @@ def symbols(self, val: Optional[Union[str, List[str]]]):
261262
def currency(self, val: Optional[str]):
262263
return self.add("currency", val)
263264

265+
def network_code(self, val: Optional[str]):
266+
return self.add("network_code", val)
267+
264268
def from_(self, val: Optional[str]):
265269
return self.add("from", val)
266270

@@ -474,6 +478,9 @@ def preferred_network(self, val: Optional[str]):
474478
def type(self, val: Optional[str]):
475479
return self.add('type', val)
476480

481+
def group_transactions(self, val: Optional[bool]):
482+
return self.add('group_transactions', val)
483+
477484
def acl_settings(self, val: ACLSettings):
478485
self.add(
479486
'deposit_address_generation_enabled',

cryptomarket/client.py

Lines changed: 134 additions & 65 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from dataclasses import dataclass
2+
from typing import Optional
23

34

45
@dataclass
56
class CommitRisk:
6-
score: int
7-
rbf: str
8-
low_fee: str
7+
score: Optional[int] = None
8+
rbf: Optional[str] = None
9+
low_fee: Optional[str] = None

cryptomarket/dataclasses/fee.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from dataclasses import dataclass
22
from typing import Any, Dict, Optional
33

4+
45
@dataclass
56
class Fee:
6-
fee: Optional[str]
7+
fee: str
78
network_fee: Optional[str]
8-
amount: Optional[str]
9-
currency: Optional[str]
9+
amount: str
10+
currency: str
1011

1112
@classmethod
1213
def from_dict(cls, data: Dict[str, Any]):
13-
return cls(data.get('fee'), data.get('networkFee'), data.get('amount'), data.get('currency'))
14+
return cls(data['fee'], data.get('networkFee'), data['amount'], data['currency'])

cryptomarket/dataclasses/network.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import Optional
2+
from typing import Mapping, Optional
33

44

55
@dataclass
@@ -21,3 +21,9 @@ class Network:
2121
avg_processing_time: Optional[str] = None
2222
crypto_payment_id_name: Optional[str] = None
2323
crypto_explorer: Optional[str] = None
24+
code: Optional[str] = None
25+
is_ens_available: Optional[bool] = None
26+
network_name: Optional[str] = None
27+
contract_address: Optional[str] = None
28+
is_multichain: Optional[bool] = None
29+
asset_id: Optional[Mapping[str,str]] = None

cryptomarket/http_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
class HttpClient:
1313

14-
def __init__(self, api_key: str, secret_key: str, window: Optional[int] = None):
14+
def __init__(self, api_key: str, api_secret: str, window: Optional[int] = None):
1515
self.api_key = api_key
16-
self.secret_key = secret_key
16+
self.api_secret = api_secret
1717
self.window = window
1818
self.session_is_open = False
1919
session = requests.session()
@@ -25,10 +25,10 @@ def close_session(self):
2525
self.session.close()
2626
self.session_is_open = False
2727

28-
def authorize(self):
28+
def reset_authorization(self):
2929
assert self.session_is_open == True
3030
self.session.auth = HmacAuth(
31-
self.api_key, self.secret_key, window=self.window)
31+
self.api_key, self.api_secret, window=self.window)
3232

3333
def get(self, endpoint, params=None):
3434
response = self.session.get(api_url + endpoint, params=params)
@@ -55,7 +55,7 @@ def delete(self, endpoint, params=None):
5555

5656
def _handle_response(self, response):
5757
"""Internal helper for handling API responses from the CryptoMarket server.
58-
Raises the appropriate exceptions when necessary; otherwise, returns the
58+
Raises the appropriate exceptions when necessary; otherwise, return the
5959
response.
6060
"""
6161
if not str(response.status_code).startswith('2'):

cryptomarket/websockets/callback_cache.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class CallbackCache:
99
def __init__(self):
10-
self.callbacks: Dict[int, ReusableCallback] = {}
10+
self.reusable_callbacks: Dict[int, ReusableCallback[Any]] = {}
1111
self.subscription_callbacks: Dict[int, Callback[Any]] = {}
1212
self._id = 1
1313

@@ -19,16 +19,16 @@ def next_id(self):
1919

2020
def save_callback(self, callback: Callback[Any], call_count: int = 1) -> int:
2121
id = self.next_id()
22-
self.callbacks[id] = ReusableCallback(callback, call_count)
22+
self.reusable_callbacks[id] = ReusableCallback(callback, call_count)
2323
return id
2424

2525
def get_callback(self, id: int) -> Optional[Callback[Any]]:
26-
if id not in self.callbacks:
26+
if id not in self.reusable_callbacks:
2727
return None
28-
reusable_callback = self.callbacks[id]
28+
reusable_callback = self.reusable_callbacks[id]
2929
callback, done = reusable_callback.get_callback()
3030
if done:
31-
del self.callbacks[id]
31+
del self.reusable_callbacks[id]
3232
return callback
3333

3434
def save_subscription_callback(self, key: int, callback: Callback[Any]):
@@ -40,5 +40,5 @@ def get_subscription_callback(self, key: int) -> Optional[Callback[Any]]:
4040
return self.subscription_callbacks[key]
4141

4242
def delete_subscription_callback(self, key: str):
43-
if key in self.callbacks:
44-
del self.callbacks[key]
43+
if key in self.reusable_callbacks:
44+
del self.reusable_callbacks[key]

cryptomarket/websockets/client_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def authenticate(self, callback: Optional[Callable[[Any, Any], Any]] = None):
6969
7070
:param callback: Optional. A callable to call with the result data. It takes two arguments, err and result. err is None for successful calls, result is None for calls with error: callback(err, result).
7171
72-
:returns: The transaction status as result argument for the callback.
72+
:return: The transaction status as result argument for the callback.
7373
7474
.. code-block:: python
7575
True

cryptomarket/websockets/reusable_callback.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from dataclasses import dataclass
2-
from typing import Any, Callable, Optional, Tuple
2+
from typing import Optional, Tuple, Generic
33

4-
from cryptomarket.websockets.callback import Callback
4+
from cryptomarket.websockets.callback import T, Callback
55

66

77
@dataclass
8-
class ReusableCallback:
9-
callback: Callable
8+
class ReusableCallback(Generic[T]):
9+
callback: Callback[T]
1010
call_count: int
1111

1212
def is_done(self) -> bool:
1313
return self.call_count < 1
1414

15-
def get_callback(self) -> Tuple[Optional[Callback[Any]], bool]:
15+
def get_callback(self) -> Tuple[Optional[Callback[T]], bool]:
1616
if self.is_done():
1717
return None, True
1818
self.call_count -= 1

cryptomarket/websockets/trading_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def intercept_result(err, response):
364364
params=params)
365365

366366
def cancel_spot_orders(self, callback: Optional[Callback[List[Report]]] = None):
367-
"""cancel all active spot orders and returns the ones that could not be canceled
367+
"""cancel all active spot orders and return the ones that could not be canceled
368368
369369
https://api.exchange.cryptomkt.com/#cancel-spot-orders
370370

0 commit comments

Comments
 (0)