@pafi-dev/issuer 0.12.7 → 0.15.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/README.md +172 -95
- package/dist/index.cjs +107 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -127
- package/dist/index.d.ts +144 -127
- package/dist/index.js +93 -137
- package/dist/index.js.map +1 -1
- package/package.json +13 -2
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(index_exports, {
|
|
|
23
23
|
AdapterMisconfiguredError: () => AdapterMisconfiguredError,
|
|
24
24
|
AuthError: () => AuthError,
|
|
25
25
|
AuthService: () => AuthService,
|
|
26
|
-
BalanceAggregator: () => BalanceAggregator,
|
|
27
26
|
BundlerNotConfiguredError: () => BundlerNotConfiguredError,
|
|
28
27
|
BundlerRejectedError: () => BundlerRejectedError,
|
|
29
28
|
BurnIndexer: () => BurnIndexer,
|
|
@@ -65,6 +64,7 @@ __export(index_exports, {
|
|
|
65
64
|
SDK_ERROR_HTTP_STATUS_CODE: () => import_core.SDK_ERROR_HTTP_STATUS_CODE,
|
|
66
65
|
SettlementClient: () => SettlementClient,
|
|
67
66
|
ValidationError: () => import_core3.ValidationError,
|
|
67
|
+
applyPaymasterGasEstimates: () => applyPaymasterGasEstimates,
|
|
68
68
|
authenticateRequest: () => authenticateRequest,
|
|
69
69
|
buildErrorEnvelope: () => buildErrorEnvelope,
|
|
70
70
|
buildSdkErrorBody: () => buildSdkErrorBody,
|
|
@@ -1010,8 +1010,8 @@ var RelayService = class {
|
|
|
1010
1010
|
* provides a pre-signed `BurnRequest` + sig bytes (typically from
|
|
1011
1011
|
* `PTRedeemHandler`).
|
|
1012
1012
|
*
|
|
1013
|
-
* Direct burn (no sig)
|
|
1014
|
-
*
|
|
1013
|
+
* Direct burn (no sig) is not used — every burn goes through the
|
|
1014
|
+
* issuer-signed `BurnRequest` path.
|
|
1015
1015
|
*/
|
|
1016
1016
|
async prepareBurn(params) {
|
|
1017
1017
|
if (!params.pointTokenAddress) {
|
|
@@ -1295,7 +1295,7 @@ var PointIndexer = class {
|
|
|
1295
1295
|
// Event fetching — two modes (wrapper vs direct)
|
|
1296
1296
|
// -------------------------------------------------------------------------
|
|
1297
1297
|
/**
|
|
1298
|
-
* Wrapper mode
|
|
1298
|
+
* Wrapper mode: listen for `MintWithFee` on the wrapper,
|
|
1299
1299
|
* filtered to events for THIS pointToken only. The event's `to` field
|
|
1300
1300
|
* is the actual end user, and `grossAmount` matches the lock amount.
|
|
1301
1301
|
*/
|
|
@@ -1817,9 +1817,8 @@ var IssuerApiHandlers = class _IssuerApiHandlers {
|
|
|
1817
1817
|
/**
|
|
1818
1818
|
* `GET /user?chainId=<id>&user=<addr>&pointToken=<addr>`
|
|
1819
1819
|
*
|
|
1820
|
-
* Returns per-user state the frontend needs to build a fresh
|
|
1821
|
-
*
|
|
1822
|
-
* balance.
|
|
1820
|
+
* Returns per-user state the frontend needs to build a fresh mint:
|
|
1821
|
+
* on-chain nonces + minter status + off-chain balance.
|
|
1823
1822
|
*/
|
|
1824
1823
|
async handleUser(userAddress, request) {
|
|
1825
1824
|
if (request.chainId !== this.chainId) {
|
|
@@ -1846,16 +1845,14 @@ var IssuerApiHandlers = class _IssuerApiHandlers {
|
|
|
1846
1845
|
{ requested: pointToken }
|
|
1847
1846
|
);
|
|
1848
1847
|
}
|
|
1849
|
-
const [mintRequestNonce,
|
|
1848
|
+
const [mintRequestNonce, offChainBalance, onChainBalance, minter] = await Promise.all([
|
|
1850
1849
|
(0, import_core6.getMintRequestNonce)(this.provider, pointToken, normalizedAuthed),
|
|
1851
|
-
(0, import_core6.getReceiverConsentNonce)(this.provider, pointToken, normalizedAuthed),
|
|
1852
1850
|
this.ledger.getBalance(normalizedAuthed, pointToken),
|
|
1853
1851
|
(0, import_core6.getPointTokenBalance)(this.provider, pointToken, normalizedAuthed),
|
|
1854
1852
|
(0, import_core6.isMinter)(this.provider, pointToken, normalizedAuthed)
|
|
1855
1853
|
]);
|
|
1856
1854
|
return {
|
|
1857
1855
|
mintRequestNonce,
|
|
1858
|
-
receiverConsentNonce,
|
|
1859
1856
|
offChainBalance,
|
|
1860
1857
|
onChainBalance,
|
|
1861
1858
|
totalBalance: offChainBalance + onChainBalance,
|
|
@@ -2423,38 +2420,42 @@ function mergePaymasterFields(userOp, paymasterFields) {
|
|
|
2423
2420
|
}
|
|
2424
2421
|
return merged;
|
|
2425
2422
|
}
|
|
2426
|
-
|
|
2423
|
+
function applyPaymasterGasEstimates(partialUserOp, paymasterFields, chainId) {
|
|
2427
2424
|
const userOp = mergePaymasterFields(
|
|
2428
|
-
|
|
2429
|
-
|
|
2425
|
+
partialUserOp,
|
|
2426
|
+
paymasterFields
|
|
2430
2427
|
);
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
(0, import_core9.
|
|
2428
|
+
return {
|
|
2429
|
+
userOp,
|
|
2430
|
+
userOpHash: (0, import_core9.computeUserOpHash)(userOp, chainId),
|
|
2431
|
+
typedData: serializeUserOpTypedData((0, import_core9.buildUserOpTypedData)(userOp, chainId))
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
async function prepareMobileUserOp(params) {
|
|
2435
|
+
const sponsored = applyPaymasterGasEstimates(
|
|
2436
|
+
params.partialUserOp,
|
|
2437
|
+
params.paymasterFields,
|
|
2438
|
+
params.chainId
|
|
2434
2439
|
);
|
|
2440
|
+
const { userOp, userOpHash } = sponsored;
|
|
2435
2441
|
let fallback;
|
|
2436
2442
|
let fallbackEntry;
|
|
2437
2443
|
if (params.partialUserOpFallback) {
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2444
|
+
fallback = applyPaymasterGasEstimates(
|
|
2445
|
+
{
|
|
2446
|
+
...params.partialUserOpFallback,
|
|
2447
|
+
maxFeePerGas: userOp.maxFeePerGas,
|
|
2448
|
+
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas
|
|
2449
|
+
},
|
|
2450
|
+
void 0,
|
|
2451
|
+
params.chainId
|
|
2446
2452
|
);
|
|
2447
|
-
fallback = {
|
|
2448
|
-
userOp: fallbackUserOp,
|
|
2449
|
-
userOpHash: fallbackHash,
|
|
2450
|
-
typedData: fallbackTypedData
|
|
2451
|
-
};
|
|
2452
2453
|
fallbackEntry = {
|
|
2453
|
-
callData:
|
|
2454
|
-
callGasLimit:
|
|
2455
|
-
verificationGasLimit:
|
|
2456
|
-
preVerificationGas:
|
|
2457
|
-
userOpHash:
|
|
2454
|
+
callData: fallback.userOp.callData,
|
|
2455
|
+
callGasLimit: fallback.userOp.callGasLimit.toString(),
|
|
2456
|
+
verificationGasLimit: fallback.userOp.verificationGasLimit.toString(),
|
|
2457
|
+
preVerificationGas: fallback.userOp.preVerificationGas.toString(),
|
|
2458
|
+
userOpHash: fallback.userOpHash
|
|
2458
2459
|
};
|
|
2459
2460
|
}
|
|
2460
2461
|
const entry = {
|
|
@@ -2476,7 +2477,7 @@ async function prepareMobileUserOp(params) {
|
|
|
2476
2477
|
};
|
|
2477
2478
|
await params.store.save(params.lockId, entry, params.ttlSeconds);
|
|
2478
2479
|
return {
|
|
2479
|
-
sponsored
|
|
2480
|
+
sponsored,
|
|
2480
2481
|
fallback,
|
|
2481
2482
|
entry
|
|
2482
2483
|
};
|
|
@@ -3003,22 +3004,13 @@ async function handleDelegatePrepare(params) {
|
|
|
3003
3004
|
eip7702Auth: authorization,
|
|
3004
3005
|
onWarning: params.onWarning
|
|
3005
3006
|
});
|
|
3006
|
-
const
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
maxFeePerGas: paymasterFields?.maxFeePerGas ?? userOp.maxFeePerGas,
|
|
3014
|
-
maxPriorityFeePerGas: paymasterFields?.maxPriorityFeePerGas ?? userOp.maxPriorityFeePerGas,
|
|
3015
|
-
paymaster: paymasterFields?.paymaster,
|
|
3016
|
-
paymasterVerificationGasLimit: paymasterFields?.paymasterVerificationGasLimit,
|
|
3017
|
-
paymasterPostOpGasLimit: paymasterFields?.paymasterPostOpGasLimit,
|
|
3018
|
-
paymasterData: paymasterFields?.paymasterData
|
|
3019
|
-
};
|
|
3020
|
-
const userOpHash = (0, import_core13.computeUserOpHash)(merged, params.chainId);
|
|
3021
|
-
const typed = (0, import_core13.buildUserOpTypedData)(merged, params.chainId);
|
|
3007
|
+
const prepared = applyPaymasterGasEstimates(
|
|
3008
|
+
userOp,
|
|
3009
|
+
paymasterFields,
|
|
3010
|
+
params.chainId
|
|
3011
|
+
);
|
|
3012
|
+
const merged = prepared.userOp;
|
|
3013
|
+
const userOpHash = prepared.userOpHash;
|
|
3022
3014
|
await params.store.save(
|
|
3023
3015
|
params.lockId,
|
|
3024
3016
|
{
|
|
@@ -3047,7 +3039,7 @@ async function handleDelegatePrepare(params) {
|
|
|
3047
3039
|
return {
|
|
3048
3040
|
lockId: params.lockId,
|
|
3049
3041
|
userOpHash,
|
|
3050
|
-
typedData:
|
|
3042
|
+
typedData: prepared.typedData,
|
|
3051
3043
|
expiresInSeconds: params.ttlSeconds,
|
|
3052
3044
|
isSponsored: !!paymasterFields
|
|
3053
3045
|
};
|
|
@@ -3151,7 +3143,6 @@ var IssuerApiAdapter = class {
|
|
|
3151
3143
|
);
|
|
3152
3144
|
return {
|
|
3153
3145
|
mintRequestNonce: result.mintRequestNonce.toString(),
|
|
3154
|
-
receiverConsentNonce: result.receiverConsentNonce.toString(),
|
|
3155
3146
|
offChainBalance: result.offChainBalance.toString(),
|
|
3156
3147
|
onChainBalance: result.onChainBalance.toString(),
|
|
3157
3148
|
totalBalance: result.totalBalance.toString(),
|
|
@@ -3502,6 +3493,7 @@ var IssuerApiAdapter = class {
|
|
|
3502
3493
|
var import_viem12 = require("viem");
|
|
3503
3494
|
var import_core15 = require("@pafi-dev/core");
|
|
3504
3495
|
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
3496
|
+
var MAX_REASONABLE_FEE_TIER = 1e6;
|
|
3505
3497
|
var POOL_QUERY = `
|
|
3506
3498
|
query GetPoolForPointToken($id: ID!) {
|
|
3507
3499
|
pafiToken(id: $id) {
|
|
@@ -3509,8 +3501,6 @@ var POOL_QUERY = `
|
|
|
3509
3501
|
pool {
|
|
3510
3502
|
id
|
|
3511
3503
|
feeTier
|
|
3512
|
-
tickSpacing
|
|
3513
|
-
hooks
|
|
3514
3504
|
token0 { id }
|
|
3515
3505
|
token1 { id }
|
|
3516
3506
|
}
|
|
@@ -3535,12 +3525,20 @@ function createSubgraphPoolsProvider(config = {}) {
|
|
|
3535
3525
|
const cacheTtl = config.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
3536
3526
|
const fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
3537
3527
|
const now = config.now ?? (() => Date.now());
|
|
3528
|
+
const onError = config.onError;
|
|
3538
3529
|
const cache = /* @__PURE__ */ new Map();
|
|
3539
3530
|
if (!fetchImpl) {
|
|
3540
3531
|
throw new Error(
|
|
3541
3532
|
"createSubgraphPoolsProvider: no fetch implementation available \u2014 pass `fetchImpl` or run on Node 18+"
|
|
3542
3533
|
);
|
|
3543
3534
|
}
|
|
3535
|
+
const reportError = (err) => {
|
|
3536
|
+
if (!onError) return;
|
|
3537
|
+
try {
|
|
3538
|
+
onError(err);
|
|
3539
|
+
} catch {
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3544
3542
|
return async (request) => {
|
|
3545
3543
|
const cacheKey = `${request.chainId}:${request.pointTokenAddress.toLowerCase()}`;
|
|
3546
3544
|
if (cacheTtl > 0) {
|
|
@@ -3552,7 +3550,8 @@ function createSubgraphPoolsProvider(config = {}) {
|
|
|
3552
3550
|
const pools = await fetchPoolsFromSubgraph(
|
|
3553
3551
|
fetchImpl,
|
|
3554
3552
|
subgraphUrl,
|
|
3555
|
-
request.pointTokenAddress
|
|
3553
|
+
request.pointTokenAddress,
|
|
3554
|
+
reportError
|
|
3556
3555
|
);
|
|
3557
3556
|
if (cacheTtl > 0) {
|
|
3558
3557
|
cache.set(cacheKey, {
|
|
@@ -3563,7 +3562,7 @@ function createSubgraphPoolsProvider(config = {}) {
|
|
|
3563
3562
|
return { pools };
|
|
3564
3563
|
};
|
|
3565
3564
|
}
|
|
3566
|
-
async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress) {
|
|
3565
|
+
async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress, reportError) {
|
|
3567
3566
|
let response;
|
|
3568
3567
|
try {
|
|
3569
3568
|
response = await fetchImpl(subgraphUrl, {
|
|
@@ -3575,24 +3574,38 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress)
|
|
|
3575
3574
|
})
|
|
3576
3575
|
});
|
|
3577
3576
|
} catch (err) {
|
|
3577
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3578
3578
|
console.warn(
|
|
3579
3579
|
"[subgraphPoolsProvider] subgraph unreachable:",
|
|
3580
|
-
|
|
3580
|
+
error.message
|
|
3581
3581
|
);
|
|
3582
|
+
reportError(error);
|
|
3582
3583
|
return [];
|
|
3583
3584
|
}
|
|
3584
3585
|
if (!response.ok) {
|
|
3585
|
-
|
|
3586
|
-
`
|
|
3586
|
+
const error = new Error(
|
|
3587
|
+
`subgraph returned HTTP ${response.status}`
|
|
3587
3588
|
);
|
|
3589
|
+
console.warn(`[subgraphPoolsProvider] ${error.message}`);
|
|
3590
|
+
reportError(error);
|
|
3588
3591
|
return [];
|
|
3589
3592
|
}
|
|
3590
|
-
|
|
3591
|
-
|
|
3593
|
+
let json;
|
|
3594
|
+
try {
|
|
3595
|
+
json = await response.json();
|
|
3596
|
+
} catch (err) {
|
|
3597
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3592
3598
|
console.warn(
|
|
3593
|
-
"[subgraphPoolsProvider] subgraph
|
|
3594
|
-
|
|
3599
|
+
"[subgraphPoolsProvider] subgraph returned non-JSON:",
|
|
3600
|
+
error.message
|
|
3595
3601
|
);
|
|
3602
|
+
reportError(error);
|
|
3603
|
+
return [];
|
|
3604
|
+
}
|
|
3605
|
+
if (json.errors && json.errors.length > 0) {
|
|
3606
|
+
const msg = json.errors.map((e) => e.message).join("; ");
|
|
3607
|
+
console.warn("[subgraphPoolsProvider] subgraph errors:", msg);
|
|
3608
|
+
reportError(new Error(`subgraph GraphQL errors: ${msg}`));
|
|
3596
3609
|
return [];
|
|
3597
3610
|
}
|
|
3598
3611
|
const token = json.data?.pafiToken;
|
|
@@ -3600,40 +3613,35 @@ async function fetchPoolsFromSubgraph(fetchImpl, subgraphUrl, pointTokenAddress)
|
|
|
3600
3613
|
return [];
|
|
3601
3614
|
}
|
|
3602
3615
|
const { pool } = token;
|
|
3603
|
-
if (!(0, import_viem12.isAddress)(pool.hooks)) {
|
|
3604
|
-
console.error(
|
|
3605
|
-
"[PAFI] SubgraphPoolsProvider: invalid hooks address in response:",
|
|
3606
|
-
pool.hooks,
|
|
3607
|
-
"\u2014 skipping pool"
|
|
3608
|
-
);
|
|
3609
|
-
return [];
|
|
3610
|
-
}
|
|
3611
3616
|
if (!(0, import_viem12.isAddress)(pool.token0.id) || !(0, import_viem12.isAddress)(pool.token1.id)) {
|
|
3612
|
-
|
|
3613
|
-
"[PAFI] SubgraphPoolsProvider: invalid token address in response
|
|
3617
|
+
const error = new Error(
|
|
3618
|
+
"[PAFI] SubgraphPoolsProvider: invalid token address in response"
|
|
3614
3619
|
);
|
|
3620
|
+
console.error(error.message, "\u2014 skipping pool");
|
|
3621
|
+
reportError(error);
|
|
3615
3622
|
return [];
|
|
3616
3623
|
}
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3624
|
+
const feeNum = Number(pool.feeTier);
|
|
3625
|
+
if (!Number.isInteger(feeNum) || feeNum < 0 || feeNum >= MAX_REASONABLE_FEE_TIER) {
|
|
3626
|
+
const error = new Error(
|
|
3627
|
+
`[PAFI] SubgraphPoolsProvider: invalid feeTier value: ${pool.feeTier}`
|
|
3620
3628
|
);
|
|
3629
|
+
console.error(error.message, "\u2014 skipping pool");
|
|
3630
|
+
reportError(error);
|
|
3621
3631
|
return [];
|
|
3622
3632
|
}
|
|
3623
|
-
const [
|
|
3633
|
+
const [token0, token1] = sortTokens(
|
|
3624
3634
|
pool.token0.id,
|
|
3625
3635
|
pool.token1.id
|
|
3626
3636
|
);
|
|
3627
3637
|
const poolKey = {
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
fee:
|
|
3631
|
-
tickSpacing: Number(pool.tickSpacing),
|
|
3632
|
-
hooks: pool.hooks
|
|
3638
|
+
token0,
|
|
3639
|
+
token1,
|
|
3640
|
+
fee: feeNum
|
|
3633
3641
|
};
|
|
3634
3642
|
return [poolKey];
|
|
3635
3643
|
}
|
|
3636
|
-
function
|
|
3644
|
+
function sortTokens(a, b) {
|
|
3637
3645
|
return a.toLowerCase() < b.toLowerCase() ? [a, b] : [b, a];
|
|
3638
3646
|
}
|
|
3639
3647
|
|
|
@@ -3861,54 +3869,8 @@ function parseBigDecimalTo18(s) {
|
|
|
3861
3869
|
return BigInt(whole + padded);
|
|
3862
3870
|
}
|
|
3863
3871
|
|
|
3864
|
-
// src/balance/balanceAggregator.ts
|
|
3865
|
-
var import_core16 = require("@pafi-dev/core");
|
|
3866
|
-
var BalanceAggregator = class {
|
|
3867
|
-
provider;
|
|
3868
|
-
ledger;
|
|
3869
|
-
constructor(config) {
|
|
3870
|
-
if (!config.provider) {
|
|
3871
|
-
throw new Error("BalanceAggregator: provider is required");
|
|
3872
|
-
}
|
|
3873
|
-
if (!config.ledger) {
|
|
3874
|
-
throw new Error("BalanceAggregator: ledger is required");
|
|
3875
|
-
}
|
|
3876
|
-
this.provider = config.provider;
|
|
3877
|
-
this.ledger = config.ledger;
|
|
3878
|
-
}
|
|
3879
|
-
/**
|
|
3880
|
-
* Combined balance for a single (user, token) pair. Fetches off-chain
|
|
3881
|
-
* + on-chain in parallel.
|
|
3882
|
-
*/
|
|
3883
|
-
async getCombinedBalance(user, pointToken) {
|
|
3884
|
-
const [offChain, onChain] = await Promise.all([
|
|
3885
|
-
this.ledger.getBalance(user, pointToken),
|
|
3886
|
-
(0, import_core16.getPointTokenBalance)(this.provider, pointToken, user)
|
|
3887
|
-
]);
|
|
3888
|
-
return {
|
|
3889
|
-
offChain,
|
|
3890
|
-
onChain,
|
|
3891
|
-
total: offChain + onChain
|
|
3892
|
-
};
|
|
3893
|
-
}
|
|
3894
|
-
/**
|
|
3895
|
-
* Combined balance for multiple tokens owned by the same user. Runs
|
|
3896
|
-
* all lookups in parallel. Returns a Map keyed by the token address
|
|
3897
|
-
* (same casing as supplied — caller should normalize if needed).
|
|
3898
|
-
*/
|
|
3899
|
-
async getCombinedBalanceMulti(user, pointTokens) {
|
|
3900
|
-
const entries = await Promise.all(
|
|
3901
|
-
pointTokens.map(async (token) => {
|
|
3902
|
-
const balance = await this.getCombinedBalance(user, token);
|
|
3903
|
-
return [token, balance];
|
|
3904
|
-
})
|
|
3905
|
-
);
|
|
3906
|
-
return new Map(entries);
|
|
3907
|
-
}
|
|
3908
|
-
};
|
|
3909
|
-
|
|
3910
3872
|
// src/pafi-backend/client.ts
|
|
3911
|
-
var
|
|
3873
|
+
var import_core16 = require("@pafi-dev/core");
|
|
3912
3874
|
function extractPafiErrorFields(json, status) {
|
|
3913
3875
|
const inner = typeof json.error === "object" && json.error !== null ? json.error : null;
|
|
3914
3876
|
const code = inner?.code ?? json.code ?? "INTERNAL_ERROR";
|
|
@@ -3929,7 +3891,7 @@ var PafiBackendClient = class {
|
|
|
3929
3891
|
if (!config.issuerId) throw new Error("PafiBackendClient: issuerId is required");
|
|
3930
3892
|
if (!config.apiKey) throw new Error("PafiBackendClient: apiKey is required");
|
|
3931
3893
|
this.config = config;
|
|
3932
|
-
this.baseUrl = (0,
|
|
3894
|
+
this.baseUrl = (0, import_core16.getPafiServiceUrls)(config.chainId).sponsorRelayer;
|
|
3933
3895
|
}
|
|
3934
3896
|
async requestSponsorship(request) {
|
|
3935
3897
|
const maxAttempts = this.config.retry?.maxAttempts ?? 1;
|
|
@@ -4090,7 +4052,7 @@ var PafiBackendClient = class {
|
|
|
4090
4052
|
|
|
4091
4053
|
// src/config.ts
|
|
4092
4054
|
var import_viem14 = require("viem");
|
|
4093
|
-
var
|
|
4055
|
+
var import_core18 = require("@pafi-dev/core");
|
|
4094
4056
|
|
|
4095
4057
|
// src/redemption/evaluator.ts
|
|
4096
4058
|
var SECONDS_PER_DAY = 24 * 60 * 60;
|
|
@@ -4195,7 +4157,7 @@ function nextBlackoutEndAfter(windows, nowUnixSec) {
|
|
|
4195
4157
|
var REDEMPTION_HISTORY_WINDOW_SEC = SECONDS_PER_DAY;
|
|
4196
4158
|
|
|
4197
4159
|
// src/redemption/settlementClient.ts
|
|
4198
|
-
var
|
|
4160
|
+
var import_core17 = require("@pafi-dev/core");
|
|
4199
4161
|
var DEFAULT_TIMEOUT_MS = 1e3;
|
|
4200
4162
|
var SettlementClient = class {
|
|
4201
4163
|
config;
|
|
@@ -4204,7 +4166,7 @@ var SettlementClient = class {
|
|
|
4204
4166
|
if (!config.issuerId) throw new Error("SettlementClient: issuerId is required");
|
|
4205
4167
|
if (!config.apiKey) throw new Error("SettlementClient: apiKey is required");
|
|
4206
4168
|
this.config = {
|
|
4207
|
-
baseUrl: (0,
|
|
4169
|
+
baseUrl: (0, import_core17.getPafiServiceUrls)(config.chainId).issuerApi.replace(/\/+$/, ""),
|
|
4208
4170
|
issuerId: config.issuerId,
|
|
4209
4171
|
apiKey: config.apiKey,
|
|
4210
4172
|
fetchTimeoutMs: config.fetchTimeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
@@ -4441,7 +4403,7 @@ function createIssuerService(config) {
|
|
|
4441
4403
|
provider: config.provider
|
|
4442
4404
|
});
|
|
4443
4405
|
}
|
|
4444
|
-
const sdkWrapperAddress = (0,
|
|
4406
|
+
const sdkWrapperAddress = (0, import_core18.getContractAddresses)(config.chainId).mintFeeWrapper;
|
|
4445
4407
|
const wrapperOverride = config.indexer?.mintFeeWrapperAddress;
|
|
4446
4408
|
const resolvedWrapperAddress = wrapperOverride !== void 0 ? wrapperOverride : sdkWrapperAddress;
|
|
4447
4409
|
const indexers = /* @__PURE__ */ new Map();
|
|
@@ -4471,14 +4433,12 @@ function createIssuerService(config) {
|
|
|
4471
4433
|
}
|
|
4472
4434
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
4473
4435
|
}
|
|
4474
|
-
const
|
|
4475
|
-
const chainAddresses = (0, import_core19.getContractAddresses)(config.chainId);
|
|
4436
|
+
const chainAddresses = (0, import_core18.getContractAddresses)(config.chainId);
|
|
4476
4437
|
const resolvedContracts = {
|
|
4477
4438
|
batchExecutor: chainAddresses.batchExecutor,
|
|
4478
4439
|
usdt: chainAddresses.usdt,
|
|
4479
4440
|
issuerRegistry: chainAddresses.issuerRegistry,
|
|
4480
4441
|
mintingOracle: chainAddresses.mintingOracle,
|
|
4481
|
-
pafiHook: chainAddresses.pafiHook,
|
|
4482
4442
|
...config.contracts
|
|
4483
4443
|
};
|
|
4484
4444
|
if (resolvedWrapperAddress !== void 0) {
|
|
@@ -4531,7 +4491,6 @@ function createIssuerService(config) {
|
|
|
4531
4491
|
relay: relayService,
|
|
4532
4492
|
fee: feeManager,
|
|
4533
4493
|
indexers,
|
|
4534
|
-
indexer: firstIndexer,
|
|
4535
4494
|
api: handlers,
|
|
4536
4495
|
redemption
|
|
4537
4496
|
};
|
|
@@ -4539,7 +4498,7 @@ function createIssuerService(config) {
|
|
|
4539
4498
|
|
|
4540
4499
|
// src/issuer-state/validator.ts
|
|
4541
4500
|
var import_viem15 = require("viem");
|
|
4542
|
-
var
|
|
4501
|
+
var import_core19 = require("@pafi-dev/core");
|
|
4543
4502
|
var ISSUER_RECORD_TTL_MS = 3e4;
|
|
4544
4503
|
var IssuerStateValidator = class _IssuerStateValidator {
|
|
4545
4504
|
constructor(provider, registryAddress) {
|
|
@@ -4556,7 +4515,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4556
4515
|
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
4557
4516
|
*/
|
|
4558
4517
|
static forChain(provider, chainId) {
|
|
4559
|
-
const { issuerRegistry } = (0,
|
|
4518
|
+
const { issuerRegistry } = (0, import_core19.getContractAddresses)(chainId);
|
|
4560
4519
|
return new _IssuerStateValidator(provider, issuerRegistry);
|
|
4561
4520
|
}
|
|
4562
4521
|
/**
|
|
@@ -4585,7 +4544,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4585
4544
|
if (cached) return cached;
|
|
4586
4545
|
const issuer = await this.provider.readContract({
|
|
4587
4546
|
address: key,
|
|
4588
|
-
abi:
|
|
4547
|
+
abi: import_core19.POINT_TOKEN_V2_ABI,
|
|
4589
4548
|
functionName: "issuer"
|
|
4590
4549
|
});
|
|
4591
4550
|
this.pointTokenIssuerCache.set(key, (0, import_viem15.getAddress)(issuer));
|
|
@@ -4665,7 +4624,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4665
4624
|
const issuerAddr = await this.getIssuerAddressForPointToken(tokenAddr);
|
|
4666
4625
|
const issuerStruct = await this.provider.readContract({
|
|
4667
4626
|
address: this.registryAddress,
|
|
4668
|
-
abi:
|
|
4627
|
+
abi: import_core19.issuerRegistryAbi,
|
|
4669
4628
|
functionName: "getIssuer",
|
|
4670
4629
|
args: [issuerAddr]
|
|
4671
4630
|
});
|
|
@@ -4679,10 +4638,10 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
4679
4638
|
mintingOracle: issuerStruct.mintingOracle
|
|
4680
4639
|
};
|
|
4681
4640
|
const [tokenCap, totalSupply] = await Promise.all([
|
|
4682
|
-
(0,
|
|
4641
|
+
(0, import_core19.getTokenCap)(this.provider, issuer.mintingOracle, tokenAddr),
|
|
4683
4642
|
this.provider.readContract({
|
|
4684
4643
|
address: tokenAddr,
|
|
4685
|
-
abi:
|
|
4644
|
+
abi: import_core19.POINT_TOKEN_V2_ABI,
|
|
4686
4645
|
functionName: "totalSupply"
|
|
4687
4646
|
})
|
|
4688
4647
|
]);
|
|
@@ -4739,13 +4698,12 @@ var MemoryRedemptionHistoryStore = class {
|
|
|
4739
4698
|
};
|
|
4740
4699
|
|
|
4741
4700
|
// src/index.ts
|
|
4742
|
-
var PAFI_ISSUER_SDK_VERSION = true ? "0.
|
|
4701
|
+
var PAFI_ISSUER_SDK_VERSION = true ? "0.15.0" : "dev";
|
|
4743
4702
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4744
4703
|
0 && (module.exports = {
|
|
4745
4704
|
AdapterMisconfiguredError,
|
|
4746
4705
|
AuthError,
|
|
4747
4706
|
AuthService,
|
|
4748
|
-
BalanceAggregator,
|
|
4749
4707
|
BundlerNotConfiguredError,
|
|
4750
4708
|
BundlerRejectedError,
|
|
4751
4709
|
BurnIndexer,
|
|
@@ -4787,6 +4745,7 @@ var PAFI_ISSUER_SDK_VERSION = true ? "0.12.7" : "dev";
|
|
|
4787
4745
|
SDK_ERROR_HTTP_STATUS_CODE,
|
|
4788
4746
|
SettlementClient,
|
|
4789
4747
|
ValidationError,
|
|
4748
|
+
applyPaymasterGasEstimates,
|
|
4790
4749
|
authenticateRequest,
|
|
4791
4750
|
buildErrorEnvelope,
|
|
4792
4751
|
buildSdkErrorBody,
|