@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.
Files changed (87) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/lib/constants/abi/cea.evm.d.ts +23 -0
  4. package/src/lib/constants/abi/cea.evm.js +34 -0
  5. package/src/lib/constants/abi/cea.evm.js.map +1 -0
  6. package/src/lib/constants/abi/ceaFactory.evm.d.ts +65 -0
  7. package/src/lib/constants/abi/ceaFactory.evm.js +41 -0
  8. package/src/lib/constants/abi/ceaFactory.evm.js.map +1 -0
  9. package/src/lib/constants/abi/erc20.evm.d.ts +14 -0
  10. package/src/lib/constants/abi/erc20.evm.js +7 -0
  11. package/src/lib/constants/abi/erc20.evm.js.map +1 -1
  12. package/src/lib/constants/abi/index.d.ts +6 -0
  13. package/src/lib/constants/abi/index.js +15 -1
  14. package/src/lib/constants/abi/index.js.map +1 -1
  15. package/src/lib/constants/abi/prc20.evm.d.ts +188 -0
  16. package/src/lib/constants/abi/prc20.evm.js +130 -0
  17. package/src/lib/constants/abi/prc20.evm.js.map +1 -0
  18. package/src/lib/constants/abi/uea-factory.d.ts +30 -0
  19. package/src/lib/constants/abi/uea-factory.js +25 -0
  20. package/src/lib/constants/abi/uea-factory.js.map +1 -0
  21. package/src/lib/constants/abi/universalGateway.evm.d.ts +93 -0
  22. package/src/lib/constants/abi/universalGateway.evm.js +70 -0
  23. package/src/lib/constants/abi/universalGateway.evm.js.map +1 -0
  24. package/src/lib/constants/abi/universalGatewayPC.evm.d.ts +140 -0
  25. package/src/lib/constants/abi/universalGatewayPC.evm.js +70 -0
  26. package/src/lib/constants/abi/universalGatewayPC.evm.js.map +1 -0
  27. package/src/lib/constants/abi/universalGatewayV0.evm.js +57 -0
  28. package/src/lib/constants/abi/universalGatewayV0.evm.js.map +1 -1
  29. package/src/lib/constants/abi/universalGatewayV0.json +1162 -1647
  30. package/src/lib/constants/chain.d.ts +52 -0
  31. package/src/lib/constants/chain.js +161 -1
  32. package/src/lib/constants/chain.js.map +1 -1
  33. package/src/lib/constants/index.d.ts +9 -1
  34. package/src/lib/constants/index.js +20 -1
  35. package/src/lib/constants/index.js.map +1 -1
  36. package/src/lib/constants/selectors.d.ts +42 -0
  37. package/src/lib/constants/selectors.js +45 -0
  38. package/src/lib/constants/selectors.js.map +1 -0
  39. package/src/lib/constants/tokens.d.ts +41 -0
  40. package/src/lib/constants/tokens.js +62 -1
  41. package/src/lib/constants/tokens.js.map +1 -1
  42. package/src/lib/generated/uexecutor/v2/index.d.ts +2 -0
  43. package/src/lib/generated/uexecutor/v2/index.js +31 -0
  44. package/src/lib/generated/uexecutor/v2/index.js.map +1 -0
  45. package/src/lib/generated/uexecutor/v2/query.d.ts +23 -0
  46. package/src/lib/generated/uexecutor/v2/query.js +79 -0
  47. package/src/lib/generated/uexecutor/v2/query.js.map +1 -0
  48. package/src/lib/generated/uexecutor/v2/types.d.ts +101 -0
  49. package/src/lib/generated/uexecutor/v2/types.js +660 -0
  50. package/src/lib/generated/uexecutor/v2/types.js.map +1 -0
  51. package/src/lib/generated/v1/tx.d.ts +22 -0
  52. package/src/lib/generated/v1/tx.js +188 -1
  53. package/src/lib/generated/v1/tx.js.map +1 -1
  54. package/src/lib/index.d.ts +5 -0
  55. package/src/lib/index.js +25 -1
  56. package/src/lib/index.js.map +1 -1
  57. package/src/lib/orchestrator/cea-utils.d.ts +85 -0
  58. package/src/lib/orchestrator/cea-utils.js +186 -0
  59. package/src/lib/orchestrator/cea-utils.js.map +1 -0
  60. package/src/lib/orchestrator/orchestrator.d.ts +326 -3
  61. package/src/lib/orchestrator/orchestrator.js +3262 -135
  62. package/src/lib/orchestrator/orchestrator.js.map +1 -1
  63. package/src/lib/orchestrator/orchestrator.types.d.ts +487 -0
  64. package/src/lib/orchestrator/orchestrator.types.js +17 -0
  65. package/src/lib/orchestrator/orchestrator.types.js.map +1 -1
  66. package/src/lib/orchestrator/payload-builders.d.ts +210 -1
  67. package/src/lib/orchestrator/payload-builders.js +481 -0
  68. package/src/lib/orchestrator/payload-builders.js.map +1 -1
  69. package/src/lib/orchestrator/route-detector.d.ts +102 -0
  70. package/src/lib/orchestrator/route-detector.js +355 -0
  71. package/src/lib/orchestrator/route-detector.js.map +1 -0
  72. package/src/lib/price-fetch/price-fetch.js +5 -2
  73. package/src/lib/price-fetch/price-fetch.js.map +1 -1
  74. package/src/lib/progress-hook/progress-hook.js +43 -0
  75. package/src/lib/progress-hook/progress-hook.js.map +1 -1
  76. package/src/lib/progress-hook/progress-hook.types.d.ts +7 -1
  77. package/src/lib/progress-hook/progress-hook.types.js +7 -0
  78. package/src/lib/progress-hook/progress-hook.types.js.map +1 -1
  79. package/src/lib/push-chain/push-chain.d.ts +71 -1
  80. package/src/lib/push-chain/push-chain.js +70 -1
  81. package/src/lib/push-chain/push-chain.js.map +1 -1
  82. package/src/lib/push-client/push-client.d.ts +10 -1
  83. package/src/lib/push-client/push-client.js +35 -6
  84. package/src/lib/push-client/push-client.js.map +1 -1
  85. package/src/lib/vm-client/evm-client.d.ts +3 -1
  86. package/src/lib/vm-client/evm-client.js +23 -15
  87. package/src/lib/vm-client/evm-client.js.map +1 -1
@@ -1,6 +1,215 @@
1
- import { ExecuteParams, MultiCall } from './orchestrator.types';
1
+ import { CHAIN } from '../constants/enums';
2
+ import type { ExecuteParams, MultiCall, UniversalOutboundTxRequest, SvmExecutePayloadFields } from './orchestrator.types';
2
3
  export declare function buildExecuteMulticall({ execute, ueaAddress, logger, }: {
3
4
  execute: ExecuteParams;
4
5
  ueaAddress: `0x${string}`;
5
6
  logger?: (msg: string) => void;
6
7
  }): MultiCall[];
8
+ /**
9
+ * Build CEA multicall payload for outbound transactions
10
+ * Format: UEA_MULTICALL_SELECTOR + abi.encode(Multicall[])
11
+ *
12
+ * The CEA contract checks for UEA_MULTICALL_SELECTOR (0x2cc2842d) at the
13
+ * start of the payload to route to _handleMulticall. Without this prefix,
14
+ * the CEA treats it as a single call and fails with InvalidRecipient.
15
+ *
16
+ * @param multicalls - Array of multicall operations to execute on external chain
17
+ * @returns UEA_MULTICALL_SELECTOR + ABI-encoded Multicall[] array
18
+ */
19
+ export declare function buildCeaMulticallPayload(multicalls: MultiCall[]): `0x${string}`;
20
+ /**
21
+ * Build an ABI-encoded UniversalPayload struct for inbound relay (Route 3 CEA→Push).
22
+ *
23
+ * The relay and Push Chain gateway expect the payload parameter of sendUniversalTxToUEA
24
+ * to be a full UniversalPayload struct: (address to, uint256 value, bytes data, uint256 gasLimit,
25
+ * uint256 maxFeePerGas, uint256 maxPriorityFeePerGas, uint256 nonce, uint256 deadline, uint8 vType).
26
+ *
27
+ * The `data` field inside the struct contains the multicall payload (with UEA_MULTICALL_SELECTOR prefix)
28
+ * which the UEA uses to execute calls on Push Chain.
29
+ *
30
+ * @param multicallData - The multicall payload (selector + abi.encode(Multicall[]))
31
+ * @param opts - Optional overrides for gasLimit, nonce, deadline
32
+ * @returns ABI-encoded UniversalPayload struct
33
+ */
34
+ export declare function buildInboundUniversalPayload(multicallData: `0x${string}`, opts?: {
35
+ gasLimit?: bigint;
36
+ nonce?: bigint;
37
+ deadline?: bigint;
38
+ }): `0x${string}`;
39
+ /**
40
+ * Build a single call as CEA multicall payload
41
+ *
42
+ * @param target - Target contract address
43
+ * @param value - Native value to send
44
+ * @param data - Calldata to execute
45
+ * @returns Encoded payload with selector prefix
46
+ */
47
+ export declare function buildSingleCeaCall(target: `0x${string}`, value: bigint, data: `0x${string}`): `0x${string}`;
48
+ /**
49
+ * Build approve + interact pattern for ERC20 operations on external chains
50
+ *
51
+ * @param tokenAddress - ERC20 token address
52
+ * @param spender - Address to approve (e.g., DEX router)
53
+ * @param amount - Amount to approve
54
+ * @param interactCall - The interaction call (e.g., swap)
55
+ * @returns Array of multicall operations
56
+ */
57
+ export declare function buildApproveAndInteract(tokenAddress: `0x${string}`, spender: `0x${string}`, amount: bigint, interactCall: MultiCall): MultiCall[];
58
+ /**
59
+ * Build sendUniversalTxFromCEA call for CEA → Push routing (Route 3)
60
+ *
61
+ * @param gatewayAddress - UniversalGateway address on external chain
62
+ * @param recipient - Recipient on Push Chain (usually UEA)
63
+ * @param token - Token address (address(0) for native)
64
+ * @param amount - Amount to send
65
+ * @param payload - Payload for Push Chain execution
66
+ * @param revertRecipient - Address to receive funds on revert
67
+ * @param signatureData - Signature data (usually empty for CEA calls)
68
+ * @param nativeValue - Native value to send with the call
69
+ * @returns MultiCall for sendUniversalTxFromCEA
70
+ */
71
+ export declare function buildSendUniversalTxFromCEA(gatewayAddress: `0x${string}`, recipient: `0x${string}`, token: `0x${string}`, amount: bigint, payload: `0x${string}`, revertRecipient: `0x${string}`, signatureData?: `0x${string}`, nativeValue?: bigint): MultiCall;
72
+ /**
73
+ * Build sendUniversalTxToUEA call for CEA self-call (Route 3)
74
+ *
75
+ * The CEA contract has a `sendUniversalTxToUEA(token, amount, payload, revertRecipient)` function
76
+ * that is only callable via self-call (multicall with to=CEA, value=0).
77
+ * It internally calls `gateway.sendUniversalTxFromCEA(...)`.
78
+ *
79
+ * @param ceaAddress - CEA contract address (multicall target = self)
80
+ * @param token - Token address (address(0) for native)
81
+ * @param amount - Amount to send
82
+ * @param payload - Payload for Push Chain execution
83
+ * @param revertRecipient - Address to receive funds on revert (on source chain)
84
+ * @returns MultiCall for sendUniversalTxToUEA (to=CEA, value=0)
85
+ */
86
+ export declare function buildSendUniversalTxToUEA(ceaAddress: `0x${string}`, token: `0x${string}`, amount: bigint, payload: `0x${string}`, revertRecipient: `0x${string}`): MultiCall;
87
+ /**
88
+ * Build UniversalOutboundTxRequest for Push Chain outbound
89
+ *
90
+ * @param target - LEGACY/DUMMY: Any non-zero address for contract compatibility.
91
+ * This value is NOT used by the relay to determine the actual destination.
92
+ * The relay determines the destination from the PRC-20 token's SOURCE_CHAIN_NAMESPACE.
93
+ * Will be removed in future contract upgrades.
94
+ * @param prc20Token - PRC20 token address to burn (or address(0) for native)
95
+ * @param amount - Amount to burn
96
+ * @param gasLimit - Gas limit for fee calculation
97
+ * @param payload - CEA multicall payload
98
+ * @param revertRecipient - Address to receive funds on revert
99
+ * @returns UniversalOutboundTxRequest object
100
+ */
101
+ export declare function buildOutboundRequest(target: `0x${string}`, prc20Token: `0x${string}`, amount: bigint, gasLimit: bigint, payload: `0x${string}`, revertRecipient: `0x${string}`): UniversalOutboundTxRequest;
102
+ /**
103
+ * Build native transfer multicall
104
+ *
105
+ * @param to - Recipient address
106
+ * @param value - Native value to transfer
107
+ * @returns MultiCall for native transfer
108
+ */
109
+ export declare function buildNativeTransfer(to: `0x${string}`, value: bigint): MultiCall;
110
+ /**
111
+ * Build ERC20 transfer multicall
112
+ *
113
+ * @param tokenAddress - ERC20 token address
114
+ * @param to - Recipient address
115
+ * @param amount - Amount to transfer
116
+ * @returns MultiCall for ERC20 transfer
117
+ */
118
+ export declare function buildErc20Transfer(tokenAddress: `0x${string}`, to: `0x${string}`, amount: bigint): MultiCall;
119
+ /**
120
+ * Build a single-element MultiCall[] for an ERC20 withdrawal (Flow 2.2).
121
+ * Wraps buildErc20Transfer so callers of Route 2 (executeUoaToCea) don't
122
+ * need to manually construct the transfer() multicall step.
123
+ *
124
+ * @param tokenAddress - ERC20 token contract on the external chain
125
+ * @param recipientAddress - Withdrawal recipient on the external chain
126
+ * @param amount - Amount of tokens to transfer
127
+ * @returns MultiCall[] with a single ERC20 transfer call
128
+ */
129
+ export declare function buildErc20WithdrawalMulticall(tokenAddress: `0x${string}`, recipientAddress: `0x${string}`, amount: bigint): MultiCall[];
130
+ /**
131
+ * Build the 4-byte migration payload for CEA upgrade (Migration flow).
132
+ * Returns exactly MIGRATION_SELECTOR — no Multicall wrapping.
133
+ *
134
+ * @returns 4-byte hex string `0xcac656d6`
135
+ */
136
+ export declare function buildMigrationPayload(): `0x${string}`;
137
+ /**
138
+ * Check if an address is the zero address
139
+ */
140
+ export declare function isZeroAddress(address: `0x${string}`): boolean;
141
+ /**
142
+ * Build approval multicalls + sendUniversalTxOutbound call for Push Chain.
143
+ *
144
+ * Extracted from executeUoaToCea to be reusable in cascade composition.
145
+ * Handles two cases:
146
+ * - gasToken === prc20Token: single approval for burnAmount + gasFee
147
+ * - gasToken !== prc20Token: two separate approvals
148
+ *
149
+ * @param opts.prc20Token - PRC-20 token to burn
150
+ * @param opts.gasToken - Gas token for fee payment
151
+ * @param opts.burnAmount - Amount to burn
152
+ * @param opts.gasFee - Gas fee amount
153
+ * @param opts.gatewayPcAddress - UniversalGatewayPC precompile address
154
+ * @param opts.outboundRequest - The outbound request struct
155
+ * @returns Array of MultiCall operations (approvals + outbound call)
156
+ */
157
+ export declare function buildOutboundApprovalAndCall(opts: {
158
+ prc20Token: `0x${string}`;
159
+ gasToken: `0x${string}`;
160
+ burnAmount: bigint;
161
+ gasFee: bigint;
162
+ nativeValueForGas?: bigint;
163
+ gatewayPcAddress: `0x${string}`;
164
+ outboundRequest: UniversalOutboundTxRequest;
165
+ }): MultiCall[];
166
+ /**
167
+ * Check if a chain targets the SVM (Solana) virtual machine
168
+ */
169
+ export declare function isSvmChain(chain: CHAIN): boolean;
170
+ /**
171
+ * Validate a Solana address in 0x-prefixed hex format.
172
+ * Must be exactly 32 bytes (0x + 64 hex chars = 66 characters total).
173
+ */
174
+ export declare function isValidSolanaHexAddress(address: string): boolean;
175
+ /**
176
+ * Encode SVM execute payload for CPI execution on Solana.
177
+ *
178
+ * Binary format (matching the Solana gateway contract expectation):
179
+ * ```
180
+ * [accounts_count: 4 bytes (u32 BE)]
181
+ * [account[i].pubkey: 32 bytes][account[i].is_writable: 1 byte] × N
182
+ * [ix_data_length: 4 bytes (u32 BE)]
183
+ * [ix_data: variable bytes]
184
+ * [instruction_id: 1 byte (u8)]
185
+ * [target_program: 32 bytes]
186
+ * ```
187
+ *
188
+ * @param fields - SVM execute payload fields
189
+ * @returns 0x-prefixed hex string of the encoded payload
190
+ */
191
+ export declare function encodeSvmExecutePayload(fields: SvmExecutePayloadFields): `0x${string}`;
192
+ /**
193
+ * Encode the SVM CEA-to-UEA payload for Route 3 on Solana.
194
+ *
195
+ * This builds a `send_universal_tx_to_uea` instruction wrapped in
196
+ * `encodeSvmExecutePayload`, targeting the gateway program as a self-call.
197
+ *
198
+ * Borsh ixData layout:
199
+ * ```
200
+ * [discriminator: 8 bytes (SHA-256("global:send_universal_tx_to_uea")[0..8])]
201
+ * [token: 32 bytes (PublicKey::default for SOL, mint pubkey for SPL)]
202
+ * [amount: 8 bytes (u64 LE)]
203
+ * [payload_len: 4 bytes (u32 LE)]
204
+ * [payload_bytes: variable]
205
+ * [revert_recipient: 32 bytes (PublicKey)]
206
+ * ```
207
+ */
208
+ export declare function encodeSvmCeaToUeaPayload({ gatewayProgramHex, drainAmount, tokenMintHex, extraPayload, revertRecipientHex, }: {
209
+ gatewayProgramHex: `0x${string}`;
210
+ drainAmount: bigint;
211
+ tokenMintHex?: `0x${string}`;
212
+ extraPayload?: Uint8Array;
213
+ /** 32-byte Solana pubkey as 0x-hex for revert recipient (required) */
214
+ revertRecipientHex: `0x${string}`;
215
+ }): `0x${string}`;