-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace runtime check by type guards
- Loading branch information
Frederik Rothenberger
committed
Feb 14, 2023
1 parent
7b79421
commit 517e9e4
Showing
7 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { DeviceData, Purpose } from "../../generated/internet_identity_types"; | ||
|
||
export type RecoveryDevice = Omit<DeviceData, "alias"> & { | ||
purpose: Extract<Purpose, { recovery: null }>; | ||
}; | ||
|
||
export const recoveryDeviceToLabel = ( | ||
device: Omit<DeviceData, "alias"> & RecoveryDevice | ||
): string => { | ||
if ("seed_phrase" in device.key_type) { | ||
return "Recovery phrase"; | ||
} | ||
return "External Hardware"; | ||
}; | ||
export const isRecoveryDevice = ( | ||
device: Omit<DeviceData, "alias"> | ||
): device is RecoveryDevice => "recovery" in device.purpose; |
This file was deleted.
Oops, something went wrong.