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: replace safe release type with autonomi #24

Merged
merged 2 commits into from
Oct 20, 2024
Merged
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
31 changes: 8 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,25 @@ use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use zip::ZipArchive;

const AUTONOMI_S3_BASE_URL: &str = "https://autonomi-cli.s3.eu-west-2.amazonaws.com";
const GITHUB_API_URL: &str = "https://api.github.com";
const FAUCET_S3_BASE_URL: &str = "https://sn-faucet.s3.eu-west-2.amazonaws.com";
const NAT_DETECTION_S3_BASE_URL: &str = "https://nat-detection.s3.eu-west-2.amazonaws.com";
const NODE_LAUNCHPAD_S3_BASE_URL: &str = "https://node-launchpad.s3.eu-west-2.amazonaws.com";
const SAFE_S3_BASE_URL: &str = "https://sn-cli.s3.eu-west-2.amazonaws.com";
const SAFENODE_S3_BASE_URL: &str = "https://sn-node.s3.eu-west-2.amazonaws.com";
const SAFENODE_MANAGER_S3_BASE_URL: &str = "https://sn-node-manager.s3.eu-west-2.amazonaws.com";
const SAFENODE_RPC_CLIENT_S3_BASE_URL: &str =
"https://sn-node-rpc-client.s3.eu-west-2.amazonaws.com";
const SN_AUDITOR_S3_BASE_URL: &str = "https://sn-auditor.s3.eu-west-2.amazonaws.com";
const SAFENODE_S3_BASE_URL: &str = "https://sn-node.s3.eu-west-2.amazonaws.com";
const WINSW_URL: &str = "https://sn-node-manager.s3.eu-west-2.amazonaws.com/WinSW-x64.exe";

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum ReleaseType {
Faucet,
Autonomi,
NatDetection,
NodeLaunchpad,
Safe,
Safenode,
SafenodeManager,
SafenodeManagerDaemon,
SafenodeRpcClient,
SnAuditor,
}

impl fmt::Display for ReleaseType {
Expand All @@ -55,15 +51,13 @@ impl fmt::Display for ReleaseType {
f,
"{}",
match self {
ReleaseType::Faucet => "faucet",
ReleaseType::Autonomi => "autonomi",
ReleaseType::NatDetection => "nat-detection",
ReleaseType::NodeLaunchpad => "node-launchpad",
ReleaseType::Safe => "safe",
ReleaseType::Safenode => "safenode",
ReleaseType::SafenodeManager => "safenode-manager",
ReleaseType::SafenodeManagerDaemon => "safenodemand",
ReleaseType::SafenodeRpcClient => "safenode_rpc_client",
ReleaseType::SnAuditor => "sn_auditor",
}
)
}
Expand All @@ -72,16 +66,13 @@ impl fmt::Display for ReleaseType {
lazy_static! {
static ref RELEASE_TYPE_CRATE_NAME_MAP: HashMap<ReleaseType, &'static str> = {
let mut m = HashMap::new();
m.insert(ReleaseType::Faucet, "sn_faucet");
m.insert(ReleaseType::Autonomi, "autonomi");
m.insert(ReleaseType::NatDetection, "nat-detection");
m.insert(ReleaseType::NodeLaunchpad, "node-launchpad");
m.insert(ReleaseType::Safe, "sn_cli");
m.insert(ReleaseType::Safenode, "sn_node");
m.insert(ReleaseType::SafenodeManager, "sn-node-manager");
m.insert(ReleaseType::SafenodeManagerDaemon, "sn-node-manager");
m.insert(ReleaseType::SafenodeRpcClient, "sn_node_rpc_client");
m.insert(ReleaseType::SnAuditor, "sn_auditor");

m
};
}
Expand Down Expand Up @@ -156,41 +147,35 @@ impl dyn SafeReleaseRepoActions {
Box::new(SafeReleaseRepository {
github_api_base_url: GITHUB_API_URL.to_string(),
nat_detection_base_url: NAT_DETECTION_S3_BASE_URL.to_string(),
faucet_base_url: FAUCET_S3_BASE_URL.to_string(),
node_launchpad_base_url: NODE_LAUNCHPAD_S3_BASE_URL.to_string(),
safe_base_url: SAFE_S3_BASE_URL.to_string(),
autonomi_base_url: AUTONOMI_S3_BASE_URL.to_string(),
safenode_base_url: SAFENODE_S3_BASE_URL.to_string(),
safenode_manager_base_url: SAFENODE_MANAGER_S3_BASE_URL.to_string(),
safenode_rpc_client_base_url: SAFENODE_RPC_CLIENT_S3_BASE_URL.to_string(),
sn_auditor_base_url: SN_AUDITOR_S3_BASE_URL.to_string(),
})
}
}

pub struct SafeReleaseRepository {
pub github_api_base_url: String,
pub faucet_base_url: String,
pub nat_detection_base_url: String,
pub node_launchpad_base_url: String,
pub safe_base_url: String,
pub autonomi_base_url: String,
pub safenode_base_url: String,
pub safenode_manager_base_url: String,
pub safenode_rpc_client_base_url: String,
pub sn_auditor_base_url: String,
}

impl SafeReleaseRepository {
fn get_base_url(&self, release_type: &ReleaseType) -> String {
match release_type {
ReleaseType::Faucet => self.faucet_base_url.clone(),
ReleaseType::NatDetection => self.nat_detection_base_url.clone(),
ReleaseType::NodeLaunchpad => self.node_launchpad_base_url.clone(),
ReleaseType::Safe => self.safe_base_url.clone(),
ReleaseType::Autonomi => self.autonomi_base_url.clone(),
ReleaseType::Safenode => self.safenode_base_url.clone(),
ReleaseType::SafenodeManager => self.safenode_manager_base_url.clone(),
ReleaseType::SafenodeManagerDaemon => self.safenode_manager_base_url.clone(),
ReleaseType::SafenodeRpcClient => self.safenode_rpc_client_base_url.clone(),
ReleaseType::SnAuditor => self.sn_auditor_base_url.clone(),
}
}

Expand Down
Loading
Loading