Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: relay-setup-CKIP-19 #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
26 changes: 26 additions & 0 deletions services/jvm/chain_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"chains": {
"icon0": {
"network": "0x3.icon",
"endpoint": "http://localhost:9080/api/v3/icon_dex",
"keystore": "./docker/icon/config/keystore.json",
"keysecret": "./docker/icon/config/keysecret"
},
"icon1": {
"network": "0x101.icon",
"endpoint": "http://localhost:9180/api/v3/icon_dex",
"keystore": "./docker/icon/config/keystore.json",
"keysecret": "./docker/icon/config/keysecret"
},
"hardhat": {
"network": "0x539.hardhat",
"endpoint": "http://localhost:8545",
"keystore": "./docker/hardhat/keystore0.json",
"keypass": "hardhat"
}
},
"link": {
"src": "icon0",
"dst": "hardhat"
}
}
75 changes: 75 additions & 0 deletions services/jvm/relay.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
RELAY_BIN = "../bin/relay"

def relay(plan,args,chain_config_path, deployment_path):
if RELAY_BIN != "null":
hello=plan.add_service(name="hello", config=ServiceConfig(
image="ubuntu:latest",
))
plan.exec(service_name="hello",recipe=ExecRecipe(
command=["echo", "hello"],
))
else:
RELAY_BIN

SRC_NETWORK = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "."+SRC+".network", deployment_path],))
SRC_BMC_ADDRESS = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "."+SRC+".contracts.bmc"],))
SRC_ADDRESS = "btp://"+SRC_NETWORK+"/"+SRC_BMC_ADDRESS
SRC = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".link.src",chain_config_path],))
SRC_ENDPOINT = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+SRC+".endpoint"],))
SRC_KEY_STORE = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+SRC+".keystore" ],))
SRC_KEY_SECRET = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+SRC+".keysecret" ],))

if SRC_KEY_SECRET != "null":
SRC_KEY_PASSWORD = plan.print(SRC_KEY_SECRET)
else:
SRC_KEY_PASSWORD = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "chain."+SRC+".keypass"],))

DST_NETWORK = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "."+DST+".network", deployment_path],))
DST_BMC_ADDRESS = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "."+DST+".contracts.bmc"],))
DST_ADDRESS = "btp://"+DST_NETWORK+"/"+DST_BMC_ADDRESS
DST = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".link.dst",chain_config_path],))
DST_ENDPOINT = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+DST+".endpoint"],))
DST_KEY_STORE = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+DST+".keystore" ],))
DST_KEY_SECRET = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", ".chains."+DST+".keysecret" ],))

if DST_KEY_SECRET != "null":
DST_KEY_PASSWORD = plan.print(DST_KEY_SECRET)
else:
DST_KEY_PASSWORD = plan.exec(service_name="hello", recipe=ExecRecipe(command=["jq", "chain."+DST+".keypass"],))

if BMV_BRIDGE == True:
plan.print("using bridge mode")
else:
plan.print("Using BTP Block node")
BMV_BRIDGE = False

exec_command = ExecRecipe(command=[
RELAY_BIN,
"--direction",
"both",
"--src.address",
SRC_ADDRESS,
"--src.endpoint",
SRC_ENDPOINT,
"--src.key_store",
SRC_KEY_STORE,
"--src.key_password",
SRC_KEY_PASSWORD,
"--src.bridge_mode",
BMV_BRIDGE,
"--dst.address",
DST_ADDRESS,
"--dst.endpoint",
DST_ENDPOINT,
"--dst.key_store"
DST_KEY_STORE,
"dst.key_password",
DST_KEY_PASSWORD,
"start"
],)
result = plan.exec(service_name="hello", recipe=exec_command)

return result["output"]