Pull metadata decimals/ss58 from Api (#3879)
This commit is contained in:
parent
6003fa725a
commit
b84e0313a3
@ -7,7 +7,7 @@ import { useMemo } from 'react';
|
||||
|
||||
import { getSystemChainColor, getSystemIcon } from '@polkadot/apps-config/ui';
|
||||
import { getSpecTypes } from '@polkadot/types-known';
|
||||
import { registry } from '@polkadot/react-api';
|
||||
import { DEFAULT_DECIMALS, DEFAULT_SS58, registry } from '@polkadot/react-api';
|
||||
import { useApi } from '@polkadot/react-hooks';
|
||||
import { isNumber } from '@polkadot/util';
|
||||
|
||||
@ -23,8 +23,8 @@ export default function useChainInfo (): ChainInfo | null {
|
||||
icon: getSystemIcon(systemName),
|
||||
metaCalls: Buffer.from(api.runtimeMetadata.asCallsOnly.toU8a()).toString('base64'),
|
||||
specVersion: api.runtimeVersion.specVersion.toNumber(),
|
||||
ss58Format: isNumber(api.registry.chainSS58) ? api.registry.chainSS58 : 42,
|
||||
tokenDecimals: isNumber(api.registry.chainDecimals) ? api.registry.chainDecimals : 12,
|
||||
ss58Format: isNumber(api.registry.chainSS58) ? api.registry.chainSS58 : DEFAULT_SS58.toNumber(),
|
||||
tokenDecimals: isNumber(api.registry.chainDecimals) ? api.registry.chainDecimals : DEFAULT_DECIMALS.toNumber(),
|
||||
tokenSymbol: api.registry.chainToken || 'Unit',
|
||||
types: getSpecTypes(registry, systemChain, api.runtimeVersion.specName, api.runtimeVersion.specVersion) as unknown as Record<string, string>
|
||||
}
|
||||
|
||||
@ -51,8 +51,9 @@ interface ChainData {
|
||||
systemVersion: string;
|
||||
}
|
||||
|
||||
const DEFAULT_DECIMALS = registry.createType('u32', 15);
|
||||
const DEFAULT_SS58 = registry.createType('u32', addressDefaults.prefix);
|
||||
export const DEFAULT_DECIMALS = registry.createType('u32', 15);
|
||||
export const DEFAULT_SS58 = registry.createType('u32', addressDefaults.prefix);
|
||||
|
||||
const injectedPromise = web3Enable('polkadot-js/apps');
|
||||
let api: ApiPromise;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Api, { api } from './Api';
|
||||
import Api, { DEFAULT_DECIMALS, DEFAULT_SS58, api } from './Api';
|
||||
import ApiContext from './ApiContext';
|
||||
import { withApi, withCalls, withCallDiv, withMulti, withObservable } from './hoc';
|
||||
import { clearLedger, getLedger, isLedger, isLedgerCapable } from './ledger';
|
||||
@ -11,6 +11,8 @@ export {
|
||||
api,
|
||||
Api,
|
||||
ApiContext,
|
||||
DEFAULT_DECIMALS,
|
||||
DEFAULT_SS58,
|
||||
registry,
|
||||
withApi,
|
||||
withCalls,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user