From 2d1d7d36f223f97800d7bcc26f74f5f768b895d5 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 7 Aug 2024 10:26:27 +0530 Subject: [PATCH 1/3] Add flag to disable KYC --- src/constants.ts | 2 ++ src/pages/SignWithNitroKey.tsx | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 1f998ac..9443af8 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -29,3 +29,5 @@ export const TNC_PARTICIPANT_CONTENT = `Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`; export const WALLET_DISCLAIMER_MSG = 'You are connecting to an experimental wallet! It is not secure. Do not use it elsewhere and/or for managing real assets.' + +export const ENABLE_KYC = false; diff --git a/src/pages/SignWithNitroKey.tsx b/src/pages/SignWithNitroKey.tsx index e2c9134..cd94f67 100644 --- a/src/pages/SignWithNitroKey.tsx +++ b/src/pages/SignWithNitroKey.tsx @@ -13,6 +13,7 @@ import LoadingButton from '@mui/lab/LoadingButton'; import { utf8ToHex } from "@walletconnect/encoding"; import { useWalletConnectContext } from "../context/WalletConnectContext"; +import { ENABLE_KYC } from "../constants"; const SignWithNitroKey = () => { @@ -56,13 +57,25 @@ const SignWithNitroKey = () => { }); setIsLoading(false) setEthSignature(ethSignature); - navigate("/user-verification", { - state: { - message, - cosmosAddress, - receivedEthSig, - }, - }); + + if(ENABLE_KYC) { + navigate("/user-verification", { + state: { + message, + cosmosAddress, + receivedEthSig, + }, + }); + } else { + const kycIdHash = ethers.utils.sha256(ethers.utils.toUtf8Bytes(cosmosAddress)); + navigate("/sign-with-cosmos", { + state: { + message, + cosmosAddress, + receivedEthSig, + kycId, + }}) + } } catch (error) { console.log("err in signing ", error); setIsLoading(false) -- 2.45.2 From 80ce257e0057af8f75cdb6d931274c528f1cf080 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 7 Aug 2024 10:33:18 +0530 Subject: [PATCH 2/3] Render KYC status if flag is enabled --- src/pages/OnboardingSuccess.tsx | 26 ++++++++++++++++---------- src/pages/SignWithNitroKey.tsx | 8 +++++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/pages/OnboardingSuccess.tsx b/src/pages/OnboardingSuccess.tsx index a180a52..67c4da5 100644 --- a/src/pages/OnboardingSuccess.tsx +++ b/src/pages/OnboardingSuccess.tsx @@ -8,6 +8,7 @@ import SumsubWebSdk from "@sumsub/websdk-react"; import { MessageHandler } from "@sumsub/websdk"; import { config, fetchAccessToken, getAccessTokenExpirationHandler, options } from "../utils/sumsub"; +import { ENABLE_KYC } from "../constants"; interface Participant { cosmosAddress: string; @@ -104,16 +105,21 @@ const OnboardingSuccess = () => { )} - KYC Status - {!loading && token && cosmosAddress && ( - - )} + {ENABLE_KYC ? ( + + KYC Status + {!loading && token && cosmosAddress && ( + + )} + + ) : '' + } ); }; diff --git a/src/pages/SignWithNitroKey.tsx b/src/pages/SignWithNitroKey.tsx index cd94f67..625f4cf 100644 --- a/src/pages/SignWithNitroKey.tsx +++ b/src/pages/SignWithNitroKey.tsx @@ -2,6 +2,7 @@ import React, { useState, useMemo, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { enqueueSnackbar } from "notistack"; import canonicalStringify from "canonical-json"; +import { ethers } from "ethers"; import { Select, @@ -58,7 +59,7 @@ const SignWithNitroKey = () => { setIsLoading(false) setEthSignature(ethSignature); - if(ENABLE_KYC) { + if (ENABLE_KYC) { navigate("/user-verification", { state: { message, @@ -73,8 +74,9 @@ const SignWithNitroKey = () => { message, cosmosAddress, receivedEthSig, - kycId, - }}) + kycIdHash, + }, + }); } } catch (error) { console.log("err in signing ", error); -- 2.45.2 From 059e8a351bca8c3134ee83641d795a05e33cda17 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 7 Aug 2024 11:08:44 +0530 Subject: [PATCH 3/3] Disable fetch token if KYC is disabled --- src/pages/OnboardingSuccess.tsx | 2 +- src/pages/SignWithNitroKey.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/OnboardingSuccess.tsx b/src/pages/OnboardingSuccess.tsx index 67c4da5..30ab8eb 100644 --- a/src/pages/OnboardingSuccess.tsx +++ b/src/pages/OnboardingSuccess.tsx @@ -64,7 +64,7 @@ const OnboardingSuccess = () => { setLoading(false); }; - if (cosmosAddress) { + if (cosmosAddress && ENABLE_KYC) { getToken(cosmosAddress).catch(error => { console.error(error); alert("Failed to fetch token"); diff --git a/src/pages/SignWithNitroKey.tsx b/src/pages/SignWithNitroKey.tsx index 625f4cf..3580ee3 100644 --- a/src/pages/SignWithNitroKey.tsx +++ b/src/pages/SignWithNitroKey.tsx @@ -69,6 +69,7 @@ const SignWithNitroKey = () => { }); } else { const kycIdHash = ethers.utils.sha256(ethers.utils.toUtf8Bytes(cosmosAddress)); + navigate("/sign-with-cosmos", { state: { message, -- 2.45.2