@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/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.1.
|
|
67
|
+
var VERSION = "1.1.9";
|
|
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,97 @@ 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: [{ internalType: "address", name: "user", type: "address" }],
|
|
569
|
+
name: "getUserStake",
|
|
570
|
+
outputs: [
|
|
571
|
+
{
|
|
572
|
+
components: [
|
|
573
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
574
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
575
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
576
|
+
],
|
|
577
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
578
|
+
name: "",
|
|
579
|
+
type: "tuple"
|
|
580
|
+
}
|
|
581
|
+
],
|
|
582
|
+
stateMutability: "view",
|
|
583
|
+
type: "function"
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
587
|
+
name: "getStakeBoostConfig",
|
|
588
|
+
outputs: [
|
|
589
|
+
{
|
|
590
|
+
components: [
|
|
591
|
+
{
|
|
592
|
+
internalType: "uint256",
|
|
593
|
+
name: "tokensPerUsdNumerator",
|
|
594
|
+
type: "uint256"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
internalType: "uint256",
|
|
598
|
+
name: "tokensPerUsdDenominator",
|
|
599
|
+
type: "uint256"
|
|
600
|
+
},
|
|
601
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
602
|
+
],
|
|
603
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
604
|
+
name: "",
|
|
605
|
+
type: "tuple"
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
stateMutability: "view",
|
|
609
|
+
type: "function"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
inputs: [],
|
|
613
|
+
name: "getStakeBoostGlobals",
|
|
614
|
+
outputs: [
|
|
615
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
616
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
617
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
618
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
619
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
620
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
621
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
622
|
+
],
|
|
623
|
+
stateMutability: "view",
|
|
624
|
+
type: "function"
|
|
625
|
+
}
|
|
626
|
+
];
|
|
627
|
+
|
|
537
628
|
// src/contracts/abis/reputation-manager.ts
|
|
538
629
|
var reputationManagerAbi = [
|
|
539
630
|
{
|
|
@@ -740,14 +831,16 @@ var reputationManagerAbi = [
|
|
|
740
831
|
var DIAMOND_ABI = [
|
|
741
832
|
...orderFlowFacetAbi,
|
|
742
833
|
...orderProcessorFacetAbi,
|
|
743
|
-
...p2pConfigFacetAbi
|
|
834
|
+
...p2pConfigFacetAbi,
|
|
835
|
+
...p2pStakeBoostFacetAbi
|
|
744
836
|
];
|
|
745
837
|
var ABIS = {
|
|
746
838
|
DIAMOND: DIAMOND_ABI,
|
|
747
839
|
FACETS: {
|
|
748
840
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
749
841
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
750
|
-
CONFIG: p2pConfigFacetAbi
|
|
842
|
+
CONFIG: p2pConfigFacetAbi,
|
|
843
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
751
844
|
},
|
|
752
845
|
EXTERNAL: {
|
|
753
846
|
USDC: import_viem.erc20Abi,
|
|
@@ -3425,15 +3518,15 @@ function weierstrassPoints(opts) {
|
|
|
3425
3518
|
throw new Error("ProjectivePoint expected");
|
|
3426
3519
|
}
|
|
3427
3520
|
const toAffineMemo = memoized((p, iz) => {
|
|
3428
|
-
const { px: x, py: y, pz:
|
|
3429
|
-
if (Fp.eql(
|
|
3521
|
+
const { px: x, py: y, pz: z10 } = p;
|
|
3522
|
+
if (Fp.eql(z10, Fp.ONE))
|
|
3430
3523
|
return { x, y };
|
|
3431
3524
|
const is0 = p.is0();
|
|
3432
3525
|
if (iz == null)
|
|
3433
|
-
iz = is0 ? Fp.ONE : Fp.inv(
|
|
3526
|
+
iz = is0 ? Fp.ONE : Fp.inv(z10);
|
|
3434
3527
|
const ax = Fp.mul(x, iz);
|
|
3435
3528
|
const ay = Fp.mul(y, iz);
|
|
3436
|
-
const zz = Fp.mul(
|
|
3529
|
+
const zz = Fp.mul(z10, iz);
|
|
3437
3530
|
if (is0)
|
|
3438
3531
|
return { x: Fp.ZERO, y: Fp.ZERO };
|
|
3439
3532
|
if (!Fp.eql(zz, Fp.ONE))
|
|
@@ -4428,7 +4521,7 @@ function createSetSellOrderUpiAction(input) {
|
|
|
4428
4521
|
}
|
|
4429
4522
|
|
|
4430
4523
|
// src/orders/internal/routing/client.ts
|
|
4431
|
-
var
|
|
4524
|
+
var import_viem17 = require("viem");
|
|
4432
4525
|
|
|
4433
4526
|
// src/contracts/error-messages.ts
|
|
4434
4527
|
var contractErrorMessages = {
|
|
@@ -5211,109 +5304,131 @@ var ZodCurrencyScopedParamsSchema = import_zod6.z.object({
|
|
|
5211
5304
|
currency: ZodCurrencySchema
|
|
5212
5305
|
});
|
|
5213
5306
|
|
|
5214
|
-
// src/contracts/
|
|
5307
|
+
// src/contracts/p2p-stake/index.ts
|
|
5215
5308
|
var import_neverthrow9 = require("neverthrow");
|
|
5216
5309
|
var import_viem13 = require("viem");
|
|
5217
5310
|
|
|
5218
|
-
// src/
|
|
5311
|
+
// src/stake/validation.ts
|
|
5219
5312
|
var import_zod7 = require("zod");
|
|
5220
|
-
var
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5313
|
+
var ZodGetUserStakeParamsSchema = import_zod7.z.object({
|
|
5314
|
+
user: ZodAddressSchema
|
|
5315
|
+
});
|
|
5316
|
+
var ZodGetStakeBoostConfigParamsSchema = import_zod7.z.object({
|
|
5317
|
+
currency: ZodCurrencySchema
|
|
5318
|
+
});
|
|
5319
|
+
var ZodGetP2pTokenBalanceParamsSchema = import_zod7.z.object({
|
|
5320
|
+
address: ZodAddressSchema
|
|
5321
|
+
});
|
|
5322
|
+
var ZodStakeParamsSchema = import_zod7.z.object({
|
|
5323
|
+
tokens: import_zod7.z.bigint().positive()
|
|
5324
|
+
});
|
|
5325
|
+
var ZodTopUpParamsSchema = import_zod7.z.object({
|
|
5326
|
+
tokens: import_zod7.z.bigint().positive()
|
|
5327
|
+
});
|
|
5328
|
+
|
|
5329
|
+
// src/contracts/reputation-manager/writes.ts
|
|
5330
|
+
var import_neverthrow10 = require("neverthrow");
|
|
5331
|
+
var import_viem14 = require("viem");
|
|
5332
|
+
|
|
5333
|
+
// src/zkkyc/validation.ts
|
|
5334
|
+
var import_zod8 = require("zod");
|
|
5335
|
+
var ZodAnonAadharProofParamsSchema = import_zod8.z.object({
|
|
5336
|
+
nullifierSeed: import_zod8.z.bigint(),
|
|
5337
|
+
nullifier: import_zod8.z.bigint(),
|
|
5338
|
+
timestamp: import_zod8.z.bigint(),
|
|
5339
|
+
signal: import_zod8.z.bigint(),
|
|
5340
|
+
revealArray: import_zod8.z.tuple([import_zod8.z.bigint(), import_zod8.z.bigint(), import_zod8.z.bigint(), import_zod8.z.bigint()]),
|
|
5341
|
+
packedGroth16Proof: import_zod8.z.tuple([
|
|
5342
|
+
import_zod8.z.bigint(),
|
|
5343
|
+
import_zod8.z.bigint(),
|
|
5344
|
+
import_zod8.z.bigint(),
|
|
5345
|
+
import_zod8.z.bigint(),
|
|
5346
|
+
import_zod8.z.bigint(),
|
|
5347
|
+
import_zod8.z.bigint(),
|
|
5348
|
+
import_zod8.z.bigint(),
|
|
5349
|
+
import_zod8.z.bigint()
|
|
5235
5350
|
])
|
|
5236
5351
|
});
|
|
5237
|
-
var ZodSocialVerifyParamsSchema =
|
|
5238
|
-
_socialName:
|
|
5239
|
-
proofs:
|
|
5240
|
-
|
|
5241
|
-
claimInfo:
|
|
5242
|
-
provider:
|
|
5243
|
-
parameters:
|
|
5244
|
-
context:
|
|
5352
|
+
var ZodSocialVerifyParamsSchema = import_zod8.z.object({
|
|
5353
|
+
_socialName: import_zod8.z.string(),
|
|
5354
|
+
proofs: import_zod8.z.array(
|
|
5355
|
+
import_zod8.z.object({
|
|
5356
|
+
claimInfo: import_zod8.z.object({
|
|
5357
|
+
provider: import_zod8.z.string(),
|
|
5358
|
+
parameters: import_zod8.z.string(),
|
|
5359
|
+
context: import_zod8.z.string()
|
|
5245
5360
|
}),
|
|
5246
|
-
signedClaim:
|
|
5247
|
-
claim:
|
|
5248
|
-
identifier:
|
|
5361
|
+
signedClaim: import_zod8.z.object({
|
|
5362
|
+
claim: import_zod8.z.object({
|
|
5363
|
+
identifier: import_zod8.z.string(),
|
|
5249
5364
|
owner: ZodAddressSchema,
|
|
5250
|
-
timestampS:
|
|
5251
|
-
epoch:
|
|
5365
|
+
timestampS: import_zod8.z.number(),
|
|
5366
|
+
epoch: import_zod8.z.number()
|
|
5252
5367
|
}),
|
|
5253
|
-
signatures:
|
|
5368
|
+
signatures: import_zod8.z.array(import_zod8.z.string())
|
|
5254
5369
|
})
|
|
5255
5370
|
})
|
|
5256
5371
|
)
|
|
5257
5372
|
});
|
|
5258
|
-
var ZodSolidityVerifierParametersSchema =
|
|
5259
|
-
version:
|
|
5373
|
+
var ZodSolidityVerifierParametersSchema = import_zod8.z.object({
|
|
5374
|
+
version: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5260
5375
|
message: "Version must be a hex string"
|
|
5261
5376
|
}),
|
|
5262
|
-
proofVerificationData:
|
|
5263
|
-
vkeyHash:
|
|
5377
|
+
proofVerificationData: import_zod8.z.object({
|
|
5378
|
+
vkeyHash: import_zod8.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5264
5379
|
message: "Invalid bytes32 hex string"
|
|
5265
5380
|
}),
|
|
5266
|
-
proof:
|
|
5381
|
+
proof: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5267
5382
|
message: "Proof must be a hex string"
|
|
5268
5383
|
}),
|
|
5269
|
-
publicInputs:
|
|
5270
|
-
|
|
5384
|
+
publicInputs: import_zod8.z.array(
|
|
5385
|
+
import_zod8.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5271
5386
|
message: "Each public input must be a valid bytes32 hex string"
|
|
5272
5387
|
})
|
|
5273
5388
|
)
|
|
5274
5389
|
}),
|
|
5275
|
-
committedInputs:
|
|
5390
|
+
committedInputs: import_zod8.z.string().refine((val) => val.startsWith("0x"), {
|
|
5276
5391
|
message: "Committed inputs must be a hex string"
|
|
5277
5392
|
}),
|
|
5278
|
-
serviceConfig:
|
|
5279
|
-
validityPeriodInSeconds:
|
|
5280
|
-
domain:
|
|
5281
|
-
scope:
|
|
5282
|
-
devMode:
|
|
5393
|
+
serviceConfig: import_zod8.z.object({
|
|
5394
|
+
validityPeriodInSeconds: import_zod8.z.number().int().nonnegative(),
|
|
5395
|
+
domain: import_zod8.z.string(),
|
|
5396
|
+
scope: import_zod8.z.string(),
|
|
5397
|
+
devMode: import_zod8.z.boolean()
|
|
5283
5398
|
})
|
|
5284
5399
|
});
|
|
5285
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
5400
|
+
var ZodZkPassportRegisterParamsSchema = import_zod8.z.object({
|
|
5286
5401
|
params: ZodSolidityVerifierParametersSchema,
|
|
5287
|
-
isIDCard:
|
|
5402
|
+
isIDCard: import_zod8.z.boolean()
|
|
5288
5403
|
});
|
|
5289
5404
|
|
|
5290
5405
|
// src/contracts/tx-limits/index.ts
|
|
5291
|
-
var
|
|
5292
|
-
var
|
|
5406
|
+
var import_neverthrow11 = require("neverthrow");
|
|
5407
|
+
var import_viem15 = require("viem");
|
|
5293
5408
|
|
|
5294
5409
|
// src/profile/validation.ts
|
|
5295
|
-
var
|
|
5296
|
-
var ZodUsdcBalanceParamsSchema =
|
|
5410
|
+
var import_zod9 = require("zod");
|
|
5411
|
+
var ZodUsdcBalanceParamsSchema = import_zod9.z.object({
|
|
5297
5412
|
address: ZodAddressSchema
|
|
5298
5413
|
});
|
|
5299
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
5414
|
+
var ZodUsdcAllowanceParamsSchema = import_zod9.z.object({
|
|
5300
5415
|
owner: ZodAddressSchema
|
|
5301
5416
|
});
|
|
5302
|
-
var ZodGetBalancesParamsSchema =
|
|
5417
|
+
var ZodGetBalancesParamsSchema = import_zod9.z.object({
|
|
5303
5418
|
address: ZodAddressSchema,
|
|
5304
5419
|
currency: ZodCurrencySchema
|
|
5305
5420
|
});
|
|
5306
|
-
var ZodTxLimitsParamsSchema =
|
|
5421
|
+
var ZodTxLimitsParamsSchema = import_zod9.z.object({
|
|
5307
5422
|
address: ZodAddressSchema,
|
|
5308
5423
|
currency: ZodCurrencySchema
|
|
5309
5424
|
});
|
|
5310
5425
|
|
|
5311
5426
|
// src/contracts/usdc/index.ts
|
|
5312
|
-
var
|
|
5313
|
-
var
|
|
5427
|
+
var import_neverthrow12 = require("neverthrow");
|
|
5428
|
+
var import_viem16 = require("viem");
|
|
5314
5429
|
|
|
5315
5430
|
// src/orders/internal/routing/routing.ts
|
|
5316
|
-
var
|
|
5431
|
+
var import_neverthrow13 = require("neverthrow");
|
|
5317
5432
|
var EPSILON = 0.25;
|
|
5318
5433
|
var RECOVERY_SCALE = 0.3;
|
|
5319
5434
|
var BOOTSTRAP_MAX_WEIGHT = 25;
|
|
@@ -5380,7 +5495,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5380
5495
|
attemptsLeft,
|
|
5381
5496
|
remainingCircles: remaining.length
|
|
5382
5497
|
});
|
|
5383
|
-
return (0,
|
|
5498
|
+
return (0, import_neverthrow13.errAsync)(
|
|
5384
5499
|
new OrderRoutingError("No eligible circles found", {
|
|
5385
5500
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5386
5501
|
})
|
|
@@ -5388,7 +5503,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5388
5503
|
}
|
|
5389
5504
|
const selected = selectCircle(remaining);
|
|
5390
5505
|
if (!selected) {
|
|
5391
|
-
return (0,
|
|
5506
|
+
return (0, import_neverthrow13.errAsync)(
|
|
5392
5507
|
new OrderRoutingError("No eligible circles found", {
|
|
5393
5508
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5394
5509
|
})
|
|
@@ -5406,11 +5521,11 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5406
5521
|
circleId: String(circleId),
|
|
5407
5522
|
error: String(error)
|
|
5408
5523
|
});
|
|
5409
|
-
return (0,
|
|
5524
|
+
return (0, import_neverthrow13.okAsync)(false);
|
|
5410
5525
|
}).andThen((isValid) => {
|
|
5411
5526
|
if (isValid) {
|
|
5412
5527
|
logger.info("circle validated successfully", { circleId: String(circleId) });
|
|
5413
|
-
return (0,
|
|
5528
|
+
return (0, import_neverthrow13.okAsync)(circleId);
|
|
5414
5529
|
}
|
|
5415
5530
|
logger.debug("circle failed validation, retrying", {
|
|
5416
5531
|
circleId: String(circleId),
|
|
@@ -5488,7 +5603,7 @@ function createOrderRouter(config) {
|
|
|
5488
5603
|
const logger = config.logger ?? noopLogger;
|
|
5489
5604
|
return {
|
|
5490
5605
|
selectCircle(params) {
|
|
5491
|
-
const currencyHex = (0,
|
|
5606
|
+
const currencyHex = (0, import_viem17.stringToHex)(params.currency, { size: 32 });
|
|
5492
5607
|
logger.info("selectCircle started", {
|
|
5493
5608
|
currency: params.currency,
|
|
5494
5609
|
user: params.user,
|
|
@@ -5520,8 +5635,8 @@ function createOrderRouter(config) {
|
|
|
5520
5635
|
}
|
|
5521
5636
|
|
|
5522
5637
|
// src/orders/normalize.ts
|
|
5523
|
-
var
|
|
5524
|
-
var
|
|
5638
|
+
var import_neverthrow14 = require("neverthrow");
|
|
5639
|
+
var import_viem18 = require("viem");
|
|
5525
5640
|
var ORDER_TYPE_MAP = {
|
|
5526
5641
|
[ORDER_TYPE.BUY]: "buy",
|
|
5527
5642
|
[ORDER_TYPE.SELL]: "sell",
|
|
@@ -5547,23 +5662,23 @@ function malformed(field, value, context) {
|
|
|
5547
5662
|
}
|
|
5548
5663
|
function mapOrderType(v, ctx) {
|
|
5549
5664
|
const t = ORDER_TYPE_MAP[v];
|
|
5550
|
-
return t ? (0,
|
|
5665
|
+
return t ? (0, import_neverthrow14.ok)(t) : (0, import_neverthrow14.err)(malformed("orderType", v, ctx));
|
|
5551
5666
|
}
|
|
5552
5667
|
function mapOrderStatus(v, ctx) {
|
|
5553
5668
|
const s = ORDER_STATUS_MAP[v];
|
|
5554
|
-
return s ? (0,
|
|
5669
|
+
return s ? (0, import_neverthrow14.ok)(s) : (0, import_neverthrow14.err)(malformed("status", v, ctx));
|
|
5555
5670
|
}
|
|
5556
5671
|
function mapDisputeStatus(v, ctx) {
|
|
5557
5672
|
const s = DISPUTE_STATUS_MAP[v];
|
|
5558
|
-
return s ? (0,
|
|
5673
|
+
return s ? (0, import_neverthrow14.ok)(s) : (0, import_neverthrow14.err)(malformed("disputeStatus", v, ctx));
|
|
5559
5674
|
}
|
|
5560
5675
|
function decodeCurrency(hex) {
|
|
5561
|
-
return (0,
|
|
5676
|
+
return (0, import_viem18.hexToString)(hex, { size: 32 }).replaceAll("\0", "");
|
|
5562
5677
|
}
|
|
5563
5678
|
function normalizeContractOrder(raw, details) {
|
|
5564
|
-
if (raw.id === 0n && (0,
|
|
5679
|
+
if (raw.id === 0n && (0, import_viem18.isAddressEqual)(raw.user, import_viem18.zeroAddress)) return (0, import_neverthrow14.ok)(null);
|
|
5565
5680
|
const ctx = { orderId: raw.id.toString() };
|
|
5566
|
-
return
|
|
5681
|
+
return import_neverthrow14.Result.combine([
|
|
5567
5682
|
mapOrderType(raw.orderType, ctx),
|
|
5568
5683
|
mapOrderStatus(raw.status, ctx),
|
|
5569
5684
|
mapDisputeStatus(raw.disputeInfo.status, ctx)
|
|
@@ -5594,7 +5709,7 @@ function normalizeContractOrder(raw, details) {
|
|
|
5594
5709
|
}
|
|
5595
5710
|
function normalizeSubgraphOrder(raw) {
|
|
5596
5711
|
const ctx = { orderId: raw.orderId };
|
|
5597
|
-
return
|
|
5712
|
+
return import_neverthrow14.Result.combine([
|
|
5598
5713
|
mapOrderType(raw.type, ctx),
|
|
5599
5714
|
mapOrderStatus(raw.status, ctx),
|
|
5600
5715
|
mapDisputeStatus(raw.disputeStatus, ctx)
|
|
@@ -5627,7 +5742,7 @@ function normalizeSubgraphOrder(raw) {
|
|
|
5627
5742
|
}
|
|
5628
5743
|
|
|
5629
5744
|
// src/orders/subgraph/index.ts
|
|
5630
|
-
var
|
|
5745
|
+
var import_neverthrow15 = require("neverthrow");
|
|
5631
5746
|
|
|
5632
5747
|
// src/orders/subgraph/queries.ts
|
|
5633
5748
|
var ORDERS_BY_USER_QUERY = (
|
|
@@ -5688,7 +5803,7 @@ function getOrdersForUser(subgraphUrl, userAddress, skip, limit, logger = noopLo
|
|
|
5688
5803
|
context: { data: d }
|
|
5689
5804
|
})
|
|
5690
5805
|
).andThen(
|
|
5691
|
-
(validated) =>
|
|
5806
|
+
(validated) => import_neverthrow15.Result.combine(validated.orders_collection.map(normalizeSubgraphOrder))
|
|
5692
5807
|
)
|
|
5693
5808
|
);
|
|
5694
5809
|
}
|
|
@@ -5842,7 +5957,7 @@ function createOrders(config) {
|
|
|
5842
5957
|
).andThen(
|
|
5843
5958
|
({ order, details }) => normalizeContractOrder(order, details).asyncAndThen((normalized) => {
|
|
5844
5959
|
if (!normalized) {
|
|
5845
|
-
return (0,
|
|
5960
|
+
return (0, import_neverthrow16.errAsync)(
|
|
5846
5961
|
new OrdersError("Order not found", {
|
|
5847
5962
|
code: "ORDER_NOT_FOUND",
|
|
5848
5963
|
context: { orderId: params.orderId.toString() }
|
|
@@ -5850,7 +5965,7 @@ function createOrders(config) {
|
|
|
5850
5965
|
);
|
|
5851
5966
|
}
|
|
5852
5967
|
logger.debug("getOrder resolved", { orderId: params.orderId.toString() });
|
|
5853
|
-
return (0,
|
|
5968
|
+
return (0, import_neverthrow16.okAsync)(normalized);
|
|
5854
5969
|
})
|
|
5855
5970
|
);
|
|
5856
5971
|
},
|