@pushchain/core 6.0.20 → 6.0.21

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 (111) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/package.json +1 -1
  3. package/src/lib/cache/cache.js +2 -0
  4. package/src/lib/constants/abi/index.d.ts +1 -0
  5. package/src/lib/constants/abi/index.js +8 -1
  6. package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
  7. package/src/lib/constants/abi/pc20.evm.js +150 -0
  8. package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
  9. package/src/lib/constants/abi/prc20.evm.js +97 -0
  10. package/src/lib/constants/abi/universalGatewayV0.json +1 -1
  11. package/src/lib/constants/chain.js +38 -8
  12. package/src/lib/constants/selectors.js +2 -2
  13. package/src/lib/constants/tokens.js +4 -3
  14. package/src/lib/formatters.js +16 -6
  15. package/src/lib/generated/uexecutor/v1/query.js +2 -4
  16. package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
  17. package/src/lib/generated/uexecutor/v1/types.js +90 -47
  18. package/src/lib/generated/uexecutor/v2/query.js +2 -4
  19. package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
  20. package/src/lib/generated/uexecutor/v2/types.js +49 -33
  21. package/src/lib/generated/v1/tx.js +30 -37
  22. package/src/lib/index.d.ts +3 -0
  23. package/src/lib/index.js +21 -3
  24. package/src/lib/internal/buffer.js +1 -2
  25. package/src/lib/orchestrator/cea-utils.js +73 -83
  26. package/src/lib/orchestrator/internals/account-manager.js +130 -139
  27. package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
  28. package/src/lib/orchestrator/internals/cascade.js +1184 -1059
  29. package/src/lib/orchestrator/internals/confirmation.js +138 -148
  30. package/src/lib/orchestrator/internals/error-decoder.js +1 -1
  31. package/src/lib/orchestrator/internals/errors.js +12 -3
  32. package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
  33. package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
  34. package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
  35. package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
  36. package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
  37. package/src/lib/orchestrator/internals/execute-standard.js +339 -342
  38. package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
  39. package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
  40. package/src/lib/orchestrator/internals/gateway-client.js +102 -103
  41. package/src/lib/orchestrator/internals/helpers.js +30 -27
  42. package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
  43. package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
  44. package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
  45. package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
  46. package/src/lib/orchestrator/internals/payload-builder.js +119 -100
  47. package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
  48. package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
  49. package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
  50. package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
  51. package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
  52. package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
  53. package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
  54. package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
  55. package/src/lib/orchestrator/internals/pc20/export.js +412 -0
  56. package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
  57. package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
  58. package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
  59. package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
  60. package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
  61. package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
  62. package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
  63. package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
  64. package/src/lib/orchestrator/internals/preflight.js +1 -1
  65. package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
  66. package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
  67. package/src/lib/orchestrator/internals/quote.js +90 -94
  68. package/src/lib/orchestrator/internals/rescue.js +76 -79
  69. package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
  70. package/src/lib/orchestrator/internals/response-builder.js +817 -701
  71. package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
  72. package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
  73. package/src/lib/orchestrator/internals/signing.js +78 -83
  74. package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
  75. package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
  76. package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
  77. package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
  78. package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
  79. package/src/lib/orchestrator/internals/svm-rent.js +163 -141
  80. package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
  81. package/src/lib/orchestrator/internals/uea-manager.js +89 -86
  82. package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
  83. package/src/lib/orchestrator/orchestrator.js +217 -200
  84. package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
  85. package/src/lib/orchestrator/orchestrator.types.js +19 -0
  86. package/src/lib/orchestrator/payload-builders.d.ts +2 -2
  87. package/src/lib/orchestrator/payload-builders.js +26 -24
  88. package/src/lib/orchestrator/route-detector.js +26 -9
  89. package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
  90. package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
  91. package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
  92. package/src/lib/price-fetch/price-fetch.js +67 -68
  93. package/src/lib/progress-hook/progress-hook.js +124 -72
  94. package/src/lib/push-chain/push-chain.js +171 -153
  95. package/src/lib/push-client/push-client.js +223 -237
  96. package/src/lib/universal/account/account.js +349 -365
  97. package/src/lib/universal/signer/signer.js +306 -294
  98. package/src/lib/universal-tx-detector/auto-detect.js +55 -60
  99. package/src/lib/universal-tx-detector/cascade.js +160 -172
  100. package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
  101. package/src/lib/universal-tx-detector/classify.js +2 -3
  102. package/src/lib/universal-tx-detector/detector-svm.js +139 -147
  103. package/src/lib/universal-tx-detector/detector.js +145 -157
  104. package/src/lib/universal-tx-detector/normalize.js +7 -7
  105. package/src/lib/utils/external-tx-hash.js +1 -2
  106. package/src/lib/utils.d.ts +44 -0
  107. package/src/lib/utils.js +762 -683
  108. package/src/lib/vm-client/evm-client.js +186 -202
  109. package/src/lib/vm-client/svm-client.d.ts +1 -1
  110. package/src/lib/vm-client/svm-client.js +220 -224
  111. package/src/lib/vm-client/vm-client.types.d.ts +14 -2
@@ -7,7 +7,10 @@ const progress_hook_types_1 = require("./progress-hook.types");
7
7
  // Helper to wrap a hook function with timestamp
8
8
  const withTimestamp = (fn) => {
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- return (...args) => (Object.assign(Object.assign({}, fn(...args)), { timestamp: new Date().toISOString() }));
10
+ return (...args) => ({
11
+ ...fn(...args),
12
+ timestamp: new Date().toISOString(),
13
+ });
11
14
  };
12
15
  const ACRONYMS = new Set(['BNB']);
13
16
  const toTitleCase = (key) => key
@@ -49,7 +52,7 @@ const displayPathTag = (pathTag) => pathTag === 'CASCADE' ? 'MULTICHAIN' : pathT
49
52
  * to "Signature Failed" would make the event self-contradict.
50
53
  */
51
54
  function classifyDeclineError(errorMessage) {
52
- const msg = errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user';
55
+ const msg = errorMessage ?? 'Verification declined by user';
53
56
  const isUserDecline = errorMessage === undefined ||
54
57
  /user\s*reject/i.test(msg) ||
55
58
  /user\s*denied/i.test(msg) ||
@@ -132,7 +135,7 @@ const RAW_HOOKS_R1 = {
132
135
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_103_03_04,
133
136
  title: 'Prepaid Deposit Estimated',
134
137
  message: `Estimated prepaid deposit: $${totalDepositUSD} (${totalPCDeposit} UPC)`,
135
- response: { totalPCDeposit, totalDepositUSD, chain: originChain !== null && originChain !== void 0 ? originChain : null },
138
+ response: { totalPCDeposit, totalDepositUSD, chain: originChain ?? null },
136
139
  level: 'SUCCESS',
137
140
  }),
138
141
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_01]: () => ({
@@ -159,7 +162,7 @@ const RAW_HOOKS_R1 = {
159
162
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_104_04]: (errorMessage) => {
160
163
  const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
161
164
  const response = {
162
- error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
165
+ error: errorMessage ?? 'Verification declined by user',
163
166
  isUserDecline,
164
167
  };
165
168
  return {
@@ -174,14 +177,14 @@ const RAW_HOOKS_R1 = {
174
177
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_01,
175
178
  title: 'Gas Funding In Progress',
176
179
  message: `Gas funding tx sent: ${originChainTxHash}`,
177
- response: { txHash: originChainTxHash, originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null },
180
+ response: { txHash: originChainTxHash, originChainTx: originChainTx ?? null },
178
181
  level: 'INFO',
179
182
  }),
180
183
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02]: (txHash) => ({
181
184
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_105_02,
182
185
  title: 'Gas Funding Confirmed',
183
186
  message: 'Gas funding confirmed on origin chain',
184
- response: { stage: 'gas-funded', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
187
+ response: { stage: 'gas-funded', txHash: txHash ?? null },
185
188
  level: 'SUCCESS',
186
189
  }),
187
190
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_01]: (amount, decimals, symbol) => ({
@@ -199,7 +202,7 @@ const RAW_HOOKS_R1 = {
199
202
  txHash,
200
203
  amount,
201
204
  symbol,
202
- originChainTx: originChainTx !== null && originChainTx !== void 0 ? originChainTx : null,
205
+ originChainTx: originChainTx ?? null,
203
206
  },
204
207
  level: 'INFO',
205
208
  }),
@@ -207,28 +210,28 @@ const RAW_HOOKS_R1 = {
207
210
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03,
208
211
  title: 'Awaiting Confirmations',
209
212
  message: `Waiting for ${required} confirmations`,
210
- response: Object.assign({ current: 0, required }, (txHash ? { txHash } : {})),
213
+ response: { current: 0, required, ...(txHash ? { txHash } : {}) },
211
214
  level: 'INFO',
212
215
  }),
213
216
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01]: (current, required, txHash) => ({
214
217
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01,
215
218
  title: `Confirmation ${current}/${required} Received`,
216
219
  message: `${current}/${required} confirmations received`,
217
- response: Object.assign({ current, required }, (txHash ? { txHash } : {})),
220
+ response: { current, required, ...(txHash ? { txHash } : {}) },
218
221
  level: 'INFO',
219
222
  }),
220
223
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02]: (current, required, txHash) => ({
221
224
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02,
222
225
  title: `Confirmation ${current}/${required} Received`,
223
226
  message: `${current}/${required} confirmations received`,
224
- response: Object.assign({ current, required }, (txHash ? { txHash } : {})),
227
+ response: { current, required, ...(txHash ? { txHash } : {}) },
225
228
  level: 'SUCCESS',
226
229
  }),
227
230
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04]: (txHash) => ({
228
231
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_04,
229
232
  title: 'Funds Confirmed',
230
233
  message: 'Origin chain lock confirmed',
231
- response: { stage: 'funds-confirmed', txHash: txHash !== null && txHash !== void 0 ? txHash : null },
234
+ response: { stage: 'funds-confirmed', txHash: txHash ?? null },
232
235
  level: 'SUCCESS',
233
236
  }),
234
237
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_05]: () => ({
@@ -253,14 +256,13 @@ const RAW_HOOKS_R1 = {
253
256
  level: 'INFO',
254
257
  }),
255
258
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01]: (txResponse, receipt) => {
256
- var _a;
257
259
  const first = Array.isArray(txResponse) ? txResponse[0] : undefined;
258
- const txHash = (_a = first === null || first === void 0 ? void 0 : first.hash) !== null && _a !== void 0 ? _a : '';
260
+ const txHash = first?.hash ?? '';
259
261
  return {
260
262
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_01,
261
263
  title: 'Push Chain Tx Success',
262
264
  message: `Tx confirmed: ${txHash}`,
263
- response: { txHash, response: txResponse, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
265
+ response: { txHash, response: txResponse, receipt: receipt ?? null },
264
266
  level: 'SUCCESS',
265
267
  };
266
268
  },
@@ -270,7 +272,11 @@ const RAW_HOOKS_R1 = {
270
272
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_199_02,
271
273
  title: 'Push Chain Tx Failed',
272
274
  message: normalizedErrMessage,
273
- response: Object.assign(Object.assign({ error: normalizedErrMessage }, (txHash ? { txHash } : {})), (decodedError ? { decodedError } : {})),
275
+ response: {
276
+ error: normalizedErrMessage,
277
+ ...(txHash ? { txHash } : {}),
278
+ ...(decodedError ? { decodedError } : {}),
279
+ },
274
280
  level: 'ERROR',
275
281
  };
276
282
  },
@@ -334,11 +340,10 @@ const RAW_HOOKS_R2 = {
334
340
  level: 'SUCCESS',
335
341
  }),
336
342
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
337
- var _a, _b, _c, _d;
338
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
343
+ const kind = extra?.kind ?? 'NATIVE';
339
344
  const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
340
345
  const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
341
- const enforceGasCheck = extra === null || extra === void 0 ? void 0 : extra.enforceGasCheck;
346
+ const enforceGasCheck = extra?.enforceGasCheck;
342
347
  return {
343
348
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_03,
344
349
  title: 'Checking Balance Requirements',
@@ -351,21 +356,20 @@ const RAW_HOOKS_R2 = {
351
356
  ueaAddress,
352
357
  pathTag,
353
358
  kind,
354
- burnToken: (_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : null,
355
- segmentIndex: (_c = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _c !== void 0 ? _c : null,
356
- enforceGasCheck: enforceGasCheck !== null && enforceGasCheck !== void 0 ? enforceGasCheck : null,
359
+ burnToken: extra?.burnToken ?? null,
360
+ segmentIndex: extra?.segmentIndex ?? null,
361
+ enforceGasCheck: enforceGasCheck ?? null,
357
362
  warningOnly: !sufficient && enforceGasCheck === false,
358
- shortfall: (_d = extra === null || extra === void 0 ? void 0 : extra.shortfall) !== null && _d !== void 0 ? _d : null,
363
+ shortfall: extra?.shortfall ?? null,
359
364
  },
360
365
  level: preflightLevel(sufficient),
361
366
  };
362
367
  },
363
368
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_04]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
364
- var _a, _b, _c, _d;
365
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
369
+ const kind = extra?.kind ?? 'NATIVE';
366
370
  const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
367
371
  const remediation = kind === 'PRC20'
368
- ? `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.`
372
+ ? `Bridge the burn token (${extra?.burnToken ?? 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
369
373
  : `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
370
374
  return {
371
375
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_203_04,
@@ -378,8 +382,8 @@ const RAW_HOOKS_R2 = {
378
382
  ueaAddress,
379
383
  pathTag,
380
384
  kind,
381
- burnToken: (_c = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _c !== void 0 ? _c : null,
382
- segmentIndex: (_d = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _d !== void 0 ? _d : null,
385
+ burnToken: extra?.burnToken ?? null,
386
+ segmentIndex: extra?.segmentIndex ?? null,
383
387
  },
384
388
  level: 'ERROR',
385
389
  };
@@ -417,7 +421,7 @@ const RAW_HOOKS_R2 = {
417
421
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_204_04]: (errorMessage) => {
418
422
  const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
419
423
  const response = {
420
- error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
424
+ error: errorMessage ?? 'Verification declined by user',
421
425
  isUserDecline,
422
426
  };
423
427
  return {
@@ -439,35 +443,50 @@ const RAW_HOOKS_R2 = {
439
443
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_01,
440
444
  title: 'Awaiting Push Chain Relay',
441
445
  message: `Waiting for UGPC to relay execution to ${targetChain}`,
442
- response: Object.assign({ chain: targetChain }, (pushTxHash ? { pushTxHash } : {})),
446
+ response: { chain: targetChain, ...(pushTxHash ? { pushTxHash } : {}) },
443
447
  level: 'INFO',
444
448
  }),
445
449
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02]: (targetChain, elapsedMs, pushTxHash) => ({
446
450
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_209_02,
447
451
  title: `Syncing State with ${friendlyChain(targetChain)}`,
448
452
  message: `Polling ${targetChain} for CEA execution`,
449
- response: Object.assign({ chain: targetChain, elapsedMs }, (pushTxHash ? { pushTxHash } : {})),
453
+ response: {
454
+ chain: targetChain,
455
+ elapsedMs,
456
+ ...(pushTxHash ? { pushTxHash } : {}),
457
+ },
450
458
  level: 'INFO',
451
459
  }),
452
460
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01]: (details) => ({
453
461
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_01,
454
462
  title: `${friendlyChain(details.destinationChain)} Tx Success`,
455
463
  message: `CEA executed on ${details.destinationChain} - tx: ${details.externalTxHash}`,
456
- response: Object.assign({ txHash: details.externalTxHash }, details),
464
+ response: { txHash: details.externalTxHash, ...details },
457
465
  level: 'SUCCESS',
458
466
  }),
459
467
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02]: (targetChain, errorMessage, decodedError, pushTxHash, txHash) => ({
460
468
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_02,
461
469
  title: `${friendlyChain(targetChain)} Tx Failed`,
462
470
  message: errorMessage,
463
- response: Object.assign(Object.assign(Object.assign({ error: errorMessage, chain: targetChain }, (pushTxHash ? { pushTxHash } : {})), (txHash ? { txHash } : {})), (decodedError ? { decodedError } : {})),
471
+ response: {
472
+ error: errorMessage,
473
+ chain: targetChain,
474
+ ...(pushTxHash ? { pushTxHash } : {}),
475
+ ...(txHash ? { txHash } : {}),
476
+ ...(decodedError ? { decodedError } : {}),
477
+ },
464
478
  level: 'ERROR',
465
479
  }),
466
480
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03]: (targetChain, elapsedMs, pushTxHash) => ({
467
481
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_03,
468
482
  title: `Syncing State with ${friendlyChain(targetChain)} Timeout`,
469
483
  message: `Timed out waiting for UGPC relay to ${targetChain}`,
470
- response: Object.assign({ error: 'relay timeout', chain: targetChain, elapsedMs }, (pushTxHash ? { pushTxHash } : {})),
484
+ response: {
485
+ error: 'relay timeout',
486
+ chain: targetChain,
487
+ elapsedMs,
488
+ ...(pushTxHash ? { pushTxHash } : {}),
489
+ },
471
490
  level: 'ERROR',
472
491
  }),
473
492
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_299_99]: (targetChain, txHash) => ({
@@ -545,11 +564,10 @@ const RAW_HOOKS_R3 = {
545
564
  }),
546
565
  // R3 single-route pre-flight balance check. Same payload shape as 203-03/04/05.
547
566
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
548
- var _a, _b, _c, _d;
549
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
567
+ const kind = extra?.kind ?? 'NATIVE';
550
568
  const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
551
569
  const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
552
- const enforceGasCheck = extra === null || extra === void 0 ? void 0 : extra.enforceGasCheck;
570
+ const enforceGasCheck = extra?.enforceGasCheck;
553
571
  return {
554
572
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_04,
555
573
  title: 'Checking Balance Requirements',
@@ -562,21 +580,20 @@ const RAW_HOOKS_R3 = {
562
580
  ueaAddress,
563
581
  pathTag,
564
582
  kind,
565
- burnToken: (_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : null,
566
- segmentIndex: (_c = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _c !== void 0 ? _c : null,
567
- enforceGasCheck: enforceGasCheck !== null && enforceGasCheck !== void 0 ? enforceGasCheck : null,
583
+ burnToken: extra?.burnToken ?? null,
584
+ segmentIndex: extra?.segmentIndex ?? null,
585
+ enforceGasCheck: enforceGasCheck ?? null,
568
586
  warningOnly: !sufficient && enforceGasCheck === false,
569
- shortfall: (_d = extra === null || extra === void 0 ? void 0 : extra.shortfall) !== null && _d !== void 0 ? _d : null,
587
+ shortfall: extra?.shortfall ?? null,
570
588
  },
571
589
  level: preflightLevel(sufficient),
572
590
  };
573
591
  },
574
592
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
575
- var _a, _b, _c, _d;
576
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
593
+ const kind = extra?.kind ?? 'NATIVE';
577
594
  const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
578
595
  const remediation = kind === 'PRC20'
579
- ? `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.`
596
+ ? `Bridge the burn token (${extra?.burnToken ?? 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
580
597
  : `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
581
598
  return {
582
599
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_303_05,
@@ -589,8 +606,8 @@ const RAW_HOOKS_R3 = {
589
606
  ueaAddress,
590
607
  pathTag,
591
608
  kind,
592
- burnToken: (_c = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _c !== void 0 ? _c : null,
593
- segmentIndex: (_d = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _d !== void 0 ? _d : null,
609
+ burnToken: extra?.burnToken ?? null,
610
+ segmentIndex: extra?.segmentIndex ?? null,
594
611
  },
595
612
  level: 'ERROR',
596
613
  };
@@ -628,7 +645,7 @@ const RAW_HOOKS_R3 = {
628
645
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_304_04]: (errorMessage) => {
629
646
  const { isUserDecline, title, message } = classifyDeclineError(errorMessage);
630
647
  const response = {
631
- error: errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Verification declined by user',
648
+ error: errorMessage ?? 'Verification declined by user',
632
649
  isUserDecline,
633
650
  };
634
651
  return {
@@ -650,14 +667,18 @@ const RAW_HOOKS_R3 = {
650
667
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_01,
651
668
  title: `Awaiting ${friendlyChain(sourceChain)} Relay`,
652
669
  message: `Waiting for UGPC to relay to CEA on ${sourceChain}`,
653
- response: Object.assign({ chain: sourceChain }, (pushTxHash ? { pushTxHash } : {})),
670
+ response: { chain: sourceChain, ...(pushTxHash ? { pushTxHash } : {}) },
654
671
  level: 'INFO',
655
672
  }),
656
673
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02]: (sourceChain, elapsedMs, pushTxHash) => ({
657
674
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_02,
658
675
  title: `Syncing State with ${friendlyChain(sourceChain)}`,
659
676
  message: `Polling ${sourceChain} for CEA execution`,
660
- response: Object.assign({ chain: sourceChain, elapsedMs }, (pushTxHash ? { pushTxHash } : {})),
677
+ response: {
678
+ chain: sourceChain,
679
+ elapsedMs,
680
+ ...(pushTxHash ? { pushTxHash } : {}),
681
+ },
661
682
  level: 'INFO',
662
683
  }),
663
684
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_309_03]: (sourceChain, txHash) => ({
@@ -671,21 +692,25 @@ const RAW_HOOKS_R3 = {
671
692
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01,
672
693
  title: `${friendlyChain(sourceChain)} → Push Chain Inbound Tx Submitted`,
673
694
  message: `CEA initiated return — waiting for Push Chain inbound from ${sourceChain}`,
674
- response: Object.assign({ chain: sourceChain }, (pushTxHash ? { pushTxHash } : {})),
695
+ response: { chain: sourceChain, ...(pushTxHash ? { pushTxHash } : {}) },
675
696
  level: 'INFO',
676
697
  }),
677
698
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02]: (sourceChain, elapsedMs, pushTxHash) => ({
678
699
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02,
679
700
  title: 'Syncing State with Push Chain for Inbound Tx',
680
701
  message: `Polling Push Chain for inbound from ${sourceChain}`,
681
- response: Object.assign({ chain: sourceChain, elapsedMs }, (pushTxHash ? { pushTxHash } : {})),
702
+ response: {
703
+ chain: sourceChain,
704
+ elapsedMs,
705
+ ...(pushTxHash ? { pushTxHash } : {}),
706
+ },
682
707
  level: 'INFO',
683
708
  }),
684
709
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01]: (sourceChain, txHash, receipt) => ({
685
710
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_01,
686
711
  title: 'Push Chain Inbound Tx Success',
687
712
  message: `Inbound from ${sourceChain} confirmed · Push tx: ${txHash}`,
688
- response: { chain: sourceChain, txHash, receipt: receipt !== null && receipt !== void 0 ? receipt : null },
713
+ response: { chain: sourceChain, txHash, receipt: receipt ?? null },
689
714
  level: 'SUCCESS',
690
715
  }),
691
716
  // 399-02 / 399-03 are multi-use terminal hooks for R3:
@@ -707,7 +732,14 @@ const RAW_HOOKS_R3 = {
707
732
  ? 'Push Chain Tx Failed'
708
733
  : 'Push Chain Inbound Tx Failed',
709
734
  message: normalizedErrorMessage,
710
- response: Object.assign(Object.assign(Object.assign({ error: normalizedErrorMessage, phase, chain: chain !== null && chain !== void 0 ? chain : null }, (pushTxHash ? { pushTxHash } : {})), (txHash ? { txHash } : {})), (decodedError ? { decodedError } : {})),
735
+ response: {
736
+ error: normalizedErrorMessage,
737
+ phase,
738
+ chain: chain ?? null,
739
+ ...(pushTxHash ? { pushTxHash } : {}),
740
+ ...(txHash ? { txHash } : {}),
741
+ ...(decodedError ? { decodedError } : {}),
742
+ },
711
743
  level: 'ERROR',
712
744
  };
713
745
  },
@@ -719,11 +751,17 @@ const RAW_HOOKS_R3 = {
719
751
  : phase === 'push'
720
752
  ? `Timed out waiting for Push Chain tx`
721
753
  : `Timed out waiting for inbound from ${sourceChain}`,
722
- response: Object.assign({ error: phase === 'outbound'
754
+ response: {
755
+ error: phase === 'outbound'
723
756
  ? 'outbound timeout'
724
757
  : phase === 'push'
725
758
  ? 'push timeout'
726
- : 'inbound timeout', phase, chain: sourceChain, elapsedMs }, (pushTxHash ? { pushTxHash } : {})),
759
+ : 'inbound timeout',
760
+ phase,
761
+ chain: sourceChain,
762
+ elapsedMs,
763
+ ...(pushTxHash ? { pushTxHash } : {}),
764
+ },
727
765
  level: 'ERROR',
728
766
  }),
729
767
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_99]: (sourceChain, txHash) => ({
@@ -811,11 +849,10 @@ const RAW_HOOKS_MULTICHAIN = {
811
849
  // streams remain self-consistent. `runPreflight` switches between
812
850
  // 203-xx and 003-xx based on pathTag === 'CASCADE'.
813
851
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_03]: (required, available, sufficient, ueaAddress, pathTag, extra) => {
814
- var _a, _b, _c, _d;
815
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
852
+ const kind = extra?.kind ?? 'NATIVE';
816
853
  const availableStr = kind === 'PRC20' ? `${available} units` : (0, formatters_1.formatPc)(available, 4);
817
854
  const requiredStr = kind === 'PRC20' ? `${required} units` : (0, formatters_1.formatPc)(required, 4);
818
- const enforceGasCheck = extra === null || extra === void 0 ? void 0 : extra.enforceGasCheck;
855
+ const enforceGasCheck = extra?.enforceGasCheck;
819
856
  const visiblePathTag = displayPathTag(pathTag);
820
857
  return {
821
858
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_03,
@@ -829,22 +866,21 @@ const RAW_HOOKS_MULTICHAIN = {
829
866
  ueaAddress,
830
867
  pathTag,
831
868
  kind,
832
- burnToken: (_b = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _b !== void 0 ? _b : null,
833
- segmentIndex: (_c = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _c !== void 0 ? _c : null,
834
- enforceGasCheck: enforceGasCheck !== null && enforceGasCheck !== void 0 ? enforceGasCheck : null,
869
+ burnToken: extra?.burnToken ?? null,
870
+ segmentIndex: extra?.segmentIndex ?? null,
871
+ enforceGasCheck: enforceGasCheck ?? null,
835
872
  warningOnly: !sufficient && enforceGasCheck === false,
836
- shortfall: (_d = extra === null || extra === void 0 ? void 0 : extra.shortfall) !== null && _d !== void 0 ? _d : null,
873
+ shortfall: extra?.shortfall ?? null,
837
874
  },
838
875
  level: preflightLevel(sufficient),
839
876
  };
840
877
  },
841
878
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_04]: (required, available, shortfall, ueaAddress, pathTag, extra) => {
842
- var _a, _b, _c, _d;
843
- const kind = (_a = extra === null || extra === void 0 ? void 0 : extra.kind) !== null && _a !== void 0 ? _a : 'NATIVE';
879
+ const kind = extra?.kind ?? 'NATIVE';
844
880
  const shortfallStr = kind === 'PRC20' ? `${shortfall} units` : (0, formatters_1.formatPc)(shortfall, 4);
845
881
  const visiblePathTag = displayPathTag(pathTag);
846
882
  const remediation = kind === 'PRC20'
847
- ? `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.`
883
+ ? `Bridge the burn token (${extra?.burnToken ?? 'PRC-20'}) to UEA ${ueaAddress} before retrying.`
848
884
  : `Bridge >=${shortfallStr} to UEA ${ueaAddress} before retrying.`;
849
885
  return {
850
886
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_003_04,
@@ -857,8 +893,8 @@ const RAW_HOOKS_MULTICHAIN = {
857
893
  ueaAddress,
858
894
  pathTag,
859
895
  kind,
860
- burnToken: (_c = extra === null || extra === void 0 ? void 0 : extra.burnToken) !== null && _c !== void 0 ? _c : null,
861
- segmentIndex: (_d = extra === null || extra === void 0 ? void 0 : extra.segmentIndex) !== null && _d !== void 0 ? _d : null,
896
+ burnToken: extra?.burnToken ?? null,
897
+ segmentIndex: extra?.segmentIndex ?? null,
862
898
  },
863
899
  level: 'ERROR',
864
900
  };
@@ -876,28 +912,44 @@ const RAW_HOOKS_MULTICHAIN = {
876
912
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01,
877
913
  title: 'All Multichain Transactions Successful',
878
914
  message: `${hopCount}-hop transaction confirmed across all chains`,
879
- response: Object.assign({ hopCount }, (txHash ? { txHash } : {})),
915
+ response: { hopCount, ...(txHash ? { txHash } : {}) },
880
916
  level: 'SUCCESS',
881
917
  }),
882
918
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02]: (failedAt, total, errorMessage, txHash, pushTxHash) => ({
883
919
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02,
884
920
  title: 'Multichain Transactions Failed',
885
921
  message: `Multichain failed at hop ${failedAt} of ${total}: ${errorMessage}`,
886
- response: Object.assign(Object.assign({ failedAt,
887
- total, error: errorMessage }, (txHash ? { txHash } : {})), (pushTxHash ? { pushTxHash } : {})),
922
+ response: {
923
+ failedAt,
924
+ total,
925
+ error: errorMessage,
926
+ ...(txHash ? { txHash } : {}),
927
+ ...(pushTxHash ? { pushTxHash } : {}),
928
+ },
888
929
  level: 'ERROR',
889
930
  }),
890
931
  [progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03]: (failedAt, total, txHash, pushTxHash) => ({
891
932
  id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03,
892
933
  title: 'Multichain Transactions Timeout',
893
934
  message: `Multichain timed out at hop ${failedAt} of ${total}`,
894
- response: Object.assign(Object.assign({ failedAt,
895
- total, error: 'multichain timeout' }, (txHash ? { txHash } : {})), (pushTxHash ? { pushTxHash } : {})),
935
+ response: {
936
+ failedAt,
937
+ total,
938
+ error: 'multichain timeout',
939
+ ...(txHash ? { txHash } : {}),
940
+ ...(pushTxHash ? { pushTxHash } : {}),
941
+ },
896
942
  level: 'ERROR',
897
943
  }),
898
944
  };
899
945
  // Combine all routes into the master record
900
- 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);
946
+ const RAW_HOOKS = {
947
+ ...RAW_HOOKS_R1,
948
+ ...RAW_HOOKS_R2,
949
+ ...RAW_HOOKS_R3,
950
+ ...RAW_HOOKS_MULTICHAIN,
951
+ ...RAW_HOOKS_MIG,
952
+ };
901
953
  // Build final hooks with timestamp injection
902
954
  const PROGRESS_HOOKS = Object.fromEntries(Object.entries(RAW_HOOKS).map(([key, value]) => [key, withTimestamp(value)]));
903
955
  exports.default = PROGRESS_HOOKS;