@pafi-dev/issuer 0.5.16 → 0.5.18
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 +54 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -7
- package/dist/index.d.ts +21 -7
- package/dist/index.js +54 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1420,8 +1420,6 @@ var PTRedeemHandler = class {
|
|
|
1420
1420
|
`fee (${fee}) must be strictly less than redeem amount (${request.amount})`
|
|
1421
1421
|
);
|
|
1422
1422
|
}
|
|
1423
|
-
const burnAmount = request.amount - fee;
|
|
1424
|
-
const netCreditAmount = burnAmount;
|
|
1425
1423
|
const onChainBalance = await (0, import_core4.getPointTokenBalance)(
|
|
1426
1424
|
this.provider,
|
|
1427
1425
|
this.pointTokenAddress,
|
|
@@ -1441,47 +1439,83 @@ var PTRedeemHandler = class {
|
|
|
1441
1439
|
chainId: this.chainId,
|
|
1442
1440
|
verifyingContract: this.domain.verifyingContract ?? this.pointTokenAddress
|
|
1443
1441
|
};
|
|
1444
|
-
const
|
|
1442
|
+
const sponsoredBurnAmount = request.amount - fee;
|
|
1443
|
+
const sponsoredBurnRequest = {
|
|
1445
1444
|
from: request.userAddress,
|
|
1446
|
-
amount:
|
|
1445
|
+
amount: sponsoredBurnAmount,
|
|
1447
1446
|
nonce: burnNonce,
|
|
1448
1447
|
deadline
|
|
1449
1448
|
};
|
|
1450
|
-
let
|
|
1449
|
+
let sponsoredSig;
|
|
1451
1450
|
try {
|
|
1452
|
-
|
|
1453
|
-
this.burnerSignerWallet,
|
|
1454
|
-
domain,
|
|
1455
|
-
burnRequest
|
|
1456
|
-
);
|
|
1457
|
-
burnerSignature = sig.serialized;
|
|
1451
|
+
sponsoredSig = (await (0, import_core4.signBurnRequest)(this.burnerSignerWallet, domain, sponsoredBurnRequest)).serialized;
|
|
1458
1452
|
} catch (err) {
|
|
1459
1453
|
throw new PTRedeemError(
|
|
1460
1454
|
"SIGNING_FAILED",
|
|
1461
|
-
`failed to sign BurnRequest: ${err instanceof Error ? err.message : String(err)}`
|
|
1455
|
+
`failed to sign sponsored BurnRequest: ${err instanceof Error ? err.message : String(err)}`
|
|
1462
1456
|
);
|
|
1463
1457
|
}
|
|
1464
|
-
const
|
|
1458
|
+
const sponsoredLockId = await this.ledger.reservePendingCredit(
|
|
1465
1459
|
request.userAddress,
|
|
1466
|
-
|
|
1460
|
+
sponsoredBurnAmount,
|
|
1467
1461
|
this.redeemLockDurationMs,
|
|
1468
1462
|
this.pointTokenAddress
|
|
1469
1463
|
);
|
|
1470
|
-
const
|
|
1464
|
+
const sponsoredUserOp = this.relayService.prepareBurn({
|
|
1471
1465
|
mode: "burnWithSig",
|
|
1472
1466
|
userAddress: request.userAddress,
|
|
1473
1467
|
aaNonce: request.aaNonce,
|
|
1474
1468
|
pointTokenAddress: this.pointTokenAddress,
|
|
1475
1469
|
batchExecutorAddress: this.batchExecutorAddress,
|
|
1476
|
-
burnRequest,
|
|
1477
|
-
burnerSignature,
|
|
1470
|
+
burnRequest: sponsoredBurnRequest,
|
|
1471
|
+
burnerSignature: sponsoredSig,
|
|
1478
1472
|
feeAmount: fee,
|
|
1479
1473
|
feeRecipient: request.feeRecipient
|
|
1480
1474
|
});
|
|
1475
|
+
let fallback = void 0;
|
|
1476
|
+
if (fee > 0n) {
|
|
1477
|
+
const fallbackBurnRequest = {
|
|
1478
|
+
from: request.userAddress,
|
|
1479
|
+
amount: request.amount,
|
|
1480
|
+
nonce: burnNonce,
|
|
1481
|
+
deadline
|
|
1482
|
+
};
|
|
1483
|
+
let fallbackSig;
|
|
1484
|
+
try {
|
|
1485
|
+
fallbackSig = (await (0, import_core4.signBurnRequest)(this.burnerSignerWallet, domain, fallbackBurnRequest)).serialized;
|
|
1486
|
+
} catch (err) {
|
|
1487
|
+
throw new PTRedeemError(
|
|
1488
|
+
"SIGNING_FAILED",
|
|
1489
|
+
`failed to sign fallback BurnRequest: ${err instanceof Error ? err.message : String(err)}`
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
const fallbackLockId = await this.ledger.reservePendingCredit(
|
|
1493
|
+
request.userAddress,
|
|
1494
|
+
request.amount,
|
|
1495
|
+
this.redeemLockDurationMs,
|
|
1496
|
+
this.pointTokenAddress
|
|
1497
|
+
);
|
|
1498
|
+
const fallbackUserOp = this.relayService.prepareBurn({
|
|
1499
|
+
mode: "burnWithSig",
|
|
1500
|
+
userAddress: request.userAddress,
|
|
1501
|
+
aaNonce: request.aaNonce,
|
|
1502
|
+
pointTokenAddress: this.pointTokenAddress,
|
|
1503
|
+
batchExecutorAddress: this.batchExecutorAddress,
|
|
1504
|
+
burnRequest: fallbackBurnRequest,
|
|
1505
|
+
burnerSignature: fallbackSig
|
|
1506
|
+
// No feeAmount/feeRecipient — fallback is fee-free.
|
|
1507
|
+
});
|
|
1508
|
+
fallback = {
|
|
1509
|
+
lockId: fallbackLockId,
|
|
1510
|
+
userOp: fallbackUserOp,
|
|
1511
|
+
netCreditAmount: request.amount
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1481
1514
|
return {
|
|
1482
|
-
lockId,
|
|
1483
|
-
userOp,
|
|
1484
|
-
netCreditAmount,
|
|
1515
|
+
lockId: sponsoredLockId,
|
|
1516
|
+
userOp: sponsoredUserOp,
|
|
1517
|
+
netCreditAmount: sponsoredBurnAmount,
|
|
1518
|
+
fallback,
|
|
1485
1519
|
expiresInSeconds: Math.floor(this.redeemLockDurationMs / 1e3),
|
|
1486
1520
|
signatureDeadline: deadline
|
|
1487
1521
|
};
|