viz-python-lib 1.0.1__tar.gz → 1.1.0__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.0.1 → viz_python_lib-1.1.0}/PKG-INFO +86 -33
- viz_python_lib-1.1.0/README.md +120 -0
- viz_python_lib-1.1.0/pyproject.toml +108 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/__init__.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/account.py +32 -18
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/block.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/blockchain.py +0 -2
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/blockchainobject.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/converter.py +1 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/exceptions.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/instance.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/memo.py +4 -5
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/storage.py +0 -6
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/transactionbuilder.py +10 -11
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/utils.py +2 -3
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/viz.py +87 -58
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/wallet.py +0 -10
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/witness.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizapi/consts.py +9 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizapi/noderpc.py +2 -2
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/account.py +0 -3
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/chains.py +0 -1
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/memo.py +2 -3
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/objects.py +13 -15
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/operationids.py +2 -2
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/operations.py +38 -29
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/signedtransactions.py +1 -2
- viz_python_lib-1.0.1/README.md +0 -69
- viz_python_lib-1.0.1/pyproject.toml +0 -64
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/LICENSE.txt +0 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/viz/amount.py +0 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizapi/__init__.py +0 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizapi/exceptions.py +0 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/__init__.py +0 -0
- {viz_python_lib-1.0.1 → viz_python_lib-1.1.0}/vizbase/exceptions.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: viz-python-lib
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Python library for VIZ blockchain
|
|
5
|
-
Home-page: https://github.com/VIZ-Blockchain/viz-python-lib
|
|
6
5
|
License: MIT
|
|
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
|
|
@@ -18,9 +18,11 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
-
Requires-Dist: aiohttp (>=3.
|
|
23
|
-
Requires-Dist: docker (>=
|
|
24
|
+
Requires-Dist: aiohttp (>=3.8,<4)
|
|
25
|
+
Requires-Dist: docker (>=7.1.0,<8.0.0)
|
|
24
26
|
Requires-Dist: funcy (>=2.0,<3.0)
|
|
25
27
|
Requires-Dist: graphenelib (>=1.6.0,<2.0.0)
|
|
26
28
|
Requires-Dist: toolz (>=0.12.0,<0.13.0)
|
|
@@ -29,37 +31,77 @@ Description-Content-Type: text/markdown
|
|
|
29
31
|
|
|
30
32
|
# Python Library for [VIZ](https://github.com/VIZ-Blockchain)
|
|
31
33
|
|
|
32
|
-

|
|
33
35
|
[](https://viz-python-lib.readthedocs.io/en/latest/?badge=latest)
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
## Usage examples
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Award someone:
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
```python
|
|
42
|
+
from viz import Client
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
node = "wss://node.viz.cx/ws"
|
|
45
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
initiator = "your_account"
|
|
48
|
+
percent = 10.5
|
|
49
|
+
viz.award("id", percent, "with love", None, initiator)
|
|
45
50
|
```
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
Award someone with fixed reward:
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
```python
|
|
55
|
+
from viz import Client
|
|
50
56
|
|
|
51
|
-
|
|
57
|
+
node = "wss://node.viz.cx/ws"
|
|
58
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
52
59
|
|
|
53
|
-
|
|
60
|
+
initiator = "your_account"
|
|
61
|
+
reward_amount = 3.5 # "3.50 VIZ"
|
|
62
|
+
max_energy = 30 # 30%
|
|
63
|
+
viz.fixed_award("id", reward_amount, max_energy, "with fixed reward", None, initiator)
|
|
64
|
+
```
|
|
54
65
|
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
Send a custom operation:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from viz import Client
|
|
70
|
+
|
|
71
|
+
node = "wss://node.viz.cx/ws"
|
|
72
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
73
|
+
|
|
74
|
+
account = "your_account"
|
|
75
|
+
protocol = "color.place"
|
|
76
|
+
json = {"x":35, "y":70, "color":"#e50000"}
|
|
77
|
+
viz.custom(protocol, json, None, [account])
|
|
57
78
|
```
|
|
58
79
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
Get account with custom protocol latest block:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from viz import Client
|
|
84
|
+
from viz.account import Account
|
|
85
|
+
from viz.block import Block
|
|
86
|
+
from viz.instance import set_shared_blockchain_instance
|
|
87
|
+
|
|
88
|
+
viz = Client('wss://node.viz.cx/ws')
|
|
89
|
+
set_shared_blockchain_instance(viz)
|
|
90
|
+
|
|
91
|
+
protocol = "V"
|
|
92
|
+
account = Account('id', viz, protocol)
|
|
93
|
+
counter_inside_protocol = account["custom_sequence"]
|
|
94
|
+
last_used_in_block = account["custom_sequence_block_num"]
|
|
95
|
+
block = Block(last_used_in_block)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Any direct RPC call:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from viz import Client
|
|
102
|
+
|
|
103
|
+
viz = Client('wss://node.viz.cx/ws')
|
|
104
|
+
viz.rpc.get_dynamic_global_properties()
|
|
63
105
|
```
|
|
64
106
|
|
|
65
107
|
## Installation
|
|
@@ -79,21 +121,32 @@ cd viz-python-lib/
|
|
|
79
121
|
poetry install
|
|
80
122
|
```
|
|
81
123
|
|
|
82
|
-
##
|
|
124
|
+
## Development
|
|
83
125
|
|
|
84
|
-
|
|
85
|
-
```python
|
|
86
|
-
from viz import Client
|
|
87
|
-
from pprint import pprint
|
|
126
|
+
### Dependencies
|
|
88
127
|
|
|
89
|
-
|
|
128
|
+
#### Linux dependencies
|
|
90
129
|
|
|
91
|
-
|
|
92
|
-
|
|
130
|
+
```sh
|
|
131
|
+
sudo apt-get install libffi-dev libssl-dev python-dev
|
|
93
132
|
```
|
|
94
133
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
134
|
+
#### Windows dependencies
|
|
135
|
+
|
|
136
|
+
Install regular version of [OpenSSL](https://slproweb.com/products/Win32OpenSSL.html) (not Light) suitable for your core processor.
|
|
137
|
+
|
|
138
|
+
#### MacOS dependencies
|
|
139
|
+
|
|
140
|
+
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to install and export some OpenSSL settings yourself, before you can install viz-python-lib:
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
brew install openssl
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
and then use the following commands:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
export CFLAGS="-I$(brew --prefix openssl)/include"
|
|
150
|
+
export LDFLAGS="-L$(brew --prefix openssl)/lib"
|
|
98
151
|
```
|
|
99
152
|
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Python Library for [VIZ](https://github.com/VIZ-Blockchain)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://viz-python-lib.readthedocs.io/en/latest/?badge=latest)
|
|
5
|
+
|
|
6
|
+
## Usage examples
|
|
7
|
+
|
|
8
|
+
Award someone:
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from viz import Client
|
|
12
|
+
|
|
13
|
+
node = "wss://node.viz.cx/ws"
|
|
14
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
15
|
+
|
|
16
|
+
initiator = "your_account"
|
|
17
|
+
percent = 10.5
|
|
18
|
+
viz.award("id", percent, "with love", None, initiator)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Award someone with fixed reward:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from viz import Client
|
|
25
|
+
|
|
26
|
+
node = "wss://node.viz.cx/ws"
|
|
27
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
28
|
+
|
|
29
|
+
initiator = "your_account"
|
|
30
|
+
reward_amount = 3.5 # "3.50 VIZ"
|
|
31
|
+
max_energy = 30 # 30%
|
|
32
|
+
viz.fixed_award("id", reward_amount, max_energy, "with fixed reward", None, initiator)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Send a custom operation:
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from viz import Client
|
|
39
|
+
|
|
40
|
+
node = "wss://node.viz.cx/ws"
|
|
41
|
+
viz = Client(node=node, keys=["5...your_private_regular_key..."])
|
|
42
|
+
|
|
43
|
+
account = "your_account"
|
|
44
|
+
protocol = "color.place"
|
|
45
|
+
json = {"x":35, "y":70, "color":"#e50000"}
|
|
46
|
+
viz.custom(protocol, json, None, [account])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Get account with custom protocol latest block:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from viz import Client
|
|
53
|
+
from viz.account import Account
|
|
54
|
+
from viz.block import Block
|
|
55
|
+
from viz.instance import set_shared_blockchain_instance
|
|
56
|
+
|
|
57
|
+
viz = Client('wss://node.viz.cx/ws')
|
|
58
|
+
set_shared_blockchain_instance(viz)
|
|
59
|
+
|
|
60
|
+
protocol = "V"
|
|
61
|
+
account = Account('id', viz, protocol)
|
|
62
|
+
counter_inside_protocol = account["custom_sequence"]
|
|
63
|
+
last_used_in_block = account["custom_sequence_block_num"]
|
|
64
|
+
block = Block(last_used_in_block)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Any direct RPC call:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from viz import Client
|
|
71
|
+
|
|
72
|
+
viz = Client('wss://node.viz.cx/ws')
|
|
73
|
+
viz.rpc.get_dynamic_global_properties()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
Current published version could be installed via
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
pip install viz-python-lib
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Manual installation:
|
|
85
|
+
|
|
86
|
+
Install [poetry](https://python-poetry.org/docs/)
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
cd viz-python-lib/
|
|
90
|
+
poetry install
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
### Dependencies
|
|
96
|
+
|
|
97
|
+
#### Linux dependencies
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
sudo apt-get install libffi-dev libssl-dev python-dev
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Windows dependencies
|
|
104
|
+
|
|
105
|
+
Install regular version of [OpenSSL](https://slproweb.com/products/Win32OpenSSL.html) (not Light) suitable for your core processor.
|
|
106
|
+
|
|
107
|
+
#### MacOS dependencies
|
|
108
|
+
|
|
109
|
+
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. This means that you will need to install and export some OpenSSL settings yourself, before you can install viz-python-lib:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
brew install openssl
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
and then use the following commands:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
export CFLAGS="-I$(brew --prefix openssl)/include"
|
|
119
|
+
export LDFLAGS="-L$(brew --prefix openssl)/lib"
|
|
120
|
+
```
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["poetry-core>=1.9.0"]
|
|
3
|
+
build-backend = "poetry.core.masonry.api"
|
|
4
|
+
|
|
5
|
+
[tool.poetry]
|
|
6
|
+
name = "viz-python-lib"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "Python library for VIZ blockchain"
|
|
9
|
+
authors = ["Vladimir Kamarzin <vvk@vvk.pp.ru>", "Vladimir Babin <vovababin@gmail.com>"]
|
|
10
|
+
license = "MIT"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
repository = "https://github.com/VIZ-Blockchain/viz-python-lib"
|
|
13
|
+
packages = [
|
|
14
|
+
{ include = "viz" },
|
|
15
|
+
{ include = "vizapi" },
|
|
16
|
+
{ include = "vizbase" },
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
keywords = ['viz', 'python', 'library', 'blockchain']
|
|
20
|
+
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 3 - Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.8",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Programming Language :: Python :: 3.14",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[tool.poetry.dependencies]
|
|
38
|
+
python = "^3.8"
|
|
39
|
+
graphenelib = "^1.6.0"
|
|
40
|
+
toolz = "^0.12.0"
|
|
41
|
+
funcy = "^2.0"
|
|
42
|
+
aiohttp = ">=3.8,<4"
|
|
43
|
+
docker = "^7.1.0"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[tool.poetry.group.dev.dependencies]
|
|
47
|
+
pre-commit = { version = "^3.6", python = ">=3.9" }
|
|
48
|
+
ruff = "^0.1"
|
|
49
|
+
mypy = "^1.8"
|
|
50
|
+
pytest = "^8.0"
|
|
51
|
+
pytest-cov = "^5.0"
|
|
52
|
+
|
|
53
|
+
sphinx = "^2.2"
|
|
54
|
+
sphinx-autoapi = "^1.4.0"
|
|
55
|
+
# used in docs to include markdown files
|
|
56
|
+
m2r = "^0.3.1"
|
|
57
|
+
# used in docs to parse pyproject.toml
|
|
58
|
+
tomlkit = "^0.11.8"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
norecursedirs = ["*.egg", ".eggs", "dist", "build", "docs", ".tox", ".git", "__pycache__"]
|
|
63
|
+
addopts = [
|
|
64
|
+
"--strict-markers",
|
|
65
|
+
"--doctest-modules",
|
|
66
|
+
"--cov=viz",
|
|
67
|
+
"--cov=vizbase",
|
|
68
|
+
"--cov=vizapi",
|
|
69
|
+
"--cov-report=term:skip-covered",
|
|
70
|
+
"--cov-report=xml",
|
|
71
|
+
"--cov-branch",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
ignore_missing_imports = false
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
[tool.ruff]
|
|
80
|
+
line-length = 120
|
|
81
|
+
target-version = "py38"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
[tool.ruff.lint]
|
|
85
|
+
select = [
|
|
86
|
+
"E", "F", "W", # pycodestyle, pyflakes
|
|
87
|
+
"I", # isort
|
|
88
|
+
"B", # bugbear
|
|
89
|
+
"C4", # comprehensions
|
|
90
|
+
"UP", # pyupgrade
|
|
91
|
+
]
|
|
92
|
+
ignore = [
|
|
93
|
+
"E501", # line-length handled by formatter
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
[tool.ruff.lint.isort]
|
|
98
|
+
known-third-party = [
|
|
99
|
+
"Crypto",
|
|
100
|
+
"docker",
|
|
101
|
+
"grapheneapi",
|
|
102
|
+
"graphenebase",
|
|
103
|
+
"graphenecommon",
|
|
104
|
+
"graphenestorage",
|
|
105
|
+
"pytest",
|
|
106
|
+
"tomlkit",
|
|
107
|
+
"toolz",
|
|
108
|
+
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, Generator, List, Optional, Union
|
|
2
2
|
from warnings import warn
|
|
3
|
+
|
|
3
4
|
from graphenecommon.exceptions import AccountDoesNotExistsException
|
|
4
5
|
from toolz import dissoc
|
|
5
6
|
|
|
@@ -23,11 +24,16 @@ class Account(dict):
|
|
|
23
24
|
instance
|
|
24
25
|
"""
|
|
25
26
|
|
|
26
|
-
def __init__(
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
account_name: str,
|
|
30
|
+
blockchain_instance: Optional["Client"] = None,
|
|
31
|
+
protocol: str = "",
|
|
32
|
+
) -> None:
|
|
27
33
|
self.blockchain_instance = blockchain_instance or shared_blockchain_instance()
|
|
28
34
|
self.name = account_name
|
|
29
35
|
|
|
30
|
-
self.refresh()
|
|
36
|
+
self.refresh(protocol)
|
|
31
37
|
|
|
32
38
|
@property
|
|
33
39
|
def balances(self):
|
|
@@ -38,18 +44,18 @@ class Account(dict):
|
|
|
38
44
|
def energy(self):
|
|
39
45
|
"""Account energy at the moment of last use (stale)"""
|
|
40
46
|
cfg = self.blockchain_instance.rpc.config
|
|
41
|
-
return self[
|
|
47
|
+
return self["energy"] / cfg["CHAIN_1_PERCENT"]
|
|
42
48
|
|
|
43
|
-
def refresh(self):
|
|
49
|
+
def refresh(self, protocol: str = "") -> None:
|
|
44
50
|
"""Loads account object from blockchain."""
|
|
45
51
|
try:
|
|
46
|
-
account = self.blockchain_instance.rpc.
|
|
47
|
-
except
|
|
48
|
-
raise AccountDoesNotExistsException
|
|
52
|
+
account = self.blockchain_instance.rpc.get_account(self.name, protocol)
|
|
53
|
+
except Exception as err:
|
|
54
|
+
raise AccountDoesNotExistsException from err
|
|
49
55
|
|
|
50
56
|
# load json_metadata
|
|
51
57
|
account = json_expand(account, "json_metadata")
|
|
52
|
-
super(
|
|
58
|
+
super().__init__(account)
|
|
53
59
|
|
|
54
60
|
def get_balances(self) -> dict:
|
|
55
61
|
"""
|
|
@@ -65,14 +71,14 @@ class Account(dict):
|
|
|
65
71
|
def current_energy(self) -> float:
|
|
66
72
|
"""Returns current account energy (actual data, counts regenerated energy)"""
|
|
67
73
|
self.refresh()
|
|
68
|
-
last_vote_time = parse_time(self[
|
|
74
|
+
last_vote_time = parse_time(self["last_vote_time"])
|
|
69
75
|
elapsed_time = time_elapsed(last_vote_time)
|
|
70
76
|
cfg = self.blockchain_instance.rpc.config
|
|
71
77
|
regenerated_energy = (
|
|
72
|
-
cfg[
|
|
78
|
+
cfg["CHAIN_100_PERCENT"] * elapsed_time.total_seconds() / cfg["CHAIN_ENERGY_REGENERATION_SECONDS"]
|
|
73
79
|
)
|
|
74
|
-
current_energy = self[
|
|
75
|
-
energy = min(current_energy, cfg[
|
|
80
|
+
current_energy = self["energy"] + regenerated_energy
|
|
81
|
+
energy = min(current_energy, cfg["CHAIN_100_PERCENT"]) / cfg["CHAIN_1_PERCENT"]
|
|
76
82
|
|
|
77
83
|
return energy
|
|
78
84
|
|
|
@@ -85,7 +91,7 @@ class Account(dict):
|
|
|
85
91
|
else:
|
|
86
92
|
return last_item
|
|
87
93
|
|
|
88
|
-
def get_withdraw_routes(self, type_: str =
|
|
94
|
+
def get_withdraw_routes(self, type_: str = "all") -> dict:
|
|
89
95
|
"""
|
|
90
96
|
Get vesting withdraw routes.
|
|
91
97
|
|
|
@@ -155,7 +161,7 @@ class Account(dict):
|
|
|
155
161
|
# removes specified key from dict
|
|
156
162
|
block_props = dissoc(event, "op")
|
|
157
163
|
|
|
158
|
-
def construct_op(account_name):
|
|
164
|
+
def construct_op(account_name, index, op_type, block_props, op, item):
|
|
159
165
|
# verbatim output from steemd
|
|
160
166
|
if raw_output:
|
|
161
167
|
return item
|
|
@@ -170,7 +176,7 @@ class Account(dict):
|
|
|
170
176
|
return immutable
|
|
171
177
|
|
|
172
178
|
if filter_by is None or op_type in filter_by:
|
|
173
|
-
yield construct_op(self.name)
|
|
179
|
+
yield construct_op(self.name, index, op_type, block_props, op, item)
|
|
174
180
|
op_count += 1
|
|
175
181
|
|
|
176
182
|
return op_count
|
|
@@ -186,7 +192,7 @@ class Account(dict):
|
|
|
186
192
|
"""
|
|
187
193
|
THIS FUNCTION IS DEPRECATED. PLEASE USE :py:func:`history_reverse` INSTEAD.
|
|
188
194
|
|
|
189
|
-
Stream account history in chronological order.
|
|
195
|
+
Stream account history in chronological order.
|
|
190
196
|
|
|
191
197
|
This generator yields history items which may be in list or dict form depending on ``raw_output``.
|
|
192
198
|
Output is similar to :py:func:`history_reverse`.
|
|
@@ -200,7 +206,11 @@ class Account(dict):
|
|
|
200
206
|
This is a rough limit, actual results could be a bit longer
|
|
201
207
|
:return: number of ops
|
|
202
208
|
"""
|
|
203
|
-
warn(
|
|
209
|
+
warn(
|
|
210
|
+
"Function `history` is not recommened. Use `history_reverse` instead.",
|
|
211
|
+
DeprecationWarning,
|
|
212
|
+
stacklevel=2,
|
|
213
|
+
)
|
|
204
214
|
|
|
205
215
|
op_count = 0
|
|
206
216
|
|
|
@@ -297,7 +307,11 @@ class Account(dict):
|
|
|
297
307
|
if i - batch_size < 0:
|
|
298
308
|
batch_size = i
|
|
299
309
|
count = yield from self.get_account_history(
|
|
300
|
-
index=i,
|
|
310
|
+
index=i,
|
|
311
|
+
limit=batch_size,
|
|
312
|
+
order=-1,
|
|
313
|
+
filter_by=filter_by,
|
|
314
|
+
raw_output=raw_output,
|
|
301
315
|
)
|
|
302
316
|
i -= batch_size + 1
|
|
303
317
|
op_count += count
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import hashlib
|
|
3
2
|
import json
|
|
4
3
|
import time
|
|
@@ -201,7 +200,6 @@ class Blockchain(GrapheneBlockchain):
|
|
|
201
200
|
for op in self.stream_from(
|
|
202
201
|
full_blocks=False, only_virtual_ops=only_virtual_ops, start_block=start_block, end_block=end_block
|
|
203
202
|
):
|
|
204
|
-
|
|
205
203
|
if not filter_by or op["op"][0] in filter_by:
|
|
206
204
|
if raw_output:
|
|
207
205
|
yield op
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import secrets
|
|
3
2
|
|
|
4
3
|
from graphenecommon.exceptions import KeyNotFound, MissingKeyError
|
|
@@ -76,9 +75,9 @@ class Memo(GrapheneMemo):
|
|
|
76
75
|
"Memo private key {} for {} could not be found".format(
|
|
77
76
|
self.from_account["memo_key"], self.from_account["name"]
|
|
78
77
|
)
|
|
79
|
-
)
|
|
78
|
+
) from None
|
|
80
79
|
if not memo_wif:
|
|
81
|
-
raise MissingKeyError("Memo key for
|
|
80
|
+
raise MissingKeyError("Memo key for {} missing!".format(self.from_account["name"]))
|
|
82
81
|
|
|
83
82
|
if not hasattr(self, "chain_prefix"):
|
|
84
83
|
self.chain_prefix = self.blockchain.prefix
|
|
@@ -105,10 +104,10 @@ class Memo(GrapheneMemo):
|
|
|
105
104
|
keys = memo.involved_keys(message)
|
|
106
105
|
wif = None
|
|
107
106
|
for key in keys:
|
|
108
|
-
try:
|
|
107
|
+
try:
|
|
109
108
|
wif = self.blockchain.wallet.getPrivateKeyForPublicKey(str(key))
|
|
110
109
|
break
|
|
111
|
-
except:
|
|
110
|
+
except Exception:
|
|
112
111
|
continue
|
|
113
112
|
if not wif:
|
|
114
113
|
raise MissingKeyError("None of the required memo keys are installed!")
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
from graphenestorage import (
|
|
3
|
-
InRamConfigurationStore,
|
|
4
|
-
InRamEncryptedKeyStore,
|
|
5
|
-
InRamPlainKeyStore,
|
|
6
2
|
SqliteConfigurationStore,
|
|
7
3
|
SqliteEncryptedKeyStore,
|
|
8
|
-
SQLiteFile,
|
|
9
|
-
SqlitePlainKeyStore,
|
|
10
4
|
)
|
|
11
5
|
|
|
12
6
|
from vizbase.chains import DEFAULT_PREFIX
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
# We don't have own Asset class because it is unneeded
|
|
3
2
|
import struct
|
|
4
3
|
from binascii import unhexlify
|
|
@@ -39,9 +38,9 @@ class ProposalBuilder(GrapheneProposalBuilder):
|
|
|
39
38
|
self, author, title, memo, proposal_expiration=None, proposal_review=None, parent=None, *args, **kwargs
|
|
40
39
|
):
|
|
41
40
|
self.define_classes()
|
|
42
|
-
assert self.operation_class
|
|
43
|
-
assert self.operations
|
|
44
|
-
assert self.account_class
|
|
41
|
+
assert self.operation_class is not None
|
|
42
|
+
assert self.operations is not None
|
|
43
|
+
assert self.account_class is not None
|
|
45
44
|
|
|
46
45
|
self.proposal_expiration = proposal_expiration or 2 * 24 * 60 * 60
|
|
47
46
|
self.proposal_review = proposal_review
|
|
@@ -62,12 +61,12 @@ class ProposalBuilder(GrapheneProposalBuilder):
|
|
|
62
61
|
return
|
|
63
62
|
ops = [self.operations.Op_wrapper(op=o) for o in list(self.ops)]
|
|
64
63
|
data = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
"author": self.proposer,
|
|
65
|
+
"title": self.title,
|
|
66
|
+
"memo": self.memo,
|
|
67
|
+
"proposed_operations": [o.json() for o in ops],
|
|
68
|
+
"expiration_time": formatTimeFromNow(self.proposal_expiration),
|
|
69
|
+
"extensions": [],
|
|
71
70
|
}
|
|
72
71
|
if self.proposal_review:
|
|
73
72
|
data.update({"review_period_time": formatTimeFromNow(self.proposal_review)})
|
|
@@ -123,7 +122,7 @@ class TransactionBuilder(GrapheneTransactionBuilder):
|
|
|
123
122
|
else:
|
|
124
123
|
accountObj = self.account_class(account, blockchain_instance=self.blockchain) # noqa: N806
|
|
125
124
|
# TODO: method overriden because of _authority
|
|
126
|
-
field = "{}_authority"
|
|
125
|
+
field = f"{permission}_authority"
|
|
127
126
|
required_treshold = accountObj[field]["weight_threshold"]
|
|
128
127
|
keys = self._fetchkeys(accountObj, field, required_treshold=required_treshold)
|
|
129
128
|
# If we couldn't find an active key, let's try overwrite it
|