Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Release #301

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e1001af
refactor(button): allow overriding button classes
deansallinen Dec 6, 2024
a0918c0
Added robots.txt
aaroncox Dec 6, 2024
cc736a7
Use Big.js to safely wrap asset quantities
aaroncox Dec 6, 2024
281cc49
Link to token page from account balances
aaroncox Dec 6, 2024
41afe8f
refactor: description list component
deansallinen Dec 6, 2024
71ce477
refactor(button): allow overriding button classes
deansallinen Dec 6, 2024
7a361f8
style: actions
deansallinen Dec 6, 2024
09acc18
refactor: use new dl and button styles
deansallinen Dec 6, 2024
24c0855
Balance alignment
aaroncox Dec 8, 2024
052d4a2
Scaffolding initial voter informtion
aaroncox Dec 8, 2024
2c019be
Adding vote weight in token format
aaroncox Dec 9, 2024
bb64e6c
Enabling Votes in advanced mode and other pages in debug mode
aaroncox Dec 9, 2024
e845ffd
Merge pull request #299 from greymass/voter
aaroncox Dec 9, 2024
5f23ace
Merge pull request #300 from greymass/tokens
aaroncox Dec 9, 2024
5a2ee4e
Merge pull request #297 from greymass/refactor-dl
aaroncox Dec 9, 2024
0801f3a
Merge pull request #296 from greymass/robots
aaroncox Dec 9, 2024
950ec8b
Merge pull request #295 from greymass/overridable-buttons
aaroncox Dec 9, 2024
e397872
Merge pull request #298 from greymass/msig
aaroncox Dec 9, 2024
bb0bfc6
fix: layout of key page
deansallinen Dec 10, 2024
4c7f2a1
Merge pull request #303 from greymass/fix-key-layout
aaroncox Dec 10, 2024
79594fc
Moved all state to manager and added debugging
aaroncox Dec 10, 2024
a97fed9
Refactored state for approvals/participants
aaroncox Dec 10, 2024
3cdf9bb
Disable success toast
aaroncox Dec 10, 2024
4519bfa
Use contexts transacting state
aaroncox Dec 10, 2024
6cb3298
Removed unused error (should be in Wharf context?)
aaroncox Dec 10, 2024
4415f78
Removed unused `changed` state
aaroncox Dec 10, 2024
64352fe
Removed try/catch, was causing further code to execute
aaroncox Dec 10, 2024
31545d5
Removed unneeded transact method
aaroncox Dec 10, 2024
7d5f058
Reworked constructor to prevent needing undefined for state
aaroncox Dec 10, 2024
50d40fe
Implement ABICache in NetworkState
aaroncox Dec 10, 2024
a47ea6f
Moved decoding to manager and allow overriding on setabi calls
aaroncox Dec 10, 2024
aa89cb9
removed logging
aaroncox Dec 10, 2024
84ae0e7
Adding cleos support while in advanced mode
aaroncox Dec 11, 2024
ff742f4
Merge pull request #305 from greymass/cleos
aaroncox Dec 11, 2024
f50984f
Add a few helper API methods to retrieve producers
aaroncox Dec 11, 2024
65cb896
Added Top21/BP checks to msig page
aaroncox Dec 11, 2024
bdda2ce
Simplified API calls
aaroncox Dec 11, 2024
bc00ac3
Linting
aaroncox Dec 11, 2024
0994cc1
Removed unneeded ORIGIN
aaroncox Dec 11, 2024
79dd0f6
Removed logging
aaroncox Dec 12, 2024
ebfb505
Merge pull request #304 from greymass/msig
aaroncox Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@wharfkit/session": "^1.4.0",
"@wharfkit/transact-plugin-resource-provider": "^1.1.1",
"@wharfkit/wallet-plugin-anchor": "^1.4.0",
"@wharfkit/wallet-plugin-cleos": "^1.2.0",
"@wharfkit/wallet-plugin-metamask": "^1.1.1",
"@wharfkit/wallet-plugin-privatekey": "^1.1.0",
"@wharfkit/wallet-plugin-scatter": "^1.5.1",
Expand Down
42 changes: 20 additions & 22 deletions src/lib/components/button/button.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { cn } from '$lib/utils';
import { emptyMeltElement, melt, type AnyMeltElement } from '@melt-ui/svelte';
import type { Snippet } from 'svelte';
import type { HTMLButtonAttributes, HTMLLinkAttributes } from 'svelte/elements';
Expand All @@ -7,7 +8,7 @@

interface ButtonProps extends HTMLAttributes {
href?: string;
variant?: 'primary' | 'secondary' | 'pill' | 'outline';
variant?: 'primary' | 'secondary' | 'pill';
disabled?: boolean;
active?: boolean;
blank?: boolean;
Expand All @@ -22,6 +23,7 @@
onclick,
variant = 'primary',
active,
class: className,
disabled = false,
...props
}: ButtonProps = $props();
Expand All @@ -41,37 +43,33 @@
}
: {}
);

const primaryStyles =
'relative inline-flex h-12 grow items-center justify-center text-nowrap rounded-lg bg-skyBlue-700 px-8 text-center text-base font-medium text-skyBlue-50 transition-all focus:outline-transparent focus-visible:outline focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-solar-500 hover:active:bg-skyBlue-800 disabled:cursor-not-allowed disabled:bg-mineShaft-900 disabled:text-white/60 disabled:opacity-30 disabled:hover:bg-mineShaft-900 [@media(any-hover:hover)]:hover:bg-skyBlue-600';

const secondaryStyles =
'relative flex h-12 grow items-center justify-center text-nowrap rounded-lg px-8 text-center text-base font-medium text-skyBlue-400 ring-2 ring-inset ring-mineShaft-600 transition-all hover:ring-transparent focus-visible:outline-none focus-visible:ring-solar-500 hover:active:bg-mineShaft-950 hover:active:ring-mineShaft-900 disabled:cursor-not-allowed disabled:text-mineShaft-400 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:ring-mineShaft-600 disabled:active:ring-mineShaft-600 [@media(any-hover:hover)]:hover:bg-mineShaft-900';

const pillStyles =
'relative inline-flex h-10 items-center justify-center text-nowrap rounded-full border-2 border-transparent px-5 text-center text-base font-medium leading-4 transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-solar-500 hover:active:bg-mineShaft-950 aria-[current]:border-mineShaft-200/30 [@media(any-hover:hover)]:hover:bg-mineShaft-900 [@media(any-hover:hover)]:hover:text-mineShaft-100';

let styles = {
primary: primaryStyles,
secondary: secondaryStyles,
pill: pillStyles
};
</script>

<svelte:element
this={tag}
use:melt={$meltElement}
data-variant={variant}
class={props.class || ''}
class={cn(styles[variant], className)}
role={ariaRole}
aria-current={ariaCurrent}
{disabled}
{onclick}
{...props}
{...linkProps}
>
<span>{@render props.children()}</span>
<span class="pointer-events-none relative text-inherit">{@render props.children()}</span>
</svelte:element>

<style lang="postcss">
[data-variant='primary'] {
@apply relative inline-flex h-12 grow items-center justify-center text-nowrap rounded-lg bg-skyBlue-700 px-8 text-center text-base font-medium text-skyBlue-50 transition-all focus:outline-transparent focus-visible:outline focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-solar-500 hover:active:bg-skyBlue-800 disabled:cursor-not-allowed disabled:bg-mineShaft-900 disabled:text-white/60 disabled:opacity-30 disabled:hover:bg-mineShaft-900 [@media(any-hover:hover)]:hover:bg-skyBlue-600;
}

[data-variant='secondary'] {
@apply relative flex h-12 grow items-center justify-center text-nowrap rounded-lg px-8 text-center text-base font-medium text-skyBlue-400 ring-2 ring-inset ring-mineShaft-600 transition-all hover:ring-transparent focus-visible:outline-none focus-visible:ring-solar-500 hover:active:bg-mineShaft-950 hover:active:ring-mineShaft-900 disabled:cursor-not-allowed disabled:text-mineShaft-400 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:ring-mineShaft-600 disabled:active:ring-mineShaft-600 [@media(any-hover:hover)]:hover:bg-mineShaft-900;
}

[data-variant='pill'] {
@apply relative inline-flex h-10 items-center justify-center text-nowrap rounded-full border-2 border-transparent px-5 text-center text-base font-medium leading-4 transition-all focus-visible:outline focus-visible:outline-2 focus-visible:outline-solar-500 hover:active:bg-mineShaft-950 aria-[current]:border-mineShaft-200/30 [@media(any-hover:hover)]:hover:bg-mineShaft-900 [@media(any-hover:hover)]:hover:text-mineShaft-100;
}

span {
@apply pointer-events-none relative text-inherit;
}
</style>
25 changes: 0 additions & 25 deletions src/lib/components/descriptionlist.svelte

This file was deleted.

5 changes: 5 additions & 0 deletions src/lib/components/descriptionlist/dd.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
let props = $props();
</script>

<dd class="grow text-balance break-all text-right tabular-nums">{@render props.children()}</dd>
10 changes: 4 additions & 6 deletions src/lib/components/descriptionlist/dl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import Dlrow from './dlrow.svelte';

type DescriptionItem = {
key: string;
value: string;
title: string;
description: string;
};

interface Props {
Expand All @@ -17,10 +17,8 @@

<dl class="@container">
{#if props.items}
{#each props.items as item}
<Dlrow title={item.key}>
{item.value}
</Dlrow>
{#each props.items as { title, description }}
<Dlrow {title} {description} />
{/each}
{:else if props.children}
{@render props.children()}
Expand Down
21 changes: 17 additions & 4 deletions src/lib/components/descriptionlist/dlrow.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import DT from './dt.svelte';
import DD from './dd.svelte';

interface Props {
title: string;
children: Snippet;
description?: string;
children?: Snippet;
}
let { title, children }: Props = $props();

let { title = '', description, children }: Props = $props();
</script>

<div
class="flex flex-wrap items-center justify-between gap-x-4 border-b border-mineShaft-900 py-3 last:border-none @xs:flex-nowrap"
>
<dt class="caption self-start text-nowrap">{title}</dt>
<dd class="grow text-balance break-all text-right tabular-nums">{@render children()}</dd>
<DT>{title}</DT>
<div
class="grow bg-red-500 before:content-['ERROR_Missing_DD_element_'] has-[dd]:bg-transparent has-[dd]:before:hidden"
>
{#if description}
<DD>{description}</DD>
{/if}
{#if children}
{@render children()}
{/if}
</div>
</div>
5 changes: 5 additions & 0 deletions src/lib/components/descriptionlist/dt.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
let props = $props();
</script>

<dt class="caption self-start text-nowrap">{@render props.children()}</dt>
2 changes: 2 additions & 0 deletions src/lib/components/descriptionlist/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { default as DL } from './dl.svelte';
export { default as DLRow } from './dlrow.svelte';
export { default as DD } from './dd.svelte';
export { default as DT } from './dt.svelte';
34 changes: 30 additions & 4 deletions src/lib/components/elements/action.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
<script lang="ts">
import { type Action } from '@wharfkit/antelope';
import Code from '../code.svelte';
import { DL, DLRow, DD } from '../descriptionlist';
import { Stack } from '../layout';
import Account from './account.svelte';

interface Props {
data: Record<string, unknown>;
action: Action;
}

let props: Props = $props();
let { action }: Props = $props();

// const arr = action.authorization.map((auth) => [Account, auth]);
// let test = [Account];
</script>

{#if props.data}
<Code>{JSON.stringify(props.data, null, 2)}</Code>
{#if action}
<div class="grid grid-cols-2 items-start gap-6">
<Code>{JSON.stringify(action.data, null, 2)}</Code>
<Stack class="gap-2">
<h3 class="h4">{String(action.name)}</h3>
<DL>
<DLRow title="Contract">
<DD>
<Account name={action.account} contract />
</DD>
</DLRow>
<DLRow title="Authorization">
{#each action.authorization as auth}
<DD>
<Account name={auth.actor}>{auth}</Account>
</DD>
{/each}
</DLRow>
</DL>
</Stack>
</div>
{/if}
6 changes: 5 additions & 1 deletion src/lib/components/elements/asset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { cn } from '$lib/utils';
import type { UnicoveContext } from '$lib/state/client.svelte';
import { getContext } from 'svelte';
import Big from 'big.js';

const context = getContext<UnicoveContext>('state');

Expand Down Expand Up @@ -34,7 +35,10 @@
};

function formatAssetValue() {
return Intl.NumberFormat(locale, assetOptions).format(asset?.value || fallback);
// Use Big.js to accurately convert the string into a usable number
// Some precision may be lost in extreme circumstances
const number = Number(new Big(asset?.quantity || fallback));
return Intl.NumberFormat(locale, assetOptions).format(number);
}

function formatCurrencyValue() {
Expand Down
34 changes: 34 additions & 0 deletions src/lib/components/elements/voteweight.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script lang="ts">
import { getContext } from 'svelte';
import type { HTMLAttributes } from 'svelte/elements';
import { Asset, Float64 } from '@wharfkit/antelope';

import AssetText from '$lib/components/elements/asset.svelte';
import type { UnicoveContext } from '$lib/state/client.svelte';

interface Props extends HTMLAttributes<HTMLSpanElement> {
variant?: 'value' | 'full';
decay?: number; // Number of weeks for voter decay
weight: Float64; // Weight of vote
}

let { weight, decay = 52, ...props }: Props = $props();
let { network } = getContext<UnicoveContext>('state');
const precision = 10 ** network.chain.systemToken!.symbol.precision;

const tokens = $derived(
Asset.from(
Number(weight) / calcVoteWeight(decay) / precision,
network.chain.systemToken!.symbol
)
);

function calcVoteWeight(voteDecayPeriod: number) {
const timestamp = 946684800000;
const dates = (Date.now() - timestamp) / 1000;
const weight = Math.floor(dates / (86400 * 7)) / voteDecayPeriod;
return 2 ** weight;
}
</script>

<AssetText {...props} value={tokens} />
33 changes: 32 additions & 1 deletion src/lib/state/client/account.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import {
APIClient,
Asset,
Checksum256,
Float64,
Int128,
Int64,
Name,
UInt128,
UInt64,
type NameType
} from '@wharfkit/antelope';
Expand All @@ -26,6 +29,24 @@ const defaultDataSources = {
rexfund: undefined
};

interface VoterInfo {
isProxy: boolean;
proxyWeight: Float64;
proxy: Name;
weight: Float64;
votes: Name[];
staked: Int64;
}

const defaultVoteInfo: VoterInfo = {
isProxy: false,
proxy: Name.from(''),
proxyWeight: Float64.from(0),
weight: Float64.from(0),
votes: [],
staked: Int64.from(0)
};

export class AccountState {
public client?: APIClient = $state();
public fetch = $state(fetch);
Expand Down Expand Up @@ -62,6 +83,7 @@ export class AccountState {
? getAccountValue(this.network, this.balance, this.ram)
: undefined;
});
public voter: VoterInfo = $state(defaultVoteInfo);

constructor(network: NetworkState, name: NameType, fetchOverride?: typeof fetch) {
if (fetchOverride) {
Expand Down Expand Up @@ -94,6 +116,14 @@ export class AccountState {
client: this.network.client,
data: API.v1.AccountObject.from(json.account_data)
});
this.voter = {
isProxy: json.account_data.voter_info.is_proxy,
proxy: Name.from(json.account_data.voter_info.proxy),
proxyWeight: Float64.from(json.account_data.voter_info.proxied_vote_weight),
weight: Float64.from(json.account_data.voter_info.last_vote_weight),
votes: json.account_data.voter_info.producers.map((producer: string) => Name.from(producer)),
staked: Int64.from(json.account_data.voter_info.staked)
};
this.loaded = true;
}

Expand All @@ -111,7 +141,8 @@ export class AccountState {
cpu: this.cpu,
net: this.net,
ram: this.ram
}
},
voter: this.voter
};
}
}
Expand Down
Loading
Loading