@unicitylabs/sphere-sdk 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1722,6 +1722,13 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1722
1722
  * Clear all data
1723
1723
  */
1724
1724
  clear?(): Promise<boolean>;
1725
+ /**
1726
+ * Create a new independent instance of this provider for a different address.
1727
+ * Used by per-address module architecture — each address gets its own
1728
+ * TokenStorageProvider instance to avoid cross-address data contamination.
1729
+ * If not implemented, the provider cannot be used in multi-address mode.
1730
+ */
1731
+ createForAddress?(): TokenStorageProvider<TData>;
1725
1732
  /**
1726
1733
  * Subscribe to storage events
1727
1734
  */
@@ -1978,6 +1985,16 @@ interface TransportProvider extends BaseProvider {
1978
1985
  * @returns Unsubscribe function
1979
1986
  */
1980
1987
  onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
1988
+ /**
1989
+ * Set fallback 'since' timestamp for event subscriptions.
1990
+ * Used when switching to an address that has never subscribed before.
1991
+ * The transport uses this instead of 'now' as the initial since filter,
1992
+ * ensuring events sent while the address was inactive are not missed.
1993
+ * Consumed once by the next subscription setup, then cleared.
1994
+ *
1995
+ * @param sinceSeconds - Unix timestamp in seconds
1996
+ */
1997
+ setFallbackSince?(sinceSeconds: number): void;
1981
1998
  /**
1982
1999
  * Fetch pending events from transport (one-shot query).
1983
2000
  * Creates a temporary subscription, processes events through normal handlers,
@@ -4628,6 +4645,11 @@ declare class Sphere {
4628
4645
  private _communications;
4629
4646
  private _groupChat;
4630
4647
  private _market;
4648
+ private _addressModules;
4649
+ private _transportMux;
4650
+ private _l1Config;
4651
+ private _groupChatConfig;
4652
+ private _marketConfig;
4631
4653
  private eventHandlers;
4632
4654
  private _disabledProviders;
4633
4655
  private _providerEventCleanups;
@@ -5023,9 +5045,28 @@ declare class Sphere {
5023
5045
  */
5024
5046
  private postSwitchSync;
5025
5047
  /**
5026
- * Re-initialize modules after address switch
5048
+ * Create a new set of per-address modules for the given index.
5049
+ * Each address gets its own PaymentsModule, CommunicationsModule, etc.
5050
+ * Modules are fully independent — they have their own token storage,
5051
+ * and can sync/finalize/split in background regardless of active address.
5052
+ *
5053
+ * @param index - HD address index
5054
+ * @param identity - Full identity for this address
5055
+ * @param tokenStorageProviders - Token storage providers for this address
5056
+ */
5057
+ private initializeAddressModules;
5058
+ /**
5059
+ * Ensure the transport multiplexer exists and register an address.
5060
+ * Creates the mux on first call. Returns an AddressTransportAdapter
5061
+ * that routes events for this address independently.
5062
+ * @returns AddressTransportAdapter or null if transport is not Nostr-based
5063
+ */
5064
+ private ensureTransportMux;
5065
+ /**
5066
+ * Get per-address modules for any address index (creates lazily if needed).
5067
+ * This allows accessing any address's modules without switching.
5027
5068
  */
5028
- private reinitializeModulesForNewAddress;
5069
+ getAddressPayments(index: number): PaymentsModule | undefined;
5029
5070
  /**
5030
5071
  * Derive address at a specific index
5031
5072
  *
package/dist/index.d.ts CHANGED
@@ -1722,6 +1722,13 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1722
1722
  * Clear all data
1723
1723
  */
1724
1724
  clear?(): Promise<boolean>;
1725
+ /**
1726
+ * Create a new independent instance of this provider for a different address.
1727
+ * Used by per-address module architecture — each address gets its own
1728
+ * TokenStorageProvider instance to avoid cross-address data contamination.
1729
+ * If not implemented, the provider cannot be used in multi-address mode.
1730
+ */
1731
+ createForAddress?(): TokenStorageProvider<TData>;
1725
1732
  /**
1726
1733
  * Subscribe to storage events
1727
1734
  */
@@ -1978,6 +1985,16 @@ interface TransportProvider extends BaseProvider {
1978
1985
  * @returns Unsubscribe function
1979
1986
  */
1980
1987
  onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
1988
+ /**
1989
+ * Set fallback 'since' timestamp for event subscriptions.
1990
+ * Used when switching to an address that has never subscribed before.
1991
+ * The transport uses this instead of 'now' as the initial since filter,
1992
+ * ensuring events sent while the address was inactive are not missed.
1993
+ * Consumed once by the next subscription setup, then cleared.
1994
+ *
1995
+ * @param sinceSeconds - Unix timestamp in seconds
1996
+ */
1997
+ setFallbackSince?(sinceSeconds: number): void;
1981
1998
  /**
1982
1999
  * Fetch pending events from transport (one-shot query).
1983
2000
  * Creates a temporary subscription, processes events through normal handlers,
@@ -4628,6 +4645,11 @@ declare class Sphere {
4628
4645
  private _communications;
4629
4646
  private _groupChat;
4630
4647
  private _market;
4648
+ private _addressModules;
4649
+ private _transportMux;
4650
+ private _l1Config;
4651
+ private _groupChatConfig;
4652
+ private _marketConfig;
4631
4653
  private eventHandlers;
4632
4654
  private _disabledProviders;
4633
4655
  private _providerEventCleanups;
@@ -5023,9 +5045,28 @@ declare class Sphere {
5023
5045
  */
5024
5046
  private postSwitchSync;
5025
5047
  /**
5026
- * Re-initialize modules after address switch
5048
+ * Create a new set of per-address modules for the given index.
5049
+ * Each address gets its own PaymentsModule, CommunicationsModule, etc.
5050
+ * Modules are fully independent — they have their own token storage,
5051
+ * and can sync/finalize/split in background regardless of active address.
5052
+ *
5053
+ * @param index - HD address index
5054
+ * @param identity - Full identity for this address
5055
+ * @param tokenStorageProviders - Token storage providers for this address
5056
+ */
5057
+ private initializeAddressModules;
5058
+ /**
5059
+ * Ensure the transport multiplexer exists and register an address.
5060
+ * Creates the mux on first call. Returns an AddressTransportAdapter
5061
+ * that routes events for this address independently.
5062
+ * @returns AddressTransportAdapter or null if transport is not Nostr-based
5063
+ */
5064
+ private ensureTransportMux;
5065
+ /**
5066
+ * Get per-address modules for any address index (creates lazily if needed).
5067
+ * This allows accessing any address's modules without switching.
5027
5068
  */
5028
- private reinitializeModulesForNewAddress;
5069
+ getAddressPayments(index: number): PaymentsModule | undefined;
5029
5070
  /**
5030
5071
  * Derive address at a specific index
5031
5072
  *