@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/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 z4 } from "zod";
1268
- var ZodAnonAadharProofParamsSchema = z4.object({
1269
- nullifierSeed: z4.bigint(),
1270
- nullifier: z4.bigint(),
1271
- timestamp: z4.bigint(),
1272
- signal: z4.bigint(),
1273
- revealArray: z4.tuple([z4.bigint(), z4.bigint(), z4.bigint(), z4.bigint()]),
1274
- packedGroth16Proof: z4.tuple([
1275
- z4.bigint(),
1276
- z4.bigint(),
1277
- z4.bigint(),
1278
- z4.bigint(),
1279
- z4.bigint(),
1280
- z4.bigint(),
1281
- z4.bigint(),
1282
- z4.bigint()
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 = z4.object({
1286
- _socialName: z4.string(),
1287
- proofs: z4.array(
1288
- z4.object({
1289
- claimInfo: z4.object({
1290
- provider: z4.string(),
1291
- parameters: z4.string(),
1292
- context: z4.string()
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: z4.object({
1295
- claim: z4.object({
1296
- identifier: z4.string(),
1416
+ signedClaim: z5.object({
1417
+ claim: z5.object({
1418
+ identifier: z5.string(),
1297
1419
  owner: ZodAddressSchema,
1298
- timestampS: z4.number(),
1299
- epoch: z4.number()
1420
+ timestampS: z5.number(),
1421
+ epoch: z5.number()
1300
1422
  }),
1301
- signatures: z4.array(z4.string())
1423
+ signatures: z5.array(z5.string())
1302
1424
  })
1303
1425
  })
1304
1426
  )
1305
1427
  });
1306
- var ZodSolidityVerifierParametersSchema = z4.object({
1307
- version: z4.string().refine((val) => val.startsWith("0x"), {
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: z4.object({
1311
- vkeyHash: z4.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
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: z4.string().refine((val) => val.startsWith("0x"), {
1436
+ proof: z5.string().refine((val) => val.startsWith("0x"), {
1315
1437
  message: "Proof must be a hex string"
1316
1438
  }),
1317
- publicInputs: z4.array(
1318
- z4.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
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: z4.string().refine((val) => val.startsWith("0x"), {
1445
+ committedInputs: z5.string().refine((val) => val.startsWith("0x"), {
1324
1446
  message: "Committed inputs must be a hex string"
1325
1447
  }),
1326
- serviceConfig: z4.object({
1327
- validityPeriodInSeconds: z4.number().int().nonnegative(),
1328
- domain: z4.string(),
1329
- scope: z4.string(),
1330
- devMode: z4.boolean()
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 = z4.object({
1455
+ var ZodZkPassportRegisterParamsSchema = z5.object({
1334
1456
  params: ZodSolidityVerifierParametersSchema,
1335
- isIDCard: z4.boolean()
1457
+ isIDCard: z5.boolean()
1336
1458
  });
1337
1459
 
1338
1460
  // src/contracts/tx-limits/index.ts
1339
- import { ResultAsync as ResultAsync5 } from "neverthrow";
1340
- import { formatUnits, stringToHex as stringToHex3 } from "viem";
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 z5 } from "zod";
1352
- var ZodUsdcBalanceParamsSchema = z5.object({
1473
+ import { z as z6 } from "zod";
1474
+ var ZodUsdcBalanceParamsSchema = z6.object({
1353
1475
  address: ZodAddressSchema
1354
1476
  });
1355
- var ZodUsdcAllowanceParamsSchema = z5.object({
1477
+ var ZodUsdcAllowanceParamsSchema = z6.object({
1356
1478
  owner: ZodAddressSchema
1357
1479
  });
1358
- var ZodGetBalancesParamsSchema = z5.object({
1480
+ var ZodGetBalancesParamsSchema = z6.object({
1359
1481
  address: ZodAddressSchema,
1360
1482
  currency: ZodCurrencySchema
1361
1483
  });
1362
- var ZodTxLimitsParamsSchema = z5.object({
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) => ResultAsync5.fromPromise(
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, stringToHex3(validated.currency, { size: 32 })]
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 ResultAsync6 } from "neverthrow";
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) => ResultAsync6.fromPromise(
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) => ResultAsync6.fromPromise(
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 ResultAsync7 } from "neverthrow";
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) => ResultAsync7.combine([
1586
+ (validated) => ResultAsync8.combine([
1465
1587
  getUsdcBalance(publicClient, usdcAddress, {
1466
1588
  address: validated.address
1467
1589
  }),