diff --git a/src/api/assets.js b/src/api/assets.js index 6df529d..b77bc1d 100644 --- a/src/api/assets.js +++ b/src/api/assets.js @@ -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); } } \ No newline at end of file diff --git a/src/components/modals/StakeCAP.svelte b/src/components/modals/StakeCAP.svelte index 2e4bf18..ea483af 100644 --- a/src/components/modals/StakeCAP.svelte +++ b/src/components/modals/StakeCAP.svelte @@ -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() { @@ -75,7 +84,7 @@
{#if $allowances['CAP']?.['FundStore'] * 1 <= amount * 1} -