@huma-finance/widgets 0.0.41 → 0.0.42-beta.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.41",
3
+ "version": "0.0.42-beta.76+6ee5093",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,8 +30,8 @@
30
30
  "@ethersproject/experimental": "^5.7.0",
31
31
  "@ethersproject/providers": "^5.6.0",
32
32
  "@ethersproject/units": "^5.6.0",
33
- "@huma-finance/sdk": "^0.0.41",
34
- "@huma-finance/shared": "^0.0.41",
33
+ "@huma-finance/sdk": "^0.0.42-beta.76+6ee5093",
34
+ "@huma-finance/shared": "^0.0.42-beta.76+6ee5093",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -194,5 +194,5 @@
194
194
  "optionalDependencies": {
195
195
  "encoding": "^0.1.13"
196
196
  },
197
- "gitHead": "2e59758ee0f4bf6cc9dd6c031f2a61a066d2fdfe"
197
+ "gitHead": "6ee509335f870cf5bc69fbd6ce742f843e3e0798"
198
198
  }
@@ -1,12 +1,13 @@
1
1
  import {
2
+ CHAINS,
2
3
  configUtil,
3
4
  DocSignatureStatus,
4
5
  IdentityService,
5
6
  PoolInfoType,
6
7
  timeUtil,
7
- VerificationStatusResult,
8
- CHAINS,
8
+ useAuthErrorHandling,
9
9
  useParamsSearch,
10
+ VerificationStatusResult,
10
11
  } from '@huma-finance/shared'
11
12
  import { Box, css, useTheme } from '@mui/material'
12
13
  import { useWeb3React } from '@web3-react/core'
@@ -26,11 +27,16 @@ const KYCProvider = 'Securitize'
26
27
  type KYCCopy = {
27
28
  title: string
28
29
  description: string
29
- buttonText: string
30
+ buttonText?: string
30
31
  }
31
32
 
32
33
  // TODO: Add copies for the other pools. Currently only the Jia pool is using the KYC process.
33
34
  const JiaPoolCopies = {
35
+ signInRequired: {
36
+ title: 'Sign In',
37
+ description:
38
+ 'Please sign in to verify that you are the owner of the wallet.',
39
+ },
34
40
  verifyIdentity: {
35
41
  title: 'Verify Identity',
36
42
  description: `This pool is only available to accredited investors at the moment, with minimum investments of $10,000. Please complete identity verification and investor accreditation via ${KYCProvider}.`,
@@ -81,6 +87,8 @@ export function EvaluationKYC({
81
87
  const isDev = envUtil.checkIsDev()
82
88
  const { account, chainId } = useWeb3React()
83
89
  const { kycProvider, code, kycPool } = useParamsSearch()
90
+ const { isWalletOwnershipVerified, setError: setAuthError } =
91
+ useAuthErrorHandling(account, chainId, isDev)
84
92
  const [loadingType, setLoadingType] = useState<
85
93
  'verificationStatus' | 'sendDocSignatureLink'
86
94
  >()
@@ -157,8 +165,13 @@ export function EvaluationKYC({
157
165
  )
158
166
  }
159
167
  } catch (e) {
160
- // The repeated call will throw an error of 401, so we can ignore it.
161
- console.error(e)
168
+ try {
169
+ setAuthError(e)
170
+ setKYCCopy(JiaPoolCopies.signInRequired)
171
+ } catch (e) {
172
+ // The repeated call will throw an error of 401, so we can ignore it.
173
+ console.log(e)
174
+ }
162
175
  }
163
176
 
164
177
  try {
@@ -204,12 +217,17 @@ export function EvaluationKYC({
204
217
  }
205
218
  }
206
219
  } catch (e: unknown) {
207
- console.error(e)
208
- dispatch(
209
- setError({
210
- errorMessage: 'Something went wrong, please try again later.',
211
- }),
212
- )
220
+ try {
221
+ setAuthError(e)
222
+ setKYCCopy(JiaPoolCopies.signInRequired)
223
+ } catch (e) {
224
+ console.error(e)
225
+ dispatch(
226
+ setError({
227
+ errorMessage: 'Something went wrong, please try again later.',
228
+ }),
229
+ )
230
+ }
213
231
  } finally {
214
232
  setLoadingType(undefined)
215
233
  }
@@ -228,6 +246,8 @@ export function EvaluationKYC({
228
246
  kycPool,
229
247
  kycProvider,
230
248
  poolInfo.pool,
249
+ setAuthError,
250
+ isWalletOwnershipVerified,
231
251
  ])
232
252
 
233
253
  const approveLender = async () => {
@@ -273,12 +293,23 @@ export function EvaluationKYC({
273
293
  setOpenSnackBar(true)
274
294
  }
275
295
  } catch (e: unknown) {
276
- console.error(e)
277
- dispatch(
278
- setError({
279
- errorMessage: 'Something went wrong, please try again later.',
280
- }),
281
- )
296
+ try {
297
+ const { envelopeId } = await IdentityService.requestDocSignature(
298
+ account!,
299
+ chainId!,
300
+ isDev,
301
+ )
302
+ localStorage.setItem(envelopeKey, envelopeId)
303
+ localStorage.setItem(
304
+ envelopeLastQueryTimeKey,
305
+ String(timeUtil.getUnixTimestamp()),
306
+ )
307
+ setOpenSnackBar(true)
308
+ setKYCCopy(JiaPoolCopies.resendSignatureLink)
309
+ } catch (e) {
310
+ setAuthError(e)
311
+ setKYCCopy(JiaPoolCopies.signInRequired)
312
+ }
282
313
  } finally {
283
314
  setLoadingType(undefined)
284
315
  }
@@ -302,9 +333,11 @@ export function EvaluationKYC({
302
333
  <img src={ApproveLenderImg} alt='approve-lender' />
303
334
  </Box>
304
335
  <Box css={styles.description}>{kycCopy.description}</Box>
305
- <BottomButton variant='contained' onClick={approveLender}>
306
- {kycCopy.buttonText}
307
- </BottomButton>
336
+ {Boolean(kycCopy.buttonText) && (
337
+ <BottomButton variant='contained' onClick={approveLender}>
338
+ {kycCopy.buttonText}
339
+ </BottomButton>
340
+ )}
308
341
  {getEmailLinkSentSnackbar()}
309
342
  </WrapperModal>
310
343
  )