@pushchain/core 4.0.14-alpha.0 → 5.1.0
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/lib/constants/abi/cea.evm.d.ts +23 -0
- package/src/lib/constants/abi/cea.evm.js +34 -0
- package/src/lib/constants/abi/cea.evm.js.map +1 -0
- package/src/lib/constants/abi/ceaFactory.evm.d.ts +65 -0
- package/src/lib/constants/abi/ceaFactory.evm.js +41 -0
- package/src/lib/constants/abi/ceaFactory.evm.js.map +1 -0
- package/src/lib/constants/abi/erc20.evm.d.ts +14 -0
- package/src/lib/constants/abi/erc20.evm.js +7 -0
- package/src/lib/constants/abi/erc20.evm.js.map +1 -1
- package/src/lib/constants/abi/index.d.ts +6 -0
- package/src/lib/constants/abi/index.js +15 -1
- package/src/lib/constants/abi/index.js.map +1 -1
- package/src/lib/constants/abi/prc20.evm.d.ts +188 -0
- package/src/lib/constants/abi/prc20.evm.js +130 -0
- package/src/lib/constants/abi/prc20.evm.js.map +1 -0
- package/src/lib/constants/abi/uea-factory.d.ts +30 -0
- package/src/lib/constants/abi/uea-factory.js +25 -0
- package/src/lib/constants/abi/uea-factory.js.map +1 -0
- package/src/lib/constants/abi/universalGateway.evm.d.ts +93 -0
- package/src/lib/constants/abi/universalGateway.evm.js +70 -0
- package/src/lib/constants/abi/universalGateway.evm.js.map +1 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +140 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.js +70 -0
- package/src/lib/constants/abi/universalGatewayPC.evm.js.map +1 -0
- package/src/lib/constants/abi/universalGatewayV0.evm.js +57 -0
- package/src/lib/constants/abi/universalGatewayV0.evm.js.map +1 -1
- package/src/lib/constants/abi/universalGatewayV0.json +1162 -1647
- package/src/lib/constants/chain.d.ts +52 -0
- package/src/lib/constants/chain.js +161 -1
- package/src/lib/constants/chain.js.map +1 -1
- package/src/lib/constants/index.d.ts +9 -1
- package/src/lib/constants/index.js +20 -1
- package/src/lib/constants/index.js.map +1 -1
- package/src/lib/constants/selectors.d.ts +42 -0
- package/src/lib/constants/selectors.js +45 -0
- package/src/lib/constants/selectors.js.map +1 -0
- package/src/lib/constants/tokens.d.ts +41 -0
- package/src/lib/constants/tokens.js +62 -1
- package/src/lib/constants/tokens.js.map +1 -1
- package/src/lib/generated/uexecutor/v2/index.d.ts +2 -0
- package/src/lib/generated/uexecutor/v2/index.js +31 -0
- package/src/lib/generated/uexecutor/v2/index.js.map +1 -0
- package/src/lib/generated/uexecutor/v2/query.d.ts +23 -0
- package/src/lib/generated/uexecutor/v2/query.js +79 -0
- package/src/lib/generated/uexecutor/v2/query.js.map +1 -0
- package/src/lib/generated/uexecutor/v2/types.d.ts +101 -0
- package/src/lib/generated/uexecutor/v2/types.js +660 -0
- package/src/lib/generated/uexecutor/v2/types.js.map +1 -0
- package/src/lib/generated/v1/tx.d.ts +22 -0
- package/src/lib/generated/v1/tx.js +188 -1
- package/src/lib/generated/v1/tx.js.map +1 -1
- package/src/lib/index.d.ts +5 -0
- package/src/lib/index.js +25 -1
- package/src/lib/index.js.map +1 -1
- package/src/lib/orchestrator/cea-utils.d.ts +85 -0
- package/src/lib/orchestrator/cea-utils.js +186 -0
- package/src/lib/orchestrator/cea-utils.js.map +1 -0
- package/src/lib/orchestrator/orchestrator.d.ts +326 -3
- package/src/lib/orchestrator/orchestrator.js +3262 -135
- package/src/lib/orchestrator/orchestrator.js.map +1 -1
- package/src/lib/orchestrator/orchestrator.types.d.ts +487 -0
- package/src/lib/orchestrator/orchestrator.types.js +17 -0
- package/src/lib/orchestrator/orchestrator.types.js.map +1 -1
- package/src/lib/orchestrator/payload-builders.d.ts +210 -1
- package/src/lib/orchestrator/payload-builders.js +481 -0
- package/src/lib/orchestrator/payload-builders.js.map +1 -1
- package/src/lib/orchestrator/route-detector.d.ts +102 -0
- package/src/lib/orchestrator/route-detector.js +355 -0
- package/src/lib/orchestrator/route-detector.js.map +1 -0
- package/src/lib/price-fetch/price-fetch.js +5 -2
- package/src/lib/price-fetch/price-fetch.js.map +1 -1
- package/src/lib/progress-hook/progress-hook.js +43 -0
- package/src/lib/progress-hook/progress-hook.js.map +1 -1
- package/src/lib/progress-hook/progress-hook.types.d.ts +7 -1
- package/src/lib/progress-hook/progress-hook.types.js +7 -0
- package/src/lib/progress-hook/progress-hook.types.js.map +1 -1
- package/src/lib/push-chain/push-chain.d.ts +71 -1
- package/src/lib/push-chain/push-chain.js +70 -1
- package/src/lib/push-chain/push-chain.js.map +1 -1
- package/src/lib/push-client/push-client.d.ts +10 -1
- package/src/lib/push-client/push-client.js +35 -6
- package/src/lib/push-client/push-client.js.map +1 -1
- package/src/lib/vm-client/evm-client.d.ts +3 -1
- package/src/lib/vm-client/evm-client.js +23 -15
- package/src/lib/vm-client/evm-client.js.map +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CEA (Chain Executor Account) Utilities
|
|
4
|
+
*
|
|
5
|
+
* Functions for computing CEA addresses and interacting with CEAFactory contracts
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getCEAAddress = getCEAAddress;
|
|
9
|
+
exports.getPushAccountForCEA = getPushAccountForCEA;
|
|
10
|
+
exports.isCEA = isCEA;
|
|
11
|
+
exports.chainSupportsCEA = chainSupportsCEA;
|
|
12
|
+
exports.chainSupportsOutbound = chainSupportsOutbound;
|
|
13
|
+
exports.getCEAFactoryAddress = getCEAFactoryAddress;
|
|
14
|
+
exports.getAllCEAAddresses = getAllCEAAddresses;
|
|
15
|
+
const tslib_1 = require("tslib");
|
|
16
|
+
const viem_1 = require("viem");
|
|
17
|
+
const chains_1 = require("viem/chains");
|
|
18
|
+
const enums_1 = require("../constants/enums");
|
|
19
|
+
const chain_1 = require("../constants/chain");
|
|
20
|
+
const abi_1 = require("../constants/abi");
|
|
21
|
+
/**
|
|
22
|
+
* Map CHAIN enum to viem chain object
|
|
23
|
+
*/
|
|
24
|
+
const VIEM_CHAINS = {
|
|
25
|
+
[enums_1.CHAIN.ETHEREUM_SEPOLIA]: chains_1.sepolia,
|
|
26
|
+
[enums_1.CHAIN.ARBITRUM_SEPOLIA]: chains_1.arbitrumSepolia,
|
|
27
|
+
[enums_1.CHAIN.BASE_SEPOLIA]: chains_1.baseSepolia,
|
|
28
|
+
[enums_1.CHAIN.BNB_TESTNET]: chains_1.bscTestnet,
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Get viem chain object for a CHAIN enum
|
|
32
|
+
*/
|
|
33
|
+
function getViemChain(chain) {
|
|
34
|
+
const viemChain = VIEM_CHAINS[chain];
|
|
35
|
+
if (!viemChain) {
|
|
36
|
+
throw new Error(`No viem chain mapping for ${chain}`);
|
|
37
|
+
}
|
|
38
|
+
return viemChain;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get CEA address for a UEA on a specific chain
|
|
42
|
+
*
|
|
43
|
+
* @param ueaAddress - UEA address on Push Chain
|
|
44
|
+
* @param chain - Target external chain
|
|
45
|
+
* @param rpcUrl - Optional custom RPC URL
|
|
46
|
+
* @returns CEA address and deployment status
|
|
47
|
+
* @throws Error if chain doesn't have CEAFactory
|
|
48
|
+
*/
|
|
49
|
+
function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
52
|
+
if (!factoryAddress) {
|
|
53
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
54
|
+
}
|
|
55
|
+
const viemChain = getViemChain(chain);
|
|
56
|
+
const client = (0, viem_1.createPublicClient)({
|
|
57
|
+
chain: viemChain,
|
|
58
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
59
|
+
});
|
|
60
|
+
const [cea, isDeployed] = yield client.readContract({
|
|
61
|
+
abi: abi_1.CEA_FACTORY_EVM,
|
|
62
|
+
address: factoryAddress,
|
|
63
|
+
functionName: 'getCEAForPushAccount',
|
|
64
|
+
args: [ueaAddress],
|
|
65
|
+
});
|
|
66
|
+
return { cea, isDeployed };
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get Push Account (UEA) address for a CEA on a specific chain
|
|
71
|
+
*
|
|
72
|
+
* @param ceaAddress - CEA address on external chain
|
|
73
|
+
* @param chain - External chain where CEA is deployed
|
|
74
|
+
* @param rpcUrl - Optional custom RPC URL
|
|
75
|
+
* @returns Push account address on Push Chain
|
|
76
|
+
* @throws Error if chain doesn't have CEAFactory
|
|
77
|
+
*/
|
|
78
|
+
function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
79
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
81
|
+
if (!factoryAddress) {
|
|
82
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
83
|
+
}
|
|
84
|
+
const viemChain = getViemChain(chain);
|
|
85
|
+
const client = (0, viem_1.createPublicClient)({
|
|
86
|
+
chain: viemChain,
|
|
87
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
88
|
+
});
|
|
89
|
+
const uea = yield client.readContract({
|
|
90
|
+
abi: abi_1.CEA_FACTORY_EVM,
|
|
91
|
+
address: factoryAddress,
|
|
92
|
+
functionName: 'getPushAccountForCEA',
|
|
93
|
+
args: [ceaAddress],
|
|
94
|
+
});
|
|
95
|
+
return uea;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if an address is a CEA on a specific chain
|
|
100
|
+
*
|
|
101
|
+
* @param address - Address to check
|
|
102
|
+
* @param chain - External chain to check
|
|
103
|
+
* @param rpcUrl - Optional custom RPC URL
|
|
104
|
+
* @returns True if address is a CEA deployed by the factory
|
|
105
|
+
* @throws Error if chain doesn't have CEAFactory
|
|
106
|
+
*/
|
|
107
|
+
function isCEA(address, chain, rpcUrl) {
|
|
108
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
110
|
+
if (!factoryAddress) {
|
|
111
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
112
|
+
}
|
|
113
|
+
const viemChain = getViemChain(chain);
|
|
114
|
+
const client = (0, viem_1.createPublicClient)({
|
|
115
|
+
chain: viemChain,
|
|
116
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
117
|
+
});
|
|
118
|
+
return client.readContract({
|
|
119
|
+
abi: abi_1.CEA_FACTORY_EVM,
|
|
120
|
+
address: factoryAddress,
|
|
121
|
+
functionName: 'isCEA',
|
|
122
|
+
args: [address],
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if a chain supports CEA operations (EVM only)
|
|
128
|
+
*
|
|
129
|
+
* @param chain - Chain to check
|
|
130
|
+
* @returns True if CEAFactory is available
|
|
131
|
+
*/
|
|
132
|
+
function chainSupportsCEA(chain) {
|
|
133
|
+
return chain_1.CEA_FACTORY_ADDRESSES[chain] !== undefined;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Check if a chain supports outbound operations (Route 2).
|
|
137
|
+
* - For EVM chains: checks CEAFactory availability
|
|
138
|
+
* - For SVM chains: always true (gateway-based, no CEA needed)
|
|
139
|
+
*
|
|
140
|
+
* @param chain - Chain to check
|
|
141
|
+
* @returns True if outbound transactions are supported
|
|
142
|
+
*/
|
|
143
|
+
function chainSupportsOutbound(chain) {
|
|
144
|
+
var _a;
|
|
145
|
+
if (((_a = chain_1.CHAIN_INFO[chain]) === null || _a === void 0 ? void 0 : _a.vm) === enums_1.VM.SVM) {
|
|
146
|
+
return true; // SVM uses gateway program, not CEA
|
|
147
|
+
}
|
|
148
|
+
return chain_1.CEA_FACTORY_ADDRESSES[chain] !== undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get CEAFactory address for a chain
|
|
152
|
+
*
|
|
153
|
+
* @param chain - Target chain
|
|
154
|
+
* @returns CEAFactory address or undefined
|
|
155
|
+
*/
|
|
156
|
+
function getCEAFactoryAddress(chain) {
|
|
157
|
+
return chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get CEA addresses for a UEA across all supported chains
|
|
161
|
+
*
|
|
162
|
+
* @param ueaAddress - UEA address on Push Chain
|
|
163
|
+
* @param rpcUrls - Optional custom RPC URLs per chain
|
|
164
|
+
* @returns Array of CEA addresses per chain
|
|
165
|
+
*/
|
|
166
|
+
function getAllCEAAddresses(ueaAddress, rpcUrls) {
|
|
167
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const chains = Object.keys(chain_1.CEA_FACTORY_ADDRESSES);
|
|
169
|
+
const results = yield Promise.all(chains.map((chain) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
try {
|
|
171
|
+
const { cea, isDeployed } = yield getCEAAddress(ueaAddress, chain, rpcUrls === null || rpcUrls === void 0 ? void 0 : rpcUrls[chain]);
|
|
172
|
+
return { chain, cea, isDeployed };
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
return {
|
|
176
|
+
chain,
|
|
177
|
+
cea: '0x0000000000000000000000000000000000000000',
|
|
178
|
+
isDeployed: false,
|
|
179
|
+
error: error instanceof Error ? error.message : String(error),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
})));
|
|
183
|
+
return results;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=cea-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cea-utils.js","sourceRoot":"","sources":["../../../../../../pack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AK,EAAE,CAAC;gBACf,OAAO;oBACL,KAAK;oBACL,GAAG,EAAE,4CAA6D;oBAClE,UAAU,EAAE,KAAK;oBACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC;YACJ,CAAC;QACH,CAAC,CAAA,CAAC,CACH,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
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
4
|
import { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
4
5
|
import { UniversalAccount, UniversalSigner } from '../universal/universal.types';
|
|
5
|
-
import { ExecuteParams, UniversalTxResponse } from './orchestrator.types';
|
|
6
|
+
import { ExecuteParams, MultiCall, UniversalExecuteParams, UniversalTxResponse, PreparedUniversalTx, ChainedTransactionBuilder, HopDescriptor, CascadeSegment, CascadedTransactionBuilder } from './orchestrator.types';
|
|
6
7
|
export declare class Orchestrator {
|
|
7
8
|
private readonly universalSigner;
|
|
8
9
|
private pushNetwork;
|
|
@@ -11,6 +12,13 @@ export declare class Orchestrator {
|
|
|
11
12
|
private progressHook?;
|
|
12
13
|
private pushClient;
|
|
13
14
|
private ueaVersionCache?;
|
|
15
|
+
private accountStatusCache;
|
|
16
|
+
/**
|
|
17
|
+
* Per-chain cache for detected gateway version (v0 or v1).
|
|
18
|
+
* Populated on first successful gateway tx per chain via try-V1-then-V0 fallback.
|
|
19
|
+
* TODO: Remove this cache + fallback logic once all chains are upgraded to V1.
|
|
20
|
+
*/
|
|
21
|
+
private gatewayVersionCache;
|
|
14
22
|
constructor(universalSigner: UniversalSigner, pushNetwork: PUSH_NETWORK, rpcUrls?: Partial<Record<CHAIN, string[]>>, printTraces?: boolean, progressHook?: ((progress: ProgressEvent) => void) | undefined);
|
|
15
23
|
/**
|
|
16
24
|
* Read-only accessors for current Orchestrator configuration
|
|
@@ -20,9 +28,215 @@ export declare class Orchestrator {
|
|
|
20
28
|
getPrintTraces(): boolean;
|
|
21
29
|
getProgressHook(): ((progress: ProgressEvent) => void) | undefined;
|
|
22
30
|
/**
|
|
23
|
-
*
|
|
31
|
+
* Fetches account status including UEA deployment state and version info.
|
|
32
|
+
* Results are cached — pass forceRefresh to bypass cache.
|
|
33
|
+
*/
|
|
34
|
+
getAccountStatus(options?: {
|
|
35
|
+
forceRefresh?: boolean;
|
|
36
|
+
}): Promise<AccountStatus>;
|
|
37
|
+
/**
|
|
38
|
+
* Upgrades the UEA to the latest implementation version.
|
|
39
|
+
* Sends MsgMigrateUEA Cosmos message with EIP-712 signed MigrationPayload.
|
|
40
|
+
* The UEA contract delegates to the UEAMigration contract to update implementation.
|
|
41
|
+
*/
|
|
42
|
+
upgradeAccount(options?: {
|
|
43
|
+
progressHook?: (progress: ProgressEvent) => void;
|
|
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
|
+
/**
|
|
52
|
+
* Migrate the CEA contract on an external chain to the latest version.
|
|
53
|
+
* Sends a MIGRATION_SELECTOR payload via Route 2 to trigger CEA upgrade.
|
|
54
|
+
*
|
|
55
|
+
* @param chain - The external chain where the CEA should be migrated
|
|
56
|
+
* @returns Transaction response
|
|
57
|
+
*/
|
|
58
|
+
migrateCEA(chain: CHAIN): Promise<UniversalTxResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Executes a transaction with automatic route detection.
|
|
61
|
+
*
|
|
62
|
+
* Supports both simple Push Chain transactions and multi-chain routing:
|
|
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
|
|
69
|
+
* @returns Transaction response
|
|
70
|
+
*/
|
|
71
|
+
execute(params: ExecuteParams | UniversalExecuteParams): Promise<UniversalTxResponse>;
|
|
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
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Internal method for multi-chain transaction routing.
|
|
85
|
+
* Called by execute() when ChainTarget or from.chain is detected.
|
|
86
|
+
*/
|
|
87
|
+
private executeMultiChain;
|
|
88
|
+
/**
|
|
89
|
+
* Prepare a universal transaction without executing it.
|
|
90
|
+
* Returns a PreparedUniversalTx that can be chained with thenOn() or sent with send().
|
|
91
|
+
*
|
|
92
|
+
* @param params - Universal execution parameters
|
|
93
|
+
* @returns PreparedUniversalTx with chaining capabilities
|
|
94
|
+
*/
|
|
95
|
+
prepareTransaction(params: UniversalExecuteParams): Promise<PreparedUniversalTx>;
|
|
96
|
+
/**
|
|
97
|
+
* Build a HopDescriptor for a prepared transaction.
|
|
98
|
+
* Resolves CEA addresses, queries gas fees, and builds multicall arrays.
|
|
99
|
+
*
|
|
100
|
+
* @param params - Original user params
|
|
101
|
+
* @param route - Detected route
|
|
102
|
+
* @param ueaAddress - UEA address
|
|
103
|
+
* @returns HopDescriptor with all metadata
|
|
104
|
+
*/
|
|
105
|
+
private buildHopDescriptor;
|
|
106
|
+
/**
|
|
107
|
+
* Query outbound gas fee from UniversalCore contract.
|
|
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
|
|
113
|
+
*/
|
|
114
|
+
queryOutboundGasFee(prc20Token: `0x${string}`, gasLimit: bigint): Promise<{
|
|
115
|
+
gasToken: `0x${string}`;
|
|
116
|
+
gasFee: bigint;
|
|
117
|
+
protocolFee: bigint;
|
|
118
|
+
nativeValueForGas: bigint;
|
|
119
|
+
gasPrice: bigint;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* Classify hops into segments for cascade composition.
|
|
123
|
+
* Consecutive same-type/same-chain hops are merged.
|
|
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
|
|
24
218
|
*/
|
|
25
|
-
|
|
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;
|
|
26
240
|
/**
|
|
27
241
|
* Locks a fee on the origin chain by interacting with the chain's fee-locker contract.
|
|
28
242
|
*
|
|
@@ -32,6 +246,59 @@ export declare class Orchestrator {
|
|
|
32
246
|
*/
|
|
33
247
|
private lockFee;
|
|
34
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;
|
|
35
302
|
/**
|
|
36
303
|
* Builds the SVM UniversalTxRequest object from an existing EVM-style UniversalTxRequest.
|
|
37
304
|
* This allows reusing the same request shape for both EVM and SVM while only translating
|
|
@@ -43,6 +310,7 @@ export declare class Orchestrator {
|
|
|
43
310
|
* Shape mirrors the request used in `svm-gateway` tests.
|
|
44
311
|
*/
|
|
45
312
|
private _buildSvmUniversalTxRequest;
|
|
313
|
+
private _getSvmProtocolFee;
|
|
46
314
|
private signUniversalPayload;
|
|
47
315
|
/**
|
|
48
316
|
* Sends a custom Cosmos tx to Push Chain (gasless) to execute user intent.
|
|
@@ -110,6 +378,61 @@ export declare class Orchestrator {
|
|
|
110
378
|
* Returns the Push Chain enum value for the current network
|
|
111
379
|
*/
|
|
112
380
|
private getPushChainForNetwork;
|
|
381
|
+
/**
|
|
382
|
+
* Compute UniversalTxId for Push Chain originated outbound transactions.
|
|
383
|
+
* Formula: keccak256("eip155:{pushChainId}:{pushChainTxHash}")
|
|
384
|
+
*
|
|
385
|
+
* @param pushChainTxHash - The Push Chain transaction hash
|
|
386
|
+
* @returns The UniversalTxId (keccak256 hash)
|
|
387
|
+
*/
|
|
388
|
+
private computeUniversalTxId;
|
|
389
|
+
/**
|
|
390
|
+
* Extract universalsubTxId from a Push Chain transaction by fetching Cosmos events.
|
|
391
|
+
* The universalsubTxId is found in the 'outbound_created' Cosmos event (attribute 'utx_id'),
|
|
392
|
+
* NOT in the EVM event data.
|
|
393
|
+
*
|
|
394
|
+
* @param pushChainTxHash - The Push Chain transaction hash
|
|
395
|
+
* @returns The universalsubTxId or null if not found
|
|
396
|
+
*/
|
|
397
|
+
extractUniversalSubTxIdFromTx(pushChainTxHash: string): Promise<string | null>;
|
|
398
|
+
/**
|
|
399
|
+
* Extract ALL universalSubTxIds from a Push Chain transaction.
|
|
400
|
+
* For cascaded transactions, a single Push Chain tx may emit multiple
|
|
401
|
+
* outbound_created events, each with its own utx_id.
|
|
402
|
+
*
|
|
403
|
+
* @param pushChainTxHash - The Push Chain transaction hash
|
|
404
|
+
* @returns Array of universalSubTxIds (may be empty)
|
|
405
|
+
*/
|
|
406
|
+
extractAllUniversalSubTxIds(pushChainTxHash: string): Promise<string[]>;
|
|
407
|
+
/**
|
|
408
|
+
* Convert CAIP-2 namespace (e.g., "eip155:97") to CHAIN enum
|
|
409
|
+
*
|
|
410
|
+
* @param namespace - CAIP-2 chain namespace string
|
|
411
|
+
* @returns CHAIN enum value or null if not found
|
|
412
|
+
*/
|
|
413
|
+
private chainFromNamespace;
|
|
414
|
+
private static readonly OUTBOUND_INITIAL_WAIT_MS;
|
|
415
|
+
private static readonly OUTBOUND_POLL_INTERVAL_MS;
|
|
416
|
+
private static readonly OUTBOUND_MAX_TIMEOUT_MS;
|
|
417
|
+
/**
|
|
418
|
+
* Wait for outbound transaction to complete and return external chain details.
|
|
419
|
+
* @internal Used by .wait() for outbound routes - not part of public API.
|
|
420
|
+
* Uses polling with configurable initial wait, interval, and timeout.
|
|
421
|
+
*
|
|
422
|
+
* Default strategy: 30s initial wait, then poll every 5s, 120s total timeout.
|
|
423
|
+
*
|
|
424
|
+
* @param pushChainTxHash - The Push Chain transaction hash
|
|
425
|
+
* @param options - Polling configuration options
|
|
426
|
+
* @returns External chain tx details
|
|
427
|
+
* @throws Error on timeout
|
|
428
|
+
*/
|
|
429
|
+
private waitForOutboundTx;
|
|
430
|
+
/**
|
|
431
|
+
* Tracks ALL outbound transactions for a cascade with multiple outbound hops
|
|
432
|
+
* (e.g., BNB + Solana). Uses V2 API which returns outboundTx[] with per-outbound
|
|
433
|
+
* status tracking, matching each outbound to the correct hop by destination chain.
|
|
434
|
+
*/
|
|
435
|
+
private waitForAllOutboundTxsV2;
|
|
113
436
|
/**
|
|
114
437
|
* Computes UEA for given UniversalAccount
|
|
115
438
|
* @dev - This fn calls a view fn of Factory Contract
|