@xyo-network/react-wallet 2.47.20 → 2.47.22

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.
@@ -6,15 +6,19 @@ import { useWallet } from '../../contexts';
6
6
  const arrayRange = (length, start = 0) => {
7
7
  return Array.from(Array(length).keys()).map((x) => x + start);
8
8
  };
9
- export const WalletAccountSelect = ({ favorites, iconOnly, iconSize = 24, icons, maxAccounts = 1, showFavorite = false, size, ...props }) => {
9
+ export const WalletAccountSelect = ({ addressNames = {}, iconOnly, iconSize = 24, icons, maxAccounts = 1, showFavorite = false, size, ...props }) => {
10
10
  const { activeAccountIndex = 0, setActiveAccountIndex, wallet } = useWallet();
11
11
  const disabled = !wallet || activeAccountIndex === undefined;
12
12
  return (_jsx(_Fragment, { children: wallet ? (_jsx(SelectEx, { disabled: disabled, renderValue: (selected) => {
13
13
  const account = wallet.deriveAccount(selected.toString());
14
- return _jsx(AddressRenderRowBox, { address: account?.addressValue.hex, iconOnly: iconOnly, iconSize: iconSize, icons: icons });
14
+ const customName = addressNames[account?.addressValue.hex];
15
+ const favorite = account?.addressValue.hex in addressNames;
16
+ return (_jsx(AddressRenderRowBox, { address: account?.addressValue.hex, iconOnly: iconOnly, iconSize: iconSize, icons: icons, name: customName, favorite: favorite, showFavorite: showFavorite }));
15
17
  }, value: activeAccountIndex, onChange: (event) => setActiveAccountIndex?.(parseInt(`${event.target.value}`)), size: size, variant: "outlined", ...props, children: arrayRange(maxAccounts).map((index) => {
16
18
  const account = wallet.deriveAccount(index.toString());
17
- return (_jsx(MenuItem, { value: index, children: _jsx(AddressRenderRowBox, { address: account?.addressValue.hex, favorite: favorites?.includes(index), iconOnly: iconOnly, iconSize: iconSize, icons: icons, showFavorite: showFavorite }) }, account?.addressValue.hex));
19
+ const customName = addressNames[account?.addressValue.hex];
20
+ const favorite = account?.addressValue.hex in addressNames;
21
+ return (_jsx(MenuItem, { value: index, children: _jsx(AddressRenderRowBox, { address: account?.addressValue.hex, favorite: favorite, iconOnly: iconOnly, iconSize: iconSize, icons: icons, name: customName, showFavorite: showFavorite }) }, account?.addressValue.hex));
18
22
  }) })) : (_jsx(CircularProgress, { size: 24 })) }));
19
23
  };
20
24
  //# sourceMappingURL=Select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAgC,MAAM,mCAAmC,CAAA;AAErG,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAS1C,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;AAC/D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,SAAS,EACT,QAAQ,EACR,QAAQ,GAAG,EAAE,EACb,KAAK,EACL,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,KAAK,EACpB,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,kBAAkB,GAAG,CAAC,EAAE,qBAAqB,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IAC7E,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,kBAAkB,KAAK,SAAS,CAAA;IAE5D,OAAO,CACL,4BACG,MAAM,CAAC,CAAC,CAAC,CACR,KAAC,QAAQ,IACP,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,CAAC,QAAQ,EAAE,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AAA;AACH,CAAC,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { FlexCol } from '@xylabs/react-flexbox';
3
3
  import { WalletAccountSelect } from './Select';
4
- export const WalletAccountSelectBar = ({ favorites, iconOnly, iconSize, icons, maxAccounts = 1, showFavorite = false, size = 'small', ...props }) => {
5
- return (_jsx(FlexCol, { alignItems: "stretch", ...props, children: _jsx(WalletAccountSelect, { favorites: favorites, fullWidth: true, showFavorite: showFavorite, iconSize: iconSize, iconOnly: iconOnly, icons: icons, maxAccounts: maxAccounts, size: size ?? 'small' }) }));
4
+ export const WalletAccountSelectBar = ({ addressNames = {}, iconOnly, iconSize, icons, maxAccounts = 1, showFavorite = false, size = 'small', ...props }) => {
5
+ return (_jsx(FlexCol, { alignItems: "stretch", ...props, children: _jsx(WalletAccountSelect, { addressNames: addressNames, fullWidth: true, showFavorite: showFavorite, iconSize: iconSize, iconOnly: iconOnly, icons: icons, maxAccounts: maxAccounts, size: size ?? 'small' }) }));
6
6
  };
7
7
  //# sourceMappingURL=SelectBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectBar.js","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/SelectBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAY9C,MAAM,CAAC,MAAM,sBAAsB,GAA0C,CAAC,EAC5E,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,KAAK,EACpB,IAAI,GAAG,OAAO,EACd,GAAG,KAAK,EACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,OAAO,IAAC,UAAU,EAAC,SAAS,KAAK,KAAK,YACrC,KAAC,mBAAmB,IAClB,SAAS,EAAE,SAAS,EACpB,SAAS,QACT,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,IAAI,IAAI,OAAO,GACrB,GACM,CACX,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"SelectBar.js","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/SelectBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAgB,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAY9C,MAAM,CAAC,MAAM,sBAAsB,GAA0C,CAAC,EAC5E,YAAY,GAAG,EAAE,EACjB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,GAAG,CAAC,EACf,YAAY,GAAG,KAAK,EACpB,IAAI,GAAG,OAAO,EACd,GAAG,KAAK,EACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,OAAO,IAAC,UAAU,EAAC,SAAS,KAAK,KAAK,YACrC,KAAC,mBAAmB,IAClB,YAAY,EAAE,YAAY,EAC1B,SAAS,QACT,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,IAAI,IAAI,OAAO,GACrB,GACM,CACX,CAAA;AACH,CAAC,CAAA"}
@@ -3,7 +3,7 @@ import { SelectProps } from '@mui/material';
3
3
  import { AddressRenderRowBoxPropsBase } from '@xyo-network/react-address-render';
4
4
  type SharedAddressRenderRowBoxProps = Pick<AddressRenderRowBoxPropsBase, 'iconOnly' | 'iconSize' | 'icons' | 'showFavorite'>;
5
5
  export interface WalletAccountSelectProps extends SharedAddressRenderRowBoxProps, SelectProps<number> {
6
- favorites?: number[];
6
+ addressNames?: Record<string, string | undefined>;
7
7
  maxAccounts?: number;
8
8
  }
9
9
  export declare const WalletAccountSelect: React.FC<WalletAccountSelectProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAuB,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAIrG,KAAK,8BAA8B,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAA;AAE5H,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAAC;IACnG,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAMD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAiDlE,CAAA"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAuB,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAIrG,KAAK,8BAA8B,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAA;AAE5H,MAAM,WAAW,wBAAyB,SAAQ,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAAC;IACnG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAMD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAgElE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { FlexBoxProps } from '@xylabs/react-flexbox';
3
3
  export interface WalletAccountSelectBarProps extends FlexBoxProps {
4
- favorites?: number[];
4
+ addressNames?: Record<string, string | undefined>;
5
5
  iconOnly?: boolean;
6
6
  iconSize?: number;
7
7
  icons?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectBar.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/SelectBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAW,MAAM,uBAAuB,CAAA;AAI7D,MAAM,WAAW,2BAA4B,SAAQ,YAAY;IAC/D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAC1B;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAwBxE,CAAA"}
1
+ {"version":3,"file":"SelectBar.d.ts","sourceRoot":"","sources":["../../../../src/components/WalletAccountSelect/SelectBar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAW,MAAM,uBAAuB,CAAA;AAI7D,MAAM,WAAW,2BAA4B,SAAQ,YAAY;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACjD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAC1B;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAwBxE,CAAA"}
package/package.json CHANGED
@@ -17,11 +17,11 @@
17
17
  "@xylabs/react-number-status": "^2.16.11",
18
18
  "@xylabs/react-select": "^2.16.11",
19
19
  "@xylabs/react-shared": "^2.16.11",
20
- "@xyo-network/account": "^2.53.24",
21
- "@xyo-network/account-model": "^2.53.24",
22
- "@xyo-network/react-address-render": "^2.47.20",
23
- "@xyo-network/react-network": "^2.47.20",
24
- "@xyo-network/react-shared": "^2.47.20"
20
+ "@xyo-network/account": "^2.53.26",
21
+ "@xyo-network/account-model": "^2.53.26",
22
+ "@xyo-network/react-address-render": "^2.47.22",
23
+ "@xyo-network/react-network": "^2.47.22",
24
+ "@xyo-network/react-shared": "^2.47.22"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@mui/icons-material": "^5",
@@ -37,7 +37,7 @@
37
37
  "@storybook/react": "^6.5.16",
38
38
  "@xylabs/ts-scripts-yarn3": "^2.16.1",
39
39
  "@xylabs/tsconfig-react": "^2.16.1",
40
- "@xyo-network/react-storybook": "^2.47.20",
40
+ "@xyo-network/react-storybook": "^2.47.22",
41
41
  "require-from-string": "^2.0.2",
42
42
  "typescript": "^4.9.5"
43
43
  },
@@ -83,5 +83,5 @@
83
83
  },
84
84
  "sideEffects": false,
85
85
  "types": "dist/types/index.d.ts",
86
- "version": "2.47.20"
86
+ "version": "2.47.22"
87
87
  }
@@ -7,7 +7,7 @@ import { useWallet } from '../../contexts'
7
7
  type SharedAddressRenderRowBoxProps = Pick<AddressRenderRowBoxPropsBase, 'iconOnly' | 'iconSize' | 'icons' | 'showFavorite'>
8
8
 
9
9
  export interface WalletAccountSelectProps extends SharedAddressRenderRowBoxProps, SelectProps<number> {
10
- favorites?: number[]
10
+ addressNames?: Record<string, string | undefined>
11
11
  maxAccounts?: number
12
12
  }
13
13
 
@@ -16,7 +16,7 @@ const arrayRange = (length: number, start = 0) => {
16
16
  }
17
17
 
18
18
  export const WalletAccountSelect: React.FC<WalletAccountSelectProps> = ({
19
- favorites,
19
+ addressNames = {},
20
20
  iconOnly,
21
21
  iconSize = 24,
22
22
  icons,
@@ -35,7 +35,19 @@ export const WalletAccountSelect: React.FC<WalletAccountSelectProps> = ({
35
35
  disabled={disabled}
36
36
  renderValue={(selected) => {
37
37
  const account = wallet.deriveAccount(selected.toString())
38
- return <AddressRenderRowBox address={account?.addressValue.hex} iconOnly={iconOnly} iconSize={iconSize} icons={icons} />
38
+ const customName = addressNames[account?.addressValue.hex]
39
+ const favorite = account?.addressValue.hex in addressNames
40
+ return (
41
+ <AddressRenderRowBox
42
+ address={account?.addressValue.hex}
43
+ iconOnly={iconOnly}
44
+ iconSize={iconSize}
45
+ icons={icons}
46
+ name={customName}
47
+ favorite={favorite}
48
+ showFavorite={showFavorite}
49
+ />
50
+ )
39
51
  }}
40
52
  value={activeAccountIndex}
41
53
  onChange={(event) => setActiveAccountIndex?.(parseInt(`${event.target.value}`))}
@@ -45,14 +57,17 @@ export const WalletAccountSelect: React.FC<WalletAccountSelectProps> = ({
45
57
  >
46
58
  {arrayRange(maxAccounts).map((index) => {
47
59
  const account = wallet.deriveAccount(index.toString())
60
+ const customName = addressNames[account?.addressValue.hex]
61
+ const favorite = account?.addressValue.hex in addressNames
48
62
  return (
49
63
  <MenuItem key={account?.addressValue.hex} value={index}>
50
64
  <AddressRenderRowBox
51
65
  address={account?.addressValue.hex}
52
- favorite={favorites?.includes(index)}
66
+ favorite={favorite}
53
67
  iconOnly={iconOnly}
54
68
  iconSize={iconSize}
55
69
  icons={icons}
70
+ name={customName}
56
71
  showFavorite={showFavorite}
57
72
  />
58
73
  </MenuItem>
@@ -3,7 +3,7 @@ import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'
3
3
  import { WalletAccountSelect } from './Select'
4
4
 
5
5
  export interface WalletAccountSelectBarProps extends FlexBoxProps {
6
- favorites?: number[]
6
+ addressNames?: Record<string, string | undefined>
7
7
  iconOnly?: boolean
8
8
  iconSize?: number
9
9
  icons?: boolean
@@ -13,7 +13,7 @@ export interface WalletAccountSelectBarProps extends FlexBoxProps {
13
13
  }
14
14
 
15
15
  export const WalletAccountSelectBar: React.FC<WalletAccountSelectBarProps> = ({
16
- favorites,
16
+ addressNames = {},
17
17
  iconOnly,
18
18
  iconSize,
19
19
  icons,
@@ -25,7 +25,7 @@ export const WalletAccountSelectBar: React.FC<WalletAccountSelectBarProps> = ({
25
25
  return (
26
26
  <FlexCol alignItems="stretch" {...props}>
27
27
  <WalletAccountSelect
28
- favorites={favorites}
28
+ addressNames={addressNames}
29
29
  fullWidth
30
30
  showFavorite={showFavorite}
31
31
  iconSize={iconSize}
@@ -2,9 +2,11 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'
2
2
  import { HDWallet } from '@xyo-network/account'
3
3
  import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
4
4
 
5
- import { WalletProvider } from '../../contexts'
5
+ import { WalletProvider, WalletRootPath } from '../../contexts'
6
6
  import { WalletAccountSelectBar } from './SelectBar'
7
7
 
8
+ const defaultWallet = HDWallet.fromMnemonic(DefaultSeedPhrase)
9
+
8
10
  const StorybookEntry = {
9
11
  argTypes: {},
10
12
  component: WalletAccountSelectBar,
@@ -22,7 +24,7 @@ const Template: ComponentStory<typeof WalletAccountSelectBar> = (args) => {
22
24
 
23
25
  const WithWalletTemplate: ComponentStory<typeof WalletAccountSelectBar> = (args) => {
24
26
  return (
25
- <WalletProvider defaultWallet={HDWallet.fromMnemonic(DefaultSeedPhrase)}>
27
+ <WalletProvider defaultWallet={defaultWallet}>
26
28
  <WalletAccountSelectBar {...args} />
27
29
  </WalletProvider>
28
30
  )
@@ -41,7 +43,17 @@ const WithAdditionalAccounts = WithWalletTemplate.bind({})
41
43
  WithAdditionalAccounts.args = { icons: true, maxAccounts: 10 }
42
44
 
43
45
  const WithAccountFavorites = WithWalletTemplate.bind({})
44
- WithAccountFavorites.args = { favorites: [0, 3, 9, 10], icons: true, maxAccounts: 10, showFavorite: true }
46
+ const defaultWalletAtIndex = defaultWallet.derivePath(WalletRootPath)
47
+ WithAccountFavorites.args = {
48
+ addressNames: {
49
+ [defaultWalletAtIndex.deriveAccount('0').addressValue.hex]: 'first address',
50
+ [defaultWalletAtIndex.deriveAccount('3').addressValue.hex]: undefined,
51
+ [defaultWalletAtIndex.deriveAccount('5').addressValue.hex]: 'sixth address',
52
+ },
53
+ icons: true,
54
+ maxAccounts: 10,
55
+ showFavorite: true,
56
+ }
45
57
 
46
58
  export { Default, WithAccountFavorites, WithAdditionalAccounts, WithWallet, WithWalletIcon }
47
59