Pass first message using state (#6)
* Pass inner message using state * Remove paranthesis * Change disconnect button color --------- Co-authored-by: Adw8 <adwait@deepstacksoft.com>
This commit is contained in:
parent
6bdaf60ff4
commit
229d9e62d3
@ -14,7 +14,7 @@ function App() {
|
|||||||
<Route path="/" element={<ConnectWallet />} />
|
<Route path="/" element={<ConnectWallet />} />
|
||||||
<Route element={<SignPageLayout />} >
|
<Route element={<SignPageLayout />} >
|
||||||
<Route path="/sign-with-ethereum" element={<SignWithEthereum />} />
|
<Route path="/sign-with-ethereum" element={<SignWithEthereum />} />
|
||||||
<Route path="/sign-with-cosmos/:ethAddress/:cosmosAddress/:ethSignature" element={<SignWithCosmos />} />
|
<Route path="/sign-with-cosmos/:ethAddress/:ethSignature" element={<SignWithCosmos />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="*" element={<PageNotFound />} />
|
<Route path="*" element={<PageNotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
@ -42,6 +42,7 @@ const SignPageLayout = () => {
|
|||||||
style={{
|
style={{
|
||||||
marginLeft: "auto",
|
marginLeft: "auto",
|
||||||
}}
|
}}
|
||||||
|
color="error"
|
||||||
onClick={disconnectHandler}
|
onClick={disconnectHandler}
|
||||||
>
|
>
|
||||||
Disconnect
|
Disconnect
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useMemo, useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams, useLocation } from "react-router-dom";
|
||||||
import { SnackbarProvider, enqueueSnackbar } from "notistack";
|
import { SnackbarProvider, enqueueSnackbar } from "notistack";
|
||||||
import canonicalStringify from "canonical-json";
|
import canonicalStringify from "canonical-json";
|
||||||
|
|
||||||
@ -17,43 +17,41 @@ import { useWalletConnectContext } from "../context/WalletConnectContext";
|
|||||||
const SignWithCosmos = () => {
|
const SignWithCosmos = () => {
|
||||||
const { session, signClient } = useWalletConnectContext();
|
const { session, signClient } = useWalletConnectContext();
|
||||||
|
|
||||||
const { ethAddress, cosmosAddress, ethSignature } = useParams();
|
const { ethAddress, ethSignature } = useParams();
|
||||||
|
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
const [cosmosSignature, setCosmosSignature] = useState("");
|
const [cosmosSignature, setCosmosSignature] = useState("");
|
||||||
|
|
||||||
|
const location = useLocation();
|
||||||
|
const innerMessage = location.state;
|
||||||
|
const cosmosAddress = innerMessage.address;
|
||||||
|
|
||||||
const displayAttestation = useMemo(() => {
|
const displayAttestation = useMemo(() => {
|
||||||
return canonicalStringify(
|
return canonicalStringify(
|
||||||
{
|
{
|
||||||
payload: {
|
payload: {
|
||||||
msg: "Onboarding my Azimuth ID onto UrbitChain",
|
msg: "Onboarding my Azimuth ID onto UrbitChain",
|
||||||
address: ethAddress,
|
address: ethAddress,
|
||||||
payload: {
|
payload: innerMessage,
|
||||||
msg: "Onboarding my cosmos validator onto UrbitChain",
|
|
||||||
address: cosmosAddress,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
signatures: [cosmosSignature, ethSignature],
|
signatures: [cosmosSignature, ethSignature],
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}, [ethAddress, cosmosAddress, cosmosSignature, ethSignature]);
|
}, [ethAddress, cosmosSignature, ethSignature, innerMessage]);
|
||||||
|
|
||||||
const message = useMemo(() => {
|
const message = useMemo(() => {
|
||||||
return canonicalStringify(
|
return canonicalStringify(
|
||||||
{
|
{
|
||||||
msg: "Onboarding my Azimuth ID onto UrbitChain",
|
msg: "Onboarding my Azimuth ID onto UrbitChain",
|
||||||
address: ethAddress,
|
address: ethAddress,
|
||||||
payload: {
|
payload: innerMessage,
|
||||||
msg: "Onboarding my cosmos validator onto UrbitChain",
|
|
||||||
address: cosmosAddress,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}, [ethAddress, cosmosAddress]);
|
}, [ethAddress, innerMessage]);
|
||||||
|
|
||||||
const signCosmos = async () => {
|
const signCosmos = async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -67,11 +67,11 @@ const SignWithEthereum = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitHandler = useCallback(() => {
|
const submitHandler = useCallback(() => {
|
||||||
navigate(
|
navigate(`/sign-with-cosmos/${ethAddress}/${ethSignature}`, {
|
||||||
`/sign-with-cosmos/${ethAddress}/${cosmosAddress}/${ethSignature}`
|
state: message,
|
||||||
);
|
});
|
||||||
setOpenModal(false);
|
setOpenModal(false);
|
||||||
}, [ethAddress, cosmosAddress, ethSignature, navigate]);
|
}, [ethAddress, ethSignature, navigate, message]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
Reference in New Issue
Block a user