strideutils 0.2.2__tar.gz → 0.2.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.2.2 → strideutils-0.2.4}/PKG-INFO +2 -1
- {strideutils-0.2.2 → strideutils-0.2.4}/pyproject.toml +6 -2
- strideutils-0.2.4/strideutils/cryptography.py +37 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/stride_requests.py +8 -5
- {strideutils-0.2.2 → strideutils-0.2.4}/README.md +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/Makefile +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/__init__.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/coingecko.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/config_examples/strideutils_config.yaml.example +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/config_examples/strideutils_secrets.yaml.example +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/invariant_helpers.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/run_safely.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/sheets_connector.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/slack_connector.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/stride_alerts.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/stride_config.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/stride_upstash.py +0 -0
- {strideutils-0.2.2 → strideutils-0.2.4}/strideutils/twilio_connector.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: strideutils
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Your Name
|
|
6
6
|
Author-email: you@example.com
|
|
@@ -17,6 +17,7 @@ Requires-Dist: google-auth-oauthlib (>=1.1.0)
|
|
|
17
17
|
Requires-Dist: google-cloud-bigquery (>=3.11.4)
|
|
18
18
|
Requires-Dist: gspread (>=6.0.2)
|
|
19
19
|
Requires-Dist: pandas (>=2.1.1)
|
|
20
|
+
Requires-Dist: pycryptodome (>=3.20.0)
|
|
20
21
|
Requires-Dist: python-dateutil (>=2.8.2)
|
|
21
22
|
Requires-Dist: pytz (>=2023.3)
|
|
22
23
|
Requires-Dist: pyyaml (>=6.0.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "strideutils"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.4"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["Your Name <you@example.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -21,9 +21,13 @@ pandas = ">=2.1.1"
|
|
|
21
21
|
twilio = ">=8.10.0"
|
|
22
22
|
tabulate = ">=0.9.0"
|
|
23
23
|
pyyaml = ">=6.0.1"
|
|
24
|
-
python-dateutil= ">=2.8.2"
|
|
24
|
+
python-dateutil = ">=2.8.2"
|
|
25
|
+
pycryptodome = ">=3.20.0"
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
[tool.poetry.group.dev.dependencies]
|
|
29
|
+
pytest = "^8.1.1"
|
|
30
|
+
|
|
27
31
|
[build-system]
|
|
28
32
|
requires = ["poetry-core"]
|
|
29
33
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
from typing import Tuple
|
|
3
|
+
|
|
4
|
+
from Crypto.Cipher import AES
|
|
5
|
+
from Crypto.Random import get_random_bytes
|
|
6
|
+
from Crypto.Util.Padding import pad, unpad
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def encrypt_message(message: str, key: bytes) -> Tuple[str, str]:
|
|
10
|
+
"""Encrypt the message using AES in CBC mode."""
|
|
11
|
+
# Generate a random initialization vector
|
|
12
|
+
iv = get_random_bytes(AES.block_size)
|
|
13
|
+
|
|
14
|
+
# Initialize the cipher for encryption
|
|
15
|
+
cipher_encrypt = AES.new(key, AES.MODE_CBC, iv)
|
|
16
|
+
|
|
17
|
+
# Encrypt the message
|
|
18
|
+
# The message needs to be padded to make sure its length is a multiple of the block size
|
|
19
|
+
encrypted = cipher_encrypt.encrypt(pad(message.encode(), AES.block_size))
|
|
20
|
+
|
|
21
|
+
# Return the encrypted data and the IV
|
|
22
|
+
return base64.b64encode(encrypted).decode(), base64.b64encode(iv).decode()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def decrypt_message(encrypted: str, iv: str, key: bytes) -> str:
|
|
26
|
+
"""Decrypt the message using AES in CBC mode."""
|
|
27
|
+
# Decode the encrypted message and IV from base64
|
|
28
|
+
encrypted = base64.b64decode(encrypted)
|
|
29
|
+
iv = base64.b64decode(iv)
|
|
30
|
+
|
|
31
|
+
# Initialize the cipher for decryption
|
|
32
|
+
cipher_decrypt = AES.new(key, AES.MODE_CBC, iv)
|
|
33
|
+
|
|
34
|
+
# Decrypt the message and unpad it
|
|
35
|
+
decrypted = unpad(cipher_decrypt.decrypt(encrypted), AES.block_size).decode()
|
|
36
|
+
|
|
37
|
+
return decrypted
|
|
@@ -538,7 +538,7 @@ def get_account_info(
|
|
|
538
538
|
return request(url)
|
|
539
539
|
|
|
540
540
|
|
|
541
|
-
def get_txs(event_filters: List[str], api_endpoint: str = config.stride.api_endpoint) -> Dict:
|
|
541
|
+
def get_txs(event_filters: List[str], api_endpoint: str = config.stride.api_endpoint, limit=None) -> Dict:
|
|
542
542
|
"""
|
|
543
543
|
Queries the txs endpoint with event filters
|
|
544
544
|
Event filters are of the form `{event_type}.{event_attribute}={attribute_value}`
|
|
@@ -559,6 +559,8 @@ def get_txs(event_filters: List[str], api_endpoint: str = config.stride.api_endp
|
|
|
559
559
|
|
|
560
560
|
url = f"{api_endpoint}/{TXS_QUERY}"
|
|
561
561
|
params: List[Tuple[str, str]] = [("events", event_filter) for event_filter in event_filters]
|
|
562
|
+
if limit is not None:
|
|
563
|
+
params.append(('limit', limit))
|
|
562
564
|
txs = request(url, params=params)
|
|
563
565
|
|
|
564
566
|
return txs
|
|
@@ -625,6 +627,7 @@ def get_block_height_in_past(
|
|
|
625
627
|
seconds_per_block: int = 6,
|
|
626
628
|
prev_time: Optional[str] = None,
|
|
627
629
|
verbose: bool = False,
|
|
630
|
+
rpc_endpoint: str = config.stride.library_rpc,
|
|
628
631
|
) -> int:
|
|
629
632
|
"""
|
|
630
633
|
Gets the block height at a specified time by binary searching at different heights
|
|
@@ -638,14 +641,14 @@ def get_block_height_in_past(
|
|
|
638
641
|
Returns:
|
|
639
642
|
The block height at the specified time
|
|
640
643
|
"""
|
|
641
|
-
latest_block = get_latest_block()
|
|
644
|
+
latest_block = get_latest_block(rpc_endpoint=rpc_endpoint)
|
|
642
645
|
|
|
643
646
|
# set parameters so we can search for the block height
|
|
644
|
-
blocks_per_day =
|
|
647
|
+
blocks_per_day = (24 * 60 * 60) // seconds_per_block
|
|
645
648
|
if prev_time is not None:
|
|
646
649
|
if type(prev_time) is str:
|
|
647
650
|
prev_time: datetime.datetime = pd.to_datetime(prev_time) # type: ignore
|
|
648
|
-
ts = (datetime.datetime.
|
|
651
|
+
ts = (datetime.datetime.utcnow() - cast(datetime.datetime, prev_time)).total_seconds()
|
|
649
652
|
num_days_back = ts / (60 * 60 * 24)
|
|
650
653
|
time_in_past = datetime.timedelta(seconds=ts)
|
|
651
654
|
else:
|
|
@@ -658,7 +661,7 @@ def get_block_height_in_past(
|
|
|
658
661
|
# do an iterative search to find the block
|
|
659
662
|
while abs(time_estimate_error) > max_acceptable_error_seconds:
|
|
660
663
|
backwards_looking_height = latest_block - blocks_in_past
|
|
661
|
-
backwards_looking_time = get_block_time(backwards_looking_height, rpc_endpoint=
|
|
664
|
+
backwards_looking_time = get_block_time(backwards_looking_height, rpc_endpoint=rpc_endpoint)
|
|
662
665
|
time_estimate_error = (current_time - backwards_looking_time - time_in_past).total_seconds()
|
|
663
666
|
error_in_blocks = time_estimate_error / seconds_per_block
|
|
664
667
|
blocks_in_past -= int(error_in_blocks)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{strideutils-0.2.2 → strideutils-0.2.4}/strideutils/config_examples/strideutils_config.yaml.example
RENAMED
|
File without changes
|
{strideutils-0.2.2 → strideutils-0.2.4}/strideutils/config_examples/strideutils_secrets.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
|