@unicitylabs/sphere-sdk 0.14.11-dev.7 → 0.14.11-dev.8
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/connect/index.cjs +1 -1
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +1 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +26 -12
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +26 -12
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +1 -1
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/wallet-api-v2/index.cjs +1 -0
- package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.js +1 -0
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +26 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +25 -12
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +25 -12
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -581,12 +581,19 @@ var SerialChain = class {
|
|
|
581
581
|
return run;
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
|
-
function coalesced(run) {
|
|
584
|
+
function coalesced(run, observe) {
|
|
585
585
|
let inFlight = false;
|
|
586
586
|
let queued = false;
|
|
587
587
|
const start = () => {
|
|
588
588
|
inFlight = true;
|
|
589
|
-
|
|
589
|
+
let running;
|
|
590
|
+
try {
|
|
591
|
+
running = run();
|
|
592
|
+
} catch {
|
|
593
|
+
running = Promise.resolve();
|
|
594
|
+
}
|
|
595
|
+
observe?.(running);
|
|
596
|
+
void running.catch(() => void 0).finally(() => {
|
|
590
597
|
inFlight = false;
|
|
591
598
|
if (!queued) return;
|
|
592
599
|
queued = false;
|
|
@@ -3293,6 +3300,17 @@ var Receive = class {
|
|
|
3293
3300
|
await flushAcks(deps, pending, epochOf);
|
|
3294
3301
|
deps.refreshView();
|
|
3295
3302
|
}
|
|
3303
|
+
/** One listing pass: process each entry, flushing and refreshing as it goes. */
|
|
3304
|
+
async drainPages(ctx, basis) {
|
|
3305
|
+
const { deps, engine, pending, stored, pageEpoch } = ctx;
|
|
3306
|
+
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
3307
|
+
const storedBefore = stored.length;
|
|
3308
|
+
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3309
|
+
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3310
|
+
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
3311
|
+
}
|
|
3312
|
+
await flushAcks(deps, pending, pageEpoch);
|
|
3313
|
+
}
|
|
3296
3314
|
async doDrain() {
|
|
3297
3315
|
const deps = this.deps;
|
|
3298
3316
|
this.lastRefreshAt = deps.now?.() ?? Date.now();
|
|
@@ -3304,13 +3322,7 @@ var Receive = class {
|
|
|
3304
3322
|
const record = await deps.kv.get(STORE_KEYS.streamCursor("mailbox"));
|
|
3305
3323
|
let basis = record !== null && record.syncEpoch === deps.syncEpoch() ? record : null;
|
|
3306
3324
|
for (let pass = 0; pass < 2; pass++) {
|
|
3307
|
-
|
|
3308
|
-
const storedBefore = stored.length;
|
|
3309
|
-
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3310
|
-
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3311
|
-
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
3312
|
-
}
|
|
3313
|
-
await flushAcks(deps, pending, pageEpoch);
|
|
3325
|
+
await this.drainPages({ deps, engine, pending, stored, pageEpoch }, basis);
|
|
3314
3326
|
const served = deps.delivery.incomingEpoch();
|
|
3315
3327
|
if (basis === null || served === null || served === basis.syncEpoch) break;
|
|
3316
3328
|
await deps.kv.remove(STORE_KEYS.streamCursor("mailbox"));
|
|
@@ -3323,6 +3335,7 @@ var Receive = class {
|
|
|
3323
3335
|
logger.warn("PaymentsV2", "receive ack flush failed \u2014 cursor holds at the acked prefix:", flushErr);
|
|
3324
3336
|
});
|
|
3325
3337
|
}
|
|
3338
|
+
if (stored.length > 0) deps.refreshView?.();
|
|
3326
3339
|
return stored;
|
|
3327
3340
|
}
|
|
3328
3341
|
async processEntry(deps, engine, entry, pending, stored) {
|
|
@@ -4253,7 +4266,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
4253
4266
|
const machineDeps = buildMachineDeps(deps, hooks, historyStore);
|
|
4254
4267
|
const machineStores = createMachineStores(deps.kv);
|
|
4255
4268
|
const heldStates = /* @__PURE__ */ new Map();
|
|
4256
|
-
const refreshView = coalesced(() => view.delta());
|
|
4269
|
+
const refreshView = coalesced(() => view.delta(), hooks.track);
|
|
4257
4270
|
return {
|
|
4258
4271
|
ownPubkeyBytes,
|
|
4259
4272
|
view,
|
|
@@ -4396,7 +4409,8 @@ var PaymentsFacade = class {
|
|
|
4396
4409
|
const parts = composeFacadeParts(deps, {
|
|
4397
4410
|
engine: () => this.engine(),
|
|
4398
4411
|
send: (request) => this.send(request),
|
|
4399
|
-
isActiveOp: (id) => this.activeMoneyOps.has(id)
|
|
4412
|
+
isActiveOp: (id) => this.activeMoneyOps.has(id),
|
|
4413
|
+
track: (op) => this.trackTail(op)
|
|
4400
4414
|
});
|
|
4401
4415
|
this.view = parts.view;
|
|
4402
4416
|
this.wakeRefresh = parts.refreshView;
|
|
@@ -4536,7 +4550,6 @@ var PaymentsFacade = class {
|
|
|
4536
4550
|
}
|
|
4537
4551
|
async receive() {
|
|
4538
4552
|
const transfers = await this.track(this.receiveLoop.drainOnce());
|
|
4539
|
-
if (transfers.length > 0) this.trackTail(this.view.delta());
|
|
4540
4553
|
return { transfers };
|
|
4541
4554
|
}
|
|
4542
4555
|
mint(coinId, amount) {
|