@pushchain/core 5.1.16 → 5.1.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushchain/core",
3
- "version": "5.1.16",
3
+ "version": "5.1.17",
4
4
  "homepage": "https://push.org",
5
5
  "keywords": [
6
6
  "pushchain",
@@ -64,17 +64,17 @@ export type PreflightResult = {
64
64
  export declare function runPreflight(opts: RunPreflightOpts): PreflightResult;
65
65
  /**
66
66
  * SVM-only telemetry threshold. Buffered pool quotes above this value
67
- * fire `SEND-TX-203-05` (single-route) or `SEND-TX-003-05` (cascade).
68
- * The threshold is for visibility, not truncation — pre-flight handles
69
- * drain protection. v2 may add a hard cap once telemetry justifies a
70
- * number.
67
+ * fire `SEND-TX-203-05` (R2 single-route), `SEND-TX-303-06` (R3
68
+ * single-route), or `SEND-TX-003-05` (cascade). The threshold is for
69
+ * visibility, not truncation — pre-flight handles drain protection.
70
+ * v2 may add a hard cap once telemetry justifies a number.
71
71
  */
72
72
  export declare const SVM_NATIVE_VALUE_WARN_THRESHOLD: bigint;
73
73
  /**
74
74
  * Fire the SVM warn-threshold hook + log line if the buffered quote
75
75
  * exceeds the threshold. Non-blocking; `nativeValueForGas` is not
76
- * truncated by the caller. The hook ID switches to the cascade 0xx
77
- * bucket (`003-05`) when `pathTag === 'CASCADE'` so cascade streams
78
- * stay self-consistent.
76
+ * truncated by the caller. The hook ID switches between buckets so
77
+ * each stream stays self-consistent within its convention (R2 → 203,
78
+ * R3 → 303, cascade → 003).
79
79
  */
80
80
  export declare function maybeFireSvmWarnThreshold(ctx: OrchestratorContext, bufferedQuote: bigint, gasToken: `0x${string}`, pathTag: PreflightPathTag): void;
@@ -51,16 +51,22 @@ function legacyClamp(ueaBalance, requiredValue, gasReserve) {
51
51
  */
52
52
  function runPreflight(opts) {
53
53
  const { ctx, ueaAddress, ueaBalance, requiredValue, gasReserve, pathTag, burnToken, burnAmount, prc20Balance, segmentIndex, allowUnderfundedSwap, } = opts;
54
- // Cascade context emits 003-xx (cascade 0xx bucket); single routes (R2/R3)
55
- // emit 203-xx (R2 bucket). The two ID sets share an identical formatter
54
+ // Each route bucket gets its own preflight IDs so hook streams stay
55
+ // self-consistent within their convention (R2 → 203-xx, R3 → 303-xx,
56
+ // cascade → 003-xx). The three hook formatters share an identical
56
57
  // signature, so the runtime branching is just an ID swap at each fire site.
57
58
  const isCascade = pathTag === 'CASCADE';
59
+ const isR3 = pathTag === 'R3_EVM' || pathTag === 'R3_SVM';
58
60
  const HOOK_PRE_INFO = isCascade
59
61
  ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_03
60
- : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03;
62
+ : isR3
63
+ ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04
64
+ : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03;
61
65
  const HOOK_PRE_FAIL = isCascade
62
66
  ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_04
63
- : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_04;
67
+ : isR3
68
+ ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05
69
+ : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_04;
64
70
  // 1. PRC-20 burn-balance check (skipped when burnAmount = 0 — R3 paths
65
71
  // structurally hold zero of the source-chain native PRC-20; see plan §9 #4).
66
72
  if (burnAmount && burnAmount > BigInt(0) && burnToken) {
@@ -119,25 +125,27 @@ function runPreflight(opts) {
119
125
  }
120
126
  /**
121
127
  * SVM-only telemetry threshold. Buffered pool quotes above this value
122
- * fire `SEND-TX-203-05` (single-route) or `SEND-TX-003-05` (cascade).
123
- * The threshold is for visibility, not truncation — pre-flight handles
124
- * drain protection. v2 may add a hard cap once telemetry justifies a
125
- * number.
128
+ * fire `SEND-TX-203-05` (R2 single-route), `SEND-TX-303-06` (R3
129
+ * single-route), or `SEND-TX-003-05` (cascade). The threshold is for
130
+ * visibility, not truncation — pre-flight handles drain protection.
131
+ * v2 may add a hard cap once telemetry justifies a number.
126
132
  */
127
133
  exports.SVM_NATIVE_VALUE_WARN_THRESHOLD = BigInt(5000) * BigInt(1e18);
128
134
  /**
129
135
  * Fire the SVM warn-threshold hook + log line if the buffered quote
130
136
  * exceeds the threshold. Non-blocking; `nativeValueForGas` is not
131
- * truncated by the caller. The hook ID switches to the cascade 0xx
132
- * bucket (`003-05`) when `pathTag === 'CASCADE'` so cascade streams
133
- * stay self-consistent.
137
+ * truncated by the caller. The hook ID switches between buckets so
138
+ * each stream stays self-consistent within its convention (R2 → 203,
139
+ * R3 → 303, cascade → 003).
134
140
  */
135
141
  function maybeFireSvmWarnThreshold(ctx, bufferedQuote, gasToken, pathTag) {
136
142
  if (bufferedQuote <= exports.SVM_NATIVE_VALUE_WARN_THRESHOLD)
137
143
  return;
138
144
  const HOOK_WARN = pathTag === 'CASCADE'
139
145
  ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_05
140
- : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_05;
146
+ : pathTag === 'R3_EVM' || pathTag === 'R3_SVM'
147
+ ? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_06
148
+ : progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_05;
141
149
  (0, context_1.fireProgressHook)(ctx, HOOK_WARN, bufferedQuote, exports.SVM_NATIVE_VALUE_WARN_THRESHOLD, gasToken, pathTag);
142
150
  (0, context_1.printLog)(ctx, `[preflight ${pathTag}] SVM warn-threshold tripped: bufferedQuote=${bufferedQuote} > ` +
143
151
  `${exports.SVM_NATIVE_VALUE_WARN_THRESHOLD} for gasToken=${gasToken} — pool may be skewed`);
@@ -176,7 +176,8 @@ function reconstructR3(universalTxResponse, universalTxData, isFailed, errorMsg)
176
176
  events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_02](universalTxResponse.from, ceaAddress, sourceChain));
177
177
  // R3 pre-flight reconstruction — R3 EVM burnAmount=0, R3 SVM burnAmount=0
178
178
  // (post-fix). Only the NATIVE pre-flight check fires; no PRC-20 second hook.
179
- events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03](BigInt(0), BigInt(0), true, universalTxResponse.from, 'R3_EVM', { kind: 'NATIVE' }));
179
+ // R3 single-route uses 303-04 (R3 bucket); see runPreflight in preflight.ts.
180
+ events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04](BigInt(0), BigInt(0), true, universalTxResponse.from, 'R3_EVM', { kind: 'NATIVE' }));
180
181
  events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01]());
181
182
  events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_02]());
182
183
  events.push(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_03]());
@@ -523,6 +523,63 @@ const RAW_HOOKS_R3 = {
523
523
  response: { uea: ueaAddr, cea: ceaAddr, chain: sourceChain, deployed: true },
524
524
  level: 'SUCCESS',
525
525
  }),
526
+ // R3 single-route pre-flight balance check. Same payload shape as 203-03/04/05.
527
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
528
+ var _a, _b, _c;
529
+ const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
530
+ const availableStr = kind === 'PRC20' ? `${available} units` : formatPC(available);
531
+ const requiredStr = kind === 'PRC20' ? `${required} units` : formatPC(required);
532
+ return {
533
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04,
534
+ title: 'Pre-flight Balance Check',
535
+ message: `UEA balance: ${availableStr}; required: ${requiredStr}; ` +
536
+ `${sufficient ? 'sufficient' : 'INSUFFICIENT'} (${pathTag})`,
537
+ response: {
538
+ required,
539
+ available,
540
+ sufficient,
541
+ ueaAddress,
542
+ pathTag,
543
+ kind,
544
+ burnToken: (_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : null,
545
+ segmentIndex: (_c = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _c !== void 0 ? _c : null,
546
+ },
547
+ level: sufficient ? 'INFO' : 'ERROR',
548
+ };
549
+ },
550
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
551
+ var _a, _b, _c, _d;
552
+ const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
553
+ const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : formatPC(shortfall);
554
+ const remediation = kind === 'PRC20'
555
+ ? `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.`
556
+ : `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
557
+ return {
558
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05,
559
+ title: 'Insufficient UEA Balance',
560
+ message: `Shortfall ${shortfallStr} on ${pathTag}. ${remediation}`,
561
+ response: {
562
+ required,
563
+ available,
564
+ shortfall,
565
+ ueaAddress,
566
+ pathTag,
567
+ kind,
568
+ burnToken: (_c = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _c !== void 0 ? _c : null,
569
+ segmentIndex: (_d = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _d !== void 0 ? _d : null,
570
+ },
571
+ level: 'ERROR',
572
+ };
573
+ },
574
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_06]: (quoted, threshold, gasToken, pathTag) => ({
575
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_06,
576
+ title: 'SVM Native-Value Warn Threshold',
577
+ message: `Buffered pool quote ${formatPC(quoted)} exceeds warn threshold ${formatPC(threshold)} ` +
578
+ `for ${gasToken} (${pathTag}). Pool may be skewed or quote is unusually large. ` +
579
+ `No action taken — pre-flight will determine if balance covers it.`,
580
+ response: { quoted, threshold, gasToken, pathTag },
581
+ level: 'INFO',
582
+ }),
526
583
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01]: () => ({
527
584
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01,
528
585
  title: 'Awaiting Signature',
@@ -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";