@pushchain/core 5.1.5-alpha.1 → 5.1.5
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 +19 -0
- package/package.json +1 -1
- package/src/lib/constants/abi/index.d.ts +2 -0
- package/src/lib/constants/abi/index.js +6 -1
- package/src/lib/constants/abi/uniswap-v3-router.evm.d.ts +58 -0
- package/src/lib/constants/abi/uniswap-v3-router.evm.js +41 -0
- package/src/lib/constants/abi/wpc.evm.d.ts +24 -0
- package/src/lib/constants/abi/wpc.evm.js +27 -0
- package/src/lib/constants/chain.d.ts +1 -0
- package/src/lib/constants/chain.js +8 -6
- package/src/lib/constants/tokens.js +3 -3
- package/src/lib/generated/uexecutor/v2/types.d.ts +14 -0
- package/src/lib/generated/uexecutor/v2/types.js +96 -3
- package/src/lib/orchestrator/internals/cascade.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.js +521 -239
- package/src/lib/orchestrator/internals/confirmation.js +60 -15
- package/src/lib/orchestrator/internals/context.d.ts +23 -0
- package/src/lib/orchestrator/internals/context.js +54 -0
- package/src/lib/orchestrator/internals/execute-funds-only.js +47 -21
- package/src/lib/orchestrator/internals/execute-funds-payload.js +53 -31
- package/src/lib/orchestrator/internals/execute-standard.js +137 -26
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +5 -2
- package/src/lib/orchestrator/internals/gas-calculator.js +59 -11
- package/src/lib/orchestrator/internals/gas-usd-sizer.d.ts +53 -0
- package/src/lib/orchestrator/internals/gas-usd-sizer.js +165 -0
- package/src/lib/orchestrator/internals/helpers.js +2 -0
- package/src/lib/orchestrator/internals/inbound-tracker.d.ts +83 -0
- package/src/lib/orchestrator/internals/inbound-tracker.js +322 -0
- package/src/lib/orchestrator/internals/index.d.ts +3 -1
- package/src/lib/orchestrator/internals/index.js +8 -2
- package/src/lib/orchestrator/internals/outbound-sync.d.ts +32 -1
- package/src/lib/orchestrator/internals/outbound-sync.js +154 -17
- package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +28 -0
- package/src/lib/orchestrator/internals/pc-usd-oracle.js +285 -0
- package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +23 -0
- package/src/lib/orchestrator/internals/progress-route-hooks.js +72 -0
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +27 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +111 -15
- package/src/lib/orchestrator/internals/rescue.js +1 -1
- package/src/lib/orchestrator/internals/response-builder.d.ts +5 -0
- package/src/lib/orchestrator/internals/response-builder.js +242 -66
- package/src/lib/orchestrator/internals/route-handlers.js +480 -206
- package/src/lib/orchestrator/internals/tx-transformer.js +293 -35
- package/src/lib/orchestrator/orchestrator.d.ts +7 -1
- package/src/lib/orchestrator/orchestrator.js +108 -56
- package/src/lib/orchestrator/orchestrator.types.d.ts +111 -5
- package/src/lib/orchestrator/payload-builders.d.ts +16 -0
- package/src/lib/orchestrator/payload-builders.js +6 -5
- package/src/lib/orchestrator/route-detector.js +20 -8
- package/src/lib/orchestrator/svm-idl/normalize-address.d.ts +19 -0
- package/src/lib/orchestrator/svm-idl/normalize-address.js +56 -0
- package/src/lib/orchestrator/svm-idl/registry.d.ts +13 -4
- package/src/lib/orchestrator/svm-idl/registry.js +15 -14
- package/src/lib/orchestrator/svm-idl/resolve.js +5 -2
- package/src/lib/progress-hook/progress-hook.d.ts +28 -0
- package/src/lib/progress-hook/progress-hook.js +545 -131
- package/src/lib/progress-hook/progress-hook.types.d.ts +76 -29
- package/src/lib/progress-hook/progress-hook.types.js +74 -35
- package/src/lib/push-client/push-client.d.ts +7 -0
- package/src/lib/push-client/push-client.js +18 -1
- package/src/lib/universal-tx-detector/__tests__/fixtures/builders.d.ts +32 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/builders.js +65 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.d.ts +72 -0
- package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.js +669 -0
- package/src/lib/universal-tx-detector/auto-detect.d.ts +37 -0
- package/src/lib/universal-tx-detector/auto-detect.js +112 -0
- package/src/lib/universal-tx-detector/cascade.d.ts +64 -0
- package/src/lib/universal-tx-detector/cascade.js +254 -0
- package/src/lib/universal-tx-detector/child-inbounds.d.ts +58 -0
- package/src/lib/universal-tx-detector/child-inbounds.js +145 -0
- package/src/lib/universal-tx-detector/classify.d.ts +33 -0
- package/src/lib/universal-tx-detector/classify.js +228 -0
- package/src/lib/universal-tx-detector/detector-svm.d.ts +46 -0
- package/src/lib/universal-tx-detector/detector-svm.js +324 -0
- package/src/lib/universal-tx-detector/detector.d.ts +13 -0
- package/src/lib/universal-tx-detector/detector.js +233 -0
- package/src/lib/universal-tx-detector/events.d.ts +765 -0
- package/src/lib/universal-tx-detector/events.js +241 -0
- package/src/lib/universal-tx-detector/index.d.ts +18 -0
- package/src/lib/universal-tx-detector/index.js +36 -0
- package/src/lib/universal-tx-detector/svm-events.d.ts +41 -0
- package/src/lib/universal-tx-detector/svm-events.js +68 -0
- package/src/lib/universal-tx-detector/types.d.ts +100 -0
- package/src/lib/universal-tx-detector/types.js +3 -0
- package/src/lib/utils.d.ts +30 -13
- package/src/lib/utils.js +47 -21
package/src/lib/utils.js
CHANGED
|
@@ -78,22 +78,17 @@ Utils.account = {
|
|
|
78
78
|
resolveControllerAccount: account_1.resolveControllerAccount,
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
|
-
* SVM (Solana) utilities
|
|
81
|
+
* SVM (Solana) escape-hatch utilities.
|
|
82
82
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* to pass `data` (discriminator + Borsh args), the same shape used for EVM.
|
|
83
|
+
* `PushChain.utils.helpers.encodeTxData({ abi: idl, ... })` auto-registers
|
|
84
|
+
* the Anchor IDL internally, so normal callers never need these.
|
|
86
85
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* PROGRAM_ADDRESS_HEX,
|
|
90
|
-
* testCounterIdl
|
|
91
|
-
* );
|
|
86
|
+
* Use `registerIdl` directly only when you build `data` manually (raw
|
|
87
|
+
* Anchor discriminator + Borsh bytes) and bypass `encodeTxData`.
|
|
92
88
|
*/
|
|
93
89
|
Utils.svm = {
|
|
94
90
|
registerIdl: registry_1.registerIdl,
|
|
95
91
|
getRegisteredIdls: registry_1.getRegisteredIdls,
|
|
96
|
-
getIdl: registry_1.getIdl,
|
|
97
92
|
};
|
|
98
93
|
Utils.signer = {
|
|
99
94
|
/**
|
|
@@ -227,22 +222,47 @@ Utils.helpers = {
|
|
|
227
222
|
return Utils.chains.getChainName(chainName);
|
|
228
223
|
};
|
|
229
224
|
})(),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Encode calldata for a universal tx.
|
|
227
|
+
*
|
|
228
|
+
* Pass `abi` for EVM targets, or `idl` for SVM (Anchor) targets. Exactly
|
|
229
|
+
* one of the two is required.
|
|
230
|
+
*
|
|
231
|
+
* @example EVM
|
|
232
|
+
* PushChain.utils.helpers.encodeTxData({
|
|
233
|
+
* abi: erc20Abi,
|
|
234
|
+
* functionName: 'transfer',
|
|
235
|
+
* args: [to, amount],
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* @example SVM (Anchor)
|
|
239
|
+
* PushChain.utils.helpers.encodeTxData({
|
|
240
|
+
* idl: counterIdl,
|
|
241
|
+
* functionName: 'increment',
|
|
242
|
+
* args: [],
|
|
243
|
+
* });
|
|
244
|
+
*/
|
|
245
|
+
encodeTxData({ abi, idl, functionName, args = [], }) {
|
|
246
|
+
if (abi !== undefined && idl !== undefined) {
|
|
247
|
+
throw new Error("encodeTxData: pass either 'abi' (EVM) or 'idl' (SVM), not both");
|
|
237
248
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
throw new Error('ABI must be an array');
|
|
249
|
+
if (abi === undefined && idl === undefined) {
|
|
250
|
+
throw new Error("encodeTxData: either 'abi' (EVM) or 'idl' (SVM) must be provided");
|
|
241
251
|
}
|
|
242
252
|
if (!Array.isArray(args)) {
|
|
243
253
|
throw new Error('Arguments must be an array');
|
|
244
254
|
}
|
|
245
|
-
//
|
|
255
|
+
// SVM path: explicit idl, or legacy abi-as-IDL for backward compat.
|
|
256
|
+
const svmIdl = idl !== null && idl !== void 0 ? idl : ((0, ix_encoder_1.isAnchorIdl)(abi) ? abi : undefined);
|
|
257
|
+
if (svmIdl) {
|
|
258
|
+
(0, registry_1.registerIdl)(svmIdl);
|
|
259
|
+
const bytes = (0, ix_encoder_1.encodeAnchorIxData)(svmIdl, functionName, args);
|
|
260
|
+
return `0x${buffer_1.Buffer.from(bytes).toString('hex')}`;
|
|
261
|
+
}
|
|
262
|
+
// EVM path
|
|
263
|
+
if (!Array.isArray(abi)) {
|
|
264
|
+
throw new Error('ABI must be an array');
|
|
265
|
+
}
|
|
246
266
|
const functionAbi = abi.find((f) => f.name === functionName);
|
|
247
267
|
if (!functionAbi) {
|
|
248
268
|
throw new Error(`Function '${functionName}' not found in ABI`);
|
|
@@ -600,6 +620,12 @@ Utils.tokens = {
|
|
|
600
620
|
*/
|
|
601
621
|
getPRC20Address(token, options) {
|
|
602
622
|
var _a, _b;
|
|
623
|
+
// PushChainMoveableToken (pETH, pSOL, pUSDT(BNB), …) carries its PRC-20 address
|
|
624
|
+
// directly. Return it as-is — no registry lookup needed.
|
|
625
|
+
const maybePrc20 = token.prc20Address;
|
|
626
|
+
if (maybePrc20) {
|
|
627
|
+
return maybePrc20;
|
|
628
|
+
}
|
|
603
629
|
// Infer origin chain and symbol by matching against the MOVEABLE_TOKENS registry
|
|
604
630
|
let originChain;
|
|
605
631
|
let tokenSymbol;
|