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

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,16 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### Features
6
+
7
+ * add shopify login ([04c6a9e](https://github.com/dynamic-labs/dynamic-auth/commit/04c6a9ee9d039d1480aa3b476ab382d7ea6dbaf2))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 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))
13
+
2
14
  ## [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
15
 
4
16
 
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.41";
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.41";
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.41",
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.41",
21
+ "@dynamic-labs/iconic": "4.0.0-alpha.41",
22
+ "@dynamic-labs/logger": "4.0.0-alpha.41",
23
+ "@dynamic-labs/utils": "4.0.0-alpha.41",
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,4 @@ export * from './findWalletGroup';
8
8
  export * from './getWalletBookCdnUrl';
9
9
  export * from './getBrandIconUrl';
10
10
  export * from './findWalletGroupOverride';
11
+ export * from './getWalletIconData';
@@ -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",
@@ -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",