viz-python-lib 1.3.0__tar.gz → 1.4.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.
Files changed (39) hide show
  1. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/PKG-INFO +76 -9
  2. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/README.md +69 -3
  3. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/pyproject.toml +25 -17
  4. viz_python_lib-1.4.0/viz/agent.py +132 -0
  5. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/blockchain.py +9 -2
  6. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizapi/consts.py +45 -1
  7. viz_python_lib-1.4.0/vizbase/chains.py +27 -0
  8. viz_python_lib-1.4.0/vizbase/objects.py +285 -0
  9. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/operationids.py +65 -0
  10. viz_python_lib-1.4.0/vizbase/operations.py +1077 -0
  11. viz_python_lib-1.3.0/vizbase/chains.py +0 -17
  12. viz_python_lib-1.3.0/vizbase/objects.py +0 -193
  13. viz_python_lib-1.3.0/vizbase/operations.py +0 -490
  14. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/LICENSE.txt +0 -0
  15. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/__init__.py +0 -0
  16. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/account.py +0 -0
  17. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/amount.py +0 -0
  18. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/block.py +0 -0
  19. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/blockchainobject.py +0 -0
  20. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/converter.py +0 -0
  21. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/exceptions.py +0 -0
  22. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/instance.py +0 -0
  23. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/memo.py +0 -0
  24. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/storage.py +0 -0
  25. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/transactionbuilder.py +0 -0
  26. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/utils.py +0 -0
  27. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/validator.py +0 -0
  28. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/viz.py +0 -0
  29. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/wallet.py +0 -0
  30. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/viz/witness.py +0 -0
  31. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizapi/__init__.py +0 -0
  32. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizapi/exceptions.py +0 -0
  33. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizapi/noderpc.py +0 -0
  34. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/__init__.py +0 -0
  35. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/account.py +0 -0
  36. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/exceptions.py +0 -0
  37. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/memo.py +0 -0
  38. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/signedtransactions.py +0 -0
  39. {viz_python_lib-1.3.0 → viz_python_lib-1.4.0}/vizbase/validator_compat.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viz-python-lib
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Python library for VIZ blockchain
5
5
  License: MIT
6
6
  License-File: LICENSE.txt
@@ -18,12 +18,13 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
21
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Requires-Dist: aiohttp (>=3.8,<4)
23
- Requires-Dist: docker (>=7.1.0,<8.0.0)
24
- Requires-Dist: funcy (>=2.0,<3.0)
25
- Requires-Dist: graphenelib (>=1.6.0,<2.0.0)
26
- Requires-Dist: toolz (>=0.12.0,<0.13.0)
23
+ Requires-Dist: aiohttp (>=3.14.5,<4.0.0)
24
+ Requires-Dist: docker (>=7.2.0,<8.0.0)
25
+ Requires-Dist: funcy (>=2.1,<3.0)
26
+ Requires-Dist: graphenelib (>=1.6.1,<2.0.0)
27
+ Requires-Dist: toolz (>=1.2.0,<2.0.0)
27
28
  Project-URL: Repository, https://github.com/VIZ-Blockchain/viz-python-lib
28
29
  Description-Content-Type: text/markdown
29
30
 
@@ -44,7 +45,7 @@ viz = Client(node=node, keys=["5...your_private_regular_key..."])
44
45
 
45
46
  initiator = "your_account"
46
47
  receiver = "id"
47
- percent = 10.5 # 10.5%
48
+ percent = 10.5 # 10.5%
48
49
  viz.award(receiver, percent, "with love", None, initiator)
49
50
  ```
50
51
 
@@ -58,8 +59,8 @@ viz = Client(node=node, keys=["5...your_private_regular_key..."])
58
59
 
59
60
  initiator = "your_account"
60
61
  receiver = "id"
61
- reward_amount = 3.5 # "3.50 VIZ"
62
- max_energy = 30 # 30%
62
+ reward_amount = 3.5 # "3.50 VIZ"
63
+ max_energy = 30 # 30%
63
64
  viz.fixed_award(receiver, reward_amount, max_energy, "with fixed reward", None, initiator)
64
65
  ```
65
66
 
@@ -78,6 +79,61 @@ custom_json = {"x": 35, "y": 70, "color": "#e50000"}
78
79
  viz.custom(protocol, custom_json, None, required_regular_auths)
79
80
  ```
80
81
 
82
+ ### Prediction market operations (HF14 / Onix)
83
+
84
+ All 23 broadcastable `pm_*` operations are available as serializers in
85
+ `vizbase.operations`. Build the operation and sign it with `finalizeOp` (the
86
+ same low-level path the built-in helpers use), passing the authority the op
87
+ requires — `active` for most PM ops, `regular` for `pm_dispute_vote`:
88
+
89
+ ```python
90
+ from viz import Client
91
+ from vizbase import operations
92
+
93
+ node = "wss://node.viz.cx/ws"
94
+ viz = Client(node=node, keys=["5...your_private_active_key..."])
95
+
96
+ account = "your_account"
97
+
98
+ # Place a bet: binary market -> side 0/1, outcome_index -1; multi -> side -1, outcome_index 0..N-1
99
+ bet = operations.Pm_place_bet(
100
+ account=account,
101
+ market_id=42,
102
+ side=1,
103
+ outcome_index=-1,
104
+ amount="1.500 VIZ",
105
+ min_tokens=0, # slippage floor (0 = none)
106
+ mode=0, # 0 instant, 1 batch
107
+ )
108
+ viz.finalizeOp(bet, account, "active")
109
+ ```
110
+
111
+ Chain governance uses the versioned variant: `versioned_chain_properties_update`
112
+ serializes variant 3 (`chain_properties_hf9`), 4 (`chain_properties_hf13`) or 5
113
+ (`chain_properties_pm`, the HF14 PM params) automatically from the fields you pass.
114
+
115
+ ### Agent keys (HF15)
116
+
117
+ An agent is a label plus a public key that may sign an explicit list of a principal's
118
+ operations. It never appears in the account's authorities, so check "authority OR agent":
119
+
120
+ ```python
121
+ from viz import Client, agent
122
+
123
+ viz = Client(node="wss://node.viz.cx/ws")
124
+
125
+ result = agent.check("alice", "VIZ...public_key...", "transfer", blockchain_instance=viz)
126
+ # {"allowed": True, "source": "agent", "role": None, "agent": {...row...}, "operation": "transfer"}
127
+
128
+ # off-chain scope of your own service
129
+ row = agent.find("alice", "VIZ...public_key...", viz)
130
+ if row and agent.addon_matches(row, "my-service"):
131
+ ...
132
+ ```
133
+
134
+ Grant or revoke with `operations.Set_agent_permission` via `finalizeOp(op, account, "active")`.
135
+ To broadcast as an agent, sign with the agent key directly: `tx.appendWif(agent_wif)`.
136
+
81
137
  ### Get data from custom protocol
82
138
 
83
139
  ```python
@@ -172,3 +228,14 @@ export CFLAGS="-I$(brew --prefix openssl)/include"
172
228
  export LDFLAGS="-L$(brew --prefix openssl)/lib"
173
229
  ```
174
230
 
231
+ ## HF16 compatibility
232
+
233
+ The block stream reads the current block interval from the node, including the
234
+ 3-second to 1-second HF16 transition. Block and header API responses retain QC,
235
+ timeout and equivocation extensions as JSON; this library does not serialize or
236
+ sign block headers. `validator_equivocation` is virtual operation 106.
237
+
238
+ `committee_worker_create_request` uses the existing transaction wire format.
239
+ From HF16 the node limits the maximum requested amount to 1% of `current_supply`
240
+ at creation (rounded down to the smallest VIZ unit), rather than a fixed 500,000 VIZ.
241
+
@@ -15,7 +15,7 @@ viz = Client(node=node, keys=["5...your_private_regular_key..."])
15
15
 
16
16
  initiator = "your_account"
17
17
  receiver = "id"
18
- percent = 10.5 # 10.5%
18
+ percent = 10.5 # 10.5%
19
19
  viz.award(receiver, percent, "with love", None, initiator)
20
20
  ```
21
21
 
@@ -29,8 +29,8 @@ viz = Client(node=node, keys=["5...your_private_regular_key..."])
29
29
 
30
30
  initiator = "your_account"
31
31
  receiver = "id"
32
- reward_amount = 3.5 # "3.50 VIZ"
33
- max_energy = 30 # 30%
32
+ reward_amount = 3.5 # "3.50 VIZ"
33
+ max_energy = 30 # 30%
34
34
  viz.fixed_award(receiver, reward_amount, max_energy, "with fixed reward", None, initiator)
35
35
  ```
36
36
 
@@ -49,6 +49,61 @@ custom_json = {"x": 35, "y": 70, "color": "#e50000"}
49
49
  viz.custom(protocol, custom_json, None, required_regular_auths)
50
50
  ```
51
51
 
52
+ ### Prediction market operations (HF14 / Onix)
53
+
54
+ All 23 broadcastable `pm_*` operations are available as serializers in
55
+ `vizbase.operations`. Build the operation and sign it with `finalizeOp` (the
56
+ same low-level path the built-in helpers use), passing the authority the op
57
+ requires — `active` for most PM ops, `regular` for `pm_dispute_vote`:
58
+
59
+ ```python
60
+ from viz import Client
61
+ from vizbase import operations
62
+
63
+ node = "wss://node.viz.cx/ws"
64
+ viz = Client(node=node, keys=["5...your_private_active_key..."])
65
+
66
+ account = "your_account"
67
+
68
+ # Place a bet: binary market -> side 0/1, outcome_index -1; multi -> side -1, outcome_index 0..N-1
69
+ bet = operations.Pm_place_bet(
70
+ account=account,
71
+ market_id=42,
72
+ side=1,
73
+ outcome_index=-1,
74
+ amount="1.500 VIZ",
75
+ min_tokens=0, # slippage floor (0 = none)
76
+ mode=0, # 0 instant, 1 batch
77
+ )
78
+ viz.finalizeOp(bet, account, "active")
79
+ ```
80
+
81
+ Chain governance uses the versioned variant: `versioned_chain_properties_update`
82
+ serializes variant 3 (`chain_properties_hf9`), 4 (`chain_properties_hf13`) or 5
83
+ (`chain_properties_pm`, the HF14 PM params) automatically from the fields you pass.
84
+
85
+ ### Agent keys (HF15)
86
+
87
+ An agent is a label plus a public key that may sign an explicit list of a principal's
88
+ operations. It never appears in the account's authorities, so check "authority OR agent":
89
+
90
+ ```python
91
+ from viz import Client, agent
92
+
93
+ viz = Client(node="wss://node.viz.cx/ws")
94
+
95
+ result = agent.check("alice", "VIZ...public_key...", "transfer", blockchain_instance=viz)
96
+ # {"allowed": True, "source": "agent", "role": None, "agent": {...row...}, "operation": "transfer"}
97
+
98
+ # off-chain scope of your own service
99
+ row = agent.find("alice", "VIZ...public_key...", viz)
100
+ if row and agent.addon_matches(row, "my-service"):
101
+ ...
102
+ ```
103
+
104
+ Grant or revoke with `operations.Set_agent_permission` via `finalizeOp(op, account, "active")`.
105
+ To broadcast as an agent, sign with the agent key directly: `tx.appendWif(agent_wif)`.
106
+
52
107
  ### Get data from custom protocol
53
108
 
54
109
  ```python
@@ -142,3 +197,14 @@ and then use the following commands:
142
197
  export CFLAGS="-I$(brew --prefix openssl)/include"
143
198
  export LDFLAGS="-L$(brew --prefix openssl)/lib"
144
199
  ```
200
+
201
+ ## HF16 compatibility
202
+
203
+ The block stream reads the current block interval from the node, including the
204
+ 3-second to 1-second HF16 transition. Block and header API responses retain QC,
205
+ timeout and equivocation extensions as JSON; this library does not serialize or
206
+ sign block headers. `validator_equivocation` is virtual operation 106.
207
+
208
+ `committee_worker_create_request` uses the existing transaction wire format.
209
+ From HF16 the node limits the maximum requested amount to 1% of `current_supply`
210
+ at creation (rounded down to the smallest VIZ unit), rather than a fixed 500,000 VIZ.
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["poetry-core>=1.9.0"]
2
+ requires = ["poetry-core>=2.5.0,<3"]
3
3
  build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "viz-python-lib"
7
- version = "1.3.0"
7
+ version = "1.4.0"
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"
@@ -34,26 +34,34 @@ classifiers = [
34
34
 
35
35
  [tool.poetry.dependencies]
36
36
  python = "^3.10"
37
- graphenelib = "^1.6.0"
38
- toolz = "^0.12.0"
39
- funcy = "^2.0"
40
- aiohttp = ">=3.8,<4"
41
- docker = "^7.1.0"
37
+ graphenelib = "^1.6.1"
38
+ toolz = "^1.2.0"
39
+ funcy = "^2.1"
40
+ aiohttp = "^3.14.5"
41
+ docker = "^7.2.0"
42
42
 
43
43
 
44
44
  [tool.poetry.group.dev.dependencies]
45
- pre-commit = "^3.6"
46
- ruff = "^0.1"
47
- mypy = "^1.8"
48
- pytest = "^9.0"
49
- pytest-cov = "^5.0"
50
-
51
- sphinx = ">=4.0,<7.0"
52
- sphinx-autoapi = "^1.8.0"
45
+ # Patched filelock requires Python 3.11+. Keep runtime/test support for 3.10,
46
+ # but run the optional pre-commit tooling on a supported patched interpreter.
47
+ pre-commit = { version = "^4.7.0", python = ">=3.11" }
48
+ filelock = { version = ">=4.2.1,<5", python = ">=3.11" }
49
+ ruff = "^0.17.2"
50
+ mypy = "^2.4"
51
+ pytest = "^9.1.1"
52
+ pytest-cov = "^7.1"
53
+
54
+ sphinx = [
55
+ { version = ">=8.1.3,<9", python = ">=3.10,<3.11" },
56
+ { version = ">=9.0.4,<9.1", python = ">=3.11,<3.12" },
57
+ { version = ">=9.1.1,<9.2", python = ">=3.12,<3.13" },
58
+ { version = "^9.2.0", python = ">=3.13" },
59
+ ]
60
+ sphinx-autoapi = "^3.8.1"
53
61
  # used in docs to include markdown files
54
- m2r2 = "^0.3.2"
62
+ m2r2 = "^2.1"
55
63
  # used in docs to parse pyproject.toml
56
- tomlkit = "^0.11.8"
64
+ tomlkit = "^0.15.2"
57
65
 
58
66
 
59
67
  [tool.pytest.ini_options]
@@ -0,0 +1,132 @@
1
+ """
2
+ HF15 agent access (op-id 105 ``set_agent_permission``) — read-side helpers.
3
+
4
+ A principal may register agents: a label plus a public key that may sign an explicit list of the
5
+ principal's operations, optionally scoped to off-chain addons, optionally expiring. An agent is
6
+ not an account and never appears in any authority, so "look at active_authority.key_auths" rejects
7
+ agent keys. The recipe is authority OR agents; :func:`check` does both.
8
+
9
+ Mirrors ``agent.js`` of viz-js-lib and ``VIZ\\Agent`` of viz-php-lib; the node
10
+ (``agent_evaluator.cpp::usable_agent_row``) is the source of truth.
11
+ """
12
+
13
+ from datetime import datetime, timezone
14
+ from typing import Any
15
+
16
+ from grapheneapi.exceptions import RPCError
17
+
18
+ from vizbase.account import PublicKey
19
+ from vizbase.chains import DEFAULT_PREFIX
20
+
21
+ from .instance import shared_blockchain_instance
22
+
23
+ # Mirrors the node's never_delegable_operation_names(): a row holding one of these grants nothing.
24
+ NEVER_DELEGABLE = frozenset(
25
+ {
26
+ "set_agent_permission",
27
+ "proposal_update",
28
+ "account_update",
29
+ "recover_account",
30
+ "change_recovery_account",
31
+ "set_account_price",
32
+ "set_subaccount_price",
33
+ "target_account_sale",
34
+ }
35
+ )
36
+
37
+ # Authority roles a key can belong to, most privileged first. Agents answer for none of them.
38
+ ROLES = ("master", "active", "regular")
39
+
40
+
41
+ def normalize_key(key: str) -> str:
42
+ """Canonical ``VIZ...`` form of an encoded public key; the stripped input if it cannot be parsed."""
43
+ value = str(key or "").strip()
44
+ try:
45
+ return format(
46
+ PublicKey(DEFAULT_PREFIX + value.removeprefix(DEFAULT_PREFIX), prefix=DEFAULT_PREFIX), DEFAULT_PREFIX
47
+ )
48
+ except Exception:
49
+ return value
50
+
51
+
52
+ def key_equals(a: object, b: object) -> bool:
53
+ return isinstance(a, str) and isinstance(b, str) and normalize_key(a) == normalize_key(b)
54
+
55
+
56
+ def is_expired(row: dict) -> bool:
57
+ """The node's own ``expired`` flag wins; the timestamp against the local clock is the fallback."""
58
+ if "expired" in row:
59
+ return bool(row["expired"])
60
+ try:
61
+ # The chain reports UTC without a trailing 'Z'.
62
+ expiration = datetime.fromisoformat(row["expiration"]).replace(tzinfo=timezone.utc)
63
+ except (KeyError, TypeError, ValueError):
64
+ return False
65
+ # epoch = perpetual
66
+ return 0 < expiration.timestamp() <= datetime.now(timezone.utc).timestamp()
67
+
68
+
69
+ def poisoned(row: dict) -> bool:
70
+ """True when the row lists a never-delegable name: the node refuses such a row whole."""
71
+ return not NEVER_DELEGABLE.isdisjoint(row.get("operations") or ())
72
+
73
+
74
+ def grants(row: dict, operation: str) -> bool:
75
+ """True when the row covers ``operation`` (wire name, e.g. ``transfer``) and is not poisoned."""
76
+ return operation in (row.get("operations") or ()) and not poisoned(row)
77
+
78
+
79
+ def addon_matches(row: dict, scope: str) -> bool:
80
+ """True when the row carries the off-chain ``scope`` (exact, case-sensitive) and is not poisoned."""
81
+ return scope in (row.get("addons") or ()) and not poisoned(row)
82
+
83
+
84
+ def in_authority(authority: dict | None, key: str) -> bool:
85
+ """True when ``key`` alone meets the authority's threshold. Nested account_auths are not resolved."""
86
+ if not authority:
87
+ return False
88
+ weight = sum(int(w) for k, w in authority.get("key_auths", ()) if key_equals(k, key))
89
+ return weight > 0 and weight >= int(authority.get("weight_threshold", 0))
90
+
91
+
92
+ def find(account: str, key: str, blockchain_instance: Any = None) -> dict | None:
93
+ """First live agent row of ``account`` signed by ``key``, or None."""
94
+ rpc = (blockchain_instance or shared_blockchain_instance()).rpc
95
+ try:
96
+ rows = rpc.get_agent_permissions(account)
97
+ except RPCError:
98
+ # A node without HF15 has no such method: no agents. Transport errors still propagate.
99
+ return None
100
+ for row in rows or ():
101
+ if row.get("agent_key") and not is_expired(row) and key_equals(row["agent_key"], key):
102
+ return row
103
+ return None
104
+
105
+
106
+ def has(account: str, key: str, operation: str | None = None, blockchain_instance: Any = None) -> bool:
107
+ """True when ``key`` is a live agent of ``account`` — and, if ``operation`` is given, may sign it."""
108
+ row = find(account, key, blockchain_instance)
109
+ return row is not None and (not operation or grants(row, operation))
110
+
111
+
112
+ def check(account: str, key: str, operation: str | None = None, blockchain_instance: Any = None) -> dict:
113
+ """
114
+ May ``key`` act for ``account``? Authority roles first, then agents.
115
+
116
+ Returns ``{"allowed", "source": "authority"|"agent"|"none", "role", "agent", "operation"}``.
117
+ With ``operation`` omitted an agent is only answered as "this is a live agent key"; pass the
118
+ wire name to check a specific operation. An authority match is by direct key membership and
119
+ does not consider which role ``operation`` requires. For the full recursive check use the
120
+ node's ``verify_authority`` with a signed transaction.
121
+ """
122
+ result = {"allowed": False, "source": "none", "role": None, "agent": None, "operation": operation}
123
+ rpc = (blockchain_instance or shared_blockchain_instance()).rpc
124
+ accounts = rpc.get_accounts([account])
125
+ if accounts and accounts[0] and accounts[0].get("name") == account:
126
+ for role in ROLES:
127
+ if in_authority(accounts[0].get(f"{role}_authority"), key):
128
+ return {**result, "allowed": True, "source": "authority", "role": role}
129
+ row = find(account, key, blockchain_instance)
130
+ if row is not None and (not operation or grants(row, operation)):
131
+ return {**result, "allowed": True, "source": "agent", "agent": row}
132
+ return result
@@ -47,8 +47,15 @@ class Blockchain(GrapheneBlockchain):
47
47
  self.operationids = operationids
48
48
 
49
49
  def get_block_interval(self) -> int:
50
- """Override class from graphenelib because our API is different."""
51
- return self.blockchain.rpc.config.get("CHAIN_BLOCK_INTERVAL")
50
+ """Override class from graphenelib because our API is different.
51
+
52
+ Asked live, not from the config cached at connect: since HF16 the node reports the
53
+ CURRENT slot (3 s before the fork, 1 s after), so a cached value goes stale at the fork.
54
+ """
55
+ try:
56
+ return int(self.blockchain.rpc.get_config()["CHAIN_BLOCK_INTERVAL"])
57
+ except Exception:
58
+ return self.blockchain.rpc.config.get("CHAIN_BLOCK_INTERVAL")
52
59
 
53
60
  def stream_from(
54
61
  self,
@@ -17,7 +17,11 @@ API = {
17
17
  "lookup_account_names": "database_api",
18
18
  "lookup_accounts": "database_api",
19
19
  "get_account_count": "database_api",
20
- "get_owner_history": "database_api",
20
+ "get_owner_history": "database_api", # pre-rename nodes
21
+ "get_master_history": "database_api",
22
+ "get_agent_permissions": "database_api",
23
+ "get_key_history": "database_api",
24
+ "get_key_history_by_key": "database_api",
21
25
  "get_recovery_request": "database_api",
22
26
  "get_escrow": "database_api",
23
27
  "get_withdraw_routes": "database_api",
@@ -107,6 +111,46 @@ API = {
107
111
  "get_validator_count": "validator_api",
108
112
  "lookup_validator_accounts": "validator_api",
109
113
  "get_account": "custom_protocol_api",
114
+ # prediction_market_api (HF14) — read-only market/oracle/liquidity/dispute/leverage queries.
115
+ # Generated from `grep -r DEFINE_API_ARGS plugins/prediction_market_api`.
116
+ "get_market": "prediction_market_api",
117
+ "get_market_full": "prediction_market_api",
118
+ "get_market_meta": "prediction_market_api",
119
+ "get_market_outcomes": "prediction_market_api",
120
+ "get_market_weight_sums": "prediction_market_api",
121
+ "get_market_bets": "prediction_market_api",
122
+ "get_market_liquidity": "prediction_market_api",
123
+ "get_market_kline": "prediction_market_api",
124
+ "list_markets": "prediction_market_api",
125
+ "list_markets_by_oracle": "prediction_market_api",
126
+ "list_markets_by_oracle_status": "prediction_market_api",
127
+ "list_markets_by_creator": "prediction_market_api",
128
+ "list_markets_by_category": "prediction_market_api",
129
+ "list_markets_by_event": "prediction_market_api",
130
+ "list_markets_awaiting_resolution": "prediction_market_api",
131
+ "list_markets_in_dispute_window": "prediction_market_api",
132
+ "get_market_categories": "prediction_market_api",
133
+ "get_category_tag_counts": "prediction_market_api",
134
+ "get_oracle": "prediction_market_api",
135
+ "list_oracles": "prediction_market_api",
136
+ "list_oracle_disputes": "prediction_market_api",
137
+ "get_creator_ban": "prediction_market_api",
138
+ "get_dispute": "prediction_market_api",
139
+ "get_dispute_votes": "prediction_market_api",
140
+ "get_account_positions": "prediction_market_api",
141
+ "get_account_leverage_positions": "prediction_market_api",
142
+ "get_market_leverage_positions": "prediction_market_api",
143
+ "get_leverage_quote": "prediction_market_api",
144
+ "get_leverage_close_preview": "prediction_market_api",
145
+ "get_leverage_convert_preview": "prediction_market_api",
146
+ "get_lazy_pool": "prediction_market_api",
147
+ "get_lazy_deposit": "prediction_market_api",
148
+ "get_lazy_allocations": "prediction_market_api",
149
+ "get_market_lazy_allocation": "prediction_market_api",
150
+ "get_lazy_withdraw_requests": "prediction_market_api",
151
+ "get_deferred_claims": "prediction_market_api",
152
+ "get_account_commits": "prediction_market_api",
153
+ "get_pm_chain_properties": "prediction_market_api",
110
154
  "test_api_a": "test_api",
111
155
  "test_api_b": "test_api",
112
156
  "api_name": "json_rpc",
@@ -0,0 +1,27 @@
1
+ DEFAULT_PREFIX = "VIZ"
2
+
3
+ # NodeRPC._get_network() matches the node's reported CHAIN_ID against these entries
4
+ # by exact string, so a chain_id here must match what `get_config()["CHAIN_ID"]` returns.
5
+ #
6
+ # Note on the public testnet: testnet.viz.world is a *snapshot fork of mainnet*
7
+ # (no fresh genesis — see the node's DLT/snapshot model), so it reports the SAME
8
+ # CHAIN_ID as mainnet (the "VIZ" entry below). Connecting the lib there therefore
9
+ # resolves to "VIZ" and signs with the mainnet chain_id — which is correct for that
10
+ # testnet. "VIZTEST" is a legacy standalone-testnet id that no current public node
11
+ # serves; it is kept for historical reference only and will not match a live network.
12
+ KNOWN_CHAINS = {
13
+ "VIZ": {
14
+ "chain_id": "2040effda178d4fffff5eab7a915d4019879f5205cc5392e4bcced2b6edda0cd",
15
+ "core_symbol": "VIZ",
16
+ "shares_symbol": "SHARES",
17
+ "prefix": "VIZ",
18
+ },
19
+ "VIZTEST": { # legacy standalone testnet — not served by testnet.viz.world (see note above)
20
+ "chain_id": "441adba730c2a8dab953abd87d452bb356627b8a7d181f46b2aaa2c053af2112",
21
+ "core_symbol": "VIZ",
22
+ "shares_symbol": "SHARES",
23
+ "prefix": "VIZ",
24
+ },
25
+ }
26
+
27
+ PRECISIONS = {"VIZ": 3, "SHARES": 6}