From 446787559eaf3a9eeecf14cc1661b3fb585ee896 Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 7 Aug 2020 11:40:15 +0200 Subject: [PATCH] Remove multiple provideres in contrustor --- scripts/web3_middleware.py | 2 +- src/web3ext/__init__.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/web3_middleware.py b/scripts/web3_middleware.py index 3623649..da8b02d 100644 --- a/scripts/web3_middleware.py +++ b/scripts/web3_middleware.py @@ -2,7 +2,7 @@ from web3ext import Web3 # TODO: remove and replace with test if __name__ == '__main__': - w3 = Web3(['ws://127.0.0.1:8546']) + w3 = Web3() print(w3.eth.personal.newAccount('foo')) print(w3.eth.blockNumber) #print(w3.eth.sendTransaction({'to': '0xd3CdA913deB6f67967B99D67aCDFa1712C293601','from': '0xc305c901078781C232A2a521C2aF7980f8385ee9','value': 1000})) diff --git a/src/web3ext/__init__.py b/src/web3ext/__init__.py index 207ef1d..07dea39 100644 --- a/src/web3ext/__init__.py +++ b/src/web3ext/__init__.py @@ -15,14 +15,12 @@ def create_middleware(ipcaddr='/tmp/foo.ipc'): # overrides the original Web3 constructor -def Web3(blockchain_providers=[], ipcaddr=None): - if len(blockchain_providers) > 1: - raise ValueError('backend only supports single provider') +def Web3(blockchain_provider='ws://localhost:8546', ipcaddr=None): provider = None - if re.match(re_websocket, blockchain_providers[0]) != None: - provider = WebsocketProvider(blockchain_providers[0]) + if re.match(re_websocket, blockchain_provider) != None: + provider = WebsocketProvider(blockchain_provider) elif re.match(re_http, blockchain_providers[0]) != None: - provider = HTTPProvider(blockchain_providers[0]) + provider = HTTPProvider(blockchain_provider) w3 = Web3super(provider)