From 3d16460ba8074a60ba2b28d05fd9c32c05481cb5 Mon Sep 17 00:00:00 2001 From: Tobias Oberstein Date: Tue, 23 Jun 2020 22:25:07 +0200 Subject: [PATCH] xbr fixes (#1396) --- autobahn/twisted/xbr/__init__.py | 4 ++-- autobahn/xbr/__init__.py | 6 ++++++ autobahn/xbr/_config.py | 24 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/autobahn/twisted/xbr/__init__.py b/autobahn/twisted/xbr/__init__.py index cbb8cdd7b..e2ae534f1 100644 --- a/autobahn/twisted/xbr/__init__.py +++ b/autobahn/twisted/xbr/__init__.py @@ -54,8 +54,8 @@ class SimpleBlockchain(_blockchain.SimpleBlockchain): class KeySeries(_seller.KeySeries): log = txaio.make_logger() - def __init__(self, api_id, price, interval, on_rotate=None): - super().__init__(api_id, price, interval, on_rotate) + def __init__(self, api_id, price, interval=None, count=None, on_rotate=None): + super().__init__(api_id, price, interval, count, on_rotate) self.running = False self._run_loop = None self._started = None diff --git a/autobahn/xbr/__init__.py b/autobahn/xbr/__init__.py index f93a6da57..c118ef55c 100644 --- a/autobahn/xbr/__init__.py +++ b/autobahn/xbr/__init__.py @@ -53,6 +53,8 @@ from autobahn.xbr._seller import SimpleSeller, KeySeries # noqa from autobahn.xbr._buyer import SimpleBuyer # noqa + from autobahn.xbr._config import load_or_create_profile, UserConfig, Profile # noqa + HAS_XBR = True if not hasattr(abi, 'collapse_type'): @@ -295,6 +297,10 @@ def account_from_seedphrase(seephrase, index=0): 'sign_eip712_channel_close', 'recover_eip712_channel_close', + 'load_or_create_profile', + 'UserConfig', + 'Profile', + 'MemberLevel', 'ActorType', 'ChannelType', diff --git a/autobahn/xbr/_config.py b/autobahn/xbr/_config.py index e89b0b9a6..d38f514fe 100644 --- a/autobahn/xbr/_config.py +++ b/autobahn/xbr/_config.py @@ -260,6 +260,7 @@ def prompt_for_key(msg, key_len): # default XBR market URL to connect to market_url={market_url} +market_realm={market_realm} # Infura blockchain gateway configuration infura_url={infura_url} @@ -284,12 +285,23 @@ def load_or_create_profile(dotdir=None, profile=None): with open(config_path, 'w') as f: market_url = prompt_for_wamp_url('enter a XBR data market URL') market_realm = click.prompt('enter the WAMP realm of the XBR data market', type=str) - ethkey = prompt_for_key('your private Etherum key', 32) - cskey = prompt_for_key('your private WAMP client key', 32) - infura_network = click.prompt('enter Ethereum network to use', type=str, default='rinkeby') - infura_url = click.prompt('enter Infura gateway URL', type=str) - infura_key = click.prompt('your Infura gateway key', type=str) - infura_secret = click.prompt('your Infura gateway secret', type=str) + ethkey = prompt_for_key('your private Etherum key', os.urandom(32)) + cskey = prompt_for_key('your private WAMP client key', os.urandom(32)) + + # infura_url=https://rinkeby.infura.io/v3/40c6... + # infura_network=rinkeby + # infura_key=40c6... + # infura_secret=5511... + infura_network = click.prompt('enter Ethereum network to use', type=str, default='') + if infura_network: + infura_url = click.prompt('enter Infura gateway URL', type=str) + infura_key = click.prompt('your Infura gateway key', type=str) + infura_secret = click.prompt('your Infura gateway secret', type=str) + else: + infura_url = '' + infura_key = '' + infura_secret = '' + f.write(_DEFAULT_CONFIG.format(market_url=market_url, market_realm=market_realm, ethkey=ethkey, cskey=cskey, infura_url=infura_url, infura_network=infura_network, infura_key=infura_key, infura_secret=infura_secret))