@pushchain/core 5.1.5-alpha.1 → 5.1.6

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 +21 -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 +58 -0
  19. package/src/lib/orchestrator/internals/execute-funds-only.js +47 -21
  20. package/src/lib/orchestrator/internals/execute-funds-payload.js +70 -37
  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 +552 -133
  57. package/src/lib/progress-hook/progress-hook.types.d.ts +77 -29
  58. package/src/lib/progress-hook/progress-hook.types.js +75 -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,581 @@ 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,
30
- title: 'Gas Estimated',
31
- message: `Total execution cost (Gas cost + value): ${executionCost} UPC`,
32
- response: null,
64
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_01]: () => ({
65
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_01,
66
+ title: 'Resolving Universal Execution Account',
67
+ message: 'Resolving UEA – computing address, checking deployment and balance',
68
+ response: { stage: 'resolving-uea' },
69
+ level: 'INFO',
70
+ }),
71
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_02]: (ueaAddress, deployed) => ({
72
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_02,
73
+ title: 'Universal Execution Account Resolved',
74
+ message: `UEA: ${ueaAddress}, Deployed: ${deployed}`,
75
+ response: { uea: ueaAddress, deployed },
33
76
  level: 'SUCCESS',
34
77
  }),
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,
78
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03]: (originChain, requiredDepositUsd) => ({
79
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03,
80
+ title: 'Calculating Prepaid Deposit',
81
+ message: `Computing required Push-chain deposit based on UEA balance and gas needs`,
82
+ response: {
83
+ stage: 'calculating-prepaid-deposit',
84
+ chain: originChain,
85
+ requiredDepositUsd,
86
+ },
40
87
  level: 'INFO',
41
88
  }),
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',
45
- message: `UEA: ${ueaAddress}, Deployed: ${deployed}`,
46
- response: null,
89
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_01]: (originChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
90
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_01,
91
+ title: 'Adjusting Prepaid Deposit to be >$1',
92
+ message: `Required deposit below $1 minimum — padding to $1 floor (gasRequired=${gasRequired} UPC, extraDepositPC=${extraDepositPC} UPC, totalDepositUSD=$${totalDepositUSD})`,
93
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: originChain },
94
+ level: 'INFO',
95
+ }),
96
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_02]: (originChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
97
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_02,
98
+ title: 'Prepaid Deposit in range (>=$1 and <$10)',
99
+ message: `Required deposit $${totalDepositUSD} within $1–$10 range — depositing as required`,
100
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: originChain },
101
+ level: 'INFO',
102
+ }),
103
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_03]: (originChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
104
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_03,
105
+ title: 'Prepaid Deposit Exceeds $10 Cap, splitting Gas and Funds',
106
+ message: `Required deposit exceeds $10 cap — splitting: $10 gas leg + ${extraDepositPC} UPC overflow bridged as funds`,
107
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: originChain },
108
+ level: 'INFO',
109
+ }),
110
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_04]: (totalPCDeposit, totalDepositUSD, originChain) => ({
111
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_04,
112
+ title: 'Prepaid Deposit Estimated',
113
+ message: `Estimated prepaid deposit: $${totalDepositUSD} (${totalPCDeposit} UPC)`,
114
+ response: { totalPCDeposit, totalDepositUSD, chain: originChain !== null && originChain !== void 0 ? originChain : null },
47
115
  level: 'SUCCESS',
48
116
  }),
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,
117
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_01]: () => ({
118
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_01,
52
119
  title: 'Awaiting Transaction',
53
120
  message: 'Awaiting user transaction on origin chain',
54
- response: null,
121
+ response: { stage: 'awaiting-transaction' },
55
122
  level: 'INFO',
56
123
  }),
57
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_02]: () => ({
58
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_04_02,
124
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_02]: () => ({
125
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_02,
59
126
  title: 'Awaiting Signature',
60
127
  message: 'Awaiting user signature for universal payload',
61
- response: null,
128
+ response: { stage: 'awaiting-signature' },
62
129
  level: 'INFO',
63
130
  }),
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,
131
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_03]: () => ({
132
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_03,
67
133
  title: 'Verification Success',
68
134
  message: 'Verification completed via Transaction or Signature',
69
- response: null,
135
+ response: { stage: 'verified' },
70
136
  level: 'SUCCESS',
71
137
  }),
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,
138
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_04]: (errorMessage) => {
139
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
140
+ const response = {
141
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
142
+ isUserDecline,
143
+ };
144
+ return {
145
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_04,
146
+ title,
147
+ message,
148
+ response,
149
+ level: 'ERROR',
150
+ };
151
+ },
152
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_01]: (originChainTxHash, originChainTx) => ({
153
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_01,
82
154
  title: 'Gas Funding In Progress',
83
155
  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,
156
+ response: { txHash: originChainTxHash, originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null },
86
157
  level: 'INFO',
87
158
  }),
88
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_02]: () => ({
89
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_05_02,
159
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02]: (txHash) => ({
160
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02,
90
161
  title: 'Gas Funding Confirmed',
91
162
  message: 'Gas funding confirmed on origin chain',
92
- response: null,
163
+ response: { stage: 'gas-funded', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
93
164
  level: 'SUCCESS',
94
165
  }),
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,
166
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_01]: (amount, decimals, symbol) => ({
167
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_01,
98
168
  title: 'Preparing Funds Transfer',
99
169
  message: `Preparing to move ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol} from origin chain`,
100
- response: null,
170
+ response: { amount, symbol },
101
171
  level: 'INFO',
102
172
  }),
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,
173
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_02]: (txHash, amount, decimals, symbol, originChainTx) => ({
174
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_02,
105
175
  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,
176
+ message: `Locking ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol} — Tx: ${txHash}`,
177
+ response: {
178
+ txHash,
179
+ amount,
180
+ symbol,
181
+ originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null,
182
+ },
109
183
  level: 'INFO',
110
184
  }),
111
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03]: (required) => ({
112
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_03,
185
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03]: (required) => ({
186
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03,
113
187
  title: 'Awaiting Confirmations',
114
188
  message: `Waiting for ${required} confirmations`,
115
- response: null,
189
+ response: { current: 0, required },
116
190
  level: 'INFO',
117
191
  }),
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`,
192
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01]: (current, required) => ({
193
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01,
194
+ title: `Confirmation ${current}/${required} Received`,
121
195
  message: `${current}/${required} confirmations received`,
122
- response: null,
196
+ response: { current, required },
123
197
  level: 'INFO',
124
198
  }),
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`,
199
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02]: (current, required) => ({
200
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02,
201
+ title: `Confirmation ${current}/${required} Received`,
128
202
  message: `${current}/${required} confirmations received`,
129
- response: null,
203
+ response: { current, required },
130
204
  level: 'SUCCESS',
131
205
  }),
132
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_04]: () => ({
133
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_06_04,
206
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04]: (txHash) => ({
207
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04,
134
208
  title: 'Funds Confirmed',
135
209
  message: 'Origin chain lock confirmed',
136
- response: null,
210
+ response: { stage: 'funds-confirmed', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
137
211
  level: 'SUCCESS',
138
212
  }),
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',
213
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_05]: () => ({
214
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_05,
215
+ title: 'Syncing with Push Chain',
142
216
  message: 'Waiting for transaction to appear on Push Chain',
143
- response: null,
217
+ response: { stage: 'syncing-push-chain' },
144
218
  level: 'INFO',
145
219
  }),
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,
220
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_06]: (amount, decimals, symbol) => ({
221
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_06,
148
222
  title: 'Funds Credited on Push Chain',
149
223
  message: `Funds credited: ${utils_1.Utils.helpers.formatUnits(amount, decimals)} ${symbol}`,
150
- response: null,
224
+ response: { amount, symbol },
151
225
  level: 'SUCCESS',
152
226
  }),
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,
227
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_107]: () => ({
228
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_107,
156
229
  title: 'Broadcasting to Push Chain',
157
- message: 'Sending Tx to Push Chain...',
158
- response: null,
230
+ message: 'Sending tx to Push Chain...',
231
+ response: { stage: 'broadcasting', destination: 'push-chain' },
159
232
  level: 'INFO',
160
233
  }),
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,
234
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01]: (txResponse, receipt) => {
235
+ var _a;
236
+ const first = Array.isArray(txResponse) ? txResponse[0] : undefined;
237
+ const txHash = (_a = first === null || first === void 0 ? void 0 : first.hash) !== null && _a !== void 0 ? _a : '';
238
+ return {
239
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01,
240
+ title: 'Push Chain Tx Success',
241
+ message: `Tx confirmed: ${txHash}`,
242
+ response: { txHash, response: txResponse, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
243
+ level: 'SUCCESS',
244
+ };
245
+ },
246
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_02]: (errMessage) => ({
247
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_02,
248
+ title: 'Push Chain Tx Failed',
249
+ message: errMessage,
250
+ response: { error: errMessage },
251
+ level: 'ERROR',
252
+ }),
253
+ };
254
+ // =============================================================================
255
+ // Route 2 — UEA → UGPC → CEA on target chain (201–299, signature-only)
256
+ // =============================================================================
257
+ const RAW_HOOKS_R2 = {
258
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_201]: (targetChain, targetAddress) => ({
259
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_201,
260
+ title: `${friendlyChain(targetChain)} Detected`,
261
+ message: `External chain: ${targetChain} — Target address: ${targetAddress}`,
262
+ response: { chain: targetChain, address: targetAddress },
171
263
  level: 'INFO',
172
264
  }),
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,
265
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_01]: (targetChain) => ({
266
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_01,
267
+ title: `Estimating ${friendlyChain(targetChain)} Chain Gas`,
268
+ message: 'Querying Push Chain gas and UGPC relay fee',
269
+ response: { stage: 'estimating-gas', chain: targetChain },
178
270
  level: 'INFO',
179
271
  }),
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,
272
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_02]: (targetChain, pushGas, relayFee) => ({
273
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_202_02,
274
+ title: `${friendlyChain(targetChain)} Chain Gas Estimated`,
275
+ message: `Push gas: ${pushGas} UPC + UGPC relay: ${relayFee} UPC = ${pushGas + relayFee} UPC`,
276
+ response: {
277
+ gasEstimate: pushGas,
278
+ relayFee,
279
+ totalCost: pushGas + relayFee,
280
+ currency: 'UPC',
281
+ },
185
282
  level: 'SUCCESS',
186
283
  }),
187
- [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_02]: (errMessage) => ({
188
- id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_99_02,
189
- title: 'Push Chain Tx Failed',
190
- message: errMessage,
191
- response: null,
284
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_01]: (targetChain) => ({
285
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_01,
286
+ title: `Resolving ${friendlyChain(targetChain)} Execution Account`,
287
+ message: `Resolving UEA on Push Chain and CEA on ${targetChain}`,
288
+ response: { stage: 'resolving-cea', chain: targetChain },
289
+ level: 'INFO',
290
+ }),
291
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_02]: (ueaAddr, ceaAddr, targetChain, deployed) => ({
292
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_02,
293
+ title: `${friendlyChain(targetChain)} Execution Account Ready`,
294
+ message: `UEA: ${ueaAddr}. CEA: ${ceaAddr} on ${targetChain}. Deployed: ${deployed}`,
295
+ response: { uea: ueaAddr, cea: ceaAddr, chain: targetChain, deployed },
296
+ level: 'SUCCESS',
297
+ }),
298
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_01]: () => ({
299
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_01,
300
+ title: 'Awaiting Signature',
301
+ message: 'Awaiting user signature for universal payload',
302
+ response: { stage: 'awaiting-signature' },
303
+ level: 'INFO',
304
+ }),
305
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_02]: () => ({
306
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_02,
307
+ title: 'Signature Received',
308
+ message: 'Universal payload signed — preparing broadcast',
309
+ response: { stage: 'signed' },
310
+ level: 'SUCCESS',
311
+ }),
312
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_03]: () => ({
313
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_03,
314
+ title: 'Verification Success',
315
+ message: 'Verification completed',
316
+ response: { stage: 'verified' },
317
+ level: 'SUCCESS',
318
+ }),
319
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_04]: (errorMessage) => {
320
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
321
+ const response = {
322
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
323
+ isUserDecline,
324
+ };
325
+ return {
326
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_04,
327
+ title,
328
+ message,
329
+ response,
330
+ level: 'ERROR',
331
+ };
332
+ },
333
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_207]: (targetChain) => ({
334
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_207,
335
+ title: `Broadcasting from Push Chain → ${friendlyChain(targetChain)}`,
336
+ message: 'Sending tx to Push Chain...',
337
+ response: { chain: targetChain },
338
+ level: 'INFO',
339
+ }),
340
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01]: (targetChain) => ({
341
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01,
342
+ title: 'Awaiting Push Chain Relay',
343
+ message: `Waiting for UGPC to relay execution to ${targetChain}`,
344
+ response: { chain: targetChain },
345
+ level: 'INFO',
346
+ }),
347
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02]: (targetChain, elapsedMs) => ({
348
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02,
349
+ title: `Syncing State with ${friendlyChain(targetChain)}`,
350
+ message: `Polling ${targetChain} for CEA execution`,
351
+ response: { chain: targetChain, elapsedMs },
352
+ level: 'INFO',
353
+ }),
354
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01]: (details) => ({
355
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01,
356
+ title: `${friendlyChain(details.destinationChain)} Tx Success`,
357
+ message: `CEA executed on ${details.destinationChain} - tx: ${details.externalTxHash}`,
358
+ response: Object.assign({ txHash: details.externalTxHash }, details),
359
+ level: 'SUCCESS',
360
+ }),
361
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02]: (targetChain, errorMessage) => ({
362
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02,
363
+ title: `${friendlyChain(targetChain)} Tx Failed`,
364
+ message: errorMessage,
365
+ response: { error: errorMessage, chain: targetChain },
366
+ level: 'ERROR',
367
+ }),
368
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03]: (targetChain, elapsedMs) => ({
369
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03,
370
+ title: `Syncing State with ${friendlyChain(targetChain)} Timeout`,
371
+ message: `Timed out waiting for UGPC relay to ${targetChain}`,
372
+ response: { error: 'relay timeout', chain: targetChain, elapsedMs },
192
373
  level: 'ERROR',
193
374
  }),
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,
375
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99]: (targetChain, txHash) => ({
376
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99,
377
+ title: `${friendlyChain(targetChain)} Tx Completed`,
378
+ message: `Intermediate ${friendlyChain(targetChain)} tx confirmed: ${txHash}, progressing to next phase`,
379
+ response: { chain: targetChain, txHash },
380
+ level: 'INFO',
381
+ }),
382
+ };
383
+ // =============================================================================
384
+ // Route 3 — UEA → UGPC → CEA → sendUniversalTxToUEA → Push Chain (301–399)
385
+ // =============================================================================
386
+ const RAW_HOOKS_R3 = {
387
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99]: (txHash) => ({
388
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_99_99,
389
+ title: 'Push Chain Tx Completed',
390
+ message: `Intermediate Push Chain tx confirmed: ${txHash}, progressing to next phase`,
391
+ response: { txHash },
392
+ level: 'INFO',
393
+ }),
394
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301]: (sourceChain, ceaAddress) => ({
395
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_301,
396
+ title: `${friendlyChain(sourceChain)}'s Executor Account Detected`,
397
+ message: `Source chain: ${sourceChain} — CEA: ${ceaAddress}`,
398
+ response: { chain: sourceChain, address: ceaAddress },
399
+ level: 'INFO',
400
+ }),
401
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_01]: (sourceChain) => ({
402
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_01,
403
+ title: `Estimating ${friendlyChain(sourceChain)} Gas`,
404
+ message: 'Querying Push Chain gas and UGPC relay fee',
405
+ response: { stage: 'estimating-gas', chain: sourceChain },
406
+ level: 'INFO',
407
+ }),
408
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_02]: (sourceChain, pushGas, relayFee) => ({
409
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_302_02,
410
+ title: `${friendlyChain(sourceChain)} Gas Estimated`,
411
+ message: `Push gas: ${pushGas} UPC + UGPC relay: ${relayFee} UPC = ${pushGas + relayFee} UPC`,
412
+ response: {
413
+ gasEstimate: pushGas,
414
+ relayFee,
415
+ totalCost: pushGas + relayFee,
416
+ currency: 'UPC',
417
+ },
199
418
  level: 'SUCCESS',
200
419
  }),
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',
420
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_01]: (sourceChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
421
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_01,
422
+ title: 'Gas Sizing: Case A',
423
+ message: `Gas cost < $1; padding to $1 minimum (gasRequired=${gasRequired} UPC, extraDepositPC=${extraDepositPC} UPC, totalDepositUSD=$${totalDepositUSD})`,
424
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: sourceChain },
425
+ level: 'INFO',
426
+ }),
427
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_02]: (sourceChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
428
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_02,
429
+ title: 'Gas Sizing: Case B',
430
+ message: `Gas cost within $1–$10 window; happy path (gasRequired=${gasRequired} UPC, totalDepositUSD=$${totalDepositUSD})`,
431
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: sourceChain },
432
+ level: 'INFO',
433
+ }),
434
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_03]: (sourceChain, gasRequired, extraDepositPC, totalDepositUSD) => ({
435
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_03_03,
436
+ title: 'Gas Sizing: Case C',
437
+ message: `Gas cost > $10; splitting into $10 gas leg + ${extraDepositPC} UPC overflow bridged as funds`,
438
+ response: { gasRequired, extraDepositPC, totalDepositUSD, chain: sourceChain },
439
+ level: 'INFO',
440
+ }),
441
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_01]: (sourceChain) => ({
442
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_01,
443
+ title: 'Resolving Execution Accounts on Chains',
444
+ message: `Resolving UEA on Push Chain and CEA on ${sourceChain}`,
445
+ response: { stage: 'resolving-cea-uea', chain: sourceChain },
446
+ level: 'INFO',
207
447
  }),
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',
448
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_02]: (ueaAddr, ceaAddr, sourceChain) => ({
449
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_02,
450
+ title: 'Execution Accounts Resolved',
451
+ message: `UEA: ${ueaAddr}. CEA: ${ceaAddr} on ${sourceChain}. Deployed: true`,
452
+ response: { uea: ueaAddr, cea: ceaAddr, chain: sourceChain, deployed: true },
453
+ level: 'SUCCESS',
454
+ }),
455
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01]: () => ({
456
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_01,
457
+ title: 'Awaiting Signature',
458
+ message: 'Awaiting user signature for universal payload',
459
+ response: { stage: 'awaiting-signature' },
460
+ level: 'INFO',
461
+ }),
462
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_02]: () => ({
463
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_02,
464
+ title: 'Signature Received',
465
+ message: 'Universal payload signed — preparing broadcast',
466
+ response: { stage: 'signed' },
467
+ level: 'SUCCESS',
468
+ }),
469
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_03]: () => ({
470
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_03,
471
+ title: 'Verification Success',
472
+ message: 'Verification completed',
473
+ response: { stage: 'verified' },
474
+ level: 'SUCCESS',
475
+ }),
476
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_04]: (errorMessage) => {
477
+ const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
478
+ const response = {
479
+ error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
480
+ isUserDecline,
481
+ };
482
+ return {
483
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_04,
484
+ title,
485
+ message,
486
+ response,
487
+ level: 'ERROR',
488
+ };
489
+ },
490
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_307]: (sourceChain) => ({
491
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_307,
492
+ title: `Broadcasting from Push Chain → ${friendlyChain(sourceChain)}`,
493
+ message: 'Sending tx from Push Chain...',
494
+ response: { chain: sourceChain },
495
+ level: 'INFO',
496
+ }),
497
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01]: (sourceChain) => ({
498
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01,
499
+ title: `Awaiting ${friendlyChain(sourceChain)} Relay`,
500
+ message: `Waiting for UGPC to relay to CEA on ${sourceChain}`,
501
+ response: { chain: sourceChain },
502
+ level: 'INFO',
503
+ }),
504
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02]: (sourceChain, elapsedMs) => ({
505
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02,
506
+ title: `Syncing State with ${friendlyChain(sourceChain)}`,
507
+ message: `Polling ${sourceChain} for CEA execution`,
508
+ response: { chain: sourceChain, elapsedMs },
509
+ level: 'INFO',
510
+ }),
511
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_03]: (sourceChain, txHash) => ({
512
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_03,
513
+ title: `${friendlyChain(sourceChain)} Tx Confirmed`,
514
+ message: `CEA executed on ${sourceChain}: ${txHash} — return inbound initiated`,
515
+ response: { chain: sourceChain, txHash },
516
+ level: 'INFO',
517
+ }),
518
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01]: (sourceChain) => ({
519
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01,
520
+ title: `${friendlyChain(sourceChain)} → Push Chain Inbound Tx Submitted`,
521
+ message: `CEA initiated return — waiting for Push Chain inbound from ${sourceChain}`,
522
+ response: { chain: sourceChain },
523
+ level: 'INFO',
524
+ }),
525
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02]: (sourceChain, elapsedMs) => ({
526
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02,
527
+ title: 'Syncing State with Push Chain for Inbound Tx',
528
+ message: `Polling Push Chain for inbound from ${sourceChain}`,
529
+ response: { chain: sourceChain, elapsedMs },
530
+ level: 'INFO',
531
+ }),
532
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01]: (sourceChain, txHash, receipt) => ({
533
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01,
534
+ title: 'Push Chain Inbound Tx Success',
535
+ message: `Inbound from ${sourceChain} confirmed · Push tx: ${txHash}`,
536
+ response: { chain: sourceChain, txHash, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
537
+ level: 'SUCCESS',
538
+ }),
539
+ // 399-02 / 399-03 are multi-use terminal hooks for R3:
540
+ // • 'inbound' (default) — round-trip Push tx failed/timed out (target: Push)
541
+ // • 'outbound' — source-chain CEA tx failed/timed out (target: source chain)
542
+ // • 'push' — Push Chain execution itself failed (gateway tx revert / pre-wait)
543
+ // Phase is passed by the emission site so the title matches the leg that
544
+ // actually failed. Default stays 'inbound' for callers that don't specify
545
+ // (backwards-compat with fixtures + response-builder's inbound block).
546
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02]: (errorMessage, phase = 'inbound', chain) => ({
547
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02,
548
+ title: phase === 'outbound'
549
+ ? `${friendlyChain(chain)} Tx Failed`
550
+ : phase === 'push'
551
+ ? 'Push Chain Tx Failed'
552
+ : 'Push Chain Inbound Tx Failed',
211
553
  message: errorMessage,
212
- response: null,
554
+ response: { error: errorMessage, phase, chain: chain !== null && chain !== void 0 ? chain : null },
555
+ level: 'ERROR',
556
+ }),
557
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03]: (sourceChain, elapsedMs, phase = 'inbound') => ({
558
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03,
559
+ title: phase === 'outbound'
560
+ ? `Syncing State with ${friendlyChain(sourceChain)} Timeout`
561
+ : phase === 'push'
562
+ ? 'Push Chain Tx Timeout'
563
+ : 'Push Chain Inbound Timeout',
564
+ message: phase === 'outbound'
565
+ ? `Timed out waiting for ${friendlyChain(sourceChain)} relay`
566
+ : phase === 'push'
567
+ ? `Timed out waiting for Push Chain tx`
568
+ : `Timed out waiting for inbound from ${sourceChain}`,
569
+ response: {
570
+ error: phase === 'outbound'
571
+ ? 'outbound timeout'
572
+ : phase === 'push'
573
+ ? 'push timeout'
574
+ : 'inbound timeout',
575
+ phase,
576
+ chain: sourceChain,
577
+ elapsedMs,
578
+ },
213
579
  level: 'ERROR',
214
580
  }),
215
- // UEA Migration hooks
581
+ };
582
+ // =============================================================================
583
+ // UEA Migration hooks (unchanged)
584
+ // =============================================================================
585
+ const RAW_HOOKS_MIG = {
216
586
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01]: () => ({
217
587
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01,
218
588
  title: 'Checking UEA',
@@ -238,14 +608,14 @@ const RAW_HOOKS = {
238
608
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9901,
239
609
  title: 'UEA Migration Successful',
240
610
  message: `UEA migration is successful. UEA is now version ${newVersion}.`,
241
- response: null,
611
+ response: { version: newVersion },
242
612
  level: 'SUCCESS',
243
613
  }),
244
614
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902]: () => ({
245
615
  id: progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902,
246
616
  title: 'UEA Migration Failed',
247
617
  message: 'UEA migration failed. Check transaction on explorer.',
248
- response: null,
618
+ response: { error: 'UEA migration failed' },
249
619
  level: 'ERROR',
250
620
  }),
251
621
  [progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9903]: () => ({
@@ -256,6 +626,55 @@ const RAW_HOOKS = {
256
626
  level: 'INFO',
257
627
  }),
258
628
  };
629
+ // =============================================================================
630
+ // Multichain (multi-hop) cascade markers (001 / 002 / 999)
631
+ // =============================================================================
632
+ const RAW_HOOKS_MULTICHAIN = {
633
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_001]: (hopCount, chains) => ({
634
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_001,
635
+ title: 'Multichain Transactions Initiated',
636
+ message: `${hopCount}-hop transaction — ${chains.map(friendlyChain).join(' → ')}`,
637
+ response: { hopCount, chains },
638
+ level: 'INFO',
639
+ }),
640
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_01]: (n, total, fromChain, toChain) => ({
641
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_01,
642
+ title: `Starting Intermediate Transaction #${n}/${total}`,
643
+ message: `Starting tx ${n} of ${total}: ${friendlyChain(fromChain)} → ${friendlyChain(toChain)}`,
644
+ response: { n, total, fromChain, toChain },
645
+ level: 'INFO',
646
+ }),
647
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99]: (n, total) => ({
648
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99,
649
+ title: `Intermediate Transaction #${n}/${total} Complete`,
650
+ message: `Tx ${n} of ${total} confirmed — proceeding to tx ${n + 1}`,
651
+ response: { n, total },
652
+ level: 'INFO',
653
+ }),
654
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01]: (hopCount) => ({
655
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01,
656
+ title: 'All Multichain Transactions Successful',
657
+ message: `${hopCount}-hop transaction confirmed across all chains`,
658
+ response: { hopCount },
659
+ level: 'SUCCESS',
660
+ }),
661
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02]: (failedAt, total, errorMessage) => ({
662
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02,
663
+ title: 'Multichain Transactions Failed',
664
+ message: `Cascade failed at hop ${failedAt} of ${total}: ${errorMessage}`,
665
+ response: { failedAt, total, error: errorMessage },
666
+ level: 'ERROR',
667
+ }),
668
+ [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03]: (failedAt, total) => ({
669
+ id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03,
670
+ title: 'Multichain Transactions Timeout',
671
+ message: `Cascade timed out at hop ${failedAt} of ${total}`,
672
+ response: { failedAt, total, error: 'cascade timeout' },
673
+ level: 'ERROR',
674
+ }),
675
+ };
676
+ // Combine all routes into the master record
677
+ 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
678
  // Build final hooks with timestamp injection
260
679
  const PROGRESS_HOOKS = Object.fromEntries(Object.entries(RAW_HOOKS).map(([key, value]) => [key, withTimestamp(value)]));
261
680
  exports.default = PROGRESS_HOOKS;