@pafi-dev/issuer 0.7.3 → 0.7.4

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;
@@ -1989,7 +1968,7 @@ async function relayUserOp(params) {
1989
1968
  }
1990
1969
 
1991
1970
  // src/api/mobileHandlers.ts
1992
- var PendingUserOpNotFoundError = class extends PafiSdkError {
1971
+ var PendingUserOpNotFoundError = class extends import_core.PafiSdkError {
1993
1972
  code = "PENDING_USEROP_NOT_FOUND";
1994
1973
  httpStatus = "not_found";
1995
1974
  constructor(lockId) {
@@ -1998,7 +1977,7 @@ var PendingUserOpNotFoundError = class extends PafiSdkError {
1998
1977
  );
1999
1978
  }
2000
1979
  };
2001
- var PendingUserOpForbiddenError = class extends PafiSdkError {
1980
+ var PendingUserOpForbiddenError = class extends import_core.PafiSdkError {
2002
1981
  code = "PENDING_USEROP_FORBIDDEN";
2003
1982
  httpStatus = "forbidden";
2004
1983
  constructor(lockId) {
@@ -2012,7 +1991,7 @@ async function handleMobilePrepare(params) {
2012
1991
  params.provider.estimateFeesPerGas(),
2013
1992
  params.provider.getCode({ address: params.userAddress })
2014
1993
  ]);
2015
- const needsDelegation = (0, import_core7.parseEip7702DelegatedAddress)(userCode) === null;
1994
+ const needsDelegation = (0, import_core10.parseEip7702DelegatedAddress)(userCode) === null;
2016
1995
  const sponsoredOp = {
2017
1996
  ...params.partialUserOp,
2018
1997
  maxFeePerGas: fees.maxFeePerGas ?? params.partialUserOp.maxFeePerGas ?? 0n,
@@ -2054,7 +2033,7 @@ async function handleMobileSubmit(params) {
2054
2033
  const result = await relayUserOp({
2055
2034
  client: params.pafiBackendClient,
2056
2035
  userOp: userOpJson,
2057
- entryPoint: params.entryPoint ?? import_core7.ENTRY_POINT_V08
2036
+ entryPoint: params.entryPoint ?? import_core10.ENTRY_POINT_V08
2058
2037
  });
2059
2038
  await params.bindUserOpHash(params.lockId, result.userOpHash);
2060
2039
  await params.store.delete(params.lockId);
@@ -2063,10 +2042,10 @@ async function handleMobileSubmit(params) {
2063
2042
 
2064
2043
  // src/api/handlers/ptClaimHandler.ts
2065
2044
  var import_viem9 = require("viem");
2066
- var import_core8 = require("@pafi-dev/core");
2045
+ var import_core11 = require("@pafi-dev/core");
2067
2046
 
2068
2047
  // src/issuer-state/types.ts
2069
- var IssuerStateError = class extends PafiSdkError {
2048
+ var IssuerStateError = class extends import_core.PafiSdkError {
2070
2049
  httpStatus = "unprocessable";
2071
2050
  code;
2072
2051
  details;
@@ -2080,7 +2059,7 @@ var IssuerStateError = class extends PafiSdkError {
2080
2059
  };
2081
2060
 
2082
2061
  // src/api/handlers/ptClaimHandler.ts
2083
- var PTClaimError = class extends PafiSdkError {
2062
+ var PTClaimError = class extends import_core.PafiSdkError {
2084
2063
  httpStatus = "unprocessable";
2085
2064
  code;
2086
2065
  details;
@@ -2126,7 +2105,7 @@ var PTClaimHandler = class {
2126
2105
  );
2127
2106
  }
2128
2107
  }
2129
- const { batchExecutor: batchExecutorAddress } = (0, import_core8.getContractAddresses)(
2108
+ const { batchExecutor: batchExecutorAddress } = (0, import_core11.getContractAddresses)(
2130
2109
  request.chainId
2131
2110
  );
2132
2111
  const lockId = await this.cfg.ledger.lockForMinting(
@@ -2187,8 +2166,8 @@ var PTClaimHandler = class {
2187
2166
  );
2188
2167
  }
2189
2168
  }
2190
- const calls = (0, import_core8.decodeBatchExecuteCalls)(userOp.callData);
2191
- const callsFallback = fallback ? (0, import_core8.decodeBatchExecuteCalls)(fallback.callData) : void 0;
2169
+ const calls = (0, import_core11.decodeBatchExecuteCalls)(userOp.callData);
2170
+ const callsFallback = fallback ? (0, import_core11.decodeBatchExecuteCalls)(fallback.callData) : void 0;
2192
2171
  return {
2193
2172
  userOp,
2194
2173
  fallback,
@@ -2208,8 +2187,8 @@ var PTClaimHandler = class {
2208
2187
  };
2209
2188
 
2210
2189
  // src/api/handlers/perpDepositHandler.ts
2211
- var import_core9 = require("@pafi-dev/core");
2212
- var PerpDepositError = class extends PafiSdkError {
2190
+ var import_core12 = require("@pafi-dev/core");
2191
+ var PerpDepositError = class extends import_core.PafiSdkError {
2213
2192
  httpStatus = "unprocessable";
2214
2193
  code;
2215
2194
  safeToRetry;
@@ -2232,26 +2211,26 @@ var PerpDepositHandler = class {
2232
2211
  if (request.amount <= 0n) {
2233
2212
  throw new PerpDepositError("INVALID_AMOUNT", "amount must be positive");
2234
2213
  }
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];
2214
+ const brokerHash = import_core12.BROKER_HASHES[request.brokerId];
2215
+ const tokenHash = import_core12.TOKEN_HASHES.USDC;
2216
+ const vault = import_core12.ORDERLY_VAULT_ADDRESSES[request.chainId];
2238
2217
  if (!vault) {
2239
2218
  throw new PerpDepositError(
2240
2219
  "PERP_DEPOSIT_UNAVAILABLE",
2241
2220
  `no Orderly Vault for chainId ${request.chainId}`
2242
2221
  );
2243
2222
  }
2244
- const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0, import_core9.getContractAddresses)(request.chainId);
2223
+ const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0, import_core12.getContractAddresses)(request.chainId);
2245
2224
  const [usdcAddress, brokerAllowed] = await Promise.all([
2246
2225
  this.cfg.provider.readContract({
2247
2226
  address: vault,
2248
- abi: import_core9.ORDERLY_VAULT_ABI,
2227
+ abi: import_core12.ORDERLY_VAULT_ABI,
2249
2228
  functionName: "getAllowedToken",
2250
2229
  args: [tokenHash]
2251
2230
  }),
2252
2231
  this.cfg.provider.readContract({
2253
2232
  address: vault,
2254
- abi: import_core9.ORDERLY_VAULT_ABI,
2233
+ abi: import_core12.ORDERLY_VAULT_ABI,
2255
2234
  functionName: "getAllowedBroker",
2256
2235
  args: [brokerHash]
2257
2236
  })
@@ -2262,7 +2241,7 @@ var PerpDepositHandler = class {
2262
2241
  `broker "${request.brokerId}" is not whitelisted on Orderly Vault`
2263
2242
  );
2264
2243
  }
2265
- const accountId = (0, import_core9.computeAccountId)(request.userAddress, brokerHash);
2244
+ const accountId = (0, import_core12.computeAccountId)(request.userAddress, brokerHash);
2266
2245
  const requestForQuote = {
2267
2246
  token: usdcAddress,
2268
2247
  receiver: request.userAddress,
@@ -2273,11 +2252,11 @@ var PerpDepositHandler = class {
2273
2252
  const [relayTokenFee, usdcGasFee] = await Promise.all([
2274
2253
  this.cfg.provider.readContract({
2275
2254
  address: relayAddress,
2276
- abi: import_core9.ORDERLY_RELAY_ABI,
2255
+ abi: import_core12.ORDERLY_RELAY_ABI,
2277
2256
  functionName: "quoteTokenFee",
2278
2257
  args: [requestForQuote]
2279
2258
  }),
2280
- (0, import_core9.quoteOperatorFeeUsdt)({
2259
+ (0, import_core12.quoteOperatorFeeUsdt)({
2281
2260
  provider: this.cfg.provider,
2282
2261
  chainId: request.chainId,
2283
2262
  gasUnits: this.cfg.gasUnits,
@@ -2304,7 +2283,7 @@ var PerpDepositHandler = class {
2304
2283
  totalAmount: request.amount,
2305
2284
  maxFee
2306
2285
  };
2307
- const sponsoredOp = (0, import_core9.buildPerpDepositViaRelay)({
2286
+ const sponsoredOp = (0, import_core12.buildPerpDepositViaRelay)({
2308
2287
  userAddress: request.userAddress,
2309
2288
  aaNonce: request.aaNonce,
2310
2289
  relayAddress,
@@ -2312,7 +2291,7 @@ var PerpDepositHandler = class {
2312
2291
  gasFeeUsdc: usdcGasFee,
2313
2292
  gasFeeUsdcRecipient: pafiFeeRecipient
2314
2293
  });
2315
- const fallbackOp = usdcGasFee > 0n ? (0, import_core9.buildPerpDepositViaRelay)({
2294
+ const fallbackOp = usdcGasFee > 0n ? (0, import_core12.buildPerpDepositViaRelay)({
2316
2295
  userAddress: request.userAddress,
2317
2296
  aaNonce: request.aaNonce,
2318
2297
  relayAddress,
@@ -2329,22 +2308,22 @@ var PerpDepositHandler = class {
2329
2308
  brokerHash,
2330
2309
  usdcAddress,
2331
2310
  relayAddress,
2332
- calls: (0, import_core9.decodeBatchExecuteCalls)(sponsoredOp.callData),
2333
- callsFallback: fallbackOp ? (0, import_core9.decodeBatchExecuteCalls)(fallbackOp.callData) : void 0
2311
+ calls: (0, import_core12.decodeBatchExecuteCalls)(sponsoredOp.callData),
2312
+ callsFallback: fallbackOp ? (0, import_core12.decodeBatchExecuteCalls)(fallbackOp.callData) : void 0
2334
2313
  };
2335
2314
  }
2336
2315
  };
2337
2316
 
2338
2317
  // src/api/delegateHandler.ts
2339
- var import_core10 = require("@pafi-dev/core");
2318
+ var import_core13 = require("@pafi-dev/core");
2340
2319
  var DEFAULT_DELEGATE_GAS = {
2341
2320
  callGasLimit: 100000n,
2342
2321
  verificationGasLimit: 150000n,
2343
2322
  preVerificationGas: 50000n
2344
2323
  };
2345
2324
  async function handleDelegateSubmit(params) {
2346
- const { batchExecutor } = (0, import_core10.getContractAddresses)(params.chainId);
2347
- const partial = (0, import_core10.buildDelegationUserOp)({
2325
+ const { batchExecutor } = (0, import_core13.getContractAddresses)(params.chainId);
2326
+ const partial = (0, import_core13.buildDelegationUserOp)({
2348
2327
  userAddress: params.userAddress,
2349
2328
  aaNonce: params.aaNonce,
2350
2329
  gasLimits: {
@@ -2375,7 +2354,7 @@ async function handleDelegateSubmit(params) {
2375
2354
  ...userOp,
2376
2355
  ...paymasterFields ?? {}
2377
2356
  };
2378
- const userOpJson = (0, import_core10.serializeUserOpToJsonRpc)(
2357
+ const userOpJson = (0, import_core13.serializeUserOpToJsonRpc)(
2379
2358
  {
2380
2359
  sender: merged.sender,
2381
2360
  nonce: merged.nonce,
@@ -2394,7 +2373,7 @@ async function handleDelegateSubmit(params) {
2394
2373
  // is the user's "consent"; no separate AA signature is needed.
2395
2374
  "0x"
2396
2375
  );
2397
- const authorization = (0, import_core10.buildEip7702Authorization)({
2376
+ const authorization = (0, import_core13.buildEip7702Authorization)({
2398
2377
  chainId: params.chainId,
2399
2378
  address: batchExecutor,
2400
2379
  nonce: params.delegationNonce,
@@ -2403,7 +2382,7 @@ async function handleDelegateSubmit(params) {
2403
2382
  const result = await relayUserOp({
2404
2383
  client: params.pafiBackendClient,
2405
2384
  userOp: userOpJson,
2406
- entryPoint: import_core10.ENTRY_POINT_V08,
2385
+ entryPoint: import_core13.ENTRY_POINT_V08,
2407
2386
  eip7702Auth: authorization
2408
2387
  });
2409
2388
  return {
@@ -2416,7 +2395,7 @@ async function handleDelegateSubmit(params) {
2416
2395
  // src/api/errorMapper.ts
2417
2396
  function createSdkErrorMapper(factories) {
2418
2397
  return (err) => {
2419
- if (!(err instanceof PafiSdkError)) {
2398
+ if (!(err instanceof import_core.PafiSdkError)) {
2420
2399
  throw err;
2421
2400
  }
2422
2401
  const body = {
@@ -2440,7 +2419,7 @@ function createSdkErrorMapper(factories) {
2440
2419
 
2441
2420
  // src/api/issuerApiAdapter.ts
2442
2421
  var import_viem10 = require("viem");
2443
- var import_core11 = require("@pafi-dev/core");
2422
+ var import_core14 = require("@pafi-dev/core");
2444
2423
  var AdapterMisconfiguredError = class extends Error {
2445
2424
  code = "ADAPTER_MISCONFIGURED";
2446
2425
  constructor(message) {
@@ -2570,8 +2549,8 @@ var IssuerApiAdapter = class {
2570
2549
  "burn"
2571
2550
  );
2572
2551
  return {
2573
- calls: (0, import_core11.decodeBatchExecuteCalls)(response.userOp.callData),
2574
- callsFallback: response.fallback ? (0, import_core11.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
2552
+ calls: (0, import_core14.decodeBatchExecuteCalls)(response.userOp.callData),
2553
+ callsFallback: response.fallback ? (0, import_core14.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
2575
2554
  feeAmount: response.feeAmount.toString(),
2576
2555
  lockId: response.lockId,
2577
2556
  lockIdFallback: response.fallback?.lockId,
@@ -2734,23 +2713,23 @@ var IssuerApiAdapter = class {
2734
2713
  }
2735
2714
  // ------------------------------ Delegate endpoints -----------------------
2736
2715
  async delegateStatus(authenticatedAddress, chainId) {
2737
- const { batchExecutor } = (0, import_core11.getContractAddresses)(chainId);
2716
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2738
2717
  const code = await this.cfg.provider.getCode({
2739
2718
  address: authenticatedAddress
2740
2719
  });
2741
2720
  return {
2742
- isDelegated: (0, import_core11.parseEip7702DelegatedAddress)(code) !== null,
2721
+ isDelegated: (0, import_core14.parseEip7702DelegatedAddress)(code) !== null,
2743
2722
  batchExecutorAddress: batchExecutor
2744
2723
  };
2745
2724
  }
2746
2725
  async delegatePrepare(authenticatedAddress, chainId) {
2747
- const { batchExecutor } = (0, import_core11.getContractAddresses)(chainId);
2726
+ const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
2748
2727
  const accountNonce = BigInt(
2749
2728
  await this.cfg.provider.getTransactionCount({
2750
2729
  address: authenticatedAddress
2751
2730
  })
2752
2731
  );
2753
- const authorizationHash = (0, import_core11.computeAuthorizationHash)(
2732
+ const authorizationHash = (0, import_core14.computeAuthorizationHash)(
2754
2733
  chainId,
2755
2734
  batchExecutor,
2756
2735
  accountNonce
@@ -2783,7 +2762,7 @@ var IssuerApiAdapter = class {
2783
2762
  */
2784
2763
  async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
2785
2764
  if (!this.cfg.pafiIssuerId) return void 0;
2786
- return (0, import_core11.buildAndSignSponsorAuth)({
2765
+ return (0, import_core14.buildAndSignSponsorAuth)({
2787
2766
  userAddress: authenticatedAddress,
2788
2767
  callData,
2789
2768
  chainId,
@@ -2833,7 +2812,7 @@ var IssuerApiAdapter = class {
2833
2812
 
2834
2813
  // src/pools/subgraphPoolsProvider.ts
2835
2814
  var import_viem11 = require("viem");
2836
- var import_core12 = require("@pafi-dev/core");
2815
+ var import_core15 = require("@pafi-dev/core");
2837
2816
  var DEFAULT_CACHE_TTL_MS = 3e4;
2838
2817
  var POOL_QUERY = `
2839
2818
  query GetPoolForPointToken($id: ID!) {
@@ -2851,7 +2830,7 @@ var POOL_QUERY = `
2851
2830
  }
2852
2831
  `;
2853
2832
  function createSubgraphPoolsProvider(config = {}) {
2854
- const subgraphUrl = config.subgraphUrl ?? import_core12.PAFI_SUBGRAPH_URL;
2833
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2855
2834
  try {
2856
2835
  const parsed = new URL(subgraphUrl);
2857
2836
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -2983,7 +2962,7 @@ var PRICE_QUERY = `
2983
2962
  }
2984
2963
  `;
2985
2964
  function createSubgraphNativeUsdtQuoter(config = {}) {
2986
- const subgraphUrl = config.subgraphUrl ?? import_core12.PAFI_SUBGRAPH_URL;
2965
+ const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
2987
2966
  try {
2988
2967
  const parsed = new URL(subgraphUrl);
2989
2968
  if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
@@ -3113,7 +3092,7 @@ function createNativePtQuoter(config) {
3113
3092
  provider,
3114
3093
  pointTokenAddress,
3115
3094
  chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
3116
- subgraphUrl = import_core12.PAFI_SUBGRAPH_URL,
3095
+ subgraphUrl = import_core15.PAFI_SUBGRAPH_URL,
3117
3096
  cacheTtlMs = 3e4,
3118
3097
  fallbackEthPriceUsd = 3e3,
3119
3098
  fallbackPtPriceUsdt = 0.1,
@@ -3195,7 +3174,7 @@ function parseBigDecimalTo18(s) {
3195
3174
  }
3196
3175
 
3197
3176
  // src/balance/balanceAggregator.ts
3198
- var import_core13 = require("@pafi-dev/core");
3177
+ var import_core16 = require("@pafi-dev/core");
3199
3178
  var BalanceAggregator = class {
3200
3179
  provider;
3201
3180
  ledger;
@@ -3216,7 +3195,7 @@ var BalanceAggregator = class {
3216
3195
  async getCombinedBalance(user, pointToken) {
3217
3196
  const [offChain, onChain] = await Promise.all([
3218
3197
  this.ledger.getBalance(user, pointToken),
3219
- (0, import_core13.getPointTokenBalance)(this.provider, pointToken, user)
3198
+ (0, import_core16.getPointTokenBalance)(this.provider, pointToken, user)
3220
3199
  ]);
3221
3200
  return {
3222
3201
  offChain,
@@ -3415,7 +3394,7 @@ var PafiBackendClient = class {
3415
3394
 
3416
3395
  // src/config.ts
3417
3396
  var import_viem13 = require("viem");
3418
- var import_core14 = require("@pafi-dev/core");
3397
+ var import_core17 = require("@pafi-dev/core");
3419
3398
  function createIssuerService(config) {
3420
3399
  if (!config.provider) {
3421
3400
  throw new Error("createIssuerService: provider is required");
@@ -3485,7 +3464,7 @@ function createIssuerService(config) {
3485
3464
  indexers.set(tokenAddress, new PointIndexer(indexerConfig));
3486
3465
  }
3487
3466
  const firstIndexer = indexers.get(tokenAddresses[0]);
3488
- const chainAddresses = (0, import_core14.getContractAddresses)(config.chainId);
3467
+ const chainAddresses = (0, import_core17.getContractAddresses)(config.chainId);
3489
3468
  const resolvedContracts = {
3490
3469
  batchExecutor: chainAddresses.batchExecutor,
3491
3470
  usdt: chainAddresses.usdt,
@@ -3525,7 +3504,7 @@ function createIssuerService(config) {
3525
3504
 
3526
3505
  // src/issuer-state/validator.ts
3527
3506
  var import_viem14 = require("viem");
3528
- var import_core15 = require("@pafi-dev/core");
3507
+ var import_core18 = require("@pafi-dev/core");
3529
3508
  var ISSUER_RECORD_TTL_MS = 3e4;
3530
3509
  var IssuerStateValidator = class _IssuerStateValidator {
3531
3510
  constructor(provider, registryAddress) {
@@ -3542,7 +3521,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3542
3521
  * `CONTRACT_ADDRESSES` map for the given chain.
3543
3522
  */
3544
3523
  static forChain(provider, chainId) {
3545
- const { issuerRegistry } = (0, import_core15.getContractAddresses)(chainId);
3524
+ const { issuerRegistry } = (0, import_core18.getContractAddresses)(chainId);
3546
3525
  return new _IssuerStateValidator(provider, issuerRegistry);
3547
3526
  }
3548
3527
  /**
@@ -3571,7 +3550,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3571
3550
  if (cached) return cached;
3572
3551
  const issuer = await this.provider.readContract({
3573
3552
  address: key,
3574
- abi: import_core15.POINT_TOKEN_V2_ABI,
3553
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3575
3554
  functionName: "issuer"
3576
3555
  });
3577
3556
  this.pointTokenIssuerCache.set(key, (0, import_viem14.getAddress)(issuer));
@@ -3652,13 +3631,13 @@ var IssuerStateValidator = class _IssuerStateValidator {
3652
3631
  const [issuerTuple, totalSupply] = await Promise.all([
3653
3632
  this.provider.readContract({
3654
3633
  address: this.registryAddress,
3655
- abi: import_core15.issuerRegistryGetIssuerFlatAbi,
3634
+ abi: import_core18.issuerRegistryGetIssuerFlatAbi,
3656
3635
  functionName: "getIssuer",
3657
3636
  args: [issuerAddr]
3658
3637
  }),
3659
3638
  this.provider.readContract({
3660
3639
  address: tokenAddr,
3661
- abi: import_core15.POINT_TOKEN_V2_ABI,
3640
+ abi: import_core18.POINT_TOKEN_V2_ABI,
3662
3641
  functionName: "totalSupply"
3663
3642
  })
3664
3643
  ]);
@@ -3680,7 +3659,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3680
3659
  };
3681
3660
 
3682
3661
  // src/index.ts
3683
- var PAFI_ISSUER_SDK_VERSION = true ? "0.7.3" : "dev";
3662
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.7.4" : "dev";
3684
3663
  // Annotate the CommonJS export names for ESM import in node:
3685
3664
  0 && (module.exports = {
3686
3665
  AdapterMisconfiguredError,