@pushchain/core 6.0.20 → 6.0.21
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 +48 -0
- package/package.json +1 -1
- package/src/lib/cache/cache.js +2 -0
- package/src/lib/constants/abi/index.d.ts +1 -0
- package/src/lib/constants/abi/index.js +8 -1
- package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
- package/src/lib/constants/abi/pc20.evm.js +150 -0
- package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
- package/src/lib/constants/abi/prc20.evm.js +97 -0
- package/src/lib/constants/abi/universalGatewayV0.json +1 -1
- package/src/lib/constants/chain.js +38 -8
- package/src/lib/constants/selectors.js +2 -2
- package/src/lib/constants/tokens.js +4 -3
- package/src/lib/formatters.js +16 -6
- package/src/lib/generated/uexecutor/v1/query.js +2 -4
- package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v1/types.js +90 -47
- package/src/lib/generated/uexecutor/v2/query.js +2 -4
- package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
- package/src/lib/generated/uexecutor/v2/types.js +49 -33
- package/src/lib/generated/v1/tx.js +30 -37
- package/src/lib/index.d.ts +3 -0
- package/src/lib/index.js +21 -3
- package/src/lib/internal/buffer.js +1 -2
- package/src/lib/orchestrator/cea-utils.js +73 -83
- package/src/lib/orchestrator/internals/account-manager.js +130 -139
- package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
- package/src/lib/orchestrator/internals/cascade.js +1184 -1059
- package/src/lib/orchestrator/internals/confirmation.js +138 -148
- package/src/lib/orchestrator/internals/error-decoder.js +1 -1
- package/src/lib/orchestrator/internals/errors.js +12 -3
- package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
- package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
- package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
- package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
- package/src/lib/orchestrator/internals/execute-standard.js +339 -342
- package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
- package/src/lib/orchestrator/internals/gateway-client.js +102 -103
- package/src/lib/orchestrator/internals/helpers.js +30 -27
- package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
- package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
- package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
- package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
- package/src/lib/orchestrator/internals/payload-builder.js +119 -100
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
- package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
- package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
- package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
- package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
- package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
- package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
- package/src/lib/orchestrator/internals/pc20/export.js +412 -0
- package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
- package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
- package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
- package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
- package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
- package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
- package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
- package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
- package/src/lib/orchestrator/internals/preflight.js +1 -1
- package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
- package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
- package/src/lib/orchestrator/internals/quote.js +90 -94
- package/src/lib/orchestrator/internals/rescue.js +76 -79
- package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
- package/src/lib/orchestrator/internals/response-builder.js +817 -701
- package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
- package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
- package/src/lib/orchestrator/internals/signing.js +78 -83
- package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
- package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
- package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
- package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
- package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
- package/src/lib/orchestrator/internals/svm-rent.js +163 -141
- package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
- package/src/lib/orchestrator/internals/uea-manager.js +89 -86
- package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
- package/src/lib/orchestrator/orchestrator.js +217 -200
- package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
- package/src/lib/orchestrator/orchestrator.types.js +19 -0
- package/src/lib/orchestrator/payload-builders.d.ts +2 -2
- package/src/lib/orchestrator/payload-builders.js +26 -24
- package/src/lib/orchestrator/route-detector.js +26 -9
- package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
- package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
- package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
- package/src/lib/price-fetch/price-fetch.js +67 -68
- package/src/lib/progress-hook/progress-hook.js +124 -72
- package/src/lib/push-chain/push-chain.js +171 -153
- package/src/lib/push-client/push-client.js +223 -237
- package/src/lib/universal/account/account.js +349 -365
- package/src/lib/universal/signer/signer.js +306 -294
- package/src/lib/universal-tx-detector/auto-detect.js +55 -60
- package/src/lib/universal-tx-detector/cascade.js +160 -172
- package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
- package/src/lib/universal-tx-detector/classify.js +2 -3
- package/src/lib/universal-tx-detector/detector-svm.js +139 -147
- package/src/lib/universal-tx-detector/detector.js +145 -157
- package/src/lib/universal-tx-detector/normalize.js +7 -7
- package/src/lib/utils/external-tx-hash.js +1 -2
- package/src/lib/utils.d.ts +44 -0
- package/src/lib/utils.js +762 -683
- package/src/lib/vm-client/evm-client.js +186 -202
- package/src/lib/vm-client/svm-client.d.ts +1 -1
- package/src/lib/vm-client/svm-client.js +220 -224
- package/src/lib/vm-client/vm-client.types.d.ts +14 -2
package/src/lib/index.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PushChain = exports.buildErc20WithdrawalMulticall = exports.buildMigrationPayload = exports.isValidSolanaHexAddress = exports.isSvmChain = exports.encodeSvmExecutePayload = exports.getAllCEAAddresses = exports.getCEAFactoryAddress = exports.chainSupportsOutbound = exports.chainSupportsCEA = exports.isCEA = exports.getPushAccountForCEA = exports.getCEAAddress = exports.quoteMaxPCForGasCapFromNativeValue = exports.quoteMaxPCForGasCap = exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = exports.isChainTarget = exports.detectRoute = exports.TransactionRoute = exports.parseUEAVersion = void 0;
|
|
3
|
+
exports.PushChain = exports.buildErc20WithdrawalMulticall = exports.buildMigrationPayload = exports.isValidSolanaHexAddress = exports.isSvmChain = exports.encodeSvmExecutePayload = exports.getAllCEAAddresses = exports.getCEAFactoryAddress = exports.chainSupportsOutbound = exports.chainSupportsCEA = exports.isCEA = exports.getPushAccountForCEA = exports.getCEAAddress = exports.quoteMaxPCForGasCapFromNativeValue = exports.quoteMaxPCForGasCap = exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = exports.isChainTarget = exports.detectRoute = exports.TransactionRoute = exports.parseUEAVersion = exports.PC20UnsafeEmptyPayloadError = exports.PC20ExportRevertedError = exports.PC20WrapperPredictionUnavailableError = exports.PC20UnknownChainNamespaceError = exports.InsufficientPC20BalanceError = exports.UnsupportedPC20DestinationError = exports.PC20AmbiguousAddressError = exports.PC20ExpectedButPRC20Error = exports.InvalidPC20MetadataError = exports.PC20FactoryMismatchError = exports.PC20RegistryMismatchError = exports.PC20WrapperNotRegisteredError = exports.PC20TokenChainMismatchError = exports.InvalidPC20AddressError = exports.PC20Error = exports.isPC20Reference = void 0;
|
|
4
4
|
const push_chain_1 = require("./push-chain/push-chain");
|
|
5
5
|
Object.defineProperty(exports, "PushChain", { enumerable: true, get: function () { return push_chain_1.PushChain; } });
|
|
6
|
-
// UEA version utility
|
|
7
6
|
var orchestrator_types_1 = require("./orchestrator/orchestrator.types");
|
|
8
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "isPC20Reference", { enumerable: true, get: function () { return orchestrator_types_1.isPC20Reference; } });
|
|
8
|
+
var errors_1 = require("./orchestrator/internals/pc20/errors");
|
|
9
|
+
Object.defineProperty(exports, "PC20Error", { enumerable: true, get: function () { return errors_1.PC20Error; } });
|
|
10
|
+
Object.defineProperty(exports, "InvalidPC20AddressError", { enumerable: true, get: function () { return errors_1.InvalidPC20AddressError; } });
|
|
11
|
+
Object.defineProperty(exports, "PC20TokenChainMismatchError", { enumerable: true, get: function () { return errors_1.PC20TokenChainMismatchError; } });
|
|
12
|
+
Object.defineProperty(exports, "PC20WrapperNotRegisteredError", { enumerable: true, get: function () { return errors_1.PC20WrapperNotRegisteredError; } });
|
|
13
|
+
Object.defineProperty(exports, "PC20RegistryMismatchError", { enumerable: true, get: function () { return errors_1.PC20RegistryMismatchError; } });
|
|
14
|
+
Object.defineProperty(exports, "PC20FactoryMismatchError", { enumerable: true, get: function () { return errors_1.PC20FactoryMismatchError; } });
|
|
15
|
+
Object.defineProperty(exports, "InvalidPC20MetadataError", { enumerable: true, get: function () { return errors_1.InvalidPC20MetadataError; } });
|
|
16
|
+
Object.defineProperty(exports, "PC20ExpectedButPRC20Error", { enumerable: true, get: function () { return errors_1.PC20ExpectedButPRC20Error; } });
|
|
17
|
+
Object.defineProperty(exports, "PC20AmbiguousAddressError", { enumerable: true, get: function () { return errors_1.PC20AmbiguousAddressError; } });
|
|
18
|
+
Object.defineProperty(exports, "UnsupportedPC20DestinationError", { enumerable: true, get: function () { return errors_1.UnsupportedPC20DestinationError; } });
|
|
19
|
+
Object.defineProperty(exports, "InsufficientPC20BalanceError", { enumerable: true, get: function () { return errors_1.InsufficientPC20BalanceError; } });
|
|
20
|
+
Object.defineProperty(exports, "PC20UnknownChainNamespaceError", { enumerable: true, get: function () { return errors_1.PC20UnknownChainNamespaceError; } });
|
|
21
|
+
Object.defineProperty(exports, "PC20WrapperPredictionUnavailableError", { enumerable: true, get: function () { return errors_1.PC20WrapperPredictionUnavailableError; } });
|
|
22
|
+
Object.defineProperty(exports, "PC20ExportRevertedError", { enumerable: true, get: function () { return errors_1.PC20ExportRevertedError; } });
|
|
23
|
+
Object.defineProperty(exports, "PC20UnsafeEmptyPayloadError", { enumerable: true, get: function () { return errors_1.PC20UnsafeEmptyPayloadError; } });
|
|
24
|
+
// UEA version utility
|
|
25
|
+
var orchestrator_types_2 = require("./orchestrator/orchestrator.types");
|
|
26
|
+
Object.defineProperty(exports, "parseUEAVersion", { enumerable: true, get: function () { return orchestrator_types_2.parseUEAVersion; } });
|
|
9
27
|
// Route detection utilities
|
|
10
28
|
var route_detector_1 = require("./orchestrator/route-detector");
|
|
11
29
|
Object.defineProperty(exports, "TransactionRoute", { enumerable: true, get: function () { return route_detector_1.TransactionRoute; } });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Buffer = void 0;
|
|
5
4
|
const buffer_1 = require("buffer");
|
|
6
|
-
exports.Buffer =
|
|
5
|
+
exports.Buffer = globalThis.Buffer ?? buffer_1.Buffer;
|
|
7
6
|
//# sourceMappingURL=buffer.js.map
|
|
@@ -12,7 +12,6 @@ exports.chainSupportsCEA = chainSupportsCEA;
|
|
|
12
12
|
exports.chainSupportsOutbound = chainSupportsOutbound;
|
|
13
13
|
exports.getCEAFactoryAddress = getCEAFactoryAddress;
|
|
14
14
|
exports.getAllCEAAddresses = getAllCEAAddresses;
|
|
15
|
-
const tslib_1 = require("tslib");
|
|
16
15
|
const viem_1 = require("viem");
|
|
17
16
|
const chains_1 = require("viem/chains");
|
|
18
17
|
const enums_1 = require("../constants/enums");
|
|
@@ -49,33 +48,31 @@ function getViemChain(chain) {
|
|
|
49
48
|
// Cache CEA address per UEA+chain — address is deterministic (CREATE2), but
|
|
50
49
|
// isDeployed can change during execution so we always re-fetch it.
|
|
51
50
|
const ceaAddressCache = new Map();
|
|
52
|
-
function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
transport: (0, viem_1.http)(rpcUrl),
|
|
64
|
-
});
|
|
65
|
-
if (cachedAddress) {
|
|
66
|
-
// Address is cached — only re-check deployment status
|
|
67
|
-
const code = yield client.getCode({ address: cachedAddress });
|
|
68
|
-
return { cea: cachedAddress, isDeployed: code !== undefined && code !== '0x' };
|
|
69
|
-
}
|
|
70
|
-
const [cea, isDeployed] = yield client.readContract({
|
|
71
|
-
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
72
|
-
address: factoryAddress,
|
|
73
|
-
functionName: 'getCEAForPushAccount',
|
|
74
|
-
args: [ueaAddress],
|
|
75
|
-
});
|
|
76
|
-
ceaAddressCache.set(cacheKey, cea);
|
|
77
|
-
return { cea, isDeployed };
|
|
51
|
+
async function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
52
|
+
const cacheKey = `${ueaAddress.toLowerCase()}:${chain}`;
|
|
53
|
+
const cachedAddress = ceaAddressCache.get(cacheKey);
|
|
54
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
55
|
+
if (!factoryAddress) {
|
|
56
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
57
|
+
}
|
|
58
|
+
const viemChain = getViemChain(chain);
|
|
59
|
+
const client = (0, viem_1.createPublicClient)({
|
|
60
|
+
chain: viemChain,
|
|
61
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
78
62
|
});
|
|
63
|
+
if (cachedAddress) {
|
|
64
|
+
// Address is cached — only re-check deployment status
|
|
65
|
+
const code = await client.getCode({ address: cachedAddress });
|
|
66
|
+
return { cea: cachedAddress, isDeployed: code !== undefined && code !== '0x' };
|
|
67
|
+
}
|
|
68
|
+
const [cea, isDeployed] = await client.readContract({
|
|
69
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
70
|
+
address: factoryAddress,
|
|
71
|
+
functionName: 'getCEAForPushAccount',
|
|
72
|
+
args: [ueaAddress],
|
|
73
|
+
});
|
|
74
|
+
ceaAddressCache.set(cacheKey, cea);
|
|
75
|
+
return { cea, isDeployed };
|
|
79
76
|
}
|
|
80
77
|
/**
|
|
81
78
|
* Get Push Account (UEA) address for a CEA on a specific chain
|
|
@@ -86,25 +83,23 @@ function getCEAAddress(ueaAddress, chain, rpcUrl) {
|
|
|
86
83
|
* @returns Push account address on Push Chain
|
|
87
84
|
* @throws Error if chain doesn't have CEAFactory
|
|
88
85
|
*/
|
|
89
|
-
function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
transport: (0, viem_1.http)(rpcUrl),
|
|
99
|
-
});
|
|
100
|
-
const uea = yield client.readContract({
|
|
101
|
-
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
102
|
-
address: factoryAddress,
|
|
103
|
-
functionName: 'getPushAccountForCEA',
|
|
104
|
-
args: [ceaAddress],
|
|
105
|
-
});
|
|
106
|
-
return uea;
|
|
86
|
+
async function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
87
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
88
|
+
if (!factoryAddress) {
|
|
89
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
90
|
+
}
|
|
91
|
+
const viemChain = getViemChain(chain);
|
|
92
|
+
const client = (0, viem_1.createPublicClient)({
|
|
93
|
+
chain: viemChain,
|
|
94
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
107
95
|
});
|
|
96
|
+
const uea = await client.readContract({
|
|
97
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
98
|
+
address: factoryAddress,
|
|
99
|
+
functionName: 'getPushAccountForCEA',
|
|
100
|
+
args: [ceaAddress],
|
|
101
|
+
});
|
|
102
|
+
return uea;
|
|
108
103
|
}
|
|
109
104
|
/**
|
|
110
105
|
* Check if an address is a CEA on a specific chain
|
|
@@ -115,23 +110,21 @@ function getPushAccountForCEA(ceaAddress, chain, rpcUrl) {
|
|
|
115
110
|
* @returns True if address is a CEA deployed by the factory
|
|
116
111
|
* @throws Error if chain doesn't have CEAFactory
|
|
117
112
|
*/
|
|
118
|
-
function isCEA(address, chain, rpcUrl) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
args: [address],
|
|
134
|
-
});
|
|
113
|
+
async function isCEA(address, chain, rpcUrl) {
|
|
114
|
+
const factoryAddress = chain_1.CEA_FACTORY_ADDRESSES[chain];
|
|
115
|
+
if (!factoryAddress) {
|
|
116
|
+
throw new Error(`CEAFactory not available on chain ${chain}`);
|
|
117
|
+
}
|
|
118
|
+
const viemChain = getViemChain(chain);
|
|
119
|
+
const client = (0, viem_1.createPublicClient)({
|
|
120
|
+
chain: viemChain,
|
|
121
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
122
|
+
});
|
|
123
|
+
return client.readContract({
|
|
124
|
+
abi: ceaFactory_evm_1.CEA_FACTORY_EVM,
|
|
125
|
+
address: factoryAddress,
|
|
126
|
+
functionName: 'isCEA',
|
|
127
|
+
args: [address],
|
|
135
128
|
});
|
|
136
129
|
}
|
|
137
130
|
/**
|
|
@@ -152,8 +145,7 @@ function chainSupportsCEA(chain) {
|
|
|
152
145
|
* @returns True if outbound transactions are supported
|
|
153
146
|
*/
|
|
154
147
|
function chainSupportsOutbound(chain) {
|
|
155
|
-
|
|
156
|
-
if (((_a = chain_1.CHAIN_INFO[chain]) === null || _a === void 0 ? void 0 : _a.vm) === enums_1.VM.SVM) {
|
|
148
|
+
if (chain_1.CHAIN_INFO[chain]?.vm === enums_1.VM.SVM) {
|
|
157
149
|
return true; // SVM uses gateway program, not CEA
|
|
158
150
|
}
|
|
159
151
|
return chain_1.CEA_FACTORY_ADDRESSES[chain] !== undefined;
|
|
@@ -174,24 +166,22 @@ function getCEAFactoryAddress(chain) {
|
|
|
174
166
|
* @param rpcUrls - Optional custom RPC URLs per chain
|
|
175
167
|
* @returns Array of CEA addresses per chain
|
|
176
168
|
*/
|
|
177
|
-
function getAllCEAAddresses(ueaAddress, rpcUrls) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return results;
|
|
195
|
-
});
|
|
169
|
+
async function getAllCEAAddresses(ueaAddress, rpcUrls) {
|
|
170
|
+
const chains = Object.keys(chain_1.CEA_FACTORY_ADDRESSES);
|
|
171
|
+
const results = await Promise.all(chains.map(async (chain) => {
|
|
172
|
+
try {
|
|
173
|
+
const { cea, isDeployed } = await getCEAAddress(ueaAddress, chain, rpcUrls?.[chain]);
|
|
174
|
+
return { chain, cea, isDeployed };
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
chain,
|
|
179
|
+
cea: '0x0000000000000000000000000000000000000000',
|
|
180
|
+
isDeployed: false,
|
|
181
|
+
error: error instanceof Error ? error.message : String(error),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}));
|
|
185
|
+
return results;
|
|
196
186
|
}
|
|
197
187
|
//# sourceMappingURL=cea-utils.js.map
|
|
@@ -24,168 +24,159 @@ const helpers_1 = require("./helpers");
|
|
|
24
24
|
// ============================================================================
|
|
25
25
|
// Fetch Latest UEA Version from Factory
|
|
26
26
|
// ============================================================================
|
|
27
|
-
function fetchLatestUEAVersion(ctx, vm) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
27
|
+
async function fetchLatestUEAVersion(ctx, vm) {
|
|
28
|
+
const factoryAddress = chain_1.UEA_FACTORY[ctx.pushNetwork];
|
|
29
|
+
if (!factoryAddress || factoryAddress === '0xTBD') {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const vmHash = vm === enums_1.VM.EVM
|
|
34
|
+
? (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'string' }], ['EVM']))
|
|
35
|
+
: (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'string' }], ['SVM']));
|
|
36
|
+
return await ctx.pushClient.readContract({
|
|
37
|
+
address: factoryAddress,
|
|
38
|
+
abi: uea_factory_1.UEA_FACTORY_ABI,
|
|
39
|
+
functionName: 'UEA_VERSION',
|
|
40
|
+
args: [vmHash],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
47
|
// ============================================================================
|
|
50
48
|
// Account Status
|
|
51
49
|
// ============================================================================
|
|
52
|
-
function getAccountStatus(ctx, options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!deployed) {
|
|
61
|
-
const status = {
|
|
62
|
-
mode: 'signer',
|
|
63
|
-
uea: {
|
|
64
|
-
loaded: true,
|
|
65
|
-
deployed: false,
|
|
66
|
-
version: '',
|
|
67
|
-
minRequiredVersion: '',
|
|
68
|
-
requiresUpgrade: false,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
ctx.accountStatusCache = status;
|
|
72
|
-
return status;
|
|
73
|
-
}
|
|
74
|
-
const [currentVersion, minRequiredVersion] = yield Promise.all([
|
|
75
|
-
(0, uea_manager_1.fetchUEAVersion)(ctx),
|
|
76
|
-
fetchLatestUEAVersion(ctx, vm),
|
|
77
|
-
]);
|
|
78
|
-
const requiresUpgrade = (0, orchestrator_types_1.parseUEAVersion)(currentVersion) < (0, orchestrator_types_1.parseUEAVersion)(minRequiredVersion);
|
|
50
|
+
async function getAccountStatus(ctx, options) {
|
|
51
|
+
if (ctx.accountStatusCache && !options?.forceRefresh) {
|
|
52
|
+
return ctx.accountStatusCache;
|
|
53
|
+
}
|
|
54
|
+
const chain = ctx.universalSigner.account.chain;
|
|
55
|
+
const { vm } = chain_1.CHAIN_INFO[chain];
|
|
56
|
+
const { deployed } = await (0, uea_manager_1.getUeaStatusAndNonce)(ctx);
|
|
57
|
+
if (!deployed) {
|
|
79
58
|
const status = {
|
|
80
59
|
mode: 'signer',
|
|
81
60
|
uea: {
|
|
82
61
|
loaded: true,
|
|
83
|
-
deployed:
|
|
84
|
-
version:
|
|
85
|
-
minRequiredVersion,
|
|
86
|
-
requiresUpgrade,
|
|
62
|
+
deployed: false,
|
|
63
|
+
version: '',
|
|
64
|
+
minRequiredVersion: '',
|
|
65
|
+
requiresUpgrade: false,
|
|
87
66
|
},
|
|
88
67
|
};
|
|
89
68
|
ctx.accountStatusCache = status;
|
|
90
69
|
return status;
|
|
91
|
-
}
|
|
70
|
+
}
|
|
71
|
+
const [currentVersion, minRequiredVersion] = await Promise.all([
|
|
72
|
+
(0, uea_manager_1.fetchUEAVersion)(ctx),
|
|
73
|
+
fetchLatestUEAVersion(ctx, vm),
|
|
74
|
+
]);
|
|
75
|
+
const requiresUpgrade = (0, orchestrator_types_1.parseUEAVersion)(currentVersion) < (0, orchestrator_types_1.parseUEAVersion)(minRequiredVersion);
|
|
76
|
+
const status = {
|
|
77
|
+
mode: 'signer',
|
|
78
|
+
uea: {
|
|
79
|
+
loaded: true,
|
|
80
|
+
deployed: true,
|
|
81
|
+
version: currentVersion,
|
|
82
|
+
minRequiredVersion,
|
|
83
|
+
requiresUpgrade,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
ctx.accountStatusCache = status;
|
|
87
|
+
return status;
|
|
92
88
|
}
|
|
93
89
|
// ============================================================================
|
|
94
90
|
// UEA Upgrade
|
|
95
91
|
// ============================================================================
|
|
96
|
-
function upgradeAccount(ctx, options) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
hook(hookEntry(...args));
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01);
|
|
106
|
-
const status = yield getAccountStatus(ctx, { forceRefresh: true });
|
|
107
|
-
if (!status.uea.requiresUpgrade) {
|
|
108
|
-
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9903);
|
|
109
|
-
return;
|
|
92
|
+
async function upgradeAccount(ctx, options) {
|
|
93
|
+
const hook = options?.progressHook || ctx.progressHook;
|
|
94
|
+
const fireHook = (hookId, ...args) => {
|
|
95
|
+
const hookEntry = progress_hook_1.default[hookId];
|
|
96
|
+
if (hookEntry && hook) {
|
|
97
|
+
hook(hookEntry(...args));
|
|
110
98
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
deadline,
|
|
127
|
-
ueaVersion,
|
|
128
|
-
ueaAddress,
|
|
129
|
-
});
|
|
130
|
-
const signature = (0, viem_1.bytesToHex)(signatureBytes);
|
|
131
|
-
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_03);
|
|
132
|
-
const universalAccountId = {
|
|
133
|
-
chainNamespace: chain_1.VM_NAMESPACE[vm],
|
|
134
|
-
chainId,
|
|
135
|
-
owner: vm === enums_1.VM.EVM
|
|
136
|
-
? address
|
|
137
|
-
: vm === enums_1.VM.SVM
|
|
138
|
-
? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
|
|
139
|
-
: address,
|
|
140
|
-
};
|
|
141
|
-
const { cosmosAddress: signer } = ctx.pushClient.getSignerAddress();
|
|
142
|
-
const msg = ctx.pushClient.createMsgMigrateUEA({
|
|
143
|
-
signer,
|
|
144
|
-
universalAccountId,
|
|
145
|
-
migrationPayload: {
|
|
146
|
-
migration: migrationContractAddress,
|
|
147
|
-
nonce: nonce.toString(),
|
|
148
|
-
deadline: deadline.toString(),
|
|
149
|
-
},
|
|
150
|
-
signature,
|
|
151
|
-
});
|
|
152
|
-
const txBody = yield ctx.pushClient.createCosmosTxBody([msg]);
|
|
153
|
-
const txRaw = yield ctx.pushClient.signCosmosTx(txBody);
|
|
154
|
-
const tx = yield ctx.pushClient.broadcastCosmosTx(txRaw);
|
|
155
|
-
if (tx.code !== 0) {
|
|
156
|
-
throw new Error(tx.rawLog || 'UEA migration transaction failed');
|
|
157
|
-
}
|
|
158
|
-
ctx.ueaVersionCache = undefined;
|
|
159
|
-
const updated = yield getAccountStatus(ctx, { forceRefresh: true });
|
|
160
|
-
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9901, updated.uea.version);
|
|
99
|
+
};
|
|
100
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_01);
|
|
101
|
+
const status = await getAccountStatus(ctx, { forceRefresh: true });
|
|
102
|
+
if (!status.uea.requiresUpgrade) {
|
|
103
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9903);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_02);
|
|
107
|
+
try {
|
|
108
|
+
const { chain, address } = ctx.universalSigner.account;
|
|
109
|
+
const { vm, chainId } = chain_1.CHAIN_INFO[chain];
|
|
110
|
+
const ueaAddress = (0, uea_manager_1.computeUEAOffchain)(ctx);
|
|
111
|
+
const migrationContractAddress = chain_1.UEA_MIGRATION[ctx.pushNetwork];
|
|
112
|
+
if (!migrationContractAddress || migrationContractAddress === '0xTBD') {
|
|
113
|
+
throw new Error('UEA migration contract address not configured');
|
|
161
114
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
115
|
+
const { nonce } = await (0, uea_manager_1.getUeaStatusAndNonce)(ctx);
|
|
116
|
+
const deadline = BigInt(9999999999);
|
|
117
|
+
const ueaVersion = status.uea.version || '0.1.0';
|
|
118
|
+
const signatureBytes = await (0, signing_1.signMigrationPayload)(ctx, {
|
|
119
|
+
migrationContractAddress,
|
|
120
|
+
nonce,
|
|
121
|
+
deadline,
|
|
122
|
+
ueaVersion,
|
|
123
|
+
ueaAddress,
|
|
124
|
+
});
|
|
125
|
+
const signature = (0, viem_1.bytesToHex)(signatureBytes);
|
|
126
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_03);
|
|
127
|
+
const universalAccountId = {
|
|
128
|
+
chainNamespace: chain_1.VM_NAMESPACE[vm],
|
|
129
|
+
chainId,
|
|
130
|
+
owner: vm === enums_1.VM.EVM
|
|
131
|
+
? address
|
|
132
|
+
: vm === enums_1.VM.SVM
|
|
133
|
+
? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
|
|
134
|
+
: address,
|
|
135
|
+
};
|
|
136
|
+
const { cosmosAddress: signer } = ctx.pushClient.getSignerAddress();
|
|
137
|
+
const msg = ctx.pushClient.createMsgMigrateUEA({
|
|
138
|
+
signer,
|
|
139
|
+
universalAccountId,
|
|
140
|
+
migrationPayload: {
|
|
141
|
+
migration: migrationContractAddress,
|
|
142
|
+
nonce: nonce.toString(),
|
|
143
|
+
deadline: deadline.toString(),
|
|
144
|
+
},
|
|
145
|
+
signature,
|
|
146
|
+
});
|
|
147
|
+
const txBody = await ctx.pushClient.createCosmosTxBody([msg]);
|
|
148
|
+
const txRaw = await ctx.pushClient.signCosmosTx(txBody);
|
|
149
|
+
const tx = await ctx.pushClient.broadcastCosmosTx(txRaw);
|
|
150
|
+
if (tx.code !== 0) {
|
|
151
|
+
throw new Error(tx.rawLog || 'UEA migration transaction failed');
|
|
165
152
|
}
|
|
166
|
-
|
|
153
|
+
ctx.ueaVersionCache = undefined;
|
|
154
|
+
const updated = await getAccountStatus(ctx, { forceRefresh: true });
|
|
155
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9901, updated.uea.version);
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
fireHook(progress_hook_types_1.PROGRESS_HOOK.UEA_MIG_9902);
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
167
161
|
}
|
|
168
162
|
// ============================================================================
|
|
169
163
|
// CEA Migration
|
|
170
164
|
// ============================================================================
|
|
171
|
-
function migrateCEA(ctx, chain, executeFn) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
to: { address: cea, chain },
|
|
187
|
-
migration: true,
|
|
188
|
-
});
|
|
165
|
+
async function migrateCEA(ctx, chain, executeFn) {
|
|
166
|
+
if ((0, helpers_1.isPushChain)(chain)) {
|
|
167
|
+
throw new Error('Cannot migrate CEA on Push Chain');
|
|
168
|
+
}
|
|
169
|
+
if (!(0, cea_utils_1.chainSupportsCEA)(chain)) {
|
|
170
|
+
throw new Error(`Chain ${chain} does not support CEA`);
|
|
171
|
+
}
|
|
172
|
+
const ueaAddress = (0, uea_manager_1.computeUEAOffchain)(ctx);
|
|
173
|
+
const { cea, isDeployed } = await (0, cea_utils_1.getCEAAddress)(ueaAddress, chain, ctx.rpcUrls[chain]?.[0]);
|
|
174
|
+
if (!isDeployed) {
|
|
175
|
+
throw new Error(`CEA not deployed on chain ${chain}. Deploy CEA first.`);
|
|
176
|
+
}
|
|
177
|
+
return executeFn({
|
|
178
|
+
to: { address: cea, chain },
|
|
179
|
+
migration: true,
|
|
189
180
|
});
|
|
190
181
|
}
|
|
191
182
|
//# sourceMappingURL=account-manager.js.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cascade composition functions extracted from Orchestrator.
|
|
3
|
-
*
|
|
4
|
-
* Covers: prepareTransaction, buildHopDescriptor, classifyIntoSegments,
|
|
5
|
-
* getSegmentType, composeCascade, createCascadedBuilder, createChainedBuilder.
|
|
6
|
-
*/
|
|
7
1
|
import { TransactionRoute } from '../route-detector';
|
|
8
2
|
import type { HopDescriptor, CascadeSegment, CascadeSegmentType, PreparedUniversalTx, CascadedTxResponse, CascadeHopInfo, UniversalTxResponse, UniversalExecuteParams, MultiCall, CascadeExecutionOptions, WaitForOutboundOptions, OutboundTxDetails } from '../orchestrator.types';
|
|
9
3
|
import type { OrchestratorContext } from './context';
|