Skip to content

Commit 959d6fc

Browse files
authored
feat: Hide unverified badge for trusted programs (#766)
## Description Removed "unverified" badge for trusted programs. ## Type of change <!-- Check the appropriate options that apply to this PR --> - [x] Bug fix - [x] New feature - [ ] Protocol integration - [ ] Documentation update - [ ] Other (please describe): ## Screenshots <img width="1195" height="315" alt="localhost_3000_address_TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" src="https://github.com/user-attachments/assets/149c6f2f-c10b-44d4-9bcb-f01a6e81b98e" /> ## Testing - Visit http://localhost:3000/address/TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb - See no "unverified" badge ## Related Issues N/A ## Checklist <!-- Verify that you have completed the following before requesting review --> - [x] My code follows the project's style guidelines - [x] I have added tests that prove my fix/feature works - [x] All tests pass locally and in CI - [x] I have updated documentation as needed - [x] CI/CD checks pass - [x] I have included screenshots for protocol screens (if applicable) - [ ] For security-related features, I have included links to related information <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Hide "unverified" badge for trusted Solana programs in `ProgramHeader.tsx` and add tests in `AccountHeader.spec.tsx`. > > - **Behavior**: > - Hides "unverified" badge for trusted programs in `ProgramHeader.tsx` using `PROGRAMS_SKIP_UNVERIFIED_BADGE`. > - Trusted programs include 'Token Program', 'Token-2022 Program', and 'Associated Token Program'. > - Badge still shown for non-trusted programs. > - **Tests**: > - Added tests in `AccountHeader.spec.tsx` to verify badge is hidden for trusted programs and shown for others. > - Utilizes `PROGRAMS_SKIP_UNVERIFIED_BADGE` for test cases. > - **Misc**: > - Added `PROGRAMS_SKIP_UNVERIFIED_BADGE` constant to `ProgramHeader.tsx` to manage trusted programs. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=solana-foundation%2Fexplorer&utm_source=github&utm_medium=referral)<sup> for c490914. You can [customize](https://app.ellipsis.dev/solana-foundation/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent abe02ed commit 959d6fc

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

app/components/account/__tests__/AccountHeader.spec.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react';
44
import { vi } from 'vitest';
55

66
import { AccountHeader } from '@/app/components/account/AccountHeader';
7+
import { PROGRAMS_SKIP_UNVERIFIED_BADGE } from '@/app/components/shared/account/ProgramHeader';
78
import { useSecurityTxt } from '@/app/features/security-txt';
89
import { createNeodymeSecurityTxt, createPmpSecurityTxt } from '@/app/features/security-txt/ui/__tests__/helpers';
910
import type { Account, UpgradeableLoaderAccountData } from '@/app/providers/accounts';
@@ -157,6 +158,45 @@ describe('AccountHeader', () => {
157158

158159
expect(screen.getByText('Unverified')).toBeInTheDocument();
159160
});
161+
162+
describe('unverified badge for trusted programs', () => {
163+
it.each([...PROGRAMS_SKIP_UNVERIFIED_BADGE].map(([address, name]) => ({ address, name })))(
164+
'should not show unverified badge for $name even with securityTxt',
165+
({ address }) => {
166+
const pmpSecurityTxt = createPmpSecurityTxt();
167+
vi.mocked(useSecurityTxt).mockReturnValue(pmpSecurityTxt);
168+
169+
const account = setup().account;
170+
render(
171+
<AccountHeader
172+
address={address}
173+
account={account}
174+
tokenInfo={undefined}
175+
isTokenInfoLoading={false}
176+
/>
177+
);
178+
179+
expect(screen.queryByText('Unverified')).not.toBeInTheDocument();
180+
}
181+
);
182+
183+
it('should show unverified badge for non-trusted programs with securityTxt', () => {
184+
const pmpSecurityTxt = createPmpSecurityTxt();
185+
vi.mocked(useSecurityTxt).mockReturnValue(pmpSecurityTxt);
186+
187+
const { account, mockAddress } = setup();
188+
render(
189+
<AccountHeader
190+
address={mockAddress}
191+
account={account}
192+
tokenInfo={undefined}
193+
isTokenInfoLoading={false}
194+
/>
195+
);
196+
197+
expect(screen.getByText('Unverified')).toBeInTheDocument();
198+
});
199+
});
160200
});
161201
});
162202

app/components/shared/account/ProgramHeader.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ import { Badge } from '../ui/badge';
1313

1414
const IDENTICON_WIDTH = 64;
1515

16+
// The "unverified" badge indicates that the securityTxt metadata (name, logo, etc.)
17+
// is self-reported by the program author and may not be accurate. However, we trust
18+
// official Solana programs (e.g. spl-token, token-2022, associated token) even if they
19+
// have securityTxt, so we skip showing the badge for these trusted programs.
20+
export const PROGRAMS_SKIP_UNVERIFIED_BADGE = new Map([
21+
['TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', 'Token Program'],
22+
['TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb', 'Token-2022 Program'],
23+
['ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', 'Associated Token Program'],
24+
]);
25+
1626
export function ProgramHeader({ address, parsedData }: { address: string; parsedData: UpgradeableLoaderAccountData }) {
1727
const securityTxt = useSecurityTxt(address, parsedData);
1828

@@ -28,17 +38,20 @@ export function ProgramHeader({ address, parsedData }: { address: string; parsed
2838
unverified: undefined,
2939
};
3040
}
41+
42+
const shouldSkipUnverifiedBadge = PROGRAMS_SKIP_UNVERIFIED_BADGE.has(address);
43+
3144
if (isPmpSecurityTXT(securityTxt)) {
3245
return {
3346
logo: getProxiedUri(securityTxt.logo),
3447
programName: securityTxt.name,
35-
unverified: true,
48+
unverified: shouldSkipUnverifiedBadge ? false : true,
3649
version: securityTxt.version,
3750
};
3851
}
3952
return {
4053
programName: securityTxt.name,
41-
unverified: true,
54+
unverified: shouldSkipUnverifiedBadge ? false : true,
4255
};
4356
})();
4457

0 commit comments

Comments
 (0)