@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
|
@@ -3153,6 +3153,7 @@ var logger = {
|
|
|
3153
3153
|
|
|
3154
3154
|
// modules/payments-v2/receive/Receive.ts
|
|
3155
3155
|
var ACK_BATCH_SIZE = 200;
|
|
3156
|
+
var REFRESH_INTERVAL_MS = 750;
|
|
3156
3157
|
var POLL_INTERVAL_MS = 3e4;
|
|
3157
3158
|
var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
|
|
3158
3159
|
function receivedDedupKey(tokenId, stateHash) {
|
|
@@ -3169,6 +3170,7 @@ var Receive = class {
|
|
|
3169
3170
|
drainFlight = new SingleFlight();
|
|
3170
3171
|
pollTimer = null;
|
|
3171
3172
|
unsubscribeWake = null;
|
|
3173
|
+
lastRefreshAt = 0;
|
|
3172
3174
|
drainOnce() {
|
|
3173
3175
|
return this.drainFlight.run(() => this.doDrain());
|
|
3174
3176
|
}
|
|
@@ -3186,6 +3188,14 @@ var Receive = class {
|
|
|
3186
3188
|
this.unsubscribeWake?.();
|
|
3187
3189
|
this.unsubscribeWake = null;
|
|
3188
3190
|
}
|
|
3191
|
+
/** Ask for a mirror refresh at most once per REFRESH_INTERVAL_MS. */
|
|
3192
|
+
maybeRefresh(deps) {
|
|
3193
|
+
if (deps.refreshView === void 0) return;
|
|
3194
|
+
const now = deps.now?.() ?? Date.now();
|
|
3195
|
+
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
3196
|
+
this.lastRefreshAt = now;
|
|
3197
|
+
deps.refreshView();
|
|
3198
|
+
}
|
|
3189
3199
|
async doDrain() {
|
|
3190
3200
|
const deps = this.deps;
|
|
3191
3201
|
const engine = deps.engine();
|
|
@@ -3199,6 +3209,7 @@ var Receive = class {
|
|
|
3199
3209
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
3200
3210
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
3201
3211
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
3212
|
+
if (stored.length > 0) this.maybeRefresh(deps);
|
|
3202
3213
|
}
|
|
3203
3214
|
await flushAcks(deps, pending, pageEpoch);
|
|
3204
3215
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -4098,7 +4109,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
4098
4109
|
machineDeps,
|
|
4099
4110
|
machine: new TransferMachine(machineDeps),
|
|
4100
4111
|
heldStates,
|
|
4101
|
-
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
|
|
4112
|
+
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
|
|
4102
4113
|
requests: buildRequests(deps, hooks),
|
|
4103
4114
|
restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
|
|
4104
4115
|
};
|
|
@@ -4165,7 +4176,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
|
|
|
4165
4176
|
}
|
|
4166
4177
|
};
|
|
4167
4178
|
}
|
|
4168
|
-
function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
4179
|
+
function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
4169
4180
|
return new Receive({
|
|
4170
4181
|
delivery: deps.deliveryPort,
|
|
4171
4182
|
engine: () => hooks.engine(),
|
|
@@ -4179,6 +4190,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
|
4179
4190
|
registry: deps.registry,
|
|
4180
4191
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
4181
4192
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
4193
|
+
// The mirror is the balance the wallet renders; refresh it as the drain runs
|
|
4194
|
+
// so a multi-token receive lands progressively instead of all at the end.
|
|
4195
|
+
refreshView: () => {
|
|
4196
|
+
void view.delta().catch(() => void 0);
|
|
4197
|
+
},
|
|
4182
4198
|
attention: (transferId, code, detail) => {
|
|
4183
4199
|
deps.emit(
|
|
4184
4200
|
"transfer:attention",
|