@huma-finance/widgets 0.0.59-beta.482 → 0.0.59-beta.487

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.
Files changed (42) hide show
  1. package/API.md +0 -1
  2. package/dist/cjs/index.cjs +120 -407
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.d.ts +0 -2
  5. package/dist/index.js +123 -409
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -6
  8. package/src/components/Activity.tsx +1 -1
  9. package/src/components/ApproveAllowanceModal.tsx +1 -1
  10. package/src/components/ApproveAllowanceModalV2.tsx +1 -1
  11. package/src/components/ChooseAmountModal.tsx +5 -6
  12. package/src/components/ConfirmTransferModal.tsx +2 -3
  13. package/src/components/CreditLine/borrow/1-Evaluation.tsx +3 -3
  14. package/src/components/ErrorModal.tsx +2 -2
  15. package/src/components/Factoring/FactoredList.tsx +2 -2
  16. package/src/components/Factoring/UpcomingList.tsx +2 -2
  17. package/src/components/HumaSnackBar.tsx +2 -2
  18. package/src/components/HumaTable.tsx +3 -3
  19. package/src/components/InputAmountModal.tsx +4 -4
  20. package/src/components/Lend/addRedemptionV2/1-ChooseTranche.tsx +2 -2
  21. package/src/components/Lend/supply/1-Evaluation/EvaluationEA.tsx +1 -1
  22. package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +1 -1
  23. package/src/components/Lend/supplyV2/1-ChooseTranche.tsx +2 -2
  24. package/src/components/Lend/supplyV2/2-Evaluation.tsx +329 -20
  25. package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +9 -3
  26. package/src/components/Lend/supplyV2/index.tsx +4 -37
  27. package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +2 -2
  28. package/src/components/Notifi/NotifiSubscriptionModal.tsx +1 -1
  29. package/src/components/ReceivableBackedCreditLine/payment/1-ChoosePaymentType.tsx +2 -2
  30. package/src/components/SignIn.tsx +1 -1
  31. package/src/components/SuperfluidFactoring/index.tsx +2 -2
  32. package/src/components/TxDoneModal.tsx +1 -1
  33. package/src/components/WrapperModal.tsx +2 -2
  34. package/src/components/humaModal/HumaModal.tsx +0 -1
  35. package/src/index.tsx +0 -2
  36. package/src/store/widgets.reducers.ts +1 -0
  37. package/src/theme/components.ts +1 -1
  38. package/dist/assets/output-f6156dde.css +0 -45
  39. package/dist/cjs/assets/output-f6156dde.css +0 -45
  40. package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +0 -361
  41. package/src/components/Lend/supplyV2/components/SecuritizeEvaluation.tsx +0 -345
  42. package/src/index.css +0 -61
@@ -1,45 +0,0 @@
1
- @font-face {
2
- font-family: "Recoleta-Medium";
3
- src: local("Recoleta-Medium"), url(./fonts/Recoleta/Recoleta-Medium.otf) format("truetype");
4
- font-weight: 500;
5
- }
6
- @font-face {
7
- font-family: "Roboto-Medium";
8
- src: local("Roboto-Medium"), url(./fonts/Roboto/Roboto-Medium.ttf) format("truetype");
9
- font-weight: 500;
10
- }
11
- @font-face {
12
- font-family: "Roboto-Regular";
13
- src: local("Roboto-Regular"), url(./fonts/Roboto/Roboto-Regular.ttf) format("truetype");
14
- font-weight: 400;
15
- }
16
- @font-face {
17
- font-family: "Inter-Bold";
18
- src: local("Inter-Bold"), url(./fonts/Inter/Inter-Bold.ttf) format("truetype");
19
- font-weight: 700;
20
- }
21
- @font-face {
22
- font-family: "Inter-Medium";
23
- src: local("Inter-Medium"), url(./fonts/Inter/Inter-Medium.ttf) format("truetype");
24
- font-weight: 500;
25
- }
26
- @font-face {
27
- font-family: "Inter-Regular";
28
- src: local("Inter-Regular"), url(./fonts/Inter/Inter-Regular.ttf) format("truetype");
29
- font-weight: 400;
30
- }
31
- @font-face {
32
- font-family: "Uni-Neue-Black";
33
- src: local("Uni-Neue-Black"), url(./fonts/UniNeue/UniNeue-Black.ttf) format("truetype");
34
- font-weight: 800;
35
- }
36
- @font-face {
37
- font-family: "Uni-Neue-Bold";
38
- src: local("Uni-Neue-Bold"), url(./fonts/UniNeue/UniNeue-Bold.ttf) format("truetype");
39
- font-weight: 700;
40
- }
41
- @font-face {
42
- font-family: "Uni-Neue-Regular";
43
- src: local("Uni-Neue-Regular"), url(./fonts/UniNeue/UniNeue-Regular.ttf) format("truetype");
44
- font-weight: 400;
45
- }
@@ -1,45 +0,0 @@
1
- @font-face {
2
- font-family: "Recoleta-Medium";
3
- src: local("Recoleta-Medium"), url(./fonts/Recoleta/Recoleta-Medium.otf) format("truetype");
4
- font-weight: 500;
5
- }
6
- @font-face {
7
- font-family: "Roboto-Medium";
8
- src: local("Roboto-Medium"), url(./fonts/Roboto/Roboto-Medium.ttf) format("truetype");
9
- font-weight: 500;
10
- }
11
- @font-face {
12
- font-family: "Roboto-Regular";
13
- src: local("Roboto-Regular"), url(./fonts/Roboto/Roboto-Regular.ttf) format("truetype");
14
- font-weight: 400;
15
- }
16
- @font-face {
17
- font-family: "Inter-Bold";
18
- src: local("Inter-Bold"), url(./fonts/Inter/Inter-Bold.ttf) format("truetype");
19
- font-weight: 700;
20
- }
21
- @font-face {
22
- font-family: "Inter-Medium";
23
- src: local("Inter-Medium"), url(./fonts/Inter/Inter-Medium.ttf) format("truetype");
24
- font-weight: 500;
25
- }
26
- @font-face {
27
- font-family: "Inter-Regular";
28
- src: local("Inter-Regular"), url(./fonts/Inter/Inter-Regular.ttf) format("truetype");
29
- font-weight: 400;
30
- }
31
- @font-face {
32
- font-family: "Uni-Neue-Black";
33
- src: local("Uni-Neue-Black"), url(./fonts/UniNeue/UniNeue-Black.ttf) format("truetype");
34
- font-weight: 800;
35
- }
36
- @font-face {
37
- font-family: "Uni-Neue-Bold";
38
- src: local("Uni-Neue-Bold"), url(./fonts/UniNeue/UniNeue-Bold.ttf) format("truetype");
39
- font-weight: 700;
40
- }
41
- @font-face {
42
- font-family: "Uni-Neue-Regular";
43
- src: local("Uni-Neue-Regular"), url(./fonts/UniNeue/UniNeue-Regular.ttf) format("truetype");
44
- font-weight: 400;
45
- }
@@ -1,361 +0,0 @@
1
- import {
2
- checkIsDev,
3
- IdentityServiceV2,
4
- IdentityVerificationStatusV2,
5
- KYCCopy,
6
- PoolInfoV2,
7
- TrancheType,
8
- useAuthErrorHandling,
9
- VerificationStatusResultV2,
10
- } from '@huma-finance/shared'
11
- import { Box, css, useTheme } from '@mui/material'
12
- import { useWeb3React } from '@web3-react/core'
13
- import React, { useCallback, useEffect, useRef, useState } from 'react'
14
-
15
- import Persona, { Client } from 'persona'
16
- import { useAppDispatch } from '../../../../hooks/useRedux'
17
- import { setError, setStep } from '../../../../store/widgets.reducers'
18
- import { BottomButton } from '../../../BottomButton'
19
- import { ApproveLenderImg } from '../../../images'
20
- import { LoadingModal } from '../../../LoadingModal'
21
- import { WrapperModal } from '../../../WrapperModal'
22
- import { WIDGET_STEP } from '../../../../store/widgets.store'
23
-
24
- const LoadingCopiesByType: {
25
- [key: string]: {
26
- description: string
27
- }
28
- } = {
29
- verificationStatus: {
30
- description: `Checking your verification status...`,
31
- },
32
- startKYC: {
33
- description: `Starting KYC...`,
34
- },
35
- approveLender: {
36
- description: `Approving as lender...`,
37
- },
38
- }
39
-
40
- type Props = {
41
- poolInfo: PoolInfoV2
42
- isUniTranche: boolean
43
- changeTranche: (tranche: TrancheType) => void
44
- handleClose: () => void
45
- }
46
-
47
- export function PersonaEvaluation({
48
- poolInfo,
49
- isUniTranche,
50
- changeTranche,
51
- handleClose,
52
- }: Props): React.ReactElement | null {
53
- const theme = useTheme()
54
- const isDev = checkIsDev()
55
- const dispatch = useAppDispatch()
56
- const { account, chainId } = useWeb3React()
57
- const {
58
- errorType,
59
- setError: setAuthError,
60
- isWalletOwnershipVerified,
61
- isWalletOwnershipVerificationRequired,
62
- } = useAuthErrorHandling(isDev)
63
- const KYCCopies = poolInfo.KYC!.Persona!
64
- const [loadingType, setLoadingType] = useState<
65
- 'verificationStatus' | 'startKYC' | 'approveLender' | undefined
66
- >()
67
- const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
68
- const [inquiryId, setInquiryId] = useState<string | undefined>()
69
- const [sessionToken, setSessionToken] = useState<string | undefined>()
70
- const [verificationStatus, setVerificationStatus] = useState<
71
- VerificationStatusResultV2 | undefined
72
- >()
73
- const [showPersonaClient, setShowPersonaClient] = useState<boolean>(false)
74
- const isKYCCompletedRef = useRef<boolean>(false)
75
- const isActionOngoingRef = useRef<boolean>(false)
76
- const isKYCResumedRef = useRef<boolean>(false)
77
-
78
- const approveLender = useCallback(async () => {
79
- try {
80
- isActionOngoingRef.current = true
81
- setLoadingType('approveLender')
82
- await IdentityServiceV2.approveLender(
83
- account!,
84
- chainId!,
85
- poolInfo.juniorTrancheVault,
86
- isDev,
87
- )
88
- if (!isUniTranche) {
89
- await IdentityServiceV2.approveLender(
90
- account!,
91
- chainId!,
92
- poolInfo.seniorTrancheVault,
93
- isDev,
94
- )
95
- }
96
- if (isUniTranche) {
97
- changeTranche('junior')
98
- dispatch(setStep(WIDGET_STEP.ChooseAmount))
99
- } else {
100
- dispatch(setStep(WIDGET_STEP.ChooseTranche))
101
- }
102
- } finally {
103
- isActionOngoingRef.current = false
104
- setLoadingType(undefined)
105
- }
106
- }, [
107
- account,
108
- chainId,
109
- changeTranche,
110
- dispatch,
111
- isDev,
112
- isUniTranche,
113
- poolInfo.juniorTrancheVault,
114
- poolInfo.seniorTrancheVault,
115
- ])
116
-
117
- const checkVerificationStatus = useCallback(async () => {
118
- if (isActionOngoingRef.current || isKYCResumedRef.current) {
119
- return
120
- }
121
- try {
122
- if (account && chainId) {
123
- isActionOngoingRef.current = true
124
- setLoadingType('verificationStatus')
125
- const verificationStatus =
126
- await IdentityServiceV2.getVerificationStatusV2(
127
- account,
128
- chainId,
129
- isDev,
130
- )
131
- setVerificationStatus(verificationStatus)
132
- setInquiryId(verificationStatus.personaInquiryId)
133
-
134
- switch (verificationStatus.status) {
135
- case IdentityVerificationStatusV2.NOT_STARTED: {
136
- const startVerificationResult =
137
- await IdentityServiceV2.startVerification(account, chainId, isDev)
138
- setInquiryId(startVerificationResult.personaInquiryId)
139
- setKYCCopy(KYCCopies.verifyIdentity)
140
- setLoadingType(undefined)
141
- break
142
- }
143
-
144
- case IdentityVerificationStatusV2.CREATED: {
145
- setKYCCopy(KYCCopies.verifyIdentity)
146
- setLoadingType(undefined)
147
- break
148
- }
149
-
150
- case IdentityVerificationStatusV2.PENDING: {
151
- if (!isKYCCompletedRef.current) {
152
- const resumeVerificationResult =
153
- await IdentityServiceV2.resumeVerification(
154
- account,
155
- chainId,
156
- isDev,
157
- )
158
- verificationStatus.status = resumeVerificationResult.status
159
- setVerificationStatus(verificationStatus)
160
- setSessionToken(resumeVerificationResult.sessionToken)
161
- setLoadingType(undefined)
162
- isKYCResumedRef.current = true
163
- } else {
164
- setLoadingType('verificationStatus')
165
- }
166
- setKYCCopy(KYCCopies.verifyIdentity)
167
- break
168
- }
169
-
170
- case IdentityVerificationStatusV2.EXPIRED: {
171
- const resumeVerificationResult =
172
- await IdentityServiceV2.resumeVerification(
173
- account,
174
- chainId,
175
- isDev,
176
- )
177
- verificationStatus.status = resumeVerificationResult.status
178
- setVerificationStatus(verificationStatus)
179
- setSessionToken(resumeVerificationResult.sessionToken)
180
- setKYCCopy(KYCCopies.verifyIdentity)
181
- setLoadingType(undefined)
182
- isKYCResumedRef.current = true
183
- break
184
- }
185
-
186
- case IdentityVerificationStatusV2.APPROVED: {
187
- await approveLender()
188
- break
189
- }
190
-
191
- case IdentityVerificationStatusV2.DECLINED: {
192
- setKYCCopy(KYCCopies.verificationDeclined)
193
- setLoadingType(undefined)
194
- break
195
- }
196
-
197
- case IdentityVerificationStatusV2.NEEDS_REVIEW: {
198
- setKYCCopy(KYCCopies.verificationNeedsReview)
199
- setLoadingType(undefined)
200
- break
201
- }
202
-
203
- default:
204
- break
205
- }
206
- }
207
- } catch (e: unknown) {
208
- setAuthError(e)
209
- } finally {
210
- isActionOngoingRef.current = false
211
- }
212
- }, [KYCCopies, account, approveLender, chainId, isDev, setAuthError])
213
-
214
- useEffect(() => {
215
- checkVerificationStatus()
216
- }, [checkVerificationStatus])
217
-
218
- useEffect(() => {
219
- if (isWalletOwnershipVerificationRequired && isWalletOwnershipVerified) {
220
- checkVerificationStatus()
221
- }
222
- }, [
223
- checkVerificationStatus,
224
- isWalletOwnershipVerificationRequired,
225
- isWalletOwnershipVerified,
226
- ])
227
-
228
- useEffect(() => {
229
- const interval = setInterval(() => {
230
- if (
231
- verificationStatus?.status &&
232
- [
233
- IdentityVerificationStatusV2.CREATED,
234
- IdentityVerificationStatusV2.PENDING,
235
- ].includes(verificationStatus.status)
236
- ) {
237
- checkVerificationStatus()
238
- }
239
- }, 10 * 1000)
240
- // eslint-disable-next-line consistent-return
241
- return () => clearInterval(interval)
242
- }, [checkVerificationStatus, verificationStatus?.status])
243
-
244
- useEffect(() => {
245
- if (errorType === 'NotSignedIn') {
246
- setLoadingType(undefined)
247
- setKYCCopy(KYCCopies.signInRequired)
248
- } else if (errorType === 'UserRejected') {
249
- dispatch(
250
- setError({
251
- errorMessage: 'User has rejected the transaction.',
252
- }),
253
- )
254
- } else if (errorType === 'Other') {
255
- dispatch(
256
- setError({
257
- errorMessage: 'Something went wrong. Please try again later.',
258
- }),
259
- )
260
- }
261
- }, [KYCCopies.signInRequired, dispatch, errorType])
262
-
263
- useEffect(() => {
264
- const modalElement = document.getElementById('huma-modal')
265
- if (modalElement) {
266
- modalElement.style.visibility = showPersonaClient ? 'hidden' : 'visible'
267
- }
268
- }, [showPersonaClient])
269
-
270
- const startKYC = async () => {
271
- isActionOngoingRef.current = true
272
- isKYCResumedRef.current = false
273
- setLoadingType('startKYC')
274
- const client: Client = new Persona.Client({
275
- inquiryId,
276
- sessionToken,
277
- onReady: () => {
278
- client.open()
279
- setShowPersonaClient(true)
280
- },
281
- onComplete: () => {
282
- isKYCCompletedRef.current = true
283
- isActionOngoingRef.current = false
284
- setShowPersonaClient(false)
285
- checkVerificationStatus()
286
- },
287
- onCancel: () => {
288
- isActionOngoingRef.current = false
289
- setShowPersonaClient(false)
290
- setLoadingType(undefined)
291
- },
292
- onError: () => {
293
- isActionOngoingRef.current = false
294
- setShowPersonaClient(false)
295
- setLoadingType(undefined)
296
- },
297
- })
298
- }
299
-
300
- const handleAction = () => {
301
- if (verificationStatus) {
302
- switch (verificationStatus.status) {
303
- case IdentityVerificationStatusV2.NOT_STARTED:
304
- case IdentityVerificationStatusV2.CREATED:
305
- case IdentityVerificationStatusV2.PENDING:
306
- case IdentityVerificationStatusV2.EXPIRED:
307
- startKYC()
308
- break
309
-
310
- case IdentityVerificationStatusV2.DECLINED:
311
- case IdentityVerificationStatusV2.NEEDS_REVIEW:
312
- handleClose()
313
- break
314
-
315
- default:
316
- break
317
- }
318
- }
319
- }
320
-
321
- const styles = {
322
- iconWrapper: css`
323
- ${theme.cssMixins.rowCentered};
324
- margin-top: ${theme.spacing(8)};
325
- & > img {
326
- width: 144px;
327
- }
328
- `,
329
- description: css`
330
- ${theme.cssMixins.rowCentered};
331
- margin-top: ${theme.spacing(10)};
332
- padding: ${theme.spacing(0, 2)};
333
- font-family: 'Uni-Neue-Regular';
334
- font-size: 16px;
335
- color: #a8a1b2;
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
- <Box css={styles.description}>{kycCopy.description}</Box>
346
- {Boolean(kycCopy.buttonText) && (
347
- <BottomButton variant='contained' onClick={handleAction}>
348
- {kycCopy.buttonText}
349
- </BottomButton>
350
- )}
351
- </WrapperModal>
352
- )
353
- }
354
-
355
- return (
356
- <LoadingModal
357
- title='Lender Approval'
358
- description={LoadingCopiesByType[loadingType].description}
359
- />
360
- )
361
- }