@pushchain/core 5.1.16 → 5.1.18

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/lib/constants/index.d.ts +1 -1
  3. package/src/lib/constants/index.js +2 -1
  4. package/src/lib/constants/selectors.d.ts +8 -0
  5. package/src/lib/constants/selectors.js +9 -1
  6. package/src/lib/formatters.d.ts +1 -0
  7. package/src/lib/formatters.js +32 -0
  8. package/src/lib/orchestrator/internals/cascade.d.ts +8 -1
  9. package/src/lib/orchestrator/internals/cascade.js +486 -143
  10. package/src/lib/orchestrator/internals/error-decoder.d.ts +2 -6
  11. package/src/lib/orchestrator/internals/error-decoder.js +10 -10
  12. package/src/lib/orchestrator/internals/errors.d.ts +1 -1
  13. package/src/lib/orchestrator/internals/errors.js +7 -4
  14. package/src/lib/orchestrator/internals/execute-standard.js +7 -6
  15. package/src/lib/orchestrator/internals/gas-calculator.js +78 -11
  16. package/src/lib/orchestrator/internals/helpers.d.ts +2 -1
  17. package/src/lib/orchestrator/internals/helpers.js +13 -11
  18. package/src/lib/orchestrator/internals/outbound-sync.d.ts +1 -0
  19. package/src/lib/orchestrator/internals/outbound-sync.js +93 -37
  20. package/src/lib/orchestrator/internals/preflight.d.ts +9 -23
  21. package/src/lib/orchestrator/internals/preflight.js +22 -48
  22. package/src/lib/orchestrator/internals/response-builder.js +23 -7
  23. package/src/lib/orchestrator/internals/route-handlers.js +34 -49
  24. package/src/lib/orchestrator/internals/tx-transformer.js +2 -1
  25. package/src/lib/orchestrator/orchestrator.d.ts +7 -1
  26. package/src/lib/orchestrator/orchestrator.js +40 -2
  27. package/src/lib/orchestrator/orchestrator.types.d.ts +4 -14
  28. package/src/lib/progress-hook/progress-hook.js +66 -16
  29. package/src/lib/progress-hook/progress-hook.types.d.ts +4 -1
  30. package/src/lib/progress-hook/progress-hook.types.js +8 -0
  31. package/src/lib/push-chain/push-chain.d.ts +11 -1
  32. package/src/lib/push-chain/push-chain.js +2 -2
  33. package/src/lib/universal-tx-detector/cascade.js +14 -4
  34. package/src/lib/universal-tx-detector/child-inbounds.js +9 -1
  35. package/src/lib/universal-tx-detector/detector.js +9 -3
  36. package/src/lib/universal-tx-detector/normalize.d.ts +42 -0
  37. package/src/lib/universal-tx-detector/normalize.js +127 -0
  38. package/src/lib/utils/external-tx-hash.d.ts +37 -0
  39. package/src/lib/utils/external-tx-hash.js +62 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushchain/core",
3
- "version": "5.1.16",
3
+ "version": "5.1.18",
4
4
  "homepage": "https://push.org",
5
5
  "keywords": [
6
6
  "pushchain",
@@ -14,4 +14,4 @@ export declare const CONSTANTS: {
14
14
  };
15
15
  export type { TypedDataDomain, TypedData };
16
16
  export { CHAIN_EXPLORERS, CEA_FACTORY_ADDRESSES, UNIVERSAL_GATEWAY_ADDRESSES, VAULT_ADDRESSES, getExplorerTxUrl, getExplorerAddressUrl, } from './chain';
17
- export { MULTICALL_SELECTOR, UEA_MULTICALL_SELECTOR, MIGRATION_SELECTOR, TX_TYPE, ZERO_ADDRESS, DEFAULT_OUTBOUND_GAS_LIMIT, } from './selectors';
17
+ export { MULTICALL_SELECTOR, UEA_MULTICALL_SELECTOR, MIGRATION_SELECTOR, TX_TYPE, ZERO_ADDRESS, DEFAULT_OUTBOUND_GAS_LIMIT, DEFAULT_CEA_TO_PUSH_GAS_LIMIT, } from './selectors';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = exports.getExplorerAddressUrl = exports.getExplorerTxUrl = exports.VAULT_ADDRESSES = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.CEA_FACTORY_ADDRESSES = exports.CHAIN_EXPLORERS = exports.CONSTANTS = void 0;
3
+ exports.DEFAULT_CEA_TO_PUSH_GAS_LIMIT = exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = exports.getExplorerAddressUrl = exports.getExplorerTxUrl = exports.VAULT_ADDRESSES = exports.UNIVERSAL_GATEWAY_ADDRESSES = exports.CEA_FACTORY_ADDRESSES = exports.CHAIN_EXPLORERS = exports.CONSTANTS = void 0;
4
4
  const enums_1 = require("./enums");
5
5
  const tokens_1 = require("./tokens");
6
6
  // NOTE - Only include enums & constants which need to be exported to end user.
@@ -27,4 +27,5 @@ Object.defineProperty(exports, "MIGRATION_SELECTOR", { enumerable: true, get: fu
27
27
  Object.defineProperty(exports, "TX_TYPE", { enumerable: true, get: function () { return selectors_1.TX_TYPE; } });
28
28
  Object.defineProperty(exports, "ZERO_ADDRESS", { enumerable: true, get: function () { return selectors_1.ZERO_ADDRESS; } });
29
29
  Object.defineProperty(exports, "DEFAULT_OUTBOUND_GAS_LIMIT", { enumerable: true, get: function () { return selectors_1.DEFAULT_OUTBOUND_GAS_LIMIT; } });
30
+ Object.defineProperty(exports, "DEFAULT_CEA_TO_PUSH_GAS_LIMIT", { enumerable: true, get: function () { return selectors_1.DEFAULT_CEA_TO_PUSH_GAS_LIMIT; } });
30
31
  //# sourceMappingURL=index.js.map
@@ -40,3 +40,11 @@ export declare const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
40
40
  * Default gas limit for outbound transactions
41
41
  */
42
42
  export declare const DEFAULT_OUTBOUND_GAS_LIMIT: bigint;
43
+ /**
44
+ * Default gas limit for EVM Route 3 (CEA -> Push) source-chain execution.
45
+ *
46
+ * This path can deploy the CEA and then execute sendUniversalTxToUEA with a
47
+ * nested Push payload. Live Sepolia traces estimate ~540k gas for that shape,
48
+ * so the generic 500k outbound default is too tight.
49
+ */
50
+ export declare const DEFAULT_CEA_TO_PUSH_GAS_LIMIT: bigint;
@@ -3,7 +3,7 @@
3
3
  * Function selectors and constants for multi-chain transactions
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = void 0;
6
+ exports.DEFAULT_CEA_TO_PUSH_GAS_LIMIT = exports.DEFAULT_OUTBOUND_GAS_LIMIT = exports.ZERO_ADDRESS = exports.TX_TYPE = exports.MIGRATION_SELECTOR = exports.UEA_MULTICALL_SELECTOR = exports.MULTICALL_SELECTOR = void 0;
7
7
  /**
8
8
  * MULTICALL_SELECTOR
9
9
  * Selector for CEA multicall execution
@@ -42,4 +42,12 @@ exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
42
42
  * Default gas limit for outbound transactions
43
43
  */
44
44
  exports.DEFAULT_OUTBOUND_GAS_LIMIT = BigInt(500000);
45
+ /**
46
+ * Default gas limit for EVM Route 3 (CEA -> Push) source-chain execution.
47
+ *
48
+ * This path can deploy the CEA and then execute sendUniversalTxToUEA with a
49
+ * nested Push payload. Live Sepolia traces estimate ~540k gas for that shape,
50
+ * so the generic 500k outbound default is too tight.
51
+ */
52
+ exports.DEFAULT_CEA_TO_PUSH_GAS_LIMIT = BigInt(750000);
45
53
  //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ export declare function formatPc(valueWei: bigint, precision?: number): string;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPc = formatPc;
4
+ const PC_DECIMALS = 18;
5
+ function formatTokenUnits(value, decimals, precision) {
6
+ if (!Number.isInteger(decimals) || decimals < 0) {
7
+ throw new Error('decimals must be a non-negative integer');
8
+ }
9
+ if (precision !== undefined &&
10
+ (!Number.isInteger(precision) || precision < 0)) {
11
+ throw new Error('precision must be a non-negative integer');
12
+ }
13
+ const negative = value < BigInt(0);
14
+ const absolute = negative ? -value : value;
15
+ let scale = BigInt(1);
16
+ for (let i = 0; i < decimals; i++) {
17
+ scale *= BigInt(10);
18
+ }
19
+ const whole = absolute / scale;
20
+ const remainder = absolute % scale;
21
+ let fraction = decimals > 0 ? remainder.toString().padStart(decimals, '0') : '';
22
+ if (precision !== undefined) {
23
+ fraction = fraction.slice(0, precision);
24
+ }
25
+ fraction = fraction.replace(/0+$/, '');
26
+ const sign = negative ? '-' : '';
27
+ return `${sign}${whole.toString()}${fraction ? `.${fraction}` : ''}`;
28
+ }
29
+ function formatPc(valueWei, precision) {
30
+ return `${formatTokenUnits(valueWei, PC_DECIMALS, precision)} PC`;
31
+ }
32
+ //# sourceMappingURL=formatters.js.map
@@ -7,9 +7,11 @@
7
7
  import { TransactionRoute } from '../route-detector';
8
8
  import type { HopDescriptor, CascadeSegment, CascadeSegmentType, PreparedUniversalTx, CascadedTxResponse, CascadeHopInfo, UniversalTxResponse, UniversalExecuteParams, MultiCall, WaitForOutboundOptions, OutboundTxDetails } from '../orchestrator.types';
9
9
  import type { OrchestratorContext } from './context';
10
+ import { type InboundPushTxDetails, type WaitForInboundOptions } from './inbound-tracker';
10
11
  export interface CascadeCallbacks {
11
12
  executeFn: (params: any) => Promise<UniversalTxResponse>;
12
13
  waitForOutboundTxFn: (hash: string, opts?: WaitForOutboundOptions) => Promise<OutboundTxDetails>;
14
+ waitForInboundPushTxFn?: (outboundExternalTxHash: string, sourceChain: string, opts?: WaitForInboundOptions) => Promise<InboundPushTxDetails>;
13
15
  waitForAllOutboundTxsFn: (hash: string, hops: CascadeHopInfo[], opts: any) => Promise<{
14
16
  success: boolean;
15
17
  failedAt?: number;
@@ -35,7 +37,12 @@ export declare function prepareTransaction(ctx: OrchestratorContext, params: Uni
35
37
  export declare function buildHopDescriptor(ctx: OrchestratorContext, params: UniversalExecuteParams, route: TransactionRoute, ueaAddress: `0x${string}`): Promise<HopDescriptor>;
36
38
  export declare function classifyIntoSegments(hops: HopDescriptor[]): CascadeSegment[];
37
39
  export declare function getSegmentType(route: string): CascadeSegmentType;
40
+ export interface ComposeCascadeResult {
41
+ multicalls: MultiCall[];
42
+ requiredNativeValue: bigint;
43
+ }
44
+ export declare function composeCascadeDetailed(ctx: OrchestratorContext, segments: CascadeSegment[], ueaAddress: `0x${string}`, ueaBalance?: bigint, ueaNonce?: bigint): Promise<ComposeCascadeResult>;
38
45
  export declare function composeCascade(ctx: OrchestratorContext, segments: CascadeSegment[], ueaAddress: `0x${string}`, ueaBalance?: bigint, ueaNonce?: bigint): Promise<MultiCall[]>;
39
- export declare function createCascadedBuilder(ctx: OrchestratorContext, preparedTxs: PreparedUniversalTx[], callbacks: CascadeCallbacks): {
46
+ export declare function createCascadedBuilder(ctx: OrchestratorContext, preparedTxs: PreparedUniversalTx[], callbacks: CascadeCallbacks, defaultEventHook?: (event: import('../../progress-hook/progress-hook.types').ProgressEvent) => void): {
40
47
  send: () => Promise<CascadedTxResponse>;
41
48
  };