strideutils 0.2.4__tar.gz → 0.2.6__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.4
3
+ Version: 0.2.6
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.4"
3
+ version = "0.2.6"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,60 @@
1
+ import re
2
+ import subprocess
3
+ import time
4
+ from dataclasses import dataclass
5
+ from typing import Optional
6
+
7
+ from strideutils import stride_requests
8
+ from strideutils.stride_config import config
9
+
10
+
11
+ @dataclass
12
+ class TxResponse:
13
+ stdout: str
14
+ stderr: str
15
+ tx_response: Optional[dict] = None
16
+ tx_hash: Optional[str] = None
17
+ success: bool = False
18
+ raw_log: Optional[str] = None
19
+
20
+
21
+ def execute_tx(command: str, api_endpoint: str = config.stride.api_endpoint) -> TxResponse:
22
+ """
23
+ Execute a tx and query the tx hash
24
+ """
25
+ output = subprocess.run(command, shell=True, capture_output=True)
26
+ standard_out = re.sub(r'\x1b\[[0-9;]*[mGKH]', '', output.stdout.decode('utf-8'))
27
+ error_out = re.sub(r'\x1b\[[0-9;]*[mGKH]', '', output.stderr.decode('utf-8'))
28
+
29
+ tx_hash = ""
30
+ for output_line in standard_out.split('\n'):
31
+ if 'txhash' in output_line:
32
+ tx_hash = output_line.split(': ')[-1]
33
+
34
+ tx_response = None
35
+ response_success = False
36
+ raw_log = ""
37
+ if not error_out:
38
+ event_filters = [(f"tx.hash='{tx_hash}'")]
39
+ for _ in range(15):
40
+ time.sleep(2)
41
+ tx_response = stride_requests.get_txs(event_filters, api_endpoint)
42
+ if tx_response['total'] != '0':
43
+ try:
44
+ response_code = tx_response['tx_responses'][0]['code']
45
+ raw_log = tx_response['tx_responses'][0]['raw_log']
46
+ response_success = response_code == 0
47
+ except KeyError:
48
+ response_success = False
49
+ break
50
+
51
+ success = response_success and not error_out
52
+ response = TxResponse(
53
+ stdout=standard_out,
54
+ stderr=error_out,
55
+ tx_response=tx_response,
56
+ success=success,
57
+ tx_hash=tx_hash,
58
+ raw_log=raw_log,
59
+ )
60
+ return response
@@ -94,6 +94,7 @@ class HostZoneChainConfig(ConfigObj):
94
94
  comdex: ChainConfig = field(default_factory=ChainConfig)
95
95
  sommelier: ChainConfig = field(default_factory=ChainConfig)
96
96
  dydx: ChainConfig = field(default_factory=ChainConfig)
97
+ saga: ChainConfig = field(default_factory=ChainConfig)
97
98
 
98
99
 
99
100
  @dataclass(repr=False)
File without changes