viz-python-lib 1.3.0__py3-none-any.whl → 1.4.0__py3-none-any.whl
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/agent.py +132 -0
- viz/blockchain.py +9 -2
- {viz_python_lib-1.3.0.dist-info → viz_python_lib-1.4.0.dist-info}/METADATA +76 -9
- {viz_python_lib-1.3.0.dist-info → viz_python_lib-1.4.0.dist-info}/RECORD +11 -10
- {viz_python_lib-1.3.0.dist-info → viz_python_lib-1.4.0.dist-info}/WHEEL +1 -1
- vizapi/consts.py +45 -1
- vizbase/chains.py +11 -1
- vizbase/objects.py +138 -46
- vizbase/operationids.py +65 -0
- vizbase/operations.py +587 -0
- {viz_python_lib-1.3.0.dist-info → viz_python_lib-1.4.0.dist-info}/licenses/LICENSE.txt +0 -0
viz/agent.py
ADDED
|
@@ -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
|
viz/blockchain.py
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: viz-python-lib
|
|
3
|
-
Version: 1.
|
|
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.
|
|
23
|
-
Requires-Dist: docker (>=7.
|
|
24
|
-
Requires-Dist: funcy (>=2.
|
|
25
|
-
Requires-Dist: graphenelib (>=1.6.
|
|
26
|
-
Requires-Dist: toolz (>=
|
|
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
|
|
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
|
|
62
|
-
max_energy = 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
|
+
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
viz/__init__.py,sha256=zZLRKB2iD1XkOhD9zHglX-q6shGvWyek5v-ZHa_Q4x8,46
|
|
2
2
|
viz/account.py,sha256=21MaPOWAbJJt9n971ytZJVAIvBBDD6NRZ5O3ANgLCAg,10865
|
|
3
|
+
viz/agent.py,sha256=2nq4H0iRrKNqghCPRby_OVCUja6Ul-GgFZ69vfh92lE,5680
|
|
3
4
|
viz/amount.py,sha256=6LoUfr4E9mOmWlRC0Smy9vKfUt0Hhdx7qH1C7mlEF70,5683
|
|
4
5
|
viz/block.py,sha256=aoCq3zOYyoI_6OmW4imQKVk0Tcn32YrrIOJJZfcGqY0,1093
|
|
5
|
-
viz/blockchain.py,sha256=
|
|
6
|
+
viz/blockchain.py,sha256=AXkrlWc6WUU5GRh5KCaowanMfm_0Iu_Lfuk0zn7XMlE,9586
|
|
6
7
|
viz/blockchainobject.py,sha256=_pwnJMDj6wmPGdxgc43iu2t_4yNozY7i0c_IeIgooUU,386
|
|
7
8
|
viz/converter.py,sha256=Bty4Av7k-fAhHZZA54M5cDYO4c3ufgl0cnjklp1G5pk,1101
|
|
8
9
|
viz/exceptions.py,sha256=yMJ0-TxS0bn2vkH8P4Mkd33CDbKqrioqwYogOfWtORI,428
|
|
@@ -16,20 +17,20 @@ viz/viz.py,sha256=4WNA1Ui00gGQp3eZ5FddzGx_mSZK5z6DetXLMC1aCL8,28955
|
|
|
16
17
|
viz/wallet.py,sha256=rD1L2LSdP0GaDn4UY13fQP-gyswIzsOnWP2O6rT5Fic,361
|
|
17
18
|
viz/witness.py,sha256=g2mMCplyrKAThHLynmmEBQ-9vcdRc0ts0CcoFd7i2rg,519
|
|
18
19
|
vizapi/__init__.py,sha256=1mfkBk0riiobfZ00LKex4r8dDlCv4rU9kX7VMAUzQY4,49
|
|
19
|
-
vizapi/consts.py,sha256=
|
|
20
|
+
vizapi/consts.py,sha256=ky1CCjso-RztnX7pFv-Y4DGEQxN1wN2m4q7ybipzyDY,7248
|
|
20
21
|
vizapi/exceptions.py,sha256=JfD1NL68ntRb4vAMhRQQWPk1UJ52RH93swJA2au2FFI,984
|
|
21
22
|
vizapi/noderpc.py,sha256=mz7z5PCMT9ANBAVR-gD87rfdYUE1Xwc02PNrP2Wrcjk,7790
|
|
22
23
|
vizbase/__init__.py,sha256=TyuPogcL9AGGSDrJq_iIcKclvsn0ZoPhBpXFMjbGsH4,186
|
|
23
24
|
vizbase/account.py,sha256=QTu8WukItc_HN6G76MMO6IfS0iY18NWXmamXzt3AG5g,3183
|
|
24
|
-
vizbase/chains.py,sha256=
|
|
25
|
+
vizbase/chains.py,sha256=vUIDtakjfUjzIQ8hghFfodfqyeXix1GLFhDR1Js7Bpg,1239
|
|
25
26
|
vizbase/exceptions.py,sha256=dm76Hj5tMoaKOTPJvTue1y8LuP3zfI8P_1BDBFyJVwM,87
|
|
26
27
|
vizbase/memo.py,sha256=artQmLtKp-b_ZtoUj02GGd1_IaLPbWEJyHw2OWC008U,3929
|
|
27
|
-
vizbase/objects.py,sha256=
|
|
28
|
-
vizbase/operationids.py,sha256=
|
|
29
|
-
vizbase/operations.py,sha256=
|
|
28
|
+
vizbase/objects.py,sha256=hg7GHCteJbjm9kGQOnP2RiZpiLUhfKrlZUahNGOGV5Q,13614
|
|
29
|
+
vizbase/operationids.py,sha256=d55wwEF6phtp8nEgjnAsbCGxADQOPamMFy0CBWLonBs,5489
|
|
30
|
+
vizbase/operations.py,sha256=yJIqDwnOUaSBNOw75MzLWmdu-BZ4zIgEQ1cboldsBTU,39889
|
|
30
31
|
vizbase/signedtransactions.py,sha256=KZuWGmzA-Lamq6VadEESDTsRl7ECpscThj6wIu47d78,665
|
|
31
32
|
vizbase/validator_compat.py,sha256=RuhaW3ZFh5eGZ74nGtEek35o5cOuQ9VBGXoPial5Dho,2962
|
|
32
|
-
viz_python_lib-1.
|
|
33
|
-
viz_python_lib-1.
|
|
34
|
-
viz_python_lib-1.
|
|
35
|
-
viz_python_lib-1.
|
|
33
|
+
viz_python_lib-1.4.0.dist-info/METADATA,sha256=ETjqVXWjybAfxchLy9RRHLhh-_U4xA8bpA4dMklp0kw,7162
|
|
34
|
+
viz_python_lib-1.4.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
35
|
+
viz_python_lib-1.4.0.dist-info/licenses/LICENSE.txt,sha256=Nl1SGZTRwbvAko1uTG4FLQMol_feVwxCWnqCTQtf8No,1211
|
|
36
|
+
viz_python_lib-1.4.0.dist-info/RECORD,,
|
vizapi/consts.py
CHANGED
|
@@ -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",
|
vizbase/chains.py
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
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.
|
|
2
12
|
KNOWN_CHAINS = {
|
|
3
13
|
"VIZ": {
|
|
4
14
|
"chain_id": "2040effda178d4fffff5eab7a915d4019879f5205cc5392e4bcced2b6edda0cd",
|
|
@@ -6,7 +16,7 @@ KNOWN_CHAINS = {
|
|
|
6
16
|
"shares_symbol": "SHARES",
|
|
7
17
|
"prefix": "VIZ",
|
|
8
18
|
},
|
|
9
|
-
"VIZTEST": {
|
|
19
|
+
"VIZTEST": { # legacy standalone testnet — not served by testnet.viz.world (see note above)
|
|
10
20
|
"chain_id": "441adba730c2a8dab953abd87d452bb356627b8a7d181f46b2aaa2c053af2112",
|
|
11
21
|
"core_symbol": "VIZ",
|
|
12
22
|
"shares_symbol": "SHARES",
|
vizbase/objects.py
CHANGED
|
@@ -4,11 +4,13 @@ from collections import OrderedDict
|
|
|
4
4
|
from graphenebase.objects import GrapheneObject, isArgsThisClass
|
|
5
5
|
from graphenebase.objects import Operation as GrapheneOperation
|
|
6
6
|
from graphenebase.types import (
|
|
7
|
+
Bool,
|
|
7
8
|
Bytes,
|
|
8
9
|
Int16,
|
|
9
10
|
Map,
|
|
10
11
|
Static_variant,
|
|
11
12
|
String,
|
|
13
|
+
Uint8,
|
|
12
14
|
Uint16,
|
|
13
15
|
Uint32,
|
|
14
16
|
Uint64,
|
|
@@ -117,13 +119,134 @@ class Permission(GrapheneObject):
|
|
|
117
119
|
|
|
118
120
|
class ChainPropertiesVariant(Static_variant):
|
|
119
121
|
def __init__(self, props):
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
# Pick the versioned_chain_properties variant (index == C++ static_variant
|
|
123
|
+
# index) from the fields present. HF14/Onix (chain_properties_pm) = 5,
|
|
124
|
+
# HF13 (chain_properties_hf13) = 4, HF9 (chain_properties_hf9) = 3.
|
|
125
|
+
if "pm_oracle_registration_fee" in props:
|
|
126
|
+
version = 5
|
|
127
|
+
data = ChainPropertiesPm(**props)
|
|
128
|
+
elif "distribution_epoch_length" in props:
|
|
129
|
+
version = 4
|
|
130
|
+
data = ChainPropertiesHf13(**props)
|
|
131
|
+
else:
|
|
132
|
+
version = 3
|
|
133
|
+
data = ChainProperties(**props)
|
|
122
134
|
|
|
123
135
|
super().__init__(data, version)
|
|
124
136
|
|
|
125
137
|
|
|
138
|
+
def _chain_properties_hf9_items(kwargs):
|
|
139
|
+
"""Fields shared by chain_properties_hf9 (variant 3) and all later versions,
|
|
140
|
+
in the exact FC_REFLECT order (binary layout is consensus-critical)."""
|
|
141
|
+
return [
|
|
142
|
+
# initial, version 0
|
|
143
|
+
("account_creation_fee", Amount(kwargs["account_creation_fee"])),
|
|
144
|
+
("maximum_block_size", Uint32(kwargs["maximum_block_size"])),
|
|
145
|
+
("create_account_delegation_ratio", Uint32(kwargs["create_account_delegation_ratio"])),
|
|
146
|
+
("create_account_delegation_time", Uint32(kwargs["create_account_delegation_time"])),
|
|
147
|
+
("min_delegation", Amount(kwargs["min_delegation"])),
|
|
148
|
+
("min_curation_percent", Uint16(kwargs["min_curation_percent"])),
|
|
149
|
+
("max_curation_percent", Uint16(kwargs["max_curation_percent"])),
|
|
150
|
+
("bandwidth_reserve_percent", Uint16(kwargs["bandwidth_reserve_percent"])),
|
|
151
|
+
("bandwidth_reserve_below", Amount(kwargs["bandwidth_reserve_below"])),
|
|
152
|
+
("flag_energy_additional_cost", Uint16(kwargs["flag_energy_additional_cost"])),
|
|
153
|
+
("vote_accounting_min_rshares", Uint32(kwargs["vote_accounting_min_rshares"])),
|
|
154
|
+
("committee_request_approve_min_percent", Uint16(kwargs["committee_request_approve_min_percent"])),
|
|
155
|
+
# chain_properties_hf4, version 1
|
|
156
|
+
("inflation_validator_percent", Uint16(kwargs["inflation_validator_percent"])),
|
|
157
|
+
("inflation_ratio_committee_vs_reward_fund", Uint16(kwargs["inflation_ratio_committee_vs_reward_fund"])),
|
|
158
|
+
("inflation_recalc_period", Uint32(kwargs["inflation_recalc_period"])),
|
|
159
|
+
# chain_properties_hf6: version 2
|
|
160
|
+
("data_operations_cost_additional_bandwidth", Uint32(kwargs["data_operations_cost_additional_bandwidth"])),
|
|
161
|
+
("validator_miss_penalty_percent", Uint16(kwargs["validator_miss_penalty_percent"])),
|
|
162
|
+
("validator_miss_penalty_duration", Uint32(kwargs["validator_miss_penalty_duration"])),
|
|
163
|
+
# chain_properties_hf9: version 3
|
|
164
|
+
("create_invite_min_balance", Amount(kwargs["create_invite_min_balance"])),
|
|
165
|
+
("committee_create_request_fee", Amount(kwargs["committee_create_request_fee"])),
|
|
166
|
+
("create_paid_subscription_fee", Amount(kwargs["create_paid_subscription_fee"])),
|
|
167
|
+
("account_on_sale_fee", Amount(kwargs["account_on_sale_fee"])),
|
|
168
|
+
("subaccount_on_sale_fee", Amount(kwargs["subaccount_on_sale_fee"])),
|
|
169
|
+
("validator_declaration_fee", Amount(kwargs["validator_declaration_fee"])),
|
|
170
|
+
("withdraw_intervals", Uint16(kwargs["withdraw_intervals"])),
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _chain_properties_hf13_items(kwargs):
|
|
175
|
+
"""hf9 + chain_properties_hf13 (variant 4)."""
|
|
176
|
+
return _chain_properties_hf9_items(kwargs) + [
|
|
177
|
+
("distribution_epoch_length", Uint32(kwargs["distribution_epoch_length"])),
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _chain_properties_pm_items(kwargs):
|
|
182
|
+
"""hf13 + HF14/Onix chain_properties_pm (variant 5) governance params.
|
|
183
|
+
Order/types mirror FC_REFLECT_DERIVED(chain_properties_pm) exactly."""
|
|
184
|
+
return _chain_properties_hf13_items(kwargs) + [
|
|
185
|
+
("pm_oracle_registration_fee", Amount(kwargs["pm_oracle_registration_fee"])),
|
|
186
|
+
("pm_min_oracle_insurance", Amount(kwargs["pm_min_oracle_insurance"])),
|
|
187
|
+
("pm_market_creation_fee", Amount(kwargs["pm_market_creation_fee"])),
|
|
188
|
+
("pm_min_liquidity", Amount(kwargs["pm_min_liquidity"])),
|
|
189
|
+
("pm_max_outcomes", Uint8(kwargs["pm_max_outcomes"])),
|
|
190
|
+
("pm_max_market_duration", Uint32(kwargs["pm_max_market_duration"])),
|
|
191
|
+
("pm_max_oracle_fee_percent", Uint16(kwargs["pm_max_oracle_fee_percent"])),
|
|
192
|
+
("pm_oracle_accept_window_sec", Uint32(kwargs["pm_oracle_accept_window_sec"])),
|
|
193
|
+
("pm_listing_min_coverage_percent", Uint16(kwargs["pm_listing_min_coverage_percent"])),
|
|
194
|
+
("pm_betting_min_coverage_percent", Uint16(kwargs["pm_betting_min_coverage_percent"])),
|
|
195
|
+
("pm_default_time_penalty_percent", Uint16(kwargs["pm_default_time_penalty_percent"])),
|
|
196
|
+
("pm_max_time_penalty", Uint32(kwargs["pm_max_time_penalty"])),
|
|
197
|
+
("pm_dispute_fee", Amount(kwargs["pm_dispute_fee"])),
|
|
198
|
+
("pm_dispute_grace_sec", Uint32(kwargs["pm_dispute_grace_sec"])),
|
|
199
|
+
("pm_oracle_dispute_response_sec", Uint32(kwargs["pm_oracle_dispute_response_sec"])),
|
|
200
|
+
("pm_dispute_auto_close_sec", Uint32(kwargs["pm_dispute_auto_close_sec"])),
|
|
201
|
+
("pm_dispute_vote_period_sec", Uint32(kwargs["pm_dispute_vote_period_sec"])),
|
|
202
|
+
("pm_dispute_approve_min_percent", Uint16(kwargs["pm_dispute_approve_min_percent"])),
|
|
203
|
+
("pm_oracle_penalty_percent", Uint16(kwargs["pm_oracle_penalty_percent"])),
|
|
204
|
+
("pm_no_contest_penalty_percent", Uint16(kwargs["pm_no_contest_penalty_percent"])),
|
|
205
|
+
("pm_dispute_reward_multiplier", Uint32(kwargs["pm_dispute_reward_multiplier"])),
|
|
206
|
+
("pm_batch_epoch_blocks", Uint32(kwargs["pm_batch_epoch_blocks"])),
|
|
207
|
+
("pm_reveal_window_blocks", Uint32(kwargs["pm_reveal_window_blocks"])),
|
|
208
|
+
("pm_commit_no_reveal_penalty_percent", Uint16(kwargs["pm_commit_no_reveal_penalty_percent"])),
|
|
209
|
+
("pm_min_batch_bet", Amount(kwargs["pm_min_batch_bet"])),
|
|
210
|
+
("pm_commit_reveal_enabled", Bool(bool(kwargs["pm_commit_reveal_enabled"]))),
|
|
211
|
+
("pm_processing_cap_per_block", Uint32(kwargs["pm_processing_cap_per_block"])),
|
|
212
|
+
("pm_lazy_pool_enabled", Bool(bool(kwargs["pm_lazy_pool_enabled"]))),
|
|
213
|
+
("pm_lazy_alloc_percent", Uint16(kwargs["pm_lazy_alloc_percent"])),
|
|
214
|
+
("pm_lazy_max_total_alloc_percent", Uint16(kwargs["pm_lazy_max_total_alloc_percent"])),
|
|
215
|
+
("pm_lazy_lock_sec", Uint32(kwargs["pm_lazy_lock_sec"])),
|
|
216
|
+
("pm_lazy_recall_step_percent", Uint16(kwargs["pm_lazy_recall_step_percent"])),
|
|
217
|
+
("pm_lazy_emergency_penalty_percent", Uint16(kwargs["pm_lazy_emergency_penalty_percent"])),
|
|
218
|
+
("pm_lazy_min_liquidity_fee_percent", Uint16(kwargs["pm_lazy_min_liquidity_fee_percent"])),
|
|
219
|
+
("pm_leverage_enabled", Bool(bool(kwargs["pm_leverage_enabled"]))),
|
|
220
|
+
("pm_leverage_fund_percent", Uint16(kwargs["pm_leverage_fund_percent"])),
|
|
221
|
+
("pm_leverage_max_per_position_bp", Uint16(kwargs["pm_leverage_max_per_position_bp"])),
|
|
222
|
+
("pm_leverage_pool_profit_percent", Uint16(kwargs["pm_leverage_pool_profit_percent"])),
|
|
223
|
+
("pm_leverage_safety_margin_percent", Uint16(kwargs["pm_leverage_safety_margin_percent"])),
|
|
224
|
+
("pm_leverage_max_slippage_percent", Uint16(kwargs["pm_leverage_max_slippage_percent"])),
|
|
225
|
+
("pm_leverage_min_market_liquidity", Amount(kwargs["pm_leverage_min_market_liquidity"])),
|
|
226
|
+
("pm_leverage_max_position_ratio_percent", Uint16(kwargs["pm_leverage_max_position_ratio_percent"])),
|
|
227
|
+
("pm_leverage_expiration_buffer_sec", Uint32(kwargs["pm_leverage_expiration_buffer_sec"])),
|
|
228
|
+
("pm_leverage_m_factor_percent", Uint16(kwargs["pm_leverage_m_factor_percent"])),
|
|
229
|
+
("pm_leverage_funding_rate_ppm_per_day", Uint32(kwargs["pm_leverage_funding_rate_ppm_per_day"])),
|
|
230
|
+
("pm_conversion_profit_cost_percent", Uint16(kwargs["pm_conversion_profit_cost_percent"])),
|
|
231
|
+
("pm_closed_market_retention_sec", Uint32(kwargs["pm_closed_market_retention_sec"])),
|
|
232
|
+
("pm_early_exit_reward_cap_percent", Uint16(kwargs["pm_early_exit_reward_cap_percent"])),
|
|
233
|
+
# #432: minimum bet of the instant path and the per-block row budget of the incremental
|
|
234
|
+
# settlement sweep. Appended at the END, matching FC_REFLECT_DERIVED(chain_properties_pm)
|
|
235
|
+
# in the node — this list IS the wire order.
|
|
236
|
+
("pm_min_bet", Amount(kwargs["pm_min_bet"])),
|
|
237
|
+
("pm_settle_rows_per_block", Uint32(kwargs["pm_settle_rows_per_block"])),
|
|
238
|
+
("committee_votes_per_request", Uint32(kwargs["committee_votes_per_request"])),
|
|
239
|
+
("committee_vote_min_vesting", Amount(kwargs["committee_vote_min_vesting"])),
|
|
240
|
+
("pm_dispute_votes_per_market", Uint32(kwargs["pm_dispute_votes_per_market"])),
|
|
241
|
+
("pm_dispute_vote_min_vesting", Amount(kwargs["pm_dispute_vote_min_vesting"])),
|
|
242
|
+
]
|
|
243
|
+
|
|
244
|
+
|
|
126
245
|
class ChainProperties(GrapheneObject):
|
|
246
|
+
"""versioned_chain_properties variant 3 (chain_properties_hf9)."""
|
|
247
|
+
|
|
248
|
+
_items = staticmethod(_chain_properties_hf9_items)
|
|
249
|
+
|
|
127
250
|
def __init__(self, *args, **kwargs):
|
|
128
251
|
if isArgsThisClass(self, args):
|
|
129
252
|
self.data = args[0].data
|
|
@@ -137,50 +260,19 @@ class ChainProperties(GrapheneObject):
|
|
|
137
260
|
context="chain_properties_update",
|
|
138
261
|
)
|
|
139
262
|
|
|
140
|
-
super().__init__(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
("flag_energy_additional_cost", Uint16(kwargs["flag_energy_additional_cost"])),
|
|
154
|
-
("vote_accounting_min_rshares", Uint32(kwargs["vote_accounting_min_rshares"])),
|
|
155
|
-
(
|
|
156
|
-
"committee_request_approve_min_percent",
|
|
157
|
-
Uint16(kwargs["committee_request_approve_min_percent"]),
|
|
158
|
-
),
|
|
159
|
-
# chain_properties_hf4, version 1
|
|
160
|
-
("inflation_validator_percent", Uint16(kwargs["inflation_validator_percent"])),
|
|
161
|
-
(
|
|
162
|
-
"inflation_ratio_committee_vs_reward_fund",
|
|
163
|
-
Uint16(kwargs["inflation_ratio_committee_vs_reward_fund"]),
|
|
164
|
-
),
|
|
165
|
-
("inflation_recalc_period", Uint32(kwargs["inflation_recalc_period"])),
|
|
166
|
-
# chain_properties_hf6: version 2
|
|
167
|
-
(
|
|
168
|
-
"data_operations_cost_additional_bandwidth",
|
|
169
|
-
Uint32(kwargs["data_operations_cost_additional_bandwidth"]),
|
|
170
|
-
),
|
|
171
|
-
("validator_miss_penalty_percent", Uint16(kwargs["validator_miss_penalty_percent"])),
|
|
172
|
-
("validator_miss_penalty_duration", Uint32(kwargs["validator_miss_penalty_duration"])),
|
|
173
|
-
# chain_properties_hf9: version 3
|
|
174
|
-
("create_invite_min_balance", Amount(kwargs["create_invite_min_balance"])),
|
|
175
|
-
("committee_create_request_fee", Amount(kwargs["committee_create_request_fee"])),
|
|
176
|
-
("create_paid_subscription_fee", Amount(kwargs["create_paid_subscription_fee"])),
|
|
177
|
-
("account_on_sale_fee", Amount(kwargs["account_on_sale_fee"])),
|
|
178
|
-
("subaccount_on_sale_fee", Amount(kwargs["subaccount_on_sale_fee"])),
|
|
179
|
-
("validator_declaration_fee", Amount(kwargs["validator_declaration_fee"])),
|
|
180
|
-
("withdraw_intervals", Uint16(kwargs["withdraw_intervals"])),
|
|
181
|
-
]
|
|
182
|
-
)
|
|
183
|
-
)
|
|
263
|
+
super().__init__(OrderedDict(self._items(kwargs)))
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class ChainPropertiesHf13(ChainProperties):
|
|
267
|
+
"""versioned_chain_properties variant 4 (chain_properties_hf13)."""
|
|
268
|
+
|
|
269
|
+
_items = staticmethod(_chain_properties_hf13_items)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class ChainPropertiesPm(ChainProperties):
|
|
273
|
+
"""versioned_chain_properties variant 5 (chain_properties_pm, HF14/Onix)."""
|
|
274
|
+
|
|
275
|
+
_items = staticmethod(_chain_properties_pm_items)
|
|
184
276
|
|
|
185
277
|
|
|
186
278
|
class Op_wrapper(GrapheneObject):
|
vizbase/operationids.py
CHANGED
|
@@ -68,6 +68,53 @@ OPS = [
|
|
|
68
68
|
"target_account_sale",
|
|
69
69
|
"bid",
|
|
70
70
|
"outbid",
|
|
71
|
+
"set_reward_sharing",
|
|
72
|
+
"stakeholder_reward",
|
|
73
|
+
# HF14 Prediction Markets (Onix). Order = the single `operation` static_variant in
|
|
74
|
+
# libraries/protocol/include/graphene/protocol/operations.hpp on the `pm` branch; the
|
|
75
|
+
# variant index IS the consensus op-id. Virtual ops (never broadcast, no serializer) MUST
|
|
76
|
+
# stay listed in-place so the broadcastable ids keep their exact offsets.
|
|
77
|
+
"pm_oracle_register", # 66
|
|
78
|
+
"pm_oracle_update", # 67
|
|
79
|
+
"pm_create_market", # 68
|
|
80
|
+
"pm_oracle_accept_market", # 69
|
|
81
|
+
"pm_place_bet", # 70
|
|
82
|
+
"pm_commit_bet", # 71
|
|
83
|
+
"pm_reveal_bet", # 72
|
|
84
|
+
"pm_cancel_bet", # 73
|
|
85
|
+
"pm_add_liquidity", # 74
|
|
86
|
+
"pm_withdraw_liquidity", # 75
|
|
87
|
+
"pm_resolve_market", # 76
|
|
88
|
+
"pm_no_contest", # 77
|
|
89
|
+
"pm_dispute_create", # 78
|
|
90
|
+
"pm_dispute_vote", # 79
|
|
91
|
+
"pm_dispute_resolve", # 80
|
|
92
|
+
"pm_transfer_position", # 81
|
|
93
|
+
"pm_lazy_deposit", # 82
|
|
94
|
+
"pm_lazy_withdraw", # 83
|
|
95
|
+
"pm_batch_settle", # 84 (virtual)
|
|
96
|
+
"pm_commit_forfeit", # 85 (virtual)
|
|
97
|
+
"pm_auto_payout", # 86 (virtual)
|
|
98
|
+
"pm_dispute_finalize", # 87 (virtual)
|
|
99
|
+
"pm_dispute_auto_close", # 88 (virtual)
|
|
100
|
+
"pm_oracle_missed_penalty", # 89 (virtual)
|
|
101
|
+
"pm_lazy_recall", # 90 (virtual)
|
|
102
|
+
"pm_leverage_open", # 91
|
|
103
|
+
"pm_leverage_close", # 92
|
|
104
|
+
"pm_leverage_convert", # 93
|
|
105
|
+
"pm_leverage_liquidate", # 94 (virtual)
|
|
106
|
+
"pm_leverage_resolve", # 95 (virtual)
|
|
107
|
+
"pm_market_accepted", # 96 (virtual)
|
|
108
|
+
"pm_payout", # 97 (virtual)
|
|
109
|
+
"pm_dispute_oracle_respond", # 98
|
|
110
|
+
"pm_unban", # 99
|
|
111
|
+
"pm_ban_expired", # 100 (virtual)
|
|
112
|
+
"pm_market_expired", # 101 (virtual)
|
|
113
|
+
"pm_dispute_opened", # 102 (virtual)
|
|
114
|
+
"pm_early_exit_claim_paid", # 103 (virtual)
|
|
115
|
+
"pm_lp_payout", # 104 (virtual)
|
|
116
|
+
"set_agent_permission", # 105 (HF15)
|
|
117
|
+
"validator_equivocation", # 106 (virtual, HF16 QC)
|
|
71
118
|
]
|
|
72
119
|
operations = {o: OPS.index(o) for o in OPS}
|
|
73
120
|
|
|
@@ -100,4 +147,22 @@ VIRTUAL_OPS = [
|
|
|
100
147
|
"expire_escrow_ratification",
|
|
101
148
|
"bid",
|
|
102
149
|
"outbid",
|
|
150
|
+
"stakeholder_reward",
|
|
151
|
+
"pm_batch_settle",
|
|
152
|
+
"pm_commit_forfeit",
|
|
153
|
+
"pm_auto_payout",
|
|
154
|
+
"pm_dispute_finalize",
|
|
155
|
+
"pm_dispute_auto_close",
|
|
156
|
+
"pm_oracle_missed_penalty",
|
|
157
|
+
"pm_lazy_recall",
|
|
158
|
+
"pm_leverage_liquidate",
|
|
159
|
+
"pm_leverage_resolve",
|
|
160
|
+
"pm_market_accepted",
|
|
161
|
+
"pm_payout",
|
|
162
|
+
"pm_ban_expired",
|
|
163
|
+
"pm_market_expired",
|
|
164
|
+
"pm_dispute_opened",
|
|
165
|
+
"pm_early_exit_claim_paid",
|
|
166
|
+
"pm_lp_payout",
|
|
167
|
+
"validator_equivocation",
|
|
103
168
|
]
|
vizbase/operations.py
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import struct
|
|
2
3
|
import warnings
|
|
3
4
|
from collections import OrderedDict
|
|
4
5
|
|
|
5
6
|
from graphenebase.types import (
|
|
6
7
|
Array,
|
|
7
8
|
Bool,
|
|
9
|
+
Int16,
|
|
10
|
+
Int64,
|
|
8
11
|
Optional,
|
|
9
12
|
PointInTime,
|
|
13
|
+
Sha256,
|
|
10
14
|
String,
|
|
15
|
+
Uint8,
|
|
11
16
|
Uint16,
|
|
17
|
+
Uint32,
|
|
12
18
|
Uint64,
|
|
13
19
|
)
|
|
14
20
|
|
|
@@ -29,6 +35,20 @@ from .validator_compat import OP_FIELD_ALIASES, translate_kwargs
|
|
|
29
35
|
# libraries/protocol/include/graphene/protocol/chain_operations.hpp
|
|
30
36
|
|
|
31
37
|
|
|
38
|
+
class Int8:
|
|
39
|
+
"""Signed 8-bit integer. graphenebase.types has Uint8/Int16 but no Int8;
|
|
40
|
+
PM `side` fields are int8_t."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, d):
|
|
43
|
+
self.data = int(d)
|
|
44
|
+
|
|
45
|
+
def __bytes__(self):
|
|
46
|
+
return struct.pack("<b", int(self.data))
|
|
47
|
+
|
|
48
|
+
def __str__(self):
|
|
49
|
+
return f"{self.data}"
|
|
50
|
+
|
|
51
|
+
|
|
32
52
|
class _DeprecatedAlias:
|
|
33
53
|
"""Warn once-per-process on first instantiation of a deprecated class name."""
|
|
34
54
|
|
|
@@ -484,6 +504,573 @@ class Custom(GrapheneObject):
|
|
|
484
504
|
)
|
|
485
505
|
|
|
486
506
|
|
|
507
|
+
# ---------------------------------------------------------------------------
|
|
508
|
+
# HF14 Prediction Markets (Onix) operations.
|
|
509
|
+
#
|
|
510
|
+
# Field order and types are taken 1:1 from the FC_REFLECT macros in
|
|
511
|
+
# libraries/protocol/include/graphene/protocol/pm_operations.hpp on the node
|
|
512
|
+
# `pm` branch. Type mapping: account_name_type/string -> String, asset -> Amount,
|
|
513
|
+
# uint8_t -> Uint8, int8_t -> Int8, int16_t -> Int16, uint16_t -> Uint16,
|
|
514
|
+
# uint32_t -> Uint32, share_type/pm_object_id_type(int64) -> Int64, bool -> Bool,
|
|
515
|
+
# time_point_sec -> PointInTime, fc::sha256 -> Sha256, vector<string> -> Array,
|
|
516
|
+
# optional<T> -> Optional, extensions_type -> Array([]) (empty set).
|
|
517
|
+
# ---------------------------------------------------------------------------
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def _prep_kwargs(self, args, kwargs):
|
|
521
|
+
"""Shared preamble mirroring the other ops: copy-construct or unwrap a single dict."""
|
|
522
|
+
if isArgsThisClass(self, args):
|
|
523
|
+
return None
|
|
524
|
+
if len(args) == 1 and len(kwargs) == 0:
|
|
525
|
+
kwargs = args[0]
|
|
526
|
+
return kwargs
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
class Set_reward_sharing(GrapheneObject):
|
|
530
|
+
def __init__(self, *args, **kwargs):
|
|
531
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
532
|
+
if kw is None:
|
|
533
|
+
self.data = args[0].data
|
|
534
|
+
return
|
|
535
|
+
super().__init__(
|
|
536
|
+
OrderedDict(
|
|
537
|
+
[
|
|
538
|
+
("owner", String(kw["owner"])),
|
|
539
|
+
("sharing_rate", Uint16(kw["sharing_rate"])),
|
|
540
|
+
]
|
|
541
|
+
)
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
class Pm_oracle_register(GrapheneObject):
|
|
546
|
+
def __init__(self, *args, **kwargs):
|
|
547
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
548
|
+
if kw is None:
|
|
549
|
+
self.data = args[0].data
|
|
550
|
+
return
|
|
551
|
+
super().__init__(
|
|
552
|
+
OrderedDict(
|
|
553
|
+
[
|
|
554
|
+
("owner", String(kw["owner"])),
|
|
555
|
+
("insurance", Amount(kw["insurance"])),
|
|
556
|
+
("fee_percent", Uint16(kw.get("fee_percent", 0))),
|
|
557
|
+
("fixed_fee", Amount(kw["fixed_fee"])),
|
|
558
|
+
("rules_url", String(kw.get("rules_url", ""))),
|
|
559
|
+
("auto_accept_creator", String(kw.get("auto_accept_creator", ""))),
|
|
560
|
+
("auto_accept_resolver", String(kw.get("auto_accept_resolver", ""))),
|
|
561
|
+
("auto_accept", Bool(bool(kw.get("auto_accept", False)))),
|
|
562
|
+
("extensions", Array([])),
|
|
563
|
+
]
|
|
564
|
+
)
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
class Pm_oracle_update(GrapheneObject):
|
|
569
|
+
def __init__(self, *args, **kwargs):
|
|
570
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
571
|
+
if kw is None:
|
|
572
|
+
self.data = args[0].data
|
|
573
|
+
return
|
|
574
|
+
insurance_delta = Amount(kw["insurance_delta"]) if kw.get("insurance_delta") else None
|
|
575
|
+
fee_percent = Uint16(kw["fee_percent"]) if kw.get("fee_percent") is not None else None
|
|
576
|
+
fixed_fee = Amount(kw["fixed_fee"]) if kw.get("fixed_fee") else None
|
|
577
|
+
rules_url = String(kw["rules_url"]) if kw.get("rules_url") is not None else None
|
|
578
|
+
aac = String(kw["auto_accept_creator"]) if kw.get("auto_accept_creator") is not None else None
|
|
579
|
+
aar = String(kw["auto_accept_resolver"]) if kw.get("auto_accept_resolver") is not None else None
|
|
580
|
+
auto_accept = Bool(bool(kw["auto_accept"])) if kw.get("auto_accept") is not None else None
|
|
581
|
+
super().__init__(
|
|
582
|
+
OrderedDict(
|
|
583
|
+
[
|
|
584
|
+
("owner", String(kw["owner"])),
|
|
585
|
+
("insurance_delta", Optional(insurance_delta)),
|
|
586
|
+
("fee_percent", Optional(fee_percent)),
|
|
587
|
+
("fixed_fee", Optional(fixed_fee)),
|
|
588
|
+
("rules_url", Optional(rules_url)),
|
|
589
|
+
("auto_accept_creator", Optional(aac)),
|
|
590
|
+
("auto_accept_resolver", Optional(aar)),
|
|
591
|
+
("auto_accept", Optional(auto_accept)),
|
|
592
|
+
("extensions", Array([])),
|
|
593
|
+
]
|
|
594
|
+
)
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
class Pm_create_market(GrapheneObject):
|
|
599
|
+
def __init__(self, *args, **kwargs):
|
|
600
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
601
|
+
if kw is None:
|
|
602
|
+
self.data = args[0].data
|
|
603
|
+
return
|
|
604
|
+
meta = kw.get("metadata", "")
|
|
605
|
+
if isinstance(meta, (dict, list)):
|
|
606
|
+
meta = json.dumps(meta)
|
|
607
|
+
super().__init__(
|
|
608
|
+
OrderedDict(
|
|
609
|
+
[
|
|
610
|
+
("creator", String(kw["creator"])),
|
|
611
|
+
("oracle", String(kw["oracle"])),
|
|
612
|
+
("market_type", Uint8(kw.get("market_type", 0))),
|
|
613
|
+
("outcomes", Array([String(o) for o in kw["outcomes"]])),
|
|
614
|
+
("url", String(kw.get("url", ""))),
|
|
615
|
+
("oracle_fee_percent", Uint16(kw.get("oracle_fee_percent", 0))),
|
|
616
|
+
("oracle_fixed_fee", Amount(kw["oracle_fixed_fee"])),
|
|
617
|
+
("creator_fee_percent", Uint16(kw.get("creator_fee_percent", 0))),
|
|
618
|
+
("liquidity_fee_percent", Uint16(kw.get("liquidity_fee_percent", 0))),
|
|
619
|
+
("liquidity", Amount(kw["liquidity"])),
|
|
620
|
+
("lmsr_b", Int64(kw.get("lmsr_b", 0))),
|
|
621
|
+
("betting_expiration", PointInTime(kw["betting_expiration"])),
|
|
622
|
+
("result_expiration", PointInTime(kw["result_expiration"])),
|
|
623
|
+
("time_penalty_type", Uint8(kw.get("time_penalty_type", 0))),
|
|
624
|
+
("time_penalty_value", Uint32(kw.get("time_penalty_value", 0))),
|
|
625
|
+
("penalty_curve_type", Uint8(kw.get("penalty_curve_type", 0))),
|
|
626
|
+
("allow_early_resolution", Bool(bool(kw.get("allow_early_resolution", False)))),
|
|
627
|
+
("allow_cancellation", Bool(bool(kw.get("allow_cancellation", False)))),
|
|
628
|
+
("allow_batch", Bool(bool(kw.get("allow_batch", False)))),
|
|
629
|
+
("allow_instant_bet", Bool(bool(kw.get("allow_instant_bet", True)))),
|
|
630
|
+
("endogeneity_tier", Uint8(kw.get("endogeneity_tier", 2))),
|
|
631
|
+
("dispute_mode", Uint8(kw.get("dispute_mode", 0))),
|
|
632
|
+
("dispute_resolver", String(kw.get("dispute_resolver", ""))),
|
|
633
|
+
("dispute_penalty_percent", Int16(kw.get("dispute_penalty_percent", 0))),
|
|
634
|
+
("metadata", String(meta)),
|
|
635
|
+
("extensions", Array([])),
|
|
636
|
+
]
|
|
637
|
+
)
|
|
638
|
+
)
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
class Pm_oracle_accept_market(GrapheneObject):
|
|
642
|
+
def __init__(self, *args, **kwargs):
|
|
643
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
644
|
+
if kw is None:
|
|
645
|
+
self.data = args[0].data
|
|
646
|
+
return
|
|
647
|
+
super().__init__(
|
|
648
|
+
OrderedDict(
|
|
649
|
+
[
|
|
650
|
+
("oracle", String(kw["oracle"])),
|
|
651
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
652
|
+
("accept", Bool(bool(kw.get("accept", True)))),
|
|
653
|
+
("oracle_fee_percent", Uint16(kw.get("oracle_fee_percent", 0))),
|
|
654
|
+
("oracle_fixed_fee", Amount(kw["oracle_fixed_fee"])),
|
|
655
|
+
("extensions", Array([])),
|
|
656
|
+
]
|
|
657
|
+
)
|
|
658
|
+
)
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
class Pm_place_bet(GrapheneObject):
|
|
662
|
+
def __init__(self, *args, **kwargs):
|
|
663
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
664
|
+
if kw is None:
|
|
665
|
+
self.data = args[0].data
|
|
666
|
+
return
|
|
667
|
+
super().__init__(
|
|
668
|
+
OrderedDict(
|
|
669
|
+
[
|
|
670
|
+
("account", String(kw["account"])),
|
|
671
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
672
|
+
("side", Int8(kw.get("side", -1))),
|
|
673
|
+
("outcome_index", Int16(kw.get("outcome_index", -1))),
|
|
674
|
+
("amount", Amount(kw["amount"])),
|
|
675
|
+
("min_tokens", Int64(kw.get("min_tokens", 0))),
|
|
676
|
+
("mode", Uint8(kw.get("mode", 0))),
|
|
677
|
+
("extensions", Array([])),
|
|
678
|
+
]
|
|
679
|
+
)
|
|
680
|
+
)
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
class Pm_commit_bet(GrapheneObject):
|
|
684
|
+
def __init__(self, *args, **kwargs):
|
|
685
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
686
|
+
if kw is None:
|
|
687
|
+
self.data = args[0].data
|
|
688
|
+
return
|
|
689
|
+
super().__init__(
|
|
690
|
+
OrderedDict(
|
|
691
|
+
[
|
|
692
|
+
("account", String(kw["account"])),
|
|
693
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
694
|
+
("commitment", Sha256(kw["commitment"])),
|
|
695
|
+
("escrow_amount", Amount(kw["escrow_amount"])),
|
|
696
|
+
("no_reveal_fee_percent", Uint16(kw.get("no_reveal_fee_percent", 0))),
|
|
697
|
+
("extensions", Array([])),
|
|
698
|
+
]
|
|
699
|
+
)
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
class Pm_reveal_bet(GrapheneObject):
|
|
704
|
+
def __init__(self, *args, **kwargs):
|
|
705
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
706
|
+
if kw is None:
|
|
707
|
+
self.data = args[0].data
|
|
708
|
+
return
|
|
709
|
+
super().__init__(
|
|
710
|
+
OrderedDict(
|
|
711
|
+
[
|
|
712
|
+
("account", String(kw["account"])),
|
|
713
|
+
("commit_id", Int64(kw.get("commit_id", 0))),
|
|
714
|
+
("side", Int8(kw.get("side", -1))),
|
|
715
|
+
("outcome_index", Int16(kw.get("outcome_index", -1))),
|
|
716
|
+
("amount", Amount(kw["amount"])),
|
|
717
|
+
("salt", String(kw.get("salt", ""))),
|
|
718
|
+
("min_tokens", Int64(kw.get("min_tokens", 0))),
|
|
719
|
+
("extensions", Array([])),
|
|
720
|
+
]
|
|
721
|
+
)
|
|
722
|
+
)
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
class Pm_cancel_bet(GrapheneObject):
|
|
726
|
+
def __init__(self, *args, **kwargs):
|
|
727
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
728
|
+
if kw is None:
|
|
729
|
+
self.data = args[0].data
|
|
730
|
+
return
|
|
731
|
+
super().__init__(
|
|
732
|
+
OrderedDict(
|
|
733
|
+
[
|
|
734
|
+
("account", String(kw["account"])),
|
|
735
|
+
("bet_id", Int64(kw.get("bet_id", 0))),
|
|
736
|
+
("min_return", Int64(kw.get("min_return", 0))),
|
|
737
|
+
("extensions", Array([])),
|
|
738
|
+
]
|
|
739
|
+
)
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
class Pm_add_liquidity(GrapheneObject):
|
|
744
|
+
def __init__(self, *args, **kwargs):
|
|
745
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
746
|
+
if kw is None:
|
|
747
|
+
self.data = args[0].data
|
|
748
|
+
return
|
|
749
|
+
super().__init__(
|
|
750
|
+
OrderedDict(
|
|
751
|
+
[
|
|
752
|
+
("provider", String(kw["provider"])),
|
|
753
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
754
|
+
("amount", Amount(kw["amount"])),
|
|
755
|
+
("extensions", Array([])),
|
|
756
|
+
]
|
|
757
|
+
)
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
class Pm_withdraw_liquidity(GrapheneObject):
|
|
762
|
+
def __init__(self, *args, **kwargs):
|
|
763
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
764
|
+
if kw is None:
|
|
765
|
+
self.data = args[0].data
|
|
766
|
+
return
|
|
767
|
+
super().__init__(
|
|
768
|
+
OrderedDict(
|
|
769
|
+
[
|
|
770
|
+
("provider", String(kw["provider"])),
|
|
771
|
+
("liquidity_id", Int64(kw.get("liquidity_id", 0))),
|
|
772
|
+
("amount", Amount(kw["amount"])),
|
|
773
|
+
("extensions", Array([])),
|
|
774
|
+
]
|
|
775
|
+
)
|
|
776
|
+
)
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
class Pm_resolve_market(GrapheneObject):
|
|
780
|
+
def __init__(self, *args, **kwargs):
|
|
781
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
782
|
+
if kw is None:
|
|
783
|
+
self.data = args[0].data
|
|
784
|
+
return
|
|
785
|
+
super().__init__(
|
|
786
|
+
OrderedDict(
|
|
787
|
+
[
|
|
788
|
+
("oracle", String(kw["oracle"])),
|
|
789
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
790
|
+
("winning_outcome", Int16(kw.get("winning_outcome", -1))),
|
|
791
|
+
("decision_url", String(kw.get("decision_url", ""))),
|
|
792
|
+
("decision_reason", String(kw.get("decision_reason", ""))),
|
|
793
|
+
("extensions", Array([])),
|
|
794
|
+
]
|
|
795
|
+
)
|
|
796
|
+
)
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
class Pm_no_contest(GrapheneObject):
|
|
800
|
+
def __init__(self, *args, **kwargs):
|
|
801
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
802
|
+
if kw is None:
|
|
803
|
+
self.data = args[0].data
|
|
804
|
+
return
|
|
805
|
+
super().__init__(
|
|
806
|
+
OrderedDict(
|
|
807
|
+
[
|
|
808
|
+
("oracle", String(kw["oracle"])),
|
|
809
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
810
|
+
("reason", String(kw.get("reason", ""))),
|
|
811
|
+
("extensions", Array([])),
|
|
812
|
+
]
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
class Pm_dispute_create(GrapheneObject):
|
|
818
|
+
def __init__(self, *args, **kwargs):
|
|
819
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
820
|
+
if kw is None:
|
|
821
|
+
self.data = args[0].data
|
|
822
|
+
return
|
|
823
|
+
super().__init__(
|
|
824
|
+
OrderedDict(
|
|
825
|
+
[
|
|
826
|
+
("disputer", String(kw["disputer"])),
|
|
827
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
828
|
+
("proposed_outcome", Int16(kw.get("proposed_outcome", -1))),
|
|
829
|
+
("reason", String(kw.get("reason", ""))),
|
|
830
|
+
("extensions", Array([])),
|
|
831
|
+
]
|
|
832
|
+
)
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
class Pm_dispute_vote(GrapheneObject):
|
|
837
|
+
def __init__(self, *args, **kwargs):
|
|
838
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
839
|
+
if kw is None:
|
|
840
|
+
self.data = args[0].data
|
|
841
|
+
return
|
|
842
|
+
super().__init__(
|
|
843
|
+
OrderedDict(
|
|
844
|
+
[
|
|
845
|
+
("voter", String(kw["voter"])),
|
|
846
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
847
|
+
("vote_outcome", Int16(kw.get("vote_outcome", -1))),
|
|
848
|
+
("vote_percent", Int16(kw.get("vote_percent", 0))),
|
|
849
|
+
("extensions", Array([])),
|
|
850
|
+
]
|
|
851
|
+
)
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
class Pm_dispute_resolve(GrapheneObject):
|
|
856
|
+
def __init__(self, *args, **kwargs):
|
|
857
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
858
|
+
if kw is None:
|
|
859
|
+
self.data = args[0].data
|
|
860
|
+
return
|
|
861
|
+
super().__init__(
|
|
862
|
+
OrderedDict(
|
|
863
|
+
[
|
|
864
|
+
("resolver", String(kw["resolver"])),
|
|
865
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
866
|
+
("correct_outcome", Int16(kw.get("correct_outcome", -1))),
|
|
867
|
+
("penalty_amount", Amount(kw["penalty_amount"])),
|
|
868
|
+
("ban_oracle", Bool(bool(kw.get("ban_oracle", False)))),
|
|
869
|
+
("ban_oracle_until", PointInTime(kw["ban_oracle_until"])),
|
|
870
|
+
("ban_creator", Bool(bool(kw.get("ban_creator", False)))),
|
|
871
|
+
("ban_creator_until", PointInTime(kw["ban_creator_until"])),
|
|
872
|
+
("extensions", Array([])),
|
|
873
|
+
]
|
|
874
|
+
)
|
|
875
|
+
)
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
class Pm_transfer_position(GrapheneObject):
|
|
879
|
+
def __init__(self, *args, **kwargs):
|
|
880
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
881
|
+
if kw is None:
|
|
882
|
+
self.data = args[0].data
|
|
883
|
+
return
|
|
884
|
+
super().__init__(
|
|
885
|
+
OrderedDict(
|
|
886
|
+
[
|
|
887
|
+
("from", String(kw["from"])),
|
|
888
|
+
("bet_id", Int64(kw.get("bet_id", 0))),
|
|
889
|
+
("to", String(kw["to"])),
|
|
890
|
+
("amount", Int64(kw.get("amount", 0))),
|
|
891
|
+
("memo", String(kw.get("memo", ""))),
|
|
892
|
+
("extensions", Array([])),
|
|
893
|
+
]
|
|
894
|
+
)
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
class Pm_lazy_deposit(GrapheneObject):
|
|
899
|
+
def __init__(self, *args, **kwargs):
|
|
900
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
901
|
+
if kw is None:
|
|
902
|
+
self.data = args[0].data
|
|
903
|
+
return
|
|
904
|
+
super().__init__(
|
|
905
|
+
OrderedDict(
|
|
906
|
+
[
|
|
907
|
+
("account", String(kw["account"])),
|
|
908
|
+
("amount", Amount(kw["amount"])),
|
|
909
|
+
("extensions", Array([])),
|
|
910
|
+
]
|
|
911
|
+
)
|
|
912
|
+
)
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
class Pm_lazy_withdraw(GrapheneObject):
|
|
916
|
+
def __init__(self, *args, **kwargs):
|
|
917
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
918
|
+
if kw is None:
|
|
919
|
+
self.data = args[0].data
|
|
920
|
+
return
|
|
921
|
+
super().__init__(
|
|
922
|
+
OrderedDict(
|
|
923
|
+
[
|
|
924
|
+
("account", String(kw["account"])),
|
|
925
|
+
("shares", Int64(kw.get("shares", 0))),
|
|
926
|
+
("emergency", Bool(bool(kw.get("emergency", False)))),
|
|
927
|
+
("extensions", Array([])),
|
|
928
|
+
]
|
|
929
|
+
)
|
|
930
|
+
)
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
class Pm_leverage_open(GrapheneObject):
|
|
934
|
+
def __init__(self, *args, **kwargs):
|
|
935
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
936
|
+
if kw is None:
|
|
937
|
+
self.data = args[0].data
|
|
938
|
+
return
|
|
939
|
+
super().__init__(
|
|
940
|
+
OrderedDict(
|
|
941
|
+
[
|
|
942
|
+
("account", String(kw["account"])),
|
|
943
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
944
|
+
("outcome_index", Int16(kw.get("outcome_index", 0))),
|
|
945
|
+
("collateral", Amount(kw["collateral"])),
|
|
946
|
+
("loan", Amount(kw["loan"])),
|
|
947
|
+
("min_tokens", Int64(kw.get("min_tokens", 0))),
|
|
948
|
+
("max_slippage_percent", Uint16(kw.get("max_slippage_percent", 0))),
|
|
949
|
+
("extensions", Array([])),
|
|
950
|
+
]
|
|
951
|
+
)
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
class Pm_leverage_close(GrapheneObject):
|
|
956
|
+
def __init__(self, *args, **kwargs):
|
|
957
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
958
|
+
if kw is None:
|
|
959
|
+
self.data = args[0].data
|
|
960
|
+
return
|
|
961
|
+
super().__init__(
|
|
962
|
+
OrderedDict(
|
|
963
|
+
[
|
|
964
|
+
("account", String(kw["account"])),
|
|
965
|
+
("position_id", Int64(kw.get("position_id", 0))),
|
|
966
|
+
("min_return", Int64(kw.get("min_return", 0))),
|
|
967
|
+
("extensions", Array([])),
|
|
968
|
+
]
|
|
969
|
+
)
|
|
970
|
+
)
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
class Pm_leverage_convert(GrapheneObject):
|
|
974
|
+
def __init__(self, *args, **kwargs):
|
|
975
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
976
|
+
if kw is None:
|
|
977
|
+
self.data = args[0].data
|
|
978
|
+
return
|
|
979
|
+
super().__init__(
|
|
980
|
+
OrderedDict(
|
|
981
|
+
[
|
|
982
|
+
("account", String(kw["account"])),
|
|
983
|
+
("position_id", Int64(kw.get("position_id", 0))),
|
|
984
|
+
("conversion_profit_cost", Uint16(kw.get("conversion_profit_cost", 0))),
|
|
985
|
+
("extensions", Array([])),
|
|
986
|
+
]
|
|
987
|
+
)
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
class Pm_dispute_oracle_respond(GrapheneObject):
|
|
992
|
+
def __init__(self, *args, **kwargs):
|
|
993
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
994
|
+
if kw is None:
|
|
995
|
+
self.data = args[0].data
|
|
996
|
+
return
|
|
997
|
+
super().__init__(
|
|
998
|
+
OrderedDict(
|
|
999
|
+
[
|
|
1000
|
+
("oracle", String(kw["oracle"])),
|
|
1001
|
+
("market_id", Int64(kw.get("market_id", 0))),
|
|
1002
|
+
("response", String(kw.get("response", ""))),
|
|
1003
|
+
("extensions", Array([])),
|
|
1004
|
+
]
|
|
1005
|
+
)
|
|
1006
|
+
)
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
class Pm_unban(GrapheneObject):
|
|
1010
|
+
def __init__(self, *args, **kwargs):
|
|
1011
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
1012
|
+
if kw is None:
|
|
1013
|
+
self.data = args[0].data
|
|
1014
|
+
return
|
|
1015
|
+
super().__init__(
|
|
1016
|
+
OrderedDict(
|
|
1017
|
+
[
|
|
1018
|
+
("resolver", String(kw["resolver"])),
|
|
1019
|
+
("target", String(kw["target"])),
|
|
1020
|
+
("unban_oracle", Bool(bool(kw.get("unban_oracle", False)))),
|
|
1021
|
+
("unban_creator", Bool(bool(kw.get("unban_creator", False)))),
|
|
1022
|
+
("extensions", Array([])),
|
|
1023
|
+
]
|
|
1024
|
+
)
|
|
1025
|
+
)
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
class Set_agent_permission(GrapheneObject):
|
|
1029
|
+
"""105 — HF15 agent access (active: account). Empty operations and addons =
|
|
1030
|
+
revoke; expiration epoch = perpetual. Sets are flat_set<string> on the node,
|
|
1031
|
+
so they are sorted and de-duplicated before serialization."""
|
|
1032
|
+
|
|
1033
|
+
def __init__(self, *args, **kwargs):
|
|
1034
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
1035
|
+
if kw is None:
|
|
1036
|
+
self.data = args[0].data
|
|
1037
|
+
return
|
|
1038
|
+
prefix = kw.get("prefix", DEFAULT_PREFIX)
|
|
1039
|
+
super().__init__(
|
|
1040
|
+
OrderedDict(
|
|
1041
|
+
[
|
|
1042
|
+
("account", String(kw["account"])),
|
|
1043
|
+
("agent_name", String(kw["agent_name"])),
|
|
1044
|
+
("agent_key", PublicKey(kw["agent_key"], prefix=prefix)),
|
|
1045
|
+
("operations", Array([String(o) for o in sorted(set(kw.get("operations") or []))])),
|
|
1046
|
+
("expiration", PointInTime(kw.get("expiration") or "1970-01-01T00:00:00")),
|
|
1047
|
+
("addons", Array([String(a) for a in sorted(set(kw.get("addons") or []))])),
|
|
1048
|
+
("extensions", Array([])),
|
|
1049
|
+
]
|
|
1050
|
+
)
|
|
1051
|
+
)
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
class Committee_worker_create_request(GrapheneObject):
|
|
1055
|
+
"""DAO request. HF16's supply-dependent ceiling is enforced by the node."""
|
|
1056
|
+
|
|
1057
|
+
def __init__(self, *args, **kwargs):
|
|
1058
|
+
kw = _prep_kwargs(self, args, kwargs)
|
|
1059
|
+
if kw is None:
|
|
1060
|
+
self.data = args[0].data
|
|
1061
|
+
return
|
|
1062
|
+
super().__init__(
|
|
1063
|
+
OrderedDict([
|
|
1064
|
+
("creator", String(kw["creator"])),
|
|
1065
|
+
("url", String(kw["url"])),
|
|
1066
|
+
("worker", String(kw["worker"])),
|
|
1067
|
+
("required_amount_min", Amount(kw["required_amount_min"])),
|
|
1068
|
+
("required_amount_max", Amount(kw["required_amount_max"])),
|
|
1069
|
+
("duration", Uint32(kw["duration"])),
|
|
1070
|
+
])
|
|
1071
|
+
)
|
|
1072
|
+
|
|
1073
|
+
|
|
487
1074
|
# Deprecated witness-named aliases. Subclasses that warn once per process
|
|
488
1075
|
# on first instantiation. Remove during Phase C cleanup.
|
|
489
1076
|
Witness_update = _DeprecatedAlias.make("Witness_update", Validator_update)
|
|
File without changes
|