Relay accounts on common-good & system paras (#6740)

* Relay accounts on common-good & system paras

* Revert useEndpoint

* Add relay values to current

* Ordering
This commit is contained in:
Jaco 2022-01-18 11:15:19 +01:00 committed by GitHub
parent 21a772414e
commit 0d74428624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,12 @@
# CHANGELOG
## master
Changes:
- Make relay accounts visible on common-good & system parachains
## 0.102.1 Jan 17, 2022
Contributed:

View File

@ -1,6 +1,7 @@
// Copyright 2017-2022 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { LinkOption } from '@polkadot/apps-config/endpoints/types';
import type { InjectedExtension } from '@polkadot/extension-inject/types';
import type { ChainProperties, ChainType } from '@polkadot/types/interfaces';
import type { KeyringStore } from '@polkadot/ui-keyring/types';
@ -122,7 +123,7 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise<InjectedExten
};
}
async function loadOnReady (api: ApiPromise, injectedPromise: Promise<InjectedExtension[]>, store: KeyringStore | undefined, types: Record<string, Record<string, string>>): Promise<ApiState> {
async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, injectedPromise: Promise<InjectedExtension[]>, store: KeyringStore | undefined, types: Record<string, Record<string, string>>): Promise<ApiState> {
registry.register(types);
const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise);
@ -149,6 +150,9 @@ async function loadOnReady (api: ApiPromise, injectedPromise: Promise<InjectedEx
// finally load the keyring
isKeyringLoaded() || keyring.loadAll({
genesisHash: api.genesisHash,
genesisHashAdd: endpoint && isNumber(endpoint.paraId) && (endpoint.paraId < 2000) && endpoint.genesisHashRelay
? [endpoint.genesisHashRelay]
: [],
isDevelopment,
ss58Format,
store,
@ -226,7 +230,7 @@ function Api ({ apiUrl, children, isElectron, store }: Props): React.ReactElemen
.then(setExtensions)
.catch(console.error);
loadOnReady(api, injectedPromise, store, types)
loadOnReady(api, apiEndpoint, injectedPromise, store, types)
.then(setState)
.catch((error): void => {
console.error(error);
@ -236,7 +240,7 @@ function Api ({ apiUrl, children, isElectron, store }: Props): React.ReactElemen
});
setIsApiInitialized(true);
}, [apiUrl, queuePayload, queueSetTxStatus, store]);
}, [apiEndpoint, apiUrl, queuePayload, queueSetTxStatus, store]);
if (!value.isApiInitialized) {
return null;

View File

@ -23,6 +23,7 @@ export { useDebounce } from './useDebounce';
export { useDelegations } from './useDelegations';
export { useDeriveAccountFlags } from './useDeriveAccountFlags';
export { useDeriveAccountInfo } from './useDeriveAccountInfo';
export { useElementPosition } from './useElementPosition';
export { useEndpoint } from './useEndpoint';
export { useEventTrigger } from './useEventTrigger';
export { useExtrinsicTrigger } from './useExtrinsicTrigger';
@ -43,16 +44,20 @@ export { useNonZeroBn } from './useNonZeroBn';
export { useOwnEraRewards } from './useOwnEraRewards';
export { useOwnStashes, useOwnStashIds } from './useOwnStashes';
export { useOwnStashInfos } from './useOwnStashInfos';
export { useOutsideClick } from './useOutsideClick';
export { useParaApi } from './useParaApi';
export { usePopupWindow } from './usePopupWindow';
export { useProxies } from './useProxies';
export { useIsParasLinked, useParaEndpoints } from './useParaEndpoints';
export { usePassword } from './usePassword';
export { useRegistrars } from './useRegistrars';
export { useSavedFlags } from './useSavedFlags';
export { useScroll } from './useScroll';
export { useSubidentities } from './useSubidentities';
export { useStakingInfo } from './useStakingInfo';
export { useStepper } from './useStepper';
export { useSudo } from './useSudo';
export { useSystemApi } from './useSystemApi';
export { useTeleport } from './useTeleport';
export { useToggle } from './useToggle';
export { useTreasury } from './useTreasury';
@ -60,9 +65,4 @@ export { useTxBatch } from './useTxBatch';
export { useVotingStatus } from './useVotingStatus';
export { useWeight } from './useWeight';
export { useWeightFee } from './useWeightFee';
export { useElementPosition } from './useElementPosition';
export { useScroll } from './useScroll';
export { useSystemApi } from './useSystemApi';
export { useWindowSize } from './useWindowSize';
export { useOutsideClick } from './useOutsideClick';
export { usePopupWindow } from './usePopupWindow';