@p2pdotme/sdk 1.1.8 → 1.1.9
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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/orders.cjs +197 -82
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.mjs +176 -61
- package/dist/orders.mjs.map +1 -1
- package/dist/prices.cjs +172 -57
- package/dist/prices.cjs.map +1 -1
- package/dist/prices.mjs +170 -55
- package/dist/prices.mjs.map +1 -1
- package/dist/profile.cjs +184 -69
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.mjs +176 -61
- package/dist/profile.mjs.map +1 -1
- package/dist/react.cjs +545 -100
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +131 -1
- package/dist/react.d.ts +131 -1
- package/dist/react.mjs +511 -67
- package/dist/react.mjs.map +1 -1
- package/dist/stake.cjs +1212 -0
- package/dist/stake.cjs.map +1 -0
- package/dist/stake.d.cts +191 -0
- package/dist/stake.d.ts +191 -0
- package/dist/stake.mjs +1184 -0
- package/dist/stake.mjs.map +1 -0
- package/dist/zkkyc.cjs +95 -2
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.mjs +95 -2
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +7 -1
package/dist/profile.mjs
CHANGED
|
@@ -478,6 +478,97 @@ var p2pConfigFacetAbi = [
|
|
|
478
478
|
}
|
|
479
479
|
];
|
|
480
480
|
|
|
481
|
+
// src/contracts/abis/p2p-stake-boost-facet.ts
|
|
482
|
+
var p2pStakeBoostFacetAbi = [
|
|
483
|
+
{
|
|
484
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
485
|
+
name: "p2pBoostStake",
|
|
486
|
+
outputs: [],
|
|
487
|
+
stateMutability: "nonpayable",
|
|
488
|
+
type: "function"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
492
|
+
name: "p2pBoostTopUp",
|
|
493
|
+
outputs: [],
|
|
494
|
+
stateMutability: "nonpayable",
|
|
495
|
+
type: "function"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
inputs: [],
|
|
499
|
+
name: "p2pBoostRequestUnstake",
|
|
500
|
+
outputs: [],
|
|
501
|
+
stateMutability: "nonpayable",
|
|
502
|
+
type: "function"
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
inputs: [],
|
|
506
|
+
name: "p2pBoostClaimUnstake",
|
|
507
|
+
outputs: [],
|
|
508
|
+
stateMutability: "nonpayable",
|
|
509
|
+
type: "function"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
inputs: [{ internalType: "address", name: "user", type: "address" }],
|
|
513
|
+
name: "getUserStake",
|
|
514
|
+
outputs: [
|
|
515
|
+
{
|
|
516
|
+
components: [
|
|
517
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
518
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
519
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
520
|
+
],
|
|
521
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
522
|
+
name: "",
|
|
523
|
+
type: "tuple"
|
|
524
|
+
}
|
|
525
|
+
],
|
|
526
|
+
stateMutability: "view",
|
|
527
|
+
type: "function"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
531
|
+
name: "getStakeBoostConfig",
|
|
532
|
+
outputs: [
|
|
533
|
+
{
|
|
534
|
+
components: [
|
|
535
|
+
{
|
|
536
|
+
internalType: "uint256",
|
|
537
|
+
name: "tokensPerUsdNumerator",
|
|
538
|
+
type: "uint256"
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
internalType: "uint256",
|
|
542
|
+
name: "tokensPerUsdDenominator",
|
|
543
|
+
type: "uint256"
|
|
544
|
+
},
|
|
545
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
546
|
+
],
|
|
547
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
548
|
+
name: "",
|
|
549
|
+
type: "tuple"
|
|
550
|
+
}
|
|
551
|
+
],
|
|
552
|
+
stateMutability: "view",
|
|
553
|
+
type: "function"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
inputs: [],
|
|
557
|
+
name: "getStakeBoostGlobals",
|
|
558
|
+
outputs: [
|
|
559
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
560
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
561
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
562
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
563
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
564
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
565
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
566
|
+
],
|
|
567
|
+
stateMutability: "view",
|
|
568
|
+
type: "function"
|
|
569
|
+
}
|
|
570
|
+
];
|
|
571
|
+
|
|
481
572
|
// src/contracts/abis/reputation-manager.ts
|
|
482
573
|
var reputationManagerAbi = [
|
|
483
574
|
{
|
|
@@ -684,14 +775,16 @@ var reputationManagerAbi = [
|
|
|
684
775
|
var DIAMOND_ABI = [
|
|
685
776
|
...orderFlowFacetAbi,
|
|
686
777
|
...orderProcessorFacetAbi,
|
|
687
|
-
...p2pConfigFacetAbi
|
|
778
|
+
...p2pConfigFacetAbi,
|
|
779
|
+
...p2pStakeBoostFacetAbi
|
|
688
780
|
];
|
|
689
781
|
var ABIS = {
|
|
690
782
|
DIAMOND: DIAMOND_ABI,
|
|
691
783
|
FACETS: {
|
|
692
784
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
693
785
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
694
|
-
CONFIG: p2pConfigFacetAbi
|
|
786
|
+
CONFIG: p2pConfigFacetAbi,
|
|
787
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
695
788
|
},
|
|
696
789
|
EXTERNAL: {
|
|
697
790
|
USDC: erc20Abi,
|
|
@@ -1259,85 +1352,107 @@ function getPriceConfig(publicClient, diamondAddress, params) {
|
|
|
1259
1352
|
);
|
|
1260
1353
|
}
|
|
1261
1354
|
|
|
1355
|
+
// src/contracts/p2p-stake/index.ts
|
|
1356
|
+
import { ResultAsync as ResultAsync5 } from "neverthrow";
|
|
1357
|
+
import { stringToHex as stringToHex3 } from "viem";
|
|
1358
|
+
|
|
1359
|
+
// src/stake/validation.ts
|
|
1360
|
+
import { z as z4 } from "zod";
|
|
1361
|
+
var ZodGetUserStakeParamsSchema = z4.object({
|
|
1362
|
+
user: ZodAddressSchema
|
|
1363
|
+
});
|
|
1364
|
+
var ZodGetStakeBoostConfigParamsSchema = z4.object({
|
|
1365
|
+
currency: ZodCurrencySchema
|
|
1366
|
+
});
|
|
1367
|
+
var ZodGetP2pTokenBalanceParamsSchema = z4.object({
|
|
1368
|
+
address: ZodAddressSchema
|
|
1369
|
+
});
|
|
1370
|
+
var ZodStakeParamsSchema = z4.object({
|
|
1371
|
+
tokens: z4.bigint().positive()
|
|
1372
|
+
});
|
|
1373
|
+
var ZodTopUpParamsSchema = z4.object({
|
|
1374
|
+
tokens: z4.bigint().positive()
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1262
1377
|
// src/contracts/reputation-manager/writes.ts
|
|
1263
1378
|
import { Result } from "neverthrow";
|
|
1264
1379
|
import { encodeFunctionData } from "viem";
|
|
1265
1380
|
|
|
1266
1381
|
// src/zkkyc/validation.ts
|
|
1267
|
-
import { z as
|
|
1268
|
-
var ZodAnonAadharProofParamsSchema =
|
|
1269
|
-
nullifierSeed:
|
|
1270
|
-
nullifier:
|
|
1271
|
-
timestamp:
|
|
1272
|
-
signal:
|
|
1273
|
-
revealArray:
|
|
1274
|
-
packedGroth16Proof:
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1382
|
+
import { z as z5 } from "zod";
|
|
1383
|
+
var ZodAnonAadharProofParamsSchema = z5.object({
|
|
1384
|
+
nullifierSeed: z5.bigint(),
|
|
1385
|
+
nullifier: z5.bigint(),
|
|
1386
|
+
timestamp: z5.bigint(),
|
|
1387
|
+
signal: z5.bigint(),
|
|
1388
|
+
revealArray: z5.tuple([z5.bigint(), z5.bigint(), z5.bigint(), z5.bigint()]),
|
|
1389
|
+
packedGroth16Proof: z5.tuple([
|
|
1390
|
+
z5.bigint(),
|
|
1391
|
+
z5.bigint(),
|
|
1392
|
+
z5.bigint(),
|
|
1393
|
+
z5.bigint(),
|
|
1394
|
+
z5.bigint(),
|
|
1395
|
+
z5.bigint(),
|
|
1396
|
+
z5.bigint(),
|
|
1397
|
+
z5.bigint()
|
|
1283
1398
|
])
|
|
1284
1399
|
});
|
|
1285
|
-
var ZodSocialVerifyParamsSchema =
|
|
1286
|
-
_socialName:
|
|
1287
|
-
proofs:
|
|
1288
|
-
|
|
1289
|
-
claimInfo:
|
|
1290
|
-
provider:
|
|
1291
|
-
parameters:
|
|
1292
|
-
context:
|
|
1400
|
+
var ZodSocialVerifyParamsSchema = z5.object({
|
|
1401
|
+
_socialName: z5.string(),
|
|
1402
|
+
proofs: z5.array(
|
|
1403
|
+
z5.object({
|
|
1404
|
+
claimInfo: z5.object({
|
|
1405
|
+
provider: z5.string(),
|
|
1406
|
+
parameters: z5.string(),
|
|
1407
|
+
context: z5.string()
|
|
1293
1408
|
}),
|
|
1294
|
-
signedClaim:
|
|
1295
|
-
claim:
|
|
1296
|
-
identifier:
|
|
1409
|
+
signedClaim: z5.object({
|
|
1410
|
+
claim: z5.object({
|
|
1411
|
+
identifier: z5.string(),
|
|
1297
1412
|
owner: ZodAddressSchema,
|
|
1298
|
-
timestampS:
|
|
1299
|
-
epoch:
|
|
1413
|
+
timestampS: z5.number(),
|
|
1414
|
+
epoch: z5.number()
|
|
1300
1415
|
}),
|
|
1301
|
-
signatures:
|
|
1416
|
+
signatures: z5.array(z5.string())
|
|
1302
1417
|
})
|
|
1303
1418
|
})
|
|
1304
1419
|
)
|
|
1305
1420
|
});
|
|
1306
|
-
var ZodSolidityVerifierParametersSchema =
|
|
1307
|
-
version:
|
|
1421
|
+
var ZodSolidityVerifierParametersSchema = z5.object({
|
|
1422
|
+
version: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1308
1423
|
message: "Version must be a hex string"
|
|
1309
1424
|
}),
|
|
1310
|
-
proofVerificationData:
|
|
1311
|
-
vkeyHash:
|
|
1425
|
+
proofVerificationData: z5.object({
|
|
1426
|
+
vkeyHash: z5.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1312
1427
|
message: "Invalid bytes32 hex string"
|
|
1313
1428
|
}),
|
|
1314
|
-
proof:
|
|
1429
|
+
proof: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1315
1430
|
message: "Proof must be a hex string"
|
|
1316
1431
|
}),
|
|
1317
|
-
publicInputs:
|
|
1318
|
-
|
|
1432
|
+
publicInputs: z5.array(
|
|
1433
|
+
z5.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1319
1434
|
message: "Each public input must be a valid bytes32 hex string"
|
|
1320
1435
|
})
|
|
1321
1436
|
)
|
|
1322
1437
|
}),
|
|
1323
|
-
committedInputs:
|
|
1438
|
+
committedInputs: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1324
1439
|
message: "Committed inputs must be a hex string"
|
|
1325
1440
|
}),
|
|
1326
|
-
serviceConfig:
|
|
1327
|
-
validityPeriodInSeconds:
|
|
1328
|
-
domain:
|
|
1329
|
-
scope:
|
|
1330
|
-
devMode:
|
|
1441
|
+
serviceConfig: z5.object({
|
|
1442
|
+
validityPeriodInSeconds: z5.number().int().nonnegative(),
|
|
1443
|
+
domain: z5.string(),
|
|
1444
|
+
scope: z5.string(),
|
|
1445
|
+
devMode: z5.boolean()
|
|
1331
1446
|
})
|
|
1332
1447
|
});
|
|
1333
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
1448
|
+
var ZodZkPassportRegisterParamsSchema = z5.object({
|
|
1334
1449
|
params: ZodSolidityVerifierParametersSchema,
|
|
1335
|
-
isIDCard:
|
|
1450
|
+
isIDCard: z5.boolean()
|
|
1336
1451
|
});
|
|
1337
1452
|
|
|
1338
1453
|
// src/contracts/tx-limits/index.ts
|
|
1339
|
-
import { ResultAsync as
|
|
1340
|
-
import { formatUnits, stringToHex as
|
|
1454
|
+
import { ResultAsync as ResultAsync6 } from "neverthrow";
|
|
1455
|
+
import { formatUnits, stringToHex as stringToHex4 } from "viem";
|
|
1341
1456
|
|
|
1342
1457
|
// src/profile/errors.ts
|
|
1343
1458
|
var ProfileError = class extends SdkError {
|
|
@@ -1348,18 +1463,18 @@ var ProfileError = class extends SdkError {
|
|
|
1348
1463
|
};
|
|
1349
1464
|
|
|
1350
1465
|
// src/profile/validation.ts
|
|
1351
|
-
import { z as
|
|
1352
|
-
var ZodUsdcBalanceParamsSchema =
|
|
1466
|
+
import { z as z6 } from "zod";
|
|
1467
|
+
var ZodUsdcBalanceParamsSchema = z6.object({
|
|
1353
1468
|
address: ZodAddressSchema
|
|
1354
1469
|
});
|
|
1355
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
1470
|
+
var ZodUsdcAllowanceParamsSchema = z6.object({
|
|
1356
1471
|
owner: ZodAddressSchema
|
|
1357
1472
|
});
|
|
1358
|
-
var ZodGetBalancesParamsSchema =
|
|
1473
|
+
var ZodGetBalancesParamsSchema = z6.object({
|
|
1359
1474
|
address: ZodAddressSchema,
|
|
1360
1475
|
currency: ZodCurrencySchema
|
|
1361
1476
|
});
|
|
1362
|
-
var ZodTxLimitsParamsSchema =
|
|
1477
|
+
var ZodTxLimitsParamsSchema = z6.object({
|
|
1363
1478
|
address: ZodAddressSchema,
|
|
1364
1479
|
currency: ZodCurrencySchema
|
|
1365
1480
|
});
|
|
@@ -1375,12 +1490,12 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1375
1490
|
context: { params: data }
|
|
1376
1491
|
})
|
|
1377
1492
|
).asyncAndThen(
|
|
1378
|
-
(validated) =>
|
|
1493
|
+
(validated) => ResultAsync6.fromPromise(
|
|
1379
1494
|
publicClient.readContract({
|
|
1380
1495
|
address: diamondAddress,
|
|
1381
1496
|
abi: ABIS.FACETS.ORDER_FLOW,
|
|
1382
1497
|
functionName: "userTxLimit",
|
|
1383
|
-
args: [validated.address,
|
|
1498
|
+
args: [validated.address, stringToHex4(validated.currency, { size: 32 })]
|
|
1384
1499
|
}),
|
|
1385
1500
|
(error) => new ProfileError("Failed to read tx limits", {
|
|
1386
1501
|
code: "CONTRACT_READ_ERROR",
|
|
@@ -1395,7 +1510,7 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1395
1510
|
}
|
|
1396
1511
|
|
|
1397
1512
|
// src/contracts/usdc/index.ts
|
|
1398
|
-
import { ResultAsync as
|
|
1513
|
+
import { ResultAsync as ResultAsync7 } from "neverthrow";
|
|
1399
1514
|
import { erc20Abi as erc20Abi2 } from "viem";
|
|
1400
1515
|
function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
1401
1516
|
return validate(
|
|
@@ -1407,7 +1522,7 @@ function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
|
1407
1522
|
context: { params: data }
|
|
1408
1523
|
})
|
|
1409
1524
|
).asyncAndThen(
|
|
1410
|
-
(validated) =>
|
|
1525
|
+
(validated) => ResultAsync7.fromPromise(
|
|
1411
1526
|
publicClient.readContract({
|
|
1412
1527
|
address: usdcAddress,
|
|
1413
1528
|
abi: ABIS.EXTERNAL.USDC,
|
|
@@ -1432,7 +1547,7 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1432
1547
|
context: { params: data }
|
|
1433
1548
|
})
|
|
1434
1549
|
).asyncAndThen(
|
|
1435
|
-
(validated) =>
|
|
1550
|
+
(validated) => ResultAsync7.fromPromise(
|
|
1436
1551
|
publicClient.readContract({
|
|
1437
1552
|
address: usdcAddress,
|
|
1438
1553
|
abi: erc20Abi2,
|
|
@@ -1449,7 +1564,7 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1449
1564
|
}
|
|
1450
1565
|
|
|
1451
1566
|
// src/profile/contracts/actions.ts
|
|
1452
|
-
import { ResultAsync as
|
|
1567
|
+
import { ResultAsync as ResultAsync8 } from "neverthrow";
|
|
1453
1568
|
import { formatUnits as formatUnits2 } from "viem";
|
|
1454
1569
|
function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
1455
1570
|
return validate(
|
|
@@ -1461,7 +1576,7 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1461
1576
|
context: { params: data }
|
|
1462
1577
|
})
|
|
1463
1578
|
).asyncAndThen(
|
|
1464
|
-
(validated) =>
|
|
1579
|
+
(validated) => ResultAsync8.combine([
|
|
1465
1580
|
getUsdcBalance(publicClient, usdcAddress, {
|
|
1466
1581
|
address: validated.address
|
|
1467
1582
|
}),
|