diff --git a/src/base/vesting/Vesting.svelte b/src/base/vesting/Vesting.svelte
index 19f37c81c..c5e5fec1c 100644
--- a/src/base/vesting/Vesting.svelte
+++ b/src/base/vesting/Vesting.svelte
@@ -2,9 +2,9 @@
import { onMount } from 'svelte';
import { get, derived, writable } from 'svelte/store';
import { ethers } from 'ethers';
- import { session, shortAddress } from '@app/session.js';
- import { STATE, state } from './state.js';
- import { getInfo, withdrawVested } from './vesting.js';
+ import { session, shortAddress } from '@app/session';
+ import { State, state } from './state';
+ import { getInfo, withdrawVested } from './vesting';
let input;
@@ -12,20 +12,20 @@
input.focus();
});
- export let config = null;
+ export let config;
let contractAddress = "";
const info = writable(null);
async function loadContract(config) {
- state.set(STATE.LOADING);
+ state.set(State.Loading);
info.set(await getInfo(contractAddress, config));
- state.set(STATE.IDLE);
+ state.set(State.Idle);
}
function reset() {
$info = null;
- state.set(STATE.IDLE);
+ state.set(State.Idle);
}
let isBeneficiary = derived([session, info], ([$s, $i]) => {
@@ -58,7 +58,7 @@
{contractAddress}
- {#if $state === STATE.WITHDRAWN}
+ {#if $state === State.Withdrawn}
Tokens successfully withdrawn to {shortAddress($info.beneficiary)}.
{:else}
@@ -71,15 +71,15 @@
{#if $isBeneficiary}
- {#if $state === STATE.WITHDRAWING_SIGN}
+ {#if $state === State.WithdrawingSign}
- {:else if $state === STATE.WITHDRAWING}
+ {:else if $state === State.Withdrawing}
- {:else if $state === STATE.IDLE}
+ {:else if $state === State.Idle}
@@ -101,7 +101,7 @@
size="40"
placeholder=""
class="subdomain"
- disabled={$state === STATE.LOADING}
+ disabled={$state === State.Loading}
type="text"
bind:this={input}
bind:value={contractAddress}
@@ -111,8 +111,8 @@
diff --git a/src/base/vesting/state.js b/src/base/vesting/state.js
deleted file mode 100644
index ea8b19e92..000000000
--- a/src/base/vesting/state.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import { derived, writable } from "svelte/store";
-
-export const STATE = {
- ERROR: -1,
- IDLE: 0,
- LOADING: 1,
- FOUND: 2,
- NOT_FOUND: 3,
- WITHDRAWING_SIGN: 4,
- WITHDRAWING: 5,
- WITHDRAWN: 6,
-};
-
-export const state = writable(STATE.IDLE);
-
-state.subscribe(s => {
- console.log("State", s);
-});
diff --git a/src/base/vesting/state.ts b/src/base/vesting/state.ts
new file mode 100644
index 000000000..1dde8db3f
--- /dev/null
+++ b/src/base/vesting/state.ts
@@ -0,0 +1,18 @@
+import { derived, writable } from "svelte/store";
+
+export enum State {
+ Error = -1,
+ Idle = 0,
+ Loading = 1,
+ Found = 2,
+ NotFound = 3,
+ WithdrawingSign = 4,
+ Withdrawing = 5,
+ Withdrawn = 6,
+};
+
+export const state = writable(State.Idle);
+
+state.subscribe(s => {
+ console.log("State", s);
+});
diff --git a/src/base/vesting/vesting.js b/src/base/vesting/vesting.ts
similarity index 92%
rename from src/base/vesting/vesting.js
rename to src/base/vesting/vesting.ts
index 1bd7ba5bf..0fd85e8ef 100644
--- a/src/base/vesting/vesting.js
+++ b/src/base/vesting/vesting.ts
@@ -1,7 +1,7 @@
import { ethers } from "ethers";
import { formatBalance } from "@app/utils";
import { refreshBalance } from "@app/session";
-import { STATE, state } from "./state.js";
+import { State, state } from "./state";
const abi = [
"function token() view returns (address)",
@@ -24,14 +24,14 @@ 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);
+ state.set(State.WithdrawingSign);
let tx = await contract.connect(signer).withdrawVested();
- state.set(STATE.WITHDRAWING);
+ state.set(State.Withdrawing);
await tx.wait();
refreshBalance(config);
- state.set(STATE.WITHDRAWN);
+ state.set(State.Withdrawn);
}
export async function getInfo(address, config) {
diff --git a/src/index.js b/src/index.ts
similarity index 100%
rename from src/index.js
rename to src/index.ts