@pushchain/core 5.1.11 → 5.1.13

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushchain/core",
3
- "version": "5.1.11",
3
+ "version": "5.1.13",
4
4
  "homepage": "https://push.org",
5
5
  "keywords": [
6
6
  "pushchain",
@@ -89,7 +89,7 @@ function prepareTransaction(ctx, params, callbacks) {
89
89
  // ============================================================================
90
90
  function buildHopDescriptor(ctx, params, route, ueaAddress) {
91
91
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
92
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
93
93
  // Pass 0 when user omits gasLimit → contract uses per-chain baseGasLimitByChainNamespace
94
94
  const gasLimit = (_a = params.gasLimit) !== null && _a !== void 0 ? _a : BigInt(0);
95
95
  const routeStr = route;
@@ -227,10 +227,39 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
227
227
  });
228
228
  }
229
229
  }
230
+ else if ((_f = params.funds) === null || _f === void 0 ? void 0 : _f.amount) {
231
+ // Funds-only transfer (no data, no value). Without this branch the
232
+ // CEA multicall is empty and relayed funds stay in the CEA instead
233
+ // of reaching the caller's recipient.
234
+ const token = params.funds.token;
235
+ if (token) {
236
+ if (token.mechanism === 'native') {
237
+ if (target.address.toLowerCase() !== ceaAddress.toLowerCase()) {
238
+ ceaMulticalls.push({
239
+ to: target.address,
240
+ value: params.funds.amount,
241
+ data: '0x',
242
+ });
243
+ }
244
+ }
245
+ else {
246
+ const erc20Transfer = (0, viem_1.encodeFunctionData)({
247
+ abi: erc20_evm_1.ERC20_EVM,
248
+ functionName: 'transfer',
249
+ args: [target.address, params.funds.amount],
250
+ });
251
+ ceaMulticalls.push({
252
+ to: token.address,
253
+ value: BigInt(0),
254
+ data: erc20Transfer,
255
+ });
256
+ }
257
+ }
258
+ }
230
259
  // Determine PRC-20 token and burn amount
231
260
  let prc20Token = selectors_1.ZERO_ADDRESS;
232
261
  let burnAmount = BigInt(0);
233
- if ((_f = params.funds) === null || _f === void 0 ? void 0 : _f.amount) {
262
+ if ((_g = params.funds) === null || _g === void 0 ? void 0 : _g.amount) {
234
263
  const token = params.funds.token;
235
264
  if (token) {
236
265
  prc20Token = push_chain_1.PushChain.utils.tokens.getPRC20Address(token).address;
@@ -288,7 +317,7 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
288
317
  Buffer.from(ceaPda.toBytes()).toString('hex'));
289
318
  let amount = BigInt(0);
290
319
  let prc20Token;
291
- if (((_g = params.funds) === null || _g === void 0 ? void 0 : _g.amount) && params.funds.amount > BigInt(0)) {
320
+ if (((_h = params.funds) === null || _h === void 0 ? void 0 : _h.amount) && params.funds.amount > BigInt(0)) {
292
321
  amount = params.funds.amount;
293
322
  const token = params.funds.token;
294
323
  if (token && token.address) {
@@ -319,14 +348,14 @@ function buildHopDescriptor(ctx, params, route, ueaAddress) {
319
348
  gasFee,
320
349
  sizing });
321
350
  }
322
- const { cea: ceaAddress } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (_h = ctx.rpcUrls[sourceChain]) === null || _h === void 0 ? void 0 : _h[0]);
351
+ const { cea: ceaAddress } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (_j = ctx.rpcUrls[sourceChain]) === null || _j === void 0 ? void 0 : _j[0]);
323
352
  // CEA auto-deploys on-chain: Vault.finalizeUniversalTx calls CEAFactory.deployCEA()
324
353
  // if CEA doesn't exist yet. No SDK-side blocking needed.
325
354
  // Determine token/amount for the inbound
326
355
  let tokenAddress = selectors_1.ZERO_ADDRESS;
327
356
  let amount = BigInt(0);
328
357
  let nativeValue = BigInt(0);
329
- if ((_j = params.funds) === null || _j === void 0 ? void 0 : _j.amount) {
358
+ if ((_k = params.funds) === null || _k === void 0 ? void 0 : _k.amount) {
330
359
  const token = params.funds.token;
331
360
  if (token) {
332
361
  if (token.mechanism === 'native') {
@@ -50,7 +50,7 @@ function waitForEvmConfirmationsWithCountdown(ctx, evmClient, txHash, confirmati
50
50
  if (Date.now() - start > timeoutMs) {
51
51
  throw new Error(`Timeout: transaction ${txHash} not confirmed with ${confirmations} confirmations within ${timeoutMs} ms`);
52
52
  }
53
- yield new Promise((r) => setTimeout(r, 12000));
53
+ yield new Promise((r) => setTimeout(r, 3000));
54
54
  }
55
55
  });
56
56
  }
@@ -127,7 +127,7 @@ function waitForLockerFeeConfirmation(ctx, txHashBytes) {
127
127
  if (Date.now() - start > timeout) {
128
128
  throw new Error(`Timeout: fee-lock tx ${txHash} not confirmed with ${fastConfirmations} confirmations within ${timeout} ms`);
129
129
  }
130
- yield new Promise((r) => setTimeout(r, 12000));
130
+ yield new Promise((r) => setTimeout(r, 3000));
131
131
  }
132
132
  }
133
133
  case enums_1.VM.SVM: {
@@ -8,9 +8,9 @@ import { CHAIN } from '../../constants/enums';
8
8
  import type { CascadeHopInfo, WaitForOutboundOptions, OutboundTxDetails, TransactionRouteType } from '../orchestrator.types';
9
9
  import type { OrchestratorContext } from './context';
10
10
  /** Initial wait before the first poll (ms). */
11
- export declare const OUTBOUND_INITIAL_WAIT_MS = 20000;
11
+ export declare const OUTBOUND_INITIAL_WAIT_MS = 15000;
12
12
  /** Interval between consecutive polls (ms). */
13
- export declare const OUTBOUND_POLL_INTERVAL_MS = 5000;
13
+ export declare const OUTBOUND_POLL_INTERVAL_MS = 3000;
14
14
  /** Maximum total timeout for the outbound polling loop (ms). */
15
15
  export declare const OUTBOUND_MAX_TIMEOUT_MS = 180000;
16
16
  /** Maximum total timeout for the R3 inbound round-trip polling loop (ms). */
@@ -49,7 +49,7 @@ export declare class OutboundFailedError extends Error {
49
49
  * @internal Used by .wait() for outbound routes - not part of public API.
50
50
  * Uses polling with configurable initial wait, interval, and timeout.
51
51
  *
52
- * Default strategy: 30s initial wait, then poll every 5s, 120s total timeout.
52
+ * Default strategy: 15s initial wait, then poll every 3s, 180s total timeout.
53
53
  *
54
54
  * @param ctx - Orchestrator context
55
55
  * @param pushChainTxHash - The Push Chain transaction hash
@@ -23,9 +23,9 @@ const outbound_tracker_1 = require("./outbound-tracker");
23
23
  // Outbound sync configuration constants
24
24
  // ============================================================================
25
25
  /** Initial wait before the first poll (ms). */
26
- exports.OUTBOUND_INITIAL_WAIT_MS = 20000; // 20s
26
+ exports.OUTBOUND_INITIAL_WAIT_MS = 15000; // 15s
27
27
  /** Interval between consecutive polls (ms). */
28
- exports.OUTBOUND_POLL_INTERVAL_MS = 5000; // 5s
28
+ exports.OUTBOUND_POLL_INTERVAL_MS = 3000; // 3s
29
29
  /** Maximum total timeout for the outbound polling loop (ms). */
30
30
  exports.OUTBOUND_MAX_TIMEOUT_MS = 180000; // 180s (3 min)
31
31
  /** Maximum total timeout for the R3 inbound round-trip polling loop (ms). */
@@ -132,7 +132,7 @@ function verifyExternalEvmReceipt(ctx, destinationChain, externalTxHash) {
132
132
  * @internal Used by .wait() for outbound routes - not part of public API.
133
133
  * Uses polling with configurable initial wait, interval, and timeout.
134
134
  *
135
- * Default strategy: 30s initial wait, then poll every 5s, 120s total timeout.
135
+ * Default strategy: 15s initial wait, then poll every 3s, 180s total timeout.
136
136
  *
137
137
  * @param ctx - Orchestrator context
138
138
  * @param pushChainTxHash - The Push Chain transaction hash
@@ -116,7 +116,7 @@ function resolveR2Prc20TokenSvm(params, targetChain, pushNetwork, hasSvmExecute)
116
116
  * multicall when the target IS the CEA (avoids a CEA._handleMulticall revert).
117
117
  */
118
118
  function buildR2CeaPayloadEvm(params, ceaAddress, targetAddress) {
119
- var _a, _b;
119
+ var _a, _b, _c;
120
120
  if (params.migration) {
121
121
  return (0, payload_builders_1.buildMigrationPayload)();
122
122
  }
@@ -164,6 +164,38 @@ function buildR2CeaPayloadEvm(params, ceaAddress, targetAddress) {
164
164
  });
165
165
  }
166
166
  }
167
+ else if ((_c = params.funds) === null || _c === void 0 ? void 0 : _c.amount) {
168
+ // Funds-only transfer (no data, no value). Without this branch the CEA
169
+ // multicall is empty and the relayed funds sit in the CEA instead of
170
+ // being forwarded to the caller's recipient.
171
+ const token = params.funds.token;
172
+ if (token) {
173
+ if (token.mechanism === 'native') {
174
+ // Native funds (e.g. pETH → ETH): forward value to the recipient.
175
+ // Self-CEA is skipped — the gateway already deposits into the CEA.
176
+ if (targetAddress.toLowerCase() !== ceaAddress.toLowerCase()) {
177
+ ceaMulticalls.push({
178
+ to: targetAddress,
179
+ value: params.funds.amount,
180
+ data: '0x',
181
+ });
182
+ }
183
+ }
184
+ else {
185
+ // ERC-20 funds: forward via ERC20.transfer from the CEA.
186
+ const erc20Transfer = (0, viem_1.encodeFunctionData)({
187
+ abi: erc20_evm_1.ERC20_EVM,
188
+ functionName: 'transfer',
189
+ args: [targetAddress, params.funds.amount],
190
+ });
191
+ ceaMulticalls.push({
192
+ to: token.address,
193
+ value: BigInt(0),
194
+ data: erc20Transfer,
195
+ });
196
+ }
197
+ }
198
+ }
167
199
  return (0, payload_builders_1.buildCeaMulticallPayload)(ceaMulticalls);
168
200
  }
169
201
  const SIZER_HOOK_BY_ROUTE = {
@@ -8,12 +8,19 @@ const withTimestamp = (fn) => {
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  return (...args) => (Object.assign(Object.assign({}, fn(...args)), { timestamp: new Date().toISOString() }));
10
10
  };
11
+ const ACRONYMS = new Set(['BNB']);
12
+ const toTitleCase = (key) => key
13
+ .split('_')
14
+ .map((part) => ACRONYMS.has(part)
15
+ ? part
16
+ : part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
17
+ .join(' ');
11
18
  const friendlyChain = (chainOrNs) => {
12
- var _a;
13
19
  if (!chainOrNs)
14
20
  return 'chain';
15
21
  const asString = String(chainOrNs);
16
- return (_a = utils_1.Utils.chains.getChainName(asString)) !== null && _a !== void 0 ? _a : asString;
22
+ const key = utils_1.Utils.chains.getChainName(asString);
23
+ return key ? toTitleCase(key) : asString;
17
24
  };
18
25
  /**
19
26
  * Classify a sign-time error as either a true wallet user-decline
@@ -82,9 +82,6 @@ class PushChain {
82
82
  return orchestrator.execute.bind(orchestrator)(...args);
83
83
  },
84
84
  prepareTransaction: (params) => {
85
- if (this.isReadMode) {
86
- throw new Error('Read only mode cannot call prepareTransaction function');
87
- }
88
85
  return orchestrator.prepareTransaction.bind(orchestrator)(params);
89
86
  },
90
87
  executeTransactions: (txs) => tslib_1.__awaiter(this, void 0, void 0, function* () {