https://github.com/holgern/beem
I created a discord channel for answering a question or discussing beem: https://discord.gg/4HM592V
auto_clean function for the cache.auto_clean is now disabled with set_cache_auto_clean(False) and the cache is manually cleaned with clear_cache_from_expired_items() when all threads are finished.blocks() finishes, set_cache_auto_clean(auto_clean) is set to the old value.Inspired by steemconnect-python-client by @emrebeyler, SteemConnect is now integrated into beem.
I created @beem.app inside steemconnect for testing (https://v2.steemconnect.com/apps/).
The following steps were done to integrate steemconnect properly:
You see a diff between both functions here (On the left side is client.py shown and on the right side steemconnect.py from beem). White ares indicate that both files are identically.
beem.steemconnect can be used to create steemconnect links for broadcasting transactions.
In the first example, nobroadcast=True and unsigned=True is used to disable signing and broadcasting. When then a broadcasting operation is called, the unsigned transaction is returned and entered into url_from_tx. This function from SteemConnect returns then a steemconnect v2 link which can be entered into the browser.
from beem import Steem
from beem.account import Account
from beem.steemconnect import SteemConnect
from pprint import pprint
steem = Steem(nobroadcast=True, unsigned=True)
sc2 = SteemConnect(steem_instance=steem)
acc = Account("test", steem_instance=steem)
pprint(sc2.url_from_tx(acc.transfer("test1", 1, "STEEM", "test")))
results in:
'https://v2.steemconnect.com/sign/transfer?from=test&to=test1&amount=1.000+STEEM&memo=test'
It is also possible to create a operation by hand:
from beem import Steem
from beem.transactionbuilder import TransactionBuilder
from beembase import operations
from beem.steemconnect import SteemConnect
from pprint import pprint
stm = Steem()
sc2 = SteemConnect(steem_instance=stm)
tx = TransactionBuilder(steem_instance=stm)
op = operations.Transfer(**{"from": 'test',
"to": 'test1',
"amount": '1.000 STEEM',
"memo": 'test'})
tx.appendOps(op)
pprint(sc2.url_from_tx(tx.json()))
results in:
'https://v2.steemconnect.com/sign/transfer?from=test&to=test1&amount=1.000+STEEM&memo=test'
By adding -l as option, all available broadcast operation can be converted into a link:
beempy -l claimreward holger80
results in
"https://v2.steemconnect.com/sign/claim_reward_balance?account=holger80&reward_steem=0.048+STEEM&reward_sbd=3.842+SBD&reward_vests=5093.882902+VESTS"
In examples/login_app, an example app.py can be found. This example was adapted from steemconnect-python-client. Set the client_id, the scope and unlocking the wallet by entering the correct passphrase.
The flask app can be started by
flask run
Enter http://127.0.0.1:5000/ in a browser and click on the link.
After entering a username and password, the generated token is stored in the wallet.
from beem import Steem
from beem.steemconnect import SteemConnect
from beem.comment import Comment
sc2 = SteemConnect(client_id="beem.app")
steem = Steem(steemconnect=sc2)
steem.wallet.unlock("supersecret-passphrase")
post = Comment("author/permlink", steem_instance=steem)
post.upvote(voter="test") # replace "test" with your account
By adding -s as option, all broadcast operation as upvote are broadcast via Steemconnect
beempy -s upvote -a test -w 100 @author/permlink
This command can be used to show all stored token: