diff --git a/package.json b/package.json index 02d0e39..52d5b11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@project-serum/swap-ui", - "version": "0.1.0-alpha.22", + "version": "0.1.0-alpha.24", "main": "dist/index.js", "types": "dist/index.d.ts", "homepage": "https://github.com/project-serum/swap-ui", diff --git a/src/components/OpenOrdersDialog.tsx b/src/components/OpenOrdersDialog.tsx index 54167ea..671490b 100644 --- a/src/components/OpenOrdersDialog.tsx +++ b/src/components/OpenOrdersDialog.tsx @@ -1,4 +1,4 @@ -import { useState, useMemo } from "react"; +import { useState, useMemo, useEffect } from "react"; import { PublicKey } from "@solana/web3.js"; import { MintInfo } from "@solana/spl-token"; import { BN } from "@project-serum/anchor"; @@ -41,8 +41,6 @@ export default function OpenOrdersDialog({ open: boolean; onClose: () => void; }) { - const styles = useStyles(); - return ( ; }) { const styles = useStyles(); - const [ooAccount, setOoAccount] = useState(openOrders[0]); - const { swapClient } = useDexContext(); + useEffect(() => { + setOoAccount(openOrders[0]); + }, [openOrders]); + const { swapClient, closeOpenOrders } = useDexContext(); const marketClient = useMarket(market); const tokenMap = useTokenMap(); const base = useMint(marketClient?.baseMintAddress); @@ -170,7 +170,7 @@ function OpenOrdersRow({ await swapClient.program.provider.send(transaction, signers); }; - const closeOpenOrders = async () => { + const _closeOpenOrders = async () => { await swapClient.program.rpc.closeAccount({ accounts: { openOrders: ooAccount.address, @@ -180,6 +180,7 @@ function OpenOrdersRow({ dexProgram: DEX_PID, }, }); + closeOpenOrders(ooAccount); }; return ( @@ -241,7 +242,7 @@ function OpenOrdersRow({