This commit is contained in:
Adrian Brzeziński 2023-10-24 02:11:26 +02:00
parent a3cd3595b6
commit be236418b5
2 changed files with 25 additions and 19 deletions

View File

@ -177,24 +177,31 @@ const ClaimPage = () => {
const transactionInstructions: TransactionInstructionWithType[] = []
// Create claim account if it doesn't exist
if (claimed === undefined) {
transactionInstructions.push({
instructionsSet: [
new TransactionInstructionWithSigners(
await rewardsClient.program.methods
.claimAccountCreate()
.accounts({
distribution: distribution.publicKey,
claimAccount: distribution.findClaimAccountAddress(publicKey!),
claimant: publicKey!,
payer: publicKey!,
systemProgram: web3.SystemProgram.programId,
rent: web3.SYSVAR_RENT_PUBKEY,
})
.instruction(),
),
],
sequenceType: SequenceType.Sequential,
})
const claimAccountPk = distribution.findClaimAccountAddress(publicKey!)
const isCreated = (await connection.getBalance(claimAccountPk)) > 1
if (!isCreated) {
transactionInstructions.push({
instructionsSet: [
new TransactionInstructionWithSigners(
await rewardsClient.program.methods
.claimAccountCreate()
.accounts({
distribution: distribution.publicKey,
claimAccount: distribution.findClaimAccountAddress(
publicKey!,
),
claimant: publicKey!,
payer: publicKey!,
systemProgram: web3.SystemProgram.programId,
rent: web3.SYSVAR_RENT_PUBKEY,
})
.instruction(),
),
],
sequenceType: SequenceType.Sequential,
})
}
}
try {

View File

@ -116,6 +116,5 @@ export const useIsAllClaimed = (
setShowClaim(false)
}
}, [distributionData, walletPk, isAllClaimed])
return { isAllClaimed, showClaim }
}