STEEM-Bash: Fixed ticker values from CryptoCompare, balances ticker, graphing, etc.

in utopian-io •  7 years ago 

Repository

https://github.com/not-a-bird/steem-bash

All of the changes in this update were applied in commit 05f2da

Bug Fixes

  • What was the issue(s)?
    • Fixed quoting around requested crypto coin tickers (made necessary by weird values used by third parties)
    • Fixed strings used in fetching SBD (it's SBD* now, broken by third party (cryptocompare))

Apparently CryptoCompare added an asterisk to some of their supported currencies, for example, SBD. As a result, the single price fetch function get_price would still fetch the price of SBD via get_price SBD*, but attempts to fetch multiple feeds would fail, as was the case with balances.sh for fetching user balance information, and graphprices.sh which graphs a set of specified crypto currency values. The result is that both of these scripts broke. This actually revealed that there was another bug in functions.sh, namely, the fetched crypo price names were not being properly quoted when they were extracted from the JSON result.

  • What was the solution?
    The solution was to update functions.sh, graphprices.sh, and balances.sh in the following ways:
  1. Add variables for SBD_TICKER and STEEM_TICKER (with values SBD* and STEEM respectively,) to account for any future arbitrary changes to the tickers as used by CryptoCompare and replace all naked references to "SBD" with ${SBD_TICKER}, and all naked references to "STEEM" with ${STEEM_TIKER}.

  2. Ensure all invocations of jq for extracting ticker values from the results JSON made use of proper quoting around the respective variables. For example, graphprices.sh, for fetching the and graphing arbitrary crypto currencies used to have code like the following:

         echo -n "   $(jq -r ".${COIN}.${CURRENCY}" <<< $PRICES)"
    

This function (and others) now includes code like the following:

        echo -n "   $(jq -r ".\"${COIN}\".\"${CURRENCY}\"" <<< $PRICES)"

New Features

New feature additions were interrupted by the seemingly innocuous bug fixes, but this commit did include the addition of the following APIs:

  • rpc_get_miner_queue()
  • rpc_get_next_scheduled_hardfork()
  • rpc_get_open_orders()
  • rpc_get_ops_in_block()
  • rpc_get_state()
  • rpc_get_tags_used_by_author()

These functions were generally added by wrapping the rpc_invoke method, calling the appropriate back-end method, and preparing any arguments (which weren't very well documented at the time the implementation was completed, so it required quite a bit of trial and error.)

GitHub Account

https://github.com/not-a-bird

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks for the contribution!

It would be great if you could add some more features when submitting future contributions. Other than that it's great, everything is nicely commented, the commit message is detailed and you clearly explain everything in the post itself.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Yeah, as I mentioned in the post, I was in the middle of making feature changes when I discovered that cryptocompare had changed the ticker symbols, so I had to do a bug fix commit immediately so everything would be working again. Otherwise I could end up passing the window on claiming the bug fixes and these few features by the time I was done with the next bigger batch of features.