mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Update balance on withdrawal
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -82,6 +82,7 @@ export async function refreshBalance(config) {
|
||||
|
||||
session.update((s) => {
|
||||
s.tokenBalance = tokenBalance;
|
||||
return s;
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
Reference in New Issue
Block a user