@pafi-dev/issuer 0.5.1 → 0.5.3

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 CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  MemorySessionStore: () => MemorySessionStore,
32
32
  NonceManager: () => NonceManager,
33
33
  PAFI_ISSUER_SDK_VERSION: () => PAFI_ISSUER_SDK_VERSION,
34
+ PAFI_SUBGRAPH_URL: () => PAFI_SUBGRAPH_URL,
34
35
  PTRedeemError: () => PTRedeemError,
35
36
  PTRedeemHandler: () => PTRedeemHandler,
36
37
  PafiBackendClient: () => PafiBackendClient,
@@ -1534,6 +1535,7 @@ var TopUpRedemptionHandler = class {
1534
1535
 
1535
1536
  // src/pools/subgraphPoolsProvider.ts
1536
1537
  var import_viem9 = require("viem");
1538
+ var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
1537
1539
  var DEFAULT_CACHE_TTL_MS = 3e4;
1538
1540
  var POOL_QUERY = `
1539
1541
  query GetPoolForPointToken($id: ID!) {
@@ -1550,21 +1552,17 @@ var POOL_QUERY = `
1550
1552
  }
1551
1553
  }
1552
1554
  `;
1553
- function createSubgraphPoolsProvider(config) {
1554
- if (!config.subgraphUrl) {
1555
- throw new Error(
1556
- "createSubgraphPoolsProvider: subgraphUrl is required"
1557
- );
1558
- }
1555
+ function createSubgraphPoolsProvider(config = {}) {
1556
+ const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
1559
1557
  try {
1560
- const parsed = new URL(config.subgraphUrl);
1558
+ const parsed = new URL(subgraphUrl);
1561
1559
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
1562
1560
  throw new Error("subgraphUrl must use HTTPS in production");
1563
1561
  }
1564
1562
  } catch (err) {
1565
1563
  if (err instanceof TypeError) {
1566
1564
  throw new Error(
1567
- `subgraphPoolsProvider: invalid subgraphUrl: ${config.subgraphUrl}`
1565
+ `subgraphPoolsProvider: invalid subgraphUrl: ${subgraphUrl}`
1568
1566
  );
1569
1567
  }
1570
1568
  throw err;
@@ -1588,7 +1586,7 @@ function createSubgraphPoolsProvider(config) {
1588
1586
  }
1589
1587
  const pools = await fetchPoolsFromSubgraph(
1590
1588
  fetchImpl,
1591
- config.subgraphUrl,
1589
+ subgraphUrl,
1592
1590
  request.pointTokenAddress
1593
1591
  );
1594
1592
  if (cacheTtl > 0) {
@@ -1686,21 +1684,17 @@ var PRICE_QUERY = `
1686
1684
  }
1687
1685
  }
1688
1686
  `;
1689
- function createSubgraphNativeUsdtQuoter(config) {
1690
- if (!config.subgraphUrl) {
1691
- throw new Error(
1692
- "createSubgraphNativeUsdtQuoter: subgraphUrl is required"
1693
- );
1694
- }
1687
+ function createSubgraphNativeUsdtQuoter(config = {}) {
1688
+ const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
1695
1689
  try {
1696
- const parsed = new URL(config.subgraphUrl);
1690
+ const parsed = new URL(subgraphUrl);
1697
1691
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
1698
1692
  throw new Error("subgraphUrl must use HTTPS in production");
1699
1693
  }
1700
1694
  } catch (err) {
1701
1695
  if (err instanceof TypeError) {
1702
1696
  throw new Error(
1703
- `subgraphPoolsProvider: invalid subgraphUrl: ${config.subgraphUrl}`
1697
+ `createSubgraphNativeUsdtQuoter: invalid subgraphUrl: ${subgraphUrl}`
1704
1698
  );
1705
1699
  }
1706
1700
  throw err;
@@ -1723,7 +1717,7 @@ function createSubgraphNativeUsdtQuoter(config) {
1723
1717
  }
1724
1718
  const price = await fetchEthPriceFromSubgraph(
1725
1719
  fetchImpl,
1726
- config.subgraphUrl
1720
+ subgraphUrl
1727
1721
  );
1728
1722
  const usdtPerNative = toUsdtPerNative(
1729
1723
  price ?? fallbackPrice,
@@ -1970,6 +1964,7 @@ var PafiBackendClient = class {
1970
1964
 
1971
1965
  // src/config.ts
1972
1966
  var import_viem10 = require("viem");
1967
+ var import_core7 = require("@pafi-dev/core");
1973
1968
  function createIssuerService(config) {
1974
1969
  if (!config.provider) {
1975
1970
  throw new Error("createIssuerService: provider is required");
@@ -2036,13 +2031,22 @@ function createIssuerService(config) {
2036
2031
  indexers.set(tokenAddress, new PointIndexer(indexerConfig));
2037
2032
  }
2038
2033
  const firstIndexer = indexers.get(tokenAddresses[0]);
2034
+ const chainAddresses = (0, import_core7.getContractAddresses)(config.chainId);
2035
+ const resolvedContracts = {
2036
+ batchExecutor: chainAddresses.batchExecutor,
2037
+ usdt: chainAddresses.usdt,
2038
+ issuerRegistry: chainAddresses.issuerRegistry,
2039
+ mintingOracle: chainAddresses.mintingOracle,
2040
+ pafiHook: chainAddresses.pafiHook,
2041
+ ...config.contracts
2042
+ };
2039
2043
  const handlersConfig = {
2040
2044
  authService,
2041
2045
  ledger,
2042
2046
  provider: config.provider,
2043
2047
  pointTokenAddresses: tokenAddresses,
2044
2048
  chainId: config.chainId,
2045
- contracts: config.contracts
2049
+ contracts: resolvedContracts
2046
2050
  };
2047
2051
  if (feeManager) handlersConfig.feeManager = feeManager;
2048
2052
  if (config.poolsProvider) handlersConfig.poolsProvider = config.poolsProvider;
@@ -2051,7 +2055,7 @@ function createIssuerService(config) {
2051
2055
  policy,
2052
2056
  relayService,
2053
2057
  issuerSignerWallet: config.claim.issuerSignerWallet,
2054
- batchExecutorAddress: config.claim.batchExecutorAddress,
2058
+ batchExecutorAddress: config.claim.batchExecutorAddress ?? chainAddresses.batchExecutor,
2055
2059
  lockDurationMs: config.claim.lockDurationMs
2056
2060
  };
2057
2061
  }
@@ -2089,6 +2093,7 @@ var PAFI_ISSUER_SDK_VERSION = "0.4.0";
2089
2093
  MemorySessionStore,
2090
2094
  NonceManager,
2091
2095
  PAFI_ISSUER_SDK_VERSION,
2096
+ PAFI_SUBGRAPH_URL,
2092
2097
  PTRedeemError,
2093
2098
  PTRedeemHandler,
2094
2099
  PafiBackendClient,