@pafi-dev/issuer 0.3.0-beta.4 → 0.3.0-beta.5
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 +21 -479
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -331
- package/dist/index.d.ts +40 -331
- package/dist/index.js +6 -468
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Address, Hex, PublicClient, Chain, WalletClient } from 'viem';
|
|
2
|
-
import { PointTokenDomainConfig, MintRequest, EIP712Signature,
|
|
3
|
-
export { encodeExtData } from '@pafi-dev/core';
|
|
2
|
+
import { PointTokenDomainConfig, MintRequest, EIP712Signature, PartialUserOperation, BurnRequest, ReceiverConsent, PathKey, PoolKey, SponsorshipScenario } from '@pafi-dev/core';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Lifecycle of a minting request as tracked by the issuer's point ledger.
|
|
@@ -449,130 +448,40 @@ declare class AuthError extends Error {
|
|
|
449
448
|
}
|
|
450
449
|
|
|
451
450
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
swap: SwapParams;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Result of a relay submission. `txHash` is returned immediately after
|
|
463
|
-
* the tx is broadcast; `receipt` is present only when the caller opted to
|
|
464
|
-
* wait for confirmation.
|
|
465
|
-
*/
|
|
466
|
-
interface RelayResult {
|
|
467
|
-
txHash: Hex;
|
|
468
|
-
blockNumber?: bigint;
|
|
469
|
-
gasUsed?: bigint;
|
|
470
|
-
status?: "success" | "reverted";
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Errors raised by RelayService carry a `code` so the MintingGateway (or
|
|
474
|
-
* any caller) can decide whether to release the ledger lock.
|
|
451
|
+
* Errors raised by RelayService carry a `code` so callers (handlers /
|
|
452
|
+
* gateway-less HTTP wrappers) can decide how to map them to HTTP status.
|
|
453
|
+
*
|
|
454
|
+
* v1.4 trimmed the error space to just encoding failures — the service
|
|
455
|
+
* no longer broadcasts transactions, so `SUBMIT_FAILED`, `TX_REVERTED`,
|
|
456
|
+
* `SIMULATION_FAILED`, and `TIMEOUT` all went away with the operator
|
|
457
|
+
* wallet. Paymaster/Bundler errors surface out-of-band on the FE.
|
|
475
458
|
*/
|
|
476
|
-
type RelayErrorCode = "NOT_CONFIGURED" | "ENCODE_FAILED"
|
|
459
|
+
type RelayErrorCode = "NOT_CONFIGURED" | "ENCODE_FAILED";
|
|
477
460
|
declare class RelayError extends Error {
|
|
478
461
|
readonly code: RelayErrorCode;
|
|
479
462
|
readonly cause?: unknown;
|
|
480
463
|
constructor(code: RelayErrorCode, message: string, cause?: unknown);
|
|
481
464
|
}
|
|
482
|
-
/**
|
|
483
|
-
* Interface an operator wallet must satisfy for the RelayService. Matches
|
|
484
|
-
* the subset of viem's `WalletClient` we actually call, so tests can pass
|
|
485
|
-
* a minimal mock instead of a full client.
|
|
486
|
-
*/
|
|
487
|
-
interface OperatorWalletLike {
|
|
488
|
-
writeContract: (args: {
|
|
489
|
-
address: Address;
|
|
490
|
-
abi: readonly unknown[];
|
|
491
|
-
functionName: string;
|
|
492
|
-
args: readonly unknown[];
|
|
493
|
-
account?: {
|
|
494
|
-
address: Address;
|
|
495
|
-
};
|
|
496
|
-
}) => Promise<Hex>;
|
|
497
|
-
account?: {
|
|
498
|
-
address: Address;
|
|
499
|
-
} | undefined;
|
|
500
|
-
}
|
|
501
465
|
|
|
502
|
-
interface RelayServiceConfig {
|
|
503
|
-
/** Address of the deployed Relay contract (chain-specific). */
|
|
504
|
-
relayAddress: Address;
|
|
505
|
-
/** Operator wallet that pays gas and receives the operator fee. */
|
|
506
|
-
operatorWallet: OperatorWalletLike;
|
|
507
|
-
/**
|
|
508
|
-
* Provider used for pre-flight simulation and receipt waiting. Optional —
|
|
509
|
-
* if omitted, the service still broadcasts but returns only `txHash`
|
|
510
|
-
* (caller is responsible for confirmation tracking).
|
|
511
|
-
*/
|
|
512
|
-
provider?: PublicClient;
|
|
513
|
-
/**
|
|
514
|
-
* If a provider is supplied, wait up to this many milliseconds for a
|
|
515
|
-
* receipt before timing out. Default: 60_000 (one minute).
|
|
516
|
-
*/
|
|
517
|
-
confirmationTimeoutMs?: number;
|
|
518
|
-
/**
|
|
519
|
-
* Whether to run `simulateContract` before submitting. Catches most
|
|
520
|
-
* reverts locally without wasting gas. Default: true (when provider is
|
|
521
|
-
* supplied).
|
|
522
|
-
*/
|
|
523
|
-
simulateBeforeSubmit?: boolean;
|
|
524
|
-
}
|
|
525
466
|
/**
|
|
526
|
-
*
|
|
527
|
-
*
|
|
467
|
+
* Builds unsigned `PartialUserOperation` payloads for the v1.4 sponsored
|
|
468
|
+
* flow. The service is stateless and HTTP-client-free:
|
|
528
469
|
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
* - `prepareBurn`
|
|
534
|
-
* `PointToken.burn(from, amount,
|
|
470
|
+
* - `prepareMint` signs a `MintRequest` EIP-712 with the caller-supplied
|
|
471
|
+
* issuer signer wallet, then encodes `PointToken.mint(to, amount,
|
|
472
|
+
* deadline, minterSig)` into a UserOp the frontend submits via
|
|
473
|
+
* EIP-7702 + Paymaster.
|
|
474
|
+
* - `prepareBurn` mirrors the above on the burn side using a
|
|
475
|
+
* pre-signed `BurnRequest` + `PointToken.burn(from, amount,
|
|
476
|
+
* deadline, burnerSig)`.
|
|
535
477
|
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
478
|
+
* There is no broadcasting, no operator wallet, no simulation — those
|
|
479
|
+
* concerns moved to the Bundler + Paymaster in v1.4.
|
|
538
480
|
*/
|
|
539
481
|
declare class RelayService {
|
|
540
|
-
private readonly relayAddress;
|
|
541
|
-
private readonly operatorWallet;
|
|
542
|
-
private readonly provider?;
|
|
543
|
-
private readonly confirmationTimeoutMs;
|
|
544
|
-
private readonly simulateBeforeSubmit;
|
|
545
|
-
constructor(config: RelayServiceConfig);
|
|
546
|
-
/** Address the operator wallet is broadcasting from (for logging). */
|
|
547
|
-
operatorAddress(): Address | undefined;
|
|
548
|
-
/**
|
|
549
|
-
* Build calldata for the Relay `mintAndSwap` function. Kept public so
|
|
550
|
-
* callers (e.g. the MintingGateway) can log or persist the encoded call
|
|
551
|
-
* for audit before broadcasting.
|
|
552
|
-
*/
|
|
553
|
-
encodeCall(params: SubmitMintAndSwapParams): Hex;
|
|
554
|
-
/**
|
|
555
|
-
* Submit a `mintAndSwap` transaction (legacy v0.2 `/claim-and-swap`).
|
|
556
|
-
*
|
|
557
|
-
* @deprecated Since 0.3.0 — replaced by `prepareMint` / `prepareBurn`
|
|
558
|
-
* in the v1.4 sponsored-UserOp flow. Kept for v0.2.x consumers;
|
|
559
|
-
* scheduled removal in 2.0.
|
|
560
|
-
*/
|
|
561
|
-
submitMintAndSwap(params: SubmitMintAndSwapParams): Promise<RelayResult>;
|
|
562
482
|
/**
|
|
563
483
|
* Build an unsigned UserOp for Scenario 1 (Mint) — sig-gated
|
|
564
484
|
* `PointToken.mint(to, amount, deadline, minterSig)`.
|
|
565
|
-
*
|
|
566
|
-
* Flow:
|
|
567
|
-
* 1. Issuer backend signs `MintRequest(to=user, amount, nonce, deadline)`
|
|
568
|
-
* with its minter signer (HSM/KMS) → `minterSig`.
|
|
569
|
-
* 2. Encode `PointToken.mint(user, amount, deadline, minterSig)`.
|
|
570
|
-
* On-chain, `msg.sender` must equal `to` — satisfied by EIP-7702
|
|
571
|
-
* delegating the user EOA to BatchExecutor.
|
|
572
|
-
* 3. Optional PT fee transfer appended after mint (application-level
|
|
573
|
-
* fee recovery since Relayer v2 no longer exists).
|
|
574
|
-
* 4. Return `PartialUserOperation` ready for Bundler gas estimate +
|
|
575
|
-
* Paymaster sponsorship + user signature.
|
|
576
485
|
*/
|
|
577
486
|
prepareMint(params: PrepareMintParams): Promise<PartialUserOperation>;
|
|
578
487
|
/**
|
|
@@ -580,12 +489,11 @@ declare class RelayService {
|
|
|
580
489
|
*
|
|
581
490
|
* Two modes:
|
|
582
491
|
* - `mode: 'burn'` — direct `PointToken.burn(from, amount)`; only
|
|
583
|
-
* usable if the
|
|
584
|
-
* v1.4
|
|
492
|
+
* usable if the caller (via EIP-7702) is whitelisted as a burner.
|
|
493
|
+
* Rare in v1.4; kept for admin/operator tools.
|
|
585
494
|
* - `mode: 'burnWithSig'` — `PointToken.burn(from, amount, deadline,
|
|
586
|
-
* burnerSig)`.
|
|
587
|
-
*
|
|
588
|
-
* the user-initiated redeem path in v1.4.
|
|
495
|
+
* burnerSig)`. Caller provides a pre-signed `BurnRequest` + sig
|
|
496
|
+
* bytes (typically from `PTRedeemHandler`).
|
|
589
497
|
*/
|
|
590
498
|
prepareBurn(params: PrepareBurnParams): PartialUserOperation;
|
|
591
499
|
}
|
|
@@ -615,7 +523,7 @@ interface PrepareMintParams {
|
|
|
615
523
|
* at provisioning time. Typically HSM/KMS-backed in prod.
|
|
616
524
|
*/
|
|
617
525
|
issuerSignerWallet: WalletClient;
|
|
618
|
-
/** EIP-712 domain for MintRequest
|
|
526
|
+
/** EIP-712 domain for MintRequest. */
|
|
619
527
|
domain: PointTokenDomainConfig;
|
|
620
528
|
/** Current `mintRequestNonces[userAddress]` — caller reads from contract. */
|
|
621
529
|
mintRequestNonce: bigint;
|
|
@@ -717,156 +625,6 @@ declare class FeeManager {
|
|
|
717
625
|
estimateGasFee(): Promise<bigint>;
|
|
718
626
|
}
|
|
719
627
|
|
|
720
|
-
/**
|
|
721
|
-
* End-user request for a full "burn points → receive USDT" flow. The
|
|
722
|
-
* receiver has already signed the `ReceiverConsent` EIP-712 message on
|
|
723
|
-
* the frontend; the issuer backend runs everything else.
|
|
724
|
-
*/
|
|
725
|
-
interface MintAndCashOutRequest {
|
|
726
|
-
/** Address owning the off-chain points (== receiver in the consent). */
|
|
727
|
-
userAddress: Address;
|
|
728
|
-
/** Point token contract to mint. */
|
|
729
|
-
pointTokenAddress: Address;
|
|
730
|
-
/** Chain id the relay will submit on. */
|
|
731
|
-
chainId: number;
|
|
732
|
-
/**
|
|
733
|
-
* EIP-712 domain for `pointTokenAddress`. The gateway passes this
|
|
734
|
-
* straight through to `@pafi/core` `verifyReceiverConsent` and the
|
|
735
|
-
* issuer signer. Callers typically fetch it once via
|
|
736
|
-
* `PafiSDK.getDomain()` and cache it.
|
|
737
|
-
*/
|
|
738
|
-
domain: PointTokenDomainConfig;
|
|
739
|
-
/**
|
|
740
|
-
* Receiver consent message + signature, pre-built by the frontend. The
|
|
741
|
-
* message specifies `onBehalfOf = relay contract` and
|
|
742
|
-
* `originalReceiver = userAddress`, plus the amount, nonce, deadline,
|
|
743
|
-
* and encoded extData.
|
|
744
|
-
*/
|
|
745
|
-
receiverConsent: ReceiverConsent;
|
|
746
|
-
receiverSignature: Hex;
|
|
747
|
-
/**
|
|
748
|
-
* Swap path for the USDT output. Empty array = "no swap" (rare — only
|
|
749
|
-
* useful for testing). Normally a single hop pointToken → USDT.
|
|
750
|
-
*/
|
|
751
|
-
swapPath: PathKey[];
|
|
752
|
-
/** Swap deadline (unix seconds). */
|
|
753
|
-
swapDeadline: bigint;
|
|
754
|
-
/**
|
|
755
|
-
* Lock TTL (ms) to apply to the off-chain balance. The gateway computes
|
|
756
|
-
* a safe default from `receiverConsent.deadline` if omitted.
|
|
757
|
-
*/
|
|
758
|
-
lockDurationMs?: number;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Result returned to the caller after a successful `processMintAndCashOut`.
|
|
762
|
-
* The `lockId` is preserved so the indexer can correlate the on-chain
|
|
763
|
-
* Mint event back to the ledger row (though that correlation is typically
|
|
764
|
-
* done by `(userAddress, amount)` in the default `MemoryPointLedger`).
|
|
765
|
-
*/
|
|
766
|
-
interface MintAndCashOutResponse {
|
|
767
|
-
txHash: Hex;
|
|
768
|
-
lockId: string;
|
|
769
|
-
blockNumber?: bigint;
|
|
770
|
-
gasUsed?: bigint;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Error codes a MintingGateway can surface. Callers (API handlers) map
|
|
774
|
-
* these to HTTP status codes. The `SAFE_TO_RETRY` field tells the caller
|
|
775
|
-
* whether the underlying lock was released — if not, the user should
|
|
776
|
-
* wait before retrying to avoid double-spend.
|
|
777
|
-
*/
|
|
778
|
-
type MintingGatewayErrorCode = "INVALID_REQUEST" | "INVALID_CONSENT_SIGNATURE" | "CONSENT_EXPIRED" | "POLICY_REJECTED" | "INSUFFICIENT_BALANCE" | "SIGNER_FAILED" | "RELAY_SIMULATION_FAILED" | "RELAY_SUBMIT_FAILED" | "RELAY_REVERTED" | "RELAY_TIMEOUT";
|
|
779
|
-
declare class MintingGatewayError extends Error {
|
|
780
|
-
readonly code: MintingGatewayErrorCode;
|
|
781
|
-
/**
|
|
782
|
-
* True if the ledger lock was released before this error was thrown,
|
|
783
|
-
* meaning the user can safely retry. False means the funds are still
|
|
784
|
-
* locked (e.g. tx may still land on-chain) and retry would double-spend.
|
|
785
|
-
*/
|
|
786
|
-
readonly safeToRetry: boolean;
|
|
787
|
-
readonly cause?: unknown;
|
|
788
|
-
constructor(code: MintingGatewayErrorCode, message: string, opts: {
|
|
789
|
-
safeToRetry: boolean;
|
|
790
|
-
cause?: unknown;
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
interface MintingGatewayConfig {
|
|
795
|
-
ledger: IPointLedger;
|
|
796
|
-
policy: IPolicyEngine;
|
|
797
|
-
signer: IIssuerSigner;
|
|
798
|
-
relayService: RelayService;
|
|
799
|
-
/**
|
|
800
|
-
* Clock override for tests. Defaults to `() => Date.now()`. Used to
|
|
801
|
-
* compute safe lock TTLs and to check consent deadlines.
|
|
802
|
-
*/
|
|
803
|
-
now?: () => number;
|
|
804
|
-
/**
|
|
805
|
-
* Extra buffer (ms) added on top of `(consent.deadline - now)` when the
|
|
806
|
-
* caller doesn't supply a `lockDurationMs`. Default: 60_000 (one minute
|
|
807
|
-
* — roughly 2× the Base L2 block confirmation time).
|
|
808
|
-
*/
|
|
809
|
-
defaultLockBufferMs?: number;
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* The MintingGateway is the central orchestrator that turns a user's
|
|
813
|
-
* signed ReceiverConsent into an on-chain `mintAndSwap` tx and a
|
|
814
|
-
* consistent off-chain ledger update.
|
|
815
|
-
*
|
|
816
|
-
* 11-step flow (per `PAFI_ISSUER_SDK_SPEC.md` §4.3):
|
|
817
|
-
*
|
|
818
|
-
* 1. Field validation (cheap rejects before any crypto)
|
|
819
|
-
* 2. Verify ReceiverConsent signature via `@pafi/core`
|
|
820
|
-
* 3. Check off-chain balance via ledger
|
|
821
|
-
* 4. Check locked requests via ledger
|
|
822
|
-
* 5. Run policy engine (balance + on-chain cap + issuer rules)
|
|
823
|
-
* 6. Lock the requested amount in the ledger
|
|
824
|
-
* 7. Sign MintRequest as issuer
|
|
825
|
-
* 8. Build MintParams + SwapParams
|
|
826
|
-
* 9. Submit via RelayService (encode + simulate + broadcast + wait)
|
|
827
|
-
* 10. Return { txHash, lockId, receipt fields }
|
|
828
|
-
* 11. On any failure, release the lock IF it's safe to retry — i.e. we
|
|
829
|
-
* know the tx cannot still land on-chain. If the tx may have made
|
|
830
|
-
* it (`TX_REVERTED` or `TIMEOUT`), we leave the lock alone and
|
|
831
|
-
* surface `safeToRetry: false` so the caller doesn't double-spend.
|
|
832
|
-
*
|
|
833
|
-
* The gateway deliberately does NOT deduct the balance here. Deduction
|
|
834
|
-
* happens in the `PointIndexer` when the on-chain Mint event is observed,
|
|
835
|
-
* which is what makes the system crash-safe: if the gateway dies between
|
|
836
|
-
* broadcast and receipt, the indexer will still finalize the ledger.
|
|
837
|
-
*/
|
|
838
|
-
declare class MintingGateway {
|
|
839
|
-
private readonly ledger;
|
|
840
|
-
private readonly policy;
|
|
841
|
-
private readonly signer;
|
|
842
|
-
private readonly relayService;
|
|
843
|
-
private readonly now;
|
|
844
|
-
private readonly defaultLockBufferMs;
|
|
845
|
-
constructor(config: MintingGatewayConfig);
|
|
846
|
-
/**
|
|
847
|
-
* @deprecated Since 0.3.0 — will be renamed to `processMint()` once
|
|
848
|
-
* the SC team finalizes Relayer v2 ABI. The new flow drops the
|
|
849
|
-
* swap steps entirely (no more single-call mint+swap); users swap
|
|
850
|
-
* separately on PAFI Web. Kept here for v0.2.x consumers. Removed in 2.0.
|
|
851
|
-
*/
|
|
852
|
-
processMintAndCashOut(request: MintAndCashOutRequest): Promise<MintAndCashOutResponse>;
|
|
853
|
-
private computeLockDurationMs;
|
|
854
|
-
/**
|
|
855
|
-
* Map a RelayError to a MintingGatewayError, releasing the lock only
|
|
856
|
-
* when the tx definitely did not land. `TX_REVERTED` and `TIMEOUT`
|
|
857
|
-
* leave the lock in place because the tx may still be in the mempool
|
|
858
|
-
* or already mined — releasing would enable a double-spend on retry.
|
|
859
|
-
* Always throws.
|
|
860
|
-
*/
|
|
861
|
-
private handleRelayFailure;
|
|
862
|
-
/**
|
|
863
|
-
* Release a lock, swallowing any secondary error. We never want a lock
|
|
864
|
-
* release failure to mask the original error — the lock will auto-expire
|
|
865
|
-
* via TTL anyway.
|
|
866
|
-
*/
|
|
867
|
-
private releaseLockSafely;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
628
|
/** Decoded Transfer(from=0x0 → to) event used to finalize a mint. */
|
|
871
629
|
interface MintEvent {
|
|
872
630
|
/** Destination address (the user who received the minted points) */
|
|
@@ -1229,7 +987,6 @@ type PoolsProvider = (request: ApiPoolsRequest) => Promise<ApiPoolsResponse>;
|
|
|
1229
987
|
|
|
1230
988
|
interface IssuerApiHandlersConfig {
|
|
1231
989
|
authService: AuthService;
|
|
1232
|
-
gateway: MintingGateway;
|
|
1233
990
|
ledger: IPointLedger;
|
|
1234
991
|
/** Used by `handleUser` to read on-chain nonces and minter status. */
|
|
1235
992
|
provider: PublicClient;
|
|
@@ -1260,8 +1017,7 @@ interface IssuerApiHandlersConfig {
|
|
|
1260
1017
|
* Framework-agnostic HTTP handlers that match the endpoints a `PafiSDK`
|
|
1261
1018
|
* frontend expects to call. Issuers wrap these in Express / Fastify /
|
|
1262
1019
|
* Hono / whatever — the handlers take plain inputs and return plain
|
|
1263
|
-
* outputs, with `AuthError`
|
|
1264
|
-
* exceptions.
|
|
1020
|
+
* outputs, with `AuthError` surfaced as typed exceptions.
|
|
1265
1021
|
*
|
|
1266
1022
|
* Every protected handler takes a pre-verified `userAddress` as its first
|
|
1267
1023
|
* argument. The issuer's middleware wraps `authenticateRequest()` from
|
|
@@ -1270,7 +1026,6 @@ interface IssuerApiHandlersConfig {
|
|
|
1270
1026
|
*/
|
|
1271
1027
|
declare class IssuerApiHandlers {
|
|
1272
1028
|
private readonly authService;
|
|
1273
|
-
private readonly gateway;
|
|
1274
1029
|
private readonly ledger;
|
|
1275
1030
|
private readonly provider;
|
|
1276
1031
|
/**
|
|
@@ -1332,19 +1087,6 @@ declare class IssuerApiHandlers {
|
|
|
1332
1087
|
* mobile apps — no app store review needed.
|
|
1333
1088
|
*/
|
|
1334
1089
|
handleBuildConsentTypedData(userAddress: Address, request: ApiBuildConsentTypedDataRequest): Promise<ApiBuildConsentTypedDataResponse>;
|
|
1335
|
-
/**
|
|
1336
|
-
* `POST /claim-and-swap`
|
|
1337
|
-
*
|
|
1338
|
-
* @deprecated Since 0.3.0 — the single-call mint-then-swap flow is
|
|
1339
|
-
* retired in v1.4. Use the new `handleClaim()` (mint only) and let
|
|
1340
|
-
* the user swap separately on PAFI Web. See
|
|
1341
|
-
* [V1.4_V1.5_OVERVIEW.md §4] for the new scenario model. Will be
|
|
1342
|
-
* removed in 2.0.
|
|
1343
|
-
*
|
|
1344
|
-
* Legacy behavior: the terminal handler forwards the verified
|
|
1345
|
-
* consent to the MintingGateway, which runs the 11-step flow.
|
|
1346
|
-
*/
|
|
1347
|
-
handleClaimAndSwap(userAddress: Address, request: ApiClaimAndSwapRequest): Promise<ApiClaimAndSwapResponse>;
|
|
1348
1090
|
}
|
|
1349
1091
|
|
|
1350
1092
|
/**
|
|
@@ -1838,31 +1580,24 @@ declare class PafiBackendClient {
|
|
|
1838
1580
|
}
|
|
1839
1581
|
|
|
1840
1582
|
/**
|
|
1841
|
-
* Top-level configuration for `createIssuerService`.
|
|
1842
|
-
*
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1583
|
+
* Top-level configuration for `createIssuerService`.
|
|
1584
|
+
*
|
|
1585
|
+
* In v1.4 the SDK is HTTP-client-free: it signs EIP-712 messages, reads
|
|
1586
|
+
* on-chain state, builds unsigned UserOperations, and maintains the
|
|
1587
|
+
* off-chain ledger. It never broadcasts transactions — that's the
|
|
1588
|
+
* frontend's responsibility via Bundler + Paymaster.
|
|
1846
1589
|
*
|
|
1847
|
-
* **Multi-token (0.2.0):** Pass `pointTokenAddresses: Address[]` to
|
|
1590
|
+
* **Multi-token (0.2.0+):** Pass `pointTokenAddresses: Address[]` to
|
|
1848
1591
|
* support multiple PointTokens under a single issuer backend. Legacy
|
|
1849
1592
|
* `pointTokenAddress: Address` still works for single-token deployments.
|
|
1850
1593
|
* When both are provided, `pointTokenAddresses` takes precedence.
|
|
1851
1594
|
*/
|
|
1852
1595
|
interface IssuerServiceConfig {
|
|
1853
1596
|
chainId: number;
|
|
1854
|
-
/**
|
|
1855
|
-
* Address of the deployed PointToken. Legacy single-token shortcut;
|
|
1856
|
-
* prefer `pointTokenAddresses` for multi-token issuers.
|
|
1857
|
-
*/
|
|
1597
|
+
/** Legacy single-token shortcut; prefer `pointTokenAddresses`. */
|
|
1858
1598
|
pointTokenAddress?: Address;
|
|
1859
|
-
/**
|
|
1860
|
-
* All PointToken addresses this issuer supports. Takes precedence over
|
|
1861
|
-
* `pointTokenAddress`. Factory creates one `PointIndexer` per address.
|
|
1862
|
-
*/
|
|
1599
|
+
/** All PointToken addresses this issuer supports. */
|
|
1863
1600
|
pointTokenAddresses?: Address[];
|
|
1864
|
-
/** Address of the deployed Relay contract. */
|
|
1865
|
-
relayAddress: Address;
|
|
1866
1601
|
/**
|
|
1867
1602
|
* Full contract address bundle returned verbatim by `handleConfig` so
|
|
1868
1603
|
* the frontend SDK can pick them up.
|
|
@@ -1873,8 +1608,6 @@ interface IssuerServiceConfig {
|
|
|
1873
1608
|
* polling, and gas-price lookups. Must be pointed at the target chain.
|
|
1874
1609
|
*/
|
|
1875
1610
|
provider: PublicClient;
|
|
1876
|
-
/** Operator wallet — pays gas, receives the operator fee. */
|
|
1877
|
-
operatorWallet: OperatorWalletLike;
|
|
1878
1611
|
auth: {
|
|
1879
1612
|
jwtSecret: string;
|
|
1880
1613
|
/** SIWE-style login-message domain, e.g. `"app.example.com"`. */
|
|
@@ -1882,19 +1615,12 @@ interface IssuerServiceConfig {
|
|
|
1882
1615
|
/** Passed straight to `jose` (`"24h"`, `"7d"`, …). Default `"24h"`. */
|
|
1883
1616
|
jwtExpiresIn?: string;
|
|
1884
1617
|
};
|
|
1885
|
-
/**
|
|
1886
|
-
* Issuer signer. No default — production issuers MUST plug in an
|
|
1887
|
-
* HSM/KMS-backed implementation. For local development use
|
|
1888
|
-
* `PrivateKeySigner` directly.
|
|
1889
|
-
*/
|
|
1890
|
-
signer: IIssuerSigner;
|
|
1891
1618
|
ledger?: IPointLedger;
|
|
1892
1619
|
policy?: IPolicyEngine;
|
|
1893
1620
|
sessionStore?: ISessionStore;
|
|
1894
1621
|
/**
|
|
1895
1622
|
* Fee management config. If omitted the `handleGasFee` endpoint will
|
|
1896
|
-
* throw "not configured" at request time.
|
|
1897
|
-
* to opt in — `provider` is inherited from the outer config.
|
|
1623
|
+
* throw "not configured" at request time.
|
|
1898
1624
|
*/
|
|
1899
1625
|
fee?: Omit<FeeManagerConfig, "provider">;
|
|
1900
1626
|
/**
|
|
@@ -1914,32 +1640,18 @@ interface IssuerServiceConfig {
|
|
|
1914
1640
|
*/
|
|
1915
1641
|
autoStart?: boolean;
|
|
1916
1642
|
};
|
|
1917
|
-
relay?: {
|
|
1918
|
-
simulateBeforeSubmit?: boolean;
|
|
1919
|
-
confirmationTimeoutMs?: number;
|
|
1920
|
-
};
|
|
1921
|
-
gateway?: {
|
|
1922
|
-
/** Extra lock TTL buffer beyond consent deadline. Default 60_000 ms. */
|
|
1923
|
-
defaultLockBufferMs?: number;
|
|
1924
|
-
};
|
|
1925
1643
|
}
|
|
1926
1644
|
interface IssuerService {
|
|
1927
1645
|
authService: AuthService;
|
|
1928
1646
|
sessionStore: ISessionStore;
|
|
1929
1647
|
ledger: IPointLedger;
|
|
1930
1648
|
policy: IPolicyEngine;
|
|
1931
|
-
signer: IIssuerSigner;
|
|
1932
1649
|
relayService: RelayService;
|
|
1933
1650
|
feeManager: FeeManager | undefined;
|
|
1934
|
-
|
|
1935
|
-
/**
|
|
1936
|
-
* All indexers keyed by PointToken address. For multi-token issuers there
|
|
1937
|
-
* is one per configured token. Single-token issuers will find one entry.
|
|
1938
|
-
*/
|
|
1651
|
+
/** All indexers keyed by PointToken address. */
|
|
1939
1652
|
indexers: Map<Address, PointIndexer>;
|
|
1940
1653
|
/**
|
|
1941
|
-
* First indexer. Kept for backward compat with 0.1.x callers
|
|
1942
|
-
* expected `service.indexer` to be a single instance.
|
|
1654
|
+
* First indexer. Kept for backward compat with 0.1.x callers.
|
|
1943
1655
|
* @deprecated use `indexers.get(tokenAddress)` for multi-token.
|
|
1944
1656
|
*/
|
|
1945
1657
|
indexer: PointIndexer;
|
|
@@ -1947,8 +1659,6 @@ interface IssuerService {
|
|
|
1947
1659
|
}
|
|
1948
1660
|
/**
|
|
1949
1661
|
* Wire a fully-functional issuer service from a single config object.
|
|
1950
|
-
* Returns every constructed collaborator so the caller can also use the
|
|
1951
|
-
* indexer or relay service directly outside the HTTP layer.
|
|
1952
1662
|
*
|
|
1953
1663
|
* Defaults:
|
|
1954
1664
|
* - `ledger` → `MemoryPointLedger`
|
|
@@ -1958,12 +1668,11 @@ interface IssuerService {
|
|
|
1958
1668
|
* - `poolsProvider` → undefined (handlePools throws until configured)
|
|
1959
1669
|
* - `indexer.autoStart` → false
|
|
1960
1670
|
*
|
|
1961
|
-
* Throws synchronously if any required field
|
|
1962
|
-
* `operatorWallet`, `auth.jwtSecret`, at least one point token) is missing.
|
|
1671
|
+
* Throws synchronously if any required field is missing.
|
|
1963
1672
|
*/
|
|
1964
1673
|
declare function createIssuerService(config: IssuerServiceConfig): IssuerService;
|
|
1965
1674
|
|
|
1966
1675
|
/** SDK package version — bumped on every release */
|
|
1967
1676
|
declare const PAFI_ISSUER_SDK_VERSION = "0.1.0";
|
|
1968
1677
|
|
|
1969
|
-
export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IIssuerSigner, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, MemoryPointLedger, MemorySessionStore, type MemorySessionStoreOptions, type
|
|
1678
|
+
export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiConfigResponse, type ApiGasFeeResponse, type ApiLoginRequest, type ApiLoginResponse, type ApiNonceResponse, type ApiPoolsRequest, type ApiPoolsResponse, type ApiUserRequest, type ApiUserResponse, type AuthContext, AuthError, type AuthErrorCode, AuthService, type AuthServiceConfig, BalanceAggregator, type BalanceAggregatorConfig, type BurnEvent, BurnIndexer, type BurnIndexerConfig, type CombinedBalance, DefaultPolicyEngine, type DefaultPolicyEngineOptions, FeeManager, type FeeManagerConfig, type IIndexerCursorStore, type IIssuerSigner, type IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, MemoryPointLedger, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintingStatus, NonceManager, PAFI_ISSUER_SDK_VERSION, PTRedeemError, PTRedeemHandler, type PTRedeemHandlerConfig, type PTRedeemRequest, type PTRedeemResponse, PafiBackendClient, type PafiBackendConfig, PafiBackendError, type PafiBackendErrorCode, PointIndexer, type PointIndexerConfig, type PolicyDecision, type PolicyEvalRequest, type PoolsProvider, type PrepareBurnDirectParams, type PrepareBurnParams, type PrepareBurnWithSigParams, type PrepareMintParams, PrivateKeySigner, type PrivateKeySignerOptions, RelayError, type RelayErrorCode, RelayService, type Session, type SponsorshipRequest, type SponsorshipResponse, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider };
|