@pafi-dev/issuer 0.5.1 → 0.5.2

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
@@ -1222,15 +1222,18 @@ declare class TopUpRedemptionHandler {
1222
1222
  handle(request: TopUpRedemptionRequest): Promise<TopUpRedemptionResponse>;
1223
1223
  }
1224
1224
 
1225
+ /** PAFI-hosted subgraph endpoint. Used as the default for all subgraph helpers. */
1226
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1225
1227
  /**
1226
1228
  * Config for `createSubgraphPoolsProvider`.
1227
1229
  */
1228
1230
  interface SubgraphPoolsProviderConfig {
1229
1231
  /**
1230
- * Fully qualified subgraph GraphQL endpoint. Example:
1231
- * `https://graph.pacificfinance.org/subgraphs/name/pafi`
1232
+ * Fully qualified subgraph GraphQL endpoint.
1233
+ * Defaults to the PAFI-hosted subgraph (`PAFI_SUBGRAPH_URL`).
1234
+ * Override only when pointing at a staging or custom deployment.
1232
1235
  */
1233
- subgraphUrl: string;
1236
+ subgraphUrl?: string;
1234
1237
  /**
1235
1238
  * Cache TTL in milliseconds. Pool discovery is near-static — a 30s
1236
1239
  * cache removes subgraph load without meaningfully delaying UX.
@@ -1278,17 +1281,18 @@ interface SubgraphPoolsProviderConfig {
1278
1281
  * });
1279
1282
  * ```
1280
1283
  */
1281
- declare function createSubgraphPoolsProvider(config: SubgraphPoolsProviderConfig): PoolsProvider;
1284
+ declare function createSubgraphPoolsProvider(config?: SubgraphPoolsProviderConfig): PoolsProvider;
1282
1285
 
1283
1286
  /**
1284
1287
  * Config for `createSubgraphNativeUsdtQuoter`.
1285
1288
  */
1286
1289
  interface SubgraphNativeUsdtQuoterConfig {
1287
1290
  /**
1288
- * Fully qualified subgraph GraphQL endpoint. Same URL used by
1289
- * `createSubgraphPoolsProvider`.
1291
+ * Fully qualified subgraph GraphQL endpoint.
1292
+ * Defaults to the PAFI-hosted subgraph (`PAFI_SUBGRAPH_URL`).
1293
+ * Override only when pointing at a staging or custom deployment.
1290
1294
  */
1291
- subgraphUrl: string;
1295
+ subgraphUrl?: string;
1292
1296
  /**
1293
1297
  * Decimals of the USDT token. Defaults to 6 (standard USDT/USDC on
1294
1298
  * Base, Ethereum, Polygon). Override for chains where USDT uses a
@@ -1349,7 +1353,7 @@ interface SubgraphNativeUsdtQuoterConfig {
1349
1353
  * });
1350
1354
  * ```
1351
1355
  */
1352
- declare function createSubgraphNativeUsdtQuoter(config: SubgraphNativeUsdtQuoterConfig): (amountNative: bigint) => Promise<bigint>;
1356
+ declare function createSubgraphNativeUsdtQuoter(config?: SubgraphNativeUsdtQuoterConfig): (amountNative: bigint) => Promise<bigint>;
1353
1357
 
1354
1358
  /**
1355
1359
  * Combined off-chain + on-chain balance for a single user / token pair.
@@ -1580,4 +1584,4 @@ declare function createIssuerService(config: IssuerServiceConfig): IssuerService
1580
1584
  /** SDK package version — bumped on every release */
1581
1585
  declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
1582
1586
 
1583
- export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiClaimRequest, type ApiClaimResponse, 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 IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, 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, RelayError, type RelayErrorCode, RelayService, type RetryConfig, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider };
1587
+ export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiClaimRequest, type ApiClaimResponse, 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 IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintingStatus, NonceManager, PAFI_ISSUER_SDK_VERSION, PAFI_SUBGRAPH_URL, 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, RelayError, type RelayErrorCode, RelayService, type RetryConfig, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider };
package/dist/index.d.ts CHANGED
@@ -1222,15 +1222,18 @@ declare class TopUpRedemptionHandler {
1222
1222
  handle(request: TopUpRedemptionRequest): Promise<TopUpRedemptionResponse>;
1223
1223
  }
1224
1224
 
1225
+ /** PAFI-hosted subgraph endpoint. Used as the default for all subgraph helpers. */
1226
+ declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1225
1227
  /**
1226
1228
  * Config for `createSubgraphPoolsProvider`.
1227
1229
  */
1228
1230
  interface SubgraphPoolsProviderConfig {
1229
1231
  /**
1230
- * Fully qualified subgraph GraphQL endpoint. Example:
1231
- * `https://graph.pacificfinance.org/subgraphs/name/pafi`
1232
+ * Fully qualified subgraph GraphQL endpoint.
1233
+ * Defaults to the PAFI-hosted subgraph (`PAFI_SUBGRAPH_URL`).
1234
+ * Override only when pointing at a staging or custom deployment.
1232
1235
  */
1233
- subgraphUrl: string;
1236
+ subgraphUrl?: string;
1234
1237
  /**
1235
1238
  * Cache TTL in milliseconds. Pool discovery is near-static — a 30s
1236
1239
  * cache removes subgraph load without meaningfully delaying UX.
@@ -1278,17 +1281,18 @@ interface SubgraphPoolsProviderConfig {
1278
1281
  * });
1279
1282
  * ```
1280
1283
  */
1281
- declare function createSubgraphPoolsProvider(config: SubgraphPoolsProviderConfig): PoolsProvider;
1284
+ declare function createSubgraphPoolsProvider(config?: SubgraphPoolsProviderConfig): PoolsProvider;
1282
1285
 
1283
1286
  /**
1284
1287
  * Config for `createSubgraphNativeUsdtQuoter`.
1285
1288
  */
1286
1289
  interface SubgraphNativeUsdtQuoterConfig {
1287
1290
  /**
1288
- * Fully qualified subgraph GraphQL endpoint. Same URL used by
1289
- * `createSubgraphPoolsProvider`.
1291
+ * Fully qualified subgraph GraphQL endpoint.
1292
+ * Defaults to the PAFI-hosted subgraph (`PAFI_SUBGRAPH_URL`).
1293
+ * Override only when pointing at a staging or custom deployment.
1290
1294
  */
1291
- subgraphUrl: string;
1295
+ subgraphUrl?: string;
1292
1296
  /**
1293
1297
  * Decimals of the USDT token. Defaults to 6 (standard USDT/USDC on
1294
1298
  * Base, Ethereum, Polygon). Override for chains where USDT uses a
@@ -1349,7 +1353,7 @@ interface SubgraphNativeUsdtQuoterConfig {
1349
1353
  * });
1350
1354
  * ```
1351
1355
  */
1352
- declare function createSubgraphNativeUsdtQuoter(config: SubgraphNativeUsdtQuoterConfig): (amountNative: bigint) => Promise<bigint>;
1356
+ declare function createSubgraphNativeUsdtQuoter(config?: SubgraphNativeUsdtQuoterConfig): (amountNative: bigint) => Promise<bigint>;
1353
1357
 
1354
1358
  /**
1355
1359
  * Combined off-chain + on-chain balance for a single user / token pair.
@@ -1580,4 +1584,4 @@ declare function createIssuerService(config: IssuerServiceConfig): IssuerService
1580
1584
  /** SDK package version — bumped on every release */
1581
1585
  declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
1582
1586
 
1583
- export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiClaimRequest, type ApiClaimResponse, 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 IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, 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, RelayError, type RelayErrorCode, RelayService, type RetryConfig, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider };
1587
+ export { type ApiBuildConsentTypedDataRequest, type ApiBuildConsentTypedDataResponse, type ApiClaimAndSwapRequest, type ApiClaimAndSwapResponse, type ApiClaimRequest, type ApiClaimResponse, 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 IPointLedger, type IPolicyEngine, type ISessionStore, InMemoryCursorStore, IssuerApiHandlers, type IssuerApiHandlersConfig, type IssuerService, type IssuerServiceConfig, type LockedMintRequest, type LoginResult, MemorySessionStore, type MemorySessionStoreOptions, type MintEvent, type MintingStatus, NonceManager, PAFI_ISSUER_SDK_VERSION, PAFI_SUBGRAPH_URL, 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, RelayError, type RelayErrorCode, RelayService, type RetryConfig, type Session, type SponsorshipRequest, type SponsorshipResponse, type SponsorshipTarget, type SponsorshipUserOp, type SubgraphNativeUsdtQuoterConfig, type SubgraphPoolsProviderConfig, TopUpRedemptionError, TopUpRedemptionHandler, type TopUpRedemptionHandlerConfig, type TopUpRedemptionRequest, type TopUpRedemptionResponse, authenticateRequest, createIssuerService, createSubgraphNativeUsdtQuoter, createSubgraphPoolsProvider };
package/dist/index.js CHANGED
@@ -1499,6 +1499,7 @@ var TopUpRedemptionHandler = class {
1499
1499
 
1500
1500
  // src/pools/subgraphPoolsProvider.ts
1501
1501
  import { isAddress } from "viem";
1502
+ var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1502
1503
  var DEFAULT_CACHE_TTL_MS = 3e4;
1503
1504
  var POOL_QUERY = `
1504
1505
  query GetPoolForPointToken($id: ID!) {
@@ -1515,21 +1516,17 @@ var POOL_QUERY = `
1515
1516
  }
1516
1517
  }
1517
1518
  `;
1518
- function createSubgraphPoolsProvider(config) {
1519
- if (!config.subgraphUrl) {
1520
- throw new Error(
1521
- "createSubgraphPoolsProvider: subgraphUrl is required"
1522
- );
1523
- }
1519
+ function createSubgraphPoolsProvider(config = {}) {
1520
+ const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
1524
1521
  try {
1525
- const parsed = new URL(config.subgraphUrl);
1522
+ const parsed = new URL(subgraphUrl);
1526
1523
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
1527
1524
  throw new Error("subgraphUrl must use HTTPS in production");
1528
1525
  }
1529
1526
  } catch (err) {
1530
1527
  if (err instanceof TypeError) {
1531
1528
  throw new Error(
1532
- `subgraphPoolsProvider: invalid subgraphUrl: ${config.subgraphUrl}`
1529
+ `subgraphPoolsProvider: invalid subgraphUrl: ${subgraphUrl}`
1533
1530
  );
1534
1531
  }
1535
1532
  throw err;
@@ -1553,7 +1550,7 @@ function createSubgraphPoolsProvider(config) {
1553
1550
  }
1554
1551
  const pools = await fetchPoolsFromSubgraph(
1555
1552
  fetchImpl,
1556
- config.subgraphUrl,
1553
+ subgraphUrl,
1557
1554
  request.pointTokenAddress
1558
1555
  );
1559
1556
  if (cacheTtl > 0) {
@@ -1651,21 +1648,17 @@ var PRICE_QUERY = `
1651
1648
  }
1652
1649
  }
1653
1650
  `;
1654
- function createSubgraphNativeUsdtQuoter(config) {
1655
- if (!config.subgraphUrl) {
1656
- throw new Error(
1657
- "createSubgraphNativeUsdtQuoter: subgraphUrl is required"
1658
- );
1659
- }
1651
+ function createSubgraphNativeUsdtQuoter(config = {}) {
1652
+ const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
1660
1653
  try {
1661
- const parsed = new URL(config.subgraphUrl);
1654
+ const parsed = new URL(subgraphUrl);
1662
1655
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
1663
1656
  throw new Error("subgraphUrl must use HTTPS in production");
1664
1657
  }
1665
1658
  } catch (err) {
1666
1659
  if (err instanceof TypeError) {
1667
1660
  throw new Error(
1668
- `subgraphPoolsProvider: invalid subgraphUrl: ${config.subgraphUrl}`
1661
+ `createSubgraphNativeUsdtQuoter: invalid subgraphUrl: ${subgraphUrl}`
1669
1662
  );
1670
1663
  }
1671
1664
  throw err;
@@ -1688,7 +1681,7 @@ function createSubgraphNativeUsdtQuoter(config) {
1688
1681
  }
1689
1682
  const price = await fetchEthPriceFromSubgraph(
1690
1683
  fetchImpl,
1691
- config.subgraphUrl
1684
+ subgraphUrl
1692
1685
  );
1693
1686
  const usdtPerNative = toUsdtPerNative(
1694
1687
  price ?? fallbackPrice,
@@ -2053,6 +2046,7 @@ export {
2053
2046
  MemorySessionStore,
2054
2047
  NonceManager,
2055
2048
  PAFI_ISSUER_SDK_VERSION,
2049
+ PAFI_SUBGRAPH_URL,
2056
2050
  PTRedeemError,
2057
2051
  PTRedeemHandler,
2058
2052
  PafiBackendClient,