From 4ce6f9a0d5585b73cfb026cf98ecac320598a7ff Mon Sep 17 00:00:00 2001 From: Evan Pipta Date: Wed, 28 Jul 2021 17:58:35 -0400 Subject: [PATCH] Fix "property x of undefined" error --- src/hooks/Serum/useSettleFunds.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/Serum/useSettleFunds.tsx b/src/hooks/Serum/useSettleFunds.tsx index aa533d3c..458436f9 100644 --- a/src/hooks/Serum/useSettleFunds.tsx +++ b/src/hooks/Serum/useSettleFunds.tsx @@ -30,8 +30,10 @@ export const useSettleFunds = ( useOwnedTokenAccounts() const openOrders = useSerumOpenOrderAccounts(serumMarketAddress, true) const serumMarket = serumMarkets[serumMarketAddress]?.serumMarket - const baseMintAddress = serumMarket.baseMintAddress.toString() - const quoteMintAddress = serumMarket.quoteMintAddress.toString() + const baseMintAddress = + serumMarket?.baseMintAddress && serumMarket.baseMintAddress.toString() + const quoteMintAddress = + serumMarket?.quoteMintAddress && serumMarket.quoteMintAddress.toString() const baseTokenAccounts = ownedTokenAccounts[baseMintAddress] ?? [] const quoteTokenAccounts = ownedTokenAccounts[quoteMintAddress] ?? [] const { pubKey: baseTokenAccountKey } = getHighestAccount(baseTokenAccounts) @@ -52,7 +54,7 @@ export const useSettleFunds = ( await createAssociatedTokenAccountInstruction({ payer: pubKey, owner: pubKey, - mintPublicKey: serumMarket.baseMintAddress, + mintPublicKey: serumMarket?.baseMintAddress, }) transaction.add(createOptAccountTx)