Skip to content

Commit

Permalink
fix(bridge-ui-v2): Show warnings on faucet correctly (#14676)
Browse files Browse the repository at this point in the history
Co-authored-by: Korbinian <[email protected]>
  • Loading branch information
xiaodino and KorbinianK authored Sep 12, 2023
1 parent 3ebf022 commit 861c7f3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/bridge-ui-v2/src/components/Faucet/Faucet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let selectedToken: Token;
let mintButtonEnabled = false;
let reasonNotMintable = '';
let alertMessage = '';
async function switchNetworkToL1() {
if (switchingNetwork) return;
Expand Down Expand Up @@ -113,12 +113,12 @@
// This function will check whether or not the button to mint should be
// enabled. If it shouldn't it'll also set the reason why so we can inform
// the user why they can't mint
async function updateMintButtonState(token?: Token, network?: Chain) {
async function updateMintButtonState(connected: boolean, token?: Token, network?: Chain) {
if (!token || !network) return false;
checkingMintable = true;
mintButtonEnabled = false;
reasonNotMintable = '';
let reasonNotMintable = '';
try {
await checkMintable(token, network.id);
Expand All @@ -143,20 +143,22 @@
} finally {
checkingMintable = false;
}
alertMessage = getAlertMessage(connected, wrongChain, reasonNotMintable);
}
function getAlertMessage(connected: boolean, wrongChain: boolean, reasonNotMintable: string) {
if (!connected) return $t('messages.account.required');
//does this really need to be dynamic? Our mint tokens will most likely stay on Sepolia
if (wrongChain) return $t('faucet.wrong_chain.message', { values: { network: 'Sepolia' } });
if (reasonNotMintable) return reasonNotMintable;
return ''
}
$: connected = isUserConnected($account);
$: wrongChain = isWrongChain($network);
$: alertMessage = getAlertMessage(connected, wrongChain, reasonNotMintable);
$: updateMintButtonState(selectedToken, $network);
$: updateMintButtonState(connected, selectedToken, $network);
</script>

<Card class="w-full md:w-[524px]" title={$t('faucet.title')} text={$t('faucet.description')}>
Expand Down

1 comment on commit 861c7f3

@vercel
Copy link

@vercel vercel bot commented on 861c7f3 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bridge-ui-v2-internal – ./packages/bridge-ui-v2

bridge-ui-v2-internal.vercel.app
bridge-ui-v2-internal-git-main-taikoxyz.vercel.app
bridge-ui-v2-internal-taikoxyz.vercel.app

Please sign in to comment.