Move vesting to its own module

This commit is contained in:
Alexis Sellier
2021-03-04 17:16:54 +01:00
parent 3a1625e775
commit c168270c99
7 changed files with 137 additions and 118 deletions
+37
View File
@@ -166,3 +166,40 @@ input[type="text"]::placeholder {
input.wide {
width: 44ch;
}
.modal {
padding: 2rem;
border: 1px solid var(--color-secondary);
box-shadow: 8px 8px 64px var(--color-secondary-2);
min-width: 480px;
text-align: center;
}
.modal-title {
font-size: 1.75rem;
margin-bottom: 1rem;
color: var(--color-secondary);
text-align: center;
}
.modal-body {
margin: 3rem 0;
}
.modal-actions {
margin-top: 2rem;
text-align: center;
}
table {
table-layout: fixed;
border-collapse: collapse;
width: 100%;
max-width: 480px;
}
td {
text-align: left;
}
td.label {
color: var(--color-secondary);
}
td strong {
font-weight: 600;
}
+6 -115
View File
@@ -1,26 +1,21 @@
<script lang="javascript">
import { ethers } from 'ethers';
import { get } from 'svelte/store';
import { STATE, state, error } from './state.js';
import { getConfig } from './config.js';
import { session } from './session.js';
import { getInfo } from './vesting.js';
import Vesting from './base/vesting/Vesting.svelte';
import Header from './Header.svelte';
let contractAddress = "";
let info = null;
let app = Vesting;
function handleKeydown(event) {
if (event.key === 'Enter') {
document.querySelector('button.primary').click();
}
}
async function loadContract(config) {
state.set(STATE.LOADING);
info = await getInfo(contractAddress, config);
state.set(STATE.IDLE);
}
</script>
<style>
@@ -35,116 +30,12 @@
justify-content: center;
height: 24rem;
}
.modal {
padding: 2rem;
border: 1px solid var(--color-secondary);
box-shadow: 8px 8px 64px var(--color-secondary-2);
min-width: 480px;
text-align: center;
}
.modal-title {
font-size: 1.75rem;
margin-bottom: 1rem;
color: var(--color-secondary);
text-align: center;
}
.modal-body {
margin: 3rem 0;
}
.modal-actions {
margin-top: 2rem;
text-align: center;
}
div.input-caption {
font-size: 1.25rem;
text-align: left;
margin-left: 1.5rem;
padding-left: 1.5rem;
margin-bottom: 1rem;
color: var(--color-secondary);
}
div.input-main {
display: flex;
align-items: center;
flex-direction: row;
margin-left: 1.5rem;
color: var(--color-secondary);
}
table {
table-layout: fixed;
border-collapse: collapse;
width: 100%;
max-width: 480px;
}
td {
text-align: left;
}
td.label {
color: var(--color-secondary);
}
td strong {
font-weight: 600;
}
</style>
<svelte:window on:keydown={handleKeydown} />
<div class="app">
<Header/>
{#await getConfig()}
<!-- Loading wallet -->
{:then config}
<div class="wrapper">
<main>
{#if info}
<div class="modal">
<div class="modal-title">
{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>
</div>
<div class="modal-actions">
<button on:click={() => info = null} class="small">
Back
</button>
</div>
</div>
{:else}
<div class="input-caption">
Enter your Radicle <strong>vesting contract</strong> address
</div>
<div class="input-main">
<span class="name">
<div>
<input
autofocus
size="40"
placeholder=""
class="subdomain"
disabled={$state === STATE.LOADING}
type="text" bind:value={contractAddress}
/>
</div>
</span>
<button
on:click={() => loadContract(config)}
class="primary"
data-waiting={$state === STATE.LOADING || null}
disabled={$state === STATE.LOADING}
>
Load
</button>
</div>
{/if}
</main>
</div>
{:catch error}
Ethereum wallet not available.
{/await}
<div class="wrapper">
<svelte:component this={app}/>
</div>
</div>
+1 -2
View File
@@ -2,9 +2,8 @@
// TODO: Shorten tx hash
// TODO: Link to correct network on etherscan
import { ethers } from "ethers";
import { STATE, state, error } from "./state.js";
import { ERROR } from "./error.js";
import { CONNECTION, session, connectWallet, disconnectWallet, shortAddress } from "./session.js";
import { error } from './error.js';
import Logo from './Logo.svelte';
import Connect from './Connect.svelte';
+89
View File
@@ -0,0 +1,89 @@
<script lang="javascript">
import { ethers } from 'ethers';
import { get } from 'svelte/store';
import { STATE, state } from './state.js';
import { getConfig } from '../../config.js';
import { getInfo } from './vesting.js';
let contractAddress = "";
let info = null;
async function loadContract(config) {
state.set(STATE.LOADING);
info = await getInfo(contractAddress, config);
state.set(STATE.IDLE);
}
</script>
<style>
div.input-caption {
font-size: 1.25rem;
text-align: left;
margin-left: 1.5rem;
padding-left: 1.5rem;
margin-bottom: 1rem;
color: var(--color-secondary);
}
div.input-main {
display: flex;
align-items: center;
flex-direction: row;
margin-left: 1.5rem;
color: var(--color-secondary);
}
</style>
{#await getConfig()}
<!-- Loading wallet -->
{:then config}
<main>
{#if info}
<div class="modal">
<div class="modal-title">
{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>
</div>
<div class="modal-actions">
<button on:click={() => info = null} class="small">
Back
</button>
</div>
</div>
{:else}
<div class="input-caption">
Enter your Radicle <strong>vesting contract</strong> address
</div>
<div class="input-main">
<span class="name">
<div>
<input
autofocus
size="40"
placeholder=""
class="subdomain"
disabled={$state === STATE.LOADING}
type="text" bind:value={contractAddress}
/>
</div>
</span>
<button
on:click={() => loadContract(config)}
class="primary"
data-waiting={$state === STATE.LOADING || null}
disabled={$state === STATE.LOADING}
>
Load
</button>
</div>
{/if}
</main>
{:catch error}
Ethereum wallet not available.
{/await}
@@ -11,4 +11,3 @@ export const STATE = {
};
export const state = writable(STATE.IDLE);
export const error = writable(null);
+4
View File
@@ -1,3 +1,7 @@
import { writable } from "svelte/store";
export const ERROR = {
TRANSACTION_FAILED: 1,
};
export const error = writable(null);