Skip to content

Commit

Permalink
Remove obsolete replace_hive_by_steem parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Oct 24, 2020
1 parent 817c49b commit 3a51a98
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 154 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog
* add new node (fin.hive.3speak.co) and change change rpc.esteem.app to rpc.ecency.com
* Replace diff_match_patch by difflib and add unit tests
* Increase timeout and retry cound in beempy
* Remove obsolete replace_hive_by_steem parameter

0.24.13
-------
Expand Down
46 changes: 21 additions & 25 deletions beem/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2755,14 +2755,16 @@ def change_recovery_account(self, new_recovery_account,
# -------------------------------------------------------------------------
# Simple Transfer
# -------------------------------------------------------------------------
def transfer(self, to, amount, asset, memo="", account=None, **kwargs):
def transfer(self, to, amount, asset, memo="", skip_account_check=False, account=None, **kwargs):
""" Transfer an asset to another account.
:param str to: Recipient
:param float amount: Amount to transfer
:param str asset: Asset to transfer
:param str memo: (optional) Memo, may begin with `#` for encrypted
messaging
:param bool skip_account_check: (optional) When True, the receiver
account name is not checked to speed up sending multiple transfers in a row
:param str account: (optional) the source account for the transfer
if not ``default_account``
Expand All @@ -2781,12 +2783,17 @@ def transfer(self, to, amount, asset, memo="", account=None, **kwargs):
"""

if account is None:
account = self
else:
account = self
elif not skip_account_check:
account = Account(account, blockchain_instance=self.blockchain)
amount = Amount(amount, asset, blockchain_instance=self.blockchain)
to = Account(to, blockchain_instance=self.blockchain)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
if not skip_account_check:
to = Account(to, blockchain_instance=self.blockchain)
to_name = to["name"]
account_name = account["name"]
else:
to_name = to
account_name = account
if memo and memo[0] == "#":
from .memo import Memo
memoObj = Memo(
Expand All @@ -2795,15 +2802,14 @@ def transfer(self, to, amount, asset, memo="", account=None, **kwargs):
blockchain_instance=self.blockchain
)
memo = memoObj.encrypt(memo[1:])["message"]

op = operations.Transfer(**{
"amount": amount,
"to": to["name"],
"to": to_name,
"memo": memo,
"from": account["name"],
"from": account_name,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)

Expand All @@ -2824,7 +2830,6 @@ def transfer_to_vesting(self, amount, to=None, account=None, **kwargs):
else:
to = Account(to, blockchain_instance=self.blockchain)
amount = self._check_amount(amount, self.blockchain.token_symbol)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
to = Account(to, blockchain_instance=self.blockchain)

op = operations.Transfer_to_vesting(**{
Expand All @@ -2833,7 +2838,6 @@ def transfer_to_vesting(self, amount, to=None, account=None, **kwargs):
"amount": amount,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)

Expand All @@ -2855,16 +2859,14 @@ def convert(self, amount, account=None, request_id=None):
if request_id:
request_id = int(request_id)
else:
request_id = random.getrandbits(32)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
request_id = random.getrandbits(32)
op = operations.Convert(
**{
"owner": account["name"],
"requestid": request_id,
"amount": amount,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})

return self.blockchain.finalizeOp(op, account, "active")
Expand Down Expand Up @@ -2894,7 +2896,6 @@ def transfer_to_savings(self, amount, asset, memo, to=None, account=None, **kwar
to = account # move to savings on same account
else:
to = Account(to, blockchain_instance=self.blockchain)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
op = operations.Transfer_to_savings(
**{
"from": account["name"],
Expand All @@ -2903,7 +2904,6 @@ def transfer_to_savings(self, amount, asset, memo, to=None, account=None, **kwar
"memo": memo,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)

Expand Down Expand Up @@ -2944,8 +2944,6 @@ def transfer_from_savings(self,
else:
request_id = random.getrandbits(32)

replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()

op = operations.Transfer_from_savings(
**{
"from": account["name"],
Expand All @@ -2955,7 +2953,6 @@ def transfer_from_savings(self,
"memo": memo,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.blockchain.finalizeOp(op, account, "active", **kwargs)

Expand Down Expand Up @@ -3024,13 +3021,13 @@ def claim_reward_balance(self,
reward_steem = self._check_amount(reward_steem + reward_hive, self.blockchain.token_symbol)
reward_sbd = self._check_amount(reward_sbd + reward_hbd, self.blockchain.backed_token_symbol)
reward_vests = self._check_amount(reward_vests, self.blockchain.vest_token_symbol)

reward_token = "reward_steem"
reward_backed_token = "reward_sbd"
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
if not replace_hive_by_steem:

if self.blockchain.is_hive:
reward_token = "reward_hive"
reward_backed_token = "reward_hbd"
else:
reward_token = "reward_steem"
reward_backed_token = "reward_sbd"

if reward_steem.amount == 0 and reward_sbd.amount == 0 and reward_vests.amount == 0:
if len(account.balances["rewards"]) == 3:
Expand All @@ -3044,7 +3041,6 @@ def claim_reward_balance(self,
reward_backed_token: reward_sbd,
"reward_vests": reward_vests,
"prefix": self.blockchain.prefix,
"replace_hive_by_steem": replace_hive_by_steem
})
else:
reward_steem = account.balances["rewards"][0]
Expand Down
34 changes: 6 additions & 28 deletions beem/blockchaininstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,15 +780,6 @@ def is_steem(self):
return False
return 'STEEM_CHAIN_ID' in config

def get_replace_hive_by_steem(self):
if not self.is_hive:
return False
hf_version = int(self.get_blockchain_version(use_stored_data=True).split('.')[1])
replace_hive_by_steem = True
if hf_version >= 24:
replace_hive_by_steem = False
return replace_hive_by_steem

def set_default_account(self, account):
""" Set the default account to be used
"""
Expand Down Expand Up @@ -1067,14 +1058,12 @@ def claim_account(self, creator, fee=None, **kwargs):
raise ValueError(
"Not creator account given. Define it with " +
"creator=x, or set the default_account using beempy")
creator = Account(creator, blockchain_instance=self)
replace_hive_by_steem = self.get_replace_hive_by_steem()
creator = Account(creator, blockchain_instance=self)
op = {
"fee": Amount(fee, blockchain_instance=self),
"creator": creator["name"],
"prefix": self.prefix,
"json_str": not bool(self.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
}
op = operations.Claim_account(**op)
return self.finalizeOp(op, creator, "active", **kwargs)
Expand Down Expand Up @@ -1248,14 +1237,12 @@ def create_claimed_account(
for k in additional_posting_accounts:
addaccount = Account(k, blockchain_instance=self)
posting_accounts_authority.append([addaccount["name"], 1])
if combine_with_claim_account:
replace_hive_by_steem = self.get_replace_hive_by_steem()
if combine_with_claim_account:
op = {
"fee": Amount(fee, blockchain_instance=self),
"creator": creator["name"],
"prefix": self.prefix,
"json_str": not bool(self.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
}
op = operations.Claim_account(**op)
ops = [op]
Expand Down Expand Up @@ -1452,8 +1439,7 @@ def create_account(
if self.hardfork >= 20:
required_fee_steem = Amount(props["account_creation_fee"], blockchain_instance=self)
else:
required_fee_steem = Amount(props["account_creation_fee"], blockchain_instance=self) * 30
replace_hive_by_steem = self.get_replace_hive_by_steem()
required_fee_steem = Amount(props["account_creation_fee"], blockchain_instance=self) * 30
op = {
"fee": required_fee_steem,
"creator": creator["name"],
Expand All @@ -1474,7 +1460,6 @@ def create_account(
"json_metadata": json_meta or {},
"prefix": self.prefix,
"json_str": not bool(self.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
}
op = operations.Account_create(**op)
return self.finalizeOp(op, creator, "active", **kwargs)
Expand Down Expand Up @@ -1683,10 +1668,8 @@ def witness_set_properties(self, wif, owner, props):
props_list = [["key", repr(PrivateKey(wif, prefix=self.prefix).pubkey)]]
for k in props:
props_list.append([k, props[k]])
replace_hive_by_steem = self.get_replace_hive_by_steem()
op = operations.Witness_set_properties({"owner": owner["name"], "props": props_list, "prefix": self.prefix,
"json_str": not bool(self.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem})
"json_str": not bool(self.config["use_condenser"])})
tb = TransactionBuilder(blockchain_instance=self)
tb.appendOps([op])
tb.appendWif(wif)
Expand Down Expand Up @@ -1722,8 +1705,7 @@ def witness_update(self, signing_key, url, props, account=None, **kwargs):
except Exception as e:
raise e
if "account_creation_fee" in props:
props["account_creation_fee"] = Amount(props["account_creation_fee"], blockchain_instance=self)
replace_hive_by_steem = self.get_replace_hive_by_steem()
props["account_creation_fee"] = Amount(props["account_creation_fee"], blockchain_instance=self)
op = operations.Witness_update(
**{
"owner": account["name"],
Expand All @@ -1733,7 +1715,6 @@ def witness_update(self, signing_key, url, props, account=None, **kwargs):
"fee": Amount(0, self.token_symbol, blockchain_instance=self),
"prefix": self.prefix,
"json_str": not bool(self.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.finalizeOp(op, account, "active", **kwargs)

Expand Down Expand Up @@ -2147,8 +2128,7 @@ def _build_comment_options_op(self, author, permlink, options,
options['beneficiaries'] = beneficiaries

default_max_payout = "1000000.000 %s" % (self.backed_token_symbol)
replace_hive_by_steem = self.get_replace_hive_by_steem()
if not replace_hive_by_steem and self.is_hive:
if self.is_hive:
comment_op = operations.Comment_options(
**{
"author":
Expand All @@ -2168,7 +2148,6 @@ def _build_comment_options_op(self, author, permlink, options,
"beneficiaries":
options.get("beneficiaries", []),
"prefix": self.prefix,
"replace_hive_by_steem": False,
})
else:
comment_op = operations.Comment_options(
Expand All @@ -2190,7 +2169,6 @@ def _build_comment_options_op(self, author, permlink, options,
"beneficiaries":
options.get("beneficiaries", []),
"prefix": self.prefix,
"replace_hive_by_steem": True,
})
return comment_op

Expand Down
6 changes: 3 additions & 3 deletions beem/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@ def createpost(markdown_file, account, title, tags, community, beneficiaries, pe
yaml_prefix += 'title: "%s"\n' % title
yaml_prefix += 'author: %s\n' % account
yaml_prefix += 'tags: %s\n' % tags
if stm.is_hive and not stm.get_replace_hive_by_steem():
if stm.is_hive:
yaml_prefix += 'percent_hbd: %d\n' % percent_hbd
else:
yaml_prefix += 'percent_steem_dollars: %d\n' % percent_steem_dollars
Expand Down Expand Up @@ -2757,9 +2757,9 @@ def post(markdown_file, account, title, permlink, tags, reply_identifier, commun
if stm.backed_token_symbol not in max_accepted_payout:
max_accepted_payout = str(Amount(float(max_accepted_payout), stm.backed_token_symbol, blockchain_instance=stm))
comment_options["max_accepted_payout"] = max_accepted_payout
if percent_hbd is not None and stm.is_hive and not stm.get_replace_hive_by_steem():
if percent_hbd is not None and stm.is_hive:
comment_options["percent_hbd"] = percent_hbd
elif percent_steem_dollars is not None and stm.is_hive and not stm.get_replace_hive_by_steem():
elif percent_steem_dollars is not None and stm.is_hive:
comment_options["percent_hbd"] = percent_steem_dollars
elif percent_steem_dollars is not None:
comment_options["percent_steem_dollars"] = percent_steem_dollars
Expand Down
5 changes: 0 additions & 5 deletions beem/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,6 @@ def get_hive_per_mvest(self, time_stamp=None, use_stored_data=True):
else:
return a2 * time_stamp + b2
global_properties = self.get_dynamic_global_properties(use_stored_data=use_stored_data)
if self.get_replace_hive_by_steem():
return (
float(Amount(global_properties['total_vesting_fund_steem'], blockchain_instance=self)) /
(float(Amount(global_properties['total_vesting_shares'], blockchain_instance=self)) / 1e6)
)
return (
float(Amount(global_properties['total_vesting_fund_hive'], blockchain_instance=self)) /
(float(Amount(global_properties['total_vesting_shares'], blockchain_instance=self)) / 1e6)
Expand Down
4 changes: 0 additions & 4 deletions beem/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ def buy(
amount = Amount(amount, blockchain_instance=self.blockchain)
else:
amount = Amount(amount, self["quote"]["symbol"], blockchain_instance=self.blockchain)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
order = operations.Limit_order_create(**{
"owner": account["name"],
"orderid": orderid or random.getrandbits(32),
Expand All @@ -605,7 +604,6 @@ def buy(
"fill_or_kill": killfill,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})

if returnOrderId:
Expand Down Expand Up @@ -673,7 +671,6 @@ def sell(
amount = Amount(amount, blockchain_instance=self.blockchain)
else:
amount = Amount(amount, self["quote"]["symbol"], blockchain_instance=self.blockchain)
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
order = operations.Limit_order_create(**{
"owner": account["name"],
"orderid": orderid or random.getrandbits(32),
Expand All @@ -691,7 +688,6 @@ def sell(
"fill_or_kill": killfill,
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
if returnOrderId:
# Make blocking broadcasts
Expand Down
2 changes: 0 additions & 2 deletions beem/witness.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def feed_publish(self,
raise AssertionError()
if not quote.symbol == self.blockchain.token_symbol:
raise AssertionError()
replace_hive_by_steem = self.blockchain.get_replace_hive_by_steem()
op = operations.Feed_publish(
**{
"publisher": account["name"],
Expand All @@ -163,7 +162,6 @@ def feed_publish(self,
},
"prefix": self.blockchain.prefix,
"json_str": not bool(self.blockchain.config["use_condenser"]),
"replace_hive_by_steem": replace_hive_by_steem,
})
return self.blockchain.finalizeOp(op, account, "active")

Expand Down
Loading

0 comments on commit 3a51a98

Please sign in to comment.