@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,345 +0,0 @@
1
- import {
2
- CHAINS,
3
- checkIsDev,
4
- configUtil,
5
- DocSignatureStatus,
6
- IdentityService,
7
- KYC_PROVIDER,
8
- KYCCopy,
9
- PoolInfoV2,
10
- timeUtil,
11
- useAuthErrorHandling,
12
- useParamsSearch,
13
- VerificationStatusResult,
14
- } from '@huma-finance/shared'
15
- import { Box, css, useTheme } from '@mui/material'
16
- import { useWeb3React } from '@web3-react/core'
17
- import React, { useCallback, useEffect, useMemo, useState } from 'react'
18
-
19
- import { useAppDispatch } from '../../../../hooks/useRedux'
20
- import { setError } from '../../../../store/widgets.reducers'
21
- import { BottomButton } from '../../../BottomButton'
22
- import { HumaSnackBar } from '../../../HumaSnackBar'
23
- import { ApproveLenderImg } from '../../../images'
24
- import { LoadingModal } from '../../../LoadingModal'
25
- import { WrapperModal } from '../../../WrapperModal'
26
-
27
- const LoadingCopiesByType: {
28
- [key: string]: {
29
- description: string
30
- }
31
- } = {
32
- verificationStatus: {
33
- description: `Checking your verification status...`,
34
- },
35
- sendDocSignatureLink: {
36
- description: `Sending signature link...`,
37
- },
38
- }
39
-
40
- type Props = {
41
- poolInfo: PoolInfoV2
42
- handleClose: () => void
43
- }
44
-
45
- export function SecuritizeEvaluation({
46
- poolInfo,
47
- handleClose,
48
- }: Props): React.ReactElement | null {
49
- const theme = useTheme()
50
- const isDev = checkIsDev()
51
- const dispatch = useAppDispatch()
52
- const { account, chainId } = useWeb3React()
53
- const { kycProvider, code, kycPool } = useParamsSearch()
54
- const {
55
- isWalletOwnershipVerified,
56
- setError: setAuthError,
57
- error: authError,
58
- } = useAuthErrorHandling(isDev)
59
- const [loadingType, setLoadingType] = useState<
60
- 'verificationStatus' | 'sendDocSignatureLink'
61
- >()
62
- const KYCCopies = poolInfo.KYC!.Securitize!
63
- const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
64
- const [KYCVerifyStatus, setKYCVerifyStatus] =
65
- useState<VerificationStatusResult>()
66
- const [docSignatureStatus, setDocSignatureStatus] =
67
- useState<DocSignatureStatus['status']>()
68
- const docSignatureCompleted = docSignatureStatus === 'completed'
69
- const [openSnackBar, setOpenSnackBar] = useState<boolean>(false)
70
-
71
- const { envelopeKey, envelopeLastQueryTimeKey, envelopeDocuSignStatusKey } =
72
- useMemo(() => {
73
- const envelopeKey = `${poolInfo.pool.toLowerCase()}-${account?.toLowerCase()}`
74
- const envelopeLastQueryTimeKey = `${envelopeKey}-last-query-time`
75
- const envelopeDocuSignStatusKey = `${envelopeKey}-docuSign-status`
76
- return {
77
- envelopeKey,
78
- envelopeLastQueryTimeKey,
79
- envelopeDocuSignStatusKey,
80
- }
81
- }, [account, poolInfo.pool])
82
-
83
- // DocuSign GET requests to any specific URL can be called not more often than once every 15 minutes.
84
- // https://developers.docusign.com/platform/api-guidelines/#:~:text=Polling,not%20once%20every%2010%20minutes
85
- const checkGetDocSignatureStatusIsAvailable = useCallback(() => {
86
- const lastQueryTime = localStorage.getItem(envelopeLastQueryTimeKey)
87
- if (!lastQueryTime) {
88
- return true
89
- }
90
- const lastQueryTimeNumber = Number(lastQueryTime)
91
- const now = timeUtil.getUnixTimestamp()
92
- const diff = now - lastQueryTimeNumber
93
- const fifteenMinutes = 15 * 60
94
- return diff > fifteenMinutes
95
- }, [envelopeLastQueryTimeKey])
96
-
97
- useEffect(() => {
98
- setKYCCopy(KYCCopies.verifyIdentity)
99
- const docuSignStatus = localStorage.getItem(envelopeDocuSignStatusKey)
100
- setDocSignatureStatus(docuSignStatus as DocSignatureStatus['status'])
101
- if (docuSignStatus === 'completed') {
102
- setKYCCopy(KYCCopies.docUnderReview!)
103
- return
104
- }
105
-
106
- const fetchData = async () => {
107
- try {
108
- if (kycProvider && kycPool && account && chainId) {
109
- setLoadingType('verificationStatus')
110
- await IdentityService.onboard(
111
- account,
112
- code as string,
113
- kycPool as string,
114
- chainId,
115
- isDev,
116
- )
117
- }
118
- } catch (e) {
119
- try {
120
- setAuthError(e)
121
- setKYCCopy(KYCCopies.signInRequired)
122
- } catch (e) {
123
- // The repeated call will throw an error of 401, so we can ignore it.
124
- console.log(e)
125
- }
126
- }
127
-
128
- try {
129
- if (account && chainId) {
130
- setLoadingType('verificationStatus')
131
- const verificationStatus =
132
- await IdentityService.getVerificationStatus(
133
- account,
134
- poolInfo.pool,
135
- chainId,
136
- isDev,
137
- )
138
- setKYCVerifyStatus(verificationStatus)
139
- if (verificationStatus.isVerified) {
140
- const envelopeId = localStorage.getItem(envelopeKey)
141
- if (!envelopeId) {
142
- setKYCCopy(KYCCopies.emailSignatureLink!)
143
- } else if (!checkGetDocSignatureStatusIsAvailable()) {
144
- setKYCCopy(KYCCopies.resendSignatureLink!)
145
- } else {
146
- const { status } = await IdentityService.getDocSignatureStatus(
147
- envelopeId,
148
- chainId,
149
- isDev,
150
- )
151
- localStorage.setItem(
152
- envelopeLastQueryTimeKey,
153
- String(timeUtil.getUnixTimestamp()),
154
- )
155
- localStorage.setItem(envelopeDocuSignStatusKey, status)
156
- setDocSignatureStatus(status)
157
- if (status === 'completed') {
158
- setKYCCopy(KYCCopies.docUnderReview!)
159
- // For voided and declined status, we need to send a new link
160
- } else if (['voided', 'declined'].includes(status)) {
161
- localStorage.removeItem(envelopeKey)
162
- localStorage.removeItem(envelopeLastQueryTimeKey)
163
- setKYCCopy(KYCCopies.emailSignatureLink!)
164
- } else {
165
- setKYCCopy(KYCCopies.resendSignatureLink!)
166
- }
167
- }
168
- } else {
169
- setKYCCopy(KYCCopies.verifyIdentity)
170
- }
171
- }
172
- } catch (e: unknown) {
173
- try {
174
- setAuthError(e)
175
- setKYCCopy(KYCCopies.signInRequired)
176
- } catch (e) {
177
- console.error(e)
178
- dispatch(
179
- setError({
180
- errorMessage: 'Something went wrong, please try again later.',
181
- }),
182
- )
183
- }
184
- } finally {
185
- setLoadingType(undefined)
186
- }
187
- }
188
- fetchData()
189
- }, [
190
- KYCCopies.docUnderReview,
191
- KYCCopies.emailSignatureLink,
192
- KYCCopies.resendSignatureLink,
193
- KYCCopies.signInRequired,
194
- KYCCopies.verifyIdentity,
195
- account,
196
- chainId,
197
- checkGetDocSignatureStatusIsAvailable,
198
- code,
199
- dispatch,
200
- envelopeDocuSignStatusKey,
201
- envelopeKey,
202
- envelopeLastQueryTimeKey,
203
- isDev,
204
- kycPool,
205
- kycProvider,
206
- poolInfo.pool,
207
- setAuthError,
208
- isWalletOwnershipVerified,
209
- ])
210
-
211
- useEffect(() => {
212
- if (
213
- authError &&
214
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
215
- [4001, 'ACTION_REJECTED'].includes((authError as any).code)
216
- ) {
217
- dispatch(
218
- setError({
219
- errorMessage: 'User has rejected the transaction.',
220
- }),
221
- )
222
- }
223
- }, [authError, dispatch])
224
-
225
- const approveLender = async () => {
226
- if (docSignatureCompleted) {
227
- handleClose()
228
- return
229
- }
230
-
231
- const { isNotOnboarded, isVerified } = KYCVerifyStatus || {}
232
-
233
- if (!isVerified) {
234
- const issuerId = CHAINS[chainId!].isTestnet
235
- ? '53a66b32-583e-40e7-ba90-baf516d2cadd'
236
- : '5557baf5-d3c2-4c80-b522-c05a11c6e586'
237
- const baseUrl = configUtil.getKYCProviderBaseUrl(
238
- KYC_PROVIDER.Securitize,
239
- chainId!,
240
- )
241
- const originUrl = window.location.href.split('?')[0]
242
- const redirectUrl = `${originUrl}?poolName=${poolInfo.poolName}&kycProvider=${KYC_PROVIDER.Securitize}&kycPool=${poolInfo.pool}`
243
- const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
244
- window.location.href = isNotOnboarded ? providerAuthorizeUrl : baseUrl
245
- } else {
246
- const envelopeId = localStorage.getItem(envelopeKey)
247
- try {
248
- setLoadingType('sendDocSignatureLink')
249
- if (!envelopeId) {
250
- const { envelopeId } = await IdentityService.requestDocSignature(
251
- account!,
252
- chainId!,
253
- isDev,
254
- )
255
- localStorage.setItem(envelopeKey, envelopeId)
256
- localStorage.setItem(
257
- envelopeLastQueryTimeKey,
258
- String(timeUtil.getUnixTimestamp()),
259
- )
260
- setOpenSnackBar(true)
261
- setKYCCopy(KYCCopies.resendSignatureLink)
262
- } else {
263
- await IdentityService.resendDocSignatureLink(
264
- envelopeId,
265
- chainId!,
266
- isDev,
267
- )
268
- setOpenSnackBar(true)
269
- }
270
- } catch (e: unknown) {
271
- try {
272
- const { envelopeId } = await IdentityService.requestDocSignature(
273
- account!,
274
- chainId!,
275
- isDev,
276
- )
277
- localStorage.setItem(envelopeKey, envelopeId)
278
- localStorage.setItem(
279
- envelopeLastQueryTimeKey,
280
- String(timeUtil.getUnixTimestamp()),
281
- )
282
- setOpenSnackBar(true)
283
- setKYCCopy(KYCCopies.resendSignatureLink)
284
- } catch (e) {
285
- setAuthError(e)
286
- setKYCCopy(KYCCopies.signInRequired)
287
- }
288
- } finally {
289
- setLoadingType(undefined)
290
- }
291
- }
292
- }
293
-
294
- const getEmailLinkSentSnackbar = () => (
295
- <HumaSnackBar
296
- open={openSnackBar}
297
- title='Signature Link Sent'
298
- message='The secure signature session link has been sent to you via email.'
299
- severity='success'
300
- onClose={() => setOpenSnackBar(false)}
301
- />
302
- )
303
-
304
- const styles = {
305
- iconWrapper: css`
306
- ${theme.cssMixins.rowCentered};
307
- margin-top: ${theme.spacing(8)};
308
- & > img {
309
- width: 144px;
310
- }
311
- `,
312
- description: css`
313
- ${theme.cssMixins.rowCentered};
314
- margin-top: ${theme.spacing(10)};
315
- padding: ${theme.spacing(0, 2)};
316
- font-family: 'Uni-Neue-Regular';
317
- font-size: 16px;
318
- color: #a8a1b2;
319
- `,
320
- }
321
-
322
- if (!loadingType) {
323
- return (
324
- <WrapperModal title={kycCopy.title}>
325
- <Box css={styles.iconWrapper}>
326
- <img src={ApproveLenderImg} alt='approve-lender' />
327
- </Box>
328
- <Box css={styles.description}>{kycCopy.description}</Box>
329
- {Boolean(kycCopy.buttonText) && (
330
- <BottomButton variant='contained' onClick={approveLender}>
331
- {kycCopy.buttonText}
332
- </BottomButton>
333
- )}
334
- {getEmailLinkSentSnackbar()}
335
- </WrapperModal>
336
- )
337
- }
338
-
339
- return (
340
- <LoadingModal
341
- title='Lender Approval'
342
- description={LoadingCopiesByType[loadingType].description}
343
- />
344
- )
345
- }
package/src/index.css DELETED
@@ -1,61 +0,0 @@
1
- @font-face {
2
- font-family: 'Recoleta-Medium';
3
- src: local('Recoleta-Medium'),
4
- url(./fonts/Recoleta/Recoleta-Medium.otf) format('truetype');
5
- font-weight: 500;
6
- }
7
-
8
- @font-face {
9
- font-family: 'Roboto-Medium';
10
- src: local('Roboto-Medium'),
11
- url(./fonts/Roboto/Roboto-Medium.ttf) format('truetype');
12
- font-weight: 500;
13
- }
14
-
15
- @font-face {
16
- font-family: 'Roboto-Regular';
17
- src: local('Roboto-Regular'),
18
- url(./fonts/Roboto/Roboto-Regular.ttf) format('truetype');
19
- font-weight: 400;
20
- }
21
-
22
- @font-face {
23
- font-family: 'Inter-Bold';
24
- src: local('Inter-Bold'), url(./fonts/Inter/Inter-Bold.ttf) format('truetype');
25
- font-weight: 700;
26
- }
27
-
28
- @font-face {
29
- font-family: 'Inter-Medium';
30
- src: local('Inter-Medium'),
31
- url(./fonts/Inter/Inter-Medium.ttf) format('truetype');
32
- font-weight: 500;
33
- }
34
-
35
- @font-face {
36
- font-family: 'Inter-Regular';
37
- src: local('Inter-Regular'),
38
- url(./fonts/Inter/Inter-Regular.ttf) format('truetype');
39
- font-weight: 400;
40
- }
41
-
42
- @font-face {
43
- font-family: 'Uni-Neue-Black';
44
- src: local('Uni-Neue-Black'),
45
- url(./fonts/UniNeue/UniNeue-Black.ttf) format('truetype');
46
- font-weight: 800;
47
- }
48
-
49
- @font-face {
50
- font-family: 'Uni-Neue-Bold';
51
- src: local('Uni-Neue-Bold'),
52
- url(./fonts/UniNeue/UniNeue-Bold.ttf) format('truetype');
53
- font-weight: 700;
54
- }
55
-
56
- @font-face {
57
- font-family: 'Uni-Neue-Regular';
58
- src: local('Uni-Neue-Regular'),
59
- url(./fonts/UniNeue/UniNeue-Regular.ttf) format('truetype');
60
- font-weight: 400;
61
- }