1- import { TxType } from "@namada/sdk" ;
1+ import { IbcTransferProps , TxType } from "@namada/sdk" ;
22import {
33 BondProps ,
44 ClaimRewardsProps ,
@@ -12,13 +12,17 @@ import {
1212} from "@namada/types" ;
1313import { shortenAddress } from "@namada/utils" ;
1414import { NamCurrency } from "App/Common/NamCurrency" ;
15+ import * as J from "fp-ts/Json" ;
16+ import { pipe } from "fp-ts/lib/function" ;
17+ import * as O from "fp-ts/Option" ;
1518import { ReactNode } from "react" ;
1619import { FaVoteYea } from "react-icons/fa" ;
1720import { FaRegEye , FaWallet } from "react-icons/fa6" ;
1821import { GoStack } from "react-icons/go" ;
1922import { PiDotsNineBold } from "react-icons/pi" ;
2023import { isShieldedPool , parseTransferType , ShieldedPoolLabel } from "utils" ;
2124import { TransactionCard } from "./TransactionCard" ;
25+ import { OsmosisSwapMemo } from "./types" ;
2226
2327type CommitmentProps = {
2428 commitment : CommitmentDetailProps ;
@@ -37,6 +41,7 @@ const IconMap: Record<TxType, React.ReactNode> = {
3741 [ TxType . VoteProposal ] : < FaVoteYea /> ,
3842 [ TxType . Batch ] : < PiDotsNineBold /> ,
3943 [ TxType . ClaimRewards ] : < GoStack /> ,
44+ [ TxType . OsmosisSwap ] : < FaWallet /> ,
4045} ;
4146
4247const TitleMap : Record < TxType , string > = {
@@ -51,6 +56,7 @@ const TitleMap: Record<TxType, string> = {
5156 [ TxType . VoteProposal ] : "Vote" ,
5257 [ TxType . Batch ] : "Batch" ,
5358 [ TxType . ClaimRewards ] : "Claim Rewards" ,
59+ [ TxType . OsmosisSwap ] : "Shielded Swap" ,
5460} ;
5561
5662const formatAddress = ( address : string ) : string =>
@@ -147,6 +153,27 @@ export const Commitment = ({
147153 wrapperFeePayer
148154 ) ;
149155 title = `${ type } ${ title } ` ;
156+ } else if ( commitment . txType === TxType . IBCTransfer ) {
157+ const ibcTx = commitment as CommitmentDetailProps < IbcTransferProps > ;
158+
159+ // It's fine not to handle errors here as memo can be optional and not JSON at all
160+ const maybeMemo = pipe (
161+ O . fromNullable ( ibcTx . memo ) ,
162+ O . map ( ( memo ) => J . parse ( memo ) ) ,
163+ O . map ( O . fromEither ) ,
164+ O . flatten
165+ ) ;
166+
167+ const maybeOsmosisSwapMemo = pipe (
168+ maybeMemo ,
169+ O . map ( OsmosisSwapMemo . decode ) ,
170+ O . map ( O . fromEither ) ,
171+ O . flatten
172+ ) ;
173+
174+ if ( O . isSome ( maybeOsmosisSwapMemo ) ) {
175+ title = TitleMap [ TxType . OsmosisSwap ] ;
176+ }
150177 }
151178
152179 return (
0 commit comments