From 7bdd91fe24b82d677fc97e317c049a7c8a0b695e Mon Sep 17 00:00:00 2001 From: chambaz Date: Tue, 10 Sep 2024 15:20:49 -0400 Subject: [PATCH] feat: store wallet pk as custom prop --- apps/marginfi-v2-trading/src/context/TradeProvider.tsx | 8 +++++++- apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/marginfi-v2-trading/src/context/TradeProvider.tsx b/apps/marginfi-v2-trading/src/context/TradeProvider.tsx index ba0d2fe48b..3b855a8276 100644 --- a/apps/marginfi-v2-trading/src/context/TradeProvider.tsx +++ b/apps/marginfi-v2-trading/src/context/TradeProvider.tsx @@ -46,8 +46,14 @@ export const TradePovider: React.FC<{ trackReferral(referralCode, wallet.publicKey.toBase58()); if (!isLoggedIn && wallet.publicKey) { + const walletAddress = wallet.publicKey.toBase58(); setIsLoggedIn(true); - identify(wallet.publicKey.toBase58()); + + if (!walletAddress) return; + + identify(walletAddress, { + wallet: walletAddress, + }); } }, [router.asPath, wallet, connected, isLoggedIn]); diff --git a/apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx b/apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx index 826c20790c..41de321b8b 100644 --- a/apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx +++ b/apps/marginfi-v2-ui/src/context/MrgnlendProvider.tsx @@ -24,7 +24,11 @@ export const MrgnlendProvider: React.FC<{ // identify user if logged in React.useEffect(() => { - identify(wallet.publicKey.toBase58()); + const walletAddress = wallet.publicKey?.toBase58(); + if (!walletAddress) return; + identify(walletAddress, { + wallet: walletAddress, + }); }, [wallet.publicKey]); // if account set in query param then store inn local storage and remove from url