mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-28 17:50:28 +08:00
Move vesting to its own module
This commit is contained in:
@@ -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
@@ -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
@@ -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';
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -1,3 +1,7 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
export const ERROR = {
|
||||
TRANSACTION_FAILED: 1,
|
||||
};
|
||||
|
||||
export const error = writable(null);
|
||||
|
||||
Reference in New Issue
Block a user