Skip to content

Commit

Permalink
fix: actionbox v2 in onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Sep 27, 2024
1 parent d33d5c5 commit cfbb81a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
17 changes: 15 additions & 2 deletions apps/marginfi-v2-ui/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -129,7 +142,7 @@ export default function MrgnApp({ Component, pageProps, path }: AppProps & MrgnA

<Analytics />
<Tutorial />
<AuthDialog />
<AuthDialog mrgnState={{ marginfiClient, selectedAccount, extendedBankInfos, nativeSolBalance }} />
<ToastContainer position="bottom-left" theme="dark" />
</LipClientProvider>
</MrgnlendProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -35,7 +37,7 @@ export type LendBoxProps = {
banks: ExtendedBankInfo[];
requestedLendType: ActionType;
requestedBank?: ExtendedBankInfo;
accountSummary?: AccountSummary;
accountSummaryArg?: AccountSummary;

onConnect?: () => void;
onComplete: (previousTxn: PreviousTxn) => void;
Expand All @@ -50,7 +52,7 @@ export const LendBox = ({
marginfiClient,
banks,
selectedAccount,
accountSummary,
accountSummaryArg,
requestedLendType,
requestedBank,
onConnect,
Expand Down Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down Expand Up @@ -47,10 +47,10 @@ export const DepositToken = ({ mrgnState, successProps, onNext, onClose }: Depos
}}
/>
) : (
<>
<IconLoader size={18} className="animate-spin-slow" />
<div className="flex flex-col items-center gap-2">
<IconLoader2 size={18} className="animate-spin" />
<span>Loading...</span>
</>
</div>
)}
{/* <ActionBox
requestedAction={ActionType.Deposit}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useRouter } from "next/router";

import { MarginfiClient } from "@mrgnlabs/marginfi-client-v2";
import { MarginfiAccountWrapper, MarginfiClient } from "@mrgnlabs/marginfi-client-v2";
import { ExtendedBankInfo } from "@mrgnlabs/marginfi-v2-ui-state";

import { Dialog, DialogContent } from "~/components/ui/dialog";
Expand All @@ -13,8 +13,8 @@ import { Progress } from "~/components/ui/progress";

type AuthDialogProps = {
mrgnState?: {
marginfiClient: MarginfiClient;
selectedAccount: string;
marginfiClient: MarginfiClient | null;
selectedAccount: MarginfiAccountWrapper | null;
extendedBankInfos: ExtendedBankInfo[];
nativeSolBalance: number;
};
Expand Down

0 comments on commit cfbb81a

Please sign in to comment.