-
Couldn't load subscription status.
- Fork 0
claim rewards #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update the connect wallet code. update function for the claim feature
…nto feat/claim-rewards
| const [isClaimLoading, setClaimLoading] = useState(false); | ||
| const [errorClaim, setErrorClaim] = useState<string | null>(null); | ||
| const [claimInfo, setClaimInfo] = useState({ | ||
| senderAddress: address, |
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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, | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
No description provided.