From 909763e8466515e50eb5448301a94ce5cc625b31 Mon Sep 17 00:00:00 2001
From: Holger Nahrstaedt <holger@nahrstaedt.de>
Date: Fri, 16 Feb 2018 17:16:49 +0100
Subject: [PATCH] first release version

---
 .travis.yml                   |   4 +-
 README.rst                    |   4 +-
 steempy/__init__.py           |   3 +-
 steempy/market.py             |  22 ----
 steempy/steem.py              | 208 ++++++++++------------------------
 steempy/transactionbuilder.py |   2 +-
 steempy/vesting.py            |  47 --------
 steempybase/objects.py        |  66 +++++++----
 steempybase/operations.py     |  41 ++++---
 steempybase/transactions.py   |  27 -----
 tests/test_steem.py           | 121 +++++++++-----------
 11 files changed, 193 insertions(+), 352 deletions(-)
 delete mode 100644 steempy/vesting.py

diff --git a/.travis.yml b/.travis.yml
index a8419ab5..94ea926d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ sudo: false
 matrix:
   include:
     - os: linux
-      python: 3.5
+      python: 3.6
       env:
         - PYFLAKES=1
         - PEP8=1
@@ -15,8 +15,6 @@ matrix:
         - pip install flake8
       script:
         - flake8
-    - os: linux
-      python: 3.5
     - os: linux
       python: 3.6
     - os: osx
diff --git a/README.rst b/README.rst
index c7166ed7..a4996c08 100644
--- a/README.rst
+++ b/README.rst
@@ -1,7 +1,7 @@
 steempy - Unofficial Python 3 Library for Steem
 =====================================
 
-!!!NOT WORKING AT THE MOMENT - DO NOT USE!!!
+!!!Alpha-State, be carefull!!!
 
 steemi is an unofficial python 3 library for steem, which is created new from scratch from https://github.com/xeroc/python-bitshares.
 
@@ -48,7 +48,7 @@ but possibly non-compiling version::
 
 Run tests after install::
 
-    python setup.py test
+    pytest
 
 Changelog
 =========
diff --git a/steempy/__init__.py b/steempy/__init__.py
index 4aa67f77..f5b16a82 100644
--- a/steempy/__init__.py
+++ b/steempy/__init__.py
@@ -8,12 +8,11 @@ __all__ = [
     "asset",
     "block",
     "blockchain",
-    "market",
+    # "market",
     "storage",
     "price",
     "utils",
     "wallet",
-    "vesting",
     "vote",
     "message"
 ]
diff --git a/steempy/market.py b/steempy/market.py
index 72bc4075..c2f973e7 100644
--- a/steempy/market.py
+++ b/steempy/market.py
@@ -127,28 +127,6 @@ class Market(dict):
         if cer["base"]["asset_id"] == self["quote"]["id"]:
             data["core_exchange_rate"] = data["core_exchange_rate"].invert()
 
-        # smartcoin stuff
-        if "bitasset_data_id" in self["quote"]:
-            bitasset = self.steem.rpc.get_object(self["quote"]["bitasset_data_id"])
-            backing_asset_id = bitasset["options"]["short_backing_asset"]
-            if backing_asset_id == self["base"]["id"]:
-                sp = bitasset["current_feed"]["settlement_price"]
-                data["quoteSettlement_price"] = Price(
-                    sp,
-                    steem_instance=self.steem
-                )
-                if sp["base"]["asset_id"] == self["quote"]["id"]:
-                    data["quoteSettlement_price"] = data["quoteSettlement_price"].invert()
-
-        elif "bitasset_data_id" in self["base"]:
-            bitasset = self.steem.rpc.get_object(self["base"]["bitasset_data_id"])
-            backing_asset_id = bitasset["options"]["short_backing_asset"]
-            if backing_asset_id == self["quote"]["id"]:
-                data["baseSettlement_price"] = Price(
-                    bitasset["current_feed"]["settlement_price"],
-                    steem_instance=self.steem
-                )
-
         ticker = self.steem.rpc.get_ticker(
             self["base"]["id"],
             self["quote"]["id"],
diff --git a/steempy/steem.py b/steempy/steem.py
index bdd1fdd6..c4dcb602 100644
--- a/steempy/steem.py
+++ b/steempy/steem.py
@@ -10,7 +10,6 @@ from .account import Account
 from .amount import Amount
 from .price import Price
 from .witness import Witness
-from .vesting import Vesting
 from .storage import configStorage as config
 from .exceptions import (
     AccountExistsException,
@@ -115,6 +114,7 @@ class Steem(object):
             kwargs["apis"] = [
                 "database",
                 "network_broadcast",
+                "market_history_api"
             ]
 
         self.rpc = None
@@ -360,17 +360,11 @@ class Steem(object):
             to_account=to,
             steem_instance=self
         )
-
         op = operations.Transfer(**{
-            "fee": {"amount": 0, "asset_id": "1.3.0"},
-            "from": account["id"],
-            "to": to["id"],
-            "amount": {
-                "amount": int(amount),
-                "asset_id": amount.asset["id"]
-            },
+            "amount": amount,
+            "to": to["name"],
             "memo": memoObj.encrypt(memo),
-            "prefix": self.prefix
+            "from": account["name"],
         })
         return self.finalizeOp(op, account, "active", **kwargs)
 
@@ -381,17 +375,17 @@ class Steem(object):
         self,
         account_name,
         registrar=None,
-        referrer="1.2.35641",
-        referrer_percent=50,
         owner_key=None,
         active_key=None,
         memo_key=None,
+        posting_key=None,
         password=None,
         additional_owner_keys=[],
         additional_active_keys=[],
+        additional_posting_keys=[],
         additional_owner_accounts=[],
         additional_active_accounts=[],
-        proxy_account="proxy-to-self",
+        additional_posting_accounts=[],
         storekeys=True,
         **kwargs
     ):
@@ -456,7 +450,6 @@ class Steem(object):
         except:
             pass
 
-        referrer = Account(referrer, steem_instance=self)
         registrar = Account(registrar, steem_instance=self)
 
         " Generate new keys from password"
@@ -464,11 +457,14 @@ class Steem(object):
         if password:
             active_key = PasswordKey(account_name, password, role="active")
             owner_key = PasswordKey(account_name, password, role="owner")
+            posting_key = PasswordKey(account_name, password, role="posting")
             memo_key = PasswordKey(account_name, password, role="memo")
             active_pubkey = active_key.get_public_key()
             owner_pubkey = owner_key.get_public_key()
+            posting_pubkey = posting_key.get_public_key()
             memo_pubkey = memo_key.get_public_key()
             active_privkey = active_key.get_private_key()
+            posting_privkey = posting_key.get_private_key()
             # owner_privkey   = owner_key.get_private_key()
             memo_privkey = memo_key.get_private_key()
             # store private keys
@@ -476,11 +472,14 @@ class Steem(object):
                 # self.wallet.addPrivateKey(owner_privkey)
                 self.wallet.addPrivateKey(active_privkey)
                 self.wallet.addPrivateKey(memo_privkey)
-        elif (owner_key and active_key and memo_key):
+                self.wallet.addPrivateKey(posting_privkey)
+        elif (owner_key and active_key and memo_key and posting_key):
             active_pubkey = PublicKey(
                 active_key, prefix=self.prefix)
             owner_pubkey = PublicKey(
                 owner_key, prefix=self.prefix)
+            posting_pubkey = PublicKey(
+                posting_key, prefix=self.prefix)
             memo_pubkey = PublicKey(
                 memo_key, prefix=self.prefix)
         else:
@@ -489,36 +488,38 @@ class Steem(object):
             )
         owner = format(owner_pubkey, self.prefix)
         active = format(active_pubkey, self.prefix)
+        posting = format(posting_pubkey, self.prefix)
         memo = format(memo_pubkey, self.prefix)
 
         owner_key_authority = [[owner, 1]]
         active_key_authority = [[active, 1]]
+        posting_key_authority = [[posting, 1]]
         owner_accounts_authority = []
         active_accounts_authority = []
+        posting_accounts_authority = []
 
         # additional authorities
         for k in additional_owner_keys:
             owner_key_authority.append([k, 1])
         for k in additional_active_keys:
             active_key_authority.append([k, 1])
+        for k in additional_posting_keys:
+            posting_key_authority.append([k, 1])
 
         for k in additional_owner_accounts:
             addaccount = Account(k, steem_instance=self)
-            owner_accounts_authority.append([addaccount["id"], 1])
+            owner_accounts_authority.append([addaccount["name"], 1])
         for k in additional_active_accounts:
             addaccount = Account(k, steem_instance=self)
-            active_accounts_authority.append([addaccount["id"], 1])
-
-        # voting account
-        voting_account = Account(
-            proxy_account or "proxy-to-self", steem_instance=self)
+            active_accounts_authority.append([addaccount["name"], 1])
+        for k in additional_posting_accounts:
+            addaccount = Account(k, steem_instance=self)
+            posting_accounts_authority.append([addaccount["name"], 1])
 
         op = {
-            "fee": {"amount": 0, "asset_id": "SBD"},
-            "registrar": registrar["id"],
-            "referrer": referrer["id"],
-            "referrer_percent": referrer_percent * 100,
-            "name": account_name,
+            "fee": Amount(0, "STEEM"),
+            "creator": registrar["name"],
+            "new_account_name": account_name,
             'owner': {'account_auths': owner_accounts_authority,
                       'key_auths': owner_key_authority,
                       "address_auths": [],
@@ -528,21 +529,11 @@ class Steem(object):
                        "address_auths": [],
                        'weight_threshold': 1},
             'posting': {'account_auths': active_accounts_authority,
-                       'key_auths': active_key_authority,
-                       "address_auths": [],
-                       'weight_threshold': 1},
-            'memo': {'account_auths': active_accounts_authority,
-                       'key_auths': active_key_authority,
-                       "address_auths": [],
-                       'weight_threshold': 1},
-            "options": {"voting_account": voting_account["id"],
-                        "num_witness": 0,
-                        "num_committee": 0,
-                        "votes": [],
-                        "extensions": []
-                        },
-            "extensions": {},
-            "prefix": self.prefix
+                        'key_auths': posting_key_authority,
+                        "address_auths": [],
+                        'weight_threshold': 1},
+            'memo_key': memo,
+            "json_metadata": {},
         }
         op = operations.Account_create(**op)
         return self.finalizeOp(op, registrar, "active", **kwargs)
@@ -585,7 +576,7 @@ class Steem(object):
             raise ValueError("Cannot have threshold of 0")
 
     def allow(
-        self, foreign, weight=None, permission="active",
+        self, foreign, weight=None, permission="posting",
         account=None, threshold=None, **kwargs
     ):
         """ Give additional access to an account by some other public
@@ -610,9 +601,9 @@ class Steem(object):
         if not account:
             raise ValueError("You need to provide an account")
 
-        if permission not in ["owner", "active"]:
+        if permission not in ["owner", "posting", "active"]:
             raise ValueError(
-                "Permission needs to be either 'owner', or 'active"
+                "Permission needs to be either 'owner', 'posting', or 'active"
             )
         account = Account(account, steem_instance=self)
 
@@ -642,10 +633,10 @@ class Steem(object):
             self._test_weights_treshold(authority)
 
         op = operations.Account_update(**{
-            "fee": {"amount": 0, "asset_id": "SBD"},
-            "account": account["id"],
+            "account": account["name"],
             permission: authority,
-            "extensions": {},
+            "memo_key": account["memo_key"],
+            "json_metadata": account["json_metadata"],
             "prefix": self.prefix
         })
         if permission == "owner":
@@ -654,7 +645,7 @@ class Steem(object):
             return self.finalizeOp(op, account["name"], "active", **kwargs)
 
     def disallow(
-        self, foreign, permission="active",
+        self, foreign, permission="posting",
         account=None, threshold=None, **kwargs
     ):
         """ Remove additional access to an account by some other public
@@ -674,9 +665,9 @@ class Steem(object):
         if not account:
             raise ValueError("You need to provide an account")
 
-        if permission not in ["owner", "active"]:
+        if permission not in ["owner", "active", "posting"]:
             raise ValueError(
-                "Permission needs to be either 'owner', or 'active"
+                "Permission needs to be either 'owner', 'posting', or 'active"
             )
         account = Account(account, steem_instance=self)
         authority = account[permission]
@@ -726,10 +717,10 @@ class Steem(object):
             self._test_weights_treshold(authority)
 
         op = operations.Account_update(**{
-            "fee": {"amount": 0, "asset_id": "SBD"},
-            "account": account["id"],
+            "account": account["name"],
             permission: authority,
-            "extensions": {}
+            "memo_key": account["memo_key"],
+            "json_metadata": account["json_metadata"]
         })
         if permission == "owner":
             return self.finalizeOp(op, account["name"], "owner", **kwargs)
@@ -757,16 +748,16 @@ class Steem(object):
         account = Account(account, steem_instance=self)
         account["memo_key"] = key
         op = operations.Account_update(**{
-            "account": account["id"],
+            "account": account["name"],
             "memo_key": account["memo_key"],
-            "extensions": {}
+            "json_metadata": account["json_metadata"]
         })
         return self.finalizeOp(op, account["name"], "active", **kwargs)
 
     # -------------------------------------------------------------------------
     #  Approval and Disapproval of witnesses
     # -------------------------------------------------------------------------
-    def approvewitness(self, witnesses, account=None, **kwargs):
+    def approvewitness(self, witness, account=None, approve=True, **kwargs):
         """ Approve a witness
 
             :param list witnesses: list of Witness name or id
@@ -779,111 +770,26 @@ class Steem(object):
         if not account:
             raise ValueError("You need to provide an account")
         account = Account(account, steem_instance=self)
-        options = account["options"]
-
-        if not isinstance(witnesses, (list, set, tuple)):
-            witnesses = {witnesses}
 
-        for witness in witnesses:
-            witness = Witness(witness, steem_instance=self)
-            options["votes"].append(witness["vote_id"])
+        # if not isinstance(witnesses, (list, set, tuple)):
+        #     witnesses = {witnesses}
 
-        options["votes"] = list(set(options["votes"]))
-        options["num_witness"] = len(list(filter(
-            lambda x: float(x.split(":")[0]) == 1,
-            options["votes"]
-        )))
+        # for witness in witnesses:
+        #     witness = Witness(witness, steem_instance=self)
 
-        op = operations.Account_update(**{
-            "fee": {"amount": 0, "asset_id": "SBD"},
+        op = operations.Account_Witness_Vote(**{
             "account": account["id"],
-            "new_options": options,
-            "extensions": {},
-            "prefix": self.prefix
+            "witness": witness,
+            "approve": approve
         })
         return self.finalizeOp(op, account["name"], "active", **kwargs)
 
-    def disapprovewitness(self, witnesses, account=None, **kwargs):
+    def disapprovewitness(self, witness, account=None, **kwargs):
         """ Disapprove a witness
 
             :param list witnesses: list of Witness name or id
             :param str account: (optional) the account to allow access
                 to (defaults to ``default_account``)
         """
-        if not account:
-            if "default_account" in config:
-                account = config["default_account"]
-        if not account:
-            raise ValueError("You need to provide an account")
-        account = Account(account, steem_instance=self)
-        options = account["options"]
-
-        if not isinstance(witnesses, (list, set, tuple)):
-            witnesses = {witnesses}
-
-        for witness in witnesses:
-            witness = Witness(witness, steem_instance=self)
-            if witness["vote_id"] in options["votes"]:
-                options["votes"].remove(witness["vote_id"])
-
-        options["votes"] = list(set(options["votes"]))
-        options["num_witness"] = len(list(filter(
-            lambda x: float(x.split(":")[0]) == 1,
-            options["votes"]
-        )))
-
-        op = operations.Account_update(**{
-            "fee": {"amount": 0, "asset_id": "SBD"},
-            "account": account["id"],
-            "new_options": options,
-            "extensions": {},
-            "prefix": self.prefix
-        })
-        return self.finalizeOp(op, account["name"], "active", **kwargs)
-
-    def cancel(self, orderNumbers, account=None, **kwargs):
-        """ Cancels an order you have placed in a given market. Requires
-            only the "orderNumbers". An order number takes the form
-            ``1.7.xxx``.
-
-            :param str orderNumbers: The Order Object ide of the form ``1.7.xxxx``
-        """
-        if not account:
-            if "default_account" in config:
-                account = config["default_account"]
-        if not account:
-            raise ValueError("You need to provide an account")
-        account = Account(account, full=False, steem_instance=self)
-
-        if not isinstance(orderNumbers, (list, set, tuple)):
-            orderNumbers = {orderNumbers}
-
-        op = []
-        for order in orderNumbers:
-            op.append(
-                operations.Limit_order_cancel(**{
-                    "fee": {"amount": 0, "asset_id": "SBD"},
-                    "fee_paying_account": account["id"],
-                    "order": order,
-                    "extensions": [],
-                    "prefix": self.prefix}))
-        return self.finalizeOp(op, account["name"], "active", **kwargs)
-
-    def update_witness(self, witness_identifier, url=None, key=None, **kwargs):
-        """ Upgrade a witness account
-
-            :param str witness_identifier: Identifier for the witness
-            :param str url: New URL for the witness
-            :param str key: Public Key for the signing
-        """
-        witness = Witness(witness_identifier)
-        account = witness.account
-        op = operations.Witness_update(**{
-            "fee": {"amount": 0, "asset_id": "SBD"},
-            "prefix": self.prefix,
-            "witness": witness["id"],
-            "witness_account": account["id"],
-            "new_url": url,
-            "new_signing_key": key,
-        })
-        return self.finalizeOp(op, account["name"], "active", **kwargs)
+        return self.approvewitness(
+            witness=witness, account=account, approve=False)
diff --git a/steempy/transactionbuilder.py b/steempy/transactionbuilder.py
index 2baa1d3e..1fc387a9 100644
--- a/steempy/transactionbuilder.py
+++ b/steempy/transactionbuilder.py
@@ -165,7 +165,7 @@ class TransactionBuilder(dict):
             ops.extend([Operation(op)])
 
         # We no wrap everything into an actual transaction
-        ops = transactions.addRequiredFees(self.steem.rpc, ops)
+        # ops = transactions.addRequiredFees(self.steem.rpc, ops)
         expiration = transactions.formatTimeFromNow(
             self.expiration or self.steem.expiration
         )
diff --git a/steempy/vesting.py b/steempy/vesting.py
deleted file mode 100644
index 54cb8612..00000000
--- a/steempy/vesting.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from .account import Account
-from .exceptions import VestingBalanceDoesNotExistsException
-from .blockchainobject import BlockchainObject
-
-
-class Vesting(BlockchainObject):
-    """ Read data about a Vesting Balance in the chain
-
-        :param str id: Id of the vesting balance
-        :param steem steem_instance: Steem() instance to use when accesing a RPC
-
-    """
-    type_id = 13
-
-    def refresh(self):
-        obj = self.steem.rpc.get_objects([self.identifier])[0]
-        if not obj:
-            raise VestingBalanceDoesNotExistsException
-        super(Vesting, self).__init__(obj, steem_instance=self.steem)
-
-    @property
-    def account(self):
-        return Account(self["owner"], steem_instance=self.steem)
-
-    @property
-    def claimable(self):
-        from .amount import Amount
-        if self["policy"][0] == 1:
-            p = self["policy"][1]
-            ratio = (
-                (float(p["coin_seconds_earned"]) /
-                    float(self["balance"]["amount"])) /
-                float(p["vesting_seconds"])
-            ) if float(p["vesting_seconds"]) > 0.0 else 1
-            return Amount(
-                self["balance"],
-                steem_instance=self.steem
-            ) * ratio
-        else:
-            raise NotImplementedError("This policy isn't implemented yet")
-
-    def claim(self, amount=None):
-        return self.steem.vesting_balance_withdraw(
-            self["id"],
-            amount=amount,
-            account=self["owner"]
-        )
diff --git a/steempybase/objects.py b/steempybase/objects.py
index 8bc48da8..65c63e50 100644
--- a/steempybase/objects.py
+++ b/steempybase/objects.py
@@ -13,6 +13,7 @@ from .objecttypes import object_type
 from .account import PublicKey
 from graphenebase.objects import Operation as GPHOperation
 from .operationids import operations
+import struct
 default_prefix = "STM"
 
 asset_precision = {
@@ -34,19 +35,44 @@ class ObjectId(GPHObjectId):
     """ Encodes object/protocol ids
     """
     def __init__(self, object_str, type_verify=None):
-        if len(object_str.split(".")) == 3:
-            space, type, id = object_str.split(".")
-            self.space = int(space)
-            self.type = int(type)
-            self.instance = Id(int(id))
-            self.Id = object_str
-            if type_verify:
-                assert object_type[type_verify] == int(type),\
-                    "Object id does not match object type! " +\
-                    "Excpected %d, got %d" %\
-                    (object_type[type_verify], int(type))
+        # space, type, id = object_str.split(".")
+        # self.space = int(space)
+        # self.type = int(type)
+        self.instance = Id(int(object_str))
+        self.Id = object_str
+        # if type_verify:
+        #     assert object_type[type_verify] == int(type),\
+        #        "Object id does not match object type! " +\
+        #        "Excpected %d, got %d" %\
+        #        (object_type[type_verify], int(type))
+        # else:
+        #     raise Exception("Object id is invalid")
+
+
+class Amount():
+    def __init__(self, d):
+        if isinstance(d, str):
+            self.amount, self.asset = d.strip().split(" ")
+            self.amount = float(self.amount)
+
+            if self.asset in asset_precision:
+                self.precision = asset_precision[self.asset]
+            else:
+                raise Exception("Asset unknown")
         else:
-            raise Exception("Object id is invalid")
+            self.amount = d.amount
+            self.asset = d.symbol
+            self.precision = d.asset.precision
+
+    def __bytes__(self):
+        # padding
+        asset = self.asset + "\x00" * (7 - len(self.asset))
+        amount = round(float(self.amount) * 10**self.precision)
+        return (struct.pack("<q", amount) + struct.pack("<b", self.precision) +
+                bytes(asset, "ascii"))
+
+    def __str__(self):
+        return '{:.{}f} {}'.format(self.amount, self.precision, self.asset)
 
 
 class Operation(GPHOperation):
@@ -73,7 +99,7 @@ class Operation(GPHOperation):
         return json.loads(str(self))
 
 
-class Asset(GrapheneObject):
+class Transfer(GrapheneObject):
     def __init__(self, *args, **kwargs):
         if isArgsThisClass(self, args):
                 self.data = args[0].data
@@ -81,8 +107,10 @@ class Asset(GrapheneObject):
             if len(args) == 1 and len(kwargs) == 0:
                 kwargs = args[0]
             super().__init__(OrderedDict([
-                ('amount', Int64(kwargs["amount"])),
-                ('asset_id', ObjectId(kwargs["asset_id"], "asset"))
+                ('from', String(kwargs["from"])),
+                ('to', String(kwargs["to"])),
+                ('amount', Amount(kwargs["amount"])),
+                ('memo', String(kwargs["memo"])),
             ]))
 
 
@@ -113,7 +141,7 @@ class WitnessProps(GrapheneObject):
             if len(args) == 1 and len(kwargs) == 0:
                 kwargs = args[0]
             super().__init__(OrderedDict([
-                ('account_creation_fee', Asset(kwargs["account_creation_fee"])),
+                ('account_creation_fee', Amount(kwargs["account_creation_fee"])),
                 ('maximum_block_size', Uint32(kwargs["maximum_block_size"])),
                 ('sbd_interest_rate', Uint16(kwargs["sbd_interest_rate"])),
             ]))
@@ -127,8 +155,8 @@ class Price(GrapheneObject):
             if len(args) == 1 and len(kwargs) == 0:
                 kwargs = args[0]
             super().__init__(OrderedDict([
-                ('base', Asset(kwargs["base"])),
-                ('quote', Asset(kwargs["quote"]))
+                ('base', Amount(kwargs["base"])),
+                ('quote', Amount(kwargs["quote"]))
             ]))
 
 
@@ -150,7 +178,7 @@ class Permission(GrapheneObject):
                 reverse=False,
             )
             accountAuths = Map([
-                [ObjectId(e[0], "account"), Uint16(e[1])]
+                [String(e[0]), Uint16(e[1])]
                 for e in kwargs["account_auths"]
             ])
             keyAuths = Map([
diff --git a/steempybase/operations.py b/steempybase/operations.py
index 38ff7e02..77a9292a 100644
--- a/steempybase/operations.py
+++ b/steempybase/operations.py
@@ -12,8 +12,9 @@ from .account import PublicKey
 from .operationids import operations
 from .objects import (
     Operation,
-    Asset,
     Memo,
+    Amount,
+    Extension,
     Price,
     WitnessProps,
     Permission,
@@ -53,9 +54,9 @@ class Transfer(GrapheneObject):
             else:
                 memo = Optional(None)
             super().__init__(OrderedDict([
-                ('from', ObjectId(kwargs["from"], "account")),
-                ('to', ObjectId(kwargs["to"], "account")),
-                ('amount', Asset(kwargs["amount"])),
+                ('from', (kwargs["from"])),
+                ('to', (kwargs["to"])),
+                ('amount', Amount(kwargs["amount"])),
                 ('memo', memo),
                 ('extensions', Set([])),
             ]))
@@ -69,14 +70,28 @@ class Vote(GrapheneObject):
             if len(args) == 1 and len(kwargs) == 0:
                 kwargs = args[0]
             super().__init__(OrderedDict([
-                ('Voter', String(kwargs["voter"])),
+                ('Voter', (kwargs["voter"])),
                 ('author', ObjectId(kwargs["author"], "account")),
-                ('permlink', String(kwargs["permlink"])),
+                ('permlink', (kwargs["permlink"])),
                 ('weight', Int16(kwargs["feed"])),
                 ('extensions', Set([])),
             ]))
 
 
+class Account_Witness_Vote(GrapheneObject):
+    def __init__(self, *args, **kwargs):
+        if isArgsThisClass(self, args):
+            self.data = args[0].data
+        else:
+            if len(args) == 1 and len(kwargs) == 0:
+                kwargs = args[0]
+            super().__init__(OrderedDict([
+                ('account', String(kwargs["account"])),
+                ('witness', String(kwargs["witness"])),
+                ('approve', Bool(bool(kwargs["approve"]))),
+            ]))
+
+
 class Op_wrapper(GrapheneObject):
     def __init__(self, *args, **kwargs):
         if isArgsThisClass(self, args):
@@ -104,14 +119,14 @@ class Account_create(GrapheneObject):
                        ) <= 16, "Account name must be at most 16 chars long"
 
             super().__init__(OrderedDict([
-                ('fee', Asset(kwargs["fee"])),
-                ('creator', ObjectId(kwargs["creator"], "account")),
+                ('fee', Amount(kwargs["fee"])),
+                ('creator', String(kwargs["creator"])),
                 ('new_account_name', String(kwargs["new_account_name"])),
                 ('owner', Permission(kwargs["owner"], prefix=prefix)),
                 ('active', Permission(kwargs["active"], prefix=prefix)),
                 ('posting', Permission(kwargs["posting"], prefix=prefix)),
-                ('memo_key', Permission(kwargs["memo_key"], prefix=prefix)),
-                ('json_metadata', AccountCreateExtensions(kwargs["json_metadata"])),
+                ('memo_key', String(kwargs["memo_key"])),
+                ('json_metadata', Set(kwargs["json_metadata"])),
             ]))
 
 
@@ -146,12 +161,12 @@ class Account_update(GrapheneObject):
                 memo_key = Optional(None)
 
             super().__init__(OrderedDict([
-                ('account', ObjectId(kwargs["account"], "account")),
+                ('account', (kwargs["account"])),
                 ('owner', owner),
                 ('active', active),
                 ('posting', posting),
                 ('memo_key', memo_key),
-                ('json_metadata', AccountCreateExtensions(kwargs["json_metadata"])),
+                ('json_metadata', Set(kwargs["json_metadata"])),
             ]))
 
 
@@ -178,5 +193,5 @@ class Witness_update(GrapheneObject):
                 ('url', url),
                 ('block_signing_key', block_signing_key),
                 ('props', WitnessProps(kwargs["props"])),
-                ('fee', Asset(kwargs["fee"])),
+                ('fee', Amount(kwargs["fee"])),
             ]))
diff --git a/steempybase/transactions.py b/steempybase/transactions.py
index ff1ef7e0..dfdf1234 100644
--- a/steempybase/transactions.py
+++ b/steempybase/transactions.py
@@ -6,31 +6,4 @@ from .operations import (
     Op_wrapper,
     Account_create,
 )
-from .objects import Asset
 from graphenebase.transactions import getBlockParams, formatTimeFromNow, timeformat
-
-
-def addRequiredFees(ws, ops, asset_id="1.3.0"):
-    """ Auxiliary method to obtain the required fees for a set of
-        operations. Requires a websocket connection to a witness node!
-    """
-    fees = ws.get_required_fees([i.json() for i in ops], asset_id)
-    for i, d in enumerate(ops):
-        if isinstance(fees[i], list):
-            # Operation is a proposal
-            ops[i].op.data["fee"] = Asset(
-                amount=fees[i][0]["amount"],
-                asset_id=fees[i][0]["asset_id"]
-            )
-            for j, _ in enumerate(ops[i].op.data["proposed_ops"].data):
-                ops[i].op.data["proposed_ops"].data[j].data["op"].op.data["fee"] = (
-                    Asset(
-                        amount=fees[i][1][j]["amount"],
-                        asset_id=fees[i][1][j]["asset_id"]))
-        else:
-            # Operation is a regular operation
-            ops[i].op.data["fee"] = Asset(
-                amount=fees[i]["amount"],
-                asset_id=fees[i]["asset_id"]
-            )
-    return ops
diff --git a/tests/test_steem.py b/tests/test_steem.py
index 379b6f36..735bf25f 100644
--- a/tests/test_steem.py
+++ b/tests/test_steem.py
@@ -10,7 +10,7 @@ from steempybase.account import PrivateKey
 from steempy.instance import set_shared_steem_instance
 
 wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
-core_unit = "STEEM"
+core_unit = "STM"
 
 
 class Testcases(unittest.TestCase):
@@ -19,7 +19,7 @@ class Testcases(unittest.TestCase):
         super().__init__(*args, **kwargs)
 
         self.bts = Steem(
-            "wss://testnet.steem.vc",
+            # "wss://testnet.steem.vc",
             nobroadcast=True,
             keys={"active": wif, "owner": wif, "memo": wif},
         )
@@ -28,52 +28,19 @@ class Testcases(unittest.TestCase):
         set_shared_steem_instance(self.bts)
         self.bts.set_default_account("test")
 
-
-"""
-    def test_connect(self):
-        self.bts.connect()
-
-    def test_set_default_account(self):
-        self.bts.set_default_account("test")
-
-    def test_info(self):
-        info = self.bts.info()
-        for key in ['current_witness',
-                    'head_block_id',
-                    'head_block_number',
-                    'id',
-                    'last_irreversible_block_num',
-                    'next_maintenance_time',
-                    'recently_missed_count',
-                    'time']:
-            self.assertTrue(key in info)
-
-    def test_finalizeOps(self):
-        bts = self.bts
-        tx1 = bts.new_tx()
-        tx2 = bts.new_tx()
-        self.bts.transfer("init1", 1, core_unit, append_to=tx1)
-        self.bts.transfer("init1", 2, core_unit, append_to=tx2)
-        self.bts.transfer("init1", 3, core_unit, append_to=tx1)
-        tx1 = tx1.json()
-        tx2 = tx2.json()
-        ops1 = tx1["operations"]
-        ops2 = tx2["operations"]
-        self.assertEqual(len(ops1), 2)
-        self.assertEqual(len(ops2), 1)
-
     def test_transfer(self):
         bts = self.bts
+        # bts.prefix ="STX"
         tx = bts.transfer(
-            "1.2.8", 1.33, core_unit, memo="Foobar", account="1.2.7")
+            "test", 1.33, "SBD", memo="Foobar", account="test1")
         self.assertEqual(
             getOperationNameForId(tx["operations"][0][0]),
             "transfer"
         )
         op = tx["operations"][0][1]
         self.assertIn("memo", op)
-        self.assertEqual(op["from"], "1.2.7")
-        self.assertEqual(op["to"], "1.2.8")
+        self.assertEqual(op["from"], "test1")
+        self.assertEqual(op["to"], "test")
         amount = Amount(op["amount"])
         self.assertEqual(float(amount), 1.33)
 
@@ -84,19 +51,18 @@ class Testcases(unittest.TestCase):
         key2 = PrivateKey()
         key3 = PrivateKey()
         key4 = PrivateKey()
+        key5 = PrivateKey()
         tx = bts.create_account(
             name,
-            registrar="init0",   # 1.2.7
-            referrer="init1",    # 1.2.8
-            referrer_percent=33,
+            registrar="test",   # 1.2.7
             owner_key=format(key1.pubkey, core_unit),
             active_key=format(key2.pubkey, core_unit),
-            memo_key=format(key3.pubkey, core_unit),
-            additional_owner_keys=[format(key4.pubkey, core_unit)],
-            additional_active_keys=[format(key4.pubkey, core_unit)],
-            additional_owner_accounts=["committee-account"],  # 1.2.0
-            additional_active_accounts=["committee-account"],
-            proxy_account="init0",
+            posting_key=format(key3.pubkey, core_unit),
+            memo_key=format(key4.pubkey, core_unit),
+            additional_owner_keys=[format(key5.pubkey, core_unit)],
+            additional_active_keys=[format(key5.pubkey, core_unit)],
+            additional_owner_accounts=["test1"],  # 1.2.0
+            additional_active_accounts=["test1"],
             storekeys=False
         )
         self.assertEqual(
@@ -106,36 +72,61 @@ class Testcases(unittest.TestCase):
         op = tx["operations"][0][1]
         role = "active"
         self.assertIn(
-            format(key4.pubkey, core_unit),
+            format(key5.pubkey, core_unit),
             [x[0] for x in op[role]["key_auths"]])
         self.assertIn(
-            format(key4.pubkey, core_unit),
+            format(key5.pubkey, core_unit),
             [x[0] for x in op[role]["key_auths"]])
         self.assertIn(
-            "1.2.0",
+            "test1",
             [x[0] for x in op[role]["account_auths"]])
         role = "owner"
         self.assertIn(
-            format(key4.pubkey, core_unit),
+            format(key5.pubkey, core_unit),
             [x[0] for x in op[role]["key_auths"]])
         self.assertIn(
-            format(key4.pubkey, core_unit),
+            format(key5.pubkey, core_unit),
             [x[0] for x in op[role]["key_auths"]])
         self.assertIn(
-            "1.2.0",
+            "test1",
             [x[0] for x in op[role]["account_auths"]])
         self.assertEqual(
-            op["options"]["voting_account"],
-            "1.2.6")
-        self.assertEqual(
-            op["registrar"],
-            "1.2.6")
-        self.assertEqual(
-            op["referrer"],
-            "1.2.7")
-        self.assertEqual(
-            op["referrer_percent"],
-            33 * 100)
+            op["creator"],
+            "test")
+
+
+"""
+    def test_connect(self):
+        self.bts.connect()
+
+    def test_set_default_account(self):
+        self.bts.set_default_account("test")
+
+    def test_info(self):
+        info = self.bts.info()
+        for key in ['current_witness',
+                    'head_block_id',
+                    'head_block_number',
+                    'id',
+                    'last_irreversible_block_num',
+                    'next_maintenance_time',
+                    'recently_missed_count',
+                    'time']:
+            self.assertTrue(key in info)
+
+    def test_finalizeOps(self):
+        bts = self.bts
+        tx1 = bts.new_tx()
+        tx2 = bts.new_tx()
+        self.bts.transfer("init1", 1, core_unit, append_to=tx1)
+        self.bts.transfer("init1", 2, core_unit, append_to=tx2)
+        self.bts.transfer("init1", 3, core_unit, append_to=tx1)
+        tx1 = tx1.json()
+        tx2 = tx2.json()
+        ops1 = tx1["operations"]
+        ops2 = tx2["operations"]
+        self.assertEqual(len(ops1), 2)
+        self.assertEqual(len(ops2), 1)
 
     def test_weight_threshold(self):
         bts = self.bts
-- 
GitLab