@pushchain/core 5.1.18 → 6.0.1
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 +1 -1
- package/src/lib/constants/abi/cea.evm.d.ts +52 -0
- package/src/lib/constants/abi/cea.evm.js +66 -1
- package/src/lib/constants/abi/prc20.evm.d.ts +117 -11
- package/src/lib/constants/abi/prc20.evm.js +38 -11
- package/src/lib/constants/abi/uea.evm.js +41 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +118 -2
- package/src/lib/constants/abi/universalGatewayPC.evm.js +41 -2
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.d.ts +2 -0
- package/src/lib/constants/chain.js +18 -14
- package/src/lib/constants/index.d.ts +1 -1
- package/src/lib/constants/tokens.d.ts +10 -1
- package/src/lib/constants/tokens.js +5 -2
- package/src/lib/formatters.d.ts +6 -0
- package/src/lib/formatters.js +14 -0
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +7 -1
- package/src/lib/orchestrator/internals/cascade.d.ts +3 -1
- package/src/lib/orchestrator/internals/cascade.js +189 -103
- package/src/lib/orchestrator/internals/errors.js +1 -1
- package/src/lib/orchestrator/internals/execute-funds-only.js +3 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +2 -1
- package/src/lib/orchestrator/internals/execute-standard.js +4 -4
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +1 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +13 -11
- package/src/lib/orchestrator/internals/helpers.js +2 -0
- package/src/lib/orchestrator/internals/inbound-tracker.js +4 -2
- package/src/lib/orchestrator/internals/outbound-sync.js +73 -60
- package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +1 -1
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +4 -3
- package/src/lib/orchestrator/internals/preflight.d.ts +8 -5
- package/src/lib/orchestrator/internals/preflight.js +35 -21
- package/src/lib/orchestrator/internals/push-chain-tx.js +5 -1
- package/src/lib/orchestrator/internals/route-handlers.js +175 -202
- package/src/lib/orchestrator/internals/signing.js +7 -2
- package/src/lib/orchestrator/internals/svm-helpers.js +3 -3
- package/src/lib/orchestrator/internals/svm-rent.d.ts +42 -9
- package/src/lib/orchestrator/internals/svm-rent.js +157 -14
- package/src/lib/orchestrator/internals/tx-transformer.js +5 -2
- package/src/lib/orchestrator/max-pc-for-gas.d.ts +60 -0
- package/src/lib/orchestrator/max-pc-for-gas.js +66 -0
- package/src/lib/orchestrator/orchestrator.d.ts +6 -6
- package/src/lib/orchestrator/orchestrator.js +10 -3
- package/src/lib/orchestrator/orchestrator.types.d.ts +48 -10
- package/src/lib/orchestrator/payload-builders.d.ts +7 -6
- package/src/lib/orchestrator/payload-builders.js +19 -7
- package/src/lib/progress-hook/progress-hook.js +59 -27
- package/src/lib/progress-hook/progress-hook.types.d.ts +3 -3
- package/src/lib/progress-hook/progress-hook.types.js +4 -2
- package/src/lib/push-chain/push-chain.d.ts +10 -4
- package/src/lib/push-chain/push-chain.js +2 -2
- package/src/lib/universal-tx-detector/events.d.ts +3 -1
- package/src/lib/universal-tx-detector/events.js +3 -1
- package/src/lib/universal-tx-detector/svm-events.d.ts +1 -1
- package/src/lib/universal-tx-detector/svm-events.js +1 -1
- package/src/lib/utils.js +1 -1
|
@@ -16,6 +16,11 @@ const enums_1 = require("../../constants/enums");
|
|
|
16
16
|
// ============================================================================
|
|
17
17
|
// EIP-712 Domain Separator (shared by execution & migration hashes)
|
|
18
18
|
// ============================================================================
|
|
19
|
+
// NOTE: Push Chain testnet UEA implementation (UEA_VM[EVM] =
|
|
20
|
+
// 0x4C8401F885c79b0e6e0241812f089e8529045d11) still uses the pre-audit
|
|
21
|
+
// 4-field domain (typehash 0x2aef22f9…) — the salted post-audit typehash
|
|
22
|
+
// 0xb90aaffa… in the audit-fixes contracts hasn't been deployed yet. Drop
|
|
23
|
+
// `salt` until the contracts redeploy. See docs/audit-2026-05/sdk-changes-required.md#11.
|
|
19
24
|
function buildDomainSeparator(vm, chainId, version, verifyingContract) {
|
|
20
25
|
const domainTypeHash = (0, viem_1.keccak256)((0, viem_1.toBytes)(vm === enums_1.VM.EVM
|
|
21
26
|
? 'EIP712Domain(string version,uint256 chainId,address verifyingContract)'
|
|
@@ -23,12 +28,12 @@ function buildDomainSeparator(vm, chainId, version, verifyingContract) {
|
|
|
23
28
|
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
24
29
|
{ name: 'typeHash', type: 'bytes32' },
|
|
25
30
|
{ name: 'version', type: 'bytes32' },
|
|
26
|
-
{ name: 'chainId', type: vm === enums_1.VM.EVM ? 'uint256' : '
|
|
31
|
+
{ name: 'chainId', type: vm === enums_1.VM.EVM ? 'uint256' : 'bytes32' },
|
|
27
32
|
{ name: 'verifyingContract', type: 'address' },
|
|
28
33
|
], [
|
|
29
34
|
domainTypeHash,
|
|
30
35
|
(0, viem_1.keccak256)((0, viem_1.toBytes)(version)),
|
|
31
|
-
vm === enums_1.VM.EVM ? BigInt(chainId) : chainId,
|
|
36
|
+
vm === enums_1.VM.EVM ? BigInt(chainId) : (0, viem_1.keccak256)((0, viem_1.toBytes)(chainId)),
|
|
32
37
|
verifyingContract,
|
|
33
38
|
]));
|
|
34
39
|
}
|
|
@@ -82,7 +82,7 @@ function buildSvmUniversalTxRequestFromReq(req, revertRecipient, signatureDataOv
|
|
|
82
82
|
// ============================================================================
|
|
83
83
|
function getSvmProtocolFee(svmClient, programId) {
|
|
84
84
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
var _a, _b, _c;
|
|
85
|
+
var _a, _b, _c, _d, _e;
|
|
86
86
|
const [feeVaultPda] = web3_js_1.PublicKey.findProgramAddressSync([(0, viem_1.stringToBytes)('fee_vault')], programId);
|
|
87
87
|
try {
|
|
88
88
|
const feeVault = yield svmClient.readContract({
|
|
@@ -91,10 +91,10 @@ function getSvmProtocolFee(svmClient, programId) {
|
|
|
91
91
|
functionName: 'feeVault',
|
|
92
92
|
args: [feeVaultPda.toBase58()],
|
|
93
93
|
});
|
|
94
|
-
const protocolFeeLamports = BigInt((_c = (_b = (
|
|
94
|
+
const protocolFeeLamports = BigInt((_e = (_d = ((_c = (_b = (_a = feeVault.inboundFeeLamports) !== null && _a !== void 0 ? _a : feeVault.inbound_fee_lamports) !== null && _b !== void 0 ? _b : feeVault.protocolFeeLamports) !== null && _c !== void 0 ? _c : feeVault.protocol_fee_lamports)) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : '0');
|
|
95
95
|
return { feeVaultPda, protocolFeeLamports };
|
|
96
96
|
}
|
|
97
|
-
catch (
|
|
97
|
+
catch (_f) {
|
|
98
98
|
return { feeVaultPda, protocolFeeLamports: BigInt(0) };
|
|
99
99
|
}
|
|
100
100
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* SVM finalize gas-budget helpers.
|
|
3
3
|
*
|
|
4
4
|
* The gateway program (svm-gateway) computes per-tx fees with a conditional
|
|
5
5
|
* rent for first-time SPL transfers — see `calculateSplExecuteFees` in
|
|
@@ -7,21 +7,26 @@
|
|
|
7
7
|
*
|
|
8
8
|
* const ataExists = await ceaAtaExists(connection, ceaAta);
|
|
9
9
|
* const ceaAtaRent = ataExists ? 0n : BigInt(getMinimumBalanceForRentExemption(165));
|
|
10
|
-
* gasFee = executedTxRent + ceaAtaRent + COMPUTE_BUFFER;
|
|
10
|
+
* gasFee = signatureFee + executedTxRent + ceaAtaRent + COMPUTE_BUFFER;
|
|
11
11
|
*
|
|
12
12
|
* The gateway's on-chain `getOutboundTxGasAndFees` quote does NOT factor in
|
|
13
13
|
* the ATA rent today, so the SDK has to bump `effectiveGasLimit` itself
|
|
14
|
-
* before
|
|
15
|
-
*
|
|
14
|
+
* before building the outbound request. Native-SOL outbounds still need the
|
|
15
|
+
* same base finalize budget plus compute buffer.
|
|
16
16
|
*/
|
|
17
17
|
import { PublicKey } from '@solana/web3.js';
|
|
18
18
|
import type { OrchestratorContext } from './context';
|
|
19
19
|
import type { CHAIN as ChainType } from '../../constants/enums';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
import { queryOutboundGasFee } from './gas-calculator';
|
|
21
|
+
/** Base Solana fee per relayer signature, mirrored from SVM gateway execute.rs. */
|
|
22
|
+
export declare const SVM_SIGNATURE_FEE_LAMPORTS: bigint;
|
|
23
|
+
/** Operational buffer used by SVM gateway tests for tx fees / compute. */
|
|
24
|
+
export declare const SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS: bigint;
|
|
25
|
+
/** Devnet/mainnet rent-exempt minimum for ExecutedSubTx::LEN = 8 bytes. */
|
|
26
|
+
export declare const SVM_EXECUTED_SUB_TX_RENT_FALLBACK: bigint;
|
|
27
|
+
/** Devnet/mainnet rent-exempt minimum for a 165-byte SPL token account. */
|
|
28
|
+
export declare const SVM_TOKEN_ACCOUNT_RENT_FALLBACK: bigint;
|
|
29
|
+
/** Back-compat export for older tests/callers: ATA rent + base finalization overhead. */
|
|
25
30
|
export declare const CEA_ATA_RENT_LAMPORTS_BUMP: bigint;
|
|
26
31
|
/** Derive CEA PDA from a 20-byte EVM address. Seeds: ["push_identity", evmBytes]. */
|
|
27
32
|
export declare function deriveSvmCeaPda(evmAddress: `0x${string}`): PublicKey;
|
|
@@ -37,6 +42,33 @@ export interface MaybeBumpInput {
|
|
|
37
42
|
burnAmount: bigint;
|
|
38
43
|
effectiveGasLimit: bigint;
|
|
39
44
|
}
|
|
45
|
+
export interface SvmFinalizeGasBudgetInput {
|
|
46
|
+
ctx: OrchestratorContext;
|
|
47
|
+
ueaAddress: `0x${string}`;
|
|
48
|
+
targetChain: ChainType;
|
|
49
|
+
/** SPL mint as base58. undefined means native SOL / no SPL staging. */
|
|
50
|
+
splMintBase58: string | undefined;
|
|
51
|
+
/** Burn amount in token units. 0 means no SPL staging. */
|
|
52
|
+
burnAmount: bigint;
|
|
53
|
+
}
|
|
54
|
+
export declare function gasLimitForSvmGasFeeBudget(gasFeeBudget: bigint, gasPrice: bigint): bigint;
|
|
55
|
+
type OutboundGasQuote = Awaited<ReturnType<typeof queryOutboundGasFee>>;
|
|
56
|
+
export declare function ensureSvmFinalizeGasBudgetQuote({ ctx, ueaAddress, targetChain, prc20Token, quote, splMintBase58, burnAmount, pathTag, }: {
|
|
57
|
+
ctx: OrchestratorContext;
|
|
58
|
+
ueaAddress: `0x${string}`;
|
|
59
|
+
targetChain: ChainType;
|
|
60
|
+
prc20Token: `0x${string}`;
|
|
61
|
+
quote: OutboundGasQuote;
|
|
62
|
+
splMintBase58: string | undefined;
|
|
63
|
+
burnAmount: bigint;
|
|
64
|
+
pathTag: string;
|
|
65
|
+
}): Promise<OutboundGasQuote>;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the minimum SVM `gas_fee` budget in lamports for the gateway
|
|
68
|
+
* finalize instruction, including a small compute buffer. If RPC is not
|
|
69
|
+
* available, falls back to Solana protocol rent constants.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getSvmFinalizeGasBudget(input: SvmFinalizeGasBudgetInput): Promise<bigint>;
|
|
40
72
|
/**
|
|
41
73
|
* Returns the (possibly bumped) effectiveGasLimit. Logs the decision via
|
|
42
74
|
* printLog. On any RPC failure or invalid input, logs a warning and returns
|
|
@@ -44,3 +76,4 @@ export interface MaybeBumpInput {
|
|
|
44
76
|
* outbounds on RPC flake; pre-flight will surface insufficient gas anyway.
|
|
45
77
|
*/
|
|
46
78
|
export declare function maybeBumpForCeaAtaRent(input: MaybeBumpInput): Promise<bigint>;
|
|
79
|
+
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CEA_ATA_RENT_LAMPORTS_BUMP = void 0;
|
|
3
|
+
exports.CEA_ATA_RENT_LAMPORTS_BUMP = exports.SVM_TOKEN_ACCOUNT_RENT_FALLBACK = exports.SVM_EXECUTED_SUB_TX_RENT_FALLBACK = exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS = exports.SVM_SIGNATURE_FEE_LAMPORTS = void 0;
|
|
4
4
|
exports.deriveSvmCeaPda = deriveSvmCeaPda;
|
|
5
5
|
exports.deriveAtaPubkey = deriveAtaPubkey;
|
|
6
|
+
exports.gasLimitForSvmGasFeeBudget = gasLimitForSvmGasFeeBudget;
|
|
7
|
+
exports.ensureSvmFinalizeGasBudgetQuote = ensureSvmFinalizeGasBudgetQuote;
|
|
8
|
+
exports.getSvmFinalizeGasBudget = getSvmFinalizeGasBudget;
|
|
6
9
|
exports.maybeBumpForCeaAtaRent = maybeBumpForCeaAtaRent;
|
|
7
10
|
const tslib_1 = require("tslib");
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
12
|
+
* SVM finalize gas-budget helpers.
|
|
10
13
|
*
|
|
11
14
|
* The gateway program (svm-gateway) computes per-tx fees with a conditional
|
|
12
15
|
* rent for first-time SPL transfers — see `calculateSplExecuteFees` in
|
|
@@ -14,31 +17,40 @@ const tslib_1 = require("tslib");
|
|
|
14
17
|
*
|
|
15
18
|
* const ataExists = await ceaAtaExists(connection, ceaAta);
|
|
16
19
|
* const ceaAtaRent = ataExists ? 0n : BigInt(getMinimumBalanceForRentExemption(165));
|
|
17
|
-
* gasFee = executedTxRent + ceaAtaRent + COMPUTE_BUFFER;
|
|
20
|
+
* gasFee = signatureFee + executedTxRent + ceaAtaRent + COMPUTE_BUFFER;
|
|
18
21
|
*
|
|
19
22
|
* The gateway's on-chain `getOutboundTxGasAndFees` quote does NOT factor in
|
|
20
23
|
* the ATA rent today, so the SDK has to bump `effectiveGasLimit` itself
|
|
21
|
-
* before
|
|
22
|
-
*
|
|
24
|
+
* before building the outbound request. Native-SOL outbounds still need the
|
|
25
|
+
* same base finalize budget plus compute buffer.
|
|
23
26
|
*/
|
|
24
27
|
const web3_js_1 = require("@solana/web3.js");
|
|
25
28
|
const buffer_1 = require("buffer");
|
|
26
29
|
const context_1 = require("./context");
|
|
27
30
|
const chain_1 = require("../../constants/chain");
|
|
31
|
+
const gas_calculator_1 = require("./gas-calculator");
|
|
28
32
|
// ---------------------------------------------------------------------------
|
|
29
33
|
// Constants — mirror gateway test-utils.ts. These are SOL protocol values;
|
|
30
34
|
// they only change if Solana itself adjusts rent rates (effectively never).
|
|
31
35
|
// ---------------------------------------------------------------------------
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports.
|
|
36
|
+
/** Base Solana fee per relayer signature, mirrored from SVM gateway execute.rs. */
|
|
37
|
+
exports.SVM_SIGNATURE_FEE_LAMPORTS = BigInt(5000);
|
|
38
|
+
/** Operational buffer used by SVM gateway tests for tx fees / compute. */
|
|
39
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS = BigInt(100000);
|
|
40
|
+
/** Devnet/mainnet rent-exempt minimum for ExecutedSubTx::LEN = 8 bytes. */
|
|
41
|
+
exports.SVM_EXECUTED_SUB_TX_RENT_FALLBACK = BigInt(946560);
|
|
42
|
+
/** Devnet/mainnet rent-exempt minimum for a 165-byte SPL token account. */
|
|
43
|
+
exports.SVM_TOKEN_ACCOUNT_RENT_FALLBACK = BigInt(2039280);
|
|
44
|
+
/** Back-compat export for older tests/callers: ATA rent + base finalization overhead. */
|
|
45
|
+
exports.CEA_ATA_RENT_LAMPORTS_BUMP = exports.SVM_SIGNATURE_FEE_LAMPORTS +
|
|
46
|
+
exports.SVM_EXECUTED_SUB_TX_RENT_FALLBACK +
|
|
47
|
+
exports.SVM_TOKEN_ACCOUNT_RENT_FALLBACK +
|
|
48
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS;
|
|
38
49
|
/** SVM gateway program ID (matches CHAIN_INFO[SOLANA_DEVNET].lockerContract). */
|
|
39
50
|
const SVM_GATEWAY_PROGRAM = new web3_js_1.PublicKey('CFVSincHYbETh2k7w6u1ENEkjbSLtveRCEBupKidw2VS');
|
|
40
51
|
const TOKEN_PROGRAM_ID = new web3_js_1.PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
|
|
41
52
|
const ASSOCIATED_TOKEN_PROGRAM_ID = new web3_js_1.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
|
53
|
+
const SVM_RENT_RPC_TIMEOUT_MS = 3000;
|
|
42
54
|
// ---------------------------------------------------------------------------
|
|
43
55
|
// PDA derivations
|
|
44
56
|
// ---------------------------------------------------------------------------
|
|
@@ -53,6 +65,138 @@ function deriveAtaPubkey(owner, mint) {
|
|
|
53
65
|
const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
54
66
|
return ata;
|
|
55
67
|
}
|
|
68
|
+
function getRpcUrl(ctx, targetChain) {
|
|
69
|
+
var _a, _b, _c, _d, _e;
|
|
70
|
+
return ((_c = (_b = (_a = ctx.rpcUrls) === null || _a === void 0 ? void 0 : _a[targetChain]) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : (_e = (_d = chain_1.CHAIN_INFO[targetChain]) === null || _d === void 0 ? void 0 : _d.defaultRPC) === null || _e === void 0 ? void 0 : _e[0]);
|
|
71
|
+
}
|
|
72
|
+
function isAccountInitialized(info) {
|
|
73
|
+
return info !== null && info.data.length > 0;
|
|
74
|
+
}
|
|
75
|
+
function withSvmRentRpcTimeout(promise, label) {
|
|
76
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
let timer;
|
|
78
|
+
try {
|
|
79
|
+
return yield Promise.race([
|
|
80
|
+
promise,
|
|
81
|
+
new Promise((_, reject) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
timer = setTimeout(() => reject(new Error(`${label} timed out after ${SVM_RENT_RPC_TIMEOUT_MS}ms`)), SVM_RENT_RPC_TIMEOUT_MS);
|
|
84
|
+
(_b = (_a = timer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
85
|
+
}),
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
if (timer)
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function gasLimitForSvmGasFeeBudget(gasFeeBudget, gasPrice) {
|
|
95
|
+
if (gasPrice <= BigInt(0)) {
|
|
96
|
+
throw new Error(`Cannot derive SVM gasLimit from gasPrice=${gasPrice.toString()}`);
|
|
97
|
+
}
|
|
98
|
+
return (gasFeeBudget + gasPrice - BigInt(1)) / gasPrice;
|
|
99
|
+
}
|
|
100
|
+
function resolveSvmGasLimitUsed(quote) {
|
|
101
|
+
if (quote.gasLimitUsed > BigInt(0) ||
|
|
102
|
+
quote.gasFee <= BigInt(0) ||
|
|
103
|
+
quote.gasPrice <= BigInt(0)) {
|
|
104
|
+
return quote;
|
|
105
|
+
}
|
|
106
|
+
return Object.assign(Object.assign({}, quote), { gasLimitUsed: gasLimitForSvmGasFeeBudget(quote.gasFee, quote.gasPrice) });
|
|
107
|
+
}
|
|
108
|
+
function ensureSvmFinalizeGasBudgetQuote(_a) {
|
|
109
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ ctx, ueaAddress, targetChain, prc20Token, quote, splMintBase58, burnAmount, pathTag, }) {
|
|
110
|
+
const minGasFee = yield getSvmFinalizeGasBudget({
|
|
111
|
+
ctx,
|
|
112
|
+
ueaAddress,
|
|
113
|
+
targetChain,
|
|
114
|
+
splMintBase58,
|
|
115
|
+
burnAmount,
|
|
116
|
+
});
|
|
117
|
+
if (quote.gasFee >= minGasFee) {
|
|
118
|
+
const resolvedQuote = resolveSvmGasLimitUsed(quote);
|
|
119
|
+
(0, context_1.printLog)(ctx, `${pathTag} — SVM finalize gas budget ok: gasFee=${resolvedQuote.gasFee.toString()}, ` +
|
|
120
|
+
`minimum=${minGasFee.toString()}, gasLimit=${resolvedQuote.gasLimitUsed.toString()}`);
|
|
121
|
+
return resolvedQuote;
|
|
122
|
+
}
|
|
123
|
+
const bumpedGasLimit = gasLimitForSvmGasFeeBudget(minGasFee, quote.gasPrice);
|
|
124
|
+
(0, context_1.printLog)(ctx, `${pathTag} — bumping SVM gasLimit ${quote.gasLimitUsed.toString()} → ${bumpedGasLimit.toString()}; ` +
|
|
125
|
+
`gasFee=${quote.gasFee.toString()} below finalize minimum=${minGasFee.toString()}`);
|
|
126
|
+
const bumpedQuote = yield (0, gas_calculator_1.queryOutboundGasFee)(ctx, prc20Token, bumpedGasLimit, targetChain);
|
|
127
|
+
if (bumpedQuote.gasFee < minGasFee) {
|
|
128
|
+
(0, context_1.printLog)(ctx, `${pathTag} — WARNING: bumped SVM gasFee=${bumpedQuote.gasFee.toString()} ` +
|
|
129
|
+
`still below finalize minimum=${minGasFee.toString()}`);
|
|
130
|
+
}
|
|
131
|
+
return resolveSvmGasLimitUsed(bumpedQuote);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns the minimum SVM `gas_fee` budget in lamports for the gateway
|
|
136
|
+
* finalize instruction, including a small compute buffer. If RPC is not
|
|
137
|
+
* available, falls back to Solana protocol rent constants.
|
|
138
|
+
*/
|
|
139
|
+
function getSvmFinalizeGasBudget(input) {
|
|
140
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const { ctx, ueaAddress, targetChain, splMintBase58, burnAmount } = input;
|
|
142
|
+
const needsSplAta = Boolean(splMintBase58) && burnAmount > BigInt(0);
|
|
143
|
+
const rpcUrl = getRpcUrl(ctx, targetChain);
|
|
144
|
+
let executedTxRent = exports.SVM_EXECUTED_SUB_TX_RENT_FALLBACK;
|
|
145
|
+
let ataRent = BigInt(0);
|
|
146
|
+
if (!needsSplAta) {
|
|
147
|
+
const budget = exports.SVM_SIGNATURE_FEE_LAMPORTS +
|
|
148
|
+
executedTxRent +
|
|
149
|
+
ataRent +
|
|
150
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS;
|
|
151
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — no SPL ATA needed for ${targetChain}; ` +
|
|
152
|
+
`using fallback base budget ${budget.toString()}`);
|
|
153
|
+
return budget;
|
|
154
|
+
}
|
|
155
|
+
if (!rpcUrl) {
|
|
156
|
+
ataRent = exports.SVM_TOKEN_ACCOUNT_RENT_FALLBACK;
|
|
157
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — no Solana RPC URL for ${targetChain}; ` +
|
|
158
|
+
`using fallback budget ${(exports.SVM_SIGNATURE_FEE_LAMPORTS +
|
|
159
|
+
executedTxRent +
|
|
160
|
+
ataRent +
|
|
161
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS).toString()}`);
|
|
162
|
+
return (exports.SVM_SIGNATURE_FEE_LAMPORTS +
|
|
163
|
+
executedTxRent +
|
|
164
|
+
ataRent +
|
|
165
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS);
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const conn = new web3_js_1.Connection(rpcUrl, 'confirmed');
|
|
169
|
+
executedTxRent = BigInt(yield withSvmRentRpcTimeout(conn.getMinimumBalanceForRentExemption(8), 'getMinimumBalanceForRentExemption(8)'));
|
|
170
|
+
if (needsSplAta && splMintBase58) {
|
|
171
|
+
const ceaPda = deriveSvmCeaPda(ueaAddress);
|
|
172
|
+
const splMint = new web3_js_1.PublicKey(splMintBase58);
|
|
173
|
+
const ceaAta = deriveAtaPubkey(ceaPda, splMint);
|
|
174
|
+
const info = yield withSvmRentRpcTimeout(conn.getAccountInfo(ceaAta), `getAccountInfo(${ceaAta.toBase58()})`);
|
|
175
|
+
if (!isAccountInitialized(info)) {
|
|
176
|
+
ataRent = BigInt(yield withSvmRentRpcTimeout(conn.getMinimumBalanceForRentExemption(165), 'getMinimumBalanceForRentExemption(165)'));
|
|
177
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — CEA ATA ${ceaAta.toBase58()} not deployed on ${targetChain}; ` +
|
|
178
|
+
`including ${ataRent.toString()} lamports ATA rent`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — CEA ATA ${ceaAta.toBase58()} already deployed on ${targetChain}; no ATA rent`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
ataRent = exports.SVM_TOKEN_ACCOUNT_RENT_FALLBACK;
|
|
187
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — RPC error on ${targetChain}: ` +
|
|
188
|
+
`${err instanceof Error ? err.message : String(err)}; using fallback rents`);
|
|
189
|
+
}
|
|
190
|
+
const budget = exports.SVM_SIGNATURE_FEE_LAMPORTS +
|
|
191
|
+
executedTxRent +
|
|
192
|
+
ataRent +
|
|
193
|
+
exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS;
|
|
194
|
+
(0, context_1.printLog)(ctx, `getSvmFinalizeGasBudget — budget=${budget.toString()} ` +
|
|
195
|
+
`(signature=${exports.SVM_SIGNATURE_FEE_LAMPORTS}, executedTxRent=${executedTxRent}, ataRent=${ataRent}, ` +
|
|
196
|
+
`computeBuffer=${exports.SVM_FINALIZE_COMPUTE_BUFFER_LAMPORTS})`);
|
|
197
|
+
return budget;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
56
200
|
/**
|
|
57
201
|
* Returns the (possibly bumped) effectiveGasLimit. Logs the decision via
|
|
58
202
|
* printLog. On any RPC failure or invalid input, logs a warning and returns
|
|
@@ -61,14 +205,13 @@ function deriveAtaPubkey(owner, mint) {
|
|
|
61
205
|
*/
|
|
62
206
|
function maybeBumpForCeaAtaRent(input) {
|
|
63
207
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
var _a, _b, _c, _d, _e;
|
|
65
208
|
const { ctx, ueaAddress, targetChain, splMintBase58, burnAmount, effectiveGasLimit, } = input;
|
|
66
209
|
// Only applies to SPL outbounds. Native SOL outbounds use the gateway's
|
|
67
210
|
// calculateSolExecuteFees which has no ATA conditional.
|
|
68
211
|
if (!splMintBase58 || burnAmount === BigInt(0)) {
|
|
69
212
|
return effectiveGasLimit;
|
|
70
213
|
}
|
|
71
|
-
const rpcUrl = (
|
|
214
|
+
const rpcUrl = getRpcUrl(ctx, targetChain);
|
|
72
215
|
if (!rpcUrl) {
|
|
73
216
|
(0, context_1.printLog)(ctx, `maybeBumpForCeaAtaRent — no Solana RPC URL for ${targetChain}; skipping rent bump`);
|
|
74
217
|
return effectiveGasLimit;
|
|
@@ -78,7 +221,7 @@ function maybeBumpForCeaAtaRent(input) {
|
|
|
78
221
|
const splMint = new web3_js_1.PublicKey(splMintBase58);
|
|
79
222
|
const ceaAta = deriveAtaPubkey(ceaPda, splMint);
|
|
80
223
|
const conn = new web3_js_1.Connection(rpcUrl, 'confirmed');
|
|
81
|
-
const info = yield conn.getAccountInfo(ceaAta);
|
|
224
|
+
const info = yield withSvmRentRpcTimeout(conn.getAccountInfo(ceaAta), `getAccountInfo(${ceaAta.toBase58()})`);
|
|
82
225
|
const ataExists = info !== null && info.data.length > 0;
|
|
83
226
|
if (!ataExists) {
|
|
84
227
|
const bumped = effectiveGasLimit + exports.CEA_ATA_RENT_LAMPORTS_BUMP;
|
|
@@ -16,6 +16,7 @@ const types_1 = require("../../generated/uexecutor/v1/types");
|
|
|
16
16
|
const types_2 = require("../../generated/uexecutor/v2/types");
|
|
17
17
|
const progress_hook_1 = tslib_1.__importDefault(require("../../progress-hook/progress-hook"));
|
|
18
18
|
const progress_hook_types_1 = require("../../progress-hook/progress-hook.types");
|
|
19
|
+
const formatters_1 = require("../../formatters");
|
|
19
20
|
const payload_builders_1 = require("../payload-builders");
|
|
20
21
|
const route_detector_1 = require("../route-detector");
|
|
21
22
|
// ============================================================================
|
|
@@ -58,9 +59,12 @@ function reconstructProgressEvents(universalTxResponse, universalTxData) {
|
|
|
58
59
|
// scoped phase ('outbound' + source-chain). Emitting in both places
|
|
59
60
|
// would double-fire the terminal with a misleading 'push' title on top.
|
|
60
61
|
const isFailed = isPcFailed || isOutboundFailed;
|
|
62
|
+
const pcErrorMsg = (pcTx === null || pcTx === void 0 ? void 0 : pcTx.errorMsg)
|
|
63
|
+
? (0, formatters_1.normalizePcInsufficientFundsError)(pcTx.errorMsg)
|
|
64
|
+
: 'Unknown error';
|
|
61
65
|
const errorMsg = isOutboundFailed
|
|
62
66
|
? 'Outbound transaction failed (status: OUTBOUND_FAILED)'
|
|
63
|
-
:
|
|
67
|
+
: pcErrorMsg;
|
|
64
68
|
// Route 2 / 3 reconstruction — keep parity with live emission from
|
|
65
69
|
// route-handlers.ts (which fires 201/203/207 or 301/303/307 then suppresses
|
|
66
70
|
// R1 IDs via fireProgressHook). Skip the R1 101–107 sequence here; it would
|
|
@@ -70,7 +74,6 @@ function reconstructProgressEvents(universalTxResponse, universalTxData) {
|
|
|
70
74
|
// leg itself failed — so prefer pcTx.errorMsg over the outbound-failed
|
|
71
75
|
// sentinel. The outer `errorMsg` above carries the outbound text when
|
|
72
76
|
// `isOutboundFailed` is set; that path is handled by wait() instead.
|
|
73
|
-
const pcErrorMsg = (pcTx === null || pcTx === void 0 ? void 0 : pcTx.errorMsg) || 'Unknown error';
|
|
74
77
|
// Multichain cascade: a single Push-chain tx that fanned out into >1
|
|
75
78
|
// outbound legs (executeTransactions([tx1, tx2, …])). The cosmos record
|
|
76
79
|
// carries one UniversalTx with multiple outboundTx entries; wrap the
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = 1000;
|
|
2
|
+
export declare const MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = 10000;
|
|
3
|
+
export interface MaxPCForGasCapInput {
|
|
4
|
+
/**
|
|
5
|
+
* Native PC estimate intended for the gas-token swap, excluding protocolFee.
|
|
6
|
+
*/
|
|
7
|
+
gasLegNativePc: bigint;
|
|
8
|
+
/**
|
|
9
|
+
* Protocol fee returned by UniversalCore. Included in nativeValueForGas but
|
|
10
|
+
* excluded from maxPCForGas because UGPC subtracts it before applying the cap.
|
|
11
|
+
*/
|
|
12
|
+
protocolFee?: bigint;
|
|
13
|
+
/**
|
|
14
|
+
* Slippage buffer in basis points. Defaults to 1000 bps (10%).
|
|
15
|
+
*/
|
|
16
|
+
bufferBps?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface MaxPCForGasCapFromNativeValueInput {
|
|
19
|
+
/**
|
|
20
|
+
* Total native PC value planned for sendUniversalTxOutbound msg.value.
|
|
21
|
+
*/
|
|
22
|
+
nativeValueForGas: bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Protocol fee returned by UniversalCore.
|
|
25
|
+
*/
|
|
26
|
+
protocolFee: bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Slippage buffer in basis points. Defaults to 1000 bps (10%).
|
|
29
|
+
*/
|
|
30
|
+
bufferBps?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MaxPCForGasCapQuote {
|
|
33
|
+
/**
|
|
34
|
+
* Value to pass as UniversalExecuteParams.maxPCForGas.
|
|
35
|
+
*/
|
|
36
|
+
maxPCForGas: bigint;
|
|
37
|
+
/**
|
|
38
|
+
* Minimum native PC msg.value that satisfies the cap:
|
|
39
|
+
* protocolFee + maxPCForGas.
|
|
40
|
+
*/
|
|
41
|
+
nativeValueForGas: bigint;
|
|
42
|
+
/**
|
|
43
|
+
* Gas-swap leg before the buffer, excluding protocolFee.
|
|
44
|
+
*/
|
|
45
|
+
gasLegNativePc: bigint;
|
|
46
|
+
protocolFee: bigint;
|
|
47
|
+
bufferBps: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Builds a contract-safe maxPCForGas cap from a native PC gas-leg estimate.
|
|
51
|
+
*
|
|
52
|
+
* UGPC validates maxPCForGas against `msg.value - protocolFee`, so the helper
|
|
53
|
+
* returns the minimum matching nativeValueForGas as well as the cap.
|
|
54
|
+
*/
|
|
55
|
+
export declare function quoteMaxPCForGasCap(input: MaxPCForGasCapInput): MaxPCForGasCapQuote;
|
|
56
|
+
/**
|
|
57
|
+
* Builds a maxPCForGas cap from queryOutboundGasFee's nativeValueForGas and
|
|
58
|
+
* protocolFee fields.
|
|
59
|
+
*/
|
|
60
|
+
export declare function quoteMaxPCForGasCapFromNativeValue(input: MaxPCForGasCapFromNativeValueInput): MaxPCForGasCapQuote;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = void 0;
|
|
4
|
+
exports.quoteMaxPCForGasCap = quoteMaxPCForGasCap;
|
|
5
|
+
exports.quoteMaxPCForGasCapFromNativeValue = quoteMaxPCForGasCapFromNativeValue;
|
|
6
|
+
const BPS_DENOMINATOR = BigInt(10000);
|
|
7
|
+
exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = 1000;
|
|
8
|
+
exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = 10000;
|
|
9
|
+
/**
|
|
10
|
+
* Builds a contract-safe maxPCForGas cap from a native PC gas-leg estimate.
|
|
11
|
+
*
|
|
12
|
+
* UGPC validates maxPCForGas against `msg.value - protocolFee`, so the helper
|
|
13
|
+
* returns the minimum matching nativeValueForGas as well as the cap.
|
|
14
|
+
*/
|
|
15
|
+
function quoteMaxPCForGasCap(input) {
|
|
16
|
+
var _a;
|
|
17
|
+
assertNonNegativeBigInt('gasLegNativePc', input.gasLegNativePc);
|
|
18
|
+
const protocolFee = (_a = input.protocolFee) !== null && _a !== void 0 ? _a : BigInt(0);
|
|
19
|
+
assertNonNegativeBigInt('protocolFee', protocolFee);
|
|
20
|
+
const bufferBps = normalizeBufferBps(input.bufferBps);
|
|
21
|
+
const maxPCForGas = applyBufferCeil(input.gasLegNativePc, bufferBps);
|
|
22
|
+
return {
|
|
23
|
+
maxPCForGas,
|
|
24
|
+
nativeValueForGas: protocolFee + maxPCForGas,
|
|
25
|
+
gasLegNativePc: input.gasLegNativePc,
|
|
26
|
+
protocolFee,
|
|
27
|
+
bufferBps,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds a maxPCForGas cap from queryOutboundGasFee's nativeValueForGas and
|
|
32
|
+
* protocolFee fields.
|
|
33
|
+
*/
|
|
34
|
+
function quoteMaxPCForGasCapFromNativeValue(input) {
|
|
35
|
+
assertNonNegativeBigInt('nativeValueForGas', input.nativeValueForGas);
|
|
36
|
+
assertNonNegativeBigInt('protocolFee', input.protocolFee);
|
|
37
|
+
if (input.nativeValueForGas < input.protocolFee) {
|
|
38
|
+
throw new RangeError('nativeValueForGas must be greater than or equal to protocolFee');
|
|
39
|
+
}
|
|
40
|
+
return quoteMaxPCForGasCap({
|
|
41
|
+
gasLegNativePc: input.nativeValueForGas - input.protocolFee,
|
|
42
|
+
protocolFee: input.protocolFee,
|
|
43
|
+
bufferBps: input.bufferBps,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function normalizeBufferBps(bufferBps) {
|
|
47
|
+
const normalized = bufferBps !== null && bufferBps !== void 0 ? bufferBps : exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS;
|
|
48
|
+
if (!Number.isInteger(normalized) ||
|
|
49
|
+
normalized < 0 ||
|
|
50
|
+
normalized > exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT) {
|
|
51
|
+
throw new RangeError(`bufferBps must be an integer between 0 and ${exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT}`);
|
|
52
|
+
}
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
function applyBufferCeil(amount, bufferBps) {
|
|
56
|
+
if (amount === BigInt(0))
|
|
57
|
+
return BigInt(0);
|
|
58
|
+
const multiplier = BPS_DENOMINATOR + BigInt(bufferBps);
|
|
59
|
+
return (amount * multiplier + BPS_DENOMINATOR - BigInt(1)) / BPS_DENOMINATOR;
|
|
60
|
+
}
|
|
61
|
+
function assertNonNegativeBigInt(name, value) {
|
|
62
|
+
if (value < BigInt(0)) {
|
|
63
|
+
throw new RangeError(`${name} must be non-negative`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=max-pc-for-gas.js.map
|
|
@@ -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, CascadedTxResponse, RescueFundsParams } from './orchestrator.types';
|
|
7
|
+
import { ExecuteParams, UniversalExecuteParams, PreparedUniversalTx, CascadedTxResponse, CascadeExecutionOptions, TransactionExecutionOptions, RescueFundsParams } from './orchestrator.types';
|
|
8
8
|
import { TransactionRoute } from './route-detector';
|
|
9
9
|
export declare class Orchestrator {
|
|
10
10
|
private readonly universalSigner;
|
|
@@ -71,15 +71,16 @@ export declare class Orchestrator {
|
|
|
71
71
|
* Routes 2-4 (multi-chain) delegate to prepareTransaction().send().
|
|
72
72
|
* Route 1 (Push Chain) dispatches to extracted sub-flow modules.
|
|
73
73
|
*/
|
|
74
|
-
execute(params: ExecuteParams | UniversalExecuteParams): Promise<UniversalTxResponse>;
|
|
74
|
+
execute(params: ExecuteParams | UniversalExecuteParams, options?: TransactionExecutionOptions): Promise<UniversalTxResponse>;
|
|
75
75
|
/**
|
|
76
76
|
* Prepare a universal transaction without executing it.
|
|
77
77
|
* Returns a PreparedUniversalTx that can be chained with thenOn() or sent with send().
|
|
78
78
|
*
|
|
79
79
|
* @param params - Universal execution parameters
|
|
80
|
+
* @param options - Optional transaction behavior switches.
|
|
80
81
|
* @returns PreparedUniversalTx with chaining capabilities
|
|
81
82
|
*/
|
|
82
|
-
prepareTransaction(params: UniversalExecuteParams): Promise<PreparedUniversalTx>;
|
|
83
|
+
prepareTransaction(params: UniversalExecuteParams, options?: TransactionExecutionOptions): Promise<PreparedUniversalTx>;
|
|
83
84
|
/**
|
|
84
85
|
* Creates a cascaded transaction builder for nested multi-chain execution.
|
|
85
86
|
* The cascade composes all hops bottom-to-top into a single Push Chain tx.
|
|
@@ -91,9 +92,7 @@ export declare class Orchestrator {
|
|
|
91
92
|
* tracking). Dedups by reference if it matches the init-time hook.
|
|
92
93
|
* @returns Object with send() method
|
|
93
94
|
*/
|
|
94
|
-
createCascadedBuilder(preparedTxs: PreparedUniversalTx[], options?: {
|
|
95
|
-
progressHook?: (event: ProgressEvent) => void;
|
|
96
|
-
}): {
|
|
95
|
+
createCascadedBuilder(preparedTxs: PreparedUniversalTx[], options?: CascadeExecutionOptions): {
|
|
97
96
|
send: () => Promise<CascadedTxResponse>;
|
|
98
97
|
};
|
|
99
98
|
/**
|
|
@@ -105,6 +104,7 @@ export declare class Orchestrator {
|
|
|
105
104
|
protocolFee: bigint;
|
|
106
105
|
nativeValueForGas: bigint;
|
|
107
106
|
gasPrice: bigint;
|
|
107
|
+
gasLimitUsed: bigint;
|
|
108
108
|
}>;
|
|
109
109
|
/**
|
|
110
110
|
* Extracts the first universal sub-tx ID from a Push Chain transaction's Cosmos events.
|
|
@@ -129,9 +129,12 @@ class Orchestrator {
|
|
|
129
129
|
* Routes 2-4 (multi-chain) delegate to prepareTransaction().send().
|
|
130
130
|
* Route 1 (Push Chain) dispatches to extracted sub-flow modules.
|
|
131
131
|
*/
|
|
132
|
-
execute(params) {
|
|
132
|
+
execute(params, options) {
|
|
133
133
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
134
134
|
var _a, _b, _c, _d;
|
|
135
|
+
if (options) {
|
|
136
|
+
params = Object.assign(Object.assign({}, params), { options: Object.assign(Object.assign({}, params.options), options) });
|
|
137
|
+
}
|
|
135
138
|
// Snapshot the caller's active route — `executeMultiChain` recurses into
|
|
136
139
|
// this same method for R2/R3's inner Push-side execution, and without
|
|
137
140
|
// snapshot/restore the recursive `detectRoute(params)` would clobber the
|
|
@@ -285,10 +288,14 @@ class Orchestrator {
|
|
|
285
288
|
* Returns a PreparedUniversalTx that can be chained with thenOn() or sent with send().
|
|
286
289
|
*
|
|
287
290
|
* @param params - Universal execution parameters
|
|
291
|
+
* @param options - Optional transaction behavior switches.
|
|
288
292
|
* @returns PreparedUniversalTx with chaining capabilities
|
|
289
293
|
*/
|
|
290
|
-
prepareTransaction(params) {
|
|
294
|
+
prepareTransaction(params, options) {
|
|
291
295
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
296
|
+
if (options) {
|
|
297
|
+
params = Object.assign(Object.assign({}, params), { options: Object.assign(Object.assign({}, params.options), options) });
|
|
298
|
+
}
|
|
292
299
|
return (0, internals_1.prepareTransaction)(this.ctx, params, this._getCascadeCallbacks());
|
|
293
300
|
});
|
|
294
301
|
}
|
|
@@ -306,7 +313,7 @@ class Orchestrator {
|
|
|
306
313
|
createCascadedBuilder(preparedTxs, options) {
|
|
307
314
|
const perCallHook = options === null || options === void 0 ? void 0 : options.progressHook;
|
|
308
315
|
if (!perCallHook) {
|
|
309
|
-
return (0, internals_1.createCascadedBuilder)(this.ctx, preparedTxs, this._getCascadeCallbacks());
|
|
316
|
+
return (0, internals_1.createCascadedBuilder)(this.ctx, preparedTxs, this._getCascadeCallbacks(), undefined);
|
|
310
317
|
}
|
|
311
318
|
// Wrap ctx.progressHook for the synchronous send() phase — captures every
|
|
312
319
|
// fireProgressHook(ctx, ...) call during pre-flight, composeCascade, and
|