@pushchain/core 6.0.18 → 6.0.20
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 +14 -0
- package/package.json +1 -1
- package/src/lib/constants/chain.d.ts +16 -0
- package/src/lib/constants/chain.js +32 -4
- package/src/lib/formatters.d.ts +1 -0
- package/src/lib/formatters.js +66 -1
- package/src/lib/index.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.js +64 -46
- package/src/lib/orchestrator/internals/confirmation.js +8 -8
- package/src/lib/orchestrator/internals/error-decoder.d.ts +1 -0
- package/src/lib/orchestrator/internals/error-decoder.js +10 -0
- package/src/lib/orchestrator/internals/errors.js +1 -1
- package/src/lib/orchestrator/internals/execute-funds-only.js +8 -6
- package/src/lib/orchestrator/internals/execute-funds-payload.js +6 -4
- package/src/lib/orchestrator/internals/execute-standard.js +10 -8
- package/src/lib/orchestrator/internals/gateway-client.js +34 -1
- package/src/lib/orchestrator/internals/inbound-tracker.js +4 -3
- package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +8 -4
- package/src/lib/orchestrator/internals/progress-route-hooks.js +8 -8
- package/src/lib/orchestrator/internals/push-chain-tx.js +71 -17
- package/src/lib/orchestrator/internals/response-builder.js +25 -16
- package/src/lib/orchestrator/internals/tx-transformer.js +11 -6
- package/src/lib/orchestrator/orchestrator.js +3 -17
- package/src/lib/orchestrator/orchestrator.types.d.ts +7 -0
- package/src/lib/progress-hook/progress-hook.js +37 -40
- package/src/lib/push-client/push-client.d.ts +39 -0
- package/src/lib/push-client/push-client.js +130 -12
- package/src/lib/universal/signer/signer.d.ts +3 -2
- package/src/lib/universal/signer/signer.js +92 -8
- package/src/lib/universal/universal.types.d.ts +37 -0
- package/src/lib/vm-client/evm-client.d.ts +43 -0
- package/src/lib/vm-client/evm-client.js +154 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
@pushchain/core@6.0.20 (2026-07-10)
|
|
2
|
+
|
|
3
|
+
- fix: support custom EIP-7702 signers and dynamic multicall gas
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
@pushchain/core@6.0.19 (2026-07-01)
|
|
8
|
+
|
|
9
|
+
- feat: use OZ ERC-7821 executor for 7702 batching
|
|
10
|
+
- feat: native EIP-7702 atomic multicall for native-Push EOAs
|
|
11
|
+
- feat: archive-RPC fallback for prune-miss reads in tracking
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
1
15
|
@pushchain/core@6.0.17 (2026-06-09)
|
|
2
16
|
|
|
3
17
|
- fix: make SVM payload encoding browser-safe
|
package/package.json
CHANGED
|
@@ -54,12 +54,27 @@ export declare const SYNTHETIC_PUSH_ERC20: Record<PUSH_NETWORK, {
|
|
|
54
54
|
* References -
|
|
55
55
|
* https://namespaces.chainagnostic.org/solana/caip2
|
|
56
56
|
*/
|
|
57
|
+
/**
|
|
58
|
+
* EIP-7702 batch executor (`PushBatchExecutor`) delegation targets, per chain.
|
|
59
|
+
*
|
|
60
|
+
* Native Push EOAs delegate their code to this contract (via a type-4 / SetCode
|
|
61
|
+
* transaction) to execute a `MultiCall[]` batch atomically in a single tx,
|
|
62
|
+
* replacing the legacy non-atomic per-call loop.
|
|
63
|
+
*
|
|
64
|
+
* An entry is absent until the contract is deployed to that chain. When absent,
|
|
65
|
+
* the SDK falls back to sequential single-call execution. Fill in the address
|
|
66
|
+
* after deploying `push-chain-core-contracts/src/executor/PushBatchExecutor.sol`.
|
|
67
|
+
*/
|
|
68
|
+
export declare const PUSH_BATCH_EXECUTOR_ADDRESS: Partial<Record<CHAIN, `0x${string}`>>;
|
|
69
|
+
/** Returns the configured 7702 batch-executor address for a chain, if any. */
|
|
70
|
+
export declare function getBatchExecutorAddress(chain: CHAIN): `0x${string}` | undefined;
|
|
57
71
|
export declare const CHAIN_INFO: Record<CHAIN, {
|
|
58
72
|
chainId: string;
|
|
59
73
|
vm: VM;
|
|
60
74
|
lockerContract?: string;
|
|
61
75
|
gatewayVersion?: 'v0' | 'v1';
|
|
62
76
|
defaultRPC: string[];
|
|
77
|
+
archiveRPC?: string[];
|
|
63
78
|
confirmations: number;
|
|
64
79
|
fastConfirmations: number;
|
|
65
80
|
timeout: number;
|
|
@@ -77,6 +92,7 @@ export declare const CHAIN_INFO: Record<CHAIN, {
|
|
|
77
92
|
export declare const PUSH_CHAIN_INFO: Record<CHAIN.PUSH_MAINNET | CHAIN.PUSH_TESTNET_DONUT | CHAIN.PUSH_LOCALNET, (typeof CHAIN_INFO)[CHAIN.PUSH_MAINNET] & {
|
|
78
93
|
denom: string;
|
|
79
94
|
tendermintRpc: string[];
|
|
95
|
+
archiveTendermintRpc?: string[];
|
|
80
96
|
prefix: string;
|
|
81
97
|
factoryAddress: `0x${string}`;
|
|
82
98
|
pushDecimals: bigint;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CHAIN_EXPLORERS = exports.CEA_FACTORY_ADDRESSES = exports.VAULT_ADDRESSES = exports.SVM_PYTH_PRICE_FEED = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.PUSH_VIEM_CHAINS = exports.PUSH_CHAIN_INFO = exports.CHAIN_INFO = exports.SYNTHETIC_PUSH_ERC20 = exports.UEA_MIGRATION = exports.UEA_FACTORY = exports.UEA_PROXY = exports.VM_NAMESPACE = void 0;
|
|
3
|
+
exports.CHAIN_EXPLORERS = exports.CEA_FACTORY_ADDRESSES = exports.VAULT_ADDRESSES = exports.SVM_PYTH_PRICE_FEED = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.PUSH_VIEM_CHAINS = exports.PUSH_CHAIN_INFO = exports.CHAIN_INFO = exports.PUSH_BATCH_EXECUTOR_ADDRESS = exports.SYNTHETIC_PUSH_ERC20 = exports.UEA_MIGRATION = exports.UEA_FACTORY = exports.UEA_PROXY = exports.VM_NAMESPACE = void 0;
|
|
4
|
+
exports.getBatchExecutorAddress = getBatchExecutorAddress;
|
|
4
5
|
exports.getPushViemChain = getPushViemChain;
|
|
5
6
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
6
7
|
exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
@@ -41,8 +42,8 @@ exports.UEA_FACTORY = {
|
|
|
41
42
|
*/
|
|
42
43
|
exports.UEA_MIGRATION = {
|
|
43
44
|
[enums_1.PUSH_NETWORK.MAINNET]: '0xTBD',
|
|
44
|
-
[enums_1.PUSH_NETWORK.TESTNET_DONUT]: '
|
|
45
|
-
[enums_1.PUSH_NETWORK.TESTNET]: '
|
|
45
|
+
[enums_1.PUSH_NETWORK.TESTNET_DONUT]: '0x862F13DBb7E21e552f7DAF6D954E7155e7f666AD',
|
|
46
|
+
[enums_1.PUSH_NETWORK.TESTNET]: '0x862F13DBb7E21e552f7DAF6D954E7155e7f666AD',
|
|
46
47
|
[enums_1.PUSH_NETWORK.LOCALNET]: '0xTBD',
|
|
47
48
|
};
|
|
48
49
|
/**
|
|
@@ -145,6 +146,27 @@ exports.SYNTHETIC_PUSH_ERC20 = {
|
|
|
145
146
|
* References -
|
|
146
147
|
* https://namespaces.chainagnostic.org/solana/caip2
|
|
147
148
|
*/
|
|
149
|
+
/**
|
|
150
|
+
* EIP-7702 batch executor (`PushBatchExecutor`) delegation targets, per chain.
|
|
151
|
+
*
|
|
152
|
+
* Native Push EOAs delegate their code to this contract (via a type-4 / SetCode
|
|
153
|
+
* transaction) to execute a `MultiCall[]` batch atomically in a single tx,
|
|
154
|
+
* replacing the legacy non-atomic per-call loop.
|
|
155
|
+
*
|
|
156
|
+
* An entry is absent until the contract is deployed to that chain. When absent,
|
|
157
|
+
* the SDK falls back to sequential single-call execution. Fill in the address
|
|
158
|
+
* after deploying `push-chain-core-contracts/src/executor/PushBatchExecutor.sol`.
|
|
159
|
+
*/
|
|
160
|
+
exports.PUSH_BATCH_EXECUTOR_ADDRESS = {
|
|
161
|
+
// OpenZeppelin ERC-7821 based executor (with payable receive), deployed
|
|
162
|
+
// 2026-06-22, tx 0xbbe4176a….
|
|
163
|
+
[enums_1.CHAIN.PUSH_TESTNET_DONUT]: '0x0106BF2F9B02f32203A83a3bDaD79fE8818f3796',
|
|
164
|
+
// [CHAIN.PUSH_MAINNET]: '0x...', // TODO: set after mainnet deploy
|
|
165
|
+
};
|
|
166
|
+
/** Returns the configured 7702 batch-executor address for a chain, if any. */
|
|
167
|
+
function getBatchExecutorAddress(chain) {
|
|
168
|
+
return exports.PUSH_BATCH_EXECUTOR_ADDRESS[chain];
|
|
169
|
+
}
|
|
148
170
|
exports.CHAIN_INFO = {
|
|
149
171
|
// Push
|
|
150
172
|
[enums_1.CHAIN.PUSH_MAINNET]: {
|
|
@@ -160,6 +182,9 @@ exports.CHAIN_INFO = {
|
|
|
160
182
|
chainId: '42101',
|
|
161
183
|
vm: enums_1.VM.EVM,
|
|
162
184
|
defaultRPC: ['https://evm.donut.rpc.push.org/'],
|
|
185
|
+
// Archive (full-history) EVM RPC — fallback for tracking older txs the
|
|
186
|
+
// prune `defaultRPC` has dropped.
|
|
187
|
+
archiveRPC: ['https://archive.evm.donut.rpc.push.org/'],
|
|
163
188
|
confirmations: 1,
|
|
164
189
|
fastConfirmations: 0,
|
|
165
190
|
timeout: 30000,
|
|
@@ -305,7 +330,10 @@ exports.CHAIN_INFO = {
|
|
|
305
330
|
*/
|
|
306
331
|
exports.PUSH_CHAIN_INFO = {
|
|
307
332
|
[enums_1.CHAIN.PUSH_MAINNET]: Object.assign(Object.assign({}, exports.CHAIN_INFO[enums_1.CHAIN.PUSH_MAINNET]), { denom: 'upc', tendermintRpc: ['TBD'], prefix: 'push', factoryAddress: '0xTBD', pushDecimals: BigInt(1e18), usdcDecimals: BigInt(1e8), pushToUsdcNumerator: BigInt(1e7), pushToUsdcDenominator: BigInt(1e18) }),
|
|
308
|
-
[enums_1.CHAIN.PUSH_TESTNET_DONUT]: Object.assign(Object.assign({}, exports.CHAIN_INFO[enums_1.CHAIN.PUSH_TESTNET_DONUT]), { denom: 'upc', tendermintRpc: ['https://donut.rpc.push.org/'],
|
|
333
|
+
[enums_1.CHAIN.PUSH_TESTNET_DONUT]: Object.assign(Object.assign({}, exports.CHAIN_INFO[enums_1.CHAIN.PUSH_TESTNET_DONUT]), { denom: 'upc', tendermintRpc: ['https://donut.rpc.push.org/'],
|
|
334
|
+
// Archive (full-history) Tendermint RPC — fallback for tracking older txs
|
|
335
|
+
// whose legs fall outside the prune window.
|
|
336
|
+
archiveTendermintRpc: ['https://archive.donut.rpc.push.org/'], prefix: 'push', factoryAddress: '0x00000000000000000000000000000000000000eA', pushDecimals: BigInt(1e18), usdcDecimals: BigInt(1e8), pushToUsdcNumerator: BigInt(1e7), pushToUsdcDenominator: BigInt(1e18) }),
|
|
309
337
|
[enums_1.CHAIN.PUSH_LOCALNET]: Object.assign(Object.assign({}, exports.CHAIN_INFO[enums_1.CHAIN.PUSH_LOCALNET]), { denom: 'upc', tendermintRpc: ['http://localhost:26657'], prefix: 'push', factoryAddress: '0x00000000000000000000000000000000000000eA', pushDecimals: BigInt(1e18), usdcDecimals: BigInt(1e8), pushToUsdcNumerator: BigInt(1e7), pushToUsdcDenominator: BigInt(1e18) }),
|
|
310
338
|
};
|
|
311
339
|
// ============================================================================
|
package/src/lib/formatters.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function formatPc(valueWei: bigint, precision?: number): string;
|
|
|
5
5
|
* debugging but prefix it with the human PC amount users can reason about.
|
|
6
6
|
*/
|
|
7
7
|
export declare function normalizePcInsufficientFundsError(message: string): string;
|
|
8
|
+
export declare function normalizePublicErrorMessage(error: unknown): string;
|
package/src/lib/formatters.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatPc = formatPc;
|
|
4
4
|
exports.normalizePcInsufficientFundsError = normalizePcInsufficientFundsError;
|
|
5
|
+
exports.normalizePublicErrorMessage = normalizePublicErrorMessage;
|
|
5
6
|
const PC_DECIMALS = 18;
|
|
6
7
|
function formatTokenUnits(value, decimals, precision) {
|
|
7
8
|
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
@@ -30,6 +31,46 @@ function formatTokenUnits(value, decimals, precision) {
|
|
|
30
31
|
function formatPc(valueWei, precision) {
|
|
31
32
|
return `${formatTokenUnits(valueWei, PC_DECIMALS, precision)} PC`;
|
|
32
33
|
}
|
|
34
|
+
function getErrorMessage(error) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36
|
+
if (typeof error === 'string')
|
|
37
|
+
return error;
|
|
38
|
+
const stringifyFallback = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
const json = JSON.stringify(value);
|
|
41
|
+
return json === undefined ? String(value) : json;
|
|
42
|
+
}
|
|
43
|
+
catch (_a) {
|
|
44
|
+
return String(value);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
const maybe = error;
|
|
49
|
+
return String((_g = (_f = (_e = (_c = (_a = maybe.shortMessage) !== null && _a !== void 0 ? _a : (_b = maybe.cause) === null || _b === void 0 ? void 0 : _b.shortMessage) !== null && _c !== void 0 ? _c : (_d = maybe.cause) === null || _d === void 0 ? void 0 : _d.reason) !== null && _e !== void 0 ? _e : maybe.details) !== null && _f !== void 0 ? _f : maybe.message) !== null && _g !== void 0 ? _g : stringifyFallback(error));
|
|
50
|
+
}
|
|
51
|
+
if (typeof error === 'object' && error !== null) {
|
|
52
|
+
const maybe = error;
|
|
53
|
+
return String((_q = (_p = (_o = (_m = (_k = (_h = maybe.shortMessage) !== null && _h !== void 0 ? _h : (_j = maybe.cause) === null || _j === void 0 ? void 0 : _j.shortMessage) !== null && _k !== void 0 ? _k : (_l = maybe.cause) === null || _l === void 0 ? void 0 : _l.reason) !== null && _m !== void 0 ? _m : maybe.reason) !== null && _o !== void 0 ? _o : maybe.details) !== null && _p !== void 0 ? _p : maybe.message) !== null && _q !== void 0 ? _q : stringifyFallback(error));
|
|
54
|
+
}
|
|
55
|
+
return String(error);
|
|
56
|
+
}
|
|
57
|
+
function collectErrorMessages(error, depth = 0) {
|
|
58
|
+
if (depth > 4)
|
|
59
|
+
return [];
|
|
60
|
+
if (typeof error === 'string')
|
|
61
|
+
return [error];
|
|
62
|
+
if (error instanceof Error || (typeof error === 'object' && error !== null)) {
|
|
63
|
+
const maybe = error;
|
|
64
|
+
const values = [
|
|
65
|
+
maybe.shortMessage,
|
|
66
|
+
maybe.details,
|
|
67
|
+
maybe.reason,
|
|
68
|
+
maybe.message,
|
|
69
|
+
].filter((value) => typeof value === 'string');
|
|
70
|
+
return [...values, ...collectErrorMessages(maybe.cause, depth + 1)];
|
|
71
|
+
}
|
|
72
|
+
return [String(error)];
|
|
73
|
+
}
|
|
33
74
|
/**
|
|
34
75
|
* Push Chain EVM/RPC insufficient-funds errors surface native balances as raw
|
|
35
76
|
* wei, usually in the form "have <wei> want <wei>". Preserve the raw value for
|
|
@@ -41,6 +82,30 @@ function normalizePcInsufficientFundsError(message) {
|
|
|
41
82
|
}
|
|
42
83
|
return message
|
|
43
84
|
.replace(/\bhave\s+([0-9]+)(?=\s+want\b)/gi, (_match, value) => `have ${formatPc(BigInt(value))} (${value} wei)`)
|
|
44
|
-
.replace(/\bwant\s+([0-9]+)(
|
|
85
|
+
.replace(/\bwant\s+([0-9]+)(?!\d|\.\d|\s*(?:wei|PC))/gi, (_match, value) => `want ${formatPc(BigInt(value))} (${value} wei)`);
|
|
86
|
+
}
|
|
87
|
+
function normalizePublicErrorMessage(error) {
|
|
88
|
+
const message = normalizePcInsufficientFundsError(getErrorMessage(error));
|
|
89
|
+
const searchableMessage = normalizePcInsufficientFundsError(collectErrorMessages(error).join(' '));
|
|
90
|
+
const haveWant = searchableMessage.match(/\bhave\s+([0-9]+(?:\.[0-9]+)?\s+PC)(?:\s+\([^)]+\))?\s+want\s+([0-9]+(?:\.[0-9]+)?\s+PC)/i);
|
|
91
|
+
if (/insufficient funds for gas \* price \+ value/i.test(searchableMessage) ||
|
|
92
|
+
/exceeds the balance of the account/i.test(searchableMessage) ||
|
|
93
|
+
/insufficient funds for intrinsic transaction cost/i.test(searchableMessage)) {
|
|
94
|
+
const havePc = haveWant === null || haveWant === void 0 ? void 0 : haveWant[1];
|
|
95
|
+
const wantPc = haveWant === null || haveWant === void 0 ? void 0 : haveWant[2];
|
|
96
|
+
if (havePc && wantPc) {
|
|
97
|
+
return `Insufficient balance for transaction gas/value: have ${havePc}, need ${wantPc}.`;
|
|
98
|
+
}
|
|
99
|
+
return 'Insufficient balance for transaction gas/value.';
|
|
100
|
+
}
|
|
101
|
+
if (/Attempt to debit an account but found no record of a prior credit/i.test(searchableMessage)) {
|
|
102
|
+
return 'Insufficient Solana balance for transaction fee/value: account has no prior credit.';
|
|
103
|
+
}
|
|
104
|
+
if (/insufficient lamports/i.test(searchableMessage) ||
|
|
105
|
+
/custom program error: 0x1/i.test(searchableMessage) ||
|
|
106
|
+
/insufficient funds for rent/i.test(searchableMessage)) {
|
|
107
|
+
return 'Insufficient Solana balance for transaction fee/value.';
|
|
108
|
+
}
|
|
109
|
+
return message.length > 500 ? `${message.slice(0, 497)}...` : message;
|
|
45
110
|
}
|
|
46
111
|
//# sourceMappingURL=formatters.js.map
|
package/src/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PushChain } from './push-chain/push-chain';
|
|
2
2
|
export type { ConversionQuote } from './constants/tokens';
|
|
3
|
-
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, DerivedExecutorAccount, ResolvedAccount, ResolvedControllerAccounts, AccountType, AccountRole, } from './universal/universal.types';
|
|
3
|
+
export type { UniversalSigner, UniversalAccount, UniversalSignerSkeleton, SignAuthorizationParams, SignedAuthorization, DerivedExecutorAccount, ResolvedAccount, ResolvedControllerAccounts, AccountType, AccountRole, } from './universal/universal.types';
|
|
4
4
|
export type { ChainTarget, ChainSource, UniversalTo, TransactionRouteType, UniversalExecuteParams, UniversalOutboundTxRequest, PreparedUniversalTx, CascadedTxResponse, CascadeHopInfo, CascadeTrackOptions, CascadeProgressEvent, CascadeCompletionResult, MultiChainTxResponse, OutboundTxDetails, WaitForOutboundOptions, SvmGatewayAccountMeta, SvmExecutePayloadFields, AccountStatus, UEAStatus, RescueFundsParams, } from './orchestrator/orchestrator.types';
|
|
5
5
|
export { parseUEAVersion } from './orchestrator/orchestrator.types';
|
|
6
6
|
export { TransactionRoute, detectRoute, isChainTarget } from './orchestrator/route-detector';
|
|
@@ -1363,9 +1363,9 @@ function composeCascade(ctx, segments, ueaAddress, ueaBalance, ueaNonce) {
|
|
|
1363
1363
|
// createCascadedBuilder
|
|
1364
1364
|
// ============================================================================
|
|
1365
1365
|
function txHashFromProgressEvent(event) {
|
|
1366
|
-
var _a, _b, _c, _d;
|
|
1366
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1367
1367
|
const response = event.response;
|
|
1368
|
-
return (
|
|
1368
|
+
return ((_f = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.txHash) !== null && _a !== void 0 ? _a : response === null || response === void 0 ? void 0 : response.pushTxHash) !== null && _b !== void 0 ? _b : response === null || response === void 0 ? void 0 : response.rootTxHash) !== null && _c !== void 0 ? _c : (_e = (_d = response === null || response === void 0 ? void 0 : response.response) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.hash) !== null && _f !== void 0 ? _f : '');
|
|
1369
1369
|
}
|
|
1370
1370
|
function withMultihopRootProgressMapping(ctx, run) {
|
|
1371
1371
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1534,7 +1534,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1534
1534
|
hops: hopInfos,
|
|
1535
1535
|
hopCount: hops.length,
|
|
1536
1536
|
waitForAll: (opts) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1537
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1537
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1538
1538
|
const { pollingIntervalMs = 10000, timeout = 300000, progressHook: cascadeProgressHook, eventHook = defaultEventHook, } = opts || {};
|
|
1539
1539
|
const startTime = Date.now();
|
|
1540
1540
|
// Per-hop progress emission. Fans out cascade markers to BOTH the
|
|
@@ -1576,20 +1576,26 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1576
1576
|
return; // skip after final hop — 999-01 takes over
|
|
1577
1577
|
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_002_99_99](n, totalHops));
|
|
1578
1578
|
};
|
|
1579
|
+
const currentFinalTxHash = () => {
|
|
1580
|
+
var _a, _b;
|
|
1581
|
+
return (_b = (_a = [...hopInfos]
|
|
1582
|
+
.reverse()
|
|
1583
|
+
.find((hop) => hop.status === 'confirmed' && hop.txHash)) === null || _a === void 0 ? void 0 : _a.txHash) !== null && _b !== void 0 ? _b : response.hash;
|
|
1584
|
+
};
|
|
1579
1585
|
const emitCascadeSuccess = () => {
|
|
1580
1586
|
if (!isMulti)
|
|
1581
1587
|
return;
|
|
1582
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01](totalHops));
|
|
1588
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_01](totalHops, currentFinalTxHash()));
|
|
1583
1589
|
};
|
|
1584
|
-
const emitCascadeFailed = (failedIdx0, errMsg) => {
|
|
1590
|
+
const emitCascadeFailed = (failedIdx0, errMsg, txHash, pushTxHash) => {
|
|
1585
1591
|
if (!isMulti)
|
|
1586
1592
|
return;
|
|
1587
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02](failedIdx0 + 1, totalHops, errMsg));
|
|
1593
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_02](failedIdx0 + 1, totalHops, errMsg, txHash, pushTxHash));
|
|
1588
1594
|
};
|
|
1589
|
-
const emitCascadeTimeout = (failedIdx0) => {
|
|
1595
|
+
const emitCascadeTimeout = (failedIdx0, txHash, pushTxHash) => {
|
|
1590
1596
|
if (!isMulti)
|
|
1591
1597
|
return;
|
|
1592
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03](failedIdx0 + 1, totalHops));
|
|
1598
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_999_03](failedIdx0 + 1, totalHops, txHash, pushTxHash));
|
|
1593
1599
|
};
|
|
1594
1600
|
const emitRouteIntermediateComplete = (hop, txHash) => {
|
|
1595
1601
|
var _a;
|
|
@@ -1612,10 +1618,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1612
1618
|
}
|
|
1613
1619
|
};
|
|
1614
1620
|
const buildCompletionResult = (success, failedAt) => {
|
|
1615
|
-
|
|
1616
|
-
const finalTxHash = (_b = (_a = [...hopInfos]
|
|
1617
|
-
.reverse()
|
|
1618
|
-
.find((hop) => hop.status === 'confirmed' && hop.txHash)) === null || _a === void 0 ? void 0 : _a.txHash) !== null && _b !== void 0 ? _b : response.hash;
|
|
1621
|
+
const finalTxHash = currentFinalTxHash();
|
|
1619
1622
|
cascadeResponse.finalTxHash = finalTxHash;
|
|
1620
1623
|
return Object.assign({ success, hops: hopInfos, finalTxHash, finalTxResponse: cascadeResponse }, (failedAt !== undefined ? { failedAt } : {}));
|
|
1621
1624
|
};
|
|
@@ -1643,7 +1646,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1643
1646
|
const isAfterCeaToPush = (index) => ceaToPushIndex >= 0 && index > ceaToPushIndex;
|
|
1644
1647
|
const rootOutboundIndexByHop = buildRootOutboundIndexByHop(segments, hops);
|
|
1645
1648
|
const trackOutboundHops = (outboundHops, pushTxHash, resolvedSubTxId, outboundIndexByHop, trackingOptions) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
1646
|
-
var _a, _b, _c, _d;
|
|
1649
|
+
var _a, _b, _c, _d, _e;
|
|
1647
1650
|
if (outboundHops.length === 0)
|
|
1648
1651
|
return null;
|
|
1649
1652
|
const shouldDeferHopCompletion = (hop) => (trackingOptions === null || trackingOptions === void 0 ? void 0 : trackingOptions.deferCeaToPushCompletion) === true &&
|
|
@@ -1661,12 +1664,12 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1661
1664
|
status: 'timeout',
|
|
1662
1665
|
elapsed: Date.now() - startTime,
|
|
1663
1666
|
});
|
|
1664
|
-
emitHopEvent(hopHooks.timeout(hop.executionChain, Date.now() - startTime));
|
|
1665
|
-
emitCascadeTimeout(hop.hopIndex);
|
|
1667
|
+
emitHopEvent(hopHooks.timeout(hop.executionChain, Date.now() - startTime, pushTxHash));
|
|
1668
|
+
emitCascadeTimeout(hop.hopIndex, undefined, pushTxHash);
|
|
1666
1669
|
return buildCompletionResult(false, hop.hopIndex);
|
|
1667
1670
|
}
|
|
1668
1671
|
emitHopStart(hop.hopIndex);
|
|
1669
|
-
emitHopEvent(hopHooks.awaiting(hop.executionChain));
|
|
1672
|
+
emitHopEvent(hopHooks.awaiting(hop.executionChain, pushTxHash));
|
|
1670
1673
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1671
1674
|
hopIndex: hop.hopIndex,
|
|
1672
1675
|
route: hop.route,
|
|
@@ -1691,7 +1694,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1691
1694
|
if (event.status === 'polling' &&
|
|
1692
1695
|
lastEmittedStatus !== 'polling') {
|
|
1693
1696
|
lastEmittedStatus = 'polling';
|
|
1694
|
-
emitHopEvent(hopHooks.polling(hop.executionChain, event.elapsed));
|
|
1697
|
+
emitHopEvent(hopHooks.polling(hop.executionChain, event.elapsed, pushTxHash));
|
|
1695
1698
|
}
|
|
1696
1699
|
} }));
|
|
1697
1700
|
// `outboundDetails.externalTxHash` from waitForOutboundTx
|
|
@@ -1726,21 +1729,29 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1726
1729
|
catch (err) {
|
|
1727
1730
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1728
1731
|
const isTimeout = errMsg.startsWith('Timeout waiting for outbound transaction');
|
|
1732
|
+
const failedExternalTxHash = err === null || err === void 0 ? void 0 : err.externalTxHash;
|
|
1733
|
+
const failedDisplayTxHash = (_c = (0, helpers_1.toExternalTxHashDisplay)(hop.executionChain, failedExternalTxHash)) !== null && _c !== void 0 ? _c : failedExternalTxHash;
|
|
1729
1734
|
emitHopEvent(isTimeout
|
|
1730
|
-
? hopHooks.timeout(hop.executionChain, remainingTimeout)
|
|
1731
|
-
: hopHooks.failed(hop.executionChain, errMsg
|
|
1735
|
+
? hopHooks.timeout(hop.executionChain, remainingTimeout, pushTxHash)
|
|
1736
|
+
: hopHooks.failed(hop.executionChain, errMsg, {
|
|
1737
|
+
pushTxHash,
|
|
1738
|
+
txHash: failedDisplayTxHash,
|
|
1739
|
+
}));
|
|
1732
1740
|
if (isTimeout) {
|
|
1733
|
-
emitCascadeTimeout(hop.hopIndex);
|
|
1741
|
+
emitCascadeTimeout(hop.hopIndex, failedDisplayTxHash, pushTxHash);
|
|
1734
1742
|
}
|
|
1735
1743
|
else {
|
|
1736
|
-
emitCascadeFailed(hop.hopIndex, errMsg);
|
|
1744
|
+
emitCascadeFailed(hop.hopIndex, errMsg, failedDisplayTxHash, pushTxHash);
|
|
1737
1745
|
}
|
|
1746
|
+
if (failedDisplayTxHash)
|
|
1747
|
+
hop.txHash = failedDisplayTxHash;
|
|
1738
1748
|
hop.status = 'failed';
|
|
1739
1749
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1740
1750
|
hopIndex: hop.hopIndex,
|
|
1741
1751
|
route: hop.route,
|
|
1742
1752
|
chain: hop.executionChain,
|
|
1743
1753
|
status: 'failed',
|
|
1754
|
+
txHash: failedDisplayTxHash,
|
|
1744
1755
|
elapsed: Date.now() - startTime,
|
|
1745
1756
|
});
|
|
1746
1757
|
return buildCompletionResult(false, hop.hopIndex);
|
|
@@ -1749,7 +1760,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1749
1760
|
else {
|
|
1750
1761
|
for (const outHop of outboundHops) {
|
|
1751
1762
|
emitHopStart(outHop.hopIndex);
|
|
1752
|
-
emitHopEvent((0, progress_route_hooks_1.pickWaitHooks)(outHop.route).awaiting(outHop.executionChain));
|
|
1763
|
+
emitHopEvent((0, progress_route_hooks_1.pickWaitHooks)(outHop.route).awaiting(outHop.executionChain, pushTxHash));
|
|
1753
1764
|
}
|
|
1754
1765
|
const perHopLastStatus = new Map();
|
|
1755
1766
|
const confirmedHops = new Set();
|
|
@@ -1774,7 +1785,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1774
1785
|
const prev = perHopLastStatus.get(event.hopIndex);
|
|
1775
1786
|
if (event.status === 'polling' && prev !== 'polling') {
|
|
1776
1787
|
perHopLastStatus.set(event.hopIndex, 'polling');
|
|
1777
|
-
emitHopEvent(eventHooks.polling((_b = (_a = matchedHop === null || matchedHop === void 0 ? void 0 : matchedHop.executionChain) !== null && _a !== void 0 ? _a : event.chain) !== null && _b !== void 0 ? _b : '', Date.now() - startTime));
|
|
1788
|
+
emitHopEvent(eventHooks.polling((_b = (_a = matchedHop === null || matchedHop === void 0 ? void 0 : matchedHop.executionChain) !== null && _a !== void 0 ? _a : event.chain) !== null && _b !== void 0 ? _b : '', Date.now() - startTime, pushTxHash));
|
|
1778
1789
|
}
|
|
1779
1790
|
if (event.status === 'confirmed' &&
|
|
1780
1791
|
event.txHash &&
|
|
@@ -1799,13 +1810,16 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1799
1810
|
}
|
|
1800
1811
|
} }));
|
|
1801
1812
|
if (!allOutboundDetails.success) {
|
|
1802
|
-
const failedIdx = (
|
|
1813
|
+
const failedIdx = (_d = allOutboundDetails.failedAt) !== null && _d !== void 0 ? _d : 0;
|
|
1803
1814
|
const failedHop = outboundHops.find((h) => h.hopIndex === failedIdx);
|
|
1804
1815
|
const failMsg = failedHop
|
|
1805
1816
|
? `Outbound failed for hop ${failedIdx} on ${failedHop.executionChain}`
|
|
1806
1817
|
: `Outbound cascade failed at hop ${failedIdx}`;
|
|
1807
|
-
emitHopEvent((0, progress_route_hooks_1.pickWaitHooks)(failedHop === null || failedHop === void 0 ? void 0 : failedHop.route).failed((
|
|
1808
|
-
|
|
1818
|
+
emitHopEvent((0, progress_route_hooks_1.pickWaitHooks)(failedHop === null || failedHop === void 0 ? void 0 : failedHop.route).failed((_e = failedHop === null || failedHop === void 0 ? void 0 : failedHop.executionChain) !== null && _e !== void 0 ? _e : '', failMsg, {
|
|
1819
|
+
pushTxHash,
|
|
1820
|
+
txHash: failedHop === null || failedHop === void 0 ? void 0 : failedHop.txHash,
|
|
1821
|
+
}));
|
|
1822
|
+
emitCascadeFailed(failedIdx, failMsg, failedHop === null || failedHop === void 0 ? void 0 : failedHop.txHash, pushTxHash);
|
|
1809
1823
|
return buildCompletionResult(false, failedIdx);
|
|
1810
1824
|
}
|
|
1811
1825
|
if (trackingOptions === null || trackingOptions === void 0 ? void 0 : trackingOptions.deferCeaToPushCompletion) {
|
|
@@ -1874,15 +1888,15 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1874
1888
|
const remainingTimeout = timeout - (Date.now() - startTime);
|
|
1875
1889
|
if (remainingTimeout <= 0) {
|
|
1876
1890
|
inboundHop.status = 'failed';
|
|
1877
|
-
emitHopEvent(hopHooks.timeout(inboundHop.executionChain, Date.now() - startTime));
|
|
1878
|
-
emitCascadeTimeout(inboundHop.hopIndex);
|
|
1891
|
+
emitHopEvent(hopHooks.timeout(inboundHop.executionChain, Date.now() - startTime, response.hash));
|
|
1892
|
+
emitCascadeTimeout(inboundHop.hopIndex, undefined, response.hash);
|
|
1879
1893
|
return buildCompletionResult(false, inboundHop.hopIndex);
|
|
1880
1894
|
}
|
|
1881
1895
|
const hasTrackedSourceOutbound = Boolean(inboundHop.outboundDetails) &&
|
|
1882
1896
|
((_d = chain_1.CHAIN_INFO[inboundHop.executionChain]) === null || _d === void 0 ? void 0 : _d.vm) === enums_1.VM.EVM;
|
|
1883
1897
|
if (!hasTrackedSourceOutbound) {
|
|
1884
1898
|
emitHopStart(inboundHop.hopIndex);
|
|
1885
|
-
emitHopEvent(hopHooks.awaiting(inboundHop.executionChain));
|
|
1899
|
+
emitHopEvent(hopHooks.awaiting(inboundHop.executionChain, response.hash));
|
|
1886
1900
|
}
|
|
1887
1901
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1888
1902
|
hopIndex: inboundHop.hopIndex,
|
|
@@ -1917,7 +1931,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1917
1931
|
if (event.status === 'polling' &&
|
|
1918
1932
|
outboundLastStatus !== 'polling') {
|
|
1919
1933
|
outboundLastStatus = 'polling';
|
|
1920
|
-
emitHopEvent(hopHooks.polling(inboundHop.executionChain, event.elapsed));
|
|
1934
|
+
emitHopEvent(hopHooks.polling(inboundHop.executionChain, event.elapsed, response.hash));
|
|
1921
1935
|
}
|
|
1922
1936
|
},
|
|
1923
1937
|
});
|
|
@@ -1926,16 +1940,19 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1926
1940
|
catch (err) {
|
|
1927
1941
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1928
1942
|
const isTimeout = errMsg.startsWith('Timeout waiting for outbound transaction');
|
|
1943
|
+
const failedExternalTxHash = err === null || err === void 0 ? void 0 : err.externalTxHash;
|
|
1944
|
+
const failedDisplayTxHash = (_f = (0, helpers_1.toExternalTxHashDisplay)(inboundHop.executionChain, failedExternalTxHash)) !== null && _f !== void 0 ? _f : failedExternalTxHash;
|
|
1929
1945
|
emitHopEvent(isTimeout
|
|
1930
|
-
? hopHooks.timeout(inboundHop.executionChain, remainingTimeout)
|
|
1931
|
-
: hopHooks.failed(inboundHop.executionChain, errMsg
|
|
1946
|
+
? hopHooks.timeout(inboundHop.executionChain, remainingTimeout, response.hash)
|
|
1947
|
+
: hopHooks.failed(inboundHop.executionChain, errMsg, {
|
|
1948
|
+
pushTxHash: response.hash,
|
|
1949
|
+
txHash: failedDisplayTxHash,
|
|
1950
|
+
}));
|
|
1932
1951
|
if (isTimeout)
|
|
1933
|
-
emitCascadeTimeout(inboundHop.hopIndex);
|
|
1952
|
+
emitCascadeTimeout(inboundHop.hopIndex, failedDisplayTxHash, response.hash);
|
|
1934
1953
|
else
|
|
1935
|
-
emitCascadeFailed(inboundHop.hopIndex, errMsg);
|
|
1954
|
+
emitCascadeFailed(inboundHop.hopIndex, errMsg, failedDisplayTxHash, response.hash);
|
|
1936
1955
|
inboundHop.status = 'failed';
|
|
1937
|
-
const failedExternalTxHash = err === null || err === void 0 ? void 0 : err.externalTxHash;
|
|
1938
|
-
const failedDisplayTxHash = (_f = (0, helpers_1.toExternalTxHashDisplay)(inboundHop.executionChain, failedExternalTxHash)) !== null && _f !== void 0 ? _f : failedExternalTxHash;
|
|
1939
1956
|
if (failedDisplayTxHash)
|
|
1940
1957
|
inboundHop.txHash = failedDisplayTxHash;
|
|
1941
1958
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
@@ -1952,7 +1969,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1952
1969
|
inboundHop.outboundDetails = Object.assign(Object.assign({}, sourceOutboundDetails), { externalTxHash: displayExternalTxHash });
|
|
1953
1970
|
inboundHop.txHash = displayExternalTxHash;
|
|
1954
1971
|
emitHopEvent(hopHooks.success(inboundHop.outboundDetails));
|
|
1955
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01](inboundHop.executionChain));
|
|
1972
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_01](inboundHop.executionChain, response.hash));
|
|
1956
1973
|
let inboundLastStatus;
|
|
1957
1974
|
const inboundRemainingTimeout = timeout - (Date.now() - startTime);
|
|
1958
1975
|
try {
|
|
@@ -1964,7 +1981,7 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1964
1981
|
if (event.status === 'polling' &&
|
|
1965
1982
|
inboundLastStatus !== 'polling') {
|
|
1966
1983
|
inboundLastStatus = 'polling';
|
|
1967
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02](inboundHop.executionChain, event.elapsedMs));
|
|
1984
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_310_02](inboundHop.executionChain, event.elapsedMs, response.hash));
|
|
1968
1985
|
}
|
|
1969
1986
|
},
|
|
1970
1987
|
});
|
|
@@ -1973,12 +1990,12 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1973
1990
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1974
1991
|
const isTimeout = err instanceof inbound_tracker_1.InboundTimeoutError;
|
|
1975
1992
|
emitHopEvent(isTimeout
|
|
1976
|
-
? progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03](inboundHop.executionChain, inboundRemainingTimeout, 'inbound')
|
|
1977
|
-
: progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02](errMsg, 'inbound', inboundHop.executionChain));
|
|
1993
|
+
? progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_03](inboundHop.executionChain, inboundRemainingTimeout, 'inbound', response.hash)
|
|
1994
|
+
: progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02](errMsg, 'inbound', inboundHop.executionChain, undefined, response.hash));
|
|
1978
1995
|
if (isTimeout)
|
|
1979
|
-
emitCascadeTimeout(inboundHop.hopIndex);
|
|
1996
|
+
emitCascadeTimeout(inboundHop.hopIndex, undefined, response.hash);
|
|
1980
1997
|
else
|
|
1981
|
-
emitCascadeFailed(inboundHop.hopIndex, errMsg);
|
|
1998
|
+
emitCascadeFailed(inboundHop.hopIndex, errMsg, undefined, response.hash);
|
|
1982
1999
|
inboundHop.status = 'failed';
|
|
1983
2000
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
1984
2001
|
hopIndex: inboundHop.hopIndex,
|
|
@@ -1994,8 +2011,8 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
1994
2011
|
inboundHop.status = 'failed';
|
|
1995
2012
|
inboundHop.txHash =
|
|
1996
2013
|
childInbound.pushTxHash || displayExternalTxHash;
|
|
1997
|
-
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02](failMsg, 'inbound', inboundHop.executionChain));
|
|
1998
|
-
emitCascadeFailed(inboundHop.hopIndex, failMsg);
|
|
2014
|
+
emitHopEvent(progress_hook_1.default[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_399_02](failMsg, 'inbound', inboundHop.executionChain, undefined, response.hash, childInbound.pushTxHash || undefined));
|
|
2015
|
+
emitCascadeFailed(inboundHop.hopIndex, failMsg, childInbound.pushTxHash || undefined, response.hash);
|
|
1999
2016
|
cascadeProgressHook === null || cascadeProgressHook === void 0 ? void 0 : cascadeProgressHook({
|
|
2000
2017
|
hopIndex: inboundHop.hopIndex,
|
|
2001
2018
|
route: inboundHop.route,
|
|
@@ -2056,12 +2073,13 @@ function createCascadedBuilder(ctx, preparedTxs, callbacks, defaultEventHook, op
|
|
|
2056
2073
|
const failedIdx = hopInfos.findIndex((h) => h.status !== 'confirmed');
|
|
2057
2074
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
2058
2075
|
const failedAt = failedIdx >= 0 ? failedIdx : 0;
|
|
2076
|
+
const failedTxHash = (_k = hopInfos[failedAt]) === null || _k === void 0 ? void 0 : _k.txHash;
|
|
2059
2077
|
const isTimeout = errMsg.startsWith('Timeout');
|
|
2060
2078
|
if (isTimeout) {
|
|
2061
|
-
emitCascadeTimeout(failedAt);
|
|
2079
|
+
emitCascadeTimeout(failedAt, failedTxHash, response.hash);
|
|
2062
2080
|
}
|
|
2063
2081
|
else {
|
|
2064
|
-
emitCascadeFailed(failedAt, errMsg);
|
|
2082
|
+
emitCascadeFailed(failedAt, errMsg, failedTxHash, response.hash);
|
|
2065
2083
|
}
|
|
2066
2084
|
return buildCompletionResult(false, failedAt);
|
|
2067
2085
|
}
|
|
@@ -51,10 +51,10 @@ function waitForEvmReceipt(evmClient, txHash, timeoutMs) {
|
|
|
51
51
|
function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmations, timeoutMs) {
|
|
52
52
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
if (confirmations <= 0) {
|
|
54
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0);
|
|
54
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txHash);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations);
|
|
57
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txHash);
|
|
58
58
|
const start = Date.now();
|
|
59
59
|
const receipt = yield waitForEvmReceipt(evmClient, txHash, timeoutMs);
|
|
60
60
|
const targetBlock = receipt.blockNumber + BigInt(confirmations);
|
|
@@ -64,7 +64,7 @@ function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmati
|
|
|
64
64
|
const currentBlock = yield evmClient.publicClient.getBlockNumber();
|
|
65
65
|
if (currentBlock >= targetBlock) {
|
|
66
66
|
if (lastEmitted < confirmations) {
|
|
67
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations);
|
|
67
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txHash);
|
|
68
68
|
}
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -73,7 +73,7 @@ function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmati
|
|
|
73
73
|
if (completed > lastEmitted) {
|
|
74
74
|
(0, context_2.fireProgressHook)(ctx, completed >= confirmations
|
|
75
75
|
? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02
|
|
76
|
-
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, completed, confirmations);
|
|
76
|
+
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, completed, confirmations, txHash);
|
|
77
77
|
lastEmitted = completed;
|
|
78
78
|
if (completed >= confirmations)
|
|
79
79
|
return;
|
|
@@ -88,10 +88,10 @@ function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmati
|
|
|
88
88
|
function waitForSvmConfirmationsWithCountdown(ctx, svmClient, txSignature, confirmations, timeoutMs) {
|
|
89
89
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
if (confirmations <= 0) {
|
|
91
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0);
|
|
91
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, 0, 0, txSignature);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations);
|
|
94
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03, confirmations, txSignature);
|
|
95
95
|
const start = Date.now();
|
|
96
96
|
let lastConfirmed = 0;
|
|
97
97
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -113,12 +113,12 @@ function waitForSvmConfirmationsWithCountdown(ctx, svmClient, txSignature, confi
|
|
|
113
113
|
const clamped = currentConfirms >= confirmations ? confirmations : currentConfirms;
|
|
114
114
|
(0, context_2.fireProgressHook)(ctx, clamped >= confirmations
|
|
115
115
|
? progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02
|
|
116
|
-
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, Math.max(1, clamped), confirmations);
|
|
116
|
+
: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_01, Math.max(1, clamped), confirmations, txSignature);
|
|
117
117
|
lastConfirmed = currentConfirms;
|
|
118
118
|
}
|
|
119
119
|
if (hasEnoughConfirmations || isFinalized) {
|
|
120
120
|
if (lastConfirmed < confirmations) {
|
|
121
|
-
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations);
|
|
121
|
+
(0, context_2.fireProgressHook)(ctx, progress_hook_types_1.PROGRESS_HOOK.SEND_TX_106_03_02, confirmations, confirmations, txSignature);
|
|
122
122
|
}
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -41,6 +41,7 @@ export type DecodedRevertUnknown = {
|
|
|
41
41
|
selector: `0x${string}`;
|
|
42
42
|
};
|
|
43
43
|
export type DecodedRevert = DecodedRevertCustom | DecodedRevertString | DecodedRevertUnknown;
|
|
44
|
+
export declare function formatDecodedRevertForUser(decoded: DecodedRevert): string;
|
|
44
45
|
/**
|
|
45
46
|
* Extracts the first hex blob after `ret ` from a Cosmos tx error message,
|
|
46
47
|
* pulls the 4-byte selector, and looks it up. Returns `null` when no blob
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ERROR_STRING_SELECTOR = exports.KNOWN_ERROR_SELECTORS = void 0;
|
|
19
|
+
exports.formatDecodedRevertForUser = formatDecodedRevertForUser;
|
|
19
20
|
exports.decodeRevert = decodeRevert;
|
|
20
21
|
exports.KNOWN_ERROR_SELECTORS = {
|
|
21
22
|
'0xacfdb444': {
|
|
@@ -57,6 +58,15 @@ exports.KNOWN_ERROR_SELECTORS = {
|
|
|
57
58
|
exports.ERROR_STRING_SELECTOR = '0x08c379a0';
|
|
58
59
|
/** Hard cap on the decoded string length; protects against malformed data. */
|
|
59
60
|
const MAX_DECODED_STRING_LEN = 1024;
|
|
61
|
+
function formatDecodedRevertForUser(decoded) {
|
|
62
|
+
if (decoded.kind === 'custom') {
|
|
63
|
+
return `${decoded.name}: ${decoded.hint}`;
|
|
64
|
+
}
|
|
65
|
+
if (decoded.kind === 'string') {
|
|
66
|
+
return `Reverted with Error("${decoded.decoded}")`;
|
|
67
|
+
}
|
|
68
|
+
return `Unknown EVM revert selector ${decoded.selector}`;
|
|
69
|
+
}
|
|
60
70
|
/**
|
|
61
71
|
* Extracts the first hex blob after `ret ` from a Cosmos tx error message,
|
|
62
72
|
* pulls the 4-byte selector, and looks it up. Returns `null` when no blob
|
|
@@ -29,7 +29,7 @@ const formatters_1 = require("../../formatters");
|
|
|
29
29
|
*/
|
|
30
30
|
class PushChainExecutionError extends Error {
|
|
31
31
|
constructor(message, opts = {}) {
|
|
32
|
-
super((0, formatters_1.
|
|
32
|
+
super((0, formatters_1.normalizePublicErrorMessage)(message));
|
|
33
33
|
this.code = 'PUSH_CHAIN_EXECUTION_FAILED';
|
|
34
34
|
this.name = 'PushChainExecutionError';
|
|
35
35
|
this.gatewayTxHash = opts.gatewayTxHash;
|