@pafi-dev/issuer 0.5.4 → 0.5.6
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 +8 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -63
- package/dist/index.d.ts +47 -63
- package/dist/index.js +2 -57
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,7 +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
|
+
PAFI_SUBGRAPH_URL: () => import_core6.PAFI_SUBGRAPH_URL,
|
|
35
35
|
PTRedeemError: () => PTRedeemError,
|
|
36
36
|
PTRedeemHandler: () => PTRedeemHandler,
|
|
37
37
|
PafiBackendClient: () => PafiBackendClient,
|
|
@@ -1188,60 +1188,6 @@ var IssuerApiHandlers = class {
|
|
|
1188
1188
|
isMinter: minter
|
|
1189
1189
|
};
|
|
1190
1190
|
}
|
|
1191
|
-
/**
|
|
1192
|
-
* `POST /build-consent-typed-data`
|
|
1193
|
-
*
|
|
1194
|
-
* Backend builds the full EIP-712 typed data payload for a
|
|
1195
|
-
* ReceiverConsent message. The domain (name, version, chainId,
|
|
1196
|
-
* verifyingContract) is read from the PointToken contract — mobile
|
|
1197
|
-
* never needs to know or hardcode these values. Forward the
|
|
1198
|
-
* response directly to `wallet.signTypedData()`.
|
|
1199
|
-
*
|
|
1200
|
-
* This ensures a single source of truth for domain + types, and
|
|
1201
|
-
* makes contract upgrades (domain version bump) transparent to
|
|
1202
|
-
* mobile apps — no app store review needed.
|
|
1203
|
-
*/
|
|
1204
|
-
async handleBuildConsentTypedData(userAddress, request) {
|
|
1205
|
-
if (request.chainId !== this.chainId) {
|
|
1206
|
-
throw new Error(
|
|
1207
|
-
`handleBuildConsentTypedData: unsupported chainId ${request.chainId}`
|
|
1208
|
-
);
|
|
1209
|
-
}
|
|
1210
|
-
const pointToken = (0, import_viem6.getAddress)(request.pointTokenAddress);
|
|
1211
|
-
if (!this.supportedTokens.has(pointToken)) {
|
|
1212
|
-
throw new Error(
|
|
1213
|
-
`handleBuildConsentTypedData: unsupported pointToken ${pointToken}`
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
const consent = request.receiverConsent;
|
|
1217
|
-
if ((0, import_viem6.getAddress)(consent.originalReceiver) !== (0, import_viem6.getAddress)(userAddress)) {
|
|
1218
|
-
throw new Error(
|
|
1219
|
-
"handleBuildConsentTypedData: receiverConsent.originalReceiver must match authenticated user"
|
|
1220
|
-
);
|
|
1221
|
-
}
|
|
1222
|
-
if (consent.amount <= 0n) {
|
|
1223
|
-
throw new Error("handleBuildConsentTypedData: amount must be positive");
|
|
1224
|
-
}
|
|
1225
|
-
const nowSecs = BigInt(Math.floor(Date.now() / 1e3));
|
|
1226
|
-
if (consent.deadline <= nowSecs) {
|
|
1227
|
-
throw new Error("handleBuildConsentTypedData: deadline is in the past");
|
|
1228
|
-
}
|
|
1229
|
-
const name = await (0, import_core3.getTokenName)(this.provider, pointToken);
|
|
1230
|
-
const domain = {
|
|
1231
|
-
name,
|
|
1232
|
-
verifyingContract: pointToken,
|
|
1233
|
-
chainId: this.chainId
|
|
1234
|
-
};
|
|
1235
|
-
const typedData = (0, import_core3.buildReceiverConsentTypedData)(domain, consent);
|
|
1236
|
-
return {
|
|
1237
|
-
typedData: {
|
|
1238
|
-
domain: typedData.domain,
|
|
1239
|
-
types: typedData.types,
|
|
1240
|
-
primaryType: typedData.primaryType,
|
|
1241
|
-
message: typedData.message
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
1191
|
/**
|
|
1246
1192
|
* `POST /claim`
|
|
1247
1193
|
*
|
|
@@ -1535,7 +1481,7 @@ var TopUpRedemptionHandler = class {
|
|
|
1535
1481
|
|
|
1536
1482
|
// src/pools/subgraphPoolsProvider.ts
|
|
1537
1483
|
var import_viem9 = require("viem");
|
|
1538
|
-
var
|
|
1484
|
+
var import_core6 = require("@pafi-dev/core");
|
|
1539
1485
|
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
1540
1486
|
var POOL_QUERY = `
|
|
1541
1487
|
query GetPoolForPointToken($id: ID!) {
|
|
@@ -1553,7 +1499,7 @@ var POOL_QUERY = `
|
|
|
1553
1499
|
}
|
|
1554
1500
|
`;
|
|
1555
1501
|
function createSubgraphPoolsProvider(config = {}) {
|
|
1556
|
-
const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
|
|
1502
|
+
const subgraphUrl = config.subgraphUrl ?? import_core6.PAFI_SUBGRAPH_URL;
|
|
1557
1503
|
try {
|
|
1558
1504
|
const parsed = new URL(subgraphUrl);
|
|
1559
1505
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -1685,7 +1631,7 @@ var PRICE_QUERY = `
|
|
|
1685
1631
|
}
|
|
1686
1632
|
`;
|
|
1687
1633
|
function createSubgraphNativeUsdtQuoter(config = {}) {
|
|
1688
|
-
const subgraphUrl = config.subgraphUrl ?? PAFI_SUBGRAPH_URL;
|
|
1634
|
+
const subgraphUrl = config.subgraphUrl ?? import_core6.PAFI_SUBGRAPH_URL;
|
|
1689
1635
|
try {
|
|
1690
1636
|
const parsed = new URL(subgraphUrl);
|
|
1691
1637
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -1793,7 +1739,7 @@ function toUsdtPerNative(priceFloat, usdtDecimals) {
|
|
|
1793
1739
|
}
|
|
1794
1740
|
|
|
1795
1741
|
// src/balance/balanceAggregator.ts
|
|
1796
|
-
var
|
|
1742
|
+
var import_core7 = require("@pafi-dev/core");
|
|
1797
1743
|
var BalanceAggregator = class {
|
|
1798
1744
|
provider;
|
|
1799
1745
|
ledger;
|
|
@@ -1814,7 +1760,7 @@ var BalanceAggregator = class {
|
|
|
1814
1760
|
async getCombinedBalance(user, pointToken) {
|
|
1815
1761
|
const [offChain, onChain] = await Promise.all([
|
|
1816
1762
|
this.ledger.getBalance(user, pointToken),
|
|
1817
|
-
(0,
|
|
1763
|
+
(0, import_core7.getPointTokenBalance)(this.provider, pointToken, user)
|
|
1818
1764
|
]);
|
|
1819
1765
|
return {
|
|
1820
1766
|
offChain,
|
|
@@ -1964,7 +1910,7 @@ var PafiBackendClient = class {
|
|
|
1964
1910
|
|
|
1965
1911
|
// src/config.ts
|
|
1966
1912
|
var import_viem10 = require("viem");
|
|
1967
|
-
var
|
|
1913
|
+
var import_core8 = require("@pafi-dev/core");
|
|
1968
1914
|
function createIssuerService(config) {
|
|
1969
1915
|
if (!config.provider) {
|
|
1970
1916
|
throw new Error("createIssuerService: provider is required");
|
|
@@ -2031,7 +1977,7 @@ function createIssuerService(config) {
|
|
|
2031
1977
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
2032
1978
|
}
|
|
2033
1979
|
const firstIndexer = indexers.get(tokenAddresses[0]);
|
|
2034
|
-
const chainAddresses = (0,
|
|
1980
|
+
const chainAddresses = (0, import_core8.getContractAddresses)(config.chainId);
|
|
2035
1981
|
const resolvedContracts = {
|
|
2036
1982
|
batchExecutor: chainAddresses.batchExecutor,
|
|
2037
1983
|
usdt: chainAddresses.usdt,
|