From 76021f36c6bbf2800cf8dc04456dba0bf59382bb Mon Sep 17 00:00:00 2001
From: Holger <holger@nahrstaedt.de>
Date: Tue, 25 Sep 2018 18:11:02 +0200
Subject: [PATCH] Preparing first release for HF20, adapt account create for
 HF20

---
 CHANGELOG.rst               |   8 +++
 beem/steem.py               | 108 ++++++++----------------------------
 beem/version.py             |   2 +-
 beemapi/version.py          |   2 +-
 beembase/version.py         |   2 +-
 beemgraphenebase/version.py |   2 +-
 setup.py                    |   2 +-
 tests/beem/test_steem.py    |  62 +--------------------
 8 files changed, 37 insertions(+), 151 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index d33cd2c7..589952d8 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,13 @@
 Changelog
 =========
+0.19.57
+--------
+* last hf19 release
+* working witness_set_properties  operation
+* witness_set_properties() added to steem
+* beempy witnessproperties added
+* beempy pricefeed uses witnessproperties  when witness wif is provided
+
 0.19.56
 -------
 * adding methods to claim and create discounted accouts (PR #84) by crokkon
diff --git a/beem/steem.py b/beem/steem.py
index 1d927204..4d256f5a 100644
--- a/beem/steem.py
+++ b/beem/steem.py
@@ -1003,7 +1003,6 @@ class Steem(object):
         storekeys=True,
         store_owner_key=False,
         json_meta=None,
-        delegation_fee_steem='0 STEEM',
         **kwargs
     ):
         """ Create new account on Steem
@@ -1035,15 +1034,6 @@ class Steem(object):
             .. note:: Account creations cost a fee that is defined by
                        the network. If you create an account, you will
                        need to pay for that fee!
-                       **You can partially pay that fee by delegating VESTS.**
-                       To pay the fee in full in STEEM, leave
-                       ``delegation_fee_steem`` set to ``0 STEEM`` (Default).
-                       To pay the fee partially in STEEM, partially with delegated
-                       VESTS, set ``delegation_fee_steem`` to a value greater than ``1
-                       STEEM``. `Required VESTS will be calculated automatically.`
-                       To pay the fee with maximum amount of delegation, set
-                       ``delegation_fee_steem`` to ``1 STEEM``. `Required VESTS will be
-                       calculated automatically.`
 
             :param str account_name: (**required**) new account name
             :param str json_meta: Optional meta data for the account
@@ -1063,10 +1053,7 @@ class Steem(object):
                 names
             :param bool storekeys: Store new keys in the wallet (default:
                 ``True``)
-            :param delegation_fee_steem: If set, `creator` pays a
-                fee of this amount, and delegates the rest with VESTS (calculated
-                automatically). Minimum: 1 STEEM. If left to 0 (Default), full fee
-                is paid without VESTS delegation.
+
             :param str creator: which account should pay the registration fee
                                 (defaults to ``default_account``)
             :raises AccountExistsException: if the account already exists on
@@ -1091,14 +1078,6 @@ class Steem(object):
             pass
 
         creator = Account(creator, steem_instance=self)
-        if isinstance(delegation_fee_steem, string_types):
-            delegation_fee_steem = Amount(delegation_fee_steem, steem_instance=self)
-        elif isinstance(delegation_fee_steem, Amount):
-            delegation_fee_steem = Amount(delegation_fee_steem, steem_instance=self)
-        else:
-            delegation_fee_steem = Amount(delegation_fee_steem, "STEEM", steem_instance=self)
-        if not delegation_fee_steem["symbol"] == "STEEM":
-            raise AssertionError()
 
         " Generate new keys from password"
         from beemgraphenebase.account import PasswordKey
@@ -1170,69 +1149,28 @@ class Steem(object):
             posting_accounts_authority.append([addaccount["name"], 1])
 
         props = self.get_chain_properties()
-        required_fee_steem = Amount(props["account_creation_fee"], steem_instance=self) * 30
-        required_fee_vests = Amount(0, "VESTS", steem_instance=self)
-        if delegation_fee_steem.amount:
-            # creating accounts without delegation requires 30x
-            # account_creation_fee creating account with delegation allows one
-            # to use VESTS to pay the fee where the ratio must satisfy 1 STEEM
-            # in fee == 5 STEEM in delegated VESTS
-
-            delegated_sp_fee_mult = 5
-
-            if delegation_fee_steem.amount < 1:
-                raise ValueError(
-                    "When creating account with delegation, at least " +
-                    "1 STEEM in fee must be paid.")
-            # calculate required remaining fee in vests
-            remaining_fee = required_fee_steem - delegation_fee_steem
-            if remaining_fee.amount > 0:
-                required_sp = remaining_fee.amount * delegated_sp_fee_mult
-                required_fee_vests = Amount(self.sp_to_vests(required_sp) + 1, "VESTS", steem_instance=self)
-            op = {
-                "fee": delegation_fee_steem,
-                'delegation': required_fee_vests,
-                "creator": creator["name"],
-                "new_account_name": account_name,
-                'owner': {'account_auths': owner_accounts_authority,
-                          'key_auths': owner_key_authority,
-                          "address_auths": [],
-                          'weight_threshold': 1},
-                'active': {'account_auths': active_accounts_authority,
-                           'key_auths': active_key_authority,
-                           "address_auths": [],
-                           'weight_threshold': 1},
-                'posting': {'account_auths': active_accounts_authority,
-                            'key_auths': posting_key_authority,
-                            "address_auths": [],
-                            'weight_threshold': 1},
-                'memo_key': memo,
-                "json_metadata": json_meta or {},
-                "prefix": self.prefix,
-            }
-            op = operations.Account_create_with_delegation(**op)
-        else:
-            op = {
-                "fee": required_fee_steem,
-                "creator": creator["name"],
-                "new_account_name": account_name,
-                'owner': {'account_auths': owner_accounts_authority,
-                          'key_auths': owner_key_authority,
-                          "address_auths": [],
-                          'weight_threshold': 1},
-                'active': {'account_auths': active_accounts_authority,
-                           'key_auths': active_key_authority,
-                           "address_auths": [],
-                           'weight_threshold': 1},
-                'posting': {'account_auths': active_accounts_authority,
-                            'key_auths': posting_key_authority,
-                            "address_auths": [],
-                            'weight_threshold': 1},
-                'memo_key': memo,
-                "json_metadata": json_meta or {},
-                "prefix": self.prefix,
-            }
-            op = operations.Account_create(**op)
+        required_fee_steem = Amount(props["account_creation_fee"], steem_instance=self)
+        op = {
+            "fee": required_fee_steem,
+            "creator": creator["name"],
+            "new_account_name": account_name,
+            'owner': {'account_auths': owner_accounts_authority,
+                      'key_auths': owner_key_authority,
+                      "address_auths": [],
+                      'weight_threshold': 1},
+            'active': {'account_auths': active_accounts_authority,
+                       'key_auths': active_key_authority,
+                       "address_auths": [],
+                       'weight_threshold': 1},
+            'posting': {'account_auths': active_accounts_authority,
+                        'key_auths': posting_key_authority,
+                        "address_auths": [],
+                        'weight_threshold': 1},
+            'memo_key': memo,
+            "json_metadata": json_meta or {},
+            "prefix": self.prefix,
+        }
+        op = operations.Account_create(**op)
         return self.finalizeOp(op, creator, "active", **kwargs)
 
     def witness_set_properties(self, wif, owner, props, use_condenser_api=True):
diff --git a/beem/version.py b/beem/version.py
index 6fa67243..ab30de67 100644
--- a/beem/version.py
+++ b/beem/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.19.57'
+version = '0.20.0'
diff --git a/beemapi/version.py b/beemapi/version.py
index 6fa67243..ab30de67 100644
--- a/beemapi/version.py
+++ b/beemapi/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.19.57'
+version = '0.20.0'
diff --git a/beembase/version.py b/beembase/version.py
index 6fa67243..ab30de67 100644
--- a/beembase/version.py
+++ b/beembase/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.19.57'
+version = '0.20.0'
diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py
index 6fa67243..ab30de67 100644
--- a/beemgraphenebase/version.py
+++ b/beemgraphenebase/version.py
@@ -1,2 +1,2 @@
 """THIS FILE IS GENERATED FROM beem SETUP.PY."""
-version = '0.19.57'
+version = '0.20.0'
diff --git a/setup.py b/setup.py
index 945034a1..be8dbb66 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.19.57'
+VERSION = '0.20.0'
 
 tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']
 
diff --git a/tests/beem/test_steem.py b/tests/beem/test_steem.py
index 88ac2d30..3ab699fd 100644
--- a/tests/beem/test_steem.py
+++ b/tests/beem/test_steem.py
@@ -106,7 +106,6 @@ class Testcases(unittest.TestCase):
             additional_owner_accounts=["test1"],  # 1.2.0
             additional_active_accounts=["test1"],
             storekeys=False,
-            delegation_fee_steem="0 STEEM"
         )
         self.assertEqual(
             tx["operations"][0][0],
@@ -168,7 +167,6 @@ class Testcases(unittest.TestCase):
             additional_owner_accounts=["test1"],  # 1.2.0
             additional_active_accounts=["test1"],
             storekeys=False,
-            delegation_fee_steem="0 STEEM"
         )
         self.assertEqual(
             tx["operations"][0][0],
@@ -199,64 +197,6 @@ class Testcases(unittest.TestCase):
             op["creator"],
             "test")
 
-    def test_create_account_with_delegation(self):
-        bts = Steem(node=self.nodelist.get_nodes(),
-                    nobroadcast=True,
-                    unsigned=True,
-                    data_refresh_time_seconds=900,
-                    keys={"active": wif, "owner": wif, "memo": wif},
-                    num_retries=10)
-        core_unit = "STM"
-        name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12))
-        key1 = PrivateKey()
-        key2 = PrivateKey()
-        key3 = PrivateKey()
-        key4 = PrivateKey()
-        key5 = PrivateKey()
-        bts.txbuffer.clear()
-        tx = bts.create_account(
-            name,
-            creator="test",   # 1.2.7
-            owner_key=format(key1.pubkey, core_unit),
-            active_key=format(key2.pubkey, core_unit),
-            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,
-            delegation_fee_steem="1 STEEM"
-        )
-        self.assertEqual(
-            tx["operations"][0][0],
-            "account_create_with_delegation"
-        )
-        op = tx["operations"][0][1]
-        role = "active"
-        self.assertIn(
-            format(key5.pubkey, core_unit),
-            [x[0] for x in op[role]["key_auths"]])
-        self.assertIn(
-            format(key5.pubkey, core_unit),
-            [x[0] for x in op[role]["key_auths"]])
-        self.assertIn(
-            "test1",
-            [x[0] for x in op[role]["account_auths"]])
-        role = "owner"
-        self.assertIn(
-            format(key5.pubkey, core_unit),
-            [x[0] for x in op[role]["key_auths"]])
-        self.assertIn(
-            format(key5.pubkey, core_unit),
-            [x[0] for x in op[role]["key_auths"]])
-        self.assertIn(
-            "test1",
-            [x[0] for x in op[role]["account_auths"]])
-        self.assertEqual(
-            op["creator"],
-            "test")
-
     @parameterized.expand([
         ("normal"),
         ("testnet"),
@@ -532,7 +472,7 @@ class Testcases(unittest.TestCase):
     def test_sp_to_rshares(self):
         stm = self.bts
         rshares = stm.sp_to_rshares(stm.vests_to_sp(1e6))
-        self.assertTrue(abs(rshares - 20000000000.0) < 2)
+        self.assertTrue(abs(rshares - 19950000000.0) < 2)
 
     def test_rshares_to_vests(self):
         stm = self.bts
-- 
GitLab