@dynamic-labs/utils 1.1.0-alpha.20 → 1.1.0-alpha.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/CHANGELOG.md +14 -0
- package/package.json +3 -3
- package/src/retryableFn.cjs +9 -2
- package/src/retryableFn.d.ts +2 -0
- package/src/retryableFn.js +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [1.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.20...v1.1.0-alpha.21) (2024-02-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add phantom redirect handling context ([#4479](https://github.com/dynamic-labs/DynamicAuth/issues/4479)) ([e0218ee](https://github.com/dynamic-labs/DynamicAuth/commit/e0218eec1a67787f5c0e7483d542a5f773e911ef))
|
|
8
|
+
* add signPsbt method to bitcoin wallet connectors ([dfdc0fe](https://github.com/dynamic-labs/DynamicAuth/commit/dfdc0fe0e6894c1307b286e89b43a4c58a8808f3))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* relax passkey feature detection check in sdk to avoid false nega… ([#4556](https://github.com/dynamic-labs/DynamicAuth/issues/4556)) ([4554f7d](https://github.com/dynamic-labs/DynamicAuth/commit/4554f7d7c5339859481cdecca95a9c07fae4ba5c))
|
|
14
|
+
* workaround braavos undefined selectedWallet on chainChange event ([#4552](https://github.com/dynamic-labs/DynamicAuth/issues/4552)) ([aa35df0](https://github.com/dynamic-labs/DynamicAuth/commit/aa35df0e894feafa0606aa1c87bd3d3879ebc594))
|
|
15
|
+
|
|
2
16
|
## [1.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.19...v1.1.0-alpha.20) (2024-01-31)
|
|
3
17
|
|
|
4
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.21",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"viem": "^1.19.13 || ^2.2.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dynamic-labs/logger": "1.1.0-alpha.
|
|
33
|
-
"@dynamic-labs/types": "1.1.0-alpha.
|
|
32
|
+
"@dynamic-labs/logger": "1.1.0-alpha.21",
|
|
33
|
+
"@dynamic-labs/types": "1.1.0-alpha.21"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/retryableFn.cjs
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
+
require('./errors/TransactionGasCannotBeSponsoredError.cjs');
|
|
7
|
+
require('./errors/InsufficientFundsError.cjs');
|
|
8
|
+
require('./logger/logger.cjs');
|
|
9
|
+
var sleep = require('./sleep/sleep.cjs');
|
|
10
|
+
require('viem/chains');
|
|
6
11
|
|
|
7
12
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
8
13
|
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', logger, } = options;
|
|
14
|
+
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, logger, } = options;
|
|
10
15
|
logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
|
|
11
16
|
currentRetry,
|
|
12
17
|
fallbackValue,
|
|
@@ -35,7 +40,7 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
|
|
|
35
40
|
}
|
|
36
41
|
return fallbackValue;
|
|
37
42
|
}
|
|
38
|
-
const isTimeout = err.message === 'Timeout';
|
|
43
|
+
const isTimeout = (err === null || err === void 0 ? void 0 : err.message) === 'Timeout';
|
|
39
44
|
const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
|
|
40
45
|
(retryStrategy === 'timeout-only' && isTimeout) ||
|
|
41
46
|
(retryStrategy === 'rejection-only' && !isTimeout);
|
|
@@ -53,6 +58,8 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
|
|
|
53
58
|
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
|
|
54
59
|
return fallbackValue;
|
|
55
60
|
}
|
|
61
|
+
if (retryIntervalMs)
|
|
62
|
+
yield sleep.sleep(retryIntervalMs);
|
|
56
63
|
return retryableFn(fn, {
|
|
57
64
|
currentRetry: currentRetry + 1,
|
|
58
65
|
fallbackValue,
|
package/src/retryableFn.d.ts
CHANGED
|
@@ -13,5 +13,7 @@ export type RetryableFnOptions<T> = {
|
|
|
13
13
|
retryStrategy?: 'timeout-only' | 'rejection-only' | 'timeout-and-rejection';
|
|
14
14
|
/** Set the logger to be used */
|
|
15
15
|
logger?: Logger | typeof console;
|
|
16
|
+
/** Ms to wait before a retry */
|
|
17
|
+
retryIntervalMs?: number;
|
|
16
18
|
};
|
|
17
19
|
export declare const retryableFn: <T>(fn: () => Promise<T>, options?: RetryableFnOptions<T>) => Promise<T>;
|
package/src/retryableFn.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import './errors/TransactionGasCannotBeSponsoredError.js';
|
|
3
|
+
import './errors/InsufficientFundsError.js';
|
|
4
|
+
import './logger/logger.js';
|
|
5
|
+
import { sleep } from './sleep/sleep.js';
|
|
6
|
+
import 'viem/chains';
|
|
2
7
|
|
|
3
8
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
4
9
|
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', logger, } = options;
|
|
10
|
+
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, logger, } = options;
|
|
6
11
|
logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
|
|
7
12
|
currentRetry,
|
|
8
13
|
fallbackValue,
|
|
@@ -31,7 +36,7 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
|
|
|
31
36
|
}
|
|
32
37
|
return fallbackValue;
|
|
33
38
|
}
|
|
34
|
-
const isTimeout = err.message === 'Timeout';
|
|
39
|
+
const isTimeout = (err === null || err === void 0 ? void 0 : err.message) === 'Timeout';
|
|
35
40
|
const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
|
|
36
41
|
(retryStrategy === 'timeout-only' && isTimeout) ||
|
|
37
42
|
(retryStrategy === 'rejection-only' && !isTimeout);
|
|
@@ -49,6 +54,8 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
|
|
|
49
54
|
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
|
|
50
55
|
return fallbackValue;
|
|
51
56
|
}
|
|
57
|
+
if (retryIntervalMs)
|
|
58
|
+
yield sleep(retryIntervalMs);
|
|
52
59
|
return retryableFn(fn, {
|
|
53
60
|
currentRetry: currentRetry + 1,
|
|
54
61
|
fallbackValue,
|