@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.
@@ -3204,7 +3204,7 @@ var logger = {
3204
3204
 
3205
3205
  // modules/payments-v2/receive/Receive.ts
3206
3206
  var ACK_BATCH_SIZE = 200;
3207
- var REFRESH_INTERVAL_MS = 750;
3207
+ var REFRESH_INTERVAL_MS = 2500;
3208
3208
  var POLL_INTERVAL_MS = 3e4;
3209
3209
  var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
3210
3210
  function receivedDedupKey(tokenId, stateHash) {
@@ -4133,15 +4133,25 @@ function parseAmount(raw) {
4133
4133
  function supportsDeterministicMint(engine) {
4134
4134
  return engine.deterministicMint === true;
4135
4135
  }
4136
- function makeSingleFlightRefresh(refresh) {
4136
+ function makeCoalescedRefresh(refresh) {
4137
4137
  let inFlight = false;
4138
- return () => {
4139
- if (inFlight) return;
4138
+ let queued = false;
4139
+ const run = () => {
4140
4140
  inFlight = true;
4141
4141
  void refresh().catch(() => void 0).finally(() => {
4142
4142
  inFlight = false;
4143
+ if (!queued) return;
4144
+ queued = false;
4145
+ run();
4143
4146
  });
4144
4147
  };
4148
+ return () => {
4149
+ if (inFlight) {
4150
+ queued = true;
4151
+ return;
4152
+ }
4153
+ run();
4154
+ };
4145
4155
  }
4146
4156
  function composeFacadeParts(deps, hooks) {
4147
4157
  const ownPubkeyBytes = hexToBytes(deps.ownPubkey);
@@ -4264,10 +4274,8 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
4264
4274
  registry: deps.registry,
4265
4275
  recordReceived: (record) => recordReceived(historyStore, record),
4266
4276
  emit: (event, transfer) => deps.emit(event, transfer),
4267
- // Single-flight: view.delta() enqueues on a strict-FIFO SerialChain, so
4268
- // firing per throttle tick regardless of the last one builds a queue that
4269
- // drains in a burst at the END — a slower version of the bug being fixed.
4270
- refreshView: makeSingleFlightRefresh(() => view.delta()),
4277
+ // Coalesced — see makeCoalescedRefresh.
4278
+ refreshView: makeCoalescedRefresh(() => view.delta()),
4271
4279
  attention: (transferId, code, detail) => {
4272
4280
  deps.emit(
4273
4281
  "transfer:attention",
@@ -4319,6 +4327,7 @@ var PaymentsFacade = class {
4319
4327
  isActiveOp: (id) => this.activeMoneyOps.has(id)
4320
4328
  });
4321
4329
  this.view = parts.view;
4330
+ this.wakeRefresh = makeCoalescedRefresh(() => this.view.delta());
4322
4331
  this.ledger = parts.ledger;
4323
4332
  this.queue = parts.queue;
4324
4333
  this.machine = parts.machine;
@@ -4348,6 +4357,7 @@ var PaymentsFacade = class {
4348
4357
  now: () => this.nowMs()
4349
4358
  });
4350
4359
  }
4360
+ wakeRefresh;
4351
4361
  prewarmed = new PrewarmCache();
4352
4362
  view;
4353
4363
  ledger;
@@ -4386,9 +4396,7 @@ var PaymentsFacade = class {
4386
4396
  this.deps.session.subscribeStream("mailbox", () => {
4387
4397
  this.trackTail(this.receiveLoop.drainOnce());
4388
4398
  }),
4389
- this.deps.session.subscribeStream("inventory", () => {
4390
- this.trackTail(this.view.delta());
4391
- }),
4399
+ this.deps.session.subscribeStream("inventory", this.wakeRefresh),
4392
4400
  this.deps.session.subscribeStream("payment_requests", () => {
4393
4401
  this.trackTail(this.requests.drainIncoming());
4394
4402
  })