Adjust Account Authorities with Steem Keychain

in #utopian-io6 years ago

Repository

https://github.com/MattyIce/steem-keychain

New Feature

Recently I augmented the Steem Keychain (now on the web store) to allow for adding/removing account authorities. Works for posting and active authorities.

This isn't a full flow for managing everything related to authorities (e.g. multi-sig, but it can be moved in that direction in the near future). However, it can now handle a very common use case for Steemconnect Integration, and I imagine it can be directly integrated with the Steemconnect auth flow without too much trouble.

To see it in action, you can download or update to the latest Steem Keychain extension here, and then go to the Steemkeychain test page which I've hosted at this location: https://eonwarped.github.io/steem/sk/main.html

You will find a section for adding and removing account authorities, like so:

formToAdjustAuths

To check that the authorities were added/removed, you can use Steemd.

Code Details

You can find the merged pull request with the highlighted changes here: https://github.com/MattyIce/steem-keychain/pull/76 (click the "Files Changed" tab).

If you click in to the changes, you will note the following changes:

  • README.md -- Documentation for how to use the newly added features.
  • example/main.html and example/main.js -- Adding the function to the test page for easy testing.
  • html/dialog.html -- This controls the view for the dialog popup that asks for approval to sign and broadcast the transaction. The way it works is that the method name, which in this case is addAccountAuthority / removeAccountAuthority works as a class to show/hide relevant input fields. Here I added a spot for the authorized account name.
  • js/dialog.js -- This is the part that populates the data for the view in html/dialog.html. Very simple jquery calls to select the element and populate with the data.
  • js/popup/settings.js -- Small change to add display names for the operation.
  • js/steem_keychain.js -- The start point, where the requestAddAccountAuthority and requestRemoveAccountAuthority methods are defined. It follows suit in passing the data to the background thread.
  • js/web_interface.js -- Validation code added to do basic checks for data population.
  • js/background.js -- This is where the action happens. This is a relatively easy case, where all we had to do is extract the data and make the corresponding API call, and since steem-js codebase already has a method for modifying authorities, we simply plugged directly into it. Another change was needed to tell the keychain to use the 'active' authority to make the call.

Notes

Any potential integrators to the keychain can follow similar steps to add functionality and submit a PR for discussion and adoption. Previously I've added abilities that was needed for condenser to use keychain. I never wrote it up, but I will likely do it in more detail in the near future because some of the methods were more involved. And a small plug, if you want to try out the keychain experience, you can use the latest keychain extension with the website I've hosted at https://cryptoempirebot.com (sometimes images don't load, though, and I have yet to figure that out).

Anyway, let me know if you have any questions below!

GitHub Account

https://github.com/eonwarped

Sort:  

Thank you for your contribution!

  1. I find very little comments in your code, a little bit more would be nice for others to understand.
  2. In general, you don't want to put too much code in the case - which bloats the entire switch statement - hard to maintain. You might want to extract the logics in a separate method - and unit test them.
  3. You might want to add messages to hint the users what is going on, instead of throwing errors in the console see below.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thanks for the feedback!

Yes, generally agreed on code structure. It's not really an option except as a refactor, which would need some coordination with the repository owner, but definitely something to consider for maintenance.

Also the console errors I presume are from the test page. In general we defer proper error handling to the clients, we have proper error codes set up, but this one is a precursor to that because this error stems from the steem keychain not being available at all (responsibility of client to check availability).

Thank you for your review, @justyy! Keep up the good work!

Curious.. how is it cool that the review comment here earns about $13 from @utopian-io but the actual post itself gets nothing? The comment clearly wasn't reviewing something that wasn't worth the effort of a review.

Explain?

ǝɹǝɥ sɐʍ ɹoʇɐɹnƆ pɐW ǝɥ┴

I’m looking forward to getting Steem Keychain running now it works on Brave. Steem usability gets better and better!

Posted using Partiko iOS

Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Hi @eonwarped!

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

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.



Coin Marketplace

STEEM 0.16
TRX 0.12
JST 0.026
BTC 56953.07
ETH 2513.05
USDT 1.00
SBD 2.28