funga-eth

Ethereum implementation of the funga keystore and signer
Info | Log | Files | Refs | README | LICENSE

__init__.py (755B)


      1 import logging
      2 import re
      3 
      4 from web3 import Web3 as Web3super
      5 from web3 import WebsocketProvider, HTTPProvider
      6 from .middleware import PlatformMiddleware
      7 
      8 re_websocket = re.compile('^wss?://')
      9 re_http = re.compile('^https?://')
     10 
     11 logg = logging.getLogger(__file__)
     12 
     13 
     14 def create_middleware(ipcpath):
     15     PlatformMiddleware.ipcaddr = ipcpath
     16     return PlatformMiddleware
     17 
     18 
     19 # overrides the original Web3 constructor
     20 #def Web3(blockchain_provider='ws://localhost:8546', ipcpath=None):
     21 def Web3(provider, ipcpath=None):
     22     w3 = Web3super(provider)
     23 
     24     if ipcpath != None:
     25         logg.info('using signer middleware with ipc {}'.format(ipcpath))
     26         w3.middleware_onion.add(create_middleware(ipcpath))
     27 
     28     w3.eth.personal = w3.geth.personal
     29     return w3