@dynamic-labs/wallet-book 1.1.0-alpha.13 → 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 +7 -0
- package/package.json +4 -2
- package/src/components/WalletIcon.cjs +1 -0
- package/src/components/WalletIcon.js +1 -0
- package/src/hooks/useWalletBookCdn.cjs +22 -16
- package/src/hooks/useWalletBookCdn.js +22 -16
- package/src/hooks/useWalletBookContext.cjs +1 -0
- package/src/hooks/useWalletBookContext.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
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
|
+
|
|
2
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)
|
|
3
10
|
|
|
4
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/wallet-book",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
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,7 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"zod": "3.22.4",
|
|
29
|
-
"@dynamic-labs/logger": "1.1.0-alpha.
|
|
29
|
+
"@dynamic-labs/logger": "1.1.0-alpha.14",
|
|
30
|
+
"@dynamic-labs/utils": "1.1.0-alpha.14",
|
|
31
|
+
"util": "0.12.5"
|
|
30
32
|
},
|
|
31
33
|
"peerDependencies": {
|
|
32
34
|
"react": "^17.0.2 || ^18.0.0",
|
|
@@ -7,6 +7,7 @@ var react = require('react');
|
|
|
7
7
|
var getWalletIconUrl = require('../helpers/getWalletIconUrl.cjs');
|
|
8
8
|
var findWalletBookWallet = require('../helpers/findWalletBookWallet.cjs');
|
|
9
9
|
require('../helpers/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
10
11
|
require('../schemas/walletConnectSourceSchema.cjs');
|
|
11
12
|
require('../schemas/walletBookSchema.cjs');
|
|
12
13
|
require('../schemas/walletSchema.cjs');
|
|
@@ -3,6 +3,7 @@ import { useState, createElement, Fragment } from 'react';
|
|
|
3
3
|
import { getWalletIconUrl, getDefaultWalletIconUrl } from '../helpers/getWalletIconUrl.js';
|
|
4
4
|
import { findWalletBookWallet } from '../helpers/findWalletBookWallet.js';
|
|
5
5
|
import '../helpers/logger.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
6
7
|
import '../schemas/walletConnectSourceSchema.js';
|
|
7
8
|
import '../schemas/walletBookSchema.js';
|
|
8
9
|
import '../schemas/walletSchema.js';
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
6
|
var react = require('react');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
8
|
require('../schemas/walletConnectSourceSchema.cjs');
|
|
8
9
|
var walletBookSchema = require('../schemas/walletBookSchema.cjs');
|
|
9
10
|
require('../schemas/walletSchema.cjs');
|
|
@@ -16,23 +17,28 @@ const useWalletBookCdn = () => {
|
|
|
16
17
|
react.useEffect(() => {
|
|
17
18
|
const fetchWalletBook = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
const url = getWalletBookCdnUrl.getWalletBookCdnUrl();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const fn = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const res = yield fetch(url, { mode: 'cors' });
|
|
22
|
+
if (res.ok) {
|
|
23
|
+
const json = yield res.json();
|
|
24
|
+
try {
|
|
25
|
+
const parsedData = walletBookSchema.walletBookSchema.parse(json);
|
|
26
|
+
return parsedData;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
logger.logger.error('Error parsing wallet book data', e, json);
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
data = walletBookSchema.walletBookSchema.parse(walletBookFallbacks["default"]);
|
|
35
|
-
}
|
|
33
|
+
throw new Error(`Failed to fetch wallet book data from ${url} with status code ${res.status}`);
|
|
34
|
+
});
|
|
35
|
+
const data = yield utils.retryableFn(fn, {
|
|
36
|
+
fallbackValue: walletBookSchema.walletBookSchema.parse(walletBookFallbacks["default"]),
|
|
37
|
+
logger: logger.logger.createLogger('useWalletBookCdn'),
|
|
38
|
+
maxRetries: 3,
|
|
39
|
+
retryStrategy: 'timeout-and-rejection',
|
|
40
|
+
timeoutMs: 5000,
|
|
41
|
+
});
|
|
36
42
|
setWalletBook(data);
|
|
37
43
|
});
|
|
38
44
|
fetchWalletBook();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
|
+
import { retryableFn } from '@dynamic-labs/utils';
|
|
3
4
|
import '../schemas/walletConnectSourceSchema.js';
|
|
4
5
|
import { walletBookSchema } from '../schemas/walletBookSchema.js';
|
|
5
6
|
import '../schemas/walletSchema.js';
|
|
@@ -12,23 +13,28 @@ const useWalletBookCdn = () => {
|
|
|
12
13
|
useEffect(() => {
|
|
13
14
|
const fetchWalletBook = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
15
|
const url = getWalletBookCdnUrl();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const fn = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const res = yield fetch(url, { mode: 'cors' });
|
|
18
|
+
if (res.ok) {
|
|
19
|
+
const json = yield res.json();
|
|
20
|
+
try {
|
|
21
|
+
const parsedData = walletBookSchema.parse(json);
|
|
22
|
+
return parsedData;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
logger.error('Error parsing wallet book data', e, json);
|
|
26
|
+
throw e;
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
data = walletBookSchema.parse(walletBookFallbacks);
|
|
31
|
-
}
|
|
29
|
+
throw new Error(`Failed to fetch wallet book data from ${url} with status code ${res.status}`);
|
|
30
|
+
});
|
|
31
|
+
const data = yield retryableFn(fn, {
|
|
32
|
+
fallbackValue: walletBookSchema.parse(walletBookFallbacks),
|
|
33
|
+
logger: logger.createLogger('useWalletBookCdn'),
|
|
34
|
+
maxRetries: 3,
|
|
35
|
+
retryStrategy: 'timeout-and-rejection',
|
|
36
|
+
timeoutMs: 5000,
|
|
37
|
+
});
|
|
32
38
|
setWalletBook(data);
|
|
33
39
|
});
|
|
34
40
|
fetchWalletBook();
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
require('../../_virtual/_tslib.cjs');
|
|
7
7
|
require('../helpers/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
8
9
|
require('../schemas/walletConnectSourceSchema.cjs');
|
|
9
10
|
require('../schemas/walletBookSchema.cjs');
|
|
10
11
|
require('../schemas/walletSchema.cjs');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import '../../_virtual/_tslib.js';
|
|
3
3
|
import '../helpers/logger.js';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
4
5
|
import '../schemas/walletConnectSourceSchema.js';
|
|
5
6
|
import '../schemas/walletBookSchema.js';
|
|
6
7
|
import '../schemas/walletSchema.js';
|