Skip to content

Commit

Permalink
refactor: simplify locked keys checking flow
Browse files Browse the repository at this point in the history
Co-authored-by: Jan W <jan.we@exodus.io>
  • Loading branch information
marcoskichel and sparten11740 authored Jul 23, 2024
1 parent b93d980 commit 139fb79
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions features/keychain/module/keychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ export class Keychain {
return Object.values(this.#seedLockStatus).some(Boolean)
}

const existingSeeds = Object.entries(this.#seedLockStatus)
const checkingSeeds = existingSeeds.filter(([seedId]) => seedIds.has(seedId))

assert(checkingSeeds.length === seedIds.size, 'must pass in existing seeds')
return checkingSeeds.some(([, locked]) => locked)
return seedIds.some((seedId) => {

Check failure on line 57 in features/keychain/module/keychain.js

View workflow job for this annotation

GitHub Actions / Test

keychain api › sodium › signDetached signs data

TypeError: seedIds.some is not a function at Keychain.some (module/keychain.js:57:20) at Keychain.#assertPrivateKeysUnlocked (module/keychain.js:48:48) at Object.<anonymous>.#getPrivateHDKey (module/keychain.js:113:38) at getPrivateHDKey (module/crypto/sodium.js:15:40) at Object.getSodiumKeysFromIdentifier [as signDetached] (module/crypto/sodium.js:38:30) at Object.signDetached (api/__tests__/index.test.js:129:42)

Check failure on line 57 in features/keychain/module/keychain.js

View workflow job for this annotation

GitHub Actions / Test

keychain api › sodium › getKeysFromSeed returns public keys

TypeError: seedIds.some is not a function at Keychain.some (module/keychain.js:57:20) at Keychain.#assertPrivateKeysUnlocked (module/keychain.js:48:48) at Object.<anonymous>.#getPrivateHDKey (module/keychain.js:113:38) at getPrivateHDKey (module/crypto/sodium.js:15:40) at Object.getSodiumKeysFromIdentifier [as getSodiumKeysFromSeed] (module/crypto/sodium.js:21:43) at Object.getSodiumKeysFromSeed [as getKeysFromSeed] (api/index.js:9:27) at Object.getKeysFromSeed (api/__tests__/index.test.js:137:37)

Check failure on line 57 in features/keychain/module/keychain.js

View workflow job for this annotation

GitHub Actions / Test

keychain api › ed25519 › signBuffer signs binary data

TypeError: seedIds.some is not a function at Keychain.some (module/keychain.js:57:20) at Keychain.#assertPrivateKeysUnlocked (module/keychain.js:48:48) at Object.<anonymous>.#getPrivateHDKey (module/keychain.js:113:38) at getPrivateHDKey (module/crypto/ed25519.js:7:40) at Object.getSodiumKeysFromIdentifier [as signBuffer] (module/crypto/ed25519.js:14:30) at Object.signBuffer (api/__tests__/index.test.js:158:43)

Check failure on line 57 in features/keychain/module/keychain.js

View workflow job for this annotation

GitHub Actions / Test

keychain api › secp256k1 › signBuffer signs binary data

TypeError: seedIds.some is not a function at Keychain.some (module/keychain.js:57:20) at Keychain.#assertPrivateKeysUnlocked (module/keychain.js:48:48) at Object.<anonymous>.#getPrivateHDKey (module/keychain.js:113:38) at Object.getPrivateHDKey [as signBuffer] (module/crypto/secp256k1.js:33:30) at Object.signBuffer (api/__tests__/index.test.js:175:45)
assert(Object.hasOwn(this.#seedLockStatus, seedId), `cannot check lock state for unknown seed "${seedId}"`)
return this.#seedLockStatus[seedId]
})
}

arePrivateKeysLocked(seeds = []) {
Expand Down

0 comments on commit 139fb79

Please sign in to comment.