Update balance on withdrawal

This commit is contained in:
Alexis Sellier
2021-03-11 18:30:37 +01:00
parent e2db821b99
commit 8dfe1b0fdc
2 changed files with 19 additions and 9 deletions
+18 -9
View File
@@ -1,7 +1,7 @@
<script lang="javascript">
import { ethers } from 'ethers';
import { get, derived, writable } from 'svelte/store';
import { session } from '@app/session.js';
import { session, shortAddress } from '@app/session.js';
import { STATE, state } from './state.js';
import { getInfo, withdrawVested } from './vesting.js';
@@ -16,6 +16,11 @@
state.set(STATE.IDLE);
}
function reset() {
$info = null;
state.set(STATE.IDLE);
}
let isBeneficiary = derived([session, info], ([$s, $i]) => {
return $i && ($i.beneficiary === $s.address);
});
@@ -46,12 +51,16 @@
{contractAddress}
</div>
<div class="modal-body">
<table>
<tr><td class="label">Beneficiary</td><td>{$info.beneficiary}</td></tr>
<tr><td class="label">Allocation</td><td>{$info.totalVesting} <strong>{$info.symbol}</strong></td></tr>
<tr><td class="label">Withdrawn</td><td>{$info.withdrawn} <strong>{$info.symbol}</strong></td></tr>
<tr><td class="label">Withdrawable</td><td>{$info.withdrawableBalance} <strong>{$info.symbol}</strong></td></tr>
</table>
{#if $state === STATE.WITHDRAWN}
Tokens successfully withdrawn to {shortAddress($info.beneficiary)}.
{:else}
<table>
<tr><td class="label">Beneficiary</td><td>{$info.beneficiary}</td></tr>
<tr><td class="label">Allocation</td><td>{$info.totalVesting} <strong>{$info.symbol}</strong></td></tr>
<tr><td class="label">Withdrawn</td><td>{$info.withdrawn} <strong>{$info.symbol}</strong></td></tr>
<tr><td class="label">Withdrawable</td><td>{$info.withdrawableBalance} <strong>{$info.symbol}</strong></td></tr>
</table>
{/if}
</div>
<div class="modal-actions">
{#if $isBeneficiary}
@@ -63,13 +72,13 @@
<button disabled data-waiting class="primary small">
Withdrawing...
</button>
{:else}
{:else if $state === STATE.IDLE}
<button on:click={() => withdrawVested(contractAddress, config)} class="primary small">
Withdraw
</button>
{/if}
{/if}
<button on:click={() => $info = null} class="small">
<button on:click={reset} class="small">
Back
</button>
</div>
+1
View File
@@ -82,6 +82,7 @@ export async function refreshBalance(config) {
session.update((s) => {
s.tokenBalance = tokenBalance;
return s;
});
} catch (e) {
console.error(e);