Skip to content

Commit 630ed77

Browse files
committed
[feat] apply changed token service
1 parent a67f030 commit 630ed77

File tree

2 files changed

+88
-54
lines changed

2 files changed

+88
-54
lines changed

apps/extension/src/pages/main/components/token-found-modal/index.tsx

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { EmbedChainInfos } from "../../../../config";
3737
import { DenomHelper } from "@keplr-wallet/common";
3838
import { TokenTag } from "../../../register/enable-chains/components/chain-item";
3939
import { SupportedPaymentType } from "@keplr-wallet/types";
40+
import { useTokenTag } from "../../../../hooks/use-token-tag";
4041

4142
export const TokenFoundModal: FunctionComponent<{
4243
close: () => void;
@@ -514,6 +515,15 @@ const FoundTokenView: FunctionComponent<{
514515
}
515516
}, [asset.currency, chainId, asset.paymentType]);
516517

518+
const tag = useTokenTag({
519+
token: new CoinPretty(asset.currency, asset.amount),
520+
chainInfo: chainStore.hasChain(chainId)
521+
? chainStore.getChain(chainId)
522+
: chainStore.getModularChain(chainId),
523+
isFetching: false,
524+
error: undefined,
525+
});
526+
517527
return (
518528
<Columns sum={1} gutter="0.5rem" alignY="center">
519529
<Box width="1.5rem" height="1.5rem">
@@ -543,35 +553,54 @@ const FoundTokenView: FunctionComponent<{
543553
}
544554
>
545555
{(() => {
546-
if (chainStore.hasChain(chainId)) {
547-
return chainStore
548-
.getChain(chainId)
549-
.forceFindCurrency(asset.currency.coinMinimalDenom).coinDenom;
550-
} else {
551-
const modularChainInfo = chainStore.getModularChain(chainId);
552-
const isBitcoin = "bitcoin" in modularChainInfo;
553-
const isStarknet = "starknet" in modularChainInfo;
554-
const isCosmos = "cosmos" in modularChainInfo;
555-
556-
if (isBitcoin || isStarknet || isCosmos) {
557-
return (
558-
chainStore
559-
.getModularChainInfoImpl(chainId)
560-
.getCurrencies(
561-
isBitcoin ? "bitcoin" : isStarknet ? "starknet" : "cosmos"
562-
)
563-
.find(
564-
(cur) =>
565-
cur.coinMinimalDenom === asset.currency.coinMinimalDenom
566-
)?.coinDenom ?? asset.currency.coinDenom
567-
);
556+
const coinDenom = (() => {
557+
if (chainStore.hasChain(chainId)) {
558+
return chainStore
559+
.getChain(chainId)
560+
.forceFindCurrency(asset.currency.coinMinimalDenom).coinDenom;
568561
} else {
569-
return asset.currency.coinDenom;
562+
const modularChainInfo = chainStore.getModularChain(chainId);
563+
const isBitcoin = "bitcoin" in modularChainInfo;
564+
const isStarknet = "starknet" in modularChainInfo;
565+
const isCosmos = "cosmos" in modularChainInfo;
566+
567+
if (isBitcoin || isStarknet || isCosmos) {
568+
return (
569+
chainStore
570+
.getModularChainInfoImpl(chainId)
571+
.getCurrencies(
572+
isBitcoin
573+
? "bitcoin"
574+
: isStarknet
575+
? "starknet"
576+
: "cosmos"
577+
)
578+
.find(
579+
(cur) =>
580+
cur.coinMinimalDenom ===
581+
asset.currency.coinMinimalDenom
582+
)?.coinDenom ?? asset.currency.coinDenom
583+
);
584+
} else {
585+
return asset.currency.coinDenom;
586+
}
570587
}
588+
})();
589+
590+
if (
591+
asset.currency.coinMinimalDenom.startsWith("ibc/") &&
592+
coinDenom
593+
) {
594+
const cut = coinDenom.indexOf(" (");
595+
return cut > 0 ? coinDenom.slice(0, cut) : coinDenom;
571596
}
597+
return coinDenom;
572598
})()}
573599
</Subtitle3>
574600
{addressTag ? <TokenTag text={addressTag.text} /> : null}
601+
{tag && tag.text === "IBC" ? (
602+
<TokenTag text={tag.text} tooltip={tag.tooltip} />
603+
) : null}
575604
</Box>
576605

577606
<Column weight={1} />
@@ -615,6 +644,7 @@ const FoundTokenView: FunctionComponent<{
615644
return uiConfigStore.hideStringIfPrivacyMode(
616645
new CoinPretty(currency, asset.amount)
617646
.shrink(true)
647+
.hideIBCMetadata(true)
618648
.trim(true)
619649
.maxDecimals(6)
620650
.inequalitySymbol(true)

apps/extension/src/pages/main/spendable.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -720,37 +720,41 @@ export const SpendableAssetView: FunctionComponent<{
720720
</React.Fragment>
721721
</VerticalCollapseTransition>
722722

723-
{numFoundToken > 0 && (
724-
<NewTokenFoundButtonContainer
725-
onClick={() => setIsFoundTokenModalOpen(true)}
726-
>
727-
<XAxis alignY="center">
728-
<Subtitle3>
729-
{intl.formatMessage(
730-
{ id: "page.main.spendable.new-token-found" },
731-
{
732-
numFoundToken: (
733-
<span
734-
style={{
735-
paddingRight: "0.25rem",
736-
color: ColorPalette["blue-300"],
737-
}}
738-
>
739-
{numFoundToken}
740-
</span>
741-
),
742-
}
743-
)}
744-
</Subtitle3>
745-
<div style={{ flex: 1 }} />
746-
<ArrowRightIcon
747-
width="1.25rem"
748-
height="1.25rem"
749-
color={ColorPalette["gray-300"]}
750-
/>
751-
</XAxis>
752-
</NewTokenFoundButtonContainer>
753-
)}
723+
{numFoundToken > 0 &&
724+
chainStore.shouldShowNewTokenFoundInMain && (
725+
<NewTokenFoundButtonContainer
726+
onClick={() => {
727+
chainStore.dismissNewTokenFoundInHome();
728+
setIsFoundTokenModalOpen(true);
729+
}}
730+
>
731+
<XAxis alignY="center">
732+
<Subtitle3>
733+
{intl.formatMessage(
734+
{ id: "page.main.spendable.new-token-found" },
735+
{
736+
numFoundToken: (
737+
<span
738+
style={{
739+
paddingRight: "0.25rem",
740+
color: ColorPalette["blue-300"],
741+
}}
742+
>
743+
{numFoundToken}
744+
</span>
745+
),
746+
}
747+
)}
748+
</Subtitle3>
749+
<div style={{ flex: 1 }} />
750+
<ArrowRightIcon
751+
width="1.25rem"
752+
height="1.25rem"
753+
color={ColorPalette["gray-300"]}
754+
/>
755+
</XAxis>
756+
</NewTokenFoundButtonContainer>
757+
)}
754758

755759
<SceneTransition
756760
ref={sceneTransitionRef}

0 commit comments

Comments
 (0)