viz-python-lib 1.1.0__tar.gz → 1.2.1__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.
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/PKG-INFO +42 -20
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/README.md +39 -15
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/pyproject.toml +10 -12
- viz_python_lib-1.2.1/viz/__init__.py +3 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/account.py +8 -7
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/blockchain.py +6 -6
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/utils.py +5 -3
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/viz.py +35 -37
- viz_python_lib-1.1.0/viz/__init__.py +0 -12
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/LICENSE.txt +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/amount.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/block.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/blockchainobject.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/converter.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/exceptions.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/instance.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/memo.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/storage.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/transactionbuilder.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/wallet.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/viz/witness.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizapi/__init__.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizapi/consts.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizapi/exceptions.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizapi/noderpc.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/__init__.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/account.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/chains.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/exceptions.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/memo.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/objects.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/operationids.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/operations.py +0 -0
- {viz_python_lib-1.1.0 → viz_python_lib-1.2.1}/vizbase/signedtransactions.py +0 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: viz-python-lib
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Python library for VIZ blockchain
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE.txt
|
|
7
7
|
Keywords: viz,python,library,blockchain
|
|
8
8
|
Author: Vladimir Kamarzin
|
|
9
9
|
Author-email: vvk@vvk.pp.ru
|
|
10
|
-
Requires-Python: >=3.
|
|
11
|
-
Classifier: Development Status ::
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -32,11 +30,11 @@ Description-Content-Type: text/markdown
|
|
|
32
30
|
# Python Library for [VIZ](https://github.com/VIZ-Blockchain)
|
|
33
31
|
|
|
34
32
|

|
|
35
|
-
[](https://viz-python.readthedocs.io/en/latest/?badge=latest)
|
|
36
34
|
|
|
37
35
|
## Usage examples
|
|
38
36
|
|
|
39
|
-
Award someone
|
|
37
|
+
### Award someone
|
|
40
38
|
|
|
41
39
|
```python
|
|
42
40
|
from viz import Client
|
|
@@ -45,11 +43,12 @@ node = "wss://node.viz.cx/ws"
|
|
|
45
43
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
46
44
|
|
|
47
45
|
initiator = "your_account"
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
receiver = "id"
|
|
47
|
+
percent = 10.5 # 10.5%
|
|
48
|
+
viz.award(receiver, percent, "with love", None, initiator)
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
Award someone with fixed reward
|
|
51
|
+
### Award someone with fixed reward
|
|
53
52
|
|
|
54
53
|
```python
|
|
55
54
|
from viz import Client
|
|
@@ -58,12 +57,13 @@ node = "wss://node.viz.cx/ws"
|
|
|
58
57
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
59
58
|
|
|
60
59
|
initiator = "your_account"
|
|
60
|
+
receiver = "id"
|
|
61
61
|
reward_amount = 3.5 # "3.50 VIZ"
|
|
62
62
|
max_energy = 30 # 30%
|
|
63
|
-
viz.fixed_award(
|
|
63
|
+
viz.fixed_award(receiver, reward_amount, max_energy, "with fixed reward", None, initiator)
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
Send a custom operation
|
|
66
|
+
### Send a custom operation
|
|
67
67
|
|
|
68
68
|
```python
|
|
69
69
|
from viz import Client
|
|
@@ -72,35 +72,57 @@ node = "wss://node.viz.cx/ws"
|
|
|
72
72
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
73
73
|
|
|
74
74
|
account = "your_account"
|
|
75
|
+
required_regular_auths = [account]
|
|
75
76
|
protocol = "color.place"
|
|
76
|
-
|
|
77
|
-
viz.custom(protocol,
|
|
77
|
+
custom_json = {"x": 35, "y": 70, "color": "#e50000"}
|
|
78
|
+
viz.custom(protocol, custom_json, None, required_regular_auths)
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
Get
|
|
81
|
+
### Get data from custom protocol
|
|
81
82
|
|
|
82
83
|
```python
|
|
83
84
|
from viz import Client
|
|
84
85
|
from viz.account import Account
|
|
85
86
|
from viz.block import Block
|
|
86
87
|
from viz.instance import set_shared_blockchain_instance
|
|
88
|
+
import json
|
|
87
89
|
|
|
88
|
-
viz = Client(
|
|
90
|
+
viz = Client("wss://node.viz.cx/ws")
|
|
89
91
|
set_shared_blockchain_instance(viz)
|
|
90
92
|
|
|
93
|
+
account_name = "id"
|
|
91
94
|
protocol = "V"
|
|
92
|
-
account = Account(
|
|
95
|
+
account = Account(account_name, protocol=protocol)
|
|
96
|
+
|
|
93
97
|
counter_inside_protocol = account["custom_sequence"]
|
|
94
98
|
last_used_in_block = account["custom_sequence_block_num"]
|
|
99
|
+
|
|
95
100
|
block = Block(last_used_in_block)
|
|
101
|
+
|
|
102
|
+
for tx in block["transactions"]:
|
|
103
|
+
for op_type, op_data in tx["operations"]:
|
|
104
|
+
if op_type != "custom":
|
|
105
|
+
continue
|
|
106
|
+
if op_data.get("id") != protocol:
|
|
107
|
+
continue
|
|
108
|
+
if account_name not in op_data.get("required_regular_auths", []):
|
|
109
|
+
continue
|
|
110
|
+
|
|
111
|
+
raw_json = op_data.get("json")
|
|
112
|
+
try:
|
|
113
|
+
json_from_protocol = json.loads(raw_json) if raw_json else None
|
|
114
|
+
except json.JSONDecodeError:
|
|
115
|
+
json_from_protocol = None
|
|
116
|
+
|
|
117
|
+
print(json_from_protocol)
|
|
96
118
|
```
|
|
97
119
|
|
|
98
|
-
Any direct RPC call
|
|
120
|
+
### Any direct RPC call
|
|
99
121
|
|
|
100
122
|
```python
|
|
101
123
|
from viz import Client
|
|
102
124
|
|
|
103
|
-
viz = Client(
|
|
125
|
+
viz = Client("wss://node.viz.cx/ws")
|
|
104
126
|
viz.rpc.get_dynamic_global_properties()
|
|
105
127
|
```
|
|
106
128
|
|
|
@@ -128,7 +150,7 @@ poetry install
|
|
|
128
150
|
#### Linux dependencies
|
|
129
151
|
|
|
130
152
|
```sh
|
|
131
|
-
sudo apt-get install libffi-dev libssl-dev
|
|
153
|
+
sudo apt-get install libffi-dev libssl-dev python3-dev
|
|
132
154
|
```
|
|
133
155
|
|
|
134
156
|
#### Windows dependencies
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Python Library for [VIZ](https://github.com/VIZ-Blockchain)
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-
[](https://viz-python.readthedocs.io/en/latest/?badge=latest)
|
|
5
5
|
|
|
6
6
|
## Usage examples
|
|
7
7
|
|
|
8
|
-
Award someone
|
|
8
|
+
### Award someone
|
|
9
9
|
|
|
10
10
|
```python
|
|
11
11
|
from viz import Client
|
|
@@ -14,11 +14,12 @@ node = "wss://node.viz.cx/ws"
|
|
|
14
14
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
15
15
|
|
|
16
16
|
initiator = "your_account"
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
receiver = "id"
|
|
18
|
+
percent = 10.5 # 10.5%
|
|
19
|
+
viz.award(receiver, percent, "with love", None, initiator)
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
Award someone with fixed reward
|
|
22
|
+
### Award someone with fixed reward
|
|
22
23
|
|
|
23
24
|
```python
|
|
24
25
|
from viz import Client
|
|
@@ -27,12 +28,13 @@ node = "wss://node.viz.cx/ws"
|
|
|
27
28
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
28
29
|
|
|
29
30
|
initiator = "your_account"
|
|
31
|
+
receiver = "id"
|
|
30
32
|
reward_amount = 3.5 # "3.50 VIZ"
|
|
31
33
|
max_energy = 30 # 30%
|
|
32
|
-
viz.fixed_award(
|
|
34
|
+
viz.fixed_award(receiver, reward_amount, max_energy, "with fixed reward", None, initiator)
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
Send a custom operation
|
|
37
|
+
### Send a custom operation
|
|
36
38
|
|
|
37
39
|
```python
|
|
38
40
|
from viz import Client
|
|
@@ -41,35 +43,57 @@ node = "wss://node.viz.cx/ws"
|
|
|
41
43
|
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
42
44
|
|
|
43
45
|
account = "your_account"
|
|
46
|
+
required_regular_auths = [account]
|
|
44
47
|
protocol = "color.place"
|
|
45
|
-
|
|
46
|
-
viz.custom(protocol,
|
|
48
|
+
custom_json = {"x": 35, "y": 70, "color": "#e50000"}
|
|
49
|
+
viz.custom(protocol, custom_json, None, required_regular_auths)
|
|
47
50
|
```
|
|
48
51
|
|
|
49
|
-
Get
|
|
52
|
+
### Get data from custom protocol
|
|
50
53
|
|
|
51
54
|
```python
|
|
52
55
|
from viz import Client
|
|
53
56
|
from viz.account import Account
|
|
54
57
|
from viz.block import Block
|
|
55
58
|
from viz.instance import set_shared_blockchain_instance
|
|
59
|
+
import json
|
|
56
60
|
|
|
57
|
-
viz = Client(
|
|
61
|
+
viz = Client("wss://node.viz.cx/ws")
|
|
58
62
|
set_shared_blockchain_instance(viz)
|
|
59
63
|
|
|
64
|
+
account_name = "id"
|
|
60
65
|
protocol = "V"
|
|
61
|
-
account = Account(
|
|
66
|
+
account = Account(account_name, protocol=protocol)
|
|
67
|
+
|
|
62
68
|
counter_inside_protocol = account["custom_sequence"]
|
|
63
69
|
last_used_in_block = account["custom_sequence_block_num"]
|
|
70
|
+
|
|
64
71
|
block = Block(last_used_in_block)
|
|
72
|
+
|
|
73
|
+
for tx in block["transactions"]:
|
|
74
|
+
for op_type, op_data in tx["operations"]:
|
|
75
|
+
if op_type != "custom":
|
|
76
|
+
continue
|
|
77
|
+
if op_data.get("id") != protocol:
|
|
78
|
+
continue
|
|
79
|
+
if account_name not in op_data.get("required_regular_auths", []):
|
|
80
|
+
continue
|
|
81
|
+
|
|
82
|
+
raw_json = op_data.get("json")
|
|
83
|
+
try:
|
|
84
|
+
json_from_protocol = json.loads(raw_json) if raw_json else None
|
|
85
|
+
except json.JSONDecodeError:
|
|
86
|
+
json_from_protocol = None
|
|
87
|
+
|
|
88
|
+
print(json_from_protocol)
|
|
65
89
|
```
|
|
66
90
|
|
|
67
|
-
Any direct RPC call
|
|
91
|
+
### Any direct RPC call
|
|
68
92
|
|
|
69
93
|
```python
|
|
70
94
|
from viz import Client
|
|
71
95
|
|
|
72
|
-
viz = Client(
|
|
96
|
+
viz = Client("wss://node.viz.cx/ws")
|
|
73
97
|
viz.rpc.get_dynamic_global_properties()
|
|
74
98
|
```
|
|
75
99
|
|
|
@@ -97,7 +121,7 @@ poetry install
|
|
|
97
121
|
#### Linux dependencies
|
|
98
122
|
|
|
99
123
|
```sh
|
|
100
|
-
sudo apt-get install libffi-dev libssl-dev
|
|
124
|
+
sudo apt-get install libffi-dev libssl-dev python3-dev
|
|
101
125
|
```
|
|
102
126
|
|
|
103
127
|
#### Windows dependencies
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "viz-python-lib"
|
|
7
|
-
version = "1.1
|
|
7
|
+
version = "1.2.1"
|
|
8
8
|
description = "Python library for VIZ blockchain"
|
|
9
9
|
authors = ["Vladimir Kamarzin <vvk@vvk.pp.ru>", "Vladimir Babin <vovababin@gmail.com>"]
|
|
10
10
|
license = "MIT"
|
|
@@ -19,13 +19,11 @@ packages = [
|
|
|
19
19
|
keywords = ['viz', 'python', 'library', 'blockchain']
|
|
20
20
|
|
|
21
21
|
classifiers = [
|
|
22
|
-
"Development Status ::
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
23
|
"Intended Audience :: Developers",
|
|
24
24
|
"Operating System :: OS Independent",
|
|
25
25
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
26
|
"Programming Language :: Python :: 3",
|
|
27
|
-
"Programming Language :: Python :: 3.8",
|
|
28
|
-
"Programming Language :: Python :: 3.9",
|
|
29
27
|
"Programming Language :: Python :: 3.10",
|
|
30
28
|
"Programming Language :: Python :: 3.11",
|
|
31
29
|
"Programming Language :: Python :: 3.12",
|
|
@@ -35,7 +33,7 @@ classifiers = [
|
|
|
35
33
|
|
|
36
34
|
|
|
37
35
|
[tool.poetry.dependencies]
|
|
38
|
-
python = "^3.
|
|
36
|
+
python = "^3.10"
|
|
39
37
|
graphenelib = "^1.6.0"
|
|
40
38
|
toolz = "^0.12.0"
|
|
41
39
|
funcy = "^2.0"
|
|
@@ -44,16 +42,16 @@ docker = "^7.1.0"
|
|
|
44
42
|
|
|
45
43
|
|
|
46
44
|
[tool.poetry.group.dev.dependencies]
|
|
47
|
-
pre-commit =
|
|
45
|
+
pre-commit = "^3.6"
|
|
48
46
|
ruff = "^0.1"
|
|
49
47
|
mypy = "^1.8"
|
|
50
|
-
pytest = "^
|
|
48
|
+
pytest = "^9.0"
|
|
51
49
|
pytest-cov = "^5.0"
|
|
52
50
|
|
|
53
|
-
sphinx = "
|
|
54
|
-
sphinx-autoapi = "^1.
|
|
51
|
+
sphinx = ">=4.0,<7.0"
|
|
52
|
+
sphinx-autoapi = "^1.8.0"
|
|
55
53
|
# used in docs to include markdown files
|
|
56
|
-
|
|
54
|
+
m2r2 = "^0.3.2"
|
|
57
55
|
# used in docs to parse pyproject.toml
|
|
58
56
|
tomlkit = "^0.11.8"
|
|
59
57
|
|
|
@@ -73,12 +71,12 @@ addopts = [
|
|
|
73
71
|
|
|
74
72
|
|
|
75
73
|
[tool.mypy]
|
|
76
|
-
ignore_missing_imports =
|
|
74
|
+
ignore_missing_imports = true
|
|
77
75
|
|
|
78
76
|
|
|
79
77
|
[tool.ruff]
|
|
80
78
|
line-length = 120
|
|
81
|
-
target-version = "
|
|
79
|
+
target-version = "py310"
|
|
82
80
|
|
|
83
81
|
|
|
84
82
|
[tool.ruff.lint]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Generator
|
|
2
|
+
from typing import TYPE_CHECKING, Optional
|
|
2
3
|
from warnings import warn
|
|
3
4
|
|
|
4
5
|
from graphenecommon.exceptions import AccountDoesNotExistsException
|
|
@@ -12,7 +13,7 @@ from .utils import json_expand, parse_time, time_elapsed
|
|
|
12
13
|
if TYPE_CHECKING:
|
|
13
14
|
from .viz import Client # noqa: F401
|
|
14
15
|
|
|
15
|
-
HistoryGenerator = Generator[
|
|
16
|
+
HistoryGenerator = Generator[dict | list, None, int]
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class Account(dict):
|
|
@@ -117,10 +118,10 @@ class Account(dict):
|
|
|
117
118
|
self,
|
|
118
119
|
index: int,
|
|
119
120
|
limit: int,
|
|
120
|
-
start:
|
|
121
|
-
stop:
|
|
121
|
+
start: int | None = None,
|
|
122
|
+
stop: int | None = None,
|
|
122
123
|
order: int = -1,
|
|
123
|
-
filter_by:
|
|
124
|
+
filter_by: str | list[str] | None = None,
|
|
124
125
|
raw_output: bool = False,
|
|
125
126
|
) -> HistoryGenerator:
|
|
126
127
|
"""
|
|
@@ -183,7 +184,7 @@ class Account(dict):
|
|
|
183
184
|
|
|
184
185
|
def history(
|
|
185
186
|
self,
|
|
186
|
-
filter_by:
|
|
187
|
+
filter_by: str | list[str] | None = None,
|
|
187
188
|
start: int = 0,
|
|
188
189
|
batch_size: int = 1000,
|
|
189
190
|
raw_output: bool = False,
|
|
@@ -240,7 +241,7 @@ class Account(dict):
|
|
|
240
241
|
|
|
241
242
|
def history_reverse(
|
|
242
243
|
self,
|
|
243
|
-
filter_by:
|
|
244
|
+
filter_by: str | list[str] | None = None,
|
|
244
245
|
batch_size: int = 1000,
|
|
245
246
|
raw_output: bool = False,
|
|
246
247
|
limit: int = -1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
3
|
import time
|
|
4
|
-
from
|
|
4
|
+
from collections.abc import Iterator
|
|
5
5
|
|
|
6
6
|
from graphenecommon.blockchain import Blockchain as GrapheneBlockchain
|
|
7
7
|
|
|
@@ -42,8 +42,8 @@ class Blockchain(GrapheneBlockchain):
|
|
|
42
42
|
|
|
43
43
|
def stream_from(
|
|
44
44
|
self,
|
|
45
|
-
start_block:
|
|
46
|
-
end_block:
|
|
45
|
+
start_block: int | None = None,
|
|
46
|
+
end_block: int | None = None,
|
|
47
47
|
batch_operations: bool = False,
|
|
48
48
|
full_blocks: bool = False,
|
|
49
49
|
only_virtual_ops: bool = False,
|
|
@@ -108,9 +108,9 @@ class Blockchain(GrapheneBlockchain):
|
|
|
108
108
|
|
|
109
109
|
def stream(
|
|
110
110
|
self,
|
|
111
|
-
filter_by:
|
|
112
|
-
start_block:
|
|
113
|
-
end_block:
|
|
111
|
+
filter_by: str | list[str] | None = None,
|
|
112
|
+
start_block: int | None = None,
|
|
113
|
+
end_block: int | None = None,
|
|
114
114
|
raw_output: bool = False,
|
|
115
115
|
) -> Iterator[dict]:
|
|
116
116
|
"""
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from datetime import datetime
|
|
2
|
+
from datetime import datetime, timezone
|
|
3
3
|
|
|
4
4
|
from toolz import assoc, update_in
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def json_expand(json_op, key_name="json"):
|
|
8
8
|
"""Convert a string json object to Python dict in an op."""
|
|
9
|
-
if
|
|
9
|
+
if isinstance(json_op, dict) and key_name in json_op and json_op[key_name]:
|
|
10
10
|
try:
|
|
11
11
|
return update_in(json_op, [key_name], json.loads)
|
|
12
12
|
except json.JSONDecodeError:
|
|
@@ -19,7 +19,9 @@ def time_elapsed(event_time):
|
|
|
19
19
|
"""Takes a string time from blockchain event, and returns a time delta from now."""
|
|
20
20
|
if isinstance(event_time, str):
|
|
21
21
|
event_time = parse_time(event_time)
|
|
22
|
-
|
|
22
|
+
if event_time.tzinfo is None:
|
|
23
|
+
event_time = event_time.replace(tzinfo=timezone.utc)
|
|
24
|
+
return datetime.now(timezone.utc) - event_time
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
def parse_time(event_time):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from collections import defaultdict
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import Any
|
|
4
4
|
|
|
5
5
|
from graphenecommon.chain import AbstractGrapheneChain
|
|
6
6
|
from graphenecommon.exceptions import AccountDoesNotExistsException, KeyAlreadyInStoreException
|
|
@@ -17,8 +17,6 @@ from .exceptions import AccountExistsException
|
|
|
17
17
|
from .transactionbuilder import ProposalBuilder, TransactionBuilder
|
|
18
18
|
from .wallet import Wallet
|
|
19
19
|
|
|
20
|
-
# from .utils import formatTime
|
|
21
|
-
|
|
22
20
|
log = logging.getLogger(__name__)
|
|
23
21
|
|
|
24
22
|
|
|
@@ -89,10 +87,10 @@ class Client(AbstractGrapheneChain):
|
|
|
89
87
|
self,
|
|
90
88
|
title: str,
|
|
91
89
|
memo: str = "",
|
|
92
|
-
parent:
|
|
90
|
+
parent: TransactionBuilder | None = None,
|
|
93
91
|
expiration_time: int = 2 * 24 * 60 * 60,
|
|
94
|
-
review_period_time:
|
|
95
|
-
account:
|
|
92
|
+
review_period_time: int | None = None,
|
|
93
|
+
account: str | None = None,
|
|
96
94
|
**kwargs: Any,
|
|
97
95
|
) -> ProposalBuilder:
|
|
98
96
|
"""
|
|
@@ -147,11 +145,11 @@ class Client(AbstractGrapheneChain):
|
|
|
147
145
|
self,
|
|
148
146
|
author: str,
|
|
149
147
|
title: str,
|
|
150
|
-
approver:
|
|
151
|
-
keys:
|
|
148
|
+
approver: str | list | None = None,
|
|
149
|
+
keys: str | list | None = None,
|
|
152
150
|
permission: str = "regular",
|
|
153
151
|
approve: bool = True,
|
|
154
|
-
account:
|
|
152
|
+
account: str | None = None,
|
|
155
153
|
) -> dict:
|
|
156
154
|
"""
|
|
157
155
|
Update proposal (approve or disapprove)
|
|
@@ -194,7 +192,7 @@ class Client(AbstractGrapheneChain):
|
|
|
194
192
|
return self.finalizeOp(op, account, permission)
|
|
195
193
|
|
|
196
194
|
def transfer(
|
|
197
|
-
self, to: str, amount: float, asset: str, memo: str = "", account:
|
|
195
|
+
self, to: str, amount: float, asset: str, memo: str = "", account: str | None = None, **kwargs: Any
|
|
198
196
|
) -> dict:
|
|
199
197
|
"""
|
|
200
198
|
Transfer an asset to another account.
|
|
@@ -230,8 +228,8 @@ class Client(AbstractGrapheneChain):
|
|
|
230
228
|
receiver: str,
|
|
231
229
|
energy: float,
|
|
232
230
|
memo: str = "",
|
|
233
|
-
beneficiaries:
|
|
234
|
-
account:
|
|
231
|
+
beneficiaries: list[dict[str, str | int]] | None = None,
|
|
232
|
+
account: str | None = None,
|
|
235
233
|
**kwargs: Any,
|
|
236
234
|
) -> dict:
|
|
237
235
|
"""
|
|
@@ -271,8 +269,8 @@ class Client(AbstractGrapheneChain):
|
|
|
271
269
|
reward_amount: float,
|
|
272
270
|
max_energy: float,
|
|
273
271
|
memo: str = "",
|
|
274
|
-
beneficiaries:
|
|
275
|
-
account:
|
|
272
|
+
beneficiaries: list[dict[str, str | int]] | None = None,
|
|
273
|
+
account: str | None = None,
|
|
276
274
|
**kwargs: Any,
|
|
277
275
|
) -> dict:
|
|
278
276
|
"""
|
|
@@ -313,9 +311,9 @@ class Client(AbstractGrapheneChain):
|
|
|
313
311
|
def custom(
|
|
314
312
|
self,
|
|
315
313
|
id_: str,
|
|
316
|
-
json:
|
|
317
|
-
required_active_auths:
|
|
318
|
-
required_regular_auths:
|
|
314
|
+
json: dict | list,
|
|
315
|
+
required_active_auths: list[str] | None = None,
|
|
316
|
+
required_regular_auths: list[str] | None = None,
|
|
319
317
|
) -> dict:
|
|
320
318
|
"""
|
|
321
319
|
Create a custom operation.
|
|
@@ -355,7 +353,7 @@ class Client(AbstractGrapheneChain):
|
|
|
355
353
|
)
|
|
356
354
|
return self.finalizeOp(op, account, required_key_type)
|
|
357
355
|
|
|
358
|
-
def withdraw_vesting(self, amount: float, account:
|
|
356
|
+
def withdraw_vesting(self, amount: float, account: str | None = None) -> dict:
|
|
359
357
|
"""
|
|
360
358
|
Withdraw SHARES from the vesting account.
|
|
361
359
|
|
|
@@ -381,7 +379,7 @@ class Client(AbstractGrapheneChain):
|
|
|
381
379
|
|
|
382
380
|
return self.finalizeOp(op, account, "active")
|
|
383
381
|
|
|
384
|
-
def transfer_to_vesting(self, amount: float, to:
|
|
382
|
+
def transfer_to_vesting(self, amount: float, to: str | None = None, account: str | None = None) -> dict:
|
|
385
383
|
"""
|
|
386
384
|
Vest free VIZ into vesting.
|
|
387
385
|
|
|
@@ -413,7 +411,7 @@ class Client(AbstractGrapheneChain):
|
|
|
413
411
|
return self.finalizeOp(op, account, "active")
|
|
414
412
|
|
|
415
413
|
def set_withdraw_vesting_route(
|
|
416
|
-
self, to: str, percentage: float = 100, account:
|
|
414
|
+
self, to: str, percentage: float = 100, account: str | None = None, auto_vest: bool = False
|
|
417
415
|
) -> dict:
|
|
418
416
|
"""
|
|
419
417
|
Set up a vesting withdraw route. When vesting shares are withdrawn, they will be routed to these accounts based
|
|
@@ -467,22 +465,22 @@ class Client(AbstractGrapheneChain):
|
|
|
467
465
|
def create_account(
|
|
468
466
|
self,
|
|
469
467
|
account_name: str,
|
|
470
|
-
json_meta:
|
|
471
|
-
password:
|
|
472
|
-
master_key:
|
|
473
|
-
active_key:
|
|
474
|
-
regular_key:
|
|
475
|
-
memo_key:
|
|
476
|
-
additional_master_keys:
|
|
477
|
-
additional_active_keys:
|
|
478
|
-
additional_regular_keys:
|
|
479
|
-
additional_master_accounts:
|
|
480
|
-
additional_active_accounts:
|
|
481
|
-
additional_regular_accounts:
|
|
468
|
+
json_meta: dict[str, Any] | None = None,
|
|
469
|
+
password: str | None = None,
|
|
470
|
+
master_key: str | None = None,
|
|
471
|
+
active_key: str | None = None,
|
|
472
|
+
regular_key: str | None = None,
|
|
473
|
+
memo_key: str | None = None,
|
|
474
|
+
additional_master_keys: list[str] | None = None,
|
|
475
|
+
additional_active_keys: list[str] | None = None,
|
|
476
|
+
additional_regular_keys: list[str] | None = None,
|
|
477
|
+
additional_master_accounts: list[str] | None = None,
|
|
478
|
+
additional_active_accounts: list[str] | None = None,
|
|
479
|
+
additional_regular_accounts: list[str] | None = None,
|
|
482
480
|
store_keys: bool = True,
|
|
483
481
|
fee: float = 0,
|
|
484
|
-
delegation:
|
|
485
|
-
creator:
|
|
482
|
+
delegation: float | None = None,
|
|
483
|
+
creator: str | None = None,
|
|
486
484
|
referrer: str = "",
|
|
487
485
|
) -> dict:
|
|
488
486
|
"""
|
|
@@ -571,7 +569,7 @@ class Client(AbstractGrapheneChain):
|
|
|
571
569
|
from vizbase.account import PasswordKey, PublicKey
|
|
572
570
|
|
|
573
571
|
key_roles = ["regular", "active", "master", "memo"]
|
|
574
|
-
keys:
|
|
572
|
+
keys: defaultdict[str, PasswordKey | dict] = defaultdict(dict)
|
|
575
573
|
|
|
576
574
|
if password:
|
|
577
575
|
for role in key_roles:
|
|
@@ -590,7 +588,7 @@ class Client(AbstractGrapheneChain):
|
|
|
590
588
|
raise ValueError("Call incomplete! Provide either a password or public keys!")
|
|
591
589
|
|
|
592
590
|
# main key authorities
|
|
593
|
-
authority:
|
|
591
|
+
authority: str | list = ""
|
|
594
592
|
for role in key_roles:
|
|
595
593
|
if role == "memo":
|
|
596
594
|
authority = format(keys["pubkeys"][role], self.prefix)
|
|
@@ -673,7 +671,7 @@ class Client(AbstractGrapheneChain):
|
|
|
673
671
|
self,
|
|
674
672
|
account_name: str,
|
|
675
673
|
memo_key: str,
|
|
676
|
-
json_meta:
|
|
674
|
+
json_meta: dict[str, Any] | None = None,
|
|
677
675
|
) -> dict:
|
|
678
676
|
"""
|
|
679
677
|
Update account profile.
|
|
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
|