Skip to content

Commit

Permalink
feat: add beta-5 network to supported networks (#5460)
Browse files Browse the repository at this point in the history
## Description
closes #5458. 
Adds beta-5 as a possible target for forc-client.

---------

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
kayagokalp and JoshuaBatty authored Jan 14, 2024
1 parent 5c24f77 commit 9fbb523
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion forc-plugins/forc-client/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pub const NODE_URL: &str = sway_utils::constants::DEFAULT_NODE_URL;
pub const BETA_2_ENDPOINT_URL: &str = "https://node-beta-2.fuel.network";
pub const BETA_3_ENDPOINT_URL: &str = "https://beta-3.fuel.network";
pub const BETA_4_ENDPOINT_URL: &str = "https://beta-4.fuel.network";
pub const BETA_4_FAUCET_URL: &str = "https://faucet-beta-4.fuel.network";
pub const BETA_5_ENDPOINT_URL: &str = "https://beta-5.fuel.network";
pub const BETA_FAUCET_URL: &str = "https://faucet-beta-5.fuel.network";
12 changes: 6 additions & 6 deletions forc-plugins/forc-client/src/util/node_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn get_node_url(
node_target.target.clone(),
node_target.node_url.clone(),
) {
(true, None, None) => Target::Beta4.target_url(),
(true, None, None) => Target::Beta5.target_url(),
(false, Some(target), None) => target.target_url(),
(false, None, Some(node_url)) => node_url,
(false, None, None) => manifest_network
Expand All @@ -38,22 +38,22 @@ fn test_get_node_url_testnet() {
};

let actual = get_node_url(&input, &None).unwrap();
assert_eq!("https://beta-4.fuel.network", actual);
assert_eq!("https://beta-5.fuel.network", actual);
}

#[test]
fn test_get_node_url_beta4() {
fn test_get_node_url_beta5() {
let input = NodeTarget {
target: Some(Target::Beta4),
target: Some(Target::Beta5),
node_url: None,
testnet: false,
};
let actual = get_node_url(&input, &None).unwrap();
assert_eq!("https://beta-4.fuel.network", actual);
assert_eq!("https://beta-5.fuel.network", actual);
}

#[test]
fn test_get_node_url_beta4_url() {
fn test_get_node_url_beta4() {
let input = NodeTarget {
target: None,
node_url: Some("https://beta-4.fuel.network".to_string()),
Expand Down
10 changes: 8 additions & 2 deletions forc-plugins/forc-client/src/util/target.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::constants::{BETA_2_ENDPOINT_URL, BETA_3_ENDPOINT_URL, BETA_4_ENDPOINT_URL, NODE_URL};
use crate::constants::{
BETA_2_ENDPOINT_URL, BETA_3_ENDPOINT_URL, BETA_4_ENDPOINT_URL, BETA_5_ENDPOINT_URL, NODE_URL,
};
use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
use std::str::FromStr;
Expand All @@ -9,6 +11,7 @@ pub enum Target {
Beta2,
Beta3,
Beta4,
Beta5,
Local,
}

Expand All @@ -24,6 +27,7 @@ impl Target {
Target::Beta2 => BETA_2_ENDPOINT_URL,
Target::Beta3 => BETA_3_ENDPOINT_URL,
Target::Beta4 => BETA_4_ENDPOINT_URL,
Target::Beta5 => BETA_5_ENDPOINT_URL,
Target::Local => NODE_URL,
};
url.to_string()
Expand All @@ -41,7 +45,7 @@ impl Target {

pub fn is_testnet(&self) -> bool {
match self {
Target::Beta2 | Target::Beta3 | Target::Beta4 => true,
Target::Beta2 | Target::Beta3 | Target::Beta4 | Target::Beta5 => true,
Target::Local => false,
}
}
Expand All @@ -55,6 +59,7 @@ impl FromStr for Target {
"beta-2" => Ok(Target::Beta2),
"beta-3" => Ok(Target::Beta3),
"beta-4" => Ok(Target::Beta4),
"beta-5" => Ok(Target::Beta5),
"local" => Ok(Target::Local),
_ => bail!(
"'{s}' is not a valid target name. Possible values: '{}', '{}', '{}', '{}'",
Expand All @@ -73,6 +78,7 @@ impl std::fmt::Display for Target {
Target::Beta2 => "beta-2",
Target::Beta3 => "beta-3",
Target::Beta4 => "beta-4",
Target::Beta5 => "beta-5",
Target::Local => "local",
};
write!(f, "{}", s)
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-client/src/util/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use forc_wallet::{
utils::default_wallet_path,
};

use crate::constants::BETA_4_FAUCET_URL;
use crate::constants::BETA_FAUCET_URL;

/// The maximum time to wait for a transaction to be included in a block by the node
pub const TX_SUBMIT_TIMEOUT_MS: u64 = 30_000u64;
Expand Down Expand Up @@ -216,7 +216,7 @@ impl<Tx: Buildable + field::Witnesses + Send> TransactionBuilderExt<Tx> for Tran
let first_account = accounts
.get(&0)
.ok_or_else(|| anyhow::anyhow!("No account derived for this wallet"))?;
let faucet_link = format!("{}/?address={first_account}", BETA_4_FAUCET_URL);
let faucet_link = format!("{}/?address={first_account}", BETA_FAUCET_URL);
anyhow::bail!("Your wallet does not have any funds to pay for the transaction.\
\n\nIf you are interacting with a testnet consider using the faucet.\
\n-> beta-4 network faucet: {faucet_link}\
Expand Down

0 comments on commit 9fbb523

Please sign in to comment.