fix call to swap history api
This commit is contained in:
parent
ea0d1ce4d4
commit
aae95b6b4a
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useMemo, useState } from 'react'
|
||||||
import mangoStore from '@store/mangoStore'
|
import mangoStore from '@store/mangoStore'
|
||||||
import TabButtons from '../shared/TabButtons'
|
import TabButtons from '../shared/TabButtons'
|
||||||
import TokenList from '../TokenList'
|
import TokenList from '../TokenList'
|
||||||
|
@ -6,7 +6,6 @@ import SwapHistoryTable from '../swap/SwapHistoryTable'
|
||||||
import ActivityFeed from './ActivityFeed'
|
import ActivityFeed from './ActivityFeed'
|
||||||
import UnsettledTrades from '@components/trade/UnsettledTrades'
|
import UnsettledTrades from '@components/trade/UnsettledTrades'
|
||||||
import { useUnsettledSpotBalances } from 'hooks/useUnsettledSpotBalances'
|
import { useUnsettledSpotBalances } from 'hooks/useUnsettledSpotBalances'
|
||||||
import useMangoAccount from 'hooks/useMangoAccount'
|
|
||||||
import { useViewport } from 'hooks/useViewport'
|
import { useViewport } from 'hooks/useViewport'
|
||||||
import { breakpoints } from 'utils/theme'
|
import { breakpoints } from 'utils/theme'
|
||||||
import useUnsettledPerpPositions from 'hooks/useUnsettledPerpPositions'
|
import useUnsettledPerpPositions from 'hooks/useUnsettledPerpPositions'
|
||||||
|
@ -20,8 +19,6 @@ const TABS = [
|
||||||
|
|
||||||
const AccountTabs = () => {
|
const AccountTabs = () => {
|
||||||
const [activeTab, setActiveTab] = useState('balances')
|
const [activeTab, setActiveTab] = useState('balances')
|
||||||
const actions = mangoStore((s) => s.actions)
|
|
||||||
const { mangoAccount } = useMangoAccount()
|
|
||||||
const { width } = useViewport()
|
const { width } = useViewport()
|
||||||
const isMobile = width ? width < breakpoints.md : false
|
const isMobile = width ? width < breakpoints.md : false
|
||||||
|
|
||||||
|
@ -29,12 +26,6 @@ const AccountTabs = () => {
|
||||||
return TABS.map((t) => [t, 0])
|
return TABS.map((t) => [t, 0])
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (mangoAccount) {
|
|
||||||
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
|
||||||
}
|
|
||||||
}, [actions, mangoAccount])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TabButtons
|
<TabButtons
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Fragment, useState } from 'react'
|
import { Fragment, useEffect, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
ArrowRightIcon,
|
ArrowRightIcon,
|
||||||
ChevronDownIcon,
|
ChevronDownIcon,
|
||||||
|
@ -13,7 +13,7 @@ import { useViewport } from '../../hooks/useViewport'
|
||||||
import { IconButton } from '../shared/Button'
|
import { IconButton } from '../shared/Button'
|
||||||
import { Transition } from '@headlessui/react'
|
import { Transition } from '@headlessui/react'
|
||||||
import SheenLoader from '../shared/SheenLoader'
|
import SheenLoader from '../shared/SheenLoader'
|
||||||
import { SwapHistoryItem } from '@store/mangoStore'
|
import mangoStore, { SwapHistoryItem } from '@store/mangoStore'
|
||||||
import {
|
import {
|
||||||
countLeadingZeros,
|
countLeadingZeros,
|
||||||
formatFixedDecimals,
|
formatFixedDecimals,
|
||||||
|
@ -27,6 +27,7 @@ import useJupiterMints from 'hooks/useJupiterMints'
|
||||||
import { Table, Td, Th, TrBody, TrHead } from '@components/shared/TableElements'
|
import { Table, Td, Th, TrBody, TrHead } from '@components/shared/TableElements'
|
||||||
import { useWallet } from '@solana/wallet-adapter-react'
|
import { useWallet } from '@solana/wallet-adapter-react'
|
||||||
import { EXPLORERS } from '@components/settings/PreferredExplorerSettings'
|
import { EXPLORERS } from '@components/settings/PreferredExplorerSettings'
|
||||||
|
import useMangoAccount from 'hooks/useMangoAccount'
|
||||||
|
|
||||||
const SwapHistoryTable = ({
|
const SwapHistoryTable = ({
|
||||||
swapHistory,
|
swapHistory,
|
||||||
|
@ -39,6 +40,8 @@ const SwapHistoryTable = ({
|
||||||
const { connected } = useWallet()
|
const { connected } = useWallet()
|
||||||
const { mangoTokens } = useJupiterMints()
|
const { mangoTokens } = useJupiterMints()
|
||||||
const [showSwapDetails, setSwapDetails] = useState('')
|
const [showSwapDetails, setSwapDetails] = useState('')
|
||||||
|
const actions = mangoStore((s) => s.actions)
|
||||||
|
const { mangoAccount } = useMangoAccount()
|
||||||
const { width } = useViewport()
|
const { width } = useViewport()
|
||||||
const showTableView = width ? width > breakpoints.md : false
|
const showTableView = width ? width > breakpoints.md : false
|
||||||
const [preferredExplorer] = useLocalStorageState(
|
const [preferredExplorer] = useLocalStorageState(
|
||||||
|
@ -46,6 +49,12 @@ const SwapHistoryTable = ({
|
||||||
EXPLORERS[0]
|
EXPLORERS[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (mangoAccount) {
|
||||||
|
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
||||||
|
}
|
||||||
|
}, [actions, mangoAccount])
|
||||||
|
|
||||||
const handleShowSwapDetails = (signature: string) => {
|
const handleShowSwapDetails = (signature: string) => {
|
||||||
showSwapDetails ? setSwapDetails('') : setSwapDetails(signature)
|
showSwapDetails ? setSwapDetails('') : setSwapDetails(signature)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, {
|
import React, {
|
||||||
Dispatch,
|
Dispatch,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
useState,
|
useState,
|
||||||
|
@ -198,7 +199,7 @@ const SwapReviewRouteInfo = ({
|
||||||
}
|
}
|
||||||
}, [inputTokenInfo, outputTokenInfo])
|
}, [inputTokenInfo, outputTokenInfo])
|
||||||
|
|
||||||
const onSwap = async () => {
|
const onSwap = useCallback(async () => {
|
||||||
if (!selectedRoute) return
|
if (!selectedRoute) return
|
||||||
try {
|
try {
|
||||||
const client = mangoStore.getState().client
|
const client = mangoStore.getState().client
|
||||||
|
@ -246,6 +247,7 @@ const SwapReviewRouteInfo = ({
|
||||||
noSound: true,
|
noSound: true,
|
||||||
})
|
})
|
||||||
actions.fetchGroup()
|
actions.fetchGroup()
|
||||||
|
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
||||||
await actions.reloadMangoAccount()
|
await actions.reloadMangoAccount()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error('onSwap error: ', e)
|
console.error('onSwap error: ', e)
|
||||||
|
@ -263,7 +265,7 @@ const SwapReviewRouteInfo = ({
|
||||||
} finally {
|
} finally {
|
||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
}
|
}, [amountIn, onClose, selectedRoute, soundSettings])
|
||||||
|
|
||||||
const [balance, borrowAmount] = useMemo(() => {
|
const [balance, borrowAmount] = useMemo(() => {
|
||||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||||
|
|
Loading…
Reference in New Issue