Skip to content
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
5 changes: 4 additions & 1 deletion apps/web/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"withdrawalFailed": "Withdrawal failed",
"withdrew": "Withdrew",
"deposited": "Deposited",
"syncDelayed": "Updating your balance..."
"syncDelayed": "Updating your balance...",
"fundingWallet": "Funding testnet wallet with Blend test USDC...",
"walletFunded": "Testnet wallet funded",
"faucetFailed": "Failed to fund testnet wallet"
},

"common": {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"withdrawalFailed": "Échec du retrait",
"withdrew": "Retiré",
"deposited": "Déposé",
"syncDelayed": "Mise à jour de votre solde en cours..."
"syncDelayed": "Mise à jour de votre solde en cours...",
"fundingWallet": "Financement du portefeuille testnet avec des USDC de test Blend...",
"walletFunded": "Portefeuille testnet financé",
"faucetFailed": "Échec du financement du portefeuille testnet"
},

"common": {
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/hooks/useBlendFaucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { USDC_ISSUER } from "@meridian/shared";
import { fetchBalances } from "../lib/horizonAccount";
import { useSignAndSubmit } from "./useSignAndSubmit";
import { useToastStore } from "../store/toast";
import { useTranslation } from "react-i18next";

// Configurable so the faucet can be rotated or disabled without a code
// deploy; falls back to Blend's public testnet faucet.
Expand Down Expand Up @@ -31,6 +32,7 @@ export async function hasBlendUsdcBalance(
}

export function useBlendFaucet() {
const { t } = useTranslation();
const { push } = useToastStore();
const { signAndSubmit, passphrase } = useSignAndSubmit();

Expand All @@ -46,18 +48,18 @@ export function useBlendFaucet() {
): Promise<boolean> {
if (!publicKey || !passphrase) return false;
try {
push("info", "Funding testnet wallet with Blend test USDC...");
push("info", t("vaultActions.fundingWallet"));
const res = await fetch(`${BLEND_FAUCET_URL}?userId=${publicKey}`);
if (!res.ok) throw new Error(`Blend faucet returned ${res.status}`);
const xdr = await res.text();
assertFaucetPayment(xdr, passphrase, network, publicKey);
await signAndSubmit(xdr);
push("success", "Testnet wallet funded");
push("success", t("vaultActions.walletFunded"));
return true;
} catch (err) {
push(
"error",
err instanceof Error ? err.message : "Failed to fund testnet wallet"
err instanceof Error ? err.message : t("vaultActions.faucetFailed")
);
return false;
}
Expand Down
Loading