diff --git a/parse.py b/parse.py index 5157325..5a2b5f2 100644 --- a/parse.py +++ b/parse.py @@ -311,8 +311,8 @@ class Router: pi = Pipe(False) po = Process(target=self.__wrap, args=(cmd.i, fn, cmd,)) self.__r[cmd.i] = (po, pi,) - time.sleep(5) po.start() + po.join() def finish(self): @@ -385,6 +385,7 @@ def load_gas(address,nonce): message = f"Added some gas to {address}" printMessage(message) + def store_voucher(voucher_creator,voucher_symbol,voucher_address): vouchers = [] @@ -407,7 +408,6 @@ def store_voucher(voucher_creator,voucher_symbol,voucher_address): json.dump(vouchers, f) - def key_create_handler(cmd): key_name = str(cmd.f).split(":")[1] master_address = w3.eth.account.from_key(master_private_key) @@ -421,10 +421,9 @@ def key_create_handler(cmd): else: private_key = cmd.k address = w3.eth.account.from_key(private_key).address - time.sleep(5) + load_gas(address,nonce) store_key_in_keystore(private_key, key_name, address) - return address @@ -438,6 +437,7 @@ def voucher_create_handler(cmd): existing_vouchers = json.load(f) except (FileNotFoundError): existing_vouchers = [] + voucher_symbols = list(map(lambda symbol: symbol['symbol'], existing_vouchers)) if symbol in voucher_symbols: @@ -453,12 +453,13 @@ def voucher_create_handler(cmd): f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \ f'p erc20 --name "{name}" --symbol "{symbol}"' - result = subprocess.run(publish_token, shell=True, capture_output=True, text=True) if result.returncode != 0: raise subprocess.CalledProcessError(result.returncode, publish_token, output=result.stdout, stderr=result.stderr) + output_lines = result.stderr.strip().split("\n") deployment_result = output_lines[1] + try: data = json.loads(deployment_result) contract_address = data.get('contract_address', None) @@ -545,6 +546,7 @@ def voucher_transfer_handler(cmd): raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr) if result.stderr: raise ValueError(f"Command failed with error: {result.stderr}") + data = json.loads(result.stdout) message = f"Transfered {value} {voucher_name} to {to} " printMessage(message) @@ -608,9 +610,6 @@ def voucher_mint_handler(cmd): -def foo_handler(cmd): - return os.popen('eth-info -p https://celo.grassecon.net').read() - parser = yacc.yacc() @@ -675,10 +674,10 @@ class WaitGet: if __name__ == '__main__': ifc = None o = Router() - o.register(CmdId.KEY_CREATE,foo_handler) - o.register(CmdId.VOUCHER_CREATE,foo_handler) - o.register(CmdId.VOUCHER_MINT, foo_handler) - o.register(CmdId.VOUCHER_TRANSFER,foo_handler) + o.register(CmdId.KEY_CREATE,key_create_handler) + o.register(CmdId.VOUCHER_CREATE,voucher_create_handler) + o.register(CmdId.VOUCHER_MINT, voucher_mint_handler) + o.register(CmdId.VOUCHER_TRANSFER,voucher_transfer_handler) if len(sys.argv) > 1: ifc = FileGet(o, sys.argv[1])