Lightsteem Updates - RC costs, HF20 helpers, and more.

in #lightsteem6 years ago (edited)


New updates on Lightsteem (0.1.4)

In order to upgrade to the latest version:

$ pip install lightsteem --upgrade

New Features


RC costs

@steemitdev posted a developer guide and an example python script about RC costs, yesterday.

With that help, it was easy to add a ResourceCredit helper. It's now possible to get an estimation of the RC cost for every kind of operation.

For example; If you want to learn about the potential cost of claiming a discounted account, all you need to do is:

from lightsteem.client import Client
from lightsteem.datastructures import Operation

client = Client()

op = Operation(
    'claim_account',
    {
        "creator": "emrebeyler",
        "fee": "0.000 STEEM",
        "extensions": [],
    }
)

print(client.rc().get_cost(op))

Let's find out, how many accounts can my account create with my available RC?


from lightsteem.client import Client
from lightsteem.datastructures import Operation

client = Client(keys=[])

op = Operation(
    'claim_account',
    {
        "creator": "emrebeyler",
        "fee": "0.000 STEEM",
        "extensions": [],
    }
)

claim_account_cost = client.rc().get_cost(op)
account_mana_info = client.account('emrebeyler').get_resource_credit_info()
current_mana = account_mana_info["current_mana"] / 1000000


print(f"You can claim {int(current_mana / claim_account_cost)} accounts.")
print(f"It takes {claim_account_cost}MM mana to claim an account.")
print(f"You have {int(current_mana)}MM mana.")


Currently, it's not very fast. Since Lightsteem doesn't have its own serializers (using get_transaction_hex for it), it's a little slow. However, there is a room for optimizations, and I will ship it in the next iterations.

Additions to Account helper

  • account.vp() function is updated to work with the HF20 format. It was already working well since the change on get_accounts is backward compatible. However, it's better to upgrade the logic and be ready for the future.

  • account.rc() method is added. Example:

In [1]: from lightsteem.client import Client
In [2]: c = Client()

In [3]: c.account('emrebeyler').rc()
Out[3]: 82.69

In [4]: c.account('emrebeyler').rc(precision=5)
Out[4]: 82.69078

Additions to Amount helper

  • It's -now- possible to construct Amount instances with the new asset format:
In [6]: from lightsteem.helpers.amount import Amount

In [7]: amount = Amount.from_asset({
   ...:     'amount': '1029141630',
   ...:     'precision': 6,
   ...:     'nai': '@@000000037'
   ...: })

In [10]: amount.symbol
Out[10]: 'VESTS'

In [12]: amount.amount
Out[12]: Decimal('1029.14163')

You can also construct the class with the old style and convert to new asset format:

In [13]: amount = Amount('0.100 STEEM')

In [14]: amount.asset
Out[14]: {'amount': '100', 'precision': 3, 'nai': '@@000000021'}

condenser_api_* calls secretly do the convert on this new format. Steem Developer Portal still states the other API namespaces may subject to change, however, it's good to be ready.

Related documentation and unit-tests are already updated with the new features.

Roadmap


I am pretty happy with the current status of Lightsteem. Even though it's not a swiss knife, I use it for most of my scripts (sometimes in cooperation with Beem) and it's working well.

There are a couple of issues needs to be addressed in the next iterations.

Commits


If you want to see exact change set, see the commits on Oct 11, 2018.

Sort:  
Loading...

Hi @emrebeyler!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @emrebeyler!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Can't vote for you enough bro! this is amazing!

Thanks.

Time is a river,this is one year old !BEER

Sorry, out of BEER, please retry later...

Birthdaypost !BEER

Sorry, out of BEER, please retry later...

If I could turn back !BEER



Hey @emrebeyler, here is a little bit of BEER for you. Enjoy it!

Coin Marketplace

STEEM 0.25
TRX 0.11
JST 0.032
BTC 62623.56
ETH 3037.97
USDT 1.00
SBD 3.70