diff --git a/LICENSE.txt b/LICENSE.txt index 17eb27b4d3b91187191f897b2cbf61e330f6ae7f..2f26102edda5faa1524a150cc996d65ea7c6a05c 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,7 @@ The MIT License (MIT) Copyright (c) 2015 Fabian Schuh + 2018 Holger Nahrstaedt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index e8e49e20f2025fb5831d164dfab195c49ae52f3b..ad8b946eace6967bc3b296850643f926a3d8b6a7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ clean-pyc: find . -name '*~' -exec rm -f {} + lint: - flake8 bitsharesapi/ bitsharesbase/ bitshares/ + flake8 steemapi/ steembase/ steem/ test: python3 setup.py test diff --git a/README.md b/README.md index 5b62257a3f6eb1ddf60c62053f718b234f4c91e3..3e586668e35d48adf63f2e0e49c00e921e526337 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,21 @@ -# Python Library for BitShares +# Python Library for Steem --- -## Documentation -Visit the [pybitshares website](http://docs.pybitshares.com/en/latest/) for in depth documentation on this Python library. ## Installation ### Install with pip: ``` $ sudo apt-get install libffi-dev libssl-dev python-dev python3-dev python3-pip -$ pip3 install bitshares +$ pip3 install steemi ``` ### Manual installation: ``` -$ git clone https://github.com/xeroc/python-bitshares/ -$ cd python-bitshares +$ git clone https://github.com/holgern/pySteemi/ +$ cd pySteemi $ python3 setup.py install --user ``` diff --git a/bitshares/__init__.py b/bitshares/__init__.py deleted file mode 100644 index 915ef88d2d41fb30f54768cce9d6e46ccbe25bc3..0000000000000000000000000000000000000000 --- a/bitshares/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .bitshares import BitShares - -__all__ = [ - "bitshares" - "aes", - "account", - "amount", - "asset", - "block", - "blockchain", - "dex", - "market", - "storage", - "price", - "utils", - "wallet", - "committee", - "vesting", - "proposal", - "message" -] diff --git a/bitsharesbase/__init__.py b/bitsharesbase/__init__.py deleted file mode 100644 index 254d7debe7dff0ffde24428ee300f909c225eaab..0000000000000000000000000000000000000000 --- a/bitsharesbase/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -__all__ = [ - 'account', - 'bip38', - 'chains', - 'memo', - 'objects', - 'objecttypes', - 'operationids', - 'operations', - 'signedtransactions', - 'transactions', -] diff --git a/bitsharesbase/chains.py b/bitsharesbase/chains.py deleted file mode 100644 index ad801664e8578777e7046c77d2dde83765fcc617..0000000000000000000000000000000000000000 --- a/bitsharesbase/chains.py +++ /dev/null @@ -1,22 +0,0 @@ -known_chains = { - "BTS": { - "chain_id": "4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8", - "core_symbol": "BTS", - "prefix": "BTS"}, - "GPH": { - "chain_id": "b8d1603965b3eb1acba27e62ff59f74efa3154d43a4188d381088ac7cdf35539", - "core_symbol": "CORE", - "prefix": "GPH"}, - "TEST": { - "chain_id": "39f5e2ede1f8bc1a3a54a7914414e3779e33193f1f5693510e73cb7a87617447", - "core_symbol": "TEST", - "prefix": "TEST"}, - "Obelisk": { - "chain_id": "1cfde7c388b9e8ac06462d68aadbd966b58f88797637d9af805b4560b0e9661e", - "core_symbol": "GOV", - "prefix": "FEW"}, - "Scnrfp": { - "chain_id": "a8a61755aaa9d2c19a5989490bbc4195f37f147be3db3dddcf0e06d373b397ce", - "core_symbol": "SCNRFP", - "prefix": "SCNRFP"} -} diff --git a/bitsharesbase/objecttypes.py b/bitsharesbase/objecttypes.py deleted file mode 100644 index cf6e63dd8967650cdfda47e68aa00c7f75218abc..0000000000000000000000000000000000000000 --- a/bitsharesbase/objecttypes.py +++ /dev/null @@ -1,19 +0,0 @@ -#: Object types for object ids -object_type = {} -object_type["null"] = 0 -object_type["base"] = 1 -object_type["account"] = 2 -object_type["asset"] = 3 -object_type["force_settlement"] = 4 -object_type["committee_member"] = 5 -object_type["witness"] = 6 -object_type["limit_order"] = 7 -object_type["call_order"] = 8 -object_type["custom"] = 9 -object_type["proposal"] = 10 -object_type["operation_history"] = 11 -object_type["withdraw_permission"] = 12 -object_type["vesting_balance"] = 13 -object_type["worker"] = 14 -object_type["balance"] = 15 -object_type["OBJECT_TYPE_COUNT"] = 16 diff --git a/bitsharesbase/operationids.py b/bitsharesbase/operationids.py deleted file mode 100644 index 6494d626baf78fa7260287c51c028c72a1d9fc60..0000000000000000000000000000000000000000 --- a/bitsharesbase/operationids.py +++ /dev/null @@ -1,60 +0,0 @@ -#: Operation ids -ops = [ - "transfer", - "limit_order_create", - "limit_order_cancel", - "call_order_update", - "fill_order", - "account_create", - "account_update", - "account_whitelist", - "account_upgrade", - "account_transfer", - "asset_create", - "asset_update", - "asset_update_bitasset", - "asset_update_feed_producers", - "asset_issue", - "asset_reserve", - "asset_fund_fee_pool", - "asset_settle", - "asset_global_settle", - "asset_publish_feed", - "witness_create", - "witness_update", - "proposal_create", - "proposal_update", - "proposal_delete", - "withdraw_permission_create", - "withdraw_permission_update", - "withdraw_permission_claim", - "withdraw_permission_delete", - "committee_member_create", - "committee_member_update", - "committee_member_update_global_parameters", - "vesting_balance_create", - "vesting_balance_withdraw", - "worker_create", - "custom", - "assert", - "balance_claim", - "override_transfer", - "transfer_to_blind", - "blind_transfer", - "transfer_from_blind", - "asset_settle_cancel", - "asset_claim_fees", - "fba_distribute", - "bid_collateral", - "execute_bid", -] -operations = {o: ops.index(o) for o in ops} - - -def getOperationNameForId(i): - """ Convert an operation id into the corresponding string - """ - for key in operations: - if int(operations[key]) is int(i): - return key - return "Unknown Operation ID %d" % i diff --git a/requirements-test.txt b/requirements-test.txt index 093b555d300cbac3f92233bf0b20e2ba0bea3936..4aef5cd1783fc5ad33ba694c39c0a17d55022e8b 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ graphenelib -pycryptodome==3.4.6 -scrypt==0.7.1 -Events==0.2.2 +pycryptodomex>=3.4.6 +scrypt>=0.7.1 +Events>=0.2.2 pyyaml pytest pytest-mock diff --git a/setup.py b/setup.py index 775fe813ebfbf92faa67b9f04361cc00f157aad2..9e8e70053cdc427d41bb1176c4a6536fc77e0f2b 100755 --- a/setup.py +++ b/setup.py @@ -11,24 +11,24 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.1.11' +VERSION = '0.19.0' setup( - name='bitshares', + name='steemi', version=VERSION, - description='Python library for bitshares', + description='Unofficial Python library for STEEM', long_description=open('README.md').read(), - download_url='https://github.com/xeroc/python-bitshares/tarball/' + VERSION, - author='Fabian Schuh', - author_email='Fabian@chainsquad.com', - maintainer='Fabian Schuh', - maintainer_email='Fabian@chainsquad.com', - url='http://www.github.com/xeroc/python-bitshares', - keywords=['bitshares', 'library', 'api', 'rpc'], + download_url='https://github.com/holgern/pySteemi/tarball/' + VERSION, + author='Holger Nahrstaedt', + author_email='holger@nahrstaedt.de', + maintainer='Holger Nahrstaedt', + maintainer_email='holger@nahrstaedt.de', + url='http://www.github.com/holgern/pySteemi', + keywords=['steem', 'library', 'api', 'rpc'], packages=[ - "bitshares", - "bitsharesapi", - "bitsharesbase" + "steem", + "steemapi", + "steembase" ], classifiers=[ 'License :: OSI Approved :: MIT License', @@ -45,7 +45,7 @@ setup( "appdirs", "Events", "scrypt", - "pycryptodome", # for AES, installed through graphenelib already + "pycryptodomex", # for AES, installed through graphenelib already ], setup_requires=['pytest-runner'], tests_require=['pytest'], diff --git a/steem/__init__.py b/steem/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..8667d245cee74511b5dc91d8463ac1ee477a7981 --- /dev/null +++ b/steem/__init__.py @@ -0,0 +1,21 @@ +#from .steem import Steem + +__all__ = [ + #"steem", + "aes", + #"account", + #"amount", + #"asset", + #"block", + #"blockchain", + #"dex", + #"market", + #"storage", + #"price", + "utils", + #"wallet", + #"committee", + #"vesting", + #"proposal", + #"message" +] diff --git a/bitshares/account.py b/steem/account.py similarity index 99% rename from bitshares/account.py rename to steem/account.py index a5b85d3be4aa3bf811d08ff9286836b392c52620..d20b085416a4849434ac9bfdb8e4171ba17f1fe7 100644 --- a/bitshares/account.py +++ b/steem/account.py @@ -1,4 +1,4 @@ -from bitshares.instance import shared_bitshares_instance +from steem.instance import shared_steem_instance from .exceptions import AccountDoesNotExistsException from .blockchainobject import BlockchainObject diff --git a/bitshares/aes.py b/steem/aes.py similarity index 82% rename from bitshares/aes.py rename to steem/aes.py index e665a467cd767d4bd847a1c1ae8efeeafdc3044f..8d0539bfdb280b38e9c690b936892d5370be0db7 100644 --- a/bitshares/aes.py +++ b/steem/aes.py @@ -1,8 +1,14 @@ -from Crypto import Random -from Crypto.Cipher import AES import hashlib import base64 - +try: + from Cryptodome import Random + from Cryptodome.Cipher import AES +except ImportError: + try: + from Crypto import Random + from Crypto.Cipher import AES + except ImportError: + raise ImportError("Missing dependency: pyCryptodome") class AESCipher(object): """ diff --git a/bitshares/amount.py b/steem/amount.py similarity index 100% rename from bitshares/amount.py rename to steem/amount.py diff --git a/bitshares/asset.py b/steem/asset.py similarity index 100% rename from bitshares/asset.py rename to steem/asset.py diff --git a/bitshares/block.py b/steem/block.py similarity index 100% rename from bitshares/block.py rename to steem/block.py diff --git a/bitshares/blockchain.py b/steem/blockchain.py similarity index 100% rename from bitshares/blockchain.py rename to steem/blockchain.py diff --git a/bitshares/blockchainobject.py b/steem/blockchainobject.py similarity index 100% rename from bitshares/blockchainobject.py rename to steem/blockchainobject.py diff --git a/bitshares/committee.py b/steem/committee.py similarity index 100% rename from bitshares/committee.py rename to steem/committee.py diff --git a/bitshares/dex.py b/steem/dex.py similarity index 100% rename from bitshares/dex.py rename to steem/dex.py diff --git a/bitshares/exceptions.py b/steem/exceptions.py similarity index 100% rename from bitshares/exceptions.py rename to steem/exceptions.py diff --git a/bitshares/instance.py b/steem/instance.py similarity index 68% rename from bitshares/instance.py rename to steem/instance.py index 72c85a7e4716a8896f4d2112d43b8291e67ea9f1..389e237cb1c25aee87e68497e2e2476ad223a555 100644 --- a/bitshares/instance.py +++ b/steem/instance.py @@ -1,29 +1,29 @@ -import bitshares as bts +import steem as stm class SharedInstance(): instance = None -def shared_bitshares_instance(): +def shared_steem_instance(): """ This method will initialize ``SharedInstance.instance`` and return it. The purpose of this method is to have offer single default bitshares instance that can be reused by multiple classes. """ if not SharedInstance.instance: clear_cache() - SharedInstance.instance = bts.BitShares() + SharedInstance.instance = stm.Steem() return SharedInstance.instance -def set_shared_bitshares_instance(bitshares_instance): - """ This method allows us to override default bitshares instance for all users of +def set_shared_steem_instance(steem_instance): + """ This method allows us to override default steem instance for all users of ``SharedInstance.instance``. :param bitshares.bitshares.BitShares bitshares_instance: BitShares instance """ clear_cache() - SharedInstance.instance = bitshares_instance + SharedInstance.instance = steem_instance def clear_cache(): diff --git a/bitshares/market.py b/steem/market.py similarity index 100% rename from bitshares/market.py rename to steem/market.py diff --git a/bitshares/memo.py b/steem/memo.py similarity index 100% rename from bitshares/memo.py rename to steem/memo.py diff --git a/bitshares/message.py b/steem/message.py similarity index 100% rename from bitshares/message.py rename to steem/message.py diff --git a/bitshares/notify.py b/steem/notify.py similarity index 100% rename from bitshares/notify.py rename to steem/notify.py diff --git a/bitshares/price.py b/steem/price.py similarity index 100% rename from bitshares/price.py rename to steem/price.py diff --git a/bitshares/proposal.py b/steem/proposal.py similarity index 100% rename from bitshares/proposal.py rename to steem/proposal.py diff --git a/bitshares/bitshares.py b/steem/steem.py similarity index 99% rename from bitshares/bitshares.py rename to steem/steem.py index b10737d27470c4f1ab7946bab4150ac6446a0a6e..d25945c356b9b522b42115de00f6fa7b336cb1a3 100644 --- a/bitshares/bitshares.py +++ b/steem/steem.py @@ -2,9 +2,9 @@ import json import logging from datetime import datetime, timedelta -from bitsharesapi.bitsharesnoderpc import BitSharesNodeRPC -from bitsharesbase.account import PrivateKey, PublicKey -from bitsharesbase import transactions, operations +from steemapi.bitsharesnoderpc import SteemNodeRPC +from steembase.account import PrivateKey, PublicKey +from steembase import transactions, operations from .asset import Asset from .account import Account from .amount import Amount @@ -24,7 +24,7 @@ from .utils import formatTime, test_proposal_in_buffer log = logging.getLogger(__name__) -class BitShares(object): +class Steem(object): """ Connect to the BitShares network. :param str node: Node to connect to *(optional)* @@ -157,13 +157,13 @@ class BitShares(object): rpcuser="", rpcpassword="", **kwargs): - """ Connect to BitShares network (internal use only) + """ Connect to Steem network (internal use only) """ if not node: if "node" in config: node = config["node"] else: - raise ValueError("A BitShares node needs to be provided!") + raise ValueError("A Steem node needs to be provided!") if not rpcuser and "rpcuser" in config: rpcuser = config["rpcuser"] @@ -171,7 +171,7 @@ class BitShares(object): if not rpcpassword and "rpcpassword" in config: rpcpassword = config["rpcpassword"] - self.rpc = BitSharesNodeRPC(node, rpcuser, rpcpassword, **kwargs) + self.rpc = SteemNodeRPC(node, rpcuser, rpcpassword, **kwargs) @property def prefix(self): diff --git a/bitshares/storage.py b/steem/storage.py similarity index 100% rename from bitshares/storage.py rename to steem/storage.py diff --git a/bitshares/transactionbuilder.py b/steem/transactionbuilder.py similarity index 100% rename from bitshares/transactionbuilder.py rename to steem/transactionbuilder.py diff --git a/bitshares/utils.py b/steem/utils.py similarity index 100% rename from bitshares/utils.py rename to steem/utils.py diff --git a/bitshares/vesting.py b/steem/vesting.py similarity index 100% rename from bitshares/vesting.py rename to steem/vesting.py diff --git a/bitshares/wallet.py b/steem/wallet.py similarity index 100% rename from bitshares/wallet.py rename to steem/wallet.py diff --git a/bitshares/witness.py b/steem/witness.py similarity index 97% rename from bitshares/witness.py rename to steem/witness.py index bd437935cdfb37f1bc01402fdcce8dce5e35fb78..eba4ce4dc4f96e610a0b29fb388e01de9ab34743 100644 --- a/bitshares/witness.py +++ b/steem/witness.py @@ -1,4 +1,4 @@ -from bitshares.instance import shared_bitshares_instance +from steem.instance import shared_steem_instance from .account import Account from .exceptions import WitnessDoesNotExistsException from .blockchainobject import BlockchainObject diff --git a/bitshares/worker.py b/steem/worker.py similarity index 100% rename from bitshares/worker.py rename to steem/worker.py diff --git a/bitsharesapi/__init__.py b/steemapi/__init__.py similarity index 67% rename from bitsharesapi/__init__.py rename to steemapi/__init__.py index f6829daaf42058d1af11c7fdba084b5fe490a21b..c4af794c03a9825db473da6886cf86f934136373 100644 --- a/bitsharesapi/__init__.py +++ b/steemapi/__init__.py @@ -1,5 +1,5 @@ __all__ = [ - "bitsharesnoderpc", + "steemnoderpc", "exceptions", "websocket", ] diff --git a/bitsharesapi/exceptions.py b/steemapi/exceptions.py similarity index 100% rename from bitsharesapi/exceptions.py rename to steemapi/exceptions.py diff --git a/bitsharesapi/bitsharesnoderpc.py b/steemapi/steemnoderpc.py similarity index 92% rename from bitsharesapi/bitsharesnoderpc.py rename to steemapi/steemnoderpc.py index e1ae4e67c2037c895836f5f6be81189304b43aa8..a846d2a7d8bfaa0ddafdb8ad997640f343ed167a 100644 --- a/bitsharesapi/bitsharesnoderpc.py +++ b/steemapi/steemnoderpc.py @@ -7,7 +7,7 @@ import json import time from itertools import cycle from grapheneapi.graphenewsrpc import GrapheneWebsocketRPC -from bitsharesbase.chains import known_chains +from steembase.chains import known_chains from . import exceptions import logging log = logging.getLogger(__name__) @@ -17,10 +17,10 @@ class NumRetriesReached(Exception): pass -class BitSharesNodeRPC(GrapheneWebsocketRPC): +class SteemNodeRPC(GrapheneWebsocketRPC): def __init__(self, *args, **kwargs): - super(BitSharesNodeRPC, self).__init__(*args, **kwargs) + super(SteemNodeRPC, self).__init__(*args, **kwargs) self.chain_params = self.get_network() def register_apis(self): @@ -39,7 +39,7 @@ class BitSharesNodeRPC(GrapheneWebsocketRPC): """ try: # Forward call to GrapheneWebsocketRPC and catch+evaluate errors - return super(BitSharesNodeRPC, self).rpcexec(payload) + return super(SteemNodeRPC, self).rpcexec(payload) except exceptions.RPCError as e: msg = exceptions.decodeRPCErrorMsg(e).strip() if msg == "missing required active authority": diff --git a/bitsharesapi/websocket.py b/steemapi/websocket.py similarity index 99% rename from bitsharesapi/websocket.py rename to steemapi/websocket.py index a4b6067a9b4580264b2e2ebea6f578300d044155..f2422728b4f7aa6ff0f84c24fa4d7059e0a05be2 100644 --- a/bitsharesapi/websocket.py +++ b/steemapi/websocket.py @@ -14,7 +14,7 @@ log = logging.getLogger(__name__) # logging.basicConfig(level=logging.DEBUG) -class BitSharesWebsocket(Events): +class SteemWebsocket(Events): """ Create a websocket connection and request push notifications :param str urls: Either a single Websocket URL, or a list of URLs diff --git a/steembase/__init__.py b/steembase/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..a10fcf088cdd1f32c51ed454db16d5b7a05aaf08 --- /dev/null +++ b/steembase/__init__.py @@ -0,0 +1,12 @@ +__all__ = [ + #'account', + 'bip38', + #'chains', + #'memo', + #'objects', + #'objecttypes', + #'operationids', + #'operations', + #'signedtransactions', + #'transactions', +] diff --git a/bitsharesbase/account.py b/steembase/account.py similarity index 87% rename from bitsharesbase/account.py rename to steembase/account.py index 850a6f3d6ebc39eaa41867327499643c1703e3f9..169b0df6faeee73050a68bf289a5f2259c8897e3 100644 --- a/bitsharesbase/account.py +++ b/steembase/account.py @@ -48,16 +48,16 @@ class Address(GPHAddress): :param str address: Base58 encoded address (defaults to ``None``) :param str pubkey: Base58 encoded pubkey (defaults to ``None``) - :param str prefix: Network prefix (defaults to ``BTS``) + :param str prefix: Network prefix (defaults to ``STM``) Example:: - Address("BTSFN9r6VYzBK8EKtMewfNbfiGCr56pHDBFi") + Address("GPHFN9r6VYzBK8EKtMewfNbfiGCr56pHDBFi") """ def __init__(self, *args, **kwargs): if "prefix" not in kwargs: - kwargs["prefix"] = "BTS" # make prefix BTS + kwargs["prefix"] = "STM" # make prefix STM super(Address, self).__init__(*args, **kwargs) @@ -65,11 +65,11 @@ class PublicKey(GPHPublicKey): """ This class deals with Public Keys and inherits ``Address``. :param str pk: Base58 encoded public key - :param str prefix: Network prefix (defaults to ``BTS``) + :param str prefix: Network prefix (defaults to ``STM``) Example::: - PublicKey("BTS6UtYWWs3rkZGV8JA86qrgkG6tyFksgECefKE1MiH4HkLD8PFGL") + PublicKey("GPH6UtYWWs3rkZGV8JA86qrgkG6tyFksgECefKE1MiH4HkLD8PFGL") .. note:: By default, graphene-based networks deal with **compressed** public keys. If an **uncompressed** key is required, the @@ -80,7 +80,7 @@ class PublicKey(GPHPublicKey): """ def __init__(self, *args, **kwargs): if "prefix" not in kwargs: - kwargs["prefix"] = "BTS" # make prefix BTS + kwargs["prefix"] = "STM" # make prefix STM super(PublicKey, self).__init__(*args, **kwargs) @@ -89,7 +89,7 @@ class PrivateKey(GPHPrivateKey): constructs two instances of ``PublicKey``: :param str wif: Base58check-encoded wif key - :param str prefix: Network prefix (defaults to ``BTS``) + :param str prefix: Network prefix (defaults to ``STM``) Example::: @@ -109,5 +109,5 @@ class PrivateKey(GPHPrivateKey): """ def __init__(self, *args, **kwargs): if "prefix" not in kwargs: - kwargs["prefix"] = "BTS" # make prefix BTS + kwargs["prefix"] = "STM" # make prefix STM super(PrivateKey, self).__init__(*args, **kwargs) diff --git a/bitsharesbase/asset_permissions.py b/steembase/asset_permissions.py similarity index 100% rename from bitsharesbase/asset_permissions.py rename to steembase/asset_permissions.py diff --git a/bitsharesbase/bip38.py b/steembase/bip38.py similarity index 100% rename from bitsharesbase/bip38.py rename to steembase/bip38.py diff --git a/steembase/chains.py b/steembase/chains.py new file mode 100644 index 0000000000000000000000000000000000000000..2a4d62af91d3c5d84376cdeb17006abb8d27d7a6 --- /dev/null +++ b/steembase/chains.py @@ -0,0 +1,21 @@ +known_chains = { + "STEEM": { + "chain_id": "0" * int(256 / 4), + "prefix": "STM", + "steem_symbol": "STEEM", + "sbd_symbol": "SBD", + "vests_symbol": "VESTS", + }, + "TEST": { + "chain_id": + "9afbce9f2416520733bacb370315d32b6b2c43d6097576df1c1222859d91eecc", + "prefix": + "TST", + "steem_symbol": + "TESTS", + "sbd_symbol": + "TBD", + "vests_symbol": + "VESTS", + }, +} diff --git a/bitsharesbase/memo.py b/steembase/memo.py similarity index 100% rename from bitsharesbase/memo.py rename to steembase/memo.py diff --git a/bitsharesbase/objects.py b/steembase/objects.py similarity index 76% rename from bitsharesbase/objects.py rename to steembase/objects.py index 2e96d9aefc7ead5eab0ffce7b43eac7c153bfecc..3bedd32cdb894688c09c73c92b7024c7e0abbd17 100644 --- a/bitsharesbase/objects.py +++ b/steembase/objects.py @@ -13,8 +13,13 @@ from .objecttypes import object_type from .account import PublicKey from graphenebase.objects import Operation as GPHOperation from .operationids import operations -default_prefix = "BTS" +default_prefix = "STM" +asset_precision = { + "STEEM": 3, + "VESTS": 6, + "SBD": 3, +} def AssetId(asset): return ObjectId(asset, "asset") @@ -48,7 +53,7 @@ class Operation(GPHOperation): super(Operation, self).__init__(*args, **kwargs) def _getklass(self, name): - module = __import__("bitsharesbase.operations", fromlist=["operations"]) + module = __import__("steembase.operations", fromlist=["operations"]) class_ = getattr(module, name) return class_ @@ -80,7 +85,7 @@ class Asset(GrapheneObject): ])) -class Memo(GrapheneObject): +class Permission(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data @@ -291,83 +296,6 @@ class SpecialAuthority(Static_variant): super().__init__(data, id) -class Extension(Array): - def __str__(self): - """ We overload the __str__ function because the json - representation is different for extensions - """ - return json.dumps(self.json) - - -class AccountCreateExtensions(Extension): - def __init__(self, *args, **kwargs): - # Extensions ################################# - class Null_ext(GrapheneObject): - def __init__(self, kwargs): - super().__init__(OrderedDict([])) - - class Owner_special_authority(SpecialAuthority): - def __init__(self, kwargs): - super().__init__(kwargs) - - class Active_special_authority(SpecialAuthority): - def __init__(self, kwargs): - super().__init__(kwargs) - class Buyback_options(GrapheneObject): - def __init__(self, kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] -# assert "1.3.0" in kwargs["markets"], "CORE asset must be in 'markets' to pay fees" - super().__init__(OrderedDict([ - ('asset_to_buy', ObjectId(kwargs["asset_to_buy"], "asset")), - ('asset_to_buy_issuer', ObjectId(kwargs["asset_to_buy_issuer"], "account")), - ('markets', Array([ - ObjectId(x, "asset") for x in kwargs["markets"] - ])), - ])) - # End of Extensions definition ################ - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - self.json = dict() - a = [] - sorted_options = [ - "null_ext", - "owner_special_authority", - "active_special_authority", - "buyback_options" - ] - sorting = sorted(kwargs.items(), key=lambda x: sorted_options.index(x[0])) - for key, value in sorting: - self.json.update({key: value}) - if key == "null_ext": - a.append(Static_variant( - Null_ext({key: value}), - sorted_options.index(key)) - ) - elif key == "owner_special_authority": - a.append(Static_variant( - Owner_special_authority(value), - sorted_options.index(key)) - ) - elif key == "active_special_authority": - a.append(Static_variant( - Active_special_authority(value), - sorted_options.index(key)) - ) - elif key == "buyback_options": - a.append(Static_variant( - Buyback_options(value), - sorted_options.index(key)) - ) - else: - raise NotImplementedError("Extension {} is unknown".format(key)) - super().__init__(a) diff --git a/steembase/objecttypes.py b/steembase/objecttypes.py new file mode 100644 index 0000000000000000000000000000000000000000..a98db28a45bfa6ae717359532470aff38271eacc --- /dev/null +++ b/steembase/objecttypes.py @@ -0,0 +1,21 @@ +#: Object types for object ids +object_type = {} +object_type["dynamic_global_property"] = 0 +object_type["reserved0"] = 1 +object_type["account"] = 2 +object_type["witness"] = 3 +object_type["transaction"] = 4 +object_type["block_summary"] = 5 +object_type["chain_property"] = 6 +object_type["witness_schedule"] = 7 +object_type["comment"] = 8 +object_type["category"] = 9 +object_type["comment_vote"] = 10 +object_type["vote"] = 11 +object_type["witness_vote"] = 12 +object_type["limit_order"] = 13 +object_type["feed_history"] = 14 +object_type["convert_request"] = 15 +object_type["liquidity_reward_balance"] = 16 +object_type["operation"] = 17 +object_type["account_history"] = 18 diff --git a/steembase/operationids.py b/steembase/operationids.py new file mode 100644 index 0000000000000000000000000000000000000000..2c57ea9b94bd613457e5736555d825ac1c762fb2 --- /dev/null +++ b/steembase/operationids.py @@ -0,0 +1,69 @@ +#: Operation ids +ops = [ + 'vote', + 'comment', + 'transfer', + 'transfer_to_vesting', + 'withdraw_vesting', + 'limit_order_create', + 'limit_order_cancel', + 'feed_publish', + 'convert', + 'account_create', + 'account_update', + 'witness_update', + 'account_witness_vote', + 'account_witness_proxy', + 'pow', + 'custom', + 'report_over_production', + 'delete_comment', + 'custom_json', + 'comment_options', + 'set_withdraw_vesting_route', + 'limit_order_create2', + 'challenge_authority', + 'prove_authority', + 'request_account_recovery', + 'recover_account', + 'change_recovery_account', + 'escrow_transfer', + 'escrow_dispute', + 'escrow_release', + 'pow2', + 'escrow_approve', + 'transfer_to_savings', + 'transfer_from_savings', + 'cancel_transfer_from_savings', + 'custom_binary', + 'decline_voting_rights', + 'reset_account', + 'set_reset_account', + 'claim_reward_balance', + 'delegate_vesting_shares', + 'account_create_with_delegation', + 'fill_convert_request', + 'author_reward', + 'curation_reward', + 'comment_reward', + 'liquidity_reward', + 'interest', + 'fill_vesting_withdraw', + 'fill_order', + 'shutdown_witness', + 'fill_transfer_from_savings', + 'hardfork', + 'comment_payout_update', + 'return_vesting_delegation', + 'comment_benefactor_reward', +] +operations = {o: ops.index(o) for o in ops} + + +def getOperationNameForId(i): + """ Convert an operation id into the corresponding string + """ + for key in operations: + if int(operations[key]) is int(i): + return key + return "Unknown Operation ID %d" % i diff --git a/bitsharesbase/operations.py b/steembase/operations.py similarity index 99% rename from bitsharesbase/operations.py rename to steembase/operations.py index 696dd276a0fa6bb81f7ec1d2cdb025e1bc189cc0..720ceaee94be2027be575b5c8f709ac2315b4cad 100644 --- a/bitsharesbase/operations.py +++ b/steembase/operations.py @@ -26,7 +26,7 @@ from .objects import ( AccountCreateExtensions ) -default_prefix = "BTS" +default_prefix = "STM" def getOperationNameForId(i): diff --git a/bitsharesbase/signedtransactions.py b/steembase/signedtransactions.py similarity index 91% rename from bitsharesbase/signedtransactions.py rename to steembase/signedtransactions.py index f56575018199cb77334d254c8e1f4091456bb5b5..d58fc5ce659546e3ce02f552a7a7900565d4c325 100644 --- a/bitsharesbase/signedtransactions.py +++ b/steembase/signedtransactions.py @@ -17,10 +17,10 @@ class Signed_Transaction(GrapheneSigned_Transaction): def __init__(self, *args, **kwargs): super(Signed_Transaction, self).__init__(*args, **kwargs) - def sign(self, wifkeys, chain="BTS"): + def sign(self, wifkeys, chain="STM"): return super(Signed_Transaction, self).sign(wifkeys, chain) - def verify(self, pubkeys=[], chain="BTS"): + def verify(self, pubkeys=[], chain="STM"): return super(Signed_Transaction, self).verify(pubkeys, chain) def getOperationKlass(self): diff --git a/bitsharesbase/transactions.py b/steembase/transactions.py similarity index 100% rename from bitsharesbase/transactions.py rename to steembase/transactions.py diff --git a/tests/.ropeproject/globalnames b/tests/.ropeproject/globalnames deleted file mode 100644 index 08fd0f766b4e0b248fa073425328342f538b4bcd..0000000000000000000000000000000000000000 --- a/tests/.ropeproject/globalnames +++ /dev/null @@ -1,4 +0,0 @@ -€}q(Ubitsharesbase.operations]q(Udefault_prefixqUAsset_fund_fee_poolqUTransferqUAsset_publish_feedqUBid_collateralqUgetOperationNameForIdqUAccount_updateq U Asset_reserveq -U Worker_createqUAccount_upgradeqUAsset_update_feed_producersq UProposal_updateqUAccount_createqUVesting_balance_withdrawqUCall_order_updateqULimit_order_cancelqUAccount_whitelistqUWitness_updateqU -Op_wrapperqUOverride_transferqUProposal_createqUAsset_updateqULimit_order_createqeUpeerplays.committee]qU CommitteeqaUtest_amount]qU TestcasesqaUtest_txbuffers]q(UwifqheUbitshares.transactionbuilder]q (Ulogq!UProposalBuilderq"UTransactionBuilderq#eUbitshares.bitshares]q$(h!U BitSharesq%eUbitshares.exceptions]q&(UNoWalletExceptionq'UBlockDoesNotExistsExceptionq(UAssetDoesNotExistsExceptionq)UInsufficientAuthorityErrorq*U%CommitteeMemberDoesNotExistsExceptionq+UMissingKeyErrorq,UWorkerDoesNotExistsExceptionq-UProposalDoesNotExistExceptionq.UInvalidAssetExceptionq/UWitnessDoesNotExistsExceptionq0UWalletExistsq1UWrongMasterPasswordExceptionq2UInvalidWifErrorq3U$VestingBalanceDoesNotExistsExceptionq4UObjectNotInProposalBufferq5UAccountDoesNotExistsExceptionq6UAccountExistsExceptionq7eUtest_proposals]q8(hheUbitshares.price]q9(U PriceFeedq:UUpdateCallOrderq;UOrderq<UFilledOrderq=UPriceq>eUbitsharesbase.objects]q?(hh>h:UAccountOptionsq@UWorker_initializerqAUMemoqBU -PermissionqCUAssetqDU AccountIdqEUAccountCreateExtensionsqFUAssetIdqGUSpecialAuthorityqHU ExtensionqIU OperationqJUAssetOptionsqKUObjectIdqLeUbitshares.account]qM(UAccountqNU AccountUpdateqOeUtest_objectcache]qPhaUtest_bitshares]qQ(hhU core_unitqReUtest_wallet]qS(hheUpeerplays.witness]qT(U WitnessesqUUWitnessqVeu. \ No newline at end of file diff --git a/tests/.ropeproject/history b/tests/.ropeproject/history deleted file mode 100644 index fcd9c963caaed6b4d36d014b5595385deef83d9e..0000000000000000000000000000000000000000 --- a/tests/.ropeproject/history +++ /dev/null @@ -1 +0,0 @@ -€]q(]q]qe. \ No newline at end of file diff --git a/tests/.ropeproject/objectdb b/tests/.ropeproject/objectdb deleted file mode 100644 index 29c40cda94351229c1ed18850732694b1aa17920..0000000000000000000000000000000000000000 --- a/tests/.ropeproject/objectdb +++ /dev/null @@ -1 +0,0 @@ -€}q. \ No newline at end of file diff --git a/tests/test_account.py b/tests/test_account.py index 6dfe2aa830a26d416572edf23712c3bdfba74188..1a3f12c329550cdeb7d743d8bb9bde5024453472 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -1,12 +1,12 @@ import unittest import mock from pprint import pprint -from bitshares import BitShares -from bitshares.account import Account -from bitshares.amount import Amount -from bitshares.asset import Asset -from bitshares.instance import set_shared_bitshares_instance -from bitsharesbase.operationids import getOperationNameForId +from steem import Steem +from steem.account import Account +from steem.amount import Amount +from steem.asset import Asset +from steem.instance import set_shared_bitshares_instance +from steembase.operationids import getOperationNameForId wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" diff --git a/tests/test_aes.py b/tests/test_aes.py index e2ad8e19f8d4629a667fc08ab11aa302592c285d..fc2a0b5fb671df44bc23ae791acc69e42432103f 100644 --- a/tests/test_aes.py +++ b/tests/test_aes.py @@ -3,7 +3,7 @@ import random import unittest import base64 from pprint import pprint -from bitshares.aes import AESCipher +from steem.aes import AESCipher class Testcases(unittest.TestCase): diff --git a/tests/test_amount.py b/tests/test_amount.py index e255a95a88ac96834001379bbac35f2a5da90770..bf6985d50198bc6b07efb99a742086f730a80f08 100644 --- a/tests/test_amount.py +++ b/tests/test_amount.py @@ -1,8 +1,8 @@ import unittest -from bitshares import BitShares -from bitshares.amount import Amount -from bitshares.asset import Asset -from bitshares.instance import set_shared_bitshares_instance, SharedInstance +from steem import Steem +from steem.amount import Amount +from steem.asset import Asset +from steem.instance import set_shared_steem_instance, SharedInstance class Testcases(unittest.TestCase): diff --git a/tests/test_bitshares.py b/tests/test_steem.py similarity index 100% rename from tests/test_bitshares.py rename to tests/test_steem.py diff --git a/tests/test_utils.py b/tests/test_utils.py index 1629bda948b026508e7eaf62a31c6f775af21a14..425bfb8cb0c01d92a9e9fe9c5d128a0e2519e6f7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,4 @@ -from bitshares.utils import assets_from_string +from steem.utils import assets_from_string def test_assets_from_string(): diff --git a/tests/test_wallet.py b/tests/test_wallet.py index 07c464022ad55a72e211d0cd0abafec94942dd0b..ebe3b5f6ff07f80daca55d1bd00e68988f83c524 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -1,12 +1,12 @@ import unittest import mock from pprint import pprint -from bitshares import BitShares -from bitshares.account import Account -from bitshares.amount import Amount -from bitshares.asset import Asset -from bitshares.instance import set_shared_bitshares_instance -from bitsharesbase.operationids import getOperationNameForId +from steem import Steem +from steem.account import Account +from steem.amount import Amount +from steem.asset import Asset +from steem.instance import set_shared_steem_instance +from steem.operationids import getOperationNameForId wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" @@ -16,12 +16,12 @@ class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.bts = BitShares( + self.stm = Steem( nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, # Overwrite wallet to use this list of wifs only wif=[wif] ) - self.bts.set_default_account("init0") - set_shared_bitshares_instance(self.bts) + self.stm.set_default_account("init0") + set_shared_steem_instance(self.stm) diff --git a/tox.ini b/tox.ini index 49ea089606c6c2afae8d551dc36b0bcf537448eb..d49d40b05342c1440f1a1c812e30782b8f78f774 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ commands= deps= flake8 commands= - flake8 --ignore=E501,F401 bitsharesapi bitsharesbase examples + flake8 --ignore=E501,F401 steemapi steembase examples [testenv:docs] basepython=