@pafi-dev/core 0.24.0 → 0.25.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.
package/dist/index.js CHANGED
@@ -1,3 +1,15 @@
1
+ import {
2
+ erc20Abi,
3
+ permit2Abi,
4
+ pointModuleCoreAbi,
5
+ pointTokenFactoryAbi,
6
+ settlementVaultAbi,
7
+ tokenRegistryAbi,
8
+ universalRouterAbi,
9
+ v3QuoterV2Abi,
10
+ vaultFactoryAbi,
11
+ vaultRegistryAbi
12
+ } from "./chunk-ZQVYWMOG.js";
1
13
  import {
2
14
  SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
3
15
  SPONSOR_AUTH_DOMAIN_NAME,
@@ -13,7 +25,7 @@ import {
13
25
  signSponsorAuth,
14
26
  verifyLoginMessage,
15
27
  verifySponsorAuth
16
- } from "./chunk-4EGXLYMM.js";
28
+ } from "./chunk-IKLFFJJK.js";
17
29
  import {
18
30
  Source,
19
31
  computeEquityCap,
@@ -33,18 +45,6 @@ import {
33
45
  verifyIssuerOperative,
34
46
  verifyMint
35
47
  } from "./chunk-4VPIPVV5.js";
36
- import {
37
- erc20Abi,
38
- permit2Abi,
39
- pointModuleCoreAbi,
40
- pointTokenFactoryAbi,
41
- settlementVaultAbi,
42
- tokenRegistryAbi,
43
- universalRouterAbi,
44
- v3QuoterV2Abi,
45
- vaultFactoryAbi,
46
- vaultRegistryAbi
47
- } from "./chunk-ZQVYWMOG.js";
48
48
  import {
49
49
  issuerRegistryAbi,
50
50
  mintFeeWrapperAbi,
@@ -332,36 +332,116 @@ function rawCallOp(target, data, value = 0n) {
332
332
  return { target, value, data };
333
333
  }
334
334
 
335
- // src/userop/batchExecute.ts
336
- import { decodeFunctionData, encodeFunctionData as encodeFunctionData2, parseAbi as parseAbi2 } from "viem";
337
- var BATCH_EXECUTOR_ABI = parseAbi2([
338
- "function executeBatch((address target, uint256 value, bytes data)[] calls)"
335
+ // src/userop/kernelExecute.ts
336
+ import {
337
+ concat,
338
+ decodeAbiParameters,
339
+ encodeAbiParameters as encodeAbiParameters2,
340
+ encodeFunctionData as encodeFunctionData2,
341
+ pad,
342
+ parseAbi as parseAbi2,
343
+ toHex
344
+ } from "viem";
345
+ var KERNEL_EXECUTE_ABI = parseAbi2([
346
+ "function execute(bytes32 execMode, bytes executionCalldata)"
339
347
  ]);
340
- function encodeBatchExecute(operations) {
348
+ var KERNEL_EXECUTE_SELECTOR = "0xe9ae5c53";
349
+ var KERNEL_EXECUTE_USEROP_SELECTOR = "0x8dd7712f";
350
+ var CALLTYPE_SINGLE = "0x00";
351
+ var CALLTYPE_BATCH = "0x01";
352
+ var EXECUTION_BATCH_ABI = [
353
+ {
354
+ name: "executionBatch",
355
+ type: "tuple[]",
356
+ components: [
357
+ { name: "target", type: "address" },
358
+ { name: "value", type: "uint256" },
359
+ { name: "callData", type: "bytes" }
360
+ ]
361
+ }
362
+ ];
363
+ function execMode(callType) {
364
+ return pad(callType, { dir: "right", size: 32 });
365
+ }
366
+ function encodeKernelExecute(operations) {
341
367
  if (operations.length === 0) {
342
- throw new Error("encodeBatchExecute: operations array must not be empty");
368
+ throw new Error("encodeKernelExecute: operations array must not be empty");
369
+ }
370
+ if (operations.length === 1) {
371
+ const op = operations[0];
372
+ const executionCalldata2 = concat([
373
+ op.target,
374
+ toHex(op.value, { size: 32 }),
375
+ op.data
376
+ ]);
377
+ return encodeFunctionData2({
378
+ abi: KERNEL_EXECUTE_ABI,
379
+ functionName: "execute",
380
+ args: [execMode(CALLTYPE_SINGLE), executionCalldata2]
381
+ });
343
382
  }
383
+ const executionCalldata = encodeAbiParameters2(EXECUTION_BATCH_ABI, [
384
+ operations.map((op) => ({
385
+ target: op.target,
386
+ value: op.value,
387
+ callData: op.data
388
+ }))
389
+ ]);
344
390
  return encodeFunctionData2({
345
- abi: BATCH_EXECUTOR_ABI,
346
- functionName: "executeBatch",
347
- args: [
348
- operations.map((op) => ({
349
- target: op.target,
350
- value: op.value,
351
- data: op.data
352
- }))
353
- ]
391
+ abi: KERNEL_EXECUTE_ABI,
392
+ functionName: "execute",
393
+ args: [execMode(CALLTYPE_BATCH), executionCalldata]
354
394
  });
355
395
  }
356
- function decodeBatchExecuteCalls(callData) {
357
- const { args } = decodeFunctionData({
358
- abi: BATCH_EXECUTOR_ABI,
359
- data: callData
360
- });
361
- return args[0].map((c) => ({
362
- to: c.target,
363
- data: c.data,
364
- value: c.value.toString()
396
+ function decodeKernelExecute(callData) {
397
+ let data = callData.toLowerCase();
398
+ if (data.startsWith(KERNEL_EXECUTE_USEROP_SELECTOR)) {
399
+ data = "0x" + data.slice(KERNEL_EXECUTE_USEROP_SELECTOR.length);
400
+ }
401
+ if (!data.startsWith(KERNEL_EXECUTE_SELECTOR)) return null;
402
+ let mode;
403
+ let executionCalldata;
404
+ try {
405
+ [mode, executionCalldata] = decodeAbiParameters(
406
+ [{ type: "bytes32" }, { type: "bytes" }],
407
+ "0x" + data.slice(10)
408
+ );
409
+ } catch {
410
+ return null;
411
+ }
412
+ const callType = mode.slice(2, 4);
413
+ const execType = mode.slice(4, 6);
414
+ if (execType !== "00") return null;
415
+ if (callType === "00") {
416
+ const body = executionCalldata.slice(2);
417
+ if (body.length < (20 + 32) * 2) return null;
418
+ return [
419
+ {
420
+ target: "0x" + body.slice(0, 40),
421
+ value: BigInt("0x" + body.slice(40, 40 + 64)),
422
+ data: "0x" + body.slice(40 + 64)
423
+ }
424
+ ];
425
+ }
426
+ if (callType === "01") {
427
+ try {
428
+ const [rows] = decodeAbiParameters(EXECUTION_BATCH_ABI, executionCalldata);
429
+ return rows.map((r) => ({ target: r.target, value: r.value, data: r.callData }));
430
+ } catch {
431
+ return null;
432
+ }
433
+ }
434
+ return null;
435
+ }
436
+ function decodeKernelExecuteCalls(callData) {
437
+ const ops = decodeKernelExecute(callData);
438
+ if (!ops) {
439
+ throw new Error("decodeKernelExecuteCalls: callData is not a Kernel execute");
440
+ }
441
+ return ops.map((op) => ({
442
+ to: op.target,
443
+ data: op.data,
444
+ value: op.value.toString()
365
445
  }));
366
446
  }
367
447
 
@@ -373,7 +453,7 @@ function buildPartialUserOperation(params) {
373
453
  return {
374
454
  sender: params.sender,
375
455
  nonce: params.nonce,
376
- callData: encodeBatchExecute(params.operations),
456
+ callData: encodeKernelExecute(params.operations),
377
457
  callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_CALL_GAS_LIMIT,
378
458
  verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_VERIFICATION_GAS_LIMIT,
379
459
  preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_PRE_VERIFICATION_GAS,
@@ -603,75 +683,41 @@ function serializeUserOpToJsonRpc(userOp, signature) {
603
683
  }
604
684
 
605
685
  // src/userop/computeUserOpHash.ts
606
- import {
607
- concat,
608
- hashTypedData,
609
- pad,
610
- toHex
611
- } from "viem";
612
- var PACKED_USER_OPERATION_TYPES = {
613
- PackedUserOperation: [
614
- { name: "sender", type: "address" },
615
- { name: "nonce", type: "uint256" },
616
- { name: "initCode", type: "bytes" },
617
- { name: "callData", type: "bytes" },
618
- { name: "accountGasLimits", type: "bytes32" },
619
- { name: "preVerificationGas", type: "uint256" },
620
- { name: "gasFees", type: "bytes32" },
621
- { name: "paymasterAndData", type: "bytes" }
622
- ]
623
- };
624
- function buildUserOpTypedData(userOp, chainId) {
625
- const accountGasLimits = pack128(
626
- userOp.verificationGasLimit,
627
- userOp.callGasLimit
628
- );
629
- const gasFees = pack128(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas);
630
- const paymasterAndData = userOp.paymaster ? concat([
631
- userOp.paymaster,
632
- pad(toHex(userOp.paymasterVerificationGasLimit ?? 0n), { size: 16 }),
633
- pad(toHex(userOp.paymasterPostOpGasLimit ?? 0n), { size: 16 }),
634
- userOp.paymasterData ?? "0x"
635
- ]) : "0x";
636
- return {
637
- domain: {
638
- name: "ERC4337",
639
- version: "1",
640
- chainId,
641
- verifyingContract: ENTRY_POINT_V08
642
- },
643
- types: PACKED_USER_OPERATION_TYPES,
644
- primaryType: "PackedUserOperation",
645
- message: {
686
+ import { getUserOperationHash } from "viem/account-abstraction";
687
+ function computeUserOpHash(userOp, chainId) {
688
+ const paymasterFields = userOp.paymaster ? {
689
+ paymaster: userOp.paymaster,
690
+ paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit ?? 0n,
691
+ paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit ?? 0n,
692
+ paymasterData: userOp.paymasterData ?? "0x"
693
+ } : {};
694
+ return getUserOperationHash({
695
+ chainId,
696
+ entryPointAddress: ENTRY_POINT_V07,
697
+ entryPointVersion: "0.7",
698
+ userOperation: {
646
699
  sender: userOp.sender,
647
700
  nonce: userOp.nonce,
648
- initCode: "0x",
649
701
  callData: userOp.callData,
650
- accountGasLimits,
702
+ callGasLimit: userOp.callGasLimit,
703
+ verificationGasLimit: userOp.verificationGasLimit,
651
704
  preVerificationGas: userOp.preVerificationGas,
652
- gasFees,
653
- paymasterAndData
705
+ maxFeePerGas: userOp.maxFeePerGas,
706
+ maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
707
+ signature: "0x",
708
+ ...paymasterFields
654
709
  }
655
- };
656
- }
657
- function computeUserOpHash(userOp, chainId) {
658
- const td = buildUserOpTypedData(userOp, chainId);
659
- return hashTypedData(td);
660
- }
661
- function pack128(hi, lo) {
662
- return `0x${(hi << 128n | lo).toString(16).padStart(64, "0")}`;
710
+ });
663
711
  }
664
712
 
665
713
  // src/userop/eip7702Helpers.ts
666
714
  import { getAddress } from "viem";
667
- var SIMPLE_7702_IMPL_BASE_MAINNET = "0xe6Cae83BdE06E4c305530e199D7217f42808555B";
668
- var BATCH_EXECUTOR_7702_IMPL = "0x7702cb554e6bFb442cb743A7dF23154544a7176C";
715
+ var KERNEL_V3_3_IMPL = "0xd6CEDDe84be40893d153Be9d467CD6aD37875b28";
669
716
  var DUMMY_SIGNATURE_V07 = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
670
717
  function detectDelegateImpl(delegate) {
671
718
  if (!delegate) return "unknown";
672
719
  const addr = getAddress(delegate).toLowerCase();
673
- if (addr === SIMPLE_7702_IMPL_BASE_MAINNET.toLowerCase()) return "simple7702";
674
- if (addr === BATCH_EXECUTOR_7702_IMPL.toLowerCase()) return "batchExecutor";
720
+ if (addr === KERNEL_V3_3_IMPL.toLowerCase()) return "kernel";
675
721
  return "unknown";
676
722
  }
677
723
  function getDummySignatureFor7702(impl) {
@@ -774,29 +820,7 @@ async function isDelegatedTo(client, address, target) {
774
820
  return impl.toLowerCase() === target.toLowerCase();
775
821
  }
776
822
 
777
- // src/delegation/buildDelegationUserOp.ts
778
- function buildDelegationUserOp(params) {
779
- return buildPartialUserOperation({
780
- sender: params.userAddress,
781
- nonce: params.aaNonce,
782
- operations: [
783
- {
784
- // Self-call with no data — triggers EIP-7702 delegation without
785
- // executing any inner logic. The BatchExecutor.execute([]) call with
786
- // an empty array would revert, so we target the EOA itself (which
787
- // forwards to BatchExecutor that then no-ops on empty input).
788
- target: params.userAddress,
789
- value: 0n,
790
- data: "0x"
791
- }
792
- ],
793
- gasLimits: {
794
- callGasLimit: params.gasLimits?.callGasLimit ?? 50000n,
795
- verificationGasLimit: params.gasLimits?.verificationGasLimit ?? 150000n,
796
- preVerificationGas: params.gasLimits?.preVerificationGas ?? 50000n
797
- }
798
- });
799
- }
823
+ // src/delegation/aaNonce.ts
800
824
  async function getAaNonce(client, userAddress) {
801
825
  const NONCE_ABI = [
802
826
  {
@@ -811,7 +835,7 @@ async function getAaNonce(client, userAddress) {
811
835
  }
812
836
  ];
813
837
  return client.readContract({
814
- address: ENTRY_POINT_V08,
838
+ address: ENTRY_POINT_V07,
815
839
  abi: NONCE_ABI,
816
840
  functionName: "getNonce",
817
841
  args: [userAddress, 0n]
@@ -883,8 +907,11 @@ var CONTRACT_ADDRESSES = {
883
907
  // were rotated as part of the dual-bucket schema change.
884
908
  // ──────────────────────────────────────────────────────────────────
885
909
  8453: {
886
- // ── Periphery (inherited from v1.6, unchanged) ────────────────
887
- batchExecutor: "0xe6Cae83BdE06E4c305530e199D7217f42808555B",
910
+ // ── Periphery ─────────────────────────────────────────────────
911
+ // ZeroDev Kernel v3.3 impl — EIP-7702 delegation target (replaces
912
+ // the retired Pimlico Simple7702Account 0xe6Cae83…8555B).
913
+ // CREATE2-deterministic → identical address on every chain.
914
+ kernel: "0xd6CEDDe84be40893d153Be9d467CD6aD37875b28",
888
915
  chainlinkEthUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
889
916
  orderlyRelay: "0xDA082DAce1522c185aeB5A713FcA6fa6B6E99e7f",
890
917
  pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e",
@@ -930,7 +957,8 @@ var CONTRACT_ADDRESSES = {
930
957
  // Base Sepolia — not in active use; placeholders kept so the map
931
958
  // compiles for tooling that enumerates chains.
932
959
  84532: {
933
- batchExecutor: PLACEHOLDER_DEAD("de01"),
960
+ // Kernel v3.3 impl is CREATE2-deterministic — same address as mainnet.
961
+ kernel: "0xd6CEDDe84be40893d153Be9d467CD6aD37875b28",
934
962
  usdt: PLACEHOLDER_DEAD("dead"),
935
963
  issuerRegistry: PLACEHOLDER_DEAD("dead"),
936
964
  mintingOracle: PLACEHOLDER_DEAD("dead"),
@@ -978,7 +1006,7 @@ function getContractAddresses(chainId) {
978
1006
 
979
1007
  // src/delegation/delegateDirect.ts
980
1008
  async function delegateDirect(params) {
981
- const target = params.contractAddress ?? getContractAddresses(params.chainId).batchExecutor;
1009
+ const target = params.contractAddress ?? getContractAddresses(params.chainId).kernel;
982
1010
  if (params.skipIfAlreadyDelegated !== false) {
983
1011
  const code = await params.publicClient.getCode({
984
1012
  address: params.userAddress
@@ -1505,9 +1533,9 @@ var POINT_TOKEN_ABI = parseAbi4([
1505
1533
  "event MintingOracleUpdated(address indexed mintingOracle)"
1506
1534
  ]);
1507
1535
 
1508
- // src/contracts/real/batchExecutor.ts
1509
- var BATCH_EXECUTOR_ADDRESS_BASE_MAINNET = getContractAddresses(8453).batchExecutor;
1510
- var BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).batchExecutor;
1536
+ // src/contracts/real/kernel.ts
1537
+ var KERNEL_ADDRESS_BASE_MAINNET = getContractAddresses(8453).kernel;
1538
+ var KERNEL_ADDRESS_BASE_SEPOLIA = getContractAddresses(84532).kernel;
1511
1539
 
1512
1540
  // src/contracts/real/pafi-services.ts
1513
1541
  var PAFI_SERVICE_URLS = {
@@ -1804,10 +1832,6 @@ var PafiSDK = class {
1804
1832
  };
1805
1833
  export {
1806
1834
  ApiError,
1807
- BATCH_EXECUTOR_7702_IMPL,
1808
- BATCH_EXECUTOR_ABI,
1809
- BATCH_EXECUTOR_ADDRESS_BASE_MAINNET,
1810
- BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA,
1811
1835
  BROKER_HASHES,
1812
1836
  COMMON_POOLS,
1813
1837
  COMMON_TOKENS,
@@ -1817,6 +1841,12 @@ export {
1817
1841
  ENTRY_POINT_V07,
1818
1842
  ENTRY_POINT_V08,
1819
1843
  Eip712DomainMismatchError,
1844
+ KERNEL_ADDRESS_BASE_MAINNET,
1845
+ KERNEL_ADDRESS_BASE_SEPOLIA,
1846
+ KERNEL_EXECUTE_ABI,
1847
+ KERNEL_EXECUTE_SELECTOR,
1848
+ KERNEL_EXECUTE_USEROP_SELECTOR,
1849
+ KERNEL_V3_3_IMPL,
1820
1850
  ORDERLY_RELAY_ABI,
1821
1851
  ORDERLY_VAULT_ABI,
1822
1852
  ORDERLY_VAULT_ADDRESSES,
@@ -1837,7 +1867,6 @@ export {
1837
1867
  QUOTER_V2_ADDRESSES,
1838
1868
  SCENARIO_GAS_UNITS,
1839
1869
  SDK_ERROR_HTTP_STATUS_CODE,
1840
- SIMPLE_7702_IMPL_BASE_MAINNET,
1841
1870
  SPONSOR_AUTH_DOMAIN_ANCHOR_BASE_MAINNET,
1842
1871
  SPONSOR_AUTH_DOMAIN_NAME,
1843
1872
  SPONSOR_AUTH_TYPES,
@@ -1858,7 +1887,6 @@ export {
1858
1887
  attachDelegationIfNeeded,
1859
1888
  buildAndSignSponsorAuth,
1860
1889
  buildBurnRequestTypedData,
1861
- buildDelegationUserOp,
1862
1890
  buildDomain,
1863
1891
  buildEip7702Authorization,
1864
1892
  buildErc20TransferUserOp,
@@ -1868,7 +1896,6 @@ export {
1868
1896
  buildPerpDepositWithGasDeduction,
1869
1897
  buildSponsorAuthDomain,
1870
1898
  buildSponsorAuthTypedData,
1871
- buildUserOpTypedData,
1872
1899
  burnRequestTypes,
1873
1900
  checkDelegation,
1874
1901
  checkEthAndBranch,
@@ -1880,11 +1907,12 @@ export {
1880
1907
  computeV3PoolAddress,
1881
1908
  createLoginMessage,
1882
1909
  createPafiProxyTransport,
1883
- decodeBatchExecuteCalls,
1910
+ decodeKernelExecute,
1911
+ decodeKernelExecuteCalls,
1884
1912
  defaultErrorTypeForStatus,
1885
1913
  delegateDirect,
1886
1914
  detectDelegateImpl,
1887
- encodeBatchExecute,
1915
+ encodeKernelExecute,
1888
1916
  encodeV3Path,
1889
1917
  encodeV3PathReversed,
1890
1918
  erc20Abi,