@pushchain/core 5.1.4-alpha.1 → 5.1.4-alpha.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushchain/core",
3
- "version": "5.1.4-alpha.1",
3
+ "version": "5.1.4-alpha.2",
4
4
  "homepage": "https://push.org",
5
5
  "keywords": [
6
6
  "pushchain",
@@ -129,7 +129,7 @@ class Orchestrator {
129
129
  */
130
130
  execute(params) {
131
131
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
132
- var _a, _b, _c, _d, _e;
132
+ var _a, _b, _c, _d;
133
133
  // Lazy UEA upgrade check
134
134
  try {
135
135
  if (!this.accountStatusCache || !this.accountStatusCache.uea.loaded) {
@@ -166,16 +166,6 @@ class Orchestrator {
166
166
  try {
167
167
  const rcb = () => this._getResponseCallbacks();
168
168
  if (execute.funds) {
169
- const hasData = execute.data && execute.data !== '0x';
170
- const isSVM = ((_e = chain_1.CHAIN_INFO[this.ctx.universalSigner.account.chain]) === null || _e === void 0 ? void 0 : _e.vm) === enums_1.VM.SVM;
171
- // SVM two-phase: bridge funds first, then execute payload separately
172
- // (Push Chain node doesn't support FUNDS_AND_PAYLOAD payload decoding for SVM yet)
173
- if (hasData && isSVM) {
174
- const fundsOnly = Object.assign(Object.assign({}, execute), { data: undefined });
175
- yield (0, internals_1.executeFundsOnly)(this.ctx, fundsOnly, eventBuffer, rcb);
176
- const dataOnly = Object.assign(Object.assign({}, execute), { funds: undefined });
177
- return yield (0, internals_1.executeStandardPayload)(this.ctx, dataOnly, eventBuffer, rcb);
178
- }
179
169
  return !hasData
180
170
  ? yield (0, internals_1.executeFundsOnly)(this.ctx, execute, eventBuffer, rcb)
181
171
  : yield (0, internals_1.executeFundsWithPayload)(this.ctx, execute, eventBuffer, rcb);
@@ -69,29 +69,29 @@ 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 origin account.
72
+ * Derive the executor account (UEA or CEA) for a given Push Chain account.
73
73
  *
74
- * @param account - CAIP-10 formatted address string (e.g., "eip155:11155111:0xABC...")
75
- * @param options.chain - Target chain for CEA derivation. If omitted, derives UEA on Push Chain.
74
+ * @param address - Plain address string (e.g., "0xABC...")
75
+ * @param options.chain - Target external chain for CEA derivation. If omitted, treats address as Push Chain account.
76
76
  * @param options.skipNetworkCheck - If true, skip deployment check and return deployed: false.
77
77
  * @returns The derived executor account address and deployment status.
78
78
  */
79
- export declare function deriveExecutorAccount(account: string, options?: {
79
+ export declare function deriveExecutorAccount(address: string, options?: {
80
80
  chain?: CHAIN;
81
81
  skipNetworkCheck?: boolean;
82
82
  }): Promise<DerivedExecutorAccount>;
83
83
  /**
84
84
  * Resolve the controller (origin) accounts for a given executor address.
85
85
  *
86
- * Given a UEA or CEA address (as CAIP-10), resolves the full controller chain
86
+ * Given a UEA or CEA plain address, resolves the full controller chain
87
87
  * back to the origin account.
88
88
  *
89
- * @param account - CAIP-10 formatted address string of the executor account
90
- * @param options.chain - Supplementary chain context (chain info is in CAIP-10)
89
+ * @param address - Plain address string of the executor account (e.g., "0xABC...")
90
+ * @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
91
  * @param options.skipNetworkCheck - If true, skip existence checks, set exists: false
92
92
  * @returns Resolved accounts in the controller chain
93
93
  */
94
- export declare function resolveControllerAccount(account: string, options?: {
94
+ export declare function resolveControllerAccount(address: string, options?: {
95
95
  chain?: CHAIN;
96
96
  skipNetworkCheck?: boolean;
97
97
  }): Promise<ResolvedControllerAccounts>;
@@ -431,120 +431,62 @@ function getChainName(chain) {
431
431
  return entry ? entry[0] : chain;
432
432
  }
433
433
  /**
434
- * Derive the executor account (UEA or CEA) for a given origin account.
434
+ * Derive the executor account (UEA or CEA) for a given Push Chain account.
435
435
  *
436
- * @param account - CAIP-10 formatted address string (e.g., "eip155:11155111:0xABC...")
437
- * @param options.chain - Target chain for CEA derivation. If omitted, derives UEA on Push Chain.
436
+ * @param address - Plain address string (e.g., "0xABC...")
437
+ * @param options.chain - Target external chain for CEA derivation. If omitted, treats address as Push Chain account.
438
438
  * @param options.skipNetworkCheck - If true, skip deployment check and return deployed: false.
439
439
  * @returns The derived executor account address and deployment status.
440
440
  */
441
- function deriveExecutorAccount(account, options) {
441
+ function deriveExecutorAccount(address, options) {
442
442
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
443
443
  var _a;
444
- const { chain: originChain, address } = fromChainAgnostic(account);
445
444
  const skipNetworkCheck = (_a = options === null || options === void 0 ? void 0 : options.skipNetworkCheck) !== null && _a !== void 0 ? _a : false;
446
445
  const targetChain = options === null || options === void 0 ? void 0 : options.chain;
447
446
  // If target chain is external, derive CEA on that chain
448
447
  if (targetChain && !isPushChain(targetChain)) {
449
- // First get the UEA on Push Chain
450
- let ueaAddress;
451
- if (isPushChain(originChain)) {
452
- ueaAddress = address;
453
- }
454
- else {
455
- const ueaResult = yield deriveExecutorAccount(account);
456
- ueaAddress = ueaResult.address;
457
- }
458
- // Get CEA on the target external chain
459
- const { cea, isDeployed } = yield (0, cea_utils_1.getCEAAddress)(ueaAddress, targetChain);
448
+ const { cea, isDeployed } = yield (0, cea_utils_1.getCEAAddress)(address, targetChain);
460
449
  return { address: cea, deployed: skipNetworkCheck ? false : isDeployed };
461
450
  }
462
- // If origin is Push chain, return the address directly
463
- if (isPushChain(originChain)) {
464
- if (skipNetworkCheck) {
465
- return { address: address, deployed: false };
466
- }
467
- const pushNetwork = getPushNetworkFromChain(originChain);
468
- const pushChainKey = pushNetworkToChainKey(pushNetwork);
469
- const pushClient = new push_client_1.PushClient({
470
- rpcUrls: chain_1.CHAIN_INFO[pushChainKey].defaultRPC,
471
- network: pushNetwork,
472
- });
473
- const byteCode = yield pushClient.publicClient.getCode({
474
- address: address,
475
- });
476
- return { address: address, deployed: byteCode !== undefined };
477
- }
478
- // Origin is external chain → compute UEA on Push Chain
479
- const { vm, chainId } = chain_1.CHAIN_INFO[originChain];
480
- const pushNetwork = getPushNetworkFromChain(originChain);
481
- // Check cache
482
- const cachedAddress = accountCache.get(cache_1.CacheKeys.ueaAddressOnchain(originChain, address, pushNetwork, vm));
483
- if (cachedAddress) {
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
- };
493
- }
451
+ // Address is on Push Chain — return with deployment check
452
+ if (skipNetworkCheck) {
453
+ return { address: address, deployed: false };
494
454
  }
455
+ const pushNetwork = targetChain && isPushChain(targetChain)
456
+ ? getPushNetworkFromChain(targetChain)
457
+ : enums_1.PUSH_NETWORK.TESTNET_DONUT;
495
458
  const pushChainKey = pushNetworkToChainKey(pushNetwork);
496
459
  const pushClient = new push_client_1.PushClient({
497
460
  rpcUrls: chain_1.CHAIN_INFO[pushChainKey].defaultRPC,
498
461
  network: pushNetwork,
499
462
  });
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
463
  const byteCode = yield pushClient.publicClient.getCode({
522
- address: computedAddress,
464
+ address: address,
523
465
  });
524
- const isDeployed = byteCode !== undefined;
525
- // Cache the deployment status
526
- accountCache.set(cache_1.CacheKeys.deploymentStatus(computedAddress), isDeployed);
527
- return { address: computedAddress, deployed: isDeployed };
466
+ return {
467
+ address: address,
468
+ deployed: byteCode !== undefined,
469
+ };
528
470
  });
529
471
  }
530
472
  /**
531
473
  * Resolve the controller (origin) accounts for a given executor address.
532
474
  *
533
- * Given a UEA or CEA address (as CAIP-10), resolves the full controller chain
475
+ * Given a UEA or CEA plain address, resolves the full controller chain
534
476
  * back to the origin account.
535
477
  *
536
- * @param account - CAIP-10 formatted address string of the executor account
537
- * @param options.chain - Supplementary chain context (chain info is in CAIP-10)
478
+ * @param address - Plain address string of the executor account (e.g., "0xABC...")
479
+ * @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
480
  * @param options.skipNetworkCheck - If true, skip existence checks, set exists: false
539
481
  * @returns Resolved accounts in the controller chain
540
482
  */
541
- function resolveControllerAccount(account, options) {
483
+ function resolveControllerAccount(address, options) {
542
484
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
543
485
  var _a;
544
- const { chain: inputChain, address } = fromChainAgnostic(account);
486
+ const inputChain = options === null || options === void 0 ? void 0 : options.chain;
545
487
  const skipNetworkCheck = (_a = options === null || options === void 0 ? void 0 : options.skipNetworkCheck) !== null && _a !== void 0 ? _a : false;
546
- // Case A: Input is on an external chain (CEA)
547
- if (!isPushChain(inputChain)) {
488
+ // Case A: External chain → address is a CEA on that chain
489
+ if (inputChain && !isPushChain(inputChain)) {
548
490
  // Look up UEA on Push Chain from CEA
549
491
  const pushAccountAddress = yield (0, cea_utils_1.getPushAccountForCEA)(address, inputChain);
550
492
  if (pushAccountAddress === '0x0000000000000000000000000000000000000000') {
@@ -597,9 +539,12 @@ function resolveControllerAccount(account, options) {
597
539
  }
598
540
  return { accounts };
599
541
  }
600
- // Case B: Input is on Push Chain (UEA or EOA)
601
- const pushNetwork = getPushNetworkFromChain(inputChain);
542
+ // Case B: No chain or Push chain → address is a UEA or EOA on Push Chain
543
+ const pushNetwork = inputChain && isPushChain(inputChain)
544
+ ? getPushNetworkFromChain(inputChain)
545
+ : enums_1.PUSH_NETWORK.TESTNET_DONUT;
602
546
  const pushChainKey = pushNetworkToChainKey(pushNetwork);
547
+ const pushChainId = pushChainKey;
603
548
  const RPC_URL = chain_1.PUSH_CHAIN_INFO[pushChainKey].defaultRPC[0];
604
549
  const FACTORY_ADDRESS = chain_1.PUSH_CHAIN_INFO[pushChainKey].factoryAddress;
605
550
  const client = (0, viem_1.createPublicClient)({ transport: (0, viem_1.http)(RPC_URL) });
@@ -639,8 +584,8 @@ function resolveControllerAccount(account, options) {
639
584
  return {
640
585
  accounts: [
641
586
  {
642
- chain: inputChain,
643
- chainName: getChainName(inputChain),
587
+ chain: pushChainId,
588
+ chainName: getChainName(pushChainId),
644
589
  address: address,
645
590
  type: 'uoa',
646
591
  exists: skipNetworkCheck ? false : true,