From 8fef0d2e2f0887e4c875fa8bb109647c437881fb Mon Sep 17 00:00:00 2001 From: riordanp Date: Tue, 1 Oct 2024 09:26:13 +0100 Subject: [PATCH] retain lev stake accounts and use for calculating next account num (#448) --- components/account/CreateAccountForm.tsx | 5 ++++- store/mangoStore.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/account/CreateAccountForm.tsx b/components/account/CreateAccountForm.tsx index 004395042..38f2f3363 100644 --- a/components/account/CreateAccountForm.tsx +++ b/components/account/CreateAccountForm.tsx @@ -66,7 +66,10 @@ const CreateAccountForm = ({ const handleNewAccount = useCallback(async () => { const client = mangoStore.getState().client const group = mangoStore.getState().group - const existingMangoAccts = mangoStore.getState().mangoAccounts + const existingMangoAccts = [ + ...mangoStore.getState().mangoAccounts, + ...mangoStore.getState().mangoAccountsLevStake, + ] const set = mangoStore.getState().set const connection = mangoStore.getState().connection diff --git a/store/mangoStore.ts b/store/mangoStore.ts index 8471171ac..490a6c2b9 100644 --- a/store/mangoStore.ts +++ b/store/mangoStore.ts @@ -235,6 +235,7 @@ export type MangoStore = { } } mangoAccounts: MangoAccount[] + mangoAccountsLevStake: MangoAccount[] markets: Serum3Market[] | undefined transactionNotificationIdCounter: number transactionNotifications: Array @@ -416,6 +417,7 @@ const mangoStore = create()( tradeHistory: { data: [], loading: true }, }, mangoAccounts: [], + mangoAccountsLevStake: [], markets: undefined, transactionNotificationIdCounter: 0, transactionNotifications: [], @@ -683,12 +685,17 @@ const mangoStore = create()( client.getMangoAccountsForDelegate(group, ownerPk), ]) - const mangoAccounts = [ + const allMangoAccounts = [ ...ownerMangoAccounts, ...delegateAccounts, - ].filter( + ] + + const mangoAccounts = allMangoAccounts.filter( (acc) => hasLevCloseInUrl || !acc.name.includes('Leverage Stake'), ) + const mangoAccountsLevStake = allMangoAccounts.filter( + (acc) => !hasLevCloseInUrl && acc.name.includes('Leverage Stake'), + ) const selectedAccountIsNotInAccountsList = mangoAccounts.find( (x) => x.publicKey.toBase58() === @@ -734,6 +741,7 @@ const mangoStore = create()( set((state) => { state.mangoAccounts = mangoAccounts + state.mangoAccountsLevStake = mangoAccountsLevStake }) } catch (e) { console.error('Error fetching mango accts', e)