@pafi-dev/issuer 0.39.3 → 0.41.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 +60 -286
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -172
- package/dist/index.d.ts +51 -172
- package/dist/index.js +45 -269
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2440,7 +2440,7 @@ __name(handleRedeemStatus, "handleRedeemStatus");
|
|
|
2440
2440
|
|
|
2441
2441
|
// src/api/mobileHandlers.ts
|
|
2442
2442
|
import { getAddress as getAddress8 } from "viem";
|
|
2443
|
-
import {
|
|
2443
|
+
import { ENTRY_POINT_V07, parseEip7702DelegatedAddress } from "@pafi-dev/core";
|
|
2444
2444
|
|
|
2445
2445
|
// src/userop-store/serialize.ts
|
|
2446
2446
|
import { serializeUserOpToJsonRpc } from "@pafi-dev/core";
|
|
@@ -2508,25 +2508,7 @@ var MemoryPendingUserOpStore = class {
|
|
|
2508
2508
|
};
|
|
2509
2509
|
|
|
2510
2510
|
// src/userop-store/prepareUserOp.ts
|
|
2511
|
-
import {
|
|
2512
|
-
function serializeUserOpTypedData(td) {
|
|
2513
|
-
return {
|
|
2514
|
-
domain: td.domain,
|
|
2515
|
-
types: td.types,
|
|
2516
|
-
primaryType: td.primaryType,
|
|
2517
|
-
message: {
|
|
2518
|
-
sender: td.message.sender,
|
|
2519
|
-
nonce: `0x${td.message.nonce.toString(16)}`,
|
|
2520
|
-
initCode: td.message.initCode,
|
|
2521
|
-
callData: td.message.callData,
|
|
2522
|
-
accountGasLimits: td.message.accountGasLimits,
|
|
2523
|
-
preVerificationGas: `0x${td.message.preVerificationGas.toString(16)}`,
|
|
2524
|
-
gasFees: td.message.gasFees,
|
|
2525
|
-
paymasterAndData: td.message.paymasterAndData
|
|
2526
|
-
}
|
|
2527
|
-
};
|
|
2528
|
-
}
|
|
2529
|
-
__name(serializeUserOpTypedData, "serializeUserOpTypedData");
|
|
2511
|
+
import { computeUserOpHash } from "@pafi-dev/core";
|
|
2530
2512
|
function mergePaymasterFields(userOp, paymasterFields) {
|
|
2531
2513
|
if (!paymasterFields) return userOp;
|
|
2532
2514
|
const merged = {
|
|
@@ -2542,8 +2524,7 @@ function applyPaymasterGasEstimates(partialUserOp, paymasterFields, chainId) {
|
|
|
2542
2524
|
const userOp = mergePaymasterFields(partialUserOp, paymasterFields);
|
|
2543
2525
|
return {
|
|
2544
2526
|
userOp,
|
|
2545
|
-
userOpHash: computeUserOpHash(userOp, chainId)
|
|
2546
|
-
typedData: serializeUserOpTypedData(buildUserOpTypedData(userOp, chainId))
|
|
2527
|
+
userOpHash: computeUserOpHash(userOp, chainId)
|
|
2547
2528
|
};
|
|
2548
2529
|
}
|
|
2549
2530
|
__name(applyPaymasterGasEstimates, "applyPaymasterGasEstimates");
|
|
@@ -2803,7 +2784,7 @@ async function handleMobileSubmit(params) {
|
|
|
2803
2784
|
const result = await relayUserOp({
|
|
2804
2785
|
client: params.pafiBackendClient,
|
|
2805
2786
|
userOp: userOpJson,
|
|
2806
|
-
entryPoint: params.entryPoint ??
|
|
2787
|
+
entryPoint: params.entryPoint ?? ENTRY_POINT_V07,
|
|
2807
2788
|
eip7702Auth: entry.eip7702Auth
|
|
2808
2789
|
});
|
|
2809
2790
|
const targetLockId = variant === "fallback" && entry.fallback?.lockId ? entry.fallback.lockId : params.lockId;
|
|
@@ -2817,7 +2798,7 @@ __name(handleMobileSubmit, "handleMobileSubmit");
|
|
|
2817
2798
|
|
|
2818
2799
|
// src/api/handlers/ptClaimHandler.ts
|
|
2819
2800
|
import { getAddress as getAddress9 } from "viem";
|
|
2820
|
-
import { POINT_TOKEN_ABI as POINT_TOKEN_ABI2,
|
|
2801
|
+
import { POINT_TOKEN_ABI as POINT_TOKEN_ABI2, decodeKernelExecuteCalls, getContractAddresses as getContractAddresses3 } from "@pafi-dev/core";
|
|
2821
2802
|
|
|
2822
2803
|
// src/issuer-state/types.ts
|
|
2823
2804
|
var IssuerStateError = class extends PafiSdkError {
|
|
@@ -2908,7 +2889,7 @@ var PTClaimHandler = class {
|
|
|
2908
2889
|
}
|
|
2909
2890
|
}
|
|
2910
2891
|
const chainAddresses = getContractAddresses3(request.chainId);
|
|
2911
|
-
const {
|
|
2892
|
+
const { kernel: batchExecutorAddress } = chainAddresses;
|
|
2912
2893
|
let mintRequestNonce;
|
|
2913
2894
|
try {
|
|
2914
2895
|
mintRequestNonce = await this.cfg.provider.readContract({
|
|
@@ -3022,8 +3003,8 @@ var PTClaimHandler = class {
|
|
|
3022
3003
|
throw new PTClaimError("BUILD_FAILED", `prepareMint (fallback) failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
3023
3004
|
}
|
|
3024
3005
|
}
|
|
3025
|
-
const calls =
|
|
3026
|
-
const callsFallback = fallback ?
|
|
3006
|
+
const calls = decodeKernelExecuteCalls(userOp.callData);
|
|
3007
|
+
const callsFallback = fallback ? decodeKernelExecuteCalls(fallback.callData) : void 0;
|
|
3027
3008
|
return {
|
|
3028
3009
|
userOp,
|
|
3029
3010
|
fallback,
|
|
@@ -3047,7 +3028,7 @@ var PTClaimHandler = class {
|
|
|
3047
3028
|
};
|
|
3048
3029
|
|
|
3049
3030
|
// src/api/handlers/perpDepositHandler.ts
|
|
3050
|
-
import { BROKER_HASHES, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, TOKEN_HASHES, buildPerpDepositViaRelay, computeAccountId,
|
|
3031
|
+
import { BROKER_HASHES, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, TOKEN_HASHES, buildPerpDepositViaRelay, computeAccountId, decodeKernelExecuteCalls as decodeKernelExecuteCalls2, getContractAddresses as getContractAddresses4, quoteOperatorFeeUsdt } from "@pafi-dev/core";
|
|
3051
3032
|
var PerpDepositError = class extends PafiSdkError {
|
|
3052
3033
|
static {
|
|
3053
3034
|
__name(this, "PerpDepositError");
|
|
@@ -3168,122 +3149,15 @@ var PerpDepositHandler = class {
|
|
|
3168
3149
|
brokerHash,
|
|
3169
3150
|
usdcAddress,
|
|
3170
3151
|
relayAddress,
|
|
3171
|
-
calls:
|
|
3172
|
-
callsFallback: fallbackOp ?
|
|
3152
|
+
calls: decodeKernelExecuteCalls2(sponsoredOp.callData),
|
|
3153
|
+
callsFallback: fallbackOp ? decodeKernelExecuteCalls2(fallbackOp.callData) : void 0
|
|
3173
3154
|
};
|
|
3174
3155
|
}
|
|
3175
3156
|
};
|
|
3176
3157
|
|
|
3177
|
-
// src/api/delegateHandler.ts
|
|
3178
|
-
import { ENTRY_POINT_V08 as ENTRY_POINT_V082, buildDelegationUserOp, buildEip7702Authorization, getContractAddresses as getContractAddresses5, serializeUserOpToJsonRpc as serializeUserOpToJsonRpc2 } from "@pafi-dev/core";
|
|
3179
|
-
import { getAddress as getAddress10 } from "viem";
|
|
3180
|
-
var DEFAULT_DELEGATE_GAS = {
|
|
3181
|
-
callGasLimit: 100000n,
|
|
3182
|
-
verificationGasLimit: 150000n,
|
|
3183
|
-
preVerificationGas: 50000n
|
|
3184
|
-
};
|
|
3185
|
-
async function handleDelegatePrepare(params) {
|
|
3186
|
-
const { batchExecutor } = getContractAddresses5(params.chainId);
|
|
3187
|
-
const partial = buildDelegationUserOp({
|
|
3188
|
-
userAddress: params.userAddress,
|
|
3189
|
-
aaNonce: params.aaNonce,
|
|
3190
|
-
gasLimits: {
|
|
3191
|
-
callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_DELEGATE_GAS.callGasLimit,
|
|
3192
|
-
verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_DELEGATE_GAS.verificationGasLimit,
|
|
3193
|
-
preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_DELEGATE_GAS.preVerificationGas
|
|
3194
|
-
}
|
|
3195
|
-
});
|
|
3196
|
-
const userOp = {
|
|
3197
|
-
sender: partial.sender,
|
|
3198
|
-
nonce: partial.nonce,
|
|
3199
|
-
callData: partial.callData,
|
|
3200
|
-
callGasLimit: partial.callGasLimit,
|
|
3201
|
-
verificationGasLimit: partial.verificationGasLimit,
|
|
3202
|
-
preVerificationGas: partial.preVerificationGas,
|
|
3203
|
-
maxFeePerGas: params.fees.maxFeePerGas ?? 0n,
|
|
3204
|
-
maxPriorityFeePerGas: params.fees.maxPriorityFeePerGas ?? 0n
|
|
3205
|
-
};
|
|
3206
|
-
const authorization = buildEip7702Authorization({
|
|
3207
|
-
chainId: params.chainId,
|
|
3208
|
-
address: batchExecutor,
|
|
3209
|
-
nonce: params.delegationNonce,
|
|
3210
|
-
authSig: params.authSig
|
|
3211
|
-
});
|
|
3212
|
-
const paymasterFields = await requestPaymaster({
|
|
3213
|
-
client: params.pafiBackendClient,
|
|
3214
|
-
chainId: params.chainId,
|
|
3215
|
-
scenario: "delegate",
|
|
3216
|
-
userOp,
|
|
3217
|
-
pointTokenAddress: batchExecutor,
|
|
3218
|
-
eip7702Auth: authorization,
|
|
3219
|
-
onWarning: params.onWarning
|
|
3220
|
-
});
|
|
3221
|
-
const prepared = applyPaymasterGasEstimates(userOp, paymasterFields, params.chainId);
|
|
3222
|
-
const merged = prepared.userOp;
|
|
3223
|
-
const userOpHash = prepared.userOpHash;
|
|
3224
|
-
await params.store.save(params.lockId, {
|
|
3225
|
-
sender: merged.sender,
|
|
3226
|
-
nonce: merged.nonce.toString(10),
|
|
3227
|
-
callData: merged.callData,
|
|
3228
|
-
callGasLimit: merged.callGasLimit.toString(10),
|
|
3229
|
-
verificationGasLimit: merged.verificationGasLimit.toString(10),
|
|
3230
|
-
preVerificationGas: merged.preVerificationGas.toString(10),
|
|
3231
|
-
maxFeePerGas: merged.maxFeePerGas.toString(10),
|
|
3232
|
-
maxPriorityFeePerGas: merged.maxPriorityFeePerGas.toString(10),
|
|
3233
|
-
...merged.paymaster ? {
|
|
3234
|
-
paymaster: merged.paymaster
|
|
3235
|
-
} : {},
|
|
3236
|
-
...merged.paymasterVerificationGasLimit ? {
|
|
3237
|
-
paymasterVerificationGasLimit: merged.paymasterVerificationGasLimit.toString(10)
|
|
3238
|
-
} : {},
|
|
3239
|
-
...merged.paymasterPostOpGasLimit ? {
|
|
3240
|
-
paymasterPostOpGasLimit: merged.paymasterPostOpGasLimit.toString(10)
|
|
3241
|
-
} : {},
|
|
3242
|
-
...merged.paymasterData ? {
|
|
3243
|
-
paymasterData: merged.paymasterData
|
|
3244
|
-
} : {},
|
|
3245
|
-
chainId: params.chainId,
|
|
3246
|
-
userOpHash,
|
|
3247
|
-
eip7702Auth: authorization
|
|
3248
|
-
}, params.ttlSeconds);
|
|
3249
|
-
return {
|
|
3250
|
-
lockId: params.lockId,
|
|
3251
|
-
userOpHash,
|
|
3252
|
-
typedData: prepared.typedData,
|
|
3253
|
-
expiresInSeconds: params.ttlSeconds,
|
|
3254
|
-
isSponsored: !!paymasterFields
|
|
3255
|
-
};
|
|
3256
|
-
}
|
|
3257
|
-
__name(handleDelegatePrepare, "handleDelegatePrepare");
|
|
3258
|
-
async function handleDelegateSubmit(params) {
|
|
3259
|
-
const entry = await params.store.get(params.lockId);
|
|
3260
|
-
if (!entry) {
|
|
3261
|
-
throw new PendingUserOpNotFoundError(params.lockId);
|
|
3262
|
-
}
|
|
3263
|
-
if (getAddress10(entry.sender) !== getAddress10(params.authenticatedAddress)) {
|
|
3264
|
-
throw new PendingUserOpForbiddenError(params.lockId);
|
|
3265
|
-
}
|
|
3266
|
-
if (!entry.eip7702Auth) {
|
|
3267
|
-
throw new Error(`delegate entry ${params.lockId} missing eip7702Auth \u2014 prepare step did not run correctly`);
|
|
3268
|
-
}
|
|
3269
|
-
const userOpJson = serializeEntryToJsonRpc(entry, params.userOpSig, "sponsored");
|
|
3270
|
-
const result = await relayUserOp({
|
|
3271
|
-
client: params.pafiBackendClient,
|
|
3272
|
-
userOp: userOpJson,
|
|
3273
|
-
entryPoint: params.entryPoint ?? ENTRY_POINT_V082,
|
|
3274
|
-
eip7702Auth: entry.eip7702Auth
|
|
3275
|
-
});
|
|
3276
|
-
await params.store.delete(params.lockId);
|
|
3277
|
-
return {
|
|
3278
|
-
userOpHash: result.userOpHash
|
|
3279
|
-
};
|
|
3280
|
-
}
|
|
3281
|
-
__name(handleDelegateSubmit, "handleDelegateSubmit");
|
|
3282
|
-
|
|
3283
3158
|
// src/api/issuerApiAdapter.ts
|
|
3284
|
-
import {
|
|
3285
|
-
import {
|
|
3286
|
-
import { buildAndSignSponsorAuth, decodeBatchExecuteCalls as decodeBatchExecuteCalls3, encodeBatchExecute, ENTRY_POINT_V08 as ENTRY_POINT_V083, getContractAddresses as getContractAddresses6, parseEip7702DelegatedAddress as parseEip7702DelegatedAddress2 } from "@pafi-dev/core";
|
|
3159
|
+
import { getAddress as getAddress10 } from "viem";
|
|
3160
|
+
import { decodeKernelExecuteCalls as decodeKernelExecuteCalls3 } from "@pafi-dev/core";
|
|
3287
3161
|
var AdapterMisconfiguredError = class extends Error {
|
|
3288
3162
|
static {
|
|
3289
3163
|
__name(this, "AdapterMisconfiguredError");
|
|
@@ -3338,7 +3212,7 @@ var IssuerApiAdapter = class {
|
|
|
3338
3212
|
async pools(authenticatedAddress, chainId, pointTokenAddress) {
|
|
3339
3213
|
const result = await this.cfg.issuerService.api.handlePools(authenticatedAddress, {
|
|
3340
3214
|
chainId,
|
|
3341
|
-
pointTokenAddress:
|
|
3215
|
+
pointTokenAddress: getAddress10(pointTokenAddress)
|
|
3342
3216
|
});
|
|
3343
3217
|
return {
|
|
3344
3218
|
pools: result.pools
|
|
@@ -3347,8 +3221,8 @@ var IssuerApiAdapter = class {
|
|
|
3347
3221
|
async user(authenticatedAddress, chainId, userAddress, pointTokenAddress) {
|
|
3348
3222
|
const result = await this.cfg.issuerService.api.handleUser(authenticatedAddress, {
|
|
3349
3223
|
chainId,
|
|
3350
|
-
userAddress:
|
|
3351
|
-
pointTokenAddress:
|
|
3224
|
+
userAddress: getAddress10(userAddress),
|
|
3225
|
+
pointTokenAddress: getAddress10(pointTokenAddress)
|
|
3352
3226
|
});
|
|
3353
3227
|
return {
|
|
3354
3228
|
offChainBalance: result.offChainBalance.toString(),
|
|
@@ -3363,7 +3237,7 @@ var IssuerApiAdapter = class {
|
|
|
3363
3237
|
// ------------------------------ Action endpoints -------------------------
|
|
3364
3238
|
async claim(input) {
|
|
3365
3239
|
const ptClaimHandler = this.assertHandler(this.cfg.ptClaimHandler, "ptClaimHandler", "claim");
|
|
3366
|
-
const pointTokenAddress =
|
|
3240
|
+
const pointTokenAddress = getAddress10(input.pointTokenAddress);
|
|
3367
3241
|
const result = await ptClaimHandler.handle({
|
|
3368
3242
|
authenticatedAddress: input.authenticatedAddress,
|
|
3369
3243
|
userAddress: input.authenticatedAddress,
|
|
@@ -3372,19 +3246,17 @@ var IssuerApiAdapter = class {
|
|
|
3372
3246
|
chainId: input.chainId,
|
|
3373
3247
|
aaNonce: input.aaNonce
|
|
3374
3248
|
});
|
|
3375
|
-
const sponsorAuth = await this.buildSponsorAuth(input.authenticatedAddress, result.userOp.callData, input.chainId, "mint");
|
|
3376
3249
|
return {
|
|
3377
3250
|
calls: result.calls,
|
|
3378
3251
|
callsFallback: result.callsFallback,
|
|
3379
3252
|
feeAmount: result.feeAmount.toString(),
|
|
3380
3253
|
lockId: result.lockId,
|
|
3381
|
-
signatureDeadline: result.signatureDeadline.toString()
|
|
3382
|
-
sponsorAuth
|
|
3254
|
+
signatureDeadline: result.signatureDeadline.toString()
|
|
3383
3255
|
};
|
|
3384
3256
|
}
|
|
3385
3257
|
async redeem(input) {
|
|
3386
3258
|
this.assertRedeemHandler();
|
|
3387
|
-
const pointTokenAddress =
|
|
3259
|
+
const pointTokenAddress = getAddress10(input.pointTokenAddress);
|
|
3388
3260
|
const response = await this.cfg.ptRedeemHandler.handle({
|
|
3389
3261
|
userAddress: input.authenticatedAddress,
|
|
3390
3262
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -3393,18 +3265,16 @@ var IssuerApiAdapter = class {
|
|
|
3393
3265
|
aaNonce: input.aaNonce,
|
|
3394
3266
|
chainId: input.chainId
|
|
3395
3267
|
});
|
|
3396
|
-
const sponsorAuth = await this.buildSponsorAuth(input.authenticatedAddress, response.userOp.callData, input.chainId, "burn");
|
|
3397
3268
|
return {
|
|
3398
|
-
calls:
|
|
3399
|
-
callsFallback: response.fallback ?
|
|
3269
|
+
calls: decodeKernelExecuteCalls3(response.userOp.callData),
|
|
3270
|
+
callsFallback: response.fallback ? decodeKernelExecuteCalls3(response.fallback.userOp.callData) : void 0,
|
|
3400
3271
|
feeAmount: response.feeAmount.toString(),
|
|
3401
3272
|
lockId: response.lockId,
|
|
3402
3273
|
lockIdFallback: response.fallback?.lockId,
|
|
3403
3274
|
netCreditAmount: response.netCreditAmount.toString(),
|
|
3404
3275
|
netCreditAmountFallback: response.fallback?.netCreditAmount.toString(),
|
|
3405
3276
|
expiresInSeconds: response.expiresInSeconds,
|
|
3406
|
-
signatureDeadline: response.signatureDeadline.toString()
|
|
3407
|
-
sponsorAuth
|
|
3277
|
+
signatureDeadline: response.signatureDeadline.toString()
|
|
3408
3278
|
};
|
|
3409
3279
|
}
|
|
3410
3280
|
// swap() removed (2026-04-27) — moved to @pafi-dev/trading.
|
|
@@ -3418,7 +3288,6 @@ var IssuerApiAdapter = class {
|
|
|
3418
3288
|
brokerId: input.brokerId,
|
|
3419
3289
|
aaNonce: input.aaNonce
|
|
3420
3290
|
});
|
|
3421
|
-
const sponsorAuth = await this.buildSponsorAuth(input.authenticatedAddress, result.userOp.callData, input.chainId, "perp-deposit");
|
|
3422
3291
|
return {
|
|
3423
3292
|
calls: result.calls,
|
|
3424
3293
|
callsFallback: result.callsFallback,
|
|
@@ -3429,14 +3298,13 @@ var IssuerApiAdapter = class {
|
|
|
3429
3298
|
accountId: result.accountId,
|
|
3430
3299
|
brokerHash: result.brokerHash,
|
|
3431
3300
|
usdcAddress: result.usdcAddress,
|
|
3432
|
-
relayAddress: result.relayAddress
|
|
3433
|
-
sponsorAuth
|
|
3301
|
+
relayAddress: result.relayAddress
|
|
3434
3302
|
};
|
|
3435
3303
|
}
|
|
3436
3304
|
// ------------------------------ Mobile endpoints -------------------------
|
|
3437
3305
|
async claimPrepare(input) {
|
|
3438
3306
|
const ptClaimHandler = this.assertHandler(this.cfg.ptClaimHandler, "ptClaimHandler", "claimPrepare");
|
|
3439
|
-
const pointTokenAddress =
|
|
3307
|
+
const pointTokenAddress = getAddress10(input.pointTokenAddress);
|
|
3440
3308
|
const claimResult = await ptClaimHandler.handle({
|
|
3441
3309
|
authenticatedAddress: input.authenticatedAddress,
|
|
3442
3310
|
userAddress: input.authenticatedAddress,
|
|
@@ -3449,9 +3317,7 @@ var IssuerApiAdapter = class {
|
|
|
3449
3317
|
return {
|
|
3450
3318
|
lockId: claimResult.lockId,
|
|
3451
3319
|
userOpHash: prepared.sponsored.userOpHash,
|
|
3452
|
-
typedData: prepared.sponsored.typedData,
|
|
3453
3320
|
userOpHashFallback: prepared.fallback?.userOpHash,
|
|
3454
|
-
typedDataFallback: prepared.fallback?.typedData,
|
|
3455
3321
|
feeAmount: claimResult.feeAmount.toString(),
|
|
3456
3322
|
signatureDeadline: claimResult.signatureDeadline.toString(),
|
|
3457
3323
|
expiresInSeconds: claimResult.expiresInSeconds,
|
|
@@ -3472,7 +3338,7 @@ var IssuerApiAdapter = class {
|
|
|
3472
3338
|
}
|
|
3473
3339
|
async redeemPrepare(input) {
|
|
3474
3340
|
this.assertRedeemHandler();
|
|
3475
|
-
const pointTokenAddress =
|
|
3341
|
+
const pointTokenAddress = getAddress10(input.pointTokenAddress);
|
|
3476
3342
|
const redeemResponse = await this.cfg.ptRedeemHandler.handle({
|
|
3477
3343
|
userAddress: input.authenticatedAddress,
|
|
3478
3344
|
authenticatedAddress: input.authenticatedAddress,
|
|
@@ -3486,9 +3352,7 @@ var IssuerApiAdapter = class {
|
|
|
3486
3352
|
lockId: redeemResponse.lockId,
|
|
3487
3353
|
lockIdFallback: redeemResponse.fallback?.lockId,
|
|
3488
3354
|
userOpHash: prepared.sponsored.userOpHash,
|
|
3489
|
-
typedData: prepared.sponsored.typedData,
|
|
3490
3355
|
userOpHashFallback: prepared.fallback?.userOpHash,
|
|
3491
|
-
typedDataFallback: prepared.fallback?.typedData,
|
|
3492
3356
|
netCreditAmount: redeemResponse.netCreditAmount.toString(),
|
|
3493
3357
|
netCreditAmountFallback: redeemResponse.fallback?.netCreditAmount.toString(),
|
|
3494
3358
|
feeAmount: redeemResponse.feeAmount.toString(),
|
|
@@ -3529,97 +3393,11 @@ var IssuerApiAdapter = class {
|
|
|
3529
3393
|
onWarning: this.cfg.onWarning
|
|
3530
3394
|
});
|
|
3531
3395
|
}
|
|
3532
|
-
//
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
this.cfg.provider.getCode({
|
|
3537
|
-
address: authenticatedAddress
|
|
3538
|
-
}),
|
|
3539
|
-
this.cfg.provider.getTransactionCount({
|
|
3540
|
-
address: authenticatedAddress,
|
|
3541
|
-
blockTag: "pending"
|
|
3542
|
-
})
|
|
3543
|
-
]);
|
|
3544
|
-
return {
|
|
3545
|
-
isDelegated: parseEip7702DelegatedAddress2(code) !== null,
|
|
3546
|
-
batchExecutorAddress: batchExecutor,
|
|
3547
|
-
delegationNonce: nonce.toString(),
|
|
3548
|
-
chainId
|
|
3549
|
-
};
|
|
3550
|
-
}
|
|
3551
|
-
/**
|
|
3552
|
-
* Build the delegation-anchor UserOp + obtain paymaster sponsorship
|
|
3553
|
-
* + persist as a pending entry. Mobile must:
|
|
3554
|
-
*
|
|
3555
|
-
* 1. Sign EIP-7702 authorization LOCALLY (Privy `signAuthorization`
|
|
3556
|
-
* with `{contractAddress: batchExecutorAddress, chainId,
|
|
3557
|
-
* nonce: delegationNonce}`) → 65-byte authSig hex.
|
|
3558
|
-
* 2. POST `/delegate/prepare` with `{ chainId, delegationNonce,
|
|
3559
|
-
* authSig }` → this method.
|
|
3560
|
-
* 3. Sign returned `userOpHash` LOCALLY (`signTypedData(typedData)`).
|
|
3561
|
-
* 4. POST `/delegate/submit` with `{ lockId, userOpSig }`.
|
|
3562
|
-
*
|
|
3563
|
-
* v0.7.7 — replaces single-shot delegateSubmit that tried to relay
|
|
3564
|
-
* a UserOp with empty `signature: "0x"` (Simple7702Account's
|
|
3565
|
-
* validateUserOp reverts `ECDSAInvalidSignatureLength` 0xfce698f7).
|
|
3566
|
-
*/
|
|
3567
|
-
async delegatePrepare(authenticatedAddress, input) {
|
|
3568
|
-
const { batchExecutor } = getContractAddresses6(input.chainId);
|
|
3569
|
-
const fees = await this.cfg.provider.estimateFeesPerGas();
|
|
3570
|
-
const lockId = randomUUID();
|
|
3571
|
-
const result = await handleDelegatePrepare({
|
|
3572
|
-
userAddress: authenticatedAddress,
|
|
3573
|
-
chainId: input.chainId,
|
|
3574
|
-
delegationNonce: input.delegationNonce,
|
|
3575
|
-
aaNonce: input.aaNonce,
|
|
3576
|
-
authSig: input.authSig,
|
|
3577
|
-
fees,
|
|
3578
|
-
lockId,
|
|
3579
|
-
store: this.cfg.pendingUserOpStore,
|
|
3580
|
-
ttlSeconds: 15 * 60,
|
|
3581
|
-
pafiBackendClient: this.cfg.pafiBackendClient,
|
|
3582
|
-
onWarning: this.cfg.onWarning
|
|
3583
|
-
});
|
|
3584
|
-
return {
|
|
3585
|
-
lockId: result.lockId,
|
|
3586
|
-
userOpHash: result.userOpHash,
|
|
3587
|
-
typedData: result.typedData,
|
|
3588
|
-
expiresInSeconds: result.expiresInSeconds,
|
|
3589
|
-
isSponsored: result.isSponsored,
|
|
3590
|
-
delegationNonce: input.delegationNonce.toString(),
|
|
3591
|
-
batchExecutorAddress: batchExecutor,
|
|
3592
|
-
chainId: input.chainId
|
|
3593
|
-
};
|
|
3594
|
-
}
|
|
3595
|
-
async delegateSubmit(input) {
|
|
3596
|
-
const result = await handleDelegateSubmit({
|
|
3597
|
-
lockId: input.lockId,
|
|
3598
|
-
authenticatedAddress: input.authenticatedAddress,
|
|
3599
|
-
userOpSig: input.userOpSig,
|
|
3600
|
-
store: this.cfg.pendingUserOpStore,
|
|
3601
|
-
pafiBackendClient: this.cfg.pafiBackendClient
|
|
3602
|
-
});
|
|
3603
|
-
return {
|
|
3604
|
-
userOpHash: result.userOpHash
|
|
3605
|
-
};
|
|
3606
|
-
}
|
|
3396
|
+
// Delegate endpoints removed — folded-in delegation (via
|
|
3397
|
+
// `eip7702Auth` on claim/redeem prepare) is now the only path. The
|
|
3398
|
+
// bundler applies SetCode + handleOps in one tx, so there is no
|
|
3399
|
+
// separate `/delegate/*` flow. See `handleMobilePrepare`.
|
|
3607
3400
|
// ------------------------------ Internal helpers -------------------------
|
|
3608
|
-
/**
|
|
3609
|
-
* Build + sign a SponsorAuth payload. Returns `undefined` when no
|
|
3610
|
-
* issuer id is configured, so the controller can skip the field.
|
|
3611
|
-
*/
|
|
3612
|
-
async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
|
|
3613
|
-
if (!this.cfg.pafiIssuerId) return void 0;
|
|
3614
|
-
return buildAndSignSponsorAuth({
|
|
3615
|
-
userAddress: authenticatedAddress,
|
|
3616
|
-
callData,
|
|
3617
|
-
chainId,
|
|
3618
|
-
scenario,
|
|
3619
|
-
issuerId: this.cfg.pafiIssuerId,
|
|
3620
|
-
issuerSignerWallet: this.cfg.issuerSignerWallet
|
|
3621
|
-
});
|
|
3622
|
-
}
|
|
3623
3401
|
async runMobilePrepare(authenticatedAddress, chainId, lockId, partialUserOp, partialUserOpFallback, scenario, pointTokenAddress, ttlSeconds, eip7702Auth, lockIdFallback) {
|
|
3624
3402
|
return await handleMobilePrepare({
|
|
3625
3403
|
userAddress: authenticatedAddress,
|
|
@@ -4211,8 +3989,8 @@ var PafiBackendClient = class {
|
|
|
4211
3989
|
};
|
|
4212
3990
|
|
|
4213
3991
|
// src/config.ts
|
|
4214
|
-
import { getAddress as
|
|
4215
|
-
import { getContractAddresses as
|
|
3992
|
+
import { getAddress as getAddress11 } from "viem";
|
|
3993
|
+
import { getContractAddresses as getContractAddresses5 } from "@pafi-dev/core";
|
|
4216
3994
|
|
|
4217
3995
|
// src/redemption/evaluator.ts
|
|
4218
3996
|
var SECONDS_PER_DAY = 24 * 60 * 60;
|
|
@@ -4626,7 +4404,7 @@ async function createIssuerService(config) {
|
|
|
4626
4404
|
if (rawAddresses.length === 0) {
|
|
4627
4405
|
throw new Error("createIssuerService: at least one of pointTokenAddress / pointTokenAddresses is required");
|
|
4628
4406
|
}
|
|
4629
|
-
const tokenAddresses = rawAddresses.map((a) =>
|
|
4407
|
+
const tokenAddresses = rawAddresses.map((a) => getAddress11(a));
|
|
4630
4408
|
const ledger = config.ledger;
|
|
4631
4409
|
const sessionStore = config.sessionStore ?? new MemorySessionStore();
|
|
4632
4410
|
const policy = config.policy ?? new DefaultPolicyEngine({
|
|
@@ -4653,7 +4431,7 @@ async function createIssuerService(config) {
|
|
|
4653
4431
|
provider: config.provider
|
|
4654
4432
|
});
|
|
4655
4433
|
}
|
|
4656
|
-
const sdkWrapperAddress =
|
|
4434
|
+
const sdkWrapperAddress = getContractAddresses5(config.chainId).mintFeeWrapper;
|
|
4657
4435
|
const wrapperOverride = config.indexer?.mintFeeWrapperAddress;
|
|
4658
4436
|
const resolvedWrapperAddress = wrapperOverride !== void 0 ? wrapperOverride : sdkWrapperAddress;
|
|
4659
4437
|
const baseCursorStore = config.indexer?.cursorStore;
|
|
@@ -4688,9 +4466,9 @@ async function createIssuerService(config) {
|
|
|
4688
4466
|
}
|
|
4689
4467
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
4690
4468
|
}
|
|
4691
|
-
const chainAddresses =
|
|
4469
|
+
const chainAddresses = getContractAddresses5(config.chainId);
|
|
4692
4470
|
const resolvedContracts = {
|
|
4693
|
-
|
|
4471
|
+
kernel: chainAddresses.kernel,
|
|
4694
4472
|
usdt: chainAddresses.usdt,
|
|
4695
4473
|
issuerRegistry: chainAddresses.issuerRegistry,
|
|
4696
4474
|
mintingOracle: chainAddresses.mintingOracle,
|
|
@@ -4778,8 +4556,8 @@ async function createIssuerService(config) {
|
|
|
4778
4556
|
__name(createIssuerService, "createIssuerService");
|
|
4779
4557
|
|
|
4780
4558
|
// src/issuer-state/validator.ts
|
|
4781
|
-
import { getAddress as
|
|
4782
|
-
import { POINT_TOKEN_ABI as POINT_TOKEN_ABI3, issuerRegistryAbi, getContractAddresses as
|
|
4559
|
+
import { getAddress as getAddress12 } from "viem";
|
|
4560
|
+
import { POINT_TOKEN_ABI as POINT_TOKEN_ABI3, issuerRegistryAbi, getContractAddresses as getContractAddresses6 } from "@pafi-dev/core";
|
|
4783
4561
|
var ISSUER_RECORD_TTL_MS = 1e4;
|
|
4784
4562
|
var IssuerStateValidator = class _IssuerStateValidator {
|
|
4785
4563
|
static {
|
|
@@ -4799,7 +4577,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4799
4577
|
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
4800
4578
|
*/
|
|
4801
4579
|
static forChain(provider, chainId) {
|
|
4802
|
-
const { issuerRegistry } =
|
|
4580
|
+
const { issuerRegistry } = getContractAddresses6(chainId);
|
|
4803
4581
|
return new _IssuerStateValidator(provider, issuerRegistry);
|
|
4804
4582
|
}
|
|
4805
4583
|
/**
|
|
@@ -4810,7 +4588,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4810
4588
|
*/
|
|
4811
4589
|
invalidate(pointToken) {
|
|
4812
4590
|
if (pointToken) {
|
|
4813
|
-
const key =
|
|
4591
|
+
const key = getAddress12(pointToken);
|
|
4814
4592
|
this.pointTokenIssuerCache.delete(key);
|
|
4815
4593
|
this.stateCache.delete(key);
|
|
4816
4594
|
this.inflight.delete(key);
|
|
@@ -4825,7 +4603,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4825
4603
|
* The issuer field is set at `initialize()` and never changes.
|
|
4826
4604
|
*/
|
|
4827
4605
|
async getIssuerAddressForPointToken(pointToken) {
|
|
4828
|
-
const key =
|
|
4606
|
+
const key = getAddress12(pointToken);
|
|
4829
4607
|
const cached = this.pointTokenIssuerCache.get(key);
|
|
4830
4608
|
if (cached) return cached;
|
|
4831
4609
|
const issuer = await this.provider.readContract({
|
|
@@ -4833,15 +4611,15 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4833
4611
|
abi: POINT_TOKEN_ABI3,
|
|
4834
4612
|
functionName: "issuer"
|
|
4835
4613
|
});
|
|
4836
|
-
this.pointTokenIssuerCache.set(key,
|
|
4837
|
-
return
|
|
4614
|
+
this.pointTokenIssuerCache.set(key, getAddress12(issuer));
|
|
4615
|
+
return getAddress12(issuer);
|
|
4838
4616
|
}
|
|
4839
4617
|
/**
|
|
4840
4618
|
* Read registry record + totalSupply, with 30s cache and in-flight
|
|
4841
4619
|
* deduplication. Does NOT throw on inactive/missing — returns raw state.
|
|
4842
4620
|
*/
|
|
4843
4621
|
async getIssuerState(pointToken) {
|
|
4844
|
-
const tokenAddr =
|
|
4622
|
+
const tokenAddr = getAddress12(pointToken);
|
|
4845
4623
|
const now = Date.now();
|
|
4846
4624
|
const cached = this.stateCache.get(tokenAddr);
|
|
4847
4625
|
if (cached && cached.expiresAt > now) return cached.value;
|
|
@@ -4976,7 +4754,7 @@ var MemoryRedemptionHistoryStore = class {
|
|
|
4976
4754
|
};
|
|
4977
4755
|
|
|
4978
4756
|
// src/index.ts
|
|
4979
|
-
var PAFI_ISSUER_SDK_VERSION = true ? "0.
|
|
4757
|
+
var PAFI_ISSUER_SDK_VERSION = true ? "0.41.0" : "dev";
|
|
4980
4758
|
export {
|
|
4981
4759
|
AdapterMisconfiguredError,
|
|
4982
4760
|
AuthError,
|
|
@@ -5040,7 +4818,6 @@ export {
|
|
|
5040
4818
|
defaultPolicyFor,
|
|
5041
4819
|
evaluateRedemption,
|
|
5042
4820
|
handleClaimStatus,
|
|
5043
|
-
handleDelegateSubmit,
|
|
5044
4821
|
handleMobilePrepare,
|
|
5045
4822
|
handleMobileSubmit,
|
|
5046
4823
|
handleRedeemStatus,
|
|
@@ -5052,7 +4829,6 @@ export {
|
|
|
5052
4829
|
prepareMobileUserOp,
|
|
5053
4830
|
relayUserOp,
|
|
5054
4831
|
requestPaymaster,
|
|
5055
|
-
serializeEntryToJsonRpc
|
|
5056
|
-
serializeUserOpTypedData
|
|
4832
|
+
serializeEntryToJsonRpc
|
|
5057
4833
|
};
|
|
5058
4834
|
//# sourceMappingURL=index.js.map
|