Skip to content

Commit

Permalink
feat: add units to balances
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs committed Jan 10, 2025
1 parent 5975f2b commit 6f2b6e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pub static MAINNET_DRIP_AMOUNT: LazyLock<TokenAmount> =
/// The amount of calibnet tFIL to be dripped to the user.
pub static CALIBNET_DRIP_AMOUNT: LazyLock<TokenAmount> =
LazyLock::new(|| TokenAmount::from_whole(1));
pub static FIL_MAINNET_UNIT: &str = "FIL";
pub static FIL_CALIBNET_UNIT: &str = "tFIL";
9 changes: 9 additions & 0 deletions src/faucet/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl FaucetController {
},
Some(TokenAmount::from_atto(0)),
);

let faucet = FaucetModel {
network,
send_disabled: create_rw_signal(false),
Expand Down Expand Up @@ -117,6 +118,14 @@ impl FaucetController {
self.faucet.target_address.get()
}

pub fn get_fil_unit(&self) -> String {
match self.faucet.network {
Network::Mainnet => crate::constants::FIL_MAINNET_UNIT,
_ => crate::constants::FIL_CALIBNET_UNIT,
}
.to_string()
}

pub fn set_target_address(&self, address: String) {
self.faucet.target_address.set(address);
}
Expand Down
9 changes: 5 additions & 4 deletions src/faucet/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::faucet::controller::FaucetController;
#[component]
pub fn Faucet(target_network: Network) -> impl IntoView {
let faucet = create_rw_signal(FaucetController::new(target_network));
let fil_unit = faucet.get().get_fil_unit();

#[cfg(feature = "hydrate")]
let _ = use_interval_fn(
Expand Down Expand Up @@ -117,11 +118,11 @@ pub fn Faucet(target_network: Network) -> impl IntoView {
<div class="flex justify-between my-4">
<div>
<h3 class="text-lg font-semibold">Faucet Balance:</h3>
<p class="text-xl">{move || faucet.get().get_faucet_balance().to_string()}</p>
<p class="text-xl">{move || faucet.get().get_faucet_balance().to_string()} " " { &fil_unit }</p>
</div>
<div>
<h3 class="text-lg font-semibold">Target Balance:</h3>
<p class="text-xl">{move || faucet.get().get_target_balance().to_string()}</p>
<p class="text-xl">{move || faucet.get().get_target_balance().to_string()} " " { &fil_unit }</p>
</div>
</div>
<hr class="my-4 border-t border-gray-300" />
Expand Down Expand Up @@ -174,7 +175,7 @@ pub fn Faucet_Calibnet() -> impl IntoView {
<Faucet target_network=Network::Testnet />
</div>
<div class="text-center mt-4">
"This faucet distributes 1 tFIL per request. It is rate-limited to 1 request per " {crate::constants::RATE_LIMIT_SECONDS} " seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans."
"This faucet distributes 1 " { crate::constants::FIL_CALIBNET_UNIT } " per request. It is rate-limited to 1 request per " {crate::constants::RATE_LIMIT_SECONDS} " seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans."
</div>
}
}
Expand All @@ -186,7 +187,7 @@ pub fn Faucet_Mainnet() -> impl IntoView {
<h1 class="text-4xl font-bold mb-6 text-center">Mainnet Faucet</h1>
<Faucet target_network=Network::Mainnet />
<div class="text-center mt-4">
"This faucet distributes 0.01 FIL per request. It is rate-limited to 1 request per " {crate::constants::RATE_LIMIT_SECONDS} " seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans or service termination. Faucet funds are limited and may run out. They are replenished periodically."
"This faucet distributes 0.01 " { crate::constants::FIL_MAINNET_UNIT } " per request. It is rate-limited to 1 request per " {crate::constants::RATE_LIMIT_SECONDS} " seconds. Farming is discouraged and will result in more stringent rate limiting in the future and/or permanent bans or service termination. Faucet funds are limited and may run out. They are replenished periodically."
</div>
</div>
}
Expand Down

0 comments on commit 6f2b6e3

Please sign in to comment.