Skip to content

Commit

Permalink
Merge pull request #261 from CarmineOptions/feature/pail
Browse files Browse the repository at this point in the history
fix: owned pail only if wallet connected
  • Loading branch information
DaveVodrazka authored Nov 19, 2024
2 parents 5d660f5 + 7b6ff3c commit 9fbb738
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/components/ConnectWallet/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ export const WalletButton = () => {
</button>
);
};

export const OpenWalletDialogButton = () => {
const { address } = useAccount();
const { openWalletConnectModal } = useConnectWallet();

if (address) {
return null;
}

return (
<button onClick={openWalletConnectModal} className="main primary active">
Connect Wallet
</button>
);
};
26 changes: 25 additions & 1 deletion src/components/PAIL/Owned.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
import { LoadingAnimation } from "../Loading/Loading";
import { usePailTokenIds } from "../../hooks/usePailTokenIds";
import { useProvider, useSendTransaction } from "@starknet-react/core";
import {
useAccount,
useProvider,
useSendTransaction,
} from "@starknet-react/core";
import { PAIL_ADDRESS, PAIL_NFT_ADDRESS } from "../../constants/amm";
import toast from "react-hot-toast";
import { OpenWalletDialogButton } from "../ConnectWallet/Button";

export const Owned = () => {
const { address } = useAccount();
const { isLoading, isError, error, data } = usePailTokenIds();
const { sendAsync } = useSendTransaction({});
const { provider } = useProvider();

if (!address) {
return (
<div style={{ width: "fit-content" }}>
<div
style={{
display: "flex",
flexFlow: "column",
alignItems: "center",
gap: "10px",
}}
>
<p>Connect wallet to see your positions</p>
<OpenWalletDialogButton />
</div>
</div>
);
}

if (isLoading) {
return <LoadingAnimation />;
}
Expand Down

0 comments on commit 9fbb738

Please sign in to comment.