strideutils 0.9.1__tar.gz → 0.9.2__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 (75) hide show
  1. {strideutils-0.9.1 → strideutils-0.9.2}/.bumpversion.cfg +1 -1
  2. {strideutils-0.9.1 → strideutils-0.9.2}/PKG-INFO +1 -1
  3. {strideutils-0.9.1 → strideutils-0.9.2}/pyproject.toml +1 -1
  4. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/exec_tx.py +17 -3
  5. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils.egg-info/PKG-INFO +1 -1
  6. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_exec_tx.py +49 -3
  7. {strideutils-0.9.1 → strideutils-0.9.2}/.github/workflows/lint.yml +0 -0
  8. {strideutils-0.9.1 → strideutils-0.9.2}/.github/workflows/publish.yml +0 -0
  9. {strideutils-0.9.1 → strideutils-0.9.2}/.github/workflows/test.yml +0 -0
  10. {strideutils-0.9.1 → strideutils-0.9.2}/.github/workflows/version.yaml +0 -0
  11. {strideutils-0.9.1 → strideutils-0.9.2}/.gitignore +0 -0
  12. {strideutils-0.9.1 → strideutils-0.9.2}/LICENSE +0 -0
  13. {strideutils-0.9.1 → strideutils-0.9.2}/MANIFEST.in +0 -0
  14. {strideutils-0.9.1 → strideutils-0.9.2}/Makefile +0 -0
  15. {strideutils-0.9.1 → strideutils-0.9.2}/README.md +0 -0
  16. {strideutils-0.9.1 → strideutils-0.9.2}/example-config.yaml +0 -0
  17. {strideutils-0.9.1 → strideutils-0.9.2}/setup.cfg +0 -0
  18. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/Makefile +0 -0
  19. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/__init__.py +0 -0
  20. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/__init__.pyi +0 -0
  21. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/coingecko.py +0 -0
  22. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/coingecko.pyi +0 -0
  23. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/config_examples/env.local.example +0 -0
  24. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
  25. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/cryptography.py +0 -0
  26. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/cryptography.pyi +0 -0
  27. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/exec_tx.pyi +0 -0
  28. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/py.typed +0 -0
  29. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/redis_connector.py +0 -0
  30. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/redis_connector.pyi +0 -0
  31. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/run_safely.py +0 -0
  32. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/run_safely.pyi +0 -0
  33. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/sheets_connector.py +0 -0
  34. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/sheets_connector.pyi +0 -0
  35. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/slack_connector.py +0 -0
  36. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/slack_connector.pyi +0 -0
  37. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_alerts.py +0 -0
  38. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_alerts.pyi +0 -0
  39. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_config.py +0 -0
  40. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_config.pyi +0 -0
  41. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_requests.py +0 -0
  42. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/stride_requests.pyi +0 -0
  43. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/telegram_connector.py +0 -0
  44. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/telegram_connector.pyi +0 -0
  45. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/twilio_connector.py +0 -0
  46. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/twilio_connector.pyi +0 -0
  47. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/types.py +0 -0
  48. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils/types.pyi +0 -0
  49. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/__init__.pyi +0 -0
  50. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/coingecko.pyi +0 -0
  51. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/cryptography.pyi +0 -0
  52. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/exec_tx.pyi +0 -0
  53. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/redis_connector.pyi +0 -0
  54. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/run_safely.pyi +0 -0
  55. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/sheets_connector.pyi +0 -0
  56. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/slack_connector.pyi +0 -0
  57. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/stride_alerts.pyi +0 -0
  58. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/stride_config.pyi +0 -0
  59. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/stride_requests.pyi +0 -0
  60. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/telegram_connector.pyi +0 -0
  61. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/twilio_connector.pyi +0 -0
  62. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils-stubs/types.pyi +0 -0
  63. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils.egg-info/SOURCES.txt +0 -0
  64. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils.egg-info/dependency_links.txt +0 -0
  65. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils.egg-info/requires.txt +0 -0
  66. {strideutils-0.9.1 → strideutils-0.9.2}/strideutils.egg-info/top_level.txt +0 -0
  67. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_coingecko.py +0 -0
  68. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_config.py +0 -0
  69. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_encryption.py +0 -0
  70. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_redis_connector.py +0 -0
  71. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_sheets_connector.py +0 -0
  72. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_slack_connector.py +0 -0
  73. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_stride_requests.py +0 -0
  74. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_telegram_connector.py +0 -0
  75. {strideutils-0.9.1 → strideutils-0.9.2}/tests/test_twilio_connector.py +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.9.1
2
+ current_version = 0.9.2
3
3
  commit = False
4
4
  tag = False
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: strideutils
3
- Version: 0.9.1
3
+ Version: 0.9.2
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.9.1"
7
+ version = "0.9.2"
8
8
  authors = [
9
9
  {name = "Stride Labs", email = "hello@stridelabs.co"},
10
10
  ]
@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import os
3
+ import re
3
4
  import subprocess
4
5
  import time
5
6
  from dataclasses import dataclass
@@ -11,6 +12,13 @@ from strideutils import stride_requests
11
12
  from strideutils.stride_config import config
12
13
 
13
14
  WALLET_SETUP_COMMAND = "echo {mnemonic} | {binary} keys add {account_name} --recover --keyring-backend=test"
15
+ _GAS_ESTIMATE_LINE = re.compile(r"gas estimate: \d+$")
16
+
17
+
18
+ def _is_gas_estimate_only_stderr(stderr: str) -> bool:
19
+ """True when stderr contains only the normal --gas auto estimate line(s)."""
20
+ lines = [line.strip() for line in stderr.splitlines() if line.strip()]
21
+ return bool(lines) and all(_GAS_ESTIMATE_LINE.fullmatch(line) for line in lines)
14
22
 
15
23
 
16
24
  @dataclass
@@ -24,7 +32,11 @@ class TxResponse:
24
32
  raw_log: Optional[str] = None
25
33
 
26
34
 
27
- def restore_wallet(account_name: str = "wallet", mnemonic_var: str = "MNEMONIC", binary: str = "strided"):
35
+ def restore_wallet(
36
+ account_name: str = "wallet",
37
+ mnemonic_var: str = "MNEMONIC",
38
+ binary: str = "strided",
39
+ ):
28
40
  """
29
41
  Restores a wallet in the keyring, using the mnemonic under the specified environment variable
30
42
  """
@@ -47,8 +59,10 @@ def execute_tx(command: str, api_endpoint: str = config.stride.api_endpoint) ->
47
59
  # Run the command in the shell and store the response
48
60
  output = subprocess.run(command, shell=True, capture_output=True, text=True)
49
61
 
50
- # If there was stderr, return the response as failed
51
- if not output.stdout or output.stderr:
62
+ if not output.stdout:
63
+ return TxResponse(stdout={}, stderr=output.stderr, raw_log=output.stderr or "")
64
+
65
+ if output.stderr and not _is_gas_estimate_only_stderr(output.stderr):
52
66
  return TxResponse(stdout={}, stderr=output.stderr, raw_log=output.stderr)
53
67
 
54
68
  # Cast the stdout and build the response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: strideutils
3
- Version: 0.9.1
3
+ Version: 0.9.2
4
4
  Summary: Utility functions for monitoring the Stride blockchain
5
5
  Author-email: Stride Labs <hello@stridelabs.co>
6
6
  License: MIT License
@@ -54,7 +54,10 @@ MOCK_FAILED_TX_RESPONSE = MockTxResponse(
54
54
 
55
55
  def test_execute_tx_success() -> None:
56
56
  """Test successful transaction execution."""
57
- with patch("subprocess.run") as mock_run, patch("strideutils.stride_requests.requests.get") as mock_get_tx:
57
+ with (
58
+ patch("subprocess.run") as mock_run,
59
+ patch("strideutils.stride_requests.requests.get") as mock_get_tx,
60
+ ):
58
61
  # Mock subprocess.run
59
62
  mock_process = MagicMock()
60
63
  mock_process.stdout = json.dumps(MOCK_SUCCESS_STDOUT)
@@ -85,7 +88,10 @@ def test_execute_tx_success() -> None:
85
88
 
86
89
  def test_execute_tx_failure() -> None:
87
90
  """Test failed transaction execution."""
88
- with patch("subprocess.run") as mock_run, patch("strideutils.stride_requests.requests.get") as mock_get_tx:
91
+ with (
92
+ patch("subprocess.run") as mock_run,
93
+ patch("strideutils.stride_requests.requests.get") as mock_get_tx,
94
+ ):
89
95
  # Mock subprocess.run
90
96
  mock_process = MagicMock()
91
97
  mock_process.stdout = json.dumps(MOCK_SUCCESS_STDOUT)
@@ -105,6 +111,43 @@ def test_execute_tx_failure() -> None:
105
111
  assert response.raw_log == "transaction failed"
106
112
 
107
113
 
114
+ def test_execute_tx_gas_estimate_stderr() -> None:
115
+ """Test that --gas auto stderr does not block tx parsing."""
116
+ with (
117
+ patch("subprocess.run") as mock_run,
118
+ patch("strideutils.stride_requests.requests.get") as mock_get_tx,
119
+ ):
120
+ mock_process = MagicMock()
121
+ mock_process.stdout = json.dumps(MOCK_SUCCESS_STDOUT)
122
+ mock_process.stderr = "gas estimate: 53873342\n"
123
+ mock_run.return_value = mock_process
124
+
125
+ mock_get_tx.return_value = MOCK_SUCCESS_TX_RESPONSE
126
+
127
+ response = execute_tx(MOCK_COMMAND, MOCK_API_ENDPOINT)
128
+
129
+ assert response.success is True
130
+ assert response.tx_hash == MOCK_TX_HASH
131
+ assert response.code == 0
132
+ assert response.raw_log == "transaction successful"
133
+ assert response.stderr == "gas estimate: 53873342\n"
134
+
135
+
136
+ def test_execute_tx_gas_estimate_plus_real_error() -> None:
137
+ """Test that gas estimate stderr plus a real error still fails."""
138
+ with patch("subprocess.run") as mock_run:
139
+ mock_process = MagicMock()
140
+ mock_process.stdout = json.dumps(MOCK_SUCCESS_STDOUT)
141
+ mock_process.stderr = "gas estimate: 53873342\ninsufficient fees"
142
+ mock_run.return_value = mock_process
143
+
144
+ response = execute_tx(MOCK_COMMAND, MOCK_API_ENDPOINT)
145
+
146
+ assert response.success is False
147
+ assert response.tx_hash == ""
148
+ assert response.raw_log == "gas estimate: 53873342\ninsufficient fees"
149
+
150
+
108
151
  def test_execute_tx_subprocess_error() -> None:
109
152
  """Test handling of subprocess execution error."""
110
153
  with patch("subprocess.run") as mock_run:
@@ -213,7 +256,10 @@ def test_execute_tx_auto_append_flags() -> None:
213
256
  test_cases: List[Tuple[str, str]] = [
214
257
  ("base command", "base command -y --output json"),
215
258
  ("base command -y", "base command -y --output json"),
216
- ("base command --output json", "base command --output json -y --output json"),
259
+ (
260
+ "base command --output json",
261
+ "base command --output json -y --output json",
262
+ ),
217
263
  ]
218
264
 
219
265
  for input_cmd, expected_cmd in test_cases:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes