@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/index.cjs
CHANGED
|
@@ -64,7 +64,7 @@ var ZodAddressSchema = import_zod.z.string().refine((s) => (0, import_viem.isAdd
|
|
|
64
64
|
var ZodCurrencySchema = import_zod.z.enum(CURRENCY_CODES);
|
|
65
65
|
|
|
66
66
|
// src/index.ts
|
|
67
|
-
var VERSION = "1.
|
|
67
|
+
var VERSION = "1.2.0";
|
|
68
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
69
|
0 && (module.exports = {
|
|
70
70
|
SdkError,
|
package/dist/index.mjs
CHANGED
package/dist/orders.cjs
CHANGED
|
@@ -48,7 +48,7 @@ __export(orders_exports, {
|
|
|
48
48
|
module.exports = __toCommonJS(orders_exports);
|
|
49
49
|
|
|
50
50
|
// src/orders/client.ts
|
|
51
|
-
var
|
|
51
|
+
var import_neverthrow16 = require("neverthrow");
|
|
52
52
|
|
|
53
53
|
// src/contracts/order-processor/index.ts
|
|
54
54
|
var import_neverthrow = require("neverthrow");
|
|
@@ -534,6 +534,104 @@ var p2pConfigFacetAbi = [
|
|
|
534
534
|
}
|
|
535
535
|
];
|
|
536
536
|
|
|
537
|
+
// src/contracts/abis/p2p-stake-boost-facet.ts
|
|
538
|
+
var p2pStakeBoostFacetAbi = [
|
|
539
|
+
{
|
|
540
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
541
|
+
name: "p2pBoostStake",
|
|
542
|
+
outputs: [],
|
|
543
|
+
stateMutability: "nonpayable",
|
|
544
|
+
type: "function"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
548
|
+
name: "p2pBoostTopUp",
|
|
549
|
+
outputs: [],
|
|
550
|
+
stateMutability: "nonpayable",
|
|
551
|
+
type: "function"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
inputs: [],
|
|
555
|
+
name: "p2pBoostRequestUnstake",
|
|
556
|
+
outputs: [],
|
|
557
|
+
stateMutability: "nonpayable",
|
|
558
|
+
type: "function"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
inputs: [],
|
|
562
|
+
name: "p2pBoostClaimUnstake",
|
|
563
|
+
outputs: [],
|
|
564
|
+
stateMutability: "nonpayable",
|
|
565
|
+
type: "function"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
inputs: [],
|
|
569
|
+
name: "p2pBoostCancelUnstake",
|
|
570
|
+
outputs: [],
|
|
571
|
+
stateMutability: "nonpayable",
|
|
572
|
+
type: "function"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
inputs: [{ internalType: "address", name: "user", type: "address" }],
|
|
576
|
+
name: "getUserStake",
|
|
577
|
+
outputs: [
|
|
578
|
+
{
|
|
579
|
+
components: [
|
|
580
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
581
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
582
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
583
|
+
],
|
|
584
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
585
|
+
name: "",
|
|
586
|
+
type: "tuple"
|
|
587
|
+
}
|
|
588
|
+
],
|
|
589
|
+
stateMutability: "view",
|
|
590
|
+
type: "function"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
594
|
+
name: "getStakeBoostConfig",
|
|
595
|
+
outputs: [
|
|
596
|
+
{
|
|
597
|
+
components: [
|
|
598
|
+
{
|
|
599
|
+
internalType: "uint256",
|
|
600
|
+
name: "tokensPerUsdNumerator",
|
|
601
|
+
type: "uint256"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
internalType: "uint256",
|
|
605
|
+
name: "tokensPerUsdDenominator",
|
|
606
|
+
type: "uint256"
|
|
607
|
+
},
|
|
608
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
609
|
+
],
|
|
610
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
611
|
+
name: "",
|
|
612
|
+
type: "tuple"
|
|
613
|
+
}
|
|
614
|
+
],
|
|
615
|
+
stateMutability: "view",
|
|
616
|
+
type: "function"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
inputs: [],
|
|
620
|
+
name: "getStakeBoostGlobals",
|
|
621
|
+
outputs: [
|
|
622
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
623
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
624
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
625
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
626
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
627
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
628
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
629
|
+
],
|
|
630
|
+
stateMutability: "view",
|
|
631
|
+
type: "function"
|
|
632
|
+
}
|
|
633
|
+
];
|
|
634
|
+
|
|
537
635
|
// src/contracts/abis/reputation-manager.ts
|
|
538
636
|
var reputationManagerAbi = [
|
|
539
637
|
{
|
|
@@ -740,14 +838,16 @@ var reputationManagerAbi = [
|
|
|
740
838
|
var DIAMOND_ABI = [
|
|
741
839
|
...orderFlowFacetAbi,
|
|
742
840
|
...orderProcessorFacetAbi,
|
|
743
|
-
...p2pConfigFacetAbi
|
|
841
|
+
...p2pConfigFacetAbi,
|
|
842
|
+
...p2pStakeBoostFacetAbi
|
|
744
843
|
];
|
|
745
844
|
var ABIS = {
|
|
746
845
|
DIAMOND: DIAMOND_ABI,
|
|
747
846
|
FACETS: {
|
|
748
847
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
749
848
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
750
|
-
CONFIG: p2pConfigFacetAbi
|
|
849
|
+
CONFIG: p2pConfigFacetAbi,
|
|
850
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
751
851
|
},
|
|
752
852
|
EXTERNAL: {
|
|
753
853
|
USDC: import_viem.erc20Abi,
|
|
@@ -3425,15 +3525,15 @@ function weierstrassPoints(opts) {
|
|
|
3425
3525
|
throw new Error("ProjectivePoint expected");
|
|
3426
3526
|
}
|
|
3427
3527
|
const toAffineMemo = memoized((p, iz) => {
|
|
3428
|
-
const { px: x, py: y, pz:
|
|
3429
|
-
if (Fp.eql(
|
|
3528
|
+
const { px: x, py: y, pz: z10 } = p;
|
|
3529
|
+
if (Fp.eql(z10, Fp.ONE))
|
|
3430
3530
|
return { x, y };
|
|
3431
3531
|
const is0 = p.is0();
|
|
3432
3532
|
if (iz == null)
|
|
3433
|
-
iz = is0 ? Fp.ONE : Fp.inv(
|
|
3533
|
+
iz = is0 ? Fp.ONE : Fp.inv(z10);
|
|
3434
3534
|
const ax = Fp.mul(x, iz);
|
|
3435
3535
|
const ay = Fp.mul(y, iz);
|
|
3436
|
-
const zz = Fp.mul(
|
|
3536
|
+
const zz = Fp.mul(z10, iz);
|
|
3437
3537
|
if (is0)
|
|
3438
3538
|
return { x: Fp.ZERO, y: Fp.ZERO };
|
|
3439
3539
|
if (!Fp.eql(zz, Fp.ONE))
|
|
@@ -4428,7 +4528,7 @@ function createSetSellOrderUpiAction(input) {
|
|
|
4428
4528
|
}
|
|
4429
4529
|
|
|
4430
4530
|
// src/orders/internal/routing/client.ts
|
|
4431
|
-
var
|
|
4531
|
+
var import_viem17 = require("viem");
|
|
4432
4532
|
|
|
4433
4533
|
// src/contracts/error-messages.ts
|
|
4434
4534
|
var contractErrorMessages = {
|
|
@@ -5211,109 +5311,131 @@ var ZodCurrencyScopedParamsSchema = import_zod6.z.object({
|
|
|
5211
5311
|
currency: ZodCurrencySchema
|
|
5212
5312
|
});
|
|
5213
5313
|
|
|
5214
|
-
// src/contracts/
|
|
5314
|
+
// src/contracts/p2p-stake/index.ts
|
|
5215
5315
|
var import_neverthrow9 = require("neverthrow");
|
|
5216
5316
|
var import_viem13 = require("viem");
|
|
5217
5317
|
|
|
5218
|
-
// src/
|
|
5318
|
+
// src/stake/validation.ts
|
|
5219
5319
|
var import_zod7 = require("zod");
|
|
5220
|
-
var
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5320
|
+
var ZodGetUserStakeParamsSchema = import_zod7.z.object({
|
|
5321
|
+
user: ZodAddressSchema
|
|
5322
|
+
});
|
|
5323
|
+
var ZodGetStakeBoostConfigParamsSchema = import_zod7.z.object({
|
|
5324
|
+
currency: ZodCurrencySchema
|
|
5325
|
+
});
|
|
5326
|
+
var ZodGetP2pTokenBalanceParamsSchema = import_zod7.z.object({
|
|
5327
|
+
address: ZodAddressSchema
|
|
5328
|
+
});
|
|
5329
|
+
var ZodStakeParamsSchema = import_zod7.z.object({
|
|
5330
|
+
tokens: import_zod7.z.bigint().positive()
|
|
5331
|
+
});
|
|
5332
|
+
var ZodTopUpParamsSchema = import_zod7.z.object({
|
|
5333
|
+
tokens: import_zod7.z.bigint().positive()
|
|
5334
|
+
});
|
|
5335
|
+
|
|
5336
|
+
// src/contracts/reputation-manager/writes.ts
|
|
5337
|
+
var import_neverthrow10 = require("neverthrow");
|
|
5338
|
+
var import_viem14 = require("viem");
|
|
5339
|
+
|
|
5340
|
+
// src/zkkyc/validation.ts
|
|
5341
|
+
var import_zod8 = require("zod");
|
|
5342
|
+
var ZodAnonAadharProofParamsSchema = import_zod8.z.object({
|
|
5343
|
+
nullifierSeed: import_zod8.z.bigint(),
|
|
5344
|
+
nullifier: import_zod8.z.bigint(),
|
|
5345
|
+
timestamp: import_zod8.z.bigint(),
|
|
5346
|
+
signal: import_zod8.z.bigint(),
|
|
5347
|
+
revealArray: import_zod8.z.tuple([import_zod8.z.bigint(), import_zod8.z.bigint(), import_zod8.z.bigint(), import_zod8.z.bigint()]),
|
|
5348
|
+
packedGroth16Proof: import_zod8.z.tuple([
|
|
5349
|
+
import_zod8.z.bigint(),
|
|
5350
|
+
import_zod8.z.bigint(),
|
|
5351
|
+
import_zod8.z.bigint(),
|
|
5352
|
+
import_zod8.z.bigint(),
|
|
5353
|
+
import_zod8.z.bigint(),
|
|
5354
|
+
import_zod8.z.bigint(),
|
|
5355
|
+
import_zod8.z.bigint(),
|
|
5356
|
+
import_zod8.z.bigint()
|
|
5235
5357
|
])
|
|
5236
5358
|
});
|
|
5237
|
-
var ZodSocialVerifyParamsSchema =
|
|
5238
|
-
_socialName:
|
|
5239
|
-
proofs:
|
|
5240
|
-
|
|
5241
|
-
claimInfo:
|
|
5242
|
-
provider:
|
|
5243
|
-
parameters:
|
|
5244
|
-
context:
|
|
5359
|
+
var ZodSocialVerifyParamsSchema = import_zod8.z.object({
|
|
5360
|
+
_socialName: import_zod8.z.string(),
|
|
5361
|
+
proofs: import_zod8.z.array(
|
|
5362
|
+
import_zod8.z.object({
|
|
5363
|
+
claimInfo: import_zod8.z.object({
|
|
5364
|
+
provider: import_zod8.z.string(),
|
|
5365
|
+
parameters: import_zod8.z.string(),
|
|
5366
|
+
context: import_zod8.z.string()
|
|
5245
5367
|
}),
|
|
5246
|
-
signedClaim:
|
|
5247
|
-
claim:
|
|
5248
|
-
identifier:
|
|
5368
|
+
signedClaim: import_zod8.z.object({
|
|
5369
|
+
claim: import_zod8.z.object({
|
|
5370
|
+
identifier: import_zod8.z.string(),
|
|
5249
5371
|
owner: ZodAddressSchema,
|
|
5250
|
-
timestampS:
|
|
5251
|
-
epoch:
|
|
5372
|
+
timestampS: import_zod8.z.number(),
|
|
5373
|
+
epoch: import_zod8.z.number()
|
|
5252
5374
|
}),
|
|
5253
|
-
signatures:
|
|
5375
|
+
signatures: import_zod8.z.array(import_zod8.z.string())
|
|
5254
5376
|
})
|
|
5255
5377
|
})
|
|
5256
5378
|
)
|
|
5257
5379
|
});
|
|
5258
|
-
var ZodSolidityVerifierParametersSchema =
|
|
5259
|
-
version:
|
|
5380
|
+
var ZodSolidityVerifierParametersSchema = import_zod8.z.object({
|
|
5381
|
+
version: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5260
5382
|
message: "Version must be a hex string"
|
|
5261
5383
|
}),
|
|
5262
|
-
proofVerificationData:
|
|
5263
|
-
vkeyHash:
|
|
5384
|
+
proofVerificationData: import_zod8.z.object({
|
|
5385
|
+
vkeyHash: import_zod8.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5264
5386
|
message: "Invalid bytes32 hex string"
|
|
5265
5387
|
}),
|
|
5266
|
-
proof:
|
|
5388
|
+
proof: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5267
5389
|
message: "Proof must be a hex string"
|
|
5268
5390
|
}),
|
|
5269
|
-
publicInputs:
|
|
5270
|
-
|
|
5391
|
+
publicInputs: import_zod8.z.array(
|
|
5392
|
+
import_zod8.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5271
5393
|
message: "Each public input must be a valid bytes32 hex string"
|
|
5272
5394
|
})
|
|
5273
5395
|
)
|
|
5274
5396
|
}),
|
|
5275
|
-
committedInputs:
|
|
5397
|
+
committedInputs: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5276
5398
|
message: "Committed inputs must be a hex string"
|
|
5277
5399
|
}),
|
|
5278
|
-
serviceConfig:
|
|
5279
|
-
validityPeriodInSeconds:
|
|
5280
|
-
domain:
|
|
5281
|
-
scope:
|
|
5282
|
-
devMode:
|
|
5400
|
+
serviceConfig: import_zod8.z.object({
|
|
5401
|
+
validityPeriodInSeconds: import_zod8.z.number().int().nonnegative(),
|
|
5402
|
+
domain: import_zod8.z.string(),
|
|
5403
|
+
scope: import_zod8.z.string(),
|
|
5404
|
+
devMode: import_zod8.z.boolean()
|
|
5283
5405
|
})
|
|
5284
5406
|
});
|
|
5285
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
5407
|
+
var ZodZkPassportRegisterParamsSchema = import_zod8.z.object({
|
|
5286
5408
|
params: ZodSolidityVerifierParametersSchema,
|
|
5287
|
-
isIDCard:
|
|
5409
|
+
isIDCard: import_zod8.z.boolean()
|
|
5288
5410
|
});
|
|
5289
5411
|
|
|
5290
5412
|
// src/contracts/tx-limits/index.ts
|
|
5291
|
-
var
|
|
5292
|
-
var
|
|
5413
|
+
var import_neverthrow11 = require("neverthrow");
|
|
5414
|
+
var import_viem15 = require("viem");
|
|
5293
5415
|
|
|
5294
5416
|
// src/profile/validation.ts
|
|
5295
|
-
var
|
|
5296
|
-
var ZodUsdcBalanceParamsSchema =
|
|
5417
|
+
var import_zod9 = require("zod");
|
|
5418
|
+
var ZodUsdcBalanceParamsSchema = import_zod9.z.object({
|
|
5297
5419
|
address: ZodAddressSchema
|
|
5298
5420
|
});
|
|
5299
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
5421
|
+
var ZodUsdcAllowanceParamsSchema = import_zod9.z.object({
|
|
5300
5422
|
owner: ZodAddressSchema
|
|
5301
5423
|
});
|
|
5302
|
-
var ZodGetBalancesParamsSchema =
|
|
5424
|
+
var ZodGetBalancesParamsSchema = import_zod9.z.object({
|
|
5303
5425
|
address: ZodAddressSchema,
|
|
5304
5426
|
currency: ZodCurrencySchema
|
|
5305
5427
|
});
|
|
5306
|
-
var ZodTxLimitsParamsSchema =
|
|
5428
|
+
var ZodTxLimitsParamsSchema = import_zod9.z.object({
|
|
5307
5429
|
address: ZodAddressSchema,
|
|
5308
5430
|
currency: ZodCurrencySchema
|
|
5309
5431
|
});
|
|
5310
5432
|
|
|
5311
5433
|
// src/contracts/usdc/index.ts
|
|
5312
|
-
var
|
|
5313
|
-
var
|
|
5434
|
+
var import_neverthrow12 = require("neverthrow");
|
|
5435
|
+
var import_viem16 = require("viem");
|
|
5314
5436
|
|
|
5315
5437
|
// src/orders/internal/routing/routing.ts
|
|
5316
|
-
var
|
|
5438
|
+
var import_neverthrow13 = require("neverthrow");
|
|
5317
5439
|
var EPSILON = 0.25;
|
|
5318
5440
|
var RECOVERY_SCALE = 0.3;
|
|
5319
5441
|
var BOOTSTRAP_MAX_WEIGHT = 25;
|
|
@@ -5380,7 +5502,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5380
5502
|
attemptsLeft,
|
|
5381
5503
|
remainingCircles: remaining.length
|
|
5382
5504
|
});
|
|
5383
|
-
return (0,
|
|
5505
|
+
return (0, import_neverthrow13.errAsync)(
|
|
5384
5506
|
new OrderRoutingError("No eligible circles found", {
|
|
5385
5507
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5386
5508
|
})
|
|
@@ -5388,7 +5510,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5388
5510
|
}
|
|
5389
5511
|
const selected = selectCircle(remaining);
|
|
5390
5512
|
if (!selected) {
|
|
5391
|
-
return (0,
|
|
5513
|
+
return (0, import_neverthrow13.errAsync)(
|
|
5392
5514
|
new OrderRoutingError("No eligible circles found", {
|
|
5393
5515
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5394
5516
|
})
|
|
@@ -5406,11 +5528,11 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5406
5528
|
circleId: String(circleId),
|
|
5407
5529
|
error: String(error)
|
|
5408
5530
|
});
|
|
5409
|
-
return (0,
|
|
5531
|
+
return (0, import_neverthrow13.okAsync)(false);
|
|
5410
5532
|
}).andThen((isValid) => {
|
|
5411
5533
|
if (isValid) {
|
|
5412
5534
|
logger.info("circle validated successfully", { circleId: String(circleId) });
|
|
5413
|
-
return (0,
|
|
5535
|
+
return (0, import_neverthrow13.okAsync)(circleId);
|
|
5414
5536
|
}
|
|
5415
5537
|
logger.debug("circle failed validation, retrying", {
|
|
5416
5538
|
circleId: String(circleId),
|
|
@@ -5488,7 +5610,7 @@ function createOrderRouter(config) {
|
|
|
5488
5610
|
const logger = config.logger ?? noopLogger;
|
|
5489
5611
|
return {
|
|
5490
5612
|
selectCircle(params) {
|
|
5491
|
-
const currencyHex = (0,
|
|
5613
|
+
const currencyHex = (0, import_viem17.stringToHex)(params.currency, { size: 32 });
|
|
5492
5614
|
logger.info("selectCircle started", {
|
|
5493
5615
|
currency: params.currency,
|
|
5494
5616
|
user: params.user,
|
|
@@ -5520,8 +5642,8 @@ function createOrderRouter(config) {
|
|
|
5520
5642
|
}
|
|
5521
5643
|
|
|
5522
5644
|
// src/orders/normalize.ts
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5645
|
+
var import_neverthrow14 = require("neverthrow");
|
|
5646
|
+
var import_viem18 = require("viem");
|
|
5525
5647
|
var ORDER_TYPE_MAP = {
|
|
5526
5648
|
[ORDER_TYPE.BUY]: "buy",
|
|
5527
5649
|
[ORDER_TYPE.SELL]: "sell",
|
|
@@ -5547,23 +5669,23 @@ function malformed(field, value, context) {
|
|
|
5547
5669
|
}
|
|
5548
5670
|
function mapOrderType(v, ctx) {
|
|
5549
5671
|
const t = ORDER_TYPE_MAP[v];
|
|
5550
|
-
return t ? (0,
|
|
5672
|
+
return t ? (0, import_neverthrow14.ok)(t) : (0, import_neverthrow14.err)(malformed("orderType", v, ctx));
|
|
5551
5673
|
}
|
|
5552
5674
|
function mapOrderStatus(v, ctx) {
|
|
5553
5675
|
const s = ORDER_STATUS_MAP[v];
|
|
5554
|
-
return s ? (0,
|
|
5676
|
+
return s ? (0, import_neverthrow14.ok)(s) : (0, import_neverthrow14.err)(malformed("status", v, ctx));
|
|
5555
5677
|
}
|
|
5556
5678
|
function mapDisputeStatus(v, ctx) {
|
|
5557
5679
|
const s = DISPUTE_STATUS_MAP[v];
|
|
5558
|
-
return s ? (0,
|
|
5680
|
+
return s ? (0, import_neverthrow14.ok)(s) : (0, import_neverthrow14.err)(malformed("disputeStatus", v, ctx));
|
|
5559
5681
|
}
|
|
5560
5682
|
function decodeCurrency(hex) {
|
|
5561
|
-
return (0,
|
|
5683
|
+
return (0, import_viem18.hexToString)(hex, { size: 32 }).replaceAll("\0", "");
|
|
5562
5684
|
}
|
|
5563
5685
|
function normalizeContractOrder(raw, details) {
|
|
5564
|
-
if (raw.id === 0n && (0,
|
|
5686
|
+
if (raw.id === 0n && (0, import_viem18.isAddressEqual)(raw.user, import_viem18.zeroAddress)) return (0, import_neverthrow14.ok)(null);
|
|
5565
5687
|
const ctx = { orderId: raw.id.toString() };
|
|
5566
|
-
return
|
|
5688
|
+
return import_neverthrow14.Result.combine([
|
|
5567
5689
|
mapOrderType(raw.orderType, ctx),
|
|
5568
5690
|
mapOrderStatus(raw.status, ctx),
|
|
5569
5691
|
mapDisputeStatus(raw.disputeInfo.status, ctx)
|
|
@@ -5594,7 +5716,7 @@ function normalizeContractOrder(raw, details) {
|
|
|
5594
5716
|
}
|
|
5595
5717
|
function normalizeSubgraphOrder(raw) {
|
|
5596
5718
|
const ctx = { orderId: raw.orderId };
|
|
5597
|
-
return
|
|
5719
|
+
return import_neverthrow14.Result.combine([
|
|
5598
5720
|
mapOrderType(raw.type, ctx),
|
|
5599
5721
|
mapOrderStatus(raw.status, ctx),
|
|
5600
5722
|
mapDisputeStatus(raw.disputeStatus, ctx)
|
|
@@ -5627,7 +5749,7 @@ function normalizeSubgraphOrder(raw) {
|
|
|
5627
5749
|
}
|
|
5628
5750
|
|
|
5629
5751
|
// src/orders/subgraph/index.ts
|
|
5630
|
-
var
|
|
5752
|
+
var import_neverthrow15 = require("neverthrow");
|
|
5631
5753
|
|
|
5632
5754
|
// src/orders/subgraph/queries.ts
|
|
5633
5755
|
var ORDERS_BY_USER_QUERY = (
|
|
@@ -5688,7 +5810,7 @@ function getOrdersForUser(subgraphUrl, userAddress, skip, limit, logger = noopLo
|
|
|
5688
5810
|
context: { data: d }
|
|
5689
5811
|
})
|
|
5690
5812
|
).andThen(
|
|
5691
|
-
(validated) =>
|
|
5813
|
+
(validated) => import_neverthrow15.Result.combine(validated.orders_collection.map(normalizeSubgraphOrder))
|
|
5692
5814
|
)
|
|
5693
5815
|
);
|
|
5694
5816
|
}
|
|
@@ -5842,7 +5964,7 @@ function createOrders(config) {
|
|
|
5842
5964
|
).andThen(
|
|
5843
5965
|
({ order, details }) => normalizeContractOrder(order, details).asyncAndThen((normalized) => {
|
|
5844
5966
|
if (!normalized) {
|
|
5845
|
-
return (0,
|
|
5967
|
+
return (0, import_neverthrow16.errAsync)(
|
|
5846
5968
|
new OrdersError("Order not found", {
|
|
5847
5969
|
code: "ORDER_NOT_FOUND",
|
|
5848
5970
|
context: { orderId: params.orderId.toString() }
|
|
@@ -5850,7 +5972,7 @@ function createOrders(config) {
|
|
|
5850
5972
|
);
|
|
5851
5973
|
}
|
|
5852
5974
|
logger.debug("getOrder resolved", { orderId: params.orderId.toString() });
|
|
5853
|
-
return (0,
|
|
5975
|
+
return (0, import_neverthrow16.okAsync)(normalized);
|
|
5854
5976
|
})
|
|
5855
5977
|
);
|
|
5856
5978
|
},
|