Skip to content

Commit

Permalink
feat(app): show token paths
Browse files Browse the repository at this point in the history
  • Loading branch information
cor committed Jan 21, 2025
1 parent 87c5d81 commit 2bfe80e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
7 changes: 4 additions & 3 deletions app/src/lib/components/table-cells/cell-assets.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export let token: {
}
</script>

<Token {chains} denom={token.base.token} chainId={token.base.chainId}/>
➡️
<Token {chains} denom={token.quote.token} chainId={token.quote.chainId}/>
<div class="flex flex-col items-start">
<Token {chains} denom={token.base.token} chainId={token.base.chainId}/>
<Token {chains} denom={token.quote.token} chainId={token.quote.chainId}/>
</div>
15 changes: 15 additions & 0 deletions app/src/lib/components/token-quality-level.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script lang="ts">
import type { Chain, TokenInfo } from "$lib/types"
import { cn } from "$lib/utilities/shadcn"
export let level: "GRAPHQL" | "ONCHAIN" | "NONE"
</script>

<div class={cn("rounded text-xs w-4 h-4 flex justify-center items-center", level === "GRAPHQL" ? "bg-black text-white" : level === "ONCHAIN" ? "bg-yellow-500 text-black" : "bg-red-500 text-black")}>
{#if level === "GRAPHQL"}
G
{:else if level === "ONCHAIN"}
O
{:else if level === "NONE"}
N
{/if}
</div>
27 changes: 20 additions & 7 deletions app/src/lib/components/token.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script lang="ts">
import type { Chain, TokenInfo } from "$lib/types"
import TokenQualityLevel from "$lib/components/token-quality-level.svelte"
import Truncate from "./truncate.svelte"
import ArrowLeftIcon from "virtual:icons/lucide/arrow-left"
import { toDisplayName } from "$lib/utilities/chains.ts"
export let chains: Array<Chain>
export let chainId: string
export let denom: string
Expand All @@ -26,7 +31,8 @@ let token: TokenInfo = (() => {
quality_level: "GRAPHQL",
denom,
primaryRepresentation: fullRepresentations[0],
representations: fullRepresentations
representations: fullRepresentations,
wrapping: graphqlToken.wrapping
}
}
}
Expand All @@ -38,9 +44,16 @@ let token: TokenInfo = (() => {
})()
</script>


{#if token.quality_level === "GRAPHQL"}
[G] {token.primaryRepresentation.symbol}
{:else}
[N] {denom}
{/if}
<div class="flex gap-1 items-center">
{#if token.quality_level === "GRAPHQL"}
<div class="font-bold">{token.primaryRepresentation.symbol}</div>
<div class="text-muted-foreground text-xs flex gap-1 items-center">
{#each token.wrapping as wrapping}
<ArrowLeftIcon/>{toDisplayName(wrapping.wrapped_chain.chain_id, chains)}
{/each}
</div>
{:else}
<Truncate value={token.denom} type = "address"/>
{/if}
<TokenQualityLevel level={token.quality_level}/>
</div>
17 changes: 10 additions & 7 deletions app/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ export type ChainToken = {
update_timestamp: string | null
}>
}>
wrapping: Array<{
wrapped_chain: {
chain_id: string
}
destination_channel_id: 3
unwrapped_denom: string
}>
wrapping: Array<Wrapping>
}

export type Wrapping = {
wrapped_chain: {
chain_id: string
}
destination_channel_id: number
unwrapped_denom: string
}

export type TokenInfoQualityLevel = "GRAPHQL" | "ONCHAIN" | "NONE"
Expand All @@ -107,6 +109,7 @@ export type TokenInfo =
denom: string
primaryRepresentation: TokenRepresentation
representations: Array<TokenRepresentation>
wrapping: Array<Wrapping>
}
| {
quality_level: "ONCHAIN"
Expand Down

0 comments on commit 2bfe80e

Please sign in to comment.