Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Update balance on withdrawal
Alexis Sellier committed 5 years ago
commit 8dfe1b0fdc96a634214251193a37b5476bc9fb1c
parent e2db821b99262c0b7d28adcdb72fd6dde3b51922
2 files changed +19 -9
modified src/base/vesting/Vesting.svelte
@@ -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>
modified src/session.js
@@ -82,6 +82,7 @@ export async function refreshBalance(config) {

      session.update((s) => {
        s.tokenBalance = tokenBalance;
+
        return s;
      });
    } catch (e) {
      console.error(e);