@p2pdotme/sdk 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/orders.cjs +204 -82
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.mjs +183 -61
- package/dist/orders.mjs.map +1 -1
- package/dist/prices.cjs +179 -57
- package/dist/prices.cjs.map +1 -1
- package/dist/prices.mjs +177 -55
- package/dist/prices.mjs.map +1 -1
- package/dist/profile.cjs +191 -69
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.mjs +183 -61
- package/dist/profile.mjs.map +1 -1
- package/dist/react.cjs +579 -100
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +137 -1
- package/dist/react.d.ts +137 -1
- package/dist/react.mjs +545 -67
- package/dist/react.mjs.map +1 -1
- package/dist/stake.cjs +1246 -0
- package/dist/stake.cjs.map +1 -0
- package/dist/stake.d.cts +197 -0
- package/dist/stake.d.ts +197 -0
- package/dist/stake.mjs +1218 -0
- package/dist/stake.mjs.map +1 -0
- package/dist/zkkyc.cjs +102 -2
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.mjs +102 -2
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +7 -1
package/dist/profile.mjs
CHANGED
|
@@ -478,6 +478,104 @@ 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: [],
|
|
513
|
+
name: "p2pBoostCancelUnstake",
|
|
514
|
+
outputs: [],
|
|
515
|
+
stateMutability: "nonpayable",
|
|
516
|
+
type: "function"
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
inputs: [{ internalType: "address", name: "user", type: "address" }],
|
|
520
|
+
name: "getUserStake",
|
|
521
|
+
outputs: [
|
|
522
|
+
{
|
|
523
|
+
components: [
|
|
524
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
525
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
526
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
527
|
+
],
|
|
528
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
529
|
+
name: "",
|
|
530
|
+
type: "tuple"
|
|
531
|
+
}
|
|
532
|
+
],
|
|
533
|
+
stateMutability: "view",
|
|
534
|
+
type: "function"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
538
|
+
name: "getStakeBoostConfig",
|
|
539
|
+
outputs: [
|
|
540
|
+
{
|
|
541
|
+
components: [
|
|
542
|
+
{
|
|
543
|
+
internalType: "uint256",
|
|
544
|
+
name: "tokensPerUsdNumerator",
|
|
545
|
+
type: "uint256"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
internalType: "uint256",
|
|
549
|
+
name: "tokensPerUsdDenominator",
|
|
550
|
+
type: "uint256"
|
|
551
|
+
},
|
|
552
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
553
|
+
],
|
|
554
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
555
|
+
name: "",
|
|
556
|
+
type: "tuple"
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
stateMutability: "view",
|
|
560
|
+
type: "function"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
inputs: [],
|
|
564
|
+
name: "getStakeBoostGlobals",
|
|
565
|
+
outputs: [
|
|
566
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
567
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
568
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
569
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
570
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
571
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
572
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
573
|
+
],
|
|
574
|
+
stateMutability: "view",
|
|
575
|
+
type: "function"
|
|
576
|
+
}
|
|
577
|
+
];
|
|
578
|
+
|
|
481
579
|
// src/contracts/abis/reputation-manager.ts
|
|
482
580
|
var reputationManagerAbi = [
|
|
483
581
|
{
|
|
@@ -684,14 +782,16 @@ var reputationManagerAbi = [
|
|
|
684
782
|
var DIAMOND_ABI = [
|
|
685
783
|
...orderFlowFacetAbi,
|
|
686
784
|
...orderProcessorFacetAbi,
|
|
687
|
-
...p2pConfigFacetAbi
|
|
785
|
+
...p2pConfigFacetAbi,
|
|
786
|
+
...p2pStakeBoostFacetAbi
|
|
688
787
|
];
|
|
689
788
|
var ABIS = {
|
|
690
789
|
DIAMOND: DIAMOND_ABI,
|
|
691
790
|
FACETS: {
|
|
692
791
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
693
792
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
694
|
-
CONFIG: p2pConfigFacetAbi
|
|
793
|
+
CONFIG: p2pConfigFacetAbi,
|
|
794
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
695
795
|
},
|
|
696
796
|
EXTERNAL: {
|
|
697
797
|
USDC: erc20Abi,
|
|
@@ -1259,85 +1359,107 @@ function getPriceConfig(publicClient, diamondAddress, params) {
|
|
|
1259
1359
|
);
|
|
1260
1360
|
}
|
|
1261
1361
|
|
|
1362
|
+
// src/contracts/p2p-stake/index.ts
|
|
1363
|
+
import { ResultAsync as ResultAsync5 } from "neverthrow";
|
|
1364
|
+
import { stringToHex as stringToHex3 } from "viem";
|
|
1365
|
+
|
|
1366
|
+
// src/stake/validation.ts
|
|
1367
|
+
import { z as z4 } from "zod";
|
|
1368
|
+
var ZodGetUserStakeParamsSchema = z4.object({
|
|
1369
|
+
user: ZodAddressSchema
|
|
1370
|
+
});
|
|
1371
|
+
var ZodGetStakeBoostConfigParamsSchema = z4.object({
|
|
1372
|
+
currency: ZodCurrencySchema
|
|
1373
|
+
});
|
|
1374
|
+
var ZodGetP2pTokenBalanceParamsSchema = z4.object({
|
|
1375
|
+
address: ZodAddressSchema
|
|
1376
|
+
});
|
|
1377
|
+
var ZodStakeParamsSchema = z4.object({
|
|
1378
|
+
tokens: z4.bigint().positive()
|
|
1379
|
+
});
|
|
1380
|
+
var ZodTopUpParamsSchema = z4.object({
|
|
1381
|
+
tokens: z4.bigint().positive()
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1262
1384
|
// src/contracts/reputation-manager/writes.ts
|
|
1263
1385
|
import { Result } from "neverthrow";
|
|
1264
1386
|
import { encodeFunctionData } from "viem";
|
|
1265
1387
|
|
|
1266
1388
|
// 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
|
-
|
|
1389
|
+
import { z as z5 } from "zod";
|
|
1390
|
+
var ZodAnonAadharProofParamsSchema = z5.object({
|
|
1391
|
+
nullifierSeed: z5.bigint(),
|
|
1392
|
+
nullifier: z5.bigint(),
|
|
1393
|
+
timestamp: z5.bigint(),
|
|
1394
|
+
signal: z5.bigint(),
|
|
1395
|
+
revealArray: z5.tuple([z5.bigint(), z5.bigint(), z5.bigint(), z5.bigint()]),
|
|
1396
|
+
packedGroth16Proof: z5.tuple([
|
|
1397
|
+
z5.bigint(),
|
|
1398
|
+
z5.bigint(),
|
|
1399
|
+
z5.bigint(),
|
|
1400
|
+
z5.bigint(),
|
|
1401
|
+
z5.bigint(),
|
|
1402
|
+
z5.bigint(),
|
|
1403
|
+
z5.bigint(),
|
|
1404
|
+
z5.bigint()
|
|
1283
1405
|
])
|
|
1284
1406
|
});
|
|
1285
|
-
var ZodSocialVerifyParamsSchema =
|
|
1286
|
-
_socialName:
|
|
1287
|
-
proofs:
|
|
1288
|
-
|
|
1289
|
-
claimInfo:
|
|
1290
|
-
provider:
|
|
1291
|
-
parameters:
|
|
1292
|
-
context:
|
|
1407
|
+
var ZodSocialVerifyParamsSchema = z5.object({
|
|
1408
|
+
_socialName: z5.string(),
|
|
1409
|
+
proofs: z5.array(
|
|
1410
|
+
z5.object({
|
|
1411
|
+
claimInfo: z5.object({
|
|
1412
|
+
provider: z5.string(),
|
|
1413
|
+
parameters: z5.string(),
|
|
1414
|
+
context: z5.string()
|
|
1293
1415
|
}),
|
|
1294
|
-
signedClaim:
|
|
1295
|
-
claim:
|
|
1296
|
-
identifier:
|
|
1416
|
+
signedClaim: z5.object({
|
|
1417
|
+
claim: z5.object({
|
|
1418
|
+
identifier: z5.string(),
|
|
1297
1419
|
owner: ZodAddressSchema,
|
|
1298
|
-
timestampS:
|
|
1299
|
-
epoch:
|
|
1420
|
+
timestampS: z5.number(),
|
|
1421
|
+
epoch: z5.number()
|
|
1300
1422
|
}),
|
|
1301
|
-
signatures:
|
|
1423
|
+
signatures: z5.array(z5.string())
|
|
1302
1424
|
})
|
|
1303
1425
|
})
|
|
1304
1426
|
)
|
|
1305
1427
|
});
|
|
1306
|
-
var ZodSolidityVerifierParametersSchema =
|
|
1307
|
-
version:
|
|
1428
|
+
var ZodSolidityVerifierParametersSchema = z5.object({
|
|
1429
|
+
version: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1308
1430
|
message: "Version must be a hex string"
|
|
1309
1431
|
}),
|
|
1310
|
-
proofVerificationData:
|
|
1311
|
-
vkeyHash:
|
|
1432
|
+
proofVerificationData: z5.object({
|
|
1433
|
+
vkeyHash: z5.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1312
1434
|
message: "Invalid bytes32 hex string"
|
|
1313
1435
|
}),
|
|
1314
|
-
proof:
|
|
1436
|
+
proof: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1315
1437
|
message: "Proof must be a hex string"
|
|
1316
1438
|
}),
|
|
1317
|
-
publicInputs:
|
|
1318
|
-
|
|
1439
|
+
publicInputs: z5.array(
|
|
1440
|
+
z5.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
1319
1441
|
message: "Each public input must be a valid bytes32 hex string"
|
|
1320
1442
|
})
|
|
1321
1443
|
)
|
|
1322
1444
|
}),
|
|
1323
|
-
committedInputs:
|
|
1445
|
+
committedInputs: z5.string().refine((val) => val.startsWith("0x"), {
|
|
1324
1446
|
message: "Committed inputs must be a hex string"
|
|
1325
1447
|
}),
|
|
1326
|
-
serviceConfig:
|
|
1327
|
-
validityPeriodInSeconds:
|
|
1328
|
-
domain:
|
|
1329
|
-
scope:
|
|
1330
|
-
devMode:
|
|
1448
|
+
serviceConfig: z5.object({
|
|
1449
|
+
validityPeriodInSeconds: z5.number().int().nonnegative(),
|
|
1450
|
+
domain: z5.string(),
|
|
1451
|
+
scope: z5.string(),
|
|
1452
|
+
devMode: z5.boolean()
|
|
1331
1453
|
})
|
|
1332
1454
|
});
|
|
1333
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
1455
|
+
var ZodZkPassportRegisterParamsSchema = z5.object({
|
|
1334
1456
|
params: ZodSolidityVerifierParametersSchema,
|
|
1335
|
-
isIDCard:
|
|
1457
|
+
isIDCard: z5.boolean()
|
|
1336
1458
|
});
|
|
1337
1459
|
|
|
1338
1460
|
// src/contracts/tx-limits/index.ts
|
|
1339
|
-
import { ResultAsync as
|
|
1340
|
-
import { formatUnits, stringToHex as
|
|
1461
|
+
import { ResultAsync as ResultAsync6 } from "neverthrow";
|
|
1462
|
+
import { formatUnits, stringToHex as stringToHex4 } from "viem";
|
|
1341
1463
|
|
|
1342
1464
|
// src/profile/errors.ts
|
|
1343
1465
|
var ProfileError = class extends SdkError {
|
|
@@ -1348,18 +1470,18 @@ var ProfileError = class extends SdkError {
|
|
|
1348
1470
|
};
|
|
1349
1471
|
|
|
1350
1472
|
// src/profile/validation.ts
|
|
1351
|
-
import { z as
|
|
1352
|
-
var ZodUsdcBalanceParamsSchema =
|
|
1473
|
+
import { z as z6 } from "zod";
|
|
1474
|
+
var ZodUsdcBalanceParamsSchema = z6.object({
|
|
1353
1475
|
address: ZodAddressSchema
|
|
1354
1476
|
});
|
|
1355
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
1477
|
+
var ZodUsdcAllowanceParamsSchema = z6.object({
|
|
1356
1478
|
owner: ZodAddressSchema
|
|
1357
1479
|
});
|
|
1358
|
-
var ZodGetBalancesParamsSchema =
|
|
1480
|
+
var ZodGetBalancesParamsSchema = z6.object({
|
|
1359
1481
|
address: ZodAddressSchema,
|
|
1360
1482
|
currency: ZodCurrencySchema
|
|
1361
1483
|
});
|
|
1362
|
-
var ZodTxLimitsParamsSchema =
|
|
1484
|
+
var ZodTxLimitsParamsSchema = z6.object({
|
|
1363
1485
|
address: ZodAddressSchema,
|
|
1364
1486
|
currency: ZodCurrencySchema
|
|
1365
1487
|
});
|
|
@@ -1375,12 +1497,12 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1375
1497
|
context: { params: data }
|
|
1376
1498
|
})
|
|
1377
1499
|
).asyncAndThen(
|
|
1378
|
-
(validated) =>
|
|
1500
|
+
(validated) => ResultAsync6.fromPromise(
|
|
1379
1501
|
publicClient.readContract({
|
|
1380
1502
|
address: diamondAddress,
|
|
1381
1503
|
abi: ABIS.FACETS.ORDER_FLOW,
|
|
1382
1504
|
functionName: "userTxLimit",
|
|
1383
|
-
args: [validated.address,
|
|
1505
|
+
args: [validated.address, stringToHex4(validated.currency, { size: 32 })]
|
|
1384
1506
|
}),
|
|
1385
1507
|
(error) => new ProfileError("Failed to read tx limits", {
|
|
1386
1508
|
code: "CONTRACT_READ_ERROR",
|
|
@@ -1395,7 +1517,7 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
1395
1517
|
}
|
|
1396
1518
|
|
|
1397
1519
|
// src/contracts/usdc/index.ts
|
|
1398
|
-
import { ResultAsync as
|
|
1520
|
+
import { ResultAsync as ResultAsync7 } from "neverthrow";
|
|
1399
1521
|
import { erc20Abi as erc20Abi2 } from "viem";
|
|
1400
1522
|
function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
1401
1523
|
return validate(
|
|
@@ -1407,7 +1529,7 @@ function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
|
1407
1529
|
context: { params: data }
|
|
1408
1530
|
})
|
|
1409
1531
|
).asyncAndThen(
|
|
1410
|
-
(validated) =>
|
|
1532
|
+
(validated) => ResultAsync7.fromPromise(
|
|
1411
1533
|
publicClient.readContract({
|
|
1412
1534
|
address: usdcAddress,
|
|
1413
1535
|
abi: ABIS.EXTERNAL.USDC,
|
|
@@ -1432,7 +1554,7 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1432
1554
|
context: { params: data }
|
|
1433
1555
|
})
|
|
1434
1556
|
).asyncAndThen(
|
|
1435
|
-
(validated) =>
|
|
1557
|
+
(validated) => ResultAsync7.fromPromise(
|
|
1436
1558
|
publicClient.readContract({
|
|
1437
1559
|
address: usdcAddress,
|
|
1438
1560
|
abi: erc20Abi2,
|
|
@@ -1449,7 +1571,7 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1449
1571
|
}
|
|
1450
1572
|
|
|
1451
1573
|
// src/profile/contracts/actions.ts
|
|
1452
|
-
import { ResultAsync as
|
|
1574
|
+
import { ResultAsync as ResultAsync8 } from "neverthrow";
|
|
1453
1575
|
import { formatUnits as formatUnits2 } from "viem";
|
|
1454
1576
|
function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
1455
1577
|
return validate(
|
|
@@ -1461,7 +1583,7 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
1461
1583
|
context: { params: data }
|
|
1462
1584
|
})
|
|
1463
1585
|
).asyncAndThen(
|
|
1464
|
-
(validated) =>
|
|
1586
|
+
(validated) => ResultAsync8.combine([
|
|
1465
1587
|
getUsdcBalance(publicClient, usdcAddress, {
|
|
1466
1588
|
address: validated.address
|
|
1467
1589
|
}),
|