@pafi-dev/issuer 0.20.0 → 0.21.0
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/README.md +11 -6
- package/dist/index.cjs +112 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -17
- package/dist/index.d.ts +59 -17
- package/dist/index.js +107 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,20 +14,25 @@ interfaces. Don't bundle into a browser app — use
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
## v0.15.
|
|
17
|
+
## v0.15.x — Uniswap V3 migration (breaking)
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**v0.15.0** — initial V3 migration:
|
|
20
|
+
- `createSubgraphPoolsProvider` returns the Uniswap V3 `PoolKey` shape (`{ token0, token1, fee }`) — sourced from `@pafi-dev/core`. Any consumer typed against an older shape with extra fields will see compile-time type errors and must be updated.
|
|
20
21
|
- New `onError?: (err: Error) => void` option — forward recoverable errors (network, GraphQL, parse) to your observability stack. Throws inside the callback are swallowed so the provider stays total.
|
|
21
22
|
- `feeTier` is range-checked (uint24, < 1_000_000) before building the `PoolKey`; invalid values are skipped with a console.error + `onError` invocation.
|
|
22
|
-
- Subgraph endpoint default → `…/pafi-subgraph-v4` (PAFI
|
|
23
|
+
- Subgraph endpoint default → `…/pafi-subgraph-v4` (the active PAFI Base-mainnet subgraph; see `@pafi-dev/core` for the constant).
|
|
23
24
|
- Bumps peer-deps on `@pafi-dev/core` to `^0.13.0` (V3 types + ABIs).
|
|
24
25
|
|
|
26
|
+
**v0.15.1** — documentation-only cleanup: refreshed JSDoc comments in `nativePtQuoter`, `feeManager`, `relayService` to match the V3 implementation. No behavior change.
|
|
27
|
+
|
|
28
|
+
**v0.15.2** — `POINT_TOKEN_V2_ABI` → `POINT_TOKEN_ABI` rename across core+issuer (canonical name, no version suffix). Breaking export name change; the back-compat alias was removed. Requires `@pafi-dev/core` `^0.14.0`.
|
|
29
|
+
|
|
25
30
|
## Requirements
|
|
26
31
|
|
|
27
32
|
- Node.js ≥ 18
|
|
28
33
|
- TypeScript ≥ 5.0
|
|
29
34
|
- `viem` ^2.0.0 (peer)
|
|
30
|
-
- `@pafi-dev/core` ^0.
|
|
35
|
+
- `@pafi-dev/core` ^0.14.0 (transitive — re-exported)
|
|
31
36
|
|
|
32
37
|
## Installation
|
|
33
38
|
|
|
@@ -156,7 +161,7 @@ export const issuerApiAdapterProvider: Provider = {
|
|
|
156
161
|
provide: ISSUER_API_ADAPTER,
|
|
157
162
|
useFactory: (issuerService, provider, walletClient, dataSource, config) => {
|
|
158
163
|
const ledger = new PostgresPointLedger(dataSource);
|
|
159
|
-
const { issuerRegistry, batchExecutor } = getContractAddresses(8453);
|
|
164
|
+
const { issuerRegistry, batchExecutor, usdc } = getContractAddresses(8453);
|
|
160
165
|
const chainId = config.get<number>("CHAIN_ID");
|
|
161
166
|
const pointToken = config.get<`0x${string}`>("POINT_TOKEN_ADDRESS");
|
|
162
167
|
|
|
@@ -369,7 +374,7 @@ All SDK errors inherit `PafiSdkError`. Subclasses + HTTP mapping:
|
|
|
369
374
|
## References
|
|
370
375
|
|
|
371
376
|
- Architecture: [`ARCHITECTURE.md`](../../ARCHITECTURE.md) at SDK root
|
|
372
|
-
- Fee flow & math: [
|
|
377
|
+
- Fee flow & math: see [`@pafi-dev/core` README — Operator fee quoter](../core/README.md#operator-fee-quoter)
|
|
373
378
|
|
|
374
379
|
## License
|
|
375
380
|
|
package/dist/index.cjs
CHANGED
|
@@ -57,6 +57,7 @@ __export(index_exports, {
|
|
|
57
57
|
PerpDepositError: () => PerpDepositError,
|
|
58
58
|
PerpDepositHandler: () => PerpDepositHandler,
|
|
59
59
|
PointIndexer: () => PointIndexer,
|
|
60
|
+
PointTokenDomainResolver: () => PointTokenDomainResolver,
|
|
60
61
|
PolicyProvider: () => PolicyProvider,
|
|
61
62
|
REDEMPTION_HISTORY_WINDOW_SEC: () => REDEMPTION_HISTORY_WINDOW_SEC,
|
|
62
63
|
RedemptionService: () => RedemptionService,
|
|
@@ -2143,8 +2144,59 @@ var IssuerApiHandlers = class _IssuerApiHandlers {
|
|
|
2143
2144
|
}
|
|
2144
2145
|
};
|
|
2145
2146
|
|
|
2146
|
-
// src/api/
|
|
2147
|
+
// src/api/pointTokenDomainResolver.ts
|
|
2147
2148
|
var import_viem7 = require("viem");
|
|
2149
|
+
var NAME_ABI = [
|
|
2150
|
+
{
|
|
2151
|
+
type: "function",
|
|
2152
|
+
name: "name",
|
|
2153
|
+
stateMutability: "view",
|
|
2154
|
+
inputs: [],
|
|
2155
|
+
outputs: [{ type: "string" }]
|
|
2156
|
+
}
|
|
2157
|
+
];
|
|
2158
|
+
var PointTokenDomainResolver = class {
|
|
2159
|
+
provider;
|
|
2160
|
+
overrides;
|
|
2161
|
+
cache = /* @__PURE__ */ new Map();
|
|
2162
|
+
constructor(config) {
|
|
2163
|
+
this.provider = config.provider;
|
|
2164
|
+
this.overrides = /* @__PURE__ */ new Map();
|
|
2165
|
+
if (config.overrides) {
|
|
2166
|
+
for (const [addr, name] of Object.entries(config.overrides)) {
|
|
2167
|
+
this.overrides.set((0, import_viem7.getAddress)(addr).toLowerCase(), name);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
async resolve(pointTokenAddress) {
|
|
2172
|
+
const key = (0, import_viem7.getAddress)(pointTokenAddress).toLowerCase();
|
|
2173
|
+
const cached = this.cache.get(key);
|
|
2174
|
+
if (cached !== void 0) return cached;
|
|
2175
|
+
const override = this.overrides.get(key);
|
|
2176
|
+
if (override !== void 0) {
|
|
2177
|
+
this.cache.set(key, override);
|
|
2178
|
+
return override;
|
|
2179
|
+
}
|
|
2180
|
+
const name = await this.provider.readContract({
|
|
2181
|
+
address: pointTokenAddress,
|
|
2182
|
+
abi: NAME_ABI,
|
|
2183
|
+
functionName: "name"
|
|
2184
|
+
});
|
|
2185
|
+
this.cache.set(key, name);
|
|
2186
|
+
return name;
|
|
2187
|
+
}
|
|
2188
|
+
/** Invalidate one address (after deploy / proxy upgrade) or all. */
|
|
2189
|
+
invalidate(pointTokenAddress) {
|
|
2190
|
+
if (pointTokenAddress) {
|
|
2191
|
+
this.cache.delete((0, import_viem7.getAddress)(pointTokenAddress).toLowerCase());
|
|
2192
|
+
} else {
|
|
2193
|
+
this.cache.clear();
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2198
|
+
// src/api/handlers/ptRedeemHandler.ts
|
|
2199
|
+
var import_viem8 = require("viem");
|
|
2148
2200
|
var import_core7 = require("@pafi-dev/core");
|
|
2149
2201
|
var DEFAULT_REDEEM_LOCK_MS = 15 * 60 * 1e3;
|
|
2150
2202
|
var DEFAULT_SIG_DEADLINE_SEC = 15 * 60;
|
|
@@ -2165,10 +2217,9 @@ var PTRedeemHandler = class {
|
|
|
2165
2217
|
relayService;
|
|
2166
2218
|
provider;
|
|
2167
2219
|
feeService;
|
|
2168
|
-
pointTokenAddress;
|
|
2169
2220
|
batchExecutorAddress;
|
|
2170
2221
|
chainId;
|
|
2171
|
-
|
|
2222
|
+
domainResolver;
|
|
2172
2223
|
burnerSignerWallet;
|
|
2173
2224
|
redeemLockDurationMs;
|
|
2174
2225
|
signatureDeadlineSeconds;
|
|
@@ -2205,10 +2256,9 @@ var PTRedeemHandler = class {
|
|
|
2205
2256
|
this.relayService = config.relayService;
|
|
2206
2257
|
this.provider = config.provider;
|
|
2207
2258
|
this.feeService = config.feeService;
|
|
2208
|
-
this.
|
|
2209
|
-
this.batchExecutorAddress = (0, import_viem7.getAddress)(config.batchExecutorAddress);
|
|
2259
|
+
this.batchExecutorAddress = (0, import_viem8.getAddress)(config.batchExecutorAddress);
|
|
2210
2260
|
this.chainId = config.chainId;
|
|
2211
|
-
this.
|
|
2261
|
+
this.domainResolver = config.domainResolver;
|
|
2212
2262
|
this.burnerSignerWallet = config.burnerSignerWallet;
|
|
2213
2263
|
if (this.burnerSignerWallet?.account?.type === "local") {
|
|
2214
2264
|
console.warn("[PAFI] PTRedeemHandler: burnerSignerWallet uses a local (private key) account. Use a KMS-backed signer in production.");
|
|
@@ -2221,7 +2271,7 @@ var PTRedeemHandler = class {
|
|
|
2221
2271
|
}
|
|
2222
2272
|
}
|
|
2223
2273
|
async handle(request) {
|
|
2224
|
-
if ((0,
|
|
2274
|
+
if ((0, import_viem8.getAddress)(request.authenticatedAddress) !== (0, import_viem8.getAddress)(request.userAddress)) {
|
|
2225
2275
|
throw new PTRedeemError(
|
|
2226
2276
|
"UNAUTHORIZED",
|
|
2227
2277
|
`userAddress (${request.userAddress}) does not match authenticated session (${request.authenticatedAddress})`
|
|
@@ -2230,11 +2280,12 @@ var PTRedeemHandler = class {
|
|
|
2230
2280
|
if (request.amount <= 0n) {
|
|
2231
2281
|
throw new PTRedeemError("INVALID_AMOUNT", "redeem amount must be positive");
|
|
2232
2282
|
}
|
|
2283
|
+
const pointTokenAddress = (0, import_viem8.getAddress)(request.pointTokenAddress);
|
|
2233
2284
|
if (this.redemptionService) {
|
|
2234
2285
|
const decision = await this.redemptionService.evaluate(
|
|
2235
2286
|
request.userAddress,
|
|
2236
2287
|
request.amount,
|
|
2237
|
-
|
|
2288
|
+
pointTokenAddress
|
|
2238
2289
|
);
|
|
2239
2290
|
if (!decision.allowed) {
|
|
2240
2291
|
const denial = decision.denial;
|
|
@@ -2248,7 +2299,7 @@ var PTRedeemHandler = class {
|
|
|
2248
2299
|
let burnNonce;
|
|
2249
2300
|
try {
|
|
2250
2301
|
burnNonce = await this.provider.readContract({
|
|
2251
|
-
address:
|
|
2302
|
+
address: pointTokenAddress,
|
|
2252
2303
|
abi: import_core7.POINT_TOKEN_ABI,
|
|
2253
2304
|
functionName: "burnRequestNonces",
|
|
2254
2305
|
args: [request.userAddress]
|
|
@@ -2259,27 +2310,27 @@ var PTRedeemHandler = class {
|
|
|
2259
2310
|
`failed to read burnRequestNonces(${request.userAddress}): ${err instanceof Error ? err.message : String(err)}`
|
|
2260
2311
|
);
|
|
2261
2312
|
}
|
|
2262
|
-
const
|
|
2263
|
-
let userNonces = this.inFlightNonces.get(
|
|
2313
|
+
const nonceKey = `${(0, import_viem8.getAddress)(request.userAddress).toLowerCase()}:${pointTokenAddress.toLowerCase()}`;
|
|
2314
|
+
let userNonces = this.inFlightNonces.get(nonceKey);
|
|
2264
2315
|
if (!userNonces) {
|
|
2265
2316
|
userNonces = /* @__PURE__ */ new Set();
|
|
2266
|
-
this.inFlightNonces.set(
|
|
2317
|
+
this.inFlightNonces.set(nonceKey, userNonces);
|
|
2267
2318
|
}
|
|
2268
2319
|
if (userNonces.has(burnNonce)) {
|
|
2269
2320
|
throw new PTRedeemError(
|
|
2270
2321
|
"NONCE_IN_FLIGHT",
|
|
2271
|
-
`A burn request for nonce ${burnNonce} is already in progress for ${request.userAddress}. Retry after the current request completes.`
|
|
2322
|
+
`A burn request for nonce ${burnNonce} is already in progress for ${request.userAddress} on ${pointTokenAddress}. Retry after the current request completes.`
|
|
2272
2323
|
);
|
|
2273
2324
|
}
|
|
2274
2325
|
userNonces.add(burnNonce);
|
|
2275
2326
|
try {
|
|
2276
|
-
return await this._handleAfterNonceLock(request, burnNonce);
|
|
2327
|
+
return await this._handleAfterNonceLock(request, burnNonce, pointTokenAddress);
|
|
2277
2328
|
} finally {
|
|
2278
2329
|
userNonces.delete(burnNonce);
|
|
2279
|
-
if (userNonces.size === 0) this.inFlightNonces.delete(
|
|
2330
|
+
if (userNonces.size === 0) this.inFlightNonces.delete(nonceKey);
|
|
2280
2331
|
}
|
|
2281
2332
|
}
|
|
2282
|
-
async _handleAfterNonceLock(request, burnNonce) {
|
|
2333
|
+
async _handleAfterNonceLock(request, burnNonce, pointTokenAddress) {
|
|
2283
2334
|
const previewDeadline = BigInt(
|
|
2284
2335
|
Math.floor(this.now() / 1e3) + this.signatureDeadlineSeconds
|
|
2285
2336
|
);
|
|
@@ -2290,13 +2341,13 @@ var PTRedeemHandler = class {
|
|
|
2290
2341
|
const previewUserOp = this.relayService.previewBurnUserOp({
|
|
2291
2342
|
userAddress: request.userAddress,
|
|
2292
2343
|
aaNonce: burnNonce,
|
|
2293
|
-
pointTokenAddress
|
|
2344
|
+
pointTokenAddress,
|
|
2294
2345
|
amount: request.amount,
|
|
2295
2346
|
deadline: previewDeadline
|
|
2296
2347
|
});
|
|
2297
2348
|
fee = await this.feeService.estimateGasFee({
|
|
2298
2349
|
scenario: "burn",
|
|
2299
|
-
contractAddress:
|
|
2350
|
+
contractAddress: pointTokenAddress,
|
|
2300
2351
|
partialUserOp: {
|
|
2301
2352
|
sender: previewUserOp.sender,
|
|
2302
2353
|
nonce: previewUserOp.nonce,
|
|
@@ -2315,7 +2366,7 @@ var PTRedeemHandler = class {
|
|
|
2315
2366
|
}
|
|
2316
2367
|
const onChainBalance = await (0, import_core7.getPointTokenBalance)(
|
|
2317
2368
|
this.provider,
|
|
2318
|
-
|
|
2369
|
+
pointTokenAddress,
|
|
2319
2370
|
request.userAddress
|
|
2320
2371
|
);
|
|
2321
2372
|
if (onChainBalance < request.amount) {
|
|
@@ -2325,10 +2376,11 @@ var PTRedeemHandler = class {
|
|
|
2325
2376
|
);
|
|
2326
2377
|
}
|
|
2327
2378
|
const deadline = previewDeadline;
|
|
2379
|
+
const domainName = await this.domainResolver.resolve(pointTokenAddress);
|
|
2328
2380
|
const domain = {
|
|
2329
|
-
name:
|
|
2381
|
+
name: domainName,
|
|
2330
2382
|
chainId: this.chainId,
|
|
2331
|
-
verifyingContract:
|
|
2383
|
+
verifyingContract: pointTokenAddress
|
|
2332
2384
|
};
|
|
2333
2385
|
const sponsoredBurnAmount = request.amount - fee;
|
|
2334
2386
|
const sponsoredBurnRequest = {
|
|
@@ -2350,14 +2402,14 @@ var PTRedeemHandler = class {
|
|
|
2350
2402
|
request.userAddress,
|
|
2351
2403
|
sponsoredBurnAmount,
|
|
2352
2404
|
this.redeemLockDurationMs,
|
|
2353
|
-
|
|
2405
|
+
pointTokenAddress
|
|
2354
2406
|
);
|
|
2355
2407
|
try {
|
|
2356
2408
|
const sponsoredUserOp = await this.relayService.prepareBurn({
|
|
2357
2409
|
mode: "burnWithSig",
|
|
2358
2410
|
userAddress: request.userAddress,
|
|
2359
2411
|
aaNonce: request.aaNonce,
|
|
2360
|
-
pointTokenAddress
|
|
2412
|
+
pointTokenAddress,
|
|
2361
2413
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
2362
2414
|
burnRequest: sponsoredBurnRequest,
|
|
2363
2415
|
burnerSignature: sponsoredSig,
|
|
@@ -2385,7 +2437,7 @@ var PTRedeemHandler = class {
|
|
|
2385
2437
|
request.userAddress,
|
|
2386
2438
|
request.amount,
|
|
2387
2439
|
this.redeemLockDurationMs,
|
|
2388
|
-
|
|
2440
|
+
pointTokenAddress
|
|
2389
2441
|
);
|
|
2390
2442
|
let fallbackUserOp;
|
|
2391
2443
|
try {
|
|
@@ -2393,7 +2445,7 @@ var PTRedeemHandler = class {
|
|
|
2393
2445
|
mode: "burnWithSig",
|
|
2394
2446
|
userAddress: request.userAddress,
|
|
2395
2447
|
aaNonce: request.aaNonce,
|
|
2396
|
-
pointTokenAddress
|
|
2448
|
+
pointTokenAddress,
|
|
2397
2449
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
2398
2450
|
burnRequest: fallbackBurnRequest,
|
|
2399
2451
|
burnerSignature: fallbackSig,
|
|
@@ -2418,7 +2470,7 @@ var PTRedeemHandler = class {
|
|
|
2418
2470
|
await this.redemptionService.recordSuccessfulInitiate({
|
|
2419
2471
|
user: request.userAddress,
|
|
2420
2472
|
amountPt: request.amount,
|
|
2421
|
-
pointTokenAddress
|
|
2473
|
+
pointTokenAddress,
|
|
2422
2474
|
reservationId: sponsoredLockId
|
|
2423
2475
|
}).catch(() => {
|
|
2424
2476
|
});
|
|
@@ -2541,7 +2593,7 @@ async function handleRedeemStatus(params) {
|
|
|
2541
2593
|
}
|
|
2542
2594
|
|
|
2543
2595
|
// src/api/mobileHandlers.ts
|
|
2544
|
-
var
|
|
2596
|
+
var import_viem9 = require("viem");
|
|
2545
2597
|
var import_core10 = require("@pafi-dev/core");
|
|
2546
2598
|
|
|
2547
2599
|
// src/userop-store/serialize.ts
|
|
@@ -2887,7 +2939,7 @@ async function handleMobileSubmit(params) {
|
|
|
2887
2939
|
if (!entry) {
|
|
2888
2940
|
throw new PendingUserOpNotFoundError(params.lockId);
|
|
2889
2941
|
}
|
|
2890
|
-
if ((0,
|
|
2942
|
+
if ((0, import_viem9.getAddress)(entry.sender) !== (0, import_viem9.getAddress)(params.authenticatedAddress)) {
|
|
2891
2943
|
throw new PendingUserOpForbiddenError(params.lockId);
|
|
2892
2944
|
}
|
|
2893
2945
|
const variant = params.variant ?? "sponsored";
|
|
@@ -2903,7 +2955,7 @@ async function handleMobileSubmit(params) {
|
|
|
2903
2955
|
}
|
|
2904
2956
|
|
|
2905
2957
|
// src/api/handlers/ptClaimHandler.ts
|
|
2906
|
-
var
|
|
2958
|
+
var import_viem10 = require("viem");
|
|
2907
2959
|
var import_core11 = require("@pafi-dev/core");
|
|
2908
2960
|
|
|
2909
2961
|
// src/issuer-state/types.ts
|
|
@@ -2949,7 +3001,7 @@ var PTClaimHandler = class {
|
|
|
2949
3001
|
};
|
|
2950
3002
|
}
|
|
2951
3003
|
async handle(request) {
|
|
2952
|
-
if ((0,
|
|
3004
|
+
if ((0, import_viem10.getAddress)(request.authenticatedAddress) !== (0, import_viem10.getAddress)(request.userAddress)) {
|
|
2953
3005
|
throw new PTClaimError(
|
|
2954
3006
|
"VALIDATION_FAILED",
|
|
2955
3007
|
`userAddress (${request.userAddress}) does not match authenticated session (${request.authenticatedAddress})`
|
|
@@ -3004,8 +3056,11 @@ var PTClaimHandler = class {
|
|
|
3004
3056
|
callData: previewUserOp.callData
|
|
3005
3057
|
}
|
|
3006
3058
|
}) : 0n;
|
|
3059
|
+
const domainName = await this.cfg.domainResolver.resolve(
|
|
3060
|
+
request.pointTokenAddress
|
|
3061
|
+
);
|
|
3007
3062
|
const domain = {
|
|
3008
|
-
name:
|
|
3063
|
+
name: domainName,
|
|
3009
3064
|
chainId: request.chainId,
|
|
3010
3065
|
verifyingContract: request.pointTokenAddress
|
|
3011
3066
|
};
|
|
@@ -3203,7 +3258,7 @@ var PerpDepositHandler = class {
|
|
|
3203
3258
|
|
|
3204
3259
|
// src/api/delegateHandler.ts
|
|
3205
3260
|
var import_core13 = require("@pafi-dev/core");
|
|
3206
|
-
var
|
|
3261
|
+
var import_viem11 = require("viem");
|
|
3207
3262
|
var DEFAULT_DELEGATE_GAS = {
|
|
3208
3263
|
callGasLimit: 100000n,
|
|
3209
3264
|
verificationGasLimit: 150000n,
|
|
@@ -3290,7 +3345,7 @@ async function handleDelegateSubmit(params) {
|
|
|
3290
3345
|
if (!entry) {
|
|
3291
3346
|
throw new PendingUserOpNotFoundError(params.lockId);
|
|
3292
3347
|
}
|
|
3293
|
-
if ((0,
|
|
3348
|
+
if ((0, import_viem11.getAddress)(entry.sender) !== (0, import_viem11.getAddress)(params.authenticatedAddress)) {
|
|
3294
3349
|
throw new PendingUserOpForbiddenError(params.lockId);
|
|
3295
3350
|
}
|
|
3296
3351
|
if (!entry.eip7702Auth) {
|
|
@@ -3311,7 +3366,7 @@ async function handleDelegateSubmit(params) {
|
|
|
3311
3366
|
|
|
3312
3367
|
// src/api/issuerApiAdapter.ts
|
|
3313
3368
|
var import_node_crypto3 = require("crypto");
|
|
3314
|
-
var
|
|
3369
|
+
var import_viem12 = require("viem");
|
|
3315
3370
|
var import_core14 = require("@pafi-dev/core");
|
|
3316
3371
|
var AdapterMisconfiguredError = class extends Error {
|
|
3317
3372
|
code = "ADAPTER_MISCONFIGURED";
|
|
@@ -3369,7 +3424,7 @@ var IssuerApiAdapter = class {
|
|
|
3369
3424
|
async pools(authenticatedAddress, chainId, pointTokenAddress) {
|
|
3370
3425
|
const result = await this.cfg.issuerService.api.handlePools(
|
|
3371
3426
|
authenticatedAddress,
|
|
3372
|
-
{ chainId, pointTokenAddress: (0,
|
|
3427
|
+
{ chainId, pointTokenAddress: (0, import_viem12.getAddress)(pointTokenAddress) }
|
|
3373
3428
|
);
|
|
3374
3429
|
return { pools: result.pools };
|
|
3375
3430
|
}
|
|
@@ -3378,8 +3433,8 @@ var IssuerApiAdapter = class {
|
|
|
3378
3433
|
authenticatedAddress,
|
|
3379
3434
|
{
|
|
3380
3435
|
chainId,
|
|
3381
|
-
userAddress: (0,
|
|
3382
|
-
pointTokenAddress: (0,
|
|
3436
|
+
userAddress: (0, import_viem12.getAddress)(userAddress),
|
|
3437
|
+
pointTokenAddress: (0, import_viem12.getAddress)(pointTokenAddress)
|
|
3383
3438
|
}
|
|
3384
3439
|
);
|
|
3385
3440
|
return {
|
|
@@ -3400,7 +3455,7 @@ var IssuerApiAdapter = class {
|
|
|
3400
3455
|
"ptClaimHandler",
|
|
3401
3456
|
"claim"
|
|
3402
3457
|
);
|
|
3403
|
-
const pointTokenAddress = (0,
|
|
3458
|
+
const pointTokenAddress = (0, import_viem12.getAddress)(input.pointTokenAddress);
|
|
3404
3459
|
const result = await ptClaimHandler.handle({
|
|
3405
3460
|
authenticatedAddress: input.authenticatedAddress,
|
|
3406
3461
|
userAddress: input.authenticatedAddress,
|
|
@@ -3427,9 +3482,11 @@ var IssuerApiAdapter = class {
|
|
|
3427
3482
|
}
|
|
3428
3483
|
async redeem(input) {
|
|
3429
3484
|
this.assertRedeemHandler();
|
|
3485
|
+
const pointTokenAddress = (0, import_viem12.getAddress)(input.pointTokenAddress);
|
|
3430
3486
|
const response = await this.cfg.ptRedeemHandler.handle({
|
|
3431
3487
|
userAddress: input.authenticatedAddress,
|
|
3432
3488
|
authenticatedAddress: input.authenticatedAddress,
|
|
3489
|
+
pointTokenAddress,
|
|
3433
3490
|
amount: input.amount,
|
|
3434
3491
|
aaNonce: input.aaNonce,
|
|
3435
3492
|
chainId: input.chainId
|
|
@@ -3495,7 +3552,7 @@ var IssuerApiAdapter = class {
|
|
|
3495
3552
|
"ptClaimHandler",
|
|
3496
3553
|
"claimPrepare"
|
|
3497
3554
|
);
|
|
3498
|
-
const pointTokenAddress = (0,
|
|
3555
|
+
const pointTokenAddress = (0, import_viem12.getAddress)(input.pointTokenAddress);
|
|
3499
3556
|
const claimResult = await ptClaimHandler.handle({
|
|
3500
3557
|
authenticatedAddress: input.authenticatedAddress,
|
|
3501
3558
|
userAddress: input.authenticatedAddress,
|
|
@@ -3541,10 +3598,11 @@ var IssuerApiAdapter = class {
|
|
|
3541
3598
|
}
|
|
3542
3599
|
async redeemPrepare(input) {
|
|
3543
3600
|
this.assertRedeemHandler();
|
|
3544
|
-
const pointTokenAddress = (0,
|
|
3601
|
+
const pointTokenAddress = (0, import_viem12.getAddress)(input.pointTokenAddress);
|
|
3545
3602
|
const redeemResponse = await this.cfg.ptRedeemHandler.handle({
|
|
3546
3603
|
userAddress: input.authenticatedAddress,
|
|
3547
3604
|
authenticatedAddress: input.authenticatedAddress,
|
|
3605
|
+
pointTokenAddress,
|
|
3548
3606
|
amount: input.amount,
|
|
3549
3607
|
aaNonce: input.aaNonce,
|
|
3550
3608
|
chainId: input.chainId
|
|
@@ -3731,7 +3789,7 @@ var IssuerApiAdapter = class {
|
|
|
3731
3789
|
};
|
|
3732
3790
|
|
|
3733
3791
|
// src/pools/subgraphPoolsProvider.ts
|
|
3734
|
-
var
|
|
3792
|
+
var import_viem13 = require("viem");
|
|
3735
3793
|
var import_core15 = require("@pafi-dev/core");
|
|
3736
3794
|
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
3737
3795
|
var MAX_REASONABLE_FEE_TIER = 1e6;
|
|
@@ -3854,7 +3912,7 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress,
|
|
|
3854
3912
|
return [];
|
|
3855
3913
|
}
|
|
3856
3914
|
const { pool } = token;
|
|
3857
|
-
if (!(0,
|
|
3915
|
+
if (!(0, import_viem13.isAddress)(pool.token0.id) || !(0, import_viem13.isAddress)(pool.token1.id)) {
|
|
3858
3916
|
const error = new Error(
|
|
3859
3917
|
"[PAFI] SubgraphPoolsProvider: invalid token address in response"
|
|
3860
3918
|
);
|
|
@@ -4007,8 +4065,8 @@ function toUsdtPerNative(priceFloat, usdtDecimals) {
|
|
|
4007
4065
|
}
|
|
4008
4066
|
|
|
4009
4067
|
// src/pools/nativePtQuoter.ts
|
|
4010
|
-
var
|
|
4011
|
-
var CHAINLINK_ABI = (0,
|
|
4068
|
+
var import_viem14 = require("viem");
|
|
4069
|
+
var CHAINLINK_ABI = (0, import_viem14.parseAbi)([
|
|
4012
4070
|
"function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"
|
|
4013
4071
|
]);
|
|
4014
4072
|
var CHAINLINK_MAX_AGE_S = 3600n;
|
|
@@ -4292,7 +4350,7 @@ var PafiBackendClient = class {
|
|
|
4292
4350
|
};
|
|
4293
4351
|
|
|
4294
4352
|
// src/config.ts
|
|
4295
|
-
var
|
|
4353
|
+
var import_viem15 = require("viem");
|
|
4296
4354
|
var import_core18 = require("@pafi-dev/core");
|
|
4297
4355
|
|
|
4298
4356
|
// src/redemption/evaluator.ts
|
|
@@ -4619,7 +4677,7 @@ function createIssuerService(config) {
|
|
|
4619
4677
|
"createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required"
|
|
4620
4678
|
);
|
|
4621
4679
|
}
|
|
4622
|
-
const tokenAddresses = rawAddresses.map((a) => (0,
|
|
4680
|
+
const tokenAddresses = rawAddresses.map((a) => (0, import_viem15.getAddress)(a));
|
|
4623
4681
|
const ledger = config.ledger;
|
|
4624
4682
|
const sessionStore = config.sessionStore ?? new MemorySessionStore();
|
|
4625
4683
|
const policy = config.policy ?? new DefaultPolicyEngine({ ledger });
|
|
@@ -4738,7 +4796,7 @@ function createIssuerService(config) {
|
|
|
4738
4796
|
}
|
|
4739
4797
|
|
|
4740
4798
|
// src/issuer-state/validator.ts
|
|
4741
|
-
var
|
|
4799
|
+
var import_viem16 = require("viem");
|
|
4742
4800
|
var import_core19 = require("@pafi-dev/core");
|
|
4743
4801
|
var ISSUER_RECORD_TTL_MS = 3e4;
|
|
4744
4802
|
var IssuerStateValidator = class _IssuerStateValidator {
|
|
@@ -4765,7 +4823,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4765
4823
|
*/
|
|
4766
4824
|
invalidate(pointToken) {
|
|
4767
4825
|
if (pointToken) {
|
|
4768
|
-
const key = (0,
|
|
4826
|
+
const key = (0, import_viem16.getAddress)(pointToken);
|
|
4769
4827
|
this.pointTokenIssuerCache.delete(key);
|
|
4770
4828
|
this.stateCache.delete(key);
|
|
4771
4829
|
this.inflight.delete(key);
|
|
@@ -4780,7 +4838,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4780
4838
|
* The issuer field is set at `initialize()` and never changes.
|
|
4781
4839
|
*/
|
|
4782
4840
|
async getIssuerAddressForPointToken(pointToken) {
|
|
4783
|
-
const key = (0,
|
|
4841
|
+
const key = (0, import_viem16.getAddress)(pointToken);
|
|
4784
4842
|
const cached = this.pointTokenIssuerCache.get(key);
|
|
4785
4843
|
if (cached) return cached;
|
|
4786
4844
|
const issuer = await this.provider.readContract({
|
|
@@ -4788,15 +4846,15 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4788
4846
|
abi: import_core19.POINT_TOKEN_ABI,
|
|
4789
4847
|
functionName: "issuer"
|
|
4790
4848
|
});
|
|
4791
|
-
this.pointTokenIssuerCache.set(key, (0,
|
|
4792
|
-
return (0,
|
|
4849
|
+
this.pointTokenIssuerCache.set(key, (0, import_viem16.getAddress)(issuer));
|
|
4850
|
+
return (0, import_viem16.getAddress)(issuer);
|
|
4793
4851
|
}
|
|
4794
4852
|
/**
|
|
4795
4853
|
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
4796
4854
|
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
4797
4855
|
*/
|
|
4798
4856
|
async getIssuerState(pointToken) {
|
|
4799
|
-
const tokenAddr = (0,
|
|
4857
|
+
const tokenAddr = (0, import_viem16.getAddress)(pointToken);
|
|
4800
4858
|
const now = Date.now();
|
|
4801
4859
|
const cached = this.stateCache.get(tokenAddr);
|
|
4802
4860
|
if (cached && cached.expiresAt > now) return cached.value;
|
|
@@ -4939,7 +4997,7 @@ var MemoryRedemptionHistoryStore = class {
|
|
|
4939
4997
|
};
|
|
4940
4998
|
|
|
4941
4999
|
// src/index.ts
|
|
4942
|
-
var PAFI_ISSUER_SDK_VERSION = true ? "0.
|
|
5000
|
+
var PAFI_ISSUER_SDK_VERSION = true ? "0.21.0" : "dev";
|
|
4943
5001
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4944
5002
|
0 && (module.exports = {
|
|
4945
5003
|
AdapterMisconfiguredError,
|
|
@@ -4979,6 +5037,7 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.20.0" : "dev";
|
|
|
4979
5037
|
PerpDepositError,
|
|
4980
5038
|
PerpDepositHandler,
|
|
4981
5039
|
PointIndexer,
|
|
5040
|
+
PointTokenDomainResolver,
|
|
4982
5041
|
PolicyProvider,
|
|
4983
5042
|
REDEMPTION_HISTORY_WINDOW_SEC,
|
|
4984
5043
|
RedemptionService,
|