From 0810024536fa702083d8bca67d3ed2208e3a58e4 Mon Sep 17 00:00:00 2001 From: David McFadzean Date: Wed, 3 Jul 2024 14:28:53 -0400 Subject: [PATCH] Added check/fix wallet to API --- kc-app/src/KeymasterUI.js | 36 ++++++++++++++++++++++++++++-------- kc-app/src/keymaster-sdk.js | 20 ++++++++++++++++++++ keymaster-api.js | 18 ++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/kc-app/src/KeymasterUI.js b/kc-app/src/KeymasterUI.js index cab419b5..299ecc86 100644 --- a/kc-app/src/KeymasterUI.js +++ b/kc-app/src/KeymasterUI.js @@ -48,6 +48,7 @@ function KeymasterUI({ keymaster, title }) { const [mnemonicString, setMnemonicString] = useState(''); const [walletString, setWalletString] = useState(''); const [manifest, setManifest] = useState(null); + const [checkingWallet, setCheckingWallet] = useState(false); useEffect(() => { refreshAll(); @@ -657,6 +658,25 @@ function KeymasterUI({ keymaster, title }) { } } + async function checkWallet() { + setCheckingWallet(true); + try { + const { checked, invalid, deleted } = await keymaster.checkWallet(); + + if (invalid == 0 && deleted == 0) { + window.alert(`${checked} DIDs checked, no problems found`); + } + else if (window.confirm(`${checked} DIDs checked\n${invalid} invalid DIDs found\n${deleted} deleted DIDs found\n\nFix wallet?`)) { + const { idsRemoved, ownedRemoved, heldRemoved } = await keymaster.fixWallet(); + window.alert(`${idsRemoved} IDs removed\n${ownedRemoved} owned DIDs removed\n${heldRemoved} held DIDs removed`); + } + + } catch (error) { + window.alert(error); + } + setCheckingWallet(false); + } + async function showWallet() { try { const wallet = await keymaster.loadWallet(); @@ -1420,6 +1440,11 @@ function KeymasterUI({ keymaster, title }) { Recover... + + +

@@ -1434,14 +1459,6 @@ function KeymasterUI({ keymaster, title }) { )} - - -

{mnemonicString}
- - - -

- {walletString ? (