Skip to content

Commit

Permalink
enhancement: calculating fee every time an input changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Sep 1, 2023
1 parent eabc012 commit 6dabfe2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/pages/transfer/confirm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
text-align: center;
border: 1px solid #ddd;
border-radius: 30px;
.top-section {
margin-bottom: 2em;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/transfer/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
tokenOptions={toOptions}
/>
</div>
{#if receivedAmount && receivedAmount.value > 0}
{#if receivedAmount && receivedAmount.value > 0 && feeAmount && feeAmount.value > 0}
<div class="label-container">
<Label align="left" >Amount Received: {String(receivedAmount)}</Label>
</div>
Expand Down
11 changes: 9 additions & 2 deletions src/pages/transfer/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@
async function submitForm() {
step = 'confirm'
const transferFee = await estimateTransferFee()
await estimateTransferFee()
deposit = (parseFloat(received) + parseFloat(transferFee?.value.toFixed(4) || '')).toFixed(4)
}
async function estimateTransferFee(): Promise<Asset | void> {
async function estimateTransferFee(): Promise<Asset | undefined> {
console.log({from, to, deposit})
if (!$evmAccount) {
errorMessage = 'An evm session is required.'
return
Expand Down Expand Up @@ -159,6 +160,12 @@
connectInterval = window.setInterval(connectEvmWallet, 3000)
connectEvmWallet()
$: {
if (from && to && deposit !== '') {
estimateTransferFee()
}
}
</script>

<style type="scss">
Expand Down

0 comments on commit 6dabfe2

Please sign in to comment.