@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.d.cts
CHANGED
|
@@ -1133,6 +1133,12 @@ interface PTRedeemResponse {
|
|
|
1133
1133
|
lockId: string;
|
|
1134
1134
|
/** Unsigned UserOp — FE attaches paymaster + user signature + submits. */
|
|
1135
1135
|
userOp: PartialUserOperation;
|
|
1136
|
+
/**
|
|
1137
|
+
* Actual burn amount signed in BurnRequest (= request.amount - feeAmount).
|
|
1138
|
+
* Equals what BurnIndexer credits off-chain. FE uses this as the user-
|
|
1139
|
+
* facing "amount you'll receive" figure.
|
|
1140
|
+
*/
|
|
1141
|
+
netCreditAmount: bigint;
|
|
1136
1142
|
/** Seconds until the lock expires if the burn doesn't land. */
|
|
1137
1143
|
expiresInSeconds: number;
|
|
1138
1144
|
/** The BurnRequest deadline (unix seconds) — FE uses this to surface a countdown. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1133,6 +1133,12 @@ interface PTRedeemResponse {
|
|
|
1133
1133
|
lockId: string;
|
|
1134
1134
|
/** Unsigned UserOp — FE attaches paymaster + user signature + submits. */
|
|
1135
1135
|
userOp: PartialUserOperation;
|
|
1136
|
+
/**
|
|
1137
|
+
* Actual burn amount signed in BurnRequest (= request.amount - feeAmount).
|
|
1138
|
+
* Equals what BurnIndexer credits off-chain. FE uses this as the user-
|
|
1139
|
+
* facing "amount you'll receive" figure.
|
|
1140
|
+
*/
|
|
1141
|
+
netCreditAmount: bigint;
|
|
1136
1142
|
/** Seconds until the lock expires if the burn doesn't land. */
|
|
1137
1143
|
expiresInSeconds: number;
|
|
1138
1144
|
/** The BurnRequest deadline (unix seconds) — FE uses this to surface a countdown. */
|
package/dist/index.js
CHANGED
|
@@ -560,13 +560,7 @@ var RelayService = class {
|
|
|
560
560
|
err
|
|
561
561
|
);
|
|
562
562
|
}
|
|
563
|
-
const operations = [
|
|
564
|
-
{
|
|
565
|
-
target: params.pointTokenAddress,
|
|
566
|
-
value: 0n,
|
|
567
|
-
data: burnCallData
|
|
568
|
-
}
|
|
569
|
-
];
|
|
563
|
+
const operations = [];
|
|
570
564
|
if (params.feeAmount && params.feeAmount > 0n) {
|
|
571
565
|
if (!params.feeRecipient) {
|
|
572
566
|
throw new RelayError(
|
|
@@ -590,6 +584,11 @@ var RelayService = class {
|
|
|
590
584
|
})
|
|
591
585
|
});
|
|
592
586
|
}
|
|
587
|
+
operations.push({
|
|
588
|
+
target: params.pointTokenAddress,
|
|
589
|
+
value: 0n,
|
|
590
|
+
data: burnCallData
|
|
591
|
+
});
|
|
593
592
|
return buildPartialUserOperation({
|
|
594
593
|
sender: params.userAddress,
|
|
595
594
|
nonce: params.aaNonce,
|
|
@@ -1373,16 +1372,24 @@ var PTRedeemHandler = class {
|
|
|
1373
1372
|
}
|
|
1374
1373
|
}
|
|
1375
1374
|
async _handleAfterNonceLock(request, burnNonce) {
|
|
1375
|
+
const fee = request.feeAmount && request.feeAmount > 0n ? request.feeAmount : 0n;
|
|
1376
|
+
if (fee > 0n && fee >= request.amount) {
|
|
1377
|
+
throw new PTRedeemError(
|
|
1378
|
+
"INVALID_AMOUNT",
|
|
1379
|
+
`fee (${fee}) must be strictly less than redeem amount (${request.amount})`
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
const burnAmount = request.amount - fee;
|
|
1383
|
+
const netCreditAmount = burnAmount;
|
|
1376
1384
|
const onChainBalance = await getPointTokenBalance2(
|
|
1377
1385
|
this.provider,
|
|
1378
1386
|
this.pointTokenAddress,
|
|
1379
1387
|
request.userAddress
|
|
1380
1388
|
);
|
|
1381
|
-
|
|
1382
|
-
if (onChainBalance < totalRequired) {
|
|
1389
|
+
if (onChainBalance < request.amount) {
|
|
1383
1390
|
throw new PTRedeemError(
|
|
1384
1391
|
"INVALID_AMOUNT",
|
|
1385
|
-
`insufficient on-chain PT balance: have ${onChainBalance}, need ${
|
|
1392
|
+
`insufficient on-chain PT balance: have ${onChainBalance}, need ${request.amount}`
|
|
1386
1393
|
);
|
|
1387
1394
|
}
|
|
1388
1395
|
const deadline = BigInt(
|
|
@@ -1395,7 +1402,7 @@ var PTRedeemHandler = class {
|
|
|
1395
1402
|
};
|
|
1396
1403
|
const burnRequest = {
|
|
1397
1404
|
from: request.userAddress,
|
|
1398
|
-
amount:
|
|
1405
|
+
amount: burnAmount,
|
|
1399
1406
|
nonce: burnNonce,
|
|
1400
1407
|
deadline
|
|
1401
1408
|
};
|
|
@@ -1415,7 +1422,7 @@ var PTRedeemHandler = class {
|
|
|
1415
1422
|
}
|
|
1416
1423
|
const lockId = await this.ledger.reservePendingCredit(
|
|
1417
1424
|
request.userAddress,
|
|
1418
|
-
|
|
1425
|
+
netCreditAmount,
|
|
1419
1426
|
this.redeemLockDurationMs,
|
|
1420
1427
|
this.pointTokenAddress
|
|
1421
1428
|
);
|
|
@@ -1427,12 +1434,13 @@ var PTRedeemHandler = class {
|
|
|
1427
1434
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
1428
1435
|
burnRequest,
|
|
1429
1436
|
burnerSignature,
|
|
1430
|
-
feeAmount:
|
|
1437
|
+
feeAmount: fee,
|
|
1431
1438
|
feeRecipient: request.feeRecipient
|
|
1432
1439
|
});
|
|
1433
1440
|
return {
|
|
1434
1441
|
lockId,
|
|
1435
1442
|
userOp,
|
|
1443
|
+
netCreditAmount,
|
|
1436
1444
|
expiresInSeconds: Math.floor(this.redeemLockDurationMs / 1e3),
|
|
1437
1445
|
signatureDeadline: deadline
|
|
1438
1446
|
};
|