Skip to content

Commit

Permalink
chore: add coderabbit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 committed Jan 14, 2025
1 parent 09bf705 commit 7b1a642
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 24 deletions.
54 changes: 36 additions & 18 deletions components/bank/components/historyBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,34 @@ export function HistoryBox({
let metadata = metadatas?.metadatas.find(m => m.base === amt.denom);

if (amt.denom.startsWith('ibc/')) {
metadata = {
description: assetInfo?.description ?? '',
denom_units:
assetInfo?.denom_units?.map(unit => ({
...unit,
aliases: unit.aliases || [],
})) ?? [],
base: assetInfo?.base ?? '',
display: assetInfo?.display ?? '',
name: assetInfo?.name ?? '',
symbol: assetInfo?.symbol ?? '',
uri: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
uri_hash: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
};
if (assetInfo) {
metadata = {
description: assetInfo?.description ?? '',
denom_units:
assetInfo?.denom_units?.map(unit => ({
...unit,
aliases: unit.aliases || [],
})) ?? [],
base: assetInfo?.base ?? '',
display: assetInfo?.display ?? '',
name: assetInfo?.name ?? '',
symbol: assetInfo?.symbol ?? '',
uri: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
uri_hash: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
};
} else {
// assetInfo is undefined
metadata = {
description: '',
denom_units: [],
base: '',
display: '',
name: '',
symbol: '',
uri: '',
uri_hash: '',
};
}
}

return <DenomImage key={index} denom={metadata} />;
Expand All @@ -252,8 +266,10 @@ export function HistoryBox({

if (amt.denom.startsWith('ibc/')) {
const assetInfo = denomToAsset(env.chain, amt.denom);
if (assetInfo?.traces?.[0]?.counterparty?.base_denom) {
display = assetInfo.traces[0].counterparty.base_denom.slice(1);
if (assetInfo?.traces && assetInfo.traces.length > 0) {
if (assetInfo.traces[0].counterparty?.base_denom) {
display = assetInfo.traces[0].counterparty.base_denom.slice(1);
}
}
}

Expand Down Expand Up @@ -301,8 +317,10 @@ export function HistoryBox({

if (amt.denom.startsWith('ibc/')) {
const assetInfo = denomToAsset(env.chain, amt.denom);
if (assetInfo?.traces?.[0]?.counterparty?.base_denom) {
baseDenom = assetInfo.traces[0].counterparty.base_denom.slice(1);
if (assetInfo?.traces && assetInfo.traces.length > 0) {
if (assetInfo.traces[0].counterparty?.base_denom) {
baseDenom = assetInfo.traces[0].counterparty.base_denom.slice(1);
}
}
}

Expand Down
17 changes: 12 additions & 5 deletions components/bank/forms/ibcSendForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ export default function IbcSendForm({
availableToChains: IbcChain[];
}>) {
const { address: osmosisAddress } = useChain(env.osmosisTestnetChain);

const formatTokenDisplayName = (displayName: string) => {
if (displayName.startsWith('factory')) {
return displayName.split('/').pop()?.toUpperCase();
}
if (displayName.startsWith('u')) {
return displayName.slice(1).toUpperCase();
}
return truncateString(displayName, 10).toUpperCase();
};

const [isSending, setIsSending] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
const [feeWarning, setFeeWarning] = useState('');
Expand Down Expand Up @@ -571,11 +582,7 @@ export default function IbcSendForm({
values.selectedToken?.denom ??
'Select';

return tokenDisplayName.startsWith('factory')
? tokenDisplayName.split('/').pop()?.toUpperCase()
: tokenDisplayName.startsWith('u')
? tokenDisplayName.slice(1).toUpperCase()
: truncateString(tokenDisplayName, 10).toUpperCase();
return formatTokenDisplayName(tokenDisplayName);
})()}
<PiCaretDownBold className="ml-1" />
</label>
Expand Down
5 changes: 4 additions & 1 deletion components/groups/components/myGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ export function YourGroups({
if (coreBalance.denom.startsWith('ibc/')) {
const assetInfo = denomToAsset(env.chain, coreBalance.denom);

const baseDenom = assetInfo?.traces?.[1]?.counterparty?.base_denom;
let baseDenom = '';
if (assetInfo?.traces && assetInfo.traces.length > 1) {
baseDenom = assetInfo.traces[1]?.counterparty?.base_denom ?? '';
}

return {
denom: baseDenom ?? '', // normalized denom (e.g., 'umfx')
Expand Down

0 comments on commit 7b1a642

Please sign in to comment.