Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ngvtuan
Copy link
Contributor

@ngvtuan ngvtuan commented Oct 14, 2025

No description provided.

@ngvtuan ngvtuan merged commit 01c3f3b into develop Oct 14, 2025
const [isClaimLoading, setClaimLoading] = useState(false);
const [errorClaim, setErrorClaim] = useState<string | null>(null);
const [claimInfo, setClaimInfo] = useState({
senderAddress: address,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The claimInfo.senderAddress is initialized with the current address but is not updated when the address changes, potentially causing claims to be attempted with an outdated address if the user switches wallets during the session.

RPC_ENDPOINT,
offlineSigner,
{
registry: new Registry([
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new Registry instance is created here, but a global registry is already defined at the top of the file. Reusing the global registry would avoid redundancy and potential inconsistencies.

amount: [{ denom: DENOM, amount: claimInfo.fees }], // Fee gas
gas: claimInfo.gas, // Gas limit
};
const memo = claimInfo.memo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after the memo assignment, which could cause linting issues or unexpected behavior in some environments.

}
};

useEffect(() => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetchData function depends on the address but is not included in the useEffect dependencies array, which means it won't refetch data when the address changes, potentially showing stale balance information.

isOpen: boolean;
setOpen: (status: boolean) => void;
sernder: string;
onVoteClick: () => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in property name: 'sernder' should be 'sender' for consistency and to avoid confusion.

abstainPercent: item.final_tally_result.yes_count ? Number(item.final_tally_result.abstain_count) * 100 / total : 0,
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the total vote count is zero, the percentage calculations will result in NaN. Adding a check to return zero percentages when total is zero would prevent this.

break;
}
} catch (error) {
console.log('error', error)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling is incomplete; setError is commented out, and errors are only logged to console, which may make debugging difficult in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants