@pafi-dev/issuer 0.5.42 → 0.5.43
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 +148 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -191
- package/dist/index.d.ts +46 -191
- package/dist/index.js +77 -216
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -570,15 +570,13 @@ var RelayService = class {
|
|
|
570
570
|
});
|
|
571
571
|
}
|
|
572
572
|
/**
|
|
573
|
-
* Build an unsigned UserOp for Scenario 2 (Burn/Redeem)
|
|
573
|
+
* Build an unsigned UserOp for Scenario 2 (Burn/Redeem) — sig-gated
|
|
574
|
+
* `PointToken.burn(from, amount, deadline, burnerSig)`. Caller
|
|
575
|
+
* provides a pre-signed `BurnRequest` + sig bytes (typically from
|
|
576
|
+
* `PTRedeemHandler`).
|
|
574
577
|
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
* usable if the caller (via EIP-7702) is whitelisted as a burner.
|
|
578
|
-
* Rare in v1.4; kept for admin/operator tools.
|
|
579
|
-
* - `mode: 'burnWithSig'` — `PointToken.burn(from, amount, deadline,
|
|
580
|
-
* burnerSig)`. Caller provides a pre-signed `BurnRequest` + sig
|
|
581
|
-
* bytes (typically from `PTRedeemHandler`).
|
|
578
|
+
* Direct burn (no sig) was dropped in v1.4 — every burn now goes
|
|
579
|
+
* through the issuer-signed `BurnRequest` path.
|
|
582
580
|
*/
|
|
583
581
|
async prepareBurn(params) {
|
|
584
582
|
if (!params.pointTokenAddress) {
|
|
@@ -590,29 +588,24 @@ var RelayService = class {
|
|
|
590
588
|
"prepareBurn: batchExecutorAddress required"
|
|
591
589
|
);
|
|
592
590
|
}
|
|
591
|
+
if (!params.burnRequest || !params.burnerSignature) {
|
|
592
|
+
throw new RelayError(
|
|
593
|
+
"ENCODE_FAILED",
|
|
594
|
+
"prepareBurn: burnRequest + burnerSignature required"
|
|
595
|
+
);
|
|
596
|
+
}
|
|
593
597
|
let burnCallData;
|
|
594
598
|
try {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
params.burnRequest.deadline,
|
|
606
|
-
params.burnerSignature
|
|
607
|
-
]
|
|
608
|
-
});
|
|
609
|
-
} else {
|
|
610
|
-
burnCallData = encodeFunctionData({
|
|
611
|
-
abi: POINT_TOKEN_V2_ABI,
|
|
612
|
-
functionName: "burn",
|
|
613
|
-
args: [params.userAddress, params.amount]
|
|
614
|
-
});
|
|
615
|
-
}
|
|
599
|
+
burnCallData = encodeFunctionData({
|
|
600
|
+
abi: POINT_TOKEN_V2_ABI,
|
|
601
|
+
functionName: "burn",
|
|
602
|
+
args: [
|
|
603
|
+
params.burnRequest.from,
|
|
604
|
+
params.burnRequest.amount,
|
|
605
|
+
params.burnRequest.deadline,
|
|
606
|
+
params.burnerSignature
|
|
607
|
+
]
|
|
608
|
+
});
|
|
616
609
|
} catch (err) {
|
|
617
610
|
throw new RelayError(
|
|
618
611
|
"ENCODE_FAILED",
|
|
@@ -1069,7 +1062,6 @@ import {
|
|
|
1069
1062
|
getMintRequestNonce,
|
|
1070
1063
|
getPointTokenBalance,
|
|
1071
1064
|
getReceiverConsentNonce,
|
|
1072
|
-
getTokenName,
|
|
1073
1065
|
isMinter
|
|
1074
1066
|
} from "@pafi-dev/core";
|
|
1075
1067
|
var IssuerApiHandlers = class {
|
|
@@ -1086,7 +1078,6 @@ var IssuerApiHandlers = class {
|
|
|
1086
1078
|
pafiWebUrl;
|
|
1087
1079
|
feeManager;
|
|
1088
1080
|
poolsProvider;
|
|
1089
|
-
claim;
|
|
1090
1081
|
constructor(config) {
|
|
1091
1082
|
this.authService = config.authService;
|
|
1092
1083
|
this.ledger = config.ledger;
|
|
@@ -1104,7 +1095,6 @@ var IssuerApiHandlers = class {
|
|
|
1104
1095
|
if (config.pafiWebUrl) this.pafiWebUrl = config.pafiWebUrl;
|
|
1105
1096
|
if (config.feeManager) this.feeManager = config.feeManager;
|
|
1106
1097
|
if (config.poolsProvider) this.poolsProvider = config.poolsProvider;
|
|
1107
|
-
if (config.claim) this.claim = config.claim;
|
|
1108
1098
|
}
|
|
1109
1099
|
// =========================================================================
|
|
1110
1100
|
// Public handlers (no auth required)
|
|
@@ -1238,91 +1228,9 @@ var IssuerApiHandlers = class {
|
|
|
1238
1228
|
isMinter: minter
|
|
1239
1229
|
};
|
|
1240
1230
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
* Policy gate + ledger lock + MintRequest signing in a single atomic
|
|
1245
|
-
* step. Returns an unsigned UserOp the frontend attaches paymaster data
|
|
1246
|
-
* to and submits via EIP-7702 + Bundler.
|
|
1247
|
-
*
|
|
1248
|
-
* Order of operations:
|
|
1249
|
-
* 1. Validate request fields.
|
|
1250
|
-
* 2. policy.evaluate() — throws if denied; cannot be bypassed.
|
|
1251
|
-
* 3. ledger.lockForMinting() — reserves the balance.
|
|
1252
|
-
* 4. Read on-chain mintRequestNonce + token name in parallel.
|
|
1253
|
-
* 5. relayService.prepareMint() — sign MintRequest + encode UserOp.
|
|
1254
|
-
* 6. On any error after step 3, release the lock before re-throwing.
|
|
1255
|
-
*/
|
|
1256
|
-
async handleClaim(userAddress, request) {
|
|
1257
|
-
if (!this.claim) {
|
|
1258
|
-
throw new Error("handleClaim: claim is not configured on this issuer");
|
|
1259
|
-
}
|
|
1260
|
-
if (request.chainId !== this.chainId) {
|
|
1261
|
-
throw new Error(`handleClaim: unsupported chainId ${request.chainId}`);
|
|
1262
|
-
}
|
|
1263
|
-
const pointToken = getAddress5(request.pointTokenAddress);
|
|
1264
|
-
if (!this.supportedTokens.has(pointToken)) {
|
|
1265
|
-
throw new Error(`handleClaim: unsupported pointToken ${pointToken}`);
|
|
1266
|
-
}
|
|
1267
|
-
if (request.amount <= 0n) {
|
|
1268
|
-
throw new Error("handleClaim: amount must be positive");
|
|
1269
|
-
}
|
|
1270
|
-
const nowSecs = BigInt(Math.floor(Date.now() / 1e3));
|
|
1271
|
-
if (request.deadline <= nowSecs) {
|
|
1272
|
-
throw new Error("handleClaim: deadline is in the past");
|
|
1273
|
-
}
|
|
1274
|
-
const { policy, relayService, issuerSignerWallet, batchExecutorAddress } = this.claim;
|
|
1275
|
-
const lockDurationMs = this.claim.lockDurationMs ?? 15 * 60 * 1e3;
|
|
1276
|
-
const normalizedUser = getAddress5(userAddress);
|
|
1277
|
-
const decision = await policy.evaluate({
|
|
1278
|
-
userAddress: normalizedUser,
|
|
1279
|
-
amount: request.amount,
|
|
1280
|
-
pointTokenAddress: pointToken,
|
|
1281
|
-
chainId: this.chainId
|
|
1282
|
-
});
|
|
1283
|
-
if (!decision.approved) {
|
|
1284
|
-
throw new Error(`handleClaim: policy denied \u2014 ${decision.reason ?? "no reason given"}`);
|
|
1285
|
-
}
|
|
1286
|
-
const lockId = await this.ledger.lockForMinting(
|
|
1287
|
-
normalizedUser,
|
|
1288
|
-
request.amount,
|
|
1289
|
-
lockDurationMs,
|
|
1290
|
-
pointToken
|
|
1291
|
-
);
|
|
1292
|
-
try {
|
|
1293
|
-
const [mintRequestNonce, tokenName] = await Promise.all([
|
|
1294
|
-
getMintRequestNonce(this.provider, pointToken, normalizedUser),
|
|
1295
|
-
getTokenName(this.provider, pointToken)
|
|
1296
|
-
]);
|
|
1297
|
-
const domain = {
|
|
1298
|
-
name: tokenName,
|
|
1299
|
-
verifyingContract: pointToken,
|
|
1300
|
-
chainId: this.chainId
|
|
1301
|
-
};
|
|
1302
|
-
const userOp = await relayService.prepareMint({
|
|
1303
|
-
userAddress: normalizedUser,
|
|
1304
|
-
aaNonce: request.aaNonce,
|
|
1305
|
-
batchExecutorAddress,
|
|
1306
|
-
pointTokenAddress: pointToken,
|
|
1307
|
-
amount: request.amount,
|
|
1308
|
-
issuerSignerWallet,
|
|
1309
|
-
domain,
|
|
1310
|
-
mintRequestNonce,
|
|
1311
|
-
deadline: request.deadline,
|
|
1312
|
-
feeAmount: request.feeAmount,
|
|
1313
|
-
feeRecipient: request.feeRecipient
|
|
1314
|
-
});
|
|
1315
|
-
return {
|
|
1316
|
-
lockId,
|
|
1317
|
-
userOp,
|
|
1318
|
-
expiresInSeconds: Math.floor(lockDurationMs / 1e3)
|
|
1319
|
-
};
|
|
1320
|
-
} catch (err) {
|
|
1321
|
-
await this.ledger.releaseLock(lockId).catch(() => {
|
|
1322
|
-
});
|
|
1323
|
-
throw err;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1231
|
+
// Note: legacy `handleClaim` (sync sponsored-claim returning calls[]) was
|
|
1232
|
+
// removed in 0.5.43 — callers should use `PTClaimHandler` directly or
|
|
1233
|
+
// wire `IssuerApiAdapter.claim()` which composes the full flow.
|
|
1326
1234
|
};
|
|
1327
1235
|
|
|
1328
1236
|
// src/api/handlers/ptRedeemHandler.ts
|
|
@@ -1566,70 +1474,6 @@ var PTRedeemHandler = class {
|
|
|
1566
1474
|
}
|
|
1567
1475
|
};
|
|
1568
1476
|
|
|
1569
|
-
// src/api/handlers/topUpRedemptionHandler.ts
|
|
1570
|
-
import { getAddress as getAddress7 } from "viem";
|
|
1571
|
-
import { getPointTokenBalance as getPointTokenBalance3 } from "@pafi-dev/core";
|
|
1572
|
-
var TopUpRedemptionError = class extends Error {
|
|
1573
|
-
constructor(code, message) {
|
|
1574
|
-
super(message);
|
|
1575
|
-
this.code = code;
|
|
1576
|
-
this.name = "TopUpRedemptionError";
|
|
1577
|
-
}
|
|
1578
|
-
code;
|
|
1579
|
-
};
|
|
1580
|
-
var TopUpRedemptionHandler = class {
|
|
1581
|
-
ledger;
|
|
1582
|
-
ptRedeemHandler;
|
|
1583
|
-
provider;
|
|
1584
|
-
pointTokenAddress;
|
|
1585
|
-
constructor(config) {
|
|
1586
|
-
this.ledger = config.ledger;
|
|
1587
|
-
this.ptRedeemHandler = config.ptRedeemHandler;
|
|
1588
|
-
this.provider = config.provider;
|
|
1589
|
-
this.pointTokenAddress = getAddress7(config.pointTokenAddress);
|
|
1590
|
-
}
|
|
1591
|
-
async handle(request) {
|
|
1592
|
-
if (getAddress7(request.authenticatedAddress) !== getAddress7(request.userAddress)) {
|
|
1593
|
-
throw new TopUpRedemptionError(
|
|
1594
|
-
"UNAUTHORIZED",
|
|
1595
|
-
`userAddress (${request.userAddress}) does not match authenticated session (${request.authenticatedAddress})`
|
|
1596
|
-
);
|
|
1597
|
-
}
|
|
1598
|
-
const offChainBalance = await this.ledger.getBalance(
|
|
1599
|
-
request.userAddress,
|
|
1600
|
-
this.pointTokenAddress
|
|
1601
|
-
);
|
|
1602
|
-
if (offChainBalance >= request.requiredAmount) {
|
|
1603
|
-
return { action: "NO_TOP_UP_NEEDED", offChainBalance };
|
|
1604
|
-
}
|
|
1605
|
-
const shortfall = request.requiredAmount - offChainBalance;
|
|
1606
|
-
const onChainBalance = await getPointTokenBalance3(
|
|
1607
|
-
this.provider,
|
|
1608
|
-
this.pointTokenAddress,
|
|
1609
|
-
request.userAddress
|
|
1610
|
-
);
|
|
1611
|
-
if (onChainBalance < shortfall) {
|
|
1612
|
-
return {
|
|
1613
|
-
action: "INSUFFICIENT_ONCHAIN",
|
|
1614
|
-
offChainBalance,
|
|
1615
|
-
onChainBalance,
|
|
1616
|
-
shortfall
|
|
1617
|
-
};
|
|
1618
|
-
}
|
|
1619
|
-
const redeem = await this.ptRedeemHandler.handle({
|
|
1620
|
-
authenticatedAddress: request.authenticatedAddress,
|
|
1621
|
-
userAddress: request.userAddress,
|
|
1622
|
-
amount: shortfall,
|
|
1623
|
-
aaNonce: request.aaNonce
|
|
1624
|
-
});
|
|
1625
|
-
return {
|
|
1626
|
-
action: "TOP_UP_STARTED",
|
|
1627
|
-
shortfall,
|
|
1628
|
-
redeem
|
|
1629
|
-
};
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
|
|
1633
1477
|
// src/api/statusHandlers.ts
|
|
1634
1478
|
var LockNotFoundError = class extends PafiSdkError {
|
|
1635
1479
|
code = "LOCK_NOT_FOUND";
|
|
@@ -1731,7 +1575,7 @@ async function handleRedeemStatus(params) {
|
|
|
1731
1575
|
}
|
|
1732
1576
|
|
|
1733
1577
|
// src/api/mobileHandlers.ts
|
|
1734
|
-
import { getAddress as
|
|
1578
|
+
import { getAddress as getAddress7 } from "viem";
|
|
1735
1579
|
import {
|
|
1736
1580
|
ENTRY_POINT_V08,
|
|
1737
1581
|
parseEip7702DelegatedAddress
|
|
@@ -1780,6 +1624,33 @@ function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
|
|
|
1780
1624
|
);
|
|
1781
1625
|
}
|
|
1782
1626
|
|
|
1627
|
+
// src/userop-store/memoryStore.ts
|
|
1628
|
+
var MemoryPendingUserOpStore = class {
|
|
1629
|
+
entries = /* @__PURE__ */ new Map();
|
|
1630
|
+
now;
|
|
1631
|
+
constructor(now = () => Date.now()) {
|
|
1632
|
+
this.now = now;
|
|
1633
|
+
}
|
|
1634
|
+
async save(lockId, entry, ttlSeconds) {
|
|
1635
|
+
this.entries.set(lockId, {
|
|
1636
|
+
entry,
|
|
1637
|
+
expiresAt: this.now() + ttlSeconds * 1e3
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
async get(lockId) {
|
|
1641
|
+
const hit = this.entries.get(lockId);
|
|
1642
|
+
if (!hit) return null;
|
|
1643
|
+
if (hit.expiresAt <= this.now()) {
|
|
1644
|
+
this.entries.delete(lockId);
|
|
1645
|
+
return null;
|
|
1646
|
+
}
|
|
1647
|
+
return hit.entry;
|
|
1648
|
+
}
|
|
1649
|
+
async delete(lockId) {
|
|
1650
|
+
this.entries.delete(lockId);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1783
1654
|
// src/userop-store/prepareUserOp.ts
|
|
1784
1655
|
import {
|
|
1785
1656
|
buildUserOpTypedData,
|
|
@@ -2001,7 +1872,7 @@ async function handleMobileSubmit(params) {
|
|
|
2001
1872
|
if (!entry) {
|
|
2002
1873
|
throw new PendingUserOpNotFoundError(params.lockId);
|
|
2003
1874
|
}
|
|
2004
|
-
if (
|
|
1875
|
+
if (getAddress7(entry.sender) !== getAddress7(params.authenticatedAddress)) {
|
|
2005
1876
|
throw new PendingUserOpForbiddenError(params.lockId);
|
|
2006
1877
|
}
|
|
2007
1878
|
const variant = params.variant ?? "sponsored";
|
|
@@ -2017,7 +1888,7 @@ async function handleMobileSubmit(params) {
|
|
|
2017
1888
|
}
|
|
2018
1889
|
|
|
2019
1890
|
// src/api/handlers/ptClaimHandler.ts
|
|
2020
|
-
import { getAddress as
|
|
1891
|
+
import { getAddress as getAddress8 } from "viem";
|
|
2021
1892
|
import {
|
|
2022
1893
|
decodeBatchExecuteCalls,
|
|
2023
1894
|
getContractAddresses as getContractAddresses3
|
|
@@ -2061,7 +1932,7 @@ var PTClaimHandler = class {
|
|
|
2061
1932
|
};
|
|
2062
1933
|
}
|
|
2063
1934
|
async handle(request) {
|
|
2064
|
-
if (
|
|
1935
|
+
if (getAddress8(request.authenticatedAddress) !== getAddress8(request.userAddress)) {
|
|
2065
1936
|
throw new PTClaimError(
|
|
2066
1937
|
"VALIDATION_FAILED",
|
|
2067
1938
|
`userAddress (${request.userAddress}) does not match authenticated session (${request.authenticatedAddress})`
|
|
@@ -2594,7 +2465,7 @@ function createSdkErrorMapper(factories) {
|
|
|
2594
2465
|
}
|
|
2595
2466
|
|
|
2596
2467
|
// src/api/issuerApiAdapter.ts
|
|
2597
|
-
import { getAddress as
|
|
2468
|
+
import { getAddress as getAddress9 } from "viem";
|
|
2598
2469
|
import {
|
|
2599
2470
|
buildAndSignSponsorAuth,
|
|
2600
2471
|
computeAuthorizationHash,
|
|
@@ -2624,7 +2495,7 @@ var IssuerApiAdapter = class {
|
|
|
2624
2495
|
async pools(authenticatedAddress, chainId, pointTokenAddress) {
|
|
2625
2496
|
const result = await this.cfg.issuerService.api.handlePools(
|
|
2626
2497
|
authenticatedAddress,
|
|
2627
|
-
{ chainId, pointTokenAddress:
|
|
2498
|
+
{ chainId, pointTokenAddress: getAddress9(pointTokenAddress) }
|
|
2628
2499
|
);
|
|
2629
2500
|
return { pools: result.pools };
|
|
2630
2501
|
}
|
|
@@ -2633,8 +2504,8 @@ var IssuerApiAdapter = class {
|
|
|
2633
2504
|
authenticatedAddress,
|
|
2634
2505
|
{
|
|
2635
2506
|
chainId,
|
|
2636
|
-
userAddress:
|
|
2637
|
-
pointTokenAddress:
|
|
2507
|
+
userAddress: getAddress9(userAddress),
|
|
2508
|
+
pointTokenAddress: getAddress9(pointTokenAddress)
|
|
2638
2509
|
}
|
|
2639
2510
|
);
|
|
2640
2511
|
return {
|
|
@@ -2652,13 +2523,13 @@ var IssuerApiAdapter = class {
|
|
|
2652
2523
|
this.cfg.issuerService.api.handleGasFee(),
|
|
2653
2524
|
this.cfg.issuerService.api.handlePools(authenticatedAddress, {
|
|
2654
2525
|
chainId,
|
|
2655
|
-
pointTokenAddress:
|
|
2526
|
+
pointTokenAddress: getAddress9(pointTokenAddress)
|
|
2656
2527
|
})
|
|
2657
2528
|
]);
|
|
2658
2529
|
const quote = await quotePointTokenToUsdt({
|
|
2659
2530
|
provider: this.cfg.provider,
|
|
2660
2531
|
chainId,
|
|
2661
|
-
pointTokenAddress:
|
|
2532
|
+
pointTokenAddress: getAddress9(pointTokenAddress),
|
|
2662
2533
|
pointAmount,
|
|
2663
2534
|
pools: poolsResult.pools,
|
|
2664
2535
|
gasFeeUsdt: gasFeeResult.gasFeeUsdt
|
|
@@ -2682,7 +2553,7 @@ var IssuerApiAdapter = class {
|
|
|
2682
2553
|
"ptClaimHandler",
|
|
2683
2554
|
"claim"
|
|
2684
2555
|
);
|
|
2685
|
-
const pointTokenAddress =
|
|
2556
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2686
2557
|
const result = await ptClaimHandler.handle({
|
|
2687
2558
|
authenticatedAddress: input.authenticatedAddress,
|
|
2688
2559
|
userAddress: input.authenticatedAddress,
|
|
@@ -2744,7 +2615,7 @@ var IssuerApiAdapter = class {
|
|
|
2744
2615
|
const result = await swapHandler.handle({
|
|
2745
2616
|
userAddress: input.authenticatedAddress,
|
|
2746
2617
|
chainId: input.chainId,
|
|
2747
|
-
pointTokenAddress:
|
|
2618
|
+
pointTokenAddress: getAddress9(input.pointTokenAddress),
|
|
2748
2619
|
amountIn: input.amountIn,
|
|
2749
2620
|
aaNonce: input.aaNonce,
|
|
2750
2621
|
slippageBps: input.slippageBps
|
|
@@ -2807,7 +2678,7 @@ var IssuerApiAdapter = class {
|
|
|
2807
2678
|
"ptClaimHandler",
|
|
2808
2679
|
"claimPrepare"
|
|
2809
2680
|
);
|
|
2810
|
-
const pointTokenAddress =
|
|
2681
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2811
2682
|
const claimResult = await ptClaimHandler.handle({
|
|
2812
2683
|
authenticatedAddress: input.authenticatedAddress,
|
|
2813
2684
|
userAddress: input.authenticatedAddress,
|
|
@@ -2853,7 +2724,7 @@ var IssuerApiAdapter = class {
|
|
|
2853
2724
|
}
|
|
2854
2725
|
async redeemPrepare(input) {
|
|
2855
2726
|
this.assertRedeemHandler();
|
|
2856
|
-
const pointTokenAddress =
|
|
2727
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2857
2728
|
const redeemResponse = await this.cfg.ptRedeemHandler.handle({
|
|
2858
2729
|
userAddress: input.authenticatedAddress,
|
|
2859
2730
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -3378,7 +3249,7 @@ function parseBigDecimalTo18(s) {
|
|
|
3378
3249
|
}
|
|
3379
3250
|
|
|
3380
3251
|
// src/balance/balanceAggregator.ts
|
|
3381
|
-
import { getPointTokenBalance as
|
|
3252
|
+
import { getPointTokenBalance as getPointTokenBalance3 } from "@pafi-dev/core";
|
|
3382
3253
|
var BalanceAggregator = class {
|
|
3383
3254
|
provider;
|
|
3384
3255
|
ledger;
|
|
@@ -3399,7 +3270,7 @@ var BalanceAggregator = class {
|
|
|
3399
3270
|
async getCombinedBalance(user, pointToken) {
|
|
3400
3271
|
const [offChain, onChain] = await Promise.all([
|
|
3401
3272
|
this.ledger.getBalance(user, pointToken),
|
|
3402
|
-
|
|
3273
|
+
getPointTokenBalance3(this.provider, pointToken, user)
|
|
3403
3274
|
]);
|
|
3404
3275
|
return {
|
|
3405
3276
|
offChain,
|
|
@@ -3632,7 +3503,7 @@ var PafiBackendClient = class {
|
|
|
3632
3503
|
};
|
|
3633
3504
|
|
|
3634
3505
|
// src/config.ts
|
|
3635
|
-
import { getAddress as
|
|
3506
|
+
import { getAddress as getAddress10 } from "viem";
|
|
3636
3507
|
import { getContractAddresses as getContractAddresses9 } from "@pafi-dev/core";
|
|
3637
3508
|
function createIssuerService(config) {
|
|
3638
3509
|
if (!config.provider) {
|
|
@@ -3653,7 +3524,7 @@ function createIssuerService(config) {
|
|
|
3653
3524
|
"createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required"
|
|
3654
3525
|
);
|
|
3655
3526
|
}
|
|
3656
|
-
const tokenAddresses = rawAddresses.map((a) =>
|
|
3527
|
+
const tokenAddresses = rawAddresses.map((a) => getAddress10(a));
|
|
3657
3528
|
const ledger = config.ledger;
|
|
3658
3529
|
const sessionStore = config.sessionStore ?? new MemorySessionStore();
|
|
3659
3530
|
const policy = config.policy ?? new DefaultPolicyEngine({ ledger });
|
|
@@ -3722,15 +3593,6 @@ function createIssuerService(config) {
|
|
|
3722
3593
|
};
|
|
3723
3594
|
if (feeManager) handlersConfig.feeManager = feeManager;
|
|
3724
3595
|
if (config.poolsProvider) handlersConfig.poolsProvider = config.poolsProvider;
|
|
3725
|
-
if (config.claim) {
|
|
3726
|
-
handlersConfig.claim = {
|
|
3727
|
-
policy,
|
|
3728
|
-
relayService,
|
|
3729
|
-
issuerSignerWallet: config.claim.issuerSignerWallet,
|
|
3730
|
-
batchExecutorAddress: config.claim.batchExecutorAddress ?? chainAddresses.batchExecutor,
|
|
3731
|
-
lockDurationMs: config.claim.lockDurationMs
|
|
3732
|
-
};
|
|
3733
|
-
}
|
|
3734
3596
|
const handlers = new IssuerApiHandlers(handlersConfig);
|
|
3735
3597
|
if (config.indexer?.autoStart) {
|
|
3736
3598
|
for (const idx of indexers.values()) {
|
|
@@ -3751,7 +3613,7 @@ function createIssuerService(config) {
|
|
|
3751
3613
|
}
|
|
3752
3614
|
|
|
3753
3615
|
// src/issuer-state/validator.ts
|
|
3754
|
-
import { getAddress as
|
|
3616
|
+
import { getAddress as getAddress11 } from "viem";
|
|
3755
3617
|
import {
|
|
3756
3618
|
POINT_TOKEN_V2_ABI as POINT_TOKEN_V2_ABI3,
|
|
3757
3619
|
issuerRegistryGetIssuerFlatAbi,
|
|
@@ -3782,7 +3644,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3782
3644
|
*/
|
|
3783
3645
|
invalidate(pointToken) {
|
|
3784
3646
|
if (pointToken) {
|
|
3785
|
-
const key =
|
|
3647
|
+
const key = getAddress11(pointToken);
|
|
3786
3648
|
this.pointTokenIssuerCache.delete(key);
|
|
3787
3649
|
this.stateCache.delete(key);
|
|
3788
3650
|
this.inflight.delete(key);
|
|
@@ -3797,7 +3659,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3797
3659
|
* The issuer field is set at `initialize()` and never changes.
|
|
3798
3660
|
*/
|
|
3799
3661
|
async getIssuerAddressForPointToken(pointToken) {
|
|
3800
|
-
const key =
|
|
3662
|
+
const key = getAddress11(pointToken);
|
|
3801
3663
|
const cached = this.pointTokenIssuerCache.get(key);
|
|
3802
3664
|
if (cached) return cached;
|
|
3803
3665
|
const issuer = await this.provider.readContract({
|
|
@@ -3805,15 +3667,15 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3805
3667
|
abi: POINT_TOKEN_V2_ABI3,
|
|
3806
3668
|
functionName: "issuer"
|
|
3807
3669
|
});
|
|
3808
|
-
this.pointTokenIssuerCache.set(key,
|
|
3809
|
-
return
|
|
3670
|
+
this.pointTokenIssuerCache.set(key, getAddress11(issuer));
|
|
3671
|
+
return getAddress11(issuer);
|
|
3810
3672
|
}
|
|
3811
3673
|
/**
|
|
3812
3674
|
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
3813
3675
|
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
3814
3676
|
*/
|
|
3815
3677
|
async getIssuerState(pointToken) {
|
|
3816
|
-
const tokenAddr =
|
|
3678
|
+
const tokenAddr = getAddress11(pointToken);
|
|
3817
3679
|
const now = Date.now();
|
|
3818
3680
|
const cached = this.stateCache.get(tokenAddr);
|
|
3819
3681
|
if (cached && cached.expiresAt > now) return cached.value;
|
|
@@ -3927,6 +3789,7 @@ export {
|
|
|
3927
3789
|
IssuerStateError,
|
|
3928
3790
|
IssuerStateValidator,
|
|
3929
3791
|
LockNotFoundError,
|
|
3792
|
+
MemoryPendingUserOpStore,
|
|
3930
3793
|
MemorySessionStore,
|
|
3931
3794
|
NonceManager,
|
|
3932
3795
|
PAFI_ISSUER_SDK_VERSION,
|
|
@@ -3947,8 +3810,6 @@ export {
|
|
|
3947
3810
|
RelayService,
|
|
3948
3811
|
SwapError,
|
|
3949
3812
|
SwapHandler,
|
|
3950
|
-
TopUpRedemptionError,
|
|
3951
|
-
TopUpRedemptionHandler,
|
|
3952
3813
|
authenticateRequest,
|
|
3953
3814
|
createIssuerService,
|
|
3954
3815
|
createNativePtQuoter,
|