@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.
@@ -12970,6 +12970,7 @@ var InventoryView = class {
12970
12970
 
12971
12971
  // modules/payments-v2/receive/Receive.ts
12972
12972
  var ACK_BATCH_SIZE = 200;
12973
+ var REFRESH_INTERVAL_MS = 750;
12973
12974
  var POLL_INTERVAL_MS = 3e4;
12974
12975
  var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
12975
12976
  function receivedDedupKey(tokenId, stateHash) {
@@ -12986,6 +12987,7 @@ var Receive = class {
12986
12987
  drainFlight = new SingleFlight();
12987
12988
  pollTimer = null;
12988
12989
  unsubscribeWake = null;
12990
+ lastRefreshAt = 0;
12989
12991
  drainOnce() {
12990
12992
  return this.drainFlight.run(() => this.doDrain());
12991
12993
  }
@@ -13003,6 +13005,14 @@ var Receive = class {
13003
13005
  this.unsubscribeWake?.();
13004
13006
  this.unsubscribeWake = null;
13005
13007
  }
13008
+ /** Ask for a mirror refresh at most once per REFRESH_INTERVAL_MS. */
13009
+ maybeRefresh(deps) {
13010
+ if (deps.refreshView === void 0) return;
13011
+ const now = deps.now?.() ?? Date.now();
13012
+ if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
13013
+ this.lastRefreshAt = now;
13014
+ deps.refreshView();
13015
+ }
13006
13016
  async doDrain() {
13007
13017
  const deps = this.deps;
13008
13018
  const engine = deps.engine();
@@ -13016,6 +13026,7 @@ var Receive = class {
13016
13026
  for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
13017
13027
  await this.processEntry(deps, engine, entry, pending, stored);
13018
13028
  if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
13029
+ if (stored.length > 0) this.maybeRefresh(deps);
13019
13030
  }
13020
13031
  await flushAcks(deps, pending, pageEpoch);
13021
13032
  const served = deps.delivery.incomingEpoch();
@@ -13915,7 +13926,7 @@ function composeFacadeParts(deps, hooks) {
13915
13926
  machineDeps,
13916
13927
  machine: new TransferMachine(machineDeps),
13917
13928
  heldStates,
13918
- receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
13929
+ receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
13919
13930
  requests: buildRequests(deps, hooks),
13920
13931
  restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
13921
13932
  };
@@ -13982,7 +13993,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
13982
13993
  }
13983
13994
  };
13984
13995
  }
13985
- function buildReceive(deps, hooks, historyStore, heldStates) {
13996
+ function buildReceive(deps, hooks, historyStore, heldStates, view) {
13986
13997
  return new Receive({
13987
13998
  delivery: deps.deliveryPort,
13988
13999
  engine: () => hooks.engine(),
@@ -13996,6 +14007,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
13996
14007
  registry: deps.registry,
13997
14008
  recordReceived: (record) => recordReceived(historyStore, record),
13998
14009
  emit: (event, transfer) => deps.emit(event, transfer),
14010
+ // The mirror is the balance the wallet renders; refresh it as the drain runs
14011
+ // so a multi-token receive lands progressively instead of all at the end.
14012
+ refreshView: () => {
14013
+ void view.delta().catch(() => void 0);
14014
+ },
13999
14015
  attention: (transferId, code, detail) => {
14000
14016
  deps.emit(
14001
14017
  "transfer:attention",