Workaround for Statemint deployment issues (#6634)

This commit is contained in:
Jaco 2021-12-05 14:16:19 +01:00 committed by GitHub
parent 03d53ce155
commit a5347ee87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
// Copyright 2017-2021 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { InjectedExtension } from '@polkadot/extension-inject/types';
import type { ChainProperties, ChainType } from '@polkadot/types/interfaces';
import type { KeyringStore } from '@polkadot/ui-keyring/types';
@ -21,7 +20,7 @@ import { StatusContext } from '@polkadot/react-components/Status';
import ApiSigner from '@polkadot/react-signer/signers/ApiSigner';
import { keyring } from '@polkadot/ui-keyring';
import { settings } from '@polkadot/ui-settings';
import { formatBalance, isTestChain, objectSpread } from '@polkadot/util';
import { formatBalance, isTestChain, objectSpread, stringify } from '@polkadot/util';
import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
import ApiContext from './ApiContext';
@ -99,8 +98,7 @@ async function getInjectedAccounts (injectedPromise: Promise<InjectedExtension[]
}
async function retrieve (api: ApiPromise, injectedPromise: Promise<InjectedExtension[]>): Promise<ChainData> {
const [chainProperties, systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([
api.rpc.system.properties(),
const [systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.chainType
? api.rpc.system.chainType()
@ -113,9 +111,9 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise<InjectedExten
return {
injectedAccounts,
properties: registry.createType('ChainProperties', {
ss58Format: api.consts.system?.ss58Prefix || chainProperties.ss58Format,
tokenDecimals: chainProperties.tokenDecimals,
tokenSymbol: chainProperties.tokenSymbol
ss58Format: api.registry.chainSS58,
tokenDecimals: api.registry.chainDecimals[0],
tokenSymbol: api.registry.chainTokens[0]
}),
systemChain: (systemChain || '<unknown>').toString(),
systemChainType,
@ -136,14 +134,14 @@ async function loadOnReady (api: ApiPromise, injectedPromise: Promise<InjectedEx
const isEthereum = ethereumChains.includes(api.runtimeVersion.specName.toString());
const isDevelopment = (systemChainType.isDevelopment || systemChainType.isLocal || isTestChain(systemChain));
console.log(`chain: ${systemChain} (${systemChainType.toString()}), ${JSON.stringify(properties)}`);
console.log(`chain: ${systemChain} (${systemChainType.toString()}), ${stringify(properties)}`);
// explicitly override the ss58Format as specified
registry.setChainProperties(registry.createType('ChainProperties', { ss58Format, tokenDecimals, tokenSymbol }));
// first setup the UI helpers
formatBalance.setDefaults({
decimals: (tokenDecimals as BN[]).map((b) => b.toNumber()),
decimals: tokenDecimals.map((b) => b.toNumber()),
unit: tokenSymbol[0].toString()
});
TokenUnit.setAbbr(tokenSymbol[0].toString());