{contractAddress}
- | Beneficiary | {info.beneficiary} |
- | Allocation | {info.totalVesting} {info.symbol} |
- | Withdrawn | {info.withdrawn} {info.symbol} |
- | Withdrawable | {info.withdrawableBalance} {info.symbol} |
+ | Beneficiary | {$info.beneficiary} |
+ | Allocation | {$info.totalVesting} {$info.symbol} |
+ | Withdrawn | {$info.withdrawn} {$info.symbol} |
+ | Withdrawable | {$info.withdrawableBalance} {$info.symbol} |
{#if $isBeneficiary}
-
+ {#if $state === STATE.WITHDRAWING_SIGN}
+
+ {:else if $state === STATE.WITHDRAWING}
+
+ {:else}
+
+ {/if}
{/if}
-
diff --git a/src/base/vesting/state.js b/src/base/vesting/state.js
index 7552c3519..f7bcf5bc7 100644
--- a/src/base/vesting/state.js
+++ b/src/base/vesting/state.js
@@ -6,8 +6,9 @@ export const STATE = {
LOADING: 1,
FOUND: 2,
NOT_FOUND: 3,
- WITHDRAWING: 4,
- WITHDRAWN: 5,
+ WITHDRAWING_SIGN: 4,
+ WITHDRAWING: 5,
+ WITHDRAWN: 6,
};
export const state = writable(STATE.IDLE);
diff --git a/src/base/vesting/vesting.js b/src/base/vesting/vesting.js
index 793d0e878..14cdcd6c4 100644
--- a/src/base/vesting/vesting.js
+++ b/src/base/vesting/vesting.js
@@ -1,4 +1,5 @@
import { ethers } from "ethers";
+import { STATE, state } from "./state.js";
const abi = [
"function token() view returns (address)",
@@ -17,6 +18,20 @@ const tokenAbi = [
"function symbol() view returns (string)",
];
+export async function withdrawVested(address, config) {
+ const contract = new ethers.Contract(address, abi, config.provider);
+ const signer = config.provider.getSigner();
+
+ state.set(STATE.WITHDRAWING_SIGN);
+
+ let tx = await contract.connect(signer).withdrawVested();
+
+ state.set(STATE.WITHDRAWING);
+ await tx.wait();
+ // TODO: Update balance.
+ state.set(STATE.WITHDRAWN);
+}
+
export async function getInfo(address, config) {
const contract = new ethers.Contract(address, abi, config.provider);
const signer = config.provider.getSigner();