forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…elLabs#4764) ## Description closes FuelLabs#4759. Adds --target parameter to forc-deploy which can take `beta-2`, `beta-3` or `latest`. If nothing is specified it defaults to `latest`. If `beta-2` or `beta-3` is specified, preset values are used for node-url and gas price so that users can deploy with a single parameter. So `forc deploy --target beta-3` would work but since forc-deploy is not compatible with beta-3 that feature will fail until we have a beta-4 released. Also adds `--testnet` flag which is translated into a `--target beta-3`. So once a beta network release is done with this additions, users will be able to simply use ```console forc deploy --testnet ``` to deploy to the latest test-net supported by that forc-deploy version ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Joshua Batty <[email protected]>
- Loading branch information
1 parent
d8ee8a2
commit 2fc902a
Showing
4 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,49 @@ | ||
use std::str::FromStr; | ||
|
||
pub(crate) mod encode; | ||
pub(crate) mod pkg; | ||
pub(crate) mod tx; | ||
|
||
use crate::default::{BETA_2_ENDPOINT_URL, BETA_3_ENDPOINT_URL, NODE_URL}; | ||
|
||
#[derive(Debug, Clone)] | ||
/// Possible target values that forc-client can interact with. | ||
pub enum Target { | ||
Beta2, | ||
Beta3, | ||
LATEST, | ||
} | ||
|
||
impl Default for Target { | ||
fn default() -> Self { | ||
Self::LATEST | ||
} | ||
} | ||
|
||
impl Target { | ||
pub fn target_url(&self) -> &str { | ||
match self { | ||
Target::Beta2 => BETA_2_ENDPOINT_URL, | ||
Target::Beta3 => BETA_3_ENDPOINT_URL, | ||
Target::LATEST => NODE_URL, | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for Target { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
if s == "latest" { | ||
Ok(Target::LATEST) | ||
} else if s == "beta-2" { | ||
Ok(Target::Beta2) | ||
} else if s == "beta-3" { | ||
Ok(Target::Beta3) | ||
} else { | ||
anyhow::bail!( | ||
"invalid testnet name provided. Possible values are 'beta-2', 'beta-3', 'latest'." | ||
) | ||
} | ||
} | ||
} |