@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 +407 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +361 -124
- package/dist/index.d.ts +361 -124
- package/dist/index.js +400 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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, decodeBatchExecuteCalls, BROKER_HASHES, Eip7702AuthorizationJsonRpc, ENTRY_POINT_V08 } from '@pafi-dev/core';
|
|
2
|
+
import { PointTokenDomainConfig, PartialUserOperation, BurnRequest, PoolKey, UserOpTypedData, decodeBatchExecuteCalls, BROKER_HASHES, Eip7702AuthorizationJsonRpc, BuiltSponsorAuth, ENTRY_POINT_V08 } from '@pafi-dev/core';
|
|
3
3
|
export { PAFI_SUBGRAPH_URL } from '@pafi-dev/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -2304,6 +2304,365 @@ interface SdkErrorMapperFactories {
|
|
|
2304
2304
|
*/
|
|
2305
2305
|
declare function createSdkErrorMapper(factories: SdkErrorMapperFactories): (err: unknown) => never;
|
|
2306
2306
|
|
|
2307
|
+
/**
|
|
2308
|
+
* Top-level configuration for `createIssuerService`.
|
|
2309
|
+
*
|
|
2310
|
+
* In v1.4 the SDK is HTTP-client-free: it signs EIP-712 messages, reads
|
|
2311
|
+
* on-chain state, builds unsigned UserOperations, and maintains the
|
|
2312
|
+
* off-chain ledger. It never broadcasts transactions — that's the
|
|
2313
|
+
* frontend's responsibility via Bundler + Paymaster.
|
|
2314
|
+
*
|
|
2315
|
+
* **Multi-token (0.2.0+):** Pass `pointTokenAddresses: Address[]` to
|
|
2316
|
+
* support multiple PointTokens under a single issuer backend. Legacy
|
|
2317
|
+
* `pointTokenAddress: Address` still works for single-token deployments.
|
|
2318
|
+
* When both are provided, `pointTokenAddresses` takes precedence.
|
|
2319
|
+
*/
|
|
2320
|
+
interface IssuerServiceConfig {
|
|
2321
|
+
chainId: number;
|
|
2322
|
+
/** Legacy single-token shortcut; prefer `pointTokenAddresses`. */
|
|
2323
|
+
pointTokenAddress?: Address;
|
|
2324
|
+
/** All PointToken addresses this issuer supports. */
|
|
2325
|
+
pointTokenAddresses?: Address[];
|
|
2326
|
+
/**
|
|
2327
|
+
* Issuer-specific contract addresses merged into the `/config` response.
|
|
2328
|
+
* PAFI-owned addresses (batchExecutor, usdt, issuerRegistry, mintingOracle,
|
|
2329
|
+
* pafiHook) are auto-resolved from `getContractAddresses(chainId)` and
|
|
2330
|
+
* can be omitted. Only `pointToken` / `pointTokens` must be provided.
|
|
2331
|
+
*/
|
|
2332
|
+
contracts?: Pick<ApiConfigResponse["contracts"], "pointToken" | "pointTokens" | "relay">;
|
|
2333
|
+
/**
|
|
2334
|
+
* Shared `PublicClient` used for on-chain reads, simulation, indexer
|
|
2335
|
+
* polling, and gas-price lookups. Must be pointed at the target chain.
|
|
2336
|
+
*/
|
|
2337
|
+
provider: PublicClient;
|
|
2338
|
+
auth: {
|
|
2339
|
+
jwtSecret: string;
|
|
2340
|
+
/** SIWE-style login-message domain, e.g. `"app.example.com"`. */
|
|
2341
|
+
domain: string;
|
|
2342
|
+
/** Passed straight to `jose` (`"24h"`, `"7d"`, …). Default `"24h"`. */
|
|
2343
|
+
jwtExpiresIn?: string;
|
|
2344
|
+
};
|
|
2345
|
+
/**
|
|
2346
|
+
* Off-chain point ledger — the source of truth for user balances and
|
|
2347
|
+
* in-flight minting locks. Every issuer provides their own database-backed
|
|
2348
|
+
* implementation (Postgres, Redis, etc.) that implements `IPointLedger`.
|
|
2349
|
+
* The SDK does not ship a production ledger; each issuer's data model and
|
|
2350
|
+
* infrastructure are different.
|
|
2351
|
+
*/
|
|
2352
|
+
ledger: IPointLedger;
|
|
2353
|
+
/**
|
|
2354
|
+
* Policy engine — optional, defaults to `DefaultPolicyEngine` which checks
|
|
2355
|
+
* off-chain balance. Extend or replace to add KYC, volume caps, etc.
|
|
2356
|
+
*/
|
|
2357
|
+
policy?: IPolicyEngine;
|
|
2358
|
+
/** Session store — optional, defaults to `MemorySessionStore` (dev/test only). */
|
|
2359
|
+
sessionStore?: ISessionStore;
|
|
2360
|
+
/**
|
|
2361
|
+
* Fee management config. If omitted the `handleGasFee` endpoint will
|
|
2362
|
+
* throw "not configured" at request time.
|
|
2363
|
+
*/
|
|
2364
|
+
fee?: Omit<FeeManagerConfig, "provider">;
|
|
2365
|
+
/**
|
|
2366
|
+
* Pool discovery function for `handlePools`. If omitted the endpoint
|
|
2367
|
+
* throws "not configured" at request time.
|
|
2368
|
+
*/
|
|
2369
|
+
poolsProvider?: PoolsProvider;
|
|
2370
|
+
/**
|
|
2371
|
+
* Enables `handleClaim`. The factory combines these with the shared
|
|
2372
|
+
* `policy` + `relayService` instances already wired by the factory.
|
|
2373
|
+
* Omit to disable the `/claim` endpoint.
|
|
2374
|
+
*/
|
|
2375
|
+
claim?: {
|
|
2376
|
+
issuerSignerWallet: WalletClient;
|
|
2377
|
+
/** Defaults to the PAFI-deployed BatchExecutor for the target chain. */
|
|
2378
|
+
batchExecutorAddress?: Address;
|
|
2379
|
+
lockDurationMs?: number;
|
|
2380
|
+
};
|
|
2381
|
+
indexer?: {
|
|
2382
|
+
fromBlock?: bigint;
|
|
2383
|
+
cursorStore?: IIndexerCursorStore;
|
|
2384
|
+
confirmations?: number;
|
|
2385
|
+
batchSize?: number;
|
|
2386
|
+
pollIntervalMs?: number;
|
|
2387
|
+
/**
|
|
2388
|
+
* If `true`, the factory calls `indexer.start()` before returning.
|
|
2389
|
+
* Default: `false` — the caller decides when to begin polling.
|
|
2390
|
+
*/
|
|
2391
|
+
autoStart?: boolean;
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
interface IssuerService {
|
|
2395
|
+
/** AuthService — login, logout, nonce management. */
|
|
2396
|
+
auth: AuthService;
|
|
2397
|
+
/** Session store — nonce + JWT session persistence. */
|
|
2398
|
+
session: ISessionStore;
|
|
2399
|
+
ledger: IPointLedger;
|
|
2400
|
+
policy: IPolicyEngine;
|
|
2401
|
+
/** RelayService — prepareMint / prepareBurn UserOp builders. */
|
|
2402
|
+
relay: RelayService;
|
|
2403
|
+
/** FeeManager — gas fee estimation. Undefined if not configured. */
|
|
2404
|
+
fee: FeeManager | undefined;
|
|
2405
|
+
/** All indexers keyed by PointToken address. */
|
|
2406
|
+
indexers: Map<Address, PointIndexer>;
|
|
2407
|
+
/**
|
|
2408
|
+
* First indexer. Kept for backward compat with 0.1.x callers.
|
|
2409
|
+
* @deprecated use `indexers.get(tokenAddress)` for multi-token.
|
|
2410
|
+
*/
|
|
2411
|
+
indexer: PointIndexer;
|
|
2412
|
+
/** Framework-agnostic HTTP handlers — wire into Express / Fastify / Hono. */
|
|
2413
|
+
api: IssuerApiHandlers;
|
|
2414
|
+
}
|
|
2415
|
+
/**
|
|
2416
|
+
* Wire a fully-functional issuer service from a single config object.
|
|
2417
|
+
*
|
|
2418
|
+
* Defaults:
|
|
2419
|
+
* - `sessionStore` → `MemorySessionStore` (dev/test only — replace in prod)
|
|
2420
|
+
* - `policy` → `DefaultPolicyEngine({ ledger })`
|
|
2421
|
+
* - `feeManager` → undefined (handleGasFee throws until configured)
|
|
2422
|
+
* - `poolsProvider` → undefined (handlePools throws until configured)
|
|
2423
|
+
* - `indexer.autoStart` → false
|
|
2424
|
+
*
|
|
2425
|
+
* Throws synchronously if any required field is missing.
|
|
2426
|
+
*/
|
|
2427
|
+
declare function createIssuerService(config: IssuerServiceConfig): IssuerService;
|
|
2428
|
+
|
|
2429
|
+
/**
|
|
2430
|
+
* Adapter that absorbs every "framework-agnostic" endpoint body into a
|
|
2431
|
+
* single class so issuer controllers stay thin (one line per endpoint).
|
|
2432
|
+
*
|
|
2433
|
+
* What this absorbs:
|
|
2434
|
+
* - Reading + reshaping IssuerApiHandlers responses into wire DTOs
|
|
2435
|
+
* (bigint → string, etc.)
|
|
2436
|
+
* - Composing handler.handle() output with sponsorAuth + decoded calls
|
|
2437
|
+
* - Wiring handleMobilePrepare / handleMobileSubmit / handleClaimStatus
|
|
2438
|
+
* - Building the EIP-7702 delegate UserOp + relay
|
|
2439
|
+
* - Quoting PT → USDT for the cashout preview
|
|
2440
|
+
*
|
|
2441
|
+
* What stays in the issuer controller:
|
|
2442
|
+
* - HTTP routing decorators (`@Get`, `@Post`, `@UseGuards`)
|
|
2443
|
+
* - Auth context extraction (`@User() user: AuthContext`)
|
|
2444
|
+
* - Body DTO classes (with framework-specific decorators)
|
|
2445
|
+
* - Nonce composer (issuer-specific; e.g. gg56 uses 2D timestamp keys)
|
|
2446
|
+
*
|
|
2447
|
+
* Every method that can throw a typed SDK error throws `PafiSdkError` —
|
|
2448
|
+
* the controller wraps every call with `try/catch + mapSdkError`, or
|
|
2449
|
+
* the adapter pre-binds an `errorMapper` and auto-translates.
|
|
2450
|
+
*/
|
|
2451
|
+
interface IssuerApiAdapterConfig {
|
|
2452
|
+
issuerService: IssuerService;
|
|
2453
|
+
ledger: IPointLedger;
|
|
2454
|
+
provider: PublicClient;
|
|
2455
|
+
/** Issuer signer wallet — used for `buildSponsorAuth` (EIP-712 sign). */
|
|
2456
|
+
issuerSignerWallet: WalletClient;
|
|
2457
|
+
/** Optional issuer id — when omitted, sponsorAuth is skipped (returns `undefined`). */
|
|
2458
|
+
pafiIssuerId?: string;
|
|
2459
|
+
/** Sig-gated mint handler. Required for `claim` / `claimPrepare`. */
|
|
2460
|
+
ptClaimHandler: PTClaimHandler;
|
|
2461
|
+
/** Reverse-flow handler. Required for `redeem` / `redeemPrepare`. */
|
|
2462
|
+
ptRedeemHandler?: PTRedeemHandler | null;
|
|
2463
|
+
/** PT → USDT swap handler. Required for `swap`. */
|
|
2464
|
+
swapHandler: SwapHandler;
|
|
2465
|
+
/** Orderly perp-deposit handler. Required for `perpDeposit`. */
|
|
2466
|
+
perpHandler: PerpDepositHandler;
|
|
2467
|
+
/** Pending UserOp store — required for mobile prepare/submit. */
|
|
2468
|
+
pendingUserOpStore: IPendingUserOpStore;
|
|
2469
|
+
/** PAFI backend client — required for mobile submit + delegate submit + status fallback. */
|
|
2470
|
+
pafiBackendClient?: PafiBackendClient | null;
|
|
2471
|
+
/** Optional logger surface for non-fatal warnings. */
|
|
2472
|
+
onWarning?: (msg: string) => void;
|
|
2473
|
+
}
|
|
2474
|
+
interface ConfigDto {
|
|
2475
|
+
chainId: number;
|
|
2476
|
+
contracts: Record<string, string | undefined>;
|
|
2477
|
+
}
|
|
2478
|
+
interface GasFeeDto {
|
|
2479
|
+
gasFeeUsdt: string;
|
|
2480
|
+
}
|
|
2481
|
+
interface PoolsDto {
|
|
2482
|
+
pools: unknown[];
|
|
2483
|
+
}
|
|
2484
|
+
interface UserDto {
|
|
2485
|
+
mintRequestNonce: string;
|
|
2486
|
+
receiverConsentNonce: string;
|
|
2487
|
+
offChainBalance: string;
|
|
2488
|
+
onChainBalance: string;
|
|
2489
|
+
totalBalance: string;
|
|
2490
|
+
/** @deprecated alias for `offChainBalance` */
|
|
2491
|
+
balance: string;
|
|
2492
|
+
isMinter: boolean;
|
|
2493
|
+
}
|
|
2494
|
+
interface QuoteDto {
|
|
2495
|
+
pointAmount: string;
|
|
2496
|
+
estimatedUsdtOut: string;
|
|
2497
|
+
gasFeeUsdt: string;
|
|
2498
|
+
netUsdtOut: string;
|
|
2499
|
+
exchangeRate: string;
|
|
2500
|
+
suggestedDeadline: string;
|
|
2501
|
+
gasEstimate: string;
|
|
2502
|
+
quoteError?: "QUOTE_UNAVAILABLE" | "AMOUNT_TOO_SMALL_FOR_GAS";
|
|
2503
|
+
}
|
|
2504
|
+
interface DecodedCallDto {
|
|
2505
|
+
to: string;
|
|
2506
|
+
data: string;
|
|
2507
|
+
value: string;
|
|
2508
|
+
}
|
|
2509
|
+
interface ClaimDto {
|
|
2510
|
+
calls: DecodedCallDto[];
|
|
2511
|
+
callsFallback?: DecodedCallDto[];
|
|
2512
|
+
feeAmount: string;
|
|
2513
|
+
lockId: string;
|
|
2514
|
+
signatureDeadline: string;
|
|
2515
|
+
sponsorAuth?: BuiltSponsorAuth;
|
|
2516
|
+
}
|
|
2517
|
+
interface RedeemDto {
|
|
2518
|
+
calls: DecodedCallDto[];
|
|
2519
|
+
callsFallback?: DecodedCallDto[];
|
|
2520
|
+
feeAmount: string;
|
|
2521
|
+
lockId: string;
|
|
2522
|
+
lockIdFallback?: string;
|
|
2523
|
+
netCreditAmount: string;
|
|
2524
|
+
netCreditAmountFallback?: string;
|
|
2525
|
+
expiresInSeconds: number;
|
|
2526
|
+
signatureDeadline: string;
|
|
2527
|
+
sponsorAuth?: BuiltSponsorAuth;
|
|
2528
|
+
}
|
|
2529
|
+
interface SwapDto {
|
|
2530
|
+
calls: DecodedCallDto[];
|
|
2531
|
+
callsFallback?: DecodedCallDto[];
|
|
2532
|
+
feeAmount: string;
|
|
2533
|
+
estimatedUsdtOut: string;
|
|
2534
|
+
minAmountOut: string;
|
|
2535
|
+
estimatedUsdtOutFallback?: string;
|
|
2536
|
+
minAmountOutFallback?: string;
|
|
2537
|
+
deadline: string;
|
|
2538
|
+
sponsorAuth?: BuiltSponsorAuth;
|
|
2539
|
+
}
|
|
2540
|
+
interface PerpDepositDto {
|
|
2541
|
+
calls: DecodedCallDto[];
|
|
2542
|
+
callsFallback?: DecodedCallDto[];
|
|
2543
|
+
relayTokenFee: string;
|
|
2544
|
+
maxFee: string;
|
|
2545
|
+
netDeposit: string;
|
|
2546
|
+
ptGasFee: string;
|
|
2547
|
+
accountId: Hex;
|
|
2548
|
+
brokerHash: Hex;
|
|
2549
|
+
usdcAddress: Address;
|
|
2550
|
+
relayAddress: Address;
|
|
2551
|
+
sponsorAuth?: BuiltSponsorAuth;
|
|
2552
|
+
}
|
|
2553
|
+
interface MobilePrepareDto {
|
|
2554
|
+
lockId: string;
|
|
2555
|
+
userOpHash: Hex;
|
|
2556
|
+
typedData: SerializedUserOpTypedData;
|
|
2557
|
+
userOpHashFallback?: Hex;
|
|
2558
|
+
typedDataFallback?: SerializedUserOpTypedData;
|
|
2559
|
+
feeAmount: string;
|
|
2560
|
+
signatureDeadline: string;
|
|
2561
|
+
expiresInSeconds: number;
|
|
2562
|
+
sponsored: boolean;
|
|
2563
|
+
needsDelegation: boolean;
|
|
2564
|
+
}
|
|
2565
|
+
interface RedeemPrepareDto extends MobilePrepareDto {
|
|
2566
|
+
netCreditAmount: string;
|
|
2567
|
+
netCreditAmountFallback?: string;
|
|
2568
|
+
}
|
|
2569
|
+
interface MobileSubmitDto {
|
|
2570
|
+
userOpHash: Hex;
|
|
2571
|
+
}
|
|
2572
|
+
interface DelegateStatusDto {
|
|
2573
|
+
isDelegated: boolean;
|
|
2574
|
+
batchExecutorAddress: Address;
|
|
2575
|
+
}
|
|
2576
|
+
interface DelegatePrepareDto {
|
|
2577
|
+
authorizationHash: Hex;
|
|
2578
|
+
delegationNonce: string;
|
|
2579
|
+
batchExecutorAddress: Address;
|
|
2580
|
+
chainId: number;
|
|
2581
|
+
}
|
|
2582
|
+
declare class IssuerApiAdapter {
|
|
2583
|
+
private readonly cfg;
|
|
2584
|
+
constructor(config: IssuerApiAdapterConfig);
|
|
2585
|
+
config(chainId: number): Promise<ConfigDto>;
|
|
2586
|
+
gasFee(): Promise<GasFeeDto>;
|
|
2587
|
+
pools(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address): Promise<PoolsDto>;
|
|
2588
|
+
user(authenticatedAddress: Address, chainId: number, userAddress: Address, pointTokenAddress: Address): Promise<UserDto>;
|
|
2589
|
+
quote(authenticatedAddress: Address, chainId: number, pointTokenAddress: Address, pointAmount: bigint): Promise<QuoteDto>;
|
|
2590
|
+
claim(input: {
|
|
2591
|
+
authenticatedAddress: Address;
|
|
2592
|
+
chainId: number;
|
|
2593
|
+
pointTokenAddress: Address;
|
|
2594
|
+
amount: bigint;
|
|
2595
|
+
aaNonce: bigint;
|
|
2596
|
+
mintRequestNonce: bigint;
|
|
2597
|
+
}): Promise<ClaimDto>;
|
|
2598
|
+
redeem(input: {
|
|
2599
|
+
authenticatedAddress: Address;
|
|
2600
|
+
chainId: number;
|
|
2601
|
+
amount: bigint;
|
|
2602
|
+
aaNonce: bigint;
|
|
2603
|
+
}): Promise<RedeemDto>;
|
|
2604
|
+
swap(input: {
|
|
2605
|
+
authenticatedAddress: Address;
|
|
2606
|
+
chainId: number;
|
|
2607
|
+
pointTokenAddress: Address;
|
|
2608
|
+
amountIn: bigint;
|
|
2609
|
+
aaNonce: bigint;
|
|
2610
|
+
slippageBps?: number;
|
|
2611
|
+
}): Promise<SwapDto>;
|
|
2612
|
+
perpDeposit(input: {
|
|
2613
|
+
authenticatedAddress: Address;
|
|
2614
|
+
chainId: number;
|
|
2615
|
+
amount: bigint;
|
|
2616
|
+
brokerId: Parameters<PerpDepositHandler["handle"]>[0]["brokerId"];
|
|
2617
|
+
aaNonce: bigint;
|
|
2618
|
+
}): Promise<PerpDepositDto>;
|
|
2619
|
+
claimPrepare(input: {
|
|
2620
|
+
authenticatedAddress: Address;
|
|
2621
|
+
chainId: number;
|
|
2622
|
+
pointTokenAddress: Address;
|
|
2623
|
+
amount: bigint;
|
|
2624
|
+
aaNonce: bigint;
|
|
2625
|
+
mintRequestNonce: bigint;
|
|
2626
|
+
}): Promise<MobilePrepareDto>;
|
|
2627
|
+
claimSubmit(input: {
|
|
2628
|
+
authenticatedAddress: Address;
|
|
2629
|
+
lockId: string;
|
|
2630
|
+
signature: Hex;
|
|
2631
|
+
variant?: "sponsored" | "fallback";
|
|
2632
|
+
}): Promise<MobileSubmitDto>;
|
|
2633
|
+
redeemPrepare(input: {
|
|
2634
|
+
authenticatedAddress: Address;
|
|
2635
|
+
chainId: number;
|
|
2636
|
+
pointTokenAddress: Address;
|
|
2637
|
+
amount: bigint;
|
|
2638
|
+
aaNonce: bigint;
|
|
2639
|
+
}): Promise<RedeemPrepareDto>;
|
|
2640
|
+
redeemSubmit(input: {
|
|
2641
|
+
authenticatedAddress: Address;
|
|
2642
|
+
lockId: string;
|
|
2643
|
+
signature: Hex;
|
|
2644
|
+
variant?: "sponsored" | "fallback";
|
|
2645
|
+
}): Promise<MobileSubmitDto>;
|
|
2646
|
+
claimStatus(authenticatedAddress: Address, lockId: string): Promise<MintStatusResponse>;
|
|
2647
|
+
redeemStatus(authenticatedAddress: Address, lockId: string): Promise<BurnStatusResponse>;
|
|
2648
|
+
delegateStatus(authenticatedAddress: Address, chainId: number): Promise<DelegateStatusDto>;
|
|
2649
|
+
delegatePrepare(authenticatedAddress: Address, chainId: number): Promise<DelegatePrepareDto>;
|
|
2650
|
+
delegateSubmit(input: {
|
|
2651
|
+
authenticatedAddress: Address;
|
|
2652
|
+
chainId: number;
|
|
2653
|
+
delegationNonce: bigint;
|
|
2654
|
+
aaNonce: bigint;
|
|
2655
|
+
authSig: Hex | string;
|
|
2656
|
+
}): Promise<MobileSubmitDto>;
|
|
2657
|
+
/**
|
|
2658
|
+
* Build + sign a SponsorAuth payload. Returns `undefined` when no
|
|
2659
|
+
* issuer id is configured, so the controller can skip the field.
|
|
2660
|
+
*/
|
|
2661
|
+
private buildSponsorAuth;
|
|
2662
|
+
private runMobilePrepare;
|
|
2663
|
+
private assertRedeemHandler;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2307
2666
|
/**
|
|
2308
2667
|
* Config for `createSubgraphPoolsProvider`.
|
|
2309
2668
|
*/
|
|
@@ -2615,128 +2974,6 @@ declare function relayUserOp(params: RelayUserOpParams): Promise<{
|
|
|
2615
2974
|
userOpHash: Hex;
|
|
2616
2975
|
}>;
|
|
2617
2976
|
|
|
2618
|
-
/**
|
|
2619
|
-
* Top-level configuration for `createIssuerService`.
|
|
2620
|
-
*
|
|
2621
|
-
* In v1.4 the SDK is HTTP-client-free: it signs EIP-712 messages, reads
|
|
2622
|
-
* on-chain state, builds unsigned UserOperations, and maintains the
|
|
2623
|
-
* off-chain ledger. It never broadcasts transactions — that's the
|
|
2624
|
-
* frontend's responsibility via Bundler + Paymaster.
|
|
2625
|
-
*
|
|
2626
|
-
* **Multi-token (0.2.0+):** Pass `pointTokenAddresses: Address[]` to
|
|
2627
|
-
* support multiple PointTokens under a single issuer backend. Legacy
|
|
2628
|
-
* `pointTokenAddress: Address` still works for single-token deployments.
|
|
2629
|
-
* When both are provided, `pointTokenAddresses` takes precedence.
|
|
2630
|
-
*/
|
|
2631
|
-
interface IssuerServiceConfig {
|
|
2632
|
-
chainId: number;
|
|
2633
|
-
/** Legacy single-token shortcut; prefer `pointTokenAddresses`. */
|
|
2634
|
-
pointTokenAddress?: Address;
|
|
2635
|
-
/** All PointToken addresses this issuer supports. */
|
|
2636
|
-
pointTokenAddresses?: Address[];
|
|
2637
|
-
/**
|
|
2638
|
-
* Issuer-specific contract addresses merged into the `/config` response.
|
|
2639
|
-
* PAFI-owned addresses (batchExecutor, usdt, issuerRegistry, mintingOracle,
|
|
2640
|
-
* pafiHook) are auto-resolved from `getContractAddresses(chainId)` and
|
|
2641
|
-
* can be omitted. Only `pointToken` / `pointTokens` must be provided.
|
|
2642
|
-
*/
|
|
2643
|
-
contracts?: Pick<ApiConfigResponse["contracts"], "pointToken" | "pointTokens" | "relay">;
|
|
2644
|
-
/**
|
|
2645
|
-
* Shared `PublicClient` used for on-chain reads, simulation, indexer
|
|
2646
|
-
* polling, and gas-price lookups. Must be pointed at the target chain.
|
|
2647
|
-
*/
|
|
2648
|
-
provider: PublicClient;
|
|
2649
|
-
auth: {
|
|
2650
|
-
jwtSecret: string;
|
|
2651
|
-
/** SIWE-style login-message domain, e.g. `"app.example.com"`. */
|
|
2652
|
-
domain: string;
|
|
2653
|
-
/** Passed straight to `jose` (`"24h"`, `"7d"`, …). Default `"24h"`. */
|
|
2654
|
-
jwtExpiresIn?: string;
|
|
2655
|
-
};
|
|
2656
|
-
/**
|
|
2657
|
-
* Off-chain point ledger — the source of truth for user balances and
|
|
2658
|
-
* in-flight minting locks. Every issuer provides their own database-backed
|
|
2659
|
-
* implementation (Postgres, Redis, etc.) that implements `IPointLedger`.
|
|
2660
|
-
* The SDK does not ship a production ledger; each issuer's data model and
|
|
2661
|
-
* infrastructure are different.
|
|
2662
|
-
*/
|
|
2663
|
-
ledger: IPointLedger;
|
|
2664
|
-
/**
|
|
2665
|
-
* Policy engine — optional, defaults to `DefaultPolicyEngine` which checks
|
|
2666
|
-
* off-chain balance. Extend or replace to add KYC, volume caps, etc.
|
|
2667
|
-
*/
|
|
2668
|
-
policy?: IPolicyEngine;
|
|
2669
|
-
/** Session store — optional, defaults to `MemorySessionStore` (dev/test only). */
|
|
2670
|
-
sessionStore?: ISessionStore;
|
|
2671
|
-
/**
|
|
2672
|
-
* Fee management config. If omitted the `handleGasFee` endpoint will
|
|
2673
|
-
* throw "not configured" at request time.
|
|
2674
|
-
*/
|
|
2675
|
-
fee?: Omit<FeeManagerConfig, "provider">;
|
|
2676
|
-
/**
|
|
2677
|
-
* Pool discovery function for `handlePools`. If omitted the endpoint
|
|
2678
|
-
* throws "not configured" at request time.
|
|
2679
|
-
*/
|
|
2680
|
-
poolsProvider?: PoolsProvider;
|
|
2681
|
-
/**
|
|
2682
|
-
* Enables `handleClaim`. The factory combines these with the shared
|
|
2683
|
-
* `policy` + `relayService` instances already wired by the factory.
|
|
2684
|
-
* Omit to disable the `/claim` endpoint.
|
|
2685
|
-
*/
|
|
2686
|
-
claim?: {
|
|
2687
|
-
issuerSignerWallet: WalletClient;
|
|
2688
|
-
/** Defaults to the PAFI-deployed BatchExecutor for the target chain. */
|
|
2689
|
-
batchExecutorAddress?: Address;
|
|
2690
|
-
lockDurationMs?: number;
|
|
2691
|
-
};
|
|
2692
|
-
indexer?: {
|
|
2693
|
-
fromBlock?: bigint;
|
|
2694
|
-
cursorStore?: IIndexerCursorStore;
|
|
2695
|
-
confirmations?: number;
|
|
2696
|
-
batchSize?: number;
|
|
2697
|
-
pollIntervalMs?: number;
|
|
2698
|
-
/**
|
|
2699
|
-
* If `true`, the factory calls `indexer.start()` before returning.
|
|
2700
|
-
* Default: `false` — the caller decides when to begin polling.
|
|
2701
|
-
*/
|
|
2702
|
-
autoStart?: boolean;
|
|
2703
|
-
};
|
|
2704
|
-
}
|
|
2705
|
-
interface IssuerService {
|
|
2706
|
-
/** AuthService — login, logout, nonce management. */
|
|
2707
|
-
auth: AuthService;
|
|
2708
|
-
/** Session store — nonce + JWT session persistence. */
|
|
2709
|
-
session: ISessionStore;
|
|
2710
|
-
ledger: IPointLedger;
|
|
2711
|
-
policy: IPolicyEngine;
|
|
2712
|
-
/** RelayService — prepareMint / prepareBurn UserOp builders. */
|
|
2713
|
-
relay: RelayService;
|
|
2714
|
-
/** FeeManager — gas fee estimation. Undefined if not configured. */
|
|
2715
|
-
fee: FeeManager | undefined;
|
|
2716
|
-
/** All indexers keyed by PointToken address. */
|
|
2717
|
-
indexers: Map<Address, PointIndexer>;
|
|
2718
|
-
/**
|
|
2719
|
-
* First indexer. Kept for backward compat with 0.1.x callers.
|
|
2720
|
-
* @deprecated use `indexers.get(tokenAddress)` for multi-token.
|
|
2721
|
-
*/
|
|
2722
|
-
indexer: PointIndexer;
|
|
2723
|
-
/** Framework-agnostic HTTP handlers — wire into Express / Fastify / Hono. */
|
|
2724
|
-
api: IssuerApiHandlers;
|
|
2725
|
-
}
|
|
2726
|
-
/**
|
|
2727
|
-
* Wire a fully-functional issuer service from a single config object.
|
|
2728
|
-
*
|
|
2729
|
-
* Defaults:
|
|
2730
|
-
* - `sessionStore` → `MemorySessionStore` (dev/test only — replace in prod)
|
|
2731
|
-
* - `policy` → `DefaultPolicyEngine({ ledger })`
|
|
2732
|
-
* - `feeManager` → undefined (handleGasFee throws until configured)
|
|
2733
|
-
* - `poolsProvider` → undefined (handlePools throws until configured)
|
|
2734
|
-
* - `indexer.autoStart` → false
|
|
2735
|
-
*
|
|
2736
|
-
* Throws synchronously if any required field is missing.
|
|
2737
|
-
*/
|
|
2738
|
-
declare function createIssuerService(config: IssuerServiceConfig): IssuerService;
|
|
2739
|
-
|
|
2740
2977
|
interface IssuerRegistryRecord {
|
|
2741
2978
|
issuerAddress: Address;
|
|
2742
2979
|
signerAddress: Address;
|
|
@@ -2837,4 +3074,4 @@ declare class IssuerStateValidator {
|
|
|
2837
3074
|
/** SDK package version — bumped on every release */
|
|
2838
3075
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
2839
3076
|
|
|
2840
|
-
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 HandleDelegateSubmitParams, type HandleDelegateSubmitResult, type HandleMobilePrepareParams, type HandleMobilePrepareResult, type HandleMobileSubmitParams, 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, PTClaimError, PTClaimHandler, type PTClaimHandlerConfig, type PTClaimRequest, type PTClaimResponse, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, PafiSdkError, type PendingCredit, type PendingUserOpEntry, PendingUserOpForbiddenError, PendingUserOpNotFoundError, PerpDepositError, PerpDepositHandler, type PerpDepositHandlerConfig, type PerpDepositRequest, type PerpDepositResponse, 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, type QuotePointTokenToUsdtParams, type QuotePointTokenToUsdtResult, RelayError, type RelayErrorCode, RelayService, type RelayUserOpParams, type RelayUserOpRequest, type RelayUserOpResponse, type RequestPaymasterParams, type RetryConfig, type SdkErrorBody, type SdkErrorHttpStatus, type SdkErrorMapperFactories, type SdkErrorStatus, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, SwapError, SwapHandler, type SwapHandlerConfig, type SwapRequest, type SwapResponse, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createNativePtQuoter, createSdkErrorMapper, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleDelegateSubmit, handleMobilePrepare, handleMobileSubmit, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, quotePointTokenToUsdt, relayUserOp, requestPaymaster, serializeEntryToJsonRpc, serializeUserOpTypedData };
|
|
3077
|
+
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 ClaimDto, type CombinedBalance, type ConfigDto, type DecodedCallDto, DefaultPolicyEngine, type DefaultPolicyEngineOptions, type DelegatePrepareDto, type DelegateStatusDto, FeeManager, type FeeManagerConfig, type GasFeeDto, type HandleDelegateSubmitParams, type HandleDelegateSubmitResult, type HandleMobilePrepareParams, type HandleMobilePrepareResult, type HandleMobileSubmitParams, type IIndexerCursorStore, type IPendingUserOpStore, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiAdapter, type IssuerApiAdapterConfig, 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 MobilePrepareDto, type MobileSubmitDto, type NativePtQuoterConfig, NonceManager, PAFI_ISSUER_SDK_VERSION, PTClaimError, PTClaimHandler, type PTClaimHandlerConfig, type PTClaimRequest, type PTClaimResponse, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, PafiSdkError, type PendingCredit, type PendingUserOpEntry, PendingUserOpForbiddenError, PendingUserOpNotFoundError, type PerpDepositDto, PerpDepositError, PerpDepositHandler, type PerpDepositHandlerConfig, type PerpDepositRequest, type PerpDepositResponse, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsDto, type PoolsProvider, type PreValidateMintResult, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, type PrepareMobileUserOpParams, type PrepareMobileUserOpResult, type PreparedUserOp, type QuoteDto, type QuotePointTokenToUsdtParams, type QuotePointTokenToUsdtResult, type RedeemDto, type RedeemPrepareDto, RelayError, type RelayErrorCode, RelayService, type RelayUserOpParams, type RelayUserOpRequest, type RelayUserOpResponse, type RequestPaymasterParams, type RetryConfig, type SdkErrorBody, type SdkErrorHttpStatus, type SdkErrorMapperFactories, type SdkErrorStatus, type SerializedUserOpTypedData, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, type SwapDto, SwapError, SwapHandler, type SwapHandlerConfig, type SwapRequest, type SwapResponse, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, type UserDto, authenticateRequest, createIssuerService, createNativePtQuoter, createSdkErrorMapper, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider, handleClaimStatus, handleDelegateSubmit, handleMobilePrepare, handleMobileSubmit, handleRedeemStatus, mergePaymasterFields, prepareMobileUserOp, quotePointTokenToUsdt, relayUserOp, requestPaymaster, serializeEntryToJsonRpc, serializeUserOpTypedData };
|