UI Improvements (#9)
* Add loading spinners for buttons * Add navigation to home page * Add logo inside anchor tag
This commit is contained in:
parent
401ca279bf
commit
3adcdfa39c
@ -6,6 +6,7 @@
|
|||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.11.4",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
"@mui/icons-material": "^5.15.14",
|
"@mui/icons-material": "^5.15.14",
|
||||||
|
"@mui/lab": "^5.0.0-alpha.169",
|
||||||
"@mui/material": "^5.15.14",
|
"@mui/material": "^5.15.14",
|
||||||
"@testing-library/jest-dom": "^5.17.0",
|
"@testing-library/jest-dom": "^5.17.0",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
|
@ -109,7 +109,7 @@ export const WalletConnectProvider = ({
|
|||||||
eip155: {
|
eip155: {
|
||||||
methods: ["personal_sign"],
|
methods: ["personal_sign"],
|
||||||
chains: ["eip155:1"],
|
chains: ["eip155:1"],
|
||||||
events: ["connect", "disconnect"],
|
events: [],
|
||||||
},
|
},
|
||||||
cosmos: {
|
cosmos: {
|
||||||
methods: ["cosmos_signDirect", "cosmos_signAmino"],
|
methods: ["cosmos_signDirect", "cosmos_signAmino"],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Outlet, useNavigate } from "react-router-dom";
|
import { Outlet, useNavigate, Link } from "react-router-dom";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Toolbar,
|
Toolbar,
|
||||||
@ -8,6 +8,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Typography,
|
Typography,
|
||||||
Container,
|
Container,
|
||||||
|
Box
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
||||||
@ -24,18 +25,22 @@ const SignPageLayout = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Toolbar variant="dense">
|
<Toolbar variant="dense">
|
||||||
<Avatar
|
<Link to="/" style={{ color: 'inherit', textDecoration: 'none' }}>
|
||||||
alt="Urbit logo"
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
src="https://avatars.githubusercontent.com/u/5237680?s=200&v=4"
|
<Avatar
|
||||||
/>
|
alt="Urbit logo"
|
||||||
<IconButton
|
src="https://avatars.githubusercontent.com/u/5237680?s=200&v=4"
|
||||||
edge="start"
|
/>
|
||||||
color="inherit"
|
<IconButton
|
||||||
aria-label="menu"
|
edge="start"
|
||||||
sx={{ mr: 2 }}
|
color="inherit"
|
||||||
>
|
aria-label="menu"
|
||||||
Urbit
|
sx={{ mr: 2 }}
|
||||||
</IconButton>
|
>
|
||||||
|
Urbit
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
</Link>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import LoadingButton from "@mui/lab/LoadingButton/LoadingButton";
|
||||||
|
|
||||||
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ const SignWithCosmos = () => {
|
|||||||
const { ethAddress, ethSignature } = useParams();
|
const { ethAddress, ethSignature } = useParams();
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [cosmosSignature, setCosmosSignature] = useState("");
|
const [cosmosSignature, setCosmosSignature] = useState("");
|
||||||
|
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@ -52,6 +54,7 @@ const SignWithCosmos = () => {
|
|||||||
const signCosmos = async () => {
|
const signCosmos = async () => {
|
||||||
try {
|
try {
|
||||||
if (ethAddress) {
|
if (ethAddress) {
|
||||||
|
setIsLoading(true)
|
||||||
const signDoc = {
|
const signDoc = {
|
||||||
msgs: [],
|
msgs: [],
|
||||||
fee: { amount: [], gas: "23" },
|
fee: { amount: [], gas: "23" },
|
||||||
@ -71,11 +74,13 @@ const SignWithCosmos = () => {
|
|||||||
params,
|
params,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
setIsLoading(false)
|
||||||
setOpenModal(true);
|
setOpenModal(true);
|
||||||
setCosmosSignature(signedMessage.signature);
|
setCosmosSignature(signedMessage.signature);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("err in signing ", error);
|
console.log("err in signing ", error);
|
||||||
|
setIsLoading(false)
|
||||||
setOpenModal(false);
|
setOpenModal(false);
|
||||||
enqueueSnackbar("Error signing message", { variant: "error" });
|
enqueueSnackbar("Error signing message", { variant: "error" });
|
||||||
}
|
}
|
||||||
@ -103,19 +108,20 @@ const SignWithCosmos = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<pre style={{ whiteSpace: "pre-wrap", margin: 0 }}>
|
<pre style={{ whiteSpace: "pre-wrap", margin: 0 }}>
|
||||||
{JSON.stringify(message, null, 2)}{" "}
|
{canonicalStringify(message, null, 2)}{" "}
|
||||||
</pre>
|
</pre>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
signCosmos();
|
signCosmos();
|
||||||
}}
|
}}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Sign with cosmos
|
Sign with cosmos
|
||||||
</Button>
|
</LoadingButton>
|
||||||
</Box>
|
</Box>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={openModal}
|
open={openModal}
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
import { utf8ToHex } from "@walletconnect/encoding";
|
import { utf8ToHex } from "@walletconnect/encoding";
|
||||||
|
|
||||||
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
||||||
@ -35,6 +36,7 @@ const SignWithEthereum = () => {
|
|||||||
const [cosmosAddress, setCosmosAddress] = useState("");
|
const [cosmosAddress, setCosmosAddress] = useState("");
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const message = useMemo(() => {
|
const message = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
@ -46,6 +48,7 @@ const SignWithEthereum = () => {
|
|||||||
const signEth = async () => {
|
const signEth = async () => {
|
||||||
if (session && signClient) {
|
if (session && signClient) {
|
||||||
try {
|
try {
|
||||||
|
setIsLoading(true)
|
||||||
const jsonMessage = canonicalStringify(message);
|
const jsonMessage = canonicalStringify(message);
|
||||||
const hexMsg = utf8ToHex(jsonMessage, true);
|
const hexMsg = utf8ToHex(jsonMessage, true);
|
||||||
const ethSignature: string = await signClient!.request({
|
const ethSignature: string = await signClient!.request({
|
||||||
@ -56,10 +59,12 @@ const SignWithEthereum = () => {
|
|||||||
params: [hexMsg, ethAddress],
|
params: [hexMsg, ethAddress],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
setIsLoading(false)
|
||||||
setEthSignature(ethSignature);
|
setEthSignature(ethSignature);
|
||||||
setOpenModal(true);
|
setOpenModal(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("err in signing ", error);
|
console.log("err in signing ", error);
|
||||||
|
setIsLoading(false)
|
||||||
setOpenModal(false);
|
setOpenModal(false);
|
||||||
enqueueSnackbar("Error signing message", { variant: "error" });
|
enqueueSnackbar("Error signing message", { variant: "error" });
|
||||||
}
|
}
|
||||||
@ -90,7 +95,6 @@ const SignWithEthereum = () => {
|
|||||||
labelId="demo-simple-select-label"
|
labelId="demo-simple-select-label"
|
||||||
id="demo-simple-select"
|
id="demo-simple-select"
|
||||||
value={cosmosAddress}
|
value={cosmosAddress}
|
||||||
label="Cosmos address"
|
|
||||||
onChange={(e: any) => {
|
onChange={(e: any) => {
|
||||||
setCosmosAddress(e.target.value);
|
setCosmosAddress(e.target.value);
|
||||||
}}
|
}}
|
||||||
@ -107,7 +111,6 @@ const SignWithEthereum = () => {
|
|||||||
labelId="demo-simple-select-label"
|
labelId="demo-simple-select-label"
|
||||||
id="demo-simple-select"
|
id="demo-simple-select"
|
||||||
value={ethAddress}
|
value={ethAddress}
|
||||||
label="Ethereum address"
|
|
||||||
onChange={(e: any) => {
|
onChange={(e: any) => {
|
||||||
setEthAddress(e.target.value);
|
setEthAddress(e.target.value);
|
||||||
}}
|
}}
|
||||||
@ -127,17 +130,18 @@ const SignWithEthereum = () => {
|
|||||||
wordWrap: "break-word",
|
wordWrap: "break-word",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<pre style={{ whiteSpace: "pre-wrap", margin: 0 }}>{JSON.stringify(message, null, 2)} </pre>
|
<pre style={{ whiteSpace: "pre-wrap", margin: 0 }}>{canonicalStringify(message, null, 2)} </pre>
|
||||||
</Box>)}
|
</Box>)}
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<LoadingButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={signEth}
|
onClick={signEth}
|
||||||
disabled={!Boolean(ethAddress)}
|
disabled={!Boolean(ethAddress)}
|
||||||
style={{ marginTop: "20px" }}
|
style={{ marginTop: "20px" }}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Sign using Ethereum key
|
Sign using Ethereum key
|
||||||
</Button>
|
</LoadingButton>
|
||||||
</Box>
|
</Box>
|
||||||
<Dialog
|
<Dialog
|
||||||
open={openModal}
|
open={openModal}
|
||||||
|
13
yarn.lock
13
yarn.lock
@ -1894,6 +1894,19 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.23.9"
|
"@babel/runtime" "^7.23.9"
|
||||||
|
|
||||||
|
"@mui/lab@^5.0.0-alpha.169":
|
||||||
|
version "5.0.0-alpha.169"
|
||||||
|
resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.169.tgz#85b88b2f06ad78c586cde2b47970653e5fd895eb"
|
||||||
|
integrity sha512-h6xe1K6ISKUbyxTDgdvql4qoDP6+q8ad5fg9nXQxGLUrIeT2jVrBuT/jRECSTufbnhzP+V5kulvYxaMfM8rEdA==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.23.9"
|
||||||
|
"@mui/base" "5.0.0-beta.40"
|
||||||
|
"@mui/system" "^5.15.14"
|
||||||
|
"@mui/types" "^7.2.14"
|
||||||
|
"@mui/utils" "^5.15.14"
|
||||||
|
clsx "^2.1.0"
|
||||||
|
prop-types "^15.8.1"
|
||||||
|
|
||||||
"@mui/material@^5.15.14":
|
"@mui/material@^5.15.14":
|
||||||
version "5.15.14"
|
version "5.15.14"
|
||||||
resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.15.14.tgz#a40bd5eccfa9fc925535e1f4d70c6cef77fa3a75"
|
resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.15.14.tgz#a40bd5eccfa9fc925535e1f4d70c6cef77fa3a75"
|
||||||
|
Loading…
Reference in New Issue
Block a user