@pafi-dev/issuer 0.5.40 → 0.5.41

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.cjs CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  DefaultPolicyEngine: () => DefaultPolicyEngine,
30
30
  FeeManager: () => FeeManager,
31
31
  InMemoryCursorStore: () => InMemoryCursorStore,
32
+ IssuerApiAdapter: () => IssuerApiAdapter,
32
33
  IssuerApiHandlers: () => IssuerApiHandlers,
33
34
  IssuerStateError: () => IssuerStateError,
34
35
  IssuerStateValidator: () => IssuerStateValidator,
@@ -36,7 +37,7 @@ __export(index_exports, {
36
37
  MemorySessionStore: () => MemorySessionStore,
37
38
  NonceManager: () => NonceManager,
38
39
  PAFI_ISSUER_SDK_VERSION: () => PAFI_ISSUER_SDK_VERSION,
39
- PAFI_SUBGRAPH_URL: () => import_core14.PAFI_SUBGRAPH_URL,
40
+ PAFI_SUBGRAPH_URL: () => import_core15.PAFI_SUBGRAPH_URL,
40
41
  PTClaimError: () => PTClaimError,
41
42
  PTClaimHandler: () => PTClaimHandler,
42
43
  PTRedeemError: () => PTRedeemError,
@@ -2618,9 +2619,388 @@ function createSdkErrorMapper(factories) {
2618
2619
  };
2619
2620
  }
2620
2621
 
2621
- // src/pools/subgraphPoolsProvider.ts
2622
+ // src/api/issuerApiAdapter.ts
2622
2623
  var import_viem11 = require("viem");
2623
2624
  var import_core14 = require("@pafi-dev/core");
2625
+ var IssuerApiAdapter = class {
2626
+ cfg;
2627
+ constructor(config) {
2628
+ this.cfg = config;
2629
+ }
2630
+ // ------------------------------ Read endpoints ---------------------------
2631
+ async config(chainId) {
2632
+ const result = await this.cfg.issuerService.api.handleConfig(chainId);
2633
+ return {
2634
+ chainId: result.chainId,
2635
+ contracts: result.contracts
2636
+ };
2637
+ }
2638
+ async gasFee() {
2639
+ const result = await this.cfg.issuerService.api.handleGasFee();
2640
+ return { gasFeeUsdt: result.gasFeeUsdt.toString() };
2641
+ }
2642
+ async pools(authenticatedAddress, chainId, pointTokenAddress) {
2643
+ const result = await this.cfg.issuerService.api.handlePools(
2644
+ authenticatedAddress,
2645
+ { chainId, pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress) }
2646
+ );
2647
+ return { pools: result.pools };
2648
+ }
2649
+ async user(authenticatedAddress, chainId, userAddress, pointTokenAddress) {
2650
+ const result = await this.cfg.issuerService.api.handleUser(
2651
+ authenticatedAddress,
2652
+ {
2653
+ chainId,
2654
+ userAddress: (0, import_viem11.getAddress)(userAddress),
2655
+ pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress)
2656
+ }
2657
+ );
2658
+ return {
2659
+ mintRequestNonce: result.mintRequestNonce.toString(),
2660
+ receiverConsentNonce: result.receiverConsentNonce.toString(),
2661
+ offChainBalance: result.offChainBalance.toString(),
2662
+ onChainBalance: result.onChainBalance.toString(),
2663
+ totalBalance: result.totalBalance.toString(),
2664
+ balance: result.offChainBalance.toString(),
2665
+ isMinter: result.isMinter
2666
+ };
2667
+ }
2668
+ async quote(authenticatedAddress, chainId, pointTokenAddress, pointAmount) {
2669
+ const [gasFeeResult, poolsResult] = await Promise.all([
2670
+ this.cfg.issuerService.api.handleGasFee(),
2671
+ this.cfg.issuerService.api.handlePools(authenticatedAddress, {
2672
+ chainId,
2673
+ pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress)
2674
+ })
2675
+ ]);
2676
+ const quote = await quotePointTokenToUsdt({
2677
+ provider: this.cfg.provider,
2678
+ chainId,
2679
+ pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress),
2680
+ pointAmount,
2681
+ pools: poolsResult.pools,
2682
+ gasFeeUsdt: gasFeeResult.gasFeeUsdt
2683
+ });
2684
+ const dto = {
2685
+ pointAmount: pointAmount.toString(),
2686
+ estimatedUsdtOut: quote.estimatedUsdtOut.toString(),
2687
+ gasFeeUsdt: gasFeeResult.gasFeeUsdt.toString(),
2688
+ netUsdtOut: quote.netUsdtOut.toString(),
2689
+ exchangeRate: quote.exchangeRate,
2690
+ suggestedDeadline: quote.suggestedDeadline.toString(),
2691
+ gasEstimate: quote.gasEstimate.toString()
2692
+ };
2693
+ if (quote.quoteError) dto.quoteError = quote.quoteError;
2694
+ return dto;
2695
+ }
2696
+ // ------------------------------ Action endpoints -------------------------
2697
+ async claim(input) {
2698
+ const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
2699
+ const result = await this.cfg.ptClaimHandler.handle({
2700
+ authenticatedAddress: input.authenticatedAddress,
2701
+ userAddress: input.authenticatedAddress,
2702
+ amount: input.amount,
2703
+ pointTokenAddress,
2704
+ chainId: input.chainId,
2705
+ aaNonce: input.aaNonce,
2706
+ mintRequestNonce: input.mintRequestNonce
2707
+ });
2708
+ const sponsorAuth = await this.buildSponsorAuth(
2709
+ input.authenticatedAddress,
2710
+ result.userOp.callData,
2711
+ input.chainId,
2712
+ "mint"
2713
+ );
2714
+ return {
2715
+ calls: result.calls,
2716
+ callsFallback: result.callsFallback,
2717
+ feeAmount: result.feeAmount.toString(),
2718
+ lockId: result.lockId,
2719
+ signatureDeadline: result.signatureDeadline.toString(),
2720
+ sponsorAuth
2721
+ };
2722
+ }
2723
+ async redeem(input) {
2724
+ this.assertRedeemHandler();
2725
+ const response = await this.cfg.ptRedeemHandler.handle({
2726
+ userAddress: input.authenticatedAddress,
2727
+ authenticatedAddress: input.authenticatedAddress,
2728
+ amount: input.amount,
2729
+ aaNonce: input.aaNonce,
2730
+ chainId: input.chainId
2731
+ });
2732
+ const sponsorAuth = await this.buildSponsorAuth(
2733
+ input.authenticatedAddress,
2734
+ response.userOp.callData,
2735
+ input.chainId,
2736
+ "burn"
2737
+ );
2738
+ return {
2739
+ calls: (0, import_core14.decodeBatchExecuteCalls)(response.userOp.callData),
2740
+ callsFallback: response.fallback ? (0, import_core14.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
2741
+ feeAmount: response.feeAmount.toString(),
2742
+ lockId: response.lockId,
2743
+ lockIdFallback: response.fallback?.lockId,
2744
+ netCreditAmount: response.netCreditAmount.toString(),
2745
+ netCreditAmountFallback: response.fallback?.netCreditAmount.toString(),
2746
+ expiresInSeconds: response.expiresInSeconds,
2747
+ signatureDeadline: response.signatureDeadline.toString(),
2748
+ sponsorAuth
2749
+ };
2750
+ }
2751
+ async swap(input) {
2752
+ const result = await this.cfg.swapHandler.handle({
2753
+ userAddress: input.authenticatedAddress,
2754
+ chainId: input.chainId,
2755
+ pointTokenAddress: (0, import_viem11.getAddress)(input.pointTokenAddress),
2756
+ amountIn: input.amountIn,
2757
+ aaNonce: input.aaNonce,
2758
+ slippageBps: input.slippageBps
2759
+ });
2760
+ const sponsorAuth = await this.buildSponsorAuth(
2761
+ input.authenticatedAddress,
2762
+ result.userOp.callData,
2763
+ input.chainId,
2764
+ "swap"
2765
+ );
2766
+ return {
2767
+ calls: result.calls,
2768
+ callsFallback: result.callsFallback,
2769
+ feeAmount: result.feeAmount.toString(),
2770
+ estimatedUsdtOut: result.estimatedUsdtOut.toString(),
2771
+ minAmountOut: result.minAmountOut.toString(),
2772
+ estimatedUsdtOutFallback: result.estimatedUsdtOutFallback?.toString(),
2773
+ minAmountOutFallback: result.minAmountOutFallback?.toString(),
2774
+ deadline: result.deadline.toString(),
2775
+ sponsorAuth
2776
+ };
2777
+ }
2778
+ async perpDeposit(input) {
2779
+ const result = await this.cfg.perpHandler.handle({
2780
+ userAddress: input.authenticatedAddress,
2781
+ chainId: input.chainId,
2782
+ amount: input.amount,
2783
+ brokerId: input.brokerId,
2784
+ aaNonce: input.aaNonce
2785
+ });
2786
+ const sponsorAuth = await this.buildSponsorAuth(
2787
+ input.authenticatedAddress,
2788
+ result.userOp.callData,
2789
+ input.chainId,
2790
+ "perp-deposit"
2791
+ );
2792
+ return {
2793
+ calls: result.calls,
2794
+ callsFallback: result.callsFallback,
2795
+ relayTokenFee: result.relayTokenFee.toString(),
2796
+ maxFee: result.maxFee.toString(),
2797
+ netDeposit: result.netDeposit.toString(),
2798
+ ptGasFee: result.feeAmount.toString(),
2799
+ accountId: result.accountId,
2800
+ brokerHash: result.brokerHash,
2801
+ usdcAddress: result.usdcAddress,
2802
+ relayAddress: result.relayAddress,
2803
+ sponsorAuth
2804
+ };
2805
+ }
2806
+ // ------------------------------ Mobile endpoints -------------------------
2807
+ async claimPrepare(input) {
2808
+ const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
2809
+ const claimResult = await this.cfg.ptClaimHandler.handle({
2810
+ authenticatedAddress: input.authenticatedAddress,
2811
+ userAddress: input.authenticatedAddress,
2812
+ amount: input.amount,
2813
+ pointTokenAddress,
2814
+ chainId: input.chainId,
2815
+ aaNonce: input.aaNonce,
2816
+ mintRequestNonce: input.mintRequestNonce
2817
+ });
2818
+ const prepared = await this.runMobilePrepare(
2819
+ input.authenticatedAddress,
2820
+ input.chainId,
2821
+ claimResult.lockId,
2822
+ claimResult.userOp,
2823
+ claimResult.fallback,
2824
+ "mint",
2825
+ pointTokenAddress,
2826
+ claimResult.expiresInSeconds
2827
+ );
2828
+ return {
2829
+ lockId: claimResult.lockId,
2830
+ userOpHash: prepared.sponsored.userOpHash,
2831
+ typedData: prepared.sponsored.typedData,
2832
+ userOpHashFallback: prepared.fallback?.userOpHash,
2833
+ typedDataFallback: prepared.fallback?.typedData,
2834
+ feeAmount: claimResult.feeAmount.toString(),
2835
+ signatureDeadline: claimResult.signatureDeadline.toString(),
2836
+ expiresInSeconds: claimResult.expiresInSeconds,
2837
+ sponsored: prepared.isSponsored,
2838
+ needsDelegation: prepared.needsDelegation
2839
+ };
2840
+ }
2841
+ async claimSubmit(input) {
2842
+ return await handleMobileSubmit({
2843
+ lockId: input.lockId,
2844
+ authenticatedAddress: input.authenticatedAddress,
2845
+ signature: input.signature,
2846
+ variant: input.variant,
2847
+ store: this.cfg.pendingUserOpStore,
2848
+ bindUserOpHash: (lockId, hash) => this.cfg.ledger.bindMintUserOpHash(lockId, hash),
2849
+ pafiBackendClient: this.cfg.pafiBackendClient
2850
+ });
2851
+ }
2852
+ async redeemPrepare(input) {
2853
+ this.assertRedeemHandler();
2854
+ const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
2855
+ const redeemResponse = await this.cfg.ptRedeemHandler.handle({
2856
+ userAddress: input.authenticatedAddress,
2857
+ authenticatedAddress: input.authenticatedAddress,
2858
+ amount: input.amount,
2859
+ aaNonce: input.aaNonce,
2860
+ chainId: input.chainId
2861
+ });
2862
+ const prepared = await this.runMobilePrepare(
2863
+ input.authenticatedAddress,
2864
+ input.chainId,
2865
+ redeemResponse.lockId,
2866
+ redeemResponse.userOp,
2867
+ redeemResponse.fallback?.userOp,
2868
+ "burn",
2869
+ pointTokenAddress,
2870
+ redeemResponse.expiresInSeconds
2871
+ );
2872
+ return {
2873
+ lockId: redeemResponse.lockId,
2874
+ userOpHash: prepared.sponsored.userOpHash,
2875
+ typedData: prepared.sponsored.typedData,
2876
+ userOpHashFallback: prepared.fallback?.userOpHash,
2877
+ typedDataFallback: prepared.fallback?.typedData,
2878
+ netCreditAmount: redeemResponse.netCreditAmount.toString(),
2879
+ netCreditAmountFallback: redeemResponse.fallback?.netCreditAmount.toString(),
2880
+ feeAmount: redeemResponse.feeAmount.toString(),
2881
+ signatureDeadline: redeemResponse.signatureDeadline.toString(),
2882
+ expiresInSeconds: redeemResponse.expiresInSeconds,
2883
+ sponsored: prepared.isSponsored,
2884
+ needsDelegation: prepared.needsDelegation
2885
+ };
2886
+ }
2887
+ async redeemSubmit(input) {
2888
+ return await handleMobileSubmit({
2889
+ lockId: input.lockId,
2890
+ authenticatedAddress: input.authenticatedAddress,
2891
+ signature: input.signature,
2892
+ variant: input.variant,
2893
+ store: this.cfg.pendingUserOpStore,
2894
+ bindUserOpHash: (lockId, hash) => this.cfg.ledger.bindCreditUserOpHash(lockId, hash),
2895
+ pafiBackendClient: this.cfg.pafiBackendClient
2896
+ });
2897
+ }
2898
+ async claimStatus(authenticatedAddress, lockId) {
2899
+ return await handleClaimStatus({
2900
+ lockId,
2901
+ userAddress: authenticatedAddress,
2902
+ ledger: this.cfg.ledger,
2903
+ pafiBackendClient: this.cfg.pafiBackendClient,
2904
+ onWarning: this.cfg.onWarning
2905
+ });
2906
+ }
2907
+ async redeemStatus(authenticatedAddress, lockId) {
2908
+ return await handleRedeemStatus({
2909
+ lockId,
2910
+ userAddress: authenticatedAddress,
2911
+ ledger: this.cfg.ledger,
2912
+ pafiBackendClient: this.cfg.pafiBackendClient,
2913
+ onWarning: this.cfg.onWarning
2914
+ });
2915
+ }
2916
+ // ------------------------------ Delegate endpoints -----------------------
2917
+ async delegateStatus(authenticatedAddress, chainId) {
2918
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2919
+ const code = await this.cfg.provider.getCode({
2920
+ address: authenticatedAddress
2921
+ });
2922
+ return {
2923
+ isDelegated: (0, import_core14.parseEip7702DelegatedAddress)(code) !== null,
2924
+ batchExecutorAddress: batchExecutor
2925
+ };
2926
+ }
2927
+ async delegatePrepare(authenticatedAddress, chainId) {
2928
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2929
+ const accountNonce = BigInt(
2930
+ await this.cfg.provider.getTransactionCount({
2931
+ address: authenticatedAddress
2932
+ })
2933
+ );
2934
+ const authorizationHash = (0, import_core14.computeAuthorizationHash)(
2935
+ chainId,
2936
+ batchExecutor,
2937
+ accountNonce
2938
+ );
2939
+ return {
2940
+ authorizationHash,
2941
+ delegationNonce: accountNonce.toString(),
2942
+ batchExecutorAddress: batchExecutor,
2943
+ chainId
2944
+ };
2945
+ }
2946
+ async delegateSubmit(input) {
2947
+ const fees = await this.cfg.provider.estimateFeesPerGas();
2948
+ const result = await handleDelegateSubmit({
2949
+ userAddress: input.authenticatedAddress,
2950
+ chainId: input.chainId,
2951
+ delegationNonce: input.delegationNonce,
2952
+ aaNonce: input.aaNonce,
2953
+ authSig: input.authSig,
2954
+ fees,
2955
+ pafiBackendClient: this.cfg.pafiBackendClient,
2956
+ onWarning: this.cfg.onWarning
2957
+ });
2958
+ return { userOpHash: result.userOpHash };
2959
+ }
2960
+ // ------------------------------ Internal helpers -------------------------
2961
+ /**
2962
+ * Build + sign a SponsorAuth payload. Returns `undefined` when no
2963
+ * issuer id is configured, so the controller can skip the field.
2964
+ */
2965
+ async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
2966
+ if (!this.cfg.pafiIssuerId) return void 0;
2967
+ return (0, import_core14.buildAndSignSponsorAuth)({
2968
+ userAddress: authenticatedAddress,
2969
+ callData,
2970
+ chainId,
2971
+ scenario,
2972
+ issuerId: this.cfg.pafiIssuerId,
2973
+ issuerSignerWallet: this.cfg.issuerSignerWallet
2974
+ });
2975
+ }
2976
+ async runMobilePrepare(authenticatedAddress, chainId, lockId, partialUserOp, partialUserOpFallback, scenario, pointTokenAddress, ttlSeconds) {
2977
+ return await handleMobilePrepare({
2978
+ userAddress: authenticatedAddress,
2979
+ chainId,
2980
+ lockId,
2981
+ partialUserOp,
2982
+ partialUserOpFallback,
2983
+ scenario,
2984
+ pointTokenAddress,
2985
+ ttlSeconds,
2986
+ store: this.cfg.pendingUserOpStore,
2987
+ provider: this.cfg.provider,
2988
+ pafiBackendClient: this.cfg.pafiBackendClient,
2989
+ onWarning: this.cfg.onWarning
2990
+ });
2991
+ }
2992
+ assertRedeemHandler() {
2993
+ if (!this.cfg.ptRedeemHandler) {
2994
+ throw new Error(
2995
+ "PTRedeemHandler not wired \u2014 IssuerApiAdapter.redeem* require a configured ptRedeemHandler."
2996
+ );
2997
+ }
2998
+ }
2999
+ };
3000
+
3001
+ // src/pools/subgraphPoolsProvider.ts
3002
+ var import_viem12 = require("viem");
3003
+ var import_core15 = require("@pafi-dev/core");
2624
3004
  var DEFAULT_CACHE_TTL_MS = 3e4;
2625
3005
  var POOL_QUERY = `
2626
3006
  query GetPoolForPointToken($id: ID!) {
@@ -2638,7 +3018,7 @@ var POOL_QUERY = `
2638
3018
  }
2639
3019
  `;
2640
3020
  function createSubgraphPoolsProvider(config = {}) {
2641
- const subgraphUrl = config.subgraphUrl ?? import_core14.PAFI_SUBGRAPH_URL;
3021
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2642
3022
  try {
2643
3023
  const parsed = new URL(subgraphUrl);
2644
3024
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -2720,7 +3100,7 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress)
2720
3100
  return [];
2721
3101
  }
2722
3102
  const { pool } = token;
2723
- if (!(0, import_viem11.isAddress)(pool.hooks)) {
3103
+ if (!(0, import_viem12.isAddress)(pool.hooks)) {
2724
3104
  console.error(
2725
3105
  "[PAFI] SubgraphPoolsProvider: invalid hooks address in response:",
2726
3106
  pool.hooks,
@@ -2728,7 +3108,7 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress)
2728
3108
  );
2729
3109
  return [];
2730
3110
  }
2731
- if (!(0, import_viem11.isAddress)(pool.token0.id) || !(0, import_viem11.isAddress)(pool.token1.id)) {
3111
+ if (!(0, import_viem12.isAddress)(pool.token0.id) || !(0, import_viem12.isAddress)(pool.token1.id)) {
2732
3112
  console.error(
2733
3113
  "[PAFI] SubgraphPoolsProvider: invalid token address in response \u2014 skipping pool"
2734
3114
  );
@@ -2770,7 +3150,7 @@ var PRICE_QUERY = `
2770
3150
  }
2771
3151
  `;
2772
3152
  function createSubgraphNativeUsdtQuoter(config = {}) {
2773
- const subgraphUrl = config.subgraphUrl ?? import_core14.PAFI_SUBGRAPH_URL;
3153
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2774
3154
  try {
2775
3155
  const parsed = new URL(subgraphUrl);
2776
3156
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -2878,8 +3258,8 @@ function toUsdtPerNative(priceFloat, usdtDecimals) {
2878
3258
  }
2879
3259
 
2880
3260
  // src/pools/nativePtQuoter.ts
2881
- var import_viem12 = require("viem");
2882
- var CHAINLINK_ABI = (0, import_viem12.parseAbi)([
3261
+ var import_viem13 = require("viem");
3262
+ var CHAINLINK_ABI = (0, import_viem13.parseAbi)([
2883
3263
  "function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"
2884
3264
  ]);
2885
3265
  var CHAINLINK_MAX_AGE_S = 3600n;
@@ -2900,7 +3280,7 @@ function createNativePtQuoter(config) {
2900
3280
  provider,
2901
3281
  pointTokenAddress,
2902
3282
  chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
2903
- subgraphUrl = import_core14.PAFI_SUBGRAPH_URL,
3283
+ subgraphUrl = import_core15.PAFI_SUBGRAPH_URL,
2904
3284
  cacheTtlMs = 3e4,
2905
3285
  fallbackEthPriceUsd = 3e3,
2906
3286
  fallbackPtPriceUsdt = 0.1,
@@ -2982,7 +3362,7 @@ function parseBigDecimalTo18(s) {
2982
3362
  }
2983
3363
 
2984
3364
  // src/balance/balanceAggregator.ts
2985
- var import_core15 = require("@pafi-dev/core");
3365
+ var import_core16 = require("@pafi-dev/core");
2986
3366
  var BalanceAggregator = class {
2987
3367
  provider;
2988
3368
  ledger;
@@ -3003,7 +3383,7 @@ var BalanceAggregator = class {
3003
3383
  async getCombinedBalance(user, pointToken) {
3004
3384
  const [offChain, onChain] = await Promise.all([
3005
3385
  this.ledger.getBalance(user, pointToken),
3006
- (0, import_core15.getPointTokenBalance)(this.provider, pointToken, user)
3386
+ (0, import_core16.getPointTokenBalance)(this.provider, pointToken, user)
3007
3387
  ]);
3008
3388
  return {
3009
3389
  offChain,
@@ -3236,8 +3616,8 @@ var PafiBackendClient = class {
3236
3616
  };
3237
3617
 
3238
3618
  // src/config.ts
3239
- var import_viem13 = require("viem");
3240
- var import_core16 = require("@pafi-dev/core");
3619
+ var import_viem14 = require("viem");
3620
+ var import_core17 = require("@pafi-dev/core");
3241
3621
  function createIssuerService(config) {
3242
3622
  if (!config.provider) {
3243
3623
  throw new Error("createIssuerService: provider is required");
@@ -3257,7 +3637,7 @@ function createIssuerService(config) {
3257
3637
  "createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required"
3258
3638
  );
3259
3639
  }
3260
- const tokenAddresses = rawAddresses.map((a) => (0, import_viem13.getAddress)(a));
3640
+ const tokenAddresses = rawAddresses.map((a) => (0, import_viem14.getAddress)(a));
3261
3641
  const ledger = config.ledger;
3262
3642
  const sessionStore = config.sessionStore ?? new MemorySessionStore();
3263
3643
  const policy = config.policy ?? new DefaultPolicyEngine({ ledger });
@@ -3307,7 +3687,7 @@ function createIssuerService(config) {
3307
3687
  indexers.set(tokenAddress, new PointIndexer(indexerConfig));
3308
3688
  }
3309
3689
  const firstIndexer = indexers.get(tokenAddresses[0]);
3310
- const chainAddresses = (0, import_core16.getContractAddresses)(config.chainId);
3690
+ const chainAddresses = (0, import_core17.getContractAddresses)(config.chainId);
3311
3691
  const resolvedContracts = {
3312
3692
  batchExecutor: chainAddresses.batchExecutor,
3313
3693
  usdt: chainAddresses.usdt,
@@ -3355,8 +3735,8 @@ function createIssuerService(config) {
3355
3735
  }
3356
3736
 
3357
3737
  // src/issuer-state/validator.ts
3358
- var import_viem14 = require("viem");
3359
- var import_core17 = require("@pafi-dev/core");
3738
+ var import_viem15 = require("viem");
3739
+ var import_core18 = require("@pafi-dev/core");
3360
3740
  var ISSUER_RECORD_TTL_MS = 3e4;
3361
3741
  var IssuerStateValidator = class _IssuerStateValidator {
3362
3742
  constructor(provider, registryAddress) {
@@ -3373,7 +3753,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3373
3753
  * `CONTRACT_ADDRESSES` map for the given chain.
3374
3754
  */
3375
3755
  static forChain(provider, chainId) {
3376
- const { issuerRegistry } = (0, import_core17.getContractAddresses)(chainId);
3756
+ const { issuerRegistry } = (0, import_core18.getContractAddresses)(chainId);
3377
3757
  return new _IssuerStateValidator(provider, issuerRegistry);
3378
3758
  }
3379
3759
  /**
@@ -3382,7 +3762,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3382
3762
  */
3383
3763
  invalidate(pointToken) {
3384
3764
  if (pointToken) {
3385
- const key = (0, import_viem14.getAddress)(pointToken);
3765
+ const key = (0, import_viem15.getAddress)(pointToken);
3386
3766
  this.pointTokenIssuerCache.delete(key);
3387
3767
  this.stateCache.delete(key);
3388
3768
  this.inflight.delete(key);
@@ -3397,23 +3777,23 @@ var IssuerStateValidator = class _IssuerStateValidator {
3397
3777
  * The issuer field is set at `initialize()` and never changes.
3398
3778
  */
3399
3779
  async getIssuerAddressForPointToken(pointToken) {
3400
- const key = (0, import_viem14.getAddress)(pointToken);
3780
+ const key = (0, import_viem15.getAddress)(pointToken);
3401
3781
  const cached = this.pointTokenIssuerCache.get(key);
3402
3782
  if (cached) return cached;
3403
3783
  const issuer = await this.provider.readContract({
3404
3784
  address: key,
3405
- abi: import_core17.POINT_TOKEN_V2_ABI,
3785
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3406
3786
  functionName: "issuer"
3407
3787
  });
3408
- this.pointTokenIssuerCache.set(key, (0, import_viem14.getAddress)(issuer));
3409
- return (0, import_viem14.getAddress)(issuer);
3788
+ this.pointTokenIssuerCache.set(key, (0, import_viem15.getAddress)(issuer));
3789
+ return (0, import_viem15.getAddress)(issuer);
3410
3790
  }
3411
3791
  /**
3412
3792
  * Read registry record + totalSupply, with 30s cache and in-flight
3413
3793
  * deduplication. Does NOT throw on inactive/missing — returns raw state.
3414
3794
  */
3415
3795
  async getIssuerState(pointToken) {
3416
- const tokenAddr = (0, import_viem14.getAddress)(pointToken);
3796
+ const tokenAddr = (0, import_viem15.getAddress)(pointToken);
3417
3797
  const now = Date.now();
3418
3798
  const cached = this.stateCache.get(tokenAddr);
3419
3799
  if (cached && cached.expiresAt > now) return cached.value;
@@ -3483,13 +3863,13 @@ var IssuerStateValidator = class _IssuerStateValidator {
3483
3863
  const [issuerTuple, totalSupply] = await Promise.all([
3484
3864
  this.provider.readContract({
3485
3865
  address: this.registryAddress,
3486
- abi: import_core17.issuerRegistryGetIssuerFlatAbi,
3866
+ abi: import_core18.issuerRegistryGetIssuerFlatAbi,
3487
3867
  functionName: "getIssuer",
3488
3868
  args: [issuerAddr]
3489
3869
  }),
3490
3870
  this.provider.readContract({
3491
3871
  address: tokenAddr,
3492
- abi: import_core17.POINT_TOKEN_V2_ABI,
3872
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3493
3873
  functionName: "totalSupply"
3494
3874
  })
3495
3875
  ]);
@@ -3523,6 +3903,7 @@ var PAFI_ISSUER_SDK_VERSION = "0.4.0";
3523
3903
  DefaultPolicyEngine,
3524
3904
  FeeManager,
3525
3905
  InMemoryCursorStore,
3906
+ IssuerApiAdapter,
3526
3907
  IssuerApiHandlers,
3527
3908
  IssuerStateError,
3528
3909
  IssuerStateValidator,