Skip to content
Open
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: 5 additions & 0 deletions src/api/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export async function approveAsset(assetLabel, spenderName) {
return true;
}
} catch(e) {
const msg = (e?.message || '').toLowerCase();
// Silent fail for user-rejected transactions (MetaMask cancel etc.)
if (msg.includes('user denied') || msg.includes('user rejected') || msg.includes('user cancelled')) {
return false;
}
showError(e);
}
}
13 changes: 11 additions & 2 deletions src/components/modals/StakeCAP.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@
}

async function _approveAsset() {
const result = await approveAsset('CAP', 'FundStore');
isSubmitting = true;
try {
const result = await approveAsset('CAP', 'FundStore');
if (result) {
await checkAllowance();
}
} catch(e) {
// Silent - errors handled in approveAsset
}
isSubmitting = false;
}

async function getBalance() {
Expand Down Expand Up @@ -75,7 +84,7 @@

<div>
{#if $allowances['CAP']?.['FundStore'] * 1 <= amount * 1}
<Button noSubmit={true} label={`Approve CAP`} on:click={_approveAsset} />
<Button isLoading={isSubmitting} noSubmit={true} label={`Approve CAP`} on:click={_approveAsset} />
{:else}
<Button isLoading={isSubmitting} label={`Stake`} />
{/if}
Expand Down