Skip to content

Commit

Permalink
Revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheran-senthil committed Jan 16, 2025
1 parent bd82383 commit 6dede67
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions content-node/content-node-register.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,27 @@ def run_command(command, parse_json=False):
return parse_json_str(output.stdout)
return output

def get_cli_network(input_network):
network_map = {
"staging": "testnet-sepolia-staging",
"testnet": "testnet-sepolia",
"testnet-sepolia": "testnet-sepolia"
}
return network_map.get(input_network)

def main():
network = input("Enter Network: ")

if network not in ["staging", "testnet", "testnet-sepolia"]:
print("Network is invalid. Network must be either staging, testnet, or testnet-sepolia")
exit(1)

cli_network = get_cli_network(network)

private_key = input("Enter Private Key: ")
hostname = input("Enter hostname: ")
operator_id = input("Enter Operator ID: ")
region = input("Enter region: ")

# if region is not "us", "eu", "emea", or "apac", exit
if region not in ["us", "eu", "emea", "apac"]:
print("region is invalid. region must be either us, eu, emea, or apac")
exit(1)

# stake 100 tokens for the node
STAKE_AMOUNT = 100
run_command(f"npx earthfast-cli operator stake {operator_id} {STAKE_AMOUNT} --key {private_key} --network {cli_network}")
run_command(f"npx earthfast-cli operator stake {operator_id} {STAKE_AMOUNT} --key {private_key} --network {network}")

# make sure that host is available
response = requests.get(f"{hostname}/statusz")
if response.status_code != 200:
Expand All @@ -55,18 +48,20 @@ def main():

ENABLED = False
PRICE = 1.0
run_command(f"npx earthfast-cli node create {operator_id} {hostname}:{region}:{ENABLED}:{PRICE} --key {private_key} --network {cli_network}")
run_command(f"npx earthfast-cli node create {operator_id} {hostname}:{region}:{ENABLED}:{PRICE} --key {private_key} --network {network}")

print("Node created successfully. Please save the 'nodeId' value from the output above. You can always retrieve this value by running 'npx earthfast-cli node list --network $NETWORK'")
nodes=run_command(f"npx earthfast-cli node list --network {cli_network} --json", True)

nodes=run_command(f"npx earthfast-cli node list --network {network} --json", True)

nodeId = None
for node in nodes:
if node.get("hostname") == hostname:
nodeId = node.get("id")
break

run_command(f"npx earthfast-cli node enable {nodeId} true --key {private_key} --network {cli_network}")
run_command(f"npx earthfast-cli node enable {nodeId} true --key {private_key} --network {network}")


if __name__ == "__main__":
main()
main()

0 comments on commit 6dede67

Please sign in to comment.