create account

Steem Keychain Promise Wrapper by therealwolf

View this thread on: hive.blogpeakd.comecency.com
· @therealwolf · (edited)
$29.63
Steem Keychain Promise Wrapper
If you've integrated [Steem Keychain](https://github.com/MattyIce/steem-keychain) into your project/business/website and are like me: you've probably been a bit annoyed with the use of callbacks, instead of promises.

Which is why I've written myself a small basic wrapper that converts the callback Keychain normally returns, into a promise. Since I'm an avid user of typescript, I also added some types. The types for arguments are still missing, I'll probably add them sometime in the future.

Nevertheless, I thought some of my fellow devs might be in need of it, so here you go:

https://gist.github.com/therealwolf42/968db625aea6b45beffaae8283911062

*Info: This code snippet is using ES6 code syntax and types. Latter can be removed if you're not using typescript/flow.*

Example usage:

```
// Original Usage
steem_keychain.requestDelegation(username, delegatee, amount, unit, function(response) {
    console.log(response);
});

// Promise Wrapper Usage

import {keychain} from '../yourcode'

const {success, msg, cancel} = await keychain(window, 'requestDelegation', username, delegatee, amount, unit)
if('cancel') // Do nothing
if(success) {
  alert('Successful delegation!')
}
alert(`Error: ${msg}`)

```

If you've got improvements/found bugs, feel free to let me know!

*Wolf*

👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 192 others
👎  ,
properties (23)
authortherealwolf
permlinksteem-keychain-promise-wrapper
categorysteem
json_metadata{"app":"steempeak/1.17.1","format":"markdown","tags":["steem","palnet","steemdev","newsteem","keychain","dev","javascript","steemleo"],"links":["https://github.com/MattyIce/steem-keychain","https://gist.github.com/therealwolf42/968db625aea6b45beffaae8283911062"],"image":[]}
created2019-09-25 13:17:00
last_update2019-09-25 13:34:45
depth0
children11
last_payout2019-10-02 13:17:00
cashout_time1969-12-31 23:59:59
total_payout_value16.210 HBD
curator_payout_value13.423 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,292
author_reputation582,203,775,583,778
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id90,930,853
net_rshares83,171,966,330,520
author_curate_reward""
vote details (258)
@clove71 ·
Hi! this is awesome, I think you are Wolfinator in Splinterlands? If so, You are an amazing player! Awesome name too! :-) I bought up all the gold Alpha wolfs long ago and maxed him out first. It is a great card too!
properties (22)
authorclove71
permlinkpyeilh
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2019-09-25 19:10:30
last_update2019-09-25 19:10:30
depth1
children0
last_payout2019-10-02 19:10:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length216
author_reputation679,481,398,650,573
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,940,158
net_rshares0
@contrabourdon ·
Thanks! Will smartsteem be moving to keychain at some point?
properties (22)
authorcontrabourdon
permlinkpye2pm
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2019-09-25 13:27:24
last_update2019-09-25 13:27:24
depth1
children4
last_payout2019-10-02 13:27:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length60
author_reputation224,923,745,418,129
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,931,159
net_rshares0
@therealwolf ·
The current version of Smartsteem is already using keychain. The only thing not supported is login via keychain. This, however, will be supported with the redesign & relaunch, coming soon.
properties (22)
authortherealwolf
permlinkre-contrabourdon-pye2u5
categorysteem
json_metadata{"tags":["steem"],"app":"steempeak/1.17.1"}
created2019-09-25 13:30:06
last_update2019-09-25 13:30:06
depth2
children3
last_payout2019-10-02 13:30:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length188
author_reputation582,203,775,583,778
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,931,238
net_rshares0
@contrabourdon ·
Yay! Thank you. !giphy cheers
properties (22)
authorcontrabourdon
permlinkpyen4e
categorysteem
json_metadata{"tags":["steem"],"app":"steemit/0.1"}
created2019-09-25 20:48:15
last_update2019-09-25 20:48:15
depth3
children1
last_payout2019-10-02 20:48:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length29
author_reputation224,923,745,418,129
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,942,924
net_rshares0
@roleerob ·
Great @therealwolf ...

> *"The only thing not supported is login via keychain. This, however, will be supported with the redesign & relaunch, coming soon."*

... to hear! 👍

Posted using [Partiko Android](https://partiko.app/referral/roleerob)
properties (22)
authorroleerob
permlinkroleerob-re-therealwolf-re-contrabourdon-pye2u5-20190925t143911517z
categorysteem
json_metadata{"app":"partiko","client":"android"}
created2019-09-25 14:39:12
last_update2019-09-25 14:39:12
depth3
children0
last_payout2019-10-02 14:39:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length244
author_reputation121,025,951,911,758
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,933,073
net_rshares0
@pennsif ·
This post has been included in the latest edition of  [**The Steem News**](https://steemit.com/steem/@pennsif/the-steem-news-25-september-2019) - a compilation of the key news stories on the Steem blockchain.
👍  
properties (23)
authorpennsif
permlinkpyg997
categorysteem
json_metadata{"tags":["steem"],"links":["https://steemit.com/steem/@pennsif/the-steem-news-25-september-2019"],"app":"steemit/0.1"}
created2019-09-26 17:43:57
last_update2019-09-26 17:43:57
depth1
children0
last_payout2019-10-03 17:43:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length208
author_reputation636,410,097,572,565
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,972,200
net_rshares609,168,007
author_curate_reward""
vote details (1)
@steem-plus ·
SteemPlus upvote
Hi, @therealwolf!

You just got a **0.27%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
authorsteem-plus
permlinksteem-keychain-promise-wrapper---vote-steemplus
categorysteem
json_metadata{}
created2019-09-26 01:26:03
last_update2019-09-26 01:26:03
depth1
children0
last_payout2019-10-03 01:26:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length438
author_reputation247,952,188,232,400
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,949,046
net_rshares0
@theguruasia ·
@therealwolf,
I didn't test this so far! I will do, thanks!
!trdovoter 100

Cheers~
👍  
properties (23)
authortheguruasia
permlinkre-therealwolf-pyff06
categorysteem
json_metadata{"tags":["steem"],"app":"steempeak/1.17.1"}
created2019-09-26 06:50:30
last_update2019-09-26 06:50:30
depth1
children1
last_payout2019-10-03 06:50:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length83
author_reputation72,582,528,957,478
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,955,790
net_rshares2,092,319,923
author_curate_reward""
vote details (1)
@trendotoken ·
Congratulations @theguruasia, you are successfuly trended the post that shared by @therealwolf!
@therealwolf got <b>7.87363200</b> [TRDO](https://steem-engine.com/?p=history&t=TRDO) & @theguruasia got <b>5.24908800</b> [TRDO](https://steem-engine.com/?p=history&t=TRDO)! 

<b>"Call [TRDO](https://steem-engine.com/?p=history&t=TRDO), Your Comment Worth Something!"</b>
---
<sup>To view or trade TRDO go to [steem-engine.com](https://steem-engine.com/?p=market&t=TRDO)
Join [TRDO Discord Channel](https://discord.gg/wySP8T9) or Join [TRDO Web Site](http://www.trendotoken.info/)</sup>
properties (22)
authortrendotoken
permlinkre-theguruasia-re-therealwolf-pyff06-20190926t065045108z
categorysteem
json_metadata{"tags":["comments-scot","trendo-bot"],"app":"comments-scot/1.1","format":"markdown"}
created2019-09-26 06:50:45
last_update2019-09-26 06:50:45
depth2
children0
last_payout2019-10-03 06:50:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length583
author_reputation5,546,209,053,433
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,955,793
net_rshares0
@trendovoter ·
Congratulations @theguruasia, <b>100%</b> upvote has been shared with your successful call on the post that shared by @therealwolf!

---
<sup>Support <b>@trendotoken</b> projects by delegating : <b>[100SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=100.000%20SP)</b> , <b>[200SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=200.000%20SP) , <b>[500SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=500.000%20SP)</b> , <b>[1000SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=1000.000%20SP)</b> , <b>[2000SP](https://beta.steemconnect.com/sign/delegateVestingShares?delegator=YOURUSERNAME&delegatee=trendovoter&vesting_shares=2000.000%20SP)</b></sup>
properties (22)
authortrendovoter
permlinkre-therealwolf-steem-keychain-promise-wrapper-20190926t065041820z
categorysteem
json_metadata{"tags":["trdo","newssteem"],"app":"trdo-voter/1.0","format":"markdown"}
created2019-09-26 06:50:42
last_update2019-09-26 06:50:42
depth1
children0
last_payout2019-10-03 06:50:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length943
author_reputation58,041,103,589
root_title"Steem Keychain Promise Wrapper"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id90,955,792
net_rshares0