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

FIX: copy token denom in dev mode #425

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions src/components/general/CopyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { useState } from "react"
interface Props {
text: string
className?: string
size?: number
}
const CopyIcon = ({ text, className }: Props) => {
const CopyIcon = ({ text, className, size }: Props) => {
const [copied, setCopied] = useState(false)

return (
Expand All @@ -19,9 +20,9 @@ const CopyIcon = ({ text, className }: Props) => {
}}
>
{copied ? (
<Check style={{ fontSize: 18 }} />
<Check style={{ fontSize: size ?? 18 }} />
) : (
<ContentCopy style={{ fontSize: 18 }} />
<ContentCopy style={{ fontSize: size ?? 18 }} />
)}
</button>
)
Expand Down
12 changes: 12 additions & 0 deletions src/pages/wallet/AssetChain.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
font-weight: var(--normal);
color: var(--text-muted);
white-space: nowrap;

.copy__denom {
display: inline-flex;
align-items: center;
justify-content: flex-start;
gap: 5px;
color: hsl(
var(--button-primary-bg-h),
var(--button-primary-bg-s),
var(--button-primary-bg-l)
);
}
}

h4 {
Expand Down
17 changes: 15 additions & 2 deletions src/pages/wallet/AssetChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@ import { useNetwork } from "data/wallet"
import { useTranslation } from "react-i18next"
import styles from "./AssetChain.module.scss"
import IbcSendBack from "./IbcSendBack"
import { InternalButton } from "components/general"
import { CopyIcon, InternalButton } from "components/general"
import { Tooltip } from "components/display"
import { useDevMode } from "utils/localStorage"
import { truncate } from "@terra-money/terra-utils"

export interface Props {
chain: string
balance: string
symbol: string
decimals: number
token: string
denom: string
path?: string[]
ibcDenom?: string
}

const AssetChain = (props: Props) => {
const { chain, symbol, balance, decimals, token, path, ibcDenom } = props
const { chain, symbol, balance, decimals, token, path, ibcDenom, denom } =
props
const currency = useCurrency()
const { data: prices, ...pricesState } = useExchangeRates()
const { t } = useTranslation()

const networks = useNetwork()
const { devMode } = useDevMode()

const { icon, name } = networks[chain]

Expand Down Expand Up @@ -78,6 +83,14 @@ const AssetChain = (props: Props) => {
))}
</h4>
{path && <p>{path.map((c) => networks[c]?.name ?? c).join(" → ")}</p>}
{devMode && (
<p>
<span className={styles.copy__denom}>
{truncate(denom)}
<CopyIcon text={denom} size={14} />
</span>
</p>
)}
</h1>
<h1 className={styles.price}>
{currency.symbol}{" "}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/wallet/AssetPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const AssetPage = () => {
balance={b.amount}
chain={b.chain}
token={token}
denom={b.denom}
decimals={decimals}
/>
{token === "uluna" && isTerraChain(b.chain) && <Vesting />}
Expand All @@ -117,6 +118,7 @@ const AssetPage = () => {
balance={b.amount}
chain={b.chain}
token={token}
denom={b.denom}
decimals={decimals}
path={unknownIBCDenoms[b.denom]?.chains}
ibcDenom={b.denom}
Expand Down