Change ethereum icons based on URL; Fixes #9632 (#9694)

This commit is contained in:
Nikos Kontakis 2023-12-12 08:27:28 +02:00 committed by GitHub
parent b88b0af5b2
commit 48dafee047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,7 +132,7 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise<InjectedExten
};
}
async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, 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>>, urlIsEthereum = false): Promise<ApiState> {
statics.registry.register(types);
const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise);
@ -142,7 +142,7 @@ async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, inject
: settings.prefix;
const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]);
const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]);
const isEthereum = ethereumChains.includes(api.runtimeVersion.specName.toString());
const isEthereum = ethereumChains.includes(api.runtimeVersion.specName.toString()) || urlIsEthereum;
const isDevelopment = (systemChainType.isDevelopment || systemChainType.isLocal || isTestChain(systemChain));
console.log(`chain: ${systemChain} (${systemChainType.toString()}), ${stringify(properties)}`);
@ -299,7 +299,9 @@ export function ApiCtxRoot ({ apiUrl, children, isElectron, store }: Props): Rea
.then(setExtensions)
.catch(console.error);
loadOnReady(statics.api, apiEndpoint, injectedPromise, store, types)
const urlIsEthereum = !!location.href.includes('keyring-type=ethereum');
loadOnReady(statics.api, apiEndpoint, injectedPromise, store, types, urlIsEthereum)
.then(setState)
.catch(onError);
});