@unicitylabs/sphere-sdk 0.5.1 → 0.5.2

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.
Files changed (43) hide show
  1. package/dist/connect/index.cjs +3 -1
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.js +3 -1
  4. package/dist/connect/index.js.map +1 -1
  5. package/dist/core/index.cjs +615 -275
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.cts +49 -2
  8. package/dist/core/index.d.ts +49 -2
  9. package/dist/core/index.js +615 -275
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/impl/browser/connect/index.cjs +3 -1
  12. package/dist/impl/browser/connect/index.cjs.map +1 -1
  13. package/dist/impl/browser/connect/index.js +3 -1
  14. package/dist/impl/browser/connect/index.js.map +1 -1
  15. package/dist/impl/browser/index.cjs +5 -2
  16. package/dist/impl/browser/index.cjs.map +1 -1
  17. package/dist/impl/browser/index.js +5 -2
  18. package/dist/impl/browser/index.js.map +1 -1
  19. package/dist/impl/browser/ipfs.cjs +3 -1
  20. package/dist/impl/browser/ipfs.cjs.map +1 -1
  21. package/dist/impl/browser/ipfs.js +3 -1
  22. package/dist/impl/browser/ipfs.js.map +1 -1
  23. package/dist/impl/nodejs/connect/index.cjs +3 -1
  24. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  25. package/dist/impl/nodejs/connect/index.js +3 -1
  26. package/dist/impl/nodejs/connect/index.js.map +1 -1
  27. package/dist/impl/nodejs/index.cjs +5 -2
  28. package/dist/impl/nodejs/index.cjs.map +1 -1
  29. package/dist/impl/nodejs/index.d.cts +6 -0
  30. package/dist/impl/nodejs/index.d.ts +6 -0
  31. package/dist/impl/nodejs/index.js +5 -2
  32. package/dist/impl/nodejs/index.js.map +1 -1
  33. package/dist/index.cjs +617 -275
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +118 -3
  36. package/dist/index.d.ts +118 -3
  37. package/dist/index.js +616 -275
  38. package/dist/index.js.map +1 -1
  39. package/dist/l1/index.cjs +3 -1
  40. package/dist/l1/index.cjs.map +1 -1
  41. package/dist/l1/index.js +3 -1
  42. package/dist/l1/index.js.map +1 -1
  43. package/package.json +1 -1
@@ -465,6 +465,8 @@ interface Asset {
465
465
  readonly confirmedTokenCount: number;
466
466
  /** Number of unconfirmed tokens aggregated */
467
467
  readonly unconfirmedTokenCount: number;
468
+ /** Number of tokens currently being sent */
469
+ readonly transferringTokenCount: number;
468
470
  /** Price per whole unit in USD (null if PriceProvider not configured) */
469
471
  readonly priceUsd: number | null;
470
472
  /** Price per whole unit in EUR (null if PriceProvider not configured) */
@@ -989,6 +991,12 @@ interface HistoryRecord {
989
991
  recipientNametag?: string;
990
992
  /** Optional memo/message attached to the transfer */
991
993
  memo?: string;
994
+ /** All token IDs in a combined transfer (V6 bundle breakdown) */
995
+ tokenIds?: Array<{
996
+ id: string;
997
+ amount: string;
998
+ source: 'split' | 'direct';
999
+ }>;
992
1000
  }
993
1001
  /**
994
1002
  * Storage result types
@@ -1933,6 +1941,7 @@ declare class PaymentsModule {
1933
1941
  private loadedPromise;
1934
1942
  private loaded;
1935
1943
  private processedSplitGroupIds;
1944
+ private processedCombinedTransferIds;
1936
1945
  private storageEventUnsubscribers;
1937
1946
  private syncDebounceTimer;
1938
1947
  private static readonly SYNC_DEBOUNCE_MS;
@@ -2002,6 +2011,43 @@ declare class PaymentsModule {
2002
2011
  * @returns InstantSplitResult with timing info
2003
2012
  */
2004
2013
  sendInstant(request: TransferRequest, options?: InstantSplitOptions): Promise<InstantSplitResult>;
2014
+ /**
2015
+ * Save a V5 split bundle as an unconfirmed token (shared by V5 standalone and V6 combined).
2016
+ * Returns the created UI token, or null if deduped.
2017
+ *
2018
+ * @param deferPersistence - If true, skip addToken/save calls (caller batches them).
2019
+ * The token is still added to the in-memory map for dedup; caller must call save().
2020
+ */
2021
+ private saveUnconfirmedV5Token;
2022
+ /**
2023
+ * Save a commitment-only (NOSTR-FIRST) token and start proof polling.
2024
+ * Shared by standalone NOSTR-FIRST handler and V6 combined handler.
2025
+ * Returns the created UI token, or null if deduped/tombstoned.
2026
+ *
2027
+ * @param deferPersistence - If true, skip save() and commitment submission
2028
+ * (caller batches them). Token is added to in-memory map + proof polling is queued.
2029
+ * @param skipGenesisDedup - If true, skip genesis-ID-only dedup. V6 handler sets this
2030
+ * because bundle-level dedup protects against replays, and split children share genesis IDs.
2031
+ */
2032
+ private saveCommitmentOnlyToken;
2033
+ /**
2034
+ * Process a received COMBINED_TRANSFER V6 bundle.
2035
+ *
2036
+ * Unpacks a single Nostr message into its component tokens:
2037
+ * - Optional V5 split bundle (saved as unconfirmed, resolved lazily)
2038
+ * - Zero or more direct tokens (saved as unconfirmed, proof-polled)
2039
+ *
2040
+ * Emits ONE transfer:incoming event and records ONE history entry.
2041
+ */
2042
+ private processCombinedTransferBundle;
2043
+ /**
2044
+ * Persist processed combined transfer IDs to KV storage.
2045
+ */
2046
+ private saveProcessedCombinedTransferIds;
2047
+ /**
2048
+ * Load processed combined transfer IDs from KV storage.
2049
+ */
2050
+ private loadProcessedCombinedTransferIds;
2005
2051
  /**
2006
2052
  * Process a received INSTANT_SPLIT bundle.
2007
2053
  *
@@ -2192,7 +2238,8 @@ declare class PaymentsModule {
2192
2238
  getAssets(coinId?: string): Promise<Asset[]>;
2193
2239
  /**
2194
2240
  * Aggregate tokens by coinId with confirmed/unconfirmed breakdown.
2195
- * Excludes tokens with status 'spent', 'invalid', or 'transferring'.
2241
+ * Excludes tokens with status 'spent' or 'invalid'.
2242
+ * Tokens with status 'transferring' are counted as unconfirmed (visible in UI as "Sending").
2196
2243
  */
2197
2244
  private aggregateTokens;
2198
2245
  /**
@@ -2592,7 +2639,7 @@ declare class PaymentsModule {
2592
2639
  /**
2593
2640
  * Handle NOSTR-FIRST commitment-only transfer (recipient side)
2594
2641
  * This is called when receiving a transfer with only commitmentData and no proof yet.
2595
- * We create the token as 'submitted', submit commitment (idempotent), and poll for proof.
2642
+ * Delegates to saveCommitmentOnlyToken() helper, then emits event + records history.
2596
2643
  */
2597
2644
  private handleCommitmentOnlyTransfer;
2598
2645
  /**
@@ -465,6 +465,8 @@ interface Asset {
465
465
  readonly confirmedTokenCount: number;
466
466
  /** Number of unconfirmed tokens aggregated */
467
467
  readonly unconfirmedTokenCount: number;
468
+ /** Number of tokens currently being sent */
469
+ readonly transferringTokenCount: number;
468
470
  /** Price per whole unit in USD (null if PriceProvider not configured) */
469
471
  readonly priceUsd: number | null;
470
472
  /** Price per whole unit in EUR (null if PriceProvider not configured) */
@@ -989,6 +991,12 @@ interface HistoryRecord {
989
991
  recipientNametag?: string;
990
992
  /** Optional memo/message attached to the transfer */
991
993
  memo?: string;
994
+ /** All token IDs in a combined transfer (V6 bundle breakdown) */
995
+ tokenIds?: Array<{
996
+ id: string;
997
+ amount: string;
998
+ source: 'split' | 'direct';
999
+ }>;
992
1000
  }
993
1001
  /**
994
1002
  * Storage result types
@@ -1933,6 +1941,7 @@ declare class PaymentsModule {
1933
1941
  private loadedPromise;
1934
1942
  private loaded;
1935
1943
  private processedSplitGroupIds;
1944
+ private processedCombinedTransferIds;
1936
1945
  private storageEventUnsubscribers;
1937
1946
  private syncDebounceTimer;
1938
1947
  private static readonly SYNC_DEBOUNCE_MS;
@@ -2002,6 +2011,43 @@ declare class PaymentsModule {
2002
2011
  * @returns InstantSplitResult with timing info
2003
2012
  */
2004
2013
  sendInstant(request: TransferRequest, options?: InstantSplitOptions): Promise<InstantSplitResult>;
2014
+ /**
2015
+ * Save a V5 split bundle as an unconfirmed token (shared by V5 standalone and V6 combined).
2016
+ * Returns the created UI token, or null if deduped.
2017
+ *
2018
+ * @param deferPersistence - If true, skip addToken/save calls (caller batches them).
2019
+ * The token is still added to the in-memory map for dedup; caller must call save().
2020
+ */
2021
+ private saveUnconfirmedV5Token;
2022
+ /**
2023
+ * Save a commitment-only (NOSTR-FIRST) token and start proof polling.
2024
+ * Shared by standalone NOSTR-FIRST handler and V6 combined handler.
2025
+ * Returns the created UI token, or null if deduped/tombstoned.
2026
+ *
2027
+ * @param deferPersistence - If true, skip save() and commitment submission
2028
+ * (caller batches them). Token is added to in-memory map + proof polling is queued.
2029
+ * @param skipGenesisDedup - If true, skip genesis-ID-only dedup. V6 handler sets this
2030
+ * because bundle-level dedup protects against replays, and split children share genesis IDs.
2031
+ */
2032
+ private saveCommitmentOnlyToken;
2033
+ /**
2034
+ * Process a received COMBINED_TRANSFER V6 bundle.
2035
+ *
2036
+ * Unpacks a single Nostr message into its component tokens:
2037
+ * - Optional V5 split bundle (saved as unconfirmed, resolved lazily)
2038
+ * - Zero or more direct tokens (saved as unconfirmed, proof-polled)
2039
+ *
2040
+ * Emits ONE transfer:incoming event and records ONE history entry.
2041
+ */
2042
+ private processCombinedTransferBundle;
2043
+ /**
2044
+ * Persist processed combined transfer IDs to KV storage.
2045
+ */
2046
+ private saveProcessedCombinedTransferIds;
2047
+ /**
2048
+ * Load processed combined transfer IDs from KV storage.
2049
+ */
2050
+ private loadProcessedCombinedTransferIds;
2005
2051
  /**
2006
2052
  * Process a received INSTANT_SPLIT bundle.
2007
2053
  *
@@ -2192,7 +2238,8 @@ declare class PaymentsModule {
2192
2238
  getAssets(coinId?: string): Promise<Asset[]>;
2193
2239
  /**
2194
2240
  * Aggregate tokens by coinId with confirmed/unconfirmed breakdown.
2195
- * Excludes tokens with status 'spent', 'invalid', or 'transferring'.
2241
+ * Excludes tokens with status 'spent' or 'invalid'.
2242
+ * Tokens with status 'transferring' are counted as unconfirmed (visible in UI as "Sending").
2196
2243
  */
2197
2244
  private aggregateTokens;
2198
2245
  /**
@@ -2592,7 +2639,7 @@ declare class PaymentsModule {
2592
2639
  /**
2593
2640
  * Handle NOSTR-FIRST commitment-only transfer (recipient side)
2594
2641
  * This is called when receiving a transfer with only commitmentData and no proof yet.
2595
- * We create the token as 'submitted', submit commitment (idempotent), and poll for proof.
2642
+ * Delegates to saveCommitmentOnlyToken() helper, then emits event + records history.
2596
2643
  */
2597
2644
  private handleCommitmentOnlyTransfer;
2598
2645
  /**