@pafi-dev/issuer 0.7.3 → 0.7.5

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 CHANGED
@@ -40,14 +40,14 @@ __export(index_exports, {
40
40
  MemorySessionStore: () => MemorySessionStore,
41
41
  NonceManager: () => NonceManager,
42
42
  PAFI_ISSUER_SDK_VERSION: () => PAFI_ISSUER_SDK_VERSION,
43
- PAFI_SUBGRAPH_URL: () => import_core12.PAFI_SUBGRAPH_URL,
43
+ PAFI_SUBGRAPH_URL: () => import_core15.PAFI_SUBGRAPH_URL,
44
44
  PTClaimError: () => PTClaimError,
45
45
  PTClaimHandler: () => PTClaimHandler,
46
46
  PTRedeemError: () => PTRedeemError,
47
47
  PTRedeemHandler: () => PTRedeemHandler,
48
48
  PafiBackendClient: () => PafiBackendClient,
49
49
  PafiBackendError: () => PafiBackendError,
50
- PafiSdkError: () => PafiSdkError,
50
+ PafiSdkError: () => import_core.PafiSdkError,
51
51
  PendingUserOpForbiddenError: () => PendingUserOpForbiddenError,
52
52
  PendingUserOpNotFoundError: () => PendingUserOpNotFoundError,
53
53
  PerpDepositError: () => PerpDepositError,
@@ -55,7 +55,7 @@ __export(index_exports, {
55
55
  PointIndexer: () => PointIndexer,
56
56
  RelayError: () => RelayError,
57
57
  RelayService: () => RelayService,
58
- ValidationError: () => ValidationError,
58
+ ValidationError: () => import_core3.ValidationError,
59
59
  authenticateRequest: () => authenticateRequest,
60
60
  createIssuerService: () => createIssuerService,
61
61
  createNativePtQuoter: () => createNativePtQuoter,
@@ -77,31 +77,10 @@ __export(index_exports, {
77
77
  module.exports = __toCommonJS(index_exports);
78
78
 
79
79
  // src/errors.ts
80
- var PafiSdkError = class extends Error {
81
- /**
82
- * `true` when the FE should consider a retry safe — typically because
83
- * the failure is transient (`MINT_CAP_EXCEEDED` may free up,
84
- * `RELAY_FEE_EXCEEDS_AMOUNT` may drop on next quote). Defaults to
85
- * `false` — subclasses opt in per-code.
86
- */
87
- safeToRetry = false;
88
- details;
89
- constructor(message) {
90
- super(message);
91
- this.name = new.target.name;
92
- }
93
- };
94
- var ValidationError = class extends PafiSdkError {
95
- httpStatus = "unprocessable";
96
- code;
97
- details;
98
- constructor(code, message, details) {
99
- super(message);
100
- this.code = code;
101
- this.details = details;
102
- }
103
- };
104
- var ConfigurationError = class extends PafiSdkError {
80
+ var import_core = require("@pafi-dev/core");
81
+ var import_core2 = require("@pafi-dev/core");
82
+ var import_core3 = require("@pafi-dev/core");
83
+ var ConfigurationError = class extends import_core2.PafiSdkError {
105
84
  httpStatus = "service_unavailable";
106
85
  code;
107
86
  details;
@@ -278,7 +257,7 @@ var NonceManager = class {
278
257
  var import_node_crypto2 = require("crypto");
279
258
  var import_jose = require("jose");
280
259
  var import_viem2 = require("viem");
281
- var import_core = require("@pafi-dev/core");
260
+ var import_core4 = require("@pafi-dev/core");
282
261
 
283
262
  // src/auth/errors.ts
284
263
  function statusForCode(code) {
@@ -300,7 +279,7 @@ function statusForCode(code) {
300
279
  return "not_found";
301
280
  }
302
281
  }
303
- var AuthError = class extends PafiSdkError {
282
+ var AuthError = class extends import_core.PafiSdkError {
304
283
  code;
305
284
  httpStatus;
306
285
  constructor(code, message) {
@@ -346,7 +325,7 @@ var AuthService = class {
346
325
  async login(message, signature) {
347
326
  let parsed;
348
327
  try {
349
- parsed = (0, import_core.parseLoginMessage)(message);
328
+ parsed = (0, import_core4.parseLoginMessage)(message);
350
329
  } catch (err) {
351
330
  const msg = err instanceof Error ? err.message : String(err);
352
331
  throw new AuthError("INVALID_MESSAGE", `Could not parse login message: ${msg}`);
@@ -379,7 +358,7 @@ var AuthService = class {
379
358
  if (parsed.expirationTime && parsed.expirationTime.getTime() <= now.getTime()) {
380
359
  throw new AuthError("MESSAGE_EXPIRED", "Login message has expired");
381
360
  }
382
- const verifyResult = await (0, import_core.verifyLoginMessage)(message, signature);
361
+ const verifyResult = await (0, import_core4.verifyLoginMessage)(message, signature);
383
362
  if (!verifyResult.valid) {
384
363
  throw new AuthError(
385
364
  "SIGNATURE_INVALID",
@@ -503,7 +482,7 @@ async function authenticateRequest(authHeader, authService) {
503
482
  }
504
483
 
505
484
  // src/relay/types.ts
506
- var RelayError = class extends PafiSdkError {
485
+ var RelayError = class extends import_core.PafiSdkError {
507
486
  httpStatus = "unprocessable";
508
487
  code;
509
488
  constructor(code, message, cause) {
@@ -517,7 +496,7 @@ var RelayError = class extends PafiSdkError {
517
496
 
518
497
  // src/relay/relayService.ts
519
498
  var import_viem3 = require("viem");
520
- var import_core2 = require("@pafi-dev/core");
499
+ var import_core5 = require("@pafi-dev/core");
521
500
  var RelayService = class {
522
501
  provider;
523
502
  chainId;
@@ -542,12 +521,12 @@ var RelayService = class {
542
521
  * transfer to be added to the batch.
543
522
  */
544
523
  async resolveFee(params) {
545
- const feeRecipient = params.feeRecipient ?? (this.chainId !== void 0 ? (0, import_core2.getContractAddresses)(this.chainId).pafiFeeRecipient : void 0);
524
+ const feeRecipient = params.feeRecipient ?? (this.chainId !== void 0 ? (0, import_core5.getContractAddresses)(this.chainId).pafiFeeRecipient : void 0);
546
525
  if (params.feeAmount !== void 0) {
547
526
  return { feeAmount: params.feeAmount, feeRecipient };
548
527
  }
549
528
  if (this.provider && this.chainId !== void 0) {
550
- const feeAmount = await (0, import_core2.quoteOperatorFeePt)({
529
+ const feeAmount = await (0, import_core5.quoteOperatorFeePt)({
551
530
  provider: this.provider,
552
531
  chainId: this.chainId,
553
532
  pointTokenAddress: params.pointTokenAddress
@@ -601,7 +580,7 @@ var RelayService = class {
601
580
  }
602
581
  let minterSig;
603
582
  try {
604
- const sig = await (0, import_core2.signMintRequest)(
583
+ const sig = await (0, import_core5.signMintRequest)(
605
584
  params.issuerSignerWallet,
606
585
  params.domain,
607
586
  {
@@ -622,7 +601,7 @@ var RelayService = class {
622
601
  let mintCallData;
623
602
  try {
624
603
  mintCallData = (0, import_viem3.encodeFunctionData)({
625
- abi: import_core2.POINT_TOKEN_V2_ABI,
604
+ abi: import_core5.POINT_TOKEN_V2_ABI,
626
605
  functionName: "mint",
627
606
  args: [params.userAddress, params.amount, params.deadline, minterSig]
628
607
  });
@@ -668,7 +647,7 @@ var RelayService = class {
668
647
  })
669
648
  });
670
649
  }
671
- return (0, import_core2.buildPartialUserOperation)({
650
+ return (0, import_core5.buildPartialUserOperation)({
672
651
  sender: params.userAddress,
673
652
  nonce: params.aaNonce,
674
653
  operations,
@@ -707,7 +686,7 @@ var RelayService = class {
707
686
  let burnCallData;
708
687
  try {
709
688
  burnCallData = (0, import_viem3.encodeFunctionData)({
710
- abi: import_core2.POINT_TOKEN_V2_ABI,
689
+ abi: import_core5.POINT_TOKEN_V2_ABI,
711
690
  functionName: "burn",
712
691
  args: [
713
692
  params.burnRequest.from,
@@ -757,7 +736,7 @@ var RelayService = class {
757
736
  value: 0n,
758
737
  data: burnCallData
759
738
  });
760
- return (0, import_core2.buildPartialUserOperation)({
739
+ return (0, import_core5.buildPartialUserOperation)({
761
740
  sender: params.userAddress,
762
741
  nonce: params.aaNonce,
763
742
  operations,
@@ -1168,7 +1147,7 @@ var BurnIndexer = class {
1168
1147
 
1169
1148
  // src/api/handlers.ts
1170
1149
  var import_viem6 = require("viem");
1171
- var import_core3 = require("@pafi-dev/core");
1150
+ var import_core6 = require("@pafi-dev/core");
1172
1151
  var IssuerApiHandlers = class {
1173
1152
  authService;
1174
1153
  ledger;
@@ -1212,16 +1191,16 @@ var IssuerApiHandlers = class {
1212
1191
  /** `POST /auth/login` */
1213
1192
  async handleLogin(body) {
1214
1193
  if (!body || typeof body.message !== "string" || body.message.length === 0 || typeof body.signature !== "string" || body.signature.length <= 2) {
1215
- throw new ValidationError(
1194
+ throw new import_core3.ValidationError(
1216
1195
  "INVALID_LOGIN_BODY",
1217
1196
  "handleLogin: message and signature are required"
1218
1197
  );
1219
1198
  }
1220
1199
  if (body.message.length > 4096) {
1221
- throw new ValidationError("MESSAGE_TOO_LONG", "message too long");
1200
+ throw new import_core3.ValidationError("MESSAGE_TOO_LONG", "message too long");
1222
1201
  }
1223
1202
  if (body.signature.length > 260) {
1224
- throw new ValidationError("SIGNATURE_TOO_LONG", "signature too long");
1203
+ throw new import_core3.ValidationError("SIGNATURE_TOO_LONG", "signature too long");
1225
1204
  }
1226
1205
  const result = await this.authService.login(body.message, body.signature);
1227
1206
  return {
@@ -1238,12 +1217,12 @@ var IssuerApiHandlers = class {
1238
1217
  */
1239
1218
  async handleConfig(chainId) {
1240
1219
  if (!Number.isInteger(chainId) || chainId <= 0) {
1241
- throw new ValidationError("INVALID_CHAIN_ID", "invalid chainId", {
1220
+ throw new import_core3.ValidationError("INVALID_CHAIN_ID", "invalid chainId", {
1242
1221
  chainId
1243
1222
  });
1244
1223
  }
1245
1224
  if (chainId !== this.chainId) {
1246
- throw new ValidationError(
1225
+ throw new import_core3.ValidationError(
1247
1226
  "UNSUPPORTED_CHAIN_ID",
1248
1227
  `handleConfig: unsupported chainId ${chainId}`,
1249
1228
  { requested: chainId, supported: this.chainId }
@@ -1292,7 +1271,7 @@ var IssuerApiHandlers = class {
1292
1271
  );
1293
1272
  }
1294
1273
  if (request.chainId !== this.chainId) {
1295
- throw new ValidationError(
1274
+ throw new import_core3.ValidationError(
1296
1275
  "UNSUPPORTED_CHAIN_ID",
1297
1276
  `handlePools: unsupported chainId ${request.chainId}`,
1298
1277
  { requested: request.chainId, supported: this.chainId }
@@ -1309,7 +1288,7 @@ var IssuerApiHandlers = class {
1309
1288
  */
1310
1289
  async handleUser(userAddress, request) {
1311
1290
  if (request.chainId !== this.chainId) {
1312
- throw new ValidationError(
1291
+ throw new import_core3.ValidationError(
1313
1292
  "UNSUPPORTED_CHAIN_ID",
1314
1293
  `handleUser: unsupported chainId ${request.chainId}`,
1315
1294
  { requested: request.chainId, supported: this.chainId }
@@ -1318,7 +1297,7 @@ var IssuerApiHandlers = class {
1318
1297
  const normalizedAuthed = (0, import_viem6.getAddress)(userAddress);
1319
1298
  const normalizedRequest = (0, import_viem6.getAddress)(request.userAddress);
1320
1299
  if (normalizedAuthed !== normalizedRequest) {
1321
- throw new ValidationError(
1300
+ throw new import_core3.ValidationError(
1322
1301
  "USER_ADDRESS_MISMATCH",
1323
1302
  "handleUser: request userAddress must match authenticated user",
1324
1303
  { authenticated: normalizedAuthed, requested: normalizedRequest }
@@ -1326,18 +1305,18 @@ var IssuerApiHandlers = class {
1326
1305
  }
1327
1306
  const pointToken = (0, import_viem6.getAddress)(request.pointTokenAddress);
1328
1307
  if (!this.supportedTokens.has(pointToken)) {
1329
- throw new ValidationError(
1308
+ throw new import_core3.ValidationError(
1330
1309
  "UNSUPPORTED_POINT_TOKEN",
1331
1310
  `handleUser: unsupported pointToken ${pointToken}`,
1332
1311
  { requested: pointToken }
1333
1312
  );
1334
1313
  }
1335
1314
  const [mintRequestNonce, receiverConsentNonce, offChainBalance, onChainBalance, minter] = await Promise.all([
1336
- (0, import_core3.getMintRequestNonce)(this.provider, pointToken, normalizedAuthed),
1337
- (0, import_core3.getReceiverConsentNonce)(this.provider, pointToken, normalizedAuthed),
1315
+ (0, import_core6.getMintRequestNonce)(this.provider, pointToken, normalizedAuthed),
1316
+ (0, import_core6.getReceiverConsentNonce)(this.provider, pointToken, normalizedAuthed),
1338
1317
  this.ledger.getBalance(normalizedAuthed, pointToken),
1339
- (0, import_core3.getPointTokenBalance)(this.provider, pointToken, normalizedAuthed),
1340
- (0, import_core3.isMinter)(this.provider, pointToken, normalizedAuthed)
1318
+ (0, import_core6.getPointTokenBalance)(this.provider, pointToken, normalizedAuthed),
1319
+ (0, import_core6.isMinter)(this.provider, pointToken, normalizedAuthed)
1341
1320
  ]);
1342
1321
  return {
1343
1322
  mintRequestNonce,
@@ -1357,10 +1336,10 @@ var IssuerApiHandlers = class {
1357
1336
 
1358
1337
  // src/api/handlers/ptRedeemHandler.ts
1359
1338
  var import_viem7 = require("viem");
1360
- var import_core4 = require("@pafi-dev/core");
1339
+ var import_core7 = require("@pafi-dev/core");
1361
1340
  var DEFAULT_REDEEM_LOCK_MS = 15 * 60 * 1e3;
1362
1341
  var DEFAULT_SIG_DEADLINE_SEC = 15 * 60;
1363
- var PTRedeemError = class extends PafiSdkError {
1342
+ var PTRedeemError = class extends import_core.PafiSdkError {
1364
1343
  httpStatus = "unprocessable";
1365
1344
  code;
1366
1345
  constructor(code, message) {
@@ -1438,7 +1417,7 @@ var PTRedeemHandler = class {
1438
1417
  try {
1439
1418
  burnNonce = await this.provider.readContract({
1440
1419
  address: this.pointTokenAddress,
1441
- abi: import_core4.POINT_TOKEN_V2_ABI,
1420
+ abi: import_core7.POINT_TOKEN_V2_ABI,
1442
1421
  functionName: "burnRequestNonces",
1443
1422
  args: [request.userAddress]
1444
1423
  });
@@ -1477,14 +1456,14 @@ var PTRedeemHandler = class {
1477
1456
  } else {
1478
1457
  fee = 0n;
1479
1458
  }
1480
- const feeRecipient = request.feeRecipient ?? (request.chainId !== void 0 ? (0, import_core4.getContractAddresses)(request.chainId).pafiFeeRecipient : (0, import_core4.getContractAddresses)(this.chainId).pafiFeeRecipient);
1459
+ const feeRecipient = request.feeRecipient ?? (request.chainId !== void 0 ? (0, import_core7.getContractAddresses)(request.chainId).pafiFeeRecipient : (0, import_core7.getContractAddresses)(this.chainId).pafiFeeRecipient);
1481
1460
  if (fee > 0n && fee >= request.amount) {
1482
1461
  throw new PTRedeemError(
1483
1462
  "INVALID_AMOUNT",
1484
1463
  `fee (${fee}) must be strictly less than redeem amount (${request.amount})`
1485
1464
  );
1486
1465
  }
1487
- const onChainBalance = await (0, import_core4.getPointTokenBalance)(
1466
+ const onChainBalance = await (0, import_core7.getPointTokenBalance)(
1488
1467
  this.provider,
1489
1468
  this.pointTokenAddress,
1490
1469
  request.userAddress
@@ -1512,7 +1491,7 @@ var PTRedeemHandler = class {
1512
1491
  };
1513
1492
  let sponsoredSig;
1514
1493
  try {
1515
- sponsoredSig = (await (0, import_core4.signBurnRequest)(this.burnerSignerWallet, domain, sponsoredBurnRequest)).serialized;
1494
+ sponsoredSig = (await (0, import_core7.signBurnRequest)(this.burnerSignerWallet, domain, sponsoredBurnRequest)).serialized;
1516
1495
  } catch (err) {
1517
1496
  throw new PTRedeemError(
1518
1497
  "SIGNING_FAILED",
@@ -1547,7 +1526,7 @@ var PTRedeemHandler = class {
1547
1526
  };
1548
1527
  let fallbackSig;
1549
1528
  try {
1550
- fallbackSig = (await (0, import_core4.signBurnRequest)(this.burnerSignerWallet, domain, fallbackBurnRequest)).serialized;
1529
+ fallbackSig = (await (0, import_core7.signBurnRequest)(this.burnerSignerWallet, domain, fallbackBurnRequest)).serialized;
1551
1530
  } catch (err) {
1552
1531
  throw new PTRedeemError(
1553
1532
  "SIGNING_FAILED",
@@ -1605,7 +1584,7 @@ var PTRedeemHandler = class {
1605
1584
  };
1606
1585
 
1607
1586
  // src/api/statusHandlers.ts
1608
- var LockNotFoundError = class extends PafiSdkError {
1587
+ var LockNotFoundError = class extends import_core.PafiSdkError {
1609
1588
  code = "LOCK_NOT_FOUND";
1610
1589
  httpStatus = "not_found";
1611
1590
  constructor() {
@@ -1706,10 +1685,10 @@ async function handleRedeemStatus(params) {
1706
1685
 
1707
1686
  // src/api/mobileHandlers.ts
1708
1687
  var import_viem8 = require("viem");
1709
- var import_core7 = require("@pafi-dev/core");
1688
+ var import_core10 = require("@pafi-dev/core");
1710
1689
 
1711
1690
  // src/userop-store/serialize.ts
1712
- var import_core5 = require("@pafi-dev/core");
1691
+ var import_core8 = require("@pafi-dev/core");
1713
1692
  function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
1714
1693
  if (variant === "fallback") {
1715
1694
  if (!entry.fallback) {
@@ -1717,7 +1696,7 @@ function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
1717
1696
  "serializeEntryToJsonRpc: variant=fallback requested but the stored entry has no `fallback` branch \u2014 caller should resubmit with variant='sponsored' or re-prepare with a fee configured."
1718
1697
  );
1719
1698
  }
1720
- return (0, import_core5.serializeUserOpToJsonRpc)(
1699
+ return (0, import_core8.serializeUserOpToJsonRpc)(
1721
1700
  {
1722
1701
  sender: entry.sender,
1723
1702
  nonce: BigInt(entry.nonce),
@@ -1732,7 +1711,7 @@ function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
1732
1711
  signature
1733
1712
  );
1734
1713
  }
1735
- return (0, import_core5.serializeUserOpToJsonRpc)(
1714
+ return (0, import_core8.serializeUserOpToJsonRpc)(
1736
1715
  {
1737
1716
  sender: entry.sender,
1738
1717
  nonce: BigInt(entry.nonce),
@@ -1779,7 +1758,7 @@ var MemoryPendingUserOpStore = class {
1779
1758
  };
1780
1759
 
1781
1760
  // src/userop-store/prepareUserOp.ts
1782
- var import_core6 = require("@pafi-dev/core");
1761
+ var import_core9 = require("@pafi-dev/core");
1783
1762
  function serializeUserOpTypedData(td) {
1784
1763
  return {
1785
1764
  domain: td.domain,
@@ -1814,9 +1793,9 @@ async function prepareMobileUserOp(params) {
1814
1793
  params.partialUserOp,
1815
1794
  params.paymasterFields
1816
1795
  );
1817
- const userOpHash = (0, import_core6.computeUserOpHash)(userOp, params.chainId);
1796
+ const userOpHash = (0, import_core9.computeUserOpHash)(userOp, params.chainId);
1818
1797
  const typedData = serializeUserOpTypedData(
1819
- (0, import_core6.buildUserOpTypedData)(userOp, params.chainId)
1798
+ (0, import_core9.buildUserOpTypedData)(userOp, params.chainId)
1820
1799
  );
1821
1800
  let fallback;
1822
1801
  let fallbackEntry;
@@ -1826,9 +1805,9 @@ async function prepareMobileUserOp(params) {
1826
1805
  maxFeePerGas: userOp.maxFeePerGas,
1827
1806
  maxPriorityFeePerGas: userOp.maxPriorityFeePerGas
1828
1807
  };
1829
- const fallbackHash = (0, import_core6.computeUserOpHash)(fallbackUserOp, params.chainId);
1808
+ const fallbackHash = (0, import_core9.computeUserOpHash)(fallbackUserOp, params.chainId);
1830
1809
  const fallbackTypedData = serializeUserOpTypedData(
1831
- (0, import_core6.buildUserOpTypedData)(fallbackUserOp, params.chainId)
1810
+ (0, import_core9.buildUserOpTypedData)(fallbackUserOp, params.chainId)
1832
1811
  );
1833
1812
  fallback = {
1834
1813
  userOp: fallbackUserOp,
@@ -1904,7 +1883,7 @@ var PafiBackendError = class extends Error {
1904
1883
  };
1905
1884
 
1906
1885
  // src/pafi-backend/helpers.ts
1907
- var BundlerNotConfiguredError = class extends PafiSdkError {
1886
+ var BundlerNotConfiguredError = class extends import_core.PafiSdkError {
1908
1887
  code = "BUNDLER_NOT_CONFIGURED";
1909
1888
  httpStatus = "service_unavailable";
1910
1889
  constructor() {
@@ -1913,7 +1892,7 @@ var BundlerNotConfiguredError = class extends PafiSdkError {
1913
1892
  );
1914
1893
  }
1915
1894
  };
1916
- var BundlerRejectedError = class extends PafiSdkError {
1895
+ var BundlerRejectedError = class extends import_core.PafiSdkError {
1917
1896
  code = "BUNDLER_REJECTED";
1918
1897
  httpStatus = "unprocessable";
1919
1898
  cause;
@@ -1934,7 +1913,8 @@ async function requestPaymaster(params) {
1934
1913
  contract: params.pointTokenAddress,
1935
1914
  function: fn,
1936
1915
  pointToken: params.pointTokenAddress
1937
- }
1916
+ },
1917
+ ...params.eip7702Auth ? { eip7702Auth: params.eip7702Auth } : {}
1938
1918
  });
1939
1919
  } catch (err) {
1940
1920
  const msg = err instanceof Error ? err.message : String(err);
@@ -1989,7 +1969,7 @@ async function relayUserOp(params) {
1989
1969
  }
1990
1970
 
1991
1971
  // src/api/mobileHandlers.ts
1992
- var PendingUserOpNotFoundError = class extends PafiSdkError {
1972
+ var PendingUserOpNotFoundError = class extends import_core.PafiSdkError {
1993
1973
  code = "PENDING_USEROP_NOT_FOUND";
1994
1974
  httpStatus = "not_found";
1995
1975
  constructor(lockId) {
@@ -1998,7 +1978,7 @@ var PendingUserOpNotFoundError = class extends PafiSdkError {
1998
1978
  );
1999
1979
  }
2000
1980
  };
2001
- var PendingUserOpForbiddenError = class extends PafiSdkError {
1981
+ var PendingUserOpForbiddenError = class extends import_core.PafiSdkError {
2002
1982
  code = "PENDING_USEROP_FORBIDDEN";
2003
1983
  httpStatus = "forbidden";
2004
1984
  constructor(lockId) {
@@ -2012,7 +1992,7 @@ async function handleMobilePrepare(params) {
2012
1992
  params.provider.estimateFeesPerGas(),
2013
1993
  params.provider.getCode({ address: params.userAddress })
2014
1994
  ]);
2015
- const needsDelegation = (0, import_core7.parseEip7702DelegatedAddress)(userCode) === null;
1995
+ const needsDelegation = (0, import_core10.parseEip7702DelegatedAddress)(userCode) === null;
2016
1996
  const sponsoredOp = {
2017
1997
  ...params.partialUserOp,
2018
1998
  maxFeePerGas: fees.maxFeePerGas ?? params.partialUserOp.maxFeePerGas ?? 0n,
@@ -2054,7 +2034,7 @@ async function handleMobileSubmit(params) {
2054
2034
  const result = await relayUserOp({
2055
2035
  client: params.pafiBackendClient,
2056
2036
  userOp: userOpJson,
2057
- entryPoint: params.entryPoint ?? import_core7.ENTRY_POINT_V08
2037
+ entryPoint: params.entryPoint ?? import_core10.ENTRY_POINT_V08
2058
2038
  });
2059
2039
  await params.bindUserOpHash(params.lockId, result.userOpHash);
2060
2040
  await params.store.delete(params.lockId);
@@ -2063,10 +2043,10 @@ async function handleMobileSubmit(params) {
2063
2043
 
2064
2044
  // src/api/handlers/ptClaimHandler.ts
2065
2045
  var import_viem9 = require("viem");
2066
- var import_core8 = require("@pafi-dev/core");
2046
+ var import_core11 = require("@pafi-dev/core");
2067
2047
 
2068
2048
  // src/issuer-state/types.ts
2069
- var IssuerStateError = class extends PafiSdkError {
2049
+ var IssuerStateError = class extends import_core.PafiSdkError {
2070
2050
  httpStatus = "unprocessable";
2071
2051
  code;
2072
2052
  details;
@@ -2080,7 +2060,7 @@ var IssuerStateError = class extends PafiSdkError {
2080
2060
  };
2081
2061
 
2082
2062
  // src/api/handlers/ptClaimHandler.ts
2083
- var PTClaimError = class extends PafiSdkError {
2063
+ var PTClaimError = class extends import_core.PafiSdkError {
2084
2064
  httpStatus = "unprocessable";
2085
2065
  code;
2086
2066
  details;
@@ -2126,7 +2106,7 @@ var PTClaimHandler = class {
2126
2106
  );
2127
2107
  }
2128
2108
  }
2129
- const { batchExecutor: batchExecutorAddress } = (0, import_core8.getContractAddresses)(
2109
+ const { batchExecutor: batchExecutorAddress } = (0, import_core11.getContractAddresses)(
2130
2110
  request.chainId
2131
2111
  );
2132
2112
  const lockId = await this.cfg.ledger.lockForMinting(
@@ -2187,8 +2167,8 @@ var PTClaimHandler = class {
2187
2167
  );
2188
2168
  }
2189
2169
  }
2190
- const calls = (0, import_core8.decodeBatchExecuteCalls)(userOp.callData);
2191
- const callsFallback = fallback ? (0, import_core8.decodeBatchExecuteCalls)(fallback.callData) : void 0;
2170
+ const calls = (0, import_core11.decodeBatchExecuteCalls)(userOp.callData);
2171
+ const callsFallback = fallback ? (0, import_core11.decodeBatchExecuteCalls)(fallback.callData) : void 0;
2192
2172
  return {
2193
2173
  userOp,
2194
2174
  fallback,
@@ -2208,8 +2188,8 @@ var PTClaimHandler = class {
2208
2188
  };
2209
2189
 
2210
2190
  // src/api/handlers/perpDepositHandler.ts
2211
- var import_core9 = require("@pafi-dev/core");
2212
- var PerpDepositError = class extends PafiSdkError {
2191
+ var import_core12 = require("@pafi-dev/core");
2192
+ var PerpDepositError = class extends import_core.PafiSdkError {
2213
2193
  httpStatus = "unprocessable";
2214
2194
  code;
2215
2195
  safeToRetry;
@@ -2232,26 +2212,26 @@ var PerpDepositHandler = class {
2232
2212
  if (request.amount <= 0n) {
2233
2213
  throw new PerpDepositError("INVALID_AMOUNT", "amount must be positive");
2234
2214
  }
2235
- const brokerHash = import_core9.BROKER_HASHES[request.brokerId];
2236
- const tokenHash = import_core9.TOKEN_HASHES.USDC;
2237
- const vault = import_core9.ORDERLY_VAULT_ADDRESSES[request.chainId];
2215
+ const brokerHash = import_core12.BROKER_HASHES[request.brokerId];
2216
+ const tokenHash = import_core12.TOKEN_HASHES.USDC;
2217
+ const vault = import_core12.ORDERLY_VAULT_ADDRESSES[request.chainId];
2238
2218
  if (!vault) {
2239
2219
  throw new PerpDepositError(
2240
2220
  "PERP_DEPOSIT_UNAVAILABLE",
2241
2221
  `no Orderly Vault for chainId ${request.chainId}`
2242
2222
  );
2243
2223
  }
2244
- const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0, import_core9.getContractAddresses)(request.chainId);
2224
+ const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0, import_core12.getContractAddresses)(request.chainId);
2245
2225
  const [usdcAddress, brokerAllowed] = await Promise.all([
2246
2226
  this.cfg.provider.readContract({
2247
2227
  address: vault,
2248
- abi: import_core9.ORDERLY_VAULT_ABI,
2228
+ abi: import_core12.ORDERLY_VAULT_ABI,
2249
2229
  functionName: "getAllowedToken",
2250
2230
  args: [tokenHash]
2251
2231
  }),
2252
2232
  this.cfg.provider.readContract({
2253
2233
  address: vault,
2254
- abi: import_core9.ORDERLY_VAULT_ABI,
2234
+ abi: import_core12.ORDERLY_VAULT_ABI,
2255
2235
  functionName: "getAllowedBroker",
2256
2236
  args: [brokerHash]
2257
2237
  })
@@ -2262,7 +2242,7 @@ var PerpDepositHandler = class {
2262
2242
  `broker "${request.brokerId}" is not whitelisted on Orderly Vault`
2263
2243
  );
2264
2244
  }
2265
- const accountId = (0, import_core9.computeAccountId)(request.userAddress, brokerHash);
2245
+ const accountId = (0, import_core12.computeAccountId)(request.userAddress, brokerHash);
2266
2246
  const requestForQuote = {
2267
2247
  token: usdcAddress,
2268
2248
  receiver: request.userAddress,
@@ -2273,11 +2253,11 @@ var PerpDepositHandler = class {
2273
2253
  const [relayTokenFee, usdcGasFee] = await Promise.all([
2274
2254
  this.cfg.provider.readContract({
2275
2255
  address: relayAddress,
2276
- abi: import_core9.ORDERLY_RELAY_ABI,
2256
+ abi: import_core12.ORDERLY_RELAY_ABI,
2277
2257
  functionName: "quoteTokenFee",
2278
2258
  args: [requestForQuote]
2279
2259
  }),
2280
- (0, import_core9.quoteOperatorFeeUsdt)({
2260
+ (0, import_core12.quoteOperatorFeeUsdt)({
2281
2261
  provider: this.cfg.provider,
2282
2262
  chainId: request.chainId,
2283
2263
  gasUnits: this.cfg.gasUnits,
@@ -2304,7 +2284,7 @@ var PerpDepositHandler = class {
2304
2284
  totalAmount: request.amount,
2305
2285
  maxFee
2306
2286
  };
2307
- const sponsoredOp = (0, import_core9.buildPerpDepositViaRelay)({
2287
+ const sponsoredOp = (0, import_core12.buildPerpDepositViaRelay)({
2308
2288
  userAddress: request.userAddress,
2309
2289
  aaNonce: request.aaNonce,
2310
2290
  relayAddress,
@@ -2312,7 +2292,7 @@ var PerpDepositHandler = class {
2312
2292
  gasFeeUsdc: usdcGasFee,
2313
2293
  gasFeeUsdcRecipient: pafiFeeRecipient
2314
2294
  });
2315
- const fallbackOp = usdcGasFee > 0n ? (0, import_core9.buildPerpDepositViaRelay)({
2295
+ const fallbackOp = usdcGasFee > 0n ? (0, import_core12.buildPerpDepositViaRelay)({
2316
2296
  userAddress: request.userAddress,
2317
2297
  aaNonce: request.aaNonce,
2318
2298
  relayAddress,
@@ -2329,22 +2309,22 @@ var PerpDepositHandler = class {
2329
2309
  brokerHash,
2330
2310
  usdcAddress,
2331
2311
  relayAddress,
2332
- calls: (0, import_core9.decodeBatchExecuteCalls)(sponsoredOp.callData),
2333
- callsFallback: fallbackOp ? (0, import_core9.decodeBatchExecuteCalls)(fallbackOp.callData) : void 0
2312
+ calls: (0, import_core12.decodeBatchExecuteCalls)(sponsoredOp.callData),
2313
+ callsFallback: fallbackOp ? (0, import_core12.decodeBatchExecuteCalls)(fallbackOp.callData) : void 0
2334
2314
  };
2335
2315
  }
2336
2316
  };
2337
2317
 
2338
2318
  // src/api/delegateHandler.ts
2339
- var import_core10 = require("@pafi-dev/core");
2319
+ var import_core13 = require("@pafi-dev/core");
2340
2320
  var DEFAULT_DELEGATE_GAS = {
2341
2321
  callGasLimit: 100000n,
2342
2322
  verificationGasLimit: 150000n,
2343
2323
  preVerificationGas: 50000n
2344
2324
  };
2345
2325
  async function handleDelegateSubmit(params) {
2346
- const { batchExecutor } = (0, import_core10.getContractAddresses)(params.chainId);
2347
- const partial = (0, import_core10.buildDelegationUserOp)({
2326
+ const { batchExecutor } = (0, import_core13.getContractAddresses)(params.chainId);
2327
+ const partial = (0, import_core13.buildDelegationUserOp)({
2348
2328
  userAddress: params.userAddress,
2349
2329
  aaNonce: params.aaNonce,
2350
2330
  gasLimits: {
@@ -2363,19 +2343,26 @@ async function handleDelegateSubmit(params) {
2363
2343
  maxFeePerGas: params.fees.maxFeePerGas ?? 0n,
2364
2344
  maxPriorityFeePerGas: params.fees.maxPriorityFeePerGas ?? 0n
2365
2345
  };
2346
+ const authorization = (0, import_core13.buildEip7702Authorization)({
2347
+ chainId: params.chainId,
2348
+ address: batchExecutor,
2349
+ nonce: params.delegationNonce,
2350
+ authSig: params.authSig
2351
+ });
2366
2352
  const paymasterFields = await requestPaymaster({
2367
2353
  client: params.pafiBackendClient,
2368
2354
  chainId: params.chainId,
2369
2355
  scenario: "delegate",
2370
2356
  userOp,
2371
2357
  pointTokenAddress: batchExecutor,
2358
+ eip7702Auth: authorization,
2372
2359
  onWarning: params.onWarning
2373
2360
  });
2374
2361
  const merged = {
2375
2362
  ...userOp,
2376
2363
  ...paymasterFields ?? {}
2377
2364
  };
2378
- const userOpJson = (0, import_core10.serializeUserOpToJsonRpc)(
2365
+ const userOpJson = (0, import_core13.serializeUserOpToJsonRpc)(
2379
2366
  {
2380
2367
  sender: merged.sender,
2381
2368
  nonce: merged.nonce,
@@ -2394,16 +2381,10 @@ async function handleDelegateSubmit(params) {
2394
2381
  // is the user's "consent"; no separate AA signature is needed.
2395
2382
  "0x"
2396
2383
  );
2397
- const authorization = (0, import_core10.buildEip7702Authorization)({
2398
- chainId: params.chainId,
2399
- address: batchExecutor,
2400
- nonce: params.delegationNonce,
2401
- authSig: params.authSig
2402
- });
2403
2384
  const result = await relayUserOp({
2404
2385
  client: params.pafiBackendClient,
2405
2386
  userOp: userOpJson,
2406
- entryPoint: import_core10.ENTRY_POINT_V08,
2387
+ entryPoint: import_core13.ENTRY_POINT_V08,
2407
2388
  eip7702Auth: authorization
2408
2389
  });
2409
2390
  return {
@@ -2416,7 +2397,7 @@ async function handleDelegateSubmit(params) {
2416
2397
  // src/api/errorMapper.ts
2417
2398
  function createSdkErrorMapper(factories) {
2418
2399
  return (err) => {
2419
- if (!(err instanceof PafiSdkError)) {
2400
+ if (!(err instanceof import_core.PafiSdkError)) {
2420
2401
  throw err;
2421
2402
  }
2422
2403
  const body = {
@@ -2440,7 +2421,7 @@ function createSdkErrorMapper(factories) {
2440
2421
 
2441
2422
  // src/api/issuerApiAdapter.ts
2442
2423
  var import_viem10 = require("viem");
2443
- var import_core11 = require("@pafi-dev/core");
2424
+ var import_core14 = require("@pafi-dev/core");
2444
2425
  var AdapterMisconfiguredError = class extends Error {
2445
2426
  code = "ADAPTER_MISCONFIGURED";
2446
2427
  constructor(message) {
@@ -2570,8 +2551,8 @@ var IssuerApiAdapter = class {
2570
2551
  "burn"
2571
2552
  );
2572
2553
  return {
2573
- calls: (0, import_core11.decodeBatchExecuteCalls)(response.userOp.callData),
2574
- callsFallback: response.fallback ? (0, import_core11.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
2554
+ calls: (0, import_core14.decodeBatchExecuteCalls)(response.userOp.callData),
2555
+ callsFallback: response.fallback ? (0, import_core14.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
2575
2556
  feeAmount: response.feeAmount.toString(),
2576
2557
  lockId: response.lockId,
2577
2558
  lockIdFallback: response.fallback?.lockId,
@@ -2734,23 +2715,23 @@ var IssuerApiAdapter = class {
2734
2715
  }
2735
2716
  // ------------------------------ Delegate endpoints -----------------------
2736
2717
  async delegateStatus(authenticatedAddress, chainId) {
2737
- const { batchExecutor } = (0, import_core11.getContractAddresses)(chainId);
2718
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2738
2719
  const code = await this.cfg.provider.getCode({
2739
2720
  address: authenticatedAddress
2740
2721
  });
2741
2722
  return {
2742
- isDelegated: (0, import_core11.parseEip7702DelegatedAddress)(code) !== null,
2723
+ isDelegated: (0, import_core14.parseEip7702DelegatedAddress)(code) !== null,
2743
2724
  batchExecutorAddress: batchExecutor
2744
2725
  };
2745
2726
  }
2746
2727
  async delegatePrepare(authenticatedAddress, chainId) {
2747
- const { batchExecutor } = (0, import_core11.getContractAddresses)(chainId);
2728
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2748
2729
  const accountNonce = BigInt(
2749
2730
  await this.cfg.provider.getTransactionCount({
2750
2731
  address: authenticatedAddress
2751
2732
  })
2752
2733
  );
2753
- const authorizationHash = (0, import_core11.computeAuthorizationHash)(
2734
+ const authorizationHash = (0, import_core14.computeAuthorizationHash)(
2754
2735
  chainId,
2755
2736
  batchExecutor,
2756
2737
  accountNonce
@@ -2783,7 +2764,7 @@ var IssuerApiAdapter = class {
2783
2764
  */
2784
2765
  async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
2785
2766
  if (!this.cfg.pafiIssuerId) return void 0;
2786
- return (0, import_core11.buildAndSignSponsorAuth)({
2767
+ return (0, import_core14.buildAndSignSponsorAuth)({
2787
2768
  userAddress: authenticatedAddress,
2788
2769
  callData,
2789
2770
  chainId,
@@ -2833,7 +2814,7 @@ var IssuerApiAdapter = class {
2833
2814
 
2834
2815
  // src/pools/subgraphPoolsProvider.ts
2835
2816
  var import_viem11 = require("viem");
2836
- var import_core12 = require("@pafi-dev/core");
2817
+ var import_core15 = require("@pafi-dev/core");
2837
2818
  var DEFAULT_CACHE_TTL_MS = 3e4;
2838
2819
  var POOL_QUERY = `
2839
2820
  query GetPoolForPointToken($id: ID!) {
@@ -2851,7 +2832,7 @@ var POOL_QUERY = `
2851
2832
  }
2852
2833
  `;
2853
2834
  function createSubgraphPoolsProvider(config = {}) {
2854
- const subgraphUrl = config.subgraphUrl ?? import_core12.PAFI_SUBGRAPH_URL;
2835
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2855
2836
  try {
2856
2837
  const parsed = new URL(subgraphUrl);
2857
2838
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -2983,7 +2964,7 @@ var PRICE_QUERY = `
2983
2964
  }
2984
2965
  `;
2985
2966
  function createSubgraphNativeUsdtQuoter(config = {}) {
2986
- const subgraphUrl = config.subgraphUrl ?? import_core12.PAFI_SUBGRAPH_URL;
2967
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2987
2968
  try {
2988
2969
  const parsed = new URL(subgraphUrl);
2989
2970
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -3113,7 +3094,7 @@ function createNativePtQuoter(config) {
3113
3094
  provider,
3114
3095
  pointTokenAddress,
3115
3096
  chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
3116
- subgraphUrl = import_core12.PAFI_SUBGRAPH_URL,
3097
+ subgraphUrl = import_core15.PAFI_SUBGRAPH_URL,
3117
3098
  cacheTtlMs = 3e4,
3118
3099
  fallbackEthPriceUsd = 3e3,
3119
3100
  fallbackPtPriceUsdt = 0.1,
@@ -3195,7 +3176,7 @@ function parseBigDecimalTo18(s) {
3195
3176
  }
3196
3177
 
3197
3178
  // src/balance/balanceAggregator.ts
3198
- var import_core13 = require("@pafi-dev/core");
3179
+ var import_core16 = require("@pafi-dev/core");
3199
3180
  var BalanceAggregator = class {
3200
3181
  provider;
3201
3182
  ledger;
@@ -3216,7 +3197,7 @@ var BalanceAggregator = class {
3216
3197
  async getCombinedBalance(user, pointToken) {
3217
3198
  const [offChain, onChain] = await Promise.all([
3218
3199
  this.ledger.getBalance(user, pointToken),
3219
- (0, import_core13.getPointTokenBalance)(this.provider, pointToken, user)
3200
+ (0, import_core16.getPointTokenBalance)(this.provider, pointToken, user)
3220
3201
  ]);
3221
3202
  return {
3222
3203
  offChain,
@@ -3415,7 +3396,7 @@ var PafiBackendClient = class {
3415
3396
 
3416
3397
  // src/config.ts
3417
3398
  var import_viem13 = require("viem");
3418
- var import_core14 = require("@pafi-dev/core");
3399
+ var import_core17 = require("@pafi-dev/core");
3419
3400
  function createIssuerService(config) {
3420
3401
  if (!config.provider) {
3421
3402
  throw new Error("createIssuerService: provider is required");
@@ -3485,7 +3466,7 @@ function createIssuerService(config) {
3485
3466
  indexers.set(tokenAddress, new PointIndexer(indexerConfig));
3486
3467
  }
3487
3468
  const firstIndexer = indexers.get(tokenAddresses[0]);
3488
- const chainAddresses = (0, import_core14.getContractAddresses)(config.chainId);
3469
+ const chainAddresses = (0, import_core17.getContractAddresses)(config.chainId);
3489
3470
  const resolvedContracts = {
3490
3471
  batchExecutor: chainAddresses.batchExecutor,
3491
3472
  usdt: chainAddresses.usdt,
@@ -3525,7 +3506,7 @@ function createIssuerService(config) {
3525
3506
 
3526
3507
  // src/issuer-state/validator.ts
3527
3508
  var import_viem14 = require("viem");
3528
- var import_core15 = require("@pafi-dev/core");
3509
+ var import_core18 = require("@pafi-dev/core");
3529
3510
  var ISSUER_RECORD_TTL_MS = 3e4;
3530
3511
  var IssuerStateValidator = class _IssuerStateValidator {
3531
3512
  constructor(provider, registryAddress) {
@@ -3542,7 +3523,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3542
3523
  * `CONTRACT_ADDRESSES` map for the given chain.
3543
3524
  */
3544
3525
  static forChain(provider, chainId) {
3545
- const { issuerRegistry } = (0, import_core15.getContractAddresses)(chainId);
3526
+ const { issuerRegistry } = (0, import_core18.getContractAddresses)(chainId);
3546
3527
  return new _IssuerStateValidator(provider, issuerRegistry);
3547
3528
  }
3548
3529
  /**
@@ -3571,7 +3552,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3571
3552
  if (cached) return cached;
3572
3553
  const issuer = await this.provider.readContract({
3573
3554
  address: key,
3574
- abi: import_core15.POINT_TOKEN_V2_ABI,
3555
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3575
3556
  functionName: "issuer"
3576
3557
  });
3577
3558
  this.pointTokenIssuerCache.set(key, (0, import_viem14.getAddress)(issuer));
@@ -3652,13 +3633,13 @@ var IssuerStateValidator = class _IssuerStateValidator {
3652
3633
  const [issuerTuple, totalSupply] = await Promise.all([
3653
3634
  this.provider.readContract({
3654
3635
  address: this.registryAddress,
3655
- abi: import_core15.issuerRegistryGetIssuerFlatAbi,
3636
+ abi: import_core18.issuerRegistryGetIssuerFlatAbi,
3656
3637
  functionName: "getIssuer",
3657
3638
  args: [issuerAddr]
3658
3639
  }),
3659
3640
  this.provider.readContract({
3660
3641
  address: tokenAddr,
3661
- abi: import_core15.POINT_TOKEN_V2_ABI,
3642
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3662
3643
  functionName: "totalSupply"
3663
3644
  })
3664
3645
  ]);
@@ -3680,7 +3661,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3680
3661
  };
3681
3662
 
3682
3663
  // src/index.ts
3683
- var PAFI_ISSUER_SDK_VERSION = true ? "0.7.3" : "dev";
3664
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.7.5" : "dev";
3684
3665
  // Annotate the CommonJS export names for ESM import in node:
3685
3666
  0 && (module.exports = {
3686
3667
  AdapterMisconfiguredError,