-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add beta-4 target to forc, refactor with tests, and UX improvements (#…
…4991) ## Description Closes #4974 Added the beta-4 target and updated documentation (from #4974) Refactored part of forc-deploy and added unit tests. - No longer mutating the Command, so the Command is always whatever the user gave us - Using the default values from the node itself via API call, rather than hardcoded constants - The values of `Gas` are now optional, so we only override them when the user hasn't specified anything Other changes: - deployment works using the urls without `/graphql` prefixes, so I updated the constants to remove the prefix. This is shown to the user and it looks cleaner without it. - Added coloring and consistent styling for errors and warnings to printed to the console. It looks like this now (previously no color) - `deploy`, `run`, and `submit` all now have the same options for specifying the node (node_url, testnet, and target), capture in the `TargetNode` struct. They use the same helper functions to extract the node url and determine gas limit & price. ![image](https://github.com/FuelLabs/sway/assets/47993817/711382e4-c79e-49f0-85a3-b75704f7af9d) ## 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: kayagokalp <kaya.gokalp@fuel.sh> Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
- Loading branch information
1 parent
122fb0b
commit ca4ed7c
Showing
21 changed files
with
377 additions
and
178 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
use clap::Parser; | ||
use forc_tracing::init_tracing_subscriber; | ||
use forc_tracing::{init_tracing_subscriber, println_error}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
init_tracing_subscriber(Default::default()); | ||
let command = forc_client::cmd::Deploy::parse(); | ||
if let Err(err) = forc_client::op::deploy(command).await { | ||
tracing::error!("Error: {:?}", err); | ||
println_error(&format!("{}", err)); | ||
std::process::exit(1); | ||
} | ||
} |
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,12 +1,12 @@ | ||
use clap::Parser; | ||
use forc_tracing::init_tracing_subscriber; | ||
use forc_tracing::{init_tracing_subscriber, println_error}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
init_tracing_subscriber(Default::default()); | ||
let command = forc_client::cmd::Run::parse(); | ||
if let Err(err) = forc_client::op::run(command).await { | ||
tracing::error!("Error: {:?}", err); | ||
println_error(&format!("{}", err)); | ||
std::process::exit(1); | ||
} | ||
} |
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,12 +1,12 @@ | ||
use clap::Parser; | ||
use forc_tracing::init_tracing_subscriber; | ||
use forc_tracing::{init_tracing_subscriber, println_error}; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
init_tracing_subscriber(Default::default()); | ||
let command = forc_client::cmd::Submit::parse(); | ||
if let Err(err) = forc_client::op::submit(command).await { | ||
tracing::error!("Error: {:?}", err); | ||
println_error(&format!("{}", err)); | ||
std::process::exit(1); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// Default to localhost to favour the common case of testing. | ||
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"; |
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,11 +1,32 @@ | ||
pub mod cmd; | ||
mod constants; | ||
pub mod op; | ||
mod util; | ||
|
||
pub mod default { | ||
/// Default to localhost to favour the common case of testing. | ||
pub const NODE_URL: &str = sway_utils::constants::DEFAULT_NODE_URL; | ||
pub const BETA_2_ENDPOINT_URL: &str = "node-beta-2.fuel.network/graphql"; | ||
pub const BETA_3_ENDPOINT_URL: &str = "beta-3.fuel.network/graphql"; | ||
pub const BETA_4_FAUCET_URL: &str = "https://faucet-beta-4.fuel.network"; | ||
use clap::Parser; | ||
use serde::{Deserialize, Serialize}; | ||
use util::target::Target; | ||
|
||
/// Flags for specifying the node to target. | ||
#[derive(Debug, Default, Parser, Deserialize, Serialize)] | ||
pub struct NodeTarget { | ||
/// The URL of the Fuel node to which we're submitting the transaction. | ||
/// If unspecified, checks the manifest's `network` table, then falls back | ||
/// to `http://127.0.0.1:4000` | ||
/// | ||
/// You can also use `--target` or `--testnet` to specify the Fuel node. | ||
#[clap(long, env = "FUEL_NODE_URL")] | ||
pub node_url: Option<String>, | ||
/// Use preset configurations for deploying to a specific target. | ||
/// | ||
/// You can also use `--node-url` or `--testnet` to specify the Fuel node. | ||
/// | ||
/// Possible values are: [beta-1, beta-2, beta-3, beta-4, local] | ||
#[clap(long)] | ||
pub target: Option<Target>, | ||
/// Use preset configuration for the latest testnet. | ||
/// | ||
/// You can also use `--node-url` or `--target` to specify the Fuel node. | ||
#[clap(long)] | ||
pub testnet: bool, | ||
} |
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
Oops, something went wrong.