@pushchain/core 5.1.3 → 5.1.4-alpha.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 +29 -6
- package/src/lib/constants/abi/prc20.evm.d.ts +22 -2
- package/src/lib/constants/abi/prc20.evm.js +11 -3
- package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +59 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.js +26 -0
- package/src/lib/constants/chain.d.ts +4 -0
- package/src/lib/constants/chain.js +6 -2
- package/src/lib/index.d.ts +2 -2
- package/src/lib/internal/bs58.d.ts +2 -0
- package/src/lib/internal/bs58.js +7 -0
- package/src/lib/orchestrator/cea-utils.d.ts +0 -9
- package/src/lib/orchestrator/cea-utils.js +15 -4
- package/src/lib/orchestrator/internals/account-manager.d.ts +16 -0
- package/src/lib/orchestrator/internals/account-manager.js +191 -0
- package/src/lib/orchestrator/internals/cascade.d.ts +23 -0
- package/src/lib/orchestrator/internals/cascade.js +945 -0
- package/src/lib/orchestrator/internals/confirmation.d.ts +9 -0
- package/src/lib/orchestrator/internals/confirmation.js +123 -0
- package/src/lib/orchestrator/internals/context.d.ts +38 -0
- package/src/lib/orchestrator/internals/context.js +49 -0
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +11 -0
- package/src/lib/orchestrator/internals/execute-funds-only.js +219 -0
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +11 -0
- package/src/lib/orchestrator/internals/execute-funds-payload.js +222 -0
- package/src/lib/orchestrator/internals/execute-standard.d.ts +13 -0
- package/src/lib/orchestrator/internals/execute-standard.js +225 -0
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +38 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +424 -0
- package/src/lib/orchestrator/internals/gateway-client.d.ts +24 -0
- package/src/lib/orchestrator/internals/gateway-client.js +191 -0
- package/src/lib/orchestrator/internals/helpers.d.ts +26 -0
- package/src/lib/orchestrator/internals/helpers.js +181 -0
- package/src/lib/orchestrator/internals/index.d.ts +24 -0
- package/src/lib/orchestrator/internals/index.js +132 -0
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +49 -0
- package/src/lib/orchestrator/internals/outbound-sync.js +357 -0
- package/src/lib/orchestrator/internals/outbound-tracker.d.ts +8 -0
- package/src/lib/orchestrator/internals/outbound-tracker.js +64 -0
- package/src/lib/orchestrator/internals/payload-builder.d.ts +24 -0
- package/src/lib/orchestrator/internals/payload-builder.js +178 -0
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +32 -0
- package/src/lib/orchestrator/internals/push-chain-tx.js +207 -0
- package/src/lib/orchestrator/internals/quote.d.ts +9 -0
- package/src/lib/orchestrator/internals/quote.js +114 -0
- package/src/lib/orchestrator/internals/rescue.d.ts +20 -0
- package/src/lib/orchestrator/internals/rescue.js +112 -0
- package/src/lib/orchestrator/internals/response-builder.d.ts +26 -0
- package/src/lib/orchestrator/internals/response-builder.js +504 -0
- package/src/lib/orchestrator/internals/route-handlers.d.ts +77 -0
- package/src/lib/orchestrator/internals/route-handlers.js +1192 -0
- package/src/lib/orchestrator/internals/signing.d.ts +27 -0
- package/src/lib/orchestrator/internals/signing.js +258 -0
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +21 -0
- package/src/lib/orchestrator/internals/svm-bridge.js +122 -0
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +35 -0
- package/src/lib/orchestrator/internals/svm-helpers.js +143 -0
- package/src/lib/orchestrator/internals/tx-transformer.d.ts +12 -0
- package/src/lib/orchestrator/internals/tx-transformer.js +120 -0
- package/src/lib/orchestrator/internals/uea-manager.d.ts +17 -0
- package/src/lib/orchestrator/internals/uea-manager.js +164 -0
- package/src/lib/orchestrator/orchestrator.d.ts +33 -431
- package/src/lib/orchestrator/orchestrator.js +124 -6125
- package/src/lib/orchestrator/orchestrator.types.d.ts +11 -10
- package/src/lib/orchestrator/payload-builders.js +34 -8
- package/src/lib/price-fetch/price-fetch.js +19 -7
- package/src/lib/push-chain/push-chain.d.ts +6 -0
- package/src/lib/push-chain/push-chain.js +10 -2
- package/src/lib/push-client/push-client.d.ts +3 -0
- package/src/lib/push-client/push-client.js +21 -31
- package/src/lib/universal/account/account.d.ts +35 -16
- package/src/lib/universal/account/account.js +298 -16
- package/src/lib/universal/signer/signer.d.ts +2 -3
- package/src/lib/universal/signer/signer.js +65 -115
- package/src/lib/universal/universal.types.d.ts +41 -0
- package/src/lib/utils.d.ts +7 -2
- package/src/lib/utils.js +65 -34
- package/src/lib/vm-client/evm-client.js +3 -11
- package/src/lib/vm-client/svm-client.d.ts +0 -4
- package/src/lib/vm-client/svm-client.js +2 -8
- 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/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/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
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { CHAIN, PUSH_NETWORK } from '../constants/enums';
|
|
2
2
|
import { ConversionQuote, MoveableToken, PayableToken } from '../constants/tokens';
|
|
3
|
-
import { AccountStatus } from './orchestrator.types';
|
|
3
|
+
import type { AccountStatus, UniversalTxResponse } from './orchestrator.types';
|
|
4
4
|
import { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { PushClient } from '../push-client/push-client';
|
|
6
|
+
import type { UniversalAccount, UniversalSigner } from '../universal/universal.types';
|
|
7
|
+
import { ExecuteParams, UniversalExecuteParams, PreparedUniversalTx, CascadedTransactionBuilder, RescueFundsParams } from './orchestrator.types';
|
|
7
8
|
export declare class Orchestrator {
|
|
8
9
|
private readonly universalSigner;
|
|
9
10
|
private pushNetwork;
|
|
10
11
|
private readonly rpcUrls;
|
|
11
12
|
private readonly printTraces;
|
|
12
13
|
private progressHook?;
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
private gatewayVersionCache;
|
|
14
|
+
private _pushClient;
|
|
15
|
+
private _pushClientOptions;
|
|
16
|
+
get pushClient(): PushClient;
|
|
17
|
+
accountStatusCache: AccountStatus | null;
|
|
18
|
+
accountStatusReadyPromise?: Promise<void>;
|
|
19
|
+
private get ctx();
|
|
20
|
+
private _getResponseCallbacks;
|
|
21
|
+
private _getCascadeCallbacks;
|
|
22
22
|
constructor(universalSigner: UniversalSigner, pushNetwork: PUSH_NETWORK, rpcUrls?: Partial<Record<CHAIN, string[]>>, printTraces?: boolean, progressHook?: ((progress: ProgressEvent) => void) | undefined);
|
|
23
23
|
/**
|
|
24
24
|
* Read-only accessors for current Orchestrator configuration
|
|
@@ -42,12 +42,6 @@ export declare class Orchestrator {
|
|
|
42
42
|
upgradeAccount(options?: {
|
|
43
43
|
progressHook?: (progress: ProgressEvent) => void;
|
|
44
44
|
}): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Fetches the latest UEA version from UEAFactory contract.
|
|
47
|
-
* This is the version of the newest registered implementation — used as minRequiredVersion.
|
|
48
|
-
* Returns empty string if factory is unavailable.
|
|
49
|
-
*/
|
|
50
|
-
private fetchLatestUEAVersion;
|
|
51
45
|
/**
|
|
52
46
|
* Migrate the CEA contract on an external chain to the latest version.
|
|
53
47
|
* Sends a MIGRATION_SELECTOR payload via Route 2 to trigger CEA upgrade.
|
|
@@ -57,34 +51,21 @@ export declare class Orchestrator {
|
|
|
57
51
|
*/
|
|
58
52
|
migrateCEA(chain: CHAIN): Promise<UniversalTxResponse>;
|
|
59
53
|
/**
|
|
60
|
-
*
|
|
54
|
+
* Rescue stuck funds on a source chain.
|
|
55
|
+
* When a CEA-to-Push inbound transaction fails, tokens get locked in the
|
|
56
|
+
* Vault on the source chain. This triggers a manual revert via TSS to
|
|
57
|
+
* release those funds back to the user.
|
|
61
58
|
*
|
|
62
|
-
*
|
|
63
|
-
* - Route 1 (UOA_TO_PUSH): `to` is a simple address string
|
|
64
|
-
* - Route 2 (UOA_TO_CEA): `to` is `{ address, chain }` targeting external chain
|
|
65
|
-
* - Route 3 (CEA_TO_PUSH): `from.chain` specified, targeting Push Chain
|
|
66
|
-
* - Route 4 (CEA_TO_CEA): `from.chain` specified, targeting external chain
|
|
67
|
-
*
|
|
68
|
-
* @param params - ExecuteParams or UniversalExecuteParams
|
|
59
|
+
* @param params - RescueFundsParams with universalTxId and prc20 token
|
|
69
60
|
* @returns Transaction response
|
|
70
61
|
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Executes a universal transaction with multi-chain routing support.
|
|
74
|
-
* Supports 4 routes:
|
|
75
|
-
* - Route 1: UOA → Push Chain (existing behavior)
|
|
76
|
-
* - Route 2: UOA → CEA (outbound to external chain)
|
|
77
|
-
* - Route 3: CEA → Push Chain (inbound from external chain)
|
|
78
|
-
* - Route 4: CEA → CEA (external chain to external chain via Push)
|
|
79
|
-
*
|
|
80
|
-
* @param params - Universal execution parameters with optional chain targets
|
|
81
|
-
* @returns UniversalTxResponse with chain information
|
|
82
|
-
*/
|
|
62
|
+
rescueFunds(params: RescueFundsParams): Promise<UniversalTxResponse>;
|
|
83
63
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
64
|
+
* Executes a transaction with automatic route detection.
|
|
65
|
+
* Routes 2-4 (multi-chain) delegate to prepareTransaction().send().
|
|
66
|
+
* Route 1 (Push Chain) dispatches to extracted sub-flow modules.
|
|
86
67
|
*/
|
|
87
|
-
|
|
68
|
+
execute(params: ExecuteParams | UniversalExecuteParams): Promise<UniversalTxResponse>;
|
|
88
69
|
/**
|
|
89
70
|
* Prepare a universal transaction without executing it.
|
|
90
71
|
* Returns a PreparedUniversalTx that can be chained with thenOn() or sent with send().
|
|
@@ -94,22 +75,15 @@ export declare class Orchestrator {
|
|
|
94
75
|
*/
|
|
95
76
|
prepareTransaction(params: UniversalExecuteParams): Promise<PreparedUniversalTx>;
|
|
96
77
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
78
|
+
* Creates a cascaded transaction builder for nested multi-chain execution.
|
|
79
|
+
* The cascade composes all hops bottom-to-top into a single Push Chain tx.
|
|
99
80
|
*
|
|
100
|
-
* @param
|
|
101
|
-
* @
|
|
102
|
-
* @param ueaAddress - UEA address
|
|
103
|
-
* @returns HopDescriptor with all metadata
|
|
81
|
+
* @param preparedTxs - Array of prepared transactions
|
|
82
|
+
* @returns CascadedTransactionBuilder
|
|
104
83
|
*/
|
|
105
|
-
|
|
84
|
+
createCascadedBuilder(preparedTxs: PreparedUniversalTx[]): CascadedTransactionBuilder;
|
|
106
85
|
/**
|
|
107
|
-
*
|
|
108
|
-
* Extracted from executeUoaToCea for reuse.
|
|
109
|
-
*
|
|
110
|
-
* @param prc20Token - PRC-20 token address
|
|
111
|
-
* @param gasLimit - Gas limit for the outbound
|
|
112
|
-
* @returns gasToken address and gasFee amount
|
|
86
|
+
* Queries gas fee for an outbound transaction from the UniversalCore contract.
|
|
113
87
|
*/
|
|
114
88
|
queryOutboundGasFee(prc20Token: `0x${string}`, gasLimit: bigint): Promise<{
|
|
115
89
|
gasToken: `0x${string}`;
|
|
@@ -119,267 +93,13 @@ export declare class Orchestrator {
|
|
|
119
93
|
gasPrice: bigint;
|
|
120
94
|
}>;
|
|
121
95
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* @param hops - Array of HopDescriptors from prepared transactions
|
|
126
|
-
* @returns Array of CascadeSegments
|
|
127
|
-
*/
|
|
128
|
-
classifyIntoSegments(hops: HopDescriptor[]): CascadeSegment[];
|
|
129
|
-
/**
|
|
130
|
-
* Map route to segment type
|
|
131
|
-
*/
|
|
132
|
-
private getSegmentType;
|
|
133
|
-
/**
|
|
134
|
-
* Compose cascade from segments using bottom-to-top nesting.
|
|
135
|
-
* Processes segments in reverse order, building nested payloads.
|
|
136
|
-
*
|
|
137
|
-
* @param segments - Classified segments from classifyIntoSegments()
|
|
138
|
-
* @param ueaAddress - UEA address
|
|
139
|
-
* @returns Final MultiCall[] to execute as the initial UEA multicall
|
|
140
|
-
*/
|
|
141
|
-
composeCascade(segments: CascadeSegment[], ueaAddress: `0x${string}`, ueaBalance?: bigint, ueaNonce?: bigint): MultiCall[];
|
|
142
|
-
/**
|
|
143
|
-
* Creates a cascaded transaction builder for nested multi-chain execution.
|
|
144
|
-
* The cascade composes all hops bottom-to-top into a single Push Chain tx.
|
|
145
|
-
*
|
|
146
|
-
* @param preparedTxs - Array of prepared transactions
|
|
147
|
-
* @returns CascadedTransactionBuilder
|
|
148
|
-
*/
|
|
149
|
-
createCascadedBuilder(preparedTxs: PreparedUniversalTx[]): CascadedTransactionBuilder;
|
|
150
|
-
/**
|
|
151
|
-
* @deprecated Use createCascadedBuilder instead.
|
|
152
|
-
* Creates a chained transaction builder for sequential multi-chain execution.
|
|
153
|
-
*
|
|
154
|
-
* @param transactions - Array of transactions to execute in sequence
|
|
155
|
-
* @returns ChainedTransactionBuilder
|
|
156
|
-
*/
|
|
157
|
-
createChainedBuilder(transactions: UniversalExecuteParams[]): ChainedTransactionBuilder;
|
|
158
|
-
/**
|
|
159
|
-
* Route 2: Execute outbound transaction from Push Chain to external CEA
|
|
160
|
-
*
|
|
161
|
-
* This method builds a multicall that executes on Push Chain (from UEA context):
|
|
162
|
-
* 1. Approves the gateway to spend PRC-20 tokens (if needed)
|
|
163
|
-
* 2. Calls sendUniversalTxOutbound on UniversalGatewayPC precompile
|
|
164
|
-
*
|
|
165
|
-
* The multicall is executed through the normal execute() flow which handles
|
|
166
|
-
* fee-locking on the origin chain and signature verification.
|
|
167
|
-
*
|
|
168
|
-
* @param params - Universal execution parameters with ChainTarget
|
|
169
|
-
* @returns UniversalTxResponse
|
|
170
|
-
*/
|
|
171
|
-
private executeUoaToCea;
|
|
172
|
-
/**
|
|
173
|
-
* Route 2 for SVM targets: Outbound from Push Chain to Solana.
|
|
174
|
-
*
|
|
175
|
-
* Three cases:
|
|
176
|
-
* 1. Withdraw SOL: Burn pSOL on Push Chain, recipient gets native SOL
|
|
177
|
-
* 2. Withdraw SPL: Burn PRC-20 on Push Chain, recipient gets SPL token
|
|
178
|
-
* 3. Execute (CPI): Burn pSOL + execute CPI on target Solana program
|
|
179
|
-
*
|
|
180
|
-
* @param params - Universal execution parameters
|
|
181
|
-
* @param target - ChainTarget with Solana chain and hex address
|
|
182
|
-
* @returns UniversalTxResponse
|
|
183
|
-
*/
|
|
184
|
-
private executeUoaToCeaSvm;
|
|
185
|
-
/**
|
|
186
|
-
* Route 3: Execute inbound transaction from CEA to Push Chain
|
|
187
|
-
*
|
|
188
|
-
* This route instructs CEA on an external chain to call sendUniversalTxFromCEA,
|
|
189
|
-
* bridging funds/payloads back to Push Chain.
|
|
190
|
-
*
|
|
191
|
-
* Flow:
|
|
192
|
-
* 1. Build multicall for CEA: [approve Gateway (if ERC20), sendUniversalTxFromCEA]
|
|
193
|
-
* 2. Execute via Route 2 (UOA → CEA) with PAYLOAD-only (CEA uses its own funds)
|
|
194
|
-
* 3. CEA executes multicall, Gateway locks funds, relayer mints PRC-20 on Push Chain
|
|
195
|
-
*
|
|
196
|
-
* @param params - Universal execution parameters with from.chain specified
|
|
197
|
-
* @returns UniversalTxResponse
|
|
198
|
-
*/
|
|
199
|
-
private executeCeaToPush;
|
|
200
|
-
/**
|
|
201
|
-
* Route 3 SVM: Execute CEA-to-Push for Solana chains.
|
|
202
|
-
*
|
|
203
|
-
* Unlike EVM Route 3 which builds CEA multicalls, SVM Route 3 encodes a
|
|
204
|
-
* `send_universal_tx_to_uea` instruction as an execute payload targeting
|
|
205
|
-
* the SVM gateway program (self-call). The drain amount is embedded in
|
|
206
|
-
* the instruction data, not in the outbound request amount.
|
|
207
|
-
*/
|
|
208
|
-
private executeCeaToPushSvm;
|
|
209
|
-
/**
|
|
210
|
-
* Route 4: Execute CEA to CEA transaction via Push Chain
|
|
211
|
-
*
|
|
212
|
-
* @param params - Universal execution parameters with from.chain and to.chain
|
|
213
|
-
* @returns UniversalTxResponse
|
|
214
|
-
*/
|
|
215
|
-
private executeCeaToCea;
|
|
216
|
-
/**
|
|
217
|
-
* Build payload for a specific route
|
|
218
|
-
*/
|
|
219
|
-
private buildPayloadForRoute;
|
|
220
|
-
/**
|
|
221
|
-
* Convert UniversalExecuteParams to ExecuteParams for backwards compatibility
|
|
222
|
-
*/
|
|
223
|
-
private toExecuteParams;
|
|
224
|
-
/**
|
|
225
|
-
* Get the UniversalGatewayPC address for the current Push network
|
|
226
|
-
*/
|
|
227
|
-
private getUniversalGatewayPCAddress;
|
|
228
|
-
/**
|
|
229
|
-
* Get the native PRC-20 token address on Push Chain for a target external chain.
|
|
230
|
-
* Maps chains to their native asset representations on Push Chain.
|
|
231
|
-
*
|
|
232
|
-
* @param targetChain - The target external chain
|
|
233
|
-
* @returns PRC-20 token address on Push Chain
|
|
234
|
-
*/
|
|
235
|
-
private getNativePRC20ForChain;
|
|
236
|
-
/**
|
|
237
|
-
* Get CAIP-2 chain namespace for a chain
|
|
238
|
-
*/
|
|
239
|
-
private getChainNamespace;
|
|
240
|
-
/**
|
|
241
|
-
* Locks a fee on the origin chain by interacting with the chain's fee-locker contract.
|
|
242
|
-
*
|
|
243
|
-
* @param amount - Fee amount in USDC (8 Decimals)
|
|
244
|
-
* @param executionHash - Optional execution payload hash (default: zeroHash)
|
|
245
|
-
* @returns Transaction hash bytes
|
|
246
|
-
*/
|
|
247
|
-
private lockFee;
|
|
248
|
-
private _buildUniversalTxRequest;
|
|
249
|
-
/**
|
|
250
|
-
* Returns the resolved gateway version for the current origin chain.
|
|
251
|
-
* Checks the per-chain runtime cache first, then falls back to static config.
|
|
252
|
-
* TODO: Remove V0 fallback once all chains are upgraded to V1.
|
|
253
|
-
*/
|
|
254
|
-
private getGatewayVersion;
|
|
255
|
-
/**
|
|
256
|
-
* Returns true if the current origin chain uses the V1 gateway (revertRecipient address).
|
|
257
|
-
*/
|
|
258
|
-
private isV1Gateway;
|
|
259
|
-
/**
|
|
260
|
-
* Returns the correct gateway ABI for the given version.
|
|
261
|
-
*/
|
|
262
|
-
private getGatewayAbiForVersion;
|
|
263
|
-
/**
|
|
264
|
-
* Returns the correct gateway ABI based on the origin chain's gateway version.
|
|
265
|
-
*/
|
|
266
|
-
private getGatewayAbi;
|
|
267
|
-
/**
|
|
268
|
-
* Converts a V0 UniversalTxRequest to V1 format.
|
|
269
|
-
*/
|
|
270
|
-
private toGatewayRequestV1;
|
|
271
|
-
/**
|
|
272
|
-
* Converts a V0 UniversalTxRequest to the correct format based on gateway version.
|
|
273
|
-
*/
|
|
274
|
-
private toGatewayRequest;
|
|
275
|
-
/**
|
|
276
|
-
* Converts a V0 UniversalTokenTxRequest to V1 format.
|
|
277
|
-
*/
|
|
278
|
-
private toGatewayTokenRequestV1;
|
|
279
|
-
/**
|
|
280
|
-
* Converts a V0 UniversalTokenTxRequest to the correct format based on gateway version.
|
|
281
|
-
*/
|
|
282
|
-
private toGatewayTokenRequest;
|
|
283
|
-
/**
|
|
284
|
-
* Sends a gateway transaction with V1-first, V0-fallback strategy.
|
|
285
|
-
*
|
|
286
|
-
* Strategy:
|
|
287
|
-
* 1. Try V1 (revertRecipient address format) first.
|
|
288
|
-
* 2. If V1 fails (contract not yet upgraded), retry with V0 (revertInstruction struct).
|
|
289
|
-
* 3. Cache the working version per chain so subsequent calls skip the fallback.
|
|
290
|
-
*
|
|
291
|
-
* TODO: Remove V0 fallback once all chains are upgraded to V1. After that,
|
|
292
|
-
* delete this method and call writeContract directly with V1 ABI.
|
|
293
|
-
*/
|
|
294
|
-
private sendGatewayTxWithFallback;
|
|
295
|
-
/**
|
|
296
|
-
* Sends a gateway token transaction with V1-first, V0-fallback strategy.
|
|
297
|
-
* Same as sendGatewayTxWithFallback but for UniversalTokenTxRequest (gas token path).
|
|
298
|
-
*
|
|
299
|
-
* TODO: Remove V0 fallback once all chains are upgraded to V1.
|
|
300
|
-
*/
|
|
301
|
-
private sendGatewayTokenTxWithFallback;
|
|
302
|
-
/**
|
|
303
|
-
* Builds the SVM UniversalTxRequest object from an existing EVM-style UniversalTxRequest.
|
|
304
|
-
* This allows reusing the same request shape for both EVM and SVM while only translating
|
|
305
|
-
* field encodings (addresses, bytes) to the Solana program format.
|
|
306
|
-
*/
|
|
307
|
-
private _buildSvmUniversalTxRequestFromReq;
|
|
308
|
-
/**
|
|
309
|
-
* Builds the SVM UniversalTxRequest object expected by the Solana gateway program.
|
|
310
|
-
* Shape mirrors the request used in `svm-gateway` tests.
|
|
311
|
-
*/
|
|
312
|
-
private _buildSvmUniversalTxRequest;
|
|
313
|
-
private _getSvmProtocolFee;
|
|
314
|
-
private signUniversalPayload;
|
|
315
|
-
/**
|
|
316
|
-
* Signs a MigrationPayload for UEA upgrade.
|
|
317
|
-
* EVM: EIP-712 signTypedData. SVM: manual hash + signMessage (same pattern as signUniversalPayload).
|
|
318
|
-
*/
|
|
319
|
-
private signMigrationPayload;
|
|
320
|
-
/**
|
|
321
|
-
* Computes the EIP-712 struct hash for MigrationPayload (used by SVM path).
|
|
322
|
-
* Mirrors computeExecutionHash but for the MigrationPayload type.
|
|
323
|
-
*/
|
|
324
|
-
private computeMigrationHash;
|
|
325
|
-
/**
|
|
326
|
-
* Sends a custom Cosmos tx to Push Chain (gasless) to execute user intent.
|
|
327
|
-
*/
|
|
328
|
-
private sendUniversalTx;
|
|
329
|
-
/**
|
|
330
|
-
* Sends a EVM trx on Push Chain
|
|
331
|
-
* @dev - Only to be used from universal signer is on Push chain
|
|
332
|
-
* @param execute
|
|
333
|
-
* @returns Cosmos Tx Response for a given Evm Tx
|
|
334
|
-
*/
|
|
335
|
-
private sendPushTx;
|
|
336
|
-
/**
|
|
337
|
-
* Computes the EIP-712 digest hash for the UniversalPayload structure.
|
|
338
|
-
* This is the message that should be signed by the user's wallet (e.g., Solana signer).
|
|
339
|
-
*
|
|
340
|
-
* The resulting hash is equivalent to:
|
|
341
|
-
* keccak256("\x19\x01" || domainSeparator || structHash)
|
|
342
|
-
*
|
|
343
|
-
* @param chainId - EVM chain ID of the destination chain (Push Chain)
|
|
344
|
-
* @param verifyingContract - Address of the verifying contract (i.e., the user's UEA smart wallet)
|
|
345
|
-
* @param version - Optional EIP-712 domain version (default: '0.1.0')
|
|
346
|
-
* @param payload - Execution details encoded into the UniversalPayload struct
|
|
347
|
-
* @returns keccak256 digest to be signed by the user
|
|
348
|
-
*/
|
|
349
|
-
private computeExecutionHash;
|
|
350
|
-
/**
|
|
351
|
-
* ABI-encodes a UniversalPayload struct to bytes, matching the Solidity layout.
|
|
352
|
-
* This mirrors abi.encode(UniversalPayload) in the EVM contracts.
|
|
353
|
-
*/
|
|
354
|
-
private encodeUniversalPayload;
|
|
355
|
-
/**
|
|
356
|
-
* Encodes a UniversalPayload into Borsh bytes for the SVM universal gateway.
|
|
357
|
-
* Layout mirrors Rust `UniversalPayload`:
|
|
358
|
-
* to: [u8; 20],
|
|
359
|
-
* value: u64,
|
|
360
|
-
* data: Vec<u8> (u32 LE len + bytes),
|
|
361
|
-
* gas_limit: u64,
|
|
362
|
-
* max_fee_per_gas: u64,
|
|
363
|
-
* max_priority_fee_per_gas: u64,
|
|
364
|
-
* nonce: u64,
|
|
365
|
-
* deadline: i64,
|
|
366
|
-
* v_type: u8 (0 = SignedVerification, 1 = UniversalTxVerification)
|
|
367
|
-
*/
|
|
368
|
-
private encodeUniversalPayloadSvm;
|
|
369
|
-
/**
|
|
370
|
-
* Reconstructs SEND-TX-* progress events from on-chain transaction data.
|
|
371
|
-
* Used by trackTransaction to replay progress for already-completed transactions.
|
|
372
|
-
*
|
|
373
|
-
* @param universalTxResponse - The transformed transaction response
|
|
374
|
-
* @param universalTxData - Optional UniversalTx data from gRPC query (for cross-chain txs)
|
|
375
|
-
* @returns Array of ProgressEvent objects to emit
|
|
376
|
-
*/
|
|
377
|
-
private reconstructProgressEvents;
|
|
96
|
+
* Extracts the first universal sub-tx ID from a Push Chain transaction's Cosmos events.
|
|
97
|
+
*/
|
|
98
|
+
extractUniversalSubTxIdFromTx(pushChainTxHash: string): Promise<string | null>;
|
|
378
99
|
/**
|
|
379
|
-
*
|
|
380
|
-
* Used by trackTransaction to infer the route when it's not set by execute().
|
|
100
|
+
* Extracts all universal sub-tx IDs from a cascaded Push Chain transaction.
|
|
381
101
|
*/
|
|
382
|
-
|
|
102
|
+
extractAllUniversalSubTxIds(pushChainTxHash: string): Promise<string[]>;
|
|
383
103
|
/**
|
|
384
104
|
* Tracks a transaction by hash on Push Chain and returns UniversalTxResponse.
|
|
385
105
|
* Reconstructs and replays SEND-TX-* progress events for completed transactions.
|
|
@@ -389,65 +109,6 @@ export declare class Orchestrator {
|
|
|
389
109
|
* @returns Promise resolving to UniversalTxResponse with wait() and progressHook() methods
|
|
390
110
|
*/
|
|
391
111
|
trackTransaction(txHash: string, options?: import('./orchestrator.types').TrackTransactionOptions): Promise<UniversalTxResponse>;
|
|
392
|
-
/**
|
|
393
|
-
* Returns the Push Chain enum value for the current network
|
|
394
|
-
*/
|
|
395
|
-
private getPushChainForNetwork;
|
|
396
|
-
/**
|
|
397
|
-
* Compute UniversalTxId for Push Chain originated outbound transactions.
|
|
398
|
-
* Formula: keccak256("eip155:{pushChainId}:{pushChainTxHash}")
|
|
399
|
-
*
|
|
400
|
-
* @param pushChainTxHash - The Push Chain transaction hash
|
|
401
|
-
* @returns The UniversalTxId (keccak256 hash)
|
|
402
|
-
*/
|
|
403
|
-
private computeUniversalTxId;
|
|
404
|
-
/**
|
|
405
|
-
* Extract universalsubTxId from a Push Chain transaction by fetching Cosmos events.
|
|
406
|
-
* The universalsubTxId is found in the 'outbound_created' Cosmos event (attribute 'utx_id'),
|
|
407
|
-
* NOT in the EVM event data.
|
|
408
|
-
*
|
|
409
|
-
* @param pushChainTxHash - The Push Chain transaction hash
|
|
410
|
-
* @returns The universalsubTxId or null if not found
|
|
411
|
-
*/
|
|
412
|
-
extractUniversalSubTxIdFromTx(pushChainTxHash: string): Promise<string | null>;
|
|
413
|
-
/**
|
|
414
|
-
* Extract ALL universalSubTxIds from a Push Chain transaction.
|
|
415
|
-
* For cascaded transactions, a single Push Chain tx may emit multiple
|
|
416
|
-
* outbound_created events, each with its own utx_id.
|
|
417
|
-
*
|
|
418
|
-
* @param pushChainTxHash - The Push Chain transaction hash
|
|
419
|
-
* @returns Array of universalSubTxIds (may be empty)
|
|
420
|
-
*/
|
|
421
|
-
extractAllUniversalSubTxIds(pushChainTxHash: string): Promise<string[]>;
|
|
422
|
-
/**
|
|
423
|
-
* Convert CAIP-2 namespace (e.g., "eip155:97") to CHAIN enum
|
|
424
|
-
*
|
|
425
|
-
* @param namespace - CAIP-2 chain namespace string
|
|
426
|
-
* @returns CHAIN enum value or null if not found
|
|
427
|
-
*/
|
|
428
|
-
private chainFromNamespace;
|
|
429
|
-
private static readonly OUTBOUND_INITIAL_WAIT_MS;
|
|
430
|
-
private static readonly OUTBOUND_POLL_INTERVAL_MS;
|
|
431
|
-
private static readonly OUTBOUND_MAX_TIMEOUT_MS;
|
|
432
|
-
/**
|
|
433
|
-
* Wait for outbound transaction to complete and return external chain details.
|
|
434
|
-
* @internal Used by .wait() for outbound routes - not part of public API.
|
|
435
|
-
* Uses polling with configurable initial wait, interval, and timeout.
|
|
436
|
-
*
|
|
437
|
-
* Default strategy: 30s initial wait, then poll every 5s, 120s total timeout.
|
|
438
|
-
*
|
|
439
|
-
* @param pushChainTxHash - The Push Chain transaction hash
|
|
440
|
-
* @param options - Polling configuration options
|
|
441
|
-
* @returns External chain tx details
|
|
442
|
-
* @throws Error on timeout
|
|
443
|
-
*/
|
|
444
|
-
private waitForOutboundTx;
|
|
445
|
-
/**
|
|
446
|
-
* Tracks ALL outbound transactions for a cascade with multiple outbound hops
|
|
447
|
-
* (e.g., BNB + Solana). Uses V2 API which returns outboundTx[] with per-outbound
|
|
448
|
-
* status tracking, matching each outbound to the correct hop by destination chain.
|
|
449
|
-
*/
|
|
450
|
-
private waitForAllOutboundTxsV2;
|
|
451
112
|
/**
|
|
452
113
|
* Computes UEA for given UniversalAccount
|
|
453
114
|
* @dev - This fn calls a view fn of Factory Contract
|
|
@@ -458,22 +119,8 @@ export declare class Orchestrator {
|
|
|
458
119
|
address: `0x${string}`;
|
|
459
120
|
deployed: boolean;
|
|
460
121
|
}>;
|
|
461
|
-
private _buildMulticallPayloadData;
|
|
462
|
-
private _sendSVMTxWithFunds;
|
|
463
122
|
computeUEAOffchain(): `0x${string}`;
|
|
464
|
-
/**
|
|
465
|
-
* @dev - Although as of now nonce var is same in evm & svm so switch conditions does not matter
|
|
466
|
-
* @param address UEA address
|
|
467
|
-
* @returns UEA current nonce
|
|
468
|
-
*/
|
|
469
|
-
private getUEANonce;
|
|
470
123
|
getUOA(): UniversalAccount;
|
|
471
|
-
private waitForLockerFeeConfirmation;
|
|
472
|
-
/**
|
|
473
|
-
* Internal helper: fetches the full origin-chain transaction for a given hash,
|
|
474
|
-
* used only for progress-hook context (EVM or Solana).
|
|
475
|
-
*/
|
|
476
|
-
private fetchOriginChainTransactionForProgress;
|
|
477
124
|
/**
|
|
478
125
|
* Quotes exact-output on Uniswap V3 for EVM origin chains using QuoterV2.
|
|
479
126
|
* Returns the minimum required input (amountIn) to receive the target amountOut.
|
|
@@ -482,49 +129,4 @@ export declare class Orchestrator {
|
|
|
482
129
|
from: PayableToken | undefined;
|
|
483
130
|
to: MoveableToken | undefined;
|
|
484
131
|
}): Promise<ConversionQuote>;
|
|
485
|
-
private ensureErc20Allowance;
|
|
486
|
-
/**
|
|
487
|
-
* Ensures we're on Sepolia, returns EVM client and gateway address.
|
|
488
|
-
*/
|
|
489
|
-
private getOriginGatewayContext;
|
|
490
|
-
/**
|
|
491
|
-
* Computes UEA and fetches its nonce if deployed; returns 0 otherwise.
|
|
492
|
-
*/
|
|
493
|
-
private getUeaNonceForExecution;
|
|
494
|
-
/**
|
|
495
|
-
* Returns UEA deployment status and nonce (0 if not deployed).
|
|
496
|
-
*/
|
|
497
|
-
private getUeaStatusAndNonce;
|
|
498
|
-
/**
|
|
499
|
-
* For sendFunds, we will call internally the sendTxWithFunds.
|
|
500
|
-
*/
|
|
501
|
-
private buildGatewayPayloadAndGas;
|
|
502
|
-
/********************************** HELPER FUNCTIONS **************************************************/
|
|
503
|
-
/**
|
|
504
|
-
* Transforms a TransactionReceipt to UniversalTxReceipt format
|
|
505
|
-
*/
|
|
506
|
-
private transformToUniversalTxReceipt;
|
|
507
|
-
/**
|
|
508
|
-
* Transforms a TxResponse to the new UniversalTxResponse format
|
|
509
|
-
*/
|
|
510
|
-
private transformToUniversalTxResponse;
|
|
511
|
-
private bigintReplacer;
|
|
512
|
-
/**
|
|
513
|
-
* Checks if the given chain belongs to the Push Chain ecosystem.
|
|
514
|
-
* Used to differentiate logic for Push-native interactions vs external chains.
|
|
515
|
-
*
|
|
516
|
-
* @param chain - The chain identifier (e.g., PUSH_MAINNET, PUSH_TESTNET_DONUT)
|
|
517
|
-
* @returns True if the chain is a Push chain, false otherwise.
|
|
518
|
-
*/
|
|
519
|
-
private isPushChain;
|
|
520
|
-
private validateMainnetConnection;
|
|
521
|
-
private printLog;
|
|
522
|
-
private executeProgressHook;
|
|
523
|
-
private getSvmGatewayLogIndexFromTx;
|
|
524
|
-
private queryUniversalTxStatusFromGatewayTx;
|
|
525
|
-
private waitForEvmConfirmationsWithCountdown;
|
|
526
|
-
private waitForSvmConfirmationsWithCountdown;
|
|
527
|
-
private fetchUEAVersion;
|
|
528
|
-
private calculateGasAmountFromAmountOutMinETH;
|
|
529
|
-
private calculateNativeAmountForDeposit;
|
|
530
132
|
}
|