@pafi-dev/issuer 0.5.14 → 0.5.15
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 +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +29 -3
- 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,6 +1121,12 @@ 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. */
|
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,6 +1121,12 @@ 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. */
|
package/dist/index.js
CHANGED
|
@@ -567,6 +567,29 @@ var RelayService = class {
|
|
|
567
567
|
data: burnCallData
|
|
568
568
|
}
|
|
569
569
|
];
|
|
570
|
+
if (params.feeAmount && params.feeAmount > 0n) {
|
|
571
|
+
if (!params.feeRecipient) {
|
|
572
|
+
throw new RelayError(
|
|
573
|
+
"ENCODE_FAILED",
|
|
574
|
+
"prepareBurn: feeRecipient required when feeAmount > 0"
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
if (params.feeRecipient === "0x0000000000000000000000000000000000000000") {
|
|
578
|
+
throw new RelayError(
|
|
579
|
+
"ENCODE_FAILED",
|
|
580
|
+
"prepareBurn: feeRecipient must not be zero address"
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
operations.push({
|
|
584
|
+
target: params.pointTokenAddress,
|
|
585
|
+
value: 0n,
|
|
586
|
+
data: encodeFunctionData({
|
|
587
|
+
abi: erc20Abi,
|
|
588
|
+
functionName: "transfer",
|
|
589
|
+
args: [params.feeRecipient, params.feeAmount]
|
|
590
|
+
})
|
|
591
|
+
});
|
|
592
|
+
}
|
|
570
593
|
return buildPartialUserOperation({
|
|
571
594
|
sender: params.userAddress,
|
|
572
595
|
nonce: params.aaNonce,
|
|
@@ -1355,10 +1378,11 @@ var PTRedeemHandler = class {
|
|
|
1355
1378
|
this.pointTokenAddress,
|
|
1356
1379
|
request.userAddress
|
|
1357
1380
|
);
|
|
1358
|
-
|
|
1381
|
+
const totalRequired = request.amount + (request.feeAmount && request.feeAmount > 0n ? request.feeAmount : 0n);
|
|
1382
|
+
if (onChainBalance < totalRequired) {
|
|
1359
1383
|
throw new PTRedeemError(
|
|
1360
1384
|
"INVALID_AMOUNT",
|
|
1361
|
-
`insufficient on-chain PT balance: have ${onChainBalance}, need ${request.amount}`
|
|
1385
|
+
`insufficient on-chain PT balance: have ${onChainBalance}, need ${totalRequired}` + (request.feeAmount && request.feeAmount > 0n ? ` (${request.amount} burn + ${request.feeAmount} fee)` : "")
|
|
1362
1386
|
);
|
|
1363
1387
|
}
|
|
1364
1388
|
const deadline = BigInt(
|
|
@@ -1402,7 +1426,9 @@ var PTRedeemHandler = class {
|
|
|
1402
1426
|
pointTokenAddress: this.pointTokenAddress,
|
|
1403
1427
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
1404
1428
|
burnRequest,
|
|
1405
|
-
burnerSignature
|
|
1429
|
+
burnerSignature,
|
|
1430
|
+
feeAmount: request.feeAmount,
|
|
1431
|
+
feeRecipient: request.feeRecipient
|
|
1406
1432
|
});
|
|
1407
1433
|
return {
|
|
1408
1434
|
lockId,
|