@pushchain/core 6.0.4 → 6.0.5
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/package.json +1 -1
- package/src/lib/orchestrator/internals/cascade.js +88 -45
- package/src/lib/orchestrator/internals/context.js +2 -3
- package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +0 -1
- package/src/lib/orchestrator/internals/progress-route-hooks.js +0 -2
- package/src/lib/orchestrator/internals/response-builder.js +1 -33
- package/src/lib/orchestrator/internals/tx-transformer.js +7 -11
- package/src/lib/orchestrator/orchestrator.types.d.ts +6 -0
- package/src/lib/progress-hook/progress-hook.js +21 -7
- package/src/lib/progress-hook/progress-hook.types.d.ts +5 -3
- package/src/lib/progress-hook/progress-hook.types.js +3 -1
package/package.json
CHANGED
|
@@ -1265,6 +1265,31 @@ function composeCascade(ctx, segments, ueaAddress, ueaBalance, ueaNonce) {
|
|
|
1265
1265
|
// ============================================================================
|
|
1266
1266
|
// createCascadedBuilder
|
|
1267
1267
|
// ============================================================================
|
|
1268
|
+
function txHashFromProgressEvent(event) {
|
|
1269
|
+
var _a, _b, _c, _d;
|
|
1270
|
+
const response = event.response;
|
|
1271
|
+
return (_d = (_a = response === null || response === void 0 ? void 0 : response.txHash) !== null && _a !== void 0 ? _a : (_c = (_b = response === null || response === void 0 ? void 0 : response.response) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.hash) !== null && _d !== void 0 ? _d : '';
|
|
1272
|
+
}
|
|
1273
|
+
function withMultihopRootProgressMapping(ctx, run) {
|
|
1274
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1275
|
+
const originalHook = ctx.progressHook;
|
|
1276
|
+
if (!originalHook)
|
|
1277
|
+
return run();
|
|
1278
|
+
ctx.progressHook = (event) => {
|
|
1279
|
+
if (event.id === progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01) {
|
|
1280
|
+
originalHook(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99](txHashFromProgressEvent(event)));
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
originalHook(event);
|
|
1284
|
+
};
|
|
1285
|
+
try {
|
|
1286
|
+
return yield run();
|
|
1287
|
+
}
|
|
1288
|
+
finally {
|
|
1289
|
+
ctx.progressHook = originalHook;
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1268
1293
|
function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
1269
1294
|
return {
|
|
1270
1295
|
send: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1293,6 +1318,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1293
1318
|
},
|
|
1294
1319
|
],
|
|
1295
1320
|
hopCount: 1,
|
|
1321
|
+
finalTxHash: response.hash,
|
|
1296
1322
|
waitForAll: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1297
1323
|
return ({
|
|
1298
1324
|
success: true,
|
|
@@ -1305,6 +1331,8 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1305
1331
|
txHash: response.hash,
|
|
1306
1332
|
},
|
|
1307
1333
|
],
|
|
1334
|
+
finalTxHash: response.hash,
|
|
1335
|
+
finalTxResponse: singleRoute1Result,
|
|
1308
1336
|
});
|
|
1309
1337
|
}),
|
|
1310
1338
|
wait: (opts) => tslib_1.__awaiter(this, void 0, void 0, function* () { return singleRoute1Result.waitForAll(opts); }),
|
|
@@ -1328,6 +1356,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1328
1356
|
},
|
|
1329
1357
|
],
|
|
1330
1358
|
hopCount: 1,
|
|
1359
|
+
finalTxHash: response.hash,
|
|
1331
1360
|
waitForAll: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1332
1361
|
return ({
|
|
1333
1362
|
success: true,
|
|
@@ -1340,6 +1369,8 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1340
1369
|
txHash: response.hash,
|
|
1341
1370
|
},
|
|
1342
1371
|
],
|
|
1372
|
+
finalTxHash: response.hash,
|
|
1373
|
+
finalTxResponse: singleRoute2Result,
|
|
1343
1374
|
});
|
|
1344
1375
|
}),
|
|
1345
1376
|
wait: (opts) => tslib_1.__awaiter(this, void 0, void 0, function* () { return singleRoute2Result.waitForAll(opts); }),
|
|
@@ -1380,7 +1411,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1380
1411
|
value: cascadeRequiredNativeValue,
|
|
1381
1412
|
data: composedMulticalls,
|
|
1382
1413
|
};
|
|
1383
|
-
const response = yield callbacks.executeFn(executeParams);
|
|
1414
|
+
const response = yield withMultihopRootProgressMapping(ctx, () => callbacks.executeFn(executeParams));
|
|
1384
1415
|
// Build hop info for tracking
|
|
1385
1416
|
const hopInfos = hops.map((hop, index) => ({
|
|
1386
1417
|
hopIndex: index,
|
|
@@ -1458,6 +1489,34 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1458
1489
|
return;
|
|
1459
1490
|
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03](failedIdx0 + 1, totalHops));
|
|
1460
1491
|
};
|
|
1492
|
+
const emitRouteIntermediateComplete = (hop, txHash) => {
|
|
1493
|
+
var _a;
|
|
1494
|
+
if (!isMulti)
|
|
1495
|
+
return;
|
|
1496
|
+
const n = hop.hopIndex + 1;
|
|
1497
|
+
if (n >= totalHops)
|
|
1498
|
+
return; // final terminal is 999-01
|
|
1499
|
+
const resolvedTxHash = (_a = txHash !== null && txHash !== void 0 ? txHash : hop.txHash) !== null && _a !== void 0 ? _a : response.hash;
|
|
1500
|
+
if (hop.route === 'UOA_TO_PUSH') {
|
|
1501
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99](resolvedTxHash));
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
if (hop.route === 'UOA_TO_CEA') {
|
|
1505
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99](hop.executionChain, resolvedTxHash));
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
if (hop.route === 'CEA_TO_PUSH') {
|
|
1509
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_99](hop.executionChain, resolvedTxHash));
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
const buildCompletionResult = (success, failedAt) => {
|
|
1513
|
+
var _a, _b;
|
|
1514
|
+
const finalTxHash = (_b = (_a = [...hopInfos]
|
|
1515
|
+
.reverse()
|
|
1516
|
+
.find((hop) => hop.status === 'confirmed' && hop.txHash)) === null || _a === void 0 ? void 0 : _a.txHash) !== null && _b !== void 0 ? _b : response.hash;
|
|
1517
|
+
cascadeResponse.finalTxHash = finalTxHash;
|
|
1518
|
+
return Object.assign({ success, hops: hopInfos, finalTxHash, finalTxResponse: cascadeResponse }, (failedAt !== undefined ? { failedAt } : {}));
|
|
1519
|
+
};
|
|
1461
1520
|
if (isMulti) {
|
|
1462
1521
|
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_001](totalHops, chainLabels));
|
|
1463
1522
|
}
|
|
@@ -1500,11 +1559,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1500
1559
|
});
|
|
1501
1560
|
emitHopEvent(hopHooks.timeout(hop.executionChain, Date.now() - startTime));
|
|
1502
1561
|
emitCascadeTimeout(hop.hopIndex);
|
|
1503
|
-
return
|
|
1504
|
-
success: false,
|
|
1505
|
-
hops: hopInfos,
|
|
1506
|
-
failedAt: hop.hopIndex,
|
|
1507
|
-
};
|
|
1562
|
+
return buildCompletionResult(false, hop.hopIndex);
|
|
1508
1563
|
}
|
|
1509
1564
|
emitHopStart(hop.hopIndex);
|
|
1510
1565
|
emitHopEvent(hopHooks.awaiting(hop.executionChain));
|
|
@@ -1545,7 +1600,12 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1545
1600
|
hop.status = 'confirmed';
|
|
1546
1601
|
hop.txHash = displayTxHash;
|
|
1547
1602
|
hop.outboundDetails = userFacingOutboundDetails;
|
|
1548
|
-
|
|
1603
|
+
if (isMulti) {
|
|
1604
|
+
emitRouteIntermediateComplete(hop, displayTxHash);
|
|
1605
|
+
}
|
|
1606
|
+
else {
|
|
1607
|
+
emitHopEvent(hopHooks.success(userFacingOutboundDetails));
|
|
1608
|
+
}
|
|
1549
1609
|
emitHopComplete(hop.hopIndex);
|
|
1550
1610
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1551
1611
|
hopIndex: hop.hopIndex,
|
|
@@ -1576,11 +1636,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1576
1636
|
status: 'failed',
|
|
1577
1637
|
elapsed: Date.now() - startTime,
|
|
1578
1638
|
});
|
|
1579
|
-
return
|
|
1580
|
-
success: false,
|
|
1581
|
-
hops: hopInfos,
|
|
1582
|
-
failedAt: hop.hopIndex,
|
|
1583
|
-
};
|
|
1639
|
+
return buildCompletionResult(false, hop.hopIndex);
|
|
1584
1640
|
}
|
|
1585
1641
|
}
|
|
1586
1642
|
else {
|
|
@@ -1622,7 +1678,12 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1622
1678
|
// guard above, so we only reach here with full details.
|
|
1623
1679
|
if (matchedHop === null || matchedHop === void 0 ? void 0 : matchedHop.outboundDetails) {
|
|
1624
1680
|
confirmedHops.add(event.hopIndex);
|
|
1625
|
-
|
|
1681
|
+
if (isMulti) {
|
|
1682
|
+
emitRouteIntermediateComplete(matchedHop, event.txHash);
|
|
1683
|
+
}
|
|
1684
|
+
else {
|
|
1685
|
+
emitHopEvent(eventHooks.success(matchedHop.outboundDetails));
|
|
1686
|
+
}
|
|
1626
1687
|
emitHopComplete(event.hopIndex);
|
|
1627
1688
|
}
|
|
1628
1689
|
}
|
|
@@ -1636,11 +1697,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1636
1697
|
: `Outbound cascade failed at hop ${failedIdx}`;
|
|
1637
1698
|
emitHopEvent((0, progress_route_hooks_1.pickWaitHooks)(failedHop === null || failedHop === void 0 ? void 0 : failedHop.route).failed((_d = failedHop === null || failedHop === void 0 ? void 0 : failedHop.executionChain) !== null && _d !== void 0 ? _d : '', failMsg));
|
|
1638
1699
|
emitCascadeFailed(failedIdx, failMsg);
|
|
1639
|
-
return
|
|
1640
|
-
success: false,
|
|
1641
|
-
hops: hopInfos,
|
|
1642
|
-
failedAt: failedIdx,
|
|
1643
|
-
};
|
|
1700
|
+
return buildCompletionResult(false, failedIdx);
|
|
1644
1701
|
}
|
|
1645
1702
|
}
|
|
1646
1703
|
return null;
|
|
@@ -1695,11 +1752,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1695
1752
|
inboundHop.status = 'failed';
|
|
1696
1753
|
emitHopEvent(hopHooks.timeout(inboundHop.executionChain, Date.now() - startTime));
|
|
1697
1754
|
emitCascadeTimeout(inboundHop.hopIndex);
|
|
1698
|
-
return
|
|
1699
|
-
success: false,
|
|
1700
|
-
hops: hopInfos,
|
|
1701
|
-
failedAt: inboundHop.hopIndex,
|
|
1702
|
-
};
|
|
1755
|
+
return buildCompletionResult(false, inboundHop.hopIndex);
|
|
1703
1756
|
}
|
|
1704
1757
|
emitHopStart(inboundHop.hopIndex);
|
|
1705
1758
|
emitHopEvent(hopHooks.awaiting(inboundHop.executionChain));
|
|
@@ -1758,11 +1811,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1758
1811
|
txHash: failedDisplayTxHash,
|
|
1759
1812
|
elapsed: Date.now() - startTime,
|
|
1760
1813
|
});
|
|
1761
|
-
return
|
|
1762
|
-
success: false,
|
|
1763
|
-
hops: hopInfos,
|
|
1764
|
-
failedAt: inboundHop.hopIndex,
|
|
1765
|
-
};
|
|
1814
|
+
return buildCompletionResult(false, inboundHop.hopIndex);
|
|
1766
1815
|
}
|
|
1767
1816
|
const displayExternalTxHash = (_f = (0, helpers_1.toExternalTxHashDisplay)(sourceOutboundDetails.destinationChain, sourceOutboundDetails.externalTxHash)) !== null && _f !== void 0 ? _f : sourceOutboundDetails.externalTxHash;
|
|
1768
1817
|
inboundHop.outboundDetails = Object.assign(Object.assign({}, sourceOutboundDetails), { externalTxHash: displayExternalTxHash });
|
|
@@ -1803,11 +1852,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1803
1852
|
status: 'failed',
|
|
1804
1853
|
elapsed: Date.now() - startTime,
|
|
1805
1854
|
});
|
|
1806
|
-
return
|
|
1807
|
-
success: false,
|
|
1808
|
-
hops: hopInfos,
|
|
1809
|
-
failedAt: inboundHop.hopIndex,
|
|
1810
|
-
};
|
|
1855
|
+
return buildCompletionResult(false, inboundHop.hopIndex);
|
|
1811
1856
|
}
|
|
1812
1857
|
if (childInbound.status !== 'confirmed') {
|
|
1813
1858
|
const failMsg = (_h = childInbound.errorMessage) !== null && _h !== void 0 ? _h : 'inbound execution failed on Push Chain';
|
|
@@ -1824,16 +1869,17 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1824
1869
|
txHash: inboundHop.txHash,
|
|
1825
1870
|
elapsed: Date.now() - startTime,
|
|
1826
1871
|
});
|
|
1827
|
-
return
|
|
1828
|
-
success: false,
|
|
1829
|
-
hops: hopInfos,
|
|
1830
|
-
failedAt: inboundHop.hopIndex,
|
|
1831
|
-
};
|
|
1872
|
+
return buildCompletionResult(false, inboundHop.hopIndex);
|
|
1832
1873
|
}
|
|
1833
1874
|
inboundHop.status = 'confirmed';
|
|
1834
1875
|
inboundHop.txHash =
|
|
1835
1876
|
childInbound.pushTxHash || displayExternalTxHash;
|
|
1836
|
-
|
|
1877
|
+
if (isMulti) {
|
|
1878
|
+
emitRouteIntermediateComplete(inboundHop, inboundHop.txHash);
|
|
1879
|
+
}
|
|
1880
|
+
else {
|
|
1881
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01](inboundHop.executionChain, childInbound.pushTxHash));
|
|
1882
|
+
}
|
|
1837
1883
|
emitHopComplete(inboundHop.hopIndex);
|
|
1838
1884
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1839
1885
|
hopIndex: inboundHop.hopIndex,
|
|
@@ -1859,6 +1905,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1859
1905
|
txHash: childInbound.pushTxHash,
|
|
1860
1906
|
elapsed: Date.now() - startTime,
|
|
1861
1907
|
});
|
|
1908
|
+
emitRouteIntermediateComplete(hop, childInbound.pushTxHash);
|
|
1862
1909
|
emitHopComplete(hop.hopIndex);
|
|
1863
1910
|
}
|
|
1864
1911
|
}
|
|
@@ -1868,7 +1915,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1868
1915
|
return childOutboundFailure;
|
|
1869
1916
|
}
|
|
1870
1917
|
emitCascadeSuccess();
|
|
1871
|
-
return
|
|
1918
|
+
return buildCompletionResult(true);
|
|
1872
1919
|
}
|
|
1873
1920
|
catch (err) {
|
|
1874
1921
|
const failedIdx = hopInfos.findIndex((h) => h.status !== 'confirmed');
|
|
@@ -1881,11 +1928,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook) {
|
|
|
1881
1928
|
else {
|
|
1882
1929
|
emitCascadeFailed(failedAt, errMsg);
|
|
1883
1930
|
}
|
|
1884
|
-
return
|
|
1885
|
-
success: false,
|
|
1886
|
-
hops: hopInfos,
|
|
1887
|
-
failedAt,
|
|
1888
|
-
};
|
|
1931
|
+
return buildCompletionResult(false, failedAt);
|
|
1889
1932
|
}
|
|
1890
1933
|
}),
|
|
1891
1934
|
wait: (opts) => tslib_1.__awaiter(this, void 0, void 0, function* () { return cascadeResponse.waitForAll(opts); }),
|
|
@@ -48,9 +48,8 @@ function printLog(ctx, msg) {
|
|
|
48
48
|
* Exceptions kept in the stream regardless of route:
|
|
49
49
|
* - All UEA migration hooks.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* internal transition signals, not consumer-facing spec events.
|
|
51
|
+
* Multihop-only intermediate success markers (199-99 / 299-99 / 399-99)
|
|
52
|
+
* are emitted by cascade tracking, not by the single-route wait path.
|
|
54
53
|
*/
|
|
55
54
|
const R1_SUPPRESSED_IN_NON_R1 = new Set([
|
|
56
55
|
progress_hook_types_1.PROGRESS_HOOK.SEND_TX_101,
|
|
@@ -10,7 +10,6 @@ import type { OutboundTxDetails } from '../orchestrator.types';
|
|
|
10
10
|
import type { ProgressEvent } from '../../progress-hook/progress-hook.types';
|
|
11
11
|
import { TransactionRoute } from '../route-detector';
|
|
12
12
|
export type WaitHookSet = {
|
|
13
|
-
intermediatePushOk?: (chain: string, pushTxHash: string) => ProgressEvent;
|
|
14
13
|
awaiting: (chain: string) => ProgressEvent;
|
|
15
14
|
polling: (chain: string, elapsedMs: number) => ProgressEvent;
|
|
16
15
|
success: (details: OutboundTxDetails) => ProgressEvent;
|
|
@@ -17,7 +17,6 @@ const route_detector_1 = require("../route-detector");
|
|
|
17
17
|
function pickWaitHooks(route) {
|
|
18
18
|
if (route === route_detector_1.TransactionRoute.UOA_TO_CEA) {
|
|
19
19
|
return {
|
|
20
|
-
intermediatePushOk: (chain, txHash) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99](chain, txHash),
|
|
21
20
|
awaiting: (chain) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01](chain),
|
|
22
21
|
polling: (chain, elapsed) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02](chain, elapsed),
|
|
23
22
|
success: (details) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01](details),
|
|
@@ -27,7 +26,6 @@ function pickWaitHooks(route) {
|
|
|
27
26
|
}
|
|
28
27
|
if (route === route_detector_1.TransactionRoute.CEA_TO_PUSH) {
|
|
29
28
|
return {
|
|
30
|
-
intermediatePushOk: (_chain, txHash) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99](txHash),
|
|
31
29
|
awaiting: (chain) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01](chain),
|
|
32
30
|
polling: (chain, elapsed) => progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02](chain, elapsed),
|
|
33
31
|
// For R3, the outbound-poll "success" is the source-chain CEA executing
|
|
@@ -29,30 +29,14 @@ const inbound_tracker_1 = require("./inbound-tracker");
|
|
|
29
29
|
const tx_transformer_1 = require("./tx-transformer");
|
|
30
30
|
const progress_route_hooks_1 = require("./progress-route-hooks");
|
|
31
31
|
const outbound_sync_1 = require("./outbound-sync");
|
|
32
|
-
/**
|
|
33
|
-
* Intermediate Push-success markers (199-99-99 for R3, 299-99 for R2) are
|
|
34
|
-
* internal transition signals — they tell response-builder's wait-phase
|
|
35
|
-
* branch that the Push leg has settled so it can skip re-emitting the
|
|
36
|
-
* intermediate marker on top of a reconstructed stream. They are not part
|
|
37
|
-
* of the published 1XX/2XX/3XX/4XX spec and are suppressed at the consumer
|
|
38
|
-
* dispatch boundary. `printLog` still fires for these so internal traces
|
|
39
|
-
* retain the transition record.
|
|
40
|
-
*/
|
|
41
|
-
const INTERMEDIATE_INTERNAL_IDS = new Set([
|
|
42
|
-
progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99,
|
|
43
|
-
progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99,
|
|
44
|
-
]);
|
|
45
32
|
/**
|
|
46
33
|
* Fan out a progress event to one or two registered callbacks, deduping
|
|
47
34
|
* when both slots hold the same reference. Keeps the emission policy in a
|
|
48
35
|
* single place shared by `emitProgress` (execute phase) and `emit` (wait
|
|
49
36
|
* phase) — so consumers that wire the same callback at multiple levels
|
|
50
|
-
* never see double-invocation.
|
|
51
|
-
* here so they never reach the consumer.
|
|
37
|
+
* never see double-invocation.
|
|
52
38
|
*/
|
|
53
39
|
function fanOut(event, primary, secondary) {
|
|
54
|
-
if (INTERMEDIATE_INTERNAL_IDS.has(event.id))
|
|
55
|
-
return;
|
|
56
40
|
if (primary)
|
|
57
41
|
primary(event);
|
|
58
42
|
if (secondary && secondary !== primary)
|
|
@@ -549,13 +533,6 @@ function transformToUniversalTxResponse(ctx_1, tx_1) {
|
|
|
549
533
|
const inboundInitialWaitMs = isReplay
|
|
550
534
|
? 0
|
|
551
535
|
: callbacks.inboundConstants.initialWaitMs;
|
|
552
|
-
// Track whether reconstruction already emitted the route's
|
|
553
|
-
// intermediate Push-success marker (299-99 / 199-99-99). When it has,
|
|
554
|
-
// skip re-emitting from the outbound branch below to avoid duplicates.
|
|
555
|
-
// This flag is only true when `this` response was created by
|
|
556
|
-
// trackTransaction() and the reconstructed stream already fired.
|
|
557
|
-
const alreadyReconstructed = universalTxResponse._eventsReconstructed === true;
|
|
558
|
-
let intermediateAlreadyEmitted = alreadyReconstructed;
|
|
559
536
|
// Build the base receipt directly from this response. Any per-call
|
|
560
537
|
// `tx.progressHook(cb)` already replayed buffered execute-phase events
|
|
561
538
|
// to `cb` via the progressHook setter — re-running trackTransaction
|
|
@@ -580,15 +557,6 @@ function transformToUniversalTxResponse(ctx_1, tx_1) {
|
|
|
580
557
|
return;
|
|
581
558
|
fanOut(event, registeredProgressHook, ctx.progressHook);
|
|
582
559
|
};
|
|
583
|
-
// Intermediate INFO marker — Push Chain tx confirmed, external/inbound
|
|
584
|
-
// leg still pending. Per spec, R1 keeps 199-01 as terminal; R2/R3
|
|
585
|
-
// reclassify Push success as intermediate. Skip when trackTransaction
|
|
586
|
-
// (called above) already reconstructed the same marker via
|
|
587
|
-
// reconstructR2/R3, otherwise the consumer sees 299-99 / 199-99-99
|
|
588
|
-
// twice in their stream.
|
|
589
|
-
if (hooks.intermediatePushOk && !intermediateAlreadyEmitted) {
|
|
590
|
-
emit(hooks.intermediatePushOk(targetChain, tx.hash));
|
|
591
|
-
}
|
|
592
560
|
// Awaiting relay
|
|
593
561
|
emit(hooks.awaiting(targetChain));
|
|
594
562
|
let lastEmittedStatus;
|
|
@@ -160,11 +160,6 @@ function reconstructR2(universalTxResponse, universalTxData, isFailed, errorMsg)
|
|
|
160
160
|
if (isFailed) {
|
|
161
161
|
events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02](errorMsg));
|
|
162
162
|
}
|
|
163
|
-
else {
|
|
164
|
-
// Push Chain success is intermediate for R2 — the wait() outbound poll
|
|
165
|
-
// appends the real terminal (299-01/02/03) once the external leg resolves.
|
|
166
|
-
events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99](targetChain, universalTxResponse.hash));
|
|
167
|
-
}
|
|
168
163
|
return events;
|
|
169
164
|
}
|
|
170
165
|
function reconstructR3(universalTxResponse, universalTxData, isFailed, errorMsg) {
|
|
@@ -190,11 +185,6 @@ function reconstructR3(universalTxResponse, universalTxData, isFailed, errorMsg)
|
|
|
190
185
|
// "Push Chain Tx Failed" rather than the inbound copy.
|
|
191
186
|
events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02](errorMsg, 'push'));
|
|
192
187
|
}
|
|
193
|
-
else {
|
|
194
|
-
// Push Chain success is intermediate for R3 — wait() drives the source-chain
|
|
195
|
-
// CEA poll (309-xx) and the inbound-to-Push poll (310-xx / 399-xx) on top.
|
|
196
|
-
events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99](universalTxResponse.hash));
|
|
197
|
-
}
|
|
198
188
|
return events;
|
|
199
189
|
}
|
|
200
190
|
// ============================================================================
|
|
@@ -315,7 +305,7 @@ function reconstructMultichain(universalTxResponse, universalTxData, isFailed, e
|
|
|
315
305
|
let failedAt = null;
|
|
316
306
|
let failureMsg = errorMsg;
|
|
317
307
|
outbounds.forEach((ob, i) => {
|
|
318
|
-
var _a;
|
|
308
|
+
var _a, _b;
|
|
319
309
|
const hopNum = i + 1;
|
|
320
310
|
const fromChain = i === 0 ? sourceChain : outbounds[i - 1].destinationChain;
|
|
321
311
|
const toChain = ob.destinationChain;
|
|
@@ -336,6 +326,12 @@ function reconstructMultichain(universalTxResponse, universalTxData, isFailed, e
|
|
|
336
326
|
events.push(...reconstructR2(legResponse, legData, legFailed, legError));
|
|
337
327
|
}
|
|
338
328
|
if (!legFailed) {
|
|
329
|
+
if (hopNum < hopCount) {
|
|
330
|
+
const txHash = ((_b = ob.observedTx) === null || _b === void 0 ? void 0 : _b.txHash) || legResponse.hash;
|
|
331
|
+
events.push(isR3Leg
|
|
332
|
+
? progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_99](toChain, txHash)
|
|
333
|
+
: progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99](toChain, txHash));
|
|
334
|
+
}
|
|
339
335
|
events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99](hopNum, hopCount));
|
|
340
336
|
}
|
|
341
337
|
else if (failedAt === null) {
|
|
@@ -639,6 +639,8 @@ export interface CascadedTxResponse {
|
|
|
639
639
|
hops: CascadeHopInfo[];
|
|
640
640
|
/** Total number of hops in the cascade */
|
|
641
641
|
hopCount: number;
|
|
642
|
+
/** Final tx hash resolved by waitForAll()/wait(), when available */
|
|
643
|
+
finalTxHash?: string;
|
|
642
644
|
/** Wait for ALL hops to complete across all chains */
|
|
643
645
|
waitForAll: (opts?: CascadeTrackOptions) => Promise<CascadeCompletionResult>;
|
|
644
646
|
/** Convenience alias for waitForAll() */
|
|
@@ -713,6 +715,10 @@ export interface CascadeCompletionResult {
|
|
|
713
715
|
success: boolean;
|
|
714
716
|
/** Final state of all hops */
|
|
715
717
|
hops: CascadeHopInfo[];
|
|
718
|
+
/** Final tx hash for the last confirmed hop, when available */
|
|
719
|
+
finalTxHash?: string;
|
|
720
|
+
/** Original cascaded response object for consumers that need the full context */
|
|
721
|
+
finalTxResponse?: CascadedTxResponse;
|
|
716
722
|
/** Index of first failed hop (if any) */
|
|
717
723
|
failedAt?: number;
|
|
718
724
|
}
|
|
@@ -273,6 +273,20 @@ const RAW_HOOKS_R1 = {
|
|
|
273
273
|
level: 'ERROR',
|
|
274
274
|
};
|
|
275
275
|
},
|
|
276
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_03]: (targetChain, elapsedMs) => ({
|
|
277
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_03,
|
|
278
|
+
title: `Syncing State with ${friendlyChain(targetChain)} Timeout`,
|
|
279
|
+
message: `Timed out waiting for UGPC relay to ${targetChain}`,
|
|
280
|
+
response: { error: 'relay timeout', chain: targetChain, elapsedMs },
|
|
281
|
+
level: 'ERROR',
|
|
282
|
+
}),
|
|
283
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99]: (txHash) => ({
|
|
284
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99,
|
|
285
|
+
title: 'Push Chain Tx Completed',
|
|
286
|
+
message: `Intermediate Push Chain tx confirmed: ${txHash}, progressing to next phase`,
|
|
287
|
+
response: { txHash },
|
|
288
|
+
level: 'INFO',
|
|
289
|
+
}),
|
|
276
290
|
};
|
|
277
291
|
// =============================================================================
|
|
278
292
|
// Route 2 — UEA → UGPC → CEA on target chain (201–299, signature-only)
|
|
@@ -467,13 +481,6 @@ const RAW_HOOKS_R2 = {
|
|
|
467
481
|
// Route 3 — UEA → UGPC → CEA → sendUniversalTxToUEA → Push Chain (301–399)
|
|
468
482
|
// =============================================================================
|
|
469
483
|
const RAW_HOOKS_R3 = {
|
|
470
|
-
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99]: (txHash) => ({
|
|
471
|
-
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99,
|
|
472
|
-
title: 'Push Chain Tx Completed',
|
|
473
|
-
message: `Intermediate Push Chain tx confirmed: ${txHash}, progressing to next phase`,
|
|
474
|
-
response: { txHash },
|
|
475
|
-
level: 'INFO',
|
|
476
|
-
}),
|
|
477
484
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301]: (sourceChain, ceaAddress) => ({
|
|
478
485
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301,
|
|
479
486
|
title: `${friendlyChain(sourceChain)}'s Executor Account Detected`,
|
|
@@ -727,6 +734,13 @@ const RAW_HOOKS_R3 = {
|
|
|
727
734
|
},
|
|
728
735
|
level: 'ERROR',
|
|
729
736
|
}),
|
|
737
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_99]: (sourceChain, txHash) => ({
|
|
738
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_99,
|
|
739
|
+
title: `${friendlyChain(sourceChain)} Tx Completed`,
|
|
740
|
+
message: `Intermediate ${friendlyChain(sourceChain)} tx confirmed: ${txHash}, progressing to next phase`,
|
|
741
|
+
response: { chain: sourceChain, txHash },
|
|
742
|
+
level: 'INFO',
|
|
743
|
+
}),
|
|
730
744
|
};
|
|
731
745
|
// =============================================================================
|
|
732
746
|
// UEA Migration hooks (unchanged)
|
|
@@ -40,7 +40,8 @@ export declare enum PROGRESS_HOOK {
|
|
|
40
40
|
SEND_TX_107 = "SEND-TX-107",
|
|
41
41
|
SEND_TX_199_01 = "SEND-TX-199-01",// R1 terminal Push success
|
|
42
42
|
SEND_TX_199_02 = "SEND-TX-199-02",// R1 terminal Push failure
|
|
43
|
-
|
|
43
|
+
SEND_TX_199_03 = "SEND-TX-199-03",
|
|
44
|
+
SEND_TX_199_99 = "SEND-TX-199-99",// R1 multihop intermediate Push success
|
|
44
45
|
SEND_TX_201 = "SEND-TX-201",
|
|
45
46
|
SEND_TX_202_01 = "SEND-TX-202-01",
|
|
46
47
|
SEND_TX_202_02 = "SEND-TX-202-02",
|
|
@@ -84,6 +85,7 @@ export declare enum PROGRESS_HOOK {
|
|
|
84
85
|
SEND_TX_399_01 = "SEND-TX-399-01",
|
|
85
86
|
SEND_TX_399_02 = "SEND-TX-399-02",
|
|
86
87
|
SEND_TX_399_03 = "SEND-TX-399-03",
|
|
88
|
+
SEND_TX_399_99 = "SEND-TX-399-99",// R3 multihop intermediate round-trip success
|
|
87
89
|
SEND_TX_001 = "SEND-TX-001",
|
|
88
90
|
SEND_TX_002_01 = "SEND-TX-002-01",
|
|
89
91
|
SEND_TX_002_99_99 = "SEND-TX-002-99-99",
|
|
@@ -100,9 +102,9 @@ export declare enum PROGRESS_HOOK {
|
|
|
100
102
|
UEA_MIG_9902 = "UEA-MIG-9902",
|
|
101
103
|
UEA_MIG_9903 = "UEA-MIG-9903"
|
|
102
104
|
}
|
|
103
|
-
export type PROGRESS_HOOK_R1 = PROGRESS_HOOK.SEND_TX_101 | PROGRESS_HOOK.SEND_TX_102_01 | PROGRESS_HOOK.SEND_TX_103_01 | PROGRESS_HOOK.SEND_TX_103_02 | PROGRESS_HOOK.SEND_TX_103_03 | PROGRESS_HOOK.SEND_TX_103_03_01 | PROGRESS_HOOK.SEND_TX_103_03_02 | PROGRESS_HOOK.SEND_TX_103_03_03 | PROGRESS_HOOK.SEND_TX_103_03_04 | PROGRESS_HOOK.SEND_TX_104_01 | PROGRESS_HOOK.SEND_TX_104_02 | PROGRESS_HOOK.SEND_TX_104_03 | PROGRESS_HOOK.SEND_TX_104_04 | PROGRESS_HOOK.SEND_TX_105_01 | PROGRESS_HOOK.SEND_TX_105_02 | PROGRESS_HOOK.SEND_TX_106_01 | PROGRESS_HOOK.SEND_TX_106_02 | PROGRESS_HOOK.SEND_TX_106_03 | PROGRESS_HOOK.SEND_TX_106_03_01 | PROGRESS_HOOK.SEND_TX_106_03_02 | PROGRESS_HOOK.SEND_TX_106_04 | PROGRESS_HOOK.SEND_TX_106_05 | PROGRESS_HOOK.SEND_TX_106_06 | PROGRESS_HOOK.SEND_TX_107 | PROGRESS_HOOK.SEND_TX_199_01 | PROGRESS_HOOK.SEND_TX_199_02;
|
|
105
|
+
export type PROGRESS_HOOK_R1 = PROGRESS_HOOK.SEND_TX_101 | PROGRESS_HOOK.SEND_TX_102_01 | PROGRESS_HOOK.SEND_TX_103_01 | PROGRESS_HOOK.SEND_TX_103_02 | PROGRESS_HOOK.SEND_TX_103_03 | PROGRESS_HOOK.SEND_TX_103_03_01 | PROGRESS_HOOK.SEND_TX_103_03_02 | PROGRESS_HOOK.SEND_TX_103_03_03 | PROGRESS_HOOK.SEND_TX_103_03_04 | PROGRESS_HOOK.SEND_TX_104_01 | PROGRESS_HOOK.SEND_TX_104_02 | PROGRESS_HOOK.SEND_TX_104_03 | PROGRESS_HOOK.SEND_TX_104_04 | PROGRESS_HOOK.SEND_TX_105_01 | PROGRESS_HOOK.SEND_TX_105_02 | PROGRESS_HOOK.SEND_TX_106_01 | PROGRESS_HOOK.SEND_TX_106_02 | PROGRESS_HOOK.SEND_TX_106_03 | PROGRESS_HOOK.SEND_TX_106_03_01 | PROGRESS_HOOK.SEND_TX_106_03_02 | PROGRESS_HOOK.SEND_TX_106_04 | PROGRESS_HOOK.SEND_TX_106_05 | PROGRESS_HOOK.SEND_TX_106_06 | PROGRESS_HOOK.SEND_TX_107 | PROGRESS_HOOK.SEND_TX_199_01 | PROGRESS_HOOK.SEND_TX_199_02 | PROGRESS_HOOK.SEND_TX_199_03 | PROGRESS_HOOK.SEND_TX_199_99;
|
|
104
106
|
export type PROGRESS_HOOK_R2 = PROGRESS_HOOK.SEND_TX_201 | PROGRESS_HOOK.SEND_TX_202_01 | PROGRESS_HOOK.SEND_TX_202_02 | PROGRESS_HOOK.SEND_TX_203_01 | PROGRESS_HOOK.SEND_TX_203_02 | PROGRESS_HOOK.SEND_TX_203_03 | PROGRESS_HOOK.SEND_TX_203_04 | PROGRESS_HOOK.SEND_TX_203_05 | PROGRESS_HOOK.SEND_TX_204_01 | PROGRESS_HOOK.SEND_TX_204_02 | PROGRESS_HOOK.SEND_TX_204_03 | PROGRESS_HOOK.SEND_TX_204_04 | PROGRESS_HOOK.SEND_TX_207 | PROGRESS_HOOK.SEND_TX_209_01 | PROGRESS_HOOK.SEND_TX_209_02 | PROGRESS_HOOK.SEND_TX_299_01 | PROGRESS_HOOK.SEND_TX_299_02 | PROGRESS_HOOK.SEND_TX_299_03 | PROGRESS_HOOK.SEND_TX_299_99;
|
|
105
|
-
export type PROGRESS_HOOK_R3 = PROGRESS_HOOK.
|
|
107
|
+
export type PROGRESS_HOOK_R3 = PROGRESS_HOOK.SEND_TX_301 | PROGRESS_HOOK.SEND_TX_302_01 | PROGRESS_HOOK.SEND_TX_302_02 | PROGRESS_HOOK.SEND_TX_303_01 | PROGRESS_HOOK.SEND_TX_303_02 | PROGRESS_HOOK.SEND_TX_303_03_01 | PROGRESS_HOOK.SEND_TX_303_03_02 | PROGRESS_HOOK.SEND_TX_303_03_03 | PROGRESS_HOOK.SEND_TX_303_04 | PROGRESS_HOOK.SEND_TX_303_05 | PROGRESS_HOOK.SEND_TX_303_06 | PROGRESS_HOOK.SEND_TX_304_01 | PROGRESS_HOOK.SEND_TX_304_02 | PROGRESS_HOOK.SEND_TX_304_03 | PROGRESS_HOOK.SEND_TX_304_04 | PROGRESS_HOOK.SEND_TX_307 | PROGRESS_HOOK.SEND_TX_309_01 | PROGRESS_HOOK.SEND_TX_309_02 | PROGRESS_HOOK.SEND_TX_309_03 | PROGRESS_HOOK.SEND_TX_310_01 | PROGRESS_HOOK.SEND_TX_310_02 | PROGRESS_HOOK.SEND_TX_399_01 | PROGRESS_HOOK.SEND_TX_399_02 | PROGRESS_HOOK.SEND_TX_399_03 | PROGRESS_HOOK.SEND_TX_399_99;
|
|
106
108
|
export type PROGRESS_HOOK_MULTICHAIN = PROGRESS_HOOK.SEND_TX_001 | PROGRESS_HOOK.SEND_TX_002_01 | PROGRESS_HOOK.SEND_TX_002_99_99 | PROGRESS_HOOK.SEND_TX_003_03 | PROGRESS_HOOK.SEND_TX_003_04 | PROGRESS_HOOK.SEND_TX_003_05 | PROGRESS_HOOK.SEND_TX_999_01 | PROGRESS_HOOK.SEND_TX_999_02 | PROGRESS_HOOK.SEND_TX_999_03;
|
|
107
109
|
export type PROGRESS_HOOK_MIG = PROGRESS_HOOK.UEA_MIG_01 | PROGRESS_HOOK.UEA_MIG_02 | PROGRESS_HOOK.UEA_MIG_03 | PROGRESS_HOOK.UEA_MIG_9901 | PROGRESS_HOOK.UEA_MIG_9902 | PROGRESS_HOOK.UEA_MIG_9903;
|
|
108
110
|
export {};
|
|
@@ -30,7 +30,8 @@ var PROGRESS_HOOK;
|
|
|
30
30
|
PROGRESS_HOOK["SEND_TX_107"] = "SEND-TX-107";
|
|
31
31
|
PROGRESS_HOOK["SEND_TX_199_01"] = "SEND-TX-199-01";
|
|
32
32
|
PROGRESS_HOOK["SEND_TX_199_02"] = "SEND-TX-199-02";
|
|
33
|
-
PROGRESS_HOOK["
|
|
33
|
+
PROGRESS_HOOK["SEND_TX_199_03"] = "SEND-TX-199-03";
|
|
34
|
+
PROGRESS_HOOK["SEND_TX_199_99"] = "SEND-TX-199-99";
|
|
34
35
|
// Route 2: UEA → UGPC → CEA on target chain (201–299)
|
|
35
36
|
PROGRESS_HOOK["SEND_TX_201"] = "SEND-TX-201";
|
|
36
37
|
PROGRESS_HOOK["SEND_TX_202_01"] = "SEND-TX-202-01";
|
|
@@ -86,6 +87,7 @@ var PROGRESS_HOOK;
|
|
|
86
87
|
PROGRESS_HOOK["SEND_TX_399_01"] = "SEND-TX-399-01";
|
|
87
88
|
PROGRESS_HOOK["SEND_TX_399_02"] = "SEND-TX-399-02";
|
|
88
89
|
PROGRESS_HOOK["SEND_TX_399_03"] = "SEND-TX-399-03";
|
|
90
|
+
PROGRESS_HOOK["SEND_TX_399_99"] = "SEND-TX-399-99";
|
|
89
91
|
// Multichain (multi-hop) cascade markers
|
|
90
92
|
PROGRESS_HOOK["SEND_TX_001"] = "SEND-TX-001";
|
|
91
93
|
PROGRESS_HOOK["SEND_TX_002_01"] = "SEND-TX-002-01";
|