diff --git a/package-lock.json b/package-lock.json index 60378b8..ce83f43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9789,9 +9789,9 @@ } }, "color": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/color/-/color-4.2.1.tgz", - "integrity": "sha512-MFJr0uY4RvTQUKvPq7dh9grVOTYSFeXja2mBXioCGjnjJoXrAp9jJ1NQTDR73c9nwBSAQiNKloKl5zq9WB9UPw==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", "dev": true, "requires": { "color-convert": "^2.0.1", @@ -9829,9 +9829,9 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "color-string": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz", - "integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", "dev": true, "requires": { "color-name": "^1.0.0", @@ -26557,9 +26557,9 @@ } }, "cosmiconfig": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", - "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", + "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", "dev": true, "requires": { "@types/parse-json": "^4.0.0", @@ -26570,9 +26570,9 @@ } }, "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "requires": { "graceful-fs": "^4.2.0", @@ -26601,9 +26601,9 @@ } }, "lilconfig": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.5.tgz", - "integrity": "sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", + "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", "dev": true }, "parse-json": { diff --git a/public/image/acala.png b/public/image/acala.png new file mode 100644 index 0000000..07cc581 Binary files /dev/null and b/public/image/acala.png differ diff --git a/public/image/acurast.png b/public/image/acurast.png new file mode 100644 index 0000000..e74d75a Binary files /dev/null and b/public/image/acurast.png differ diff --git a/public/image/assethub-kusama-button-mobile.png b/public/image/assethub-kusama-button-mobile.png deleted file mode 100644 index 4f3697f..0000000 Binary files a/public/image/assethub-kusama-button-mobile.png and /dev/null differ diff --git a/public/image/assethub-kusama.png b/public/image/assethub-kusama.png new file mode 100644 index 0000000..56b5f87 Binary files /dev/null and b/public/image/assethub-kusama.png differ diff --git a/public/image/assethub-paseo-button-mobile.png b/public/image/assethub-paseo-button-mobile.png deleted file mode 100644 index a988e14..0000000 Binary files a/public/image/assethub-paseo-button-mobile.png and /dev/null differ diff --git a/public/image/assethub-paseo.png b/public/image/assethub-paseo.png new file mode 100644 index 0000000..4cec31d Binary files /dev/null and b/public/image/assethub-paseo.png differ diff --git a/public/image/assethub-polkadot-button-mobile.png b/public/image/assethub-polkadot-button-mobile.png deleted file mode 100644 index 4d65a43..0000000 Binary files a/public/image/assethub-polkadot-button-mobile.png and /dev/null differ diff --git a/public/image/assethub-polkadot.png b/public/image/assethub-polkadot.png new file mode 100644 index 0000000..d415026 Binary files /dev/null and b/public/image/assethub-polkadot.png differ diff --git a/public/image/astar.png b/public/image/astar.png new file mode 100644 index 0000000..b6b6b0f Binary files /dev/null and b/public/image/astar.png differ diff --git a/public/image/bifrost-kusama.png b/public/image/bifrost-kusama.png new file mode 100644 index 0000000..4bb1c2e Binary files /dev/null and b/public/image/bifrost-kusama.png differ diff --git a/public/image/bifrost.png b/public/image/bifrost.png new file mode 100644 index 0000000..9b484b7 Binary files /dev/null and b/public/image/bifrost.png differ diff --git a/public/image/coretime-kusama.png b/public/image/coretime-kusama.png new file mode 100644 index 0000000..56b5f87 Binary files /dev/null and b/public/image/coretime-kusama.png differ diff --git a/public/image/coretime-paseo.png b/public/image/coretime-paseo.png new file mode 100644 index 0000000..4cec31d Binary files /dev/null and b/public/image/coretime-paseo.png differ diff --git a/public/image/coretime-polkadot.png b/public/image/coretime-polkadot.png new file mode 100644 index 0000000..d415026 Binary files /dev/null and b/public/image/coretime-polkadot.png differ diff --git a/public/image/crust.png b/public/image/crust.png new file mode 100644 index 0000000..ebdc026 Binary files /dev/null and b/public/image/crust.png differ diff --git a/public/image/hydration.png b/public/image/hydration.png new file mode 100644 index 0000000..6fbefc9 Binary files /dev/null and b/public/image/hydration.png differ diff --git a/public/image/hyperbridge.png b/public/image/hyperbridge.png new file mode 100644 index 0000000..8834fcc Binary files /dev/null and b/public/image/hyperbridge.png differ diff --git a/public/image/pendulum.png b/public/image/pendulum.png new file mode 100644 index 0000000..6fb6c4b Binary files /dev/null and b/public/image/pendulum.png differ diff --git a/public/image/people-kusama.png b/public/image/people-kusama.png new file mode 100644 index 0000000..56b5f87 Binary files /dev/null and b/public/image/people-kusama.png differ diff --git a/public/image/people-paseo.png b/public/image/people-paseo.png new file mode 100644 index 0000000..4cec31d Binary files /dev/null and b/public/image/people-paseo.png differ diff --git a/public/image/people-polkadot.png b/public/image/people-polkadot.png new file mode 100644 index 0000000..d415026 Binary files /dev/null and b/public/image/people-polkadot.png differ diff --git a/public/image/xcavate.png b/public/image/xcavate.png new file mode 100644 index 0000000..13bd9e3 Binary files /dev/null and b/public/image/xcavate.png differ diff --git a/src/components/modals/SelectNetworkModal.tsx b/src/components/modals/SelectNetworkModal.tsx index c4c284e..7cd78ce 100644 --- a/src/components/modals/SelectNetworkModal.tsx +++ b/src/components/modals/SelectNetworkModal.tsx @@ -26,30 +26,57 @@ export const SelectNetworkModal = (props: SelectNetworkModalProps) => { return getThemeColor(network); }, [network]); - const networks = useMemo(() => { - const priorityOrder = ['assethub-polkadot', 'assethub-kusama', 'assethub-paseo']; + const networksByCategory = useMemo(() => { + const categoryOrder = ['polkadot', 'kusama', 'mainnet', 'paseo', 'testnet']; + const specialNetworkPrefixes = ['assethub', 'coretime', 'people']; + + const getNetworkTypeOrder = (name: string): number => { + const lowerName = name.toLowerCase(); + for (let i = 0; i < specialNetworkPrefixes.length; i++) { + if (lowerName.includes(specialNetworkPrefixes[i])) { + return i; + } + } + return specialNetworkPrefixes.length; + }; - // eslint-disable-next-line complexity - const compareNetworks = (a: NetConfigV2 | undefined, b: NetConfigV2 | undefined): number => { - const aIndex = priorityOrder.indexOf(a?.name || ''); - const bIndex = priorityOrder.indexOf(b?.name || ''); + const getCategoryIndex = (config: NetConfigV2): number => { + const category = config.category || 'mainnet'; + return categoryOrder.indexOf(category); + }; - if (aIndex !== -1 && bIndex !== -1) { - return aIndex - bIndex; - } + const compareByCategory = (a: NetConfigV2, b: NetConfigV2): number => { + return getCategoryIndex(a) - getCategoryIndex(b); + }; - if (aIndex !== -1) { - return -1; + const compareByType = (a: NetConfigV2, b: NetConfigV2): number => { + return getNetworkTypeOrder(a.name) - getNetworkTypeOrder(b.name); + }; + + const compareNetworks = (a: NetConfigV2, b: NetConfigV2): number => { + const categoryComparison = compareByCategory(a, b); + if (categoryComparison !== 0) { + return categoryComparison; } - if (bIndex !== -1) { - return 1; + const typeComparison = compareByType(a, b); + if (typeComparison !== 0) { + return typeComparison; } - return (a?.name || '').localeCompare(b?.name || ''); + return a.name.localeCompare(b.name); }; - return _.values(chains).sort(compareNetworks); + const sortedNetworks = _.values(chains) + .filter((item): item is NetConfigV2 => !!item) + .sort(compareNetworks); + + const grouped = categoryOrder.reduce((acc, category) => { + acc[category] = sortedNetworks.filter((item) => (item.category || 'mainnet') === category); + return acc; + }, {} as Record); + + return grouped; }, []); const [customNetworks, setCustomNetworks] = useState([]); @@ -116,7 +143,7 @@ export const SelectNetworkModal = (props: SelectNetworkModalProps) => { destroyOnClose onCancel={props.onCancel} closable={false} - width={620} + width={760} bodyStyle={{ paddingLeft: '20px', paddingRight: '20px', @@ -126,10 +153,10 @@ export const SelectNetworkModal = (props: SelectNetworkModalProps) => { {addCustomNetworkVisible ? ( setAddCustomNetworkVisible(false)} editNetwork={editingNetwork} /> ) : ( -
+
- {t('mainnet')} + {t('network')}
@@ -137,48 +164,47 @@ export const SelectNetworkModal = (props: SelectNetworkModalProps) => {
-
- {networks - .filter((item) => !item?.isTestnet) - .filter((item) => !!item) - .map((item) => ( -
selectPresetNetwork(item)} - > - logo - -
- {item?.displayName || item?.name} +
+ {['polkadot', 'kusama', 'mainnet', 'paseo', 'testnet'].map((category) => { + const categoryNetworks = networksByCategory[category] || []; + if (categoryNetworks.length === 0) return null; + + const getCategoryLabel = (cat: string) => { + const labels: Record = { + polkadot: 'Polkadot', + kusama: 'Kusama', + mainnet: 'Mainnet', + paseo: 'Paseo', + testnet: 'Testnet', + }; + return labels[cat] || cat; + }; + + return ( +
+
+ {getCategoryLabel(category)}
-
- ))} -
- -
- {t('testnet')} -
- -
- -
- {networks - .filter((item) => item?.isTestnet) - .filter((item) => !!item) - .map((item) => ( -
selectPresetNetwork(item)} - > - logo +
+ +
+ {categoryNetworks.map((item) => ( +
selectPresetNetwork(item)} + > + logo -
- {item?.displayName || item?.name} +
+ {item.displayName || item.name} +
+
+ ))}
- ))} + ); + })}
diff --git a/src/config/chains/acurast.json b/src/config/chains/acurast.json new file mode 100644 index 0000000..dfe0a56 --- /dev/null +++ b/src/config/chains/acurast.json @@ -0,0 +1,12 @@ +{ + "name": "acurast", + "displayName": "Acurast Mainnet", + "rpc": "wss://public-rpc.mainnet.acurast.com/", + "api": { + "subql": "" + }, + "category": "mainnet", + "logo": "/image/acurast.png", + "explorerHostName": "acurast", + "themeColor": "#000000" +} diff --git a/src/config/chains/assethub_kusama.json b/src/config/chains/assethub_kusama.json index 9ca9476..e30e0dc 100644 --- a/src/config/chains/assethub_kusama.json +++ b/src/config/chains/assethub_kusama.json @@ -6,7 +6,8 @@ "subql": "", "subscan": "https://assethub-kusama.webapi.subscan.io" }, - "logo": "/image/assethub-kusama-button-mobile.png", + "category": "kusama", + "logo": "/image/assethub-kusama.png", "explorerHostName": "assethub-kusama", "themeColor": "#000000" } diff --git a/src/config/chains/assethub_paseo.json b/src/config/chains/assethub_paseo.json index 08b0692..921d501 100644 --- a/src/config/chains/assethub_paseo.json +++ b/src/config/chains/assethub_paseo.json @@ -6,7 +6,8 @@ "subql": "", "subscan": "https://assethub-paseo.webapi.subscan.io" }, - "logo": "/image/assethub-paseo-button-mobile.png", + "category": "paseo", + "logo": "/image/assethub-paseo.png", "explorerHostName": "assethub-paseo", "themeColor": "#38393F" } diff --git a/src/config/chains/assethub_polkadot.json b/src/config/chains/assethub_polkadot.json index 7575e71..5a0a34e 100644 --- a/src/config/chains/assethub_polkadot.json +++ b/src/config/chains/assethub_polkadot.json @@ -6,7 +6,8 @@ "subql": "", "subscan": "https://assethub-polkadot.webapi.subscan.io" }, - "logo": "/image/assethub-polkadot-button-mobile.png", + "category": "polkadot", + "logo": "/image/assethub-polkadot.png", "explorerHostName": "assethub-polkadot", "themeColor": "#E90979" } diff --git a/src/config/chains/astar.json b/src/config/chains/astar.json new file mode 100644 index 0000000..a583c90 --- /dev/null +++ b/src/config/chains/astar.json @@ -0,0 +1,13 @@ +{ + "name": "astar", + "displayName": "Astar", + "rpc": "wss://astar-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://astar.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/astar.png", + "explorerHostName": "astar", + "themeColor": "#694EA4" +} diff --git a/src/config/chains/bifrost.json b/src/config/chains/bifrost.json new file mode 100644 index 0000000..a744207 --- /dev/null +++ b/src/config/chains/bifrost.json @@ -0,0 +1,13 @@ +{ + "name": "bifrost", + "displayName": "Bifrost", + "rpc": "wss://hk.p.bifrost-rpc.liebi.com/ws", + "api": { + "subql": "", + "subscan": "https://bifrost.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/bifrost.png", + "explorerHostName": "bifrost", + "themeColor": "#5a25f0" +} diff --git a/src/config/chains/coretime_kusama.json b/src/config/chains/coretime_kusama.json new file mode 100644 index 0000000..dca4f62 --- /dev/null +++ b/src/config/chains/coretime_kusama.json @@ -0,0 +1,13 @@ +{ + "name": "coretime-kusama", + "displayName": "Coretime Kusama", + "rpc": "wss://coretime-kusama-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://coretime-kusama.webapi.subscan.io" + }, + "category": "kusama", + "logo": "/image/coretime-kusama.png", + "explorerHostName": "coretime-kusama", + "themeColor": "#000000" +} diff --git a/src/config/chains/coretime_paseo.json b/src/config/chains/coretime_paseo.json new file mode 100644 index 0000000..3293de5 --- /dev/null +++ b/src/config/chains/coretime_paseo.json @@ -0,0 +1,13 @@ +{ + "name": "coretime-paseo", + "displayName": "Coretime Paseo", + "rpc": "wss://sys.ibp.network/coretime-paseo", + "api": { + "subql": "", + "subscan": "https://coretime-paseo.webapi.subscan.io" + }, + "category": "paseo", + "logo": "/image/coretime-paseo.png", + "explorerHostName": "coretime-paseo", + "themeColor": "#000000" +} diff --git a/src/config/chains/coretime_polkadot.json b/src/config/chains/coretime_polkadot.json new file mode 100644 index 0000000..b3091df --- /dev/null +++ b/src/config/chains/coretime_polkadot.json @@ -0,0 +1,13 @@ +{ + "name": "coretime-polkadot", + "displayName": "Coretime Polkadot", + "rpc": "wss://coretime-polkadot-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://coretime-polkadot.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/coretime-polkadot.png", + "explorerHostName": "coretime-polkadot", + "themeColor": "#0F0F0F" +} diff --git a/src/config/chains/heiko.json b/src/config/chains/heiko.json index 9189e20..2674cce 100644 --- a/src/config/chains/heiko.json +++ b/src/config/chains/heiko.json @@ -5,6 +5,7 @@ "api": { "subql": "" }, + "category": "kusama", "logo": "/image/parallel.svg", "explorerHostName": "parallel-heiko", "themeColor": "#42d5de" diff --git a/src/config/chains/hydration.json b/src/config/chains/hydration.json new file mode 100644 index 0000000..6cb6f8a --- /dev/null +++ b/src/config/chains/hydration.json @@ -0,0 +1,13 @@ +{ + "name": "hydration", + "displayName": "Hydration", + "rpc": "wss://hydration-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://hydration.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/hydration.png", + "explorerHostName": "hydration", + "themeColor": "#E53E76" +} diff --git a/src/config/chains/hyperbridge.json b/src/config/chains/hyperbridge.json new file mode 100644 index 0000000..f7731cc --- /dev/null +++ b/src/config/chains/hyperbridge.json @@ -0,0 +1,12 @@ +{ + "name": "hyperbridge", + "displayName": "Hyperbridge (Nexus)", + "rpc": "wss://nexus.ibp.network", + "api": { + "subql": "" + }, + "category": "polkadot", + "logo": "/image/hyperbridge.png", + "explorerHostName": "hyperbridge", + "themeColor": "#ED6FF1" +} diff --git a/src/config/chains/interlay.json b/src/config/chains/interlay.json index d638d7f..f5323ff 100644 --- a/src/config/chains/interlay.json +++ b/src/config/chains/interlay.json @@ -5,6 +5,7 @@ "api": { "subql": "" }, + "category": "polkadot", "logo": "/image/interlay.png", "explorerHostName": "interlay", "themeColor": "#075ABC" diff --git a/src/config/chains/kintsugi.json b/src/config/chains/kintsugi.json index 35db96a..32673ac 100644 --- a/src/config/chains/kintsugi.json +++ b/src/config/chains/kintsugi.json @@ -5,6 +5,7 @@ "api": { "subql": "" }, + "category": "kusama", "logo": "/image/kintsugi.png", "explorerHostName": "kintsugi", "themeColor": "#041333" diff --git a/src/config/chains/parallel.json b/src/config/chains/parallel.json index e582b1e..4dcdb7f 100644 --- a/src/config/chains/parallel.json +++ b/src/config/chains/parallel.json @@ -5,6 +5,7 @@ "api": { "subql": "" }, + "category": "polkadot", "logo": "/image/parallel.svg", "explorerHostName": "parallel", "themeColor": "#ef18ac" diff --git a/src/config/chains/pendulum.json b/src/config/chains/pendulum.json new file mode 100644 index 0000000..3d5f006 --- /dev/null +++ b/src/config/chains/pendulum.json @@ -0,0 +1,13 @@ +{ + "name": "pendulum", + "displayName": "Pendulum", + "rpc": "wss://rpc-pendulum.prd.pendulumchain.tech", + "api": { + "subql": "", + "subscan": "https://pendulum.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/pendulum.png", + "explorerHostName": "pendulum", + "themeColor": "#32253E" +} diff --git a/src/config/chains/people_kusama.json b/src/config/chains/people_kusama.json new file mode 100644 index 0000000..b28f135 --- /dev/null +++ b/src/config/chains/people_kusama.json @@ -0,0 +1,13 @@ +{ + "name": "people-kusama", + "displayName": "People Kusama", + "rpc": "wss://people-kusama-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://people-kusama.webapi.subscan.io" + }, + "category": "kusama", + "logo": "/image/people-kusama.png", + "explorerHostName": "people-kusama", + "themeColor": "#000000" +} diff --git a/src/config/chains/people_paseo.json b/src/config/chains/people_paseo.json new file mode 100644 index 0000000..1563cdc --- /dev/null +++ b/src/config/chains/people_paseo.json @@ -0,0 +1,13 @@ +{ + "name": "people-paseo", + "displayName": "People Paseo", + "rpc": "wss://sys.ibp.network/people-paseo", + "api": { + "subql": "", + "subscan": "https://people-paseo.webapi.subscan.io" + }, + "category": "paseo", + "logo": "/image/people-paseo.png", + "explorerHostName": "people-paseo", + "themeColor": "#000000" +} diff --git a/src/config/chains/people_polkadot.json b/src/config/chains/people_polkadot.json new file mode 100644 index 0000000..6f7de55 --- /dev/null +++ b/src/config/chains/people_polkadot.json @@ -0,0 +1,13 @@ +{ + "name": "people-polkadot", + "displayName": "People Polkadot", + "rpc": "wss://people-polkadot-rpc.n.dwellir.com", + "api": { + "subql": "", + "subscan": "https://people-polkadot.webapi.subscan.io" + }, + "category": "polkadot", + "logo": "/image/people-polkadot.png", + "explorerHostName": "people-polkadot", + "themeColor": "#0F0F0F" +} diff --git a/src/config/chains/xcavate.json b/src/config/chains/xcavate.json new file mode 100644 index 0000000..4dc0248 --- /dev/null +++ b/src/config/chains/xcavate.json @@ -0,0 +1,12 @@ +{ + "name": "xcavate", + "displayName": "Xcavate", + "rpc": "wss://xcavate.ibp.network", + "api": { + "subql": "" + }, + "category": "polkadot", + "logo": "/image/xcavate.png", + "explorerHostName": "xcavate", + "themeColor": "#FF0083" +} diff --git a/src/model/network.ts b/src/model/network.ts index bbcc363..2eca54d 100644 --- a/src/model/network.ts +++ b/src/model/network.ts @@ -38,6 +38,7 @@ export interface NetConfigV2 { displayName: string; rpc: string; isTestnet?: boolean; + category?: string; logo?: string; api?: Api; explorerHostName?: string; diff --git a/src/providers/api-provider.tsx b/src/providers/api-provider.tsx index b02e562..10e5246 100644 --- a/src/providers/api-provider.tsx +++ b/src/providers/api-provider.tsx @@ -161,128 +161,60 @@ export const ApiProvider = ({ children }: React.PropsWithChildren) => { const url = selectedNetwork.rpc; const provider = new WsProvider(url); - const nApi = new ApiPromise({ - provider, - // typesBundle, - typesBundle: { - chain: { - Polkadot: { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], - }, - Kusama: { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], - }, - // rpc call - system (chain) - 'Paseo Testnet': { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], - }, - 'Polkadot Asset Hub': { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], - }, - 'Kusama Asset Hub': { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], - }, - 'Paseo Asset Hub': { - types: [ - { - // eslint-disable-next-line no-magic-numbers - minmax: [0, undefined], - types: { - WeightV1: 'u64', - WeightV2: { - refTime: 'Compact', - proofSize: 'Compact', - }, - Weight: { - refTime: 'Compact', - proofSize: 'Compact', - }, - }, - }, - ], + + const commonWeightTypes = { + types: [ + { + // eslint-disable-next-line no-magic-numbers + minmax: [0, undefined], + types: { + WeightV1: 'u64', + WeightV2: { + refTime: 'Compact', + proofSize: 'Compact', + }, + Weight: { + refTime: 'Compact', + proofSize: 'Compact', + }, }, }, - }, + ], + }; + + const chainNames = [ + 'Polkadot', + 'Kusama', + 'Paseo Testnet', + 'Polkadot Asset Hub', + 'Kusama Asset Hub', + 'Paseo Asset Hub', + 'Kusama Coretime', + 'Polkadot Coretime', + 'Paseo Coretime', + 'Kusama People', + 'Polkadot People', + 'Paseo People', + 'Acala', + 'Acurast Mainnet', + 'Astar', + 'Bifrost Polkadot', + 'Crust', + 'Hydration', + 'Hyperbridge (Nexus)', + 'Interlay', + 'kintsugi', + 'Pendulum', + 'Xcavate', + ]; + + const typesBundle = { + chain: chainNames.reduce((acc, name) => ({ ...acc, [name]: commonWeightTypes }), {}), + }; + + const nApi = new ApiPromise({ + provider, + typesBundle, typesChain, });