Skip to content
Snippets Groups Projects
Commit a02405ca authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'mt-update-proposal-fix' into 'master'

Extension in 'update_proposal' is internally created

See merge request !6
parents ba671227 b26eb7ed
No related branches found
No related tags found
1 merge request!6Extension in 'update_proposal' is internally created
......@@ -228,3 +228,57 @@ class RC(object):
execution_time_count = resource_execution_time["account_update_operation_exec_time"]
resource_count = self.get_resource_count(tx_size, execution_time_count, state_bytes_count)
return self.blockchain.get_rc_cost(resource_count)
def set_slot_delegator(self, from_pool, to_account, to_slot, signer):
""" Set a slot to receive RC from a pool
:param str from_pool: Pool to set the slot to
:param str to_account: Account on which we want to update the slot
:param int to_slot: slot we want to set
:param str signer: Account who broadcast this
"""
json_body = [
'set_slot_delegator', {
'from_pool': from_pool,
'to_account': to_account,
'to_slot': to_slot,
'signer': signer,
}
]
return self.blockchain.custom_json(
"rc", json_body, required_auths=[signer])
def delegate_from_pool(self, from_pool, to_account, max_rc):
""" Set a slot to receive RC from a pool
:param str from_pool: Pool to set the slot to
:param str to_account: Account on which we want to update the slot
:param int max_rc: max rc to delegate
"""
json_body = [
'delegate_drc_from_pool', {
'from_pool': from_pool,
'to_account': to_account,
'asset_symbol': {'nai': "@@000000037", 'decimals': 6},
"drc_max_mana": max_rc,
}
]
return self.blockchain.custom_json(
"rc", json_body, required_auths=[from_pool])
def delegate_to_pool(self, username, to_pool, rc):
""" Set a slot to receive RC from a pool
:param str username: user delegating rc to the pool
:param str to_pool: Pool to delegate to
:param str rc: rc to delegate
"""
json_body = [
'delegate_to_pool', {
'from_account': username,
'to_pool': to_pool,
'amount': {'symbol': "VESTS", 'amount': rc, 'precision': 6, 'nai': '@@000000037'},
}
]
return self.blockchain.custom_json(
"rc", json_body, required_auths=[username])
\ No newline at end of file
......@@ -358,10 +358,12 @@ class UpdateProposalExtensions(Static_variant):
"""
def __init__(self, o):
if isinstance(o, dict) and 'type' in o and 'value' in o:
if o['type'] == "update_proposal_end_date":
type_id = 1
else:
type_id = ~0
if o['type'] == "update_proposal_end_date":
type_id = 1
else:
type_id = ~0
else:
type_id, data = o
if type_id == 1:
data = (UpdateProposalEndDate(o['value']))
......
......@@ -402,8 +402,9 @@ class Update_proposal(GrapheneObject):
prefix = kwargs.get("prefix", default_prefix)
extensions = Array([])
if "extensions" in kwargs and kwargs["extensions"]:
extensions = Array([UpdateProposalExtensions(o) for o in kwargs["extensions"]])
if "end_date" in kwargs and kwargs["end_date"]:
extension = { 'type': 'update_proposal_end_date', 'value': {'end_date': kwargs["end_date"]} }
extensions = Array([UpdateProposalExtensions(extension)])
super(Update_proposal, self).__init__(
......
......@@ -7,8 +7,8 @@ requests==2.25.1
websocket-client==0.58.0
pytz==2021.1
pycryptodomex==3.10.1
scrypt==0.8.17
cryptography==3.4.6
scrypt==0.8.18
cryptography==3.4.7
ruamel.yaml
mock==4.0.3
appdirs==1.4.4
......@@ -16,7 +16,7 @@ Click==7.1.2
click_shell>=2.0
prettytable
pycodestyle==2.7.0
pyflakes==2.3.0
pyflakes==2.3.1
pylibscrypt==2.0.0
six==1.15.0
pytest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment