Skip to content

Commit

Permalink
fix proof capitalization (#731)
Browse files Browse the repository at this point in the history
* fix proof capitalization

* lint
  • Loading branch information
cjinghong authored May 24, 2024
1 parent ae535b2 commit cfa9708
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions governance/src/hooks/airdrop/useAirdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,34 @@ const getProof = (account: string) => {
? (ProofData as AirdropProof)
: (ProofTestnetData as AirdropProof);

// lowercased all claims
const proofClaims = Object.keys(proof.claims).reduce((prev, address) => {
return {
...prev,
[address.toLowerCase()]: proof.claims[address],
};
}, proof.claims);
proof.claims = proofClaims;

const missedProof = isProduction()
? (ProofData2 as AirdropProof)
: (ProofTestnetData as AirdropProof);

const isMissedAccount = !proof.claims[account] && missedProof.claims[account];
// lowercased all claims
const missedProofClaims = Object.keys(missedProof.claims).reduce(
(prev, address) => {
return {
...prev,
[address.toLowerCase()]: missedProof.claims[address],
};
},
missedProof.claims
);
missedProof.claims = missedProofClaims;

const isMissedAccount =
!Boolean(proof.claims[account.toLowerCase()]) &&
Boolean(missedProof.claims[account.toLowerCase()]);

return {
merkleProof: isMissedAccount ? missedProof : proof,
Expand Down Expand Up @@ -100,7 +123,7 @@ const useAirdrop = () => {
return;
}

const airdropClaim = proof.merkleProof.claims[account];
const airdropClaim = proof.merkleProof.claims[account.toLowerCase()];
const totalBn = BigNumber.from(airdropClaim?.amount || 0);
const total = parseFloat(formatUnits(totalBn, rbnDecimals));

Expand Down

0 comments on commit cfa9708

Please sign in to comment.