@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.
@@ -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 Buffer.from(JSON.stringify(c)).toString("base64url");
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(Buffer.from(token, "base64url").toString());
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
- buildId: () => buildId,
1419
+ from: () => from2,
1421
1420
  types: () => types
1422
1421
  });
1423
1422
  var types = ["offer_created", "offer_matched", "offer_validation"];
1424
- function buildId(event) {
1425
- switch (event.type) {
1426
- case "offer_created":
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