@unicitylabs/sphere-sdk 0.14.6 → 0.14.8-dev.1
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 +36 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +36 -7
- 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 +36 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +28 -3
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.js +28 -3
- 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
|
@@ -823,6 +823,9 @@ function classifyError(e) {
|
|
|
823
823
|
}
|
|
824
824
|
return "other";
|
|
825
825
|
}
|
|
826
|
+
function firstNonConflictError(outcomes) {
|
|
827
|
+
return outcomes.find((o) => o.error !== void 0 && classifyError(o.error) !== "conflict");
|
|
828
|
+
}
|
|
826
829
|
function summarize(outcomes) {
|
|
827
830
|
const committed = outcomes.filter((o) => o.certified);
|
|
828
831
|
const rank = { "keep-open": 3, conflict: 2, other: 1 };
|
|
@@ -883,14 +886,15 @@ var TransferMachine = class {
|
|
|
883
886
|
...r.payload.memo !== void 0 ? { memo: r.payload.memo } : {}
|
|
884
887
|
};
|
|
885
888
|
const outcomes = await this.resumeOps(ctx, engine, r);
|
|
886
|
-
const { committed
|
|
889
|
+
const { committed } = summarize(outcomes);
|
|
887
890
|
const conflicts = this.toConflicts(engine, r, outcomes);
|
|
888
891
|
if (committed.length === 0 && conflicts.length > 0) throw conflicts[0].error;
|
|
889
892
|
let deliveryPending = false;
|
|
890
893
|
if (committed.length > 0) {
|
|
891
894
|
deliveryPending = await this.deliverSet(r.transferId, r.payload.recipient, r.payload.memo, committed);
|
|
892
895
|
}
|
|
893
|
-
|
|
896
|
+
const blocking = firstNonConflictError(outcomes);
|
|
897
|
+
if (blocking !== void 0) throw blocking.error;
|
|
894
898
|
await this.applyCommitted(engine, r.transferId, committed);
|
|
895
899
|
if (conflicts.length > 0) {
|
|
896
900
|
return { deliveryPending, partial: await this.settlePartial(engine, r, committed, conflicts) };
|
|
@@ -916,16 +920,37 @@ var TransferMachine = class {
|
|
|
916
920
|
...plan.memo !== void 0 ? { memo: plan.memo } : {}
|
|
917
921
|
};
|
|
918
922
|
const outcomes = [];
|
|
923
|
+
const certified = [];
|
|
919
924
|
for (let at = 0; at < plan.ops.length; at += CERTIFY_WIDTH) {
|
|
920
925
|
const batch = plan.ops.slice(at, at + CERTIFY_WIDTH);
|
|
921
926
|
const settled = await Promise.all(
|
|
922
|
-
batch.map(
|
|
927
|
+
batch.map(
|
|
928
|
+
(op) => this.certifyOne(ctx, engine, op, plan.sources.get(op.sourceTokenId)).then((o) => {
|
|
929
|
+
if (o.certified) {
|
|
930
|
+
certified.push(o);
|
|
931
|
+
this.emitProgress(plan, certified);
|
|
932
|
+
}
|
|
933
|
+
return o;
|
|
934
|
+
})
|
|
935
|
+
)
|
|
923
936
|
);
|
|
924
937
|
outcomes.push(...settled);
|
|
925
938
|
if (settled.some((o) => o.error !== void 0 && !o.certified)) break;
|
|
926
939
|
}
|
|
927
940
|
return outcomes;
|
|
928
941
|
}
|
|
942
|
+
/** In-flight snapshot: `tokenTransfers` holds the legs certified SO FAR. */
|
|
943
|
+
emitProgress(plan, certified) {
|
|
944
|
+
this.deps.emit("transfer:updated", {
|
|
945
|
+
id: plan.transferId,
|
|
946
|
+
status: "submitted",
|
|
947
|
+
tokens: [],
|
|
948
|
+
tokenTransfers: certified.map((o) => ({
|
|
949
|
+
sourceTokenId: o.op.sourceTokenId,
|
|
950
|
+
method: o.op.kind
|
|
951
|
+
}))
|
|
952
|
+
});
|
|
953
|
+
}
|
|
929
954
|
async certifyOne(ctx, engine, op, source) {
|
|
930
955
|
if (source === void 0) {
|
|
931
956
|
return {
|