@pafi-dev/core 0.5.1 → 0.5.3

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.cts CHANGED
@@ -453,6 +453,31 @@ declare function assembleUserOperation(partial: PartialUserOperation, paymaster:
453
453
  paymasterPostOpGasLimit: bigint;
454
454
  }, signature: `0x${string}`): UserOperation;
455
455
 
456
+ /**
457
+ * ERC-4337 v0.7 UserOp hash, matching EntryPoint._hashUserOp().
458
+ *
459
+ * The returned hash is what the user signs via personal_sign / eth_sign.
460
+ * Paymaster fields are included when present — they must match exactly
461
+ * what was sent to the bundler, or signature recovery fails on-chain.
462
+ *
463
+ * Use this on the **backend** (mobile prepare/submit pattern) to compute
464
+ * the hash before returning it to the mobile client for signing.
465
+ */
466
+ declare function computeUserOpHash(userOp: {
467
+ sender: Address;
468
+ nonce: bigint;
469
+ callData: Hex;
470
+ callGasLimit: bigint;
471
+ verificationGasLimit: bigint;
472
+ preVerificationGas: bigint;
473
+ maxFeePerGas: bigint;
474
+ maxPriorityFeePerGas: bigint;
475
+ paymaster?: Address;
476
+ paymasterVerificationGasLimit?: bigint;
477
+ paymasterPostOpGasLimit?: bigint;
478
+ paymasterData?: Hex;
479
+ }, chainId: number): Hex;
480
+
456
481
  /**
457
482
  * Module-level paymaster config shared by all batch builders and the
458
483
  * `@pafi/issuer` RelayService. Holds the fee recipient address and the
@@ -649,6 +674,29 @@ declare function buildDelegationUserOp(params: BuildDelegationUserOpParams): Par
649
674
  */
650
675
  declare function getAaNonce(client: PublicClient, userAddress: Address): Promise<bigint>;
651
676
 
677
+ /**
678
+ * EIP-7702 authorization tuple hash.
679
+ *
680
+ * keccak256(0x05 || rlp([chain_id, address, nonce]))
681
+ *
682
+ * The user signs this hash with a **raw secp256k1 sign** (no EIP-191 prefix).
683
+ * On mobile, pass the result to the wallet's raw signing primitive.
684
+ *
685
+ * The resulting 65-byte signature is sent to `POST /delegate/submit` as `authSig`.
686
+ *
687
+ * Reference: EIP-7702 §3 — Authorization tuple
688
+ */
689
+ declare function computeAuthorizationHash(chainId: number, address: Address, nonce: bigint): Hex;
690
+ /**
691
+ * Check whether an EOA code string carries an EIP-7702 delegation to `target`.
692
+ *
693
+ * Sync alternative to `isDelegatedTo()` for callers that already have the
694
+ * code from a prior `eth_getCode` call and don't want another RPC round-trip.
695
+ *
696
+ * Delegation designator format: 0xef0100 (3 bytes) || address (20 bytes)
697
+ */
698
+ declare function isDelegatedToTarget(code: string | null | undefined, target: Address): boolean;
699
+
652
700
  /**
653
701
  * Parameters for `createPafiProxyTransport`.
654
702
  */
@@ -1406,6 +1454,21 @@ declare function getPafiWebModalAdapter(): PafiWebModalAdapter | null;
1406
1454
  */
1407
1455
  declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Promise<PafiWebModalHandle>;
1408
1456
 
1457
+ /** PAFI-hosted subgraph endpoint — single source of truth across all SDK packages. */
1458
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1459
+ /**
1460
+ * Fetch the Uniswap V4 pool(s) for a PAFI PointToken from the subgraph.
1461
+ *
1462
+ * Browser and Node compatible — uses globalThis.fetch. Returns an empty
1463
+ * array (never throws) when the token has no pool yet or the subgraph is
1464
+ * unreachable, so callers can show "quote unavailable" without crashing.
1465
+ *
1466
+ * @param chainId - Chain ID (reserved for multi-subgraph routing; currently unused)
1467
+ * @param pointTokenAddress - The PointToken contract address
1468
+ * @param subgraphUrl - Override the default PAFI subgraph URL
1469
+ */
1470
+ declare function fetchPafiPools(_chainId: number, pointTokenAddress: Address, subgraphUrl?: string): Promise<PoolKey[]>;
1471
+
1409
1472
  declare class PafiSDK {
1410
1473
  private _pointTokenAddress?;
1411
1474
  private _signer?;
@@ -1541,4 +1604,4 @@ declare class PafiSDK {
1541
1604
  signLoginMessage(message: string): Promise<Hex>;
1542
1605
  }
1543
1606
 
1544
- export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
1607
+ export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
package/dist/index.d.ts CHANGED
@@ -453,6 +453,31 @@ declare function assembleUserOperation(partial: PartialUserOperation, paymaster:
453
453
  paymasterPostOpGasLimit: bigint;
454
454
  }, signature: `0x${string}`): UserOperation;
455
455
 
456
+ /**
457
+ * ERC-4337 v0.7 UserOp hash, matching EntryPoint._hashUserOp().
458
+ *
459
+ * The returned hash is what the user signs via personal_sign / eth_sign.
460
+ * Paymaster fields are included when present — they must match exactly
461
+ * what was sent to the bundler, or signature recovery fails on-chain.
462
+ *
463
+ * Use this on the **backend** (mobile prepare/submit pattern) to compute
464
+ * the hash before returning it to the mobile client for signing.
465
+ */
466
+ declare function computeUserOpHash(userOp: {
467
+ sender: Address;
468
+ nonce: bigint;
469
+ callData: Hex;
470
+ callGasLimit: bigint;
471
+ verificationGasLimit: bigint;
472
+ preVerificationGas: bigint;
473
+ maxFeePerGas: bigint;
474
+ maxPriorityFeePerGas: bigint;
475
+ paymaster?: Address;
476
+ paymasterVerificationGasLimit?: bigint;
477
+ paymasterPostOpGasLimit?: bigint;
478
+ paymasterData?: Hex;
479
+ }, chainId: number): Hex;
480
+
456
481
  /**
457
482
  * Module-level paymaster config shared by all batch builders and the
458
483
  * `@pafi/issuer` RelayService. Holds the fee recipient address and the
@@ -649,6 +674,29 @@ declare function buildDelegationUserOp(params: BuildDelegationUserOpParams): Par
649
674
  */
650
675
  declare function getAaNonce(client: PublicClient, userAddress: Address): Promise<bigint>;
651
676
 
677
+ /**
678
+ * EIP-7702 authorization tuple hash.
679
+ *
680
+ * keccak256(0x05 || rlp([chain_id, address, nonce]))
681
+ *
682
+ * The user signs this hash with a **raw secp256k1 sign** (no EIP-191 prefix).
683
+ * On mobile, pass the result to the wallet's raw signing primitive.
684
+ *
685
+ * The resulting 65-byte signature is sent to `POST /delegate/submit` as `authSig`.
686
+ *
687
+ * Reference: EIP-7702 §3 — Authorization tuple
688
+ */
689
+ declare function computeAuthorizationHash(chainId: number, address: Address, nonce: bigint): Hex;
690
+ /**
691
+ * Check whether an EOA code string carries an EIP-7702 delegation to `target`.
692
+ *
693
+ * Sync alternative to `isDelegatedTo()` for callers that already have the
694
+ * code from a prior `eth_getCode` call and don't want another RPC round-trip.
695
+ *
696
+ * Delegation designator format: 0xef0100 (3 bytes) || address (20 bytes)
697
+ */
698
+ declare function isDelegatedToTarget(code: string | null | undefined, target: Address): boolean;
699
+
652
700
  /**
653
701
  * Parameters for `createPafiProxyTransport`.
654
702
  */
@@ -1406,6 +1454,21 @@ declare function getPafiWebModalAdapter(): PafiWebModalAdapter | null;
1406
1454
  */
1407
1455
  declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Promise<PafiWebModalHandle>;
1408
1456
 
1457
+ /** PAFI-hosted subgraph endpoint — single source of truth across all SDK packages. */
1458
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1459
+ /**
1460
+ * Fetch the Uniswap V4 pool(s) for a PAFI PointToken from the subgraph.
1461
+ *
1462
+ * Browser and Node compatible — uses globalThis.fetch. Returns an empty
1463
+ * array (never throws) when the token has no pool yet or the subgraph is
1464
+ * unreachable, so callers can show "quote unavailable" without crashing.
1465
+ *
1466
+ * @param chainId - Chain ID (reserved for multi-subgraph routing; currently unused)
1467
+ * @param pointTokenAddress - The PointToken contract address
1468
+ * @param subgraphUrl - Override the default PAFI subgraph URL
1469
+ */
1470
+ declare function fetchPafiPools(_chainId: number, pointTokenAddress: Address, subgraphUrl?: string): Promise<PoolKey[]>;
1471
+
1409
1472
  declare class PafiSDK {
1410
1473
  private _pointTokenAddress?;
1411
1474
  private _signer?;
@@ -1541,4 +1604,4 @@ declare class PafiSDK {
1541
1604
  signLoginMessage(message: string): Promise<Hex>;
1542
1605
  }
1543
1606
 
1544
- export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
1607
+ export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
package/dist/index.js CHANGED
@@ -245,6 +245,69 @@ function buildPerpDepositWithGasDeduction(params) {
245
245
  // src/userop/types.ts
246
246
  var ZERO_VALUE = 0n;
247
247
 
248
+ // src/userop/computeUserOpHash.ts
249
+ import {
250
+ concat,
251
+ encodeAbiParameters as encodeAbiParameters2,
252
+ keccak256 as keccak2562,
253
+ pad,
254
+ toHex
255
+ } from "viem";
256
+ function computeUserOpHash(userOp, chainId) {
257
+ const accountGasLimits = pack128(
258
+ userOp.verificationGasLimit,
259
+ userOp.callGasLimit
260
+ );
261
+ const gasFees = pack128(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas);
262
+ const paymasterAndData = userOp.paymaster ? concat([
263
+ userOp.paymaster,
264
+ pad(toHex(userOp.paymasterVerificationGasLimit ?? 0n), { size: 16 }),
265
+ pad(toHex(userOp.paymasterPostOpGasLimit ?? 0n), { size: 16 }),
266
+ userOp.paymasterData ?? "0x"
267
+ ]) : "0x";
268
+ const packed = keccak2562(
269
+ encodeAbiParameters2(
270
+ [
271
+ { type: "address" },
272
+ // sender
273
+ { type: "uint256" },
274
+ // nonce
275
+ { type: "bytes32" },
276
+ // keccak(initCode) — no factory so keccak(0x)
277
+ { type: "bytes32" },
278
+ // keccak(callData)
279
+ { type: "bytes32" },
280
+ // accountGasLimits
281
+ { type: "uint256" },
282
+ // preVerificationGas
283
+ { type: "bytes32" },
284
+ // gasFees
285
+ { type: "bytes32" }
286
+ // keccak(paymasterAndData)
287
+ ],
288
+ [
289
+ userOp.sender,
290
+ userOp.nonce,
291
+ keccak2562("0x"),
292
+ keccak2562(userOp.callData),
293
+ accountGasLimits,
294
+ userOp.preVerificationGas,
295
+ gasFees,
296
+ keccak2562(paymasterAndData)
297
+ ]
298
+ )
299
+ );
300
+ return keccak2562(
301
+ encodeAbiParameters2(
302
+ [{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
303
+ [packed, ENTRY_POINT_V07, BigInt(chainId)]
304
+ )
305
+ );
306
+ }
307
+ function pack128(hi, lo) {
308
+ return `0x${(hi << 128n | lo).toString(16).padStart(64, "0")}`;
309
+ }
310
+
248
311
  // src/paymaster/config.ts
249
312
  var _config = null;
250
313
  function setPaymasterConfig(config) {
@@ -354,6 +417,27 @@ async function getAaNonce(client, userAddress) {
354
417
  });
355
418
  }
356
419
 
420
+ // src/delegation/computeAuthorizationHash.ts
421
+ import { concat as concat2, keccak256 as keccak2563, toRlp } from "viem";
422
+ function computeAuthorizationHash(chainId, address, nonce) {
423
+ const rlpEncoded = toRlp([
424
+ toMinimalHex(BigInt(chainId)),
425
+ address,
426
+ toMinimalHex(nonce)
427
+ ]);
428
+ return keccak2563(concat2(["0x05", rlpEncoded]));
429
+ }
430
+ function isDelegatedToTarget(code, target) {
431
+ if (!code || code === "0x") return false;
432
+ const expected = `0xef0100${target.slice(2).toLowerCase()}`;
433
+ return code.toLowerCase() === expected;
434
+ }
435
+ function toMinimalHex(n) {
436
+ if (n === 0n) return "0x";
437
+ const hex = n.toString(16);
438
+ return `0x${hex.length % 2 === 0 ? hex : "0" + hex}`;
439
+ }
440
+
357
441
  // src/transport/proxyTransport.ts
358
442
  import { http } from "viem";
359
443
  function createPafiProxyTransport(params) {
@@ -612,6 +696,73 @@ async function openPafiWebModal(url, options = {}) {
612
696
  );
613
697
  }
614
698
 
699
+ // src/subgraph/pools.ts
700
+ import { isAddress } from "viem";
701
+ var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
702
+ var POOL_QUERY = `
703
+ query GetPoolForPointToken($id: ID!) {
704
+ pafiToken(id: $id) {
705
+ id
706
+ pool {
707
+ id
708
+ feeTier
709
+ tickSpacing
710
+ hooks
711
+ token0 { id }
712
+ token1 { id }
713
+ }
714
+ }
715
+ }
716
+ `;
717
+ function sortCurrencies(a, b) {
718
+ return a.toLowerCase() < b.toLowerCase() ? [a, b] : [b, a];
719
+ }
720
+ async function fetchPafiPools(_chainId, pointTokenAddress, subgraphUrl = PAFI_SUBGRAPH_URL) {
721
+ let response;
722
+ try {
723
+ response = await fetch(subgraphUrl, {
724
+ method: "POST",
725
+ headers: { "Content-Type": "application/json" },
726
+ body: JSON.stringify({
727
+ query: POOL_QUERY,
728
+ variables: { id: pointTokenAddress.toLowerCase() }
729
+ })
730
+ });
731
+ } catch (err) {
732
+ console.warn("[fetchPafiPools] subgraph unreachable:", err.message);
733
+ return [];
734
+ }
735
+ if (!response.ok) {
736
+ console.warn(`[fetchPafiPools] subgraph returned ${response.status}`);
737
+ return [];
738
+ }
739
+ const json = await response.json();
740
+ if (json.errors && json.errors.length > 0) {
741
+ console.warn(
742
+ "[fetchPafiPools] subgraph errors:",
743
+ json.errors.map((e) => e.message).join("; ")
744
+ );
745
+ return [];
746
+ }
747
+ const pool = json.data?.pafiToken?.pool;
748
+ if (!pool) return [];
749
+ if (!isAddress(pool.hooks) || !isAddress(pool.token0.id) || !isAddress(pool.token1.id) || !Number.isFinite(Number(pool.feeTier)) || !Number.isFinite(Number(pool.tickSpacing))) {
750
+ console.error("[fetchPafiPools] invalid pool data in subgraph response \u2014 skipping");
751
+ return [];
752
+ }
753
+ const [currency0, currency1] = sortCurrencies(
754
+ pool.token0.id,
755
+ pool.token1.id
756
+ );
757
+ return [{
758
+ currency0,
759
+ currency1,
760
+ fee: Number(pool.feeTier),
761
+ tickSpacing: Number(pool.tickSpacing),
762
+ hooks: pool.hooks
763
+ }];
764
+ }
765
+
615
766
  // src/index.ts
616
767
  var PafiSDK = class {
617
768
  _pointTokenAddress;
@@ -845,6 +996,7 @@ export {
845
996
  ORDERLY_VAULT_ABI,
846
997
  ORDERLY_VAULT_ADDRESSES,
847
998
  ORDERLY_VAULT_BASE_MAINNET,
999
+ PAFI_SUBGRAPH_URL,
848
1000
  PERMIT2_ADDRESS,
849
1001
  POINT_TOKEN_FACTORY_ADDRESSES,
850
1002
  POINT_TOKEN_IMPL_ADDRESSES,
@@ -889,7 +1041,9 @@ export {
889
1041
  checkEthAndBranch,
890
1042
  combineRoutes,
891
1043
  computeAccountId,
1044
+ computeAuthorizationHash,
892
1045
  computeCallDataHash,
1046
+ computeUserOpHash,
893
1047
  createLoginMessage,
894
1048
  createPafiProxyTransport,
895
1049
  encodeBatchExecute,
@@ -897,6 +1051,7 @@ export {
897
1051
  erc20ApproveOp,
898
1052
  erc20BurnOp,
899
1053
  erc20TransferOp,
1054
+ fetchPafiPools,
900
1055
  findBestQuote,
901
1056
  getAaNonce,
902
1057
  getContractAddresses,
@@ -911,6 +1066,7 @@ export {
911
1066
  getTokenName,
912
1067
  isActiveIssuer,
913
1068
  isDelegatedTo,
1069
+ isDelegatedToTarget,
914
1070
  isMinter,
915
1071
  isPaymasterConfigured,
916
1072
  isPaymasterError,