From 6a469122215ddc4ffaf69e814193a78cb26c0994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Mon, 10 Jun 2024 00:08:19 +0200 Subject: [PATCH] fix silent publickey error --- components/MangoProvider.tsx | 3 ++- utils/governance/tools.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index 11f8714a..1974a9c0 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -30,6 +30,7 @@ import { notify } from 'utils/notifications' import { usePlausible } from 'next-plausible' import { TelemetryEvents } from 'utils/telemetry' import { groupBy, mapValues, maxBy, sampleSize } from 'lodash' +import { tryGetPubKey } from 'utils/governance/tools' const set = mangoStore.getState().set const actions = mangoStore.getState().actions @@ -228,7 +229,7 @@ const ReadOnlyMangoAccount = () => { async function loadUnownedMangoAccount() { try { - if (!ma || !group) return + if (!ma || !group || !tryGetPubKey(ma)) return const client = mangoStore.getState().client const pk = new PublicKey(ma) diff --git a/utils/governance/tools.ts b/utils/governance/tools.ts index 0bc2728c..b2588d6b 100644 --- a/utils/governance/tools.ts +++ b/utils/governance/tools.ts @@ -92,7 +92,7 @@ export function parseMintAccountData(data: Buffer): RawMint { export const fmtTokenAmount = (c: BN, decimals?: number) => c?.div(new BN(10).pow(new BN(decimals ?? 0))).toNumber() || 0 -export const tryGetPubKey = (pubkey: string) => { +export const tryGetPubKey = (pubkey: string | string[]) => { try { return new PublicKey(pubkey) } catch (e) {