Integrate sumsub KYC with terms & conditions #6
@ -6,4 +6,4 @@ REACT_APP_LACONICD_RPC_ENDPOINT=http://localhost:26657
|
||||
REACT_APP_LACONICD_DENOM=photon
|
||||
REACT_APP_FAUCET_ENDPOINT=http://localhost:4000
|
||||
REACT_APP_WALLET_META_URL=http://localhost:3000
|
||||
REACT_APP_SUMSUB_TOKEN=
|
||||
REACT_APP_SUMSUB_API_ENDPOINT=
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@cerc-io/registry-sdk": "^0.2.2",
|
||||
"@cerc-io/registry-sdk": "^0.2.3",
|
||||
"@cosmjs/stargate": "^0.32.4",
|
||||
"@emotion/react": "^11.11.4",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
|
@ -19,13 +19,13 @@ function App() {
|
||||
<WalletConnectProvider>
|
||||
<Routes>
|
||||
<Route path="/" element={<TermsAndConditions />} />
|
||||
<Route path="/connect-wallet" element={<ConnectWallet />} />
|
||||
<Route element={<SignPageLayout />}>
|
||||
<Route path="/sign-with-nitro-key" element={<SignWithNitroKey />} />
|
||||
<Route
|
||||
path="/user-verification"
|
||||
element={<UserVerification />}
|
||||
/>
|
||||
<Route path="/connect-wallet" element={<ConnectWallet />} />
|
||||
<Route element={<SignPageLayout />}>
|
||||
<Route path="/sign-with-nitro-key" element={<SignWithNitroKey />} />
|
||||
<Route
|
||||
path="/sign-with-cosmos"
|
||||
element={<SignWithCosmos />}
|
||||
|
@ -1,15 +1,16 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { Typography, Button, Box, Paper, Radio, RadioGroup, FormControlLabel, FormControl, FormLabel, Link, Checkbox } from '@mui/material';
|
||||
import { Role } from '@cerc-io/registry-sdk/dist/proto/cerc/onboarding/v1/onboarding';
|
||||
|
||||
import TermsAndConditionsDialog from './TermsAndConditionsDialog';
|
||||
|
||||
const VALIDATOR_OPTION = "validator";
|
||||
const PARTICIPANT_OPTION = "participant";
|
||||
export enum Role {
|
||||
Validator = 'validator',
|
||||
Participant = 'participant'
|
||||
}
|
||||
|
||||
const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAccept: () => void, handleRoleChange: (role: Role) => void }) => {
|
||||
const [selectedRole, setSelectedRole] = useState(PARTICIPANT_OPTION);
|
||||
const [selectedRole, setSelectedRole] = useState<Role>(Role.Participant);
|
||||
const [checked, setChecked] = useState(false);
|
||||
const [isHidden, setIsHidden] = useState(false);
|
||||
|
||||
@ -25,8 +26,9 @@ const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAcce
|
||||
}
|
||||
|
||||
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSelectedRole((event.target as HTMLInputElement).value);
|
||||
handleRoleChange((event.target as HTMLInputElement).value === VALIDATOR_OPTION ? Role.ROLE_VALIDATOR : Role.ROLE_PARTICIPANT);
|
||||
setSelectedRole(event.target.value as Role);
|
||||
handleRoleChange((event.target as HTMLInputElement).value === Role.Validator ? Role.Validator : Role.Participant);
|
||||
setChecked(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -40,12 +42,12 @@ const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAcce
|
||||
onChange={handleRadioChange}
|
||||
>
|
||||
<FormControlLabel
|
||||
value={VALIDATOR_OPTION}
|
||||
value={Role.Validator}
|
||||
control={<Radio />}
|
||||
label="Validator"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value={PARTICIPANT_OPTION}
|
||||
value={Role.Participant}
|
||||
control={<Radio />}
|
||||
label="Participant"
|
||||
/>
|
||||
@ -73,7 +75,7 @@ const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAcce
|
||||
Continue
|
||||
</Button>
|
||||
</Box>
|
||||
<TermsAndConditionsDialog isValidator = { selectedRole === VALIDATOR_OPTION } open={isDialogOpen} onClose={() => setisDialogOpen(false)}/>
|
||||
<TermsAndConditionsDialog isValidator = { selectedRole === Role.Validator } open={isDialogOpen} onClose={() => setisDialogOpen(false)}/>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
|
||||
import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Button, Typography } from '@mui/material';
|
||||
|
||||
import { TNC_CONTENT } from '../constants';
|
||||
import { TNC_PARTICIPANT_CONTENT, TNC_VALIDATOR_CONTENT } from '../constants';
|
||||
|
||||
interface TermsDialogProps {
|
||||
isValidator: boolean;
|
||||
@ -19,7 +19,7 @@ const TermsAndConditionsDialog: React.FC<TermsDialogProps> = ({ isValidator, ope
|
||||
Onboard as a {isValidator ? "validator" : "participant"}
|
||||
</Typography>
|
||||
<DialogContentText>
|
||||
<div dangerouslySetInnerHTML={{__html: TNC_CONTENT}} />
|
||||
<div dangerouslySetInnerHTML={{__html: isValidator ? TNC_VALIDATOR_CONTENT : TNC_PARTICIPANT_CONTENT }} />
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
@ -1,4 +1,24 @@
|
||||
export const TNC_CONTENT = `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. <br/>
|
||||
export const TNC_GENERIC_CONTENT = `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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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 TNC_VALIDATOR_CONTENT = `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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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 TNC_PARTICIPANT_CONTENT = `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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
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. <br/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import {useNavigate } from "react-router-dom";
|
||||
|
||||
import { Button, Box, Container } from "@mui/material";
|
||||
|
||||
@ -10,16 +10,13 @@ const ConnectWallet = () => {
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const kycId = queryParams.get('kycId');
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if (session) {
|
||||
navigate(`/sign-with-nitro-key?kycId=${kycId}`);
|
||||
navigate("/sign-with-nitro-key");
|
||||
}
|
||||
}, [session, navigate, kycId]);
|
||||
}, [session, navigate,]);
|
||||
|
||||
const handler = async () => {
|
||||
await connect();
|
||||
|
@ -16,8 +16,9 @@ const registry = new Registry(
|
||||
|
||||
const OnboardingSuccess = () => {
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const cosmosAddress = queryParams.get('cosmosAddress');
|
||||
const { cosmosAddress } = location.state as {
|
||||
cosmosAddress?: string
|
||||
}
|
||||
|
||||
const [participant, setParticipant] = useState<Participant>();
|
||||
|
||||
|
@ -8,30 +8,34 @@ import {
|
||||
MsgOnboardParticipantEncodeObject,
|
||||
typeUrlMsgOnboardParticipant,
|
||||
} from "@cerc-io/registry-sdk";
|
||||
import { Role } from "@cerc-io/registry-sdk/dist/proto/cerc/onboarding/v1/onboarding";
|
||||
import { StargateClient } from "@cosmjs/stargate";
|
||||
|
||||
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
||||
import TermsAndConditionsCard from "../components/TermsAndConditionsCard";
|
||||
import TermsAndConditionsCard, {Role} from "../components/TermsAndConditionsCard";
|
||||
|
||||
const SignWithCosmos = () => {
|
||||
const { session, signClient } = useWalletConnectContext();
|
||||
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const cosmosAddress = queryParams.get('cosmosAddress');
|
||||
const ethSignature = queryParams.get('ethSignature');
|
||||
const kycId = queryParams.get('kycId');
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [balance, setBalance] = useState('');
|
||||
const [isRequesting, setIsRequesting] = useState(false);
|
||||
const [isTncAccepted, setIsTncAccepted] = useState(false);
|
||||
const [role, setRole] = useState(Role.ROLE_PARTICIPANT);
|
||||
const [role, setRole] = useState(Role.Participant);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const innerMessage = location.state;
|
||||
const ethAddress = innerMessage.address;
|
||||
|
||||
const {message: innerMessage, cosmosAddress, receivedEthSig: ethSignature, kycId} = location.state as {
|
||||
message?: {
|
||||
msg: string;
|
||||
address: string;
|
||||
};
|
||||
cosmosAddress?: string;
|
||||
receivedEthSig?: string;
|
||||
kycId?: string;
|
||||
};
|
||||
|
||||
const ethAddress = innerMessage!.address;
|
||||
|
||||
const createCosmosClient = useCallback(async (endpoint: string) => {
|
||||
return await StargateClient.connect(endpoint);
|
||||
@ -109,7 +113,11 @@ const SignWithCosmos = () => {
|
||||
if (responseFromWallet.code !== 0) {
|
||||
enqueueSnackbar("Transaction not sent", { variant: "error" });
|
||||
} else {
|
||||
navigate(`/onboarding-success?cosmosAddress=${cosmosAddress}`);
|
||||
navigate("/onboarding-success", {
|
||||
state: {
|
||||
cosmosAddress
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -143,7 +151,7 @@ const SignWithCosmos = () => {
|
||||
gap: "10px",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h5">Please accept terms and conditions to continue</Typography>
|
||||
<Typography variant="h5" display={`${isTncAccepted ? "none" : "block"}`}>Please accept terms and conditions to continue</Typography>
|
||||
<TermsAndConditionsCard handleAccept={() => setIsTncAccepted(true)} handleRoleChange={setRole}/>
|
||||
<Typography variant="h5">Send transaction to chain</Typography>
|
||||
<Typography>Cosmos Account:</Typography>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, useMemo, useEffect } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { SnackbarProvider, enqueueSnackbar } from "notistack";
|
||||
import canonicalStringify from "canonical-json";
|
||||
|
||||
@ -15,9 +15,6 @@ import { utf8ToHex } from "@walletconnect/encoding";
|
||||
import { useWalletConnectContext } from "../context/WalletConnectContext";
|
||||
|
||||
const SignWithNitroKey = () => {
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const kycId = queryParams.get('kycId');
|
||||
|
||||
const { session, signClient, checkPersistedState } =
|
||||
useWalletConnectContext();
|
||||
@ -59,8 +56,12 @@ const SignWithNitroKey = () => {
|
||||
});
|
||||
setIsLoading(false)
|
||||
setEthSignature(ethSignature);
|
||||
navigate(`/sign-with-cosmos?cosmosAddress=${cosmosAddress}ðSignature=${receivedEthSig}&kycId=${kycId}`, {
|
||||
state: message,
|
||||
navigate("/user-verification", {
|
||||
state: {
|
||||
message,
|
||||
cosmosAddress,
|
||||
receivedEthSig,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("err in signing ", error);
|
||||
@ -70,7 +71,6 @@ const SignWithNitroKey = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
{session ? (
|
||||
|
@ -3,13 +3,13 @@ import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { Container, Typography, Button, Box, Paper } from '@mui/material';
|
||||
|
||||
import { TNC_CONTENT } from '../constants';
|
||||
import { TNC_GENERIC_CONTENT } from '../constants';
|
||||
|
||||
const TermsAndConditions = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleAccept = () => {
|
||||
navigate('/user-verification');
|
||||
navigate('/connect-wallet');
|
||||
};
|
||||
|
||||
return (
|
||||
@ -26,8 +26,12 @@ const TermsAndConditions = () => {
|
||||
marginBottom: '1rem',
|
||||
}}
|
||||
>
|
||||
<Typography variant="body1" gutterBottom>
|
||||
<div dangerouslySetInnerHTML={{__html: TNC_CONTENT}} />
|
||||
<Typography
|
||||
variant="body1"
|
||||
gutterBottom
|
||||
component="div"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{__html: TNC_GENERIC_CONTENT}} />
|
||||
</Typography>
|
||||
|
||||
</Box>
|
||||
|
@ -1,59 +1,91 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
|
||||
import { Box, Typography } from '@mui/material'
|
||||
import SumsubWebSdk from '@sumsub/websdk-react'
|
||||
import { Box, Typography } from '@mui/material';
|
||||
import SumsubWebSdk from '@sumsub/websdk-react';
|
||||
import { MessageHandler } from '@sumsub/websdk';
|
||||
import { EventPayload } from '@sumsub/websdk/types/types';
|
||||
|
||||
import { fetchAccessToken } from '../utils/sumsub';
|
||||
|
||||
const config = {
|
||||
lang: "en", //language of WebSDK texts and comments (ISO 639-1 format)
|
||||
lang: "en", // language of WebSDK texts and comments (ISO 639-1 format)
|
||||
theme: "light",
|
||||
}
|
||||
};
|
||||
|
||||
const options = {
|
||||
addViewportTag: false,
|
||||
adaptIframeHeight: true
|
||||
}
|
||||
adaptIframeHeight: true,
|
||||
};
|
||||
|
||||
const UserVerification = () => {
|
||||
const [kycId, setKycId] = useState<String>('');
|
||||
const [kycId, setKycId] = useState<string>('unknown');
|
||||
const [applicationSubmitted, setApplicationSubmitted] = useState<boolean>(false);
|
||||
const [token, setToken] = useState<string>('');
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(()=>{
|
||||
if (applicationSubmitted && kycId !== '') {
|
||||
navigate(`/connect-wallet?kycId=${kycId}`)
|
||||
}
|
||||
}, [applicationSubmitted, kycId, navigate]);
|
||||
const {message, cosmosAddress, receivedEthSig} = location.state as {
|
||||
message?: string;
|
||||
cosmosAddress?: string;
|
||||
receivedEthSig?: string;
|
||||
};
|
||||
|
||||
const userId = cosmosAddress;
|
||||
|
||||
useEffect(() => {
|
||||
const getToken = async (userId: string) => {
|
||||
console.log(userId);
|
||||
const newToken = await fetchAccessToken(userId);
|
||||
|
||||
setToken(newToken);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
if (userId) {
|
||||
getToken(userId).catch(error => {
|
||||
console.error(error);
|
||||
alert("Failed to fetch token");
|
||||
});
|
||||
}
|
||||
}, [userId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (applicationSubmitted && kycId !== '') {
|
||||
navigate("/sign-with-cosmos", {
|
||||
state: {
|
||||
message,
|
||||
cosmosAddress,
|
||||
receivedEthSig,
|
||||
kycId,
|
||||
}})
|
||||
}
|
||||
}, [applicationSubmitted, kycId, navigate, cosmosAddress, message, receivedEthSig]);
|
||||
|
||||
// TODO: Implement
|
||||
const accessTokenExpirationHandler = async () => {
|
||||
alert("Please renew token");
|
||||
return "Token expired";
|
||||
}
|
||||
};
|
||||
|
||||
const accessToken = {
|
||||
// TODO: Programmatically fetch access-token using sumsub API
|
||||
"token": process.env.REACT_APP_SUMSUB_TOKEN!,
|
||||
// TODO: Generate random user-id string
|
||||
"userId": "alice"
|
||||
}
|
||||
const messageHandler: MessageHandler = (event, payload) => {
|
||||
console.log('sumsubEvent:', event);
|
||||
|
||||
const messageHandler = (event: any, payload: any ) => {
|
||||
if (event === 'idCheck.onApplicantLoaded') {
|
||||
setKycId(payload.applicantId);
|
||||
setKycId((payload as EventPayload<'idCheck.onApplicantLoaded'>).applicantId);
|
||||
}
|
||||
|
||||
if (event === 'idCheck.onApplicantSubmitted'){
|
||||
if (event === 'idCheck.onApplicantSubmitted') {
|
||||
setApplicationSubmitted(true);
|
||||
}
|
||||
|
||||
if (event === 'idCheck.onApplicantStatusChanged') {
|
||||
if (payload.reviewStatus === 'pending') {
|
||||
if ((payload as EventPayload<'idCheck.onApplicantStatusChanged'>).reviewStatus === 'pending') {
|
||||
setApplicationSubmitted(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -66,19 +98,19 @@ const UserVerification = () => {
|
||||
}}
|
||||
>
|
||||
<Typography variant="h5">User verification</Typography>
|
||||
<div id="sumsub-websdk-container">
|
||||
|
||||
</div>
|
||||
<div id="sumsub-websdk-container"></div>
|
||||
</Box>
|
||||
{!loading && token && (
|
||||
<SumsubWebSdk
|
||||
accessToken={accessToken.token}
|
||||
accessToken={token}
|
||||
expirationHandler={accessTokenExpirationHandler}
|
||||
config={config}
|
||||
options={options}
|
||||
onMessage={messageHandler}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default UserVerification
|
||||
export default UserVerification;
|
||||
|
16
src/utils/sumsub.ts
Normal file
16
src/utils/sumsub.ts
Normal file
@ -0,0 +1,16 @@
|
||||
export const fetchAccessToken = async (userId: string): Promise<string> => {
|
||||
const response = await fetch(`${process.env.REACT_APP_SUMSUB_API_ENDPOINT}/generate-token`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ userId })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.token;
|
||||
};
|
@ -1183,10 +1183,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@cerc-io/registry-sdk@^0.2.2":
|
||||
version "0.2.2"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.2/registry-sdk-0.2.2.tgz#2e8a533f069b4bb9f4cd4798e783f52e29167d0d"
|
||||
integrity sha512-ocRMbWtdewOg02ORfK1U+qbTqB46anHP4ApXokGkY4d+mFSApR3sdUEi2geHcs8oh+SG8YAp7LUJ9AAJneNY8g==
|
||||
"@cerc-io/registry-sdk@^0.2.3":
|
||||
version "0.2.3"
|
||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.3/registry-sdk-0.2.3.tgz#73e955b4d49d7c97eea40c351bbc21f98bb330f9"
|
||||
integrity sha512-8fXRdyiTXn8WsJ8r3DCSBYzUBNEZYPPk5JGUrEmkGQhKOJr+ZeakN+2t6HrqEVB9IMYTJK9BtVLPA0KlaXILYA==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.28.1"
|
||||
"@cosmjs/crypto" "^0.28.1"
|
||||
|
Loading…
Reference in New Issue
Block a user