strideutils 0.8.2__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.
- {strideutils-0.8.2 → strideutils-0.8.4}/.bumpversion.cfg +1 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/.github/workflows/lint.yml +4 -4
- {strideutils-0.8.2 → strideutils-0.8.4}/.github/workflows/publish.yml +1 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/.github/workflows/test.yml +2 -2
- {strideutils-0.8.2 → strideutils-0.8.4}/.github/workflows/version.yaml +2 -2
- {strideutils-0.8.2 → strideutils-0.8.4}/PKG-INFO +1 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/pyproject.toml +1 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/exec_tx.py +14 -0
- {strideutils-0.8.2/strideutils-stubs → strideutils-0.8.4/strideutils}/exec_tx.pyi +3 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_requests.py +27 -5
- {strideutils-0.8.2/strideutils → strideutils-0.8.4/strideutils-stubs}/exec_tx.pyi +4 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils.egg-info/PKG-INFO +1 -1
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_stride_requests.py +8 -6
- {strideutils-0.8.2 → strideutils-0.8.4}/.gitignore +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/LICENSE +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/MANIFEST.in +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/Makefile +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/README.md +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/example-config.yaml +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/setup.cfg +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/Makefile +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/__init__.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/__init__.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/coingecko.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/coingecko.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/config_examples/env.local.example +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/cryptography.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/cryptography.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/py.typed +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/redis_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/redis_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/run_safely.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/run_safely.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/sheets_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/sheets_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/slack_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/slack_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_alerts.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_alerts.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_config.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_config.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/stride_requests.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/twilio_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/twilio_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/types.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils/types.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/__init__.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/coingecko.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/cryptography.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/redis_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/run_safely.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/sheets_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/slack_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/stride_alerts.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/stride_config.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/stride_requests.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/twilio_connector.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils-stubs/types.pyi +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils.egg-info/SOURCES.txt +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils.egg-info/dependency_links.txt +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils.egg-info/requires.txt +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/strideutils.egg-info/top_level.txt +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_coingecko.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_config.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_encryption.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_redis_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_sheets_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_slack_connector.py +0 -0
- {strideutils-0.8.2 → strideutils-0.8.4}/tests/test_twilio_connector.py +0 -0
|
@@ -3,7 +3,7 @@ name: Python Lint
|
|
|
3
3
|
on: [push]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
|
-
|
|
6
|
+
Flake8:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
9
|
- uses: actions/checkout@v3
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
with:
|
|
15
15
|
max-line-length: "120"
|
|
16
16
|
path: "strideutils/ tests strideutils-stubs"
|
|
17
|
-
|
|
17
|
+
Black:
|
|
18
18
|
runs-on: ubuntu-latest
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v3
|
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
with:
|
|
23
23
|
options: "--check --verbose --skip-string-normalization --line-length=120"
|
|
24
24
|
src: "strideutils tests strideutils-stubs"
|
|
25
|
-
|
|
25
|
+
Isort:
|
|
26
26
|
runs-on: ubuntu-latest
|
|
27
27
|
steps:
|
|
28
28
|
- uses: actions/checkout@v3
|
|
@@ -32,7 +32,7 @@ jobs:
|
|
|
32
32
|
|
|
33
33
|
- name: Run isort on each project
|
|
34
34
|
run: isort --check-only --diff --profile=black strideutils tests strideutils-stubs
|
|
35
|
-
|
|
35
|
+
Typing:
|
|
36
36
|
runs-on: ubuntu-latest
|
|
37
37
|
steps:
|
|
38
38
|
- uses: actions/checkout@v3
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Version
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
@@ -14,7 +14,7 @@ on:
|
|
|
14
14
|
- minor
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
|
-
|
|
17
|
+
Bump-Version:
|
|
18
18
|
if: ${{ github.event.label.name == 'version-patch' || github.event.label.name == 'version-minor' }} || github.event_name == 'workflow_dispatch'
|
|
19
19
|
runs-on: ubuntu-latest
|
|
20
20
|
permissions:
|
|
@@ -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
|
-
|
|
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
|
|
@@ -458,7 +480,7 @@ def get_redemption_rate_slack() -> pd.DataFrame:
|
|
|
458
480
|
"""
|
|
459
481
|
df_list: List[Dict[str, Any]] = []
|
|
460
482
|
|
|
461
|
-
for host_zone in config:
|
|
483
|
+
for host_zone in config.host_zones:
|
|
462
484
|
slack_data = _get_host_zone_redemption_rate_slack(host_zone.id)
|
|
463
485
|
df_list.append({'host_zone_id': host_zone.id, **slack_data})
|
|
464
486
|
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from unittest.mock import patch
|
|
2
|
+
from unittest.mock import PropertyMock, patch
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
import pandas as pd
|
|
@@ -83,11 +83,11 @@ def test_get_host_zone_redemption_rate_slack(mock_host_zone_data: dict[str, Any]
|
|
|
83
83
|
def test_get_redemption_rate_slack(mock_host_zones: list[HostChainConfig], mock_host_zone_data: dict[str, Any]):
|
|
84
84
|
"""Test DataFrame output of redemption rate slack"""
|
|
85
85
|
with (
|
|
86
|
-
patch('strideutils.stride_requests.config') as mock_config,
|
|
86
|
+
patch('strideutils.stride_requests.config') as mock_config, # Mock entire config
|
|
87
87
|
patch('strideutils.stride_requests.get_host_zone') as mock_get_host_zone,
|
|
88
88
|
):
|
|
89
|
-
#
|
|
90
|
-
mock_config.
|
|
89
|
+
# Set up the host_zones property to return our mock data
|
|
90
|
+
type(mock_config).host_zones = PropertyMock(return_value=mock_host_zones)
|
|
91
91
|
mock_get_host_zone.side_effect = mock_host_zone_data
|
|
92
92
|
|
|
93
93
|
result = get_redemption_rate_slack()
|
|
@@ -110,7 +110,8 @@ def test_get_redemption_rate_slack_string(mock_host_zones: HostChainConfig, mock
|
|
|
110
110
|
patch('strideutils.stride_requests.config') as mock_config,
|
|
111
111
|
patch('strideutils.stride_requests.get_host_zone') as mock_get_host_zone,
|
|
112
112
|
):
|
|
113
|
-
|
|
113
|
+
# Set up the host_zones property
|
|
114
|
+
type(mock_config).host_zones = PropertyMock(return_value=mock_host_zones)
|
|
114
115
|
mock_get_host_zone.side_effect = mock_host_zone_data
|
|
115
116
|
|
|
116
117
|
result = get_redemption_rate_slack_string()
|
|
@@ -125,7 +126,8 @@ def test_get_redemption_rate_slack_string(mock_host_zones: HostChainConfig, mock
|
|
|
125
126
|
def test_get_redemption_rate_slack_no_zones():
|
|
126
127
|
"""Test behavior when no host zones are available"""
|
|
127
128
|
with patch('strideutils.stride_requests.config') as mock_config:
|
|
128
|
-
|
|
129
|
+
# Set up empty host_zones
|
|
130
|
+
type(mock_config).host_zones = PropertyMock(return_value=[])
|
|
129
131
|
|
|
130
132
|
result = get_redemption_rate_slack()
|
|
131
133
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{strideutils-0.8.2 → strideutils-0.8.4}/strideutils/config_examples/strideutils_config.yaml.example
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|