@unicitylabs/sphere-sdk 0.14.6 → 0.14.7
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 +14 -6
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +14 -6
- 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/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +14 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +6 -2
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +6 -2
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +8 -4
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.js +8 -4
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9414,12 +9414,15 @@ function pause(ms, signal) {
|
|
|
9414
9414
|
});
|
|
9415
9415
|
}
|
|
9416
9416
|
async function retryTransient(attempt, signal, intervalMs) {
|
|
9417
|
+
let retried = false;
|
|
9417
9418
|
for (; ; ) {
|
|
9419
|
+
if (signal.aborted) throw signal.reason;
|
|
9418
9420
|
try {
|
|
9419
|
-
return await attempt();
|
|
9421
|
+
return { value: await attempt(), retried };
|
|
9420
9422
|
} catch (err) {
|
|
9421
9423
|
if (signal.aborted) throw err;
|
|
9422
9424
|
if (!isTransientGatewayError(err)) throw err;
|
|
9425
|
+
retried = true;
|
|
9423
9426
|
await pause(intervalMs, signal);
|
|
9424
9427
|
}
|
|
9425
9428
|
}
|
|
@@ -9445,7 +9448,7 @@ function certificationDeadline(timeoutMs, external, label) {
|
|
|
9445
9448
|
};
|
|
9446
9449
|
}
|
|
9447
9450
|
async function awaitProofBounded(deps, transaction, signal) {
|
|
9448
|
-
|
|
9451
|
+
const { value } = await retryTransient(
|
|
9449
9452
|
() => waitInclusionProof(
|
|
9450
9453
|
deps.client,
|
|
9451
9454
|
deps.trustBase,
|
|
@@ -9457,6 +9460,7 @@ async function awaitProofBounded(deps, transaction, signal) {
|
|
|
9457
9460
|
signal,
|
|
9458
9461
|
deps.intervalMs
|
|
9459
9462
|
);
|
|
9463
|
+
return value;
|
|
9460
9464
|
}
|
|
9461
9465
|
|
|
9462
9466
|
// token-engine/errors.ts
|
|
@@ -10052,14 +10056,14 @@ var SphereTokenEngine = class {
|
|
|
10052
10056
|
let submitError = null;
|
|
10053
10057
|
let submitRejectedCleanly = false;
|
|
10054
10058
|
try {
|
|
10055
|
-
const response = await retryTransient(
|
|
10059
|
+
const { value: response, retried } = await retryTransient(
|
|
10056
10060
|
() => this.deps.client.submitCertificationRequest(certificationData),
|
|
10057
10061
|
signal,
|
|
10058
10062
|
this.deps.proofPollIntervalMs ?? DEFAULT_PROOF_POLL_INTERVAL_MS
|
|
10059
10063
|
);
|
|
10060
10064
|
if (response.status !== CertificationStatus.SUCCESS) {
|
|
10061
10065
|
submitError = new SphereError(`${failLabel}: ${response.status}`, failCode);
|
|
10062
|
-
submitRejectedCleanly = CLEAN_REJECT_STATUSES.has(response.status);
|
|
10066
|
+
submitRejectedCleanly = !retried && CLEAN_REJECT_STATUSES.has(response.status);
|
|
10063
10067
|
}
|
|
10064
10068
|
} catch (err) {
|
|
10065
10069
|
submitError = err ?? new SphereError(`${failLabel}: submit failed`, failCode);
|
|
@@ -11456,6 +11460,9 @@ function classifyError(e) {
|
|
|
11456
11460
|
}
|
|
11457
11461
|
return "other";
|
|
11458
11462
|
}
|
|
11463
|
+
function firstNonConflictError(outcomes) {
|
|
11464
|
+
return outcomes.find((o) => o.error !== void 0 && classifyError(o.error) !== "conflict");
|
|
11465
|
+
}
|
|
11459
11466
|
function summarize(outcomes) {
|
|
11460
11467
|
const committed = outcomes.filter((o) => o.certified);
|
|
11461
11468
|
const rank = { "keep-open": 3, conflict: 2, other: 1 };
|
|
@@ -11516,14 +11523,15 @@ var TransferMachine = class {
|
|
|
11516
11523
|
...r.payload.memo !== void 0 ? { memo: r.payload.memo } : {}
|
|
11517
11524
|
};
|
|
11518
11525
|
const outcomes = await this.resumeOps(ctx, engine, r);
|
|
11519
|
-
const { committed
|
|
11526
|
+
const { committed } = summarize(outcomes);
|
|
11520
11527
|
const conflicts = this.toConflicts(engine, r, outcomes);
|
|
11521
11528
|
if (committed.length === 0 && conflicts.length > 0) throw conflicts[0].error;
|
|
11522
11529
|
let deliveryPending = false;
|
|
11523
11530
|
if (committed.length > 0) {
|
|
11524
11531
|
deliveryPending = await this.deliverSet(r.transferId, r.payload.recipient, r.payload.memo, committed);
|
|
11525
11532
|
}
|
|
11526
|
-
|
|
11533
|
+
const blocking = firstNonConflictError(outcomes);
|
|
11534
|
+
if (blocking !== void 0) throw blocking.error;
|
|
11527
11535
|
await this.applyCommitted(engine, r.transferId, committed);
|
|
11528
11536
|
if (conflicts.length > 0) {
|
|
11529
11537
|
return { deliveryPending, partial: await this.settlePartial(engine, r, committed, conflicts) };
|