@pushchain/core 5.1.5-alpha.1 → 5.1.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.json +1 -1
  3. package/src/lib/constants/abi/index.d.ts +2 -0
  4. package/src/lib/constants/abi/index.js +6 -1
  5. package/src/lib/constants/abi/uniswap-v3-router.evm.d.ts +58 -0
  6. package/src/lib/constants/abi/uniswap-v3-router.evm.js +41 -0
  7. package/src/lib/constants/abi/wpc.evm.d.ts +24 -0
  8. package/src/lib/constants/abi/wpc.evm.js +27 -0
  9. package/src/lib/constants/chain.d.ts +1 -0
  10. package/src/lib/constants/chain.js +8 -6
  11. package/src/lib/constants/tokens.js +3 -3
  12. package/src/lib/generated/uexecutor/v2/types.d.ts +14 -0
  13. package/src/lib/generated/uexecutor/v2/types.js +96 -3
  14. package/src/lib/orchestrator/internals/cascade.d.ts +1 -1
  15. package/src/lib/orchestrator/internals/cascade.js +521 -239
  16. package/src/lib/orchestrator/internals/confirmation.js +60 -15
  17. package/src/lib/orchestrator/internals/context.d.ts +23 -0
  18. package/src/lib/orchestrator/internals/context.js +54 -0
  19. package/src/lib/orchestrator/internals/execute-funds-only.js +47 -21
  20. package/src/lib/orchestrator/internals/execute-funds-payload.js +53 -31
  21. package/src/lib/orchestrator/internals/execute-standard.js +137 -26
  22. package/src/lib/orchestrator/internals/gas-calculator.d.ts +5 -2
  23. package/src/lib/orchestrator/internals/gas-calculator.js +59 -11
  24. package/src/lib/orchestrator/internals/gas-usd-sizer.d.ts +53 -0
  25. package/src/lib/orchestrator/internals/gas-usd-sizer.js +165 -0
  26. package/src/lib/orchestrator/internals/helpers.js +2 -0
  27. package/src/lib/orchestrator/internals/inbound-tracker.d.ts +83 -0
  28. package/src/lib/orchestrator/internals/inbound-tracker.js +322 -0
  29. package/src/lib/orchestrator/internals/index.d.ts +3 -1
  30. package/src/lib/orchestrator/internals/index.js +8 -2
  31. package/src/lib/orchestrator/internals/outbound-sync.d.ts +32 -1
  32. package/src/lib/orchestrator/internals/outbound-sync.js +154 -17
  33. package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +28 -0
  34. package/src/lib/orchestrator/internals/pc-usd-oracle.js +285 -0
  35. package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +23 -0
  36. package/src/lib/orchestrator/internals/progress-route-hooks.js +72 -0
  37. package/src/lib/orchestrator/internals/push-chain-tx.d.ts +27 -1
  38. package/src/lib/orchestrator/internals/push-chain-tx.js +111 -15
  39. package/src/lib/orchestrator/internals/rescue.js +1 -1
  40. package/src/lib/orchestrator/internals/response-builder.d.ts +5 -0
  41. package/src/lib/orchestrator/internals/response-builder.js +242 -66
  42. package/src/lib/orchestrator/internals/route-handlers.js +480 -206
  43. package/src/lib/orchestrator/internals/tx-transformer.js +293 -35
  44. package/src/lib/orchestrator/orchestrator.d.ts +7 -1
  45. package/src/lib/orchestrator/orchestrator.js +108 -56
  46. package/src/lib/orchestrator/orchestrator.types.d.ts +111 -5
  47. package/src/lib/orchestrator/payload-builders.d.ts +16 -0
  48. package/src/lib/orchestrator/payload-builders.js +6 -5
  49. package/src/lib/orchestrator/route-detector.js +20 -8
  50. package/src/lib/orchestrator/svm-idl/normalize-address.d.ts +19 -0
  51. package/src/lib/orchestrator/svm-idl/normalize-address.js +56 -0
  52. package/src/lib/orchestrator/svm-idl/registry.d.ts +13 -4
  53. package/src/lib/orchestrator/svm-idl/registry.js +15 -14
  54. package/src/lib/orchestrator/svm-idl/resolve.js +5 -2
  55. package/src/lib/progress-hook/progress-hook.d.ts +28 -0
  56. package/src/lib/progress-hook/progress-hook.js +545 -131
  57. package/src/lib/progress-hook/progress-hook.types.d.ts +76 -29
  58. package/src/lib/progress-hook/progress-hook.types.js +74 -35
  59. package/src/lib/push-client/push-client.d.ts +7 -0
  60. package/src/lib/push-client/push-client.js +18 -1
  61. package/src/lib/universal-tx-detector/__tests__/fixtures/builders.d.ts +32 -0
  62. package/src/lib/universal-tx-detector/__tests__/fixtures/builders.js +65 -0
  63. package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.d.ts +72 -0
  64. package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.js +669 -0
  65. package/src/lib/universal-tx-detector/auto-detect.d.ts +37 -0
  66. package/src/lib/universal-tx-detector/auto-detect.js +112 -0
  67. package/src/lib/universal-tx-detector/cascade.d.ts +64 -0
  68. package/src/lib/universal-tx-detector/cascade.js +254 -0
  69. package/src/lib/universal-tx-detector/child-inbounds.d.ts +58 -0
  70. package/src/lib/universal-tx-detector/child-inbounds.js +145 -0
  71. package/src/lib/universal-tx-detector/classify.d.ts +33 -0
  72. package/src/lib/universal-tx-detector/classify.js +228 -0
  73. package/src/lib/universal-tx-detector/detector-svm.d.ts +46 -0
  74. package/src/lib/universal-tx-detector/detector-svm.js +324 -0
  75. package/src/lib/universal-tx-detector/detector.d.ts +13 -0
  76. package/src/lib/universal-tx-detector/detector.js +233 -0
  77. package/src/lib/universal-tx-detector/events.d.ts +765 -0
  78. package/src/lib/universal-tx-detector/events.js +241 -0
  79. package/src/lib/universal-tx-detector/index.d.ts +18 -0
  80. package/src/lib/universal-tx-detector/index.js +36 -0
  81. package/src/lib/universal-tx-detector/svm-events.d.ts +41 -0
  82. package/src/lib/universal-tx-detector/svm-events.js +68 -0
  83. package/src/lib/universal-tx-detector/types.d.ts +100 -0
  84. package/src/lib/universal-tx-detector/types.js +3 -0
  85. package/src/lib/utils.d.ts +30 -13
  86. package/src/lib/utils.js +47 -21
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyDeclineError = classifyDeclineError;
3
4
  const utils_1 = require("../utils");
4
5
  const progress_hook_types_1 = require("./progress-hook.types");
5
6
  // Helper to wrap a hook function with timestamp
@@ -7,212 +8,576 @@ const withTimestamp = (fn) => {
7
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
9
  return (...args) => (Object.assign(Object.assign({}, fn(...args)), { timestamp: new Date().toISOString() }));
9
10
  };
10
- const RAW_HOOKS = {
11
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_01]: (originChainNamespace, originChainAddress) => {
12
- var _a;
13
- return ({
14
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_01,
15
- title: 'Origin Chain Detected',
16
- message: `Origin chain: ${(_a = utils_1.Utils.chains.getChainName(originChainNamespace)) !== null && _a !== void 0 ? _a : originChainNamespace} - Origin Address: ${originChainAddress}`,
17
- response: null,
18
- level: 'INFO',
19
- });
20
- },
21
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_01]: () => ({
22
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_01,
11
+ const friendlyChain = (chainOrNs) => {
12
+ var _a;
13
+ if (!chainOrNs)
14
+ return 'chain';
15
+ const asString = String(chainOrNs);
16
+ return (_a = utils_1.Utils.chains.getChainName(asString)) !== null && _a !== void 0 ? _a : asString;
17
+ };
18
+ /**
19
+ * Classify a sign-time error as either a true wallet user-decline
20
+ * (viem `UserRejectedRequestError`, ethers `ACTION_REJECTED`, EIP-1193 4001,
21
+ * or textual "user rejected"/"user denied"/"declined by user") or a generic
22
+ * signature failure (insufficient funds, RPC failure, contract revert
23
+ * during sign, etc.). Shared by SEND_TX_104_04 (R1), SEND_TX_204_04 (R2),
24
+ * and SEND_TX_304_04 (R3) so the heuristic lives in one place.
25
+ *
26
+ * When `errorMessage` is omitted, treat it as a decline — the spec copy is
27
+ * already the decline copy ("Verification declined by user"), so flipping
28
+ * to "Signature Failed" would make the event self-contradict.
29
+ */
30
+ function classifyDeclineError(errorMessage) {
31
+ const msg = errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user';
32
+ const isUserDecline = errorMessage === undefined ||
33
+ /user\s*reject/i.test(msg) ||
34
+ /user\s*denied/i.test(msg) ||
35
+ /rejected\s*the\s*request/i.test(msg) ||
36
+ /UserRejectedRequestError/i.test(msg) ||
37
+ /ACTION_REJECTED/i.test(msg) ||
38
+ /declined\s*by\s*user/i.test(msg) ||
39
+ /\b4001\b/.test(msg);
40
+ return {
41
+ isUserDecline,
42
+ title: isUserDecline ? 'Verification Declined' : 'Signature Failed',
43
+ message: isUserDecline ? 'Verification declined by user' : msg,
44
+ };
45
+ }
46
+ // =============================================================================
47
+ // Route 1 — UOA → Push Chain (101–199)
48
+ // =============================================================================
49
+ const RAW_HOOKS_R1 = {
50
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_101]: (originChainNamespace, originChainAddress) => ({
51
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_101,
52
+ title: 'Origin Chain Detected',
53
+ message: `Origin chain: ${friendlyChain(originChainNamespace)} — Address: ${originChainAddress}`,
54
+ response: { chain: originChainNamespace, address: originChainAddress },
55
+ level: 'INFO',
56
+ }),
57
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_102_01]: () => ({
58
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_102_01,
23
59
  title: 'Estimating Gas',
24
60
  message: 'Estimating and fetching gas limit, gas price for TX',
25
- response: null,
61
+ response: { stage: 'estimating-gas' },
26
62
  level: 'INFO',
27
63
  }),
28
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_02]: (executionCost) => ({
29
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_02_02,
64
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_102_02]: (executionCost) => ({
65
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_102_02,
30
66
  title: 'Gas Estimated',
31
- message: `Total execution cost (Gas cost + value): ${executionCost} UPC`,
32
- response: null,
67
+ message: `Total execution cost: ${executionCost} UPC`,
68
+ response: { totalCost: executionCost, currency: 'UPC' },
33
69
  level: 'SUCCESS',
34
70
  }),
35
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_01]: () => ({
36
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_01,
37
- title: 'Resolving UEA',
38
- message: 'Resolving Executor Account (UEA) – computing address, checking deployment status and balance',
39
- response: null,
71
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_01]: () => ({
72
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_01,
73
+ title: 'Resolving Universal Execution Account',
74
+ message: 'Resolving UEA – computing address, checking deployment and balance',
75
+ response: { stage: 'resolving-uea' },
40
76
  level: 'INFO',
41
77
  }),
42
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_02]: (ueaAddress, deployed) => ({
43
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_02,
44
- title: 'UEA Resolved',
78
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_02]: (ueaAddress, deployed) => ({
79
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_02,
80
+ title: 'Universal Execution Account Resolved',
45
81
  message: `UEA: ${ueaAddress}, Deployed: ${deployed}`,
46
- response: null,
82
+ response: { uea: ueaAddress, deployed },
47
83
  level: 'SUCCESS',
48
84
  }),
49
- // Payload flow (04-x)
50
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_01]: () => ({
51
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_01,
85
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_01]: () => ({
86
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_01,
52
87
  title: 'Awaiting Transaction',
53
88
  message: 'Awaiting user transaction on origin chain',
54
- response: null,
89
+ response: { stage: 'awaiting-transaction' },
55
90
  level: 'INFO',
56
91
  }),
57
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_02]: () => ({
58
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_02,
92
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_02]: () => ({
93
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_02,
59
94
  title: 'Awaiting Signature',
60
95
  message: 'Awaiting user signature for universal payload',
61
- response: null,
96
+ response: { stage: 'awaiting-signature' },
62
97
  level: 'INFO',
63
98
  }),
64
- // V2 Payload flow
65
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_03]: () => ({
66
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_03,
99
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_03]: () => ({
100
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_03,
67
101
  title: 'Verification Success',
68
102
  message: 'Verification completed via Transaction or Signature',
69
- response: null,
103
+ response: { stage: 'verified' },
70
104
  level: 'SUCCESS',
71
105
  }),
72
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_04]: () => ({
73
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_04,
74
- title: 'Verification Declined',
75
- message: 'Verification declined by user',
76
- response: null,
77
- level: 'ERROR',
78
- }),
79
- // Gas flow (05-x)
80
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_01]: (originChainTxHash, originChainTx) => ({
81
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_01,
106
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_04]: (errorMessage) => {
107
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
108
+ const response = {
109
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
110
+ isUserDecline,
111
+ };
112
+ return {
113
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_04,
114
+ title,
115
+ message,
116
+ response,
117
+ level: 'ERROR',
118
+ };
119
+ },
120
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_01]: (originChainTxHash, originChainTx) => ({
121
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_01,
82
122
  title: 'Gas Funding In Progress',
83
123
  message: `Gas funding tx sent: ${originChainTxHash}`,
84
- // Attach the full origin-chain transaction object when provided
85
- response: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null,
124
+ response: { txHash: originChainTxHash, originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null },
86
125
  level: 'INFO',
87
126
  }),
88
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_02]: () => ({
89
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_02,
127
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02]: (txHash) => ({
128
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02,
90
129
  title: 'Gas Funding Confirmed',
91
130
  message: 'Gas funding confirmed on origin chain',
92
- response: null,
131
+ response: { stage: 'gas-funded', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
93
132
  level: 'SUCCESS',
94
133
  }),
95
- // V2 Funds flow (06-x)
96
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_01]: (amount, decimals, symbol) => ({
97
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_01,
134
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_01]: (amount, decimals, symbol) => ({
135
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_01,
98
136
  title: 'Preparing Funds Transfer',
99
137
  message: `Preparing to move ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol} from origin chain`,
100
- response: null,
138
+ response: { amount, symbol },
101
139
  level: 'INFO',
102
140
  }),
103
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_02]: (txHash, amount, decimals, symbol, originChainTx) => ({
104
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_02,
141
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_02]: (txHash, amount, decimals, symbol, originChainTx) => ({
142
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_02,
105
143
  title: 'Funds Lock Submitted',
106
- message: `Locking ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol} for transfer (Tx hash: ${txHash})`,
107
- // Attach the full origin-chain transaction object when available
108
- response: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null,
144
+ message: `Locking ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol} — Tx: ${txHash}`,
145
+ response: {
146
+ txHash,
147
+ amount,
148
+ symbol,
149
+ originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null,
150
+ },
109
151
  level: 'INFO',
110
152
  }),
111
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03]: (required) => ({
112
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03,
153
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03]: (required) => ({
154
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03,
113
155
  title: 'Awaiting Confirmations',
114
156
  message: `Waiting for ${required} confirmations`,
115
- response: null,
157
+ response: { current: 0, required },
116
158
  level: 'INFO',
117
159
  }),
118
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03_01]: (current, required) => ({
119
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03_01,
120
- title: `Confirmation ${current}/${required} received`,
160
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01]: (current, required) => ({
161
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01,
162
+ title: `Confirmation ${current}/${required} Received`,
121
163
  message: `${current}/${required} confirmations received`,
122
- response: null,
164
+ response: { current, required },
123
165
  level: 'INFO',
124
166
  }),
125
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03_02]: (current, required) => ({
126
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03_02,
127
- title: `Confirmation ${current}/${required} received`,
167
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02]: (current, required) => ({
168
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02,
169
+ title: `Confirmation ${current}/${required} Received`,
128
170
  message: `${current}/${required} confirmations received`,
129
- response: null,
171
+ response: { current, required },
130
172
  level: 'SUCCESS',
131
173
  }),
132
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_04]: () => ({
133
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_04,
174
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04]: (txHash) => ({
175
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04,
134
176
  title: 'Funds Confirmed',
135
177
  message: 'Origin chain lock confirmed',
136
- response: null,
178
+ response: { stage: 'funds-confirmed', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
137
179
  level: 'SUCCESS',
138
180
  }),
139
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_05]: () => ({
140
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_05,
141
- title: 'Syncing State with Push Chain',
181
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_05]: () => ({
182
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_05,
183
+ title: 'Syncing with Push Chain',
142
184
  message: 'Waiting for transaction to appear on Push Chain',
143
- response: null,
185
+ response: { stage: 'syncing-push-chain' },
144
186
  level: 'INFO',
145
187
  }),
146
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_06]: (amount, decimals, symbol) => ({
147
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_06,
188
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_06]: (amount, decimals, symbol) => ({
189
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_06,
148
190
  title: 'Funds Credited on Push Chain',
149
191
  message: `Funds credited: ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol}`,
150
- response: null,
192
+ response: { amount, symbol },
151
193
  level: 'SUCCESS',
152
194
  }),
153
- // Execution flow (07-x)
154
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_07]: () => ({
155
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_07,
156
- title: 'Broadcasting to Push Chain',
157
- message: 'Sending Tx to Push Chain...',
158
- response: null,
195
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_01]: (originChain, pushGasUsd, paddedDepositUsd) => ({
196
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_01,
197
+ title: `${friendlyChain(originChain)} Push Gas Sizing: Case A`,
198
+ message: `Push-chain gas < $1; padding deposit to $1 floor (pushGasUsd=${pushGasUsd}, paddedDepositUsd=${paddedDepositUsd})`,
199
+ response: { category: 'A', pushGasUsd, paddedDepositUsd, chain: originChain },
159
200
  level: 'INFO',
160
201
  }),
161
- // External chain polling (08-x) — emitted from .wait() / cascade.waitForAll()
162
- // after Push Chain tx success, while the SDK polls the relay for the
163
- // external chain tx hash on outbound routes.
164
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_08_01]: (destinationChain) => ({
165
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_08_01,
166
- title: 'Awaiting External Chain',
167
- message: destinationChain
168
- ? `Waiting for relay to dispatch to ${destinationChain}...`
169
- : 'Waiting for relay to dispatch to external chain...',
170
- response: null,
202
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_02]: (originChain, pushGasUsd, paddedDepositUsd) => ({
203
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_02,
204
+ title: `${friendlyChain(originChain)} Push Gas Sizing: Case B`,
205
+ message: `Push-chain gas within $1–$10; happy path (pushGasUsd=${pushGasUsd}, paddedDepositUsd=${paddedDepositUsd})`,
206
+ response: { category: 'B', pushGasUsd, paddedDepositUsd, chain: originChain },
171
207
  level: 'INFO',
172
208
  }),
173
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_08_02]: (elapsedMs) => ({
174
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_08_02,
175
- title: 'Polling External Chain',
176
- message: `Polling relay for external transaction hash (elapsed: ${Math.round(elapsedMs / 1000)}s)`,
177
- response: null,
209
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_03]: (originChain, pushGasUsd, paddedDepositUsd) => ({
210
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_07_03,
211
+ title: `${friendlyChain(originChain)} Push Gas Sizing: Case C`,
212
+ message: `Push-chain gas > $10; deposit passes through to origin gateway MAX_CAP_UNIVERSAL_TX_USD (pushGasUsd=${pushGasUsd}, paddedDepositUsd=${paddedDepositUsd})`,
213
+ response: { category: 'C', pushGasUsd, paddedDepositUsd, chain: originChain },
178
214
  level: 'INFO',
179
215
  }),
180
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_01]: (txResponse) => ({
181
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_01,
182
- title: 'Push Chain Tx Success',
183
- message: 'Tx executed successfully on Push Chain',
184
- response: txResponse,
185
- level: 'SUCCESS',
216
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_107]: () => ({
217
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_107,
218
+ title: 'Broadcasting to Push Chain',
219
+ message: 'Sending tx to Push Chain...',
220
+ response: { stage: 'broadcasting', destination: 'push-chain' },
221
+ level: 'INFO',
186
222
  }),
187
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_02]: (errMessage) => ({
188
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_02,
223
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01]: (txResponse, receipt) => {
224
+ var _a;
225
+ const first = Array.isArray(txResponse) ? txResponse[0] : undefined;
226
+ const txHash = (_a = first === null || first === void 0 ? void 0 : first.hash) !== null && _a !== void 0 ? _a : '';
227
+ return {
228
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01,
229
+ title: 'Push Chain Tx Success',
230
+ message: `Tx confirmed: ${txHash}`,
231
+ response: { txHash, response: txResponse, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
232
+ level: 'SUCCESS',
233
+ };
234
+ },
235
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_02]: (errMessage) => ({
236
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_02,
189
237
  title: 'Push Chain Tx Failed',
190
238
  message: errMessage,
191
- response: null,
239
+ response: { error: errMessage },
192
240
  level: 'ERROR',
193
241
  }),
194
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_03]: (details) => ({
195
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_03,
196
- title: 'External Chain Tx Confirmed',
197
- message: `External tx confirmed on ${details.destinationChain}: ${details.externalTxHash}`,
198
- response: details,
242
+ };
243
+ // =============================================================================
244
+ // Route 2 — UEA → UGPC → CEA on target chain (201–299, signature-only)
245
+ // =============================================================================
246
+ const RAW_HOOKS_R2 = {
247
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_201]: (targetChain, targetAddress) => ({
248
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_201,
249
+ title: `${friendlyChain(targetChain)} Detected`,
250
+ message: `External chain: ${targetChain} — Target address: ${targetAddress}`,
251
+ response: { chain: targetChain, address: targetAddress },
252
+ level: 'INFO',
253
+ }),
254
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_01]: (targetChain) => ({
255
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_01,
256
+ title: `Estimating ${friendlyChain(targetChain)} Chain Gas`,
257
+ message: 'Querying Push Chain gas and UGPC relay fee',
258
+ response: { stage: 'estimating-gas', chain: targetChain },
259
+ level: 'INFO',
260
+ }),
261
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_02]: (targetChain, pushGas, relayFee) => ({
262
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_02,
263
+ title: `${friendlyChain(targetChain)} Chain Gas Estimated`,
264
+ message: `Push gas: ${pushGas} UPC + UGPC relay: ${relayFee} UPC = ${pushGas + relayFee} UPC`,
265
+ response: {
266
+ gasEstimate: pushGas,
267
+ relayFee,
268
+ totalCost: pushGas + relayFee,
269
+ currency: 'UPC',
270
+ },
199
271
  level: 'SUCCESS',
200
272
  }),
201
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_04]: (elapsedMs) => ({
202
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_04,
203
- title: 'External Chain Tx Timeout',
204
- message: `Timed out waiting for external chain tx after ${Math.round(elapsedMs / 1000)}s. Push Chain tx succeeded; the relay may still be processing.`,
205
- response: null,
206
- level: 'WARNING',
273
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_01]: (targetChain) => ({
274
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_01,
275
+ title: `Resolving ${friendlyChain(targetChain)} Execution Account`,
276
+ message: `Resolving UEA on Push Chain and CEA on ${targetChain}`,
277
+ response: { stage: 'resolving-cea', chain: targetChain },
278
+ level: 'INFO',
279
+ }),
280
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_02]: (ueaAddr, ceaAddr, targetChain, deployed) => ({
281
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_02,
282
+ title: `${friendlyChain(targetChain)} Execution Account Ready`,
283
+ message: `UEA: ${ueaAddr}. CEA: ${ceaAddr} on ${targetChain}. Deployed: ${deployed}`,
284
+ response: { uea: ueaAddr, cea: ceaAddr, chain: targetChain, deployed },
285
+ level: 'SUCCESS',
286
+ }),
287
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_01]: () => ({
288
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_01,
289
+ title: 'Awaiting Signature',
290
+ message: 'Awaiting user signature for universal payload',
291
+ response: { stage: 'awaiting-signature' },
292
+ level: 'INFO',
293
+ }),
294
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_02]: () => ({
295
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_02,
296
+ title: 'Signature Received',
297
+ message: 'Universal payload signed — preparing broadcast',
298
+ response: { stage: 'signed' },
299
+ level: 'SUCCESS',
207
300
  }),
208
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_05]: (errorMessage) => ({
209
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_05,
210
- title: 'External Chain Tx Failed',
301
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_03]: () => ({
302
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_03,
303
+ title: 'Verification Success',
304
+ message: 'Verification completed',
305
+ response: { stage: 'verified' },
306
+ level: 'SUCCESS',
307
+ }),
308
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_04]: (errorMessage) => {
309
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
310
+ const response = {
311
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
312
+ isUserDecline,
313
+ };
314
+ return {
315
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_04,
316
+ title,
317
+ message,
318
+ response,
319
+ level: 'ERROR',
320
+ };
321
+ },
322
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_207]: (targetChain) => ({
323
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_207,
324
+ title: `Broadcasting from Push Chain → ${friendlyChain(targetChain)}`,
325
+ message: 'Sending tx to Push Chain...',
326
+ response: { chain: targetChain },
327
+ level: 'INFO',
328
+ }),
329
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01]: (targetChain) => ({
330
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01,
331
+ title: 'Awaiting Push Chain Relay',
332
+ message: `Waiting for UGPC to relay execution to ${targetChain}`,
333
+ response: { chain: targetChain },
334
+ level: 'INFO',
335
+ }),
336
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02]: (targetChain, elapsedMs) => ({
337
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02,
338
+ title: `Syncing State with ${friendlyChain(targetChain)}`,
339
+ message: `Polling ${targetChain} for CEA execution`,
340
+ response: { chain: targetChain, elapsedMs },
341
+ level: 'INFO',
342
+ }),
343
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01]: (details) => ({
344
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01,
345
+ title: `${friendlyChain(details.destinationChain)} Tx Success`,
346
+ message: `CEA executed on ${details.destinationChain} - tx: ${details.externalTxHash}`,
347
+ response: Object.assign({ txHash: details.externalTxHash }, details),
348
+ level: 'SUCCESS',
349
+ }),
350
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02]: (targetChain, errorMessage) => ({
351
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02,
352
+ title: `${friendlyChain(targetChain)} Tx Failed`,
211
353
  message: errorMessage,
212
- response: null,
354
+ response: { error: errorMessage, chain: targetChain },
355
+ level: 'ERROR',
356
+ }),
357
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03]: (targetChain, elapsedMs) => ({
358
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03,
359
+ title: `Syncing State with ${friendlyChain(targetChain)} Timeout`,
360
+ message: `Timed out waiting for UGPC relay to ${targetChain}`,
361
+ response: { error: 'relay timeout', chain: targetChain, elapsedMs },
362
+ level: 'ERROR',
363
+ }),
364
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99]: (targetChain, txHash) => ({
365
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99,
366
+ title: `${friendlyChain(targetChain)} Tx Completed`,
367
+ message: `Intermediate ${friendlyChain(targetChain)} tx confirmed: ${txHash}, progressing to next phase`,
368
+ response: { chain: targetChain, txHash },
369
+ level: 'INFO',
370
+ }),
371
+ };
372
+ // =============================================================================
373
+ // Route 3 — UEA → UGPC → CEA → sendUniversalTxToUEA → Push Chain (301–399)
374
+ // =============================================================================
375
+ const RAW_HOOKS_R3 = {
376
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99]: (txHash) => ({
377
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99,
378
+ title: 'Push Chain TX Completed',
379
+ message: `Intermediate Push Chain tx confirmed: ${txHash}, progressing to next phase`,
380
+ response: { txHash },
381
+ level: 'INFO',
382
+ }),
383
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301]: (sourceChain, ceaAddress) => ({
384
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301,
385
+ title: `${friendlyChain(sourceChain)}'s Executor Account Detected`,
386
+ message: `Source chain: ${sourceChain} — CEA: ${ceaAddress}`,
387
+ response: { chain: sourceChain, address: ceaAddress },
388
+ level: 'INFO',
389
+ }),
390
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_01]: (sourceChain) => ({
391
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_01,
392
+ title: `Estimating ${friendlyChain(sourceChain)} Gas`,
393
+ message: 'Querying Push Chain gas and UGPC relay fee',
394
+ response: { stage: 'estimating-gas', chain: sourceChain },
395
+ level: 'INFO',
396
+ }),
397
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_02]: (sourceChain, pushGas, relayFee) => ({
398
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_02,
399
+ title: `${friendlyChain(sourceChain)} Gas Estimated`,
400
+ message: `Push gas: ${pushGas} UPC + UGPC relay: ${relayFee} UPC = ${pushGas + relayFee} UPC`,
401
+ response: {
402
+ gasEstimate: pushGas,
403
+ relayFee,
404
+ totalCost: pushGas + relayFee,
405
+ currency: 'UPC',
406
+ },
407
+ level: 'SUCCESS',
408
+ }),
409
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_01]: (sourceChain, gasUsd, gasLegNativePc) => ({
410
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_01,
411
+ title: `${friendlyChain(sourceChain)} Gas Sizing: Case A`,
412
+ message: `Gas cost < $1; padding to $1 minimum (gasUsd=${gasUsd}, gasLeg=${gasLegNativePc} UPC)`,
413
+ response: { category: 'A', gasUsd, gasLegNativePc, chain: sourceChain },
414
+ level: 'INFO',
415
+ }),
416
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_02]: (sourceChain, gasUsd, gasLegNativePc) => ({
417
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_02,
418
+ title: `${friendlyChain(sourceChain)} Gas Sizing: Case B`,
419
+ message: `Gas cost within $1–$10 window; happy path (gasUsd=${gasUsd}, gasLeg=${gasLegNativePc} UPC)`,
420
+ response: { category: 'B', gasUsd, gasLegNativePc, chain: sourceChain },
421
+ level: 'INFO',
422
+ }),
423
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_03]: (sourceChain, gasUsd, gasLegNativePc, overflowNativePc) => ({
424
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_03_03,
425
+ title: `${friendlyChain(sourceChain)} Gas Sizing: Case C`,
426
+ message: `Gas cost > $10; splitting into $10 gas leg + ${overflowNativePc} UPC overflow bridged as funds`,
427
+ response: {
428
+ category: 'C',
429
+ gasUsd,
430
+ gasLegNativePc,
431
+ overflowNativePc,
432
+ chain: sourceChain,
433
+ },
434
+ level: 'INFO',
435
+ }),
436
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_01]: (sourceChain) => ({
437
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_01,
438
+ title: 'Resolving Execution Accounts on Chains',
439
+ message: `Resolving UEA on Push Chain and CEA on ${sourceChain}`,
440
+ response: { stage: 'resolving-cea-uea', chain: sourceChain },
441
+ level: 'INFO',
442
+ }),
443
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_02]: (ueaAddr, ceaAddr, sourceChain) => ({
444
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_02,
445
+ title: 'Execution Accounts Resolved',
446
+ message: `UEA: ${ueaAddr}. CEA: ${ceaAddr} on ${sourceChain}. Deployed: true`,
447
+ response: { uea: ueaAddr, cea: ceaAddr, chain: sourceChain, deployed: true },
448
+ level: 'SUCCESS',
449
+ }),
450
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01]: () => ({
451
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01,
452
+ title: 'Awaiting Signature',
453
+ message: 'Awaiting user signature for universal payload',
454
+ response: { stage: 'awaiting-signature' },
455
+ level: 'INFO',
456
+ }),
457
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_02]: () => ({
458
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_02,
459
+ title: 'Signature Received',
460
+ message: 'Universal payload signed — preparing broadcast',
461
+ response: { stage: 'signed' },
462
+ level: 'SUCCESS',
463
+ }),
464
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_03]: () => ({
465
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_03,
466
+ title: 'Verification Success',
467
+ message: 'Verification completed',
468
+ response: { stage: 'verified' },
469
+ level: 'SUCCESS',
470
+ }),
471
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_04]: (errorMessage) => {
472
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
473
+ const response = {
474
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
475
+ isUserDecline,
476
+ };
477
+ return {
478
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_04,
479
+ title,
480
+ message,
481
+ response,
482
+ level: 'ERROR',
483
+ };
484
+ },
485
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_307]: (sourceChain) => ({
486
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_307,
487
+ title: `Broadcasting from Push Chain → ${friendlyChain(sourceChain)}`,
488
+ message: 'Sending tx from Push Chain...',
489
+ response: { chain: sourceChain },
490
+ level: 'INFO',
491
+ }),
492
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01]: (sourceChain) => ({
493
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01,
494
+ title: `Awaiting ${friendlyChain(sourceChain)} Relay`,
495
+ message: `Waiting for UGPC to relay to CEA on ${sourceChain}`,
496
+ response: { chain: sourceChain },
497
+ level: 'INFO',
498
+ }),
499
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02]: (sourceChain, elapsedMs) => ({
500
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02,
501
+ title: `Syncing State with ${friendlyChain(sourceChain)}`,
502
+ message: `Polling ${sourceChain} for CEA execution`,
503
+ response: { chain: sourceChain, elapsedMs },
504
+ level: 'INFO',
505
+ }),
506
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_03]: (sourceChain, txHash) => ({
507
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_03,
508
+ title: `${friendlyChain(sourceChain)} Tx Confirmed`,
509
+ message: `CEA executed on ${sourceChain}: ${txHash} — return inbound initiated`,
510
+ response: { chain: sourceChain, txHash },
511
+ level: 'INFO',
512
+ }),
513
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01]: (sourceChain) => ({
514
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01,
515
+ title: `${friendlyChain(sourceChain)} → Push Chain Inbound Tx Submitted`,
516
+ message: `CEA initiated return — waiting for Push Chain inbound from ${sourceChain}`,
517
+ response: { chain: sourceChain },
518
+ level: 'INFO',
519
+ }),
520
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02]: (sourceChain, elapsedMs) => ({
521
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02,
522
+ title: 'Syncing State with Push Chain for Inbound Tx',
523
+ message: `Polling Push Chain for inbound from ${sourceChain}`,
524
+ response: { chain: sourceChain, elapsedMs },
525
+ level: 'INFO',
526
+ }),
527
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01]: (sourceChain, txHash, receipt) => ({
528
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01,
529
+ title: 'Push Chain Inbound Tx Success',
530
+ message: `Inbound from ${sourceChain} confirmed · Push tx: ${txHash}`,
531
+ response: { chain: sourceChain, txHash, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
532
+ level: 'SUCCESS',
533
+ }),
534
+ // 399-02 / 399-03 are multi-use terminal hooks for R3:
535
+ // • 'inbound' (default) — round-trip Push tx failed/timed out (target: Push)
536
+ // • 'outbound' — source-chain CEA tx failed/timed out (target: source chain)
537
+ // • 'push' — Push Chain execution itself failed (gateway tx revert / pre-wait)
538
+ // Phase is passed by the emission site so the title matches the leg that
539
+ // actually failed. Default stays 'inbound' for callers that don't specify
540
+ // (backwards-compat with fixtures + response-builder's inbound block).
541
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02]: (errorMessage, phase = 'inbound', chain) => ({
542
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02,
543
+ title: phase === 'outbound'
544
+ ? `${friendlyChain(chain)} Tx Failed`
545
+ : phase === 'push'
546
+ ? 'Push Chain Tx Failed'
547
+ : 'Push Chain Inbound Tx Failed',
548
+ message: errorMessage,
549
+ response: { error: errorMessage, phase, chain: chain !== null && chain !== void 0 ? chain : null },
550
+ level: 'ERROR',
551
+ }),
552
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03]: (sourceChain, elapsedMs, phase = 'inbound') => ({
553
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03,
554
+ title: phase === 'outbound'
555
+ ? `Syncing State with ${friendlyChain(sourceChain)} Timeout`
556
+ : phase === 'push'
557
+ ? 'Push Chain Tx Timeout'
558
+ : 'Push Chain Inbound Timeout',
559
+ message: phase === 'outbound'
560
+ ? `Timed out waiting for ${friendlyChain(sourceChain)} relay`
561
+ : phase === 'push'
562
+ ? `Timed out waiting for Push Chain tx`
563
+ : `Timed out waiting for inbound from ${sourceChain}`,
564
+ response: {
565
+ error: phase === 'outbound'
566
+ ? 'outbound timeout'
567
+ : phase === 'push'
568
+ ? 'push timeout'
569
+ : 'inbound timeout',
570
+ phase,
571
+ chain: sourceChain,
572
+ elapsedMs,
573
+ },
213
574
  level: 'ERROR',
214
575
  }),
215
- // UEA Migration hooks
576
+ };
577
+ // =============================================================================
578
+ // UEA Migration hooks (unchanged)
579
+ // =============================================================================
580
+ const RAW_HOOKS_MIG = {
216
581
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01]: () => ({
217
582
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01,
218
583
  title: 'Checking UEA',
@@ -238,14 +603,14 @@ const RAW_HOOKS = {
238
603
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9901,
239
604
  title: 'UEA Migration Successful',
240
605
  message: `UEA migration is successful. UEA is now version ${newVersion}.`,
241
- response: null,
606
+ response: { version: newVersion },
242
607
  level: 'SUCCESS',
243
608
  }),
244
609
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902]: () => ({
245
610
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902,
246
611
  title: 'UEA Migration Failed',
247
612
  message: 'UEA migration failed. Check transaction on explorer.',
248
- response: null,
613
+ response: { error: 'UEA migration failed' },
249
614
  level: 'ERROR',
250
615
  }),
251
616
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9903]: () => ({
@@ -256,6 +621,55 @@ const RAW_HOOKS = {
256
621
  level: 'INFO',
257
622
  }),
258
623
  };
624
+ // =============================================================================
625
+ // Multichain (multi-hop) cascade markers (001 / 002 / 999)
626
+ // =============================================================================
627
+ const RAW_HOOKS_MULTICHAIN = {
628
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_001]: (hopCount, chains) => ({
629
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_001,
630
+ title: 'Multichain Transactions Initiated',
631
+ message: `${hopCount}-hop transaction — ${chains.map(friendlyChain).join(' → ')}`,
632
+ response: { hopCount, chains },
633
+ level: 'INFO',
634
+ }),
635
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_01]: (n, total, fromChain, toChain) => ({
636
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_01,
637
+ title: `Starting Intermediate Transaction #${n}/${total}`,
638
+ message: `Starting tx ${n} of ${total}: ${friendlyChain(fromChain)} → ${friendlyChain(toChain)}`,
639
+ response: { n, total, fromChain, toChain },
640
+ level: 'INFO',
641
+ }),
642
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99]: (n, total) => ({
643
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99,
644
+ title: `Intermediate Transaction #${n}/${total} Complete`,
645
+ message: `Tx ${n} of ${total} confirmed — proceeding to tx ${n + 1}`,
646
+ response: { n, total },
647
+ level: 'INFO',
648
+ }),
649
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01]: (hopCount) => ({
650
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01,
651
+ title: 'All Multichain Transactions Successful',
652
+ message: `${hopCount}-hop transaction confirmed across all chains`,
653
+ response: { hopCount },
654
+ level: 'SUCCESS',
655
+ }),
656
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02]: (failedAt, total, errorMessage) => ({
657
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02,
658
+ title: 'Multichain Transactions Failed',
659
+ message: `Cascade failed at hop ${failedAt} of ${total}: ${errorMessage}`,
660
+ response: { failedAt, total, error: errorMessage },
661
+ level: 'ERROR',
662
+ }),
663
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03]: (failedAt, total) => ({
664
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03,
665
+ title: 'Multichain Transactions Timeout',
666
+ message: `Cascade timed out at hop ${failedAt} of ${total}`,
667
+ response: { failedAt, total, error: 'cascade timeout' },
668
+ level: 'ERROR',
669
+ }),
670
+ };
671
+ // Combine all routes into the master record
672
+ const RAW_HOOKS = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, RAW_HOOKS_R1), RAW_HOOKS_R2), RAW_HOOKS_R3), RAW_HOOKS_MULTICHAIN), RAW_HOOKS_MIG);
259
673
  // Build final hooks with timestamp injection
260
674
  const PROGRESS_HOOKS = Object.fromEntries(Object.entries(RAW_HOOKS).map(([key, value]) => [key, withTimestamp(value)]));
261
675
  exports.default = PROGRESS_HOOKS;