@morpho-dev/router 0.0.27 → 0.1.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.
@@ -41,7 +41,7 @@ function getChain(chainId) {
41
41
  return chains[chainName];
42
42
  }
43
43
  var getWhitelistedChains = () => {
44
- return [chains.ethereum, chains["ethereum-virtual-testnet"]];
44
+ return [chains.ethereum, chains.base, chains["ethereum-virtual-testnet"]];
45
45
  };
46
46
  var chains = {
47
47
  ethereum: {
@@ -848,7 +848,7 @@ function connect(opts) {
848
848
  if (u.protocol !== "http:" && u.protocol !== "https:") {
849
849
  throw new InvalidUrlError(u.toString());
850
850
  }
851
- const headers = new Headers();
851
+ const headers = opts?.headers ?? new Headers();
852
852
  headers.set("Content-Type", "application/json");
853
853
  opts?.apiKey !== void 0 ? headers.set("X-API-Key", opts.apiKey) : null;
854
854
  const config = {
@@ -1625,7 +1625,8 @@ __export(Logger_exports, {
1625
1625
  LogLevelValues: () => LogLevelValues,
1626
1626
  defaultLogger: () => defaultLogger,
1627
1627
  getLogger: () => getLogger,
1628
- runWithLogger: () => runWithLogger
1628
+ runWithLogger: () => runWithLogger,
1629
+ silentLogger: () => silentLogger
1629
1630
  });
1630
1631
  var LogLevelValues = [
1631
1632
  "silent",
@@ -1636,20 +1637,50 @@ var LogLevelValues = [
1636
1637
  "error",
1637
1638
  "fatal"
1638
1639
  ];
1639
- function defaultLogger() {
1640
+ function defaultLogger(minLevel) {
1641
+ const threshold = minLevel ?? "trace";
1642
+ const levelIndexByName = LogLevelValues.reduce(
1643
+ (acc, lvl, idx) => {
1644
+ acc[lvl] = idx;
1645
+ return acc;
1646
+ },
1647
+ {}
1648
+ );
1649
+ const isEnabled = (methodLevel) => levelIndexByName[methodLevel] >= levelIndexByName[threshold];
1640
1650
  return {
1641
1651
  // biome-ignore lint/suspicious/noConsole: console is used for logging
1642
- trace: console.trace.bind(console),
1652
+ trace: isEnabled("trace") ? console.trace.bind(console) : () => {
1653
+ },
1643
1654
  // biome-ignore lint/suspicious/noConsole: console is used for logging
1644
- debug: console.debug.bind(console),
1655
+ debug: isEnabled("debug") ? console.debug.bind(console) : () => {
1656
+ },
1645
1657
  // biome-ignore lint/suspicious/noConsole: console is used for logging
1646
- info: console.info.bind(console),
1658
+ info: isEnabled("info") ? console.info.bind(console) : () => {
1659
+ },
1647
1660
  // biome-ignore lint/suspicious/noConsole: console is used for logging
1648
- warn: console.warn.bind(console),
1661
+ warn: isEnabled("warn") ? console.warn.bind(console) : () => {
1662
+ },
1649
1663
  // biome-ignore lint/suspicious/noConsole: console is used for logging
1650
- error: console.error.bind(console),
1651
- // biome-ignore lint/suspicious/noConsole: console.fatal does not exist
1652
- fatal: (...args) => console.error("[fatal]", ...args)
1664
+ error: isEnabled("error") ? console.error.bind(console) : () => {
1665
+ },
1666
+ fatal: isEnabled("fatal") ? (...args) => console.error("[fatal]", ...args) : () => {
1667
+ }
1668
+ };
1669
+ }
1670
+ function silentLogger() {
1671
+ return {
1672
+ trace: () => {
1673
+ },
1674
+ debug: () => {
1675
+ },
1676
+ info: () => {
1677
+ },
1678
+ warn: () => {
1679
+ },
1680
+ error: () => {
1681
+ },
1682
+ fatal: () => {
1683
+ }
1653
1684
  };
1654
1685
  }
1655
1686
  var loggerContext = new AsyncLocalStorage();