beem is now AppBase ready

beem has now 10,948 lines of code, 204 unit tests and a coverage of 70%. The current version is 0.19.12. beem is now ready for AppBase testing. I implemented most api calls natively (without using condenser_api). You an run the print_appbase_calls.py from the example directory of beem. You can find it on github. beem can now handle websocket and https node addresses simultanously. You can mix both type of addresses in the node list.

AppBase

1
2
3
4
5
6
from beem.steem import Steem
stm = Steem(node="https://api.steemitstage.com")
stm.rpc.get_signature({"method": "block_api.get_block"}, api="jsonrpc")
{'args': {'block_num': 0}, 'ret': {}}
stm.rpc.get_block({"block_num": 1}, api="block")
{'block': {'previous': '0000000000000000000000000000000000000000', 'timestamp': '2016-03-24T16:05:00', 'witness': 'initminer', 'transaction_merkle_root': '0000000000000000000000000000000000000000', 'extensions': [], 'witness_signature': '204f8ad56a8f5cf722a02b035a61b500aa59b9519b2c33c77a80c0a714680a5a5a7a340d909d19996613c5e4ae92146b9add8a7a663eef37d837ef881477313043', 'transactions': [], 'block_id': '0000000109833ce528d5bbfb3f6225b39ee10086', 'signing_key': 'STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX', 'transaction_ids': []}}

You can also use the node from timcliff (this node has no block_api):

1
2
3
4
from beem.steem import Steem
stm = Steem(node="wss://appbasetest.timcliff.com")
stm.get_config()["STEEM_BLOCKCHAIN_VERSION"]
'0.19.4'

You can use the condenser api to be compatible with calls before 0.19.4. In order to enable this, set appbase to False in Steem.

1
2
stm = Steem(node="wss://appbasetest.timcliff.com", appbase=False)
stm.rpc.get_accounts(["holger80"])

The rpc calls are handled in the background in all classes. New AppBase-calls are used when, the node version is 0.19.4 and when steem.appbase is set to True (default).

The new assets are also handled:

1
2
3
4
5
6
7
8
9
from beem.steem import Steem
from beem.amount import Amount
stm = Steem(node="https://api.steemitstage.com")
stm.get_current_median_history()
{'base': ['3424', 3, '@@000000013'], 'quote': ['1000', 3, '@@000000021']}
a = Amount(stm.get_current_median_history()['base'], steem_instance=stm)
3.424 SBD
Amount(stm.get_current_median_history()['quote'], steem_instance=stm)
1.000 STEEM

Changes

Code improvements and new examples added



Posted on Utopian.io - Rewarding Open Source Contributors