@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 +25 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
1231
|
-
* `
|
|
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
|
|
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
|
|
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.
|
|
1289
|
-
* `
|
|
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
|
|
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
|
|
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.
|
|
@@ -1478,10 +1482,12 @@ interface IssuerServiceConfig {
|
|
|
1478
1482
|
/** All PointToken addresses this issuer supports. */
|
|
1479
1483
|
pointTokenAddresses?: Address[];
|
|
1480
1484
|
/**
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1485
|
+
* Issuer-specific contract addresses merged into the `/config` response.
|
|
1486
|
+
* PAFI-owned addresses (batchExecutor, usdt, issuerRegistry, mintingOracle,
|
|
1487
|
+
* pafiHook) are auto-resolved from `getContractAddresses(chainId)` and
|
|
1488
|
+
* can be omitted. Only `pointToken` / `pointTokens` must be provided.
|
|
1483
1489
|
*/
|
|
1484
|
-
contracts
|
|
1490
|
+
contracts?: Pick<ApiConfigResponse["contracts"], "pointToken" | "pointTokens" | "relay">;
|
|
1485
1491
|
/**
|
|
1486
1492
|
* Shared `PublicClient` used for on-chain reads, simulation, indexer
|
|
1487
1493
|
* polling, and gas-price lookups. Must be pointed at the target chain.
|
|
@@ -1526,7 +1532,8 @@ interface IssuerServiceConfig {
|
|
|
1526
1532
|
*/
|
|
1527
1533
|
claim?: {
|
|
1528
1534
|
issuerSignerWallet: WalletClient;
|
|
1529
|
-
|
|
1535
|
+
/** Defaults to the PAFI-deployed BatchExecutor for the target chain. */
|
|
1536
|
+
batchExecutorAddress?: Address;
|
|
1530
1537
|
lockDurationMs?: number;
|
|
1531
1538
|
};
|
|
1532
1539
|
indexer?: {
|
|
@@ -1580,4 +1587,4 @@ declare function createIssuerService(config: IssuerServiceConfig): IssuerService
|
|
|
1580
1587
|
/** SDK package version — bumped on every release */
|
|
1581
1588
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
1582
1589
|
|
|
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 };
|
|
1590
|
+
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.
|
|
1231
|
-
* `
|
|
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
|
|
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
|
|
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.
|
|
1289
|
-
* `
|
|
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
|
|
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
|
|
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.
|
|
@@ -1478,10 +1482,12 @@ interface IssuerServiceConfig {
|
|
|
1478
1482
|
/** All PointToken addresses this issuer supports. */
|
|
1479
1483
|
pointTokenAddresses?: Address[];
|
|
1480
1484
|
/**
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1485
|
+
* Issuer-specific contract addresses merged into the `/config` response.
|
|
1486
|
+
* PAFI-owned addresses (batchExecutor, usdt, issuerRegistry, mintingOracle,
|
|
1487
|
+
* pafiHook) are auto-resolved from `getContractAddresses(chainId)` and
|
|
1488
|
+
* can be omitted. Only `pointToken` / `pointTokens` must be provided.
|
|
1483
1489
|
*/
|
|
1484
|
-
contracts
|
|
1490
|
+
contracts?: Pick<ApiConfigResponse["contracts"], "pointToken" | "pointTokens" | "relay">;
|
|
1485
1491
|
/**
|
|
1486
1492
|
* Shared `PublicClient` used for on-chain reads, simulation, indexer
|
|
1487
1493
|
* polling, and gas-price lookups. Must be pointed at the target chain.
|
|
@@ -1526,7 +1532,8 @@ interface IssuerServiceConfig {
|
|
|
1526
1532
|
*/
|
|
1527
1533
|
claim?: {
|
|
1528
1534
|
issuerSignerWallet: WalletClient;
|
|
1529
|
-
|
|
1535
|
+
/** Defaults to the PAFI-deployed BatchExecutor for the target chain. */
|
|
1536
|
+
batchExecutorAddress?: Address;
|
|
1530
1537
|
lockDurationMs?: number;
|
|
1531
1538
|
};
|
|
1532
1539
|
indexer?: {
|
|
@@ -1580,4 +1587,4 @@ declare function createIssuerService(config: IssuerServiceConfig): IssuerService
|
|
|
1580
1587
|
/** SDK package version — bumped on every release */
|
|
1581
1588
|
declare const PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
1582
1589
|
|
|
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 };
|
|
1590
|
+
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
|
-
|
|
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(
|
|
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: ${
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
`
|
|
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
|
-
|
|
1684
|
+
subgraphUrl
|
|
1692
1685
|
);
|
|
1693
1686
|
const usdtPerNative = toUsdtPerNative(
|
|
1694
1687
|
price ?? fallbackPrice,
|
|
@@ -1935,6 +1928,7 @@ var PafiBackendClient = class {
|
|
|
1935
1928
|
|
|
1936
1929
|
// src/config.ts
|
|
1937
1930
|
import { getAddress as getAddress8 } from "viem";
|
|
1931
|
+
import { getContractAddresses } from "@pafi-dev/core";
|
|
1938
1932
|
function createIssuerService(config) {
|
|
1939
1933
|
if (!config.provider) {
|
|
1940
1934
|
throw new Error("createIssuerService: provider is required");
|
|
@@ -2001,13 +1995,22 @@ function createIssuerService(config) {
|
|
|
2001
1995
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
2002
1996
|
}
|
|
2003
1997
|
const firstIndexer = indexers.get(tokenAddresses[0]);
|
|
1998
|
+
const chainAddresses = getContractAddresses(config.chainId);
|
|
1999
|
+
const resolvedContracts = {
|
|
2000
|
+
batchExecutor: chainAddresses.batchExecutor,
|
|
2001
|
+
usdt: chainAddresses.usdt,
|
|
2002
|
+
issuerRegistry: chainAddresses.issuerRegistry,
|
|
2003
|
+
mintingOracle: chainAddresses.mintingOracle,
|
|
2004
|
+
pafiHook: chainAddresses.pafiHook,
|
|
2005
|
+
...config.contracts
|
|
2006
|
+
};
|
|
2004
2007
|
const handlersConfig = {
|
|
2005
2008
|
authService,
|
|
2006
2009
|
ledger,
|
|
2007
2010
|
provider: config.provider,
|
|
2008
2011
|
pointTokenAddresses: tokenAddresses,
|
|
2009
2012
|
chainId: config.chainId,
|
|
2010
|
-
contracts:
|
|
2013
|
+
contracts: resolvedContracts
|
|
2011
2014
|
};
|
|
2012
2015
|
if (feeManager) handlersConfig.feeManager = feeManager;
|
|
2013
2016
|
if (config.poolsProvider) handlersConfig.poolsProvider = config.poolsProvider;
|
|
@@ -2016,7 +2019,7 @@ function createIssuerService(config) {
|
|
|
2016
2019
|
policy,
|
|
2017
2020
|
relayService,
|
|
2018
2021
|
issuerSignerWallet: config.claim.issuerSignerWallet,
|
|
2019
|
-
batchExecutorAddress: config.claim.batchExecutorAddress,
|
|
2022
|
+
batchExecutorAddress: config.claim.batchExecutorAddress ?? chainAddresses.batchExecutor,
|
|
2020
2023
|
lockDurationMs: config.claim.lockDurationMs
|
|
2021
2024
|
};
|
|
2022
2025
|
}
|
|
@@ -2053,6 +2056,7 @@ export {
|
|
|
2053
2056
|
MemorySessionStore,
|
|
2054
2057
|
NonceManager,
|
|
2055
2058
|
PAFI_ISSUER_SDK_VERSION,
|
|
2059
|
+
PAFI_SUBGRAPH_URL,
|
|
2056
2060
|
PTRedeemError,
|
|
2057
2061
|
PTRedeemHandler,
|
|
2058
2062
|
PafiBackendClient,
|