strideutils 0.1.2__tar.gz → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strideutils
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary:
5
5
  Author: Your Name
6
6
  Author-email: you@example.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "strideutils"
3
- version = "0.1.2"
3
+ version = "0.1.4"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  readme = "README.md"
@@ -13,6 +13,7 @@ def post_msg(
13
13
  botname: Optional[str] = None,
14
14
  unfurl_links: bool = False,
15
15
  unfurl_media: bool = False,
16
+ thread_ts: Optional[str] = None,
16
17
  ):
17
18
  """
18
19
  Posts a slack message to the given channel, e.g.
@@ -31,7 +32,7 @@ def post_msg(
31
32
  messages = [txt] if type(txt) is str else txt
32
33
 
33
34
  # thread ts keeps track of the latest thread ID so we can keep replying in-thread
34
- thread_ts = None
35
+ thread_ts = None or thread_ts
35
36
  for msg in messages:
36
37
  try:
37
38
  response = client.chat_postMessage(
@@ -47,3 +48,4 @@ def post_msg(
47
48
  except SlackApiError as e:
48
49
  print("Error sending message: ", e)
49
50
  raise
51
+ return thread_ts
@@ -3,7 +3,7 @@ import datetime
3
3
  import time
4
4
  import urllib.parse
5
5
  from functools import lru_cache
6
- from typing import Any, Dict, List, Optional, cast
6
+ from typing import Any, Dict, List, Optional, Union, cast
7
7
 
8
8
  import bech32
9
9
  import pandas as pd
@@ -15,6 +15,8 @@ from strideutils import stride_upstash
15
15
  from strideutils.stride_config import config
16
16
 
17
17
  HOST_ZONE_QUERY = "Stride-Labs/stride/stakeibc/host_zone"
18
+ ACCOUNT_QUERY = "cosmos/auth/v1beta1/accounts/{address}"
19
+ TX_QUERY = "cosmos/tx/v1beta1/txs?events=tx.acc_seq%3D%27{address}/{sequence}%27"
18
20
 
19
21
  requests_session = requests.Session()
20
22
 
@@ -290,6 +292,39 @@ def get_icns_name(address: str) -> str:
290
292
  return resp['data']['name']
291
293
 
292
294
 
295
+ def get_account_info(
296
+ address: str,
297
+ api: str = config.stride.api_endpoint,
298
+ ):
299
+ """
300
+ Returns
301
+ -------
302
+ {'account':
303
+ {'@type': '/cosmos.auth.v1beta1.BaseAccount',
304
+ 'address': 'stride1am99pcvynqqhyrwqfvfmnvxjk96rn46le9j65c',
305
+ 'pub_key': {'@type': '/cosmos.crypto.secp256k1.PubKey',
306
+ 'key': 'A138uH3qwMpMbtRnvtuHgJMO6Cq+9iGlFkGUTYpVRQ9J'},
307
+ 'account_number': '90',
308
+ 'sequence': '553'}}
309
+ """
310
+ url = f"{api}/{ACCOUNT_QUERY.format(address=address)}"
311
+ return request(url)
312
+
313
+
314
+ def get_tx_info(
315
+ address: str,
316
+ sequence: Union[str, int],
317
+ api: str = config.stride.api_endpoint,
318
+ ):
319
+ """
320
+ Returns
321
+ -------
322
+ {'txs': [...]}
323
+ """
324
+ url = f"{api}/{TX_QUERY.format(address=address, sequence=sequence)}"
325
+ return request(url)
326
+
327
+
293
328
  def generate_vesting_account(
294
329
  start_time_in_local_tz: str,
295
330
  total_tokens: int,
@@ -317,8 +352,8 @@ def generate_vesting_account(
317
352
  tokens_per_period = int(total_tokens / num_periods)
318
353
  for i in range(num_periods):
319
354
  out += ' {\n'
320
- out += f' "coins": "{tokens_per_period}ustrd",\n'
321
- out += f' "length_seconds":{seconds_in_period}\n'
355
+ out += f' "coins": "{tokens_per_period}ustrd",\n' # noqa: E231
356
+ out += f' "length_seconds":{seconds_in_period}\n' # noqa: E231
322
357
  out += ' }'
323
358
  if i != num_periods - 1:
324
359
  out += ','
File without changes