@pushchain/core 5.1.4-alpha.1 → 5.1.4-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/lib/constants/abi/factoryV1.d.ts +59 -76
- package/src/lib/constants/abi/factoryV1.js +0 -517
- package/src/lib/constants/abi/feeLocker.evm.d.ts +15 -50
- package/src/lib/constants/abi/feeLocker.evm.js +0 -385
- package/src/lib/constants/abi/index.d.ts +1 -1
- package/src/lib/constants/abi/index.js +1 -2
- package/src/lib/constants/abi/prc20.evm.d.ts +0 -53
- package/src/lib/constants/abi/prc20.evm.js +1 -42
- package/src/lib/constants/abi/uea.svm.d.ts +21 -99
- package/src/lib/constants/abi/uea.svm.js +0 -299
- package/src/lib/constants/abi/universalGatewayV0.evm.d.ts +45 -104
- package/src/lib/constants/abi/universalGatewayV0.evm.js +0 -2149
- package/src/lib/index.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.d.ts +4 -2
- package/src/lib/orchestrator/internals/cascade.js +34 -18
- package/src/lib/orchestrator/internals/execute-standard.js +5 -1
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +9 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +94 -0
- package/src/lib/orchestrator/internals/route-handlers.js +47 -38
- package/src/lib/orchestrator/orchestrator.d.ts +5 -3
- package/src/lib/orchestrator/orchestrator.js +2 -12
- package/src/lib/orchestrator/orchestrator.types.d.ts +8 -15
- package/src/lib/progress-hook/progress-hook.js +1 -1
- package/src/lib/push-chain/push-chain.d.ts +5 -6
- package/src/lib/push-chain/push-chain.js +4 -3
- package/src/lib/universal/account/account.d.ts +16 -8
- package/src/lib/universal/account/account.js +118 -73
- package/src/lib/universal/signer/signer.js +1 -1
- package/src/lib/universal/universal.types.d.ts +2 -2
|
@@ -69,29 +69,37 @@ export declare function convertExecutorToOrigin(executorAddress: string, options
|
|
|
69
69
|
_internal?: boolean;
|
|
70
70
|
}): Promise<OriginAccountInfo>;
|
|
71
71
|
/**
|
|
72
|
-
* Derive the executor account (UEA or CEA) for a given
|
|
72
|
+
* Derive the executor account (UEA or CEA) for a given account.
|
|
73
73
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* - If account is on an external chain (Ethereum, Solana, etc.):
|
|
75
|
+
* Computes the UEA on Push Chain via the factory contract's computeUEA.
|
|
76
|
+
* If options.chain is an external chain, further derives the CEA on that chain.
|
|
77
|
+
*
|
|
78
|
+
* - If account is on Push Chain:
|
|
79
|
+
* Returns the address as-is (it's already a UEA or Push EOA).
|
|
80
|
+
* If options.chain is an external chain, derives the CEA on that chain.
|
|
81
|
+
*
|
|
82
|
+
* @param account - UniversalAccount with chain and address.
|
|
83
|
+
* @param options.chain - Target external chain for CEA derivation. If omitted, returns UEA.
|
|
76
84
|
* @param options.skipNetworkCheck - If true, skip deployment check and return deployed: false.
|
|
77
85
|
* @returns The derived executor account address and deployment status.
|
|
78
86
|
*/
|
|
79
|
-
export declare function deriveExecutorAccount(account:
|
|
87
|
+
export declare function deriveExecutorAccount(account: UniversalAccount, options?: {
|
|
80
88
|
chain?: CHAIN;
|
|
81
89
|
skipNetworkCheck?: boolean;
|
|
82
90
|
}): Promise<DerivedExecutorAccount>;
|
|
83
91
|
/**
|
|
84
92
|
* Resolve the controller (origin) accounts for a given executor address.
|
|
85
93
|
*
|
|
86
|
-
* Given a UEA or CEA address
|
|
94
|
+
* Given a UEA or CEA plain address, resolves the full controller chain
|
|
87
95
|
* back to the origin account.
|
|
88
96
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @param options.chain -
|
|
97
|
+
* @param address - Plain address string of the executor account (e.g., "0xABC...")
|
|
98
|
+
* @param options.chain - Chain context. If external chain, address is treated as CEA on that chain. If omitted or Push chain, address is treated as UEA on Push Chain.
|
|
91
99
|
* @param options.skipNetworkCheck - If true, skip existence checks, set exists: false
|
|
92
100
|
* @returns Resolved accounts in the controller chain
|
|
93
101
|
*/
|
|
94
|
-
export declare function resolveControllerAccount(
|
|
102
|
+
export declare function resolveControllerAccount(address: string, options?: {
|
|
95
103
|
chain?: CHAIN;
|
|
96
104
|
skipNetworkCheck?: boolean;
|
|
97
105
|
}): Promise<ResolvedControllerAccounts>;
|
|
@@ -10,6 +10,7 @@ exports.deriveExecutorAccount = deriveExecutorAccount;
|
|
|
10
10
|
exports.resolveControllerAccount = resolveControllerAccount;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const viem_1 = require("viem");
|
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
13
14
|
const chain_1 = require("../../constants/chain");
|
|
14
15
|
const enums_1 = require("../../constants/enums");
|
|
15
16
|
const bs58_1 = require("../../internal/bs58");
|
|
@@ -431,120 +432,161 @@ function getChainName(chain) {
|
|
|
431
432
|
return entry ? entry[0] : chain;
|
|
432
433
|
}
|
|
433
434
|
/**
|
|
434
|
-
* Derive the
|
|
435
|
+
* Derive the SVM CEA (PDA) for a UEA address on a Solana-based chain.
|
|
435
436
|
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
437
|
+
* Solana doesn't use a CEAFactory contract — instead, the CEA is a
|
|
438
|
+
* Program Derived Address (PDA) with seeds: ["push_identity", ueaBytes]
|
|
439
|
+
* and the SVM gateway program as the program ID.
|
|
440
|
+
*
|
|
441
|
+
* @param ueaAddress - The UEA (or Push EOA) hex address (20 bytes).
|
|
442
|
+
* @param targetChain - The SVM target chain.
|
|
443
|
+
* @param skipNetworkCheck - Whether to skip deployment status check.
|
|
444
|
+
* @returns The derived 32-byte Solana PDA address (as 0x-prefixed hex) and deployment status.
|
|
445
|
+
*/
|
|
446
|
+
function deriveSvmCeaPda(ueaAddress, targetChain, skipNetworkCheck) {
|
|
447
|
+
const gatewayAddress = chain_1.CHAIN_INFO[targetChain].lockerContract;
|
|
448
|
+
if (!gatewayAddress) {
|
|
449
|
+
throw new Error(`SVM gateway program not configured for chain ${targetChain}`);
|
|
450
|
+
}
|
|
451
|
+
const gatewayProgramId = new web3_js_1.PublicKey(gatewayAddress);
|
|
452
|
+
const ueaBytes = Buffer.from(ueaAddress.slice(2), 'hex'); // 20 bytes
|
|
453
|
+
const [ceaPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('push_identity'), ueaBytes], gatewayProgramId);
|
|
454
|
+
const ceaPdaHex = ('0x' +
|
|
455
|
+
Buffer.from(ceaPda.toBytes()).toString('hex'));
|
|
456
|
+
return { address: ceaPdaHex, deployed: skipNetworkCheck ? null : null };
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Derive the executor account (UEA or CEA) for a given account.
|
|
460
|
+
*
|
|
461
|
+
* - If account is on an external chain (Ethereum, Solana, etc.):
|
|
462
|
+
* Computes the UEA on Push Chain via the factory contract's computeUEA.
|
|
463
|
+
* If options.chain is an external chain, further derives the CEA on that chain.
|
|
464
|
+
*
|
|
465
|
+
* - If account is on Push Chain:
|
|
466
|
+
* Returns the address as-is (it's already a UEA or Push EOA).
|
|
467
|
+
* If options.chain is an external chain, derives the CEA on that chain.
|
|
468
|
+
*
|
|
469
|
+
* @param account - UniversalAccount with chain and address.
|
|
470
|
+
* @param options.chain - Target external chain for CEA derivation. If omitted, returns UEA.
|
|
438
471
|
* @param options.skipNetworkCheck - If true, skip deployment check and return deployed: false.
|
|
439
472
|
* @returns The derived executor account address and deployment status.
|
|
440
473
|
*/
|
|
441
474
|
function deriveExecutorAccount(account, options) {
|
|
442
475
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
443
476
|
var _a;
|
|
444
|
-
const { chain: originChain, address } = fromChainAgnostic(account);
|
|
445
477
|
const skipNetworkCheck = (_a = options === null || options === void 0 ? void 0 : options.skipNetworkCheck) !== null && _a !== void 0 ? _a : false;
|
|
446
478
|
const targetChain = options === null || options === void 0 ? void 0 : options.chain;
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
479
|
+
const { chain, address } = account;
|
|
480
|
+
// --- Case 1: Input is on an external chain ---
|
|
481
|
+
if (!isPushChain(chain)) {
|
|
482
|
+
const { vm, chainId } = chain_1.CHAIN_INFO[chain];
|
|
483
|
+
const pushNetwork = getPushNetworkFromChain(chain);
|
|
484
|
+
// Check cache for previously computed UEA
|
|
485
|
+
const cachedUea = accountCache.get(cache_1.CacheKeys.ueaAddressOnchain(chain, address, pushNetwork, vm));
|
|
450
486
|
let ueaAddress;
|
|
451
|
-
if (
|
|
452
|
-
ueaAddress =
|
|
487
|
+
if (cachedUea) {
|
|
488
|
+
ueaAddress = cachedUea;
|
|
453
489
|
}
|
|
454
490
|
else {
|
|
455
|
-
|
|
456
|
-
|
|
491
|
+
// Compute UEA via factory contract
|
|
492
|
+
const pushChainKey = pushNetworkToChainKey(pushNetwork);
|
|
493
|
+
const pushClient = new push_client_1.PushClient({
|
|
494
|
+
rpcUrls: chain_1.CHAIN_INFO[pushChainKey].defaultRPC,
|
|
495
|
+
network: pushNetwork,
|
|
496
|
+
});
|
|
497
|
+
ueaAddress = yield pushClient.readContract({
|
|
498
|
+
address: pushClient.pushChainInfo.factoryAddress,
|
|
499
|
+
abi: factoryV1_1.FACTORY_V1,
|
|
500
|
+
functionName: 'computeUEA',
|
|
501
|
+
args: [
|
|
502
|
+
{
|
|
503
|
+
chainNamespace: chain_1.VM_NAMESPACE[vm],
|
|
504
|
+
chainId: chainId,
|
|
505
|
+
owner: vm === enums_1.VM.EVM
|
|
506
|
+
? address
|
|
507
|
+
: vm === enums_1.VM.SVM
|
|
508
|
+
? (0, viem_1.bytesToHex)(Uint8Array.from(bs58_1.bs58.decode(address)))
|
|
509
|
+
: address,
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
});
|
|
513
|
+
// Cache the computed address
|
|
514
|
+
accountCache.set(cache_1.CacheKeys.ueaAddressOnchain(chain, address, pushNetwork, vm), ueaAddress);
|
|
457
515
|
}
|
|
458
|
-
//
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
516
|
+
// If target chain is external, derive CEA from the computed UEA
|
|
517
|
+
if (targetChain && !isPushChain(targetChain)) {
|
|
518
|
+
// SVM chains use PDA derivation, not CEAFactory
|
|
519
|
+
if (chain_1.CHAIN_INFO[targetChain].vm === enums_1.VM.SVM) {
|
|
520
|
+
return deriveSvmCeaPda(ueaAddress, targetChain, skipNetworkCheck);
|
|
521
|
+
}
|
|
522
|
+
const { cea, isDeployed } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, targetChain);
|
|
523
|
+
return { address: cea, deployed: skipNetworkCheck ? null : isDeployed };
|
|
524
|
+
}
|
|
525
|
+
// Return UEA with deployment check
|
|
464
526
|
if (skipNetworkCheck) {
|
|
465
|
-
return { address:
|
|
527
|
+
return { address: ueaAddress, deployed: null };
|
|
466
528
|
}
|
|
467
|
-
const pushNetwork = getPushNetworkFromChain(originChain);
|
|
468
529
|
const pushChainKey = pushNetworkToChainKey(pushNetwork);
|
|
469
530
|
const pushClient = new push_client_1.PushClient({
|
|
470
531
|
rpcUrls: chain_1.CHAIN_INFO[pushChainKey].defaultRPC,
|
|
471
532
|
network: pushNetwork,
|
|
472
533
|
});
|
|
473
534
|
const byteCode = yield pushClient.publicClient.getCode({
|
|
474
|
-
address:
|
|
535
|
+
address: ueaAddress,
|
|
475
536
|
});
|
|
476
|
-
|
|
537
|
+
const isDeployed = byteCode !== undefined;
|
|
538
|
+
accountCache.set(cache_1.CacheKeys.deploymentStatus(ueaAddress), isDeployed);
|
|
539
|
+
return { address: ueaAddress, deployed: isDeployed };
|
|
477
540
|
}
|
|
478
|
-
//
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (skipNetworkCheck) {
|
|
485
|
-
return { address: cachedAddress, deployed: false };
|
|
486
|
-
}
|
|
487
|
-
const cachedDeploymentStatus = accountCache.get(cache_1.CacheKeys.deploymentStatus(cachedAddress));
|
|
488
|
-
if (cachedDeploymentStatus !== null) {
|
|
489
|
-
return {
|
|
490
|
-
address: cachedAddress,
|
|
491
|
-
deployed: cachedDeploymentStatus,
|
|
492
|
-
};
|
|
541
|
+
// --- Case 2: Input is on Push Chain ---
|
|
542
|
+
// If target chain is external, derive CEA
|
|
543
|
+
if (targetChain && !isPushChain(targetChain)) {
|
|
544
|
+
// SVM chains use PDA derivation, not CEAFactory
|
|
545
|
+
if (chain_1.CHAIN_INFO[targetChain].vm === enums_1.VM.SVM) {
|
|
546
|
+
return deriveSvmCeaPda(address, targetChain, skipNetworkCheck);
|
|
493
547
|
}
|
|
548
|
+
const { cea, isDeployed } = yield (0, cea_utils_1.getCEAAddress)(address, targetChain);
|
|
549
|
+
return { address: cea, deployed: skipNetworkCheck ? null : isDeployed };
|
|
494
550
|
}
|
|
551
|
+
// Push address, no external target — return with deployment check
|
|
552
|
+
if (skipNetworkCheck) {
|
|
553
|
+
return { address: address, deployed: null };
|
|
554
|
+
}
|
|
555
|
+
const pushNetwork = targetChain && isPushChain(targetChain)
|
|
556
|
+
? getPushNetworkFromChain(targetChain)
|
|
557
|
+
: getPushNetworkFromChain(chain);
|
|
495
558
|
const pushChainKey = pushNetworkToChainKey(pushNetwork);
|
|
496
559
|
const pushClient = new push_client_1.PushClient({
|
|
497
560
|
rpcUrls: chain_1.CHAIN_INFO[pushChainKey].defaultRPC,
|
|
498
561
|
network: pushNetwork,
|
|
499
562
|
});
|
|
500
|
-
const computedAddress = yield pushClient.readContract({
|
|
501
|
-
address: pushClient.pushChainInfo.factoryAddress,
|
|
502
|
-
abi: factoryV1_1.FACTORY_V1,
|
|
503
|
-
functionName: 'computeUEA',
|
|
504
|
-
args: [
|
|
505
|
-
{
|
|
506
|
-
chainNamespace: chain_1.VM_NAMESPACE[vm],
|
|
507
|
-
chainId: chainId,
|
|
508
|
-
owner: vm === enums_1.VM.EVM
|
|
509
|
-
? address
|
|
510
|
-
: vm === enums_1.VM.SVM
|
|
511
|
-
? (0, viem_1.bytesToHex)(Uint8Array.from(bs58_1.bs58.decode(address)))
|
|
512
|
-
: address,
|
|
513
|
-
},
|
|
514
|
-
],
|
|
515
|
-
});
|
|
516
|
-
// Cache the computed address
|
|
517
|
-
accountCache.set(cache_1.CacheKeys.ueaAddressOnchain(originChain, address, pushNetwork, vm), computedAddress);
|
|
518
|
-
if (skipNetworkCheck) {
|
|
519
|
-
return { address: computedAddress, deployed: false };
|
|
520
|
-
}
|
|
521
563
|
const byteCode = yield pushClient.publicClient.getCode({
|
|
522
|
-
address:
|
|
564
|
+
address: address,
|
|
523
565
|
});
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
566
|
+
return {
|
|
567
|
+
address: address,
|
|
568
|
+
deployed: byteCode !== undefined,
|
|
569
|
+
};
|
|
528
570
|
});
|
|
529
571
|
}
|
|
530
572
|
/**
|
|
531
573
|
* Resolve the controller (origin) accounts for a given executor address.
|
|
532
574
|
*
|
|
533
|
-
* Given a UEA or CEA address
|
|
575
|
+
* Given a UEA or CEA plain address, resolves the full controller chain
|
|
534
576
|
* back to the origin account.
|
|
535
577
|
*
|
|
536
|
-
* @param
|
|
537
|
-
* @param options.chain -
|
|
578
|
+
* @param address - Plain address string of the executor account (e.g., "0xABC...")
|
|
579
|
+
* @param options.chain - Chain context. If external chain, address is treated as CEA on that chain. If omitted or Push chain, address is treated as UEA on Push Chain.
|
|
538
580
|
* @param options.skipNetworkCheck - If true, skip existence checks, set exists: false
|
|
539
581
|
* @returns Resolved accounts in the controller chain
|
|
540
582
|
*/
|
|
541
|
-
function resolveControllerAccount(
|
|
583
|
+
function resolveControllerAccount(address, options) {
|
|
542
584
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
543
585
|
var _a;
|
|
544
|
-
const
|
|
586
|
+
const inputChain = options === null || options === void 0 ? void 0 : options.chain;
|
|
545
587
|
const skipNetworkCheck = (_a = options === null || options === void 0 ? void 0 : options.skipNetworkCheck) !== null && _a !== void 0 ? _a : false;
|
|
546
|
-
// Case A:
|
|
547
|
-
if (!isPushChain(inputChain)) {
|
|
588
|
+
// Case A: External chain → address is a CEA on that chain
|
|
589
|
+
if (inputChain && !isPushChain(inputChain)) {
|
|
548
590
|
// Look up UEA on Push Chain from CEA
|
|
549
591
|
const pushAccountAddress = yield (0, cea_utils_1.getPushAccountForCEA)(address, inputChain);
|
|
550
592
|
if (pushAccountAddress === '0x0000000000000000000000000000000000000000') {
|
|
@@ -597,9 +639,12 @@ function resolveControllerAccount(account, options) {
|
|
|
597
639
|
}
|
|
598
640
|
return { accounts };
|
|
599
641
|
}
|
|
600
|
-
// Case B:
|
|
601
|
-
const pushNetwork =
|
|
642
|
+
// Case B: No chain or Push chain → address is a UEA or EOA on Push Chain
|
|
643
|
+
const pushNetwork = inputChain && isPushChain(inputChain)
|
|
644
|
+
? getPushNetworkFromChain(inputChain)
|
|
645
|
+
: enums_1.PUSH_NETWORK.TESTNET_DONUT;
|
|
602
646
|
const pushChainKey = pushNetworkToChainKey(pushNetwork);
|
|
647
|
+
const pushChainId = pushChainKey;
|
|
603
648
|
const RPC_URL = chain_1.PUSH_CHAIN_INFO[pushChainKey].defaultRPC[0];
|
|
604
649
|
const FACTORY_ADDRESS = chain_1.PUSH_CHAIN_INFO[pushChainKey].factoryAddress;
|
|
605
650
|
const client = (0, viem_1.createPublicClient)({ transport: (0, viem_1.http)(RPC_URL) });
|
|
@@ -639,8 +684,8 @@ function resolveControllerAccount(account, options) {
|
|
|
639
684
|
return {
|
|
640
685
|
accounts: [
|
|
641
686
|
{
|
|
642
|
-
chain:
|
|
643
|
-
chainName: getChainName(
|
|
687
|
+
chain: pushChainId,
|
|
688
|
+
chainName: getChainName(pushChainId),
|
|
644
689
|
address: address,
|
|
645
690
|
type: 'uoa',
|
|
646
691
|
exists: skipNetworkCheck ? false : true,
|
|
@@ -23,7 +23,7 @@ const bs58_1 = require("../../internal/bs58");
|
|
|
23
23
|
* viem uses `gas` while ethers expects `gasLimit`.
|
|
24
24
|
*/
|
|
25
25
|
function toEthersTxRequest(viemTx) {
|
|
26
|
-
const _a = viemTx, { gas } = _a, rest = tslib_1.__rest(_a, ["gas"]);
|
|
26
|
+
const _a = viemTx, { gas, type } = _a, rest = tslib_1.__rest(_a, ["gas", "type"]);
|
|
27
27
|
return Object.assign(Object.assign({}, rest), { gasLimit: gas });
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -137,8 +137,8 @@ export type AccountRole = 'controller';
|
|
|
137
137
|
export interface DerivedExecutorAccount {
|
|
138
138
|
/** The computed executor address on Push Chain (or CEA on external chain) */
|
|
139
139
|
address: `0x${string}`;
|
|
140
|
-
/** Whether the executor account is deployed on-chain */
|
|
141
|
-
deployed: boolean;
|
|
140
|
+
/** Whether the executor account is deployed on-chain. null when skipNetworkCheck is true. */
|
|
141
|
+
deployed: boolean | null;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* A single resolved account entry in the resolveControllerAccount response.
|