@pushchain/core 6.0.10 → 6.0.11
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/package.json
CHANGED
|
@@ -925,6 +925,21 @@ function composeCascadeDetailed(ctx, segments, ueaAddress, ueaBalance, ueaNonce,
|
|
|
925
925
|
}
|
|
926
926
|
for (let segIdxLoop = segments.length - 1; segIdxLoop >= 0; segIdxLoop--) {
|
|
927
927
|
const segment = segments[segIdxLoop];
|
|
928
|
+
const gasPriceForOutboundRequest = (chainForLog) => {
|
|
929
|
+
var _a;
|
|
930
|
+
const quotedGasPrice = (_a = segment.gasPrice) !== null && _a !== void 0 ? _a : BigInt(0);
|
|
931
|
+
// If this outbound is being accumulated into an earlier Route 3
|
|
932
|
+
// inbound payload, it may execute minutes after the quote. Keep
|
|
933
|
+
// immediate outbounds pinned to the quote, but let delayed nested
|
|
934
|
+
// outbounds resolve the live base gas price at execution time.
|
|
935
|
+
const executesAfterInbound = segments
|
|
936
|
+
.slice(0, segIdxLoop)
|
|
937
|
+
.some((s) => s.type === 'INBOUND_FROM_CEA');
|
|
938
|
+
if (executesAfterInbound && quotedGasPrice > BigInt(0)) {
|
|
939
|
+
(0, context_1.printLog)(ctx, `composeCascade — delayed outbound to ${chainForLog !== null && chainForLog !== void 0 ? chainForLog : 'unknown chain'}: using gasPrice=0 instead of quoted ${quotedGasPrice} so UGPC resolves the live base price at execution time`);
|
|
940
|
+
}
|
|
941
|
+
return executesAfterInbound ? BigInt(0) : quotedGasPrice;
|
|
942
|
+
};
|
|
928
943
|
switch (segment.type) {
|
|
929
944
|
case 'PUSH_EXECUTION': {
|
|
930
945
|
// Prepend Push Chain multicalls to accumulated
|
|
@@ -1026,7 +1041,7 @@ function composeCascadeDetailed(ctx, segments, ueaAddress, ueaBalance, ueaNonce,
|
|
|
1026
1041
|
}
|
|
1027
1042
|
}
|
|
1028
1043
|
// Build outbound request
|
|
1029
|
-
const outboundReq = (0, payload_builders_1.buildOutboundRequest)(targetForOutbound, segment.prc20Token || selectors_1.ZERO_ADDRESS, segment.totalBurnAmount || BigInt(0), (_e = segment.gasLimit) !== null && _e !== void 0 ? _e : BigInt(0), outboundPayload, ueaAddress, (_f = segment.maxPCForGas) !== null && _f !== void 0 ? _f : BigInt(0));
|
|
1044
|
+
const outboundReq = (0, payload_builders_1.buildOutboundRequest)(targetForOutbound, segment.prc20Token || selectors_1.ZERO_ADDRESS, segment.totalBurnAmount || BigInt(0), (_e = segment.gasLimit) !== null && _e !== void 0 ? _e : BigInt(0), outboundPayload, ueaAddress, (_f = segment.maxPCForGas) !== null && _f !== void 0 ? _f : BigInt(0), gasPriceForOutboundRequest(firstHop === null || firstHop === void 0 ? void 0 : firstHop.targetChain));
|
|
1030
1045
|
// Build approval + outbound multicalls
|
|
1031
1046
|
const segGasFee = segment.gasFee || BigInt(0);
|
|
1032
1047
|
const svmOverride = svmNativeValueBySegment.get(segment);
|
|
@@ -1158,7 +1173,7 @@ function composeCascadeDetailed(ctx, segments, ueaAddress, ueaBalance, ueaNonce,
|
|
|
1158
1173
|
});
|
|
1159
1174
|
const svmBurnAmount = segment.totalBurnAmount || BigInt(0);
|
|
1160
1175
|
const outboundReq = (0, payload_builders_1.buildOutboundRequest)(gatewayProgramHex, segment.prc20Token ||
|
|
1161
|
-
(0, helpers_1.getNativePRC20ForChain)(sourceChain, ctx.pushNetwork), svmBurnAmount, (_l = segment.gasLimit) !== null && _l !== void 0 ? _l : BigInt(0), svmPayload, ueaAddress, (_m = segment.maxPCForGas) !== null && _m !== void 0 ? _m : BigInt(0));
|
|
1176
|
+
(0, helpers_1.getNativePRC20ForChain)(sourceChain, ctx.pushNetwork), svmBurnAmount, (_l = segment.gasLimit) !== null && _l !== void 0 ? _l : BigInt(0), svmPayload, ueaAddress, (_m = segment.maxPCForGas) !== null && _m !== void 0 ? _m : BigInt(0), gasPriceForOutboundRequest(sourceChain));
|
|
1162
1177
|
const inboundGasFee = segment.gasFee || BigInt(0);
|
|
1163
1178
|
let svmInboundFallback;
|
|
1164
1179
|
if (effectiveUeaBalance > BigInt(0)) {
|
|
@@ -1245,7 +1260,7 @@ function composeCascadeDetailed(ctx, segments, ueaAddress, ueaBalance, ueaNonce,
|
|
|
1245
1260
|
? segment.gasLimit
|
|
1246
1261
|
: selectors_1.DEFAULT_CEA_TO_PUSH_GAS_LIMIT;
|
|
1247
1262
|
const outboundReq = (0, payload_builders_1.buildOutboundRequest)(ceaAddress, segment.prc20Token ||
|
|
1248
|
-
(0, helpers_1.getNativePRC20ForChain)(sourceChain, ctx.pushNetwork), segment.totalBurnAmount || BigInt(0), effectiveGasLimit, ceaPayload, ueaAddress, (_q = segment.maxPCForGas) !== null && _q !== void 0 ? _q : BigInt(0));
|
|
1263
|
+
(0, helpers_1.getNativePRC20ForChain)(sourceChain, ctx.pushNetwork), segment.totalBurnAmount || BigInt(0), effectiveGasLimit, ceaPayload, ueaAddress, (_q = segment.maxPCForGas) !== null && _q !== void 0 ? _q : BigInt(0), gasPriceForOutboundRequest(sourceChain));
|
|
1249
1264
|
const inboundGasFee = segment.gasFee || BigInt(0);
|
|
1250
1265
|
let evmInboundFallback;
|
|
1251
1266
|
if (effectiveUeaBalance > BigInt(0)) {
|
|
@@ -112,7 +112,7 @@ function findChildUtxIdFromExternalTx(ctx, externalTxHash, sourceChain) {
|
|
|
112
112
|
*/
|
|
113
113
|
function waitForInboundPushTx(ctx_1, outboundExternalTxHash_1, sourceChain_1) {
|
|
114
114
|
return tslib_1.__awaiter(this, arguments, void 0, function* (ctx, outboundExternalTxHash, sourceChain, opts = {}) {
|
|
115
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
116
116
|
const initialWaitMs = (_a = opts.initialWaitMs) !== null && _a !== void 0 ? _a : 30000;
|
|
117
117
|
const pollingIntervalMs = (_b = opts.pollingIntervalMs) !== null && _b !== void 0 ? _b : 5000;
|
|
118
118
|
const timeout = (_c = opts.timeout) !== null && _c !== void 0 ? _c : 300000;
|
|
@@ -183,6 +183,10 @@ function waitForInboundPushTx(ctx_1, outboundExternalTxHash_1, sourceChain_1) {
|
|
|
183
183
|
pushTxHash = utx.pcTx[0].txHash;
|
|
184
184
|
}
|
|
185
185
|
(0, context_1.printLog)(ctx, `[waitForInboundPushTx] Poll #${pollCount} utx-status | status: ${status} | pcTx[0].txHash: '${pushTxHash !== null && pushTxHash !== void 0 ? pushTxHash : ''}' | pcTx len: ${(_j = (_h = utx === null || utx === void 0 ? void 0 : utx.pcTx) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0}`);
|
|
186
|
+
const failedPcTx = (_k = utx === null || utx === void 0 ? void 0 : utx.pcTx) === null || _k === void 0 ? void 0 : _k.find((pcTx) => {
|
|
187
|
+
const pcTxStatus = String(pcTx.status || '').toUpperCase();
|
|
188
|
+
return pcTxStatus === 'FAILED' || Boolean(pcTx.errorMsg);
|
|
189
|
+
});
|
|
186
190
|
if (TERMINAL_SUCCESS_STATUSES.has(status)) {
|
|
187
191
|
// Wait one more poll cycle if pcTx hasn't populated yet — the
|
|
188
192
|
// indexer occasionally flips status before the pcTx hash is queryable.
|
|
@@ -206,8 +210,8 @@ function waitForInboundPushTx(ctx_1, outboundExternalTxHash_1, sourceChain_1) {
|
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
212
|
else if (TERMINAL_FAILURE_STATUSES.has(status)) {
|
|
209
|
-
const errMsg = (
|
|
210
|
-
? (0, formatters_1.normalizePcInsufficientFundsError)(
|
|
213
|
+
const errMsg = (failedPcTx === null || failedPcTx === void 0 ? void 0 : failedPcTx.errorMsg)
|
|
214
|
+
? (0, formatters_1.normalizePcInsufficientFundsError)(failedPcTx.errorMsg)
|
|
211
215
|
: `inbound terminated with status ${status}`;
|
|
212
216
|
progressHook === null || progressHook === void 0 ? void 0 : progressHook({
|
|
213
217
|
status: 'failed',
|
|
@@ -224,6 +228,25 @@ function waitForInboundPushTx(ctx_1, outboundExternalTxHash_1, sourceChain_1) {
|
|
|
224
228
|
errorMessage: errMsg,
|
|
225
229
|
};
|
|
226
230
|
}
|
|
231
|
+
else if (failedPcTx) {
|
|
232
|
+
const errMsg = failedPcTx.errorMsg
|
|
233
|
+
? (0, formatters_1.normalizePcInsufficientFundsError)(failedPcTx.errorMsg)
|
|
234
|
+
: `inbound Push tx failed while universalStatus=${status}`;
|
|
235
|
+
progressHook === null || progressHook === void 0 ? void 0 : progressHook({
|
|
236
|
+
status: 'failed',
|
|
237
|
+
elapsedMs: elapsed(),
|
|
238
|
+
childUtxId,
|
|
239
|
+
pushTxHash,
|
|
240
|
+
});
|
|
241
|
+
return {
|
|
242
|
+
childUtxId,
|
|
243
|
+
pushTxHash: pushTxHash !== null && pushTxHash !== void 0 ? pushTxHash : '',
|
|
244
|
+
sourceChain,
|
|
245
|
+
outboundExternalTxHash,
|
|
246
|
+
status: 'failed',
|
|
247
|
+
errorMessage: errMsg,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
227
250
|
else if (pushTxHash) {
|
|
228
251
|
// Tiebreaker: cosmos has the Push Chain tx hash populated but the
|
|
229
252
|
// indexer hasn't transitioned universalStatus to a terminal yet.
|
|
@@ -21,6 +21,40 @@ const error_decoder_1 = require("./error-decoder");
|
|
|
21
21
|
const errors_1 = require("./errors");
|
|
22
22
|
Object.defineProperty(exports, "PushChainExecutionError", { enumerable: true, get: function () { return errors_1.PushChainExecutionError; } });
|
|
23
23
|
const formatters_1 = require("../../formatters");
|
|
24
|
+
const PUSH_TX_INDEX_TIMEOUT_MS = 30000;
|
|
25
|
+
const PUSH_TX_INDEX_POLL_MS = 1000;
|
|
26
|
+
const TX_NOT_INDEXED_RE = /not found|TransactionNotFound|TransactionReceiptNotFound|could not be found|No transaction found/i;
|
|
27
|
+
function getIndexedPushTransaction(ctx, txHash, label) {
|
|
28
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const startedAt = Date.now();
|
|
30
|
+
let receiptWaited = false;
|
|
31
|
+
let retryLogged = false;
|
|
32
|
+
// eslint-disable-next-line no-constant-condition
|
|
33
|
+
while (true) {
|
|
34
|
+
try {
|
|
35
|
+
if (!receiptWaited) {
|
|
36
|
+
yield ctx.pushClient.publicClient.waitForTransactionReceipt({
|
|
37
|
+
hash: txHash,
|
|
38
|
+
});
|
|
39
|
+
receiptWaited = true;
|
|
40
|
+
}
|
|
41
|
+
return yield ctx.pushClient.getTransaction(txHash);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const msg = (err === null || err === void 0 ? void 0 : err.shortMessage) || (err === null || err === void 0 ? void 0 : err.message) || String(err);
|
|
45
|
+
const retryable = TX_NOT_INDEXED_RE.test(msg);
|
|
46
|
+
if (!retryable || Date.now() - startedAt >= PUSH_TX_INDEX_TIMEOUT_MS) {
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
if (!retryLogged) {
|
|
50
|
+
(0, context_1.printLog)(ctx, `${label} — Push tx ${txHash} has a receipt but is not indexed yet; retrying transaction lookup`);
|
|
51
|
+
retryLogged = true;
|
|
52
|
+
}
|
|
53
|
+
yield new Promise((r) => setTimeout(r, PUSH_TX_INDEX_POLL_MS));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
24
58
|
// ============================================================================
|
|
25
59
|
// sendPushTx
|
|
26
60
|
// ============================================================================
|
|
@@ -107,7 +141,7 @@ function sendPushTx(ctx, execute, eventBuffer, transformFn) {
|
|
|
107
141
|
(0, context_1.printLog)(ctx, `sendPushTx — operation ${i + 1}/${calls.length} confirmed in block ${receipt.blockNumber}`);
|
|
108
142
|
nonce++;
|
|
109
143
|
}
|
|
110
|
-
const txResponse = yield ctx
|
|
144
|
+
const txResponse = yield getIndexedPushTransaction(ctx, lastTxHash, 'sendPushTx');
|
|
111
145
|
return yield transformFn(txResponse, eventBuffer);
|
|
112
146
|
}
|
|
113
147
|
const txHash = yield ctx.pushClient.sendTransaction({
|
|
@@ -116,7 +150,7 @@ function sendPushTx(ctx, execute, eventBuffer, transformFn) {
|
|
|
116
150
|
value: execute.value,
|
|
117
151
|
signer: ctx.universalSigner,
|
|
118
152
|
});
|
|
119
|
-
const txResponse = yield ctx
|
|
153
|
+
const txResponse = yield getIndexedPushTransaction(ctx, txHash, 'sendPushTx');
|
|
120
154
|
return yield transformFn(txResponse, eventBuffer);
|
|
121
155
|
});
|
|
122
156
|
}
|
|
@@ -275,9 +309,7 @@ function sendUniversalTx(ctx, isUEADeployed, feeLockTxHash, universalPayload, ve
|
|
|
275
309
|
if (ethTxHashes.length === 0) {
|
|
276
310
|
throw new Error('No ethereumTxHash found in transaction events');
|
|
277
311
|
}
|
|
278
|
-
const evmTxs = yield Promise.all(ethTxHashes.map((hash) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
return yield ctx.pushClient.getTransaction(hash);
|
|
280
|
-
})));
|
|
312
|
+
const evmTxs = yield Promise.all(ethTxHashes.map((hash) => tslib_1.__awaiter(this, void 0, void 0, function* () { return getIndexedPushTransaction(ctx, hash, 'sendUniversalTx'); })));
|
|
281
313
|
const responses = yield Promise.all(evmTxs.map((tx, index) => transformFn(tx, index === evmTxs.length - 1 ? eventBuffer : [])));
|
|
282
314
|
return responses;
|
|
283
315
|
});
|
|
@@ -341,7 +373,7 @@ function extractPcTxAndTransform(ctx, pushChainUniversalTx, gatewayTxHash, event
|
|
|
341
373
|
decodedError: decodedForPayload,
|
|
342
374
|
});
|
|
343
375
|
}
|
|
344
|
-
const tx = yield ctx
|
|
376
|
+
const tx = yield getIndexedPushTransaction(ctx, lastPcTransaction.txHash, label);
|
|
345
377
|
return transformFn(tx, eventBuffer);
|
|
346
378
|
});
|
|
347
379
|
}
|