Skip to content

Commit

Permalink
Merge pull request #2041 from ChainSafe/fix/has-mnemonic-share-check
Browse files Browse the repository at this point in the history
Has mnemonic share check
  • Loading branch information
FSM1 authored Mar 24, 2022
2 parents 0918fe8 + 202a6f9 commit f4b86da
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/files-ui/src/Contexts/ThresholdKeyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -254,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) {
Expand Down Expand Up @@ -626,6 +627,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
Expand Down

0 comments on commit f4b86da

Please sign in to comment.