Skip to content

Commit

Permalink
Merge pull request #331 from greymass/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
aaroncox authored Jan 13, 2025
2 parents 6f25e1d + 05d819e commit f64f946
Show file tree
Hide file tree
Showing 56 changed files with 1,573 additions and 456 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2 Unicove 2 Furious
# Unicove 2.0

![inspiration](https://i.ibb.co/2nbtvms/image-1.png)

Expand All @@ -9,16 +9,24 @@ Clone this repo and run `bun install` to install the dependencies.
Add a `.env` file to the root of the project with the following content:

```
# Specify environment Unicove is operating in
PUBLIC_ENVIRONMENT="development"
# Optional Private Key of testnet account for use with the WalletPluginPrivateKey
PUBLIC_LOCAL_SIGNER=""
# APIs for supported networks
API_EOS_HISTORY=https://eos.greymass.com
API_EOS_CHAIN=https://eos.greymass.com
API_EOS_LIGHTAPI=https://eos.light-api.net
API_JUNGLE4_HISTORY=https://jungle4.greymass.com
API_JUNGLE4_CHAIN=https://jungle4.greymass.com
API_KYLIN_HISTORY=https://kylintestnet.greymass.com
API_KYLIN_CHAIN=https://kylintestnet.greymass.com
```
Add your private key in there if you want to enable the local Private Key Signer instead of using Anchor for each test transaction.
# EOS Wallet for MetaMask
PUBLIC_METAMASK_SNAP_ORIGIN=npm:@greymass/eos-wallet
PUBLIC_METAMASK_SERVICE_URL=https://dev.account-creation-portal.pages.dev/buy
```

Run `bun dev` to start the development server then visit `http://localhost:5173`
Binary file modified bun.lockb
Binary file not shown.
248 changes: 222 additions & 26 deletions messages/en.json

Large diffs are not rendered by default.

367 changes: 366 additions & 1 deletion messages/ko.json

Large diffs are not rendered by default.

373 changes: 369 additions & 4 deletions messages/zh.json

Large diffs are not rendered by default.

14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unicove",
"version": "2.0.0-alpha",
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down Expand Up @@ -54,10 +54,8 @@
"@sveltejs/enhanced-img": "^0.4.4",
"@tailwindcss/container-queries": "^0.1.1",
"@wharfkit/account": "^1.3.0",
"@wharfkit/account-creation-plugin-greymass": "^1.2.0",
"@wharfkit/account-creation-plugin-metamask": "^1.1.1",
"@wharfkit/antelope": "^1.0.11",
"@wharfkit/common": "^1.4.0",
"@wharfkit/account-creation-plugin-metamask": "^1.2.1",
"@wharfkit/common": "^1.4.2",
"@wharfkit/contract": "^1.1.5",
"@wharfkit/resources": "^1.3.1",
"@wharfkit/roborovski": "^1.1.0",
Expand All @@ -84,11 +82,5 @@
"svead": "^0.0.13",
"tailwind-merge": "^2.5.3",
"typescript-svelte-plugin": "^0.3.40"
},
"resolutions": {
"@wharfkit/antelope": "^1.0.11",
"@wharfkit/common": "^1.4.0",
"@wharfkit/session": "^1.4.0",
"svelte": "^5.1.9"
}
}
5 changes: 2 additions & 3 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { sequence } from '@sveltejs/kit/hooks';
import type { Handle, RequestEvent } from '@sveltejs/kit';

import { PUBLIC_ENVIRONMENT } from '$env/static/public';
import { availableLanguageTags } from '$lib/paraglide/runtime.js';
import { i18n } from '$lib/i18n';
import { isNetworkShortName } from '$lib/wharf/chains';
Expand Down Expand Up @@ -63,7 +64,7 @@ export async function redirectHandle({ event, resolve }: HandleParams): Promise<
const [, pathFirst, pathSecond, ...pathMore] = pathname.split('/').map((p) => p.trim());

let lang = 'en';
let network: string | undefined = 'eos';
let network: string | undefined = PUBLIC_ENVIRONMENT !== 'production' ? 'jungle4' : 'eos';

if (isLanguage(pathFirst) && isNetwork(pathSecond)) {
// Proceed, correct URL
Expand All @@ -72,7 +73,6 @@ export async function redirectHandle({ event, resolve }: HandleParams): Promise<
} else if (isLanguage(pathFirst) && !isNetwork(pathSecond) && !pathSecond) {
// Only a language is specified, land on the language specific homepage
lang = pathFirst;
network = undefined;
} else if (isLanguage(pathFirst) && !isNetwork(pathSecond)) {
// The network isn't specified, but the language is - redirect to the default network
lang = pathFirst;
Expand Down Expand Up @@ -103,7 +103,6 @@ export async function redirectHandle({ event, resolve }: HandleParams): Promise<
}

if (pathname !== url) {
console.log('redirecting to', url + search);
return new Response(undefined, {
headers: { Location: url + search },
status: 301
Expand Down
7 changes: 4 additions & 3 deletions src/lib/components/accountswitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { createDialog, melt } from '@melt-ui/svelte';
import { Session, type SerializedSession } from '@wharfkit/session';
import { chainLogos } from '@wharfkit/common';
import * as m from '$lib/paraglide/messages';
import type { UnicoveContext } from '$lib/state/client.svelte';
import type { NetworkState } from '$lib/state/network.svelte';
Expand Down Expand Up @@ -102,7 +103,7 @@
>
</div>
{:else}
<span class="pointer-events-none z-10 px-4 py-2">Connect Wallet</span>
<span class="pointer-events-none z-10 px-4 py-2">{m.common_connect_wallet()}</span>
{/if}
</button>

Expand Down Expand Up @@ -145,7 +146,7 @@

<section id="accounts" class="flex flex-1 flex-col gap-3 pt-2">
<header class="flex items-center justify-between text-xl font-semibold">
<span>My Accounts</span>
<span>{m.common_my_accounts()}</span>
<button
onclick={addSession}
class="grid size-12 place-items-center rounded-lg hover:bg-mineShaft-950"
Expand Down Expand Up @@ -198,7 +199,7 @@
</li>
{/each}
{:else}
<p>No active sessions</p>
<p>{m.common_no_active_sessions()}</p>
{/if}
</ul>
</section>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/breakdown/breakdown.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import { Stack } from '$lib/components/layout';
import type { Snippet } from 'svelte';
import * as m from '$lib/paraglide/messages';
interface Props {
children: Snippet;
isCurrentUser?: boolean;
Expand All @@ -9,7 +11,7 @@
</script>

<Stack class="gap-2 @container">
<h5 class="h5">Breakdown</h5>
<h5 class="h5">{m.common_breakdown()}</h5>
{#if props.isCurrentUser}
<div class="grid grid-cols-3 gap-0">
{@render props.children()}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/button/copy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { UnicoveContext } from '$lib/state/client.svelte';
import { getContext } from 'svelte';
import { cn } from '$lib/utils';
import * as m from '$lib/paraglide/messages';
const context = getContext<UnicoveContext>('state');
Expand Down Expand Up @@ -43,7 +44,7 @@
'peer absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 focus-visible:outline-none',
buttonSize
)}
aria-label="Copy"
aria-label={m.common_copy()}
>
<!-- Button is done this way with absolute positioning so we can maintain a decent hit slop on mobile without affecting layout -->
</button>
Expand All @@ -53,7 +54,7 @@
in:fly={{ x: -20, easing: quartOut, duration: 100 }}
out:fade={{ easing: quadIn, duration: 200 }}
class="absolute inset-y-0 left-full translate-x-2 select-none text-nowrap text-xs text-skyBlue-400"
>Copied!</span
>{m.common_copied_result()}</span
>
{/if}
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/lib/components/card/accountbalance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Button from '$lib/components/button/button.svelte';
import Chip from '$lib/components/chip.svelte';
import AssetText from '$lib/components/elements/asset.svelte';
import * as m from '$lib/paraglide/messages';
const context = getContext<UnicoveContext>('state');
Expand All @@ -17,18 +18,18 @@
title?: string;
}
const { cta, title = 'Account Balance' }: Props = $props();
const { cta, title = m.common_account_balance() }: Props = $props();
</script>

<Card {title}>
<Stack>
<Stack class="gap-2">
<h4 class="text-muted text-base leading-none">Available</h4>
<h4 class="text-muted text-base leading-none">{m.common_available()}</h4>
<p class="text-xl font-semibold leading-none text-white">
{#if context.account}
<AssetText variant="full" value={context.account?.balance?.liquid} />
{:else}
Not logged in
{m.common_not_logged_in()}
{/if}
</p>
{#if context.account?.value?.liquid}
Expand Down
7 changes: 4 additions & 3 deletions src/lib/components/chart/barchart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Chart } from 'chart.js';
import 'chart.js/auto';
import { Card } from '$lib/components/layout';
import * as m from '$lib/paraglide/messages';
interface Props {
data: { x: number; y: number; y1?: number }[];
Expand Down Expand Up @@ -74,13 +75,13 @@
<div class="flex gap-4">
<div class="flex items-center gap-1">
<div class="size-4 rounded bg-[#00ED97]"></div>
<span class="text-[#00ED97]">Staked</span>
<span class="text-[#00ED97]">{m.common_staked()}</span>
</div>
<div class="flex items-center gap-1">
<div class="size-4 rounded bg-[#B2FAE0]"></div>
<span class="text-[#B2FAE0]">Yield</span>
<span class="text-[#B2FAE0]">{m.common_yield()}</span>
</div>
</div>
<span class="text-shark-200/70">Today</span>
<span class="text-shark-200/70">{m.common_today()}</span>
</div>
</Card>
11 changes: 6 additions & 5 deletions src/lib/components/chart/tokendistribution.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
import type { AccountValue } from '$lib/state/client/account.svelte';
import { cn, percentString } from '$lib/utils';
import { Card } from '../layout';
import * as m from '$lib/paraglide/messages';
interface Props {
data?: AccountValue;
}
let { data }: Props = $props();
const distributionMap = {
delegated: { label: 'Delegated', color: 'bg-mineShaft-300' },
liquid: { label: 'Available', color: 'bg-green-400' },
delegated: { label: m.common_delegated(), color: 'bg-mineShaft-300' },
liquid: { label: m.common_available(), color: 'bg-green-400' },
ram: { label: 'RAM', color: 'bg-solar-400' },
staked: { label: 'Staked', color: 'bg-skyBlue-400' },
unstaked: { label: 'Unstaked', color: 'bg-skyBlue-400' }
staked: { label: m.common_staked(), color: 'bg-skyBlue-400' },
unstaked: { label: m.common_unstaked(), color: 'bg-skyBlue-400' }
};
type DistributionItem = {
Expand All @@ -39,7 +40,7 @@
const displayThreshold = 0.0001;
</script>

<Card id="distribution" title="Distribution">
<Card id="distribution" title={m.common_distribution()}>
{#if distribution}
<div id="distribution-container" class="flex gap-1">
{#each distribution as item}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/elements/unstaking.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import Button from '$lib/components/button/button.svelte';
import type { UnstakingRecord } from '$lib/utils/staking';
import { languageTag } from '$lib/paraglide/runtime';
import * as m from '$lib/paraglide/messages';
interface Props extends HTMLAttributes<HTMLDivElement> {
href?: string;
Expand All @@ -17,16 +18,15 @@
</script>

{#if records.filter((r) => !r.savings).length > 0}
<Card {...props} title="Unstaking" class="auto-rows-max">
<Card {...props} title={m.common_unstaking()} class="auto-rows-max">
<p>
The tokens currently being unstaked are listed below with the date they become available.
These balances will continue to earn rewards until they are withdrawn.
{m.unstaking_description()}
</p>
<table class="table-styles mt-4">
<thead class="border-b-2 border-shark-100/10">
<tr class="caption font-medium">
<th class="text-left">Amount</th>
<th class="text-right">Date available</th>
<th class="text-left">{m.common_amount()}</th>
<th class="text-right">{m.common_date_available()}</th>
</tr>
</thead>
<tbody>
Expand All @@ -44,7 +44,7 @@
</tbody>
</table>
{#if href}
<Button {href} variant="secondary">Withdraw</Button>
<Button {href} variant="secondary">{m.common_withdraw()}</Button>
{/if}
</Card>
{/if}
12 changes: 7 additions & 5 deletions src/lib/components/navigation/sidemenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import type { UnicoveContext } from '$lib/state/client.svelte';
import type { NetworkState } from '$lib/state/network.svelte';
import * as m from '$lib/paraglide/messages';
const context = getContext<UnicoveContext>('state');
interface Props {
Expand All @@ -26,13 +28,13 @@
// text: network.chain.name,
// active: pathname[2] === String(network) && !pathname[3]
// },
{ href: `/${network}/send`, text: 'Send', active: pathname[3] === 'send' }
{ href: `/${network}/send`, text: m.common_send(), active: pathname[3] === 'send' }
];
if (network.supports('staking')) {
items.push({
href: `/${network}/staking`,
text: 'Staking',
text: m.common_staking(),
active: pathname[3] === 'staking'
});
}
Expand All @@ -44,7 +46,7 @@
if (context.settings.data.advancedMode) {
items.push({
href: `/${network}/resources`,
text: 'Resources',
text: m.common_resources(),
active: pathname[3] === 'resources'
});
}
Expand All @@ -60,14 +62,14 @@
if (context.account) {
items.splice(0, 0, {
href: `/${network}/account/${context.account.name}`,
text: 'My Account',
text: m.common_my_account(),
active: pathname[3] === 'account' && pathname[4] === String(context.account.name)
});
}
items.push({
href: `/${network}/settings`,
text: 'Settings',
text: m.common_settings(),
active: pathname[3] === 'settings'
});
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/networkswitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { goto } from '$app/navigation';
import { languageTag } from '$lib/paraglide/runtime';
import type { NetworkState } from '$lib/state/network.svelte';
import * as m from '$lib/paraglide/messages';
interface Props {
currentNetwork: NetworkState;
Expand Down Expand Up @@ -84,7 +85,7 @@

{#if context.settings.data.advancedMode}
<div class="font-regular m-0 flex items-center gap-1 pr-1 text-base text-zinc-400">
<span use:melt={$label}>Change network</span>
<span use:melt={$label}>{m.change_network()}</span>
<ChevronDown
data-open={$open}
class="size-4 transition-transform duration-100 data-[open=true]:rotate-180"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/select/select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type { ChangeFn } from '@melt-ui/svelte/internal/helpers';
import { SelectTrigger, SelectMenu, SelectItem } from './elements';
import type { ExtendedSelectOption, SelectOptionVariant } from './types';
import * as m from '$lib/paraglide/messages';
interface Props {
options: ExtendedSelectOption[];
Expand Down Expand Up @@ -69,7 +70,7 @@
{#if selectedOption.image && typeof selectedOption.image === 'string'}
<img src={selectedOption.image} alt={selectedOption.label} class="mr-2 size-5 object-contain" />
{/if}
{$selectedLabel || 'Select an option'}
{$selectedLabel || m.common_select_an_option()}
</SelectTrigger>

{#if $open}
Expand Down
Loading

0 comments on commit f64f946

Please sign in to comment.