From cfbb81a038b57dcd496904653a2fbb8dae8bbbf5 Mon Sep 17 00:00:00 2001 From: Kobe Date: Fri, 27 Sep 2024 16:08:08 +0200 Subject: [PATCH] fix: actionbox v2 in onboarding --- apps/marginfi-v2-ui/src/pages/_app.tsx | 17 +++++++++++++++-- .../actionbox-v2/actions/lend-box/lend-box.tsx | 12 ++++++++++-- .../components/onboarding/screens/deposit.tsx | 8 ++++---- .../wallet-v2/components/sign-up/sign-up.tsx | 6 +++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/apps/marginfi-v2-ui/src/pages/_app.tsx b/apps/marginfi-v2-ui/src/pages/_app.tsx index 57c13833f0..d1be998f03 100644 --- a/apps/marginfi-v2-ui/src/pages/_app.tsx +++ b/apps/marginfi-v2-ui/src/pages/_app.tsx @@ -55,11 +55,24 @@ type MrgnAppProps = { path: string }; export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnAppProps) { const [setIsFetchingData, isOraclesStale] = useUiStore((state) => [state.setIsFetchingData, state.isOraclesStale]); - const [isMrgnlendStoreInitialized, isRefreshingMrgnlendStore, fetchMrgnlendState] = useMrgnlendStore((state) => [ + const [ + isMrgnlendStoreInitialized, + isRefreshingMrgnlendStore, + marginfiClient, + selectedAccount, + extendedBankInfos, + nativeSolBalance, + fetchMrgnlendState, + ] = useMrgnlendStore((state) => [ state.initialized, state.isRefreshingStore, + state.marginfiClient, + state.selectedAccount, + state.extendedBankInfos, + state.nativeSolBalance, state.fetchMrgnlendState, ]); + const [isLstStoreInitialised, isRefreshingLstStore] = useLstStore((state) => [ state.initialized, state.isRefreshingStore, @@ -129,7 +142,7 @@ export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnA - + diff --git a/packages/mrgn-ui/src/components/actionbox-v2/actions/lend-box/lend-box.tsx b/packages/mrgn-ui/src/components/actionbox-v2/actions/lend-box/lend-box.tsx index 1f53ab6a8c..6b9fe299e8 100644 --- a/packages/mrgn-ui/src/components/actionbox-v2/actions/lend-box/lend-box.tsx +++ b/packages/mrgn-ui/src/components/actionbox-v2/actions/lend-box/lend-box.tsx @@ -8,6 +8,8 @@ import { ActionType, TokenAccountMap, AccountSummary, + computeAccountSummary, + DEFAULT_ACCOUNT_SUMMARY, } from "@mrgnlabs/marginfi-v2-ui-state"; import { ActionMethod, MarginfiActionParams, PreviousTxn } from "@mrgnlabs/mrgn-utils"; import { MarginfiAccountWrapper, MarginfiClient } from "@mrgnlabs/marginfi-client-v2"; @@ -35,7 +37,7 @@ export type LendBoxProps = { banks: ExtendedBankInfo[]; requestedLendType: ActionType; requestedBank?: ExtendedBankInfo; - accountSummary?: AccountSummary; + accountSummaryArg?: AccountSummary; onConnect?: () => void; onComplete: (previousTxn: PreviousTxn) => void; @@ -50,7 +52,7 @@ export const LendBox = ({ marginfiClient, banks, selectedAccount, - accountSummary, + accountSummaryArg, requestedLendType, requestedBank, onConnect, @@ -99,6 +101,12 @@ export const LendBox = ({ state.setErrorMessage, ]); + const accountSummary = React.useMemo(() => { + return ( + accountSummaryArg ?? (selectedAccount ? computeAccountSummary(selectedAccount, banks) : DEFAULT_ACCOUNT_SUMMARY) + ); + }, [accountSummaryArg, selectedAccount, banks]); + const [setIsSettingsDialogOpen] = useActionBoxStore((state) => [state.setIsSettingsDialogOpen]); const { amount, debouncedAmount, walletAmount, maxAmount } = useActionAmounts({ diff --git a/packages/mrgn-ui/src/components/wallet-v2/components/sign-up/components/onboarding/screens/deposit.tsx b/packages/mrgn-ui/src/components/wallet-v2/components/sign-up/components/onboarding/screens/deposit.tsx index e1a27ecadc..c963abcd0c 100644 --- a/packages/mrgn-ui/src/components/wallet-v2/components/sign-up/components/onboarding/screens/deposit.tsx +++ b/packages/mrgn-ui/src/components/wallet-v2/components/sign-up/components/onboarding/screens/deposit.tsx @@ -6,7 +6,7 @@ import { ActionBox } from "~/components/actionbox-v2"; import { ScreenWrapper, WalletSeperator } from "~/components/wallet-v2/components/sign-up/components"; import { useWallet } from "~/components/wallet-v2/hooks/use-wallet.hook"; -import { IconLoader } from "@tabler/icons-react"; +import { IconLoader2 } from "@tabler/icons-react"; interface DepositTokenProps extends OnrampScreenProps {} @@ -47,10 +47,10 @@ export const DepositToken = ({ mrgnState, successProps, onNext, onClose }: Depos }} /> ) : ( - <> - +
+ Loading... - +
)} {/*