Skip to content

Commit fccd32c

Browse files
committed
Satscard: add wait unlock for rate-limited cards
1 parent bde59d3 commit fccd32c

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

locales/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"views.Satscard.slotStatus": "Slot status",
129129
"views.Satscard.generateAddress": "Generate address",
130130
"views.Satscard.tapsignerNotSupported": "Tapsigner not supported",
131+
"views.Satscard.wait": "Wait and unlock rate-limited card",
131132
"views.Settings.AddEditNode.certificateButton": "Certificate Install Instructions",
132133
"views.Settings.AddEditNode.nodeConfig": "Node Configuration",
133134
"views.Settings.AddEditNode.connectionStringClipboard": "Detected the following connection string in your clipboard",

views/Settings/Satscard.tsx

+54-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface SatscardState {
4444
selectedSlot: number;
4545
selectedSlotIndex: number;
4646
selectedSlotStatus: string;
47+
rateLimited: boolean;
4748
}
4849

4950
interface CardStatus {
@@ -74,7 +75,8 @@ export default class Satscard extends React.Component<
7475
privkey: '',
7576
slotStatus: '',
7677
tapsignerError: false,
77-
error: ''
78+
error: '',
79+
rateLimited: false
7880
};
7981
}
8082

@@ -101,7 +103,8 @@ export default class Satscard extends React.Component<
101103
error,
102104
selectedSlot,
103105
selectedSlotIndex,
104-
selectedSlotStatus
106+
selectedSlotStatus,
107+
rateLimited
105108
} = this.state;
106109

107110
const BackButton = () => (
@@ -561,7 +564,55 @@ export default class Satscard extends React.Component<
561564
error:
562565
err.error ||
563566
err.message ||
564-
err.toString()
567+
err.toString(),
568+
rateLimited:
569+
err.toString() ===
570+
'Error: 429 on dump: rate limited'
571+
});
572+
}
573+
574+
if (Platform.OS === 'android') {
575+
await card.endNfcSession();
576+
ModalStore.toggleAndroidNfcModal(false);
577+
}
578+
}}
579+
/>
580+
</View>
581+
)}
582+
{!cardStatus && rateLimited && (
583+
<View style={styles.button}>
584+
<Button
585+
title={localeString('views.Satscard.wait')}
586+
onPress={async () => {
587+
try {
588+
awaitNfc();
589+
await card.nfcWrapper(async () => {
590+
const status = await card.first_look();
591+
if (status.auth_delay) {
592+
for (let i = 0; i < status.auth_delay; i++) {
593+
await card.wait();
594+
}
595+
}
596+
});
597+
598+
this.setState({
599+
rateLimited: false
600+
});
601+
602+
if (Platform.OS === 'android') {
603+
ModalStore.toggleAndroidNfcModal(
604+
false
605+
);
606+
}
607+
} catch (err) {
608+
this.setState({
609+
error:
610+
err.error ||
611+
err.message ||
612+
err.toString(),
613+
rateLimited:
614+
err.toString() ===
615+
'Error: 429 on dump: rate limited'
565616
});
566617
}
567618

0 commit comments

Comments
 (0)