@morpho-org/blue-sdk 2.0.0-next.29 → 2.0.0-next.30

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/lib/errors.d.ts CHANGED
@@ -53,4 +53,5 @@ export declare namespace BlueErrors {
53
53
  export interface ErrorClass<E extends Error> {
54
54
  new (...args: any[]): E;
55
55
  }
56
+ export declare function _try<T, E extends Error>(accessor: () => Promise<T>, ...errorClasses: ErrorClass<E>[]): Promise<T | undefined>;
56
57
  export declare function _try<T, E extends Error>(accessor: () => T, ...errorClasses: ErrorClass<E>[]): T | undefined;
package/lib/errors.js CHANGED
@@ -103,13 +103,19 @@ var BlueErrors;
103
103
  BlueErrors.InsufficientCollateral = InsufficientCollateral;
104
104
  })(BlueErrors || (exports.BlueErrors = BlueErrors = {}));
105
105
  function _try(accessor, ...errorClasses) {
106
- try {
107
- return accessor();
108
- }
109
- catch (error) {
106
+ const maybeCatchError = (error) => {
110
107
  if (errorClasses.length === 0 ||
111
108
  errorClasses.some((errorClass) => error instanceof errorClass))
112
109
  return;
113
110
  throw error;
111
+ };
112
+ try {
113
+ const res = accessor();
114
+ if (res instanceof Promise)
115
+ return res.catch(maybeCatchError);
116
+ return res;
117
+ }
118
+ catch (error) {
119
+ return maybeCatchError(error);
114
120
  }
115
121
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/blue-sdk",
3
3
  "description": "Framework-agnostic package that defines Morpho-related entity classes (such as `Market`, `Token`, `Vault`).",
4
- "version": "2.0.0-next.29",
4
+ "version": "2.0.0-next.30",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Rubilmax <rmilon@gmail.com>"
@@ -21,14 +21,14 @@
21
21
  "@noble/hashes": "^1.5.0"
22
22
  },
23
23
  "peerDependencies": {
24
- "@morpho-org/morpho-ts": "^2.0.0-next.15"
24
+ "@morpho-org/morpho-ts": "^2.0.0-next.16"
25
25
  },
26
26
  "devDependencies": {
27
27
  "typescript": "^5.7.2",
28
28
  "viem": "^2.21.53",
29
29
  "vitest": "^2.1.8",
30
- "@morpho-org/morpho-ts": "^2.0.0-next.15",
31
- "@morpho-org/test": "^2.0.0-next.23"
30
+ "@morpho-org/morpho-ts": "^2.0.0-next.16",
31
+ "@morpho-org/test": "^2.0.0-next.24"
32
32
  },
33
33
  "scripts": {
34
34
  "prepublish": "$npm_execpath build",