@xylabs/sdk-react 2.7.8 → 2.7.9
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/dist/components/EthAccount/EthAccount.d.ts.map +1 -1
- package/dist/components/EthAccount/EthAccount.js +18 -20
- package/dist/components/EthAccount/EthAccount.js.map +1 -1
- package/dist/components/EthAccount/EthAccount.stories.d.ts +4 -1
- package/dist/components/EthAccount/EthAccount.stories.d.ts.map +1 -1
- package/dist/components/EthAccount/EthAccount.stories.js +22 -1
- package/dist/components/EthAccount/EthAccount.stories.js.map +1 -1
- package/package.json +2 -2
- package/src/components/EthAccount/EthAccount.stories.tsx +25 -1
- package/src/components/EthAccount/EthAccount.tsx +42 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthAccount.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"EthAccount.d.ts","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+DzC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Typography, useTheme } from '@mui/material';
|
|
14
|
+
import { assertEx, EthAddress } from '@xylabs/sdk-js';
|
|
14
15
|
import { useContext } from 'react';
|
|
15
16
|
import { EthersContext } from '../../contexts';
|
|
16
17
|
import { useMediaQuery } from '../../hooks';
|
|
@@ -22,26 +23,23 @@ const EthAccount = (_a) => {
|
|
|
22
23
|
const { localAddress } = useContext(EthersContext);
|
|
23
24
|
const theme = useTheme();
|
|
24
25
|
const large = useMediaQuery(theme.breakpoints.up('md'));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return _jsx(ButtonEx, Object.assign({}, props, { children: ' - - ' }), void 0);
|
|
44
|
-
}
|
|
26
|
+
const isLocalAddress = address ? (localAddress === null || localAddress === void 0 ? void 0 : localAddress.toString()) === address.toString() : false;
|
|
27
|
+
const onClickLocal = (event) => {
|
|
28
|
+
onButtonClick === null || onButtonClick === void 0 ? void 0 : onButtonClick(event);
|
|
29
|
+
if (toEtherScan && address) {
|
|
30
|
+
window.open(`https://etherscan.io/address/${address.toString()}`, '_blank');
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const addressToDisplay = assertEx(address !== null && address !== void 0 ? address : EthAddress.fromString('0x00'), 'Bad Eth Address');
|
|
34
|
+
const testToDisplay = addressLength === 'long'
|
|
35
|
+
? addressToDisplay.toString()
|
|
36
|
+
: addressLength === 'short'
|
|
37
|
+
? addressToDisplay.toShortString()
|
|
38
|
+
: large
|
|
39
|
+
? addressToDisplay.toString()
|
|
40
|
+
: addressToDisplay.toShortString();
|
|
41
|
+
// Note: We use the all zero address for spacing in case it is
|
|
42
|
+
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 : (_jsxs(FlexRow, { children: [_jsx(Typography, Object.assign({ marginLeft: icon ? 1 : 0, variant: "body1", fontFamily: fontFamily, visibility: address ? 'inherit' : 'hidden' }, { children: testToDisplay }), void 0), address ? null : (_jsx(Typography, Object.assign({ position: "absolute", marginLeft: icon ? 1 : 0, variant: "body1", fontFamily: fontFamily }, { children: "-- --" }), void 0))] }, void 0)), isLocalAddress ? _jsx(FlexRow, Object.assign({ marginLeft: 0.5 }, { children: "(You)" }), void 0) : null] }), void 0) }), void 0));
|
|
45
43
|
};
|
|
46
44
|
export { EthAccount };
|
|
47
45
|
//# sourceMappingURL=EthAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthAccount.js","sourceRoot":"","sources":["../../../src/components/EthAccount/EthAccount.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,cAAc,CAAA;AAGxC,MAAM,UAAU,GAA8B,CAAC,EAU9C,EAAE,EAAE;QAV0C,EAC7C,OAAO,EACP,IAAI,GAAG,KAAK,EACZ,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,KAAK,EAChB,aAAa,GAAG,MAAM,EACtB,UAAU,GAAG,6BAA6B,EAC1C,WAAW,EACX,aAAa,OAEd,EADI,KAAK,cATqC,0GAU9C,CADS;IAER,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAClD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,EA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,CAAC,EACxB,OAAO,EAAC,OAAO,EACf,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,gBAEzC,aAAa,YACH,EACZ,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,KAAC,UAAU,kBAAC,QAAQ,EAAC,UAAU,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAC,OAAO,EAAC,UAAU,EAAE,UAAU,mCAEnF,CACd,YACO,CACX,EACA,cAAc,CAAC,CAAC,CAAC,KAAC,OAAO,kBAAC,UAAU,EAAE,GAAG,mCAAiB,CAAC,CAAC,CAAC,IAAI,aACtD,YACL,CACZ,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
3
3
|
declare const StorybookEntry: ComponentMeta<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
4
4
|
declare const Long: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
5
|
+
declare const LongEmpty: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
5
6
|
declare const Short: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
7
|
+
declare const ShortEmpty: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
6
8
|
declare const Auto: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
7
|
-
|
|
9
|
+
declare const AutoEmpty: ComponentStory<import("react").FC<import("./EthAccountProps").EthAccountProps>>;
|
|
10
|
+
export { Auto, AutoEmpty, Long, LongEmpty, Short, ShortEmpty };
|
|
8
11
|
export default StorybookEntry;
|
|
9
12
|
//# 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;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;
|
|
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,SAAS,iFAAoB,CAAA;AAQnC,QAAA,MAAM,KAAK,iFAAoB,CAAA;AAS/B,QAAA,MAAM,UAAU,iFAAoB,CAAA;AAQpC,QAAA,MAAM,IAAI,iFAAoB,CAAA;AAS9B,QAAA,MAAM,SAAS,iFAAoB,CAAA;AAQnC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;AAG9D,eAAe,cAAc,CAAA"}
|
|
@@ -21,6 +21,13 @@ Long.args = {
|
|
|
21
21
|
title: 'Sample EthAccount',
|
|
22
22
|
toEtherScan: true,
|
|
23
23
|
};
|
|
24
|
+
const LongEmpty = Template.bind({});
|
|
25
|
+
LongEmpty.args = {
|
|
26
|
+
addressLength: 'long',
|
|
27
|
+
icon: true,
|
|
28
|
+
title: 'Sample EthAccount',
|
|
29
|
+
toEtherScan: true,
|
|
30
|
+
};
|
|
24
31
|
const Short = Template.bind({});
|
|
25
32
|
Short.args = {
|
|
26
33
|
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
@@ -29,6 +36,13 @@ Short.args = {
|
|
|
29
36
|
title: 'Sample EthAccount',
|
|
30
37
|
toEtherScan: true,
|
|
31
38
|
};
|
|
39
|
+
const ShortEmpty = Template.bind({});
|
|
40
|
+
ShortEmpty.args = {
|
|
41
|
+
addressLength: 'short',
|
|
42
|
+
icon: true,
|
|
43
|
+
title: 'Sample EthAccount',
|
|
44
|
+
toEtherScan: true,
|
|
45
|
+
};
|
|
32
46
|
const Auto = Template.bind({});
|
|
33
47
|
Auto.args = {
|
|
34
48
|
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
@@ -37,7 +51,14 @@ Auto.args = {
|
|
|
37
51
|
title: 'Sample EthAccount',
|
|
38
52
|
toEtherScan: true,
|
|
39
53
|
};
|
|
40
|
-
|
|
54
|
+
const AutoEmpty = Template.bind({});
|
|
55
|
+
AutoEmpty.args = {
|
|
56
|
+
addressLength: 'auto',
|
|
57
|
+
icon: true,
|
|
58
|
+
title: 'Sample EthAccount',
|
|
59
|
+
toEtherScan: true,
|
|
60
|
+
};
|
|
61
|
+
export { Auto, AutoEmpty, Long, LongEmpty, Short, ShortEmpty };
|
|
41
62
|
// eslint-disable-next-line import/no-default-export
|
|
42
63
|
export default StorybookEntry;
|
|
43
64
|
//# 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,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MA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AW,EAAE,IAAI;CAClB,CAAA;AAED,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACpC,UAAU,CAAC,IAAI,GAAG;IAChB,aAAa,EAAE,OAAO;IACtB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,IAAI;CAClB,CAAA;AAED,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC9B,IAAI,CAAC,IAAI,GAAG;IACV,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,4CAA4C,CAAC;IAC5E,aAAa,EAAE,MAAM;IACrB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,IAAI;CAClB,CAAA;AAED,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACnC,SAAS,CAAC,IAAI,GAAG;IACf,aAAa,EAAE,MAAM;IACrB,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,IAAI;CAClB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAA;AAE9D,oDAAoD;AACpD,eAAe,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/react": "^17",
|
|
44
44
|
"@xylabs/eslint-config-react": "^2",
|
|
45
45
|
"@xylabs/pixel": "^1.1.6",
|
|
46
|
-
"@xylabs/sdk-js": "^2.3.
|
|
46
|
+
"@xylabs/sdk-js": "^2.3.13",
|
|
47
47
|
"@xylabs/ts-scripts": "^1.0.23",
|
|
48
48
|
"babel-loader": "^8.2.3",
|
|
49
49
|
"bn.js": "^5.2.0",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"sideEffects": false,
|
|
109
109
|
"type": "module",
|
|
110
110
|
"types": "dist/index.d.ts",
|
|
111
|
-
"version": "2.7.
|
|
111
|
+
"version": "2.7.9"
|
|
112
112
|
}
|
|
@@ -30,6 +30,14 @@ Long.args = {
|
|
|
30
30
|
toEtherScan: true,
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const LongEmpty = Template.bind({})
|
|
34
|
+
LongEmpty.args = {
|
|
35
|
+
addressLength: 'long',
|
|
36
|
+
icon: true,
|
|
37
|
+
title: 'Sample EthAccount',
|
|
38
|
+
toEtherScan: true,
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
const Short = Template.bind({})
|
|
34
42
|
Short.args = {
|
|
35
43
|
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
@@ -39,6 +47,14 @@ Short.args = {
|
|
|
39
47
|
toEtherScan: true,
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
const ShortEmpty = Template.bind({})
|
|
51
|
+
ShortEmpty.args = {
|
|
52
|
+
addressLength: 'short',
|
|
53
|
+
icon: true,
|
|
54
|
+
title: 'Sample EthAccount',
|
|
55
|
+
toEtherScan: true,
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
const Auto = Template.bind({})
|
|
43
59
|
Auto.args = {
|
|
44
60
|
address: EthAddress.fromString('0x6792b02f88b32c4fe8e31cfa41ae5af44865f930'),
|
|
@@ -48,7 +64,15 @@ Auto.args = {
|
|
|
48
64
|
toEtherScan: true,
|
|
49
65
|
}
|
|
50
66
|
|
|
51
|
-
|
|
67
|
+
const AutoEmpty = Template.bind({})
|
|
68
|
+
AutoEmpty.args = {
|
|
69
|
+
addressLength: 'auto',
|
|
70
|
+
icon: true,
|
|
71
|
+
title: 'Sample EthAccount',
|
|
72
|
+
toEtherScan: true,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Auto, AutoEmpty, Long, LongEmpty, Short, ShortEmpty }
|
|
52
76
|
|
|
53
77
|
// eslint-disable-next-line import/no-default-export
|
|
54
78
|
export default StorybookEntry
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Typography, useTheme } from '@mui/material'
|
|
2
|
+
import { assertEx, EthAddress } from '@xylabs/sdk-js'
|
|
2
3
|
import { MouseEvent, useContext } from 'react'
|
|
3
4
|
|
|
4
5
|
import { EthersContext } from '../../contexts'
|
|
@@ -24,41 +25,53 @@ const EthAccount: React.FC<EthAccountProps> = ({
|
|
|
24
25
|
|
|
25
26
|
const large = useMediaQuery(theme.breakpoints.up('md'))
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
const isLocalAddress = localAddress?.toString() === address.toString()
|
|
28
|
+
const isLocalAddress = address ? localAddress?.toString() === address.toString() : false
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
const onClickLocal = (event: MouseEvent<HTMLButtonElement>) => {
|
|
31
|
+
onButtonClick?.(event)
|
|
32
|
+
if (toEtherScan && address) {
|
|
33
|
+
window.open(`https://etherscan.io/address/${address.toString()}`, '_blank')
|
|
35
34
|
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const addressToDisplay = assertEx(address ?? EthAddress.fromString('0x00'), 'Bad Eth Address')
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const testToDisplay =
|
|
40
|
+
addressLength === 'long'
|
|
41
|
+
? addressToDisplay.toString()
|
|
42
|
+
: addressLength === 'short'
|
|
43
|
+
? addressToDisplay.toShortString()
|
|
44
|
+
: large
|
|
45
|
+
? addressToDisplay.toString()
|
|
46
|
+
: addressToDisplay.toShortString()
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// Note: We use the all zero address for spacing in case it is
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<ButtonEx onClick={onClickLocal} title={`0x${address?.toHex()}`} {...props}>
|
|
52
|
+
<FlexGrowRow justifyContent="space-between" alignItems="center">
|
|
53
|
+
{icon ? <Identicon size={iconSize} value={address?.toHex()} /> : null}
|
|
54
|
+
{iconOnly ? null : (
|
|
55
|
+
<FlexRow>
|
|
56
|
+
<Typography
|
|
57
|
+
marginLeft={icon ? 1 : 0}
|
|
58
|
+
variant="body1"
|
|
59
|
+
fontFamily={fontFamily}
|
|
60
|
+
visibility={address ? 'inherit' : 'hidden'}
|
|
61
|
+
>
|
|
52
62
|
{testToDisplay}
|
|
53
63
|
</Typography>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
{address ? null : (
|
|
65
|
+
<Typography position="absolute" marginLeft={icon ? 1 : 0} variant="body1" fontFamily={fontFamily}>
|
|
66
|
+
-- --
|
|
67
|
+
</Typography>
|
|
68
|
+
)}
|
|
69
|
+
</FlexRow>
|
|
70
|
+
)}
|
|
71
|
+
{isLocalAddress ? <FlexRow marginLeft={0.5}>(You)</FlexRow> : null}
|
|
72
|
+
</FlexGrowRow>
|
|
73
|
+
</ButtonEx>
|
|
74
|
+
)
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
export { EthAccount }
|