near-jsonrpc-client 1.0.21__py3-none-any.whl → 1.0.23__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  from .client import NearClientAsync, NearClientSync
2
2
  from .transport import HttpTransportAsync, HttpTransportSync
3
3
  from .errors import (
4
- ClientError,
5
- TransportError,
6
- HttpError,
4
+ RpcClientError,
5
+ RpcTransportError,
6
+ RpcHttpError,
7
7
  RpcError,
8
8
  RpcTimeoutError
9
9
  )
@@ -19,9 +19,9 @@ __all__ = [
19
19
  "HttpTransportSync",
20
20
 
21
21
  # Errors
22
- "ClientError",
23
- "TransportError",
24
- "HttpError",
22
+ "RpcClientError",
23
+ "RpcTransportError",
24
+ "RpcHttpError",
25
25
  "RpcError",
26
26
  "RpcTimeoutError"
27
27
  ]
@@ -7,11 +7,11 @@ from pydantic import BaseModel
7
7
  from typing import get_args
8
8
 
9
9
  from .errors import (
10
- ClientError,
11
- TransportError,
12
- HttpError,
10
+ RpcClientError,
11
+ RpcTransportError,
12
+ RpcHttpError,
13
13
  RpcError,
14
- RequestTimeoutError,
14
+ RpcTimeoutError,
15
15
  )
16
16
  from .transport import HttpTransportAsync, HttpTransportSync
17
17
 
@@ -19,13 +19,13 @@ from .transport import HttpTransportAsync, HttpTransportSync
19
19
  def _extract_method(request_model: Type[BaseModel]) -> str:
20
20
  field = request_model.model_fields.get("method")
21
21
  if field is None:
22
- raise ClientError(
22
+ raise RpcClientError(
23
23
  f"{request_model.__name__} does not define a 'method' field"
24
24
  )
25
25
 
26
26
  args = get_args(field.annotation)
27
27
  if len(args) != 1 or not isinstance(args[0], str):
28
- raise ClientError(
28
+ raise RpcClientError(
29
29
  f"Invalid JSON-RPC method definition in {request_model.__name__}"
30
30
  )
31
31
 
@@ -39,9 +39,9 @@ def _parse_response(response_model: Type[BaseModel], response_json: dict):
39
39
  except Exception as e:
40
40
 
41
41
  if response_json["result"]["error"] is not None:
42
- raise ClientError(response_json["result"]["error"]) from e
42
+ raise RpcClientError(response_json["result"]["error"]) from e
43
43
 
44
- raise ClientError("Invalid response format") from e
44
+ raise RpcClientError("Invalid response format") from e
45
45
 
46
46
  inner = parsed.root
47
47
  if hasattr(inner, "error") and inner.error is not None:
@@ -87,12 +87,12 @@ class NearBaseClientAsync:
87
87
  print("⬅️ JSON-RPC Raw Response:", response.text)
88
88
 
89
89
  except httpx.TimeoutException as e:
90
- raise RequestTimeoutError() from e
90
+ raise RpcTimeoutError() from e
91
91
  except httpx.RequestError as e:
92
- raise TransportError(str(e)) from e
92
+ raise RpcTransportError(str(e)) from e
93
93
 
94
94
  if 500 <= response.status_code < 600:
95
- raise HttpError(status_code=response.status_code, body=response.text)
95
+ raise RpcHttpError(status_code=response.status_code, body=response.text)
96
96
 
97
97
  return _parse_response(response_model, response.json())
98
98
 
@@ -139,12 +139,12 @@ class NearBaseClientSync:
139
139
 
140
140
  # handle sync transport exceptions (requests or httpx sync)
141
141
  except requests.Timeout as e:
142
- raise RequestTimeoutError() from e
142
+ raise RpcTimeoutError() from e
143
143
  except requests.RequestException as e:
144
- raise TransportError(str(e)) from e
144
+ raise RpcTransportError(str(e)) from e
145
145
 
146
146
  if 500 <= response.status_code < 600:
147
- raise HttpError(status_code=response.status_code, body=response.text)
147
+ raise RpcHttpError(status_code=response.status_code, body=response.text)
148
148
 
149
149
  return _parse_response(response_model, response.json())
150
150
 
@@ -1,17 +1,17 @@
1
1
  from pydantic import BaseModel
2
2
 
3
3
 
4
- class ClientError(Exception):
4
+ class RpcClientError(Exception):
5
5
  """Base error for all NEAR client related failures."""
6
6
  pass
7
7
 
8
8
 
9
- class TransportError(ClientError):
9
+ class RpcTransportError(RpcClientError):
10
10
  """Network-level errors (timeout, DNS, connection, etc)."""
11
11
  pass
12
12
 
13
13
 
14
- class HttpError(ClientError):
14
+ class RpcHttpError(RpcClientError):
15
15
  """Non-200 HTTP responses."""
16
16
 
17
17
  def __init__(self, status_code: int, body: str | None = None):
@@ -20,7 +20,7 @@ class HttpError(ClientError):
20
20
  super().__init__(f"HTTP error {status_code}")
21
21
 
22
22
 
23
- class RpcError(ClientError):
23
+ class RpcError(RpcClientError):
24
24
  """JSON-RPC error object wrapping the Pydantic error model."""
25
25
 
26
26
  def __init__(self, error: BaseModel | str):
@@ -32,7 +32,7 @@ class RpcError(ClientError):
32
32
  super().__init__(error)
33
33
 
34
34
 
35
- class RpcTimeoutError(ClientError):
35
+ class RpcTimeoutError(RpcClientError):
36
36
  """Timeout Error"""
37
37
 
38
38
  def __init__(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: near-jsonrpc-client
3
- Version: 1.0.21
3
+ Version: 1.0.23
4
4
  Summary: A typed Python client for the NEAR JSON-RPC API with Pydantic models and async HTTP support
5
5
  Requires-Python: >=3.9
6
6
  Description-Content-Type: text/markdown
@@ -174,24 +174,24 @@ print(response)
174
174
  The client raises structured exceptions:
175
175
 
176
176
  * `RpcError` – returned from NEAR JSON-RPC
177
- * `HttpError` – HTTP errors with status code and body
178
- * `RequestTimeoutError` – request timeout
179
- * `ClientError` – unexpected or invalid responses
177
+ * `RpcHttpError` – HTTP errors with status code and body
178
+ * `RpcTimeoutError` – request timeout
179
+ * `RpcClientError` – unexpected or invalid responses
180
180
 
181
181
  Example:
182
182
 
183
183
  ```python
184
- from near_jsonrpc_client import RpcError, HttpError, RequestTimeoutError, ClientError
184
+ from near_jsonrpc_client import RpcError, RpcHttpError, RpcTimeoutError, RpcClientError
185
185
 
186
186
  try:
187
187
  block = client.block(params=params)
188
188
  except RpcError as e:
189
189
  print(f"RPC error: {e.error}")
190
- except HttpError as e:
190
+ except RpcHttpError as e:
191
191
  print(f"HTTP error: {e.status_code}, {e.body}")
192
- except RequestTimeoutError as e:
192
+ except RpcTimeoutError as e:
193
193
  print("Request timed out")
194
- except ClientError as e:
194
+ except RpcClientError as e:
195
195
  print("Invalid response", e)
196
196
  ```
197
197
 
@@ -1,11 +1,11 @@
1
- near_jsonrpc_client/__init__.py,sha256=AFX_TCuWlM5KoNPbCyBXE8eXYOt_ToHMx4rXjU5a12g,481
1
+ near_jsonrpc_client/__init__.py,sha256=Sf6Vun5j7BU_gfA-VvoOCvxVcJUMfS9GCTSe0mHE76o,499
2
2
  near_jsonrpc_client/api_methods_async.py,sha256=ELi7-hV3GugFlI7hLNhkjYStupO2LY3O1MxPysNJLmg,27606
3
3
  near_jsonrpc_client/api_methods_sync.py,sha256=XUtvoUmMeMRmq1XT-QNgvLWKEJ9mq1GAwM85j-xXE6g,27095
4
- near_jsonrpc_client/base_client.py,sha256=70KENuSAb7DN5zUM0uA_1pC2kVQ9n3Kt_R59m1c3j4w,4313
4
+ near_jsonrpc_client/base_client.py,sha256=xd4_o8-Z1wWFpRmkveYTzo1xoqUeQgw-1_oZzFogSIg,4334
5
5
  near_jsonrpc_client/client.py,sha256=8gnY3tgUOGwUe4r8_mOedlLik8Zr6jxbNMVxwPlmHYo,453
6
- near_jsonrpc_client/errors.py,sha256=s0p8fDeith1WyuN9fERry9lMduFeaGmu8cXEqaEYvXM,957
6
+ near_jsonrpc_client/errors.py,sha256=pfhIENT9KxjYXTrEsN7dfFpcbnQj2yTFuLMPtDANdeQ,978
7
7
  near_jsonrpc_client/transport.py,sha256=r92Zf7r_4ggU_fKp4pR9WyeaUOVOyLEW7xqz8Ny1buY,1012
8
- near_jsonrpc_client-1.0.21.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
8
+ near_jsonrpc_client-1.0.23.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
9
9
  near_jsonrpc_models/__init__.py,sha256=l7gDQiY4sNIibaz_KVMSS70kE5UrqVsjIrn9xNv-Hw4,225545
10
10
  near_jsonrpc_models/access_key.py,sha256=Yxb_imR1x07BdrtSifGDbhKHfuvD8HYYa0iaj3g0V84,918
11
11
  near_jsonrpc_models/access_key_creation_config_view.py,sha256=z3DIfoi6jojkk-S91Eyj15CM_0ZScyOOOmyWYqio4e0,466
@@ -67,7 +67,7 @@ near_jsonrpc_models/deterministic_state_init_action.py,sha256=zYRxiLHt3oLRkuO9-K
67
67
  near_jsonrpc_models/direction.py,sha256=IBTozgwUQ2VwESQc41VNj2BG8kSvhiLiFqy2Z5eF6d0,124
68
68
  near_jsonrpc_models/dump_config.py,sha256=lsvXa66JMOUMtLnX7IfQ0FBFME2mM0mhTzj5MVhik6M,905
69
69
  near_jsonrpc_models/duration_as_std_schema_provider.py,sha256=sQsSNAiZj61nVXe3SfCzXkJVQ7XQFpzoQPWa_KhU0M4,170
70
- near_jsonrpc_models/dynamic_resharding_config_view.py,sha256=rA6Hq2pb67LPm_NWj53Vy2PkO2dFBLFfBcoB8_BjZV8,908
70
+ near_jsonrpc_models/dynamic_resharding_config_view.py,sha256=Srmi4HWILUTEEupmhqCV8SHbqNHRzT51_73eJb7EJ0Y,1033
71
71
  near_jsonrpc_models/epoch_id.py,sha256=PhzEnxhfsr4KF3PJYYk62iXRWUhoyNQvFOBwzTWACeg,238
72
72
  near_jsonrpc_models/epoch_sync_config.py,sha256=mvI-SS2IhWixV2wYciKJSQbTg235L8UQmlfPt14EpYY,1636
73
73
  near_jsonrpc_models/error_wrapper_for_genesis_config_error.py,sha256=Fy8v8wHg2qkmjfNaAr64XPWY8VHt3yJjkcMtJdv1rp8,985
@@ -303,7 +303,7 @@ near_jsonrpc_models/rpc_view_gas_key_response.py,sha256=Wnymph7cwmVIJITV-UgECT82
303
303
  near_jsonrpc_models/rpc_view_state_error.py,sha256=XM-6-poRLwcSdfqwbxVeXQRvevV-erHF8NCIvPYbjNw,1915
304
304
  near_jsonrpc_models/rpc_view_state_request.py,sha256=QZjrAJSaT5gc-oq3G-5HqKBcuiD4OMTpnnOhS4B1mC8,987
305
305
  near_jsonrpc_models/rpc_view_state_response.py,sha256=GgZv8V6m8lrx-lV7tbteHNrT9UiculhU2SNzOYQSnpE,432
306
- near_jsonrpc_models/runtime_config_view.py,sha256=oh5_sX_Z7yy3eDHpRHWjW7pgv6LWbZeq28NQSbWuAu8,1797
306
+ near_jsonrpc_models/runtime_config_view.py,sha256=SZJklyVA7GjhIuPEAsJa3a4tvDjUKs_q-qY2LS5YzC4,1849
307
307
  near_jsonrpc_models/runtime_fees_config_view.py,sha256=stmMEjLjoEn87xiQ4Ois_BGSw_Nbkgrjpo2WjH5n57g,1581
308
308
  near_jsonrpc_models/shard_id.py,sha256=BGs5Po_GSyiHz9jfTNUc6gwMg1tcXH1AJ4IMz-1SMAc,572
309
309
  near_jsonrpc_models/shard_layout.py,sha256=cQn_buHJBpUINWXwYS1HbKo_vZvFECpRkyiLt3vc4vM,1371
@@ -351,7 +351,7 @@ near_jsonrpc_models/vmconfig_view.py,sha256=LiW1t0jqnCiSdb8uuUBMaGzGg2NAudUo9kcO
351
351
  near_jsonrpc_models/vmkind.py,sha256=tCxyZlDaGn3bz-lThkbUj0oO6qxoQP7lGANMusstpC8,252
352
352
  near_jsonrpc_models/wasm_trap.py,sha256=y0nay7ulaHOGpHPRnKIU0FWxHeWfwnrYiYvllLry3Mw,791
353
353
  near_jsonrpc_models/witness_config_view.py,sha256=kTeYTx1mtk0IT6ary63awFk5hIGn8mS8UlOCMaqhr2Q,912
354
- near_jsonrpc_client-1.0.21.dist-info/METADATA,sha256=HY7NBixxCffxIhmcqeP6b5DT2g7hJVtK_mlE-eK3z5Q,6303
355
- near_jsonrpc_client-1.0.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
356
- near_jsonrpc_client-1.0.21.dist-info/top_level.txt,sha256=uMGb9-6Ckd8WvQ5-m1l9mVFmM5lCORE6YybUIOimSuc,40
357
- near_jsonrpc_client-1.0.21.dist-info/RECORD,,
354
+ near_jsonrpc_client-1.0.23.dist-info/METADATA,sha256=7Dtm_XeYiNu4xcKbGqBD0ZCWbAe3759QeEheywnS0KI,6309
355
+ near_jsonrpc_client-1.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
356
+ near_jsonrpc_client-1.0.23.dist-info/top_level.txt,sha256=uMGb9-6Ckd8WvQ5-m1l9mVFmM5lCORE6YybUIOimSuc,40
357
+ near_jsonrpc_client-1.0.23.dist-info/RECORD,,
@@ -1,23 +1,22 @@
1
- """Configuration for dynamic resharding feature"""
1
+ """Configuration for dynamic resharding feature
2
+ See [`DynamicReshardingConfig`] for more details."""
2
3
 
4
+ from near_jsonrpc_models.shard_id import ShardId
3
5
  from pydantic import BaseModel
4
6
  from pydantic import conint
7
+ from typing import List
5
8
 
6
9
 
7
10
  class DynamicReshardingConfigView(BaseModel):
11
+ # Shards that should **not** be split even when they meet the regular split criteria.
12
+ block_split_shards: List[ShardId]
13
+ # Shards that should be split even when they don't meet the regular split criteria.
14
+ force_split_shards: List[ShardId]
8
15
  # Maximum number of shards in the network.
9
- #
10
- # See [`CongestionControlConfig`] for more details.
11
16
  max_number_of_shards: conint(ge=0, le=18446744073709551615)
12
17
  # Memory threshold over which a shard is marked for a split.
13
- #
14
- # See [`CongestionControlConfig`] for more details.
15
18
  memory_usage_threshold: conint(ge=0, le=18446744073709551615)
16
19
  # Minimum memory usage of a child shard.
17
- #
18
- # See [`CongestionControlConfig`] for more details.
19
20
  min_child_memory_usage: conint(ge=0, le=18446744073709551615)
20
21
  # Minimum number of epochs until next resharding can be scheduled.
21
- #
22
- # See [`CongestionControlConfig`] for more details.
23
22
  min_epochs_between_resharding: conint(ge=0, le=18446744073709551615)
@@ -17,7 +17,7 @@ class RuntimeConfigView(BaseModel):
17
17
  # The configuration for congestion control.
18
18
  congestion_control_config: CongestionControlConfigView = None
19
19
  # Configuration for dynamic resharding feature.
20
- dynamic_resharding_config: DynamicReshardingConfigView = Field(default_factory=lambda: DynamicReshardingConfigView(**{'max_number_of_shards': 999999999999999, 'memory_usage_threshold': 999999999999999, 'min_child_memory_usage': 999999999999999, 'min_epochs_between_resharding': 999999999999999}))
20
+ dynamic_resharding_config: DynamicReshardingConfigView = Field(default_factory=lambda: DynamicReshardingConfigView(**{'block_split_shards': [], 'force_split_shards': [], 'max_number_of_shards': 999999999999999, 'memory_usage_threshold': 999999999999999, 'min_child_memory_usage': 999999999999999, 'min_epochs_between_resharding': 999999999999999}))
21
21
  # Amount of yN per byte required to have on the account. See
22
22
  # <https://nomicon.io/Economics/Economics.html#state-stake> for details.
23
23
  storage_amount_per_byte: NearToken = None