Adjust extension list typings (#8074)

This commit is contained in:
Jaco 2022-08-31 09:35:37 +02:00 committed by GitHub
parent 04651fc56e
commit c7641aa27e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
// Copyright 2017-2022 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
// it would have been really good to import this from detect-browser, however... not exported
type Browser = 'chrome' | 'firefox';
interface Extension {
@ -10,21 +9,30 @@ interface Extension {
name: string;
}
interface Known {
all: Record<Browser, string>;
desc: string;
name: string;
}
// The list of known extensions including the links to tem on the store. This is used when
// no extensions are actually available, promoting the user to install one or more
// (Any known extension can and should be added here)
export const availableExtensions: Record<Browser, Extension[]> = [
const known: Known[] = [
{
browsers: {
all: {
chrome: 'https://chrome.google.com/webstore/detail/polkadot%7Bjs%7D-extension/mopnmbcafieddcagagdcbnhejhlodfdd',
firefox: 'https://addons.mozilla.org/en-US/firefox/addon/polkadot-js-extension/'
},
desc: 'Basic account injection and signer',
name: 'polkadot-js extension'
}
].reduce((available: Record<Browser, Extension[]>, { browsers, desc, name }): Record<Browser, Extension[]> => {
Object.entries(browsers).forEach(([browser, link]): void => {
available[browser as 'chrome'].push({ desc, link, name });
];
export const availableExtensions = known.reduce<Record<Browser, Extension[]>>((available, { all, desc, name }) => {
Object.entries(all).forEach(([browser, link]): void => {
available[browser as Browser].push({ desc, link, name });
});
return available;