@pafi-dev/issuer 0.5.41 → 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 +186 -291
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -194
- package/dist/index.d.ts +56 -194
- package/dist/index.js +115 -220
- 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
|
|
@@ -2677,8 +2548,13 @@ var IssuerApiAdapter = class {
|
|
|
2677
2548
|
}
|
|
2678
2549
|
// ------------------------------ Action endpoints -------------------------
|
|
2679
2550
|
async claim(input) {
|
|
2680
|
-
const
|
|
2681
|
-
|
|
2551
|
+
const ptClaimHandler = this.assertHandler(
|
|
2552
|
+
this.cfg.ptClaimHandler,
|
|
2553
|
+
"ptClaimHandler",
|
|
2554
|
+
"claim"
|
|
2555
|
+
);
|
|
2556
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2557
|
+
const result = await ptClaimHandler.handle({
|
|
2682
2558
|
authenticatedAddress: input.authenticatedAddress,
|
|
2683
2559
|
userAddress: input.authenticatedAddress,
|
|
2684
2560
|
amount: input.amount,
|
|
@@ -2731,10 +2607,15 @@ var IssuerApiAdapter = class {
|
|
|
2731
2607
|
};
|
|
2732
2608
|
}
|
|
2733
2609
|
async swap(input) {
|
|
2734
|
-
const
|
|
2610
|
+
const swapHandler = this.assertHandler(
|
|
2611
|
+
this.cfg.swapHandler,
|
|
2612
|
+
"swapHandler",
|
|
2613
|
+
"swap"
|
|
2614
|
+
);
|
|
2615
|
+
const result = await swapHandler.handle({
|
|
2735
2616
|
userAddress: input.authenticatedAddress,
|
|
2736
2617
|
chainId: input.chainId,
|
|
2737
|
-
pointTokenAddress:
|
|
2618
|
+
pointTokenAddress: getAddress9(input.pointTokenAddress),
|
|
2738
2619
|
amountIn: input.amountIn,
|
|
2739
2620
|
aaNonce: input.aaNonce,
|
|
2740
2621
|
slippageBps: input.slippageBps
|
|
@@ -2758,7 +2639,12 @@ var IssuerApiAdapter = class {
|
|
|
2758
2639
|
};
|
|
2759
2640
|
}
|
|
2760
2641
|
async perpDeposit(input) {
|
|
2761
|
-
const
|
|
2642
|
+
const perpHandler = this.assertHandler(
|
|
2643
|
+
this.cfg.perpHandler,
|
|
2644
|
+
"perpHandler",
|
|
2645
|
+
"perpDeposit"
|
|
2646
|
+
);
|
|
2647
|
+
const result = await perpHandler.handle({
|
|
2762
2648
|
userAddress: input.authenticatedAddress,
|
|
2763
2649
|
chainId: input.chainId,
|
|
2764
2650
|
amount: input.amount,
|
|
@@ -2787,8 +2673,13 @@ var IssuerApiAdapter = class {
|
|
|
2787
2673
|
}
|
|
2788
2674
|
// ------------------------------ Mobile endpoints -------------------------
|
|
2789
2675
|
async claimPrepare(input) {
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2676
|
+
const ptClaimHandler = this.assertHandler(
|
|
2677
|
+
this.cfg.ptClaimHandler,
|
|
2678
|
+
"ptClaimHandler",
|
|
2679
|
+
"claimPrepare"
|
|
2680
|
+
);
|
|
2681
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2682
|
+
const claimResult = await ptClaimHandler.handle({
|
|
2792
2683
|
authenticatedAddress: input.authenticatedAddress,
|
|
2793
2684
|
userAddress: input.authenticatedAddress,
|
|
2794
2685
|
amount: input.amount,
|
|
@@ -2833,7 +2724,7 @@ var IssuerApiAdapter = class {
|
|
|
2833
2724
|
}
|
|
2834
2725
|
async redeemPrepare(input) {
|
|
2835
2726
|
this.assertRedeemHandler();
|
|
2836
|
-
const pointTokenAddress =
|
|
2727
|
+
const pointTokenAddress = getAddress9(input.pointTokenAddress);
|
|
2837
2728
|
const redeemResponse = await this.cfg.ptRedeemHandler.handle({
|
|
2838
2729
|
userAddress: input.authenticatedAddress,
|
|
2839
2730
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -2978,6 +2869,20 @@ var IssuerApiAdapter = class {
|
|
|
2978
2869
|
);
|
|
2979
2870
|
}
|
|
2980
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Narrow an optional handler to non-null and throw a clear error when
|
|
2874
|
+
* the issuer wired the adapter without it. Lets issuers opt out of
|
|
2875
|
+
* flows they don't expose (gg56 ships only mobile claim/redeem, so
|
|
2876
|
+
* `swapHandler` + `perpHandler` aren't constructed).
|
|
2877
|
+
*/
|
|
2878
|
+
assertHandler(handler, fieldName, methodName) {
|
|
2879
|
+
if (handler === null || handler === void 0) {
|
|
2880
|
+
throw new Error(
|
|
2881
|
+
`${fieldName} not wired \u2014 IssuerApiAdapter.${methodName}() requires a configured ${fieldName}.`
|
|
2882
|
+
);
|
|
2883
|
+
}
|
|
2884
|
+
return handler;
|
|
2885
|
+
}
|
|
2981
2886
|
};
|
|
2982
2887
|
|
|
2983
2888
|
// src/pools/subgraphPoolsProvider.ts
|
|
@@ -3344,7 +3249,7 @@ function parseBigDecimalTo18(s) {
|
|
|
3344
3249
|
}
|
|
3345
3250
|
|
|
3346
3251
|
// src/balance/balanceAggregator.ts
|
|
3347
|
-
import { getPointTokenBalance as
|
|
3252
|
+
import { getPointTokenBalance as getPointTokenBalance3 } from "@pafi-dev/core";
|
|
3348
3253
|
var BalanceAggregator = class {
|
|
3349
3254
|
provider;
|
|
3350
3255
|
ledger;
|
|
@@ -3365,7 +3270,7 @@ var BalanceAggregator = class {
|
|
|
3365
3270
|
async getCombinedBalance(user, pointToken) {
|
|
3366
3271
|
const [offChain, onChain] = await Promise.all([
|
|
3367
3272
|
this.ledger.getBalance(user, pointToken),
|
|
3368
|
-
|
|
3273
|
+
getPointTokenBalance3(this.provider, pointToken, user)
|
|
3369
3274
|
]);
|
|
3370
3275
|
return {
|
|
3371
3276
|
offChain,
|
|
@@ -3598,7 +3503,7 @@ var PafiBackendClient = class {
|
|
|
3598
3503
|
};
|
|
3599
3504
|
|
|
3600
3505
|
// src/config.ts
|
|
3601
|
-
import { getAddress as
|
|
3506
|
+
import { getAddress as getAddress10 } from "viem";
|
|
3602
3507
|
import { getContractAddresses as getContractAddresses9 } from "@pafi-dev/core";
|
|
3603
3508
|
function createIssuerService(config) {
|
|
3604
3509
|
if (!config.provider) {
|
|
@@ -3619,7 +3524,7 @@ function createIssuerService(config) {
|
|
|
3619
3524
|
"createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required"
|
|
3620
3525
|
);
|
|
3621
3526
|
}
|
|
3622
|
-
const tokenAddresses = rawAddresses.map((a) =>
|
|
3527
|
+
const tokenAddresses = rawAddresses.map((a) => getAddress10(a));
|
|
3623
3528
|
const ledger = config.ledger;
|
|
3624
3529
|
const sessionStore = config.sessionStore ?? new MemorySessionStore();
|
|
3625
3530
|
const policy = config.policy ?? new DefaultPolicyEngine({ ledger });
|
|
@@ -3688,15 +3593,6 @@ function createIssuerService(config) {
|
|
|
3688
3593
|
};
|
|
3689
3594
|
if (feeManager) handlersConfig.feeManager = feeManager;
|
|
3690
3595
|
if (config.poolsProvider) handlersConfig.poolsProvider = config.poolsProvider;
|
|
3691
|
-
if (config.claim) {
|
|
3692
|
-
handlersConfig.claim = {
|
|
3693
|
-
policy,
|
|
3694
|
-
relayService,
|
|
3695
|
-
issuerSignerWallet: config.claim.issuerSignerWallet,
|
|
3696
|
-
batchExecutorAddress: config.claim.batchExecutorAddress ?? chainAddresses.batchExecutor,
|
|
3697
|
-
lockDurationMs: config.claim.lockDurationMs
|
|
3698
|
-
};
|
|
3699
|
-
}
|
|
3700
3596
|
const handlers = new IssuerApiHandlers(handlersConfig);
|
|
3701
3597
|
if (config.indexer?.autoStart) {
|
|
3702
3598
|
for (const idx of indexers.values()) {
|
|
@@ -3717,7 +3613,7 @@ function createIssuerService(config) {
|
|
|
3717
3613
|
}
|
|
3718
3614
|
|
|
3719
3615
|
// src/issuer-state/validator.ts
|
|
3720
|
-
import { getAddress as
|
|
3616
|
+
import { getAddress as getAddress11 } from "viem";
|
|
3721
3617
|
import {
|
|
3722
3618
|
POINT_TOKEN_V2_ABI as POINT_TOKEN_V2_ABI3,
|
|
3723
3619
|
issuerRegistryGetIssuerFlatAbi,
|
|
@@ -3748,7 +3644,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3748
3644
|
*/
|
|
3749
3645
|
invalidate(pointToken) {
|
|
3750
3646
|
if (pointToken) {
|
|
3751
|
-
const key =
|
|
3647
|
+
const key = getAddress11(pointToken);
|
|
3752
3648
|
this.pointTokenIssuerCache.delete(key);
|
|
3753
3649
|
this.stateCache.delete(key);
|
|
3754
3650
|
this.inflight.delete(key);
|
|
@@ -3763,7 +3659,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3763
3659
|
* The issuer field is set at `initialize()` and never changes.
|
|
3764
3660
|
*/
|
|
3765
3661
|
async getIssuerAddressForPointToken(pointToken) {
|
|
3766
|
-
const key =
|
|
3662
|
+
const key = getAddress11(pointToken);
|
|
3767
3663
|
const cached = this.pointTokenIssuerCache.get(key);
|
|
3768
3664
|
if (cached) return cached;
|
|
3769
3665
|
const issuer = await this.provider.readContract({
|
|
@@ -3771,15 +3667,15 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3771
3667
|
abi: POINT_TOKEN_V2_ABI3,
|
|
3772
3668
|
functionName: "issuer"
|
|
3773
3669
|
});
|
|
3774
|
-
this.pointTokenIssuerCache.set(key,
|
|
3775
|
-
return
|
|
3670
|
+
this.pointTokenIssuerCache.set(key, getAddress11(issuer));
|
|
3671
|
+
return getAddress11(issuer);
|
|
3776
3672
|
}
|
|
3777
3673
|
/**
|
|
3778
3674
|
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
3779
3675
|
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
3780
3676
|
*/
|
|
3781
3677
|
async getIssuerState(pointToken) {
|
|
3782
|
-
const tokenAddr =
|
|
3678
|
+
const tokenAddr = getAddress11(pointToken);
|
|
3783
3679
|
const now = Date.now();
|
|
3784
3680
|
const cached = this.stateCache.get(tokenAddr);
|
|
3785
3681
|
if (cached && cached.expiresAt > now) return cached.value;
|
|
@@ -3893,6 +3789,7 @@ export {
|
|
|
3893
3789
|
IssuerStateError,
|
|
3894
3790
|
IssuerStateValidator,
|
|
3895
3791
|
LockNotFoundError,
|
|
3792
|
+
MemoryPendingUserOpStore,
|
|
3896
3793
|
MemorySessionStore,
|
|
3897
3794
|
NonceManager,
|
|
3898
3795
|
PAFI_ISSUER_SDK_VERSION,
|
|
@@ -3913,8 +3810,6 @@ export {
|
|
|
3913
3810
|
RelayService,
|
|
3914
3811
|
SwapError,
|
|
3915
3812
|
SwapHandler,
|
|
3916
|
-
TopUpRedemptionError,
|
|
3917
|
-
TopUpRedemptionHandler,
|
|
3918
3813
|
authenticateRequest,
|
|
3919
3814
|
createIssuerService,
|
|
3920
3815
|
createNativePtQuoter,
|