@pafi-dev/issuer 0.5.33 → 0.5.34

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
@@ -1,5 +1,5 @@
1
1
  import { Address, Hex, PublicClient, WalletClient } from 'viem';
2
- import { PointTokenDomainConfig, PartialUserOperation, BurnRequest, PoolKey, UserOpTypedData } from '@pafi-dev/core';
2
+ import { PointTokenDomainConfig, PartialUserOperation, BurnRequest, PoolKey, ENTRY_POINT_V08, UserOpTypedData } from '@pafi-dev/core';
3
3
  export { PAFI_SUBGRAPH_URL } from '@pafi-dev/core';
4
4
 
5
5
  /**
@@ -1744,6 +1744,98 @@ declare class BalanceAggregator {
1744
1744
  getCombinedBalanceMulti(user: Address, pointTokens: Address[]): Promise<Map<Address, CombinedBalance>>;
1745
1745
  }
1746
1746
 
1747
+ /**
1748
+ * Typed errors thrown by the helpers below — issuer controllers map
1749
+ * these to the appropriate HTTP status. We don't depend on @nestjs/common
1750
+ * here because the SDK is framework-agnostic; the consuming controller
1751
+ * wraps each one in its preferred exception class.
1752
+ */
1753
+ declare class BundlerNotConfiguredError extends Error {
1754
+ readonly code = "BUNDLER_NOT_CONFIGURED";
1755
+ constructor();
1756
+ }
1757
+ declare class BundlerRejectedError extends Error {
1758
+ readonly code = "BUNDLER_REJECTED";
1759
+ readonly cause: unknown;
1760
+ constructor(message: string, cause: unknown);
1761
+ }
1762
+ interface RequestPaymasterParams {
1763
+ /** PAFI backend client. When `null` / `undefined` → returns `undefined`. */
1764
+ client: PafiBackendClient | null | undefined;
1765
+ chainId: number;
1766
+ scenario: string;
1767
+ /** UserOp skeleton — must have all gas + fee fields set. */
1768
+ userOp: {
1769
+ sender: Address;
1770
+ nonce: bigint;
1771
+ callData: Hex;
1772
+ callGasLimit: bigint;
1773
+ verificationGasLimit: bigint;
1774
+ preVerificationGas: bigint;
1775
+ maxFeePerGas: bigint;
1776
+ maxPriorityFeePerGas: bigint;
1777
+ };
1778
+ /** Target contract (typically the PointToken). */
1779
+ pointTokenAddress: Address;
1780
+ /**
1781
+ * Function name to surface in audit / paymaster context. Defaults to
1782
+ * a per-scenario sensible value (`mint` / `burn` / `swap` / generic
1783
+ * scenario name).
1784
+ */
1785
+ functionName?: string;
1786
+ /** Optional logger for the "sponsorship declined" warning. */
1787
+ onWarning?: (msg: string) => void;
1788
+ }
1789
+ /**
1790
+ * Thin wrapper around `PafiBackendClient.requestSponsorship` with the
1791
+ * "non-fatal on failure" semantics every issuer wants:
1792
+ *
1793
+ * - When the client is missing → returns `undefined` (the caller falls
1794
+ * back to a self-funded UserOp).
1795
+ * - When the network call throws OR PAFI declines (rate limit, intent
1796
+ * rejection, paymaster outage) → returns `undefined` after logging,
1797
+ * so the controller doesn't hard-fail. The caller's
1798
+ * `prepareMobileUserOp` / `mergePaymasterFields` will gracefully
1799
+ * produce the unsponsored variant.
1800
+ *
1801
+ * Replaces ~30 LoC of try/catch + scenario-to-function mapping every
1802
+ * issuer would copy.
1803
+ */
1804
+ declare function requestPaymaster(params: RequestPaymasterParams): Promise<Awaited<ReturnType<PafiBackendClient["requestSponsorship"]>> | undefined>;
1805
+ interface RelayUserOpParams {
1806
+ client: PafiBackendClient | null | undefined;
1807
+ /** EntryPoint address — typically `ENTRY_POINT_V08` from core. */
1808
+ entryPoint: typeof ENTRY_POINT_V08 | string;
1809
+ userOp: Record<string, string | null>;
1810
+ /** EIP-7702 authorization (delegation UserOps only). */
1811
+ eip7702Auth?: {
1812
+ chainId: string;
1813
+ address: string;
1814
+ nonce: string;
1815
+ r: string;
1816
+ s: string;
1817
+ yParity: string;
1818
+ };
1819
+ }
1820
+ /**
1821
+ * Submit a serialized UserOp to the Pimlico bundler via PAFI's
1822
+ * sponsor-relayer. Handles the "client missing" / "bundler rejected"
1823
+ * branches as typed errors so the controller can map to HTTP cleanly.
1824
+ *
1825
+ * Every issuer mobile flow has this exact wrapper — moved into SDK
1826
+ * to drop ~30 LoC of try/catch + error-shape boilerplate per
1827
+ * controller.
1828
+ *
1829
+ * Throws:
1830
+ * - `BundlerNotConfiguredError` — caller didn't configure
1831
+ * `PafiBackendClient`. Map to 503.
1832
+ * - `BundlerRejectedError` — bundler returned an error. Map to 422
1833
+ * (the FE can show the reason — usually `AA21` / `AA34` / etc.).
1834
+ */
1835
+ declare function relayUserOp(params: RelayUserOpParams): Promise<{
1836
+ userOpHash: Hex;
1837
+ }>;
1838
+
1747
1839
  /**
1748
1840
  * Top-level configuration for `createIssuerService`.
1749
1841
  *
@@ -2177,4 +2269,4 @@ declare class IssuerStateValidator {
2177
2269
  /** SDK package version — bumped on every release */
2178
2270
  declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
2179
2271
 
2180
- export { type ApiClaimRequest, type ApiClaimResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiRedeemRequest, type ApiRedeemResponse, type ApiTopUpRequest, type ApiTopUpResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type BurnStatusParams, type BurnStatusResponse, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerRegistryRecord, type IssuerService, type IssuerServiceConfig, IssuerStateError, IssuerStateValidator, LockNotFoundError, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintStatusParams, type MintStatusResponse, type MintingStatus, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, type PendingCredit, type PendingUserOpEntry, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsProvider, type PreValidateMintResult, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, RelayError, type RelayErrorCode, RelayService, type RelayUserOpRequest, type RelayUserOpResponse, type RetryConfig, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createNativePtQuoter, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, serializeEntryToJsonRpc, serializeUserOpTypedData };
2272
+ export { type ApiClaimRequest, type ApiClaimResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiRedeemRequest, type ApiRedeemResponse, type ApiTopUpRequest, type ApiTopUpResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, BundlerNotConfiguredError, BundlerRejectedError, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type BurnStatusParams, type BurnStatusResponse, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerRegistryRecord, type IssuerService, type IssuerServiceConfig, IssuerStateError, IssuerStateValidator, LockNotFoundError, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintStatusParams, type MintStatusResponse, type MintingStatus, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, type PendingCredit, type PendingUserOpEntry, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsProvider, type PreValidateMintResult, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, RelayError, type RelayErrorCode, RelayService, type RelayUserOpParams, type RelayUserOpRequest, type RelayUserOpResponse, type RequestPaymasterParams, type RetryConfig, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createNativePtQuoter, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, relayUserOp, requestPaymaster, serializeEntryToJsonRpc, serializeUserOpTypedData };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Address, Hex, PublicClient, WalletClient } from 'viem';
2
- import { PointTokenDomainConfig, PartialUserOperation, BurnRequest, PoolKey, UserOpTypedData } from '@pafi-dev/core';
2
+ import { PointTokenDomainConfig, PartialUserOperation, BurnRequest, PoolKey, ENTRY_POINT_V08, UserOpTypedData } from '@pafi-dev/core';
3
3
  export { PAFI_SUBGRAPH_URL } from '@pafi-dev/core';
4
4
 
5
5
  /**
@@ -1744,6 +1744,98 @@ declare class BalanceAggregator {
1744
1744
  getCombinedBalanceMulti(user: Address, pointTokens: Address[]): Promise<Map<Address, CombinedBalance>>;
1745
1745
  }
1746
1746
 
1747
+ /**
1748
+ * Typed errors thrown by the helpers below — issuer controllers map
1749
+ * these to the appropriate HTTP status. We don't depend on @nestjs/common
1750
+ * here because the SDK is framework-agnostic; the consuming controller
1751
+ * wraps each one in its preferred exception class.
1752
+ */
1753
+ declare class BundlerNotConfiguredError extends Error {
1754
+ readonly code = "BUNDLER_NOT_CONFIGURED";
1755
+ constructor();
1756
+ }
1757
+ declare class BundlerRejectedError extends Error {
1758
+ readonly code = "BUNDLER_REJECTED";
1759
+ readonly cause: unknown;
1760
+ constructor(message: string, cause: unknown);
1761
+ }
1762
+ interface RequestPaymasterParams {
1763
+ /** PAFI backend client. When `null` / `undefined` → returns `undefined`. */
1764
+ client: PafiBackendClient | null | undefined;
1765
+ chainId: number;
1766
+ scenario: string;
1767
+ /** UserOp skeleton — must have all gas + fee fields set. */
1768
+ userOp: {
1769
+ sender: Address;
1770
+ nonce: bigint;
1771
+ callData: Hex;
1772
+ callGasLimit: bigint;
1773
+ verificationGasLimit: bigint;
1774
+ preVerificationGas: bigint;
1775
+ maxFeePerGas: bigint;
1776
+ maxPriorityFeePerGas: bigint;
1777
+ };
1778
+ /** Target contract (typically the PointToken). */
1779
+ pointTokenAddress: Address;
1780
+ /**
1781
+ * Function name to surface in audit / paymaster context. Defaults to
1782
+ * a per-scenario sensible value (`mint` / `burn` / `swap` / generic
1783
+ * scenario name).
1784
+ */
1785
+ functionName?: string;
1786
+ /** Optional logger for the "sponsorship declined" warning. */
1787
+ onWarning?: (msg: string) => void;
1788
+ }
1789
+ /**
1790
+ * Thin wrapper around `PafiBackendClient.requestSponsorship` with the
1791
+ * "non-fatal on failure" semantics every issuer wants:
1792
+ *
1793
+ * - When the client is missing → returns `undefined` (the caller falls
1794
+ * back to a self-funded UserOp).
1795
+ * - When the network call throws OR PAFI declines (rate limit, intent
1796
+ * rejection, paymaster outage) → returns `undefined` after logging,
1797
+ * so the controller doesn't hard-fail. The caller's
1798
+ * `prepareMobileUserOp` / `mergePaymasterFields` will gracefully
1799
+ * produce the unsponsored variant.
1800
+ *
1801
+ * Replaces ~30 LoC of try/catch + scenario-to-function mapping every
1802
+ * issuer would copy.
1803
+ */
1804
+ declare function requestPaymaster(params: RequestPaymasterParams): Promise<Awaited<ReturnType<PafiBackendClient["requestSponsorship"]>> | undefined>;
1805
+ interface RelayUserOpParams {
1806
+ client: PafiBackendClient | null | undefined;
1807
+ /** EntryPoint address — typically `ENTRY_POINT_V08` from core. */
1808
+ entryPoint: typeof ENTRY_POINT_V08 | string;
1809
+ userOp: Record<string, string | null>;
1810
+ /** EIP-7702 authorization (delegation UserOps only). */
1811
+ eip7702Auth?: {
1812
+ chainId: string;
1813
+ address: string;
1814
+ nonce: string;
1815
+ r: string;
1816
+ s: string;
1817
+ yParity: string;
1818
+ };
1819
+ }
1820
+ /**
1821
+ * Submit a serialized UserOp to the Pimlico bundler via PAFI's
1822
+ * sponsor-relayer. Handles the "client missing" / "bundler rejected"
1823
+ * branches as typed errors so the controller can map to HTTP cleanly.
1824
+ *
1825
+ * Every issuer mobile flow has this exact wrapper — moved into SDK
1826
+ * to drop ~30 LoC of try/catch + error-shape boilerplate per
1827
+ * controller.
1828
+ *
1829
+ * Throws:
1830
+ * - `BundlerNotConfiguredError` — caller didn't configure
1831
+ * `PafiBackendClient`. Map to 503.
1832
+ * - `BundlerRejectedError` — bundler returned an error. Map to 422
1833
+ * (the FE can show the reason — usually `AA21` / `AA34` / etc.).
1834
+ */
1835
+ declare function relayUserOp(params: RelayUserOpParams): Promise<{
1836
+ userOpHash: Hex;
1837
+ }>;
1838
+
1747
1839
  /**
1748
1840
  * Top-level configuration for `createIssuerService`.
1749
1841
  *
@@ -2177,4 +2269,4 @@ declare class IssuerStateValidator {
2177
2269
  /** SDK package version — bumped on every release */
2178
2270
  declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
2179
2271
 
2180
- export { type ApiClaimRequest, type ApiClaimResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiRedeemRequest, type ApiRedeemResponse, type ApiTopUpRequest, type ApiTopUpResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type BurnStatusParams, type BurnStatusResponse, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerRegistryRecord, type IssuerService, type IssuerServiceConfig, IssuerStateError, IssuerStateValidator, LockNotFoundError, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintStatusParams, type MintStatusResponse, type MintingStatus, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, type PendingCredit, type PendingUserOpEntry, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsProvider, type PreValidateMintResult, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, RelayError, type RelayErrorCode, RelayService, type RelayUserOpRequest, type RelayUserOpResponse, type RetryConfig, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createNativePtQuoter, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, serializeEntryToJsonRpc, serializeUserOpTypedData };
2272
+ export { type ApiClaimRequest, type ApiClaimResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiRedeemRequest, type ApiRedeemResponse, type ApiTopUpRequest, type ApiTopUpResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, BundlerNotConfiguredError, BundlerRejectedError, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type BurnStatusParams, type BurnStatusResponse, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerRegistryRecord, type IssuerService, type IssuerServiceConfig, IssuerStateError, IssuerStateValidator, LockNotFoundError, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintStatusParams, type MintStatusResponse, type MintingStatus, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, type PendingCredit, type PendingUserOpEntry, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsProvider, type PreValidateMintResult, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, RelayError, type RelayErrorCode, RelayService, type RelayUserOpParams, type RelayUserOpRequest, type RelayUserOpResponse, type RequestPaymasterParams, type RetryConfig, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createNativePtQuoter, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, relayUserOp, requestPaymaster, serializeEntryToJsonRpc, serializeUserOpTypedData };
package/dist/index.js CHANGED
@@ -2315,6 +2315,76 @@ var PafiBackendClient = class {
2315
2315
  }
2316
2316
  };
2317
2317
 
2318
+ // src/pafi-backend/helpers.ts
2319
+ var BundlerNotConfiguredError = class extends Error {
2320
+ code = "BUNDLER_NOT_CONFIGURED";
2321
+ constructor() {
2322
+ super(
2323
+ "PAFI backend client not configured \u2014 set PAFI_BACKEND_URL, PAFI_ISSUER_ID, PAFI_API_KEY to enable mobile submit."
2324
+ );
2325
+ this.name = "BundlerNotConfiguredError";
2326
+ }
2327
+ };
2328
+ var BundlerRejectedError = class extends Error {
2329
+ code = "BUNDLER_REJECTED";
2330
+ cause;
2331
+ constructor(message, cause) {
2332
+ super(message);
2333
+ this.name = "BundlerRejectedError";
2334
+ this.cause = cause;
2335
+ }
2336
+ };
2337
+ async function requestPaymaster(params) {
2338
+ if (!params.client) return void 0;
2339
+ const fn = params.functionName ?? defaultFunctionForScenario(params.scenario);
2340
+ try {
2341
+ return await params.client.requestSponsorship({
2342
+ chainId: params.chainId,
2343
+ scenario: params.scenario,
2344
+ userOp: params.userOp,
2345
+ target: {
2346
+ contract: params.pointTokenAddress,
2347
+ function: fn,
2348
+ pointToken: params.pointTokenAddress
2349
+ }
2350
+ });
2351
+ } catch (err) {
2352
+ const msg = err instanceof Error ? err.message : String(err);
2353
+ params.onWarning?.(`Paymaster sponsorship declined: ${msg}`);
2354
+ return void 0;
2355
+ }
2356
+ }
2357
+ function defaultFunctionForScenario(scenario) {
2358
+ switch (scenario) {
2359
+ case "mint":
2360
+ return "mint";
2361
+ case "burn":
2362
+ return "burn";
2363
+ case "swap":
2364
+ return "swap";
2365
+ case "perp-deposit":
2366
+ return "deposit";
2367
+ default:
2368
+ return scenario;
2369
+ }
2370
+ }
2371
+ async function relayUserOp(params) {
2372
+ if (!params.client) {
2373
+ throw new BundlerNotConfiguredError();
2374
+ }
2375
+ try {
2376
+ const result = await params.client.relayUserOperation({
2377
+ userOp: params.userOp,
2378
+ entryPoint: params.entryPoint,
2379
+ eip7702Auth: params.eip7702Auth
2380
+ });
2381
+ return { userOpHash: result.userOpHash };
2382
+ } catch (err) {
2383
+ const msg = err instanceof Error ? err.message : String(err);
2384
+ throw new BundlerRejectedError(msg, err);
2385
+ }
2386
+ }
2387
+
2318
2388
  // src/config.ts
2319
2389
  import { getAddress as getAddress8 } from "viem";
2320
2390
  import { getContractAddresses as getContractAddresses2 } from "@pafi-dev/core";
@@ -2750,6 +2820,8 @@ export {
2750
2820
  AuthError,
2751
2821
  AuthService,
2752
2822
  BalanceAggregator,
2823
+ BundlerNotConfiguredError,
2824
+ BundlerRejectedError,
2753
2825
  BurnIndexer,
2754
2826
  DefaultPolicyEngine,
2755
2827
  FeeManager,
@@ -2780,6 +2852,8 @@ export {
2780
2852
  handleRedeemStatus,
2781
2853
  mergePaymasterFields,
2782
2854
  prepareMobileUserOp,
2855
+ relayUserOp,
2856
+ requestPaymaster,
2783
2857
  serializeEntryToJsonRpc,
2784
2858
  serializeUserOpTypedData
2785
2859
  };