@huma-finance/widgets 0.0.80 → 0.0.81-beta.1108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +0 -11
- package/dist/index.js +60790 -64401
- package/dist/src/components/Lend/solanaSupply/6-Transfer.d.ts +2 -3
- package/dist/src/components/Lend/solanaSupply/7-Success.d.ts +1 -4
- package/dist/src/components/Lend/solanaSupply/index.d.ts +1 -7
- package/dist/src/components/Lend/stellarSupply/index.d.ts +0 -4
- package/dist/src/components/Lend/supply/1-Evaluation.d.ts +8 -0
- package/dist/src/components/Lend/supplyV2/6-Transfer.d.ts +2 -5
- package/dist/src/components/Lend/supplyV2/7-Success.d.ts +1 -3
- package/dist/src/components/Lend/supplyV2/8-Notifications.d.ts +1 -3
- package/dist/src/components/Lend/supplyV2/index.d.ts +1 -9
- package/dist/src/hooks/useEA.d.ts +0 -2
- package/dist/src/store/widgets.reducers.d.ts +1 -2
- package/dist/src/store/widgets.store.d.ts +0 -4
- package/package.json +6 -6
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -11
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -10
- package/src/components/Lend/solanaSupply/6-Transfer.tsx +4 -34
- package/src/components/Lend/solanaSupply/7-Success.tsx +2 -16
- package/src/components/Lend/solanaSupply/index.tsx +1 -66
- package/src/components/Lend/stellarSupply/index.tsx +0 -5
- package/src/components/Lend/supply/{1-Evaluation/EvaluationEA.tsx → 1-Evaluation.tsx} +9 -9
- package/src/components/Lend/supply/index.tsx +0 -1
- package/src/components/Lend/supplyV2/6-Transfer.tsx +7 -35
- package/src/components/Lend/supplyV2/7-Success.tsx +2 -18
- package/src/components/Lend/supplyV2/8-Notifications.tsx +3 -26
- package/src/components/Lend/supplyV2/index.tsx +15 -72
- package/src/components/SolanaTxSendModal.tsx +1 -1
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +1 -10
- package/src/hooks/useEA.ts +4 -22
- package/src/store/widgets.reducers.ts +0 -7
- package/src/store/widgets.store.ts +0 -4
- package/vite.config.ts +1 -1
- package/dist/src/components/Lend/components/ApproveLenderBase.d.ts +0 -14
- package/dist/src/components/Lend/components/PersonaEvaluation.d.ts +0 -17
- package/dist/src/components/Lend/components/SecuritizeEvaluation.d.ts +0 -8
- package/dist/src/components/Lend/solanaSupply/1-Evaluation.d.ts +0 -12
- package/dist/src/components/Lend/solanaSupply/2-ApproveLender.d.ts +0 -10
- package/dist/src/components/Lend/solanaSupply/8-PointsEarned.d.ts +0 -11
- package/dist/src/components/Lend/supply/1-Evaluation/EvaluationEA.d.ts +0 -8
- package/dist/src/components/Lend/supply/1-Evaluation/EvaluationKYC.d.ts +0 -8
- package/dist/src/components/Lend/supply/1-Evaluation/index.d.ts +0 -9
- package/dist/src/components/Lend/supplyV2/2-Evaluation.d.ts +0 -12
- package/dist/src/components/Lend/supplyV2/3-ApproveLender.d.ts +0 -10
- package/dist/src/components/PointsEarned.d.ts +0 -10
- package/dist/src/components/SignIn.d.ts +0 -6
- package/dist/src/cosmos/CreditLineBorrow.fixture.d.ts +0 -2
- package/dist/src/cosmos/CreditLinePayment.fixture.d.ts +0 -2
- package/dist/src/cosmos/InvoiceFactoringBorrow.fixture.d.ts +0 -2
- package/dist/src/cosmos/InvoiceFactoringPayment.fixture.d.ts +0 -2
- package/dist/src/cosmos/LendSupply.fixture.d.ts +0 -2
- package/dist/src/cosmos/LendWithdraw.fixture.d.ts +0 -2
- package/dist/src/cosmos/SDKTesting.fixture.d.ts +0 -2
- package/dist/src/cosmos/SuperfluidFactoringBorrow.fixture.d.ts +0 -2
- package/dist/src/cosmos/WalletWrapper.d.ts +0 -3
- package/dist/src/cosmos/utils/index.d.ts +0 -18
- package/src/components/Lend/components/ApproveLenderBase.tsx +0 -128
- package/src/components/Lend/components/PersonaEvaluation.tsx +0 -371
- package/src/components/Lend/components/SecuritizeEvaluation.tsx +0 -343
- package/src/components/Lend/solanaSupply/1-Evaluation.tsx +0 -43
- package/src/components/Lend/solanaSupply/2-ApproveLender.tsx +0 -45
- package/src/components/Lend/solanaSupply/8-PointsEarned.tsx +0 -189
- package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +0 -369
- package/src/components/Lend/supply/1-Evaluation/index.tsx +0 -31
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +0 -47
- package/src/components/Lend/supplyV2/3-ApproveLender.tsx +0 -35
- package/src/components/PointsEarned.tsx +0 -135
- package/src/components/SignIn.tsx +0 -53
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge';
|
|
2
|
-
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
3
|
-
import { ethers } from 'ethers';
|
|
4
|
-
export declare enum ChainEnum {
|
|
5
|
-
Goerli = 5,
|
|
6
|
-
Mumbai = 80001
|
|
7
|
-
}
|
|
8
|
-
declare class MetamaskBridge extends Eip1193Bridge {
|
|
9
|
-
private walletAddress;
|
|
10
|
-
private chainId;
|
|
11
|
-
constructor(signer: ethers.Signer, provider: ethers.providers.Provider, walletAddress: string, chainId?: number);
|
|
12
|
-
sendAsync(...args: any[]): Promise<any>;
|
|
13
|
-
send(...args: any[]): Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
export declare const getProvider: (chainId?: ChainEnum) => JsonRpcProvider;
|
|
16
|
-
export declare const getInjectedMetamask: (testPrivateKey: string, chainId?: ChainEnum) => MetamaskBridge;
|
|
17
|
-
export declare const getSigner: (testPrivateKey: string, chainId?: ChainEnum) => ethers.Wallet;
|
|
18
|
-
export {};
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-await-in-loop */
|
|
2
|
-
import {
|
|
3
|
-
CHAIN_TYPE,
|
|
4
|
-
COMMON_ERROR_MESSAGE,
|
|
5
|
-
IdentityServiceV2,
|
|
6
|
-
NETWORK_TYPE,
|
|
7
|
-
SOLANA_TRANSACTION_EXPIRED_BLOCKHEIGHT_EXCEEDED_ERROR,
|
|
8
|
-
timeUtil,
|
|
9
|
-
TrancheType,
|
|
10
|
-
} from '@huma-finance/shared'
|
|
11
|
-
import { useChainInfo, checkIsDev } from '@huma-finance/web-shared'
|
|
12
|
-
import React, { useCallback, useEffect } from 'react'
|
|
13
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
14
|
-
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
15
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
16
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
17
|
-
|
|
18
|
-
type Props = {
|
|
19
|
-
juniorTrancheVault: string
|
|
20
|
-
seniorTrancheVault: string
|
|
21
|
-
chainType: CHAIN_TYPE
|
|
22
|
-
networkType: NETWORK_TYPE
|
|
23
|
-
isUniTranche: boolean
|
|
24
|
-
documentHash?: string
|
|
25
|
-
chainSpecificData?: Record<string, unknown>
|
|
26
|
-
changeTranche: (tranche: TrancheType) => void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function ApproveLenderBase({
|
|
30
|
-
juniorTrancheVault,
|
|
31
|
-
seniorTrancheVault,
|
|
32
|
-
isUniTranche,
|
|
33
|
-
chainType,
|
|
34
|
-
networkType,
|
|
35
|
-
chainSpecificData,
|
|
36
|
-
documentHash,
|
|
37
|
-
changeTranche,
|
|
38
|
-
}: Props): React.ReactElement | null {
|
|
39
|
-
const isDev = checkIsDev()
|
|
40
|
-
const dispatch = useAppDispatch()
|
|
41
|
-
const { account, chainId } = useChainInfo(isDev, chainType)
|
|
42
|
-
|
|
43
|
-
const approveLender = useCallback(
|
|
44
|
-
async (trancheVault: string) => {
|
|
45
|
-
if (!documentHash) {
|
|
46
|
-
throw new Error('No document hash provided')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let tryAttempts = 2
|
|
50
|
-
|
|
51
|
-
while (tryAttempts > 0) {
|
|
52
|
-
try {
|
|
53
|
-
tryAttempts -= 1
|
|
54
|
-
await IdentityServiceV2.approveLender(
|
|
55
|
-
networkType,
|
|
56
|
-
account!,
|
|
57
|
-
chainId!,
|
|
58
|
-
trancheVault,
|
|
59
|
-
documentHash,
|
|
60
|
-
isDev,
|
|
61
|
-
chainSpecificData,
|
|
62
|
-
)
|
|
63
|
-
tryAttempts = 0
|
|
64
|
-
} catch (e: unknown) {
|
|
65
|
-
if (tryAttempts === 0) {
|
|
66
|
-
throw e
|
|
67
|
-
} else {
|
|
68
|
-
await timeUtil.sleep(3000)
|
|
69
|
-
console.error(e)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
[account, chainId, chainSpecificData, documentHash, isDev, networkType],
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const approveLenderAsync = async () => {
|
|
79
|
-
if (account && chainId) {
|
|
80
|
-
try {
|
|
81
|
-
if (isUniTranche) {
|
|
82
|
-
await approveLender(juniorTrancheVault)
|
|
83
|
-
changeTranche('junior')
|
|
84
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
85
|
-
} else {
|
|
86
|
-
await approveLender(juniorTrancheVault)
|
|
87
|
-
await approveLender(seniorTrancheVault)
|
|
88
|
-
dispatch(setStep(WIDGET_STEP.ChooseTranche))
|
|
89
|
-
}
|
|
90
|
-
} catch (e: unknown) {
|
|
91
|
-
console.error(e)
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
let errorMessage = e.message ?? COMMON_ERROR_MESSAGE
|
|
94
|
-
if (
|
|
95
|
-
errorMessage.indexOf(
|
|
96
|
-
SOLANA_TRANSACTION_EXPIRED_BLOCKHEIGHT_EXCEEDED_ERROR,
|
|
97
|
-
) >= 0
|
|
98
|
-
) {
|
|
99
|
-
errorMessage = `Transaction failed due to blockchain congestion. Please try again.`
|
|
100
|
-
}
|
|
101
|
-
dispatch(
|
|
102
|
-
setError({
|
|
103
|
-
errorMessage,
|
|
104
|
-
}),
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
approveLenderAsync()
|
|
111
|
-
}, [
|
|
112
|
-
account,
|
|
113
|
-
approveLender,
|
|
114
|
-
chainId,
|
|
115
|
-
changeTranche,
|
|
116
|
-
dispatch,
|
|
117
|
-
isUniTranche,
|
|
118
|
-
juniorTrancheVault,
|
|
119
|
-
seniorTrancheVault,
|
|
120
|
-
])
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<LoadingModal
|
|
124
|
-
title='Lender Approval'
|
|
125
|
-
description='Checking your verification status...'
|
|
126
|
-
/>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHAIN_TYPE,
|
|
3
|
-
CloseModalOptions,
|
|
4
|
-
IdentityServiceV2,
|
|
5
|
-
IdentityVerificationStatusV2,
|
|
6
|
-
KYCCopy,
|
|
7
|
-
KYCType,
|
|
8
|
-
NETWORK_TYPE,
|
|
9
|
-
VerificationStatusResultV2,
|
|
10
|
-
} from '@huma-finance/shared'
|
|
11
|
-
import {
|
|
12
|
-
AUTH_ERROR_TYPE,
|
|
13
|
-
checkIsDev,
|
|
14
|
-
useAuthErrorHandling,
|
|
15
|
-
} from '@huma-finance/web-shared'
|
|
16
|
-
import { Box, css, useTheme } from '@mui/material'
|
|
17
|
-
import Persona, { Client } from 'persona'
|
|
18
|
-
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
19
|
-
|
|
20
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
21
|
-
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
22
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
23
|
-
import { BottomButton } from '../../BottomButton'
|
|
24
|
-
import { ApproveLenderImg } from '../../images'
|
|
25
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
26
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
27
|
-
import { Campaign } from '../supplyV2'
|
|
28
|
-
|
|
29
|
-
type LoadingType = 'verificationStatus' | 'startKYC' | 'approveLender'
|
|
30
|
-
|
|
31
|
-
type Props = {
|
|
32
|
-
poolInfo: {
|
|
33
|
-
KYC?: KYCType
|
|
34
|
-
juniorTrancheVault: string
|
|
35
|
-
seniorTrancheVault: string
|
|
36
|
-
}
|
|
37
|
-
networkType: NETWORK_TYPE
|
|
38
|
-
chainType: CHAIN_TYPE
|
|
39
|
-
documentHash: string
|
|
40
|
-
campaign?: Campaign
|
|
41
|
-
handleClose: (options?: CloseModalOptions) => void
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function PersonaEvaluation({
|
|
45
|
-
poolInfo,
|
|
46
|
-
campaign,
|
|
47
|
-
networkType,
|
|
48
|
-
chainType,
|
|
49
|
-
documentHash,
|
|
50
|
-
handleClose,
|
|
51
|
-
}: Props): React.ReactElement | null {
|
|
52
|
-
const theme = useTheme()
|
|
53
|
-
const isDev = checkIsDev()
|
|
54
|
-
const dispatch = useAppDispatch()
|
|
55
|
-
const {
|
|
56
|
-
authErrorType,
|
|
57
|
-
setAuthError,
|
|
58
|
-
isWalletOwnershipVerified,
|
|
59
|
-
isWalletOwnershipVerificationRequired,
|
|
60
|
-
} = useAuthErrorHandling(isDev, chainType)
|
|
61
|
-
const KYCCopies = poolInfo.KYC!.Persona!
|
|
62
|
-
const [loadingType, setLoadingType] = useState<LoadingType>()
|
|
63
|
-
const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
|
|
64
|
-
const [inquiryId, setInquiryId] = useState<string>()
|
|
65
|
-
const [sessionToken, setSessionToken] = useState<string>()
|
|
66
|
-
const [verificationStatus, setVerificationStatus] =
|
|
67
|
-
useState<VerificationStatusResultV2>()
|
|
68
|
-
const [showPersonaClient, setShowPersonaClient] = useState<boolean>(false)
|
|
69
|
-
const [KYCAutoStarted, setKYCAutoStarted] = useState<boolean>(false)
|
|
70
|
-
const isKYCCompletedRef = useRef<boolean>(false)
|
|
71
|
-
const isActionOngoingRef = useRef<boolean>(false)
|
|
72
|
-
const isKYCResumedRef = useRef<boolean>(false)
|
|
73
|
-
|
|
74
|
-
const checkVerificationStatus = useCallback(async () => {
|
|
75
|
-
if (isActionOngoingRef.current || isKYCResumedRef.current) {
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
isActionOngoingRef.current = true
|
|
80
|
-
setLoadingType('verificationStatus')
|
|
81
|
-
const verificationStatus =
|
|
82
|
-
await IdentityServiceV2.getVerificationStatusV2(
|
|
83
|
-
networkType,
|
|
84
|
-
documentHash,
|
|
85
|
-
isDev,
|
|
86
|
-
)
|
|
87
|
-
setVerificationStatus(verificationStatus)
|
|
88
|
-
setInquiryId(verificationStatus.personaInquiryId)
|
|
89
|
-
|
|
90
|
-
switch (verificationStatus.status) {
|
|
91
|
-
case IdentityVerificationStatusV2.ACCREDITED: {
|
|
92
|
-
const startVerificationResult =
|
|
93
|
-
await IdentityServiceV2.startVerification(networkType, isDev)
|
|
94
|
-
setInquiryId(startVerificationResult.personaInquiryId)
|
|
95
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
96
|
-
setLoadingType(undefined)
|
|
97
|
-
if (
|
|
98
|
-
startVerificationResult.status ===
|
|
99
|
-
IdentityVerificationStatusV2.BYPASSED
|
|
100
|
-
) {
|
|
101
|
-
setVerificationStatus(startVerificationResult)
|
|
102
|
-
setKYCCopy(KYCCopies.verificationBypassed)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
break
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
case IdentityVerificationStatusV2.CREATED: {
|
|
109
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
110
|
-
setLoadingType(undefined)
|
|
111
|
-
break
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
case IdentityVerificationStatusV2.PENDING: {
|
|
115
|
-
if (!isKYCCompletedRef.current) {
|
|
116
|
-
const resumeVerificationResult =
|
|
117
|
-
await IdentityServiceV2.resumeVerification(networkType, isDev)
|
|
118
|
-
verificationStatus.status = resumeVerificationResult.status
|
|
119
|
-
setVerificationStatus(verificationStatus)
|
|
120
|
-
setSessionToken(resumeVerificationResult.sessionToken)
|
|
121
|
-
setLoadingType(undefined)
|
|
122
|
-
isKYCResumedRef.current = true
|
|
123
|
-
} else {
|
|
124
|
-
setLoadingType('verificationStatus')
|
|
125
|
-
}
|
|
126
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
127
|
-
break
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
case IdentityVerificationStatusV2.EXPIRED: {
|
|
131
|
-
const resumeVerificationResult =
|
|
132
|
-
await IdentityServiceV2.resumeVerification(networkType, isDev)
|
|
133
|
-
verificationStatus.status = resumeVerificationResult.status
|
|
134
|
-
setVerificationStatus(verificationStatus)
|
|
135
|
-
setSessionToken(resumeVerificationResult.sessionToken)
|
|
136
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
137
|
-
setLoadingType(undefined)
|
|
138
|
-
isKYCResumedRef.current = true
|
|
139
|
-
break
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
case IdentityVerificationStatusV2.BYPASSED: {
|
|
143
|
-
setKYCCopy(KYCCopies.verificationBypassed)
|
|
144
|
-
setLoadingType(undefined)
|
|
145
|
-
|
|
146
|
-
break
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
case IdentityVerificationStatusV2.APPROVED: {
|
|
150
|
-
setKYCCopy(KYCCopies.verificationApproved)
|
|
151
|
-
setLoadingType(undefined)
|
|
152
|
-
break
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
case IdentityVerificationStatusV2.DECLINED: {
|
|
156
|
-
setKYCCopy(KYCCopies.verificationDeclined)
|
|
157
|
-
setLoadingType(undefined)
|
|
158
|
-
break
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
case IdentityVerificationStatusV2.NEEDS_REVIEW: {
|
|
162
|
-
setKYCCopy(KYCCopies.verificationNeedsReview)
|
|
163
|
-
setLoadingType(undefined)
|
|
164
|
-
break
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
case IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION: {
|
|
168
|
-
dispatch(setStep(WIDGET_STEP.ApproveLender))
|
|
169
|
-
break
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
default:
|
|
173
|
-
break
|
|
174
|
-
}
|
|
175
|
-
} catch (e: unknown) {
|
|
176
|
-
setAuthError(e)
|
|
177
|
-
} finally {
|
|
178
|
-
isActionOngoingRef.current = false
|
|
179
|
-
}
|
|
180
|
-
}, [KYCCopies, dispatch, isDev, networkType, documentHash, setAuthError])
|
|
181
|
-
|
|
182
|
-
useEffect(() => {
|
|
183
|
-
checkVerificationStatus()
|
|
184
|
-
}, [checkVerificationStatus])
|
|
185
|
-
|
|
186
|
-
useEffect(() => {
|
|
187
|
-
if (isWalletOwnershipVerificationRequired && isWalletOwnershipVerified) {
|
|
188
|
-
checkVerificationStatus()
|
|
189
|
-
}
|
|
190
|
-
}, [
|
|
191
|
-
checkVerificationStatus,
|
|
192
|
-
isWalletOwnershipVerificationRequired,
|
|
193
|
-
isWalletOwnershipVerified,
|
|
194
|
-
])
|
|
195
|
-
|
|
196
|
-
useEffect(() => {
|
|
197
|
-
const interval = setInterval(() => {
|
|
198
|
-
if (
|
|
199
|
-
verificationStatus?.status &&
|
|
200
|
-
[
|
|
201
|
-
IdentityVerificationStatusV2.CREATED,
|
|
202
|
-
IdentityVerificationStatusV2.PENDING,
|
|
203
|
-
].includes(verificationStatus.status)
|
|
204
|
-
) {
|
|
205
|
-
checkVerificationStatus()
|
|
206
|
-
}
|
|
207
|
-
}, 3 * 1000)
|
|
208
|
-
// eslint-disable-next-line consistent-return
|
|
209
|
-
return () => clearInterval(interval)
|
|
210
|
-
}, [checkVerificationStatus, verificationStatus?.status])
|
|
211
|
-
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (authErrorType === AUTH_ERROR_TYPE.NotSignedIn) {
|
|
214
|
-
setLoadingType(undefined)
|
|
215
|
-
setKYCCopy(KYCCopies.signInRequired)
|
|
216
|
-
} else if (authErrorType === AUTH_ERROR_TYPE.UserRejected) {
|
|
217
|
-
dispatch(
|
|
218
|
-
setError({
|
|
219
|
-
errorMessage: 'User has rejected the transaction.',
|
|
220
|
-
}),
|
|
221
|
-
)
|
|
222
|
-
} else if (authErrorType === AUTH_ERROR_TYPE.Other) {
|
|
223
|
-
dispatch(
|
|
224
|
-
setError({
|
|
225
|
-
errorMessage: 'Something went wrong. Please try again later.',
|
|
226
|
-
}),
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
}, [KYCCopies.signInRequired, dispatch, authErrorType])
|
|
230
|
-
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
const modalElement = document.getElementById('huma-modal')
|
|
233
|
-
if (modalElement) {
|
|
234
|
-
modalElement.style.visibility = showPersonaClient ? 'hidden' : 'visible'
|
|
235
|
-
}
|
|
236
|
-
}, [showPersonaClient])
|
|
237
|
-
|
|
238
|
-
const startKYC = useCallback(async () => {
|
|
239
|
-
isActionOngoingRef.current = true
|
|
240
|
-
isKYCResumedRef.current = false
|
|
241
|
-
setLoadingType('startKYC')
|
|
242
|
-
const client: Client = new Persona.Client({
|
|
243
|
-
inquiryId,
|
|
244
|
-
sessionToken,
|
|
245
|
-
frameWidth: '480px',
|
|
246
|
-
onReady: () => {
|
|
247
|
-
client.open()
|
|
248
|
-
setShowPersonaClient(true)
|
|
249
|
-
},
|
|
250
|
-
onComplete: () => {
|
|
251
|
-
isKYCCompletedRef.current = true
|
|
252
|
-
isActionOngoingRef.current = false
|
|
253
|
-
setShowPersonaClient(false)
|
|
254
|
-
checkVerificationStatus()
|
|
255
|
-
},
|
|
256
|
-
onCancel: () => {
|
|
257
|
-
isActionOngoingRef.current = false
|
|
258
|
-
setShowPersonaClient(false)
|
|
259
|
-
setLoadingType(undefined)
|
|
260
|
-
handleClose()
|
|
261
|
-
},
|
|
262
|
-
onError: () => {
|
|
263
|
-
isActionOngoingRef.current = false
|
|
264
|
-
setShowPersonaClient(false)
|
|
265
|
-
setLoadingType(undefined)
|
|
266
|
-
},
|
|
267
|
-
})
|
|
268
|
-
}, [checkVerificationStatus, handleClose, inquiryId, sessionToken])
|
|
269
|
-
|
|
270
|
-
// Start KYC flow directly for the first time
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (isActionOngoingRef.current || isKYCResumedRef.current) {
|
|
273
|
-
return
|
|
274
|
-
}
|
|
275
|
-
if (verificationStatus && !KYCAutoStarted) {
|
|
276
|
-
switch (verificationStatus.status) {
|
|
277
|
-
case IdentityVerificationStatusV2.ACCREDITED:
|
|
278
|
-
case IdentityVerificationStatusV2.CREATED:
|
|
279
|
-
case IdentityVerificationStatusV2.PENDING:
|
|
280
|
-
case IdentityVerificationStatusV2.EXPIRED: {
|
|
281
|
-
startKYC()
|
|
282
|
-
setKYCAutoStarted(true)
|
|
283
|
-
break
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
default:
|
|
287
|
-
break
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}, [KYCAutoStarted, startKYC, verificationStatus])
|
|
291
|
-
|
|
292
|
-
const handleAction = useCallback(() => {
|
|
293
|
-
if (verificationStatus) {
|
|
294
|
-
switch (verificationStatus.status) {
|
|
295
|
-
case IdentityVerificationStatusV2.ACCREDITED:
|
|
296
|
-
case IdentityVerificationStatusV2.CREATED:
|
|
297
|
-
case IdentityVerificationStatusV2.PENDING:
|
|
298
|
-
case IdentityVerificationStatusV2.EXPIRED:
|
|
299
|
-
startKYC()
|
|
300
|
-
break
|
|
301
|
-
|
|
302
|
-
case IdentityVerificationStatusV2.DECLINED:
|
|
303
|
-
case IdentityVerificationStatusV2.NEEDS_REVIEW:
|
|
304
|
-
case IdentityVerificationStatusV2.APPROVED:
|
|
305
|
-
handleClose({ identityStatus: verificationStatus.status })
|
|
306
|
-
break
|
|
307
|
-
|
|
308
|
-
case IdentityVerificationStatusV2.BYPASSED:
|
|
309
|
-
handleClose({ identityStatus: IdentityVerificationStatusV2.APPROVED })
|
|
310
|
-
break
|
|
311
|
-
|
|
312
|
-
default:
|
|
313
|
-
break
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}, [handleClose, startKYC, verificationStatus])
|
|
317
|
-
|
|
318
|
-
const styles = {
|
|
319
|
-
iconWrapper: css`
|
|
320
|
-
${theme.cssMixins.rowCentered};
|
|
321
|
-
margin-top: ${theme.spacing(8)};
|
|
322
|
-
& > img {
|
|
323
|
-
width: 144px;
|
|
324
|
-
}
|
|
325
|
-
`,
|
|
326
|
-
description: css`
|
|
327
|
-
margin-top: ${theme.spacing(10)};
|
|
328
|
-
padding: ${theme.spacing(0, 2)};
|
|
329
|
-
font-weight: 400;
|
|
330
|
-
font-size: 16px;
|
|
331
|
-
color: ${theme.palette.text.primary};
|
|
332
|
-
`,
|
|
333
|
-
points: css`
|
|
334
|
-
color: ${theme.palette.primary.main};
|
|
335
|
-
font-weight: 700;
|
|
336
|
-
`,
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (!loadingType) {
|
|
340
|
-
return (
|
|
341
|
-
<WrapperModal title={kycCopy.title}>
|
|
342
|
-
<Box css={styles.iconWrapper}>
|
|
343
|
-
<img src={ApproveLenderImg} alt='approve-lender' />
|
|
344
|
-
</Box>
|
|
345
|
-
{campaign && kycCopy === KYCCopies.verifyIdentity ? (
|
|
346
|
-
<Box css={styles.description}>
|
|
347
|
-
<span>
|
|
348
|
-
You'll be rewarded with Huma rewards after completing KYC/KYB and
|
|
349
|
-
your first investment.
|
|
350
|
-
</span>
|
|
351
|
-
</Box>
|
|
352
|
-
) : (
|
|
353
|
-
<Box css={styles.description}>{kycCopy.description}</Box>
|
|
354
|
-
)}
|
|
355
|
-
|
|
356
|
-
{Boolean(kycCopy.buttonText) && (
|
|
357
|
-
<BottomButton variant='contained' onClick={handleAction}>
|
|
358
|
-
{kycCopy.buttonText}
|
|
359
|
-
</BottomButton>
|
|
360
|
-
)}
|
|
361
|
-
</WrapperModal>
|
|
362
|
-
)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return (
|
|
366
|
-
<LoadingModal
|
|
367
|
-
title='Lender Approval'
|
|
368
|
-
description='Checking your verification status...'
|
|
369
|
-
/>
|
|
370
|
-
)
|
|
371
|
-
}
|