@pafi-dev/issuer 0.5.15 → 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 +21 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -607,13 +607,7 @@ var RelayService = class {
|
|
|
607
607
|
err
|
|
608
608
|
);
|
|
609
609
|
}
|
|
610
|
-
const operations = [
|
|
611
|
-
{
|
|
612
|
-
target: params.pointTokenAddress,
|
|
613
|
-
value: 0n,
|
|
614
|
-
data: burnCallData
|
|
615
|
-
}
|
|
616
|
-
];
|
|
610
|
+
const operations = [];
|
|
617
611
|
if (params.feeAmount && params.feeAmount > 0n) {
|
|
618
612
|
if (!params.feeRecipient) {
|
|
619
613
|
throw new RelayError(
|
|
@@ -637,6 +631,11 @@ var RelayService = class {
|
|
|
637
631
|
})
|
|
638
632
|
});
|
|
639
633
|
}
|
|
634
|
+
operations.push({
|
|
635
|
+
target: params.pointTokenAddress,
|
|
636
|
+
value: 0n,
|
|
637
|
+
data: burnCallData
|
|
638
|
+
});
|
|
640
639
|
return (0, import_core2.buildPartialUserOperation)({
|
|
641
640
|
sender: params.userAddress,
|
|
642
641
|
nonce: params.aaNonce,
|
|
@@ -1414,16 +1413,24 @@ var PTRedeemHandler = class {
|
|
|
1414
1413
|
}
|
|
1415
1414
|
}
|
|
1416
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;
|
|
1417
1425
|
const onChainBalance = await (0, import_core4.getPointTokenBalance)(
|
|
1418
1426
|
this.provider,
|
|
1419
1427
|
this.pointTokenAddress,
|
|
1420
1428
|
request.userAddress
|
|
1421
1429
|
);
|
|
1422
|
-
|
|
1423
|
-
if (onChainBalance < totalRequired) {
|
|
1430
|
+
if (onChainBalance < request.amount) {
|
|
1424
1431
|
throw new PTRedeemError(
|
|
1425
1432
|
"INVALID_AMOUNT",
|
|
1426
|
-
`insufficient on-chain PT balance: have ${onChainBalance}, need ${
|
|
1433
|
+
`insufficient on-chain PT balance: have ${onChainBalance}, need ${request.amount}`
|
|
1427
1434
|
);
|
|
1428
1435
|
}
|
|
1429
1436
|
const deadline = BigInt(
|
|
@@ -1436,7 +1443,7 @@ var PTRedeemHandler = class {
|
|
|
1436
1443
|
};
|
|
1437
1444
|
const burnRequest = {
|
|
1438
1445
|
from: request.userAddress,
|
|
1439
|
-
amount:
|
|
1446
|
+
amount: burnAmount,
|
|
1440
1447
|
nonce: burnNonce,
|
|
1441
1448
|
deadline
|
|
1442
1449
|
};
|
|
@@ -1456,7 +1463,7 @@ var PTRedeemHandler = class {
|
|
|
1456
1463
|
}
|
|
1457
1464
|
const lockId = await this.ledger.reservePendingCredit(
|
|
1458
1465
|
request.userAddress,
|
|
1459
|
-
|
|
1466
|
+
netCreditAmount,
|
|
1460
1467
|
this.redeemLockDurationMs,
|
|
1461
1468
|
this.pointTokenAddress
|
|
1462
1469
|
);
|
|
@@ -1468,12 +1475,13 @@ var PTRedeemHandler = class {
|
|
|
1468
1475
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
1469
1476
|
burnRequest,
|
|
1470
1477
|
burnerSignature,
|
|
1471
|
-
feeAmount:
|
|
1478
|
+
feeAmount: fee,
|
|
1472
1479
|
feeRecipient: request.feeRecipient
|
|
1473
1480
|
});
|
|
1474
1481
|
return {
|
|
1475
1482
|
lockId,
|
|
1476
1483
|
userOp,
|
|
1484
|
+
netCreditAmount,
|
|
1477
1485
|
expiresInSeconds: Math.floor(this.redeemLockDurationMs / 1e3),
|
|
1478
1486
|
signatureDeadline: deadline
|
|
1479
1487
|
};
|