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: forc-client points empty accounts to beta-4 faucet #4972

Merged
merged 3 commits into from
Aug 18, 2023
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
1 change: 1 addition & 0 deletions forc-plugins/forc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pub mod default {
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";
}
15 changes: 10 additions & 5 deletions forc-plugins/forc-client/src/util/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use forc_wallet::{
utils::default_wallet_path,
};

use crate::default::BETA_4_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 @@ -203,11 +205,14 @@ impl<Tx: Buildable + SerializableVec + field::Witnesses + Send> TransactionBuild
.flat_map(|account| account.values())
.sum::<u64>();
if total_balance == 0 {
// TODO: Point to latest test-net faucet with account info added to the
// link as a parameter.
anyhow::bail!("Your wallet does not have any funds to pay for the deployment transaction.\
\nIf you are deploying to a testnet consider using the faucet.\
\nIf you are deploying to a local node, consider providing a chainConfig which funds your account.")
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);
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}\
\nIf you are interacting with a local node, consider providing a chainConfig which funds your account.")
}
print_account_balances(&accounts, &account_balances);

Expand Down
Loading