fixed wallet adapter type issues
This commit is contained in:
parent
1b7c251870
commit
99664f97e9
|
@ -27,7 +27,7 @@ const AccountNameModal: FunctionComponent<AccountNameModalProps> = ({
|
|||
}) => {
|
||||
const [name, setName] = useState(accountName || '')
|
||||
const [invalidNameMessage, setInvalidNameMessage] = useState('')
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
const selectedMangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
|
||||
const selectedMarginAccount = useMangoStore(
|
||||
(s) => s.selectedMarginAccount.current
|
||||
|
|
|
@ -21,7 +21,7 @@ const BalancesTable = () => {
|
|||
)
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
|
||||
try {
|
||||
await settleAll(
|
||||
|
|
|
@ -145,7 +145,7 @@ const BorrowModal: FunctionComponent<BorrowModalProps> = ({
|
|||
setSubmitting(true)
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
if (!marginAccount || !mangoGroup) return
|
||||
|
||||
borrowAndWithdraw(
|
||||
|
|
|
@ -176,7 +176,7 @@ const DepositModal: FunctionComponent<DepositModalProps> = ({
|
|||
setSubmitting(true)
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
|
||||
if (!marginAccount && mangoGroup) {
|
||||
initMarginAccountAndDeposit(
|
||||
|
|
|
@ -10,8 +10,9 @@ interface DepositWithdrawHistoryTableProps {
|
|||
type: 'deposits' | 'withdrawals'
|
||||
}
|
||||
|
||||
const DepositWithdrawHistoryTable: FunctionComponent<DepositWithdrawHistoryTableProps> =
|
||||
({ type }) => {
|
||||
const DepositWithdrawHistoryTable: FunctionComponent<
|
||||
DepositWithdrawHistoryTableProps
|
||||
> = ({ type }) => {
|
||||
const depositHistory = useMangoStore((s) => s.depositHistory)
|
||||
const withdrawalHistory = useMangoStore((s) => s.withdrawalHistory)
|
||||
const history = type === 'deposits' ? depositHistory : withdrawalHistory
|
||||
|
@ -23,9 +24,7 @@ const DepositWithdrawHistoryTable: FunctionComponent<DepositWithdrawHistoryTable
|
|||
return (
|
||||
<>
|
||||
<div>{date.toLocaleDateString()}</div>
|
||||
<div className="text-xs text-th-fgd-3">
|
||||
{date.toLocaleTimeString()}
|
||||
</div>
|
||||
<div className="text-xs text-th-fgd-3">{date.toLocaleTimeString()}</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -33,9 +32,7 @@ const DepositWithdrawHistoryTable: FunctionComponent<DepositWithdrawHistoryTable
|
|||
return (
|
||||
<div className={`flex flex-col py-4`}>
|
||||
<div className={`-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8`}>
|
||||
<div
|
||||
className={`align-middle inline-block min-w-full sm:px-6 lg:px-8`}
|
||||
>
|
||||
<div className={`align-middle inline-block min-w-full sm:px-6 lg:px-8`}>
|
||||
{history.length > 0 ? (
|
||||
<div
|
||||
className={`overflow-hidden border-b border-th-bkg-2 sm:rounded-md`}
|
||||
|
@ -164,12 +161,9 @@ const DepositWithdrawHistoryTable: FunctionComponent<DepositWithdrawHistoryTable
|
|||
className={`px-6 py-3 whitespace-nowrap text-sm text-th-fgd-1`}
|
||||
>
|
||||
$
|
||||
{transaction.usd_equivalent.toLocaleString(
|
||||
undefined,
|
||||
{
|
||||
{transaction.usd_equivalent.toLocaleString(undefined, {
|
||||
maximumFractionDigits: 2,
|
||||
}
|
||||
)}
|
||||
})}
|
||||
</Td>
|
||||
<Td
|
||||
className={`px-6 py-3 whitespace-nowrap text-sm text-th-fgd-1`}
|
||||
|
@ -200,6 +194,6 @@ const DepositWithdrawHistoryTable: FunctionComponent<DepositWithdrawHistoryTable
|
|||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default DepositWithdrawHistoryTable
|
||||
|
|
|
@ -88,7 +88,7 @@ const NewAccount: FunctionComponent<NewAccountProps> = ({
|
|||
const handleNewAccountDeposit = () => {
|
||||
setSubmitting(true)
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
|
||||
initMarginAccountAndDeposit(
|
||||
connection,
|
||||
|
|
|
@ -23,7 +23,7 @@ const OpenOrdersTable = () => {
|
|||
const actions = useMangoStore((s) => s.actions)
|
||||
|
||||
const handleCancelOrder = async (order) => {
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
const selectedMangoGroup =
|
||||
useMangoStore.getState().selectedMangoGroup.current
|
||||
const selectedMarginAccount =
|
||||
|
|
|
@ -200,7 +200,7 @@ export default function TradeForm() {
|
|||
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
|
||||
if (!mangoGroup || !marketAddress || !marginAccount || !market) return
|
||||
setSubmitting(true)
|
||||
|
|
|
@ -148,7 +148,7 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
|
|||
setSubmitting(true)
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const wallet = useMangoStore.getState().wallet.current as any
|
||||
if (!marginAccount || !mangoGroup) return
|
||||
|
||||
if (!includeBorrow) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import DepositModal from '../DepositModal'
|
|||
import WithdrawModal from '../WithdrawModal'
|
||||
import Button from '../Button'
|
||||
import Tooltip from '../Tooltip'
|
||||
import { Market } from '@project-serum/serum'
|
||||
|
||||
export default function AccountAssets() {
|
||||
const balances = useBalances()
|
||||
|
@ -53,12 +54,11 @@ export default function AccountAssets() {
|
|||
}
|
||||
|
||||
async function handleSettleAllTrades() {
|
||||
const markets = Object.values(
|
||||
useMangoStore.getState().selectedMangoGroup.markets
|
||||
)
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const { selectedMangoGroup, selectedMarginAccount, wallet } =
|
||||
useMangoStore.getState() as any
|
||||
const markets = Object.values(selectedMangoGroup.markets) as Market[]
|
||||
const marginAccount = selectedMarginAccount.current
|
||||
const mangoGroup = selectedMangoGroup.current
|
||||
|
||||
try {
|
||||
await settleAllTrades(
|
||||
|
@ -67,7 +67,7 @@ export default function AccountAssets() {
|
|||
mangoGroup,
|
||||
marginAccount,
|
||||
markets,
|
||||
wallet
|
||||
wallet.current
|
||||
)
|
||||
await sleep(250)
|
||||
actions.fetchMarginAccounts()
|
||||
|
|
|
@ -35,9 +35,8 @@ export default function AccountBorrows() {
|
|||
const [showDepositModal, setShowDepositModal] = useState(false)
|
||||
|
||||
async function handleSettleBorrow(token, borrowQuantity, depositBalance) {
|
||||
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
||||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const { selectedMarginAccount, selectedMangoGroup, wallet } =
|
||||
useMangoStore.getState() as any
|
||||
|
||||
if (borrowQuantity > depositBalance) {
|
||||
const deficit = borrowQuantity - depositBalance
|
||||
|
@ -49,9 +48,9 @@ export default function AccountBorrows() {
|
|||
await settleBorrow(
|
||||
connection,
|
||||
new PublicKey(programId),
|
||||
mangoGroup,
|
||||
marginAccount,
|
||||
wallet,
|
||||
selectedMangoGroup.current,
|
||||
selectedMarginAccount.current,
|
||||
wallet.current,
|
||||
new PublicKey(symbols[token]),
|
||||
Number(borrowQuantity)
|
||||
)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
const withTM = require('next-transpile-modules')([
|
||||
'@project-serum/sol-wallet-adapter',
|
||||
])
|
||||
|
@ -7,12 +6,12 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
|||
enabled: process.env.ANALYZE === 'true',
|
||||
})
|
||||
|
||||
module.exports = withBundleAnalyzer(withTM({
|
||||
module.exports = withBundleAnalyzer(
|
||||
withTM({
|
||||
target: 'serverless',
|
||||
webpack(config, {isServer}) {
|
||||
webpack(config, { isServer }) {
|
||||
if (!isServer) config.resolve.fallback.fs = false
|
||||
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
use: ['@svgr/webpack'],
|
||||
|
@ -20,4 +19,5 @@ module.exports = withBundleAnalyzer(withTM({
|
|||
|
||||
return config
|
||||
},
|
||||
}))
|
||||
})
|
||||
)
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
|
@ -19,12 +15,7 @@
|
|||
"jsx": "preserve",
|
||||
"incremental": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".next",
|
||||
"out",
|
||||
"public/datafeeds"
|
||||
],
|
||||
"exclude": ["node_modules", ".next", "out", "public/datafeeds"],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
|
|
Loading…
Reference in New Issue