Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has mnemonic share check #2041

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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