-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
115 additions
and
57 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[ | ||
{ | ||
{ | ||
"0xef268b5C05452D63a17Da12f562368e88a036Ef1": { | ||
"name": "Celo Whale", | ||
"address": "0xef268b5C05452D63a17Da12f562368e88a036Ef1", | ||
"logoUri": "/logos/delegatees/default.svg", | ||
"date": "2024-03-08", | ||
"links": { | ||
"website": "https://celowhale.com", | ||
"twitter": "https://twitter.com/celowhale", | ||
"github": "https://twitter.com/celowhale" | ||
"website": "https://www.google.com/search?q=whale", | ||
"twitter": "https://twitter.com", | ||
"github": "https://github.com" | ||
}, | ||
"interests": ["Fish", "Water", "Swimming"], | ||
"description": "An unknown Celo whale account. One of the largest CELO holders in the world." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ImageOrIdenticon } from 'src/components/icons/Identicon'; | ||
import { getDelegateeMetadata } from 'src/features/delegation/delegateeMetadata'; | ||
import { shortenAddress } from 'src/utils/addresses'; | ||
|
||
export function DelegateeLogo({ address, size }: { address: Address; size: number }) { | ||
const metadata = getDelegateeMetadata(); | ||
const imgSrc = metadata[address]?.logoUri; | ||
return <ImageOrIdenticon imgSrc={imgSrc} address={address} size={size} />; | ||
} | ||
|
||
export function DelegateeLogoAndName({ | ||
address, | ||
name, | ||
size = 30, | ||
className, | ||
}: { | ||
address: Address; | ||
name?: string; | ||
size?: number; | ||
className?: string; | ||
}) { | ||
return ( | ||
<div className={`flex items-center ${className}`}> | ||
<DelegateeLogo address={address} size={size} /> | ||
<div className="ml-2 flex flex-col"> | ||
<span>{name || 'Unknown Delegate'}</span> | ||
<span className="font-mono text-xs text-taupe-600">{shortenAddress(address)}</span> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import DelegateeJsonData from 'src/config/delegates.json'; | ||
import { DelegateeMetadata, DelegateeMetadataMapSchema } from 'src/features/delegation/types'; | ||
import { logger } from 'src/utils/logger'; | ||
|
||
let cachedMetadata: AddressTo<DelegateeMetadata>; | ||
|
||
export function getDelegateeMetadata(): AddressTo<DelegateeMetadata> { | ||
if (!cachedMetadata) { | ||
cachedMetadata = parseDelegateeMetadata(); | ||
} | ||
return cachedMetadata; | ||
} | ||
|
||
function parseDelegateeMetadata(): AddressTo<DelegateeMetadata> { | ||
try { | ||
return DelegateeMetadataMapSchema.parse(DelegateeJsonData); | ||
} catch (error) { | ||
logger.error('Error parsing delegatee metadata', error); | ||
throw new Error('Invalid delegatee metadata'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters