@morpho-dev/router 0.0.19 → 0.0.21
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 +15 -27
- package/dist/index.browser.d.ts +15 -27
- package/dist/index.browser.js +10 -20
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +10 -20
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +118 -69
- package/dist/index.node.d.ts +118 -69
- package/dist/index.node.js +1450 -56991
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +1455 -56971
- package/dist/index.node.mjs.map +1 -1
- package/package.json +6 -6
- package/dist/bytecode/erc20.txt +0 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { base, mainnet } from 'viem/chains';
|
|
|
4
4
|
import { parseUnits, maxUint256, formatUnits, parseAbi } from 'viem';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
import { createDocument } from 'zod-openapi';
|
|
7
|
+
import { Base64 } from 'js-base64';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -156,8 +157,6 @@ function* batch(array, batchSize) {
|
|
|
156
157
|
yield array.slice(i, i + batchSize);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
|
|
160
|
-
// src/utils/cursor.ts
|
|
161
160
|
function validateCursor(cursor) {
|
|
162
161
|
if (!cursor || typeof cursor !== "object") {
|
|
163
162
|
throw new Error("Cursor must be an object");
|
|
@@ -228,11 +227,11 @@ function validateCursor(cursor) {
|
|
|
228
227
|
return true;
|
|
229
228
|
}
|
|
230
229
|
function encodeCursor(c) {
|
|
231
|
-
return
|
|
230
|
+
return Base64.encodeURL(JSON.stringify(c));
|
|
232
231
|
}
|
|
233
232
|
function decodeCursor(token) {
|
|
234
233
|
if (!token) return null;
|
|
235
|
-
const decoded = JSON.parse(
|
|
234
|
+
const decoded = JSON.parse(Base64.decode(token));
|
|
236
235
|
validateCursor(decoded);
|
|
237
236
|
return decoded;
|
|
238
237
|
}
|
|
@@ -985,12 +984,12 @@ async function getApi(config, url) {
|
|
|
985
984
|
const pathname = url.pathname;
|
|
986
985
|
let action;
|
|
987
986
|
switch (true) {
|
|
988
|
-
case pathname.includes("/v1/offers"):
|
|
989
|
-
action = "get_offers";
|
|
990
|
-
break;
|
|
991
987
|
case pathname.includes("/v1/offers/match"):
|
|
992
988
|
action = "match_offers";
|
|
993
989
|
break;
|
|
990
|
+
case pathname.includes("/v1/offers"):
|
|
991
|
+
action = "get_offers";
|
|
992
|
+
break;
|
|
994
993
|
default:
|
|
995
994
|
throw new HttpGetOffersFailedError("Unknown endpoint", {
|
|
996
995
|
details: `Unsupported path: ${pathname}`
|
|
@@ -1417,22 +1416,13 @@ function memory(parameters) {
|
|
|
1417
1416
|
// src/RouterEvent.ts
|
|
1418
1417
|
var RouterEvent_exports = {};
|
|
1419
1418
|
__export(RouterEvent_exports, {
|
|
1420
|
-
|
|
1419
|
+
from: () => from2,
|
|
1421
1420
|
types: () => types
|
|
1422
1421
|
});
|
|
1423
1422
|
var types = ["offer_created", "offer_matched", "offer_validation"];
|
|
1424
|
-
function
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return `offer_created:${event.offer.hash.toLowerCase()}`;
|
|
1428
|
-
case "offer_matched":
|
|
1429
|
-
return `offer_matched:${event.offer.hash.toLowerCase()}`;
|
|
1430
|
-
case "offer_validation":
|
|
1431
|
-
return `offer_validation:${event.offer.hash.toLowerCase()}`;
|
|
1432
|
-
default: {
|
|
1433
|
-
throw new Error("Unhandled event type");
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1423
|
+
function from2(base) {
|
|
1424
|
+
const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1425
|
+
return { id, ...base };
|
|
1436
1426
|
}
|
|
1437
1427
|
|
|
1438
1428
|
// src/Validation.ts
|