Skip to content

Commit a7474b7

Browse files
committed
Match how Ondo assets are displayed elsewhere
1 parent 063f7d7 commit a7474b7

8 files changed

Lines changed: 81 additions & 114 deletions

File tree

app/components/UI/Rewards/Views/OndoCampaignRwaSelectorView.test.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,18 @@ describe('OndoCampaignRwaSelectorView', () => {
608608
});
609609
});
610610

611-
describe('token name sanitization', () => {
612-
it('strips "Ondo Tokenized " prefix from token names in list rows', () => {
611+
describe('Ondo token name display', () => {
612+
it('normalizes "Ondo Tokenized " prefix names to the suffix form in list rows', () => {
613613
const token = { ...buildToken('AAPL'), name: 'Ondo Tokenized Apple' };
614614
mockUseRwaTokens.mockReturnValue({ data: [token], isLoading: false });
615615
const { getByText, queryByText } = render(
616616
<OndoCampaignRwaSelectorView />,
617617
);
618-
expect(getByText('Apple')).toBeDefined();
618+
expect(getByText('Apple (Ondo Tokenized)')).toBeDefined();
619619
expect(queryByText('Ondo Tokenized Apple')).toBeNull();
620620
});
621621

622-
it('strips "(Ondo Tokenized)" suffix from token names in list rows', () => {
622+
it('keeps "(Ondo Tokenized)" suffix names unchanged in list rows', () => {
623623
const token = {
624624
...buildToken('AAPL'),
625625
name: 'Apple (Ondo Tokenized)',
@@ -628,25 +628,25 @@ describe('OndoCampaignRwaSelectorView', () => {
628628
const { getByText, queryByText } = render(
629629
<OndoCampaignRwaSelectorView />,
630630
);
631-
expect(getByText('Apple')).toBeDefined();
632-
expect(queryByText('Apple (Ondo Tokenized)')).toBeNull();
631+
expect(getByText('Apple (Ondo Tokenized)')).toBeDefined();
632+
expect(queryByText('Apple')).toBeNull();
633633
});
634634

635-
it('leaves unrelated token names unchanged', () => {
636-
const token = { ...buildToken('USDY'), name: 'Ondo USD Yield' };
635+
it('normalizes "Tokenized Ondo " prefix names to the suffix form in list rows', () => {
636+
const token = { ...buildToken('AAPL'), name: 'Tokenized Ondo Apple' };
637637
mockUseRwaTokens.mockReturnValue({ data: [token], isLoading: false });
638638
const { getByText } = render(<OndoCampaignRwaSelectorView />);
639-
expect(getByText('Ondo USD Yield')).toBeDefined();
639+
expect(getByText('Apple (Ondo Tokenized)')).toBeDefined();
640640
});
641641

642-
it('passes original unsanitized name to goToSwaps when token has Ondo prefix', () => {
642+
it('passes the suffix-form name to goToSwaps when token has Ondo prefix', () => {
643643
const token = { ...buildToken('AAPL'), name: 'Ondo Tokenized Apple' };
644644
mockUseRwaTokens.mockReturnValue({ data: [token], isLoading: false });
645645
const { getByTestId } = render(<OndoCampaignRwaSelectorView />);
646646
fireEvent.press(getByTestId('token-row-AAPL'));
647647
expect(mockGoToSwaps).toHaveBeenCalledWith(
648648
undefined,
649-
expect.objectContaining({ name: 'Ondo Tokenized Apple' }),
649+
expect.objectContaining({ name: 'Apple (Ondo Tokenized)' }),
650650
);
651651
});
652652
});

app/components/UI/Rewards/Views/OndoCampaignRwaSelectorView.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import { getTrendingTokenImageUrl } from '../../Trending/utils/getTrendingTokenI
3939
import {
4040
parseCaip19,
4141
caipChainIdToHex,
42-
sanitizeOndoTokenName,
42+
formatOndoTokenName,
4343
} from '../utils/formatUtils';
4444
import { RWA_NETWORKS_LIST } from '../../Trending/utils/trendingNetworksList';
4545
import {
@@ -262,7 +262,7 @@ const OndoCampaignRwaSelectorView: React.FC = () => {
262262
sourceToken: srcBridgeToken,
263263
});
264264

265-
// Deduplicate by assetId and sanitize display names.
265+
// Deduplicate by assetId and normalize names to the app-wide Ondo suffix form.
266266
// Use CAIP-19 assetId (not symbol) for deduplication — symbol comparison
267267
// is fragile when casing differs between chains.
268268
const tokens = useMemo((): TrendingAsset[] => {
@@ -274,18 +274,17 @@ const OndoCampaignRwaSelectorView: React.FC = () => {
274274
seen.add(token.assetId);
275275
return true;
276276
})
277-
.map((token) => ({ ...token, name: sanitizeOndoTokenName(token.name) }));
277+
.map((token) => ({ ...token, name: formatOndoTokenName(token.name) }));
278278
}, [rwaTokens, srcTokenAsset]);
279279

280280
const handleAssetSelect = useCallback(
281281
(asset: TrendingAsset) => {
282282
const parsed = parseCaip19(asset.assetId);
283283
if (!parsed) return;
284-
const rawToken = rwaTokens.find((t) => t.assetId === asset.assetId);
285284
const destToken: BridgeToken = {
286285
address: parsed.assetReference,
287286
symbol: asset.symbol,
288-
name: rawToken?.name ?? asset.name,
287+
name: asset.name,
289288
decimals: asset.decimals,
290289
chainId: `${parsed.namespace}:${parsed.chainId}` as CaipChainId,
291290
image: getTrendingTokenImageUrl(asset.assetId),
@@ -318,7 +317,6 @@ const OndoCampaignRwaSelectorView: React.FC = () => {
318317
trackEvent,
319318
createEventBuilder,
320319
ondoUsdSrcToken,
321-
rwaTokens,
322320
],
323321
);
324322

app/components/UI/Rewards/components/Campaigns/OndoPortfolio.test.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ jest.mock(
216216
);
217217

218218
const mockRefetch = jest.fn();
219+
const MOCK_POSITION_DISPLAY_NAME = 'Apple Inc. (Ondo Tokenized)';
219220

220221
const MOCK_POSITION: OndoGmPortfolioPositionDto = {
221222
tokenSymbol: 'AAPLon',
@@ -368,7 +369,7 @@ describe('OndoPortfolio', () => {
368369
it('renders the token name', () => {
369370
const { getByText } = render(<OndoPortfolio {...loadedProps} />);
370371

371-
expect(getByText('Apple Inc.')).toBeDefined();
372+
expect(getByText(MOCK_POSITION_DISPLAY_NAME)).toBeDefined();
372373
});
373374
});
374375

@@ -394,8 +395,8 @@ describe('OndoPortfolio', () => {
394395

395396
it('pressing a position row does not throw', () => {
396397
const { getByText } = render(<OndoPortfolio {...loadedProps} />);
397-
fireEvent.press(getByText('Apple Inc.'));
398-
expect(getByText('Apple Inc.')).toBeDefined();
398+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
399+
expect(getByText(MOCK_POSITION_DISPLAY_NAME)).toBeDefined();
399400
});
400401

401402
it('renders empty banner when portfolio has no positions', () => {
@@ -479,7 +480,7 @@ describe('OndoPortfolio', () => {
479480
const props = buildPropsWithBalance(rawHexBalance);
480481
const { getByText } = render(<OndoPortfolio {...props} />);
481482

482-
fireEvent.press(getByText('Apple Inc.'));
483+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
483484

484485
expect(props.onOpenAccountPicker).not.toHaveBeenCalled();
485486
},
@@ -492,7 +493,9 @@ describe('OndoPortfolio', () => {
492493
// empty and the component navigates directly (length === 0 branch).
493494
// Picker not opened either way — we just confirm no throw.
494495
const { getByText } = render(<OndoPortfolio {...props} />);
495-
expect(() => fireEvent.press(getByText('Apple Inc.'))).not.toThrow();
496+
expect(() =>
497+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME)),
498+
).not.toThrow();
496499
});
497500
});
498501

@@ -571,7 +574,7 @@ describe('OndoPortfolio', () => {
571574
onOpenAccountPicker={onOpenAccountPicker}
572575
/>,
573576
);
574-
fireEvent.press(getByText('Apple Inc.'));
577+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
575578
expect(onOpenAccountPicker).not.toHaveBeenCalled();
576579
});
577580
});
@@ -672,7 +675,7 @@ describe('OndoPortfolio', () => {
672675
/>,
673676
);
674677

675-
fireEvent.press(getByText('Apple Inc.'));
678+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
676679

677680
expect(onOpenAccountPicker).toHaveBeenCalledTimes(1);
678681
const config = (onOpenAccountPicker as jest.Mock).mock.calls[0][0];
@@ -725,7 +728,7 @@ describe('OndoPortfolio', () => {
725728
/>,
726729
);
727730

728-
fireEvent.press(getByText('Apple Inc.'));
731+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
729732

730733
expect(onOpenAccountPicker).not.toHaveBeenCalled();
731734
});
@@ -787,7 +790,7 @@ describe('OndoPortfolio', () => {
787790
/>,
788791
);
789792

790-
fireEvent.press(getByText('Apple Inc.'));
793+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
791794

792795
// Account must be found despite key case mismatch → picker opened
793796
expect(onOpenAccountPicker).toHaveBeenCalledTimes(1);
@@ -849,7 +852,7 @@ describe('OndoPortfolio', () => {
849852
/>,
850853
);
851854

852-
fireEvent.press(getByText('Apple Inc.'));
855+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
853856

854857
expect(onOpenAccountPicker).toHaveBeenCalledTimes(1);
855858
const config = (onOpenAccountPicker as jest.Mock).mock.calls[0][0];
@@ -907,7 +910,7 @@ describe('OndoPortfolio', () => {
907910
/>,
908911
);
909912

910-
fireEvent.press(getByText('Apple Inc.'));
913+
fireEvent.press(getByText(MOCK_POSITION_DISPLAY_NAME));
911914

912915
// No subscribed account has balance → navigate directly, picker not opened
913916
expect(onOpenAccountPicker).not.toHaveBeenCalled();

app/components/UI/Rewards/components/Campaigns/OndoPortfolio.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
groupPortfolioPositionsByAsset,
4242
formatPnlPercent,
4343
isPnlNonNegative,
44-
sanitizeOndoTokenName,
44+
formatOndoTokenName,
4545
} from './OndoPortfolio.utils';
4646
import { selectAllTokenBalances } from '../../../../../selectors/tokenBalancesController';
4747
import { selectAllTokens } from '../../../../../selectors/tokensController';
@@ -458,15 +458,20 @@ const OndoPortfolio: React.FC<OndoPortfolioProps> = ({
458458
justifyContent={BoxJustifyContent.Between}
459459
alignItems={BoxAlignItems.Center}
460460
>
461+
<Box twClassName="flex-1 min-w-0 pr-2">
462+
<Text
463+
variant={TextVariant.BodyMd}
464+
fontWeight={FontWeight.Medium}
465+
numberOfLines={1}
466+
ellipsizeMode="tail"
467+
>
468+
{formatOndoTokenName(row.tokenName)}
469+
</Text>
470+
</Box>
461471
<Text
462472
variant={TextVariant.BodyMd}
463473
fontWeight={FontWeight.Medium}
464-
>
465-
{sanitizeOndoTokenName(row.tokenName)}
466-
</Text>
467-
<Text
468-
variant={TextVariant.BodyMd}
469-
fontWeight={FontWeight.Medium}
474+
numberOfLines={1}
470475
>
471476
{formatUsd(row.currentValue)}
472477
</Text>

app/components/UI/Rewards/components/Campaigns/OndoPortfolio.utils.test.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
groupPortfolioPositionsByAsset,
33
formatPnlPercent,
44
isPnlNonNegative,
5-
sanitizeOndoTokenName,
5+
formatOndoTokenName,
66
} from './OndoPortfolio.utils';
77

88
describe('groupPortfolioPositionsByAsset', () => {
@@ -113,44 +113,30 @@ describe('isPnlNonNegative', () => {
113113
});
114114
});
115115

116-
describe('sanitizeOndoTokenName', () => {
117-
it('strips "(Ondo Tokenized)" suffix and trims', () => {
118-
expect(sanitizeOndoTokenName('US Dollar (Ondo Tokenized)')).toBe(
119-
'US Dollar',
116+
describe('formatOndoTokenName', () => {
117+
it('keeps the app-wide "(Ondo Tokenized)" suffix form unchanged', () => {
118+
expect(formatOndoTokenName('US Dollar (Ondo Tokenized)')).toBe(
119+
'US Dollar (Ondo Tokenized)',
120120
);
121121
});
122122

123-
it('strips "Ondo Tokenized " prefix (trending token API format)', () => {
124-
expect(sanitizeOndoTokenName('Ondo Tokenized Apple')).toBe('Apple');
125-
});
126-
127-
it('is case-insensitive', () => {
128-
expect(sanitizeOndoTokenName('Token (ondo tokenized)')).toBe('Token');
129-
});
130-
131-
it('truncates to 28 characters with ellipsis', () => {
132-
expect(sanitizeOndoTokenName('A Very Long Token Name That Exceeds')).toBe(
133-
'A Very Long Token Name That...',
123+
it('normalizes the "Ondo Tokenized " prefix form to the suffix form', () => {
124+
expect(formatOndoTokenName('Ondo Tokenized Apple')).toBe(
125+
'Apple (Ondo Tokenized)',
134126
);
135127
});
136128

137-
it('strips then truncates with ellipsis', () => {
138-
const long = 'Extremely Long Name Here That Keeps Going (Ondo Tokenized)';
139-
const result = sanitizeOndoTokenName(long);
140-
expect(result).toBe('Extremely Long Name Here Tha...');
141-
});
142-
143-
it('does not add ellipsis when exactly 28 characters', () => {
144-
expect(sanitizeOndoTokenName('1234567890123456789012345678')).toBe(
145-
'1234567890123456789012345678',
129+
it('normalizes the "Tokenized Ondo " prefix form to the suffix form', () => {
130+
expect(formatOndoTokenName('Tokenized Ondo Apple')).toBe(
131+
'Apple (Ondo Tokenized)',
146132
);
147133
});
148134

149-
it('returns the name unchanged when no stripping or truncation is needed', () => {
150-
expect(sanitizeOndoTokenName('OUSG')).toBe('OUSG');
135+
it('adds the suffix when the Ondo asset name has no marker', () => {
136+
expect(formatOndoTokenName('OUSG')).toBe('OUSG (Ondo Tokenized)');
151137
});
152138

153139
it('handles empty string', () => {
154-
expect(sanitizeOndoTokenName('')).toBe('');
140+
expect(formatOndoTokenName('')).toBe('');
155141
});
156142
});

app/components/UI/Rewards/components/Campaigns/OndoPortfolio.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export {
88
getChainHex,
99
shortenAddress,
1010
getAssetReference,
11-
sanitizeOndoTokenName,
11+
formatOndoTokenName,
1212
} from '../../utils/formatUtils';
1313

1414
/**

0 commit comments

Comments
 (0)