@pafi-dev/issuer 0.23.0 → 0.24.1

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
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  BundlerNotConfiguredError: () => BundlerNotConfiguredError,
27
27
  BundlerRejectedError: () => BundlerRejectedError,
28
28
  BurnIndexer: () => BurnIndexer,
29
+ BurnIndexerFinalizeError: () => BurnIndexerFinalizeError,
29
30
  ConfigurationError: () => ConfigurationError,
30
31
  DEFAULT_REDEMPTION_POLICY: () => DEFAULT_REDEMPTION_POLICY,
31
32
  DefaultPolicyEngine: () => DefaultPolicyEngine,
@@ -57,6 +58,7 @@ __export(index_exports, {
57
58
  PerpDepositError: () => PerpDepositError,
58
59
  PerpDepositHandler: () => PerpDepositHandler,
59
60
  PointIndexer: () => PointIndexer,
61
+ PointIndexerFinalizeError: () => PointIndexerFinalizeError,
60
62
  PointTokenDomainResolver: () => PointTokenDomainResolver,
61
63
  PolicyProvider: () => PolicyProvider,
62
64
  REDEMPTION_HISTORY_WINDOW_SEC: () => REDEMPTION_HISTORY_WINDOW_SEC,
@@ -908,6 +910,7 @@ var RelayService = class {
908
910
  "prepareMint: deadline exceeds maximum allowed window (1 hour)"
909
911
  );
910
912
  }
913
+ const MINT_SOURCE = import_core5.Source.EQUITY;
911
914
  const useWrapper = params.mintFeeWrapperAddress !== void 0;
912
915
  const receiverForSig = useWrapper ? params.mintFeeWrapperAddress : params.userAddress;
913
916
  let minterSig;
@@ -919,6 +922,7 @@ var RelayService = class {
919
922
  user: params.userAddress,
920
923
  receiver: receiverForSig,
921
924
  amount: params.amount,
925
+ source: MINT_SOURCE,
922
926
  nonce: params.mintRequestNonce,
923
927
  deadline: params.deadline
924
928
  }
@@ -949,9 +953,15 @@ var RelayService = class {
949
953
  mintTarget = params.mintFeeWrapperAddress;
950
954
  } else {
951
955
  mintCallData = (0, import_viem3.encodeFunctionData)({
952
- abi: import_core5.POINT_TOKEN_ABI,
956
+ abi: import_core5.POINT_TOKEN_MINT_SIG_ABI,
953
957
  functionName: "mint",
954
- args: [params.userAddress, params.amount, params.deadline, minterSig]
958
+ args: [
959
+ params.userAddress,
960
+ params.amount,
961
+ MINT_SOURCE,
962
+ params.deadline,
963
+ minterSig
964
+ ]
955
965
  });
956
966
  mintTarget = params.pointTokenAddress;
957
967
  }
@@ -1036,11 +1046,12 @@ var RelayService = class {
1036
1046
  let burnCallData;
1037
1047
  try {
1038
1048
  burnCallData = (0, import_viem3.encodeFunctionData)({
1039
- abi: import_core5.POINT_TOKEN_ABI,
1049
+ abi: import_core5.POINT_TOKEN_BURN_SIG_ABI,
1040
1050
  functionName: "burn",
1041
1051
  args: [
1042
1052
  params.burnRequest.from,
1043
1053
  params.burnRequest.amount,
1054
+ params.burnRequest.source,
1044
1055
  params.burnRequest.deadline,
1045
1056
  params.burnerSignature
1046
1057
  ]
@@ -1135,11 +1146,12 @@ var RelayService = class {
1135
1146
  mintTarget = params.mintFeeWrapperAddress;
1136
1147
  } else {
1137
1148
  mintCallData = (0, import_viem3.encodeFunctionData)({
1138
- abi: import_core5.POINT_TOKEN_ABI,
1149
+ abi: import_core5.POINT_TOKEN_MINT_SIG_ABI,
1139
1150
  functionName: "mint",
1140
1151
  args: [
1141
1152
  params.userAddress,
1142
1153
  params.amount,
1154
+ import_core5.Source.EQUITY,
1143
1155
  params.deadline,
1144
1156
  PLACEHOLDER_SIG_65
1145
1157
  ]
@@ -1161,11 +1173,12 @@ var RelayService = class {
1161
1173
  /** Burn-side mirror of `previewMintUserOp`. */
1162
1174
  previewBurnUserOp(params) {
1163
1175
  const burnCallData = (0, import_viem3.encodeFunctionData)({
1164
- abi: import_core5.POINT_TOKEN_ABI,
1176
+ abi: import_core5.POINT_TOKEN_BURN_SIG_ABI,
1165
1177
  functionName: "burn",
1166
1178
  args: [
1167
1179
  params.userAddress,
1168
1180
  params.amount,
1181
+ import_core5.Source.EQUITY,
1169
1182
  params.deadline,
1170
1183
  PLACEHOLDER_SIG_65
1171
1184
  ]
@@ -1383,6 +1396,16 @@ var InMemoryCursorStore = class _InMemoryCursorStore {
1383
1396
 
1384
1397
  // src/indexer/pointIndexer.ts
1385
1398
  var import_viem4 = require("viem");
1399
+ var PointIndexerFinalizeError = class extends Error {
1400
+ constructor(message, context, cause) {
1401
+ super(message);
1402
+ this.context = context;
1403
+ this.cause = cause;
1404
+ this.name = "PointIndexerFinalizeError";
1405
+ }
1406
+ context;
1407
+ cause;
1408
+ };
1386
1409
  var TRANSFER_EVENT = (0, import_viem4.parseAbiItem)(
1387
1410
  "event Transfer(address indexed from, address indexed to, uint256 value)"
1388
1411
  );
@@ -1608,8 +1631,18 @@ var PointIndexer = class {
1608
1631
  evt.txHash,
1609
1632
  this.pointTokenAddress
1610
1633
  );
1611
- } catch {
1612
- return;
1634
+ } catch (err) {
1635
+ throw new PointIndexerFinalizeError(
1636
+ `PointIndexer.deductBalance failed for tx ${evt.txHash} (to=${evt.to}, amount=${evt.amount}, block=${evt.blockNumber}); cursor will NOT advance, next tick retries.`,
1637
+ {
1638
+ pointToken: this.pointTokenAddress,
1639
+ to: evt.to,
1640
+ amount: evt.amount,
1641
+ txHash: evt.txHash,
1642
+ blockNumber: evt.blockNumber
1643
+ },
1644
+ err
1645
+ );
1613
1646
  }
1614
1647
  try {
1615
1648
  await this.ledger.updateMintStatus(match.lockId, "MINTED", evt.txHash);
@@ -1631,6 +1664,16 @@ function pickMatchingLock(locks, amount) {
1631
1664
 
1632
1665
  // src/indexer/burnIndexer.ts
1633
1666
  var import_viem5 = require("viem");
1667
+ var BurnIndexerFinalizeError = class extends Error {
1668
+ constructor(message, context, cause) {
1669
+ super(message);
1670
+ this.context = context;
1671
+ this.cause = cause;
1672
+ this.name = "BurnIndexerFinalizeError";
1673
+ }
1674
+ context;
1675
+ cause;
1676
+ };
1634
1677
  var TRANSFER_EVENT2 = (0, import_viem5.parseAbiItem)(
1635
1678
  "event Transfer(address indexed from, address indexed to, uint256 value)"
1636
1679
  );
@@ -1798,7 +1841,18 @@ var BurnIndexer = class {
1798
1841
  try {
1799
1842
  await this.ledger.resolveCreditByBurnTx(lockId, evt.txHash);
1800
1843
  } catch (err) {
1801
- console.error("[PAFI] BurnIndexer finalize error \u2014 credit may be lost:", err);
1844
+ throw new BurnIndexerFinalizeError(
1845
+ `BurnIndexer.resolveCreditByBurnTx failed for tx ${evt.txHash} (lockId=${lockId}, from=${evt.from}, amount=${evt.amount}, block=${evt.blockNumber}); cursor will NOT advance, next tick retries.`,
1846
+ {
1847
+ pointToken: this.pointTokenAddress,
1848
+ from: evt.from,
1849
+ amount: evt.amount,
1850
+ txHash: evt.txHash,
1851
+ blockNumber: evt.blockNumber,
1852
+ lockId
1853
+ },
1854
+ err
1855
+ );
1802
1856
  }
1803
1857
  }
1804
1858
  };
@@ -2440,10 +2494,12 @@ var PTRedeemHandler = class {
2440
2494
  chainId: this.chainId,
2441
2495
  verifyingContract: pointTokenAddress
2442
2496
  };
2497
+ const BURN_SOURCE = import_core7.Source.EQUITY;
2443
2498
  const sponsoredBurnAmount = request.amount - fee;
2444
2499
  const sponsoredBurnRequest = {
2445
2500
  from: request.userAddress,
2446
2501
  amount: sponsoredBurnAmount,
2502
+ source: BURN_SOURCE,
2447
2503
  nonce: burnNonce,
2448
2504
  deadline
2449
2505
  };
@@ -2479,6 +2535,7 @@ var PTRedeemHandler = class {
2479
2535
  const fallbackBurnRequest = {
2480
2536
  from: request.userAddress,
2481
2537
  amount: request.amount,
2538
+ source: BURN_SOURCE,
2482
2539
  nonce: burnNonce,
2483
2540
  deadline
2484
2541
  };
@@ -4990,22 +5047,22 @@ var IssuerStateValidator = class _IssuerStateValidator {
4990
5047
  }
4991
5048
  throw err;
4992
5049
  }
4993
- const { issuer, totalSupply, hardCap, remaining } = state;
5050
+ const { issuer, equityCap, equitySupply, remaining } = state;
4994
5051
  if (!issuer.active) {
4995
5052
  throw new IssuerStateError(
4996
5053
  "ISSUER_INACTIVE",
4997
- `Issuer ${issuer.issuerAddress} is deactivated on IssuerRegistry`,
4998
- { issuer: issuer.issuerAddress, pointToken: issuer.pointToken }
5054
+ `Issuer "${issuer.name}" is deactivated on IssuerRegistry`,
5055
+ { pointToken }
4999
5056
  );
5000
5057
  }
5001
- if (totalSupply + amount > hardCap) {
5058
+ if (equitySupply + amount > equityCap.hardCap) {
5002
5059
  throw new IssuerStateError(
5003
5060
  "MINT_CAP_EXCEEDED",
5004
- `Requested ${amount} PT would exceed mint cap. Cap=${hardCap}, minted=${totalSupply}, remaining=${remaining}`,
5061
+ `Requested ${amount} PT would exceed EQUITY mint cap. Cap=${equityCap.hardCap}, equityMinted=${equitySupply}, remaining=${remaining}`,
5005
5062
  {
5006
5063
  requested: amount.toString(),
5007
- cap: hardCap.toString(),
5008
- minted: totalSupply.toString(),
5064
+ cap: equityCap.hardCap.toString(),
5065
+ equityMinted: equitySupply.toString(),
5009
5066
  remaining: remaining.toString()
5010
5067
  }
5011
5068
  );
@@ -5021,33 +5078,28 @@ var IssuerStateValidator = class _IssuerStateValidator {
5021
5078
  args: [issuerAddr]
5022
5079
  });
5023
5080
  const issuer = {
5024
- issuerAddress: issuerStruct.issuerAddress,
5025
5081
  signerAddress: issuerStruct.signerAddress,
5026
5082
  name: issuerStruct.name,
5027
- symbol: issuerStruct.symbol,
5028
5083
  active: issuerStruct.active,
5029
- pointToken: issuerStruct.pointToken,
5030
- mintingOracle: issuerStruct.mintingOracle
5084
+ capitalBase: issuerStruct.capitalBase,
5085
+ basisPoints: Number(issuerStruct.basisPoints)
5031
5086
  };
5032
- const [tokenCap, totalSupply] = await Promise.all([
5033
- (0, import_core19.getTokenCap)(this.provider, issuer.mintingOracle, tokenAddr),
5034
- this.provider.readContract({
5035
- address: tokenAddr,
5036
- abi: import_core19.POINT_TOKEN_ABI,
5037
- functionName: "totalSupply"
5038
- })
5039
- ]);
5040
- const tokenCapRecord = {
5041
- declaredTotalSupply: tokenCap.declaredTotalSupply,
5042
- capBasisPoints: tokenCap.capBasisPoints
5087
+ const equitySupply = await this.provider.readContract({
5088
+ address: tokenAddr,
5089
+ abi: import_core19.POINT_TOKEN_ABI,
5090
+ functionName: "equitySupply"
5091
+ });
5092
+ const hardCap = issuer.capitalBase * BigInt(issuer.basisPoints) / 10000n;
5093
+ const equityCap = {
5094
+ capitalBase: issuer.capitalBase,
5095
+ basisPoints: issuer.basisPoints,
5096
+ hardCap
5043
5097
  };
5044
- const hardCap = tokenCapRecord.declaredTotalSupply * BigInt(tokenCapRecord.capBasisPoints) / 10000n;
5045
- const remaining = hardCap > totalSupply ? hardCap - totalSupply : 0n;
5098
+ const remaining = hardCap > equitySupply ? hardCap - equitySupply : 0n;
5046
5099
  return {
5047
5100
  issuer,
5048
- tokenCap: tokenCapRecord,
5049
- totalSupply,
5050
- hardCap,
5101
+ equityCap,
5102
+ equitySupply,
5051
5103
  remaining
5052
5104
  };
5053
5105
  }
@@ -5090,7 +5142,7 @@ var MemoryRedemptionHistoryStore = class {
5090
5142
  };
5091
5143
 
5092
5144
  // src/index.ts
5093
- var PAFI_ISSUER_SDK_VERSION = true ? "0.23.0" : "dev";
5145
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.24.1" : "dev";
5094
5146
  // Annotate the CommonJS export names for ESM import in node:
5095
5147
  0 && (module.exports = {
5096
5148
  AdapterMisconfiguredError,
@@ -5099,6 +5151,7 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.23.0" : "dev";
5099
5151
  BundlerNotConfiguredError,
5100
5152
  BundlerRejectedError,
5101
5153
  BurnIndexer,
5154
+ BurnIndexerFinalizeError,
5102
5155
  ConfigurationError,
5103
5156
  DEFAULT_REDEMPTION_POLICY,
5104
5157
  DefaultPolicyEngine,
@@ -5130,6 +5183,7 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.23.0" : "dev";
5130
5183
  PerpDepositError,
5131
5184
  PerpDepositHandler,
5132
5185
  PointIndexer,
5186
+ PointIndexerFinalizeError,
5133
5187
  PointTokenDomainResolver,
5134
5188
  PolicyProvider,
5135
5189
  REDEMPTION_HISTORY_WINDOW_SEC,