@xylabs/sdk-react 2.12.4 → 2.12.7
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/cjs/components/Errors/ErrorsViewer.js +2 -2
- package/dist/cjs/components/Errors/ErrorsViewer.js.map +1 -1
- package/dist/cjs/components/QuickTipButton/QuickTipButton.d.ts +4 -2
- package/dist/cjs/components/QuickTipButton/QuickTipButton.js +3 -3
- package/dist/cjs/components/QuickTipButton/QuickTipButton.js.map +1 -1
- package/dist/cjs/components/QuickTipButton/index.d.ts +1 -2
- package/dist/cjs/components/QuickTipButton/index.js +2 -3
- package/dist/cjs/components/QuickTipButton/index.js.map +1 -1
- package/dist/cjs/contexts/Ethers/MetaMask.js +21 -19
- package/dist/cjs/contexts/Ethers/MetaMask.js.map +1 -1
- package/dist/cjs/nodeIndex.d.ts +2 -0
- package/dist/cjs/nodeIndex.js +6 -0
- package/dist/cjs/nodeIndex.js.map +1 -0
- package/dist/docs.json +31326 -21769
- package/dist/esm/components/Errors/ErrorsViewer.js +2 -2
- package/dist/esm/components/Errors/ErrorsViewer.js.map +1 -1
- package/dist/esm/components/QuickTipButton/QuickTipButton.d.ts +4 -2
- package/dist/esm/components/QuickTipButton/QuickTipButton.js +3 -4
- package/dist/esm/components/QuickTipButton/QuickTipButton.js.map +1 -1
- package/dist/esm/components/QuickTipButton/index.d.ts +1 -2
- package/dist/esm/components/QuickTipButton/index.js +1 -2
- package/dist/esm/components/QuickTipButton/index.js.map +1 -1
- package/dist/esm/contexts/Ethers/MetaMask.js +19 -16
- package/dist/esm/contexts/Ethers/MetaMask.js.map +1 -1
- package/dist/esm/nodeIndex.d.ts +2 -0
- package/dist/esm/nodeIndex.js +3 -0
- package/dist/esm/nodeIndex.js.map +1 -0
- package/package.json +32 -32
- package/src/components/Errors/ErrorsViewer.tsx +2 -2
- package/src/components/QuickTipButton/QuickTipButton.stories.tsx +6 -1
- package/src/components/QuickTipButton/QuickTipButton.tsx +7 -5
- package/src/components/QuickTipButton/index.ts +1 -3
- package/src/contexts/Ethers/MetaMask.tsx +21 -18
- package/src/contexts/Ethers/global.d.ts +8 -0
- package/src/nodeIndex.ts +2 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ReplayIcon from '@mui/icons-material/Replay';
|
|
2
3
|
import { IconButton } from '@mui/material';
|
|
3
|
-
import { AiOutlineReload } from 'react-icons/ai';
|
|
4
4
|
import { FlexGrowCol } from '../FlexBox';
|
|
5
5
|
import { ErrorViewer } from './ErrorViewer';
|
|
6
6
|
const ErrorsViewer = (props) => {
|
|
7
7
|
const { onRetry, errors, ...boxProps } = props;
|
|
8
8
|
return (_jsxs(FlexGrowCol, { padding: 1, ...boxProps, children: [errors?.map((error, index) => {
|
|
9
9
|
return _jsx(ErrorViewer, { error: error }, index);
|
|
10
|
-
}), onRetry ? (_jsx(IconButton, { onClick: onRetry, children: _jsx(
|
|
10
|
+
}), onRetry ? (_jsx(IconButton, { onClick: onRetry, children: _jsx(ReplayIcon, {}) })) : null] }));
|
|
11
11
|
};
|
|
12
12
|
export { ErrorsViewer };
|
|
13
13
|
//# sourceMappingURL=ErrorsViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorsViewer.js","sourceRoot":"","sources":["../../../../src/components/Errors/ErrorsViewer.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ErrorsViewer.js","sourceRoot":"","sources":["../../../../src/components/Errors/ErrorsViewer.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,YAAY,GAAgC,CAAC,KAAK,EAAE,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC9C,OAAO,CACL,MAAC,WAAW,IAAC,OAAO,EAAE,CAAC,KAAM,QAAQ,aAClC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC5B,OAAO,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,IAAO,KAAK,CAAI,CAAA;YAClD,CAAC,CAAC,EACD,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,UAAU,IAAC,OAAO,EAAE,OAAO,YAC1B,KAAC,UAAU,KAAG,GACH,CACd,CAAC,CAAC,CAAC,IAAI,IACI,CACf,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconButtonProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface QuickTipButtonProps extends IconButtonProps {
|
|
4
|
+
fontSize?: 'small' | 'medium' | 'large' | 'inherit';
|
|
5
|
+
}
|
|
6
|
+
export declare const QuickTipButton: React.FC<QuickTipButtonProps>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
|
|
2
3
|
import { IconButton } from '@mui/material';
|
|
3
4
|
import { useState } from 'react';
|
|
4
|
-
import { AiOutlineQuestionCircle } from 'react-icons/ai';
|
|
5
5
|
import { MessageDialog } from '../dialogs';
|
|
6
|
-
const QuickTipButton = ({ title, children, ...props }) => {
|
|
6
|
+
export const QuickTipButton = ({ fontSize = 'inherit', title, children, ...props }) => {
|
|
7
7
|
const [messageOpen, setMessageOpen] = useState(false);
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { onClick: () => setMessageOpen(true), size: "small", ...props, children: _jsx(
|
|
8
|
+
return (_jsxs(_Fragment, { children: [_jsx(IconButton, { onClick: () => setMessageOpen(true), size: "small", ...props, children: _jsx(HelpOutlineIcon, { fontSize: fontSize }) }), _jsx(MessageDialog, { onOk: () => setMessageOpen(false), onCancel: () => setMessageOpen(false), onClose: () => setMessageOpen(false), open: messageOpen, title: title ?? '', children: children })] }));
|
|
9
9
|
};
|
|
10
|
-
export { QuickTipButton };
|
|
11
10
|
//# sourceMappingURL=QuickTipButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickTipButton.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/QuickTipButton.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"QuickTipButton.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/QuickTipButton.tsx"],"names":[],"mappings":";AAAA,OAAO,eAAe,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAM1C,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACnH,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAErD,OAAO,CACL,8BACE,KAAC,UAAU,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAC,OAAO,KAAK,KAAK,YACrE,KAAC,eAAe,IAAC,QAAQ,EAAE,QAAQ,GAAI,GAC5B,EACb,KAAC,aAAa,IAAC,IAAI,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,YACjK,QAAQ,GACK,IACf,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { QuickTipButton };
|
|
1
|
+
export * from './QuickTipButton';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/QuickTipButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -7,24 +7,30 @@ import { EthersContext } from './Context';
|
|
|
7
7
|
import { infuraKey } from './Infura';
|
|
8
8
|
export const MetaMaskEthersLoader = (props) => {
|
|
9
9
|
const { children, enabled = true } = props;
|
|
10
|
-
|
|
11
|
-
const global = window;
|
|
12
|
-
const ethereum = global.ethereum;
|
|
10
|
+
const ethereum = window.ethereum;
|
|
13
11
|
const [error, setError] = useState();
|
|
14
12
|
const [localAddress, setLocalAddress] = useState();
|
|
15
13
|
const [resetCount, setResetCount] = useState(0);
|
|
16
14
|
const [providerName, setProviderName] = useState();
|
|
17
|
-
if (ethereum) {
|
|
18
|
-
ethereum.autoRefreshOnNetworkChange = false;
|
|
19
|
-
}
|
|
20
15
|
const connect = async () => {
|
|
21
|
-
await
|
|
22
|
-
|
|
16
|
+
const accounts = await walletProvider?.send('eth_requestAccounts', []);
|
|
17
|
+
// We could have multiple accounts. Check for one.
|
|
18
|
+
if (accounts.length !== 0) {
|
|
19
|
+
setLocalAddress(accounts[0]);
|
|
20
|
+
console.log('Connected: ', accounts[0]);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log('No authorized account found.');
|
|
24
|
+
}
|
|
25
|
+
return accounts;
|
|
23
26
|
};
|
|
24
27
|
const [isConnected, setIsConnected] = useState();
|
|
28
|
+
const [walletProvider, setWalletProvider] = useState();
|
|
29
|
+
const [provider, setProvider] = useState();
|
|
30
|
+
const [signer, setSigner] = useState();
|
|
25
31
|
useEffect(() => {
|
|
26
|
-
if (
|
|
27
|
-
|
|
32
|
+
if (provider && enabled) {
|
|
33
|
+
provider.on('accountsChanged', (accounts) => {
|
|
28
34
|
console.log(`accountsChanged: ${JSON.stringify(accounts)}`);
|
|
29
35
|
setResetCount(resetCount + 1);
|
|
30
36
|
if (accounts.length > 0) {
|
|
@@ -34,7 +40,7 @@ export const MetaMaskEthersLoader = (props) => {
|
|
|
34
40
|
setLocalAddress(undefined);
|
|
35
41
|
}
|
|
36
42
|
});
|
|
37
|
-
|
|
43
|
+
provider.on('chainChanged', (chainId) => {
|
|
38
44
|
setResetCount(resetCount + 1);
|
|
39
45
|
if (chainId) {
|
|
40
46
|
setChainId(parseInt(chainId));
|
|
@@ -44,13 +50,10 @@ export const MetaMaskEthersLoader = (props) => {
|
|
|
44
50
|
}
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
|
-
}, [
|
|
48
|
-
const [walletProvider, setWalletProvider] = useState();
|
|
49
|
-
const [provider, setProvider] = useState();
|
|
50
|
-
const [signer, setSigner] = useState();
|
|
53
|
+
}, [provider, resetCount, enabled]);
|
|
51
54
|
useEffect(() => {
|
|
52
55
|
if (enabled) {
|
|
53
|
-
const walletProvider = ethereum ? new Web3Provider(ethereum) : null;
|
|
56
|
+
const walletProvider = ethereum ? new Web3Provider(window.ethereum) : null;
|
|
54
57
|
let provider = null;
|
|
55
58
|
let providerName = null;
|
|
56
59
|
if (walletProvider) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaMask.js","sourceRoot":"","sources":["../../../../src/contexts/Ethers/Met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mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@emotion/react": "^11.9.0",
|
|
13
13
|
"@emotion/styled": "^11.8.1",
|
|
14
|
-
"@ethersproject/abstract-signer": "^5.6.
|
|
15
|
-
"@ethersproject/providers": "^5.6.
|
|
16
|
-
"@
|
|
17
|
-
"@mui/material": "^5.
|
|
18
|
-
"@mui/
|
|
14
|
+
"@ethersproject/abstract-signer": "^5.6.1",
|
|
15
|
+
"@ethersproject/providers": "^5.6.7",
|
|
16
|
+
"@metamask/providers": "^8.1.1",
|
|
17
|
+
"@mui/icons-material": "^5.8.0",
|
|
18
|
+
"@mui/material": "^5.8.1",
|
|
19
|
+
"@mui/styles": "^5.8.0",
|
|
19
20
|
"@xylabs/pixel": "^1.3.7",
|
|
20
21
|
"@xylabs/sdk-js": "^2.5.5",
|
|
21
22
|
"axios": "^0.27.2",
|
|
@@ -24,49 +25,48 @@
|
|
|
24
25
|
"numeral": "^2.0.6",
|
|
25
26
|
"query-string": "^7.1.1",
|
|
26
27
|
"react-helmet": "^6.1.0",
|
|
27
|
-
"react-icons": "^4.3.1",
|
|
28
28
|
"react-router-dom": "^6.3.0"
|
|
29
29
|
},
|
|
30
30
|
"description": "Common React library for all XY Labs projects that use React",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/core": "^7.
|
|
33
|
-
"@babel/preset-env": "^7.
|
|
34
|
-
"@storybook/addon-actions": "^6.4
|
|
35
|
-
"@storybook/addon-docs": "^6.4
|
|
36
|
-
"@storybook/addon-essentials": "^6.4
|
|
37
|
-
"@storybook/addon-interactions": "^6.4
|
|
38
|
-
"@storybook/addon-links": "^6.4
|
|
39
|
-
"@storybook/addons": "^6.4
|
|
40
|
-
"@storybook/api": "^6.4
|
|
41
|
-
"@storybook/builder-webpack5": "^6.4
|
|
42
|
-
"@storybook/components": "^6.4
|
|
43
|
-
"@storybook/core-events": "^6.4
|
|
44
|
-
"@storybook/manager-webpack5": "^6.4
|
|
45
|
-
"@storybook/react": "^6.4
|
|
32
|
+
"@babel/core": "^7.18.0",
|
|
33
|
+
"@babel/preset-env": "^7.18.0",
|
|
34
|
+
"@storybook/addon-actions": "^6.5.4",
|
|
35
|
+
"@storybook/addon-docs": "^6.5.4",
|
|
36
|
+
"@storybook/addon-essentials": "^6.5.4",
|
|
37
|
+
"@storybook/addon-interactions": "^6.5.4",
|
|
38
|
+
"@storybook/addon-links": "^6.5.4",
|
|
39
|
+
"@storybook/addons": "^6.5.4",
|
|
40
|
+
"@storybook/api": "^6.5.4",
|
|
41
|
+
"@storybook/builder-webpack5": "^6.5.4",
|
|
42
|
+
"@storybook/components": "^6.5.4",
|
|
43
|
+
"@storybook/core-events": "^6.5.4",
|
|
44
|
+
"@storybook/manager-webpack5": "^6.5.4",
|
|
45
|
+
"@storybook/react": "^6.5.4",
|
|
46
46
|
"@storybook/testing-library": "^0.0.11",
|
|
47
|
-
"@storybook/theming": "^6.4
|
|
47
|
+
"@storybook/theming": "^6.5.4",
|
|
48
48
|
"@types/lodash": "^4.14.182",
|
|
49
49
|
"@types/md5": "^2.3.2",
|
|
50
50
|
"@types/numeral": "^2.0.2",
|
|
51
|
-
"@types/react": "^18.0.
|
|
52
|
-
"@types/react-dom": "^18.0.
|
|
51
|
+
"@types/react": "^18.0.9",
|
|
52
|
+
"@types/react-dom": "^18.0.5",
|
|
53
53
|
"@types/react-helmet": "^6.1.5",
|
|
54
54
|
"@xylabs/eslint-config-react": "^2.1.5",
|
|
55
55
|
"@xylabs/rollup-config": "^1.1.17",
|
|
56
|
-
"@xylabs/ts-scripts": "^1.0.
|
|
56
|
+
"@xylabs/ts-scripts": "^1.0.66",
|
|
57
57
|
"@xylabs/tsconfig": "^1.0.13",
|
|
58
58
|
"copyfiles": "^2.4.1",
|
|
59
59
|
"depcheck": "^1.4.3",
|
|
60
|
-
"eslint": "^8.
|
|
60
|
+
"eslint": "^8.16.0",
|
|
61
61
|
"react": "^18.1.0",
|
|
62
62
|
"react-dom": "^18.1.0",
|
|
63
63
|
"rimraf": "^3.0.2",
|
|
64
|
-
"rollup": "^2.
|
|
64
|
+
"rollup": "^2.74.1",
|
|
65
65
|
"storybook-dark-mode": "^1.1.0",
|
|
66
|
-
"ts-node": "^10.
|
|
66
|
+
"ts-node": "^10.8.0",
|
|
67
67
|
"typedoc": "^0.22.15",
|
|
68
68
|
"typescript": "^4.6.4",
|
|
69
|
-
"webpack": "^5.72.
|
|
69
|
+
"webpack": "^5.72.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "*",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"exports": {
|
|
82
82
|
".": {
|
|
83
83
|
"node": {
|
|
84
|
-
"import": "./dist/esm/
|
|
85
|
-
"require": "./dist/cjs/
|
|
84
|
+
"import": "./dist/esm/nodeIndex.js",
|
|
85
|
+
"require": "./dist/cjs/nodeIndex.js"
|
|
86
86
|
},
|
|
87
87
|
"browser": {
|
|
88
88
|
"import": "./dist/esm/index.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
},
|
|
96
96
|
"./package.json": "./package.json"
|
|
97
97
|
},
|
|
98
|
-
"main": "dist/cjs/
|
|
98
|
+
"main": "dist/cjs/nodeIndex.js",
|
|
99
99
|
"module": "dist/esm/index.js",
|
|
100
100
|
"homepage": "https://xylabs.com",
|
|
101
101
|
"keywords": [
|
|
@@ -126,6 +126,6 @@
|
|
|
126
126
|
},
|
|
127
127
|
"sideEffects": false,
|
|
128
128
|
"types": "dist/esm/index.d.ts",
|
|
129
|
-
"version": "2.12.
|
|
129
|
+
"version": "2.12.7",
|
|
130
130
|
"packageManager": "yarn@3.1.1"
|
|
131
131
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import ReplayIcon from '@mui/icons-material/Replay'
|
|
1
2
|
import { IconButton } from '@mui/material'
|
|
2
3
|
import React from 'react'
|
|
3
|
-
import { AiOutlineReload } from 'react-icons/ai'
|
|
4
4
|
|
|
5
5
|
import { FlexGrowCol } from '../FlexBox'
|
|
6
6
|
import { ErrorsViewerProps } from './ErrorsViewerProps'
|
|
@@ -15,7 +15,7 @@ const ErrorsViewer: React.FC<ErrorsViewerProps> = (props) => {
|
|
|
15
15
|
})}
|
|
16
16
|
{onRetry ? (
|
|
17
17
|
<IconButton onClick={onRetry}>
|
|
18
|
-
<
|
|
18
|
+
<ReplayIcon />
|
|
19
19
|
</IconButton>
|
|
20
20
|
) : null}
|
|
21
21
|
</FlexGrowCol>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Typography } from '@mui/material'
|
|
2
2
|
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
3
3
|
|
|
4
|
+
import { FlexRow } from '../FlexBox'
|
|
4
5
|
import { QuickTipButton } from './QuickTipButton'
|
|
5
6
|
|
|
6
7
|
const StorybookEntry = {
|
|
@@ -14,7 +15,11 @@ const StorybookEntry = {
|
|
|
14
15
|
title: 'Components/QuickTipButton',
|
|
15
16
|
} as ComponentMeta<typeof QuickTipButton>
|
|
16
17
|
|
|
17
|
-
const Template: ComponentStory<typeof QuickTipButton> = (args) =>
|
|
18
|
+
const Template: ComponentStory<typeof QuickTipButton> = (args) => (
|
|
19
|
+
<FlexRow>
|
|
20
|
+
<QuickTipButton {...args}></QuickTipButton>
|
|
21
|
+
</FlexRow>
|
|
22
|
+
)
|
|
18
23
|
|
|
19
24
|
const Default = Template.bind({})
|
|
20
25
|
Default.args = {
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import HelpOutlineIcon from '@mui/icons-material/HelpOutline'
|
|
1
2
|
import { IconButton, IconButtonProps } from '@mui/material'
|
|
2
3
|
import { useState } from 'react'
|
|
3
|
-
import { AiOutlineQuestionCircle } from 'react-icons/ai'
|
|
4
4
|
|
|
5
5
|
import { MessageDialog } from '../dialogs'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export interface QuickTipButtonProps extends IconButtonProps {
|
|
8
|
+
fontSize?: 'small' | 'medium' | 'large' | 'inherit'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const QuickTipButton: React.FC<QuickTipButtonProps> = ({ fontSize = 'inherit', title, children, ...props }) => {
|
|
8
12
|
const [messageOpen, setMessageOpen] = useState(false)
|
|
9
13
|
|
|
10
14
|
return (
|
|
11
15
|
<>
|
|
12
16
|
<IconButton onClick={() => setMessageOpen(true)} size="small" {...props}>
|
|
13
|
-
<
|
|
17
|
+
<HelpOutlineIcon fontSize={fontSize} />
|
|
14
18
|
</IconButton>
|
|
15
19
|
<MessageDialog onOk={() => setMessageOpen(false)} onCancel={() => setMessageOpen(false)} onClose={() => setMessageOpen(false)} open={messageOpen} title={title ?? ''}>
|
|
16
20
|
{children}
|
|
@@ -18,5 +22,3 @@ const QuickTipButton: React.FC<IconButtonProps> = ({ title, children, ...props }
|
|
|
18
22
|
</>
|
|
19
23
|
)
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
export { QuickTipButton }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InfuraProvider, JsonRpcSigner, Provider, Web3Provider } from '@ethersproject/providers'
|
|
2
|
+
import { MetaMaskInpageProvider } from '@metamask/providers'
|
|
2
3
|
import { EthAddress } from '@xylabs/sdk-js'
|
|
3
4
|
import React, { PropsWithChildren, useEffect, useState } from 'react'
|
|
4
5
|
|
|
@@ -12,28 +13,34 @@ interface Props {
|
|
|
12
13
|
|
|
13
14
|
export const MetaMaskEthersLoader: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
14
15
|
const { children, enabled = true } = props
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const ethereum = global.ethereum
|
|
16
|
+
|
|
17
|
+
const ethereum = window.ethereum as MetaMaskInpageProvider
|
|
18
18
|
const [error, setError] = useState<Error>()
|
|
19
19
|
const [localAddress, setLocalAddress] = useState<EthAddress>()
|
|
20
20
|
const [resetCount, setResetCount] = useState(0)
|
|
21
21
|
const [providerName, setProviderName] = useState<string>()
|
|
22
22
|
|
|
23
|
-
if (ethereum) {
|
|
24
|
-
ethereum.autoRefreshOnNetworkChange = false
|
|
25
|
-
}
|
|
26
|
-
|
|
27
23
|
const connect = async () => {
|
|
28
|
-
await
|
|
29
|
-
|
|
24
|
+
const accounts = await walletProvider?.send('eth_requestAccounts', [])
|
|
25
|
+
// We could have multiple accounts. Check for one.
|
|
26
|
+
if (accounts.length !== 0) {
|
|
27
|
+
setLocalAddress(accounts[0])
|
|
28
|
+
console.log('Connected: ', accounts[0])
|
|
29
|
+
} else {
|
|
30
|
+
console.log('No authorized account found.')
|
|
31
|
+
}
|
|
32
|
+
return accounts
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
const [isConnected, setIsConnected] = useState<boolean>()
|
|
33
36
|
|
|
37
|
+
const [walletProvider, setWalletProvider] = useState<Web3Provider | null>()
|
|
38
|
+
const [provider, setProvider] = useState<Provider>()
|
|
39
|
+
const [signer, setSigner] = useState<JsonRpcSigner | null>()
|
|
40
|
+
|
|
34
41
|
useEffect(() => {
|
|
35
|
-
if (
|
|
36
|
-
|
|
42
|
+
if (provider && enabled) {
|
|
43
|
+
provider.on('accountsChanged', (accounts: string[]) => {
|
|
37
44
|
console.log(`accountsChanged: ${JSON.stringify(accounts)}`)
|
|
38
45
|
setResetCount(resetCount + 1)
|
|
39
46
|
if (accounts.length > 0) {
|
|
@@ -42,7 +49,7 @@ export const MetaMaskEthersLoader: React.FC<PropsWithChildren<Props>> = (props)
|
|
|
42
49
|
setLocalAddress(undefined)
|
|
43
50
|
}
|
|
44
51
|
})
|
|
45
|
-
|
|
52
|
+
provider.on('chainChanged', (chainId: string) => {
|
|
46
53
|
setResetCount(resetCount + 1)
|
|
47
54
|
if (chainId) {
|
|
48
55
|
setChainId(parseInt(chainId))
|
|
@@ -51,15 +58,11 @@ export const MetaMaskEthersLoader: React.FC<PropsWithChildren<Props>> = (props)
|
|
|
51
58
|
}
|
|
52
59
|
})
|
|
53
60
|
}
|
|
54
|
-
}, [
|
|
55
|
-
|
|
56
|
-
const [walletProvider, setWalletProvider] = useState<Web3Provider | null>()
|
|
57
|
-
const [provider, setProvider] = useState<Provider>()
|
|
58
|
-
const [signer, setSigner] = useState<JsonRpcSigner | null>()
|
|
61
|
+
}, [provider, resetCount, enabled])
|
|
59
62
|
|
|
60
63
|
useEffect(() => {
|
|
61
64
|
if (enabled) {
|
|
62
|
-
const walletProvider = ethereum ? new Web3Provider(ethereum) : null
|
|
65
|
+
const walletProvider = ethereum ? new Web3Provider(window.ethereum) : null
|
|
63
66
|
let provider = null
|
|
64
67
|
let providerName = null
|
|
65
68
|
if (walletProvider) {
|
package/src/nodeIndex.ts
ADDED