@unicitylabs/sphere-sdk 0.14.11-dev.2 → 0.14.11-dev.4
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 +38 -10
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +38 -10
- 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/index.cjs +38 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -10
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +38 -10
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +38 -10
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2889,6 +2889,12 @@ var InventoryView = class {
|
|
|
2889
2889
|
release(tokenId) {
|
|
2890
2890
|
if (this.inFlight.delete(tokenId)) this.deps.emit("inventory:updated");
|
|
2891
2891
|
}
|
|
2892
|
+
/** Release a whole set as ONE change (per-token emitted 54 events per send). */
|
|
2893
|
+
releaseMany(tokenIds) {
|
|
2894
|
+
let changed = false;
|
|
2895
|
+
for (const tokenId of tokenIds) if (this.inFlight.delete(tokenId)) changed = true;
|
|
2896
|
+
if (changed) this.deps.emit("inventory:updated");
|
|
2897
|
+
}
|
|
2892
2898
|
pinned(tokenId) {
|
|
2893
2899
|
return this.deps.isPinned?.(tokenId) ?? false;
|
|
2894
2900
|
}
|
|
@@ -3233,16 +3239,28 @@ var Receive = class {
|
|
|
3233
3239
|
this.unsubscribeWake?.();
|
|
3234
3240
|
this.unsubscribeWake = null;
|
|
3235
3241
|
}
|
|
3236
|
-
/**
|
|
3237
|
-
|
|
3242
|
+
/**
|
|
3243
|
+
* Flush what has been accepted, then ask for a mirror refresh — at most once
|
|
3244
|
+
* per REFRESH_INTERVAL_MS.
|
|
3245
|
+
*
|
|
3246
|
+
* The flush is not incidental. A `claimed` ack is what materializes a token
|
|
3247
|
+
* into SERVER inventory, and acks otherwise sit queued until ACK_BATCH_SIZE
|
|
3248
|
+
* (200) — so for any ordinary drain, including the 54-token case this exists
|
|
3249
|
+
* for, refreshing before the flush would query an inventory holding none of
|
|
3250
|
+
* the tokens just accepted, and the balance would still only move at the end.
|
|
3251
|
+
* Ordering is preserved: store() still precedes the ack (§5.7).
|
|
3252
|
+
*/
|
|
3253
|
+
async maybeRefresh(deps, pending, epochOf) {
|
|
3238
3254
|
if (deps.refreshView === void 0) return;
|
|
3239
3255
|
const now = deps.now?.() ?? Date.now();
|
|
3240
3256
|
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
3241
3257
|
this.lastRefreshAt = now;
|
|
3258
|
+
await flushAcks(deps, pending, epochOf);
|
|
3242
3259
|
deps.refreshView();
|
|
3243
3260
|
}
|
|
3244
3261
|
async doDrain() {
|
|
3245
3262
|
const deps = this.deps;
|
|
3263
|
+
this.lastRefreshAt = deps.now?.() ?? Date.now();
|
|
3246
3264
|
const engine = deps.engine();
|
|
3247
3265
|
const stored = [];
|
|
3248
3266
|
const pending = [];
|
|
@@ -3252,9 +3270,10 @@ var Receive = class {
|
|
|
3252
3270
|
let basis = record !== null && record.syncEpoch === deps.syncEpoch() ? record : null;
|
|
3253
3271
|
for (let pass = 0; pass < 2; pass++) {
|
|
3254
3272
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
3273
|
+
const storedBefore = stored.length;
|
|
3255
3274
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3256
3275
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3257
|
-
if (stored.length >
|
|
3276
|
+
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
3258
3277
|
}
|
|
3259
3278
|
await flushAcks(deps, pending, pageEpoch);
|
|
3260
3279
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -4114,6 +4133,16 @@ function parseAmount(raw) {
|
|
|
4114
4133
|
function supportsDeterministicMint(engine) {
|
|
4115
4134
|
return engine.deterministicMint === true;
|
|
4116
4135
|
}
|
|
4136
|
+
function makeSingleFlightRefresh(refresh) {
|
|
4137
|
+
let inFlight = false;
|
|
4138
|
+
return () => {
|
|
4139
|
+
if (inFlight) return;
|
|
4140
|
+
inFlight = true;
|
|
4141
|
+
void refresh().catch(() => void 0).finally(() => {
|
|
4142
|
+
inFlight = false;
|
|
4143
|
+
});
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4117
4146
|
function composeFacadeParts(deps, hooks) {
|
|
4118
4147
|
const ownPubkeyBytes = hexToBytes(deps.ownPubkey);
|
|
4119
4148
|
const ledger = new ReservationLedger();
|
|
@@ -4235,11 +4264,10 @@ function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
|
4235
4264
|
registry: deps.registry,
|
|
4236
4265
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
4237
4266
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
4238
|
-
//
|
|
4239
|
-
//
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
},
|
|
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()),
|
|
4243
4271
|
attention: (transferId, code, detail) => {
|
|
4244
4272
|
deps.emit(
|
|
4245
4273
|
"transfer:attention",
|
|
@@ -4684,7 +4712,7 @@ var PaymentsFacade = class {
|
|
|
4684
4712
|
settleFailure(transferId, coinId, releaseIds) {
|
|
4685
4713
|
this.ledger.cancel(transferId);
|
|
4686
4714
|
this.queue.clearExpectedChange(transferId);
|
|
4687
|
-
|
|
4715
|
+
this.view.releaseMany(releaseIds);
|
|
4688
4716
|
this.queue.notifyChange(coinId);
|
|
4689
4717
|
}
|
|
4690
4718
|
/** Open intent: sources stay reserved + in-flight (§5.2) until resume adopts them. */
|
|
@@ -4709,7 +4737,7 @@ var PaymentsFacade = class {
|
|
|
4709
4737
|
async refreshThenRelease(coinId, spentIds) {
|
|
4710
4738
|
try {
|
|
4711
4739
|
await this.view.delta();
|
|
4712
|
-
|
|
4740
|
+
this.view.releaseMany(spentIds);
|
|
4713
4741
|
} finally {
|
|
4714
4742
|
this.queue.notifyChange(coinId);
|
|
4715
4743
|
}
|