diff --git a/beem/cli.py b/beem/cli.py index 88bc0f14097aeb1c219f242b4bec17a6d3a29dd6..d49c95f35ea60d9bf31e3040ccf9514426576b97 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -559,7 +559,7 @@ def addtoken(name, unsafe_import_token): @cli.command() @click.option('--confirm', - prompt='Are your sure? This is IRREVERSIBLE! If you dont have a backup you may lose access to your account!', + prompt='Are your sure?', hide_input=False, callback=prompt_flag_callback, is_flag=True, confirmation_prompt=False, help='Please confirm!') @click.argument('name') diff --git a/beem/steemconnect.py b/beem/steemconnect.py index cb2119e850a5cb33f88193e8701a0502cff3259e..98025d56337e45ba322503844e94816c59c3a704 100644 --- a/beem/steemconnect.py +++ b/beem/steemconnect.py @@ -13,6 +13,7 @@ except ImportError: import requests from .storage import configStorage as config from beem.instance import shared_steem_instance +from beem.amount import Amount class SteemConnect(object): @@ -242,7 +243,17 @@ class SteemConnect(object): urls = [] operations = tx["operations"] for op in operations: - urls.append(self.create_hot_sign_url(op[0], op[1], redirect_uri=redirect_uri)) + operation = op[0] + params = op[1] + for key in params: + value = params[key] + if isinstance(value, list) and len(value) == 3: + try: + amount = Amount(value, steem_instance=self.steem) + params[key] = str(amount) + except: + amount = None + urls.append(self.create_hot_sign_url(operation, params, redirect_uri=redirect_uri)) if len(urls) == 1: return urls[0] else: diff --git a/beem/transactionbuilder.py b/beem/transactionbuilder.py index 74fec880852fd9b37ae912ef7b7509f585d4203c..2209c8ae6195b535dce6402c03c748c6758e39d2 100644 --- a/beem/transactionbuilder.py +++ b/beem/transactionbuilder.py @@ -377,7 +377,7 @@ class TransactionBuilder(dict): self.steem.rpc.broadcast_transaction( args, api="network_broadcast") except Exception as e: - log.error("Could Not broadcasting anything!") + # log.error("Could Not broadcasting anything!") self.clear() raise e diff --git a/tests/beem/test_steemconnect.py b/tests/beem/test_steemconnect.py new file mode 100644 index 0000000000000000000000000000000000000000..647668062e72e9ccb17dcd402868702a1c1b37e5 --- /dev/null +++ b/tests/beem/test_steemconnect.py @@ -0,0 +1,80 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +from builtins import range +from builtins import super +import mock +import string +import unittest +from parameterized import parameterized +import random +import json +from pprint import pprint +from beem import Steem, exceptions +from beem.amount import Amount +from beem.memo import Memo +from beem.version import version as beem_version +from beem.wallet import Wallet +from beem.witness import Witness +from beem.account import Account +from beemgraphenebase.account import PrivateKey +from beem.instance import set_shared_steem_instance +from beem.nodelist import NodeList +from beem.steemconnect import SteemConnect +# Py3 compatibility +import sys +core_unit = "STM" + + +class Testcases(unittest.TestCase): + + @classmethod + def setUpClass(cls): + nodelist = NodeList() + cls.bts = Steem( + node=nodelist.get_nodes(appbase=False), + nobroadcast=True, + unsigned=True, + data_refresh_time_seconds=900, + num_retries=10) + cls.appbase = Steem( + node=nodelist.get_nodes(normal=False, appbase=True), + nobroadcast=True, + unsigned=True, + data_refresh_time_seconds=900, + num_retries=10) + + cls.account = Account("test", full=True, steem_instance=cls.bts) + cls.account_appbase = Account("test", full=True, steem_instance=cls.appbase) + + @parameterized.expand([ + ("non_appbase"), + ("appbase"), + ]) + def test_transfer(self, node_param): + if node_param == "non_appbase": + bts = self.bts + acc = self.account + elif node_param == "appbase": + bts = self.appbase + acc = self.account_appbase + acc.steem.txbuffer.clear() + tx = acc.transfer( + "test1", 1.000, "STEEM", memo="test") + sc2 = SteemConnect(steem_instance=bts) + url = sc2.url_from_tx(tx) + self.assertEqual(url, 'https://v2.steemconnect.com/sign/transfer?from=test&to=test1&amount=1.000+STEEM&memo=test') + + @parameterized.expand([ + ("non_appbase"), + ("appbase"), + ]) + def test_login_url(self, node_param): + if node_param == "non_appbase": + bts = self.bts + elif node_param == "appbase": + bts = self.appbase + sc2 = SteemConnect(steem_instance=bts) + url = sc2.get_login_url("localhost", scope="login,vote") + self.assertEqual(url, 'https://v2.steemconnect.com/oauth2/authorize?client_id=None&redirect_uri=localhost&scope=login,vote')