Skip to content

Commit

Permalink
feat: forc-client points empty accounts to beta-4 faucet (#4972)
Browse files Browse the repository at this point in the history
## Description
closes #4862.

waiting for #4905 to be merged first.

With this PR, we are now pointing empty accounts to beta-4 faucet with
their address already inserted so that people can click on it and get
funded.

```console
Please provide the password of your encrypted wallet vault at "/Users/kayagokalp/.fuel/wallets/.wallet": 
Error: Your wallet does not have any funds to pay for the transaction.

If you are interacting with a testnet consider using the faucet.
-> beta-4 network faucet: https://faucet-beta-4.fuel.network/?address=fuel1l6su7ldka75ntmz7vx05tfznshxjpa4ftt4p537vl2ck45a5p5tsmwjevm
If you are interacting with a local node, consider providing a chainConfig which funds your account.
```

---------

Co-authored-by: Sophie Dankel <[email protected]>
  • Loading branch information
kayagokalp and sdankel authored Aug 18, 2023
1 parent d1dbc09 commit 6322255
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 6322255

Please sign in to comment.