From 3b16b7093a4b5499049eb2c6edecb75e0e28d1f8 Mon Sep 17 00:00:00 2001 From: Michael Yankelev Date: Thu, 24 Mar 2022 14:34:55 +0100 Subject: [PATCH 1/2] fix mnemonic share --- packages/files-ui/src/Contexts/ThresholdKeyContext.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx index a18195a92e..d389d51cb2 100644 --- a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx +++ b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx @@ -157,8 +157,10 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f ...bs, ...bowser.parse(bs.userAgent) } as BrowserShare)), [parsedShares]) - const hasMnemonicShare = useMemo(() => (keyDetails && (keyDetails.totalShares - parsedShares.length > 1)) || false, - [keyDetails, parsedShares.length]) + + const hasMnemonicShare = useMemo(() => parsedShares.filter((s) => s.module === SHARE_SERIALIZATION_MODULE_NAME).length > 0, + [parsedShares]) + const hasPasswordShare = useMemo(() => parsedShares.filter((s) => s.module === SECURITY_QUESTIONS_MODULE_NAME).length > 0, [parsedShares]) @@ -626,6 +628,10 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f requiredShareStore.share.share, "mnemonic" )) as string + await TKeySdk.addShareDescription( + shareCreated.newShareIndex.toString("hex"), + JSON.stringify({ module: SHARE_SERIALIZATION_MODULE_NAME }), + true) const keyDetails = await TKeySdk.getKeyDetails() setKeyDetails(keyDetails) return result From 202a6f9094946d431dc5363dbbddfa2bf8e143c0 Mon Sep 17 00:00:00 2001 From: Michael Yankelev Date: Thu, 24 Mar 2022 14:37:16 +0100 Subject: [PATCH 2/2] fix lint --- packages/files-ui/src/Contexts/ThresholdKeyContext.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx index d389d51cb2..a2e36fa857 100644 --- a/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx +++ b/packages/files-ui/src/Contexts/ThresholdKeyContext.tsx @@ -256,7 +256,6 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f // cached may be stale, resulting in a failure to reconstruct the key. This is // identified through the nonce. Manually refreshing the metadata cache solves this problem if (error.message.includes("nonce")) { - // await TKeySdk._syncShareMetadata() const { privKey } = await TKeySdk.reconstructKey(false) const privKeyString = privKey.toString("hex") if (privKeyString.length < 64) { @@ -629,7 +628,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f "mnemonic" )) as string await TKeySdk.addShareDescription( - shareCreated.newShareIndex.toString("hex"), + shareCreated.newShareIndex.toString("hex"), JSON.stringify({ module: SHARE_SERIALIZATION_MODULE_NAME }), true) const keyDetails = await TKeySdk.getKeyDetails()