fix: address review feedback on LocalSwapWidget and CheatsView
- LocalSwapWidget: move useWallet() to top-level <script setup> (was incorrectly called inside async buyKrk() event handler) - LocalSwapWidget + CheatsView: fix misleading toast — all transactions are fully confirmed at that point, so say 'Swap complete' not 'Swap submitted' - LocalSwapWidget: add $KRK sigil to warning/hint text for consistency with GetKrkView - LocalSwapWidget: add comment on amountOutMinimum: 0n explaining it is intentional for a no-MEV local anvil environment - CheatsView: apply same useWallet() fix (pre-existing anti-pattern) - docs/ENVIRONMENT.md: document VITE_ENABLE_LOCAL_SWAP and related VITE_ variables in a new webapp env-var table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1b647f844a
commit
cf4e401d03
3 changed files with 18 additions and 11 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="local-swap-widget">
|
||||
<template v-if="!canSwap">
|
||||
<p class="swap-warning">Connect your wallet to swap ETH for KRK on the local Uniswap pool.</p>
|
||||
<p class="swap-warning">Connect your wallet to swap ETH for $KRK on the local Uniswap pool.</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="swap-field">
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<button class="swap-button" :disabled="swapping" @click="buyKrk">
|
||||
{{ swapping ? 'Submitting…' : 'Buy KRK' }}
|
||||
</button>
|
||||
<p class="swap-hint">Wraps ETH → WETH, approves the swap router, then trades into KRK.</p>
|
||||
<p class="swap-hint">Wraps ETH → WETH, approves the swap router, then trades into $KRK.</p>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -28,6 +28,7 @@ import { useWallet } from '@/composables/useWallet';
|
|||
|
||||
const toast = useToast();
|
||||
const { address, chainId } = useAccount();
|
||||
const { loadBalance } = useWallet();
|
||||
|
||||
const swapAmount = ref('0.1');
|
||||
const swapping = ref(false);
|
||||
|
|
@ -240,17 +241,16 @@ async function buyKrk() {
|
|||
fee: 10_000,
|
||||
recipient: caller,
|
||||
amountIn: amount,
|
||||
amountOutMinimum: 0n,
|
||||
amountOutMinimum: 0n, // no slippage protection — acceptable on no-MEV local anvil
|
||||
sqrtPriceLimitX96: 0n,
|
||||
},
|
||||
],
|
||||
chainId: currentChainId,
|
||||
});
|
||||
|
||||
const { loadBalance } = useWallet();
|
||||
await loadBalance();
|
||||
|
||||
toast.success('Swap submitted. Watch your wallet for KRK.');
|
||||
toast.success('Swap complete. $KRK has been added to your wallet.');
|
||||
} catch (error: unknown) {
|
||||
toast.error(getErrorMessage(error, 'Swap failed'));
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue