@pushchain/core 5.1.16 → 5.1.18
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/constants/index.d.ts +1 -1
- package/src/lib/constants/index.js +2 -1
- package/src/lib/constants/selectors.d.ts +8 -0
- package/src/lib/constants/selectors.js +9 -1
- package/src/lib/formatters.d.ts +1 -0
- package/src/lib/formatters.js +32 -0
- package/src/lib/orchestrator/internals/cascade.d.ts +8 -1
- package/src/lib/orchestrator/internals/cascade.js +486 -143
- package/src/lib/orchestrator/internals/error-decoder.d.ts +2 -6
- package/src/lib/orchestrator/internals/error-decoder.js +10 -10
- package/src/lib/orchestrator/internals/errors.d.ts +1 -1
- package/src/lib/orchestrator/internals/errors.js +7 -4
- package/src/lib/orchestrator/internals/execute-standard.js +7 -6
- package/src/lib/orchestrator/internals/gas-calculator.js +78 -11
- package/src/lib/orchestrator/internals/helpers.d.ts +2 -1
- package/src/lib/orchestrator/internals/helpers.js +13 -11
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +1 -0
- package/src/lib/orchestrator/internals/outbound-sync.js +93 -37
- package/src/lib/orchestrator/internals/preflight.d.ts +9 -23
- package/src/lib/orchestrator/internals/preflight.js +22 -48
- package/src/lib/orchestrator/internals/response-builder.js +23 -7
- package/src/lib/orchestrator/internals/route-handlers.js +34 -49
- package/src/lib/orchestrator/internals/tx-transformer.js +2 -1
- package/src/lib/orchestrator/orchestrator.d.ts +7 -1
- package/src/lib/orchestrator/orchestrator.js +40 -2
- package/src/lib/orchestrator/orchestrator.types.d.ts +4 -14
- package/src/lib/progress-hook/progress-hook.js +66 -16
- package/src/lib/progress-hook/progress-hook.types.d.ts +4 -1
- package/src/lib/progress-hook/progress-hook.types.js +8 -0
- package/src/lib/push-chain/push-chain.d.ts +11 -1
- package/src/lib/push-chain/push-chain.js +2 -2
- package/src/lib/universal-tx-detector/cascade.js +14 -4
- package/src/lib/universal-tx-detector/child-inbounds.js +9 -1
- package/src/lib/universal-tx-detector/detector.js +9 -3
- package/src/lib/universal-tx-detector/normalize.d.ts +42 -0
- package/src/lib/universal-tx-detector/normalize.js +127 -0
- package/src/lib/utils/external-tx-hash.d.ts +37 -0
- package/src/lib/utils/external-tx-hash.js +62 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.classifyDeclineError = classifyDeclineError;
|
|
4
|
+
const formatters_1 = require("../formatters");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
6
|
const progress_hook_types_1 = require("./progress-hook.types");
|
|
6
7
|
// Helper to wrap a hook function with timestamp
|
|
@@ -22,14 +23,6 @@ const friendlyChain = (chainOrNs) => {
|
|
|
22
23
|
const key = utils_1.Utils.chains.getChainName(asString);
|
|
23
24
|
return key ? toTitleCase(key) : asString;
|
|
24
25
|
};
|
|
25
|
-
/**
|
|
26
|
-
* Format a wei-denominated UPC bigint as a human-readable PC string for use
|
|
27
|
-
* in progress-hook `message` fields. Used by the pre-flight hooks
|
|
28
|
-
* (203-03/04/05 + 003-03/04/05) so consumers see "956.7834 PC" instead of
|
|
29
|
-
* "956783432238079848707 wei UPC". Response payload bigints are NOT
|
|
30
|
-
* transformed — programmatic consumers still get raw wei.
|
|
31
|
-
*/
|
|
32
|
-
const formatPC = (wei, precision = 4) => `${utils_1.Utils.helpers.formatUnits(wei, { decimals: 18, precision })} PC`;
|
|
33
26
|
/**
|
|
34
27
|
* Classify a sign-time error as either a true wallet user-decline
|
|
35
28
|
* (viem `UserRejectedRequestError`, ethers `ACTION_REJECTED`, EIP-1193 4001,
|
|
@@ -313,8 +306,8 @@ const RAW_HOOKS_R2 = {
|
|
|
313
306
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
|
|
314
307
|
var _a, _b, _c;
|
|
315
308
|
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
316
|
-
const availableStr = kind === 'PRC20' ? `${available} units` :
|
|
317
|
-
const requiredStr = kind === 'PRC20' ? `${required} units` :
|
|
309
|
+
const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
|
|
310
|
+
const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
|
|
318
311
|
return {
|
|
319
312
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03,
|
|
320
313
|
title: 'Pre-flight Balance Check',
|
|
@@ -336,7 +329,7 @@ const RAW_HOOKS_R2 = {
|
|
|
336
329
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_04]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
|
|
337
330
|
var _a, _b, _c, _d;
|
|
338
331
|
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
339
|
-
const shortfallStr = kind === 'PRC20' ? `${shortfall} units` :
|
|
332
|
+
const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
|
|
340
333
|
const remediation = kind === 'PRC20'
|
|
341
334
|
? `Bridge the burn token (${(_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
|
|
342
335
|
: `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
|
|
@@ -360,7 +353,7 @@ const RAW_HOOKS_R2 = {
|
|
|
360
353
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_05]: (quoted, threshold, gasToken, pathTag) => ({
|
|
361
354
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_05,
|
|
362
355
|
title: 'SVM Native-Value Warn Threshold',
|
|
363
|
-
message: `Buffered pool quote ${
|
|
356
|
+
message: `Buffered pool quote ${(0, formatters_1.formatPc)(quoted, 4)} exceeds warn threshold ${(0, formatters_1.formatPc)(threshold, 4)} ` +
|
|
364
357
|
`for ${gasToken} (${pathTag}). Pool may be skewed or quote is unusually large. ` +
|
|
365
358
|
`No action taken — pre-flight will determine if balance covers it.`,
|
|
366
359
|
response: { quoted, threshold, gasToken, pathTag },
|
|
@@ -523,6 +516,63 @@ const RAW_HOOKS_R3 = {
|
|
|
523
516
|
response: { uea: ueaAddr, cea: ceaAddr, chain: sourceChain, deployed: true },
|
|
524
517
|
level: 'SUCCESS',
|
|
525
518
|
}),
|
|
519
|
+
// R3 single-route pre-flight balance check. Same payload shape as 203-03/04/05.
|
|
520
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
|
|
521
|
+
var _a, _b, _c;
|
|
522
|
+
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
523
|
+
const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
|
|
524
|
+
const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
|
|
525
|
+
return {
|
|
526
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04,
|
|
527
|
+
title: 'Pre-flight Balance Check',
|
|
528
|
+
message: `UEA balance: ${availableStr}; required: ${requiredStr}; ` +
|
|
529
|
+
`${sufficient ? 'sufficient' : 'INSUFFICIENT'} (${pathTag})`,
|
|
530
|
+
response: {
|
|
531
|
+
required,
|
|
532
|
+
available,
|
|
533
|
+
sufficient,
|
|
534
|
+
ueaAddress,
|
|
535
|
+
pathTag,
|
|
536
|
+
kind,
|
|
537
|
+
burnToken: (_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : null,
|
|
538
|
+
segmentIndex: (_c = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _c !== void 0 ? _c : null,
|
|
539
|
+
},
|
|
540
|
+
level: sufficient ? 'INFO' : 'ERROR',
|
|
541
|
+
};
|
|
542
|
+
},
|
|
543
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
|
|
544
|
+
var _a, _b, _c, _d;
|
|
545
|
+
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
546
|
+
const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
|
|
547
|
+
const remediation = kind === 'PRC20'
|
|
548
|
+
? `Bridge the burn token (${(_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
|
|
549
|
+
: `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
|
|
550
|
+
return {
|
|
551
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05,
|
|
552
|
+
title: 'Insufficient UEA Balance',
|
|
553
|
+
message: `Shortfall ${shortfallStr} on ${pathTag}. ${remediation}`,
|
|
554
|
+
response: {
|
|
555
|
+
required,
|
|
556
|
+
available,
|
|
557
|
+
shortfall,
|
|
558
|
+
ueaAddress,
|
|
559
|
+
pathTag,
|
|
560
|
+
kind,
|
|
561
|
+
burnToken: (_c = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _c !== void 0 ? _c : null,
|
|
562
|
+
segmentIndex: (_d = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _d !== void 0 ? _d : null,
|
|
563
|
+
},
|
|
564
|
+
level: 'ERROR',
|
|
565
|
+
};
|
|
566
|
+
},
|
|
567
|
+
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_06]: (quoted, threshold, gasToken, pathTag) => ({
|
|
568
|
+
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_06,
|
|
569
|
+
title: 'SVM Native-Value Warn Threshold',
|
|
570
|
+
message: `Buffered pool quote ${(0, formatters_1.formatPc)(quoted, 4)} exceeds warn threshold ${(0, formatters_1.formatPc)(threshold, 4)} ` +
|
|
571
|
+
`for ${gasToken} (${pathTag}). Pool may be skewed or quote is unusually large. ` +
|
|
572
|
+
`No action taken — pre-flight will determine if balance covers it.`,
|
|
573
|
+
response: { quoted, threshold, gasToken, pathTag },
|
|
574
|
+
level: 'INFO',
|
|
575
|
+
}),
|
|
526
576
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01]: () => ({
|
|
527
577
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01,
|
|
528
578
|
title: 'Awaiting Signature',
|
|
@@ -729,8 +779,8 @@ const RAW_HOOKS_MULTICHAIN = {
|
|
|
729
779
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_03]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
|
|
730
780
|
var _a, _b, _c;
|
|
731
781
|
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
732
|
-
const availableStr = kind === 'PRC20' ? `${available} units` :
|
|
733
|
-
const requiredStr = kind === 'PRC20' ? `${required} units` :
|
|
782
|
+
const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
|
|
783
|
+
const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
|
|
734
784
|
return {
|
|
735
785
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_03,
|
|
736
786
|
title: 'Cascade Pre-flight Balance Check',
|
|
@@ -752,7 +802,7 @@ const RAW_HOOKS_MULTICHAIN = {
|
|
|
752
802
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_04]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
|
|
753
803
|
var _a, _b, _c, _d;
|
|
754
804
|
const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
|
|
755
|
-
const shortfallStr = kind === 'PRC20' ? `${shortfall} units` :
|
|
805
|
+
const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
|
|
756
806
|
const remediation = kind === 'PRC20'
|
|
757
807
|
? `Bridge the burn token (${(_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
|
|
758
808
|
: `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
|
|
@@ -776,7 +826,7 @@ const RAW_HOOKS_MULTICHAIN = {
|
|
|
776
826
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_05]: (quoted, threshold, gasToken, pathTag) => ({
|
|
777
827
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_05,
|
|
778
828
|
title: 'Cascade SVM Native-Value Warn Threshold',
|
|
779
|
-
message: `Buffered pool quote ${
|
|
829
|
+
message: `Buffered pool quote ${(0, formatters_1.formatPc)(quoted, 4)} exceeds warn threshold ${(0, formatters_1.formatPc)(threshold, 4)} ` +
|
|
780
830
|
`for ${gasToken} (${pathTag}). Pool may be skewed or quote is unusually large. ` +
|
|
781
831
|
`No action taken — pre-flight will determine if balance covers it.`,
|
|
782
832
|
response: { quoted, threshold, gasToken, pathTag },
|
|
@@ -68,6 +68,9 @@ export declare enum PROGRESS_HOOK {
|
|
|
68
68
|
SEND_TX_303_03_01 = "SEND-TX-303-03-01",// Sizer: Case A (< $1, padded)
|
|
69
69
|
SEND_TX_303_03_02 = "SEND-TX-303-03-02",// Sizer: Case B ($1–$10, happy path)
|
|
70
70
|
SEND_TX_303_03_03 = "SEND-TX-303-03-03",// Sizer: Case C (> $10, split + overflow bridge)
|
|
71
|
+
SEND_TX_303_04 = "SEND-TX-303-04",// R3 pre-flight balance check (INFO when sufficient, ERROR when insufficient)
|
|
72
|
+
SEND_TX_303_05 = "SEND-TX-303-05",// R3 pre-flight FAILED (ERROR, terminal precursor before 399-02)
|
|
73
|
+
SEND_TX_303_06 = "SEND-TX-303-06",// R3 SVM warn-threshold tripped (INFO, no action)
|
|
71
74
|
SEND_TX_304_01 = "SEND-TX-304-01",
|
|
72
75
|
SEND_TX_304_02 = "SEND-TX-304-02",
|
|
73
76
|
SEND_TX_304_03 = "SEND-TX-304-03",
|
|
@@ -99,7 +102,7 @@ export declare enum PROGRESS_HOOK {
|
|
|
99
102
|
}
|
|
100
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;
|
|
101
104
|
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;
|
|
102
|
-
export type PROGRESS_HOOK_R3 = PROGRESS_HOOK.SEND_TX_199_99_99 | 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_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;
|
|
105
|
+
export type PROGRESS_HOOK_R3 = PROGRESS_HOOK.SEND_TX_199_99_99 | 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;
|
|
103
106
|
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;
|
|
104
107
|
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;
|
|
105
108
|
export {};
|
|
@@ -64,6 +64,14 @@ var PROGRESS_HOOK;
|
|
|
64
64
|
PROGRESS_HOOK["SEND_TX_303_03_01"] = "SEND-TX-303-03-01";
|
|
65
65
|
PROGRESS_HOOK["SEND_TX_303_03_02"] = "SEND-TX-303-03-02";
|
|
66
66
|
PROGRESS_HOOK["SEND_TX_303_03_03"] = "SEND-TX-303-03-03";
|
|
67
|
+
// R3 single-route pre-flight balance check. Mirror of R2's 203-03/04/05
|
|
68
|
+
// semantics scoped to the R3 (3xx) bucket. Slots 303-03/-03-* are already
|
|
69
|
+
// owned by the sizer cluster so preflight uses the next free slots
|
|
70
|
+
// (304-01..04 are sign/verify), inserted between sizer and signature
|
|
71
|
+
// burst because that is the temporal point where UEA balance is checked.
|
|
72
|
+
PROGRESS_HOOK["SEND_TX_303_04"] = "SEND-TX-303-04";
|
|
73
|
+
PROGRESS_HOOK["SEND_TX_303_05"] = "SEND-TX-303-05";
|
|
74
|
+
PROGRESS_HOOK["SEND_TX_303_06"] = "SEND-TX-303-06";
|
|
67
75
|
PROGRESS_HOOK["SEND_TX_304_01"] = "SEND-TX-304-01";
|
|
68
76
|
PROGRESS_HOOK["SEND_TX_304_02"] = "SEND-TX-304-02";
|
|
69
77
|
PROGRESS_HOOK["SEND_TX_304_03"] = "SEND-TX-304-03";
|
|
@@ -77,8 +77,18 @@ export declare class PushChain {
|
|
|
77
77
|
/**
|
|
78
78
|
* Execute one or more prepared transactions as a cascade across chains.
|
|
79
79
|
* Accepts an array of PreparedUniversalTx (from prepareTransaction).
|
|
80
|
+
*
|
|
81
|
+
* @param txs - Prepared transactions to execute as a cascade.
|
|
82
|
+
* @param options.progressHook - Optional per-call progress callback.
|
|
83
|
+
* Additive with the init-time `progressHook` passed to `initialize`:
|
|
84
|
+
* both hooks receive every `ProgressEvent` emitted during this call
|
|
85
|
+
* (pre-flight, broadcast, and cascade tracking). Dedups by reference
|
|
86
|
+
* if it matches the init-time hook. Note: concurrent calls on the
|
|
87
|
+
* same instance share the hook channel during the broadcast phase.
|
|
80
88
|
*/
|
|
81
|
-
executeTransactions: (txs: PreparedUniversalTx[]
|
|
89
|
+
executeTransactions: (txs: PreparedUniversalTx[], options?: {
|
|
90
|
+
progressHook?: (event: ProgressEvent) => void;
|
|
91
|
+
}) => Promise<CascadedTxResponse>;
|
|
82
92
|
/**
|
|
83
93
|
* Tracks a transaction by hash on Push Chain
|
|
84
94
|
*/
|
|
@@ -84,11 +84,11 @@ class PushChain {
|
|
|
84
84
|
prepareTransaction: (params) => {
|
|
85
85
|
return orchestrator.prepareTransaction.bind(orchestrator)(params);
|
|
86
86
|
},
|
|
87
|
-
executeTransactions: (txs) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
executeTransactions: (txs, options) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
88
88
|
if (this.isReadMode) {
|
|
89
89
|
throw new Error('Read only mode cannot call executeTransactions function');
|
|
90
90
|
}
|
|
91
|
-
return orchestrator.createCascadedBuilder(txs).send();
|
|
91
|
+
return orchestrator.createCascadedBuilder(txs, options).send();
|
|
92
92
|
}),
|
|
93
93
|
trackTransaction: (txHash, options) => {
|
|
94
94
|
return orchestrator.trackTransaction.bind(orchestrator)(txHash, options);
|
|
@@ -25,6 +25,7 @@ const enums_1 = require("../constants/enums");
|
|
|
25
25
|
Object.defineProperty(exports, "PUSH_NETWORK", { enumerable: true, get: function () { return enums_1.PUSH_NETWORK; } });
|
|
26
26
|
const child_inbounds_1 = require("./child-inbounds");
|
|
27
27
|
const detector_1 = require("./detector");
|
|
28
|
+
const normalize_1 = require("./normalize");
|
|
28
29
|
const PUSH_CHAIN_CAIPS = new Set([
|
|
29
30
|
enums_1.CHAIN.PUSH_MAINNET,
|
|
30
31
|
enums_1.CHAIN.PUSH_TESTNET_DONUT,
|
|
@@ -46,8 +47,10 @@ function traceUniversalTxCascade(startHash, startChain, opts) {
|
|
|
46
47
|
const root = yield walk(startHash, startChain, 0, state, opts);
|
|
47
48
|
if (!root) {
|
|
48
49
|
// Should never happen for depth=0; return an empty detection node so the
|
|
49
|
-
// caller has something to render.
|
|
50
|
-
|
|
50
|
+
// caller has something to render. No outbound summaries → nothing to
|
|
51
|
+
// normalize, but we still pass through `normalizeCascadeNodeForUser`
|
|
52
|
+
// for symmetry with the happy path below.
|
|
53
|
+
return (0, normalize_1.normalizeCascadeNodeForUser)({
|
|
51
54
|
detection: {
|
|
52
55
|
txHash: startHash,
|
|
53
56
|
chain: startChain,
|
|
@@ -60,9 +63,16 @@ function traceUniversalTxCascade(startHash, startChain, opts) {
|
|
|
60
63
|
},
|
|
61
64
|
children: [],
|
|
62
65
|
depth: 0,
|
|
63
|
-
};
|
|
66
|
+
});
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
// User-facing normalization pass — recursively rewrites every
|
|
69
|
+
// `PushChainOutboundSummary.externalTxHash` in the tree to base58 for SVM
|
|
70
|
+
// destinations. Each internal `detectUniversalTx` call (in `walk`) already
|
|
71
|
+
// produced a normalized detection; this final pass also normalizes the
|
|
72
|
+
// edge-level `relation` summaries inside `expandPushOutbounds` /
|
|
73
|
+
// `expandExternalChildInbounds` which build summaries DIRECTLY (without
|
|
74
|
+
// going through `detectUniversalTx`).
|
|
75
|
+
return (0, normalize_1.normalizeCascadeNodeForUser)(root);
|
|
66
76
|
});
|
|
67
77
|
}
|
|
68
78
|
// ── Core recursion ────────────────────────────────────────────────────
|
|
@@ -22,6 +22,7 @@ const tslib_1 = require("tslib");
|
|
|
22
22
|
* `pushClient.getUniversalTxByIdV2`, no event-attribute predicate needed.
|
|
23
23
|
*/
|
|
24
24
|
const viem_1 = require("viem");
|
|
25
|
+
const normalize_1 = require("./normalize");
|
|
25
26
|
const STATUS_NAMES = {
|
|
26
27
|
0: 'UNIVERSAL_TX_STATUS_UNSPECIFIED',
|
|
27
28
|
1: 'INBOUND_SUCCESS',
|
|
@@ -75,7 +76,14 @@ function resolveChildInboundsFromDetection(pushClient, detection, diagnostics) {
|
|
|
75
76
|
const inboundLogs = detection.detections
|
|
76
77
|
.filter((d) => INBOUND_EVENT_NAMES.has(d.log.eventName))
|
|
77
78
|
.map((d) => d.log);
|
|
78
|
-
|
|
79
|
+
const resolutions = yield resolveChildInboundsFromLogs(pushClient, detection.chain, detection.txHash, inboundLogs, diagnostics);
|
|
80
|
+
// User-facing normalization pass: rewrites nested
|
|
81
|
+
// `outboundHashes[n].externalTxHash` to base58 for SVM destinations.
|
|
82
|
+
// `pcTxHashes` is Push Chain (EVM) and stays hex by chain type. The lower-
|
|
83
|
+
// level `resolveChildInboundsFromLogs` is left producing raw hex so
|
|
84
|
+
// internal callers (`findChildUtxIdFromExternalTx` via the detector path)
|
|
85
|
+
// that go through it directly still see the canonical form.
|
|
86
|
+
return resolutions.map(normalize_1.normalizeChildInboundResolutionForUser);
|
|
79
87
|
});
|
|
80
88
|
}
|
|
81
89
|
/**
|
|
@@ -25,6 +25,7 @@ const events_1 = require("./events");
|
|
|
25
25
|
const classify_1 = require("./classify");
|
|
26
26
|
const child_inbounds_1 = require("./child-inbounds");
|
|
27
27
|
const detector_svm_1 = require("./detector-svm");
|
|
28
|
+
const normalize_1 = require("./normalize");
|
|
28
29
|
// ── Status name table (copied from scripts/poll-outbound.ts:33-44) ────
|
|
29
30
|
const UNIVERSAL_TX_STATUS_NAMES = {
|
|
30
31
|
0: 'UNIVERSAL_TX_STATUS_UNSPECIFIED',
|
|
@@ -51,7 +52,7 @@ function detectUniversalTx(txHash_1, chain_2) {
|
|
|
51
52
|
throw new Error(`detectUniversalTx: unknown chain ${chain}`);
|
|
52
53
|
}
|
|
53
54
|
if (chainInfo.vm === enums_1.VM.SVM) {
|
|
54
|
-
return (0, detector_svm_1.detectUniversalTxSvm)(txHash, chain, opts);
|
|
55
|
+
return (0, normalize_1.normalizeDetectionForUser)(yield (0, detector_svm_1.detectUniversalTxSvm)(txHash, chain, opts));
|
|
55
56
|
}
|
|
56
57
|
if (chainInfo.vm !== enums_1.VM.EVM) {
|
|
57
58
|
throw new Error(`detectUniversalTx: unsupported vm=${chainInfo.vm} for ${chain}`);
|
|
@@ -132,7 +133,12 @@ function detectUniversalTx(txHash_1, chain_2) {
|
|
|
132
133
|
notes.push('push cross-reference skipped (no pushClient provided)');
|
|
133
134
|
}
|
|
134
135
|
const detections = (0, classify_1.classifyAll)(classified.matchingLogs);
|
|
135
|
-
|
|
136
|
+
// User-facing normalization pass: rewrites `pushChainTx.outboundHashes[n]
|
|
137
|
+
// .externalTxHash` to base58 for SVM destinations. The raw `0x`-hex form
|
|
138
|
+
// never leaves this function — internal consumers (findChildUtxIdFromExternalTx,
|
|
139
|
+
// Cosmos `inbound_tx_hash=` queries) work off their own input parameters,
|
|
140
|
+
// not the detection result's outbound summaries.
|
|
141
|
+
return (0, normalize_1.normalizeDetectionForUser)({
|
|
136
142
|
txHash,
|
|
137
143
|
chain,
|
|
138
144
|
kind: classified.kind,
|
|
@@ -142,7 +148,7 @@ function detectUniversalTx(txHash_1, chain_2) {
|
|
|
142
148
|
detections,
|
|
143
149
|
pushChainTx,
|
|
144
150
|
notes,
|
|
145
|
-
};
|
|
151
|
+
});
|
|
146
152
|
});
|
|
147
153
|
}
|
|
148
154
|
// ── Helpers ───────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-facing normalization pass for detector outputs.
|
|
3
|
+
*
|
|
4
|
+
* The detector module's internal pipeline produces `PushChainOutboundSummary`
|
|
5
|
+
* objects with raw `0x`-hex `externalTxHash` for SVM destinations — that's
|
|
6
|
+
* the form Cosmos delivers and the form `findChildUtxIdFromExternalTx` /
|
|
7
|
+
* `inbound_tx_hash='…'` queries require. For USER-facing entry points
|
|
8
|
+
* (`detectUniversalTx`, `traceUniversalTxCascade`,
|
|
9
|
+
* `resolveChildInboundsFromDetection`), the SVM hash should be base58 so
|
|
10
|
+
* consumers can paste it straight into a Solana explorer or
|
|
11
|
+
* `connection.getTransaction(sig)`.
|
|
12
|
+
*
|
|
13
|
+
* These helpers are applied at the three public-API return points (and
|
|
14
|
+
* NOWHERE else) — they walk the result tree and rewrite
|
|
15
|
+
* `PushChainOutboundSummary.externalTxHash` for SVM destinations. The
|
|
16
|
+
* internal pipeline never sees the normalized form.
|
|
17
|
+
*
|
|
18
|
+
* Helpers are idempotent: a value not starting with `0x` or whose
|
|
19
|
+
* `destinationChain` isn't SVM passes through unchanged. New objects are
|
|
20
|
+
* returned only when a field actually changed; otherwise the same reference
|
|
21
|
+
* is reused so EVM-only graphs incur near-zero allocation.
|
|
22
|
+
*/
|
|
23
|
+
import type { PushChainOutboundSummary, UniversalTxDetection } from './types';
|
|
24
|
+
import type { CascadeNode } from './cascade';
|
|
25
|
+
import type { ChildInboundResolution } from './child-inbounds';
|
|
26
|
+
/**
|
|
27
|
+
* Normalize a single outbound summary's `externalTxHash` for user display.
|
|
28
|
+
* Returns the same reference when no change is needed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeOutboundSummaryForUser(s: PushChainOutboundSummary): PushChainOutboundSummary;
|
|
31
|
+
/**
|
|
32
|
+
* Normalize the outbound summaries embedded in `detection.pushChainTx`.
|
|
33
|
+
* The root `detection.txHash` is left untouched — per agreed scope.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeDetectionForUser(d: UniversalTxDetection): UniversalTxDetection;
|
|
36
|
+
/**
|
|
37
|
+
* Normalize the outbound summaries inside a `ChildInboundResolution`.
|
|
38
|
+
* `pcTxHashes` (Push Chain — always EVM) is left untouched.
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeChildInboundResolutionForUser(r: ChildInboundResolution): ChildInboundResolution;
|
|
41
|
+
/** Recursively normalize a cascade tree. */
|
|
42
|
+
export declare function normalizeCascadeNodeForUser(n: CascadeNode): CascadeNode;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User-facing normalization pass for detector outputs.
|
|
4
|
+
*
|
|
5
|
+
* The detector module's internal pipeline produces `PushChainOutboundSummary`
|
|
6
|
+
* objects with raw `0x`-hex `externalTxHash` for SVM destinations — that's
|
|
7
|
+
* the form Cosmos delivers and the form `findChildUtxIdFromExternalTx` /
|
|
8
|
+
* `inbound_tx_hash='…'` queries require. For USER-facing entry points
|
|
9
|
+
* (`detectUniversalTx`, `traceUniversalTxCascade`,
|
|
10
|
+
* `resolveChildInboundsFromDetection`), the SVM hash should be base58 so
|
|
11
|
+
* consumers can paste it straight into a Solana explorer or
|
|
12
|
+
* `connection.getTransaction(sig)`.
|
|
13
|
+
*
|
|
14
|
+
* These helpers are applied at the three public-API return points (and
|
|
15
|
+
* NOWHERE else) — they walk the result tree and rewrite
|
|
16
|
+
* `PushChainOutboundSummary.externalTxHash` for SVM destinations. The
|
|
17
|
+
* internal pipeline never sees the normalized form.
|
|
18
|
+
*
|
|
19
|
+
* Helpers are idempotent: a value not starting with `0x` or whose
|
|
20
|
+
* `destinationChain` isn't SVM passes through unchanged. New objects are
|
|
21
|
+
* returned only when a field actually changed; otherwise the same reference
|
|
22
|
+
* is reused so EVM-only graphs incur near-zero allocation.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.normalizeOutboundSummaryForUser = normalizeOutboundSummaryForUser;
|
|
26
|
+
exports.normalizeDetectionForUser = normalizeDetectionForUser;
|
|
27
|
+
exports.normalizeChildInboundResolutionForUser = normalizeChildInboundResolutionForUser;
|
|
28
|
+
exports.normalizeCascadeNodeForUser = normalizeCascadeNodeForUser;
|
|
29
|
+
const external_tx_hash_1 = require("../utils/external-tx-hash");
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a single outbound summary's `externalTxHash` for user display.
|
|
32
|
+
* Returns the same reference when no change is needed.
|
|
33
|
+
*/
|
|
34
|
+
function normalizeOutboundSummaryForUser(s) {
|
|
35
|
+
if (!s.externalTxHash)
|
|
36
|
+
return s;
|
|
37
|
+
const chain = (0, external_tx_hash_1.chainFromNamespace)(s.destinationChain);
|
|
38
|
+
const next = (0, external_tx_hash_1.toExternalTxHashDisplay)(chain !== null && chain !== void 0 ? chain : undefined, s.externalTxHash);
|
|
39
|
+
if (next === s.externalTxHash)
|
|
40
|
+
return s;
|
|
41
|
+
return Object.assign(Object.assign({}, s), { externalTxHash: next });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize the outbound summaries inside `PushChainCrossRef.outboundHashes`.
|
|
45
|
+
* Reuses the input when no nested summary changed.
|
|
46
|
+
*/
|
|
47
|
+
function normalizeCrossRefForUser(x) {
|
|
48
|
+
if (!x.outboundHashes || x.outboundHashes.length === 0)
|
|
49
|
+
return x;
|
|
50
|
+
let changed = false;
|
|
51
|
+
const next = x.outboundHashes.map((s) => {
|
|
52
|
+
const n = normalizeOutboundSummaryForUser(s);
|
|
53
|
+
if (n !== s)
|
|
54
|
+
changed = true;
|
|
55
|
+
return n;
|
|
56
|
+
});
|
|
57
|
+
if (!changed)
|
|
58
|
+
return x;
|
|
59
|
+
return Object.assign(Object.assign({}, x), { outboundHashes: next });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Normalize the outbound summaries embedded in `detection.pushChainTx`.
|
|
63
|
+
* The root `detection.txHash` is left untouched — per agreed scope.
|
|
64
|
+
*/
|
|
65
|
+
function normalizeDetectionForUser(d) {
|
|
66
|
+
if (!d.pushChainTx)
|
|
67
|
+
return d;
|
|
68
|
+
const nextPushChainTx = normalizeCrossRefForUser(d.pushChainTx);
|
|
69
|
+
if (nextPushChainTx === d.pushChainTx)
|
|
70
|
+
return d;
|
|
71
|
+
return Object.assign(Object.assign({}, d), { pushChainTx: nextPushChainTx });
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Normalize the outbound summaries inside a `ChildInboundResolution`.
|
|
75
|
+
* `pcTxHashes` (Push Chain — always EVM) is left untouched.
|
|
76
|
+
*/
|
|
77
|
+
function normalizeChildInboundResolutionForUser(r) {
|
|
78
|
+
if (!r.outboundHashes || r.outboundHashes.length === 0)
|
|
79
|
+
return r;
|
|
80
|
+
let changed = false;
|
|
81
|
+
const next = r.outboundHashes.map((s) => {
|
|
82
|
+
const n = normalizeOutboundSummaryForUser(s);
|
|
83
|
+
if (n !== s)
|
|
84
|
+
changed = true;
|
|
85
|
+
return n;
|
|
86
|
+
});
|
|
87
|
+
if (!changed)
|
|
88
|
+
return r;
|
|
89
|
+
return Object.assign(Object.assign({}, r), { outboundHashes: next });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Type guard: identifies a `CascadeEdge.relation` as a
|
|
93
|
+
* `PushChainOutboundSummary`. Outbound summaries carry `destinationChain` and
|
|
94
|
+
* (optionally) `externalTxHash`; refund summaries and child-inbound
|
|
95
|
+
* resolutions don't.
|
|
96
|
+
*/
|
|
97
|
+
function isOutboundRelation(r) {
|
|
98
|
+
return (typeof r.destinationChain === 'string' &&
|
|
99
|
+
!('universalTxId' in r) &&
|
|
100
|
+
!('parentOutboundId' in r));
|
|
101
|
+
}
|
|
102
|
+
function isChildInboundRelation(r) {
|
|
103
|
+
return 'universalTxId' in r;
|
|
104
|
+
}
|
|
105
|
+
/** Recursively normalize a cascade tree. */
|
|
106
|
+
function normalizeCascadeNodeForUser(n) {
|
|
107
|
+
const nextDetection = normalizeDetectionForUser(n.detection);
|
|
108
|
+
let childrenChanged = nextDetection !== n.detection;
|
|
109
|
+
const nextChildren = n.children.map((edge) => {
|
|
110
|
+
let nextRelation = edge.relation;
|
|
111
|
+
if (isOutboundRelation(edge.relation)) {
|
|
112
|
+
nextRelation = normalizeOutboundSummaryForUser(edge.relation);
|
|
113
|
+
}
|
|
114
|
+
else if (isChildInboundRelation(edge.relation)) {
|
|
115
|
+
nextRelation = normalizeChildInboundResolutionForUser(edge.relation);
|
|
116
|
+
}
|
|
117
|
+
const nextNode = edge.node ? normalizeCascadeNodeForUser(edge.node) : edge.node;
|
|
118
|
+
if (nextRelation === edge.relation && nextNode === edge.node)
|
|
119
|
+
return edge;
|
|
120
|
+
childrenChanged = true;
|
|
121
|
+
return Object.assign(Object.assign({}, edge), { relation: nextRelation, node: nextNode });
|
|
122
|
+
});
|
|
123
|
+
if (!childrenChanged)
|
|
124
|
+
return n;
|
|
125
|
+
return Object.assign(Object.assign({}, n), { detection: nextDetection, children: nextChildren });
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External-tx-hash display helpers.
|
|
3
|
+
*
|
|
4
|
+
* Lives at a neutral cross-module location so both the orchestrator and the
|
|
5
|
+
* universal-tx-detector module can import without creating a circular /
|
|
6
|
+
* back-layered dependency (orchestrator/internals imports detector via
|
|
7
|
+
* inbound-tracker.ts; detector must not import back into orchestrator).
|
|
8
|
+
*
|
|
9
|
+
* The SDK stores SVM (Solana) outbound tx signatures as `0x`-prefixed hex
|
|
10
|
+
* internally — that's how the Cosmos keeper indexes them. Users, however,
|
|
11
|
+
* expect Solana explorers / RPCs to see base58 signatures. `toExternalTxHashDisplay`
|
|
12
|
+
* is the one-way conversion applied at every user-facing boundary; the
|
|
13
|
+
* internal canonical form stays hex.
|
|
14
|
+
*/
|
|
15
|
+
import { CHAIN } from '../constants/enums';
|
|
16
|
+
/**
|
|
17
|
+
* Convert an outbound tx hash from the internal canonical form (`0x`-prefixed
|
|
18
|
+
* hex, as Cosmos delivers it) to the form users expect on the destination
|
|
19
|
+
* chain. SVM signatures (64 bytes) become base58; EVM hashes pass through
|
|
20
|
+
* unchanged. Idempotent: a value that already lacks `0x` or whose chain isn't
|
|
21
|
+
* SVM is returned as-is.
|
|
22
|
+
*
|
|
23
|
+
* Used at user-facing boundaries that surface `externalTxHash` (receipt
|
|
24
|
+
* construction in response-builder, cascade hop info in cascade.ts, detector
|
|
25
|
+
* public-API output normalization). Do NOT apply at internal boundaries —
|
|
26
|
+
* `findChildUtxIdFromExternalTx` and the Cosmos tx-search query in
|
|
27
|
+
* inbound-tracker.ts expect the raw hex form.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toExternalTxHashDisplay(chain: CHAIN | undefined, rawTxHash: string | undefined): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Map a CAIP namespace string (e.g. `'solana:devnet'`, `'eip155:11155111'`)
|
|
32
|
+
* to the corresponding `CHAIN` enum value, or `null` if no matching chain is
|
|
33
|
+
* registered. Used to resolve `PushChainOutboundSummary.destinationChain`
|
|
34
|
+
* (string) to a CHAIN enum so `toExternalTxHashDisplay` can decide whether
|
|
35
|
+
* to convert.
|
|
36
|
+
*/
|
|
37
|
+
export declare function chainFromNamespace(namespace: string): CHAIN | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* External-tx-hash display helpers.
|
|
4
|
+
*
|
|
5
|
+
* Lives at a neutral cross-module location so both the orchestrator and the
|
|
6
|
+
* universal-tx-detector module can import without creating a circular /
|
|
7
|
+
* back-layered dependency (orchestrator/internals imports detector via
|
|
8
|
+
* inbound-tracker.ts; detector must not import back into orchestrator).
|
|
9
|
+
*
|
|
10
|
+
* The SDK stores SVM (Solana) outbound tx signatures as `0x`-prefixed hex
|
|
11
|
+
* internally — that's how the Cosmos keeper indexes them. Users, however,
|
|
12
|
+
* expect Solana explorers / RPCs to see base58 signatures. `toExternalTxHashDisplay`
|
|
13
|
+
* is the one-way conversion applied at every user-facing boundary; the
|
|
14
|
+
* internal canonical form stays hex.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.toExternalTxHashDisplay = toExternalTxHashDisplay;
|
|
18
|
+
exports.chainFromNamespace = chainFromNamespace;
|
|
19
|
+
const chain_1 = require("../constants/chain");
|
|
20
|
+
const enums_1 = require("../constants/enums");
|
|
21
|
+
const bs58_1 = require("../internal/bs58");
|
|
22
|
+
/**
|
|
23
|
+
* Convert an outbound tx hash from the internal canonical form (`0x`-prefixed
|
|
24
|
+
* hex, as Cosmos delivers it) to the form users expect on the destination
|
|
25
|
+
* chain. SVM signatures (64 bytes) become base58; EVM hashes pass through
|
|
26
|
+
* unchanged. Idempotent: a value that already lacks `0x` or whose chain isn't
|
|
27
|
+
* SVM is returned as-is.
|
|
28
|
+
*
|
|
29
|
+
* Used at user-facing boundaries that surface `externalTxHash` (receipt
|
|
30
|
+
* construction in response-builder, cascade hop info in cascade.ts, detector
|
|
31
|
+
* public-API output normalization). Do NOT apply at internal boundaries —
|
|
32
|
+
* `findChildUtxIdFromExternalTx` and the Cosmos tx-search query in
|
|
33
|
+
* inbound-tracker.ts expect the raw hex form.
|
|
34
|
+
*/
|
|
35
|
+
function toExternalTxHashDisplay(chain, rawTxHash) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!rawTxHash)
|
|
38
|
+
return rawTxHash;
|
|
39
|
+
if (!chain || ((_a = chain_1.CHAIN_INFO[chain]) === null || _a === void 0 ? void 0 : _a.vm) !== enums_1.VM.SVM)
|
|
40
|
+
return rawTxHash;
|
|
41
|
+
if (!rawTxHash.startsWith('0x'))
|
|
42
|
+
return rawTxHash;
|
|
43
|
+
const bytes = new Uint8Array(Buffer.from(rawTxHash.slice(2), 'hex'));
|
|
44
|
+
return bs58_1.bs58.encode(Buffer.from(bytes));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Map a CAIP namespace string (e.g. `'solana:devnet'`, `'eip155:11155111'`)
|
|
48
|
+
* to the corresponding `CHAIN` enum value, or `null` if no matching chain is
|
|
49
|
+
* registered. Used to resolve `PushChainOutboundSummary.destinationChain`
|
|
50
|
+
* (string) to a CHAIN enum so `toExternalTxHashDisplay` can decide whether
|
|
51
|
+
* to convert.
|
|
52
|
+
*/
|
|
53
|
+
function chainFromNamespace(namespace) {
|
|
54
|
+
for (const [chainKey, info] of Object.entries(chain_1.CHAIN_INFO)) {
|
|
55
|
+
const expected = `${chain_1.VM_NAMESPACE[info.vm]}:${info.chainId}`;
|
|
56
|
+
if (expected === namespace) {
|
|
57
|
+
return chainKey;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=external-tx-hash.js.map
|