From 6389c4737311df36acf20af0903b5ed9bbd510f0 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Tue, 10 May 2022 00:48:34 +0200 Subject: [PATCH] Only show hardcoded paratimes --- src/background/api/index.js | 4 +++- src/reducers/accountReducer.js | 1 + src/utils/utils.js | 5 +---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/background/api/index.js b/src/background/api/index.js index dd06c1ba..1922d75e 100644 --- a/src/background/api/index.js +++ b/src/background/api/index.js @@ -1,6 +1,6 @@ import * as oasis from "@oasisprotocol/client"; import { cointypes, TX_LIST_LENGTH } from "../../../config"; -import { amountDecimals, isNumber } from "../../utils/utils"; +import { amountDecimals, getRuntimeConfig, isNumber } from "../../utils/utils"; import { commonFetch, getOasisClient } from "./request"; import { getRpcAccount } from "./rpc"; import * as oasisRT from "@oasisprotocol/client-rt"; @@ -186,6 +186,8 @@ export async function getRpcRuntimeList() { const runtime = runtimeList[index]; let id = runtime.id; let runtimeId = oasis.misc.toHex(id); + let runtimeConfig = getRuntimeConfig(runtimeId); + if (!runtimeConfig) continue; // Only keep runtimes from PARATIME_CONFIG list.push({ name: "unknown", runtimeId: runtimeId, diff --git a/src/reducers/accountReducer.js b/src/reducers/accountReducer.js index 5eb1e3a6..3407022b 100644 --- a/src/reducers/accountReducer.js +++ b/src/reducers/accountReducer.js @@ -153,6 +153,7 @@ const setRuntimeName=(currentAccount,runtimeList)=>{ for (let index = 0; index < runtimeList.length; index++) { let runtime = runtimeList[index]; let runtimeConfig = getRuntimeConfig(runtime.runtimeId) + if (!runtimeConfig) continue // Only keep runtimes from PARATIME_CONFIG let isEmerald = runtimeConfig.accountType === RUNTIME_ACCOUNT_TYPE.EVM let config = { ...runtime, diff --git a/src/utils/utils.js b/src/utils/utils.js index 207575f0..9843ef32 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -304,19 +304,16 @@ export async function getEvmBech32Address(evmAddress){ * @returns */ export function getRuntimeConfig(runtimeId){ - let runtimeConfig = {} for (let index = 0; index < PARATIME_CONFIG.length; index++) { const runtime = PARATIME_CONFIG[index]; let runtimeIdList = runtime.runtimeIdList for (let j = 0; j < runtimeIdList.length; j++) { let config = runtimeIdList[j] if(runtimeId === config.runtimeId){ - runtimeConfig = runtime - return runtimeConfig + return runtime } } } - return runtimeConfig } /**