@unicitylabs/sphere-sdk 0.14.11-dev.1 → 0.14.11-dev.2
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 +18 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +18 -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 +18 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +18 -2
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +18 -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,6 +3233,14 @@ var Receive = class {
|
|
|
3231
3233
|
this.unsubscribeWake?.();
|
|
3232
3234
|
this.unsubscribeWake = null;
|
|
3233
3235
|
}
|
|
3236
|
+
/** Ask for a mirror refresh at most once per REFRESH_INTERVAL_MS. */
|
|
3237
|
+
maybeRefresh(deps) {
|
|
3238
|
+
if (deps.refreshView === void 0) return;
|
|
3239
|
+
const now = deps.now?.() ?? Date.now();
|
|
3240
|
+
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
3241
|
+
this.lastRefreshAt = now;
|
|
3242
|
+
deps.refreshView();
|
|
3243
|
+
}
|
|
3234
3244
|
async doDrain() {
|
|
3235
3245
|
const deps = this.deps;
|
|
3236
3246
|
const engine = deps.engine();
|
|
@@ -3244,6 +3254,7 @@ var Receive = class {
|
|
|
3244
3254
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
3245
3255
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3246
3256
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3257
|
+
if (stored.length > 0) this.maybeRefresh(deps);
|
|
3247
3258
|
}
|
|
3248
3259
|
await flushAcks(deps, pending, pageEpoch);
|
|
3249
3260
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -4143,7 +4154,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
4143
4154
|
machineDeps,
|
|
4144
4155
|
machine: new TransferMachine(machineDeps),
|
|
4145
4156
|
heldStates,
|
|
4146
|
-
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
|
|
4157
|
+
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
|
|
4147
4158
|
requests: buildRequests(deps, hooks),
|
|
4148
4159
|
restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
|
|
4149
4160
|
};
|
|
@@ -4210,7 +4221,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
|
|
|
4210
4221
|
}
|
|
4211
4222
|
};
|
|
4212
4223
|
}
|
|
4213
|
-
function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
4224
|
+
function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
4214
4225
|
return new Receive({
|
|
4215
4226
|
delivery: deps.deliveryPort,
|
|
4216
4227
|
engine: () => hooks.engine(),
|
|
@@ -4224,6 +4235,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
|
4224
4235
|
registry: deps.registry,
|
|
4225
4236
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
4226
4237
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
4238
|
+
// The mirror is the balance the wallet renders; refresh it as the drain runs
|
|
4239
|
+
// so a multi-token receive lands progressively instead of all at the end.
|
|
4240
|
+
refreshView: () => {
|
|
4241
|
+
void view.delta().catch(() => void 0);
|
|
4242
|
+
},
|
|
4227
4243
|
attention: (transferId, code, detail) => {
|
|
4228
4244
|
deps.emit(
|
|
4229
4245
|
"transfer:attention",
|