@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/core/index.cjs
CHANGED
|
@@ -12970,6 +12970,7 @@ var InventoryView = class {
|
|
|
12970
12970
|
|
|
12971
12971
|
// modules/payments-v2/receive/Receive.ts
|
|
12972
12972
|
var ACK_BATCH_SIZE = 200;
|
|
12973
|
+
var REFRESH_INTERVAL_MS = 750;
|
|
12973
12974
|
var POLL_INTERVAL_MS = 3e4;
|
|
12974
12975
|
var ATTENTION_CLAIM_CONFLICT = "claim:conflict";
|
|
12975
12976
|
function receivedDedupKey(tokenId, stateHash) {
|
|
@@ -12986,6 +12987,7 @@ var Receive = class {
|
|
|
12986
12987
|
drainFlight = new SingleFlight();
|
|
12987
12988
|
pollTimer = null;
|
|
12988
12989
|
unsubscribeWake = null;
|
|
12990
|
+
lastRefreshAt = 0;
|
|
12989
12991
|
drainOnce() {
|
|
12990
12992
|
return this.drainFlight.run(() => this.doDrain());
|
|
12991
12993
|
}
|
|
@@ -13003,8 +13005,28 @@ var Receive = class {
|
|
|
13003
13005
|
this.unsubscribeWake?.();
|
|
13004
13006
|
this.unsubscribeWake = null;
|
|
13005
13007
|
}
|
|
13008
|
+
/**
|
|
13009
|
+
* Flush what has been accepted, then ask for a mirror refresh — at most once
|
|
13010
|
+
* per REFRESH_INTERVAL_MS.
|
|
13011
|
+
*
|
|
13012
|
+
* The flush is not incidental. A `claimed` ack is what materializes a token
|
|
13013
|
+
* into SERVER inventory, and acks otherwise sit queued until ACK_BATCH_SIZE
|
|
13014
|
+
* (200) — so for any ordinary drain, including the 54-token case this exists
|
|
13015
|
+
* for, refreshing before the flush would query an inventory holding none of
|
|
13016
|
+
* the tokens just accepted, and the balance would still only move at the end.
|
|
13017
|
+
* Ordering is preserved: store() still precedes the ack (§5.7).
|
|
13018
|
+
*/
|
|
13019
|
+
async maybeRefresh(deps, pending, epochOf) {
|
|
13020
|
+
if (deps.refreshView === void 0) return;
|
|
13021
|
+
const now = deps.now?.() ?? Date.now();
|
|
13022
|
+
if (now - this.lastRefreshAt < REFRESH_INTERVAL_MS) return;
|
|
13023
|
+
this.lastRefreshAt = now;
|
|
13024
|
+
await flushAcks(deps, pending, epochOf);
|
|
13025
|
+
deps.refreshView();
|
|
13026
|
+
}
|
|
13006
13027
|
async doDrain() {
|
|
13007
13028
|
const deps = this.deps;
|
|
13029
|
+
this.lastRefreshAt = deps.now?.() ?? Date.now();
|
|
13008
13030
|
const engine = deps.engine();
|
|
13009
13031
|
const stored = [];
|
|
13010
13032
|
const pending = [];
|
|
@@ -13014,8 +13036,10 @@ var Receive = class {
|
|
|
13014
13036
|
let basis = record !== null && record.syncEpoch === deps.syncEpoch() ? record : null;
|
|
13015
13037
|
for (let pass = 0; pass < 2; pass++) {
|
|
13016
13038
|
for await (const entry of deps.delivery.incoming(basis === null ? void 0 : String(basis.cursor))) {
|
|
13039
|
+
const storedBefore = stored.length;
|
|
13017
13040
|
await this.processEntry(deps, engine, entry, pending, stored);
|
|
13018
13041
|
if (pending.length >= ACK_BATCH_SIZE) await flushAcks(deps, pending, pageEpoch);
|
|
13042
|
+
if (stored.length > storedBefore) await this.maybeRefresh(deps, pending, pageEpoch);
|
|
13019
13043
|
}
|
|
13020
13044
|
await flushAcks(deps, pending, pageEpoch);
|
|
13021
13045
|
const served = deps.delivery.incomingEpoch();
|
|
@@ -13915,7 +13939,7 @@ function composeFacadeParts(deps, hooks) {
|
|
|
13915
13939
|
machineDeps,
|
|
13916
13940
|
machine: new TransferMachine(machineDeps),
|
|
13917
13941
|
heldStates,
|
|
13918
|
-
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates),
|
|
13942
|
+
receiveLoop: buildReceive(deps, hooks, historyStore, heldStates, view),
|
|
13919
13943
|
requests: buildRequests(deps, hooks),
|
|
13920
13944
|
restoreDeps: buildRestoreDeps(deps, machineDeps, machineStores, view)
|
|
13921
13945
|
};
|
|
@@ -13982,7 +14006,7 @@ function buildMachineDeps(deps, hooks, historyStore) {
|
|
|
13982
14006
|
}
|
|
13983
14007
|
};
|
|
13984
14008
|
}
|
|
13985
|
-
function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
14009
|
+
function buildReceive(deps, hooks, historyStore, heldStates, view) {
|
|
13986
14010
|
return new Receive({
|
|
13987
14011
|
delivery: deps.deliveryPort,
|
|
13988
14012
|
engine: () => hooks.engine(),
|
|
@@ -13996,6 +14020,11 @@ function buildReceive(deps, hooks, historyStore, heldStates) {
|
|
|
13996
14020
|
registry: deps.registry,
|
|
13997
14021
|
recordReceived: (record) => recordReceived(historyStore, record),
|
|
13998
14022
|
emit: (event, transfer) => deps.emit(event, transfer),
|
|
14023
|
+
// The mirror is the balance the wallet renders; refresh it as the drain runs
|
|
14024
|
+
// so a multi-token receive lands progressively instead of all at the end.
|
|
14025
|
+
refreshView: () => {
|
|
14026
|
+
void view.delta().catch(() => void 0);
|
|
14027
|
+
},
|
|
13999
14028
|
attention: (transferId, code, detail) => {
|
|
14000
14029
|
deps.emit(
|
|
14001
14030
|
"transfer:attention",
|