def import_contract(): contract_address = tools.get_file("contract_address.txt") contract_interface = tools.get_json("contract_interface.json") authority_contract = w3.eth.contract(abi=contract_interface['abi'], address=contract_address) log.out.debug("chainhandler: \"Imported contract: {}\"".format( authority_contract.address)) return authority_contract
def web3_login(): log.out.info("\033[93m### GETH LOG IN ####\033[0m") is_unlocked = False attempts_left = 3 while (is_unlocked is False and (attempts_left > 0)): log.out.debug("Loading User Info") user_info = tools.get_json("user_info.json") log.out.debug("User_info: {}".format(user_info)) log.out.info("\033[93mPlease enter your username:\033[0m") #username = "******" username = input() try: account = user_info[username]["address"] log.out.info("\033[93mLogging in with Account: {}\033[0m".format(account)) log.out.info("\033[93mPlease enter your Pasword\033[0m") password = getpass.getpass() is_unlocked = w3.personal.unlockAccount(account, password, 15000) if (is_unlocked is False): log.out.warning("\033[91mPassword incorrect, please try again.\033[0m") attempts_left -= 1 if (attempts_left > 0): log.out.warning("\033[91m{} attepts left\033[0m".format(attempts_left)) else: log.out.warning("\033[91mNo attepts left.\033[0m".format(attempts_left)) log.out.warning("\033[91mExiting...\033[0m".format(attempts_left)) exit() else: log.out.info("\033[92mLogin successful.\033[0m") return account except KeyError as e: log.out.warning("\033[91mUsername {} not found, please try again.\033[0m".format(username)) attempts_left -= 1 if (attempts_left > 0): log.out.warning("\033[91m{} attepts left\033[0m".format(attempts_left)) else: log.out.warning("\033[91mNo attepts left.\033[0m".format(attempts_left)) log.out.warning("\033[91mExiting...\033[0m".format(attempts_left)) exit()
import json from etheronauth import tools from etheronauth import log log.out.info("### Testing on module > tools <") log.out.info("# Checking on global Datadir") log.out.info(tools.get_dir()) log.out.info("# Standard File write") log.out.info( tools.write_file("../tests/results/res_filewrite.txt", "Test payload")) log.out.info("# Standard File read") log.out.info(tools.get_file("../tests/results/res_filewrite.txt")) log.out.info("# JSON File write") log.out.info( tools.write_json("../tests/results/res_filewrite_json.txt", json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]'))) log.out.info("# JSON File read") log.out.info(tools.get_json("../tests/results/res_filewrite_json.txt")) log.out.info("### End of Test")
from etheronauth import secrethandling from etheronauth import tools keys = tools.get_json("jwt_keys.json") secrethandling.write_json_to_file("TestTestTest", "jwt_keys.secure", keys)
import json from etheronauth import tokengen from etheronauth import log from etheronauth import tools # Please make sure: # - You provide the File: ressources/jwt_keys.secure # - You adjust the password in this file (line 13 + 16) log.out.info("### Testing on module > tokengen <") log.out.info("#Checking get_private_key") log.out.info(tokengen.get_private_key("TestTestTest")[0:30]) log.out.info("#Checking get_public_key") log.out.info(tokengen.get_public_key("TestTestTest")[0:30]) log.out.info("Loading Example") data = tools.get_json("../tests/examples/example_jwt.json") log.out.info("#Checking encode_jwt") encoded_Data = tokengen.encode_jwt(data) tools.write_file("../tests/results/res_encoded_jwt.txt", encoded_Data.decode()) log.out.info("Encoded JWT is: {} ...".format(encoded_Data[0:20])) log.out.info("#Checking decode_jwt") decoded_Data = tokengen.decode_jwt(encoded_Data) tools.write_json("../tests/results/res_decoded_jwt.json", decoded_Data) log.out.info("Decoded JWT is: {} ...".format(decoded_Data))