@pafi-dev/issuer 0.39.3 → 0.40.0
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 +57 -262
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -156
- package/dist/index.d.ts +33 -156
- package/dist/index.js +40 -243
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -45,7 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
NonceManager: () => NonceManager,
|
|
46
46
|
NoopRateLimiter: () => NoopRateLimiter,
|
|
47
47
|
PAFI_ISSUER_SDK_VERSION: () => PAFI_ISSUER_SDK_VERSION,
|
|
48
|
-
PAFI_SUBGRAPH_URL: () =>
|
|
48
|
+
PAFI_SUBGRAPH_URL: () => import_core14.PAFI_SUBGRAPH_URL,
|
|
49
49
|
PTClaimError: () => PTClaimError,
|
|
50
50
|
PTClaimHandler: () => PTClaimHandler,
|
|
51
51
|
PTRedeemError: () => PTRedeemError,
|
|
@@ -83,7 +83,6 @@ __export(index_exports, {
|
|
|
83
83
|
defaultPolicyFor: () => defaultPolicyFor,
|
|
84
84
|
evaluateRedemption: () => evaluateRedemption,
|
|
85
85
|
handleClaimStatus: () => handleClaimStatus,
|
|
86
|
-
handleDelegateSubmit: () => handleDelegateSubmit,
|
|
87
86
|
handleMobilePrepare: () => handleMobilePrepare,
|
|
88
87
|
handleMobileSubmit: () => handleMobileSubmit,
|
|
89
88
|
handleRedeemStatus: () => handleRedeemStatus,
|
|
@@ -95,8 +94,7 @@ __export(index_exports, {
|
|
|
95
94
|
prepareMobileUserOp: () => prepareMobileUserOp,
|
|
96
95
|
relayUserOp: () => relayUserOp,
|
|
97
96
|
requestPaymaster: () => requestPaymaster,
|
|
98
|
-
serializeEntryToJsonRpc: () => serializeEntryToJsonRpc
|
|
99
|
-
serializeUserOpTypedData: () => serializeUserOpTypedData
|
|
97
|
+
serializeEntryToJsonRpc: () => serializeEntryToJsonRpc
|
|
100
98
|
});
|
|
101
99
|
module.exports = __toCommonJS(index_exports);
|
|
102
100
|
|
|
@@ -2770,24 +2768,6 @@ var MemoryPendingUserOpStore = class {
|
|
|
2770
2768
|
|
|
2771
2769
|
// src/userop-store/prepareUserOp.ts
|
|
2772
2770
|
var import_core9 = require("@pafi-dev/core");
|
|
2773
|
-
function serializeUserOpTypedData(td) {
|
|
2774
|
-
return {
|
|
2775
|
-
domain: td.domain,
|
|
2776
|
-
types: td.types,
|
|
2777
|
-
primaryType: td.primaryType,
|
|
2778
|
-
message: {
|
|
2779
|
-
sender: td.message.sender,
|
|
2780
|
-
nonce: `0x${td.message.nonce.toString(16)}`,
|
|
2781
|
-
initCode: td.message.initCode,
|
|
2782
|
-
callData: td.message.callData,
|
|
2783
|
-
accountGasLimits: td.message.accountGasLimits,
|
|
2784
|
-
preVerificationGas: `0x${td.message.preVerificationGas.toString(16)}`,
|
|
2785
|
-
gasFees: td.message.gasFees,
|
|
2786
|
-
paymasterAndData: td.message.paymasterAndData
|
|
2787
|
-
}
|
|
2788
|
-
};
|
|
2789
|
-
}
|
|
2790
|
-
__name(serializeUserOpTypedData, "serializeUserOpTypedData");
|
|
2791
2771
|
function mergePaymasterFields(userOp, paymasterFields) {
|
|
2792
2772
|
if (!paymasterFields) return userOp;
|
|
2793
2773
|
const merged = {
|
|
@@ -2803,8 +2783,7 @@ function applyPaymasterGasEstimates(partialUserOp, paymasterFields, chainId) {
|
|
|
2803
2783
|
const userOp = mergePaymasterFields(partialUserOp, paymasterFields);
|
|
2804
2784
|
return {
|
|
2805
2785
|
userOp,
|
|
2806
|
-
userOpHash: (0, import_core9.computeUserOpHash)(userOp, chainId)
|
|
2807
|
-
typedData: serializeUserOpTypedData((0, import_core9.buildUserOpTypedData)(userOp, chainId))
|
|
2786
|
+
userOpHash: (0, import_core9.computeUserOpHash)(userOp, chainId)
|
|
2808
2787
|
};
|
|
2809
2788
|
}
|
|
2810
2789
|
__name(applyPaymasterGasEstimates, "applyPaymasterGasEstimates");
|
|
@@ -3169,7 +3148,7 @@ var PTClaimHandler = class {
|
|
|
3169
3148
|
}
|
|
3170
3149
|
}
|
|
3171
3150
|
const chainAddresses = (0, import_core11.getContractAddresses)(request.chainId);
|
|
3172
|
-
const {
|
|
3151
|
+
const { kernel: batchExecutorAddress } = chainAddresses;
|
|
3173
3152
|
let mintRequestNonce;
|
|
3174
3153
|
try {
|
|
3175
3154
|
mintRequestNonce = await this.cfg.provider.readContract({
|
|
@@ -3283,8 +3262,8 @@ var PTClaimHandler = class {
|
|
|
3283
3262
|
throw new PTClaimError("BUILD_FAILED", `prepareMint (fallback) failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
3284
3263
|
}
|
|
3285
3264
|
}
|
|
3286
|
-
const calls = (0, import_core11.
|
|
3287
|
-
const callsFallback = fallback ? (0, import_core11.
|
|
3265
|
+
const calls = (0, import_core11.decodeKernelExecuteCalls)(userOp.callData);
|
|
3266
|
+
const callsFallback = fallback ? (0, import_core11.decodeKernelExecuteCalls)(fallback.callData) : void 0;
|
|
3288
3267
|
return {
|
|
3289
3268
|
userOp,
|
|
3290
3269
|
fallback,
|
|
@@ -3429,122 +3408,15 @@ var PerpDepositHandler = class {
|
|
|
3429
3408
|
brokerHash,
|
|
3430
3409
|
usdcAddress,
|
|
3431
3410
|
relayAddress,
|
|
3432
|
-
calls: (0, import_core12.
|
|
3433
|
-
callsFallback: fallbackOp ? (0, import_core12.
|
|
3411
|
+
calls: (0, import_core12.decodeKernelExecuteCalls)(sponsoredOp.callData),
|
|
3412
|
+
callsFallback: fallbackOp ? (0, import_core12.decodeKernelExecuteCalls)(fallbackOp.callData) : void 0
|
|
3434
3413
|
};
|
|
3435
3414
|
}
|
|
3436
3415
|
};
|
|
3437
3416
|
|
|
3438
|
-
// src/api/delegateHandler.ts
|
|
3439
|
-
var import_core13 = require("@pafi-dev/core");
|
|
3440
|
-
var import_viem11 = require("viem");
|
|
3441
|
-
var DEFAULT_DELEGATE_GAS = {
|
|
3442
|
-
callGasLimit: 100000n,
|
|
3443
|
-
verificationGasLimit: 150000n,
|
|
3444
|
-
preVerificationGas: 50000n
|
|
3445
|
-
};
|
|
3446
|
-
async function handleDelegatePrepare(params) {
|
|
3447
|
-
const { batchExecutor } = (0, import_core13.getContractAddresses)(params.chainId);
|
|
3448
|
-
const partial = (0, import_core13.buildDelegationUserOp)({
|
|
3449
|
-
userAddress: params.userAddress,
|
|
3450
|
-
aaNonce: params.aaNonce,
|
|
3451
|
-
gasLimits: {
|
|
3452
|
-
callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_DELEGATE_GAS.callGasLimit,
|
|
3453
|
-
verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_DELEGATE_GAS.verificationGasLimit,
|
|
3454
|
-
preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_DELEGATE_GAS.preVerificationGas
|
|
3455
|
-
}
|
|
3456
|
-
});
|
|
3457
|
-
const userOp = {
|
|
3458
|
-
sender: partial.sender,
|
|
3459
|
-
nonce: partial.nonce,
|
|
3460
|
-
callData: partial.callData,
|
|
3461
|
-
callGasLimit: partial.callGasLimit,
|
|
3462
|
-
verificationGasLimit: partial.verificationGasLimit,
|
|
3463
|
-
preVerificationGas: partial.preVerificationGas,
|
|
3464
|
-
maxFeePerGas: params.fees.maxFeePerGas ?? 0n,
|
|
3465
|
-
maxPriorityFeePerGas: params.fees.maxPriorityFeePerGas ?? 0n
|
|
3466
|
-
};
|
|
3467
|
-
const authorization = (0, import_core13.buildEip7702Authorization)({
|
|
3468
|
-
chainId: params.chainId,
|
|
3469
|
-
address: batchExecutor,
|
|
3470
|
-
nonce: params.delegationNonce,
|
|
3471
|
-
authSig: params.authSig
|
|
3472
|
-
});
|
|
3473
|
-
const paymasterFields = await requestPaymaster({
|
|
3474
|
-
client: params.pafiBackendClient,
|
|
3475
|
-
chainId: params.chainId,
|
|
3476
|
-
scenario: "delegate",
|
|
3477
|
-
userOp,
|
|
3478
|
-
pointTokenAddress: batchExecutor,
|
|
3479
|
-
eip7702Auth: authorization,
|
|
3480
|
-
onWarning: params.onWarning
|
|
3481
|
-
});
|
|
3482
|
-
const prepared = applyPaymasterGasEstimates(userOp, paymasterFields, params.chainId);
|
|
3483
|
-
const merged = prepared.userOp;
|
|
3484
|
-
const userOpHash = prepared.userOpHash;
|
|
3485
|
-
await params.store.save(params.lockId, {
|
|
3486
|
-
sender: merged.sender,
|
|
3487
|
-
nonce: merged.nonce.toString(10),
|
|
3488
|
-
callData: merged.callData,
|
|
3489
|
-
callGasLimit: merged.callGasLimit.toString(10),
|
|
3490
|
-
verificationGasLimit: merged.verificationGasLimit.toString(10),
|
|
3491
|
-
preVerificationGas: merged.preVerificationGas.toString(10),
|
|
3492
|
-
maxFeePerGas: merged.maxFeePerGas.toString(10),
|
|
3493
|
-
maxPriorityFeePerGas: merged.maxPriorityFeePerGas.toString(10),
|
|
3494
|
-
...merged.paymaster ? {
|
|
3495
|
-
paymaster: merged.paymaster
|
|
3496
|
-
} : {},
|
|
3497
|
-
...merged.paymasterVerificationGasLimit ? {
|
|
3498
|
-
paymasterVerificationGasLimit: merged.paymasterVerificationGasLimit.toString(10)
|
|
3499
|
-
} : {},
|
|
3500
|
-
...merged.paymasterPostOpGasLimit ? {
|
|
3501
|
-
paymasterPostOpGasLimit: merged.paymasterPostOpGasLimit.toString(10)
|
|
3502
|
-
} : {},
|
|
3503
|
-
...merged.paymasterData ? {
|
|
3504
|
-
paymasterData: merged.paymasterData
|
|
3505
|
-
} : {},
|
|
3506
|
-
chainId: params.chainId,
|
|
3507
|
-
userOpHash,
|
|
3508
|
-
eip7702Auth: authorization
|
|
3509
|
-
}, params.ttlSeconds);
|
|
3510
|
-
return {
|
|
3511
|
-
lockId: params.lockId,
|
|
3512
|
-
userOpHash,
|
|
3513
|
-
typedData: prepared.typedData,
|
|
3514
|
-
expiresInSeconds: params.ttlSeconds,
|
|
3515
|
-
isSponsored: !!paymasterFields
|
|
3516
|
-
};
|
|
3517
|
-
}
|
|
3518
|
-
__name(handleDelegatePrepare, "handleDelegatePrepare");
|
|
3519
|
-
async function handleDelegateSubmit(params) {
|
|
3520
|
-
const entry = await params.store.get(params.lockId);
|
|
3521
|
-
if (!entry) {
|
|
3522
|
-
throw new PendingUserOpNotFoundError(params.lockId);
|
|
3523
|
-
}
|
|
3524
|
-
if ((0, import_viem11.getAddress)(entry.sender) !== (0, import_viem11.getAddress)(params.authenticatedAddress)) {
|
|
3525
|
-
throw new PendingUserOpForbiddenError(params.lockId);
|
|
3526
|
-
}
|
|
3527
|
-
if (!entry.eip7702Auth) {
|
|
3528
|
-
throw new Error(`delegate entry ${params.lockId} missing eip7702Auth \u2014 prepare step did not run correctly`);
|
|
3529
|
-
}
|
|
3530
|
-
const userOpJson = serializeEntryToJsonRpc(entry, params.userOpSig, "sponsored");
|
|
3531
|
-
const result = await relayUserOp({
|
|
3532
|
-
client: params.pafiBackendClient,
|
|
3533
|
-
userOp: userOpJson,
|
|
3534
|
-
entryPoint: params.entryPoint ?? import_core13.ENTRY_POINT_V08,
|
|
3535
|
-
eip7702Auth: entry.eip7702Auth
|
|
3536
|
-
});
|
|
3537
|
-
await params.store.delete(params.lockId);
|
|
3538
|
-
return {
|
|
3539
|
-
userOpHash: result.userOpHash
|
|
3540
|
-
};
|
|
3541
|
-
}
|
|
3542
|
-
__name(handleDelegateSubmit, "handleDelegateSubmit");
|
|
3543
|
-
|
|
3544
3417
|
// src/api/issuerApiAdapter.ts
|
|
3545
|
-
var
|
|
3546
|
-
var
|
|
3547
|
-
var import_core14 = require("@pafi-dev/core");
|
|
3418
|
+
var import_viem11 = require("viem");
|
|
3419
|
+
var import_core13 = require("@pafi-dev/core");
|
|
3548
3420
|
var AdapterMisconfiguredError = class extends Error {
|
|
3549
3421
|
static {
|
|
3550
3422
|
__name(this, "AdapterMisconfiguredError");
|
|
@@ -3599,7 +3471,7 @@ var IssuerApiAdapter = class {
|
|
|
3599
3471
|
async pools(authenticatedAddress, chainId, pointTokenAddress) {
|
|
3600
3472
|
const result = await this.cfg.issuerService.api.handlePools(authenticatedAddress, {
|
|
3601
3473
|
chainId,
|
|
3602
|
-
pointTokenAddress: (0,
|
|
3474
|
+
pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress)
|
|
3603
3475
|
});
|
|
3604
3476
|
return {
|
|
3605
3477
|
pools: result.pools
|
|
@@ -3608,8 +3480,8 @@ var IssuerApiAdapter = class {
|
|
|
3608
3480
|
async user(authenticatedAddress, chainId, userAddress, pointTokenAddress) {
|
|
3609
3481
|
const result = await this.cfg.issuerService.api.handleUser(authenticatedAddress, {
|
|
3610
3482
|
chainId,
|
|
3611
|
-
userAddress: (0,
|
|
3612
|
-
pointTokenAddress: (0,
|
|
3483
|
+
userAddress: (0, import_viem11.getAddress)(userAddress),
|
|
3484
|
+
pointTokenAddress: (0, import_viem11.getAddress)(pointTokenAddress)
|
|
3613
3485
|
});
|
|
3614
3486
|
return {
|
|
3615
3487
|
offChainBalance: result.offChainBalance.toString(),
|
|
@@ -3624,7 +3496,7 @@ var IssuerApiAdapter = class {
|
|
|
3624
3496
|
// ------------------------------ Action endpoints -------------------------
|
|
3625
3497
|
async claim(input) {
|
|
3626
3498
|
const ptClaimHandler = this.assertHandler(this.cfg.ptClaimHandler, "ptClaimHandler", "claim");
|
|
3627
|
-
const pointTokenAddress = (0,
|
|
3499
|
+
const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
|
|
3628
3500
|
const result = await ptClaimHandler.handle({
|
|
3629
3501
|
authenticatedAddress: input.authenticatedAddress,
|
|
3630
3502
|
userAddress: input.authenticatedAddress,
|
|
@@ -3645,7 +3517,7 @@ var IssuerApiAdapter = class {
|
|
|
3645
3517
|
}
|
|
3646
3518
|
async redeem(input) {
|
|
3647
3519
|
this.assertRedeemHandler();
|
|
3648
|
-
const pointTokenAddress = (0,
|
|
3520
|
+
const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
|
|
3649
3521
|
const response = await this.cfg.ptRedeemHandler.handle({
|
|
3650
3522
|
userAddress: input.authenticatedAddress,
|
|
3651
3523
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -3656,8 +3528,8 @@ var IssuerApiAdapter = class {
|
|
|
3656
3528
|
});
|
|
3657
3529
|
const sponsorAuth = await this.buildSponsorAuth(input.authenticatedAddress, response.userOp.callData, input.chainId, "burn");
|
|
3658
3530
|
return {
|
|
3659
|
-
calls: (0,
|
|
3660
|
-
callsFallback: response.fallback ? (0,
|
|
3531
|
+
calls: (0, import_core13.decodeKernelExecuteCalls)(response.userOp.callData),
|
|
3532
|
+
callsFallback: response.fallback ? (0, import_core13.decodeKernelExecuteCalls)(response.fallback.userOp.callData) : void 0,
|
|
3661
3533
|
feeAmount: response.feeAmount.toString(),
|
|
3662
3534
|
lockId: response.lockId,
|
|
3663
3535
|
lockIdFallback: response.fallback?.lockId,
|
|
@@ -3697,7 +3569,7 @@ var IssuerApiAdapter = class {
|
|
|
3697
3569
|
// ------------------------------ Mobile endpoints -------------------------
|
|
3698
3570
|
async claimPrepare(input) {
|
|
3699
3571
|
const ptClaimHandler = this.assertHandler(this.cfg.ptClaimHandler, "ptClaimHandler", "claimPrepare");
|
|
3700
|
-
const pointTokenAddress = (0,
|
|
3572
|
+
const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
|
|
3701
3573
|
const claimResult = await ptClaimHandler.handle({
|
|
3702
3574
|
authenticatedAddress: input.authenticatedAddress,
|
|
3703
3575
|
userAddress: input.authenticatedAddress,
|
|
@@ -3710,9 +3582,7 @@ var IssuerApiAdapter = class {
|
|
|
3710
3582
|
return {
|
|
3711
3583
|
lockId: claimResult.lockId,
|
|
3712
3584
|
userOpHash: prepared.sponsored.userOpHash,
|
|
3713
|
-
typedData: prepared.sponsored.typedData,
|
|
3714
3585
|
userOpHashFallback: prepared.fallback?.userOpHash,
|
|
3715
|
-
typedDataFallback: prepared.fallback?.typedData,
|
|
3716
3586
|
feeAmount: claimResult.feeAmount.toString(),
|
|
3717
3587
|
signatureDeadline: claimResult.signatureDeadline.toString(),
|
|
3718
3588
|
expiresInSeconds: claimResult.expiresInSeconds,
|
|
@@ -3733,7 +3603,7 @@ var IssuerApiAdapter = class {
|
|
|
3733
3603
|
}
|
|
3734
3604
|
async redeemPrepare(input) {
|
|
3735
3605
|
this.assertRedeemHandler();
|
|
3736
|
-
const pointTokenAddress = (0,
|
|
3606
|
+
const pointTokenAddress = (0, import_viem11.getAddress)(input.pointTokenAddress);
|
|
3737
3607
|
const redeemResponse = await this.cfg.ptRedeemHandler.handle({
|
|
3738
3608
|
userAddress: input.authenticatedAddress,
|
|
3739
3609
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -3747,9 +3617,7 @@ var IssuerApiAdapter = class {
|
|
|
3747
3617
|
lockId: redeemResponse.lockId,
|
|
3748
3618
|
lockIdFallback: redeemResponse.fallback?.lockId,
|
|
3749
3619
|
userOpHash: prepared.sponsored.userOpHash,
|
|
3750
|
-
typedData: prepared.sponsored.typedData,
|
|
3751
3620
|
userOpHashFallback: prepared.fallback?.userOpHash,
|
|
3752
|
-
typedDataFallback: prepared.fallback?.typedData,
|
|
3753
3621
|
netCreditAmount: redeemResponse.netCreditAmount.toString(),
|
|
3754
3622
|
netCreditAmountFallback: redeemResponse.fallback?.netCreditAmount.toString(),
|
|
3755
3623
|
feeAmount: redeemResponse.feeAmount.toString(),
|
|
@@ -3790,81 +3658,10 @@ var IssuerApiAdapter = class {
|
|
|
3790
3658
|
onWarning: this.cfg.onWarning
|
|
3791
3659
|
});
|
|
3792
3660
|
}
|
|
3793
|
-
//
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
this.cfg.provider.getCode({
|
|
3798
|
-
address: authenticatedAddress
|
|
3799
|
-
}),
|
|
3800
|
-
this.cfg.provider.getTransactionCount({
|
|
3801
|
-
address: authenticatedAddress,
|
|
3802
|
-
blockTag: "pending"
|
|
3803
|
-
})
|
|
3804
|
-
]);
|
|
3805
|
-
return {
|
|
3806
|
-
isDelegated: (0, import_core14.parseEip7702DelegatedAddress)(code) !== null,
|
|
3807
|
-
batchExecutorAddress: batchExecutor,
|
|
3808
|
-
delegationNonce: nonce.toString(),
|
|
3809
|
-
chainId
|
|
3810
|
-
};
|
|
3811
|
-
}
|
|
3812
|
-
/**
|
|
3813
|
-
* Build the delegation-anchor UserOp + obtain paymaster sponsorship
|
|
3814
|
-
* + persist as a pending entry. Mobile must:
|
|
3815
|
-
*
|
|
3816
|
-
* 1. Sign EIP-7702 authorization LOCALLY (Privy `signAuthorization`
|
|
3817
|
-
* with `{contractAddress: batchExecutorAddress, chainId,
|
|
3818
|
-
* nonce: delegationNonce}`) → 65-byte authSig hex.
|
|
3819
|
-
* 2. POST `/delegate/prepare` with `{ chainId, delegationNonce,
|
|
3820
|
-
* authSig }` → this method.
|
|
3821
|
-
* 3. Sign returned `userOpHash` LOCALLY (`signTypedData(typedData)`).
|
|
3822
|
-
* 4. POST `/delegate/submit` with `{ lockId, userOpSig }`.
|
|
3823
|
-
*
|
|
3824
|
-
* v0.7.7 — replaces single-shot delegateSubmit that tried to relay
|
|
3825
|
-
* a UserOp with empty `signature: "0x"` (Simple7702Account's
|
|
3826
|
-
* validateUserOp reverts `ECDSAInvalidSignatureLength` 0xfce698f7).
|
|
3827
|
-
*/
|
|
3828
|
-
async delegatePrepare(authenticatedAddress, input) {
|
|
3829
|
-
const { batchExecutor } = (0, import_core14.getContractAddresses)(input.chainId);
|
|
3830
|
-
const fees = await this.cfg.provider.estimateFeesPerGas();
|
|
3831
|
-
const lockId = (0, import_node_crypto3.randomUUID)();
|
|
3832
|
-
const result = await handleDelegatePrepare({
|
|
3833
|
-
userAddress: authenticatedAddress,
|
|
3834
|
-
chainId: input.chainId,
|
|
3835
|
-
delegationNonce: input.delegationNonce,
|
|
3836
|
-
aaNonce: input.aaNonce,
|
|
3837
|
-
authSig: input.authSig,
|
|
3838
|
-
fees,
|
|
3839
|
-
lockId,
|
|
3840
|
-
store: this.cfg.pendingUserOpStore,
|
|
3841
|
-
ttlSeconds: 15 * 60,
|
|
3842
|
-
pafiBackendClient: this.cfg.pafiBackendClient,
|
|
3843
|
-
onWarning: this.cfg.onWarning
|
|
3844
|
-
});
|
|
3845
|
-
return {
|
|
3846
|
-
lockId: result.lockId,
|
|
3847
|
-
userOpHash: result.userOpHash,
|
|
3848
|
-
typedData: result.typedData,
|
|
3849
|
-
expiresInSeconds: result.expiresInSeconds,
|
|
3850
|
-
isSponsored: result.isSponsored,
|
|
3851
|
-
delegationNonce: input.delegationNonce.toString(),
|
|
3852
|
-
batchExecutorAddress: batchExecutor,
|
|
3853
|
-
chainId: input.chainId
|
|
3854
|
-
};
|
|
3855
|
-
}
|
|
3856
|
-
async delegateSubmit(input) {
|
|
3857
|
-
const result = await handleDelegateSubmit({
|
|
3858
|
-
lockId: input.lockId,
|
|
3859
|
-
authenticatedAddress: input.authenticatedAddress,
|
|
3860
|
-
userOpSig: input.userOpSig,
|
|
3861
|
-
store: this.cfg.pendingUserOpStore,
|
|
3862
|
-
pafiBackendClient: this.cfg.pafiBackendClient
|
|
3863
|
-
});
|
|
3864
|
-
return {
|
|
3865
|
-
userOpHash: result.userOpHash
|
|
3866
|
-
};
|
|
3867
|
-
}
|
|
3661
|
+
// Delegate endpoints removed — folded-in delegation (via
|
|
3662
|
+
// `eip7702Auth` on claim/redeem prepare) is now the only path. The
|
|
3663
|
+
// bundler applies SetCode + handleOps in one tx, so there is no
|
|
3664
|
+
// separate `/delegate/*` flow. See `handleMobilePrepare`.
|
|
3868
3665
|
// ------------------------------ Internal helpers -------------------------
|
|
3869
3666
|
/**
|
|
3870
3667
|
* Build + sign a SponsorAuth payload. Returns `undefined` when no
|
|
@@ -3872,7 +3669,7 @@ var IssuerApiAdapter = class {
|
|
|
3872
3669
|
*/
|
|
3873
3670
|
async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
|
|
3874
3671
|
if (!this.cfg.pafiIssuerId) return void 0;
|
|
3875
|
-
return (0,
|
|
3672
|
+
return (0, import_core13.buildAndSignSponsorAuth)({
|
|
3876
3673
|
userAddress: authenticatedAddress,
|
|
3877
3674
|
callData,
|
|
3878
3675
|
chainId,
|
|
@@ -3919,8 +3716,8 @@ var IssuerApiAdapter = class {
|
|
|
3919
3716
|
};
|
|
3920
3717
|
|
|
3921
3718
|
// src/pools/subgraphPoolsProvider.ts
|
|
3922
|
-
var
|
|
3923
|
-
var
|
|
3719
|
+
var import_viem12 = require("viem");
|
|
3720
|
+
var import_core14 = require("@pafi-dev/core");
|
|
3924
3721
|
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
3925
3722
|
var MAX_REASONABLE_FEE_TIER = 1e6;
|
|
3926
3723
|
var POOL_QUERY = `
|
|
@@ -3937,7 +3734,7 @@ var POOL_QUERY = `
|
|
|
3937
3734
|
}
|
|
3938
3735
|
`;
|
|
3939
3736
|
function createSubgraphPoolsProvider(config = {}) {
|
|
3940
|
-
const subgraphUrl = config.subgraphUrl ??
|
|
3737
|
+
const subgraphUrl = config.subgraphUrl ?? import_core14.PAFI_SUBGRAPH_URL;
|
|
3941
3738
|
try {
|
|
3942
3739
|
const parsed = new URL(subgraphUrl);
|
|
3943
3740
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -4034,7 +3831,7 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress,
|
|
|
4034
3831
|
return [];
|
|
4035
3832
|
}
|
|
4036
3833
|
const { pool } = token;
|
|
4037
|
-
if (!(0,
|
|
3834
|
+
if (!(0, import_viem12.isAddress)(pool.token0.id) || !(0, import_viem12.isAddress)(pool.token1.id)) {
|
|
4038
3835
|
const error = new Error("[PAFI] SubgraphPoolsProvider: invalid token address in response");
|
|
4039
3836
|
console.error(error.message, "\u2014 skipping pool");
|
|
4040
3837
|
reportError(error);
|
|
@@ -4082,7 +3879,7 @@ var PRICE_QUERY = `
|
|
|
4082
3879
|
}
|
|
4083
3880
|
`;
|
|
4084
3881
|
function createSubgraphNativeUsdtQuoter(config = {}) {
|
|
4085
|
-
const subgraphUrl = config.subgraphUrl ??
|
|
3882
|
+
const subgraphUrl = config.subgraphUrl ?? import_core14.PAFI_SUBGRAPH_URL;
|
|
4086
3883
|
try {
|
|
4087
3884
|
const parsed = new URL(subgraphUrl);
|
|
4088
3885
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -4176,8 +3973,8 @@ function toUsdtPerNative(priceFloat, usdtDecimals) {
|
|
|
4176
3973
|
__name(toUsdtPerNative, "toUsdtPerNative");
|
|
4177
3974
|
|
|
4178
3975
|
// src/pools/nativePtQuoter.ts
|
|
4179
|
-
var
|
|
4180
|
-
var CHAINLINK_ABI = (0,
|
|
3976
|
+
var import_viem13 = require("viem");
|
|
3977
|
+
var CHAINLINK_ABI = (0, import_viem13.parseAbi)([
|
|
4181
3978
|
"function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"
|
|
4182
3979
|
]);
|
|
4183
3980
|
var CHAINLINK_MAX_AGE_S = 3600n;
|
|
@@ -4194,7 +3991,7 @@ var POOL_PRICE_QUERY = `
|
|
|
4194
3991
|
}
|
|
4195
3992
|
`;
|
|
4196
3993
|
function createNativePtQuoter(config) {
|
|
4197
|
-
const { provider, pointTokenAddress, chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70", subgraphUrl =
|
|
3994
|
+
const { provider, pointTokenAddress, chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70", subgraphUrl = import_core14.PAFI_SUBGRAPH_URL, cacheTtlMs = 3e4, fallbackEthPriceUsd = 3e3, fallbackPtPriceUsdt = 0.1, failClosed = false, fetchImpl = globalThis.fetch, now = /* @__PURE__ */ __name(() => Date.now(), "now") } = config;
|
|
4198
3995
|
let ethPriceCache;
|
|
4199
3996
|
let ptPriceCache;
|
|
4200
3997
|
async function getEthPrice8dec() {
|
|
@@ -4290,7 +4087,7 @@ function parseBigDecimalTo18(s) {
|
|
|
4290
4087
|
__name(parseBigDecimalTo18, "parseBigDecimalTo18");
|
|
4291
4088
|
|
|
4292
4089
|
// src/pafi-backend/client.ts
|
|
4293
|
-
var
|
|
4090
|
+
var import_core15 = require("@pafi-dev/core");
|
|
4294
4091
|
function extractPafiErrorFields(json, status) {
|
|
4295
4092
|
const inner = typeof json.error === "object" && json.error !== null ? json.error : null;
|
|
4296
4093
|
const code = inner?.code ?? json.code ?? "INTERNAL_ERROR";
|
|
@@ -4320,7 +4117,7 @@ var PafiBackendClient = class {
|
|
|
4320
4117
|
if (!config.issuerId) throw new Error("PafiBackendClient: issuerId is required");
|
|
4321
4118
|
if (!config.apiKey) throw new Error("PafiBackendClient: apiKey is required");
|
|
4322
4119
|
this.config = config;
|
|
4323
|
-
this.baseUrl = (0,
|
|
4120
|
+
this.baseUrl = (0, import_core15.getPafiServiceUrls)(config.chainId, {
|
|
4324
4121
|
sponsorRelayer: config.baseUrl
|
|
4325
4122
|
}).sponsorRelayer;
|
|
4326
4123
|
}
|
|
@@ -4472,8 +4269,8 @@ var PafiBackendClient = class {
|
|
|
4472
4269
|
};
|
|
4473
4270
|
|
|
4474
4271
|
// src/config.ts
|
|
4475
|
-
var
|
|
4476
|
-
var
|
|
4272
|
+
var import_viem14 = require("viem");
|
|
4273
|
+
var import_core18 = require("@pafi-dev/core");
|
|
4477
4274
|
|
|
4478
4275
|
// src/redemption/evaluator.ts
|
|
4479
4276
|
var SECONDS_PER_DAY = 24 * 60 * 60;
|
|
@@ -4587,10 +4384,10 @@ __name(nextBlackoutEndAfter, "nextBlackoutEndAfter");
|
|
|
4587
4384
|
var REDEMPTION_HISTORY_WINDOW_SEC = SECONDS_PER_DAY;
|
|
4588
4385
|
|
|
4589
4386
|
// src/redemption/policyProvider.ts
|
|
4590
|
-
var
|
|
4387
|
+
var import_core17 = require("@pafi-dev/core");
|
|
4591
4388
|
|
|
4592
4389
|
// src/redemption/settlementClient.ts
|
|
4593
|
-
var
|
|
4390
|
+
var import_core16 = require("@pafi-dev/core");
|
|
4594
4391
|
var DEFAULT_TIMEOUT_MS = 1e3;
|
|
4595
4392
|
var SettlementClient = class {
|
|
4596
4393
|
static {
|
|
@@ -4602,7 +4399,7 @@ var SettlementClient = class {
|
|
|
4602
4399
|
if (!config.issuerId) throw new Error("SettlementClient: issuerId is required");
|
|
4603
4400
|
if (!config.apiKey) throw new Error("SettlementClient: apiKey is required");
|
|
4604
4401
|
this.config = {
|
|
4605
|
-
baseUrl: (0,
|
|
4402
|
+
baseUrl: (0, import_core16.getPafiServiceUrls)(config.chainId, {
|
|
4606
4403
|
issuerApi: config.baseUrl
|
|
4607
4404
|
}).issuerApi.replace(/\/+$/, ""),
|
|
4608
4405
|
issuerId: config.issuerId,
|
|
@@ -4737,7 +4534,7 @@ __name(defaultPolicyFor, "defaultPolicyFor");
|
|
|
4737
4534
|
|
|
4738
4535
|
// src/redemption/policyProvider.ts
|
|
4739
4536
|
var DEFAULT_CACHE_TTL_MS3 = 5 * 60 * 1e3;
|
|
4740
|
-
var PolicyProviderUnavailableError = class extends
|
|
4537
|
+
var PolicyProviderUnavailableError = class extends import_core17.PafiSdkError {
|
|
4741
4538
|
static {
|
|
4742
4539
|
__name(this, "PolicyProviderUnavailableError");
|
|
4743
4540
|
}
|
|
@@ -4887,7 +4684,7 @@ async function createIssuerService(config) {
|
|
|
4887
4684
|
if (rawAddresses.length === 0) {
|
|
4888
4685
|
throw new Error("createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required");
|
|
4889
4686
|
}
|
|
4890
|
-
const tokenAddresses = rawAddresses.map((a) => (0,
|
|
4687
|
+
const tokenAddresses = rawAddresses.map((a) => (0, import_viem14.getAddress)(a));
|
|
4891
4688
|
const ledger = config.ledger;
|
|
4892
4689
|
const sessionStore = config.sessionStore ?? new MemorySessionStore();
|
|
4893
4690
|
const policy = config.policy ?? new DefaultPolicyEngine({
|
|
@@ -4914,7 +4711,7 @@ async function createIssuerService(config) {
|
|
|
4914
4711
|
provider: config.provider
|
|
4915
4712
|
});
|
|
4916
4713
|
}
|
|
4917
|
-
const sdkWrapperAddress = (0,
|
|
4714
|
+
const sdkWrapperAddress = (0, import_core18.getContractAddresses)(config.chainId).mintFeeWrapper;
|
|
4918
4715
|
const wrapperOverride = config.indexer?.mintFeeWrapperAddress;
|
|
4919
4716
|
const resolvedWrapperAddress = wrapperOverride !== void 0 ? wrapperOverride : sdkWrapperAddress;
|
|
4920
4717
|
const baseCursorStore = config.indexer?.cursorStore;
|
|
@@ -4949,9 +4746,9 @@ async function createIssuerService(config) {
|
|
|
4949
4746
|
}
|
|
4950
4747
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
4951
4748
|
}
|
|
4952
|
-
const chainAddresses = (0,
|
|
4749
|
+
const chainAddresses = (0, import_core18.getContractAddresses)(config.chainId);
|
|
4953
4750
|
const resolvedContracts = {
|
|
4954
|
-
|
|
4751
|
+
kernel: chainAddresses.kernel,
|
|
4955
4752
|
usdt: chainAddresses.usdt,
|
|
4956
4753
|
issuerRegistry: chainAddresses.issuerRegistry,
|
|
4957
4754
|
mintingOracle: chainAddresses.mintingOracle,
|
|
@@ -5039,8 +4836,8 @@ async function createIssuerService(config) {
|
|
|
5039
4836
|
__name(createIssuerService, "createIssuerService");
|
|
5040
4837
|
|
|
5041
4838
|
// src/issuer-state/validator.ts
|
|
5042
|
-
var
|
|
5043
|
-
var
|
|
4839
|
+
var import_viem15 = require("viem");
|
|
4840
|
+
var import_core19 = require("@pafi-dev/core");
|
|
5044
4841
|
var ISSUER_RECORD_TTL_MS = 1e4;
|
|
5045
4842
|
var IssuerStateValidator = class _IssuerStateValidator {
|
|
5046
4843
|
static {
|
|
@@ -5060,7 +4857,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
5060
4857
|
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
5061
4858
|
*/
|
|
5062
4859
|
static forChain(provider, chainId) {
|
|
5063
|
-
const { issuerRegistry } = (0,
|
|
4860
|
+
const { issuerRegistry } = (0, import_core19.getContractAddresses)(chainId);
|
|
5064
4861
|
return new _IssuerStateValidator(provider, issuerRegistry);
|
|
5065
4862
|
}
|
|
5066
4863
|
/**
|
|
@@ -5071,7 +4868,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
5071
4868
|
*/
|
|
5072
4869
|
invalidate(pointToken) {
|
|
5073
4870
|
if (pointToken) {
|
|
5074
|
-
const key = (0,
|
|
4871
|
+
const key = (0, import_viem15.getAddress)(pointToken);
|
|
5075
4872
|
this.pointTokenIssuerCache.delete(key);
|
|
5076
4873
|
this.stateCache.delete(key);
|
|
5077
4874
|
this.inflight.delete(key);
|
|
@@ -5086,23 +4883,23 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
5086
4883
|
* The issuer field is set at `initialize()` and never changes.
|
|
5087
4884
|
*/
|
|
5088
4885
|
async getIssuerAddressForPointToken(pointToken) {
|
|
5089
|
-
const key = (0,
|
|
4886
|
+
const key = (0, import_viem15.getAddress)(pointToken);
|
|
5090
4887
|
const cached = this.pointTokenIssuerCache.get(key);
|
|
5091
4888
|
if (cached) return cached;
|
|
5092
4889
|
const issuer = await this.provider.readContract({
|
|
5093
4890
|
address: key,
|
|
5094
|
-
abi:
|
|
4891
|
+
abi: import_core19.POINT_TOKEN_ABI,
|
|
5095
4892
|
functionName: "issuer"
|
|
5096
4893
|
});
|
|
5097
|
-
this.pointTokenIssuerCache.set(key, (0,
|
|
5098
|
-
return (0,
|
|
4894
|
+
this.pointTokenIssuerCache.set(key, (0, import_viem15.getAddress)(issuer));
|
|
4895
|
+
return (0, import_viem15.getAddress)(issuer);
|
|
5099
4896
|
}
|
|
5100
4897
|
/**
|
|
5101
4898
|
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
5102
4899
|
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
5103
4900
|
*/
|
|
5104
4901
|
async getIssuerState(pointToken) {
|
|
5105
|
-
const tokenAddr = (0,
|
|
4902
|
+
const tokenAddr = (0, import_viem15.getAddress)(pointToken);
|
|
5106
4903
|
const now = Date.now();
|
|
5107
4904
|
const cached = this.stateCache.get(tokenAddr);
|
|
5108
4905
|
if (cached && cached.expiresAt > now) return cached.value;
|
|
@@ -5163,7 +4960,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
5163
4960
|
const issuerAddr = await this.getIssuerAddressForPointToken(tokenAddr);
|
|
5164
4961
|
const issuerStruct = await this.provider.readContract({
|
|
5165
4962
|
address: this.registryAddress,
|
|
5166
|
-
abi:
|
|
4963
|
+
abi: import_core19.issuerRegistryAbi,
|
|
5167
4964
|
functionName: "getIssuer",
|
|
5168
4965
|
args: [
|
|
5169
4966
|
issuerAddr
|
|
@@ -5178,7 +4975,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
5178
4975
|
};
|
|
5179
4976
|
const equitySupply = await this.provider.readContract({
|
|
5180
4977
|
address: tokenAddr,
|
|
5181
|
-
abi:
|
|
4978
|
+
abi: import_core19.POINT_TOKEN_ABI,
|
|
5182
4979
|
functionName: "equitySupply"
|
|
5183
4980
|
});
|
|
5184
4981
|
const hardCap = issuer.capitalBase * BigInt(issuer.basisPoints) / 10000n;
|
|
@@ -5237,7 +5034,7 @@ var MemoryRedemptionHistoryStore = class {
|
|
|
5237
5034
|
};
|
|
5238
5035
|
|
|
5239
5036
|
// src/index.ts
|
|
5240
|
-
var PAFI_ISSUER_SDK_VERSION = true ? "0.
|
|
5037
|
+
var PAFI_ISSUER_SDK_VERSION = true ? "0.40.0" : "dev";
|
|
5241
5038
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5242
5039
|
0 && (module.exports = {
|
|
5243
5040
|
AdapterMisconfiguredError,
|
|
@@ -5302,7 +5099,6 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.39.3" : "dev";
|
|
|
5302
5099
|
defaultPolicyFor,
|
|
5303
5100
|
evaluateRedemption,
|
|
5304
5101
|
handleClaimStatus,
|
|
5305
|
-
handleDelegateSubmit,
|
|
5306
5102
|
handleMobilePrepare,
|
|
5307
5103
|
handleMobileSubmit,
|
|
5308
5104
|
handleRedeemStatus,
|
|
@@ -5314,7 +5110,6 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.39.3" : "dev";
|
|
|
5314
5110
|
prepareMobileUserOp,
|
|
5315
5111
|
relayUserOp,
|
|
5316
5112
|
requestPaymaster,
|
|
5317
|
-
serializeEntryToJsonRpc
|
|
5318
|
-
serializeUserOpTypedData
|
|
5113
|
+
serializeEntryToJsonRpc
|
|
5319
5114
|
});
|
|
5320
5115
|
//# sourceMappingURL=index.cjs.map
|