@unicitylabs/sphere-sdk 0.14.11-dev.5 → 0.14.11-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.
@@ -13905,15 +13905,25 @@ function parseAmount(raw) {
13905
13905
  function supportsDeterministicMint(engine) {
13906
13906
  return engine.deterministicMint === true;
13907
13907
  }
13908
- function makeSingleFlightRefresh(refresh) {
13908
+ function makeCoalescedRefresh(refresh) {
13909
13909
  let inFlight = false;
13910
- return () => {
13911
- if (inFlight) return;
13910
+ let queued = false;
13911
+ const run = () => {
13912
13912
  inFlight = true;
13913
13913
  void refresh().catch(() => void 0).finally(() => {
13914
13914
  inFlight = false;
13915
+ if (!queued) return;
13916
+ queued = false;
13917
+ run();
13915
13918
  });
13916
13919
  };
13920
+ return () => {
13921
+ if (inFlight) {
13922
+ queued = true;
13923
+ return;
13924
+ }
13925
+ run();
13926
+ };
13917
13927
  }
13918
13928
  function composeFacadeParts(deps, hooks) {
13919
13929
  const ownPubkeyBytes = hexToBytes4(deps.ownPubkey);
@@ -14036,10 +14046,8 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
14036
14046
  registry: deps.registry,
14037
14047
  recordReceived: (record) => recordReceived(historyStore, record),
14038
14048
  emit: (event, transfer) => deps.emit(event, transfer),
14039
- // Single-flight: view.delta() enqueues on a strict-FIFO SerialChain, so
14040
- // firing per throttle tick regardless of the last one builds a queue that
14041
- // drains in a burst at the END — a slower version of the bug being fixed.
14042
- refreshView: makeSingleFlightRefresh(() => view.delta()),
14049
+ // Coalesced — see makeCoalescedRefresh.
14050
+ refreshView: makeCoalescedRefresh(() => view.delta()),
14043
14051
  attention: (transferId, code, detail) => {
14044
14052
  deps.emit(
14045
14053
  "transfer:attention",
@@ -14091,6 +14099,7 @@ var PaymentsFacade = class {
14091
14099
  isActiveOp: (id) => this.activeMoneyOps.has(id)
14092
14100
  });
14093
14101
  this.view = parts.view;
14102
+ this.wakeRefresh = makeCoalescedRefresh(() => this.view.delta());
14094
14103
  this.ledger = parts.ledger;
14095
14104
  this.queue = parts.queue;
14096
14105
  this.machine = parts.machine;
@@ -14120,6 +14129,7 @@ var PaymentsFacade = class {
14120
14129
  now: () => this.nowMs()
14121
14130
  });
14122
14131
  }
14132
+ wakeRefresh;
14123
14133
  prewarmed = new PrewarmCache();
14124
14134
  view;
14125
14135
  ledger;
@@ -14158,9 +14168,7 @@ var PaymentsFacade = class {
14158
14168
  this.deps.session.subscribeStream("mailbox", () => {
14159
14169
  this.trackTail(this.receiveLoop.drainOnce());
14160
14170
  }),
14161
- this.deps.session.subscribeStream("inventory", () => {
14162
- this.trackTail(this.view.delta());
14163
- }),
14171
+ this.deps.session.subscribeStream("inventory", this.wakeRefresh),
14164
14172
  this.deps.session.subscribeStream("payment_requests", () => {
14165
14173
  this.trackTail(this.requests.drainIncoming());
14166
14174
  })