@dynamic-labs/wallet-book 0.0.0-exp20240808.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 +3746 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/_virtual/_tslib.cjs +49 -0
- package/_virtual/_tslib.js +44 -0
- package/package.json +38 -0
- package/src/build/index.d.ts +76 -0
- package/src/build/sources/firstParty/index.d.ts +2 -0
- package/src/build/sources/index.d.ts +4 -0
- package/src/build/sources/walletConnect/index.d.ts +128 -0
- package/src/build/sources/walletConnect/preprocessors.d.ts +14 -0
- package/src/build/sources/walletConnectOverrides/index.d.ts +197 -0
- package/src/build/sources/walletGroups/index.d.ts +2 -0
- package/src/components/BrandIcon.cjs +27 -0
- package/src/components/BrandIcon.d.ts +8 -0
- package/src/components/BrandIcon.js +23 -0
- package/src/components/WalletBookContext.cjs +14 -0
- package/src/components/WalletBookContext.d.ts +9 -0
- package/src/components/WalletBookContext.js +9 -0
- package/src/components/WalletIcon.cjs +34 -0
- package/src/components/WalletIcon.d.ts +8 -0
- package/src/components/WalletIcon.js +30 -0
- package/src/components/index.d.ts +3 -0
- package/src/helpers/findWalletBookWallet.cjs +18 -0
- package/src/helpers/findWalletBookWallet.d.ts +70 -0
- package/src/helpers/findWalletBookWallet.js +14 -0
- package/src/helpers/findWalletGroup.cjs +19 -0
- package/src/helpers/findWalletGroup.d.ts +18 -0
- package/src/helpers/findWalletGroup.js +15 -0
- package/src/helpers/findWalletGroupOverride.cjs +14 -0
- package/src/helpers/findWalletGroupOverride.d.ts +3 -0
- package/src/helpers/findWalletGroupOverride.js +10 -0
- package/src/helpers/getBrandIconUrl.cjs +15 -0
- package/src/helpers/getBrandIconUrl.d.ts +2 -0
- package/src/helpers/getBrandIconUrl.js +11 -0
- package/src/helpers/getWalletBookCdnUrl.cjs +14 -0
- package/src/helpers/getWalletBookCdnUrl.d.ts +1 -0
- package/src/helpers/getWalletBookCdnUrl.js +10 -0
- package/src/helpers/getWalletBookWallet.cjs +17 -0
- package/src/helpers/getWalletBookWallet.d.ts +2 -0
- package/src/helpers/getWalletBookWallet.js +13 -0
- package/src/helpers/getWalletGroup.cjs +13 -0
- package/src/helpers/getWalletGroup.d.ts +3 -0
- package/src/helpers/getWalletGroup.js +9 -0
- package/src/helpers/getWalletIconUrl.cjs +34 -0
- package/src/helpers/getWalletIconUrl.d.ts +3 -0
- package/src/helpers/getWalletIconUrl.js +29 -0
- package/src/helpers/getWalletLinks.cjs +34 -0
- package/src/helpers/getWalletLinks.d.ts +10 -0
- package/src/helpers/getWalletLinks.js +30 -0
- package/src/helpers/getWalletPrimaryColor.cjs +14 -0
- package/src/helpers/getWalletPrimaryColor.d.ts +2 -0
- package/src/helpers/getWalletPrimaryColor.js +10 -0
- package/src/helpers/index.d.ts +14 -0
- package/src/helpers/isWalletEventSupported.cjs +8 -0
- package/src/helpers/isWalletEventSupported.d.ts +2 -0
- package/src/helpers/isWalletEventSupported.js +4 -0
- package/src/helpers/isWalletMethodSupported.cjs +8 -0
- package/src/helpers/isWalletMethodSupported.d.ts +2 -0
- package/src/helpers/isWalletMethodSupported.js +4 -0
- package/src/helpers/logger.cjs +10 -0
- package/src/helpers/logger.d.ts +2 -0
- package/src/helpers/logger.js +6 -0
- package/src/helpers/renderTemplate.cjs +23 -0
- package/src/helpers/renderTemplate.d.ts +12 -0
- package/src/helpers/renderTemplate.js +19 -0
- package/src/hooks/index.d.ts +2 -0
- package/src/hooks/useWalletBookCdn.cjs +51 -0
- package/src/hooks/useWalletBookCdn.d.ts +88 -0
- package/src/hooks/useWalletBookCdn.js +47 -0
- package/src/hooks/useWalletBookContext.cjs +24 -0
- package/src/hooks/useWalletBookContext.d.ts +1 -0
- package/src/hooks/useWalletBookContext.js +20 -0
- package/src/index.cjs +44 -0
- package/src/index.d.ts +18 -0
- package/src/index.js +20 -0
- package/src/schemas/index.d.ts +3 -0
- package/src/schemas/utils/filterEmptyObject.cjs +13 -0
- package/src/schemas/utils/filterEmptyObject.d.ts +6 -0
- package/src/schemas/utils/filterEmptyObject.js +9 -0
- package/src/schemas/utils/nonEmptyString.cjs +13 -0
- package/src/schemas/utils/nonEmptyString.d.ts +5 -0
- package/src/schemas/utils/nonEmptyString.js +9 -0
- package/src/schemas/utils/nonEmptyStringArray.cjs +13 -0
- package/src/schemas/utils/nonEmptyStringArray.d.ts +5 -0
- package/src/schemas/utils/nonEmptyStringArray.js +9 -0
- package/src/schemas/utils/processWalletConnectNativeUrl.d.ts +1 -0
- package/src/schemas/utils/sortKeys.d.ts +5 -0
- package/src/schemas/utils/transformAndroidId.cjs +24 -0
- package/src/schemas/utils/transformAndroidId.d.ts +1 -0
- package/src/schemas/utils/transformAndroidId.js +20 -0
- package/src/schemas/utils/transformChromeExtensionId.cjs +21 -0
- package/src/schemas/utils/transformChromeExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformChromeExtensionId.js +17 -0
- package/src/schemas/utils/transformEdgeExtensionId.cjs +21 -0
- package/src/schemas/utils/transformEdgeExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformEdgeExtensionId.js +17 -0
- package/src/schemas/utils/transformFirefoxExtensionId.cjs +21 -0
- package/src/schemas/utils/transformFirefoxExtensionId.d.ts +1 -0
- package/src/schemas/utils/transformFirefoxExtensionId.js +17 -0
- package/src/schemas/utils/transformIosId.cjs +28 -0
- package/src/schemas/utils/transformIosId.d.ts +1 -0
- package/src/schemas/utils/transformIosId.js +24 -0
- package/src/schemas/walletBookSchema.cjs +17 -0
- package/src/schemas/walletBookSchema.d.ts +1369 -0
- package/src/schemas/walletBookSchema.js +13 -0
- package/src/schemas/walletConnectSourceSchema.cjs +78 -0
- package/src/schemas/walletConnectSourceSchema.d.ts +516 -0
- package/src/schemas/walletConnectSourceSchema.js +74 -0
- package/src/schemas/walletGroup.cjs +27 -0
- package/src/schemas/walletGroup.d.ts +113 -0
- package/src/schemas/walletGroup.js +23 -0
- package/src/schemas/walletSchema.cjs +141 -0
- package/src/schemas/walletSchema.d.ts +614 -0
- package/src/schemas/walletSchema.js +136 -0
- package/wallet-book-fallbacks.cjs +1082 -0
- package/wallet-book-fallbacks.js +1076 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const getWalletBookWallet = (walletBook, walletKey, walletFallback) => {
|
|
3
|
+
var _a, _b, _c;
|
|
4
|
+
if (!walletKey)
|
|
5
|
+
throw new Error('Wallet key is required. Please pass in a wallet key to getWalletBookWallet');
|
|
6
|
+
const walletData = (_b = (_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) === null || _a === void 0 ? void 0 : _a[walletKey]) !== null && _b !== void 0 ? _b : walletFallback;
|
|
7
|
+
if (!walletData) {
|
|
8
|
+
throw new Error(`Wallet ${walletKey} not found in wallet book (${Object.keys((_c = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _c !== void 0 ? _c : {}).length} wallets found)`);
|
|
9
|
+
}
|
|
10
|
+
return walletData;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { getWalletBookWallet };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const getWalletGroup = (walletBook, key) => {
|
|
7
|
+
const group = walletBook.groups[key];
|
|
8
|
+
if (!group)
|
|
9
|
+
throw new Error(`Group ${key} not found in wallet book`);
|
|
10
|
+
return group;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.getWalletGroup = getWalletGroup;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var getWalletBookWallet = require('./getWalletBookWallet.cjs');
|
|
7
|
+
var getBrandIconUrl = require('./getBrandIconUrl.cjs');
|
|
8
|
+
var logger = require('./logger.cjs');
|
|
9
|
+
var renderTemplate = require('./renderTemplate.cjs');
|
|
10
|
+
|
|
11
|
+
const getWalletIconUrl = (walletBook, walletKey) => {
|
|
12
|
+
try {
|
|
13
|
+
const walletData = getWalletBookWallet.getWalletBookWallet(walletBook, walletKey);
|
|
14
|
+
if (walletData === null || walletData === void 0 ? void 0 : walletData.brand) {
|
|
15
|
+
return getBrandIconUrl.getBrandIconUrl(walletData.brand);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
logger.logger.error(err);
|
|
20
|
+
}
|
|
21
|
+
return '';
|
|
22
|
+
};
|
|
23
|
+
const getDefaultWalletIconUrl = () => {
|
|
24
|
+
try {
|
|
25
|
+
return renderTemplate.renderTemplate('iconicUrl', 'defaultwallet');
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
logger.logger.error(err);
|
|
29
|
+
}
|
|
30
|
+
return '';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getDefaultWalletIconUrl = getDefaultWalletIconUrl;
|
|
34
|
+
exports.getWalletIconUrl = getWalletIconUrl;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletBookWallet } from './getWalletBookWallet.js';
|
|
3
|
+
import { getBrandIconUrl } from './getBrandIconUrl.js';
|
|
4
|
+
import { logger } from './logger.js';
|
|
5
|
+
import { renderTemplate } from './renderTemplate.js';
|
|
6
|
+
|
|
7
|
+
const getWalletIconUrl = (walletBook, walletKey) => {
|
|
8
|
+
try {
|
|
9
|
+
const walletData = getWalletBookWallet(walletBook, walletKey);
|
|
10
|
+
if (walletData === null || walletData === void 0 ? void 0 : walletData.brand) {
|
|
11
|
+
return getBrandIconUrl(walletData.brand);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
logger.error(err);
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
};
|
|
19
|
+
const getDefaultWalletIconUrl = () => {
|
|
20
|
+
try {
|
|
21
|
+
return renderTemplate('iconicUrl', 'defaultwallet');
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
logger.error(err);
|
|
25
|
+
}
|
|
26
|
+
return '';
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { getDefaultWalletIconUrl, getWalletIconUrl };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var findWalletBookWallet = require('./findWalletBookWallet.cjs');
|
|
7
|
+
var renderTemplate = require('./renderTemplate.cjs');
|
|
8
|
+
|
|
9
|
+
const getWalletLinks = (walletBook, walletKey) => {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
11
|
+
const walletData = findWalletBookWallet.findWalletBookWallet(walletBook, walletKey);
|
|
12
|
+
const links = {
|
|
13
|
+
android: '',
|
|
14
|
+
brave: '',
|
|
15
|
+
chrome: '',
|
|
16
|
+
edge: '',
|
|
17
|
+
firefox: '',
|
|
18
|
+
ios: '',
|
|
19
|
+
};
|
|
20
|
+
links.brave =
|
|
21
|
+
(_b = renderTemplate.renderTemplate('chromeUrl', (_a = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _a === void 0 ? void 0 : _a.chromeId)) !== null && _b !== void 0 ? _b : '';
|
|
22
|
+
links.chrome =
|
|
23
|
+
(_d = renderTemplate.renderTemplate('chromeUrl', (_c = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _c === void 0 ? void 0 : _c.chromeId)) !== null && _d !== void 0 ? _d : '';
|
|
24
|
+
links.edge = (_f = renderTemplate.renderTemplate('edgeUrl', (_e = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _e === void 0 ? void 0 : _e.edgeId)) !== null && _f !== void 0 ? _f : '';
|
|
25
|
+
links.firefox =
|
|
26
|
+
(_h = renderTemplate.renderTemplate('firefoxUrl', (_g = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _g === void 0 ? void 0 : _g.firefoxId)) !== null && _h !== void 0 ? _h : '';
|
|
27
|
+
links.ios =
|
|
28
|
+
(_m = (_k = renderTemplate.renderTemplate('iosUrl', (_j = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _j === void 0 ? void 0 : _j.iosId)) !== null && _k !== void 0 ? _k : (_l = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _l === void 0 ? void 0 : _l.ios) !== null && _m !== void 0 ? _m : '';
|
|
29
|
+
links.android =
|
|
30
|
+
(_r = (_p = renderTemplate.renderTemplate('androidUrl', (_o = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _o === void 0 ? void 0 : _o.androidId)) !== null && _p !== void 0 ? _p : (_q = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _q === void 0 ? void 0 : _q.android) !== null && _r !== void 0 ? _r : '';
|
|
31
|
+
return links;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.getWalletLinks = getWalletLinks;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WalletBookSchema } from '../schemas';
|
|
2
|
+
export type WalletLinks = {
|
|
3
|
+
android: string;
|
|
4
|
+
brave: string;
|
|
5
|
+
chrome: string;
|
|
6
|
+
edge: string;
|
|
7
|
+
firefox: string;
|
|
8
|
+
ios: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getWalletLinks: (walletBook: WalletBookSchema, walletKey: string) => WalletLinks;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { findWalletBookWallet } from './findWalletBookWallet.js';
|
|
3
|
+
import { renderTemplate } from './renderTemplate.js';
|
|
4
|
+
|
|
5
|
+
const getWalletLinks = (walletBook, walletKey) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
7
|
+
const walletData = findWalletBookWallet(walletBook, walletKey);
|
|
8
|
+
const links = {
|
|
9
|
+
android: '',
|
|
10
|
+
brave: '',
|
|
11
|
+
chrome: '',
|
|
12
|
+
edge: '',
|
|
13
|
+
firefox: '',
|
|
14
|
+
ios: '',
|
|
15
|
+
};
|
|
16
|
+
links.brave =
|
|
17
|
+
(_b = renderTemplate('chromeUrl', (_a = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _a === void 0 ? void 0 : _a.chromeId)) !== null && _b !== void 0 ? _b : '';
|
|
18
|
+
links.chrome =
|
|
19
|
+
(_d = renderTemplate('chromeUrl', (_c = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _c === void 0 ? void 0 : _c.chromeId)) !== null && _d !== void 0 ? _d : '';
|
|
20
|
+
links.edge = (_f = renderTemplate('edgeUrl', (_e = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _e === void 0 ? void 0 : _e.edgeId)) !== null && _f !== void 0 ? _f : '';
|
|
21
|
+
links.firefox =
|
|
22
|
+
(_h = renderTemplate('firefoxUrl', (_g = walletData === null || walletData === void 0 ? void 0 : walletData.desktop) === null || _g === void 0 ? void 0 : _g.firefoxId)) !== null && _h !== void 0 ? _h : '';
|
|
23
|
+
links.ios =
|
|
24
|
+
(_m = (_k = renderTemplate('iosUrl', (_j = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _j === void 0 ? void 0 : _j.iosId)) !== null && _k !== void 0 ? _k : (_l = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _l === void 0 ? void 0 : _l.ios) !== null && _m !== void 0 ? _m : '';
|
|
25
|
+
links.android =
|
|
26
|
+
(_r = (_p = renderTemplate('androidUrl', (_o = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _o === void 0 ? void 0 : _o.androidId)) !== null && _p !== void 0 ? _p : (_q = walletData === null || walletData === void 0 ? void 0 : walletData.mobile) === null || _q === void 0 ? void 0 : _q.android) !== null && _r !== void 0 ? _r : '';
|
|
27
|
+
return links;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { getWalletLinks };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var getWalletBookWallet = require('./getWalletBookWallet.cjs');
|
|
7
|
+
|
|
8
|
+
const getWalletPrimaryColor = (walletBook, walletKey) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const walletData = getWalletBookWallet.getWalletBookWallet(walletBook, walletKey);
|
|
11
|
+
return (_a = walletData === null || walletData === void 0 ? void 0 : walletData.brand) === null || _a === void 0 ? void 0 : _a.primaryColor;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getWalletPrimaryColor = getWalletPrimaryColor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletBookWallet } from './getWalletBookWallet.js';
|
|
3
|
+
|
|
4
|
+
const getWalletPrimaryColor = (walletBook, walletKey) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const walletData = getWalletBookWallet(walletBook, walletKey);
|
|
7
|
+
return (_a = walletData === null || walletData === void 0 ? void 0 : walletData.brand) === null || _a === void 0 ? void 0 : _a.primaryColor;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { getWalletPrimaryColor };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './getWalletIconUrl';
|
|
2
|
+
export * from './getWalletBookWallet';
|
|
3
|
+
export * from './getWalletLinks';
|
|
4
|
+
export * from './getWalletPrimaryColor';
|
|
5
|
+
export * from './renderTemplate';
|
|
6
|
+
export * from './findWalletBookWallet';
|
|
7
|
+
export * from './logger';
|
|
8
|
+
export * from './getWalletGroup';
|
|
9
|
+
export * from './findWalletGroup';
|
|
10
|
+
export * from './getWalletBookCdnUrl';
|
|
11
|
+
export * from './getBrandIconUrl';
|
|
12
|
+
export * from './findWalletGroupOverride';
|
|
13
|
+
export * from './isWalletMethodSupported';
|
|
14
|
+
export * from './isWalletEventSupported';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const isWalletEventSupported = (wallet, event, platform) => { var _a, _b, _c; return !((_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.walletLimitations) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b.unsupportedEvents) === null || _c === void 0 ? void 0 : _c.includes(event)); };
|
|
7
|
+
|
|
8
|
+
exports.isWalletEventSupported = isWalletEventSupported;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const isWalletEventSupported = (wallet, event, platform) => { var _a, _b, _c; return !((_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.walletLimitations) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b.unsupportedEvents) === null || _c === void 0 ? void 0 : _c.includes(event)); };
|
|
3
|
+
|
|
4
|
+
export { isWalletEventSupported };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const isWalletMethodSupported = (wallet, method, platform) => { var _a, _b, _c; return !((_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.walletLimitations) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b.unsupportedMethods) === null || _c === void 0 ? void 0 : _c.includes(method)); };
|
|
7
|
+
|
|
8
|
+
exports.isWalletMethodSupported = isWalletMethodSupported;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
const isWalletMethodSupported = (wallet, method, platform) => { var _a, _b, _c; return !((_c = (_b = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.walletLimitations) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b.unsupportedMethods) === null || _c === void 0 ? void 0 : _c.includes(method)); };
|
|
3
|
+
|
|
4
|
+
export { isWalletMethodSupported };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var iconic = require('@dynamic-labs/iconic');
|
|
7
|
+
|
|
8
|
+
const TEMPLATES = {
|
|
9
|
+
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
10
|
+
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
11
|
+
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
12
|
+
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
13
|
+
iconicUrl: `${iconic.getIconicSpriteUrl()}#{{id}}`,
|
|
14
|
+
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
15
|
+
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
16
|
+
};
|
|
17
|
+
const renderTemplate = (templateName, data) => {
|
|
18
|
+
if (!data)
|
|
19
|
+
return undefined;
|
|
20
|
+
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.renderTemplate = renderTemplate;
|
|
@@ -0,0 +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: `${string}#{{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 {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
|
|
3
|
+
|
|
4
|
+
const TEMPLATES = {
|
|
5
|
+
androidUrl: 'https://play.google.com/store/apps/details?id={{id}}',
|
|
6
|
+
chromeUrl: 'https://chrome.google.com/webstore/detail/{{id}}',
|
|
7
|
+
edgeUrl: 'https://microsoftedge.microsoft.com/addons/detail/{{id}}',
|
|
8
|
+
firefoxUrl: 'https://addons.mozilla.org/en-US/firefox/addon/{{id}}',
|
|
9
|
+
iconicUrl: `${getIconicSpriteUrl()}#{{id}}`,
|
|
10
|
+
iosUrl: 'https://apps.apple.com/app/apple-store/{{id}}',
|
|
11
|
+
walletConnectUrl: 'https://registry.walletconnect.org/v2/logo/sm/{{id}}',
|
|
12
|
+
};
|
|
13
|
+
const renderTemplate = (templateName, data) => {
|
|
14
|
+
if (!data)
|
|
15
|
+
return undefined;
|
|
16
|
+
return TEMPLATES[templateName].replace('{{id}}', data);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { renderTemplate };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
require('../schemas/walletConnectSourceSchema.cjs');
|
|
10
|
+
var walletBookSchema = require('../schemas/walletBookSchema.cjs');
|
|
11
|
+
require('../schemas/walletSchema.cjs');
|
|
12
|
+
require('../helpers/renderTemplate.cjs');
|
|
13
|
+
var logger = require('../helpers/logger.cjs');
|
|
14
|
+
var getWalletBookCdnUrl = require('../helpers/getWalletBookCdnUrl.cjs');
|
|
15
|
+
var walletBookFallbacks = require('../../wallet-book-fallbacks.cjs');
|
|
16
|
+
|
|
17
|
+
const useWalletBookCdn = () => {
|
|
18
|
+
const [walletBook, setWalletBook] = react.useState({});
|
|
19
|
+
react.useEffect(() => {
|
|
20
|
+
const fetchWalletBook = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const url = getWalletBookCdnUrl.getWalletBookCdnUrl();
|
|
22
|
+
const fn = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const res = yield fetch(url, { mode: 'cors' });
|
|
24
|
+
if (res.ok) {
|
|
25
|
+
const json = yield res.json();
|
|
26
|
+
try {
|
|
27
|
+
const parsedData = walletBookSchema.walletBookSchema.parse(json);
|
|
28
|
+
return parsedData;
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
logger.logger.error('Error parsing wallet book data', e, json);
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Failed to fetch wallet book data from ${url} with status code ${res.status}`);
|
|
36
|
+
});
|
|
37
|
+
const data = yield utils.retryableFn(fn, {
|
|
38
|
+
fallbackValue: walletBookSchema.walletBookSchema.parse(walletBookFallbacks["default"]),
|
|
39
|
+
logger: logger.logger.createLogger('useWalletBookCdn'),
|
|
40
|
+
maxRetries: 3,
|
|
41
|
+
retryStrategy: 'timeout-and-rejection',
|
|
42
|
+
timeoutMs: 30000,
|
|
43
|
+
});
|
|
44
|
+
setWalletBook(data);
|
|
45
|
+
});
|
|
46
|
+
fetchWalletBook();
|
|
47
|
+
}, []);
|
|
48
|
+
return walletBook;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.useWalletBookCdn = useWalletBookCdn;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export declare const useWalletBookCdn: () => {
|
|
2
|
+
groups: Record<string, {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
brand?: {
|
|
6
|
+
alt?: string | undefined;
|
|
7
|
+
primaryColor?: string | undefined;
|
|
8
|
+
spriteId?: string | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
walletOverrides?: Record<string, {
|
|
11
|
+
brand?: {
|
|
12
|
+
alt?: string | undefined;
|
|
13
|
+
primaryColor?: string | undefined;
|
|
14
|
+
spriteId?: string | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
}> | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
wallets: Record<string, {
|
|
20
|
+
name: string;
|
|
21
|
+
brand?: {
|
|
22
|
+
alt?: string | undefined;
|
|
23
|
+
primaryColor?: string | undefined;
|
|
24
|
+
spriteId?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
chainGroup?: string | undefined;
|
|
27
|
+
chains?: string[] | undefined;
|
|
28
|
+
desktop?: {
|
|
29
|
+
chromeId?: string | undefined;
|
|
30
|
+
edgeId?: string | undefined;
|
|
31
|
+
firefoxId?: string | undefined;
|
|
32
|
+
native?: string | undefined;
|
|
33
|
+
operaId?: string | undefined;
|
|
34
|
+
safariId?: string | undefined;
|
|
35
|
+
universal?: string | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
eip6963Config?: {
|
|
38
|
+
rdns: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
filterFromWalletConnect?: boolean | undefined;
|
|
41
|
+
group?: string | undefined;
|
|
42
|
+
hardwareWallets?: string[] | undefined;
|
|
43
|
+
injectedConfig?: {
|
|
44
|
+
chain: string;
|
|
45
|
+
extensionLocators: {
|
|
46
|
+
value: boolean;
|
|
47
|
+
flag: string;
|
|
48
|
+
}[];
|
|
49
|
+
providerInterface?: string | undefined;
|
|
50
|
+
walletStandard?: {
|
|
51
|
+
name: string;
|
|
52
|
+
features: string[];
|
|
53
|
+
} | undefined;
|
|
54
|
+
walletStandardLocators?: {
|
|
55
|
+
name: string;
|
|
56
|
+
locator: string;
|
|
57
|
+
}[] | undefined;
|
|
58
|
+
windowLocations?: string[] | undefined;
|
|
59
|
+
}[] | undefined;
|
|
60
|
+
mobile?: {
|
|
61
|
+
android?: string | null | undefined;
|
|
62
|
+
androidId?: string | undefined;
|
|
63
|
+
inAppBrowser?: string | null | undefined;
|
|
64
|
+
ios?: string | null | undefined;
|
|
65
|
+
iosId?: string | undefined;
|
|
66
|
+
native?: string | undefined;
|
|
67
|
+
universal?: string | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
70
|
+
shortName?: string | undefined;
|
|
71
|
+
showOnlyIfInstalled?: boolean | undefined;
|
|
72
|
+
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
73
|
+
walletConnect?: {
|
|
74
|
+
sdks?: string[] | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
walletGroup?: string | undefined;
|
|
77
|
+
walletLimitations?: {
|
|
78
|
+
browserExtension?: {
|
|
79
|
+
unsupportedEvents?: string[] | undefined;
|
|
80
|
+
unsupportedMethods?: string[] | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
mobile?: {
|
|
83
|
+
unsupportedEvents?: string[] | undefined;
|
|
84
|
+
unsupportedMethods?: string[] | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}>;
|
|
88
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { retryableFn } from '@dynamic-labs/utils';
|
|
5
|
+
import '../schemas/walletConnectSourceSchema.js';
|
|
6
|
+
import { walletBookSchema } from '../schemas/walletBookSchema.js';
|
|
7
|
+
import '../schemas/walletSchema.js';
|
|
8
|
+
import '../helpers/renderTemplate.js';
|
|
9
|
+
import { logger } from '../helpers/logger.js';
|
|
10
|
+
import { getWalletBookCdnUrl } from '../helpers/getWalletBookCdnUrl.js';
|
|
11
|
+
import walletBookFallbacks from '../../wallet-book-fallbacks.js';
|
|
12
|
+
|
|
13
|
+
const useWalletBookCdn = () => {
|
|
14
|
+
const [walletBook, setWalletBook] = useState({});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const fetchWalletBook = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const url = getWalletBookCdnUrl();
|
|
18
|
+
const fn = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const res = yield fetch(url, { mode: 'cors' });
|
|
20
|
+
if (res.ok) {
|
|
21
|
+
const json = yield res.json();
|
|
22
|
+
try {
|
|
23
|
+
const parsedData = walletBookSchema.parse(json);
|
|
24
|
+
return parsedData;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
logger.error('Error parsing wallet book data', e, json);
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Failed to fetch wallet book data from ${url} with status code ${res.status}`);
|
|
32
|
+
});
|
|
33
|
+
const data = yield retryableFn(fn, {
|
|
34
|
+
fallbackValue: walletBookSchema.parse(walletBookFallbacks),
|
|
35
|
+
logger: logger.createLogger('useWalletBookCdn'),
|
|
36
|
+
maxRetries: 3,
|
|
37
|
+
retryStrategy: 'timeout-and-rejection',
|
|
38
|
+
timeoutMs: 30000,
|
|
39
|
+
});
|
|
40
|
+
setWalletBook(data);
|
|
41
|
+
});
|
|
42
|
+
fetchWalletBook();
|
|
43
|
+
}, []);
|
|
44
|
+
return walletBook;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { useWalletBookCdn };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var react = require('react');
|
|
7
|
+
require('../../_virtual/_tslib.cjs');
|
|
8
|
+
require('../helpers/renderTemplate.cjs');
|
|
9
|
+
require('../helpers/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../schemas/walletConnectSourceSchema.cjs');
|
|
12
|
+
require('../schemas/walletBookSchema.cjs');
|
|
13
|
+
require('../schemas/walletSchema.cjs');
|
|
14
|
+
var WalletBookContext = require('../components/WalletBookContext.cjs');
|
|
15
|
+
|
|
16
|
+
const useWalletBookContext = () => {
|
|
17
|
+
const context = react.useContext(WalletBookContext.WalletBookContext);
|
|
18
|
+
if (context === undefined) {
|
|
19
|
+
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.useWalletBookContext = useWalletBookContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useWalletBookContext: () => import("../components").IWalletBookContext;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import '../../_virtual/_tslib.js';
|
|
4
|
+
import '../helpers/renderTemplate.js';
|
|
5
|
+
import '../helpers/logger.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../schemas/walletConnectSourceSchema.js';
|
|
8
|
+
import '../schemas/walletBookSchema.js';
|
|
9
|
+
import '../schemas/walletSchema.js';
|
|
10
|
+
import { WalletBookContext } from '../components/WalletBookContext.js';
|
|
11
|
+
|
|
12
|
+
const useWalletBookContext = () => {
|
|
13
|
+
const context = useContext(WalletBookContext);
|
|
14
|
+
if (context === undefined) {
|
|
15
|
+
throw new Error('useWalletBookContext must be used within a WalletBookContextProvider');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { useWalletBookContext };
|