Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
add funding address to allocmd
Browse files Browse the repository at this point in the history
  • Loading branch information
okedeji committed Apr 24, 2024
1 parent 6f88512 commit a8ebaaa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
14 changes: 12 additions & 2 deletions allocmd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from jinja2 import Environment, FileSystemLoader
from importlib.resources import files
from termcolor import colored, cprint
from .utilities.utils import generate_all_files, print_allora_banner, run_key_generate_command, deployWorker, deployValidator, generateWorkerAccount, generateProdCompose, check_docker_running, blocklessNode
from .utilities.utils import generate_all_files, print_allora_banner, run_key_generate_command, deployWorker, deployValidator, generateWorkerAccount, generateProdCompose, check_docker_running, blocklessNode, fundAddress
from .utilities.typings import Command, BlocklessNodeType
from .utilities.constants import cliVersion

Expand Down Expand Up @@ -79,9 +79,19 @@ def validator(name=None, network=None):
subprocess.run(['chmod', '+x', f'{name}/validator/scripts/start-validator.sh'], check=True)
else:
cprint("\nOperation cancelled.", 'red')


@click.command()
@click.option('--address',required=True, help='the account address to be funded.')
@click.option('--network', required=True, type=click.Choice(['testnet', 'edgenet']), help='Your preffered chain network to fund address from.')
def fund(address=None, network=None):
"""fund allora account address"""

cprint(f"\nfunding allora address: {address}", 'green')
cprint(f"Funding account with {network} tokens", 'green')
faucet_url = f'https://faucet.{network}.allora.network/'
fundAddress(faucet_url, address, network)

cli.add_command(fund)



Expand Down
2 changes: 1 addition & 1 deletion allocmd/utilities/constants.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cliVersion = "0.3.18"
cliVersion = "0.3.19"
22 changes: 17 additions & 5 deletions allocmd/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import re
import yaml

def create_worker_account(worker_name, faucet_url, type):
def create_worker_account(worker_name, faucet_url, type, network="testnet"):
current_file_dir = os.path.dirname(os.path.abspath(__file__))
cli_tool_dir = os.path.dirname(current_file_dir)
allora_chain_dir = os.path.join(cli_tool_dir, 'allora-chain')
Expand Down Expand Up @@ -75,15 +75,28 @@ def create_worker_account(worker_name, faucet_url, type):
subprocess.run([
'curl',
'-Lvvv',
f'{faucet_url}/send/testnet/{address}'
f'{faucet_url}/send/{network}/{address}'
], stdout=subprocess.DEVNULL)

print(colored(f"keys created and testnet-funded for this {type}. please check config.yaml for your address and mnemonic", "green"))
print(colored(f"keys created and {network}-funded for this {type}. please check config.yaml for your address and mnemonic", "green"))
return mnemonic, hex_coded_pk, address
else:
print(colored("'make' is not available in the system's PATH. Please install it or check your PATH settings.", "red"))
return ''

def fundAddress(faucet_url, address, network="testnet"):
try:
subprocess.run([
'curl',
'-Lvvv',
f'{faucet_url}/send/{network}/{address}'
], stdout=subprocess.DEVNULL)

print(colored(f"address funded with {network}-faucet", "green"))
return address
except subprocess.CalledProcessError as e:
click.echo(f"error funding address: {e}", err=True)

def print_allora_banner():
"""Prints an ASCII art styled banner for ALLORA."""
banner_text = r"""
Expand Down Expand Up @@ -173,7 +186,6 @@ def generateProdCompose(env: Environment, type):

try:
result = subprocess.run("chmod -R +rx ./data/scripts", shell=True, check=True, capture_output=True, text=True)
print(result)
except subprocess.CalledProcessError as e:
print(f"Command '{e.cmd}' returned non-zero exit status {e.returncode}.")
if e.stderr:
Expand Down Expand Up @@ -216,7 +228,7 @@ def generateProdCompose(env: Environment, type):

generate_all_files(env, file_configs, Command.DEPLOY, type)
cprint(f"production docker compose file generated to be deployed", 'green')
# cprint(f"please run chmod -R +rx ./data/scripts to grant script access to the image", 'yellow')
cprint(f"please run chmod -R +rx ./data/scripts to grant script access to the image", 'yellow')
else:
cprint("\nOperation cancelled.", 'red')

Expand Down

0 comments on commit a8ebaaa

Please sign in to comment.