Add chainType to chainInfo (#5766)
* add chainType * Update packages/page-settings/src/types.ts Co-authored-by: Jaco <jacogr@gmail.com> Co-authored-by: Jaco <jacogr@gmail.com>
This commit is contained in:
parent
3faf445e55
commit
e55a18689b
@ -3,6 +3,9 @@
|
||||
|
||||
import type { MetadataDef } from '@polkadot/extension-inject/types';
|
||||
|
||||
type ChainType = 'substrate' | 'ethereum';
|
||||
|
||||
export interface ChainInfo extends MetadataDef {
|
||||
color: string | undefined;
|
||||
chainType: ChainType;
|
||||
}
|
||||
|
||||
@ -12,9 +12,10 @@ import { useApi } from '@polkadot/react-hooks';
|
||||
import { getSpecTypes } from '@polkadot/types-known';
|
||||
import { formatBalance, isNumber } from '@polkadot/util';
|
||||
|
||||
function createInfo (api: ApiPromise, systemChain: string, systemName: string, specName: string): ChainInfo {
|
||||
function createInfo (api: ApiPromise, systemChain: string, systemName: string, specName: string, isEthereum: boolean): ChainInfo {
|
||||
return {
|
||||
chain: systemChain,
|
||||
chainType: isEthereum ? 'ethereum' : 'substrate',
|
||||
color: getSystemColor(systemChain, systemName, specName),
|
||||
genesisHash: api.genesisHash.toHex(),
|
||||
icon: getSystemIcon(systemName, specName),
|
||||
@ -28,12 +29,12 @@ function createInfo (api: ApiPromise, systemChain: string, systemName: string, s
|
||||
}
|
||||
|
||||
export default function useChainInfo (): ChainInfo | null {
|
||||
const { api, isApiReady, specName, systemChain, systemName } = useApi();
|
||||
const { api, isApiReady, isEthereum, specName, systemChain, systemName } = useApi();
|
||||
|
||||
return useMemo(
|
||||
() => isApiReady
|
||||
? createInfo(api, systemChain, systemName, specName)
|
||||
? createInfo(api, systemChain, systemName, specName, isEthereum)
|
||||
: null,
|
||||
[api, isApiReady, specName, systemChain, systemName]
|
||||
[api, isApiReady, specName, systemChain, systemName, isEthereum]
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user