@morpho-dev/router 0.0.27 → 0.1.1
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.browser.d.cts +25 -26
- package/dist/index.browser.d.ts +25 -26
- package/dist/index.browser.js +35 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +35 -15
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +29 -28
- package/dist/index.node.d.ts +29 -28
- package/dist/index.node.js +75 -24
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +75 -24
- package/dist/index.node.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.mjs
CHANGED
|
@@ -40,7 +40,7 @@ function getChain(chainId) {
|
|
|
40
40
|
return chains[chainName];
|
|
41
41
|
}
|
|
42
42
|
var getWhitelistedChains = () => {
|
|
43
|
-
return [chains.ethereum, chains["ethereum-virtual-testnet"]];
|
|
43
|
+
return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
|
|
44
44
|
};
|
|
45
45
|
var chains = {
|
|
46
46
|
ethereum: {
|
|
@@ -419,12 +419,15 @@ var GetOffersQueryParams = z.object({
|
|
|
419
419
|
description: "Filter by multiple rate oracles (comma-separated)",
|
|
420
420
|
example: "0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"
|
|
421
421
|
}),
|
|
422
|
-
collateral_tuple: z.string().
|
|
423
|
-
/^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)
|
|
424
|
-
{
|
|
425
|
-
|
|
422
|
+
collateral_tuple: z.string().transform((val, ctx) => {
|
|
423
|
+
const pattern = /^(0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)(#0x[a-fA-F0-9]{40}(:0x[a-fA-F0-9]{40})?(:[0-9]+(\.[0-9]+)?)?)*$/;
|
|
424
|
+
if (!pattern.test(val)) {
|
|
425
|
+
ctx.addIssue({
|
|
426
|
+
code: "custom",
|
|
427
|
+
message: "collateral_tuple has an invalid format",
|
|
428
|
+
input: val
|
|
429
|
+
});
|
|
426
430
|
}
|
|
427
|
-
).transform((val, ctx) => {
|
|
428
431
|
return val.split("#").map((tuple) => {
|
|
429
432
|
const parts = tuple.split(":");
|
|
430
433
|
if (parts.length === 0 || !parts[0]) {
|
|
@@ -554,9 +557,23 @@ var MatchOffersQueryParams = z.object({
|
|
|
554
557
|
description: "The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell. If your intent is to sell, buy offers will be returned, and vice versa.",
|
|
555
558
|
example: "buy"
|
|
556
559
|
}),
|
|
557
|
-
chain_id: z.string().
|
|
558
|
-
|
|
559
|
-
|
|
560
|
+
chain_id: z.string().transform((val, ctx) => {
|
|
561
|
+
const numericLike = /^-?\d+$/.test(val);
|
|
562
|
+
if (!numericLike) {
|
|
563
|
+
ctx.addIssue({
|
|
564
|
+
code: "custom",
|
|
565
|
+
message: "chain_id has an invalid format",
|
|
566
|
+
input: val
|
|
567
|
+
});
|
|
568
|
+
ctx.addIssue({
|
|
569
|
+
code: "custom",
|
|
570
|
+
message: "Invalid input: expected number, received NaN",
|
|
571
|
+
input: val
|
|
572
|
+
});
|
|
573
|
+
return z.NEVER;
|
|
574
|
+
}
|
|
575
|
+
return Number.parseInt(val, 10);
|
|
576
|
+
}).pipe(z.number().positive()).meta({
|
|
560
577
|
description: "The blockchain network chain ID",
|
|
561
578
|
example: "1"
|
|
562
579
|
}),
|
|
@@ -568,12 +585,15 @@ var MatchOffersQueryParams = z.object({
|
|
|
568
585
|
example: "1000000000000000000"
|
|
569
586
|
}),
|
|
570
587
|
// Collateral filtering
|
|
571
|
-
collaterals: z.string().
|
|
572
|
-
/^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)
|
|
573
|
-
{
|
|
574
|
-
|
|
588
|
+
collaterals: z.string().transform((val, ctx) => {
|
|
589
|
+
const pattern = /^(0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)(#0x[a-fA-F0-9]{40}:0x[a-fA-F0-9]{40}:[0-9]+(\.[0-9]+)?)*$/;
|
|
590
|
+
if (!pattern.test(val)) {
|
|
591
|
+
ctx.addIssue({
|
|
592
|
+
code: "custom",
|
|
593
|
+
message: "Collaterals must be in format: asset:oracle:lltv#asset2:oracle2:lltv2. All fields are required for each collateral.",
|
|
594
|
+
input: val
|
|
595
|
+
});
|
|
575
596
|
}
|
|
576
|
-
).transform((val, ctx) => {
|
|
577
597
|
return val.split("#").map((collateral) => {
|
|
578
598
|
const parts = collateral.split(":");
|
|
579
599
|
if (parts.length !== 3) {
|
|
@@ -827,7 +847,7 @@ function connect(opts) {
|
|
|
827
847
|
if (u.protocol !== "http:" && u.protocol !== "https:") {
|
|
828
848
|
throw new InvalidUrlError(u.toString());
|
|
829
849
|
}
|
|
830
|
-
const headers = new Headers();
|
|
850
|
+
const headers = opts?.headers ?? new Headers();
|
|
831
851
|
headers.set("Content-Type", "application/json");
|
|
832
852
|
opts?.apiKey !== void 0 ? headers.set("X-API-Key", opts.apiKey) : null;
|
|
833
853
|
const config = {
|