Skip to content
Snippets Groups Projects
Commit c6c6529a authored by roadscape's avatar roadscape
Browse files

rename STEEM to HIVE and SBD to HBD for API values

parent e21a4a43
No related branches found
No related tags found
1 merge request!2Autoclave rename assets
......@@ -52,8 +52,8 @@ class Payments:
return # only care about payments to null
amount, token = parse_amount(op['amount'])
if token != 'SBD':
return # only care about SBD payments
if token != 'HBD':
return # only care about HBD payments
url = op['memo']
if not cls._validate_url(url):
......
......@@ -242,10 +242,10 @@ def _condenser_post_object(row, truncate_body=0):
return post
def _amount(amount, asset='SBD'):
def _amount(amount, asset='HBD'):
"""Return a steem-style amount string given a (numeric, asset-str)."""
assert asset == 'SBD', 'unhandled asset %s' % asset
return "%.3f SBD" % amount
assert asset == 'HBD', 'unhandled asset %s' % asset
return "%.3f HBD" % amount
def _hydrate_active_votes(vote_csv):
"""Convert minimal CSV representation into steemd-style object."""
......
......@@ -64,7 +64,10 @@ async def normalize_post(context, post):
post['gray'] = core['is_muted']
post['hide'] = not core['is_valid']
promoted = sbd_amount(post['promoted']) if post['promoted'] != '0.000 STEEM' else None
# TODO: there is a bug in steemd.. promoted value returned as 0.000 LIQUID
# until it's promoted.. then returned as X.XXX STABLE. So here we
# ignore the non-promoted case because sbd_amount asserts proper input units.
promoted = sbd_amount(post['promoted']) if post['promoted'] != '0.000 HIVE' else None
# convert to internal object
row = None
......
......@@ -282,7 +282,7 @@ async def _load_discussion(db, author, permlink):
async def _get_feed_price(db):
"""Get a steemd-style ratio object representing feed price."""
price = await db.query_one("SELECT usd_per_steem FROM hive_state")
return {"base": "%.3f SBD" % price, "quote": "1.000 STEEM"}
return {"base": "%.3f HBD" % price, "quote": "1.000 HIVE"}
@cached(ttl=1800, timeout=1200)
async def _get_props_lite(db):
......
......@@ -143,7 +143,7 @@ def _condenser_post_object(row, truncate_body=0):
post['total_payout_value'] = _amount(row['payout'] if paid else 0)
post['curator_payout_value'] = _amount(0)
post['pending_payout_value'] = _amount(0 if paid else row['payout'])
post['promoted'] = "%.3f SBD" % row['promoted']
post['promoted'] = _amount(row['promoted'])
post['replies'] = []
post['body_length'] = len(row['body'])
......@@ -181,10 +181,10 @@ def _condenser_post_object(row, truncate_body=0):
return post
def _amount(amount, asset='SBD'):
def _amount(amount, asset='HBD'):
"""Return a steem-style amount string given a (numeric, asset-str)."""
assert asset == 'SBD', 'unhandled asset %s' % asset
return "%.3f SBD" % amount
assert asset == 'HBD', 'unhandled asset %s' % asset
return "%.3f HBD" % amount
def _hydrate_active_votes(vote_csv):
"""Convert minimal CSV representation into steemd-style object."""
......
......@@ -56,6 +56,6 @@ async def get_trending_tags(context, start_tag: str = '', limit: int = 250):
'name': row['category'],
'comments': row['total_posts'] - row['top_posts'],
'top_posts': row['top_posts'],
'total_payouts': "%.3f SBD" % row['total_payouts']})
'total_payouts': "%.3f HBD" % row['total_payouts']})
return out
......@@ -112,7 +112,7 @@ class SteemClient:
# TODO: add latest feed price: get_feed_history.price_history[0]
feed = self.__exec('get_feed_history')['current_median_history']
units = dict([parse_amount(feed[k])[::-1] for k in ['base', 'quote']])
price = units['SBD'] / units['STEEM']
price = units['HBD'] / units['HIVE']
return "%.6f" % price
def _get_steem_price(self):
......
......@@ -8,8 +8,8 @@ from pytz import utc
import ujson as json
NAI_MAP = {
'@@000000013': 'SBD',
'@@000000021': 'STEEM',
'@@000000013': 'HBD',
'@@000000021': 'HIVE',
'@@000000037': 'VESTS',
}
......@@ -18,12 +18,12 @@ def vests_amount(value):
return parse_amount(value, 'VESTS')
def steem_amount(value):
"""Returns a decimal amount, asserting units are STEEM"""
return parse_amount(value, 'STEEM')
"""Returns a decimal amount, asserting units are HIVE"""
return parse_amount(value, 'HIVE')
def sbd_amount(value):
"""Returns a decimal amount, asserting units are SBD"""
return parse_amount(value, 'SBD')
"""Returns a decimal amount, asserting units are HBD"""
return parse_amount(value, 'HBD')
def parse_amount(value, expected_unit=None):
"""Parse steemd-style amout/asset value, return (decimal, name)."""
......@@ -59,7 +59,7 @@ def legacy_amount(value):
if isinstance(value, str):
return value # already legacy
amt, asset = parse_amount(value)
prec = {'SBD': 3, 'STEEM': 3, 'VESTS': 6}[asset]
prec = {'HBD': 3, 'HIVE': 3, 'VESTS': 6}[asset]
tmpl = ("%%.%df %%s" % prec)
return tmpl % (amt, asset)
......
......@@ -41,10 +41,10 @@ def test_vests_amount():
assert vests_amount('4.549292 VESTS') == Decimal('4.549292')
def test_steem_amount():
assert steem_amount('1.234567 STEEM') == Decimal('1.234567')
assert steem_amount('1.234567 HIVE') == Decimal('1.234567')
def test_sbd_amount():
assert sbd_amount('1.001 SBD') == Decimal('1.001')
assert sbd_amount('1.001 HBD') == Decimal('1.001')
def test_parse_amount():
nai = [1231121, 6, '@@000000037']
......
......@@ -60,22 +60,22 @@ POST_1 = {
"children": 0,
"children_abs_rshares": 0,
"created": "2017-06-20T15:53:51",
"curator_payout_value": "0.000 SBD",
"curator_payout_value": "0.000 HBD",
"depth": 0,
"id": 4437869,
"json_metadata": "{\"tags\":[\"spam\"],\"image\":[\"ddd\", \"https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg\",\"https://example.com/image.jpg\"],\"app\":\"steemit/0.1\",\"format\":\"markdown\"}",
"last_payout": "2017-06-27T15:53:51",
"last_update": "2017-06-20T15:53:51",
"max_accepted_payout": "1000000.000 SBD",
"max_accepted_payout": "1000000.000 HBD",
"max_cashout_time": "1969-12-31T23:59:59",
"net_rshares": 0,
"net_votes": 4,
"parent_author": "",
"parent_permlink": "spam",
"pending_payout_value": "0.000 SBD",
"pending_payout_value": "0.000 HBD",
"percent_steem_dollars": 10000,
"permlink": "june-spam",
"promoted": "0.000 SBD",
"promoted": "0.000 HBD",
"reblogged_by": [],
"replies": [],
"reward_weight": 10000,
......@@ -83,8 +83,8 @@ POST_1 = {
"root_permlink": "june-spam",
"root_title": "June Spam",
"title": "June Spam",
"total_payout_value": "0.044 SBD",
"total_pending_payout_value": "0.000 STEEM",
"total_payout_value": "0.044 HBD",
"total_pending_payout_value": "0.000 HIVE",
"total_vote_weight": 0,
"url": "/spam/@test-safari/june-spam",
"vote_rshares": 0
......@@ -108,22 +108,22 @@ POST_2 = {
"children": 0,
"children_abs_rshares": 0,
"created": "2017-06-20T15:53:51",
"curator_payout_value": "0.000 SBD",
"curator_payout_value": "0.000 HBD",
"depth": 0,
"id": 4437869,
"json_metadata": "{\"tags\":[\"steemit\",\"steem\",\"\",\"abc\",\"bcd\",\"cde\"]}",
"last_payout": "2017-06-27T15:53:51",
"last_update": "2017-06-20T15:53:51",
"max_accepted_payout": "1000000.000 SBD",
"max_accepted_payout": "1000000.000 HBD",
"max_cashout_time": "1969-12-31T23:59:59",
"net_rshares": 0,
"net_votes": 4,
"parent_author": "",
"parent_permlink": "spam",
"pending_payout_value": "0.000 SBD",
"pending_payout_value": "0.000 HBD",
"percent_steem_dollars": 10000,
"permlink": "june-spam",
"promoted": "0.000 SBD",
"promoted": "0.000 HBD",
"reblogged_by": [],
"replies": [],
"reward_weight": 10000,
......@@ -131,8 +131,8 @@ POST_2 = {
"root_permlink": "june-spam",
"root_title": "June Spam",
"title": "June Spam",
"total_payout_value": "0.044 SBD",
"total_pending_payout_value": "0.000 STEEM",
"total_payout_value": "0.044 HBD",
"total_pending_payout_value": "0.000 HIVE",
"total_vote_weight": 0,
"url": "/spam/@test-safari/june-spam",
"vote_rshares": 0
......@@ -177,9 +177,9 @@ def test_post_legacy():
'allow_replies': True,
'allow_votes': True,
'beneficiaries': [],
'curator_payout_value': '0.000 SBD',
'curator_payout_value': '0.000 HBD',
'id': 4437869,
'max_accepted_payout': '1000000.000 SBD',
'max_accepted_payout': '1000000.000 HBD',
'parent_author': '',
'parent_permlink': 'spam',
'percent_steem_dollars': 10000,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment