@unicitylabs/sphere-sdk 0.14.0-dev.5 → 0.14.0-dev.6

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.
@@ -547,6 +547,25 @@ interface PaymentsRequestsApi {
547
547
  decline(id: string): Promise<void>;
548
548
  dismissProcessed(): void;
549
549
  }
550
+ /**
551
+ * A pending-transfers row, derived ON READ from the §6 stores (intent backstop
552
+ * + delivery journal + shortfalls) — never a cached mirror. kind 'shortfall' =
553
+ * a completed partial (#690) whose `amount` is the remainder still owed;
554
+ * legs.certified counts journaled legs (certified, delivery still owed).
555
+ */
556
+ interface PendingTransfer {
557
+ transferId: string;
558
+ kind: 'open' | 'shortfall';
559
+ recipient: string;
560
+ coinId: string;
561
+ amount: string;
562
+ legs: {
563
+ certified: number;
564
+ total: number;
565
+ };
566
+ deliveryPending: boolean;
567
+ createdAt: number;
568
+ }
550
569
  interface PaymentsV2 {
551
570
  assets(coinId?: string): Promise<Asset[]>;
552
571
  tokens(filter?: {
@@ -561,6 +580,8 @@ interface PaymentsV2 {
561
580
  receive(): Promise<{
562
581
  transfers: IncomingTransfer[];
563
582
  }>;
583
+ pendingTransfers(): Promise<PendingTransfer[]>;
584
+ resumeNow(): Promise<void>;
564
585
  readonly requests: PaymentsRequestsApi;
565
586
  }
566
587
  interface PaymentsV2Events {
@@ -919,6 +940,12 @@ interface FacadeSession {
919
940
  start(): Promise<void>;
920
941
  stop(): Promise<void>;
921
942
  subscribeStream(stream: 'inventory' | 'mailbox' | 'payment_requests', handler: () => void): () => void;
943
+ /**
944
+ * Optional connection-status feed (same wiring pattern as the streams; the
945
+ * emission point is the session's existing `connection:status` transition).
946
+ * The facade's heartbeat resets its backoff on a 'connected' recovery.
947
+ */
948
+ subscribeStatus?(handler: (status: 'connected' | 'degraded' | 'offline') => void): () => void;
922
949
  }
923
950
  interface IntentWireLike {
924
951
  transferId: string;
@@ -980,6 +1007,12 @@ declare class PaymentsFacade implements PaymentsV2 {
980
1007
  private readonly pendingOps;
981
1008
  private unsubscribers;
982
1009
  private started;
1010
+ private readonly heartbeat;
1011
+ private readonly converger;
1012
+ /** Resume single-flight (§7): ticks, start() and resumeNow() coalesce onto ONE pass. */
1013
+ private readonly resumeFlight;
1014
+ /** §7 ownership: ids with an in-process machine attempt — the pass never adopts one. */
1015
+ private readonly activeMoneyOps;
983
1016
  constructor(deps: PaymentsFacadeDeps);
984
1017
  start(): Promise<void>;
985
1018
  /** §7 same-address restart gate: resolves only after in-flight ops settle. */
@@ -994,11 +1027,17 @@ declare class PaymentsFacade implements PaymentsV2 {
994
1027
  before?: string;
995
1028
  limit?: number;
996
1029
  }): Promise<HistoryPage>;
1030
+ /** §4 pending-transfers UI surface — derived on read, never cached (convergence.ts). */
1031
+ pendingTransfers(): Promise<PendingTransfer[]>;
997
1032
  send(request: SendRequest): Promise<TransferResult>;
998
1033
  receive(): Promise<{
999
1034
  transfers: IncomingTransfer[];
1000
1035
  }>;
1001
1036
  mint(coinId: string, amount: bigint): Promise<MintResult>;
1037
+ resumeNow(): Promise<void>;
1038
+ /** One single-flighted pass + its reschedule: concurrent callers coalesce. */
1039
+ private runConvergencePass;
1040
+ private nowMs;
1002
1041
  private sendWithPolicy;
1003
1042
  /** §5.6 cross-network deposit trap: refused BEFORE any reserve/certification. */
1004
1043
  private requireSameNetworkRecipient;
@@ -1043,18 +1082,22 @@ declare class PaymentsFacade implements PaymentsV2 {
1043
1082
  private stampTransferId;
1044
1083
  private softAbort;
1045
1084
  private mintInner;
1085
+ private mintUnderJournal;
1046
1086
  private finalizeMint;
1087
+ /** @returns how many journal entries were RESOLVED (cleared) — heartbeat progress. */
1047
1088
  private replayMints;
1048
1089
  private replayMint;
1049
1090
  private mintParams;
1050
1091
  private tokenInServerInventory;
1051
1092
  private engine;
1052
1093
  private newId;
1053
- private runResume;
1054
1094
  private seedHeldStates;
1055
1095
  private toUiToken;
1056
1096
  private track;
1057
1097
  private trackTail;
1058
1098
  }
1059
1099
 
1060
- export { ATTENTION_MINT_UNRESOLVED, type ApplyDeltaResult, type DeliverOptions, type DeliveryJournalEntry, type DeliveryPort, type DeliveryReceipt, type DeterministicMintCapable, type FacadeClient, type FacadeSession, type HistoryEntry, type HistoryPage, type IncomingDelivery, type IntentBackstopEntry, type IntentPayload, type InventoryAsset, type InventoryItem, type InventoryPage, MAX_RESELECT, type MintJournalEntry, type MintResult, type OpOutcome, type OutcomeClass, type PaymentRequestStatus, type PaymentRequestView, PaymentsFacade, type PaymentsFacadeDeps, type PaymentsRequestsApi, type PaymentsV2, type PaymentsV2Events, type PlannedOp, type RecipientInfo, STORE_KEYS, type ScopedKV, type SendRequest, type SettlingLink, type ShortfallEntry, type StoragePort, type StreamCursor, type StreamName, createScopedKV, supportsDeterministicMint };
1100
+ declare const HEARTBEAT_SEED_MS = 5000;
1101
+ declare const HEARTBEAT_CAP_MS = 120000;
1102
+
1103
+ export { ATTENTION_MINT_UNRESOLVED, type ApplyDeltaResult, type DeliverOptions, type DeliveryJournalEntry, type DeliveryPort, type DeliveryReceipt, type DeterministicMintCapable, type FacadeClient, type FacadeSession, HEARTBEAT_CAP_MS, HEARTBEAT_SEED_MS, type HistoryEntry, type HistoryPage, type IncomingDelivery, type IntentBackstopEntry, type IntentPayload, type InventoryAsset, type InventoryItem, type InventoryPage, MAX_RESELECT, type MintJournalEntry, type MintResult, type OpOutcome, type OutcomeClass, type PaymentRequestStatus, type PaymentRequestView, PaymentsFacade, type PaymentsFacadeDeps, type PaymentsRequestsApi, type PaymentsV2, type PaymentsV2Events, type PendingTransfer, type PlannedOp, type RecipientInfo, STORE_KEYS, type ScopedKV, type SendRequest, type SettlingLink, type ShortfallEntry, type StoragePort, type StreamCursor, type StreamName, createScopedKV, supportsDeterministicMint };
@@ -547,6 +547,25 @@ interface PaymentsRequestsApi {
547
547
  decline(id: string): Promise<void>;
548
548
  dismissProcessed(): void;
549
549
  }
550
+ /**
551
+ * A pending-transfers row, derived ON READ from the §6 stores (intent backstop
552
+ * + delivery journal + shortfalls) — never a cached mirror. kind 'shortfall' =
553
+ * a completed partial (#690) whose `amount` is the remainder still owed;
554
+ * legs.certified counts journaled legs (certified, delivery still owed).
555
+ */
556
+ interface PendingTransfer {
557
+ transferId: string;
558
+ kind: 'open' | 'shortfall';
559
+ recipient: string;
560
+ coinId: string;
561
+ amount: string;
562
+ legs: {
563
+ certified: number;
564
+ total: number;
565
+ };
566
+ deliveryPending: boolean;
567
+ createdAt: number;
568
+ }
550
569
  interface PaymentsV2 {
551
570
  assets(coinId?: string): Promise<Asset[]>;
552
571
  tokens(filter?: {
@@ -561,6 +580,8 @@ interface PaymentsV2 {
561
580
  receive(): Promise<{
562
581
  transfers: IncomingTransfer[];
563
582
  }>;
583
+ pendingTransfers(): Promise<PendingTransfer[]>;
584
+ resumeNow(): Promise<void>;
564
585
  readonly requests: PaymentsRequestsApi;
565
586
  }
566
587
  interface PaymentsV2Events {
@@ -919,6 +940,12 @@ interface FacadeSession {
919
940
  start(): Promise<void>;
920
941
  stop(): Promise<void>;
921
942
  subscribeStream(stream: 'inventory' | 'mailbox' | 'payment_requests', handler: () => void): () => void;
943
+ /**
944
+ * Optional connection-status feed (same wiring pattern as the streams; the
945
+ * emission point is the session's existing `connection:status` transition).
946
+ * The facade's heartbeat resets its backoff on a 'connected' recovery.
947
+ */
948
+ subscribeStatus?(handler: (status: 'connected' | 'degraded' | 'offline') => void): () => void;
922
949
  }
923
950
  interface IntentWireLike {
924
951
  transferId: string;
@@ -980,6 +1007,12 @@ declare class PaymentsFacade implements PaymentsV2 {
980
1007
  private readonly pendingOps;
981
1008
  private unsubscribers;
982
1009
  private started;
1010
+ private readonly heartbeat;
1011
+ private readonly converger;
1012
+ /** Resume single-flight (§7): ticks, start() and resumeNow() coalesce onto ONE pass. */
1013
+ private readonly resumeFlight;
1014
+ /** §7 ownership: ids with an in-process machine attempt — the pass never adopts one. */
1015
+ private readonly activeMoneyOps;
983
1016
  constructor(deps: PaymentsFacadeDeps);
984
1017
  start(): Promise<void>;
985
1018
  /** §7 same-address restart gate: resolves only after in-flight ops settle. */
@@ -994,11 +1027,17 @@ declare class PaymentsFacade implements PaymentsV2 {
994
1027
  before?: string;
995
1028
  limit?: number;
996
1029
  }): Promise<HistoryPage>;
1030
+ /** §4 pending-transfers UI surface — derived on read, never cached (convergence.ts). */
1031
+ pendingTransfers(): Promise<PendingTransfer[]>;
997
1032
  send(request: SendRequest): Promise<TransferResult>;
998
1033
  receive(): Promise<{
999
1034
  transfers: IncomingTransfer[];
1000
1035
  }>;
1001
1036
  mint(coinId: string, amount: bigint): Promise<MintResult>;
1037
+ resumeNow(): Promise<void>;
1038
+ /** One single-flighted pass + its reschedule: concurrent callers coalesce. */
1039
+ private runConvergencePass;
1040
+ private nowMs;
1002
1041
  private sendWithPolicy;
1003
1042
  /** §5.6 cross-network deposit trap: refused BEFORE any reserve/certification. */
1004
1043
  private requireSameNetworkRecipient;
@@ -1043,18 +1082,22 @@ declare class PaymentsFacade implements PaymentsV2 {
1043
1082
  private stampTransferId;
1044
1083
  private softAbort;
1045
1084
  private mintInner;
1085
+ private mintUnderJournal;
1046
1086
  private finalizeMint;
1087
+ /** @returns how many journal entries were RESOLVED (cleared) — heartbeat progress. */
1047
1088
  private replayMints;
1048
1089
  private replayMint;
1049
1090
  private mintParams;
1050
1091
  private tokenInServerInventory;
1051
1092
  private engine;
1052
1093
  private newId;
1053
- private runResume;
1054
1094
  private seedHeldStates;
1055
1095
  private toUiToken;
1056
1096
  private track;
1057
1097
  private trackTail;
1058
1098
  }
1059
1099
 
1060
- export { ATTENTION_MINT_UNRESOLVED, type ApplyDeltaResult, type DeliverOptions, type DeliveryJournalEntry, type DeliveryPort, type DeliveryReceipt, type DeterministicMintCapable, type FacadeClient, type FacadeSession, type HistoryEntry, type HistoryPage, type IncomingDelivery, type IntentBackstopEntry, type IntentPayload, type InventoryAsset, type InventoryItem, type InventoryPage, MAX_RESELECT, type MintJournalEntry, type MintResult, type OpOutcome, type OutcomeClass, type PaymentRequestStatus, type PaymentRequestView, PaymentsFacade, type PaymentsFacadeDeps, type PaymentsRequestsApi, type PaymentsV2, type PaymentsV2Events, type PlannedOp, type RecipientInfo, STORE_KEYS, type ScopedKV, type SendRequest, type SettlingLink, type ShortfallEntry, type StoragePort, type StreamCursor, type StreamName, createScopedKV, supportsDeterministicMint };
1100
+ declare const HEARTBEAT_SEED_MS = 5000;
1101
+ declare const HEARTBEAT_CAP_MS = 120000;
1102
+
1103
+ export { ATTENTION_MINT_UNRESOLVED, type ApplyDeltaResult, type DeliverOptions, type DeliveryJournalEntry, type DeliveryPort, type DeliveryReceipt, type DeterministicMintCapable, type FacadeClient, type FacadeSession, HEARTBEAT_CAP_MS, HEARTBEAT_SEED_MS, type HistoryEntry, type HistoryPage, type IncomingDelivery, type IntentBackstopEntry, type IntentPayload, type InventoryAsset, type InventoryItem, type InventoryPage, MAX_RESELECT, type MintJournalEntry, type MintResult, type OpOutcome, type OutcomeClass, type PaymentRequestStatus, type PaymentRequestView, PaymentsFacade, type PaymentsFacadeDeps, type PaymentsRequestsApi, type PaymentsV2, type PaymentsV2Events, type PendingTransfer, type PlannedOp, type RecipientInfo, STORE_KEYS, type ScopedKV, type SendRequest, type SettlingLink, type ShortfallEntry, type StoragePort, type StreamCursor, type StreamName, createScopedKV, supportsDeterministicMint };