From 3adcdfa39c3359fc9a56797d3e36b34011fea6d6 Mon Sep 17 00:00:00 2001 From: neerajvijay1997 <111040298+neerajvijay1997@users.noreply.github.com> Date: Thu, 28 Mar 2024 09:14:06 +0530 Subject: [PATCH] UI Improvements (#9) * Add loading spinners for buttons * Add navigation to home page * Add logo inside anchor tag --- package.json | 1 + src/context/WalletConnectContext.tsx | 2 +- src/layout/SignPageLayout.tsx | 31 ++++++++++++++++------------ src/pages/SignWithCosmos.tsx | 12 ++++++++--- src/pages/SignWithEthereum.tsx | 16 ++++++++------ yarn.lock | 13 ++++++++++++ 6 files changed, 52 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 0981820..9dd7ce8 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.15.14", + "@mui/lab": "^5.0.0-alpha.169", "@mui/material": "^5.15.14", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", diff --git a/src/context/WalletConnectContext.tsx b/src/context/WalletConnectContext.tsx index 0e7e8ab..027b95d 100644 --- a/src/context/WalletConnectContext.tsx +++ b/src/context/WalletConnectContext.tsx @@ -109,7 +109,7 @@ export const WalletConnectProvider = ({ eip155: { methods: ["personal_sign"], chains: ["eip155:1"], - events: ["connect", "disconnect"], + events: [], }, cosmos: { methods: ["cosmos_signDirect", "cosmos_signAmino"], diff --git a/src/layout/SignPageLayout.tsx b/src/layout/SignPageLayout.tsx index 0374892..3fe8744 100644 --- a/src/layout/SignPageLayout.tsx +++ b/src/layout/SignPageLayout.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Outlet, useNavigate } from "react-router-dom"; +import { Outlet, useNavigate, Link } from "react-router-dom"; import { Toolbar, @@ -8,6 +8,7 @@ import { Button, Typography, Container, + Box } from "@mui/material"; import { useWalletConnectContext } from "../context/WalletConnectContext"; @@ -24,18 +25,22 @@ const SignPageLayout = () => { return ( <> - - - Urbit - + + + + + Urbit + + + + { const [cosmosAddress, setCosmosAddress] = useState(""); const [openModal, setOpenModal] = useState(false); + const [isLoading, setIsLoading] = useState(false); const message = useMemo(() => { return { @@ -46,6 +48,7 @@ const SignWithEthereum = () => { const signEth = async () => { if (session && signClient) { try { + setIsLoading(true) const jsonMessage = canonicalStringify(message); const hexMsg = utf8ToHex(jsonMessage, true); const ethSignature: string = await signClient!.request({ @@ -56,10 +59,12 @@ const SignWithEthereum = () => { params: [hexMsg, ethAddress], }, }); + setIsLoading(false) setEthSignature(ethSignature); setOpenModal(true); } catch (error) { console.log("err in signing ", error); + setIsLoading(false) setOpenModal(false); enqueueSnackbar("Error signing message", { variant: "error" }); } @@ -90,7 +95,6 @@ const SignWithEthereum = () => { labelId="demo-simple-select-label" id="demo-simple-select" value={cosmosAddress} - label="Cosmos address" onChange={(e: any) => { setCosmosAddress(e.target.value); }} @@ -107,7 +111,6 @@ const SignWithEthereum = () => { labelId="demo-simple-select-label" id="demo-simple-select" value={ethAddress} - label="Ethereum address" onChange={(e: any) => { setEthAddress(e.target.value); }} @@ -127,17 +130,18 @@ const SignWithEthereum = () => { wordWrap: "break-word", }} > -
{JSON.stringify(message, null, 2)} 
+
{canonicalStringify(message, null, 2)} 
)} - + Sign using Ethereum key +