Adjust endpoint ui config with identityIcon (#9544)

* Adjust endpoint ui config with identityIcon

* Add defaults & missing package.json entry
This commit is contained in:
Jaco 2023-06-16 08:26:38 +03:00 committed by GitHub
parent 793159ea91
commit adb2c98bd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 28 additions and 8 deletions

View File

@ -38,6 +38,7 @@
"@polkadot/api": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@polkadot/networks": "^12.3.2",
"@polkadot/react-identicon": "^3.5.1",
"@polkadot/types": "^10.9.1",
"@polkadot/types-codec": "^10.9.1",
"@polkadot/util": "^12.3.2",

View File

@ -853,6 +853,7 @@ export const prodRelayKusama: EndpointOption = {
text: 'Kusama',
ui: {
color: '#000000',
identityIcon: 'polkadot',
logo: chainsKusamaSVG
}
};

View File

@ -740,6 +740,7 @@ export const prodRelayPolkadot: EndpointOption = {
text: 'Polkadot',
ui: {
color: '#e6007a',
identityIcon: 'polkadot',
logo: chainsPolkadotCircleSVG
}
};

View File

@ -699,6 +699,7 @@ export const testRelayRococo: EndpointOption = {
text: 'Rococo',
ui: {
color: '#6f36dc',
identityIcon: 'polkadot',
logo: chainsRococoSVG
}
};

View File

@ -195,6 +195,7 @@ export const testRelayWestend: EndpointOption = {
text: 'Westend',
ui: {
color: '#da68a7',
identityIcon: 'polkadot',
logo: nodesWestendColourSVG
}
};

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { IconTheme } from '@polkadot/react-identicon/types';
import type { HexString } from '@polkadot/util/types';
import type { Option } from '../settings/types.js';
@ -14,6 +15,7 @@ interface BaseOption {
teleport?: number[];
ui: {
color?: string;
identityIcon?: IconTheme;
logo?: string;
}
}

View File

@ -38,6 +38,14 @@ function expandLinked (input: LinkOption[]): LinkOption[] {
: undefined;
child.valueRelay = valueRelay;
if (entry.ui?.identityIcon && child.paraId && child.paraId < 2000) {
if (!child.ui) {
child.ui = { identityIcon: entry.ui.identityIcon };
} else if (!child.ui.identityIcon) {
child.ui.identityIcon = entry.ui.identityIcon;
}
}
return child;
})
)

View File

@ -18,10 +18,7 @@ export const identitySpec: Record<string, string> = [
['kusama', 'polkadot'],
['polkadot', 'polkadot'],
['rococo', 'polkadot'],
['statemine', 'polkadot'],
['statemint', 'polkadot'],
['westend', 'polkadot'],
['westmint', 'polkadot']
['westend', 'polkadot']
].reduce((icons, [spec, icon]): Record<string, string> => ({
...icons,
[spec.toLowerCase().replace(/-/g, ' ')]: icon

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { LinkOption } from '@polkadot/apps-config/endpoints/types';
import type { IdentityProps } from '@polkadot/react-identicon/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { ThemeProps } from '../types.js';
@ -25,8 +26,14 @@ interface Props {
value?: AccountId | AccountIndex | Address | string | Uint8Array | null;
}
export function getIdentityTheme (systemName: string, specName: string): 'substrate' {
return ((settings.icon === 'default' && getSystemIcon(systemName, specName)) || settings.icon) as 'substrate';
export function getIdentityTheme (apiEndpoint: LinkOption | null, systemName: string, specName: string): 'substrate' {
return (
(settings.icon === 'default' && (
apiEndpoint?.ui?.identityIcon ||
getSystemIcon(systemName, specName)
)) ||
settings.icon
) as 'substrate';
}
function isCodec (value?: AccountId | AccountIndex | Address | string | Uint8Array | null): value is AccountId | AccountIndex | Address {
@ -34,10 +41,10 @@ function isCodec (value?: AccountId | AccountIndex | Address | string | Uint8Arr
}
function IdentityIcon ({ className = '', forceIconType, prefix, size = 24, theme, value }: Props): React.ReactElement<Props> {
const { isEthereum, specName, systemName } = useApi();
const { apiEndpoint, isEthereum, specName, systemName } = useApi();
const { t } = useTranslation();
const { queueAction } = useQueue();
const thisTheme = theme || getIdentityTheme(systemName, specName);
const thisTheme = theme || getIdentityTheme(apiEndpoint, systemName, specName);
const Custom = thisTheme === 'robohash'
? RoboHash

View File

@ -1861,6 +1861,7 @@ __metadata:
"@polkadot/api": ^10.9.1
"@polkadot/api-derive": ^10.9.1
"@polkadot/networks": ^12.3.2
"@polkadot/react-identicon": ^3.5.1
"@polkadot/types": ^10.9.1
"@polkadot/types-codec": ^10.9.1
"@polkadot/util": ^12.3.2