diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6978ca349022311b5abb93a1f39fefd4c86ca71e..de363f7cd9ec3e0ba5995c9808de80e9f3734a81 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,9 @@ Changelog * Add claimaccount to beempy and some improvements for steem.sbd_symbol * newaccount adapted for HF20 and can be used to create claimed account * Correct operationids for WLS +* Improve steem.refresh_data() reading +* Set network prefix in Signed_Transaction and Operation for using the correct operationids +* Fix test_block unit test 0.20.6 ------ diff --git a/beem/steem.py b/beem/steem.py index 5dc798329059b0029f089ba95756556784eb22f3..d47a940e41b6e996505faa8afaf2df57e3aeefd4 100644 --- a/beem/steem.py +++ b/beem/steem.py @@ -273,12 +273,18 @@ class Steem(object): except: self.data['feed_history'] = None self.data['get_feed_history'] = None - self.data['hardfork_properties'] = self.get_hardfork_properties(False) + try: + self.data['hardfork_properties'] = self.get_hardfork_properties(False) + except: + self.data['hardfork_properties'] = None self.data['network'] = self.get_network(False) self.data['witness_schedule'] = self.get_witness_schedule(False) self.data['config'] = self.get_config(False) self.data['reward_funds'] = self.get_reward_funds(False) - self.data['reserve_ratio'] = self.get_reserve_ratio(False) + try: + self.data['reserve_ratio'] = self.get_reserve_ratio(False) + except: + self.data['reserve_ratio'] = None def get_dynamic_global_properties(self, use_stored_data=True): """ This call returns the *dynamic global properties* @@ -350,7 +356,11 @@ class Steem(object): ret = None self.rpc.set_next_node_on_empty_reply(True) if self.rpc.get_use_appbase(): - funds = self.rpc.get_reward_funds(api="database")['funds'] + funds = self.rpc.get_reward_funds(api="database") + if funds is not None: + funds = funds['funds'] + else: + return None if len(funds) > 0: funds = funds[0] ret = funds @@ -390,7 +400,7 @@ class Steem(object): if self.rpc is None: return None ret = None - # self.rpc.set_next_node_on_empty_reply(True) + self.rpc.set_next_node_on_empty_reply(True) if self.rpc.get_use_appbase(): ret = self.rpc.get_hardfork_properties(api="database") else: diff --git a/beem/transactionbuilder.py b/beem/transactionbuilder.py index a1487e1581bd7cf132f59f2db97e5b27a653b889..79b24b740303002e7f80d32a1f7551d2fd081d7d 100644 --- a/beem/transactionbuilder.py +++ b/beem/transactionbuilder.py @@ -120,12 +120,15 @@ class TransactionBuilder(dict): """ return self - def json(self): + def json(self, with_prefix=False): """ Show the transaction as plain json """ if not self._is_constructed() or self._is_require_reconstruction(): self.constructTx() - return dict(self) + json_dict = dict(self) + if with_prefix: + json_dict["prefix"] = self.steem.prefix + return json_dict def appendOps(self, ops, append_to=None): """ Append op(s) to the transaction builder @@ -294,7 +297,7 @@ class TransactionBuilder(dict): operations.default_prefix = self["blockchain"]["prefix"] try: - signedtx = Signed_Transaction(**self.json(), prefix=self.steem.prefix) + signedtx = Signed_Transaction(**self.json(with_prefix=True)) signedtx.add_custom_chains(self.steem.custom_chains) except: raise ValueError("Invalid TransactionBuilder Format") diff --git a/beemgraphenebase/signedtransactions.py b/beemgraphenebase/signedtransactions.py index 4878641ae016b45c51ca10968737a2f779cf43e2..1af5aa897da124c2db49f131ae453de39cd5847e 100644 --- a/beemgraphenebase/signedtransactions.py +++ b/beemgraphenebase/signedtransactions.py @@ -50,7 +50,7 @@ class Signed_Transaction(GrapheneObject): else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] - prefix = kwargs.get("prefix", "STM") + prefix = kwargs.pop("prefix", "STM") if "extensions" not in kwargs: kwargs["extensions"] = Set([]) elif not kwargs.get("extensions"): diff --git a/tests/beem/test_block.py b/tests/beem/test_block.py index 6cb638f5aa39a070dd98a497dcd77819eacac0e7..e5af5c4f3f60cbaaf4a0c5dc1c9db298b495892b 100644 --- a/tests/beem/test_block.py +++ b/tests/beem/test_block.py @@ -65,17 +65,9 @@ class Testcases(unittest.TestCase): ): Block(0, steem_instance=bts) - @parameterized.expand([ - ("normal"), - ("testnet"), - ]) - def test_block_only_ops(self, node_param): - if node_param == "normal": - bts = self.bts - test_block_id = self.test_block_id - else: - bts = self.testnet - test_block_id = self.test_block_id_testnet + def test_block_only_ops(self): + bts = self.bts + test_block_id = self.test_block_id block = Block(test_block_id, only_ops=True, steem_instance=bts) self.assertEqual(block.identifier, test_block_id) self.assertTrue(isinstance(block.time(), datetime)) @@ -114,17 +106,9 @@ class Testcases(unittest.TestCase): ): BlockHeader(0, steem_instance=bts) - @parameterized.expand([ - ("normal"), - ("testnet"), - ]) - def test_export(self, node_param): - if node_param == "normal": - bts = self.bts - block_num = 2000000 - else: - bts = self.testnet - block_num = 2 + def test_export(self): + bts = self.bts + block_num = 2000000 if bts.rpc.get_use_appbase(): block = bts.rpc.get_block({"block_num": block_num}, api="block")