parse json from ge-publish
This commit is contained in:
parent
a5e84ba7df
commit
dc87181e0a
18
parse.py
18
parse.py
@ -381,21 +381,21 @@ def voucher_create_handler(cmd):
|
|||||||
if privatekey.startswith("0x"):
|
if privatekey.startswith("0x"):
|
||||||
private_key = privatekey[2:]
|
private_key = privatekey[2:]
|
||||||
|
|
||||||
command = f'ge-publish --private-key {private_key} ' \
|
command = f'ge-publish --private-key {private_key} --json ' \
|
||||||
f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \
|
f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \
|
||||||
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
||||||
|
|
||||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
||||||
output = result.stderr.strip().split("\n")
|
output_lines = result.stderr.strip().split("\n")
|
||||||
contract_address = None
|
deployment_result = output_lines[1]
|
||||||
|
try:
|
||||||
for word in output[1].split():
|
data = json.loads(deployment_result)
|
||||||
if "contract_address=" in word:
|
contract_address = data.get('contract_address', None)
|
||||||
contract_address = word.split("=")[1]
|
except json.JSONDecodeError as e:
|
||||||
print("Voucher created with Address:",contract_address)
|
print("Error parsing JSON:", e)
|
||||||
store_voucher(privatekey,symbol,remove_ansi_escape_codes(contract_address))
|
print("Voucher created with contract address:",contract_address)
|
||||||
return contract_address
|
return contract_address
|
||||||
|
|
||||||
def voucher_transfer_handler(cmd):
|
def voucher_transfer_handler(cmd):
|
||||||
|
Loading…
Reference in New Issue
Block a user