-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1576 from oasisprotocol/mz/validatorNames
Show validator name instead of an address
- Loading branch information
Showing
8 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
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 @@ | ||
Show validator name instead of an address |
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,34 @@ | ||
import { FC } from 'react' | ||
import { Layer, useGetConsensusValidatorsAddressNameMap } from './../../../oasis-nexus/api' | ||
import { Network } from '../../../types/network' | ||
import { ValidatorLink } from '../Validators/ValidatorLink' | ||
import { AccountLink } from './AccountLink' | ||
|
||
type ConsensusAccountLinkProps = { | ||
address: string | ||
alwaysTrim?: boolean | ||
labelOnly?: boolean | ||
network: Network | ||
} | ||
|
||
export const ConsensusAccountLink: FC<ConsensusAccountLinkProps> = ({ | ||
address, | ||
alwaysTrim = true, | ||
labelOnly, | ||
network, | ||
}) => { | ||
const { data } = useGetConsensusValidatorsAddressNameMap(network) | ||
|
||
if (data?.data?.[address]) { | ||
return <ValidatorLink address={address} network={network} alwaysTrim={alwaysTrim} /> | ||
} | ||
|
||
return ( | ||
<AccountLink | ||
labelOnly={labelOnly} | ||
scope={{ network, layer: Layer.consensus }} | ||
address={address} | ||
alwaysTrim={alwaysTrim} | ||
/> | ||
) | ||
} |
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,9 @@ | ||
import { Network } from 'types/network' | ||
import { useGetConsensusValidatorsAddressNameMap } from '../../oasis-nexus/api' | ||
|
||
export const useValidatorName = (network: Network, address: string): string | undefined => { | ||
const { data } = useGetConsensusValidatorsAddressNameMap(network) | ||
const validatorName = data?.data?.[address] | ||
|
||
return validatorName | ||
} |
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