@unicitylabs/sphere-sdk 0.14.11-dev.1 → 0.14.11-dev.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.
@@ -12884,6 +12884,7 @@ var InventoryView = class {
12884
12884
 
12885
12885
  // modules/payments-v2/receive/Receive.ts
12886
12886
  var ACK_BATCH_SIZE = 200;
12887
+ var REFRESH_INTERVAL_MS = 750;
12887
12888
  var POLL_INTERVAL_MS = 3e4;
12888
12889
  var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
12889
12890
  function receivedDedupKey(tokenId, stateHash) {
@@ -12900,6 +12901,7 @@ var Receive = class {
12900
12901
  drainFlight = new SingleFlight();
12901
12902
  pollTimer = null;
12902
12903
  unsubscribeWake = null;
12904
+ lastRefreshAt = 0;
12903
12905
  drainOnce() {
12904
12906
  return this.drainFlight.run(() => this.doDrain());
12905
12907
  }
@@ -12917,6 +12919,14 @@ var Receive = class {
12917
12919
  this.unsubscribeWake?.();
12918
12920
  this.unsubscribeWake = null;
12919
12921
  }
12922
+ /** Ask for a mirror refresh at most once per REFRESH_INTERVAL_MS. */
12923
+ maybeRefresh(deps) {
12924
+ if (deps.refreshView === void 0) return;
12925
+ const now = deps.now?.() ?? Date.now();
12926
+ if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
12927
+ this.lastRefreshAt = now;
12928
+ deps.refreshView();
12929
+ }
12920
12930
  async doDrain() {
12921
12931
  const deps = this.deps;
12922
12932
  const engine = deps.engine();
@@ -12930,6 +12940,7 @@ var Receive = class {
12930
12940
  for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
12931
12941
  await this.processEntry(deps, engine, entry, pending, stored);
12932
12942
  if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
12943
+ if (stored.length > 0) this.maybeRefresh(deps);
12933
12944
  }
12934
12945
  await flushAcks(deps, pending, pageEpoch);
12935
12946
  const served = deps.delivery.incomingEpoch();
@@ -13829,7 +13840,7 @@ function composeFacadeParts(deps, hooks) {
13829
13840
  machineDeps,
13830
13841
  machine: new TransferMachine(machineDeps),
13831
13842
  heldStates,
13832
- receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
13843
+ receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
13833
13844
  requests: buildRequests(deps, hooks),
13834
13845
  restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
13835
13846
  };
@@ -13896,7 +13907,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
13896
13907
  }
13897
13908
  };
13898
13909
  }
13899
- function buildReceive(deps, hooks, historyStore, heldStates) {
13910
+ function buildReceive(deps, hooks, historyStore, heldStates, view) {
13900
13911
  return new Receive({
13901
13912
  delivery: deps.deliveryPort,
13902
13913
  engine: () => hooks.engine(),
@@ -13910,6 +13921,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
13910
13921
  registry: deps.registry,
13911
13922
  recordReceived: (record) => recordReceived(historyStore, record),
13912
13923
  emit: (event, transfer) => deps.emit(event, transfer),
13924
+ // The mirror is the balance the wallet renders; refresh it as the drain runs
13925
+ // so a multi-token receive lands progressively instead of all at the end.
13926
+ refreshView: () => {
13927
+ void view.delta().catch(() => void 0);
13928
+ },
13913
13929
  attention: (transferId, code, detail) => {
13914
13930
  deps.emit(
13915
13931
  "transfer:attention",