@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 +42 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -452,6 +452,14 @@ interface PrepareBurnCommonParams {
|
|
|
452
452
|
aaNonce: bigint;
|
|
453
453
|
pointTokenAddress: Address;
|
|
454
454
|
batchExecutorAddress: Address;
|
|
455
|
+
/**
|
|
456
|
+
* Optional — application-level PT fee transfer appended after burn.
|
|
457
|
+
* Used for gas reimbursement on the sponsored path. Set both
|
|
458
|
+
* `feeAmount` and `feeRecipient` together. User must hold
|
|
459
|
+
* `burnAmount + feeAmount` PT.
|
|
460
|
+
*/
|
|
461
|
+
feeAmount?: bigint;
|
|
462
|
+
feeRecipient?: Address;
|
|
455
463
|
callGasLimit?: bigint;
|
|
456
464
|
verificationGasLimit?: bigint;
|
|
457
465
|
preVerificationGas?: bigint;
|
|
@@ -1113,12 +1121,24 @@ interface PTRedeemRequest {
|
|
|
1113
1121
|
amount: bigint;
|
|
1114
1122
|
/** ERC-4337 account nonce for the user's EOA. */
|
|
1115
1123
|
aaNonce: bigint;
|
|
1124
|
+
/**
|
|
1125
|
+
* Optional PT fee transfer appended after the burn (sponsored path).
|
|
1126
|
+
* User must hold `amount + feeAmount` PT. Both fields together or neither.
|
|
1127
|
+
*/
|
|
1128
|
+
feeAmount?: bigint;
|
|
1129
|
+
feeRecipient?: Address;
|
|
1116
1130
|
}
|
|
1117
1131
|
interface PTRedeemResponse {
|
|
1118
1132
|
/** Lock id from the ledger — client polls status with this. */
|
|
1119
1133
|
lockId: string;
|
|
1120
1134
|
/** Unsigned UserOp — FE attaches paymaster + user signature + submits. */
|
|
1121
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;
|
|
1122
1142
|
/** Seconds until the lock expires if the burn doesn't land. */
|
|
1123
1143
|
expiresInSeconds: number;
|
|
1124
1144
|
/** The BurnRequest deadline (unix seconds) — FE uses this to surface a countdown. */
|
package/dist/index.d.ts
CHANGED
|
@@ -452,6 +452,14 @@ interface PrepareBurnCommonParams {
|
|
|
452
452
|
aaNonce: bigint;
|
|
453
453
|
pointTokenAddress: Address;
|
|
454
454
|
batchExecutorAddress: Address;
|
|
455
|
+
/**
|
|
456
|
+
* Optional — application-level PT fee transfer appended after burn.
|
|
457
|
+
* Used for gas reimbursement on the sponsored path. Set both
|
|
458
|
+
* `feeAmount` and `feeRecipient` together. User must hold
|
|
459
|
+
* `burnAmount + feeAmount` PT.
|
|
460
|
+
*/
|
|
461
|
+
feeAmount?: bigint;
|
|
462
|
+
feeRecipient?: Address;
|
|
455
463
|
callGasLimit?: bigint;
|
|
456
464
|
verificationGasLimit?: bigint;
|
|
457
465
|
preVerificationGas?: bigint;
|
|
@@ -1113,12 +1121,24 @@ interface PTRedeemRequest {
|
|
|
1113
1121
|
amount: bigint;
|
|
1114
1122
|
/** ERC-4337 account nonce for the user's EOA. */
|
|
1115
1123
|
aaNonce: bigint;
|
|
1124
|
+
/**
|
|
1125
|
+
* Optional PT fee transfer appended after the burn (sponsored path).
|
|
1126
|
+
* User must hold `amount + feeAmount` PT. Both fields together or neither.
|
|
1127
|
+
*/
|
|
1128
|
+
feeAmount?: bigint;
|
|
1129
|
+
feeRecipient?: Address;
|
|
1116
1130
|
}
|
|
1117
1131
|
interface PTRedeemResponse {
|
|
1118
1132
|
/** Lock id from the ledger — client polls status with this. */
|
|
1119
1133
|
lockId: string;
|
|
1120
1134
|
/** Unsigned UserOp — FE attaches paymaster + user signature + submits. */
|
|
1121
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;
|
|
1122
1142
|
/** Seconds until the lock expires if the burn doesn't land. */
|
|
1123
1143
|
expiresInSeconds: number;
|
|
1124
1144
|
/** The BurnRequest deadline (unix seconds) — FE uses this to surface a countdown. */
|
package/dist/index.js
CHANGED
|
@@ -560,13 +560,35 @@ var RelayService = class {
|
|
|
560
560
|
err
|
|
561
561
|
);
|
|
562
562
|
}
|
|
563
|
-
const operations = [
|
|
564
|
-
|
|
563
|
+
const operations = [];
|
|
564
|
+
if (params.feeAmount && params.feeAmount > 0n) {
|
|
565
|
+
if (!params.feeRecipient) {
|
|
566
|
+
throw new RelayError(
|
|
567
|
+
"ENCODE_FAILED",
|
|
568
|
+
"prepareBurn: feeRecipient required when feeAmount > 0"
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
if (params.feeRecipient === "0x0000000000000000000000000000000000000000") {
|
|
572
|
+
throw new RelayError(
|
|
573
|
+
"ENCODE_FAILED",
|
|
574
|
+
"prepareBurn: feeRecipient must not be zero address"
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
operations.push({
|
|
565
578
|
target: params.pointTokenAddress,
|
|
566
579
|
value: 0n,
|
|
567
|
-
data:
|
|
568
|
-
|
|
569
|
-
|
|
580
|
+
data: encodeFunctionData({
|
|
581
|
+
abi: erc20Abi,
|
|
582
|
+
functionName: "transfer",
|
|
583
|
+
args: [params.feeRecipient, params.feeAmount]
|
|
584
|
+
})
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
operations.push({
|
|
588
|
+
target: params.pointTokenAddress,
|
|
589
|
+
value: 0n,
|
|
590
|
+
data: burnCallData
|
|
591
|
+
});
|
|
570
592
|
return buildPartialUserOperation({
|
|
571
593
|
sender: params.userAddress,
|
|
572
594
|
nonce: params.aaNonce,
|
|
@@ -1350,6 +1372,15 @@ var PTRedeemHandler = class {
|
|
|
1350
1372
|
}
|
|
1351
1373
|
}
|
|
1352
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;
|
|
1353
1384
|
const onChainBalance = await getPointTokenBalance2(
|
|
1354
1385
|
this.provider,
|
|
1355
1386
|
this.pointTokenAddress,
|
|
@@ -1371,7 +1402,7 @@ var PTRedeemHandler = class {
|
|
|
1371
1402
|
};
|
|
1372
1403
|
const burnRequest = {
|
|
1373
1404
|
from: request.userAddress,
|
|
1374
|
-
amount:
|
|
1405
|
+
amount: burnAmount,
|
|
1375
1406
|
nonce: burnNonce,
|
|
1376
1407
|
deadline
|
|
1377
1408
|
};
|
|
@@ -1391,7 +1422,7 @@ var PTRedeemHandler = class {
|
|
|
1391
1422
|
}
|
|
1392
1423
|
const lockId = await this.ledger.reservePendingCredit(
|
|
1393
1424
|
request.userAddress,
|
|
1394
|
-
|
|
1425
|
+
netCreditAmount,
|
|
1395
1426
|
this.redeemLockDurationMs,
|
|
1396
1427
|
this.pointTokenAddress
|
|
1397
1428
|
);
|
|
@@ -1402,11 +1433,14 @@ var PTRedeemHandler = class {
|
|
|
1402
1433
|
pointTokenAddress: this.pointTokenAddress,
|
|
1403
1434
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
1404
1435
|
burnRequest,
|
|
1405
|
-
burnerSignature
|
|
1436
|
+
burnerSignature,
|
|
1437
|
+
feeAmount: fee,
|
|
1438
|
+
feeRecipient: request.feeRecipient
|
|
1406
1439
|
});
|
|
1407
1440
|
return {
|
|
1408
1441
|
lockId,
|
|
1409
1442
|
userOp,
|
|
1443
|
+
netCreditAmount,
|
|
1410
1444
|
expiresInSeconds: Math.floor(this.redeemLockDurationMs / 1e3),
|
|
1411
1445
|
signatureDeadline: deadline
|
|
1412
1446
|
};
|