Keystore
-
-
+
+
+
@@ -105,3 +119,40 @@ function useSelectedKeystore() {
onKeystoreChanged,
};
}
+
+function useImportExportKeystore() {
+ const { rln } = useRLN();
+
+ const onExportKeystore = () => {
+ if (!rln) {
+ return;
+ }
+
+ const filename = "keystore.json";
+ const text = rln.keystore.toString();
+ const file = new File([text], filename, {
+ type: "application/json",
+ });
+
+ const link = document.createElement("a");
+ link.href = URL.createObjectURL(file);
+ link.download = filename;
+ link.click();
+ };
+
+ const onImportKeystoreFileChange = async (
+ event: React.FormEvent