diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 887958c72d6bcf1cc95f8a0242bd21a1ae377e84..8e5b0fe5243e4fda2926788fb378849042b74c62 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,16 @@ Changelog ========= +0.23.9 +------ +* Improve chain detection (Steem chain detection fixed and preparing for Hive HF24) +* Add authored_by and description fields in YAMLM header +* Improve doc +* beempy post image upload includes the markdown file path now + +0.23.8 +------ +* Missing dongle.close() added (thanks to @netuoso) + 0.23.7 ------ * Fix update_account_jsonmetadata and add posting_json_metadata property to Account diff --git a/beem/cli.py b/beem/cli.py index 7c06d755a77ff8b4315640e24a831d24852210b0..60b1b4df567b5d489d07121a9a73fa3e91e3843d 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -2169,6 +2169,10 @@ def download(permlink, account, save, export): yaml_prefix += 'title: "%s"\n' % comment["title"] yaml_prefix += 'permlink: %s\n' % comment["permlink"] yaml_prefix += 'author: %s\n' % comment["author"] + if "author" in comment.json_metadata: + yaml_prefix += 'authored by: %s\n' % comment.json_metadata["author"] + if "description" in comment.json_metadata: + yaml_prefix += 'description: "%s"\n' % comment.json_metadata["description"] yaml_prefix += 'last_update: %s\n' % comment.json()["last_update"] yaml_prefix += 'max_accepted_payout: %s\n' % str(comment["max_accepted_payout"]) yaml_prefix += 'percent_steem_dollars: %s\n' % str(comment["percent_steem_dollars"]) @@ -2299,7 +2303,11 @@ def post(markdown_file, account, title, permlink, tags, reply_identifier, commun beneficiaries = derive_beneficiaries(parameter["beneficiaries"]) for b in beneficiaries: Account(b["account"], blockchain_instance=stm) - + json_metadata = {} + if "authored_by" in parameter: + json_metadata["authored_by"] = parameter["authored_by"] + if "description" in parameter: + json_metadata["description"] = parameter["description"] if permlink is not None: try: comment = Comment(construct_authorperm(author, permlink), blockchain_instance=stm) @@ -2316,10 +2324,13 @@ def post(markdown_file, account, title, permlink, tags, reply_identifier, commun continue if stm.unsigned: continue + basepath = os.path.dirname(markdown_file) if os.path.exists(image): tx = iu.upload(image, author, image_name) body = body.replace(image, tx["url"]) - + elif os.path.exists(os.path.join(basepath, image)): + tx = iu.upload(image, author, image_name) + body = body.replace(image, tx["url"]) if comment is None and permlink is None and reply_identifier is None: permlink = derive_permlink(title, with_suffix=False) @@ -2333,7 +2344,7 @@ def post(markdown_file, account, title, permlink, tags, reply_identifier, commun if reply_identifier is None and (len(tags) == 0 or tags is None): raise ValueError("Tags must not be empty!") tx = stm.post(title, body, author=author, permlink=permlink, reply_identifier=reply_identifier, community=community, - tags=tags, comment_options=comment_options, beneficiaries=beneficiaries, parse_body=parse_body, + tags=tags, json_metadata=json_metadata, comment_options=comment_options, beneficiaries=beneficiaries, parse_body=parse_body, app='beempy/%s' % (__version__)) else: import diff_match_patch as dmp_module diff --git a/beem/version.py b/beem/version.py index 807d3748088d9fa8a2180e86f12af0d6ea504966..c583e868fe2ea14bc70ca94e6510a0c11f8ccb12 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.7' +version = '0.23.9' diff --git a/beemapi/graphenerpc.py b/beemapi/graphenerpc.py index 61ef1cdfefbf8b4f18881a9fe8c08dc50cf28a42..e5c0064064d14f1ac0a86a4f8584516bf3f0b8f0 100644 --- a/beemapi/graphenerpc.py +++ b/beemapi/graphenerpc.py @@ -315,10 +315,12 @@ class GrapheneRPC(object): if chain_id is None: raise("Connecting to unknown network!") - if is_hive: - return self.known_chains["HIVE"] highest_version_chain = None for k, v in list(self.known_chains.items()): + if is_hive and k not in ["HIVE", "HIVE2"]: + continue + if is_steem and k not in ["STEEMZERO", "STEEM", "STEEMAPPBASE"]: + continue if v["chain_id"] == chain_id and self.version_string_to_int(v["min_version"]) <= self.version_string_to_int(network_version): if highest_version_chain is None: highest_version_chain = v diff --git a/beemapi/version.py b/beemapi/version.py index 807d3748088d9fa8a2180e86f12af0d6ea504966..c583e868fe2ea14bc70ca94e6510a0c11f8ccb12 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.7' +version = '0.23.9' diff --git a/beembase/version.py b/beembase/version.py index 807d3748088d9fa8a2180e86f12af0d6ea504966..c583e868fe2ea14bc70ca94e6510a0c11f8ccb12 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.7' +version = '0.23.9' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index 807d3748088d9fa8a2180e86f12af0d6ea504966..c583e868fe2ea14bc70ca94e6510a0c11f8ccb12 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.7' +version = '0.23.9' diff --git a/docs/index.rst b/docs/index.rst index 047b5db90bc62faa6d605708e47a938822cdd973..8bd18fb3eea6270a4bc2eca15ed318820ce880b7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,7 +36,7 @@ About this Library ------------------ The purpose of *beem* is to simplify development of products and -services that use the Steem blockchain. It comes with +services that use the Hive blockchain. It comes with * its own (bip32-encrypted) wallet * RPC interface for the Blockchain backend @@ -63,10 +63,10 @@ Quickstart .. code-block:: python - from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - account = Account("test", steem_instance=steem) + from beem import Hive + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + account = Account("test", blockchain_instance=hive) account.transfer("<to>", "<amount>", "<asset>", "<memo>") .. code-block:: python @@ -91,21 +91,21 @@ Quickstart .. code-block:: python - from beem.steem import Steem - stm = Steem() - stm.wallet.wipe(True) - stm.wallet.create("wallet-passphrase") - stm.wallet.unlock("wallet-passphrase") - stm.wallet.addPrivateKey("512345678") - stm.wallet.lock() + from beem.hive import Hive + hive = Hive() + hive.wallet.wipe(True) + hive.wallet.create("wallet-passphrase") + hive.wallet.unlock("wallet-passphrase") + hive.wallet.addPrivateKey("512345678") + hive.wallet.lock() .. code-block:: python from beem.market import Market - market = Market("SBD:STEEM") + market = Market("HBD:HIVE") print(market.ticker()) market.steem.wallet.unlock("wallet-passphrase") - print(market.sell(300, 100) # sell 100 STEEM for 300 STEEM/SBD + print(market.sell(300, 100) # sell 100 HIVE for 300 HIVE/HBD General diff --git a/docs/installation.rst b/docs/installation.rst index 7db836163de13d153df2e15abd93b3bca4b5c537..6eb55081d85406033d91e7aba14a6f92871e5041 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,6 +1,6 @@ Installation ============ -The minimal working python version is 2.7.x. or 3.4.x +The minimal working python version is 3.5.x beem can be installed parallel to python-steem. diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 43b156f9c8313591e7169186edc5389c026257a1..ada666ef1afcbc5ce5d4e3b7b3df6dbbc41af139 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -10,7 +10,7 @@ Nodes for using beem with the Hive blockchain can be set by the command line too beempy updatenodes --hive -Nodes for the Steem blockchain are set with +Nodes for the Hive blockchain are set with .. code-block:: bash @@ -21,12 +21,12 @@ Hive nodes can be set in a python script with .. code-block:: python - from beem import Steem + from beem import Hive from beem.nodelist import NodeList nodelist = NodeList() nodelist.update_nodes() - nodes = nodelist.get_nodes(hive=True) - hive = Steem(node=nodes) + nodes = nodelist.get_hive_nodes() + hive = Hive(node=nodes) print(hive.is_hive) Steem nodes can be set in a python script with @@ -37,40 +37,40 @@ Steem nodes can be set in a python script with from beem.nodelist import NodeList nodelist = NodeList() nodelist.update_nodes() - nodes = nodelist.get_nodes(hive=False) + nodes = nodelist.get_steem_nodes() hive = Steem(node=nodes) print(hive.is_hive) -Steem ------ -The steem object is the connection to the Steem/Hive blockchain. +Hive +---- +The hive object is the connection to the Hive blockchain. By creating this object different options can be set. .. note:: All init methods of beem classes can be given - the ``steem_instance=`` parameter to assure that + the ``blockchain_instance=`` parameter to assure that all objects use the same steem object. When the - ``steem_instance=`` parameter is not used, the - steem object is taken from get_shared_steem_instance(). + ``blockchain_instance=`` parameter is not used, the + steem object is taken from get_shared_blockchain_instance(). - :func:`beem.instance.shared_steem_instance` returns a global instance of steem. - It can be set by :func:`beem.instance.set_shared_steem_instance` otherwise it is created + :func:`beem.instance.shared_blockchain_instance` returns a global instance of steem. + It can be set by :func:`beem.instance.set_shared_blockchain_instance` otherwise it is created on the first call. .. code-block:: python - from beem import Steem + from beem import Hive from beem.account import Account - stm = Steem() - account = Account("test", steem_instance=stm) + hive = Hive() + account = Account("test", blockchain_instance=hive) .. code-block:: python - from beem import Steem + from beem import Hive from beem.account import Account - from beem.instance import set_shared_steem_instance - stm = Steem() - set_shared_steem_instance(stm) + from beem.instance import set_shared_blockchain_instance + hive = Hive() + set_shared_blockchain_instance(hive) account = Account("test") Wallet and Keys @@ -93,34 +93,34 @@ stored encrypted in a sql-database (wallet). Creating a wallet ~~~~~~~~~~~~~~~~~ -``steem.wallet.wipe(True)`` is only necessary when there was already an wallet created. +``hive.wallet.wipe(True)`` is only necessary when there was already an wallet created. .. code-block:: python - from beem import Steem - steem = Steem() - steem.wallet.wipe(True) - steem.wallet.unlock("wallet-passphrase") + from beem import Hive + hive = Hive() + hive.wallet.wipe(True) + hive.wallet.unlock("wallet-passphrase") Adding keys to the wallet ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - steem.wallet.addPrivateKey("xxxxxxx") - steem.wallet.addPrivateKey("xxxxxxx") + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + hive.wallet.addPrivateKey("xxxxxxx") + hive.wallet.addPrivateKey("xxxxxxx") Using the keys in the wallet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python - from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - account = Account("test", steem_instance=steem) + from beem import Hive + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + account = Account("test", blockchain_instance=hive) account.transfer("<to>", "<amount>", "<asset>", "<memo>") Private keys can also set temporary @@ -128,9 +128,9 @@ Private keys can also set temporary .. code-block:: python - from beem import Steem - steem = Steem(keys=["xxxxxxxxx"]) - account = Account("test", steem_instance=steem) + from beem import Hive + hive = Hive(keys=["xxxxxxxxx"]) + account = Account("test", blockchain_instance=hive) account.transfer("<to>", "<amount>", "<asset>", "<memo>") Receiving information about blocks, accounts, votes, comments, market and witness @@ -190,7 +190,7 @@ Access the market .. code-block:: python from beem.market import Market - market = Market("SBD:STEEM") + market = Market("HBD:HIVE") print(market.ticker()) Access a witness @@ -208,10 +208,10 @@ Sending a Transfer .. code-block:: python - from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - account = Account("test", steem_instance=steem) + from beem import Hive + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + account = Account("test", blockchain_instance=hive) account.transfer("null", 1, "SBD", "test") Upvote a post @@ -219,29 +219,29 @@ Upvote a post .. code-block:: python from beem.comment import Comment - from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - comment = Comment("@gtg/ffdhu-gtg-witness-log", steem_instance=steem) + from beem import Hive + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + comment = Comment("@gtg/ffdhu-gtg-witness-log", blockchain_instance=hive) comment.upvote(weight=10, voter="test") Publish a post to the blockchain .. code-block:: python - from beem import Steem - steem = Steem() - steem.wallet.unlock("wallet-passphrase") - steem.post("title", "body", author="test", tags=["a", "b", "c", "d", "e"], self_vote=True) + from beem import Hive + hive = Hive() + hive.wallet.unlock("wallet-passphrase") + hive.post("title", "body", author="test", tags=["a", "b", "c", "d", "e"], self_vote=True) -Sell STEEM on the market +Sell HIVE on the market .. code-block:: python from beem.market import Market - from beem import Steem - steem.wallet.unlock("wallet-passphrase") - market = Market("SBD:STEEM", steem_instance=steem) + from beem import Hive + hive.wallet.unlock("wallet-passphrase") + market = Market("HBD:HIVE", blockchain_instance=hive) print(market.ticker()) - market.steem.wallet.unlock("wallet-passphrase") - print(market.sell(300, 100)) # sell 100 STEEM for 300 STEEM/SBD + market.hive.wallet.unlock("wallet-passphrase") + print(market.sell(300, 100)) # sell 100 HIVE for 300 HIVE/HBD diff --git a/docs/tutorials.rst b/docs/tutorials.rst index 761ec49193db4124afe2271c5f27ef9945958e61..f293a29792d6aec5fc40ee8d642006f19c1b3876 100644 --- a/docs/tutorials.rst +++ b/docs/tutorials.rst @@ -20,7 +20,7 @@ one comment operation from each sender. from beem import Steem from beem.account import Account from beem.comment import Comment - from beem.instance import set_shared_steem_instance + from beem.instance import set_shared_blockchain_instance # not a real working key wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -31,7 +31,7 @@ one comment operation from each sender. keys=[wif], ) # Set stm as shared instance - set_shared_steem_instance(stm) + set_shared_blockchain_instance(stm) # Account and Comment will use now stm account = Account("test") @@ -58,7 +58,7 @@ When using `nobroadcast=True` the transaction is not broadcasted but printed. from pprint import pprint from beem import Steem from beem.account import Account - from beem.instance import set_shared_steem_instance + from beem.instance import set_shared_blockchain_instance # Only for testing not a real working key wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -69,7 +69,7 @@ When using `nobroadcast=True` the transaction is not broadcasted but printed. keys=[wif], ) # Set testnet as shared instance - set_shared_steem_instance(testnet) + set_shared_blockchain_instance(testnet) # Account will use now testnet account = Account("test") @@ -140,7 +140,7 @@ Simple Sell Script # Sell and buy calls always refer to the *quote* # market = Market("SBD:STEEM", - steem_instance=steem + blockchain_instance=steem ) # @@ -192,7 +192,7 @@ Sell at a timely rate # Sell and buy calls always refer to the *quote* # market = Market("STEEM:SBD", - steem_instance=steem + blockchain_instance=steem ) sell() @@ -277,7 +277,7 @@ Example with one operation with and without the wallet: stm = Steem() # Uncomment the following when using a wallet: # stm.wallet.unlock("secret_password") - tx = TransactionBuilder(steem_instance=stm) + tx = TransactionBuilder(blockchain_instance=stm) op = operations.Transfer(**{"from": 'user_a', "to": 'user_b', "amount": '1.000 SBD', @@ -299,7 +299,7 @@ Example with signing and broadcasting two operations: stm = Steem() # Uncomment the following when using a wallet: # stm.wallet.unlock("secret_password") - tx = TransactionBuilder(steem_instance=stm) + tx = TransactionBuilder(blockchain_instance=stm) ops = [] op = operations.Transfer(**{"from": 'user_a', "to": 'user_b', diff --git a/setup.py b/setup.py index 402f722fdbb7627569a83887dc059e95d356e5bf..3409968b0851f403d65073876bf176184106e982 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.23.7' +VERSION = '0.23.9' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']