@unicitylabs/sphere-sdk 0.14.11-dev.1 → 0.14.11-dev.3
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 +31 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +31 -2
- 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 +31 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +31 -2
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +31 -2
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3198,6 +3198,7 @@ var logger = {
|
|
|
3198
3198
|
|
|
3199
3199
|
// modules/payments-v2/receive/Receive.ts
|
|
3200
3200
|
var ACK_BATCH_SIZE = 200;
|
|
3201
|
+
var REFRESH_INTERVAL_MS = 750;
|
|
3201
3202
|
var POLL_INTERVAL_MS = 3e4;
|
|
3202
3203
|
var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
|
|
3203
3204
|
function receivedDedupKey(tokenId, stateHash) {
|
|
@@ -3214,6 +3215,7 @@ var Receive = class {
|
|
|
3214
3215
|
drainFlight = new SingleFlight();
|
|
3215
3216
|
pollTimer = null;
|
|
3216
3217
|
unsubscribeWake = null;
|
|
3218
|
+
lastRefreshAt = 0;
|
|
3217
3219
|
drainOnce() {
|
|
3218
3220
|
return this.drainFlight.run(() => this.doDrain());
|
|
3219
3221
|
}
|
|
@@ -3231,8 +3233,28 @@ var Receive = class {
|
|
|
3231
3233
|
this.unsubscribeWake?.();
|
|
3232
3234
|
this.unsubscribeWake = null;
|
|
3233
3235
|
}
|
|
3236
|
+
/**
|
|
3237
|
+
* Flush what has been accepted, then ask for a mirror refresh — at most once
|
|
3238
|
+
* per REFRESH_INTERVAL_MS.
|
|
3239
|
+
*
|
|
3240
|
+
* The flush is not incidental. A `claimed` ack is what materializes a token
|
|
3241
|
+
* into SERVER inventory, and acks otherwise sit queued until ACK_BATCH_SIZE
|
|
3242
|
+
* (200) — so for any ordinary drain, including the 54-token case this exists
|
|
3243
|
+
* for, refreshing before the flush would query an inventory holding none of
|
|
3244
|
+
* the tokens just accepted, and the balance would still only move at the end.
|
|
3245
|
+
* Ordering is preserved: store() still precedes the ack (§5.7).
|
|
3246
|
+
*/
|
|
3247
|
+
async maybeRefresh(deps, pending, epochOf) {
|
|
3248
|
+
if (deps.refreshView === void 0) return;
|
|
3249
|
+
const now = deps.now?.() ?? Date.now();
|
|
3250
|
+
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
3251
|
+
this.lastRefreshAt = now;
|
|
3252
|
+
await flushAcks(deps, pending, epochOf);
|
|
3253
|
+
deps.refreshView();
|
|
3254
|
+
}
|
|
3234
3255
|
async doDrain() {
|
|
3235
3256
|
const deps = this.deps;
|
|
3257
|
+
this.lastRefreshAt = deps.now?.() ?? Date.now();
|
|
3236
3258
|
const engine = deps.engine();
|
|
3237
3259
|
const stored = [];
|
|
3238
3260
|
const pending = [];
|
|
@@ -3242,8 +3264,10 @@ var Receive = class {
|
|
|
3242
3264
|
let basis = record !== null && record.syncEpoch === deps.syncEpoch() ? record : null;
|
|
3243
3265
|
for (let pass = 0; pass < 2; pass++) {
|
|
3244
3266
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
3267
|
+
const storedBefore = stored.length;
|
|
3245
3268
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3246
3269
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3270
|
+
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
3247
3271
|
}
|
|
3248
3272
|
await flushAcks(deps, pending, pageEpoch);
|
|
3249
3273
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -4143,7 +4167,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
4143
4167
|
machineDeps,
|
|
4144
4168
|
machine: new TransferMachine(machineDeps),
|
|
4145
4169
|
heldStates,
|
|
4146
|
-
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
|
|
4170
|
+
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
|
|
4147
4171
|
requests: buildRequests(deps, hooks),
|
|
4148
4172
|
restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
|
|
4149
4173
|
};
|
|
@@ -4210,7 +4234,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
|
|
|
4210
4234
|
}
|
|
4211
4235
|
};
|
|
4212
4236
|
}
|
|
4213
|
-
function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
4237
|
+
function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
4214
4238
|
return new Receive({
|
|
4215
4239
|
delivery: deps.deliveryPort,
|
|
4216
4240
|
engine: () => hooks.engine(),
|
|
@@ -4224,6 +4248,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
|
4224
4248
|
registry: deps.registry,
|
|
4225
4249
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
4226
4250
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
4251
|
+
// The mirror is the balance the wallet renders; refresh it as the drain runs
|
|
4252
|
+
// so a multi-token receive lands progressively instead of all at the end.
|
|
4253
|
+
refreshView: () => {
|
|
4254
|
+
void view.delta().catch(() => void 0);
|
|
4255
|
+
},
|
|
4227
4256
|
attention: (transferId, code, detail) => {
|
|
4228
4257
|
deps.emit(
|
|
4229
4258
|
"transfer:attention",
|