@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.
- package/CHANGELOG.md +48 -0
- package/package.json +1 -1
- package/src/lib/cache/cache.js +2 -0
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +8 -1
- package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
- package/src/lib/constants/abi/pc20.evm.js +150 -0
- package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
- package/src/lib/constants/abi/prc20.evm.js +97 -0
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.js +38 -8
- package/src/lib/constants/selectors.js +2 -2
- package/src/lib/constants/tokens.js +4 -3
- package/src/lib/formatters.js +16 -6
- package/src/lib/generated/uexecutor/v1/query.js +2 -4
- package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v1/types.js +90 -47
- package/src/lib/generated/uexecutor/v2/query.js +2 -4
- package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
- package/src/lib/generated/uexecutor/v2/types.js +49 -33
- package/src/lib/generated/v1/tx.js +30 -37
- package/src/lib/index.d.ts +3 -0
- package/src/lib/index.js +21 -3
- package/src/lib/internal/buffer.js +1 -2
- package/src/lib/orchestrator/cea-utils.js +73 -83
- package/src/lib/orchestrator/internals/account-manager.js +130 -139
- package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
- package/src/lib/orchestrator/internals/cascade.js +1184 -1059
- package/src/lib/orchestrator/internals/confirmation.js +138 -148
- package/src/lib/orchestrator/internals/error-decoder.js +1 -1
- package/src/lib/orchestrator/internals/errors.js +12 -3
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
- package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
- package/src/lib/orchestrator/internals/execute-standard.js +339 -342
- package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
- package/src/lib/orchestrator/internals/gateway-client.js +102 -103
- package/src/lib/orchestrator/internals/helpers.js +30 -27
- package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
- package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
- package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
- package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
- package/src/lib/orchestrator/internals/payload-builder.js +119 -100
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
- package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
- package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
- package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
- package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
- package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
- package/src/lib/orchestrator/internals/pc20/export.js +412 -0
- package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
- package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
- package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
- package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
- package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
- package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
- package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
- package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
- package/src/lib/orchestrator/internals/preflight.js +1 -1
- package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
- package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
- package/src/lib/orchestrator/internals/quote.js +90 -94
- package/src/lib/orchestrator/internals/rescue.js +76 -79
- package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
- package/src/lib/orchestrator/internals/response-builder.js +817 -701
- package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
- package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
- package/src/lib/orchestrator/internals/signing.js +78 -83
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
- package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
- package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
- package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
- package/src/lib/orchestrator/internals/svm-rent.js +163 -141
- package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
- package/src/lib/orchestrator/internals/uea-manager.js +89 -86
- package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
- package/src/lib/orchestrator/orchestrator.js +217 -200
- package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
- package/src/lib/orchestrator/orchestrator.types.js +19 -0
- package/src/lib/orchestrator/payload-builders.d.ts +2 -2
- package/src/lib/orchestrator/payload-builders.js +26 -24
- package/src/lib/orchestrator/route-detector.js +26 -9
- package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
- package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
- package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
- package/src/lib/price-fetch/price-fetch.js +67 -68
- package/src/lib/progress-hook/progress-hook.js +124 -72
- package/src/lib/push-chain/push-chain.js +171 -153
- package/src/lib/push-client/push-client.js +223 -237
- package/src/lib/universal/account/account.js +349 -365
- package/src/lib/universal/signer/signer.js +306 -294
- package/src/lib/universal-tx-detector/auto-detect.js +55 -60
- package/src/lib/universal-tx-detector/cascade.js +160 -172
- package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
- package/src/lib/universal-tx-detector/classify.js +2 -3
- package/src/lib/universal-tx-detector/detector-svm.js +139 -147
- package/src/lib/universal-tx-detector/detector.js +145 -157
- package/src/lib/universal-tx-detector/normalize.js +7 -7
- package/src/lib/utils/external-tx-hash.js +1 -2
- package/src/lib/utils.d.ts +44 -0
- package/src/lib/utils.js +762 -683
- package/src/lib/vm-client/evm-client.js +186 -202
- package/src/lib/vm-client/svm-client.d.ts +1 -1
- package/src/lib/vm-client/svm-client.js +220 -224
- 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) => (
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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 =
|
|
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
|
|
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:
|
|
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
|
-
|
|
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
|
|
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:
|
|
355
|
-
segmentIndex:
|
|
356
|
-
enforceGasCheck: enforceGasCheck
|
|
359
|
+
burnToken: extra?.burnToken ?? null,
|
|
360
|
+
segmentIndex: extra?.segmentIndex ?? null,
|
|
361
|
+
enforceGasCheck: enforceGasCheck ?? null,
|
|
357
362
|
warningOnly: !sufficient && enforceGasCheck === false,
|
|
358
|
-
shortfall:
|
|
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
|
-
|
|
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 (${
|
|
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:
|
|
382
|
-
segmentIndex:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
|
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:
|
|
566
|
-
segmentIndex:
|
|
567
|
-
enforceGasCheck: enforceGasCheck
|
|
583
|
+
burnToken: extra?.burnToken ?? null,
|
|
584
|
+
segmentIndex: extra?.segmentIndex ?? null,
|
|
585
|
+
enforceGasCheck: enforceGasCheck ?? null,
|
|
568
586
|
warningOnly: !sufficient && enforceGasCheck === false,
|
|
569
|
-
shortfall:
|
|
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
|
-
|
|
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 (${
|
|
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:
|
|
593
|
-
segmentIndex:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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:
|
|
754
|
+
response: {
|
|
755
|
+
error: phase === 'outbound'
|
|
723
756
|
? 'outbound timeout'
|
|
724
757
|
: phase === 'push'
|
|
725
758
|
? 'push timeout'
|
|
726
|
-
: 'inbound timeout',
|
|
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
|
-
|
|
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
|
|
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:
|
|
833
|
-
segmentIndex:
|
|
834
|
-
enforceGasCheck: enforceGasCheck
|
|
869
|
+
burnToken: extra?.burnToken ?? null,
|
|
870
|
+
segmentIndex: extra?.segmentIndex ?? null,
|
|
871
|
+
enforceGasCheck: enforceGasCheck ?? null,
|
|
835
872
|
warningOnly: !sufficient && enforceGasCheck === false,
|
|
836
|
-
shortfall:
|
|
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
|
-
|
|
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 (${
|
|
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:
|
|
861
|
-
segmentIndex:
|
|
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:
|
|
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:
|
|
887
|
-
|
|
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:
|
|
895
|
-
|
|
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 =
|
|
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;
|