strideutils 0.8.3__tar.gz → 0.8.4__tar.gz

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.
Files changed (70) hide show
  1. {strideutils-0.8.3 → strideutils-0.8.4}/.bumpversion.cfg +1 -1
  2. {strideutils-0.8.3 → strideutils-0.8.4}/PKG-INFO +1 -1
  3. {strideutils-0.8.3 → strideutils-0.8.4}/pyproject.toml +1 -1
  4. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/exec_tx.py +14 -0
  5. {strideutils-0.8.3/strideutils-stubs → strideutils-0.8.4/strideutils}/exec_tx.pyi +3 -1
  6. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_requests.py +26 -4
  7. {strideutils-0.8.3/strideutils → strideutils-0.8.4/strideutils-stubs}/exec_tx.pyi +4 -0
  8. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils.egg-info/PKG-INFO +1 -1
  9. {strideutils-0.8.3 → strideutils-0.8.4}/.github/workflows/lint.yml +0 -0
  10. {strideutils-0.8.3 → strideutils-0.8.4}/.github/workflows/publish.yml +0 -0
  11. {strideutils-0.8.3 → strideutils-0.8.4}/.github/workflows/test.yml +0 -0
  12. {strideutils-0.8.3 → strideutils-0.8.4}/.github/workflows/version.yaml +0 -0
  13. {strideutils-0.8.3 → strideutils-0.8.4}/.gitignore +0 -0
  14. {strideutils-0.8.3 → strideutils-0.8.4}/LICENSE +0 -0
  15. {strideutils-0.8.3 → strideutils-0.8.4}/MANIFEST.in +0 -0
  16. {strideutils-0.8.3 → strideutils-0.8.4}/Makefile +0 -0
  17. {strideutils-0.8.3 → strideutils-0.8.4}/README.md +0 -0
  18. {strideutils-0.8.3 → strideutils-0.8.4}/example-config.yaml +0 -0
  19. {strideutils-0.8.3 → strideutils-0.8.4}/setup.cfg +0 -0
  20. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/Makefile +0 -0
  21. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/__init__.py +0 -0
  22. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/__init__.pyi +0 -0
  23. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/coingecko.py +0 -0
  24. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/coingecko.pyi +0 -0
  25. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/config_examples/env.local.example +0 -0
  26. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
  27. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/cryptography.py +0 -0
  28. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/cryptography.pyi +0 -0
  29. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/py.typed +0 -0
  30. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/redis_connector.py +0 -0
  31. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/redis_connector.pyi +0 -0
  32. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/run_safely.py +0 -0
  33. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/run_safely.pyi +0 -0
  34. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/sheets_connector.py +0 -0
  35. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/sheets_connector.pyi +0 -0
  36. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/slack_connector.py +0 -0
  37. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/slack_connector.pyi +0 -0
  38. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_alerts.py +0 -0
  39. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_alerts.pyi +0 -0
  40. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_config.py +0 -0
  41. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_config.pyi +0 -0
  42. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/stride_requests.pyi +0 -0
  43. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/twilio_connector.py +0 -0
  44. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/twilio_connector.pyi +0 -0
  45. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/types.py +0 -0
  46. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils/types.pyi +0 -0
  47. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/__init__.pyi +0 -0
  48. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/coingecko.pyi +0 -0
  49. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/cryptography.pyi +0 -0
  50. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/redis_connector.pyi +0 -0
  51. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/run_safely.pyi +0 -0
  52. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/sheets_connector.pyi +0 -0
  53. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/slack_connector.pyi +0 -0
  54. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/stride_alerts.pyi +0 -0
  55. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/stride_config.pyi +0 -0
  56. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/stride_requests.pyi +0 -0
  57. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/twilio_connector.pyi +0 -0
  58. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils-stubs/types.pyi +0 -0
  59. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils.egg-info/SOURCES.txt +0 -0
  60. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils.egg-info/dependency_links.txt +0 -0
  61. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils.egg-info/requires.txt +0 -0
  62. {strideutils-0.8.3 → strideutils-0.8.4}/strideutils.egg-info/top_level.txt +0 -0
  63. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_coingecko.py +0 -0
  64. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_config.py +0 -0
  65. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_encryption.py +0 -0
  66. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_redis_connector.py +0 -0
  67. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_sheets_connector.py +0 -0
  68. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_slack_connector.py +0 -0
  69. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_stride_requests.py +0 -0
  70. {strideutils-0.8.3 → strideutils-0.8.4}/tests/test_twilio_connector.py +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.8.3
2
+ current_version = 0.8.4
3
3
  commit = False
4
4
  tag = False
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: Utility functions for monitoring the Stride blockchain
5
5
  Author-email: Stride Labs <hello@stridelabs.co>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "strideutils"
7
- version = "0.8.3"
7
+ version = "0.8.4"
8
8
  authors = [
9
9
  {name = "Stride Labs", email = "hello@stridelabs.co"},
10
10
  ]
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import os
2
3
  import subprocess
3
4
  import time
4
5
  from dataclasses import dataclass
@@ -7,6 +8,8 @@ from typing import Optional
7
8
  from strideutils import stride_requests
8
9
  from strideutils.stride_config import config
9
10
 
11
+ WALLET_SETUP_COMMAND = "echo {mnemonic} | {binary} keys add {wallet_name} --recover --keyring-backend=test"
12
+
10
13
 
11
14
  @dataclass
12
15
  class TxResponse:
@@ -19,6 +22,17 @@ class TxResponse:
19
22
  raw_log: Optional[str] = None
20
23
 
21
24
 
25
+ def restore_wallet(wallet_name: str = "wallet", mnemonic_var: str = "MNEMONIC", binary: str = "strided"):
26
+ """
27
+ Restores a wallet in the keyring, using the mnemonic under the specified environment variable
28
+ """
29
+ mnemonic = os.getenv(mnemonic_var)
30
+ if not mnemonic:
31
+ raise EnvironmentError(f"{mnemonic_var} must be set")
32
+
33
+ os.system(WALLET_SETUP_COMMAND.format(mnemonic=mnemonic, binary=binary, wallet_name=wallet_name))
34
+
35
+
22
36
  def execute_tx(command: str, api_endpoint: str = config.stride.api_endpoint) -> TxResponse:
23
37
  """
24
38
  Execute a tx and query the tx hash
@@ -1,8 +1,9 @@
1
1
  from dataclasses import dataclass
2
-
3
2
  from strideutils import stride_requests as stride_requests
4
3
  from strideutils.stride_config import config as config
5
4
 
5
+ WALLET_SETUP_COMMAND: str
6
+
6
7
  @dataclass
7
8
  class TxResponse:
8
9
  stdout: dict
@@ -13,4 +14,5 @@ class TxResponse:
13
14
  tx_response: dict | None = ...
14
15
  raw_log: str | None = ...
15
16
 
17
+ def restore_wallet(wallet_name: str = 'wallet', mnemonic_var: str = 'MNEMONIC', binary: str = 'strided'): ...
16
18
  def execute_tx(command: str, api_endpoint: str = ...) -> TxResponse: ...
@@ -100,11 +100,33 @@ def request(
100
100
  params = list(params.items())
101
101
 
102
102
  resp = requests_session.get(url, headers=headers, params=params, data=data)
103
- if not resp.ok: # resp.ok is true if state_code is less than 400
104
- print(f"Error fetching {url}: {resp.status_code} {resp.json()}")
105
- raise Exception(f"Error fetching {url}: {resp.status_code} {resp.json()}")
106
103
 
107
- out = resp.json()
104
+ # Handle non-200 responses.
105
+ if not resp.ok:
106
+ error_msg = f"Error fetching {url}: {resp.status_code} {resp.json()}"
107
+ try:
108
+ error_details = resp.json()
109
+ error_msg += f" {error_details}"
110
+ except requests.exceptions.JSONDecodeError:
111
+ error_msg += f" {resp.text}"
112
+
113
+ print(error_msg)
114
+ raise Exception(error_msg)
115
+
116
+ # Handle empty responses.
117
+ if not resp.text:
118
+ error_msg = f"Empty response received from {url}"
119
+ print(error_msg)
120
+ raise Exception(error_msg)
121
+
122
+ # Try to parse JSON response.
123
+ try:
124
+ out = resp.json()
125
+ except requests.exceptions.JSONDecodeError as e:
126
+ error_msg = f"Invalid JSON response received from {url}: {resp.text[:200]}..."
127
+ print(error_msg)
128
+ raise Exception(error_msg) from e
129
+
108
130
  if cache_response:
109
131
  _cache[cache_key] = out
110
132
  return out
@@ -1,7 +1,10 @@
1
1
  from dataclasses import dataclass
2
+
2
3
  from strideutils import stride_requests as stride_requests
3
4
  from strideutils.stride_config import config as config
4
5
 
6
+ WALLET_SETUP_COMMAND: str
7
+
5
8
  @dataclass
6
9
  class TxResponse:
7
10
  stdout: dict
@@ -12,4 +15,5 @@ class TxResponse:
12
15
  tx_response: dict | None = ...
13
16
  raw_log: str | None = ...
14
17
 
18
+ def restore_wallet(wallet_name: str = 'wallet', mnemonic_var: str = 'MNEMONIC', binary: str = 'strided'): ...
15
19
  def execute_tx(command: str, api_endpoint: str = ...) -> TxResponse: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.8.3
3
+ Version: 0.8.4
4
4
  Summary: Utility functions for monitoring the Stride blockchain
5
5
  Author-email: Stride Labs <hello@stridelabs.co>
6
6
  License: MIT License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes