@pushchain/core 5.1.4-alpha.0 → 5.1.4-alpha.10
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 +7 -8
- package/src/lib/constants/abi/factoryV1.d.ts +59 -76
- package/src/lib/constants/abi/factoryV1.js +0 -517
- package/src/lib/constants/abi/feeLocker.evm.d.ts +15 -50
- package/src/lib/constants/abi/feeLocker.evm.js +0 -385
- package/src/lib/constants/abi/index.d.ts +1 -1
- package/src/lib/constants/abi/index.js +1 -2
- package/src/lib/constants/abi/prc20.evm.d.ts +0 -53
- package/src/lib/constants/abi/prc20.evm.js +1 -42
- package/src/lib/constants/abi/uea.svm.d.ts +21 -99
- package/src/lib/constants/abi/uea.svm.js +0 -299
- package/src/lib/constants/abi/universalGatewayV0.evm.d.ts +45 -104
- package/src/lib/constants/abi/universalGatewayV0.evm.js +0 -2149
- package/src/lib/index.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.d.ts +4 -2
- package/src/lib/orchestrator/internals/cascade.js +34 -18
- package/src/lib/orchestrator/internals/execute-standard.js +5 -1
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +17 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +236 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +24 -1
- package/src/lib/orchestrator/internals/route-handlers.js +60 -62
- package/src/lib/orchestrator/orchestrator.d.ts +5 -3
- package/src/lib/orchestrator/orchestrator.js +2 -12
- package/src/lib/orchestrator/orchestrator.types.d.ts +8 -15
- package/src/lib/progress-hook/progress-hook.js +1 -1
- package/src/lib/push-chain/push-chain.d.ts +5 -6
- package/src/lib/push-chain/push-chain.js +4 -3
- package/src/lib/universal/account/account.d.ts +16 -8
- package/src/lib/universal/account/account.js +118 -73
- package/src/lib/universal/signer/signer.js +1 -1
- package/src/lib/universal/universal.types.d.ts +2 -2
- package/src/index.js.map +0 -1
- package/src/lib/cache/cache.js.map +0 -1
- package/src/lib/constants/abi/cea.evm.js.map +0 -1
- package/src/lib/constants/abi/ceaFactory.evm.js.map +0 -1
- package/src/lib/constants/abi/erc20.evm.js.map +0 -1
- package/src/lib/constants/abi/factoryV1.js.map +0 -1
- package/src/lib/constants/abi/feeLocker.evm.js.map +0 -1
- package/src/lib/constants/abi/index.js.map +0 -1
- package/src/lib/constants/abi/prc20.evm.js.map +0 -1
- package/src/lib/constants/abi/uea-factory.js.map +0 -1
- package/src/lib/constants/abi/uea.evm.js.map +0 -1
- package/src/lib/constants/abi/uea.svm.js.map +0 -1
- package/src/lib/constants/abi/universalGateway.evm.js.map +0 -1
- package/src/lib/constants/abi/universalGatewayPC.evm.js.map +0 -1
- package/src/lib/constants/abi/universalGatewayV0.evm.js.map +0 -1
- package/src/lib/constants/chain.js.map +0 -1
- package/src/lib/constants/enums.js.map +0 -1
- package/src/lib/constants/index.js.map +0 -1
- package/src/lib/constants/selectors.js.map +0 -1
- package/src/lib/constants/tokens.js.map +0 -1
- package/src/lib/generated/uexecutor/v1/query.js.map +0 -1
- package/src/lib/generated/uexecutor/v1/types.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/index.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/query.js.map +0 -1
- package/src/lib/generated/uexecutor/v2/types.js.map +0 -1
- package/src/lib/generated/v1/tx.js.map +0 -1
- package/src/lib/index.js.map +0 -1
- package/src/lib/internal/bs58.js.map +0 -1
- package/src/lib/internal/buffer.js.map +0 -1
- package/src/lib/internal/global-buffer-polyfill.js.map +0 -1
- package/src/lib/orchestrator/cea-utils.js.map +0 -1
- package/src/lib/orchestrator/internals/account-manager.js.map +0 -1
- package/src/lib/orchestrator/internals/cascade.js.map +0 -1
- package/src/lib/orchestrator/internals/confirmation.js.map +0 -1
- package/src/lib/orchestrator/internals/context.js.map +0 -1
- package/src/lib/orchestrator/internals/execute-funds-only.js.map +0 -1
- package/src/lib/orchestrator/internals/execute-funds-payload.js.map +0 -1
- package/src/lib/orchestrator/internals/execute-standard.js.map +0 -1
- package/src/lib/orchestrator/internals/gas-calculator.js.map +0 -1
- package/src/lib/orchestrator/internals/gateway-client.js.map +0 -1
- package/src/lib/orchestrator/internals/helpers.js.map +0 -1
- package/src/lib/orchestrator/internals/index.js.map +0 -1
- package/src/lib/orchestrator/internals/outbound-sync.js.map +0 -1
- package/src/lib/orchestrator/internals/outbound-tracker.js.map +0 -1
- package/src/lib/orchestrator/internals/payload-builder.js.map +0 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js.map +0 -1
- package/src/lib/orchestrator/internals/quote.js.map +0 -1
- package/src/lib/orchestrator/internals/rescue.js.map +0 -1
- package/src/lib/orchestrator/internals/response-builder.js.map +0 -1
- package/src/lib/orchestrator/internals/route-handlers.js.map +0 -1
- package/src/lib/orchestrator/internals/signing.js.map +0 -1
- package/src/lib/orchestrator/internals/svm-bridge.js.map +0 -1
- package/src/lib/orchestrator/internals/svm-helpers.js.map +0 -1
- package/src/lib/orchestrator/internals/tx-transformer.js.map +0 -1
- package/src/lib/orchestrator/internals/uea-manager.js.map +0 -1
- package/src/lib/orchestrator/orchestrator.js.map +0 -1
- package/src/lib/orchestrator/orchestrator.types.js.map +0 -1
- package/src/lib/orchestrator/payload-builders.js.map +0 -1
- package/src/lib/orchestrator/route-detector.js.map +0 -1
- package/src/lib/price-fetch/price-fetch.js.map +0 -1
- package/src/lib/progress-hook/progress-hook.js.map +0 -1
- package/src/lib/progress-hook/progress-hook.types.js.map +0 -1
- package/src/lib/push-chain/helpers/abis.js.map +0 -1
- package/src/lib/push-chain/helpers/addresses.js.map +0 -1
- package/src/lib/push-chain/push-chain.js.map +0 -1
- package/src/lib/push-client/push-client.js.map +0 -1
- package/src/lib/push-client/push-client.types.js.map +0 -1
- package/src/lib/universal/account/account.js.map +0 -1
- package/src/lib/universal/account/index.js.map +0 -1
- package/src/lib/universal/signer/index.js.map +0 -1
- package/src/lib/universal/signer/signer.js.map +0 -1
- package/src/lib/universal/signer/signer.types.js.map +0 -1
- package/src/lib/universal/universal.types.js.map +0 -1
- package/src/lib/utils.js.map +0 -1
- package/src/lib/vm-client/evm-client.js.map +0 -1
- package/src/lib/vm-client/svm-client.js.map +0 -1
- package/src/lib/vm-client/vm-client.types.js.map +0 -1
|
@@ -31,6 +31,8 @@ const payload_builder_1 = require("./payload-builder");
|
|
|
31
31
|
const uea_manager_1 = require("./uea-manager");
|
|
32
32
|
const gas_calculator_1 = require("./gas-calculator");
|
|
33
33
|
const chain_1 = require("../../constants/chain");
|
|
34
|
+
const utils_1 = require("../../utils");
|
|
35
|
+
const price_fetch_1 = require("../../price-fetch/price-fetch");
|
|
34
36
|
const route_detector_1 = require("../route-detector");
|
|
35
37
|
const cea_utils_1 = require("../cea-utils");
|
|
36
38
|
const payload_builders_1 = require("../payload-builders");
|
|
@@ -255,11 +257,7 @@ function executeUoaToCea(ctx, params, executeFn) {
|
|
|
255
257
|
ctx.pushClient.getBalance(ueaAddress),
|
|
256
258
|
]);
|
|
257
259
|
const isUEADeployed = isNativePushEOA || ueaCode !== undefined;
|
|
258
|
-
|
|
259
|
-
throw new Error('UEA is not deployed. Please send an inbound transaction to Push Chain first ' +
|
|
260
|
-
'(e.g. sendTransaction with value) to deploy your Universal Execution Account before using outbound transfers.');
|
|
261
|
-
}
|
|
262
|
-
const ueaNonce = isNativePushEOA ? BigInt(0) : yield (0, uea_manager_1.getUEANonce)(ctx, ueaAddress);
|
|
260
|
+
const ueaNonce = (!isUEADeployed || isNativePushEOA) ? BigInt(0) : yield (0, uea_manager_1.getUEANonce)(ctx, ueaAddress);
|
|
263
261
|
// Build the multicall that will execute ON Push Chain from UEA context
|
|
264
262
|
// This includes: 1) approve PRC-20 (if needed), 2) call sendUniversalTxOutbound
|
|
265
263
|
const pushChainMulticalls = [];
|
|
@@ -267,41 +265,62 @@ function executeUoaToCea(ctx, params, executeFn) {
|
|
|
267
265
|
let gasFee = BigInt(0);
|
|
268
266
|
let nativeValueForGas = BigInt(0);
|
|
269
267
|
let gasToken = selectors_1.ZERO_ADDRESS;
|
|
268
|
+
let universalCoreAddress;
|
|
270
269
|
if (prc20Token !== selectors_1.ZERO_ADDRESS) {
|
|
271
270
|
try {
|
|
272
271
|
const result = yield (0, gas_calculator_1.queryOutboundGasFee)(ctx, prc20Token, outboundReq.gasLimit);
|
|
273
272
|
gasFee = result.gasFee;
|
|
274
273
|
gasToken = result.gasToken;
|
|
275
274
|
nativeValueForGas = result.nativeValueForGas;
|
|
275
|
+
universalCoreAddress = result.universalCoreAddress;
|
|
276
276
|
(0, context_1.printLog)(ctx, `executeUoaToCea — queried gas fee: ${gasFee.toString()}, gasToken: ${gasToken}, nativeValueForGas: ${nativeValueForGas.toString()}`);
|
|
277
277
|
}
|
|
278
278
|
catch (err) {
|
|
279
279
|
throw new Error(`Failed to query outbound gas fee: ${err}`);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
// The contract's swapAndBurnGas does exactOutputSingle and refunds excess PC.
|
|
282
|
+
// Balance-aware adjustment: MAXIMIZE nativeValueForGas within available balance.
|
|
283
|
+
// The contract's swapAndBurnGas does exactOutputSingle and refunds excess PC,
|
|
284
|
+
// so overshooting within balance is safe. Undershooting causes the swap to revert.
|
|
286
285
|
const EVM_NATIVE_VALUE_TARGET = BigInt(200e18); // 200 UPC
|
|
287
286
|
const EVM_GAS_RESERVE = BigInt(3e18); // 3 UPC for tx overhead
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
const ROUTE2_MINIMUM_DEPOSIT_USD = utils_1.Utils.helpers.parseUnits('10', 8); // $10
|
|
288
|
+
// Determine effective balance for the adjustment.
|
|
289
|
+
// For deployed UEAs: use real balance.
|
|
290
|
+
// For fresh wallets: predict the post-fee-locking balance by querying the same
|
|
291
|
+
// Uniswap V3 quoter the chain uses (pETH → WPC swap in execute_inbound_gas.go).
|
|
292
|
+
let effectiveBalance = ueaBalance;
|
|
293
|
+
if (!isUEADeployed && effectiveBalance <= EVM_GAS_RESERVE) {
|
|
294
|
+
// Calculate the ETH amount lockFee will send (same formula as lockFee)
|
|
295
|
+
const ethPrice = yield new price_fetch_1.PriceFetch(ctx.rpcUrls).getPrice(signerChain);
|
|
296
|
+
const nativeAmountETH = ethPrice > BigInt(0)
|
|
297
|
+
? (ROUTE2_MINIMUM_DEPOSIT_USD * BigInt(1e18) + (ethPrice - BigInt(1))) / ethPrice + BigInt(1)
|
|
298
|
+
: BigInt(0);
|
|
299
|
+
if (nativeAmountETH > BigInt(0)) {
|
|
300
|
+
// Query the real swap quote: how much WPC (UPC) for this pETH amount?
|
|
301
|
+
const originPrc20 = (0, helpers_1.getNativePRC20ForChain)(signerChain, ctx.pushNetwork);
|
|
302
|
+
const predictedUPC = yield (0, gas_calculator_1.estimateDepositFromLockedNative)(ctx, nativeAmountETH, originPrc20);
|
|
303
|
+
if (predictedUPC > BigInt(0)) {
|
|
304
|
+
// 10% safety margin for slippage between quote and actual execution
|
|
305
|
+
effectiveBalance = (predictedUPC * BigInt(90)) / BigInt(100);
|
|
306
|
+
(0, context_1.printLog)(ctx, `executeUoaToCea — fresh wallet: Uniswap quote predicts ${predictedUPC.toString()} UPC ` +
|
|
307
|
+
`from ${nativeAmountETH.toString()} wei pETH, using ${effectiveBalance.toString()} (90%)`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
290
311
|
let adjustedValue;
|
|
291
|
-
if (
|
|
292
|
-
// Enough balance: use 200 UPC target
|
|
312
|
+
if (effectiveBalance > EVM_NATIVE_VALUE_TARGET + EVM_GAS_RESERVE) {
|
|
293
313
|
adjustedValue = EVM_NATIVE_VALUE_TARGET;
|
|
294
314
|
}
|
|
295
|
-
else if (
|
|
296
|
-
|
|
297
|
-
adjustedValue = currentBalance - EVM_GAS_RESERVE;
|
|
315
|
+
else if (effectiveBalance > EVM_GAS_RESERVE) {
|
|
316
|
+
adjustedValue = effectiveBalance - EVM_GAS_RESERVE;
|
|
298
317
|
}
|
|
299
318
|
else {
|
|
300
|
-
// Very low balance: use original query value as-is
|
|
301
319
|
adjustedValue = nativeValueForGas;
|
|
302
320
|
}
|
|
303
321
|
if (adjustedValue !== nativeValueForGas) {
|
|
304
|
-
(0, context_1.printLog)(ctx, `executeUoaToCea — adjusting nativeValueForGas from ${nativeValueForGas.toString()}
|
|
322
|
+
(0, context_1.printLog)(ctx, `executeUoaToCea — adjusting nativeValueForGas from ${nativeValueForGas.toString()} ` +
|
|
323
|
+
`to ${adjustedValue.toString()} (effective balance: ${effectiveBalance.toString()})`);
|
|
305
324
|
nativeValueForGas = adjustedValue;
|
|
306
325
|
}
|
|
307
326
|
// Build outbound multicalls (approve burn + sendUniversalTxOutbound with native value)
|
|
@@ -345,17 +364,11 @@ function executeUoaToCea(ctx, params, executeFn) {
|
|
|
345
364
|
// This handles fee-locking on origin chain and executes the multicall from UEA context
|
|
346
365
|
// Sum native values from multicall entries for proper fee calculation
|
|
347
366
|
const multicallNativeValue = pushChainMulticalls.reduce((sum, mc) => { var _a; return sum + ((_a = mc.value) !== null && _a !== void 0 ? _a : BigInt(0)); }, BigInt(0));
|
|
348
|
-
const executeParams = {
|
|
349
|
-
to: ueaAddress, // multicall executes from UEA
|
|
350
|
-
value: multicallNativeValue, // ensures correct requiredFunds calculation
|
|
351
|
-
data: pushChainMulticalls, // array triggers multicall mode
|
|
352
|
-
_ueaStatus: {
|
|
367
|
+
const executeParams = Object.assign({ to: ueaAddress, value: multicallNativeValue, data: pushChainMulticalls, _ueaStatus: {
|
|
353
368
|
isDeployed: isUEADeployed,
|
|
354
369
|
nonce: ueaNonce,
|
|
355
370
|
balance: ueaBalance,
|
|
356
|
-
},
|
|
357
|
-
_skipFeeLocking: true, // outbound executes on Push Chain, no external fee locking
|
|
358
|
-
};
|
|
371
|
+
}, _skipFeeLocking: isUEADeployed }, (!isUEADeployed ? { _minimumDepositUsd: ROUTE2_MINIMUM_DEPOSIT_USD } : {}));
|
|
359
372
|
const response = yield executeFn(executeParams);
|
|
360
373
|
// Add chain info to response
|
|
361
374
|
response.chain = targetChain;
|
|
@@ -463,14 +476,11 @@ function executeUoaToCeaSvm(ctx, params, target, executeFn) {
|
|
|
463
476
|
isUEADeployed = ueaCode !== undefined;
|
|
464
477
|
ueaBalance = balance;
|
|
465
478
|
}
|
|
466
|
-
|
|
467
|
-
throw new Error('UEA is not deployed. Please send an inbound transaction to Push Chain first ' +
|
|
468
|
-
'(e.g. sendTransaction with value) to deploy your Universal Execution Account before using outbound transfers.');
|
|
469
|
-
}
|
|
470
|
-
const ueaNonce = isNativePushEOASvm ? BigInt(0) : yield (0, uea_manager_1.getUEANonce)(ctx, ueaAddress);
|
|
479
|
+
const ueaNonce = (!isUEADeployed || isNativePushEOASvm) ? BigInt(0) : yield (0, uea_manager_1.getUEANonce)(ctx, ueaAddress);
|
|
471
480
|
// --- Query gas fee (identical to EVM path) ---
|
|
472
481
|
let gasFee = BigInt(0);
|
|
473
482
|
let gasToken = selectors_1.ZERO_ADDRESS;
|
|
483
|
+
let universalCoreAddress;
|
|
474
484
|
let nativeValueForGas = BigInt(0);
|
|
475
485
|
if (prc20Token !== selectors_1.ZERO_ADDRESS) {
|
|
476
486
|
const gasLimit = outboundReq.gasLimit;
|
|
@@ -479,6 +489,7 @@ function executeUoaToCeaSvm(ctx, params, target, executeFn) {
|
|
|
479
489
|
gasFee = result.gasFee;
|
|
480
490
|
gasToken = result.gasToken;
|
|
481
491
|
nativeValueForGas = result.nativeValueForGas;
|
|
492
|
+
universalCoreAddress = result.universalCoreAddress;
|
|
482
493
|
// When user omits gasLimit (sent as 0), the contract computes fees using its internal
|
|
483
494
|
// baseGasLimitByChainNamespace. But the relay reads the stored gasLimit=0 from the
|
|
484
495
|
// on-chain outbound record and uses it as the Solana compute budget — 0 CU means the
|
|
@@ -494,30 +505,17 @@ function executeUoaToCeaSvm(ctx, params, target, executeFn) {
|
|
|
494
505
|
throw new Error(`Failed to query outbound gas fee: ${err}`);
|
|
495
506
|
}
|
|
496
507
|
}
|
|
497
|
-
//
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
//
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
adjustedValue = SVM_NATIVE_VALUE_TARGET;
|
|
509
|
-
}
|
|
510
|
-
else if (currentBalance > SVM_GAS_RESERVE) {
|
|
511
|
-
// Low balance: use what's available minus reserve
|
|
512
|
-
adjustedValue = currentBalance - SVM_GAS_RESERVE;
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
// Very low balance: use original query value as-is
|
|
516
|
-
adjustedValue = nativeValueForGas;
|
|
517
|
-
}
|
|
518
|
-
if (adjustedValue !== nativeValueForGas) {
|
|
519
|
-
(0, context_1.printLog)(ctx, `executeUoaToCeaSvm — adjusting nativeValueForGas from ${nativeValueForGas.toString()} to ${adjustedValue.toString()} (UEA balance: ${currentBalance.toString()})`);
|
|
520
|
-
nativeValueForGas = adjustedValue;
|
|
508
|
+
// Estimate the actual WPC needed for the swap using on-chain pool price.
|
|
509
|
+
// The static 1Mx multiplier from queryOutboundGasFee doesn't reflect the real
|
|
510
|
+
// WPC/gasToken exchange rate. estimateNativeValueForSwap reads the Uniswap V3
|
|
511
|
+
// pool's slot0, computes the true cost, and adds a 2x buffer.
|
|
512
|
+
// Excess msg.value is refunded by the contract's swapAndBurnGas.
|
|
513
|
+
if (universalCoreAddress && gasFee > BigInt(0)) {
|
|
514
|
+
const estimated = yield (0, gas_calculator_1.estimateNativeValueForSwap)(ctx, universalCoreAddress, gasToken, gasFee, ueaBalance);
|
|
515
|
+
if (estimated > nativeValueForGas) {
|
|
516
|
+
(0, context_1.printLog)(ctx, `executeUoaToCeaSvm — adjusting nativeValueForGas from ${nativeValueForGas.toString()} to ${estimated.toString()} (pool-price estimate, UEA balance: ${ueaBalance.toString()})`);
|
|
517
|
+
nativeValueForGas = estimated;
|
|
518
|
+
}
|
|
521
519
|
}
|
|
522
520
|
// --- Build Push Chain multicalls (approve + sendUniversalTxOutbound) ---
|
|
523
521
|
// Reuse the same builder as EVM — this part is identical
|
|
@@ -542,7 +540,7 @@ function executeUoaToCeaSvm(ctx, params, target, executeFn) {
|
|
|
542
540
|
nonce: ueaNonce,
|
|
543
541
|
balance: ueaBalance,
|
|
544
542
|
},
|
|
545
|
-
_skipFeeLocking:
|
|
543
|
+
_skipFeeLocking: isUEADeployed, // skip fee-locking only if UEA is already deployed
|
|
546
544
|
};
|
|
547
545
|
const response = yield executeFn(executeParams);
|
|
548
546
|
// Add chain info to response
|
|
@@ -588,10 +586,8 @@ function executeCeaToPush(ctx, params, executeFn) {
|
|
|
588
586
|
// 4. Get CEA address on source chain
|
|
589
587
|
const { cea: ceaAddress, isDeployed: ceaDeployed } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (_b = ctx.rpcUrls[sourceChain]) === null || _b === void 0 ? void 0 : _b[0]);
|
|
590
588
|
(0, context_1.printLog)(ctx, `executeCeaToPush — sourceChain: ${sourceChain}, CEA: ${ceaAddress}, deployed: ${ceaDeployed}`);
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
`Deploy CEA first using Route 2 (UOA -> CEA) before using Route 3.`);
|
|
594
|
-
}
|
|
589
|
+
// CEA auto-deploys on-chain: Vault.finalizeUniversalTx calls CEAFactory.deployCEA()
|
|
590
|
+
// if CEA doesn't exist yet. No SDK-side blocking needed.
|
|
595
591
|
// 5. Get UniversalGateway address on source chain
|
|
596
592
|
const gatewayAddress = chain_1.UNIVERSAL_GATEWAY_ADDRESSES[sourceChain];
|
|
597
593
|
if (!gatewayAddress) {
|
|
@@ -628,7 +624,7 @@ function executeCeaToPush(ctx, params, executeFn) {
|
|
|
628
624
|
// external chain), but that approach is racy: the balance can change between the SDK
|
|
629
625
|
// query and relay execution, causing sendUniversalTxToUEA to revert with
|
|
630
626
|
// InsufficientBalance. Pre-existing CEA funds remain parked and can be swept separately.
|
|
631
|
-
|
|
627
|
+
const bridgeAmount = amount;
|
|
632
628
|
// Note: CEA contract may reject amount=0 in sendUniversalTxToUEA.
|
|
633
629
|
// Keeping bridgeAmount as-is (0) for payload-only to test precompile behavior.
|
|
634
630
|
// For ERC20 tokens, add approve call for the bridge amount
|
|
@@ -954,7 +950,7 @@ function executeCeaToCea(ctx, params, executeFn) {
|
|
|
954
950
|
// CEA -> CEA requires chaining Route 3 (CEA -> Push) and Route 2 (Push -> CEA)
|
|
955
951
|
// This is a complex flow that requires coordination
|
|
956
952
|
throw new Error('CEA -> CEA transactions are not yet fully implemented. ' +
|
|
957
|
-
'Use prepareTransaction()
|
|
953
|
+
'Use prepareTransaction() and executeTransactions() to chain Route 3 -> Route 2 manually.');
|
|
958
954
|
});
|
|
959
955
|
}
|
|
960
956
|
// ---------------------------------------------------------------------------
|
|
@@ -1120,6 +1116,8 @@ function buildPayloadForRoute(ctx, params, route, nonce) {
|
|
|
1120
1116
|
return { payload: svmPayload, gatewayRequest: outboundReq };
|
|
1121
1117
|
}
|
|
1122
1118
|
const { cea: ceaAddress } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, sourceChain, (_l = ctx.rpcUrls[sourceChain]) === null || _l === void 0 ? void 0 : _l[0]);
|
|
1119
|
+
// CEA auto-deploys on-chain: Vault.finalizeUniversalTx calls CEAFactory.deployCEA()
|
|
1120
|
+
// if CEA doesn't exist yet. No SDK-side blocking needed.
|
|
1123
1121
|
const gatewayAddr = chain_1.UNIVERSAL_GATEWAY_ADDRESSES[sourceChain];
|
|
1124
1122
|
if (!gatewayAddr) {
|
|
1125
1123
|
throw new Error(`No UniversalGateway address configured for chain ${sourceChain}`);
|
|
@@ -4,7 +4,7 @@ import type { AccountStatus, UniversalTxResponse } from './orchestrator.types';
|
|
|
4
4
|
import { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
5
5
|
import { PushClient } from '../push-client/push-client';
|
|
6
6
|
import type { UniversalAccount, UniversalSigner } from '../universal/universal.types';
|
|
7
|
-
import { ExecuteParams, UniversalExecuteParams, PreparedUniversalTx,
|
|
7
|
+
import { ExecuteParams, UniversalExecuteParams, PreparedUniversalTx, CascadedTxResponse, RescueFundsParams } from './orchestrator.types';
|
|
8
8
|
export declare class Orchestrator {
|
|
9
9
|
private readonly universalSigner;
|
|
10
10
|
private pushNetwork;
|
|
@@ -79,9 +79,11 @@ export declare class Orchestrator {
|
|
|
79
79
|
* The cascade composes all hops bottom-to-top into a single Push Chain tx.
|
|
80
80
|
*
|
|
81
81
|
* @param preparedTxs - Array of prepared transactions
|
|
82
|
-
* @returns
|
|
82
|
+
* @returns Object with send() method
|
|
83
83
|
*/
|
|
84
|
-
createCascadedBuilder(preparedTxs: PreparedUniversalTx[]):
|
|
84
|
+
createCascadedBuilder(preparedTxs: PreparedUniversalTx[]): {
|
|
85
|
+
send: () => Promise<CascadedTxResponse>;
|
|
86
|
+
};
|
|
85
87
|
/**
|
|
86
88
|
* Queries gas fee for an outbound transaction from the UniversalCore contract.
|
|
87
89
|
*/
|
|
@@ -129,7 +129,7 @@ class Orchestrator {
|
|
|
129
129
|
*/
|
|
130
130
|
execute(params) {
|
|
131
131
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
var _a, _b, _c, _d
|
|
132
|
+
var _a, _b, _c, _d;
|
|
133
133
|
// Lazy UEA upgrade check
|
|
134
134
|
try {
|
|
135
135
|
if (!this.accountStatusCache || !this.accountStatusCache.uea.loaded) {
|
|
@@ -166,16 +166,6 @@ class Orchestrator {
|
|
|
166
166
|
try {
|
|
167
167
|
const rcb = () => this._getResponseCallbacks();
|
|
168
168
|
if (execute.funds) {
|
|
169
|
-
const hasData = execute.data && execute.data !== '0x';
|
|
170
|
-
const isSVM = ((_e = chain_1.CHAIN_INFO[this.ctx.universalSigner.account.chain]) === null || _e === void 0 ? void 0 : _e.vm) === enums_1.VM.SVM;
|
|
171
|
-
// SVM two-phase: bridge funds first, then execute payload separately
|
|
172
|
-
// (Push Chain node doesn't support FUNDS_AND_PAYLOAD payload decoding for SVM yet)
|
|
173
|
-
if (hasData && isSVM) {
|
|
174
|
-
const fundsOnly = Object.assign(Object.assign({}, execute), { data: undefined });
|
|
175
|
-
yield (0, internals_1.executeFundsOnly)(this.ctx, fundsOnly, eventBuffer, rcb);
|
|
176
|
-
const dataOnly = Object.assign(Object.assign({}, execute), { funds: undefined });
|
|
177
|
-
return yield (0, internals_1.executeStandardPayload)(this.ctx, dataOnly, eventBuffer, rcb);
|
|
178
|
-
}
|
|
179
169
|
return !hasData
|
|
180
170
|
? yield (0, internals_1.executeFundsOnly)(this.ctx, execute, eventBuffer, rcb)
|
|
181
171
|
: yield (0, internals_1.executeFundsWithPayload)(this.ctx, execute, eventBuffer, rcb);
|
|
@@ -221,7 +211,7 @@ class Orchestrator {
|
|
|
221
211
|
* The cascade composes all hops bottom-to-top into a single Push Chain tx.
|
|
222
212
|
*
|
|
223
213
|
* @param preparedTxs - Array of prepared transactions
|
|
224
|
-
* @returns
|
|
214
|
+
* @returns Object with send() method
|
|
225
215
|
*/
|
|
226
216
|
createCascadedBuilder(preparedTxs) {
|
|
227
217
|
return (0, internals_1.createCascadedBuilder)(this.ctx, preparedTxs, this._getCascadeCallbacks());
|
|
@@ -106,6 +106,14 @@ export type ExecuteParams = {
|
|
|
106
106
|
* @internal
|
|
107
107
|
*/
|
|
108
108
|
_skipFeeLocking?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Internal: Minimum fee-locking deposit in USD (8 decimals).
|
|
111
|
+
* Overrides the default $1 floor when the caller needs a larger deposit
|
|
112
|
+
* (e.g., Route 2 needs enough UPC for the outbound swap).
|
|
113
|
+
* Still capped at $10 by lockFee.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
_minimumDepositUsd?: bigint;
|
|
109
117
|
};
|
|
110
118
|
/**
|
|
111
119
|
* New Universal Transaction Receipt interface with prioritized field ordering
|
|
@@ -465,10 +473,6 @@ export interface PreparedUniversalTx {
|
|
|
465
473
|
deadline: bigint;
|
|
466
474
|
/** Internal hop descriptor for cascade nesting @internal */
|
|
467
475
|
_hop: HopDescriptor;
|
|
468
|
-
/** Chain additional transactions after this one (cascade) */
|
|
469
|
-
thenOn: (nextTx: PreparedUniversalTx) => CascadedTransactionBuilder;
|
|
470
|
-
/** Execute this prepared transaction */
|
|
471
|
-
send: () => Promise<UniversalTxResponse>;
|
|
472
476
|
}
|
|
473
477
|
/**
|
|
474
478
|
* @deprecated Use CascadedTxResponse instead.
|
|
@@ -485,17 +489,6 @@ export interface MultiChainTxResponse {
|
|
|
485
489
|
status: 'pending' | 'confirmed' | 'failed';
|
|
486
490
|
}[];
|
|
487
491
|
}
|
|
488
|
-
/**
|
|
489
|
-
* Builder for composing cascaded (nested) multi-chain transactions.
|
|
490
|
-
* Each call to thenOn() adds another hop to the cascade.
|
|
491
|
-
* send() composes all hops bottom-to-top and executes a single Push Chain tx.
|
|
492
|
-
*/
|
|
493
|
-
export interface CascadedTransactionBuilder {
|
|
494
|
-
/** Add another hop to the cascade */
|
|
495
|
-
thenOn: (nextTx: PreparedUniversalTx) => CascadedTransactionBuilder;
|
|
496
|
-
/** Compose all hops bottom-to-top and execute the single initial tx */
|
|
497
|
-
send: () => Promise<CascadedTxResponse>;
|
|
498
|
-
}
|
|
499
492
|
/**
|
|
500
493
|
* Response for cascaded multi-chain transactions.
|
|
501
494
|
* Contains the initial tx and tracking info for all hops.
|
|
@@ -35,7 +35,7 @@ const RAW_HOOKS = {
|
|
|
35
35
|
[progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_01]: () => ({
|
|
36
36
|
id: progress_hook_types_1.PROGRESS_HOOK.SEND_TX_03_01,
|
|
37
37
|
title: 'Resolving UEA',
|
|
38
|
-
message: 'Resolving
|
|
38
|
+
message: 'Resolving Executor Account (UEA) – computing address, checking deployment status and balance',
|
|
39
39
|
response: null,
|
|
40
40
|
level: 'INFO',
|
|
41
41
|
}),
|
|
@@ -6,7 +6,7 @@ import { TypedData, TypedDataDomain } from 'viem';
|
|
|
6
6
|
import { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
7
7
|
import type { AccountStatus } from '../orchestrator/orchestrator.types';
|
|
8
8
|
import { MoveableToken, PayableToken, ConversionQuote, MoveableTokenAccessor, PayableTokenAccessor } from '../constants/tokens';
|
|
9
|
-
import type { PreparedUniversalTx,
|
|
9
|
+
import type { PreparedUniversalTx, CascadedTxResponse } from '../orchestrator/orchestrator.types';
|
|
10
10
|
/**
|
|
11
11
|
* @class PushChain
|
|
12
12
|
*
|
|
@@ -71,15 +71,14 @@ export declare class PushChain {
|
|
|
71
71
|
sendTransaction: Orchestrator['execute'];
|
|
72
72
|
/**
|
|
73
73
|
* Prepare a universal transaction without executing it.
|
|
74
|
-
* Returns a PreparedUniversalTx that can be
|
|
74
|
+
* Returns a PreparedUniversalTx that can be passed to executeTransactions.
|
|
75
75
|
*/
|
|
76
76
|
prepareTransaction: Orchestrator['prepareTransaction'];
|
|
77
77
|
/**
|
|
78
|
-
* Execute
|
|
79
|
-
* Accepts PreparedUniversalTx (from prepareTransaction)
|
|
80
|
-
* a CascadedTransactionBuilder that supports .thenOn() for chaining.
|
|
78
|
+
* Execute one or more prepared transactions as a cascade across chains.
|
|
79
|
+
* Accepts an array of PreparedUniversalTx (from prepareTransaction).
|
|
81
80
|
*/
|
|
82
|
-
executeTransactions: (
|
|
81
|
+
executeTransactions: (txs: PreparedUniversalTx[]) => Promise<CascadedTxResponse>;
|
|
83
82
|
/**
|
|
84
83
|
* Tracks a transaction by hash on Push Chain
|
|
85
84
|
*/
|
|
@@ -87,12 +87,12 @@ class PushChain {
|
|
|
87
87
|
}
|
|
88
88
|
return orchestrator.prepareTransaction.bind(orchestrator)(params);
|
|
89
89
|
},
|
|
90
|
-
executeTransactions: (
|
|
90
|
+
executeTransactions: (txs) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
91
91
|
if (this.isReadMode) {
|
|
92
92
|
throw new Error('Read only mode cannot call executeTransactions function');
|
|
93
93
|
}
|
|
94
|
-
return orchestrator.createCascadedBuilder(
|
|
95
|
-
},
|
|
94
|
+
return orchestrator.createCascadedBuilder(txs).send();
|
|
95
|
+
}),
|
|
96
96
|
trackTransaction: (txHash, options) => {
|
|
97
97
|
return orchestrator.trackTransaction.bind(orchestrator)(txHash, options);
|
|
98
98
|
},
|
|
@@ -400,6 +400,7 @@ class PushChain {
|
|
|
400
400
|
// Stored on instance so consumers can await it if needed: await client.accountStatusReady
|
|
401
401
|
const ACCOUNT_STATUS_TIMEOUT = 30000;
|
|
402
402
|
instance.accountStatusReady = Promise.race([
|
|
403
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
403
404
|
instance.getAccountStatus().then(() => { }),
|
|
404
405
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Account status fetch timed out')), ACCOUNT_STATUS_TIMEOUT)),
|
|
405
406
|
]).catch(() => {
|
|
@@ -69,29 +69,37 @@ export declare function convertExecutorToOrigin(executorAddress: string, options
|
|
|
69
69
|
_internal?: boolean;
|
|
70
70
|
}): Promise<OriginAccountInfo>;
|
|
71
71
|
/**
|
|
72
|
-
* Derive the executor account (UEA or CEA) for a given
|
|
72
|
+
* Derive the executor account (UEA or CEA) for a given account.
|
|
73
73
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* - If account is on an external chain (Ethereum, Solana, etc.):
|
|
75
|
+
* Computes the UEA on Push Chain via the factory contract's computeUEA.
|
|
76
|
+
* If options.chain is an external chain, further derives the CEA on that chain.
|
|
77
|
+
*
|
|
78
|
+
* - If account is on Push Chain:
|
|
79
|
+
* Returns the address as-is (it's already a UEA or Push EOA).
|
|
80
|
+
* If options.chain is an external chain, derives the CEA on that chain.
|
|
81
|
+
*
|
|
82
|
+
* @param account - UniversalAccount with chain and address.
|
|
83
|
+
* @param options.chain - Target external chain for CEA derivation. If omitted, returns UEA.
|
|
76
84
|
* @param options.skipNetworkCheck - If true, skip deployment check and return deployed: false.
|
|
77
85
|
* @returns The derived executor account address and deployment status.
|
|
78
86
|
*/
|
|
79
|
-
export declare function deriveExecutorAccount(account:
|
|
87
|
+
export declare function deriveExecutorAccount(account: UniversalAccount, options?: {
|
|
80
88
|
chain?: CHAIN;
|
|
81
89
|
skipNetworkCheck?: boolean;
|
|
82
90
|
}): Promise<DerivedExecutorAccount>;
|
|
83
91
|
/**
|
|
84
92
|
* Resolve the controller (origin) accounts for a given executor address.
|
|
85
93
|
*
|
|
86
|
-
* Given a UEA or CEA address
|
|
94
|
+
* Given a UEA or CEA plain address, resolves the full controller chain
|
|
87
95
|
* back to the origin account.
|
|
88
96
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @param options.chain -
|
|
97
|
+
* @param address - Plain address string of the executor account (e.g., "0xABC...")
|
|
98
|
+
* @param options.chain - Chain context. If external chain, address is treated as CEA on that chain. If omitted or Push chain, address is treated as UEA on Push Chain.
|
|
91
99
|
* @param options.skipNetworkCheck - If true, skip existence checks, set exists: false
|
|
92
100
|
* @returns Resolved accounts in the controller chain
|
|
93
101
|
*/
|
|
94
|
-
export declare function resolveControllerAccount(
|
|
102
|
+
export declare function resolveControllerAccount(address: string, options?: {
|
|
95
103
|
chain?: CHAIN;
|
|
96
104
|
skipNetworkCheck?: boolean;
|
|
97
105
|
}): Promise<ResolvedControllerAccounts>;
|