@dynamic-labs/utils 1.1.0-alpha.12 → 1.1.0-alpha.14

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/CHANGELOG.md CHANGED
@@ -1,4 +1,29 @@
1
1
 
2
+ ## [1.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.13...v1.1.0-alpha.14) (2024-01-23)
3
+
4
+
5
+ ### Features
6
+
7
+ * add wallet-book retryable ([#4462](https://github.com/dynamic-labs/DynamicAuth/issues/4462)) ([513b1a6](https://github.com/dynamic-labs/DynamicAuth/commit/513b1a67d6c49624398ad4b0cdca4f5618c9583f))
8
+
9
+ ## [1.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.12...v1.1.0-alpha.13) (2024-01-23)
10
+
11
+
12
+ ### Features
13
+
14
+ * add createWalletClientFromWallet helper function ([#4416](https://github.com/dynamic-labs/DynamicAuth/issues/4416)) ([b384898](https://github.com/dynamic-labs/DynamicAuth/commit/b384898061bb3f9b38b2ed670b6650cfc1d4b429))
15
+ * add hardware wallets to wallet book ([#4445](https://github.com/dynamic-labs/DynamicAuth/issues/4445)) ([66c0f5b](https://github.com/dynamic-labs/DynamicAuth/commit/66c0f5b29a6a700099bb95a6f7622f6178e0bccf))
16
+ * add support for Argent Web and Mobile ([#4328](https://github.com/dynamic-labs/DynamicAuth/issues/4328)) ([bce20b8](https://github.com/dynamic-labs/DynamicAuth/commit/bce20b8f35a8630f2621f53a541a1acb06a38fc0))
17
+ * enable ledger for glow, solflare and backpack ([#4392](https://github.com/dynamic-labs/DynamicAuth/issues/4392)) ([fa7b992](https://github.com/dynamic-labs/DynamicAuth/commit/fa7b992f87ebc43560f87b43ac56f2cd9909b306))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * breaking changes script ([#4440](https://github.com/dynamic-labs/DynamicAuth/issues/4440)) ([446173d](https://github.com/dynamic-labs/DynamicAuth/commit/446173d074d652d81856c6412e304b46b1565320))
23
+ * broken help icon in create passkey view ([#4428](https://github.com/dynamic-labs/DynamicAuth/issues/4428)) ([e0ffc02](https://github.com/dynamic-labs/DynamicAuth/commit/e0ffc02ffea34b7ac3198ff6e1baf7f9907acddd))
24
+ * infinite loop when connecting with trust wallet ([#4448](https://github.com/dynamic-labs/DynamicAuth/issues/4448)) ([4e20edf](https://github.com/dynamic-labs/DynamicAuth/commit/4e20edf9abaabf20e5e9f9167b44d7f691e844f1))
25
+ * render wagmi elements based on react version ([#4453](https://github.com/dynamic-labs/DynamicAuth/issues/4453)) ([43c624c](https://github.com/dynamic-labs/DynamicAuth/commit/43c624ca996b0c51de1454910f19fdf908149938))
26
+
2
27
  ## [1.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.11...v1.1.0-alpha.12) (2024-01-18)
3
28
 
4
29
 
@@ -25,6 +25,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
25
25
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
26
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27
27
  });
28
- }
28
+ }
29
+
30
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
31
+ var e = new Error(message);
32
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
33
+ };
29
34
 
30
35
  exports.__awaiter = __awaiter;
@@ -21,6 +21,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
21
21
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
- }
24
+ }
25
+
26
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
27
+ var e = new Error(message);
28
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
29
+ };
25
30
 
26
31
  export { __awaiter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "1.1.0-alpha.12",
3
+ "version": "1.1.0-alpha.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,10 +26,10 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "peerDependencies": {
29
- "viem": "^1.19.13"
29
+ "viem": "^1.19.13 || ^2.2.0"
30
30
  },
31
31
  "dependencies": {
32
- "@dynamic-labs/logger": "1.1.0-alpha.12",
33
- "@dynamic-labs/types": "1.1.0-alpha.12"
32
+ "@dynamic-labs/logger": "1.1.0-alpha.14",
33
+ "@dynamic-labs/types": "1.1.0-alpha.14"
34
34
  }
35
35
  }
@@ -6,6 +6,7 @@ require('../errors/TransactionGasCannotBeSponsoredError.cjs');
6
6
  require('../errors/InsufficientFundsError.cjs');
7
7
  require('../logger/logger.cjs');
8
8
  var isMobile = require('../isMobile.cjs');
9
+ require('../../_virtual/_tslib.cjs');
9
10
  require('viem/chains');
10
11
 
11
12
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
@@ -2,6 +2,7 @@ import '../errors/TransactionGasCannotBeSponsoredError.js';
2
2
  import '../errors/InsufficientFundsError.js';
3
3
  import '../logger/logger.js';
4
4
  import { isSamsungBrowser } from '../isMobile.js';
5
+ import '../../_virtual/_tslib.js';
5
6
  import 'viem/chains';
6
7
 
7
8
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
@@ -6,7 +6,14 @@ var _tslib = require('../_virtual/_tslib.cjs');
6
6
 
7
7
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
8
8
  const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
9
- const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', } = options;
9
+ const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', logger, } = options;
10
+ logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
11
+ currentRetry,
12
+ fallbackValue,
13
+ maxRetries,
14
+ retryStrategy,
15
+ timeoutMs,
16
+ });
10
17
  const timeoutPromise = new Promise((_, reject) => {
11
18
  setTimeout(() => {
12
19
  reject(new Error('Timeout'));
@@ -17,7 +24,9 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
17
24
  return result;
18
25
  }
19
26
  catch (err) {
27
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
20
28
  if (currentRetry >= maxRetries) {
29
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
21
30
  if (fallbackValue instanceof Error) {
22
31
  throw fallbackValue;
23
32
  }
@@ -30,18 +39,24 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
30
39
  const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
31
40
  (retryStrategy === 'timeout-only' && isTimeout) ||
32
41
  (retryStrategy === 'rejection-only' && !isTimeout);
42
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
33
43
  if (!shouldRetry) {
34
44
  if (fallbackValue instanceof Error) {
45
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
35
46
  throw err;
36
47
  }
37
48
  else if (fallbackValue === FALLBACK_UNDEFINED) {
49
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
38
50
  return undefined;
39
51
  }
52
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
53
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
40
54
  return fallbackValue;
41
55
  }
42
56
  return retryableFn(fn, {
43
57
  currentRetry: currentRetry + 1,
44
58
  fallbackValue,
59
+ logger,
45
60
  maxRetries,
46
61
  retryStrategy,
47
62
  timeoutMs,
@@ -1,3 +1,4 @@
1
+ import { Logger } from '@dynamic-labs/logger';
1
2
  export declare const FALLBACK_UNDEFINED = "FALLBACK_UNDEFINED";
2
3
  export type RetryableFnOptions<T> = {
3
4
  /** Maximum number of retry attempts before returning fallbackValue */
@@ -10,5 +11,7 @@ export type RetryableFnOptions<T> = {
10
11
  fallbackValue?: T | Error | typeof FALLBACK_UNDEFINED;
11
12
  /** Configure whether the fn should be retried only on timeout, only on rejection, or both */
12
13
  retryStrategy?: 'timeout-only' | 'rejection-only' | 'timeout-and-rejection';
14
+ /** Set the logger to be used */
15
+ logger?: Logger | typeof console;
13
16
  };
14
17
  export declare const retryableFn: <T>(fn: () => Promise<T>, options?: RetryableFnOptions<T>) => Promise<T>;
@@ -2,7 +2,14 @@ import { __awaiter } from '../_virtual/_tslib.js';
2
2
 
3
3
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
4
4
  const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
5
- const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', } = options;
5
+ const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', logger, } = options;
6
+ logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
7
+ currentRetry,
8
+ fallbackValue,
9
+ maxRetries,
10
+ retryStrategy,
11
+ timeoutMs,
12
+ });
6
13
  const timeoutPromise = new Promise((_, reject) => {
7
14
  setTimeout(() => {
8
15
  reject(new Error('Timeout'));
@@ -13,7 +20,9 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
13
20
  return result;
14
21
  }
15
22
  catch (err) {
23
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
16
24
  if (currentRetry >= maxRetries) {
25
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
17
26
  if (fallbackValue instanceof Error) {
18
27
  throw fallbackValue;
19
28
  }
@@ -26,18 +35,24 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
26
35
  const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
27
36
  (retryStrategy === 'timeout-only' && isTimeout) ||
28
37
  (retryStrategy === 'rejection-only' && !isTimeout);
38
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
29
39
  if (!shouldRetry) {
30
40
  if (fallbackValue instanceof Error) {
41
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
31
42
  throw err;
32
43
  }
33
44
  else if (fallbackValue === FALLBACK_UNDEFINED) {
45
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
34
46
  return undefined;
35
47
  }
48
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
49
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
36
50
  return fallbackValue;
37
51
  }
38
52
  return retryableFn(fn, {
39
53
  currentRetry: currentRetry + 1,
40
54
  fallbackValue,
55
+ logger,
41
56
  maxRetries,
42
57
  retryStrategy,
43
58
  timeoutMs,