@pafi-dev/issuer 0.5.14 → 0.5.16

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
@@ -607,13 +607,35 @@ var RelayService = class {
607
607
  err
608
608
  );
609
609
  }
610
- const operations = [
611
- {
610
+ const operations = [];
611
+ if (params.feeAmount && params.feeAmount > 0n) {
612
+ if (!params.feeRecipient) {
613
+ throw new RelayError(
614
+ "ENCODE_FAILED",
615
+ "prepareBurn: feeRecipient required when feeAmount > 0"
616
+ );
617
+ }
618
+ if (params.feeRecipient === "0x0000000000000000000000000000000000000000") {
619
+ throw new RelayError(
620
+ "ENCODE_FAILED",
621
+ "prepareBurn: feeRecipient must not be zero address"
622
+ );
623
+ }
624
+ operations.push({
612
625
  target: params.pointTokenAddress,
613
626
  value: 0n,
614
- data: burnCallData
615
- }
616
- ];
627
+ data: (0, import_viem3.encodeFunctionData)({
628
+ abi: import_viem3.erc20Abi,
629
+ functionName: "transfer",
630
+ args: [params.feeRecipient, params.feeAmount]
631
+ })
632
+ });
633
+ }
634
+ operations.push({
635
+ target: params.pointTokenAddress,
636
+ value: 0n,
637
+ data: burnCallData
638
+ });
617
639
  return (0, import_core2.buildPartialUserOperation)({
618
640
  sender: params.userAddress,
619
641
  nonce: params.aaNonce,
@@ -1391,6 +1413,15 @@ var PTRedeemHandler = class {
1391
1413
  }
1392
1414
  }
1393
1415
  async _handleAfterNonceLock(request, burnNonce) {
1416
+ const fee = request.feeAmount && request.feeAmount > 0n ? request.feeAmount : 0n;
1417
+ if (fee > 0n && fee >= request.amount) {
1418
+ throw new PTRedeemError(
1419
+ "INVALID_AMOUNT",
1420
+ `fee (${fee}) must be strictly less than redeem amount (${request.amount})`
1421
+ );
1422
+ }
1423
+ const burnAmount = request.amount - fee;
1424
+ const netCreditAmount = burnAmount;
1394
1425
  const onChainBalance = await (0, import_core4.getPointTokenBalance)(
1395
1426
  this.provider,
1396
1427
  this.pointTokenAddress,
@@ -1412,7 +1443,7 @@ var PTRedeemHandler = class {
1412
1443
  };
1413
1444
  const burnRequest = {
1414
1445
  from: request.userAddress,
1415
- amount: request.amount,
1446
+ amount: burnAmount,
1416
1447
  nonce: burnNonce,
1417
1448
  deadline
1418
1449
  };
@@ -1432,7 +1463,7 @@ var PTRedeemHandler = class {
1432
1463
  }
1433
1464
  const lockId = await this.ledger.reservePendingCredit(
1434
1465
  request.userAddress,
1435
- request.amount,
1466
+ netCreditAmount,
1436
1467
  this.redeemLockDurationMs,
1437
1468
  this.pointTokenAddress
1438
1469
  );
@@ -1443,11 +1474,14 @@ var PTRedeemHandler = class {
1443
1474
  pointTokenAddress: this.pointTokenAddress,
1444
1475
  batchExecutorAddress: this.batchExecutorAddress,
1445
1476
  burnRequest,
1446
- burnerSignature
1477
+ burnerSignature,
1478
+ feeAmount: fee,
1479
+ feeRecipient: request.feeRecipient
1447
1480
  });
1448
1481
  return {
1449
1482
  lockId,
1450
1483
  userOp,
1484
+ netCreditAmount,
1451
1485
  expiresInSeconds: Math.floor(this.redeemLockDurationMs / 1e3),
1452
1486
  signatureDeadline: deadline
1453
1487
  };