strideutils 0.2.7__tar.gz → 0.2.9__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.2.7
3
+ Version: 0.2.9
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.2.7"
3
+ version = "0.2.9"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  readme = "README.md"
@@ -41,7 +41,7 @@ def get_auth(
41
41
  auth_dict = config.PUBLICSHEETS_AUTH
42
42
  if config.ENV == 'PROD':
43
43
  # Auth info is passed as a string in prod
44
- auth_dict = json.loads(cast(str, auth_dict))
44
+ auth_dict = json.loads(cast(str, auth_dict), strict=False)
45
45
  creds = service_account.Credentials.from_service_account_info(auth_dict, scopes=scopes)
46
46
  except AttributeError:
47
47
  print('Google sheets auth is not found or badly configured')
@@ -22,6 +22,8 @@ ACCOUNT_DELEGATIONS_QUERY = "cosmos/staking/v1beta1/delegations/{delegator_addre
22
22
  ACCOUNT_UNBONDINGS_QUERY = "cosmos/staking/v1beta1/delegators/{delegator_address}/unbonding_delegations"
23
23
  MODULE_ACCOUNTS_QUERY = "cosmos/auth/v1beta1/module_accounts"
24
24
  SUPPLY_QUERY = "cosmos/bank/v1beta1/supply/by_denom"
25
+ VALIDATORS_QUERY = "cosmos/staking/v1beta1/validators"
26
+ VALIDATOR_SLASHES_QUERY = "cosmos/distribution/v1beta1/validators/{validator_address}/slashes"
25
27
 
26
28
  CONNECTION_QUERY = "ibc/core/connection/v1/connections/{connection_id}"
27
29
  CHANNELS_QUERY = "ibc/core/channel/v1/connections/{connection_id}/channels"
@@ -101,6 +103,7 @@ def query_list_with_pagination(
101
103
  rel_key: str,
102
104
  block_height: int = 0,
103
105
  max_pages: int = 50,
106
+ params: Union[dict, List[Tuple[str, str]]] = {},
104
107
  ) -> List[Dict]:
105
108
  """
106
109
  Query a list with pagination
@@ -111,7 +114,7 @@ def query_list_with_pagination(
111
114
  query_count = 0
112
115
 
113
116
  while True:
114
- res = request(url=query_url, block_height=block_height)
117
+ res = request(url=query_url, block_height=block_height, params=params)
115
118
  data += res[rel_key]
116
119
 
117
120
  query_count += 1
@@ -393,16 +396,25 @@ def get_rate_limits(**kwargs):
393
396
  return host_zone
394
397
 
395
398
 
396
- def get_validators(
397
- api_endpoint: str = config.stride.api_endpoint,
398
- ) -> List[Dict[str, Any]]:
399
+ def get_validators(api_endpoint: str = config.stride.api_endpoint) -> List[Dict[str, Any]]:
399
400
  """
400
401
  Queries the list of validators from a chain
401
402
  """
402
- url = f"{api_endpoint}/cosmos/staking/v1beta1/validators"
403
+ url = f"{api_endpoint}/{VALIDATORS_QUERY}"
403
404
  return query_list_with_pagination(url, rel_key="validators")
404
405
 
405
406
 
407
+ def get_validator_slashes(api_endpoint: str, validator_address: str) -> List[Dict[str, str]]:
408
+ """
409
+ Queries the list of all slashes for a particular validator
410
+ The start and end heights are required with the query
411
+ An arbitrarily large end height to get all slashes
412
+ """
413
+ url = f"{api_endpoint}/{VALIDATOR_SLASHES_QUERY.format(validator_address=validator_address)}"
414
+ params = {"starting_height": "0", "ending_height": "10000000000000000"}
415
+ return query_list_with_pagination(url, rel_key="slashes", params=params)
416
+
417
+
406
418
  def get_redemption_rate(token: str) -> float:
407
419
  """
408
420
  Queries the redemption rate for a particular token
File without changes