@xylabs/sdk-react 2.7.7 → 2.7.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"EthAccount.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGnD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAMzC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"EthAccount.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAmDzC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -9,16 +9,38 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { EthAccountBase } from './EthAccountBase';
14
- import { EthAccountTo } from './EthAccountTo';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Typography, useTheme } from '@mui/material';
14
+ import { useContext } from 'react';
15
+ import { EthersContext } from '../../contexts';
16
+ import { useMediaQuery } from '../../hooks';
17
+ import { ButtonEx } from '../ButtonEx';
18
+ import { FlexGrowRow, FlexRow } from '../FlexBox';
19
+ import { Identicon } from '../Identicon';
15
20
  const EthAccount = (_a) => {
16
- var { to, toOptions } = _a, props = __rest(_a, ["to", "toOptions"]);
17
- if (to || toOptions) {
18
- return _jsx(EthAccountTo, Object.assign({ to: to, toOptions: toOptions }, props), void 0);
21
+ var { address, icon = false, iconSize = 16, iconOnly = false, addressLength = 'auto', fontFamily = '"Source Code Pro",monospace', toEtherScan, onButtonClick } = _a, props = __rest(_a, ["address", "icon", "iconSize", "iconOnly", "addressLength", "fontFamily", "toEtherScan", "onButtonClick"]);
22
+ const { localAddress } = useContext(EthersContext);
23
+ const theme = useTheme();
24
+ const large = useMediaQuery(theme.breakpoints.up('md'));
25
+ if (address) {
26
+ const isLocalAddress = (localAddress === null || localAddress === void 0 ? void 0 : localAddress.toString()) === address.toString();
27
+ const onClickLocal = (event) => {
28
+ onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
29
+ if (toEtherScan) {
30
+ window.open(`https://etherscan.io/address/${address.toString()}`, '_blank');
31
+ }
32
+ };
33
+ const testToDisplay = addressLength === 'long'
34
+ ? address.toString()
35
+ : addressLength === 'short'
36
+ ? address.toShortString()
37
+ : large
38
+ ? address.toString()
39
+ : address.toShortString();
40
+ return (_jsx(ButtonEx, Object.assign({ onClick: onClickLocal, title: `0x${address === null || address === void 0 ? void 0 : address.toHex()}` }, props, { children: _jsxs(FlexGrowRow, Object.assign({ justifyContent: "space-between", alignItems: "center" }, { children: [icon ? _jsx(Identicon, { size: iconSize, value: address === null || address === void 0 ? void 0 : address.toHex() }, void 0) : null, iconOnly ? null : (_jsx(Typography, Object.assign({ marginLeft: icon ? 1 : 0, variant: "body1", fontFamily: fontFamily }, { children: testToDisplay }), void 0)), isLocalAddress ? _jsx(FlexRow, Object.assign({ marginLeft: 0.5 }, { children: "(You)" }), void 0) : null] }), void 0) }), void 0));
19
41
  }
20
42
  else {
21
- return _jsx(EthAccountBase, Object.assign({}, props), void 0);
43
+ return _jsx(ButtonEx, Object.assign({}, props, { children: ' - - ' }), void 0);
22
44
  }
23
45
  };
24
46
  export { EthAccount };
@@ -1 +1 @@
1
- {"version":3,"file":"EthAccount.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,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CACjB,KAAC,UAAU,kBAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAC,OAAO,EAAC,UAAU,EAAE,UAAU,gBACzE,aAAa,YACH,CACd,EACA,cAAc,CAAC,CAAC,CAAC,KAAC,OAAO,kBAAC,UAAU,EAAE,GAAG,mCAAiB,CAAC,CAAC,CAAC,IAAI,aACtD,YACL,CACZ,CAAA;KACF;SAAM;QACL,OAAO,KAAC,QAAQ,oBAAK,KAAK,cAAG,OAAO,YAAY,CAAA;KACjD;AACH,CAAC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ComponentMeta, ComponentStory } from '@storybook/react';
3
3
  declare const StorybookEntry: ComponentMeta<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
4
- declare const Default: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
5
- export { Default };
4
+ declare const Long: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
5
+ declare const Short: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
6
+ declare const Auto: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
7
+ export { Auto, Long, Short };
6
8
  export default StorybookEntry;
7
9
  //# sourceMappingURL=EthAccount.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthAccount.stories.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAKhE,QAAA,MAAM,cAAc,gFASiB,CAAA;AAIrC,QAAA,MAAM,OAAO,iFAAoB,CAAA;AASjC,OAAO,EAAE,OAAO,EAAE,CAAA;AAGlB,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"EthAccount.stories.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMhE,QAAA,MAAM,cAAc,gFASiB,CAAA;AAQrC,QAAA,MAAM,IAAI,iFAAoB,CAAA;AAS9B,QAAA,MAAM,KAAK,iFAAoB,CAAA;AAS/B,QAAA,MAAM,IAAI,iFAAoB,CAAA;AAS9B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAG5B,eAAe,cAAc,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { EthAddress } from '@xylabs/sdk-js';
3
+ import { FlexRow } from '../FlexBox';
3
4
  import { EthAccount } from './EthAccount';
4
5
  const StorybookEntry = {
5
6
  argTypes: {},
@@ -11,16 +12,32 @@ const StorybookEntry = {
11
12
  },
12
13
  title: 'Components/EthAccount',
13
14
  };
14
- const Template = (args) => _jsx(EthAccount, Object.assign({}, args), void 0);
15
- const Default = Template.bind({});
16
- Default.args = {
15
+ const Template = (args) => (_jsx(FlexRow, { children: _jsx(EthAccount, Object.assign({ variant: "outlined" }, args), void 0) }, void 0));
16
+ const Long = Template.bind({});
17
+ Long.args = {
17
18
  address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
18
- auto: true,
19
+ addressLength: 'long',
19
20
  icon: true,
20
21
  title: 'Sample EthAccount',
21
22
  toEtherScan: true,
22
23
  };
23
- export { Default };
24
+ const Short = Template.bind({});
25
+ Short.args = {
26
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
27
+ addressLength: 'short',
28
+ icon: true,
29
+ title: 'Sample EthAccount',
30
+ toEtherScan: true,
31
+ };
32
+ const Auto = Template.bind({});
33
+ Auto.args = {
34
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
35
+ addressLength: 'auto',
36
+ icon: true,
37
+ title: 'Sample EthAccount',
38
+ toEtherScan: true,
39
+ };
40
+ export { Auto, Long, Short };
24
41
  // eslint-disable-next-line import/no-default-export
25
42
  export default StorybookEntry;
26
43
  //# sourceMappingURL=EthAccount.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthAccount.stories.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,UAAU;IACrB,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,IAAI;SACX;KACF;IACD,KAAK,EAAE,uBAAuB;CACK,CAAA;AAErC,MAAM,QAAQ,GAAsC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,UAAU,oBAAK,IAAI,UAAe,CAAA;AAEjG,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACjC,OAAO,CAAC,IAAI,GAAG;IACb,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,4CAA4C,CAAC;IAC5E,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,IAAI;CAClB,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,CAAA;AAElB,oDAAoD;AACpD,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"EthAccount.stories.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,cAAc,GAA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oxProps } from '@mui/material';
2
1
  import { EthAddress } from '@xylabs/sdk-js';
3
2
  import { MouseEventHandler } from 'react';
4
- import { NavigateOptions, To } from 'react-router-dom';
5
- interface EthAccountProps extends BoxProps {
3
+ import { ButtonExProps } from '../ButtonEx';
4
+ interface EthAccountProps extends ButtonExProps {
6
5
  address?: EthAddress | null;
7
- auto?: boolean;
6
+ addressLength?: 'auto' | 'short' | 'long';
8
7
  full?: boolean;
9
8
  icon?: boolean;
9
+ iconSize?: number;
10
10
  iconOnly?: boolean;
11
- size?: number;
12
11
  text?: boolean;
13
- to?: To;
14
- toOptions?: NavigateOptions;
15
12
  page?: string;
16
13
  toEtherScan?: boolean;
14
+ fontFamily?: string;
17
15
  onButtonClick?: MouseEventHandler<HTMLButtonElement>;
18
16
  }
19
17
  export type { EthAccountProps };
@@ -1 +1 @@
1
- {"version":3,"file":"EthAccountProps.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAEtD,UAAU,eAAgB,SAAQ,QAAQ;IACxC,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,aAAa,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAA;CACrD;AAED,YAAY,EAAE,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"EthAccountProps.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,UAAU,eAAgB,SAAQ,aAAa;IAC7C,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;IACzC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAA;CACrD;AAED,YAAY,EAAE,eAAe,EAAE,CAAA"}
package/package.json CHANGED
@@ -26,16 +26,16 @@
26
26
  "@emotion/styled": "^11.6.0",
27
27
  "@ethersproject/abstract-signer": "^5.5.0",
28
28
  "@ethersproject/providers": "^5.5.1",
29
- "@mui/icons-material": "^5.2.0",
30
- "@mui/material": "^5.2.2",
31
- "@mui/styles": "^5.2.2",
32
- "@storybook/addon-actions": "^6.4.7",
33
- "@storybook/addon-docs": "^6.4.7",
34
- "@storybook/addon-essentials": "^6.4.7",
35
- "@storybook/addon-links": "^6.4.7",
36
- "@storybook/components": "^6.4.7",
37
- "@storybook/core-events": "^6.4.7",
38
- "@storybook/react": "^6.4.7",
29
+ "@mui/icons-material": "^5.2.1",
30
+ "@mui/material": "^5.2.3",
31
+ "@mui/styles": "^5.2.3",
32
+ "@storybook/addon-actions": "^6.4.8",
33
+ "@storybook/addon-docs": "^6.4.8",
34
+ "@storybook/addon-essentials": "^6.4.8",
35
+ "@storybook/addon-links": "^6.4.8",
36
+ "@storybook/components": "^6.4.8",
37
+ "@storybook/core-events": "^6.4.8",
38
+ "@storybook/react": "^6.4.8",
39
39
  "@types/bn.js": "^5.1.0",
40
40
  "@types/lodash": "^4.14.177",
41
41
  "@types/md5": "^2.3.1",
@@ -108,5 +108,5 @@
108
108
  "sideEffects": false,
109
109
  "type": "module",
110
110
  "types": "dist/index.d.ts",
111
- "version": "2.7.7"
111
+ "version": "2.7.8"
112
112
  }
@@ -1,6 +1,7 @@
1
1
  import { ComponentMeta, ComponentStory } from '@storybook/react'
2
2
  import { EthAddress } from '@xylabs/sdk-js'
3
3
 
4
+ import { FlexRow } from '../FlexBox'
4
5
  import { EthAccount } from './EthAccount'
5
6
 
6
7
  const StorybookEntry = {
@@ -14,18 +15,40 @@ const StorybookEntry = {
14
15
  title: 'Components/EthAccount',
15
16
  } as ComponentMeta<typeof EthAccount>
16
17
 
17
- const Template: ComponentStory<typeof EthAccount> = (args) => <EthAccount {...args}></EthAccount>
18
+ const Template: ComponentStory<typeof EthAccount> = (args) => (
19
+ <FlexRow>
20
+ <EthAccount variant="outlined" {...args}></EthAccount>
21
+ </FlexRow>
22
+ )
18
23
 
19
- const Default = Template.bind({})
20
- Default.args = {
24
+ const Long = Template.bind({})
25
+ Long.args = {
21
26
  address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
22
- auto: true,
27
+ addressLength: 'long',
23
28
  icon: true,
24
29
  title: 'Sample EthAccount',
25
30
  toEtherScan: true,
26
31
  }
27
32
 
28
- export { Default }
33
+ const Short = Template.bind({})
34
+ Short.args = {
35
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
36
+ addressLength: 'short',
37
+ icon: true,
38
+ title: 'Sample EthAccount',
39
+ toEtherScan: true,
40
+ }
41
+
42
+ const Auto = Template.bind({})
43
+ Auto.args = {
44
+ address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
45
+ addressLength: 'auto',
46
+ icon: true,
47
+ title: 'Sample EthAccount',
48
+ toEtherScan: true,
49
+ }
50
+
51
+ export { Auto, Long, Short }
29
52
 
30
53
  // eslint-disable-next-line import/no-default-export
31
54
  export default StorybookEntry
@@ -1,12 +1,63 @@
1
- import { EthAccountBase } from './EthAccountBase'
1
+ import { Typography, useTheme } from '@mui/material'
2
+ import { MouseEvent, useContext } from 'react'
3
+
4
+ import { EthersContext } from '../../contexts'
5
+ import { useMediaQuery } from '../../hooks'
6
+ import { ButtonEx } from '../ButtonEx'
7
+ import { FlexGrowRow, FlexRow } from '../FlexBox'
8
+ import { Identicon } from '../Identicon'
2
9
  import { EthAccountProps } from './EthAccountProps'
3
- import { EthAccountTo } from './EthAccountTo'
4
10
 
5
- const EthAccount: React.FC<EthAccountProps> = ({ to, toOptions, ...props }) => {
6
- if (to || toOptions) {
7
- return <EthAccountTo to={to} toOptions={toOptions} {...props} />
11
+ const EthAccount: React.FC<EthAccountProps> = ({
12
+ address,
13
+ icon = false,
14
+ iconSize = 16,
15
+ iconOnly = false,
16
+ addressLength = 'auto',
17
+ fontFamily = '"Source Code Pro",monospace',
18
+ toEtherScan,
19
+ onButtonClick,
20
+ ...props
21
+ }) => {
22
+ const { localAddress } = useContext(EthersContext)
23
+ const theme = useTheme()
24
+
25
+ const large = useMediaQuery(theme.breakpoints.up('md'))
26
+
27
+ if (address) {
28
+ const isLocalAddress = localAddress?.toString() === address.toString()
29
+
30
+ const onClickLocal = (event: MouseEvent<HTMLButtonElement>) => {
31
+ onButtonClick?.(event)
32
+ if (toEtherScan) {
33
+ window.open(`https://etherscan.io/address/${address.toString()}`, '_blank')
34
+ }
35
+ }
36
+
37
+ const testToDisplay =
38
+ addressLength === 'long'
39
+ ? address.toString()
40
+ : addressLength === 'short'
41
+ ? address.toShortString()
42
+ : large
43
+ ? address.toString()
44
+ : address.toShortString()
45
+
46
+ return (
47
+ <ButtonEx onClick={onClickLocal} title={`0x${address?.toHex()}`} {...props}>
48
+ <FlexGrowRow justifyContent="space-between" alignItems="center">
49
+ {icon ? <Identicon size={iconSize} value={address?.toHex()} /> : null}
50
+ {iconOnly ? null : (
51
+ <Typography marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
52
+ {testToDisplay}
53
+ </Typography>
54
+ )}
55
+ {isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
56
+ </FlexGrowRow>
57
+ </ButtonEx>
58
+ )
8
59
  } else {
9
- return <EthAccountBase {...props} />
60
+ return <ButtonEx {...props}>{' - - '}</ButtonEx>
10
61
  }
11
62
  }
12
63
 
@@ -1,20 +1,19 @@
1
- import { BoxProps } from '@mui/material'
2
1
  import { EthAddress } from '@xylabs/sdk-js'
3
2
  import { MouseEventHandler } from 'react'
4
- import { NavigateOptions, To } from 'react-router-dom'
5
3
 
6
- interface EthAccountProps extends BoxProps {
4
+ import { ButtonExProps } from '../ButtonEx'
5
+
6
+ interface EthAccountProps extends ButtonExProps {
7
7
  address?: EthAddress | null
8
- auto?: boolean
8
+ addressLength?: 'auto' | 'short' | 'long'
9
9
  full?: boolean
10
10
  icon?: boolean
11
+ iconSize?: number
11
12
  iconOnly?: boolean
12
- size?: number
13
13
  text?: boolean
14
- to?: To
15
- toOptions?: NavigateOptions
16
14
  page?: string
17
15
  toEtherScan?: boolean
16
+ fontFamily?: string
18
17
  onButtonClick?: MouseEventHandler<HTMLButtonElement>
19
18
  }
20
19
 
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EthAccountProps } from './EthAccountProps';
3
- declare const EthAccountBase: React.FC<EthAccountProps>;
4
- export { EthAccountBase };
5
- //# sourceMappingURL=EthAccountBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountBase.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountBase.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+C7C,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,42 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Typography, useTheme } from '@mui/material';
14
- import { useContext } from 'react';
15
- import { EthersContext } from '../../contexts';
16
- import { useMediaQuery } from '../../hooks';
17
- import { ButtonEx } from '../ButtonEx';
18
- import { FlexGrowRow, FlexRow } from '../FlexBox';
19
- import { Identicon } from '../Identicon';
20
- const EthAccountBase = (_a) => {
21
- var { address, icon = false, iconOnly = false, full = false, auto, size = 16, toEtherScan, onButtonClick } = _a, props = __rest(_a, ["address", "icon", "iconOnly", "full", "auto", "size", "toEtherScan", "onButtonClick"]);
22
- const { localAddress } = useContext(EthersContext);
23
- const theme = useTheme();
24
- const large = useMediaQuery(theme.breakpoints.up('md'));
25
- const fontFamily = '"Source Code Pro",monospace';
26
- if (address) {
27
- const isLocalAddress = (localAddress === null || localAddress === void 0 ? void 0 : localAddress.toString()) === address.toString();
28
- const onClickLocal = (event) => {
29
- onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
30
- if (toEtherScan) {
31
- window.open(`https://etherscan.io/address/${address.toString()}`, '_blank');
32
- }
33
- };
34
- const testToDisplay = full || !auto ? address.toString() : large ? address.toString() : address.toShortString();
35
- return (_jsx(FlexRow, Object.assign({ margin: 0.5, padding: 0.5, title: `0x${address === null || address === void 0 ? void 0 : address.toHex()}` }, props, { children: _jsx(ButtonEx, Object.assign({ fullWidth: true, onClick: onClickLocal, variant: "outlined" }, { children: _jsxs(FlexGrowRow, Object.assign({ justifyContent: "space-between", alignItems: "center" }, { children: [icon ? _jsx(Identicon, { size: size, value: address === null || address === void 0 ? void 0 : address.toHex() }, void 0) : null, iconOnly ? null : (_jsx(Typography, Object.assign({ variant: "body1", fontFamily: fontFamily, style: { textTransform: 'none' } }, { children: testToDisplay }), void 0)), isLocalAddress ? _jsx(FlexRow, Object.assign({ marginLeft: 0.5 }, { children: "(You)" }), void 0) : null] }), void 0) }), void 0) }), void 0));
36
- }
37
- else {
38
- return _jsx(FlexRow, Object.assign({}, props, { children: ' - - ' }), void 0);
39
- }
40
- };
41
- export { EthAccountBase };
42
- //# sourceMappingURL=EthAccountBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountBase.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,c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CAAE,KAAK,EAAE,EAAE,IAAM,KAAK,cAC3E,KAAC,QAAQ,kBAAC,SAAS,QAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAC,UAAU,gBAC3D,MAAC,WAAW,kBAAC,cAAc,EAAC,eAAe,EAAC,UAAU,EAAC,QAAQ,iBAC5D,IAAI,CAAC,CAAC,CAAC,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,WAAI,CAAC,CAAC,CAAC,IAAI,EAChE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACjB,KAAC,UAAU,kBAAC,OAAO,EAAC,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,gBACjF,aAAa,YACH,CACd,EACA,cAAc,CAAC,CAAC,CAAC,KAAC,OAAO,kBAAC,UAAU,EAAE,GAAG,mCAAiB,CAAC,CAAC,CAAC,IAAI,aACtD,YACL,YACH,CACX,CAAA;KACF;SAAM;QACL,OAAO,KAAC,OAAO,oBAAK,KAAK,cAAG,OAAO,YAAW,CAAA;KAC/C;AACH,CAAC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import { EthAccountProps } from './EthAccountProps';
3
- declare const EthAccountTo: React.FC<EthAccountProps>;
4
- export { EthAccountTo };
5
- //# sourceMappingURL=EthAccountTo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountTo.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountTo.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqB3C,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,30 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { useNavigateToEthAddress } from '../../hooks';
14
- import { EthAccountBase } from './EthAccountBase';
15
- const EthAccountTo = (_a) => {
16
- var { address, to, page, toOptions, toEtherScan, onButtonClick } = _a, props = __rest(_a, ["address", "to", "page", "toOptions", "toEtherScan", "onButtonClick"]);
17
- const { navigateToEthAddress } = useNavigateToEthAddress();
18
- if (address) {
19
- const localOnClick = (event) => {
20
- onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
21
- if (to) {
22
- navigateToEthAddress(address, event, page, to, toOptions, toEtherScan);
23
- }
24
- };
25
- return _jsx(EthAccountBase, Object.assign({ onButtonClick: localOnClick }, props), void 0);
26
- }
27
- return null;
28
- };
29
- export { EthAccountTo };
30
- //# sourceMappingURL=EthAccountTo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EthAccountTo.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccountTo.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,YAAY,GAA8B,CAAC,EAQhD,EAAE,EAAE;QAR4C,EAC/C,OAAO,EACP,EAAE,EACF,IAAI,EACJ,SAAS,EACT,WAAW,EACX,aAAa,OAEd,EADI,KAAK,cAPuC,sEAQhD,CADS;IAER,MAAM,EAAE,oBAAoB,EAAE,GAAG,uBAAuB,EAAE,CAAA;IAC1D,IAAI,OAAO,EAAE;QACX,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE;YAC5D,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,KAAK,CAAC,CAAA;YACtB,IAAI,EAAE,EAAE;gBACN,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;aACvE;QACH,CAAC,CAAA;QAED,OAAO,KAAC,cAAc,kBAAC,aAAa,EAAE,YAAY,IAAM,KAAK,UAAI,CAAA;KAClE;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,60 +0,0 @@
1
- import { Typography, useTheme } from '@mui/material'
2
- import { MouseEvent, useContext } from 'react'
3
-
4
- import { EthersContext } from '../../contexts'
5
- import { useMediaQuery } from '../../hooks'
6
- import { ButtonEx } from '../ButtonEx'
7
- import { FlexGrowRow, FlexRow } from '../FlexBox'
8
- import { Identicon } from '../Identicon'
9
- import { EthAccountProps } from './EthAccountProps'
10
-
11
- const EthAccountBase: React.FC<EthAccountProps> = ({
12
- address,
13
- icon = false,
14
- iconOnly = false,
15
- full = false,
16
- auto,
17
- size = 16,
18
- toEtherScan,
19
- onButtonClick,
20
- ...props
21
- }) => {
22
- const { localAddress } = useContext(EthersContext)
23
- const theme = useTheme()
24
-
25
- const large = useMediaQuery(theme.breakpoints.up('md'))
26
- const fontFamily = '"Source Code Pro",monospace'
27
-
28
- if (address) {
29
- const isLocalAddress = localAddress?.toString() === address.toString()
30
-
31
- const onClickLocal = (event: MouseEvent<HTMLButtonElement>) => {
32
- onButtonClick?.(event)
33
- if (toEtherScan) {
34
- window.open(`https://etherscan.io/address/${address.toString()}`, '_blank')
35
- }
36
- }
37
-
38
- const testToDisplay = full || !auto ? address.toString() : large ? address.toString() : address.toShortString()
39
-
40
- return (
41
- <FlexRow margin={0.5} padding={0.5} title={`0x${address?.toHex()}`} {...props}>
42
- <ButtonEx fullWidth onClick={onClickLocal} variant="outlined">
43
- <FlexGrowRow justifyContent="space-between" alignItems="center">
44
- {icon ? <Identicon size={size} value={address?.toHex()} /> : null}
45
- {iconOnly ? null : (
46
- <Typography variant="body1" fontFamily={fontFamily} style={{ textTransform: 'none' }}>
47
- {testToDisplay}
48
- </Typography>
49
- )}
50
- {isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
51
- </FlexGrowRow>
52
- </ButtonEx>
53
- </FlexRow>
54
- )
55
- } else {
56
- return <FlexRow {...props}>{' - - '}</FlexRow>
57
- }
58
- }
59
-
60
- export { EthAccountBase }
@@ -1,30 +0,0 @@
1
- import { MouseEvent } from 'react'
2
-
3
- import { useNavigateToEthAddress } from '../../hooks'
4
- import { EthAccountBase } from './EthAccountBase'
5
- import { EthAccountProps } from './EthAccountProps'
6
-
7
- const EthAccountTo: React.FC<EthAccountProps> = ({
8
- address,
9
- to,
10
- page,
11
- toOptions,
12
- toEtherScan,
13
- onButtonClick,
14
- ...props
15
- }) => {
16
- const { navigateToEthAddress } = useNavigateToEthAddress()
17
- if (address) {
18
- const localOnClick = (event: MouseEvent<HTMLButtonElement>) => {
19
- onButtonClick?.(event)
20
- if (to) {
21
- navigateToEthAddress(address, event, page, to, toOptions, toEtherScan)
22
- }
23
- }
24
-
25
- return <EthAccountBase onButtonClick={localOnClick} {...props} />
26
- }
27
- return null
28
- }
29
-
30
- export { EthAccountTo }