@dynamic-labs/wallet-book 4.0.0-alpha.40 → 4.0.0-alpha.42

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 CHANGED
@@ -1,4 +1,23 @@
1
1
 
2
+ ## [4.0.0-alpha.42](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.41...v4.0.0-alpha.42) (2024-12-06)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * walletbook loading issues ([#7553](https://github.com/dynamic-labs/dynamic-auth/issues/7553)) ([684ecc3](https://github.com/dynamic-labs/dynamic-auth/commit/684ecc32960e34680088d6cf200318336647ab77))
8
+
9
+ ## [4.0.0-alpha.41](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.40...v4.0.0-alpha.41) (2024-12-05)
10
+
11
+
12
+ ### Features
13
+
14
+ * add shopify login ([04c6a9e](https://github.com/dynamic-labs/dynamic-auth/commit/04c6a9ee9d039d1480aa3b476ab382d7ea6dbaf2))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * wallet group icon not rendering properly when no wallets with that same id are found ([#7543](https://github.com/dynamic-labs/dynamic-auth/issues/7543)) ([a26a629](https://github.com/dynamic-labs/dynamic-auth/commit/a26a6294bbe845147245cccc60a7fded49196db6))
20
+
2
21
  ## [4.0.0-alpha.40](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.39...v4.0.0-alpha.40) (2024-12-03)
3
22
 
4
23
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.0.0-alpha.40";
6
+ var version = "4.0.0-alpha.42";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.0.0-alpha.40";
2
+ var version = "4.0.0-alpha.42";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/wallet-book",
3
- "version": "4.0.0-alpha.40",
3
+ "version": "4.0.0-alpha.42",
4
4
  "author": "Dynamic Labs, Inc.",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.cjs",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "zod": "3.22.4",
20
- "@dynamic-labs/assert-package-version": "4.0.0-alpha.40",
21
- "@dynamic-labs/iconic": "4.0.0-alpha.40",
22
- "@dynamic-labs/logger": "4.0.0-alpha.40",
23
- "@dynamic-labs/utils": "4.0.0-alpha.40",
20
+ "@dynamic-labs/assert-package-version": "4.0.0-alpha.42",
21
+ "@dynamic-labs/iconic": "4.0.0-alpha.42",
22
+ "@dynamic-labs/logger": "4.0.0-alpha.42",
23
+ "@dynamic-labs/utils": "4.0.0-alpha.42",
24
24
  "eventemitter3": "5.0.1",
25
25
  "util": "0.12.5"
26
26
  },
@@ -7,29 +7,29 @@ var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var react = require('react');
8
8
  var getWalletIconUrl = require('../helpers/getWalletIconUrl.cjs');
9
9
  require('../helpers/renderTemplate.cjs');
10
- var findWalletBookWallet = require('../helpers/findWalletBookWallet.cjs');
11
10
  require('../helpers/logger.cjs');
11
+ var getWalletIconData = require('../helpers/getWalletIconData.cjs');
12
12
  var WalletBookContext = require('../context/WalletBookContext.cjs');
13
13
 
14
14
  const WalletBookWalletIcon = (_a) => {
15
- var { walletKey, children } = _a, props = _tslib.__rest(_a, ["walletKey", "children"]);
15
+ var { walletKey, isGroup, children } = _a, props = _tslib.__rest(_a, ["walletKey", "isGroup", "children"]);
16
16
  const { walletBook } = WalletBookContext.useWalletBookContext();
17
- const walletData = findWalletBookWallet.findWalletBookWallet(walletBook, walletKey);
18
17
  const [imgError, setImgError] = react.useState(false);
19
- const walletIconUrl = getWalletIconUrl.getWalletIconUrl(walletBook, walletKey);
18
+ const { walletIconUrl, walletIconAlt } = getWalletIconData.getWalletIconData(walletBook, walletKey, isGroup);
20
19
  const defaultWalletIconUrl = getWalletIconUrl.getDefaultWalletIconUrl();
21
- if (!walletData || !walletData.brand || !walletIconUrl) {
20
+ if (!walletIconUrl) {
22
21
  return react.createElement(react.Fragment, {}, children);
23
22
  }
24
23
  const onError = () => {
25
24
  setImgError(true);
26
25
  };
27
- return react.createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletData.brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
26
+ return react.createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletIconAlt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
28
27
  };
29
28
  const WalletIcon = (_a) => {
30
- var { icon, walletKey, children } = _a, props = _tslib.__rest(_a, ["icon", "walletKey", "children"]);
29
+ var { icon, walletKey, isGroup, children } = _a, props = _tslib.__rest(_a, ["icon", "walletKey", "isGroup", "children"]);
31
30
  if (!icon) {
32
31
  return react.createElement(WalletBookWalletIcon, Object.assign({ children,
32
+ isGroup,
33
33
  walletKey }, props));
34
34
  }
35
35
  return react.createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletKey, src: icon }), children);
@@ -3,9 +3,10 @@ type WalletIconProps = React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImage
3
3
  icon?: string | undefined;
4
4
  walletKey: string | undefined;
5
5
  children?: ReactNode | any;
6
+ isGroup?: boolean;
6
7
  };
7
8
  type WalletBookWalletIconProps = Omit<WalletIconProps, 'icon' | 'iconUrl'>;
8
- export declare const WalletIcon: ({ icon, walletKey, children, ...props }: WalletIconProps) => React.FunctionComponentElement<WalletBookWalletIconProps> | React.DetailedReactHTMLElement<{
9
+ export declare const WalletIcon: ({ icon, walletKey, isGroup, children, ...props }: WalletIconProps) => React.FunctionComponentElement<WalletBookWalletIconProps> | React.DetailedReactHTMLElement<{
9
10
  alt: string | undefined;
10
11
  src: string;
11
12
  ref?: React.LegacyRef<HTMLImageElement> | undefined;
@@ -1,31 +1,31 @@
1
1
  'use client'
2
2
  import { __rest } from '../../_virtual/_tslib.js';
3
3
  import { createElement, useState, Fragment } from 'react';
4
- import { getWalletIconUrl, getDefaultWalletIconUrl } from '../helpers/getWalletIconUrl.js';
4
+ import { getDefaultWalletIconUrl } from '../helpers/getWalletIconUrl.js';
5
5
  import '../helpers/renderTemplate.js';
6
- import { findWalletBookWallet } from '../helpers/findWalletBookWallet.js';
7
6
  import '../helpers/logger.js';
7
+ import { getWalletIconData } from '../helpers/getWalletIconData.js';
8
8
  import { useWalletBookContext } from '../context/WalletBookContext.js';
9
9
 
10
10
  const WalletBookWalletIcon = (_a) => {
11
- var { walletKey, children } = _a, props = __rest(_a, ["walletKey", "children"]);
11
+ var { walletKey, isGroup, children } = _a, props = __rest(_a, ["walletKey", "isGroup", "children"]);
12
12
  const { walletBook } = useWalletBookContext();
13
- const walletData = findWalletBookWallet(walletBook, walletKey);
14
13
  const [imgError, setImgError] = useState(false);
15
- const walletIconUrl = getWalletIconUrl(walletBook, walletKey);
14
+ const { walletIconUrl, walletIconAlt } = getWalletIconData(walletBook, walletKey, isGroup);
16
15
  const defaultWalletIconUrl = getDefaultWalletIconUrl();
17
- if (!walletData || !walletData.brand || !walletIconUrl) {
16
+ if (!walletIconUrl) {
18
17
  return createElement(Fragment, {}, children);
19
18
  }
20
19
  const onError = () => {
21
20
  setImgError(true);
22
21
  };
23
- return createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletData.brand.alt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
22
+ return createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletIconAlt, onError: onError, src: imgError ? defaultWalletIconUrl : walletIconUrl }), children);
24
23
  };
25
24
  const WalletIcon = (_a) => {
26
- var { icon, walletKey, children } = _a, props = __rest(_a, ["icon", "walletKey", "children"]);
25
+ var { icon, walletKey, isGroup, children } = _a, props = __rest(_a, ["icon", "walletKey", "isGroup", "children"]);
27
26
  if (!icon) {
28
27
  return createElement(WalletBookWalletIcon, Object.assign({ children,
28
+ isGroup,
29
29
  walletKey }, props));
30
30
  }
31
31
  return createElement('img', Object.assign(Object.assign({ 'data-testid': `wallet-icon-${walletKey}` }, props), { alt: walletKey, src: icon }), children);
@@ -0,0 +1,39 @@
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 findWalletGroup = require('./findWalletGroup.cjs');
10
+
11
+ const getWalletIconData = (walletBook, walletKey, isGroup) => {
12
+ if (!walletKey) {
13
+ return {
14
+ walletIconAlt: '',
15
+ walletIconUrl: '',
16
+ };
17
+ }
18
+ try {
19
+ const walletData = isGroup
20
+ ? findWalletGroup.findWalletGroup(walletBook, walletKey)
21
+ : getWalletBookWallet.getWalletBookWallet(walletBook, walletKey);
22
+ const iconData = walletData === null || walletData === void 0 ? void 0 : walletData.brand;
23
+ if (iconData) {
24
+ return {
25
+ walletIconAlt: iconData.alt,
26
+ walletIconUrl: getBrandIconUrl.getBrandIconUrl(iconData),
27
+ };
28
+ }
29
+ }
30
+ catch (err) {
31
+ logger.logger.error(err);
32
+ }
33
+ return {
34
+ walletIconAlt: '',
35
+ walletIconUrl: '',
36
+ };
37
+ };
38
+
39
+ exports.getWalletIconData = getWalletIconData;
@@ -0,0 +1,5 @@
1
+ import { WalletBookSchema } from '../schemas';
2
+ export declare const getWalletIconData: (walletBook: WalletBookSchema, walletKey?: string, isGroup?: boolean) => {
3
+ walletIconAlt: string | undefined;
4
+ walletIconUrl: string | undefined;
5
+ };
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+ import { getWalletBookWallet } from './getWalletBookWallet.js';
3
+ import { getBrandIconUrl } from './getBrandIconUrl.js';
4
+ import { logger } from './logger.js';
5
+ import { findWalletGroup } from './findWalletGroup.js';
6
+
7
+ const getWalletIconData = (walletBook, walletKey, isGroup) => {
8
+ if (!walletKey) {
9
+ return {
10
+ walletIconAlt: '',
11
+ walletIconUrl: '',
12
+ };
13
+ }
14
+ try {
15
+ const walletData = isGroup
16
+ ? findWalletGroup(walletBook, walletKey)
17
+ : getWalletBookWallet(walletBook, walletKey);
18
+ const iconData = walletData === null || walletData === void 0 ? void 0 : walletData.brand;
19
+ if (iconData) {
20
+ return {
21
+ walletIconAlt: iconData.alt,
22
+ walletIconUrl: getBrandIconUrl(iconData),
23
+ };
24
+ }
25
+ }
26
+ catch (err) {
27
+ logger.error(err);
28
+ }
29
+ return {
30
+ walletIconAlt: '',
31
+ walletIconUrl: '',
32
+ };
33
+ };
34
+
35
+ export { getWalletIconData };
@@ -8,3 +8,5 @@ export * from './findWalletGroup';
8
8
  export * from './getWalletBookCdnUrl';
9
9
  export * from './getBrandIconUrl';
10
10
  export * from './findWalletGroupOverride';
11
+ export * from './getWalletIconData';
12
+ export * from './isWalletBookPopulated';
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const isWalletBookPopulated = (walletBook) => { var _a; return Object.keys((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).length > 0; };
7
+
8
+ exports.isWalletBookPopulated = isWalletBookPopulated;
@@ -0,0 +1,2 @@
1
+ import { WalletBookSchema } from '../schemas/walletBookSchema';
2
+ export declare const isWalletBookPopulated: (walletBook?: WalletBookSchema) => boolean;
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ const isWalletBookPopulated = (walletBook) => { var _a; return Object.keys((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).length > 0; };
3
+
4
+ export { isWalletBookPopulated };
package/src/index.cjs CHANGED
@@ -16,6 +16,7 @@ var findWalletGroup = require('./helpers/findWalletGroup.cjs');
16
16
  var getWalletBookCdnUrl = require('./helpers/getWalletBookCdnUrl.cjs');
17
17
  var getBrandIconUrl = require('./helpers/getBrandIconUrl.cjs');
18
18
  var findWalletGroupOverride = require('./helpers/findWalletGroupOverride.cjs');
19
+ var isWalletBookPopulated = require('./helpers/isWalletBookPopulated.cjs');
19
20
  var useWalletBookCdn = require('./hooks/useWalletBookCdn.cjs');
20
21
  var WalletIcon = require('./components/WalletIcon.cjs');
21
22
  var WalletBookContextProvider = require('./components/WalletBookContextProvider.cjs');
@@ -33,6 +34,7 @@ exports.findWalletGroup = findWalletGroup.findWalletGroup;
33
34
  exports.getWalletBookCdnUrl = getWalletBookCdnUrl.getWalletBookCdnUrl;
34
35
  exports.getBrandIconUrl = getBrandIconUrl.getBrandIconUrl;
35
36
  exports.findWalletGroupOverride = findWalletGroupOverride.findWalletGroupOverride;
37
+ exports.isWalletBookPopulated = isWalletBookPopulated.isWalletBookPopulated;
36
38
  exports.useWalletBookCdn = useWalletBookCdn.useWalletBookCdn;
37
39
  exports.WalletIcon = WalletIcon.WalletIcon;
38
40
  exports.WalletBookContextProvider = WalletBookContextProvider.WalletBookContextProvider;
package/src/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { useWalletBookContext } from './context/WalletBookContext';
10
10
  /**
11
11
  * HELPERS
12
12
  */
13
- export { getWalletBookWallet, getWalletIconUrl, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, getBrandIconUrl, findWalletGroupOverride, renderTemplate, } from './helpers';
13
+ export { getWalletBookWallet, getWalletIconUrl, getWalletGroup, getWalletBookCdnUrl, findWalletBookWallet, findWalletGroup, getBrandIconUrl, findWalletGroupOverride, renderTemplate, isWalletBookPopulated, } from './helpers';
14
14
  /**
15
15
  * HOOKS
16
16
  */
package/src/index.js CHANGED
@@ -12,6 +12,7 @@ export { findWalletGroup } from './helpers/findWalletGroup.js';
12
12
  export { getWalletBookCdnUrl } from './helpers/getWalletBookCdnUrl.js';
13
13
  export { getBrandIconUrl } from './helpers/getBrandIconUrl.js';
14
14
  export { findWalletGroupOverride } from './helpers/findWalletGroupOverride.js';
15
+ export { isWalletBookPopulated } from './helpers/isWalletBookPopulated.js';
15
16
  export { useWalletBookCdn } from './hooks/useWalletBookCdn.js';
16
17
  export { WalletIcon } from './components/WalletIcon.js';
17
18
  export { WalletBookContextProvider } from './components/WalletBookContextProvider.js';
@@ -132,6 +132,14 @@ var groups = {
132
132
  key: "metamask",
133
133
  name: "MetaMask"
134
134
  },
135
+ nightly: {
136
+ brand: {
137
+ alt: "Nightly Wallet",
138
+ spriteId: "nightly"
139
+ },
140
+ key: "nightly",
141
+ name: "Nightly"
142
+ },
135
143
  okxwallet: {
136
144
  brand: {
137
145
  alt: "OKX Wallet",
@@ -143,7 +151,7 @@ var groups = {
143
151
  onekey: {
144
152
  brand: {
145
153
  alt: "OneKey Wallet",
146
- spriteId: "12bebb3f-8030-4892-8452-c60a6bac1500"
154
+ spriteId: "onekey"
147
155
  },
148
156
  key: "onekey",
149
157
  name: "OneKey"
@@ -1402,6 +1410,32 @@ var wallets = {
1402
1410
  ],
1403
1411
  name: "Eden Online"
1404
1412
  },
1413
+ onekeybtc: {
1414
+ brand: {
1415
+ alt: "OneKey Wallet",
1416
+ spriteId: "onekey"
1417
+ },
1418
+ chainGroup: "onekey",
1419
+ desktop: {
1420
+ chromeId: "jnmbobjmhlngoefaiojfljckilhhlhcj"
1421
+ },
1422
+ group: "onekey",
1423
+ injectedConfig: [
1424
+ {
1425
+ chain: "btc",
1426
+ extensionLocators: [
1427
+ ],
1428
+ windowLocations: [
1429
+ "$onekey.btc"
1430
+ ]
1431
+ }
1432
+ ],
1433
+ mobile: {
1434
+ androidId: "so.onekey.app.wallet",
1435
+ iosId: "id1609559473"
1436
+ },
1437
+ name: "OneKey"
1438
+ },
1405
1439
  intersend: {
1406
1440
  brand: {
1407
1441
  alt: "Intersend",
@@ -128,6 +128,14 @@ var groups = {
128
128
  key: "metamask",
129
129
  name: "MetaMask"
130
130
  },
131
+ nightly: {
132
+ brand: {
133
+ alt: "Nightly Wallet",
134
+ spriteId: "nightly"
135
+ },
136
+ key: "nightly",
137
+ name: "Nightly"
138
+ },
131
139
  okxwallet: {
132
140
  brand: {
133
141
  alt: "OKX Wallet",
@@ -139,7 +147,7 @@ var groups = {
139
147
  onekey: {
140
148
  brand: {
141
149
  alt: "OneKey Wallet",
142
- spriteId: "12bebb3f-8030-4892-8452-c60a6bac1500"
150
+ spriteId: "onekey"
143
151
  },
144
152
  key: "onekey",
145
153
  name: "OneKey"
@@ -1398,6 +1406,32 @@ var wallets = {
1398
1406
  ],
1399
1407
  name: "Eden Online"
1400
1408
  },
1409
+ onekeybtc: {
1410
+ brand: {
1411
+ alt: "OneKey Wallet",
1412
+ spriteId: "onekey"
1413
+ },
1414
+ chainGroup: "onekey",
1415
+ desktop: {
1416
+ chromeId: "jnmbobjmhlngoefaiojfljckilhhlhcj"
1417
+ },
1418
+ group: "onekey",
1419
+ injectedConfig: [
1420
+ {
1421
+ chain: "btc",
1422
+ extensionLocators: [
1423
+ ],
1424
+ windowLocations: [
1425
+ "$onekey.btc"
1426
+ ]
1427
+ }
1428
+ ],
1429
+ mobile: {
1430
+ androidId: "so.onekey.app.wallet",
1431
+ iosId: "id1609559473"
1432
+ },
1433
+ name: "OneKey"
1434
+ },
1401
1435
  intersend: {
1402
1436
  brand: {
1403
1437
  alt: "Intersend",