Skip to content

Architecture: CryptoProvider DI + broadcast pattern for shared mutation hooks #67

Description

@lamat1111

@CassOnMars — two architectural questions for shared mutation hooks in @quilibrium/quorum-shared. Sibling to #65, #66.

1. CryptoProvider DI

Mobile uses NativeCryptoProvider ad-hoc at every space-crypto call site, plus a module-level singleton for DM crypto. When a shared hook needs crypto, it has to get a provider from somewhere.

Two paths:

  • ContextCryptoContext + useCryptoProvider(), matching the existing StorageContext pattern. Shared hooks call useCryptoProvider() internally.
  • Parameter — shared hooks accept cryptoProvider as an option. Cleaner separation, more boilerplate at each consumer.

2. Broadcast pattern for shared mutation hooks

When a shared mutation hook produces a new state, it has to broadcast a WS envelope. The send is platform-specific (broadcastSpaceUpdate on mobile, SpaceService.updateSpace on desktop).

Two paths:

  • Return the envelope — caller dispatches via their platform's broadcast function.
  • Callback — hook accepts onBroadcast(envelope) and calls it internally.

Issue #66 (channel reorder mutations not broadcasting) is a live instance of this question.

Or...

Defer shared mutation hooks entirely for now and migrate only read-query hooks until the patterns are clearer?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions