Skip to content

Commit 98f2a2d

Browse files
authored
Merge pull request #4482 from Emurgo/feat/YW-444/failed-thaw
show failed status from the thaw schedule endpoint
2 parents cda66c2 + e4c8c86 commit 98f2a2d

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

packages/yoroi-extension/app/UI/features/airdrop/common/hooks/useStrings.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export const messages = Object.freeze(
7272
id: 'airdrop.schedule.redeemed',
7373
defaultMessage: '!!!Redeemed',
7474
},
75+
failed: {
76+
id: 'airdrop.schedule.failed',
77+
defaultMessage: '!!!Failed',
78+
},
7579
thawExplanation: {
7680
id: 'airdrop.schedule.thawExplanation',
7781
defaultMessage: '!!!Each thaw is 25% of your claimed NIGHT allocation',
@@ -279,6 +283,7 @@ export const useStrings = () => {
279283
thawTitle: (index: number, total: number) => intl.formatMessage(messages.thawTitle, { index, total }),
280284
notAvailable: intl.formatMessage(messages.notAvailable),
281285
redeemed: intl.formatMessage(messages.redeemed),
286+
failed: intl.formatMessage(messages.failed),
282287
thawExplanation: intl.formatMessage(messages.thawExplanation),
283288
statusLabel: intl.formatMessage(messages.statusLabel),
284289
subTitle: intl.formatMessage(messages.subTitle),

packages/yoroi-extension/app/UI/features/airdrop/useCases/AddressDetails.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,17 @@ function formatDate(dateString: string, locale: string): string {
158158
}
159159

160160
function getCurrentThawIndex(schedule: Schedule): number {
161-
const redeemableIndex = schedule.thaws.findIndex(thaw => thaw.status === 'redeemable');
161+
const redeemableIndex = schedule.thaws.findIndex(thaw => thaw.status === 'redeemable' || thaw.status === 'failed');
162162
if (redeemableIndex >= 0) return redeemableIndex;
163-
const upcomingIndex = schedule.thaws.findIndex(thaw => thaw.status === 'upcoming');
163+
const upcomingIndex = schedule.thaws.findIndex(thaw => thaw.status === 'upcoming' || thaw.status === 'failed');
164164
if (upcomingIndex >= 0) return upcomingIndex;
165165
return 0;
166166
}
167167

168-
type ThawStatus = 'redeemable' | 'confirmed' | 'upcoming';
168+
type ThawStatus = 'redeemable' | 'confirmed' | 'upcoming' | 'failed';
169169

170170
function getThawStatusType(status: string): ThawStatus {
171+
if (status === 'failed') return 'failed';
171172
if (status === 'redeemable') return 'redeemable';
172173
if (status === 'confirmed') return 'confirmed';
173174
return 'upcoming';
@@ -202,6 +203,8 @@ function getStatusMessage(status: ThawStatus, strings: ReturnType<typeof useStri
202203
return strings.redeemable;
203204
case 'confirmed':
204205
return strings.redeemed;
206+
case 'failed':
207+
return strings.failed;
205208
default:
206209
return strings.notAvailable;
207210
}
@@ -238,6 +241,7 @@ function ScheduleCard({ schedule }: { schedule: Schedule }) {
238241
const isCurrent = index === currentThawIndex;
239242
const isPast = index < currentThawIndex;
240243
const isLast = index === totalThaws - 1;
244+
const isFailed = thaw.status === 'failed';
241245

242246
return (
243247
<Box key={index} sx={{ flex: 1, position: 'relative' }}>
@@ -251,15 +255,30 @@ function ScheduleCard({ schedule }: { schedule: Schedule }) {
251255
display: 'flex',
252256
alignItems: 'center',
253257
justifyContent: 'center',
254-
backgroundColor: isPast ? 'ds.primary_300' : isCurrent ? 'ds.primary_500' : 'ds.gray_200',
258+
backgroundColor: isFailed
259+
? 'ds.gray_200'
260+
: isPast
261+
? 'ds.primary_300'
262+
: isCurrent
263+
? 'ds.primary_500'
264+
: 'ds.gray_200',
255265
color: isPast || isCurrent ? 'ds.white_static' : 'ds.text_gray_min',
256266
fontSize: '12px',
257267
fontWeight: 500,
258268
zIndex: 1,
259269
flexShrink: 0,
260270
}}
261271
>
262-
{isPast ? (
272+
{isFailed ? (
273+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16" fill="none">
274+
<path
275+
fill-rule="evenodd"
276+
clip-rule="evenodd"
277+
d="M4.29289 4.29289C4.68342 3.90237 5.31658 3.90237 5.70711 4.29289L8 6.58579L10.2929 4.29289C10.6834 3.90237 11.3166 3.90237 11.7071 4.29289C12.0976 4.68342 12.0976 5.31658 11.7071 5.70711L9.41421 8L11.7071 10.2929C12.0976 10.6834 12.0976 11.3166 11.7071 11.7071C11.3166 12.0976 10.6834 12.0976 10.2929 11.7071L8 9.41421L5.70711 11.7071C5.31658 12.0976 4.68342 12.0976 4.29289 11.7071C3.90237 11.3166 3.90237 10.6834 4.29289 10.2929L6.58579 8L4.29289 5.70711C3.90237 5.31658 3.90237 4.68342 4.29289 4.29289Z"
278+
fill="#FF0000"
279+
/>
280+
</svg>
281+
) : isPast ? (
263282
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
264283
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16" fill="none">
265284
<path

packages/yoroi-extension/app/api/ada/midnightRedemption.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function formatNumberExactly(n: number): string {
2727
export function getRedeemableAmount(schedule: Schedule): number {
2828
return schedule.thaws
2929
.slice(schedule.numberOfClaimedAllocations)
30-
.filter(thaw => thaw.status === 'redeemable')
30+
.filter(thaw => thaw.status === 'redeemable' || thaw.status === 'failed')
3131
.reduce((accu, thaw) => accu + thaw.amount, 0);
3232
}
3333

packages/yoroi-extension/app/i18n/locales/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"airdrop.redeem.reorgMessage": "Please re-orgnize the wallet for collateral UTxOs",
5353
"airdrop.redeem.waitingForReorg": "Waiting for the re-organization transaction to be confirmed",
5454
"airdrop.schedule.currentThaw": "Current thaw: {current}/{total}",
55+
"airdrop.schedule.failed": "Failed",
5556
"airdrop.schedule.notAvailable": "Not available yet",
5657
"airdrop.schedule.redeemable": "Redeemable",
5758
"airdrop.schedule.redeemed": "Redeemed",

0 commit comments

Comments
 (0)