@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.
Files changed (86) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.json +1 -1
  3. package/src/lib/constants/abi/index.d.ts +2 -0
  4. package/src/lib/constants/abi/index.js +6 -1
  5. package/src/lib/constants/abi/uniswap-v3-router.evm.d.ts +58 -0
  6. package/src/lib/constants/abi/uniswap-v3-router.evm.js +41 -0
  7. package/src/lib/constants/abi/wpc.evm.d.ts +24 -0
  8. package/src/lib/constants/abi/wpc.evm.js +27 -0
  9. package/src/lib/constants/chain.d.ts +1 -0
  10. package/src/lib/constants/chain.js +8 -6
  11. package/src/lib/constants/tokens.js +3 -3
  12. package/src/lib/generated/uexecutor/v2/types.d.ts +14 -0
  13. package/src/lib/generated/uexecutor/v2/types.js +96 -3
  14. package/src/lib/orchestrator/internals/cascade.d.ts +1 -1
  15. package/src/lib/orchestrator/internals/cascade.js +521 -239
  16. package/src/lib/orchestrator/internals/confirmation.js +60 -15
  17. package/src/lib/orchestrator/internals/context.d.ts +23 -0
  18. package/src/lib/orchestrator/internals/context.js +54 -0
  19. package/src/lib/orchestrator/internals/execute-funds-only.js +47 -21
  20. package/src/lib/orchestrator/internals/execute-funds-payload.js +53 -31
  21. package/src/lib/orchestrator/internals/execute-standard.js +137 -26
  22. package/src/lib/orchestrator/internals/gas-calculator.d.ts +5 -2
  23. package/src/lib/orchestrator/internals/gas-calculator.js +59 -11
  24. package/src/lib/orchestrator/internals/gas-usd-sizer.d.ts +53 -0
  25. package/src/lib/orchestrator/internals/gas-usd-sizer.js +165 -0
  26. package/src/lib/orchestrator/internals/helpers.js +2 -0
  27. package/src/lib/orchestrator/internals/inbound-tracker.d.ts +83 -0
  28. package/src/lib/orchestrator/internals/inbound-tracker.js +322 -0
  29. package/src/lib/orchestrator/internals/index.d.ts +3 -1
  30. package/src/lib/orchestrator/internals/index.js +8 -2
  31. package/src/lib/orchestrator/internals/outbound-sync.d.ts +32 -1
  32. package/src/lib/orchestrator/internals/outbound-sync.js +154 -17
  33. package/src/lib/orchestrator/internals/pc-usd-oracle.d.ts +28 -0
  34. package/src/lib/orchestrator/internals/pc-usd-oracle.js +285 -0
  35. package/src/lib/orchestrator/internals/progress-route-hooks.d.ts +23 -0
  36. package/src/lib/orchestrator/internals/progress-route-hooks.js +72 -0
  37. package/src/lib/orchestrator/internals/push-chain-tx.d.ts +27 -1
  38. package/src/lib/orchestrator/internals/push-chain-tx.js +111 -15
  39. package/src/lib/orchestrator/internals/rescue.js +1 -1
  40. package/src/lib/orchestrator/internals/response-builder.d.ts +5 -0
  41. package/src/lib/orchestrator/internals/response-builder.js +242 -66
  42. package/src/lib/orchestrator/internals/route-handlers.js +480 -206
  43. package/src/lib/orchestrator/internals/tx-transformer.js +293 -35
  44. package/src/lib/orchestrator/orchestrator.d.ts +7 -1
  45. package/src/lib/orchestrator/orchestrator.js +108 -56
  46. package/src/lib/orchestrator/orchestrator.types.d.ts +111 -5
  47. package/src/lib/orchestrator/payload-builders.d.ts +16 -0
  48. package/src/lib/orchestrator/payload-builders.js +6 -5
  49. package/src/lib/orchestrator/route-detector.js +20 -8
  50. package/src/lib/orchestrator/svm-idl/normalize-address.d.ts +19 -0
  51. package/src/lib/orchestrator/svm-idl/normalize-address.js +56 -0
  52. package/src/lib/orchestrator/svm-idl/registry.d.ts +13 -4
  53. package/src/lib/orchestrator/svm-idl/registry.js +15 -14
  54. package/src/lib/orchestrator/svm-idl/resolve.js +5 -2
  55. package/src/lib/progress-hook/progress-hook.d.ts +28 -0
  56. package/src/lib/progress-hook/progress-hook.js +545 -131
  57. package/src/lib/progress-hook/progress-hook.types.d.ts +76 -29
  58. package/src/lib/progress-hook/progress-hook.types.js +74 -35
  59. package/src/lib/push-client/push-client.d.ts +7 -0
  60. package/src/lib/push-client/push-client.js +18 -1
  61. package/src/lib/universal-tx-detector/__tests__/fixtures/builders.d.ts +32 -0
  62. package/src/lib/universal-tx-detector/__tests__/fixtures/builders.js +65 -0
  63. package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.d.ts +72 -0
  64. package/src/lib/universal-tx-detector/__tests__/fixtures/scenarios.js +669 -0
  65. package/src/lib/universal-tx-detector/auto-detect.d.ts +37 -0
  66. package/src/lib/universal-tx-detector/auto-detect.js +112 -0
  67. package/src/lib/universal-tx-detector/cascade.d.ts +64 -0
  68. package/src/lib/universal-tx-detector/cascade.js +254 -0
  69. package/src/lib/universal-tx-detector/child-inbounds.d.ts +58 -0
  70. package/src/lib/universal-tx-detector/child-inbounds.js +145 -0
  71. package/src/lib/universal-tx-detector/classify.d.ts +33 -0
  72. package/src/lib/universal-tx-detector/classify.js +228 -0
  73. package/src/lib/universal-tx-detector/detector-svm.d.ts +46 -0
  74. package/src/lib/universal-tx-detector/detector-svm.js +324 -0
  75. package/src/lib/universal-tx-detector/detector.d.ts +13 -0
  76. package/src/lib/universal-tx-detector/detector.js +233 -0
  77. package/src/lib/universal-tx-detector/events.d.ts +765 -0
  78. package/src/lib/universal-tx-detector/events.js +241 -0
  79. package/src/lib/universal-tx-detector/index.d.ts +18 -0
  80. package/src/lib/universal-tx-detector/index.js +36 -0
  81. package/src/lib/universal-tx-detector/svm-events.d.ts +41 -0
  82. package/src/lib/universal-tx-detector/svm-events.js +68 -0
  83. package/src/lib/universal-tx-detector/types.d.ts +100 -0
  84. package/src/lib/universal-tx-detector/types.js +3 -0
  85. package/src/lib/utils.d.ts +30 -13
  86. 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 for registering program Anchor IDLs.
81
+ * SVM (Solana) escape-hatch utilities.
82
82
  *
83
- * Register your program's Anchor IDL once per process; `prepareTransaction`
84
- * then resolves accounts, PDAs, and signers from the IDL so you only need
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
- * @example
88
- * PushChain.utils.svm.registerIdl(
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
- encodeTxData({ abi, functionName, args = [], }) {
231
- if ((0, ix_encoder_1.isAnchorIdl)(abi)) {
232
- if (!Array.isArray(args)) {
233
- throw new Error('Arguments must be an array');
234
- }
235
- const bytes = (0, ix_encoder_1.encodeAnchorIxData)(abi, functionName, args);
236
- return `0x${buffer_1.Buffer.from(bytes).toString('hex')}`;
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
- // Validate inputs
239
- if (!Array.isArray(abi)) {
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
- // Find the function in the ABI
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;