Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Add types for store and fix type discrepancies - #247

Merged
mikesposito merged 8 commits into
mainfrom
fix/store-types
Jul 18, 2023
Merged

Add types for store and fix type discrepancies#247
mikesposito merged 8 commits into
mainfrom
fix/store-types

Conversation

@mikesposito

@mikespositomikesposito commented Jul 17, 2023

Copy link
Copy Markdown
Member

Description

This PR updates obs-store to @metamask/obs-store and fixes some type discrepancies with the actual states

Changes

  • BREAKING: constructor opts KeyringControllerArgs properties types changed
    • Simplified type for keyringBuilders, now is an optional { (): Keyring<Json>; type: string }[]
    • initState now accepts only an optional persistent state, of type KeyringControllerPersistentState
  • BREAKING: type of store and memStore public properties changed
    • KeyringController.store is now an ObservableStore<KeyringControllerPersistentState>
    • KeyringController.memStore is now an ObservableStore<KeyringControllerState>
  • BREAKING: updateMemStoreKeyrings method return type changed to Promise<void>
  • BREAKING: KeyringControllerState type changed to include only non-persistent state:
    • Now undefined is used instead of null when encryptionKey and encryptionSalt are unset
    • keyrings is now of type KeyringObject[] instead of Keyring<Json>
    • password, store, memStore have been removed - note that in practice this change only affects types
    • This changes cause the following methods also to change the return type:
      • createNewVaultAndKeychain
      • createNewVaultAndRestore
      • setLocked
      • submitPassword
      • submitEncryptionKey
      • addNewAccount
      • removeAccount
      • fullUpdate
  • ADDED: KeyringControllerPersistentState type which includes only persistent state, an optional string property with key vault
  • ADDED: KeyringObject type for how keyrings are represented in memStore

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation for new or updated code as appropriate (note: this will usually be JSDoc)
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@mikesposito
mikesposito requested a review from a team as a code ownerJuly 17, 2023 18:52
@socket-security

Copy link
Copy Markdown

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

PackagesVersionNew capabilitiesTransitivesSizePublisher
@metamask/obs-store8.1.0None+137.6 kBgudahtt

🚮 Removed packages:obs-store@4.0.3

@socket-security

socket-securityBot commented Jul 17, 2023

Copy link
Copy Markdown

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: @metamask/obs-store@8.1.0, @metamask/safe-event-emitter@2.0.0

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

    Comment threadsrc/types.ts Outdated
    Comment threadsrc/types.ts

    @GudahttGudahtt left a comment

    Copy link
    Copy Markdown
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Looks great! Let me know when the description is ready so that I can review the list of changes. Lots of changes here.

    @Gudahtt

    Gudahtt commented Jul 17, 2023

    Copy link
    Copy Markdown
    Member

    I spotted a few more type errors caused by the types/@metamask/eth-sig-util file overriding the types from that package. Perhaps that can wait for a separate PR though.

    @Gudahtt

    Copy link
    Copy Markdown
    Member
    @SocketSecurity ignore @metamask/obs-store@8.1.0
    @SocketSecurity ignore @metamask/safe-event-emitter@2.0.0
    

    These are our packages

    @mikesposito

    Copy link
    Copy Markdown
    MemberAuthor

    The description should now be ready, I hope I mentioned everything 😄

    @Gudahtt

    Copy link
    Copy Markdown
    Member

    @mcmiremcmire left a comment

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Did a quick pass on this and had a couple of suggestions/questions. Will do another pass tomorrow to make sure I understand how these types are changing.

    Comment threadsrc/KeyringController.ts Outdated
    Comment threadsrc/KeyringController.test.ts Outdated
    Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
    Comment threadsrc/KeyringController.ts Outdated

    @GudahttGudahtt left a comment

    Copy link
    Copy Markdown
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM! Description of changes looks great too

    @mikesposito
    mikesposito merged commit f0baaac into mainJul 18, 2023
    @mikesposito
    mikesposito deleted the fix/store-types branch July 18, 2023 11:57
    Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants

    @mikesposito@Gudahtt@mcmire