Skip to content

Commit

Permalink
checked ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
ebedoise committed Aug 1, 2024
1 parent cfc1e57 commit a154b74
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions apps/poll/src/Choices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,17 @@ export const Choices = () => {
});

const handleNftSearchOwner = async () => {
console.log('address: ', address);
if (address == null) {
return false;
}
const client = XRPNftReaderClient();
console.log('identifiers: ', identifiers);
if (!identifiers.issuer || !identifiers.nftokenTaxon) {
return false;
}
const nfts = await client.getWalletNfts(address, {
issuer: identifiers.issuer,
nftokenTaxon: identifiers.nftokenTaxon,
});
console.log('nfts: ', nfts);
if (nfts.length <= 0) return false;
else return true;
};
Expand All @@ -99,27 +96,20 @@ export const Choices = () => {
};

const handleVote = async (choiceId: string) => {
const isOwner = await handleNftSearchOwner();
console.log('isOwner: ', isOwner);
if (!isOwner) {
toast({
title: "You don't have the required NFT to vote",
status: 'warning',
duration: 2000,
});
return;
} else {
if (!address) {
toast({
title: 'Emile baka',
title: 'Connect your wallet to vote',
status: 'warning',
duration: 2000,
});
return;
}

if (!address) {
const isOwner = await handleNftSearchOwner();

if (!isOwner) {
toast({
title: 'Connect your wallet to vote',
title: "You don't have the required NFT to vote",
status: 'warning',
duration: 2000,
});
Expand Down

0 comments on commit a154b74

Please sign in to comment.