diff --git a/beem/rc.py b/beem/rc.py index dc04a43c6f8556fbed187010d052ad6282827f21..c241602f0e6a5de558d45c2b7459bcd48c454958 100644 --- a/beem/rc.py +++ b/beem/rc.py @@ -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 diff --git a/beembase/objects.py b/beembase/objects.py index 0b712c1df26e4e07269be646431902ef83ae6055..586eeb3f43ec250418a6bbe1a340130b7327cc59 100644 --- a/beembase/objects.py +++ b/beembase/objects.py @@ -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'])) diff --git a/beembase/operations.py b/beembase/operations.py index 41e40ab015a1fa548652b2459b90956ca679b14b..126024a93a997c8a6507d02ad81e2284d1dec18c 100644 --- a/beembase/operations.py +++ b/beembase/operations.py @@ -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__( diff --git a/requirements-test.txt b/requirements-test.txt index 601a6e1a035fe5d0c9baabe11812a72dbe671fa5..e0a3962289d7c7ca35541b5a1afee80fc64d9139 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -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