server.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from urllib.parse import urlparse
  2. import streamlit as st
  3. from git_utils import show_git_diff
  4. from run_deploy_script import run_deploy_script
  5. from update_files import update_files
  6. def validate_inputs(chain_name: str, rpc_url: str) -> bool:
  7. if not chain_name:
  8. st.error("Chain name cannot be empty")
  9. return False
  10. if not rpc_url:
  11. st.error("RPC URL cannot be empty")
  12. return False
  13. # Validate URL format
  14. try:
  15. result = urlparse(rpc_url)
  16. if not all([result.scheme in ("http", "https"), result.netloc]):
  17. st.error("Invalid RPC URL format. Please enter a valid HTTP/HTTPS URL")
  18. return False
  19. except:
  20. st.error("Invalid URL format")
  21. return False
  22. return True
  23. def main():
  24. st.header("EVM Contract Deployer")
  25. with st.form("deploy_config", enter_to_submit=False):
  26. chain_name = st.text_input("Chain Name", placeholder="e.g. Ethereum, Sepolia")
  27. rpc_url = st.text_input("RPC URL", placeholder="https://...")
  28. is_mainnet = st.checkbox("Is Mainnet?", value=False)
  29. submitted = st.form_submit_button("🚀 Deploy Contracts and Generate PR")
  30. if submitted:
  31. try:
  32. if not validate_inputs(chain_name, rpc_url):
  33. return
  34. update_files(is_mainnet, chain_name, rpc_url)
  35. # show_git_diff()
  36. run_deploy_script(chain_name)
  37. except Exception as e:
  38. st.error(f"An unexpected error occurred: {e}")
  39. def initialize():
  40. pass
  41. if __name__ == "__main__":
  42. # st.set_page_config(layout="wide")
  43. initialize()
  44. main()