Skip to content

Commit 24fb0df

Browse files
authored
fix erc1155 numClaimsLeft (#1026)
1 parent 4f15861 commit 24fb0df

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/common/types.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,11 @@ export interface Reward {
915915
name: string
916916
contract_address: `0x${string}`
917917
decimals: number | null
918-
/* eslint-disable-next-line */
919-
token_ids: { amount_per_user: string; token_id: number }[]
918+
token_ids: {
919+
amount_per_user: string
920+
token_id: number
921+
numClaimsLeft: string
922+
}[]
920923
image_url: string
921924
numClaimsLeft: string
922925
}

src/frontend/hooks/useGetRewards.ts

+24-7
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,31 @@ export function useGetRewards(questId: number | null) {
4545
).toString()
4646
}
4747

48-
const questReward_i: QuestReward = {
49-
title: reward_i.name,
50-
imageUrl: reward_i.image_url,
51-
chainName: getRewardCategory(reward_i, t),
52-
numToClaim,
53-
numOfClaimsLeft: reward_i.numClaimsLeft
48+
if (
49+
reward_i.reward_type === 'ERC1155' &&
50+
reward_i.token_ids &&
51+
reward_i.token_ids.length
52+
) {
53+
for (const token_i of reward_i.token_ids) {
54+
const questReward_i: QuestReward = {
55+
title: reward_i.name,
56+
imageUrl: reward_i.image_url,
57+
chainName: getRewardCategory(reward_i, t),
58+
numToClaim: token_i.amount_per_user,
59+
numOfClaimsLeft: token_i.numClaimsLeft
60+
}
61+
rewards.push(questReward_i)
62+
}
63+
} else {
64+
const questReward_i: QuestReward = {
65+
title: reward_i.name,
66+
imageUrl: reward_i.image_url,
67+
chainName: getRewardCategory(reward_i, t),
68+
numToClaim,
69+
numOfClaimsLeft: reward_i.numClaimsLeft
70+
}
71+
rewards.push(questReward_i)
5472
}
55-
rewards.push(questReward_i)
5673
}
5774
return rewards
5875
},

0 commit comments

Comments
 (0)