@pafi-dev/issuer 0.7.2 → 0.7.4
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 +121 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -80
- package/dist/index.d.ts +23 -80
- package/dist/index.js +24 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -40,14 +40,14 @@ __export(index_exports, {
|
|
|
40
40
|
MemorySessionStore: () => MemorySessionStore,
|
|
41
41
|
NonceManager: () => NonceManager,
|
|
42
42
|
PAFI_ISSUER_SDK_VERSION: () => PAFI_ISSUER_SDK_VERSION,
|
|
43
|
-
PAFI_SUBGRAPH_URL: () =>
|
|
43
|
+
PAFI_SUBGRAPH_URL: () => import_core15.PAFI_SUBGRAPH_URL,
|
|
44
44
|
PTClaimError: () => PTClaimError,
|
|
45
45
|
PTClaimHandler: () => PTClaimHandler,
|
|
46
46
|
PTRedeemError: () => PTRedeemError,
|
|
47
47
|
PTRedeemHandler: () => PTRedeemHandler,
|
|
48
48
|
PafiBackendClient: () => PafiBackendClient,
|
|
49
49
|
PafiBackendError: () => PafiBackendError,
|
|
50
|
-
PafiSdkError: () => PafiSdkError,
|
|
50
|
+
PafiSdkError: () => import_core.PafiSdkError,
|
|
51
51
|
PendingUserOpForbiddenError: () => PendingUserOpForbiddenError,
|
|
52
52
|
PendingUserOpNotFoundError: () => PendingUserOpNotFoundError,
|
|
53
53
|
PerpDepositError: () => PerpDepositError,
|
|
@@ -55,7 +55,7 @@ __export(index_exports, {
|
|
|
55
55
|
PointIndexer: () => PointIndexer,
|
|
56
56
|
RelayError: () => RelayError,
|
|
57
57
|
RelayService: () => RelayService,
|
|
58
|
-
ValidationError: () => ValidationError,
|
|
58
|
+
ValidationError: () => import_core3.ValidationError,
|
|
59
59
|
authenticateRequest: () => authenticateRequest,
|
|
60
60
|
createIssuerService: () => createIssuerService,
|
|
61
61
|
createNativePtQuoter: () => createNativePtQuoter,
|
|
@@ -77,31 +77,10 @@ __export(index_exports, {
|
|
|
77
77
|
module.exports = __toCommonJS(index_exports);
|
|
78
78
|
|
|
79
79
|
// src/errors.ts
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* `RELAY_FEE_EXCEEDS_AMOUNT` may drop on next quote). Defaults to
|
|
85
|
-
* `false` — subclasses opt in per-code.
|
|
86
|
-
*/
|
|
87
|
-
safeToRetry = false;
|
|
88
|
-
details;
|
|
89
|
-
constructor(message) {
|
|
90
|
-
super(message);
|
|
91
|
-
this.name = new.target.name;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var ValidationError = class extends PafiSdkError {
|
|
95
|
-
httpStatus = "unprocessable";
|
|
96
|
-
code;
|
|
97
|
-
details;
|
|
98
|
-
constructor(code, message, details) {
|
|
99
|
-
super(message);
|
|
100
|
-
this.code = code;
|
|
101
|
-
this.details = details;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
var ConfigurationError = class extends PafiSdkError {
|
|
80
|
+
var import_core = require("@pafi-dev/core");
|
|
81
|
+
var import_core2 = require("@pafi-dev/core");
|
|
82
|
+
var import_core3 = require("@pafi-dev/core");
|
|
83
|
+
var ConfigurationError = class extends import_core2.PafiSdkError {
|
|
105
84
|
httpStatus = "service_unavailable";
|
|
106
85
|
code;
|
|
107
86
|
details;
|
|
@@ -278,7 +257,7 @@ var NonceManager = class {
|
|
|
278
257
|
var import_node_crypto2 = require("crypto");
|
|
279
258
|
var import_jose = require("jose");
|
|
280
259
|
var import_viem2 = require("viem");
|
|
281
|
-
var
|
|
260
|
+
var import_core4 = require("@pafi-dev/core");
|
|
282
261
|
|
|
283
262
|
// src/auth/errors.ts
|
|
284
263
|
function statusForCode(code) {
|
|
@@ -300,7 +279,7 @@ function statusForCode(code) {
|
|
|
300
279
|
return "not_found";
|
|
301
280
|
}
|
|
302
281
|
}
|
|
303
|
-
var AuthError = class extends PafiSdkError {
|
|
282
|
+
var AuthError = class extends import_core.PafiSdkError {
|
|
304
283
|
code;
|
|
305
284
|
httpStatus;
|
|
306
285
|
constructor(code, message) {
|
|
@@ -346,7 +325,7 @@ var AuthService = class {
|
|
|
346
325
|
async login(message, signature) {
|
|
347
326
|
let parsed;
|
|
348
327
|
try {
|
|
349
|
-
parsed = (0,
|
|
328
|
+
parsed = (0, import_core4.parseLoginMessage)(message);
|
|
350
329
|
} catch (err) {
|
|
351
330
|
const msg = err instanceof Error ? err.message : String(err);
|
|
352
331
|
throw new AuthError("INVALID_MESSAGE", `Could not parse login message: ${msg}`);
|
|
@@ -379,7 +358,7 @@ var AuthService = class {
|
|
|
379
358
|
if (parsed.expirationTime && parsed.expirationTime.getTime() <= now.getTime()) {
|
|
380
359
|
throw new AuthError("MESSAGE_EXPIRED", "Login message has expired");
|
|
381
360
|
}
|
|
382
|
-
const verifyResult = await (0,
|
|
361
|
+
const verifyResult = await (0, import_core4.verifyLoginMessage)(message, signature);
|
|
383
362
|
if (!verifyResult.valid) {
|
|
384
363
|
throw new AuthError(
|
|
385
364
|
"SIGNATURE_INVALID",
|
|
@@ -503,7 +482,7 @@ async function authenticateRequest(authHeader, authService) {
|
|
|
503
482
|
}
|
|
504
483
|
|
|
505
484
|
// src/relay/types.ts
|
|
506
|
-
var RelayError = class extends PafiSdkError {
|
|
485
|
+
var RelayError = class extends import_core.PafiSdkError {
|
|
507
486
|
httpStatus = "unprocessable";
|
|
508
487
|
code;
|
|
509
488
|
constructor(code, message, cause) {
|
|
@@ -517,7 +496,7 @@ var RelayError = class extends PafiSdkError {
|
|
|
517
496
|
|
|
518
497
|
// src/relay/relayService.ts
|
|
519
498
|
var import_viem3 = require("viem");
|
|
520
|
-
var
|
|
499
|
+
var import_core5 = require("@pafi-dev/core");
|
|
521
500
|
var RelayService = class {
|
|
522
501
|
provider;
|
|
523
502
|
chainId;
|
|
@@ -542,12 +521,12 @@ var RelayService = class {
|
|
|
542
521
|
* transfer to be added to the batch.
|
|
543
522
|
*/
|
|
544
523
|
async resolveFee(params) {
|
|
545
|
-
const feeRecipient = params.feeRecipient ?? (this.chainId !== void 0 ? (0,
|
|
524
|
+
const feeRecipient = params.feeRecipient ?? (this.chainId !== void 0 ? (0, import_core5.getContractAddresses)(this.chainId).pafiFeeRecipient : void 0);
|
|
546
525
|
if (params.feeAmount !== void 0) {
|
|
547
526
|
return { feeAmount: params.feeAmount, feeRecipient };
|
|
548
527
|
}
|
|
549
528
|
if (this.provider && this.chainId !== void 0) {
|
|
550
|
-
const feeAmount = await (0,
|
|
529
|
+
const feeAmount = await (0, import_core5.quoteOperatorFeePt)({
|
|
551
530
|
provider: this.provider,
|
|
552
531
|
chainId: this.chainId,
|
|
553
532
|
pointTokenAddress: params.pointTokenAddress
|
|
@@ -601,7 +580,7 @@ var RelayService = class {
|
|
|
601
580
|
}
|
|
602
581
|
let minterSig;
|
|
603
582
|
try {
|
|
604
|
-
const sig = await (0,
|
|
583
|
+
const sig = await (0, import_core5.signMintRequest)(
|
|
605
584
|
params.issuerSignerWallet,
|
|
606
585
|
params.domain,
|
|
607
586
|
{
|
|
@@ -622,7 +601,7 @@ var RelayService = class {
|
|
|
622
601
|
let mintCallData;
|
|
623
602
|
try {
|
|
624
603
|
mintCallData = (0, import_viem3.encodeFunctionData)({
|
|
625
|
-
abi:
|
|
604
|
+
abi: import_core5.POINT_TOKEN_V2_ABI,
|
|
626
605
|
functionName: "mint",
|
|
627
606
|
args: [params.userAddress, params.amount, params.deadline, minterSig]
|
|
628
607
|
});
|
|
@@ -668,7 +647,7 @@ var RelayService = class {
|
|
|
668
647
|
})
|
|
669
648
|
});
|
|
670
649
|
}
|
|
671
|
-
return (0,
|
|
650
|
+
return (0, import_core5.buildPartialUserOperation)({
|
|
672
651
|
sender: params.userAddress,
|
|
673
652
|
nonce: params.aaNonce,
|
|
674
653
|
operations,
|
|
@@ -707,7 +686,7 @@ var RelayService = class {
|
|
|
707
686
|
let burnCallData;
|
|
708
687
|
try {
|
|
709
688
|
burnCallData = (0, import_viem3.encodeFunctionData)({
|
|
710
|
-
abi:
|
|
689
|
+
abi: import_core5.POINT_TOKEN_V2_ABI,
|
|
711
690
|
functionName: "burn",
|
|
712
691
|
args: [
|
|
713
692
|
params.burnRequest.from,
|
|
@@ -757,7 +736,7 @@ var RelayService = class {
|
|
|
757
736
|
value: 0n,
|
|
758
737
|
data: burnCallData
|
|
759
738
|
});
|
|
760
|
-
return (0,
|
|
739
|
+
return (0, import_core5.buildPartialUserOperation)({
|
|
761
740
|
sender: params.userAddress,
|
|
762
741
|
nonce: params.aaNonce,
|
|
763
742
|
operations,
|
|
@@ -1168,7 +1147,7 @@ var BurnIndexer = class {
|
|
|
1168
1147
|
|
|
1169
1148
|
// src/api/handlers.ts
|
|
1170
1149
|
var import_viem6 = require("viem");
|
|
1171
|
-
var
|
|
1150
|
+
var import_core6 = require("@pafi-dev/core");
|
|
1172
1151
|
var IssuerApiHandlers = class {
|
|
1173
1152
|
authService;
|
|
1174
1153
|
ledger;
|
|
@@ -1212,16 +1191,16 @@ var IssuerApiHandlers = class {
|
|
|
1212
1191
|
/** `POST /auth/login` */
|
|
1213
1192
|
async handleLogin(body) {
|
|
1214
1193
|
if (!body || typeof body.message !== "string" || body.message.length === 0 || typeof body.signature !== "string" || body.signature.length <= 2) {
|
|
1215
|
-
throw new ValidationError(
|
|
1194
|
+
throw new import_core3.ValidationError(
|
|
1216
1195
|
"INVALID_LOGIN_BODY",
|
|
1217
1196
|
"handleLogin: message and signature are required"
|
|
1218
1197
|
);
|
|
1219
1198
|
}
|
|
1220
1199
|
if (body.message.length > 4096) {
|
|
1221
|
-
throw new ValidationError("MESSAGE_TOO_LONG", "message too long");
|
|
1200
|
+
throw new import_core3.ValidationError("MESSAGE_TOO_LONG", "message too long");
|
|
1222
1201
|
}
|
|
1223
1202
|
if (body.signature.length > 260) {
|
|
1224
|
-
throw new ValidationError("SIGNATURE_TOO_LONG", "signature too long");
|
|
1203
|
+
throw new import_core3.ValidationError("SIGNATURE_TOO_LONG", "signature too long");
|
|
1225
1204
|
}
|
|
1226
1205
|
const result = await this.authService.login(body.message, body.signature);
|
|
1227
1206
|
return {
|
|
@@ -1238,12 +1217,12 @@ var IssuerApiHandlers = class {
|
|
|
1238
1217
|
*/
|
|
1239
1218
|
async handleConfig(chainId) {
|
|
1240
1219
|
if (!Number.isInteger(chainId) || chainId <= 0) {
|
|
1241
|
-
throw new ValidationError("INVALID_CHAIN_ID", "invalid chainId", {
|
|
1220
|
+
throw new import_core3.ValidationError("INVALID_CHAIN_ID", "invalid chainId", {
|
|
1242
1221
|
chainId
|
|
1243
1222
|
});
|
|
1244
1223
|
}
|
|
1245
1224
|
if (chainId !== this.chainId) {
|
|
1246
|
-
throw new ValidationError(
|
|
1225
|
+
throw new import_core3.ValidationError(
|
|
1247
1226
|
"UNSUPPORTED_CHAIN_ID",
|
|
1248
1227
|
`handleConfig: unsupported chainId ${chainId}`,
|
|
1249
1228
|
{ requested: chainId, supported: this.chainId }
|
|
@@ -1292,7 +1271,7 @@ var IssuerApiHandlers = class {
|
|
|
1292
1271
|
);
|
|
1293
1272
|
}
|
|
1294
1273
|
if (request.chainId !== this.chainId) {
|
|
1295
|
-
throw new ValidationError(
|
|
1274
|
+
throw new import_core3.ValidationError(
|
|
1296
1275
|
"UNSUPPORTED_CHAIN_ID",
|
|
1297
1276
|
`handlePools: unsupported chainId ${request.chainId}`,
|
|
1298
1277
|
{ requested: request.chainId, supported: this.chainId }
|
|
@@ -1309,7 +1288,7 @@ var IssuerApiHandlers = class {
|
|
|
1309
1288
|
*/
|
|
1310
1289
|
async handleUser(userAddress, request) {
|
|
1311
1290
|
if (request.chainId !== this.chainId) {
|
|
1312
|
-
throw new ValidationError(
|
|
1291
|
+
throw new import_core3.ValidationError(
|
|
1313
1292
|
"UNSUPPORTED_CHAIN_ID",
|
|
1314
1293
|
`handleUser: unsupported chainId ${request.chainId}`,
|
|
1315
1294
|
{ requested: request.chainId, supported: this.chainId }
|
|
@@ -1318,7 +1297,7 @@ var IssuerApiHandlers = class {
|
|
|
1318
1297
|
const normalizedAuthed = (0, import_viem6.getAddress)(userAddress);
|
|
1319
1298
|
const normalizedRequest = (0, import_viem6.getAddress)(request.userAddress);
|
|
1320
1299
|
if (normalizedAuthed !== normalizedRequest) {
|
|
1321
|
-
throw new ValidationError(
|
|
1300
|
+
throw new import_core3.ValidationError(
|
|
1322
1301
|
"USER_ADDRESS_MISMATCH",
|
|
1323
1302
|
"handleUser: request userAddress must match authenticated user",
|
|
1324
1303
|
{ authenticated: normalizedAuthed, requested: normalizedRequest }
|
|
@@ -1326,18 +1305,18 @@ var IssuerApiHandlers = class {
|
|
|
1326
1305
|
}
|
|
1327
1306
|
const pointToken = (0, import_viem6.getAddress)(request.pointTokenAddress);
|
|
1328
1307
|
if (!this.supportedTokens.has(pointToken)) {
|
|
1329
|
-
throw new ValidationError(
|
|
1308
|
+
throw new import_core3.ValidationError(
|
|
1330
1309
|
"UNSUPPORTED_POINT_TOKEN",
|
|
1331
1310
|
`handleUser: unsupported pointToken ${pointToken}`,
|
|
1332
1311
|
{ requested: pointToken }
|
|
1333
1312
|
);
|
|
1334
1313
|
}
|
|
1335
1314
|
const [mintRequestNonce, receiverConsentNonce, offChainBalance, onChainBalance, minter] = await Promise.all([
|
|
1336
|
-
(0,
|
|
1337
|
-
(0,
|
|
1315
|
+
(0, import_core6.getMintRequestNonce)(this.provider, pointToken, normalizedAuthed),
|
|
1316
|
+
(0, import_core6.getReceiverConsentNonce)(this.provider, pointToken, normalizedAuthed),
|
|
1338
1317
|
this.ledger.getBalance(normalizedAuthed, pointToken),
|
|
1339
|
-
(0,
|
|
1340
|
-
(0,
|
|
1318
|
+
(0, import_core6.getPointTokenBalance)(this.provider, pointToken, normalizedAuthed),
|
|
1319
|
+
(0, import_core6.isMinter)(this.provider, pointToken, normalizedAuthed)
|
|
1341
1320
|
]);
|
|
1342
1321
|
return {
|
|
1343
1322
|
mintRequestNonce,
|
|
@@ -1357,10 +1336,10 @@ var IssuerApiHandlers = class {
|
|
|
1357
1336
|
|
|
1358
1337
|
// src/api/handlers/ptRedeemHandler.ts
|
|
1359
1338
|
var import_viem7 = require("viem");
|
|
1360
|
-
var
|
|
1339
|
+
var import_core7 = require("@pafi-dev/core");
|
|
1361
1340
|
var DEFAULT_REDEEM_LOCK_MS = 15 * 60 * 1e3;
|
|
1362
1341
|
var DEFAULT_SIG_DEADLINE_SEC = 15 * 60;
|
|
1363
|
-
var PTRedeemError = class extends PafiSdkError {
|
|
1342
|
+
var PTRedeemError = class extends import_core.PafiSdkError {
|
|
1364
1343
|
httpStatus = "unprocessable";
|
|
1365
1344
|
code;
|
|
1366
1345
|
constructor(code, message) {
|
|
@@ -1438,7 +1417,7 @@ var PTRedeemHandler = class {
|
|
|
1438
1417
|
try {
|
|
1439
1418
|
burnNonce = await this.provider.readContract({
|
|
1440
1419
|
address: this.pointTokenAddress,
|
|
1441
|
-
abi:
|
|
1420
|
+
abi: import_core7.POINT_TOKEN_V2_ABI,
|
|
1442
1421
|
functionName: "burnRequestNonces",
|
|
1443
1422
|
args: [request.userAddress]
|
|
1444
1423
|
});
|
|
@@ -1477,14 +1456,14 @@ var PTRedeemHandler = class {
|
|
|
1477
1456
|
} else {
|
|
1478
1457
|
fee = 0n;
|
|
1479
1458
|
}
|
|
1480
|
-
const feeRecipient = request.feeRecipient ?? (request.chainId !== void 0 ? (0,
|
|
1459
|
+
const feeRecipient = request.feeRecipient ?? (request.chainId !== void 0 ? (0, import_core7.getContractAddresses)(request.chainId).pafiFeeRecipient : (0, import_core7.getContractAddresses)(this.chainId).pafiFeeRecipient);
|
|
1481
1460
|
if (fee > 0n && fee >= request.amount) {
|
|
1482
1461
|
throw new PTRedeemError(
|
|
1483
1462
|
"INVALID_AMOUNT",
|
|
1484
1463
|
`fee (${fee}) must be strictly less than redeem amount (${request.amount})`
|
|
1485
1464
|
);
|
|
1486
1465
|
}
|
|
1487
|
-
const onChainBalance = await (0,
|
|
1466
|
+
const onChainBalance = await (0, import_core7.getPointTokenBalance)(
|
|
1488
1467
|
this.provider,
|
|
1489
1468
|
this.pointTokenAddress,
|
|
1490
1469
|
request.userAddress
|
|
@@ -1512,7 +1491,7 @@ var PTRedeemHandler = class {
|
|
|
1512
1491
|
};
|
|
1513
1492
|
let sponsoredSig;
|
|
1514
1493
|
try {
|
|
1515
|
-
sponsoredSig = (await (0,
|
|
1494
|
+
sponsoredSig = (await (0, import_core7.signBurnRequest)(this.burnerSignerWallet, domain, sponsoredBurnRequest)).serialized;
|
|
1516
1495
|
} catch (err) {
|
|
1517
1496
|
throw new PTRedeemError(
|
|
1518
1497
|
"SIGNING_FAILED",
|
|
@@ -1547,7 +1526,7 @@ var PTRedeemHandler = class {
|
|
|
1547
1526
|
};
|
|
1548
1527
|
let fallbackSig;
|
|
1549
1528
|
try {
|
|
1550
|
-
fallbackSig = (await (0,
|
|
1529
|
+
fallbackSig = (await (0, import_core7.signBurnRequest)(this.burnerSignerWallet, domain, fallbackBurnRequest)).serialized;
|
|
1551
1530
|
} catch (err) {
|
|
1552
1531
|
throw new PTRedeemError(
|
|
1553
1532
|
"SIGNING_FAILED",
|
|
@@ -1605,7 +1584,7 @@ var PTRedeemHandler = class {
|
|
|
1605
1584
|
};
|
|
1606
1585
|
|
|
1607
1586
|
// src/api/statusHandlers.ts
|
|
1608
|
-
var LockNotFoundError = class extends PafiSdkError {
|
|
1587
|
+
var LockNotFoundError = class extends import_core.PafiSdkError {
|
|
1609
1588
|
code = "LOCK_NOT_FOUND";
|
|
1610
1589
|
httpStatus = "not_found";
|
|
1611
1590
|
constructor() {
|
|
@@ -1706,10 +1685,10 @@ async function handleRedeemStatus(params) {
|
|
|
1706
1685
|
|
|
1707
1686
|
// src/api/mobileHandlers.ts
|
|
1708
1687
|
var import_viem8 = require("viem");
|
|
1709
|
-
var
|
|
1688
|
+
var import_core10 = require("@pafi-dev/core");
|
|
1710
1689
|
|
|
1711
1690
|
// src/userop-store/serialize.ts
|
|
1712
|
-
var
|
|
1691
|
+
var import_core8 = require("@pafi-dev/core");
|
|
1713
1692
|
function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
|
|
1714
1693
|
if (variant === "fallback") {
|
|
1715
1694
|
if (!entry.fallback) {
|
|
@@ -1717,7 +1696,7 @@ function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
|
|
|
1717
1696
|
"serializeEntryToJsonRpc: variant=fallback requested but the stored entry has no `fallback` branch \u2014 caller should resubmit with variant='sponsored' or re-prepare with a fee configured."
|
|
1718
1697
|
);
|
|
1719
1698
|
}
|
|
1720
|
-
return (0,
|
|
1699
|
+
return (0, import_core8.serializeUserOpToJsonRpc)(
|
|
1721
1700
|
{
|
|
1722
1701
|
sender: entry.sender,
|
|
1723
1702
|
nonce: BigInt(entry.nonce),
|
|
@@ -1732,7 +1711,7 @@ function serializeEntryToJsonRpc(entry, signature, variant = "sponsored") {
|
|
|
1732
1711
|
signature
|
|
1733
1712
|
);
|
|
1734
1713
|
}
|
|
1735
|
-
return (0,
|
|
1714
|
+
return (0, import_core8.serializeUserOpToJsonRpc)(
|
|
1736
1715
|
{
|
|
1737
1716
|
sender: entry.sender,
|
|
1738
1717
|
nonce: BigInt(entry.nonce),
|
|
@@ -1779,7 +1758,7 @@ var MemoryPendingUserOpStore = class {
|
|
|
1779
1758
|
};
|
|
1780
1759
|
|
|
1781
1760
|
// src/userop-store/prepareUserOp.ts
|
|
1782
|
-
var
|
|
1761
|
+
var import_core9 = require("@pafi-dev/core");
|
|
1783
1762
|
function serializeUserOpTypedData(td) {
|
|
1784
1763
|
return {
|
|
1785
1764
|
domain: td.domain,
|
|
@@ -1814,9 +1793,9 @@ async function prepareMobileUserOp(params) {
|
|
|
1814
1793
|
params.partialUserOp,
|
|
1815
1794
|
params.paymasterFields
|
|
1816
1795
|
);
|
|
1817
|
-
const userOpHash = (0,
|
|
1796
|
+
const userOpHash = (0, import_core9.computeUserOpHash)(userOp, params.chainId);
|
|
1818
1797
|
const typedData = serializeUserOpTypedData(
|
|
1819
|
-
(0,
|
|
1798
|
+
(0, import_core9.buildUserOpTypedData)(userOp, params.chainId)
|
|
1820
1799
|
);
|
|
1821
1800
|
let fallback;
|
|
1822
1801
|
let fallbackEntry;
|
|
@@ -1826,9 +1805,9 @@ async function prepareMobileUserOp(params) {
|
|
|
1826
1805
|
maxFeePerGas: userOp.maxFeePerGas,
|
|
1827
1806
|
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas
|
|
1828
1807
|
};
|
|
1829
|
-
const fallbackHash = (0,
|
|
1808
|
+
const fallbackHash = (0, import_core9.computeUserOpHash)(fallbackUserOp, params.chainId);
|
|
1830
1809
|
const fallbackTypedData = serializeUserOpTypedData(
|
|
1831
|
-
(0,
|
|
1810
|
+
(0, import_core9.buildUserOpTypedData)(fallbackUserOp, params.chainId)
|
|
1832
1811
|
);
|
|
1833
1812
|
fallback = {
|
|
1834
1813
|
userOp: fallbackUserOp,
|
|
@@ -1904,7 +1883,7 @@ var PafiBackendError = class extends Error {
|
|
|
1904
1883
|
};
|
|
1905
1884
|
|
|
1906
1885
|
// src/pafi-backend/helpers.ts
|
|
1907
|
-
var BundlerNotConfiguredError = class extends PafiSdkError {
|
|
1886
|
+
var BundlerNotConfiguredError = class extends import_core.PafiSdkError {
|
|
1908
1887
|
code = "BUNDLER_NOT_CONFIGURED";
|
|
1909
1888
|
httpStatus = "service_unavailable";
|
|
1910
1889
|
constructor() {
|
|
@@ -1913,7 +1892,7 @@ var BundlerNotConfiguredError = class extends PafiSdkError {
|
|
|
1913
1892
|
);
|
|
1914
1893
|
}
|
|
1915
1894
|
};
|
|
1916
|
-
var BundlerRejectedError = class extends PafiSdkError {
|
|
1895
|
+
var BundlerRejectedError = class extends import_core.PafiSdkError {
|
|
1917
1896
|
code = "BUNDLER_REJECTED";
|
|
1918
1897
|
httpStatus = "unprocessable";
|
|
1919
1898
|
cause;
|
|
@@ -1989,7 +1968,7 @@ async function relayUserOp(params) {
|
|
|
1989
1968
|
}
|
|
1990
1969
|
|
|
1991
1970
|
// src/api/mobileHandlers.ts
|
|
1992
|
-
var PendingUserOpNotFoundError = class extends PafiSdkError {
|
|
1971
|
+
var PendingUserOpNotFoundError = class extends import_core.PafiSdkError {
|
|
1993
1972
|
code = "PENDING_USEROP_NOT_FOUND";
|
|
1994
1973
|
httpStatus = "not_found";
|
|
1995
1974
|
constructor(lockId) {
|
|
@@ -1998,7 +1977,7 @@ var PendingUserOpNotFoundError = class extends PafiSdkError {
|
|
|
1998
1977
|
);
|
|
1999
1978
|
}
|
|
2000
1979
|
};
|
|
2001
|
-
var PendingUserOpForbiddenError = class extends PafiSdkError {
|
|
1980
|
+
var PendingUserOpForbiddenError = class extends import_core.PafiSdkError {
|
|
2002
1981
|
code = "PENDING_USEROP_FORBIDDEN";
|
|
2003
1982
|
httpStatus = "forbidden";
|
|
2004
1983
|
constructor(lockId) {
|
|
@@ -2012,7 +1991,7 @@ async function handleMobilePrepare(params) {
|
|
|
2012
1991
|
params.provider.estimateFeesPerGas(),
|
|
2013
1992
|
params.provider.getCode({ address: params.userAddress })
|
|
2014
1993
|
]);
|
|
2015
|
-
const needsDelegation = (0,
|
|
1994
|
+
const needsDelegation = (0, import_core10.parseEip7702DelegatedAddress)(userCode) === null;
|
|
2016
1995
|
const sponsoredOp = {
|
|
2017
1996
|
...params.partialUserOp,
|
|
2018
1997
|
maxFeePerGas: fees.maxFeePerGas ?? params.partialUserOp.maxFeePerGas ?? 0n,
|
|
@@ -2054,7 +2033,7 @@ async function handleMobileSubmit(params) {
|
|
|
2054
2033
|
const result = await relayUserOp({
|
|
2055
2034
|
client: params.pafiBackendClient,
|
|
2056
2035
|
userOp: userOpJson,
|
|
2057
|
-
entryPoint: params.entryPoint ??
|
|
2036
|
+
entryPoint: params.entryPoint ?? import_core10.ENTRY_POINT_V08
|
|
2058
2037
|
});
|
|
2059
2038
|
await params.bindUserOpHash(params.lockId, result.userOpHash);
|
|
2060
2039
|
await params.store.delete(params.lockId);
|
|
@@ -2063,10 +2042,10 @@ async function handleMobileSubmit(params) {
|
|
|
2063
2042
|
|
|
2064
2043
|
// src/api/handlers/ptClaimHandler.ts
|
|
2065
2044
|
var import_viem9 = require("viem");
|
|
2066
|
-
var
|
|
2045
|
+
var import_core11 = require("@pafi-dev/core");
|
|
2067
2046
|
|
|
2068
2047
|
// src/issuer-state/types.ts
|
|
2069
|
-
var IssuerStateError = class extends PafiSdkError {
|
|
2048
|
+
var IssuerStateError = class extends import_core.PafiSdkError {
|
|
2070
2049
|
httpStatus = "unprocessable";
|
|
2071
2050
|
code;
|
|
2072
2051
|
details;
|
|
@@ -2080,7 +2059,7 @@ var IssuerStateError = class extends PafiSdkError {
|
|
|
2080
2059
|
};
|
|
2081
2060
|
|
|
2082
2061
|
// src/api/handlers/ptClaimHandler.ts
|
|
2083
|
-
var PTClaimError = class extends PafiSdkError {
|
|
2062
|
+
var PTClaimError = class extends import_core.PafiSdkError {
|
|
2084
2063
|
httpStatus = "unprocessable";
|
|
2085
2064
|
code;
|
|
2086
2065
|
details;
|
|
@@ -2126,7 +2105,7 @@ var PTClaimHandler = class {
|
|
|
2126
2105
|
);
|
|
2127
2106
|
}
|
|
2128
2107
|
}
|
|
2129
|
-
const { batchExecutor: batchExecutorAddress } = (0,
|
|
2108
|
+
const { batchExecutor: batchExecutorAddress } = (0, import_core11.getContractAddresses)(
|
|
2130
2109
|
request.chainId
|
|
2131
2110
|
);
|
|
2132
2111
|
const lockId = await this.cfg.ledger.lockForMinting(
|
|
@@ -2187,8 +2166,8 @@ var PTClaimHandler = class {
|
|
|
2187
2166
|
);
|
|
2188
2167
|
}
|
|
2189
2168
|
}
|
|
2190
|
-
const calls = (0,
|
|
2191
|
-
const callsFallback = fallback ? (0,
|
|
2169
|
+
const calls = (0, import_core11.decodeBatchExecuteCalls)(userOp.callData);
|
|
2170
|
+
const callsFallback = fallback ? (0, import_core11.decodeBatchExecuteCalls)(fallback.callData) : void 0;
|
|
2192
2171
|
return {
|
|
2193
2172
|
userOp,
|
|
2194
2173
|
fallback,
|
|
@@ -2208,8 +2187,8 @@ var PTClaimHandler = class {
|
|
|
2208
2187
|
};
|
|
2209
2188
|
|
|
2210
2189
|
// src/api/handlers/perpDepositHandler.ts
|
|
2211
|
-
var
|
|
2212
|
-
var PerpDepositError = class extends PafiSdkError {
|
|
2190
|
+
var import_core12 = require("@pafi-dev/core");
|
|
2191
|
+
var PerpDepositError = class extends import_core.PafiSdkError {
|
|
2213
2192
|
httpStatus = "unprocessable";
|
|
2214
2193
|
code;
|
|
2215
2194
|
safeToRetry;
|
|
@@ -2232,26 +2211,26 @@ var PerpDepositHandler = class {
|
|
|
2232
2211
|
if (request.amount <= 0n) {
|
|
2233
2212
|
throw new PerpDepositError("INVALID_AMOUNT", "amount must be positive");
|
|
2234
2213
|
}
|
|
2235
|
-
const brokerHash =
|
|
2236
|
-
const tokenHash =
|
|
2237
|
-
const vault =
|
|
2214
|
+
const brokerHash = import_core12.BROKER_HASHES[request.brokerId];
|
|
2215
|
+
const tokenHash = import_core12.TOKEN_HASHES.USDC;
|
|
2216
|
+
const vault = import_core12.ORDERLY_VAULT_ADDRESSES[request.chainId];
|
|
2238
2217
|
if (!vault) {
|
|
2239
2218
|
throw new PerpDepositError(
|
|
2240
2219
|
"PERP_DEPOSIT_UNAVAILABLE",
|
|
2241
2220
|
`no Orderly Vault for chainId ${request.chainId}`
|
|
2242
2221
|
);
|
|
2243
2222
|
}
|
|
2244
|
-
const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0,
|
|
2223
|
+
const { orderlyRelay: relayAddress, pafiFeeRecipient } = (0, import_core12.getContractAddresses)(request.chainId);
|
|
2245
2224
|
const [usdcAddress, brokerAllowed] = await Promise.all([
|
|
2246
2225
|
this.cfg.provider.readContract({
|
|
2247
2226
|
address: vault,
|
|
2248
|
-
abi:
|
|
2227
|
+
abi: import_core12.ORDERLY_VAULT_ABI,
|
|
2249
2228
|
functionName: "getAllowedToken",
|
|
2250
2229
|
args: [tokenHash]
|
|
2251
2230
|
}),
|
|
2252
2231
|
this.cfg.provider.readContract({
|
|
2253
2232
|
address: vault,
|
|
2254
|
-
abi:
|
|
2233
|
+
abi: import_core12.ORDERLY_VAULT_ABI,
|
|
2255
2234
|
functionName: "getAllowedBroker",
|
|
2256
2235
|
args: [brokerHash]
|
|
2257
2236
|
})
|
|
@@ -2262,7 +2241,7 @@ var PerpDepositHandler = class {
|
|
|
2262
2241
|
`broker "${request.brokerId}" is not whitelisted on Orderly Vault`
|
|
2263
2242
|
);
|
|
2264
2243
|
}
|
|
2265
|
-
const accountId = (0,
|
|
2244
|
+
const accountId = (0, import_core12.computeAccountId)(request.userAddress, brokerHash);
|
|
2266
2245
|
const requestForQuote = {
|
|
2267
2246
|
token: usdcAddress,
|
|
2268
2247
|
receiver: request.userAddress,
|
|
@@ -2273,11 +2252,11 @@ var PerpDepositHandler = class {
|
|
|
2273
2252
|
const [relayTokenFee, usdcGasFee] = await Promise.all([
|
|
2274
2253
|
this.cfg.provider.readContract({
|
|
2275
2254
|
address: relayAddress,
|
|
2276
|
-
abi:
|
|
2255
|
+
abi: import_core12.ORDERLY_RELAY_ABI,
|
|
2277
2256
|
functionName: "quoteTokenFee",
|
|
2278
2257
|
args: [requestForQuote]
|
|
2279
2258
|
}),
|
|
2280
|
-
(0,
|
|
2259
|
+
(0, import_core12.quoteOperatorFeeUsdt)({
|
|
2281
2260
|
provider: this.cfg.provider,
|
|
2282
2261
|
chainId: request.chainId,
|
|
2283
2262
|
gasUnits: this.cfg.gasUnits,
|
|
@@ -2304,7 +2283,7 @@ var PerpDepositHandler = class {
|
|
|
2304
2283
|
totalAmount: request.amount,
|
|
2305
2284
|
maxFee
|
|
2306
2285
|
};
|
|
2307
|
-
const sponsoredOp = (0,
|
|
2286
|
+
const sponsoredOp = (0, import_core12.buildPerpDepositViaRelay)({
|
|
2308
2287
|
userAddress: request.userAddress,
|
|
2309
2288
|
aaNonce: request.aaNonce,
|
|
2310
2289
|
relayAddress,
|
|
@@ -2312,7 +2291,7 @@ var PerpDepositHandler = class {
|
|
|
2312
2291
|
gasFeeUsdc: usdcGasFee,
|
|
2313
2292
|
gasFeeUsdcRecipient: pafiFeeRecipient
|
|
2314
2293
|
});
|
|
2315
|
-
const fallbackOp = usdcGasFee > 0n ? (0,
|
|
2294
|
+
const fallbackOp = usdcGasFee > 0n ? (0, import_core12.buildPerpDepositViaRelay)({
|
|
2316
2295
|
userAddress: request.userAddress,
|
|
2317
2296
|
aaNonce: request.aaNonce,
|
|
2318
2297
|
relayAddress,
|
|
@@ -2329,29 +2308,37 @@ var PerpDepositHandler = class {
|
|
|
2329
2308
|
brokerHash,
|
|
2330
2309
|
usdcAddress,
|
|
2331
2310
|
relayAddress,
|
|
2332
|
-
calls: (0,
|
|
2333
|
-
callsFallback: fallbackOp ? (0,
|
|
2311
|
+
calls: (0, import_core12.decodeBatchExecuteCalls)(sponsoredOp.callData),
|
|
2312
|
+
callsFallback: fallbackOp ? (0, import_core12.decodeBatchExecuteCalls)(fallbackOp.callData) : void 0
|
|
2334
2313
|
};
|
|
2335
2314
|
}
|
|
2336
2315
|
};
|
|
2337
2316
|
|
|
2338
2317
|
// src/api/delegateHandler.ts
|
|
2339
|
-
var
|
|
2318
|
+
var import_core13 = require("@pafi-dev/core");
|
|
2340
2319
|
var DEFAULT_DELEGATE_GAS = {
|
|
2341
2320
|
callGasLimit: 100000n,
|
|
2342
2321
|
verificationGasLimit: 150000n,
|
|
2343
2322
|
preVerificationGas: 50000n
|
|
2344
2323
|
};
|
|
2345
2324
|
async function handleDelegateSubmit(params) {
|
|
2346
|
-
const { batchExecutor } = (0,
|
|
2347
|
-
const
|
|
2325
|
+
const { batchExecutor } = (0, import_core13.getContractAddresses)(params.chainId);
|
|
2326
|
+
const partial = (0, import_core13.buildDelegationUserOp)({
|
|
2327
|
+
userAddress: params.userAddress,
|
|
2328
|
+
aaNonce: params.aaNonce,
|
|
2329
|
+
gasLimits: {
|
|
2330
|
+
callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_DELEGATE_GAS.callGasLimit,
|
|
2331
|
+
verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_DELEGATE_GAS.verificationGasLimit,
|
|
2332
|
+
preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_DELEGATE_GAS.preVerificationGas
|
|
2333
|
+
}
|
|
2334
|
+
});
|
|
2348
2335
|
const userOp = {
|
|
2349
|
-
sender:
|
|
2350
|
-
nonce:
|
|
2351
|
-
callData,
|
|
2352
|
-
callGasLimit:
|
|
2353
|
-
verificationGasLimit:
|
|
2354
|
-
preVerificationGas:
|
|
2336
|
+
sender: partial.sender,
|
|
2337
|
+
nonce: partial.nonce,
|
|
2338
|
+
callData: partial.callData,
|
|
2339
|
+
callGasLimit: partial.callGasLimit,
|
|
2340
|
+
verificationGasLimit: partial.verificationGasLimit,
|
|
2341
|
+
preVerificationGas: partial.preVerificationGas,
|
|
2355
2342
|
maxFeePerGas: params.fees.maxFeePerGas ?? 0n,
|
|
2356
2343
|
maxPriorityFeePerGas: params.fees.maxPriorityFeePerGas ?? 0n
|
|
2357
2344
|
};
|
|
@@ -2367,7 +2354,7 @@ async function handleDelegateSubmit(params) {
|
|
|
2367
2354
|
...userOp,
|
|
2368
2355
|
...paymasterFields ?? {}
|
|
2369
2356
|
};
|
|
2370
|
-
const userOpJson = (0,
|
|
2357
|
+
const userOpJson = (0, import_core13.serializeUserOpToJsonRpc)(
|
|
2371
2358
|
{
|
|
2372
2359
|
sender: merged.sender,
|
|
2373
2360
|
nonce: merged.nonce,
|
|
@@ -2386,7 +2373,7 @@ async function handleDelegateSubmit(params) {
|
|
|
2386
2373
|
// is the user's "consent"; no separate AA signature is needed.
|
|
2387
2374
|
"0x"
|
|
2388
2375
|
);
|
|
2389
|
-
const authorization = (0,
|
|
2376
|
+
const authorization = (0, import_core13.buildEip7702Authorization)({
|
|
2390
2377
|
chainId: params.chainId,
|
|
2391
2378
|
address: batchExecutor,
|
|
2392
2379
|
nonce: params.delegationNonce,
|
|
@@ -2395,7 +2382,7 @@ async function handleDelegateSubmit(params) {
|
|
|
2395
2382
|
const result = await relayUserOp({
|
|
2396
2383
|
client: params.pafiBackendClient,
|
|
2397
2384
|
userOp: userOpJson,
|
|
2398
|
-
entryPoint:
|
|
2385
|
+
entryPoint: import_core13.ENTRY_POINT_V08,
|
|
2399
2386
|
eip7702Auth: authorization
|
|
2400
2387
|
});
|
|
2401
2388
|
return {
|
|
@@ -2408,7 +2395,7 @@ async function handleDelegateSubmit(params) {
|
|
|
2408
2395
|
// src/api/errorMapper.ts
|
|
2409
2396
|
function createSdkErrorMapper(factories) {
|
|
2410
2397
|
return (err) => {
|
|
2411
|
-
if (!(err instanceof PafiSdkError)) {
|
|
2398
|
+
if (!(err instanceof import_core.PafiSdkError)) {
|
|
2412
2399
|
throw err;
|
|
2413
2400
|
}
|
|
2414
2401
|
const body = {
|
|
@@ -2432,7 +2419,7 @@ function createSdkErrorMapper(factories) {
|
|
|
2432
2419
|
|
|
2433
2420
|
// src/api/issuerApiAdapter.ts
|
|
2434
2421
|
var import_viem10 = require("viem");
|
|
2435
|
-
var
|
|
2422
|
+
var import_core14 = require("@pafi-dev/core");
|
|
2436
2423
|
var AdapterMisconfiguredError = class extends Error {
|
|
2437
2424
|
code = "ADAPTER_MISCONFIGURED";
|
|
2438
2425
|
constructor(message) {
|
|
@@ -2562,8 +2549,8 @@ var IssuerApiAdapter = class {
|
|
|
2562
2549
|
"burn"
|
|
2563
2550
|
);
|
|
2564
2551
|
return {
|
|
2565
|
-
calls: (0,
|
|
2566
|
-
callsFallback: response.fallback ? (0,
|
|
2552
|
+
calls: (0, import_core14.decodeBatchExecuteCalls)(response.userOp.callData),
|
|
2553
|
+
callsFallback: response.fallback ? (0, import_core14.decodeBatchExecuteCalls)(response.fallback.userOp.callData) : void 0,
|
|
2567
2554
|
feeAmount: response.feeAmount.toString(),
|
|
2568
2555
|
lockId: response.lockId,
|
|
2569
2556
|
lockIdFallback: response.fallback?.lockId,
|
|
@@ -2726,23 +2713,23 @@ var IssuerApiAdapter = class {
|
|
|
2726
2713
|
}
|
|
2727
2714
|
// ------------------------------ Delegate endpoints -----------------------
|
|
2728
2715
|
async delegateStatus(authenticatedAddress, chainId) {
|
|
2729
|
-
const { batchExecutor } = (0,
|
|
2716
|
+
const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
|
|
2730
2717
|
const code = await this.cfg.provider.getCode({
|
|
2731
2718
|
address: authenticatedAddress
|
|
2732
2719
|
});
|
|
2733
2720
|
return {
|
|
2734
|
-
isDelegated: (0,
|
|
2721
|
+
isDelegated: (0, import_core14.parseEip7702DelegatedAddress)(code) !== null,
|
|
2735
2722
|
batchExecutorAddress: batchExecutor
|
|
2736
2723
|
};
|
|
2737
2724
|
}
|
|
2738
2725
|
async delegatePrepare(authenticatedAddress, chainId) {
|
|
2739
|
-
const { batchExecutor } = (0,
|
|
2726
|
+
const { batchExecutor } = (0, import_core14.getContractAddresses)(chainId);
|
|
2740
2727
|
const accountNonce = BigInt(
|
|
2741
2728
|
await this.cfg.provider.getTransactionCount({
|
|
2742
2729
|
address: authenticatedAddress
|
|
2743
2730
|
})
|
|
2744
2731
|
);
|
|
2745
|
-
const authorizationHash = (0,
|
|
2732
|
+
const authorizationHash = (0, import_core14.computeAuthorizationHash)(
|
|
2746
2733
|
chainId,
|
|
2747
2734
|
batchExecutor,
|
|
2748
2735
|
accountNonce
|
|
@@ -2772,15 +2759,10 @@ var IssuerApiAdapter = class {
|
|
|
2772
2759
|
/**
|
|
2773
2760
|
* Build + sign a SponsorAuth payload. Returns `undefined` when no
|
|
2774
2761
|
* issuer id is configured, so the controller can skip the field.
|
|
2775
|
-
*
|
|
2776
|
-
* v0.7.1 — `scenario` typed as `SponsorshipScenario` (was `string`).
|
|
2777
|
-
* Previously a typo (`"perp_deposit"` vs `"perp-deposit"`) compiled
|
|
2778
|
-
* fine but rejected at L1 by sponsor-relayer's IntentValidator. See
|
|
2779
|
-
* SDK_ISSUER_AUDIT.md N5.
|
|
2780
2762
|
*/
|
|
2781
2763
|
async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
|
|
2782
2764
|
if (!this.cfg.pafiIssuerId) return void 0;
|
|
2783
|
-
return (0,
|
|
2765
|
+
return (0, import_core14.buildAndSignSponsorAuth)({
|
|
2784
2766
|
userAddress: authenticatedAddress,
|
|
2785
2767
|
callData,
|
|
2786
2768
|
chainId,
|
|
@@ -2830,7 +2812,7 @@ var IssuerApiAdapter = class {
|
|
|
2830
2812
|
|
|
2831
2813
|
// src/pools/subgraphPoolsProvider.ts
|
|
2832
2814
|
var import_viem11 = require("viem");
|
|
2833
|
-
var
|
|
2815
|
+
var import_core15 = require("@pafi-dev/core");
|
|
2834
2816
|
var DEFAULT_CACHE_TTL_MS = 3e4;
|
|
2835
2817
|
var POOL_QUERY = `
|
|
2836
2818
|
query GetPoolForPointToken($id: ID!) {
|
|
@@ -2848,7 +2830,7 @@ var POOL_QUERY = `
|
|
|
2848
2830
|
}
|
|
2849
2831
|
`;
|
|
2850
2832
|
function createSubgraphPoolsProvider(config = {}) {
|
|
2851
|
-
const subgraphUrl = config.subgraphUrl ??
|
|
2833
|
+
const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
|
|
2852
2834
|
try {
|
|
2853
2835
|
const parsed = new URL(subgraphUrl);
|
|
2854
2836
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -2980,7 +2962,7 @@ var PRICE_QUERY = `
|
|
|
2980
2962
|
}
|
|
2981
2963
|
`;
|
|
2982
2964
|
function createSubgraphNativeUsdtQuoter(config = {}) {
|
|
2983
|
-
const subgraphUrl = config.subgraphUrl ??
|
|
2965
|
+
const subgraphUrl = config.subgraphUrl ?? import_core15.PAFI_SUBGRAPH_URL;
|
|
2984
2966
|
try {
|
|
2985
2967
|
const parsed = new URL(subgraphUrl);
|
|
2986
2968
|
if (process.env.NODE_ENV === "production" && parsed.protocol !== "https:") {
|
|
@@ -3110,7 +3092,7 @@ function createNativePtQuoter(config) {
|
|
|
3110
3092
|
provider,
|
|
3111
3093
|
pointTokenAddress,
|
|
3112
3094
|
chainlinkFeedAddress = "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
|
|
3113
|
-
subgraphUrl =
|
|
3095
|
+
subgraphUrl = import_core15.PAFI_SUBGRAPH_URL,
|
|
3114
3096
|
cacheTtlMs = 3e4,
|
|
3115
3097
|
fallbackEthPriceUsd = 3e3,
|
|
3116
3098
|
fallbackPtPriceUsdt = 0.1,
|
|
@@ -3192,7 +3174,7 @@ function parseBigDecimalTo18(s) {
|
|
|
3192
3174
|
}
|
|
3193
3175
|
|
|
3194
3176
|
// src/balance/balanceAggregator.ts
|
|
3195
|
-
var
|
|
3177
|
+
var import_core16 = require("@pafi-dev/core");
|
|
3196
3178
|
var BalanceAggregator = class {
|
|
3197
3179
|
provider;
|
|
3198
3180
|
ledger;
|
|
@@ -3213,7 +3195,7 @@ var BalanceAggregator = class {
|
|
|
3213
3195
|
async getCombinedBalance(user, pointToken) {
|
|
3214
3196
|
const [offChain, onChain] = await Promise.all([
|
|
3215
3197
|
this.ledger.getBalance(user, pointToken),
|
|
3216
|
-
(0,
|
|
3198
|
+
(0, import_core16.getPointTokenBalance)(this.provider, pointToken, user)
|
|
3217
3199
|
]);
|
|
3218
3200
|
return {
|
|
3219
3201
|
offChain,
|
|
@@ -3412,7 +3394,7 @@ var PafiBackendClient = class {
|
|
|
3412
3394
|
|
|
3413
3395
|
// src/config.ts
|
|
3414
3396
|
var import_viem13 = require("viem");
|
|
3415
|
-
var
|
|
3397
|
+
var import_core17 = require("@pafi-dev/core");
|
|
3416
3398
|
function createIssuerService(config) {
|
|
3417
3399
|
if (!config.provider) {
|
|
3418
3400
|
throw new Error("createIssuerService: provider is required");
|
|
@@ -3482,7 +3464,7 @@ function createIssuerService(config) {
|
|
|
3482
3464
|
indexers.set(tokenAddress, new PointIndexer(indexerConfig));
|
|
3483
3465
|
}
|
|
3484
3466
|
const firstIndexer = indexers.get(tokenAddresses[0]);
|
|
3485
|
-
const chainAddresses = (0,
|
|
3467
|
+
const chainAddresses = (0, import_core17.getContractAddresses)(config.chainId);
|
|
3486
3468
|
const resolvedContracts = {
|
|
3487
3469
|
batchExecutor: chainAddresses.batchExecutor,
|
|
3488
3470
|
usdt: chainAddresses.usdt,
|
|
@@ -3522,7 +3504,7 @@ function createIssuerService(config) {
|
|
|
3522
3504
|
|
|
3523
3505
|
// src/issuer-state/validator.ts
|
|
3524
3506
|
var import_viem14 = require("viem");
|
|
3525
|
-
var
|
|
3507
|
+
var import_core18 = require("@pafi-dev/core");
|
|
3526
3508
|
var ISSUER_RECORD_TTL_MS = 3e4;
|
|
3527
3509
|
var IssuerStateValidator = class _IssuerStateValidator {
|
|
3528
3510
|
constructor(provider, registryAddress) {
|
|
@@ -3539,7 +3521,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3539
3521
|
* `CONTRACT_ADDRESSES` map for the given chain.
|
|
3540
3522
|
*/
|
|
3541
3523
|
static forChain(provider, chainId) {
|
|
3542
|
-
const { issuerRegistry } = (0,
|
|
3524
|
+
const { issuerRegistry } = (0, import_core18.getContractAddresses)(chainId);
|
|
3543
3525
|
return new _IssuerStateValidator(provider, issuerRegistry);
|
|
3544
3526
|
}
|
|
3545
3527
|
/**
|
|
@@ -3568,7 +3550,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3568
3550
|
if (cached) return cached;
|
|
3569
3551
|
const issuer = await this.provider.readContract({
|
|
3570
3552
|
address: key,
|
|
3571
|
-
abi:
|
|
3553
|
+
abi: import_core18.POINT_TOKEN_V2_ABI,
|
|
3572
3554
|
functionName: "issuer"
|
|
3573
3555
|
});
|
|
3574
3556
|
this.pointTokenIssuerCache.set(key, (0, import_viem14.getAddress)(issuer));
|
|
@@ -3649,13 +3631,13 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3649
3631
|
const [issuerTuple, totalSupply] = await Promise.all([
|
|
3650
3632
|
this.provider.readContract({
|
|
3651
3633
|
address: this.registryAddress,
|
|
3652
|
-
abi:
|
|
3634
|
+
abi: import_core18.issuerRegistryGetIssuerFlatAbi,
|
|
3653
3635
|
functionName: "getIssuer",
|
|
3654
3636
|
args: [issuerAddr]
|
|
3655
3637
|
}),
|
|
3656
3638
|
this.provider.readContract({
|
|
3657
3639
|
address: tokenAddr,
|
|
3658
|
-
abi:
|
|
3640
|
+
abi: import_core18.POINT_TOKEN_V2_ABI,
|
|
3659
3641
|
functionName: "totalSupply"
|
|
3660
3642
|
})
|
|
3661
3643
|
]);
|
|
@@ -3677,7 +3659,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
|
|
|
3677
3659
|
};
|
|
3678
3660
|
|
|
3679
3661
|
// src/index.ts
|
|
3680
|
-
var PAFI_ISSUER_SDK_VERSION = true ? "0.7.
|
|
3662
|
+
var PAFI_ISSUER_SDK_VERSION = true ? "0.7.4" : "dev";
|
|
3681
3663
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3682
3664
|
0 && (module.exports = {
|
|
3683
3665
|
AdapterMisconfiguredError,
|