@unicitylabs/sphere-sdk 0.14.11-dev.4 → 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.
package/dist/index.cjs CHANGED
@@ -13034,7 +13034,7 @@ var InventoryView = class {
13034
13034
 
13035
13035
  // modules/payments-v2/receive/Receive.ts
13036
13036
  var ACK_BATCH_SIZE = 200;
13037
- var REFRESH_INTERVAL_MS = 750;
13037
+ var REFRESH_INTERVAL_MS = 2500;
13038
13038
  var POLL_INTERVAL_MS = 3e4;
13039
13039
  var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
13040
13040
  function receivedDedupKey(tokenId, stateHash) {
@@ -13963,15 +13963,25 @@ function parseAmount(raw) {
13963
13963
  function supportsDeterministicMint(engine) {
13964
13964
  return engine.deterministicMint === true;
13965
13965
  }
13966
- function makeSingleFlightRefresh(refresh) {
13966
+ function makeCoalescedRefresh(refresh) {
13967
13967
  let inFlight = false;
13968
- return () => {
13969
- if (inFlight) return;
13968
+ let queued = false;
13969
+ const run = () => {
13970
13970
  inFlight = true;
13971
13971
  void refresh().catch(() => void 0).finally(() => {
13972
13972
  inFlight = false;
13973
+ if (!queued) return;
13974
+ queued = false;
13975
+ run();
13973
13976
  });
13974
13977
  };
13978
+ return () => {
13979
+ if (inFlight) {
13980
+ queued = true;
13981
+ return;
13982
+ }
13983
+ run();
13984
+ };
13975
13985
  }
13976
13986
  function composeFacadeParts(deps, hooks) {
13977
13987
  const ownPubkeyBytes = hexToBytes4(deps.ownPubkey);
@@ -14094,10 +14104,8 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
14094
14104
  registry: deps.registry,
14095
14105
  recordReceived: (record) => recordReceived(historyStore, record),
14096
14106
  emit: (event, transfer) => deps.emit(event, transfer),
14097
- // Single-flight: view.delta() enqueues on a strict-FIFO SerialChain, so
14098
- // firing per throttle tick regardless of the last one builds a queue that
14099
- // drains in a burst at the END — a slower version of the bug being fixed.
14100
- refreshView: makeSingleFlightRefresh(() => view.delta()),
14107
+ // Coalesced — see makeCoalescedRefresh.
14108
+ refreshView: makeCoalescedRefresh(() => view.delta()),
14101
14109
  attention: (transferId, code, detail) => {
14102
14110
  deps.emit(
14103
14111
  "transfer:attention",
@@ -14149,6 +14157,7 @@ var PaymentsFacade = class {
14149
14157
  isActiveOp: (id) => this.activeMoneyOps.has(id)
14150
14158
  });
14151
14159
  this.view = parts.view;
14160
+ this.wakeRefresh = makeCoalescedRefresh(() => this.view.delta());
14152
14161
  this.ledger = parts.ledger;
14153
14162
  this.queue = parts.queue;
14154
14163
  this.machine = parts.machine;
@@ -14178,6 +14187,7 @@ var PaymentsFacade = class {
14178
14187
  now: () => this.nowMs()
14179
14188
  });
14180
14189
  }
14190
+ wakeRefresh;
14181
14191
  prewarmed = new PrewarmCache();
14182
14192
  view;
14183
14193
  ledger;
@@ -14216,9 +14226,7 @@ var PaymentsFacade = class {
14216
14226
  this.deps.session.subscribeStream("mailbox", () => {
14217
14227
  this.trackTail(this.receiveLoop.drainOnce());
14218
14228
  }),
14219
- this.deps.session.subscribeStream("inventory", () => {
14220
- this.trackTail(this.view.delta());
14221
- }),
14229
+ this.deps.session.subscribeStream("inventory", this.wakeRefresh),
14222
14230
  this.deps.session.subscribeStream("payment_requests", () => {
14223
14231
  this.trackTail(this.requests.drainIncoming());
14224
14232
  })