From 5774c7b32db37a289cdad55ed4f5c86d17e59db1 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 14 Aug 2024 11:01:07 +0530 Subject: [PATCH] Replace cosmos_address with laconic_address --- README.md | 2 +- src/App.tsx | 4 +-- src/pages/OnboardingSuccess.tsx | 22 +++++++-------- ...SignWithCosmos.tsx => SignWithLaconic.tsx} | 28 +++++++++---------- src/pages/SignWithNitroKey.tsx | 14 +++++----- src/pages/UserVerification.tsx | 12 ++++---- src/pages/Validator.tsx | 26 ++++++++--------- src/types.ts | 2 +- 8 files changed, 55 insertions(+), 55 deletions(-) rename src/pages/{SignWithCosmos.tsx => SignWithLaconic.tsx} (90%) diff --git a/README.md b/README.md index 0c48213..3b4c674 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # testnet-onboarding-app -React app for onboarding participants to laconicd chain with Nitro/Cosmos key attestation +React app for onboarding participants to laconicd chain with Nitro/Laconic key attestation ## Setup for testnet-onboarding-app diff --git a/src/App.tsx b/src/App.tsx index cb7cbac..d189d9f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,7 +3,7 @@ import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; import ConnectWallet from "./pages/ConnectWallet"; import SignWithNitroKey from "./pages/SignWithNitroKey"; -import SignWithCosmos from "./pages/SignWithCosmos"; +import SignWithLaconic from "./pages/SignWithLaconic"; import PageNotFound from "./pages/PageNotFound"; import OnboardingSuccess from "./pages/OnboardingSuccess"; import SignPageLayout from "./layout/SignPageLayout"; @@ -111,7 +111,7 @@ function App() { path="/user-verification" element={} /> - } /> + } /> } diff --git a/src/pages/OnboardingSuccess.tsx b/src/pages/OnboardingSuccess.tsx index b7e307a..855ac39 100644 --- a/src/pages/OnboardingSuccess.tsx +++ b/src/pages/OnboardingSuccess.tsx @@ -21,8 +21,8 @@ const registry = new Registry(process.env.REACT_APP_REGISTRY_GQL_ENDPOINT!); const OnboardingSuccess = () => { const location = useLocation(); - const { cosmosAddress } = location.state as { - cosmosAddress?: string; + const { laconicAddress } = location.state as { + laconicAddress?: string; }; const [participant, setParticipant] = useState(); @@ -36,14 +36,14 @@ const OnboardingSuccess = () => { useEffect(() => { const fetchParticipants = async () => { try { - if (!cosmosAddress) { + if (!laconicAddress) { enqueueSnackbar("Laconic address is not provided", { variant: "error", }); return; } const participant: Participant = - await registry.getParticipantByAddress(cosmosAddress); + await registry.getParticipantByAddress(laconicAddress); if (!participant) { enqueueSnackbar("Participant not found", { variant: "error" }); return; @@ -58,7 +58,7 @@ const OnboardingSuccess = () => { }; fetchParticipants(); - }, [cosmosAddress]); + }, [laconicAddress]); useEffect(() => { const getToken = async (userId: string) => { @@ -67,13 +67,13 @@ const OnboardingSuccess = () => { setLoading(false); }; - if (cosmosAddress && ENABLE_KYC) { - getToken(cosmosAddress).catch((error) => { + if (laconicAddress && ENABLE_KYC) { + getToken(laconicAddress).catch((error) => { console.error(error); alert("Failed to fetch token"); }); } - }, [cosmosAddress]); + }, [laconicAddress]); return ( <> @@ -92,7 +92,7 @@ const OnboardingSuccess = () => { {participant && (
- Laconic Address: {participant.cosmosAddress}
+ Laconic Address: {participant.laconicAddress}
Nitro Address: {participant.nitroAddress}
Role: {participant.role}
KYC ID: {participant.kycId}
@@ -103,11 +103,11 @@ const OnboardingSuccess = () => { {ENABLE_KYC ? ( KYC Status - {!loading && token && cosmosAddress && ( + {!loading && token && laconicAddress && ( { +const SignWithLaconic = () => { const { session, signClient } = useWalletConnectContext(); const location = useLocation(); @@ -30,21 +30,21 @@ const SignWithCosmos = () => { const { message: innerMessage, - cosmosAddress, + laconicAddress, receivedEthSig: ethSignature, } = location.state as { message?: { msg: string; address: string; }; - cosmosAddress?: string; + laconicAddress?: string; receivedEthSig?: string; }; const ethAddress = innerMessage!.address; const subscriberIdHash = localStorage.getItem(HASHED_SUBSCRIBER_ID_KEY); - const createCosmosClient = useCallback(async (endpoint: string) => { + const createLaconicClient = useCallback(async (endpoint: string) => { return await StargateClient.connect(endpoint); }, []); @@ -53,14 +53,14 @@ const SignWithCosmos = () => { return { typeUrl: typeUrlMsgOnboardParticipant, value: { - participant: cosmosAddress!, + participant: laconicAddress!, ethPayload: innerMessage, ethSignature: ethSignature!, kycId: subscriberIdHash!, role, }, }; - }, [cosmosAddress, innerMessage, ethSignature, subscriberIdHash, role]); + }, [laconicAddress, innerMessage, ethSignature, subscriberIdHash, role]); const handleTokenRequest = async () => { try { @@ -73,7 +73,7 @@ const SignWithCosmos = () => { "Content-Type": "application/json", }, body: JSON.stringify({ - address: cosmosAddress, + address: laconicAddress, }), }, ); @@ -115,7 +115,7 @@ const SignWithCosmos = () => { variant: "info", }); - const params = { transactionMessage, signer: cosmosAddress }; + const params = { transactionMessage, signer: laconicAddress }; const responseFromWallet = await signClient!.request<{ code: number; }>({ @@ -131,7 +131,7 @@ const SignWithCosmos = () => { } else { navigate("/onboarding-success", { state: { - cosmosAddress, + laconicAddress, }, }); } @@ -145,11 +145,11 @@ const SignWithCosmos = () => { const getBalances = useCallback(async () => { try { - const cosmosClient = await createCosmosClient( + const cosmosClient = await createLaconicClient( process.env.REACT_APP_LACONICD_RPC_ENDPOINT!, ); const balance = await cosmosClient.getBalance( - cosmosAddress!, + laconicAddress!, process.env.REACT_APP_LACONICD_DENOM!, ); setBalance(balance.amount); @@ -157,7 +157,7 @@ const SignWithCosmos = () => { console.error("Error fetching balance:", error); throw error; } - }, [cosmosAddress, createCosmosClient]); + }, [laconicAddress, createLaconicClient]); useEffect(() => { getBalances(); @@ -179,7 +179,7 @@ const SignWithCosmos = () => { Laconic Account: - Address: {cosmosAddress} + Address: {laconicAddress} Balance: {balance} {process.env.REACT_APP_LACONICD_DENOM} @@ -219,4 +219,4 @@ const SignWithCosmos = () => { ); }; -export default SignWithCosmos; +export default SignWithLaconic; diff --git a/src/pages/SignWithNitroKey.tsx b/src/pages/SignWithNitroKey.tsx index 8388962..3451152 100644 --- a/src/pages/SignWithNitroKey.tsx +++ b/src/pages/SignWithNitroKey.tsx @@ -33,7 +33,7 @@ const SignWithNitroKey = () => { const [ethAddress, setEthAddress] = useState(""); const [ethSignature, setEthSignature] = useState(""); - const [cosmosAddress, setCosmosAddress] = useState(""); + const [laconicAddress, setLaconicAddress] = useState(""); const [isLoading, setIsLoading] = useState(false); @@ -84,15 +84,15 @@ const SignWithNitroKey = () => { navigate("/user-verification", { state: { message, - cosmosAddress, + laconicAddress, receivedEthSig, }, }); } else { - navigate("/sign-with-cosmos", { + navigate("/sign-with-laconic", { state: { message, - cosmosAddress, + laconicAddress, receivedEthSig, }, }); @@ -113,9 +113,9 @@ const SignWithNitroKey = () => { - {Boolean(ethAddress) && Boolean(cosmosAddress) && ( + {Boolean(ethAddress) && Boolean(laconicAddress) && ( {canonicalStringify(message, null, 2)} )} diff --git a/src/pages/UserVerification.tsx b/src/pages/UserVerification.tsx index e2ad450..fb5bcc4 100644 --- a/src/pages/UserVerification.tsx +++ b/src/pages/UserVerification.tsx @@ -18,13 +18,13 @@ const UserVerification = () => { const location = useLocation(); const navigate = useNavigate(); - const {message, cosmosAddress, receivedEthSig} = location.state as { + const {message, laconicAddress, receivedEthSig} = location.state as { message?: string; - cosmosAddress?: string; + laconicAddress?: string; receivedEthSig?: string; }; - const userId = cosmosAddress; + const userId = laconicAddress; useEffect(() => { const getToken = async (userId: string) => { @@ -46,15 +46,15 @@ const UserVerification = () => { if (applicationSubmitted && kycId !== '') { const kycIdHash = ethers.utils.sha256(ethers.utils.toUtf8Bytes(kycId)); - navigate("/sign-with-cosmos", { + navigate("/sign-with-laconic", { state: { message, - cosmosAddress, + laconicAddress, receivedEthSig, kycIdHash }}); } - }, [applicationSubmitted, kycId, navigate, cosmosAddress, message, receivedEthSig]); + }, [applicationSubmitted, kycId, navigate, laconicAddress, message, receivedEthSig]); const messageHandler: MessageHandler = (event, payload) => { console.log('sumsubEvent:', event, payload); diff --git a/src/pages/Validator.tsx b/src/pages/Validator.tsx index 5f54d69..3f522eb 100644 --- a/src/pages/Validator.tsx +++ b/src/pages/Validator.tsx @@ -25,7 +25,7 @@ const Validator = () => { const { session, signClient, isSessionLoading } = useWalletConnectContext(); const navigate = useNavigate(); - const [cosmosAddress, setCosmosAddress] = useState(""); + const [laconicAddress, setLaconicAddress] = useState(""); const [isLoading, setIsLoading] = useState(false); const [moniker, setMoniker] = useState(""); const [pubKey, setPubKey] = useState(""); @@ -43,7 +43,7 @@ const Validator = () => { }, [session, navigate, isSessionLoading]); useEffect(() => { - if (!cosmosAddress) { + if (!laconicAddress) { setParticipant(null); return; } @@ -55,7 +55,7 @@ const Validator = () => { try { const fetchedParticipant = - await registry.getParticipantByAddress(cosmosAddress); + await registry.getParticipantByAddress(laconicAddress); if (fetchedParticipant) { setParticipant(fetchedParticipant); } else { @@ -69,7 +69,7 @@ const Validator = () => { }; fetchParticipant(); - }, [cosmosAddress]); + }, [laconicAddress]); const isMonikerValid = useMemo(() => moniker.trim().length > 0, [moniker]); const isPubKeyValid = useMemo(() => pubKey.length === 44, [pubKey]); @@ -96,15 +96,15 @@ const Validator = () => { minSelfDelegation: "1", delegatorAddress: "", validatorAddress: - cosmosAddress && - toBech32("laconicvaloper", fromBech32(cosmosAddress).data), + laconicAddress && + toBech32("laconicvaloper", fromBech32(laconicAddress).data), pubkey: encodedPubKey, value: { amount: process.env.REACT_APP_STAKING_AMOUNT!, denom: process.env.REACT_APP_LACONICD_DENOM!, }, }; - }, [cosmosAddress, pubKey, moniker]); + }, [laconicAddress, pubKey, moniker]); const msgCreateValidatorEncodeObject: EncodeObject = { typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", @@ -129,7 +129,7 @@ const Validator = () => { try { const params = { transactionMessage: msgCreateValidatorEncodeObject, - signer: cosmosAddress, + signer: laconicAddress, }; const response = await signClient!.request<{ code: number }>({ topic: session!.topic, @@ -167,9 +167,9 @@ const Validator = () => { Select Laconic account: - {Boolean(cosmosAddress) && ( + {Boolean(laconicAddress) && ( <> {participant ? ( Onboarded participant @@ -189,7 +189,7 @@ const Validator = () => { {participant && ( - Laconic Address: {participant.cosmosAddress}
+ Laconic Address: {participant.laconicAddress}
Nitro Address: {participant.nitroAddress}
Role: {participant.role}
KYC ID: {participant.kycId}
diff --git a/src/types.ts b/src/types.ts index da7f296..7efa1cb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ export interface Participant { - cosmosAddress: string; + laconicAddress: string; nitroAddress: string; role: string; kycId: string;