@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
package/dist/index.cjs
CHANGED
|
@@ -13028,6 +13028,7 @@ var InventoryView = class {
|
|
|
13028
13028
|
|
|
13029
13029
|
// modules/payments-v2/receive/Receive.ts
|
|
13030
13030
|
var ACK_BATCH_SIZE = 200;
|
|
13031
|
+
var REFRESH_INTERVAL_MS = 750;
|
|
13031
13032
|
var POLL_INTERVAL_MS = 3e4;
|
|
13032
13033
|
var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
|
|
13033
13034
|
function receivedDedupKey(tokenId, stateHash) {
|
|
@@ -13044,6 +13045,7 @@ var Receive = class {
|
|
|
13044
13045
|
drainFlight = new SingleFlight();
|
|
13045
13046
|
pollTimer = null;
|
|
13046
13047
|
unsubscribeWake = null;
|
|
13048
|
+
lastRefreshAt = 0;
|
|
13047
13049
|
drainOnce() {
|
|
13048
13050
|
return this.drainFlight.run(() => this.doDrain());
|
|
13049
13051
|
}
|
|
@@ -13061,8 +13063,28 @@ var Receive = class {
|
|
|
13061
13063
|
this.unsubscribeWake?.();
|
|
13062
13064
|
this.unsubscribeWake = null;
|
|
13063
13065
|
}
|
|
13066
|
+
/**
|
|
13067
|
+
* Flush what has been accepted, then ask for a mirror refresh — at most once
|
|
13068
|
+
* per REFRESH_INTERVAL_MS.
|
|
13069
|
+
*
|
|
13070
|
+
* The flush is not incidental. A `claimed` ack is what materializes a token
|
|
13071
|
+
* into SERVER inventory, and acks otherwise sit queued until ACK_BATCH_SIZE
|
|
13072
|
+
* (200) — so for any ordinary drain, including the 54-token case this exists
|
|
13073
|
+
* for, refreshing before the flush would query an inventory holding none of
|
|
13074
|
+
* the tokens just accepted, and the balance would still only move at the end.
|
|
13075
|
+
* Ordering is preserved: store() still precedes the ack (§5.7).
|
|
13076
|
+
*/
|
|
13077
|
+
async maybeRefresh(deps, pending, epochOf) {
|
|
13078
|
+
if (deps.refreshView === void 0) return;
|
|
13079
|
+
const now = deps.now?.() ?? Date.now();
|
|
13080
|
+
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
13081
|
+
this.lastRefreshAt = now;
|
|
13082
|
+
await flushAcks(deps, pending, epochOf);
|
|
13083
|
+
deps.refreshView();
|
|
13084
|
+
}
|
|
13064
13085
|
async doDrain() {
|
|
13065
13086
|
const deps = this.deps;
|
|
13087
|
+
this.lastRefreshAt = deps.now?.() ?? Date.now();
|
|
13066
13088
|
const engine = deps.engine();
|
|
13067
13089
|
const stored = [];
|
|
13068
13090
|
const pending = [];
|
|
@@ -13072,8 +13094,10 @@ var Receive = class {
|
|
|
13072
13094
|
let basis = record !== null && record.syncEpoch === deps.syncEpoch() ? record : null;
|
|
13073
13095
|
for (let pass = 0; pass < 2; pass++) {
|
|
13074
13096
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
13097
|
+
const storedBefore = stored.length;
|
|
13075
13098
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
13076
13099
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
13100
|
+
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
13077
13101
|
}
|
|
13078
13102
|
await flushAcks(deps, pending, pageEpoch);
|
|
13079
13103
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -13973,7 +13997,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
13973
13997
|
machineDeps,
|
|
13974
13998
|
machine: new TransferMachine(machineDeps),
|
|
13975
13999
|
heldStates,
|
|
13976
|
-
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
|
|
14000
|
+
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
|
|
13977
14001
|
requests: buildRequests(deps, hooks),
|
|
13978
14002
|
restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
|
|
13979
14003
|
};
|
|
@@ -14040,7 +14064,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
|
|
|
14040
14064
|
}
|
|
14041
14065
|
};
|
|
14042
14066
|
}
|
|
14043
|
-
function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
14067
|
+
function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
14044
14068
|
return new Receive({
|
|
14045
14069
|
delivery: deps.deliveryPort,
|
|
14046
14070
|
engine: () => hooks.engine(),
|
|
@@ -14054,6 +14078,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
|
14054
14078
|
registry: deps.registry,
|
|
14055
14079
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
14056
14080
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
14081
|
+
// The mirror is the balance the wallet renders; refresh it as the drain runs
|
|
14082
|
+
// so a multi-token receive lands progressively instead of all at the end.
|
|
14083
|
+
refreshView: () => {
|
|
14084
|
+
void view.delta().catch(() => void 0);
|
|
14085
|
+
},
|
|
14057
14086
|
attention: (transferId, code, detail) => {
|
|
14058
14087
|
deps.emit(
|
|
14059
14088
|
"transfer:attention",
|