@pafi-dev/issuer 0.5.35 → 0.5.36
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.map +1 -1
- package/dist/index.d.cts +98 -89
- package/dist/index.d.ts +98 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1847,98 +1847,17 @@ declare function handleMobileSubmit(params: HandleMobileSubmitParams): Promise<{
|
|
|
1847
1847
|
userOpHash: Hex;
|
|
1848
1848
|
}>;
|
|
1849
1849
|
|
|
1850
|
-
|
|
1851
|
-
issuerAddress: Address;
|
|
1852
|
-
signerAddress: Address;
|
|
1853
|
-
name: string;
|
|
1854
|
-
symbol: string;
|
|
1855
|
-
declaredTotalSupply: bigint;
|
|
1856
|
-
capBasisPoints: number;
|
|
1857
|
-
active: boolean;
|
|
1858
|
-
pointToken: Address;
|
|
1859
|
-
mintingOracle: Address;
|
|
1860
|
-
}
|
|
1861
|
-
interface PreValidateMintResult {
|
|
1862
|
-
/** Registry record read at pre-validation time. */
|
|
1863
|
-
issuer: IssuerRegistryRecord;
|
|
1864
|
-
/** Current on-chain PointToken.totalSupply(). */
|
|
1865
|
-
totalSupply: bigint;
|
|
1866
|
-
/** declaredTotalSupply × capBasisPoints / 10000. */
|
|
1867
|
-
hardCap: bigint;
|
|
1868
|
-
/** hardCap − totalSupply (clamped to 0). */
|
|
1869
|
-
remaining: bigint;
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Thrown by `IssuerStateValidator.preValidateMint()`.
|
|
1873
|
-
* `code` maps 1:1 to the HTTP error the issuer API surfaces to clients.
|
|
1874
|
-
*/
|
|
1875
|
-
declare class IssuerStateError extends Error {
|
|
1876
|
-
readonly code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED";
|
|
1877
|
-
readonly details?: Record<string, unknown> | undefined;
|
|
1878
|
-
constructor(code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED", message: string, details?: Record<string, unknown> | undefined);
|
|
1879
|
-
}
|
|
1850
|
+
type DecodedCall$2 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1880
1851
|
|
|
1881
1852
|
/**
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
* off-chain lets issuers fail fast with a clear error rather than
|
|
1887
|
-
* wasting gas on a revert.
|
|
1888
|
-
*
|
|
1889
|
-
* Caching:
|
|
1890
|
-
* - `PointToken.issuer()` — memoized for the process lifetime (immutable)
|
|
1891
|
-
* - Full state (registry + totalSupply) — 30s TTL per PointToken
|
|
1892
|
-
* - Burst calls while a fetch is in-flight share the same Promise
|
|
1893
|
-
* (thundering-herd protection)
|
|
1894
|
-
*
|
|
1895
|
-
* Usage in NestJS: wrap this in an `@Injectable()` service; pass
|
|
1896
|
-
* `PublicClient` and `registryAddress` from your DI container.
|
|
1853
|
+
* Structural shape — accepts both the raw `IssuerStateValidator` from
|
|
1854
|
+
* `@pafi-dev/issuer/issuer-state` and any host-framework wrapper (e.g.
|
|
1855
|
+
* a NestJS Injectable that delegates to it). Only `preValidateMint`
|
|
1856
|
+
* is needed on this surface.
|
|
1897
1857
|
*/
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
private readonly registryAddress;
|
|
1901
|
-
private readonly pointTokenIssuerCache;
|
|
1902
|
-
private readonly stateCache;
|
|
1903
|
-
private readonly inflight;
|
|
1904
|
-
constructor(provider: PublicClient, registryAddress: Address);
|
|
1905
|
-
/**
|
|
1906
|
-
* Convenience factory — reads `registryAddress` from the SDK
|
|
1907
|
-
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
1908
|
-
*/
|
|
1909
|
-
static forChain(provider: PublicClient, chainId: number): IssuerStateValidator;
|
|
1910
|
-
/**
|
|
1911
|
-
* Invalidate cached state for one PointToken, or everything if omitted.
|
|
1912
|
-
* Call after admin txs that change registry or cap settings.
|
|
1913
|
-
*/
|
|
1914
|
-
invalidate(pointToken?: Address): void;
|
|
1915
|
-
/**
|
|
1916
|
-
* Resolve `PointToken.issuer()` once per token and memoize.
|
|
1917
|
-
* The issuer field is set at `initialize()` and never changes.
|
|
1918
|
-
*/
|
|
1919
|
-
getIssuerAddressForPointToken(pointToken: Address): Promise<Address>;
|
|
1920
|
-
/**
|
|
1921
|
-
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
1922
|
-
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
1923
|
-
*/
|
|
1924
|
-
getIssuerState(pointToken: Address): Promise<PreValidateMintResult>;
|
|
1925
|
-
/**
|
|
1926
|
-
* Validate that `amount` PT can be minted on `pointToken` right now.
|
|
1927
|
-
*
|
|
1928
|
-
* Throws `IssuerStateError` with:
|
|
1929
|
-
* - `ISSUER_NOT_REGISTERED` — registry has no record for this issuer
|
|
1930
|
-
* - `ISSUER_INACTIVE` — issuer.active is false
|
|
1931
|
-
* - `MINT_CAP_EXCEEDED` — totalSupply + amount would exceed hardCap
|
|
1932
|
-
*
|
|
1933
|
-
* Returns the fetched state on success so callers can log without a
|
|
1934
|
-
* second RPC round-trip.
|
|
1935
|
-
*/
|
|
1936
|
-
preValidateMint(pointToken: Address, amount: bigint): Promise<PreValidateMintResult>;
|
|
1937
|
-
private fetchIssuerState;
|
|
1858
|
+
interface IssuerStateValidatorLike {
|
|
1859
|
+
preValidateMint(pointToken: Address, amount: bigint): Promise<unknown>;
|
|
1938
1860
|
}
|
|
1939
|
-
|
|
1940
|
-
type DecodedCall$2 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1941
|
-
|
|
1942
1861
|
/**
|
|
1943
1862
|
* v1.4 sig-gated mint handler — mirrors `PTRedeemHandler` on the mint side.
|
|
1944
1863
|
*
|
|
@@ -1971,7 +1890,7 @@ interface PTClaimHandlerConfig {
|
|
|
1971
1890
|
/** Optional — when wired, used to estimate the PT gas-reimbursement fee. */
|
|
1972
1891
|
feeService?: FeeManager;
|
|
1973
1892
|
/** Optional — pre-validates issuer status + cap before locking balance. */
|
|
1974
|
-
issuerStateValidator?:
|
|
1893
|
+
issuerStateValidator?: IssuerStateValidatorLike;
|
|
1975
1894
|
/** How long the off-chain balance lock survives if the mint never lands. Default 15 min. */
|
|
1976
1895
|
lockDurationMs?: number;
|
|
1977
1896
|
/** How far ahead of `now` to set the MintRequest deadline. Default 15 min. */
|
|
@@ -2581,6 +2500,96 @@ interface IssuerService {
|
|
|
2581
2500
|
*/
|
|
2582
2501
|
declare function createIssuerService(config: IssuerServiceConfig): IssuerService;
|
|
2583
2502
|
|
|
2503
|
+
interface IssuerRegistryRecord {
|
|
2504
|
+
issuerAddress: Address;
|
|
2505
|
+
signerAddress: Address;
|
|
2506
|
+
name: string;
|
|
2507
|
+
symbol: string;
|
|
2508
|
+
declaredTotalSupply: bigint;
|
|
2509
|
+
capBasisPoints: number;
|
|
2510
|
+
active: boolean;
|
|
2511
|
+
pointToken: Address;
|
|
2512
|
+
mintingOracle: Address;
|
|
2513
|
+
}
|
|
2514
|
+
interface PreValidateMintResult {
|
|
2515
|
+
/** Registry record read at pre-validation time. */
|
|
2516
|
+
issuer: IssuerRegistryRecord;
|
|
2517
|
+
/** Current on-chain PointToken.totalSupply(). */
|
|
2518
|
+
totalSupply: bigint;
|
|
2519
|
+
/** declaredTotalSupply × capBasisPoints / 10000. */
|
|
2520
|
+
hardCap: bigint;
|
|
2521
|
+
/** hardCap − totalSupply (clamped to 0). */
|
|
2522
|
+
remaining: bigint;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Thrown by `IssuerStateValidator.preValidateMint()`.
|
|
2526
|
+
* `code` maps 1:1 to the HTTP error the issuer API surfaces to clients.
|
|
2527
|
+
*/
|
|
2528
|
+
declare class IssuerStateError extends Error {
|
|
2529
|
+
readonly code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED";
|
|
2530
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
2531
|
+
constructor(code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED", message: string, details?: Record<string, unknown> | undefined);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Pure (framework-agnostic) validator for issuer state.
|
|
2536
|
+
*
|
|
2537
|
+
* Reads IssuerRegistry + PointToken on-chain state and pre-validates
|
|
2538
|
+
* mint requests before the user submits a UserOp. Catching these
|
|
2539
|
+
* off-chain lets issuers fail fast with a clear error rather than
|
|
2540
|
+
* wasting gas on a revert.
|
|
2541
|
+
*
|
|
2542
|
+
* Caching:
|
|
2543
|
+
* - `PointToken.issuer()` — memoized for the process lifetime (immutable)
|
|
2544
|
+
* - Full state (registry + totalSupply) — 30s TTL per PointToken
|
|
2545
|
+
* - Burst calls while a fetch is in-flight share the same Promise
|
|
2546
|
+
* (thundering-herd protection)
|
|
2547
|
+
*
|
|
2548
|
+
* Usage in NestJS: wrap this in an `@Injectable()` service; pass
|
|
2549
|
+
* `PublicClient` and `registryAddress` from your DI container.
|
|
2550
|
+
*/
|
|
2551
|
+
declare class IssuerStateValidator {
|
|
2552
|
+
private readonly provider;
|
|
2553
|
+
private readonly registryAddress;
|
|
2554
|
+
private readonly pointTokenIssuerCache;
|
|
2555
|
+
private readonly stateCache;
|
|
2556
|
+
private readonly inflight;
|
|
2557
|
+
constructor(provider: PublicClient, registryAddress: Address);
|
|
2558
|
+
/**
|
|
2559
|
+
* Convenience factory — reads `registryAddress` from the SDK
|
|
2560
|
+
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
2561
|
+
*/
|
|
2562
|
+
static forChain(provider: PublicClient, chainId: number): IssuerStateValidator;
|
|
2563
|
+
/**
|
|
2564
|
+
* Invalidate cached state for one PointToken, or everything if omitted.
|
|
2565
|
+
* Call after admin txs that change registry or cap settings.
|
|
2566
|
+
*/
|
|
2567
|
+
invalidate(pointToken?: Address): void;
|
|
2568
|
+
/**
|
|
2569
|
+
* Resolve `PointToken.issuer()` once per token and memoize.
|
|
2570
|
+
* The issuer field is set at `initialize()` and never changes.
|
|
2571
|
+
*/
|
|
2572
|
+
getIssuerAddressForPointToken(pointToken: Address): Promise<Address>;
|
|
2573
|
+
/**
|
|
2574
|
+
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
2575
|
+
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
2576
|
+
*/
|
|
2577
|
+
getIssuerState(pointToken: Address): Promise<PreValidateMintResult>;
|
|
2578
|
+
/**
|
|
2579
|
+
* Validate that `amount` PT can be minted on `pointToken` right now.
|
|
2580
|
+
*
|
|
2581
|
+
* Throws `IssuerStateError` with:
|
|
2582
|
+
* - `ISSUER_NOT_REGISTERED` — registry has no record for this issuer
|
|
2583
|
+
* - `ISSUER_INACTIVE` — issuer.active is false
|
|
2584
|
+
* - `MINT_CAP_EXCEEDED` — totalSupply + amount would exceed hardCap
|
|
2585
|
+
*
|
|
2586
|
+
* Returns the fetched state on success so callers can log without a
|
|
2587
|
+
* second RPC round-trip.
|
|
2588
|
+
*/
|
|
2589
|
+
preValidateMint(pointToken: Address, amount: bigint): Promise<PreValidateMintResult>;
|
|
2590
|
+
private fetchIssuerState;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2584
2593
|
/** SDK package version — bumped on every release */
|
|
2585
2594
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
2586
2595
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1847,98 +1847,17 @@ declare function handleMobileSubmit(params: HandleMobileSubmitParams): Promise<{
|
|
|
1847
1847
|
userOpHash: Hex;
|
|
1848
1848
|
}>;
|
|
1849
1849
|
|
|
1850
|
-
|
|
1851
|
-
issuerAddress: Address;
|
|
1852
|
-
signerAddress: Address;
|
|
1853
|
-
name: string;
|
|
1854
|
-
symbol: string;
|
|
1855
|
-
declaredTotalSupply: bigint;
|
|
1856
|
-
capBasisPoints: number;
|
|
1857
|
-
active: boolean;
|
|
1858
|
-
pointToken: Address;
|
|
1859
|
-
mintingOracle: Address;
|
|
1860
|
-
}
|
|
1861
|
-
interface PreValidateMintResult {
|
|
1862
|
-
/** Registry record read at pre-validation time. */
|
|
1863
|
-
issuer: IssuerRegistryRecord;
|
|
1864
|
-
/** Current on-chain PointToken.totalSupply(). */
|
|
1865
|
-
totalSupply: bigint;
|
|
1866
|
-
/** declaredTotalSupply × capBasisPoints / 10000. */
|
|
1867
|
-
hardCap: bigint;
|
|
1868
|
-
/** hardCap − totalSupply (clamped to 0). */
|
|
1869
|
-
remaining: bigint;
|
|
1870
|
-
}
|
|
1871
|
-
/**
|
|
1872
|
-
* Thrown by `IssuerStateValidator.preValidateMint()`.
|
|
1873
|
-
* `code` maps 1:1 to the HTTP error the issuer API surfaces to clients.
|
|
1874
|
-
*/
|
|
1875
|
-
declare class IssuerStateError extends Error {
|
|
1876
|
-
readonly code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED";
|
|
1877
|
-
readonly details?: Record<string, unknown> | undefined;
|
|
1878
|
-
constructor(code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED", message: string, details?: Record<string, unknown> | undefined);
|
|
1879
|
-
}
|
|
1850
|
+
type DecodedCall$2 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1880
1851
|
|
|
1881
1852
|
/**
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1886
|
-
* off-chain lets issuers fail fast with a clear error rather than
|
|
1887
|
-
* wasting gas on a revert.
|
|
1888
|
-
*
|
|
1889
|
-
* Caching:
|
|
1890
|
-
* - `PointToken.issuer()` — memoized for the process lifetime (immutable)
|
|
1891
|
-
* - Full state (registry + totalSupply) — 30s TTL per PointToken
|
|
1892
|
-
* - Burst calls while a fetch is in-flight share the same Promise
|
|
1893
|
-
* (thundering-herd protection)
|
|
1894
|
-
*
|
|
1895
|
-
* Usage in NestJS: wrap this in an `@Injectable()` service; pass
|
|
1896
|
-
* `PublicClient` and `registryAddress` from your DI container.
|
|
1853
|
+
* Structural shape — accepts both the raw `IssuerStateValidator` from
|
|
1854
|
+
* `@pafi-dev/issuer/issuer-state` and any host-framework wrapper (e.g.
|
|
1855
|
+
* a NestJS Injectable that delegates to it). Only `preValidateMint`
|
|
1856
|
+
* is needed on this surface.
|
|
1897
1857
|
*/
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
private readonly registryAddress;
|
|
1901
|
-
private readonly pointTokenIssuerCache;
|
|
1902
|
-
private readonly stateCache;
|
|
1903
|
-
private readonly inflight;
|
|
1904
|
-
constructor(provider: PublicClient, registryAddress: Address);
|
|
1905
|
-
/**
|
|
1906
|
-
* Convenience factory — reads `registryAddress` from the SDK
|
|
1907
|
-
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
1908
|
-
*/
|
|
1909
|
-
static forChain(provider: PublicClient, chainId: number): IssuerStateValidator;
|
|
1910
|
-
/**
|
|
1911
|
-
* Invalidate cached state for one PointToken, or everything if omitted.
|
|
1912
|
-
* Call after admin txs that change registry or cap settings.
|
|
1913
|
-
*/
|
|
1914
|
-
invalidate(pointToken?: Address): void;
|
|
1915
|
-
/**
|
|
1916
|
-
* Resolve `PointToken.issuer()` once per token and memoize.
|
|
1917
|
-
* The issuer field is set at `initialize()` and never changes.
|
|
1918
|
-
*/
|
|
1919
|
-
getIssuerAddressForPointToken(pointToken: Address): Promise<Address>;
|
|
1920
|
-
/**
|
|
1921
|
-
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
1922
|
-
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
1923
|
-
*/
|
|
1924
|
-
getIssuerState(pointToken: Address): Promise<PreValidateMintResult>;
|
|
1925
|
-
/**
|
|
1926
|
-
* Validate that `amount` PT can be minted on `pointToken` right now.
|
|
1927
|
-
*
|
|
1928
|
-
* Throws `IssuerStateError` with:
|
|
1929
|
-
* - `ISSUER_NOT_REGISTERED` — registry has no record for this issuer
|
|
1930
|
-
* - `ISSUER_INACTIVE` — issuer.active is false
|
|
1931
|
-
* - `MINT_CAP_EXCEEDED` — totalSupply + amount would exceed hardCap
|
|
1932
|
-
*
|
|
1933
|
-
* Returns the fetched state on success so callers can log without a
|
|
1934
|
-
* second RPC round-trip.
|
|
1935
|
-
*/
|
|
1936
|
-
preValidateMint(pointToken: Address, amount: bigint): Promise<PreValidateMintResult>;
|
|
1937
|
-
private fetchIssuerState;
|
|
1858
|
+
interface IssuerStateValidatorLike {
|
|
1859
|
+
preValidateMint(pointToken: Address, amount: bigint): Promise<unknown>;
|
|
1938
1860
|
}
|
|
1939
|
-
|
|
1940
|
-
type DecodedCall$2 = ReturnType<typeof decodeBatchExecuteCalls>[number];
|
|
1941
|
-
|
|
1942
1861
|
/**
|
|
1943
1862
|
* v1.4 sig-gated mint handler — mirrors `PTRedeemHandler` on the mint side.
|
|
1944
1863
|
*
|
|
@@ -1971,7 +1890,7 @@ interface PTClaimHandlerConfig {
|
|
|
1971
1890
|
/** Optional — when wired, used to estimate the PT gas-reimbursement fee. */
|
|
1972
1891
|
feeService?: FeeManager;
|
|
1973
1892
|
/** Optional — pre-validates issuer status + cap before locking balance. */
|
|
1974
|
-
issuerStateValidator?:
|
|
1893
|
+
issuerStateValidator?: IssuerStateValidatorLike;
|
|
1975
1894
|
/** How long the off-chain balance lock survives if the mint never lands. Default 15 min. */
|
|
1976
1895
|
lockDurationMs?: number;
|
|
1977
1896
|
/** How far ahead of `now` to set the MintRequest deadline. Default 15 min. */
|
|
@@ -2581,6 +2500,96 @@ interface IssuerService {
|
|
|
2581
2500
|
*/
|
|
2582
2501
|
declare function createIssuerService(config: IssuerServiceConfig): IssuerService;
|
|
2583
2502
|
|
|
2503
|
+
interface IssuerRegistryRecord {
|
|
2504
|
+
issuerAddress: Address;
|
|
2505
|
+
signerAddress: Address;
|
|
2506
|
+
name: string;
|
|
2507
|
+
symbol: string;
|
|
2508
|
+
declaredTotalSupply: bigint;
|
|
2509
|
+
capBasisPoints: number;
|
|
2510
|
+
active: boolean;
|
|
2511
|
+
pointToken: Address;
|
|
2512
|
+
mintingOracle: Address;
|
|
2513
|
+
}
|
|
2514
|
+
interface PreValidateMintResult {
|
|
2515
|
+
/** Registry record read at pre-validation time. */
|
|
2516
|
+
issuer: IssuerRegistryRecord;
|
|
2517
|
+
/** Current on-chain PointToken.totalSupply(). */
|
|
2518
|
+
totalSupply: bigint;
|
|
2519
|
+
/** declaredTotalSupply × capBasisPoints / 10000. */
|
|
2520
|
+
hardCap: bigint;
|
|
2521
|
+
/** hardCap − totalSupply (clamped to 0). */
|
|
2522
|
+
remaining: bigint;
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Thrown by `IssuerStateValidator.preValidateMint()`.
|
|
2526
|
+
* `code` maps 1:1 to the HTTP error the issuer API surfaces to clients.
|
|
2527
|
+
*/
|
|
2528
|
+
declare class IssuerStateError extends Error {
|
|
2529
|
+
readonly code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED";
|
|
2530
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
2531
|
+
constructor(code: "ISSUER_NOT_REGISTERED" | "ISSUER_INACTIVE" | "MINT_CAP_EXCEEDED", message: string, details?: Record<string, unknown> | undefined);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Pure (framework-agnostic) validator for issuer state.
|
|
2536
|
+
*
|
|
2537
|
+
* Reads IssuerRegistry + PointToken on-chain state and pre-validates
|
|
2538
|
+
* mint requests before the user submits a UserOp. Catching these
|
|
2539
|
+
* off-chain lets issuers fail fast with a clear error rather than
|
|
2540
|
+
* wasting gas on a revert.
|
|
2541
|
+
*
|
|
2542
|
+
* Caching:
|
|
2543
|
+
* - `PointToken.issuer()` — memoized for the process lifetime (immutable)
|
|
2544
|
+
* - Full state (registry + totalSupply) — 30s TTL per PointToken
|
|
2545
|
+
* - Burst calls while a fetch is in-flight share the same Promise
|
|
2546
|
+
* (thundering-herd protection)
|
|
2547
|
+
*
|
|
2548
|
+
* Usage in NestJS: wrap this in an `@Injectable()` service; pass
|
|
2549
|
+
* `PublicClient` and `registryAddress` from your DI container.
|
|
2550
|
+
*/
|
|
2551
|
+
declare class IssuerStateValidator {
|
|
2552
|
+
private readonly provider;
|
|
2553
|
+
private readonly registryAddress;
|
|
2554
|
+
private readonly pointTokenIssuerCache;
|
|
2555
|
+
private readonly stateCache;
|
|
2556
|
+
private readonly inflight;
|
|
2557
|
+
constructor(provider: PublicClient, registryAddress: Address);
|
|
2558
|
+
/**
|
|
2559
|
+
* Convenience factory — reads `registryAddress` from the SDK
|
|
2560
|
+
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
2561
|
+
*/
|
|
2562
|
+
static forChain(provider: PublicClient, chainId: number): IssuerStateValidator;
|
|
2563
|
+
/**
|
|
2564
|
+
* Invalidate cached state for one PointToken, or everything if omitted.
|
|
2565
|
+
* Call after admin txs that change registry or cap settings.
|
|
2566
|
+
*/
|
|
2567
|
+
invalidate(pointToken?: Address): void;
|
|
2568
|
+
/**
|
|
2569
|
+
* Resolve `PointToken.issuer()` once per token and memoize.
|
|
2570
|
+
* The issuer field is set at `initialize()` and never changes.
|
|
2571
|
+
*/
|
|
2572
|
+
getIssuerAddressForPointToken(pointToken: Address): Promise<Address>;
|
|
2573
|
+
/**
|
|
2574
|
+
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
2575
|
+
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
2576
|
+
*/
|
|
2577
|
+
getIssuerState(pointToken: Address): Promise<PreValidateMintResult>;
|
|
2578
|
+
/**
|
|
2579
|
+
* Validate that `amount` PT can be minted on `pointToken` right now.
|
|
2580
|
+
*
|
|
2581
|
+
* Throws `IssuerStateError` with:
|
|
2582
|
+
* - `ISSUER_NOT_REGISTERED` — registry has no record for this issuer
|
|
2583
|
+
* - `ISSUER_INACTIVE` — issuer.active is false
|
|
2584
|
+
* - `MINT_CAP_EXCEEDED` — totalSupply + amount would exceed hardCap
|
|
2585
|
+
*
|
|
2586
|
+
* Returns the fetched state on success so callers can log without a
|
|
2587
|
+
* second RPC round-trip.
|
|
2588
|
+
*/
|
|
2589
|
+
preValidateMint(pointToken: Address, amount: bigint): Promise<PreValidateMintResult>;
|
|
2590
|
+
private fetchIssuerState;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2584
2593
|
/** SDK package version — bumped on every release */
|
|
2585
2594
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
2586
2595
|
|