@dynamic-labs/wallet-book 1.1.0-phantom.0 → 1.1.1
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 +152 -2
- package/README.md +5 -1
- package/_virtual/_tslib.cjs +6 -1
- package/_virtual/_tslib.js +6 -1
- package/package.json +4 -2
- package/src/build/index.d.ts +2 -0
- package/src/build/sources/walletConnect/index.d.ts +12 -10
- package/src/components/BrandIcon.cjs +25 -0
- package/src/components/BrandIcon.d.ts +8 -0
- package/src/components/BrandIcon.js +21 -0
- package/src/components/WalletIcon.cjs +2 -1
- package/src/components/WalletIcon.js +2 -1
- package/src/components/index.d.ts +1 -0
- package/src/helpers/findWalletBookWallet.cjs +0 -2
- package/src/helpers/findWalletBookWallet.d.ts +2 -0
- package/src/helpers/findWalletBookWallet.js +0 -2
- package/src/helpers/findWalletGroup.d.ts +9 -0
- package/src/helpers/findWalletGroupOverride.cjs +13 -0
- package/src/helpers/findWalletGroupOverride.d.ts +3 -0
- package/src/helpers/findWalletGroupOverride.js +9 -0
- package/src/helpers/getBrandIconUrl.cjs +17 -0
- package/src/helpers/getBrandIconUrl.d.ts +2 -0
- package/src/helpers/getBrandIconUrl.js +13 -0
- package/src/helpers/getWalletBookWallet.cjs +18 -6
- package/src/helpers/getWalletBookWallet.js +18 -6
- package/src/helpers/getWalletIconUrl.cjs +3 -6
- package/src/helpers/getWalletIconUrl.js +3 -6
- package/src/helpers/index.d.ts +2 -0
- package/src/helpers/normalizeWalletName.cjs +7 -0
- package/src/helpers/normalizeWalletName.js +3 -0
- package/src/hooks/useWalletBookCdn.cjs +22 -16
- package/src/hooks/useWalletBookCdn.d.ts +11 -0
- package/src/hooks/useWalletBookCdn.js +22 -16
- package/src/hooks/useWalletBookContext.cjs +2 -0
- package/src/hooks/useWalletBookContext.js +2 -0
- package/src/index.cjs +6 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +3 -0
- package/src/schemas/walletBookSchema.d.ts +185 -8
- package/src/schemas/walletGroup.cjs +6 -0
- package/src/schemas/walletGroup.d.ts +112 -2
- package/src/schemas/walletGroup.js +6 -0
- package/src/schemas/walletSchema.cjs +25 -20
- package/src/schemas/walletSchema.d.ts +41 -4
- package/src/schemas/walletSchema.js +25 -21
- package/wallet-book-fallbacks.cjs +30 -9
- package/wallet-book-fallbacks.js +30 -9
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { getWalletBookWallet } from './getWalletBookWallet.js';
|
|
2
|
+
import { getBrandIconUrl } from './getBrandIconUrl.js';
|
|
2
3
|
import { logger } from './logger.js';
|
|
3
4
|
import { renderTemplate } from './renderTemplate.js';
|
|
4
5
|
|
|
5
6
|
const getWalletIconUrl = (walletBook, walletKey) => {
|
|
6
|
-
var _a, _b;
|
|
7
7
|
try {
|
|
8
8
|
const walletData = getWalletBookWallet(walletBook, walletKey);
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
if ((_b = walletData === null || walletData === void 0 ? void 0 : walletData.brand) === null || _b === void 0 ? void 0 : _b.imageId) {
|
|
13
|
-
return renderTemplate('walletConnectUrl', walletData.brand.imageId);
|
|
9
|
+
if (walletData === null || walletData === void 0 ? void 0 : walletData.brand) {
|
|
10
|
+
return getBrandIconUrl(walletData.brand);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
catch (err) {
|
package/src/helpers/index.d.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const normalizeWalletName = (name) => { var _a; return (_a = name === null || name === void 0 ? void 0 : name.toLowerCase().replace(/\W/g, '')) !== null && _a !== void 0 ? _a : 'undefined-wallet'; };
|
|
6
|
+
|
|
7
|
+
exports.normalizeWalletName = normalizeWalletName;
|
|
@@ -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: 30000,
|
|
41
|
+
});
|
|
36
42
|
setWalletBook(data);
|
|
37
43
|
});
|
|
38
44
|
fetchWalletBook();
|
|
@@ -8,6 +8,15 @@ export declare const useWalletBookCdn: () => {
|
|
|
8
8
|
primaryColor?: string | undefined;
|
|
9
9
|
spriteId?: string | undefined;
|
|
10
10
|
} | undefined;
|
|
11
|
+
walletOverrides?: Record<string, {
|
|
12
|
+
brand?: {
|
|
13
|
+
alt?: string | undefined;
|
|
14
|
+
imageId?: string | undefined;
|
|
15
|
+
primaryColor?: string | undefined;
|
|
16
|
+
spriteId?: string | undefined;
|
|
17
|
+
} | undefined;
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
}> | undefined;
|
|
11
20
|
}>;
|
|
12
21
|
wallets: Record<string, {
|
|
13
22
|
name: string;
|
|
@@ -17,6 +26,7 @@ export declare const useWalletBookCdn: () => {
|
|
|
17
26
|
primaryColor?: string | undefined;
|
|
18
27
|
spriteId?: string | undefined;
|
|
19
28
|
} | undefined;
|
|
29
|
+
chainGroup?: string | undefined;
|
|
20
30
|
chains?: string[] | undefined;
|
|
21
31
|
desktop?: {
|
|
22
32
|
chromeId?: string | undefined;
|
|
@@ -60,5 +70,6 @@ export declare const useWalletBookCdn: () => {
|
|
|
60
70
|
walletConnect?: {
|
|
61
71
|
sdks?: string[] | undefined;
|
|
62
72
|
} | undefined;
|
|
73
|
+
walletGroup?: string | undefined;
|
|
63
74
|
}>;
|
|
64
75
|
};
|
|
@@ -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: 30000,
|
|
37
|
+
});
|
|
32
38
|
setWalletBook(data);
|
|
33
39
|
});
|
|
34
40
|
fetchWalletBook();
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
|
+
require('../../_virtual/_tslib.cjs');
|
|
6
7
|
require('../helpers/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
7
9
|
require('../schemas/walletConnectSourceSchema.cjs');
|
|
8
10
|
require('../schemas/walletBookSchema.cjs');
|
|
9
11
|
require('../schemas/walletSchema.cjs');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
+
import '../../_virtual/_tslib.js';
|
|
2
3
|
import '../helpers/logger.js';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
3
5
|
import '../schemas/walletConnectSourceSchema.js';
|
|
4
6
|
import '../schemas/walletBookSchema.js';
|
|
5
7
|
import '../schemas/walletSchema.js';
|
package/src/index.cjs
CHANGED
|
@@ -11,10 +11,13 @@ require('./helpers/logger.cjs');
|
|
|
11
11
|
var getWalletGroup = require('./helpers/getWalletGroup.cjs');
|
|
12
12
|
var findWalletGroup = require('./helpers/findWalletGroup.cjs');
|
|
13
13
|
var getWalletBookCdnUrl = require('./helpers/getWalletBookCdnUrl.cjs');
|
|
14
|
+
var getBrandIconUrl = require('./helpers/getBrandIconUrl.cjs');
|
|
15
|
+
var findWalletGroupOverride = require('./helpers/findWalletGroupOverride.cjs');
|
|
14
16
|
var useWalletBookCdn = require('./hooks/useWalletBookCdn.cjs');
|
|
15
17
|
var useWalletBookContext = require('./hooks/useWalletBookContext.cjs');
|
|
16
18
|
var WalletIcon = require('./components/WalletIcon.cjs');
|
|
17
19
|
var WalletBookContext = require('./components/WalletBookContext.cjs');
|
|
20
|
+
var BrandIcon = require('./components/BrandIcon.cjs');
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
|
|
@@ -26,7 +29,10 @@ exports.findWalletBookWallet = findWalletBookWallet.findWalletBookWallet;
|
|
|
26
29
|
exports.getWalletGroup = getWalletGroup.getWalletGroup;
|
|
27
30
|
exports.findWalletGroup = findWalletGroup.findWalletGroup;
|
|
28
31
|
exports.getWalletBookCdnUrl = getWalletBookCdnUrl.getWalletBookCdnUrl;
|
|
32
|
+
exports.getBrandIconUrl = getBrandIconUrl.getBrandIconUrl;
|
|
33
|
+
exports.findWalletGroupOverride = findWalletGroupOverride.findWalletGroupOverride;
|
|
29
34
|
exports.useWalletBookCdn = useWalletBookCdn.useWalletBookCdn;
|
|
30
35
|
exports.useWalletBookContext = useWalletBookContext.useWalletBookContext;
|
|
31
36
|
exports.WalletIcon = WalletIcon.WalletIcon;
|
|
32
37
|
exports.WalletBookContextProvider = WalletBookContext.WalletBookContextProvider;
|
|
38
|
+
exports.BrandIcon = BrandIcon.BrandIcon;
|
package/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { WalletLinks } from './helpers';
|
|
|
7
7
|
/**
|
|
8
8
|
* HELPERS
|
|
9
9
|
*/
|
|
10
|
-
export { getWalletBookWallet, getWalletIconUrl, getWalletLinks, getWalletPrimaryColor, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, } from './helpers';
|
|
10
|
+
export { getWalletBookWallet, getWalletIconUrl, getWalletLinks, getWalletPrimaryColor, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, getBrandIconUrl, findWalletGroupOverride, } from './helpers';
|
|
11
11
|
/**
|
|
12
12
|
* HOOKS
|
|
13
13
|
*/
|
|
@@ -15,4 +15,4 @@ export { useWalletBookCdn, useWalletBookContext } from './hooks';
|
|
|
15
15
|
/**
|
|
16
16
|
* COMPONENTS
|
|
17
17
|
*/
|
|
18
|
-
export { WalletIcon, WalletBookContextProvider } from './components';
|
|
18
|
+
export { WalletIcon, WalletBookContextProvider, BrandIcon } from './components';
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,10 @@ import './helpers/logger.js';
|
|
|
7
7
|
export { getWalletGroup } from './helpers/getWalletGroup.js';
|
|
8
8
|
export { findWalletGroup } from './helpers/findWalletGroup.js';
|
|
9
9
|
export { getWalletBookCdnUrl } from './helpers/getWalletBookCdnUrl.js';
|
|
10
|
+
export { getBrandIconUrl } from './helpers/getBrandIconUrl.js';
|
|
11
|
+
export { findWalletGroupOverride } from './helpers/findWalletGroupOverride.js';
|
|
10
12
|
export { useWalletBookCdn } from './hooks/useWalletBookCdn.js';
|
|
11
13
|
export { useWalletBookContext } from './hooks/useWalletBookContext.js';
|
|
12
14
|
export { WalletIcon } from './components/WalletIcon.js';
|
|
13
15
|
export { WalletBookContextProvider } from './components/WalletBookContext.js';
|
|
16
|
+
export { BrandIcon } from './components/BrandIcon.js';
|