Skip to content

Commit

Permalink
fix erc1155 numClaimsLeft (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettCleary authored Aug 15, 2024
1 parent 4f15861 commit 24fb0df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,11 @@ export interface Reward {
name: string
contract_address: `0x${string}`
decimals: number | null
/* eslint-disable-next-line */
token_ids: { amount_per_user: string; token_id: number }[]
token_ids: {
amount_per_user: string
token_id: number
numClaimsLeft: string
}[]
image_url: string
numClaimsLeft: string
}
Expand Down
31 changes: 24 additions & 7 deletions src/frontend/hooks/useGetRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,31 @@ export function useGetRewards(questId: number | null) {
).toString()
}

const questReward_i: QuestReward = {
title: reward_i.name,
imageUrl: reward_i.image_url,
chainName: getRewardCategory(reward_i, t),
numToClaim,
numOfClaimsLeft: reward_i.numClaimsLeft
if (
reward_i.reward_type === 'ERC1155' &&
reward_i.token_ids &&
reward_i.token_ids.length
) {
for (const token_i of reward_i.token_ids) {
const questReward_i: QuestReward = {
title: reward_i.name,
imageUrl: reward_i.image_url,
chainName: getRewardCategory(reward_i, t),
numToClaim: token_i.amount_per_user,
numOfClaimsLeft: token_i.numClaimsLeft
}
rewards.push(questReward_i)
}
} else {
const questReward_i: QuestReward = {
title: reward_i.name,
imageUrl: reward_i.image_url,
chainName: getRewardCategory(reward_i, t),
numToClaim,
numOfClaimsLeft: reward_i.numClaimsLeft
}
rewards.push(questReward_i)
}
rewards.push(questReward_i)
}
return rewards
},
Expand Down

0 comments on commit 24fb0df

Please sign in to comment.