@pafi-dev/core 0.5.20 → 0.5.22

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.d.ts CHANGED
@@ -972,6 +972,53 @@ declare function computeAuthorizationHash(chainId: number, address: Address, non
972
972
  */
973
973
  declare function isDelegatedToTarget(code: string | null | undefined, target: Address): boolean;
974
974
 
975
+ /**
976
+ * EIP-7702 authorization tuple in the JSON-RPC wire format that bundlers
977
+ * (Pimlico, Stackup, etc.) accept on `eth_sendUserOperation`. All
978
+ * numeric fields are 0x-prefixed hex strings.
979
+ *
980
+ * Constructed from the user's secp256k1 signature over
981
+ * `keccak256(0x05 || rlp([chainId, address, nonce]))` — see
982
+ * `computeAuthorizationHash`.
983
+ */
984
+ interface Eip7702AuthorizationJsonRpc {
985
+ chainId: Hex;
986
+ address: Address;
987
+ nonce: Hex;
988
+ r: Hex;
989
+ s: Hex;
990
+ yParity: Hex;
991
+ }
992
+ /**
993
+ * Split a serialized 65-byte ECDSA signature (`r || s || v`) into the
994
+ * `{ r, s, yParity }` triple required by EIP-7702 authorization tuples
995
+ * and EIP-1559+ transactions.
996
+ *
997
+ * Accepts the legacy `v ∈ {27, 28}` form and converts to `yParity ∈ {0, 1}`
998
+ * automatically. Already-normalized `v ∈ {0, 1}` passes through unchanged.
999
+ *
1000
+ * @throws when the signature is not 65 bytes (130 hex chars).
1001
+ */
1002
+ declare function splitAuthorizationSig(authSig: Hex | string): {
1003
+ r: Hex;
1004
+ s: Hex;
1005
+ yParity: 0 | 1;
1006
+ };
1007
+ /**
1008
+ * Build the JSON-RPC EIP-7702 authorization tuple from raw fields and a
1009
+ * 65-byte secp256k1 signature.
1010
+ *
1011
+ * The `authSig` is the user's signature over `computeAuthorizationHash(
1012
+ * chainId, address, nonce )` — typically obtained via
1013
+ * `wallet.signAuthorization(...)` on the client.
1014
+ */
1015
+ declare function buildEip7702Authorization(params: {
1016
+ chainId: number;
1017
+ address: Address;
1018
+ nonce: bigint;
1019
+ authSig: Hex | string;
1020
+ }): Eip7702AuthorizationJsonRpc;
1021
+
975
1022
  /**
976
1023
  * Parameters for `createPafiProxyTransport`.
977
1024
  */
@@ -1202,6 +1249,8 @@ interface ContractAddresses {
1202
1249
  * shouldn't be able to redirect this fee to themselves.
1203
1250
  */
1204
1251
  pafiFeeRecipient: Address;
1252
+ /** Uniswap V4 UniversalRouter — swap entry point for the swap handler. */
1253
+ universalRouter: Address;
1205
1254
  }
1206
1255
  declare const CONTRACT_ADDRESSES: Record<number, ContractAddresses>;
1207
1256
  /**
@@ -1597,4 +1646,4 @@ declare class PafiSDK {
1597
1646
  signLoginMessage(message: string): Promise<Hex>;
1598
1647
  }
1599
1648
 
1600
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, QuoteResult, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpTypedData, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
1649
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, QuoteResult, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpTypedData, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.js CHANGED
@@ -586,6 +586,37 @@ function toMinimalHex(n) {
586
586
  return `0x${hex.length % 2 === 0 ? hex : "0" + hex}`;
587
587
  }
588
588
 
589
+ // src/delegation/eip7702Authorization.ts
590
+ function splitAuthorizationSig(authSig) {
591
+ const raw = authSig.startsWith("0x") ? authSig.slice(2) : authSig;
592
+ if (raw.length !== 130) {
593
+ throw new Error(
594
+ `splitAuthorizationSig: expected 65-byte signature (130 hex chars), got ${raw.length}`
595
+ );
596
+ }
597
+ const r = `0x${raw.slice(0, 64)}`;
598
+ const s = `0x${raw.slice(64, 128)}`;
599
+ const v = parseInt(raw.slice(128, 130), 16);
600
+ const yParity = v === 27 ? 0 : v === 28 ? 1 : v;
601
+ if (yParity !== 0 && yParity !== 1) {
602
+ throw new Error(
603
+ `splitAuthorizationSig: invalid recovery byte ${v} (expected 0/1/27/28)`
604
+ );
605
+ }
606
+ return { r, s, yParity };
607
+ }
608
+ function buildEip7702Authorization(params) {
609
+ const { r, s, yParity } = splitAuthorizationSig(params.authSig);
610
+ return {
611
+ chainId: `0x${params.chainId.toString(16)}`,
612
+ address: params.address,
613
+ nonce: `0x${params.nonce.toString(16)}`,
614
+ r,
615
+ s,
616
+ yParity: `0x${yParity}`
617
+ };
618
+ }
619
+
589
620
  // src/transport/proxyTransport.ts
590
621
  import { http } from "viem";
591
622
  function createPafiProxyTransport(params) {
@@ -716,7 +747,8 @@ var CONTRACT_ADDRESSES = {
716
747
  pafiHook: "0x870cAF9882d3160602AaC1769C2B264A2d8EC044",
717
748
  chainlinkEthUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
718
749
  orderlyRelay: "0xDA082DAce1522c185aeB5A713FcA6fa6B6E99e7f",
719
- pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e"
750
+ pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e",
751
+ universalRouter: "0x6fF5693b99212Da76ad316178A184AB56D299b43"
720
752
  },
721
753
  // Base Sepolia — not in active use; placeholders kept so the map
722
754
  // compiles for tooling that enumerates chains.
@@ -729,7 +761,8 @@ var CONTRACT_ADDRESSES = {
729
761
  pafiHook: PLACEHOLDER_DEAD("dead"),
730
762
  chainlinkEthUsd: PLACEHOLDER_DEAD("de02"),
731
763
  orderlyRelay: PLACEHOLDER_DEAD("de03"),
732
- pafiFeeRecipient: PLACEHOLDER_DEAD("de04")
764
+ pafiFeeRecipient: PLACEHOLDER_DEAD("de04"),
765
+ universalRouter: PLACEHOLDER_DEAD("de05")
733
766
  }
734
767
  };
735
768
  var POINT_TOKEN_FACTORY_ADDRESSES = {
@@ -1255,6 +1288,7 @@ export {
1255
1288
  buildBurnRequestTypedData,
1256
1289
  buildDelegationUserOp,
1257
1290
  buildDomain,
1291
+ buildEip7702Authorization,
1258
1292
  buildErc20ApprovalCalldata,
1259
1293
  buildMintRequestTypedData,
1260
1294
  buildPartialUserOperation,
@@ -1334,6 +1368,7 @@ export {
1334
1368
  signReceiverConsent,
1335
1369
  signSponsorAuth,
1336
1370
  simulateSwap,
1371
+ splitAuthorizationSig,
1337
1372
  universalRouterAbi,
1338
1373
  v4QuoterAbi,
1339
1374
  verifyBurnRequest,