Skip to content

Commit 8b96230

Browse files
authored
chore: merge from develop to preview (#4430)
2 parents eef0ecf + eedbcfc commit 8b96230

File tree

24 files changed

+1103
-132
lines changed

24 files changed

+1103
-132
lines changed

mobile/scripts/check-thaw-schedule.js

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

mobile/src/features/Airdrop/common/useAirdropEligibility.ts

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,20 @@ export const useAirdropEligibility = () => {
175175
: 'Manual address'
176176
}
177177

178+
// Recalculate numberOfClaimedAllocations from confirmed/confirming thaws
179+
// (API sometimes returns incorrect value, so we calculate it ourselves)
180+
const numberOfClaimedAllocations =
181+
cachedAllocation.schedule.thaws.filter(
182+
(thaw) =>
183+
thaw.status === 'confirmed' || thaw.status === 'confirming',
184+
).length
185+
178186
allocations.push({
179187
...cachedAllocation,
188+
schedule: {
189+
...cachedAllocation.schedule,
190+
numberOfClaimedAllocations,
191+
},
180192
isExternal,
181193
displayName,
182194
nextThawDate,
@@ -219,9 +231,21 @@ export const useAirdropEligibility = () => {
219231
continue
220232
}
221233

234+
// Recalculate numberOfClaimedAllocations from confirmed/confirming thaws
235+
// (API sometimes returns incorrect value, so we calculate it ourselves)
236+
const numberOfClaimedAllocations =
237+
cachedAllocation.schedule.thaws.filter(
238+
(thaw) =>
239+
thaw.status === 'confirmed' || thaw.status === 'confirming',
240+
).length
241+
222242
// We have cached data - include it
223243
allocations.push({
224244
...cachedAllocation,
245+
schedule: {
246+
...cachedAllocation.schedule,
247+
numberOfClaimedAllocations,
248+
},
225249
isExternal: true,
226250
displayName,
227251
nextThawDate,
@@ -263,11 +287,10 @@ export const useAirdropEligibility = () => {
263287
.filter((thaw) => thaw.status === 'redeemable')
264288
.reduce((sum, thaw) => sum + thaw.amount, 0)
265289

266-
// Calculate total allocation (sum of all thaws)
267-
const totalAllocation = schedule.thaws.reduce(
268-
(sum, thaw) => sum + thaw.amount,
269-
0,
270-
)
290+
// Calculate total allocation (sum of all thaws excluding failed ones)
291+
const totalAllocation = schedule.thaws
292+
.filter((thaw) => thaw.status !== 'failed')
293+
.reduce((sum, thaw) => sum + thaw.amount, 0)
271294

272295
// Calculate redeemed so far (sum of confirmed thaws)
273296
const redeemedSoFar = schedule.thaws
@@ -277,6 +300,7 @@ export const useAirdropEligibility = () => {
277300
)
278301
.reduce((sum, thaw) => sum + thaw.amount, 0)
279302

303+
// Total left to redeem excludes redeemed thaws (failed already excluded from totalAllocation)
280304
const totalLeftToRedeem = totalAllocation - redeemedSoFar
281305

282306
// Find the next upcoming thaw that hasn't started yet
@@ -297,6 +321,13 @@ export const useAirdropEligibility = () => {
297321
? (upcomingThaws[0]?.thawing_period_start ?? null)
298322
: null
299323

324+
// Calculate numberOfClaimedAllocations from confirmed/confirming thaws
325+
// (API sometimes returns incorrect value, so we calculate it ourselves)
326+
const numberOfClaimedAllocations = schedule.thaws.filter(
327+
(thaw) =>
328+
thaw.status === 'confirmed' || thaw.status === 'confirming',
329+
).length
330+
300331
// Get display name for external address
301332
const isExternal = externalAddresses.has(address)
302333
let displayName: string | undefined
@@ -312,7 +343,10 @@ export const useAirdropEligibility = () => {
312343

313344
allocations.push({
314345
address,
315-
schedule,
346+
schedule: {
347+
...schedule,
348+
numberOfClaimedAllocations,
349+
},
316350
redeemableAmount,
317351
totalAllocation,
318352
redeemedSoFar,

mobile/src/features/Airdrop/common/useHasRedeemableThaws.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@ export const useHasRedeemableThaws = () => {
2424

2525
// Also check if any thaw has started but isn't confirmed yet
2626
// (in case backend hasn't updated status yet)
27+
// Exclude failed and skipped thaws - they cannot be redeemed
2728
return allocation.schedule.thaws.some((thaw) => {
29+
const thawStatus = thaw.status
30+
// Skip failed and skipped thaws - they cannot be redeemed
31+
if (thawStatus === 'failed' || thawStatus === 'skipped') {
32+
return false
33+
}
34+
2835
const thawDate = new Date(thaw.thawing_period_start.replace(/\s/g, ''))
2936
const hasStarted = thawDate <= now
30-
const isRedeemable = thaw.status === 'redeemable'
37+
const isRedeemable = thawStatus === 'redeemable'
3138
const isPendingRedeemable =
32-
thaw.status === 'upcoming' || thaw.status === 'queued'
39+
thawStatus === 'upcoming' || thawStatus === 'queued'
3340
const isNotRedeemed =
34-
thaw.status !== 'confirmed' &&
35-
thaw.status !== 'confirming' &&
36-
thaw.status !== 'submitted' &&
37-
thaw.status !== 'failed'
41+
thawStatus !== 'confirmed' &&
42+
thawStatus !== 'confirming' &&
43+
thawStatus !== 'submitted'
3844

3945
return (
4046
isRedeemable || (hasStarted && isPendingRedeemable && isNotRedeemed)

mobile/src/features/Airdrop/ui/AirdropDetailsScreen.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,22 @@ const getCurrentThawIndex = (thaws: ReadonlyArray<Thaw>): number | null => {
7272

7373
const now = new Date()
7474

75-
// First, try to find an active/redeemable thaw (started but not confirmed)
75+
// First, try to find an active/redeemable thaw (started but not confirmed and not failed)
7676
for (let i = 0; i < thaws.length; i++) {
7777
const thaw = thaws[i]
7878
if (!thaw) continue
7979
const thawDate = new Date(thaw.thawing_period_start.replace(/\s/g, ''))
80-
// Active thaw: started and not confirmed
81-
if (thawDate <= now && thaw.status !== 'confirmed') {
80+
// Active thaw: started and not confirmed and not failed
81+
if (
82+
thawDate <= now &&
83+
thaw.status !== 'confirmed' &&
84+
thaw.status !== 'failed'
85+
) {
8286
return i
8387
}
8488
}
8589

86-
// If no active thaw, find the first upcoming thaw (next one to start)
90+
// If no active thaw, find the first upcoming thaw (next one to start, not failed)
8791
for (let i = 0; i < thaws.length; i++) {
8892
const thaw = thaws[i]
8993
if (!thaw) continue
@@ -293,7 +297,7 @@ export const AirdropDetailsScreen = () => {
293297
)
294298
resultNavigation.showResultScreen({
295299
type: 'error',
296-
context: 'default',
300+
context: 'airdrop',
297301
title: strings.airdrop.insufficientFunds,
298302
message: strings.airdrop.redeemError,
299303
primaryAction: {

0 commit comments

Comments
 (0)