Exemple #1
0
def sethost(host: str):
    """
    Setup the Web3 connection (RPC, IPC, HTTP) - This should be the first step 
    """
    if host is None:
        cprint("Missing Argument 'host'?", "red")
        return 0

    ctx = context.get_context()
    cprint("Input: {}".format(host), "yellow")
    cprint("Verbose? {}".format(ctx.verbose), "yellow")

    w3.connect(host)

    if w3.isConnected():
        cprint("Web3 API Version: {}".format(w3.api), "green")
        cprint(
            "connected to: {}".format(w3.node_uri),
            "green",
        )
        cprint("Version: {}".format(w3.clientVersion), "green")
    else:
        cprint("Web3 API Version: {}".format(w3.api), "red")
        cprint("Cannot connect to: {} ".format(host), "red")

    return 0
Exemple #2
0
def sethost(host: str):
    """
    Setup the Web3 connection (RPC, IPC, HTTP) - This should be the first step 
    """
    if (host is None):
        cprint("Missing Argument 'host'?", "red")
        return 0

    ctx = context.get_context()
    cprint("Input: {}".format(host), "yellow")
    cprint("Verbose? {}".format(ctx.verbose), "yellow")

    w3 = Web3()
    if not any(ext in host for ext in Protocols):
        host = "https://" + host

    WEB3_PROVIDER_URI = host
    os.environ["WEB3_PROVIDER_URI"] = host

    if (w3.isConnected()):
        cprint("Web3 API Version: {}".format(w3.api), "green")
        cprint("connected to: {}".format(w3.provider._active_provider.endpoint_uri), "green")
        cprint("Version: {}".format(w3.clientVersion), "green")
    else:
        cprint("Web3 API Version: {}".format(w3.api), "red")
        cprint("Cannot connect to: {} ".format(host), "red")

    return 0
Exemple #3
0
 def get_tokens(self):
     spacer = (Token.Spacer, "  ")
     if context.get_context().verbose:
         is_verbose = (Token.Warn, "ON")
     else:
         is_verbose = (Token.Info, "OFF")
     return [
         (Token.Toolbar, "Legions"),
         spacer,
         (Token.Toolbar, "Verbose "),
         spacer,
         is_verbose,
     ]