Skip to content

Commit

Permalink
chore: try/catch exceptions, skip banks missing data rather than error
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 21, 2023
1 parent 7906cfd commit 10684fb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ const stateCreator: StateCreator<MrgnlendState, [], []> = (set, get) => ({
return;
}

const tokenMetadata = getValueInsensitive(tokenMetadataMap, bankMetadata.tokenSymbol);
if (!tokenMetadata) {
return;
}
try {
const tokenMetadata = getValueInsensitive(tokenMetadataMap, bankMetadata.tokenSymbol);
if (!tokenMetadata) {
return;
}

banksWithPriceAndToken.push({ bank, oraclePrice, tokenMetadata });
banksWithPriceAndToken.push({ bank, oraclePrice, tokenMetadata });
} catch (err) {
console.error("error fetching token metadata: ", err);
}
});

const [extendedBankInfos, extendedBankMetadatas] = banksWithPriceAndToken.reduce(
Expand All @@ -185,7 +189,9 @@ const stateCreator: StateCreator<MrgnlendState, [], []> = (set, get) => ({
let userData;
if (wallet?.publicKey) {
const tokenAccount = tokenAccountMap!.get(bank.mint.toBase58());
if (!tokenAccount) throw new Error(`Token account not found for ${bank.mint.toBase58()}`);
if (!tokenAccount) {
return acc;
}
userData = {
nativeSolBalance,
tokenAccount,
Expand Down

2 comments on commit 10684fb

@vercel
Copy link

@vercel vercel bot commented on 10684fb Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

omni – ./apps/omni

omni-mrgn.vercel.app
omni-git-production-mrgn.vercel.app
omni-one.vercel.app
omni.marginfi.com

@vercel
Copy link

@vercel vercel bot commented on 10684fb Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.