@p2pdotme/sdk 1.1.7 → 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/country.cjs +18 -1
- package/dist/country.cjs.map +1 -1
- package/dist/country.d.cts +5 -1
- package/dist/country.d.ts +5 -1
- package/dist/country.mjs +17 -1
- package/dist/country.mjs.map +1 -1
- 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/qr-parsers.cjs.map +1 -1
- package/dist/qr-parsers.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.cjs
CHANGED
|
@@ -505,6 +505,97 @@ var p2pConfigFacetAbi = [
|
|
|
505
505
|
}
|
|
506
506
|
];
|
|
507
507
|
|
|
508
|
+
// src/contracts/abis/p2p-stake-boost-facet.ts
|
|
509
|
+
var p2pStakeBoostFacetAbi = [
|
|
510
|
+
{
|
|
511
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
512
|
+
name: "p2pBoostStake",
|
|
513
|
+
outputs: [],
|
|
514
|
+
stateMutability: "nonpayable",
|
|
515
|
+
type: "function"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
519
|
+
name: "p2pBoostTopUp",
|
|
520
|
+
outputs: [],
|
|
521
|
+
stateMutability: "nonpayable",
|
|
522
|
+
type: "function"
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
inputs: [],
|
|
526
|
+
name: "p2pBoostRequestUnstake",
|
|
527
|
+
outputs: [],
|
|
528
|
+
stateMutability: "nonpayable",
|
|
529
|
+
type: "function"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
inputs: [],
|
|
533
|
+
name: "p2pBoostClaimUnstake",
|
|
534
|
+
outputs: [],
|
|
535
|
+
stateMutability: "nonpayable",
|
|
536
|
+
type: "function"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
inputs: [{ internalType: "address", name: "user", type: "address" }],
|
|
540
|
+
name: "getUserStake",
|
|
541
|
+
outputs: [
|
|
542
|
+
{
|
|
543
|
+
components: [
|
|
544
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
545
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
546
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
547
|
+
],
|
|
548
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
549
|
+
name: "",
|
|
550
|
+
type: "tuple"
|
|
551
|
+
}
|
|
552
|
+
],
|
|
553
|
+
stateMutability: "view",
|
|
554
|
+
type: "function"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
558
|
+
name: "getStakeBoostConfig",
|
|
559
|
+
outputs: [
|
|
560
|
+
{
|
|
561
|
+
components: [
|
|
562
|
+
{
|
|
563
|
+
internalType: "uint256",
|
|
564
|
+
name: "tokensPerUsdNumerator",
|
|
565
|
+
type: "uint256"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
internalType: "uint256",
|
|
569
|
+
name: "tokensPerUsdDenominator",
|
|
570
|
+
type: "uint256"
|
|
571
|
+
},
|
|
572
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
573
|
+
],
|
|
574
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
575
|
+
name: "",
|
|
576
|
+
type: "tuple"
|
|
577
|
+
}
|
|
578
|
+
],
|
|
579
|
+
stateMutability: "view",
|
|
580
|
+
type: "function"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
inputs: [],
|
|
584
|
+
name: "getStakeBoostGlobals",
|
|
585
|
+
outputs: [
|
|
586
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
587
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
588
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
589
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
590
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
591
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
592
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
593
|
+
],
|
|
594
|
+
stateMutability: "view",
|
|
595
|
+
type: "function"
|
|
596
|
+
}
|
|
597
|
+
];
|
|
598
|
+
|
|
508
599
|
// src/contracts/abis/reputation-manager.ts
|
|
509
600
|
var reputationManagerAbi = [
|
|
510
601
|
{
|
|
@@ -711,14 +802,16 @@ var reputationManagerAbi = [
|
|
|
711
802
|
var DIAMOND_ABI = [
|
|
712
803
|
...orderFlowFacetAbi,
|
|
713
804
|
...orderProcessorFacetAbi,
|
|
714
|
-
...p2pConfigFacetAbi
|
|
805
|
+
...p2pConfigFacetAbi,
|
|
806
|
+
...p2pStakeBoostFacetAbi
|
|
715
807
|
];
|
|
716
808
|
var ABIS = {
|
|
717
809
|
DIAMOND: DIAMOND_ABI,
|
|
718
810
|
FACETS: {
|
|
719
811
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
720
812
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
721
|
-
CONFIG: p2pConfigFacetAbi
|
|
813
|
+
CONFIG: p2pConfigFacetAbi,
|
|
814
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
722
815
|
},
|
|
723
816
|
EXTERNAL: {
|
|
724
817
|
USDC: import_viem.erc20Abi,
|
|
@@ -1286,85 +1379,107 @@ function getPriceConfig(publicClient, diamondAddress, params) {
|
|
|
1286
1379
|
);
|
|
1287
1380
|
}
|
|
1288
1381
|
|
|
1289
|
-
// src/contracts/
|
|
1382
|
+
// src/contracts/p2p-stake/index.ts
|
|
1290
1383
|
var import_neverthrow6 = require("neverthrow");
|
|
1291
1384
|
var import_viem5 = require("viem");
|
|
1292
1385
|
|
|
1293
|
-
// src/
|
|
1386
|
+
// src/stake/validation.ts
|
|
1294
1387
|
var import_zod4 = require("zod");
|
|
1295
|
-
var
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1388
|
+
var ZodGetUserStakeParamsSchema = import_zod4.z.object({
|
|
1389
|
+
user: ZodAddressSchema
|
|
1390
|
+
});
|
|
1391
|
+
var ZodGetStakeBoostConfigParamsSchema = import_zod4.z.object({
|
|
1392
|
+
currency: ZodCurrencySchema
|
|
1393
|
+
});
|
|
1394
|
+
var ZodGetP2pTokenBalanceParamsSchema = import_zod4.z.object({
|
|
1395
|
+
address: ZodAddressSchema
|
|
1396
|
+
});
|
|
1397
|
+
var ZodStakeParamsSchema = import_zod4.z.object({
|
|
1398
|
+
tokens: import_zod4.z.bigint().positive()
|
|
1399
|
+
});
|
|
1400
|
+
var ZodTopUpParamsSchema = import_zod4.z.object({
|
|
1401
|
+
tokens: import_zod4.z.bigint().positive()
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// src/contracts/reputation-manager/writes.ts
|
|
1405
|
+
var import_neverthrow7 = require("neverthrow");
|
|
1406
|
+
var import_viem6 = require("viem");
|
|
1407
|
+
|
|
1408
|
+
// src/zkkyc/validation.ts
|
|
1409
|
+
var import_zod5 = require("zod");
|
|
1410
|
+
var ZodAnonAadharProofParamsSchema = import_zod5.z.object({
|
|
1411
|
+
nullifierSeed: import_zod5.z.bigint(),
|
|
1412
|
+
nullifier: import_zod5.z.bigint(),
|
|
1413
|
+
timestamp: import_zod5.z.bigint(),
|
|
1414
|
+
signal: import_zod5.z.bigint(),
|
|
1415
|
+
revealArray: import_zod5.z.tuple([import_zod5.z.bigint(), import_zod5.z.bigint(), import_zod5.z.bigint(), import_zod5.z.bigint()]),
|
|
1416
|
+
packedGroth16Proof: import_zod5.z.tuple([
|
|
1417
|
+
import_zod5.z.bigint(),
|
|
1418
|
+
import_zod5.z.bigint(),
|
|
1419
|
+
import_zod5.z.bigint(),
|
|
1420
|
+
import_zod5.z.bigint(),
|
|
1421
|
+
import_zod5.z.bigint(),
|
|
1422
|
+
import_zod5.z.bigint(),
|
|
1423
|
+
import_zod5.z.bigint(),
|
|
1424
|
+
import_zod5.z.bigint()
|
|
1310
1425
|
])
|
|
1311
1426
|
});
|
|
1312
|
-
var ZodSocialVerifyParamsSchema =
|
|
1313
|
-
_socialName:
|
|
1314
|
-
proofs:
|
|
1315
|
-
|
|
1316
|
-
claimInfo:
|
|
1317
|
-
provider:
|
|
1318
|
-
parameters:
|
|
1319
|
-
context:
|
|
1427
|
+
var ZodSocialVerifyParamsSchema = import_zod5.z.object({
|
|
1428
|
+
_socialName: import_zod5.z.string(),
|
|
1429
|
+
proofs: import_zod5.z.array(
|
|
1430
|
+
import_zod5.z.object({
|
|
1431
|
+
claimInfo: import_zod5.z.object({
|
|
1432
|
+
provider: import_zod5.z.string(),
|
|
1433
|
+
parameters: import_zod5.z.string(),
|
|
1434
|
+
context: import_zod5.z.string()
|
|
1320
1435
|
}),
|
|
1321
|
-
signedClaim:
|
|
1322
|
-
claim:
|
|
1323
|
-
identifier:
|
|
1436
|
+
signedClaim: import_zod5.z.object({
|
|
1437
|
+
claim: import_zod5.z.object({
|
|
1438
|
+
identifier: import_zod5.z.string(),
|
|
1324
1439
|
owner: ZodAddressSchema,
|
|
1325
|
-
timestampS:
|
|
1326
|
-
epoch:
|
|
1440
|
+
timestampS: import_zod5.z.number(),
|
|
1441
|
+
epoch: import_zod5.z.number()
|
|
1327
1442
|
}),
|
|
1328
|
-
signatures:
|
|
1443
|
+
signatures: import_zod5.z.array(import_zod5.z.string())
|
|
1329
1444
|
})
|
|
1330
1445
|
})
|
|
1331
1446
|
)
|
|
1332
1447
|
});
|
|
1333
|
-
var ZodSolidityVerifierParametersSchema =
|
|
1334
|
-
version:
|
|
1448
|
+
var ZodSolidityVerifierParametersSchema = import_zod5.z.object({
|
|
1449
|
+
version: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
|
|
1335
1450
|
message: "Version must be a hex string"
|
|
1336
1451
|
}),
|
|
1337
|
-
proofVerificationData:
|
|
1338
|
-
vkeyHash:
|
|
1452
|
+
proofVerificationData: import_zod5.z.object({
|
|
1453
|
+
vkeyHash: import_zod5.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1339
1454
|
message: "Invalid bytes32 hex string"
|
|
1340
1455
|
}),
|
|
1341
|
-
proof:
|
|
1456
|
+
proof: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
|
|
1342
1457
|
message: "Proof must be a hex string"
|
|
1343
1458
|
}),
|
|
1344
|
-
publicInputs:
|
|
1345
|
-
|
|
1459
|
+
publicInputs: import_zod5.z.array(
|
|
1460
|
+
import_zod5.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1346
1461
|
message: "Each public input must be a valid bytes32 hex string"
|
|
1347
1462
|
})
|
|
1348
1463
|
)
|
|
1349
1464
|
}),
|
|
1350
|
-
committedInputs:
|
|
1465
|
+
committedInputs: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
|
|
1351
1466
|
message: "Committed inputs must be a hex string"
|
|
1352
1467
|
}),
|
|
1353
|
-
serviceConfig:
|
|
1354
|
-
validityPeriodInSeconds:
|
|
1355
|
-
domain:
|
|
1356
|
-
scope:
|
|
1357
|
-
devMode:
|
|
1468
|
+
serviceConfig: import_zod5.z.object({
|
|
1469
|
+
validityPeriodInSeconds: import_zod5.z.number().int().nonnegative(),
|
|
1470
|
+
domain: import_zod5.z.string(),
|
|
1471
|
+
scope: import_zod5.z.string(),
|
|
1472
|
+
devMode: import_zod5.z.boolean()
|
|
1358
1473
|
})
|
|
1359
1474
|
});
|
|
1360
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
1475
|
+
var ZodZkPassportRegisterParamsSchema = import_zod5.z.object({
|
|
1361
1476
|
params: ZodSolidityVerifierParametersSchema,
|
|
1362
|
-
isIDCard:
|
|
1477
|
+
isIDCard: import_zod5.z.boolean()
|
|
1363
1478
|
});
|
|
1364
1479
|
|
|
1365
1480
|
// src/contracts/tx-limits/index.ts
|
|
1366
|
-
var
|
|
1367
|
-
var
|
|
1481
|
+
var import_neverthrow8 = require("neverthrow");
|
|
1482
|
+
var import_viem7 = require("viem");
|
|
1368
1483
|
|
|
1369
1484
|
// src/profile/errors.ts
|
|
1370
1485
|
var ProfileError = class extends SdkError {
|
|
@@ -1375,18 +1490,18 @@ var ProfileError = class extends SdkError {
|
|
|
1375
1490
|
};
|
|
1376
1491
|
|
|
1377
1492
|
// src/profile/validation.ts
|
|
1378
|
-
var
|
|
1379
|
-
var ZodUsdcBalanceParamsSchema =
|
|
1493
|
+
var import_zod6 = require("zod");
|
|
1494
|
+
var ZodUsdcBalanceParamsSchema = import_zod6.z.object({
|
|
1380
1495
|
address: ZodAddressSchema
|
|
1381
1496
|
});
|
|
1382
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
1497
|
+
var ZodUsdcAllowanceParamsSchema = import_zod6.z.object({
|
|
1383
1498
|
owner: ZodAddressSchema
|
|
1384
1499
|
});
|
|
1385
|
-
var ZodGetBalancesParamsSchema =
|
|
1500
|
+
var ZodGetBalancesParamsSchema = import_zod6.z.object({
|
|
1386
1501
|
address: ZodAddressSchema,
|
|
1387
1502
|
currency: ZodCurrencySchema
|
|
1388
1503
|
});
|
|
1389
|
-
var ZodTxLimitsParamsSchema =
|
|
1504
|
+
var ZodTxLimitsParamsSchema = import_zod6.z.object({
|
|
1390
1505
|
address: ZodAddressSchema,
|
|
1391
1506
|
currency: ZodCurrencySchema
|
|
1392
1507
|
});
|
|
@@ -1402,12 +1517,12 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1402
1517
|
context: { params: data }
|
|
1403
1518
|
})
|
|
1404
1519
|
).asyncAndThen(
|
|
1405
|
-
(validated) =>
|
|
1520
|
+
(validated) => import_neverthrow8.ResultAsync.fromPromise(
|
|
1406
1521
|
publicClient.readContract({
|
|
1407
1522
|
address: diamondAddress,
|
|
1408
1523
|
abi: ABIS.FACETS.ORDER_FLOW,
|
|
1409
1524
|
functionName: "userTxLimit",
|
|
1410
|
-
args: [validated.address, (0,
|
|
1525
|
+
args: [validated.address, (0, import_viem7.stringToHex)(validated.currency, { size: 32 })]
|
|
1411
1526
|
}),
|
|
1412
1527
|
(error) => new ProfileError("Failed to read tx limits", {
|
|
1413
1528
|
code: "CONTRACT_READ_ERROR",
|
|
@@ -1415,15 +1530,15 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1415
1530
|
context: { address: validated.address, currency: validated.currency, diamondAddress }
|
|
1416
1531
|
})
|
|
1417
1532
|
).map(([buyLimit, sellLimit]) => ({
|
|
1418
|
-
buyLimit: Number((0,
|
|
1419
|
-
sellLimit: Number((0,
|
|
1533
|
+
buyLimit: Number((0, import_viem7.formatUnits)(buyLimit, 6)),
|
|
1534
|
+
sellLimit: Number((0, import_viem7.formatUnits)(sellLimit, 6))
|
|
1420
1535
|
}))
|
|
1421
1536
|
);
|
|
1422
1537
|
}
|
|
1423
1538
|
|
|
1424
1539
|
// src/contracts/usdc/index.ts
|
|
1425
|
-
var
|
|
1426
|
-
var
|
|
1540
|
+
var import_neverthrow9 = require("neverthrow");
|
|
1541
|
+
var import_viem8 = require("viem");
|
|
1427
1542
|
function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
1428
1543
|
return validate(
|
|
1429
1544
|
ZodUsdcBalanceParamsSchema,
|
|
@@ -1434,7 +1549,7 @@ function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
|
1434
1549
|
context: { params: data }
|
|
1435
1550
|
})
|
|
1436
1551
|
).asyncAndThen(
|
|
1437
|
-
(validated) =>
|
|
1552
|
+
(validated) => import_neverthrow9.ResultAsync.fromPromise(
|
|
1438
1553
|
publicClient.readContract({
|
|
1439
1554
|
address: usdcAddress,
|
|
1440
1555
|
abi: ABIS.EXTERNAL.USDC,
|
|
@@ -1459,10 +1574,10 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1459
1574
|
context: { params: data }
|
|
1460
1575
|
})
|
|
1461
1576
|
).asyncAndThen(
|
|
1462
|
-
(validated) =>
|
|
1577
|
+
(validated) => import_neverthrow9.ResultAsync.fromPromise(
|
|
1463
1578
|
publicClient.readContract({
|
|
1464
1579
|
address: usdcAddress,
|
|
1465
|
-
abi:
|
|
1580
|
+
abi: import_viem8.erc20Abi,
|
|
1466
1581
|
functionName: "allowance",
|
|
1467
1582
|
args: [validated.owner, diamondAddress]
|
|
1468
1583
|
}),
|
|
@@ -1476,8 +1591,8 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1476
1591
|
}
|
|
1477
1592
|
|
|
1478
1593
|
// src/profile/contracts/actions.ts
|
|
1479
|
-
var
|
|
1480
|
-
var
|
|
1594
|
+
var import_neverthrow10 = require("neverthrow");
|
|
1595
|
+
var import_viem9 = require("viem");
|
|
1481
1596
|
function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
1482
1597
|
return validate(
|
|
1483
1598
|
ZodGetBalancesParamsSchema,
|
|
@@ -1488,7 +1603,7 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1488
1603
|
context: { params: data }
|
|
1489
1604
|
})
|
|
1490
1605
|
).asyncAndThen(
|
|
1491
|
-
(validated) =>
|
|
1606
|
+
(validated) => import_neverthrow10.ResultAsync.combine([
|
|
1492
1607
|
getUsdcBalance(publicClient, usdcAddress, {
|
|
1493
1608
|
address: validated.address
|
|
1494
1609
|
}),
|
|
@@ -1502,8 +1617,8 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1502
1617
|
})
|
|
1503
1618
|
)
|
|
1504
1619
|
]).map(([usdc, priceConfig]) => {
|
|
1505
|
-
const usdcFormatted = Number((0,
|
|
1506
|
-
const sellPriceFormatted = Number((0,
|
|
1620
|
+
const usdcFormatted = Number((0, import_viem9.formatUnits)(usdc, 6));
|
|
1621
|
+
const sellPriceFormatted = Number((0, import_viem9.formatUnits)(priceConfig.sellPrice, 6));
|
|
1507
1622
|
return {
|
|
1508
1623
|
usdc: usdcFormatted,
|
|
1509
1624
|
fiat: usdcFormatted * sellPriceFormatted,
|