@dynamic-labs/wallet-book 0.19.0-alpha.8 → 0.19.0
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 +321 -0
- package/README.md +34 -0
- package/package.json +3 -3
- package/src/build/index.d.ts +50 -41
- package/src/build/sources/firstParty/index.d.ts +2 -2
- package/src/build/sources/index.d.ts +4 -4
- package/src/build/sources/walletConnect/index.d.ts +100 -91
- package/src/build/sources/walletConnect/preprocessors.d.ts +13 -13
- package/src/build/sources/walletConnectOverrides/index.d.ts +249 -249
- package/src/build/sources/walletGroups/index.d.ts +2 -2
- package/src/components/WalletBookContext.cjs +3 -3
- package/src/components/WalletBookContext.d.ts +9 -9
- package/src/components/WalletBookContext.js +3 -3
- package/src/components/WalletIcon.cjs +19 -19
- package/src/components/WalletIcon.d.ts +8 -8
- package/src/components/WalletIcon.js +19 -19
- package/src/components/index.d.ts +2 -2
- package/src/helpers/findWalletBookWallet.cjs +9 -9
- package/src/helpers/findWalletBookWallet.d.ts +44 -35
- package/src/helpers/findWalletBookWallet.js +9 -9
- package/src/helpers/findWalletGroup.cjs +8 -8
- package/src/helpers/findWalletGroup.d.ts +11 -11
- package/src/helpers/findWalletGroup.js +8 -8
- package/src/helpers/getWalletBookCdnUrl.cjs +8 -8
- package/src/helpers/getWalletBookCdnUrl.d.ts +1 -1
- package/src/helpers/getWalletBookCdnUrl.js +8 -8
- package/src/helpers/getWalletBookWallet.cjs +6 -6
- package/src/helpers/getWalletBookWallet.d.ts +2 -2
- package/src/helpers/getWalletBookWallet.js +6 -6
- package/src/helpers/getWalletGroup.cjs +5 -5
- package/src/helpers/getWalletGroup.d.ts +3 -3
- package/src/helpers/getWalletGroup.js +5 -5
- package/src/helpers/getWalletIconUrl.cjs +23 -23
- package/src/helpers/getWalletIconUrl.d.ts +3 -3
- package/src/helpers/getWalletIconUrl.js +23 -23
- package/src/helpers/getWalletLinks.cjs +26 -26
- package/src/helpers/getWalletLinks.d.ts +10 -10
- package/src/helpers/getWalletLinks.js +26 -26
- package/src/helpers/getWalletPrimaryColor.cjs +3 -3
- package/src/helpers/getWalletPrimaryColor.d.ts +2 -2
- package/src/helpers/getWalletPrimaryColor.js +3 -3
- package/src/helpers/index.d.ts +11 -11
- package/src/helpers/logger.d.ts +2 -2
- package/src/helpers/normalizeWalletName.d.ts +1 -1
- package/src/helpers/renderTemplate.cjs +13 -13
- package/src/helpers/renderTemplate.d.ts +12 -12
- package/src/helpers/renderTemplate.js +13 -13
- package/src/hooks/index.d.ts +2 -2
- package/src/hooks/useWalletBookCdn.cjs +27 -27
- package/src/hooks/useWalletBookCdn.d.ts +55 -46
- package/src/hooks/useWalletBookCdn.js +27 -27
- package/src/hooks/useWalletBookContext.cjs +6 -6
- package/src/hooks/useWalletBookContext.d.ts +1 -1
- package/src/hooks/useWalletBookContext.js +6 -6
- package/src/index.d.ts +18 -18
- package/src/schemas/index.d.ts +3 -3
- package/src/schemas/utils/filterEmptyObject.cjs +5 -5
- package/src/schemas/utils/filterEmptyObject.d.ts +6 -6
- package/src/schemas/utils/filterEmptyObject.js +5 -5
- package/src/schemas/utils/nonEmptyString.cjs +3 -3
- package/src/schemas/utils/nonEmptyString.d.ts +5 -5
- package/src/schemas/utils/nonEmptyString.js +3 -3
- package/src/schemas/utils/nonEmptyStringArray.cjs +3 -3
- package/src/schemas/utils/nonEmptyStringArray.d.ts +5 -5
- package/src/schemas/utils/nonEmptyStringArray.js +3 -3
- package/src/schemas/utils/processWalletConnectNativeUrl.d.ts +1 -1
- package/src/schemas/utils/sortKeys.d.ts +5 -5
- package/src/schemas/utils/transformAndroidId.cjs +16 -16
- package/src/schemas/utils/transformAndroidId.d.ts +1 -1
- package/src/schemas/utils/transformAndroidId.js +16 -16
- package/src/schemas/utils/transformChromeExtensionId.cjs +13 -13
- package/src/schemas/utils/transformChromeExtensionId.d.ts +1 -1
- package/src/schemas/utils/transformChromeExtensionId.js +13 -13
- package/src/schemas/utils/transformEdgeExtensionId.cjs +13 -13
- package/src/schemas/utils/transformEdgeExtensionId.d.ts +1 -1
- package/src/schemas/utils/transformEdgeExtensionId.js +13 -13
- package/src/schemas/utils/transformFirefoxExtensionId.cjs +13 -13
- package/src/schemas/utils/transformFirefoxExtensionId.d.ts +1 -1
- package/src/schemas/utils/transformFirefoxExtensionId.js +13 -13
- package/src/schemas/utils/transformIosId.cjs +20 -20
- package/src/schemas/utils/transformIosId.d.ts +1 -1
- package/src/schemas/utils/transformIosId.js +20 -20
- package/src/schemas/walletBookSchema.cjs +5 -5
- package/src/schemas/walletBookSchema.d.ts +862 -714
- package/src/schemas/walletBookSchema.js +5 -5
- package/src/schemas/walletConnectSourceSchema.cjs +64 -64
- package/src/schemas/walletConnectSourceSchema.d.ts +504 -504
- package/src/schemas/walletConnectSourceSchema.js +64 -64
- package/src/schemas/walletGroup.cjs +22 -22
- package/src/schemas/walletGroup.d.ts +50 -50
- package/src/schemas/walletGroup.js +22 -22
- package/src/schemas/walletSchema.cjs +88 -66
- package/src/schemas/walletSchema.d.ts +351 -256
- package/src/schemas/walletSchema.js +88 -66
- package/wallet-book-fallbacks.cjs +82 -1
- package/wallet-book-fallbacks.js +82 -1
package/src/helpers/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './getWalletIconUrl';
|
|
2
|
-
export * from './getWalletBookWallet';
|
|
3
|
-
export * from './getWalletLinks';
|
|
4
|
-
export * from './getWalletPrimaryColor';
|
|
5
|
-
export * from './normalizeWalletName';
|
|
6
|
-
export * from './renderTemplate';
|
|
7
|
-
export * from './findWalletBookWallet';
|
|
8
|
-
export * from './logger';
|
|
9
|
-
export * from './getWalletGroup';
|
|
10
|
-
export * from './findWalletGroup';
|
|
11
|
-
export * from './getWalletBookCdnUrl';
|
|
1
|
+
export * from './getWalletIconUrl';
|
|
2
|
+
export * from './getWalletBookWallet';
|
|
3
|
+
export * from './getWalletLinks';
|
|
4
|
+
export * from './getWalletPrimaryColor';
|
|
5
|
+
export * from './normalizeWalletName';
|
|
6
|
+
export * from './renderTemplate';
|
|
7
|
+
export * from './findWalletBookWallet';
|
|
8
|
+
export * from './logger';
|
|
9
|
+
export * from './getWalletGroup';
|
|
10
|
+
export * from './findWalletGroup';
|
|
11
|
+
export * from './getWalletBookCdnUrl';
|
package/src/helpers/logger.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Logger } from '@dynamic-labs/logger';
|
|
2
|
-
export declare const logger: Logger;
|
|
1
|
+
import { Logger } from '@dynamic-labs/logger';
|
|
2
|
+
export declare const logger: Logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const normalizeWalletName: (name?: string) => string;
|
|
1
|
+
export declare const normalizeWalletName: (name?: string) => string;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const TEMPLATES = {
|
|
6
|
-
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
7
|
-
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
8
|
-
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
9
|
-
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
10
|
-
iconicUrl: 'https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}',
|
|
11
|
-
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
12
|
-
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
13
|
-
};
|
|
14
|
-
const renderTemplate = (templateName, data) => {
|
|
15
|
-
if (!data)
|
|
16
|
-
return undefined;
|
|
17
|
-
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
5
|
+
const TEMPLATES = {
|
|
6
|
+
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
7
|
+
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
8
|
+
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
9
|
+
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
10
|
+
iconicUrl: 'https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}',
|
|
11
|
+
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
12
|
+
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
13
|
+
};
|
|
14
|
+
const renderTemplate = (templateName, data) => {
|
|
15
|
+
if (!data)
|
|
16
|
+
return undefined;
|
|
17
|
+
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
exports.renderTemplate = renderTemplate;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
declare const TEMPLATES: {
|
|
2
|
-
readonly androidUrl: "https://play.google.com/store/apps/details?id={{id}}";
|
|
3
|
-
readonly chromeUrl: "https://chrome.google.com/webstore/detail/{{id}}";
|
|
4
|
-
readonly edgeUrl: "https://microsoftedge.microsoft.com/addons/detail/{{id}}";
|
|
5
|
-
readonly firefoxUrl: "https://addons.mozilla.org/en-US/firefox/addon/{{id}}";
|
|
6
|
-
readonly iconicUrl: "https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}";
|
|
7
|
-
readonly iosUrl: "https://apps.apple.com/app/apple-store/{{id}}";
|
|
8
|
-
readonly walletConnectUrl: "https://registry.walletconnect.org/v2/logo/sm/{{id}}";
|
|
9
|
-
};
|
|
10
|
-
export type TemplateName = keyof typeof TEMPLATES;
|
|
11
|
-
export declare const renderTemplate: (templateName: TemplateName, data: any) => string | undefined;
|
|
12
|
-
export {};
|
|
1
|
+
declare const TEMPLATES: {
|
|
2
|
+
readonly androidUrl: "https://play.google.com/store/apps/details?id={{id}}";
|
|
3
|
+
readonly chromeUrl: "https://chrome.google.com/webstore/detail/{{id}}";
|
|
4
|
+
readonly edgeUrl: "https://microsoftedge.microsoft.com/addons/detail/{{id}}";
|
|
5
|
+
readonly firefoxUrl: "https://addons.mozilla.org/en-US/firefox/addon/{{id}}";
|
|
6
|
+
readonly iconicUrl: "https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}";
|
|
7
|
+
readonly iosUrl: "https://apps.apple.com/app/apple-store/{{id}}";
|
|
8
|
+
readonly walletConnectUrl: "https://registry.walletconnect.org/v2/logo/sm/{{id}}";
|
|
9
|
+
};
|
|
10
|
+
export type TemplateName = keyof typeof TEMPLATES;
|
|
11
|
+
export declare const renderTemplate: (templateName: TemplateName, data: any) => string | undefined;
|
|
12
|
+
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const TEMPLATES = {
|
|
2
|
-
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
3
|
-
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
4
|
-
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
5
|
-
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
6
|
-
iconicUrl: 'https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}',
|
|
7
|
-
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
8
|
-
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
9
|
-
};
|
|
10
|
-
const renderTemplate = (templateName, data) => {
|
|
11
|
-
if (!data)
|
|
12
|
-
return undefined;
|
|
13
|
-
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
1
|
+
const TEMPLATES = {
|
|
2
|
+
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
3
|
+
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
4
|
+
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
5
|
+
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
6
|
+
iconicUrl: 'https://iconic.dynamic-static-assets.com/icons/sprite.svg#{{id}}',
|
|
7
|
+
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
8
|
+
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
9
|
+
};
|
|
10
|
+
const renderTemplate = (templateName, data) => {
|
|
11
|
+
if (!data)
|
|
12
|
+
return undefined;
|
|
13
|
+
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { renderTemplate };
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useWalletBookCdn';
|
|
2
|
-
export * from './useWalletBookContext';
|
|
1
|
+
export * from './useWalletBookCdn';
|
|
2
|
+
export * from './useWalletBookContext';
|
|
@@ -10,33 +10,33 @@ var logger = require('../helpers/logger.cjs');
|
|
|
10
10
|
var getWalletBookCdnUrl = require('../helpers/getWalletBookCdnUrl.cjs');
|
|
11
11
|
var walletBookFallbacks = require('../../wallet-book-fallbacks.cjs');
|
|
12
12
|
|
|
13
|
-
const useWalletBookCdn = () => {
|
|
14
|
-
const [walletBook, setWalletBook] = react.useState({});
|
|
15
|
-
react.useEffect(() => {
|
|
16
|
-
const fetchWalletBook = async () => {
|
|
17
|
-
const url = getWalletBookCdnUrl.getWalletBookCdnUrl();
|
|
18
|
-
let data;
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch(url);
|
|
21
|
-
if (response.ok) {
|
|
22
|
-
data = walletBookSchema.walletBookSchema.parse(await response.json());
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
throw new Error('Fetch Failed with status: ' + response.status);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
logger.logger.error(`Failed to fetch wallet book data from CDN (${url})`, e);
|
|
30
|
-
}
|
|
31
|
-
if (!data) {
|
|
32
|
-
logger.logger.warn('Falling back to wallet book data from wallet-book-fallbacks.json');
|
|
33
|
-
data = walletBookSchema.walletBookSchema.parse(walletBookFallbacks["default"]);
|
|
34
|
-
}
|
|
35
|
-
setWalletBook(data);
|
|
36
|
-
};
|
|
37
|
-
fetchWalletBook();
|
|
38
|
-
}, []);
|
|
39
|
-
return walletBook;
|
|
13
|
+
const useWalletBookCdn = () => {
|
|
14
|
+
const [walletBook, setWalletBook] = react.useState({});
|
|
15
|
+
react.useEffect(() => {
|
|
16
|
+
const fetchWalletBook = async () => {
|
|
17
|
+
const url = getWalletBookCdnUrl.getWalletBookCdnUrl();
|
|
18
|
+
let data;
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(url);
|
|
21
|
+
if (response.ok) {
|
|
22
|
+
data = walletBookSchema.walletBookSchema.parse(await response.json());
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new Error('Fetch Failed with status: ' + response.status);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
logger.logger.error(`Failed to fetch wallet book data from CDN (${url})`, e);
|
|
30
|
+
}
|
|
31
|
+
if (!data) {
|
|
32
|
+
logger.logger.warn('Falling back to wallet book data from wallet-book-fallbacks.json');
|
|
33
|
+
data = walletBookSchema.walletBookSchema.parse(walletBookFallbacks["default"]);
|
|
34
|
+
}
|
|
35
|
+
setWalletBook(data);
|
|
36
|
+
};
|
|
37
|
+
fetchWalletBook();
|
|
38
|
+
}, []);
|
|
39
|
+
return walletBook;
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
exports.useWalletBookCdn = useWalletBookCdn;
|
|
@@ -1,46 +1,55 @@
|
|
|
1
|
-
export declare const useWalletBookCdn: () => {
|
|
2
|
-
groups: Record<string, {
|
|
3
|
-
key: string;
|
|
4
|
-
name: string;
|
|
5
|
-
brand?: {
|
|
6
|
-
alt?: string | undefined;
|
|
7
|
-
imageId?: string | undefined;
|
|
8
|
-
primaryColor?: string | undefined;
|
|
9
|
-
spriteId?: string | undefined;
|
|
10
|
-
} | undefined;
|
|
11
|
-
}>;
|
|
12
|
-
wallets: Record<string, {
|
|
13
|
-
name: string;
|
|
14
|
-
brand?: {
|
|
15
|
-
alt?: string | undefined;
|
|
16
|
-
imageId?: string | undefined;
|
|
17
|
-
primaryColor?: string | undefined;
|
|
18
|
-
spriteId?: string | undefined;
|
|
19
|
-
} | undefined;
|
|
20
|
-
chains?: string[] | undefined;
|
|
21
|
-
desktop?: {
|
|
22
|
-
chromeId?: string | undefined;
|
|
23
|
-
edgeId?: string | undefined;
|
|
24
|
-
firefoxId?: string | undefined;
|
|
25
|
-
native?: string | undefined;
|
|
26
|
-
operaId?: string | undefined;
|
|
27
|
-
safariId?: string | undefined;
|
|
28
|
-
universal?: string | undefined;
|
|
29
|
-
} | undefined;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
export declare const useWalletBookCdn: () => {
|
|
2
|
+
groups: Record<string, {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
brand?: {
|
|
6
|
+
alt?: string | undefined;
|
|
7
|
+
imageId?: string | undefined;
|
|
8
|
+
primaryColor?: string | undefined;
|
|
9
|
+
spriteId?: string | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
wallets: Record<string, {
|
|
13
|
+
name: string;
|
|
14
|
+
brand?: {
|
|
15
|
+
alt?: string | undefined;
|
|
16
|
+
imageId?: string | undefined;
|
|
17
|
+
primaryColor?: string | undefined;
|
|
18
|
+
spriteId?: string | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
chains?: string[] | undefined;
|
|
21
|
+
desktop?: {
|
|
22
|
+
chromeId?: string | undefined;
|
|
23
|
+
edgeId?: string | undefined;
|
|
24
|
+
firefoxId?: string | undefined;
|
|
25
|
+
native?: string | undefined;
|
|
26
|
+
operaId?: string | undefined;
|
|
27
|
+
safariId?: string | undefined;
|
|
28
|
+
universal?: string | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
filterFromWalletConnect?: boolean | undefined;
|
|
31
|
+
group?: string | undefined;
|
|
32
|
+
injectedConfig?: {
|
|
33
|
+
chain: string;
|
|
34
|
+
extensionLocators: {
|
|
35
|
+
value: boolean;
|
|
36
|
+
flag: string;
|
|
37
|
+
}[];
|
|
38
|
+
windowLocations?: string[] | undefined;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
mobile?: {
|
|
41
|
+
android?: string | null | undefined;
|
|
42
|
+
androidId?: string | undefined;
|
|
43
|
+
ios?: string | null | undefined;
|
|
44
|
+
iosId?: string | undefined;
|
|
45
|
+
native?: string | undefined;
|
|
46
|
+
universal?: string | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
shortName?: string | undefined;
|
|
49
|
+
showOnlyIfInstalled?: boolean | undefined;
|
|
50
|
+
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
51
|
+
walletConnect?: {
|
|
52
|
+
sdks?: string[] | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
@@ -6,33 +6,33 @@ import { logger } from '../helpers/logger.js';
|
|
|
6
6
|
import { getWalletBookCdnUrl } from '../helpers/getWalletBookCdnUrl.js';
|
|
7
7
|
import walletBookFallbacks from '../../wallet-book-fallbacks.js';
|
|
8
8
|
|
|
9
|
-
const useWalletBookCdn = () => {
|
|
10
|
-
const [walletBook, setWalletBook] = useState({});
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const fetchWalletBook = async () => {
|
|
13
|
-
const url = getWalletBookCdnUrl();
|
|
14
|
-
let data;
|
|
15
|
-
try {
|
|
16
|
-
const response = await fetch(url);
|
|
17
|
-
if (response.ok) {
|
|
18
|
-
data = walletBookSchema.parse(await response.json());
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
throw new Error('Fetch Failed with status: ' + response.status);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
logger.error(`Failed to fetch wallet book data from CDN (${url})`, e);
|
|
26
|
-
}
|
|
27
|
-
if (!data) {
|
|
28
|
-
logger.warn('Falling back to wallet book data from wallet-book-fallbacks.json');
|
|
29
|
-
data = walletBookSchema.parse(walletBookFallbacks);
|
|
30
|
-
}
|
|
31
|
-
setWalletBook(data);
|
|
32
|
-
};
|
|
33
|
-
fetchWalletBook();
|
|
34
|
-
}, []);
|
|
35
|
-
return walletBook;
|
|
9
|
+
const useWalletBookCdn = () => {
|
|
10
|
+
const [walletBook, setWalletBook] = useState({});
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const fetchWalletBook = async () => {
|
|
13
|
+
const url = getWalletBookCdnUrl();
|
|
14
|
+
let data;
|
|
15
|
+
try {
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
if (response.ok) {
|
|
18
|
+
data = walletBookSchema.parse(await response.json());
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error('Fetch Failed with status: ' + response.status);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
logger.error(`Failed to fetch wallet book data from CDN (${url})`, e);
|
|
26
|
+
}
|
|
27
|
+
if (!data) {
|
|
28
|
+
logger.warn('Falling back to wallet book data from wallet-book-fallbacks.json');
|
|
29
|
+
data = walletBookSchema.parse(walletBookFallbacks);
|
|
30
|
+
}
|
|
31
|
+
setWalletBook(data);
|
|
32
|
+
};
|
|
33
|
+
fetchWalletBook();
|
|
34
|
+
}, []);
|
|
35
|
+
return walletBook;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export { useWalletBookCdn };
|
|
@@ -9,12 +9,12 @@ require('../schemas/walletBookSchema.cjs');
|
|
|
9
9
|
require('../schemas/walletSchema.cjs');
|
|
10
10
|
var WalletBookContext = require('../components/WalletBookContext.cjs');
|
|
11
11
|
|
|
12
|
-
const useWalletBookContext = () => {
|
|
13
|
-
const context = react.useContext(WalletBookContext.WalletBookContext);
|
|
14
|
-
if (context === undefined) {
|
|
15
|
-
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
16
|
-
}
|
|
17
|
-
return context;
|
|
12
|
+
const useWalletBookContext = () => {
|
|
13
|
+
const context = react.useContext(WalletBookContext.WalletBookContext);
|
|
14
|
+
if (context === undefined) {
|
|
15
|
+
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
exports.useWalletBookContext = useWalletBookContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useWalletBookContext: () => import("../components").IWalletBookContext;
|
|
1
|
+
export declare const useWalletBookContext: () => import("../components").IWalletBookContext;
|
|
@@ -5,12 +5,12 @@ import '../schemas/walletBookSchema.js';
|
|
|
5
5
|
import '../schemas/walletSchema.js';
|
|
6
6
|
import { WalletBookContext } from '../components/WalletBookContext.js';
|
|
7
7
|
|
|
8
|
-
const useWalletBookContext = () => {
|
|
9
|
-
const context = useContext(WalletBookContext);
|
|
10
|
-
if (context === undefined) {
|
|
11
|
-
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
12
|
-
}
|
|
13
|
-
return context;
|
|
8
|
+
const useWalletBookContext = () => {
|
|
9
|
+
const context = useContext(WalletBookContext);
|
|
10
|
+
if (context === undefined) {
|
|
11
|
+
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { useWalletBookContext };
|
package/src/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TYPES
|
|
3
|
-
*/
|
|
4
|
-
export type { WalletBookSchema, WalletRecordsSchema, } from './schemas/walletBookSchema';
|
|
5
|
-
export type { WalletSchema } from './schemas/walletSchema';
|
|
6
|
-
export type { WalletLinks } from './helpers';
|
|
7
|
-
/**
|
|
8
|
-
* HELPERS
|
|
9
|
-
*/
|
|
10
|
-
export { getWalletBookWallet, getWalletIconUrl, getWalletLinks, getWalletPrimaryColor, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, } from './helpers';
|
|
11
|
-
/**
|
|
12
|
-
* HOOKS
|
|
13
|
-
*/
|
|
14
|
-
export { useWalletBookCdn, useWalletBookContext } from './hooks';
|
|
15
|
-
/**
|
|
16
|
-
* COMPONENTS
|
|
17
|
-
*/
|
|
18
|
-
export { WalletIcon, WalletBookContextProvider } from './components';
|
|
1
|
+
/**
|
|
2
|
+
* TYPES
|
|
3
|
+
*/
|
|
4
|
+
export type { WalletBookSchema, WalletRecordsSchema, } from './schemas/walletBookSchema';
|
|
5
|
+
export type { WalletSchema } from './schemas/walletSchema';
|
|
6
|
+
export type { WalletLinks } from './helpers';
|
|
7
|
+
/**
|
|
8
|
+
* HELPERS
|
|
9
|
+
*/
|
|
10
|
+
export { getWalletBookWallet, getWalletIconUrl, getWalletLinks, getWalletPrimaryColor, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, } from './helpers';
|
|
11
|
+
/**
|
|
12
|
+
* HOOKS
|
|
13
|
+
*/
|
|
14
|
+
export { useWalletBookCdn, useWalletBookContext } from './hooks';
|
|
15
|
+
/**
|
|
16
|
+
* COMPONENTS
|
|
17
|
+
*/
|
|
18
|
+
export { WalletIcon, WalletBookContextProvider } from './components';
|
package/src/schemas/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './walletConnectSourceSchema';
|
|
2
|
-
export * from './walletBookSchema';
|
|
3
|
-
export * from './walletSchema';
|
|
1
|
+
export * from './walletConnectSourceSchema';
|
|
2
|
+
export * from './walletBookSchema';
|
|
3
|
+
export * from './walletSchema';
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Returns undefined if an object values are all nullish
|
|
7
|
-
* @param val object
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
5
|
+
/**
|
|
6
|
+
* Returns undefined if an object values are all nullish
|
|
7
|
+
* @param val object
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
10
|
const filterEmptyObject = (val) => val && Object.values(val).some((x) => Boolean(x)) ? val : undefined;
|
|
11
11
|
|
|
12
12
|
exports.filterEmptyObject = filterEmptyObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns undefined if an object values are all nullish
|
|
3
|
-
* @param val object
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
export declare const filterEmptyObject: <T>(val: T) => T | undefined;
|
|
1
|
+
/**
|
|
2
|
+
* Returns undefined if an object values are all nullish
|
|
3
|
+
* @param val object
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
export declare const filterEmptyObject: <T>(val: T) => T | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns undefined if an object values are all nullish
|
|
3
|
-
* @param val object
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* Returns undefined if an object values are all nullish
|
|
3
|
+
* @param val object
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
6
|
const filterEmptyObject = (val) => val && Object.values(val).some((x) => Boolean(x)) ? val : undefined;
|
|
7
7
|
|
|
8
8
|
export { filterEmptyObject };
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* A zod type to ensure a string is not empty
|
|
9
|
-
*/
|
|
7
|
+
/**
|
|
8
|
+
* A zod type to ensure a string is not empty
|
|
9
|
+
*/
|
|
10
10
|
const nonEmptyString = zod.z.preprocess((val) => (val ? val : undefined), zod.z.string().optional());
|
|
11
11
|
|
|
12
12
|
exports.nonEmptyString = nonEmptyString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* A zod type to ensure a string is not empty
|
|
4
|
-
*/
|
|
5
|
-
export declare const nonEmptyString: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, unknown>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A zod type to ensure a string is not empty
|
|
4
|
+
*/
|
|
5
|
+
export declare const nonEmptyString: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, unknown>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* A zod type to ensure a string is not empty
|
|
5
|
-
*/
|
|
3
|
+
/**
|
|
4
|
+
* A zod type to ensure a string is not empty
|
|
5
|
+
*/
|
|
6
6
|
const nonEmptyString = z.preprocess((val) => (val ? val : undefined), z.string().optional());
|
|
7
7
|
|
|
8
8
|
export { nonEmptyString };
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* A zod type to ensure an array is not empty
|
|
9
|
-
*/
|
|
7
|
+
/**
|
|
8
|
+
* A zod type to ensure an array is not empty
|
|
9
|
+
*/
|
|
10
10
|
const nonEmptyStringArray = zod.z.preprocess((val) => (Array.isArray(val) && val.length > 0 ? val : undefined), zod.z.array(zod.z.string()).optional());
|
|
11
11
|
|
|
12
12
|
exports.nonEmptyStringArray = nonEmptyStringArray;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* A zod type to ensure an array is not empty
|
|
4
|
-
*/
|
|
5
|
-
export declare const nonEmptyStringArray: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodString, "many">>, string[] | undefined, unknown>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* A zod type to ensure an array is not empty
|
|
4
|
+
*/
|
|
5
|
+
export declare const nonEmptyStringArray: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodString, "many">>, string[] | undefined, unknown>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* A zod type to ensure an array is not empty
|
|
5
|
-
*/
|
|
3
|
+
/**
|
|
4
|
+
* A zod type to ensure an array is not empty
|
|
5
|
+
*/
|
|
6
6
|
const nonEmptyStringArray = z.preprocess((val) => (Array.isArray(val) && val.length > 0 ? val : undefined), z.array(z.string()).optional());
|
|
7
7
|
|
|
8
8
|
export { nonEmptyStringArray };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const processWalletConnectNativeUrl: (url: string) => string | undefined;
|
|
1
|
+
export declare const processWalletConnectNativeUrl: (url: string) => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sorts an object by key
|
|
3
|
-
* @param val object
|
|
4
|
-
*/
|
|
5
|
-
export declare const sortKeys: (val: Record<string, unknown>) => Record<string, unknown>;
|
|
1
|
+
/**
|
|
2
|
+
* Sorts an object by key
|
|
3
|
+
* @param val object
|
|
4
|
+
*/
|
|
5
|
+
export declare const sortKeys: (val: Record<string, unknown>) => Record<string, unknown>;
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const transformAndroidId = (url) => {
|
|
6
|
-
if (!url?.match(/^https?:\/\//))
|
|
7
|
-
return url;
|
|
8
|
-
if (!url)
|
|
9
|
-
return;
|
|
10
|
-
try {
|
|
11
|
-
const urlObject = new URL(url);
|
|
12
|
-
const id = urlObject.searchParams.get('id');
|
|
13
|
-
if (id) {
|
|
14
|
-
return id;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
// ignore
|
|
19
|
-
}
|
|
20
|
-
return;
|
|
5
|
+
const transformAndroidId = (url) => {
|
|
6
|
+
if (!url?.match(/^https?:\/\//))
|
|
7
|
+
return url;
|
|
8
|
+
if (!url)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
const urlObject = new URL(url);
|
|
12
|
+
const id = urlObject.searchParams.get('id');
|
|
13
|
+
if (id) {
|
|
14
|
+
return id;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// ignore
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
exports.transformAndroidId = transformAndroidId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const transformAndroidId: (url: string | undefined) => string | undefined;
|
|
1
|
+
export declare const transformAndroidId: (url: string | undefined) => string | undefined;
|