fetch open orders on wallet connect

This commit is contained in:
Maximilian Schneider 2021-09-23 22:52:16 +02:00
parent d310e0b66f
commit 724bb77ef4
2 changed files with 9 additions and 4 deletions

View File

@ -104,6 +104,7 @@ export default function useWallet() {
}) })
// set connected before fetching data // set connected before fetching data
await actions.fetchMangoAccounts() await actions.fetchMangoAccounts()
actions.reloadOrders()
actions.fetchTradeHistory() actions.fetchTradeHistory()
actions.fetchWalletTokens() actions.fetchWalletTokens()
notify({ notify({

View File

@ -440,7 +440,15 @@ const useMangoStore = create<MangoStore>((set, get) => {
const connection = get().connection.current const connection = get().connection.current
const reloadedMangoAccount = await mangoAccount.reload(connection) const reloadedMangoAccount = await mangoAccount.reload(connection)
await get().actions.reloadOrders()
set((state) => {
state.selectedMangoAccount.current = reloadedMangoAccount
})
},
async reloadOrders() {
const mangoAccount = get().selectedMangoAccount.current
const connection = get().connection.current
await Promise.all([ await Promise.all([
mangoAccount.loadOpenOrders( mangoAccount.loadOpenOrders(
connection, connection,
@ -448,10 +456,6 @@ const useMangoStore = create<MangoStore>((set, get) => {
), ),
mangoAccount.loadAdvancedOrders(connection), mangoAccount.loadAdvancedOrders(connection),
]) ])
set((state) => {
state.selectedMangoAccount.current = reloadedMangoAccount
})
}, },
// DEPRECATED // DEPRECATED
async _updateOpenOrders() { async _updateOpenOrders() {