@huma-finance/widgets 0.0.62-beta.632 → 0.0.62-beta.634

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.62-beta.632+7821904",
3
+ "version": "0.0.62-beta.634+3b6186e",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -29,9 +29,9 @@
29
29
  "@ethersproject/experimental": "^5.7.0",
30
30
  "@ethersproject/providers": "^5.6.0",
31
31
  "@ethersproject/units": "^5.6.0",
32
- "@huma-finance/sdk": "^0.0.62-beta.632+7821904",
33
- "@huma-finance/shared": "^0.0.62-beta.632+7821904",
34
- "@huma-finance/web-shared": "^0.0.62-beta.632+7821904",
32
+ "@huma-finance/sdk": "^0.0.62-beta.634+3b6186e",
33
+ "@huma-finance/shared": "^0.0.62-beta.634+3b6186e",
34
+ "@huma-finance/web-shared": "^0.0.62-beta.634+3b6186e",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -207,5 +207,5 @@
207
207
  "optionalDependencies": {
208
208
  "encoding": "^0.1.13"
209
209
  },
210
- "gitHead": "7821904f16b9e15eede83b80acf1432f4554550c"
210
+ "gitHead": "3b6186e9343a513451443b20e2b76f96dddefdb0"
211
211
  }
@@ -1,33 +1,38 @@
1
1
  import {
2
2
  CAMPAIGN_REFERENCE_CODE,
3
3
  CampaignService,
4
+ CHAIN_TYPE,
4
5
  checkIsDev,
5
6
  IdentityServiceV2,
6
7
  IdentityVerificationStatusV2,
7
8
  KYCCopy,
8
- PoolInfoV2,
9
+ KYCType,
9
10
  TrancheType,
10
11
  VerificationStatusResultV2,
11
12
  } from '@huma-finance/shared'
12
- import { useAuthErrorHandling } from '@huma-finance/web-shared'
13
+ import { useAuthErrorHandling, useChainInfo } from '@huma-finance/web-shared'
13
14
  import { Box, css, useTheme } from '@mui/material'
14
- import { useWeb3React } from '@web3-react/core'
15
15
  import Persona, { Client } from 'persona'
16
16
  import React, { useCallback, useEffect, useRef, useState } from 'react'
17
17
 
18
- import { Campaign } from '..'
19
- import { useAppDispatch } from '../../../../hooks/useRedux'
20
- import { setError, setStep } from '../../../../store/widgets.reducers'
21
- import { WIDGET_STEP } from '../../../../store/widgets.store'
22
- import { BottomButton } from '../../../BottomButton'
23
- import { ApproveLenderImg } from '../../../images'
24
- import { LoadingModal } from '../../../LoadingModal'
25
- import { WrapperModal } from '../../../WrapperModal'
18
+ import { useAppDispatch } from '../../../hooks/useRedux'
19
+ import { setError, setStep } from '../../../store/widgets.reducers'
20
+ import { WIDGET_STEP } from '../../../store/widgets.store'
21
+ import { BottomButton } from '../../BottomButton'
22
+ import { ApproveLenderImg } from '../../images'
23
+ import { LoadingModal } from '../../LoadingModal'
24
+ import { WrapperModal } from '../../WrapperModal'
25
+ import { Campaign } from '../supplyV2'
26
26
 
27
27
  type LoadingType = 'verificationStatus' | 'startKYC' | 'approveLender'
28
28
 
29
29
  type Props = {
30
- poolInfo: PoolInfoV2
30
+ poolInfo: {
31
+ KYC?: KYCType
32
+ juniorTrancheVault: string
33
+ seniorTrancheVault: string
34
+ }
35
+ chainType: CHAIN_TYPE
31
36
  isUniTranche: boolean
32
37
  pointsTestnetExperience: boolean
33
38
  campaign?: Campaign
@@ -40,13 +45,14 @@ export function PersonaEvaluation({
40
45
  isUniTranche,
41
46
  campaign,
42
47
  pointsTestnetExperience,
48
+ chainType,
43
49
  changeTranche,
44
50
  handleClose,
45
51
  }: Props): React.ReactElement | null {
46
52
  const theme = useTheme()
47
53
  const isDev = checkIsDev()
48
54
  const dispatch = useAppDispatch()
49
- const { account, chainId } = useWeb3React()
55
+ const { account, chainId } = useChainInfo(isDev, chainType)
50
56
  const {
51
57
  errorType,
52
58
  setError: setAuthError,
@@ -14,14 +14,13 @@ import { useAuthErrorHandling, useParamsSearch } from '@huma-finance/web-shared'
14
14
  import { Box, css, useTheme } from '@mui/material'
15
15
  import { useWeb3React } from '@web3-react/core'
16
16
  import React, { useCallback, useEffect, useMemo, useState } from 'react'
17
-
18
- import { useAppDispatch } from '../../../../hooks/useRedux'
19
- import { setError } from '../../../../store/widgets.reducers'
20
- import { BottomButton } from '../../../BottomButton'
21
- import { HumaSnackBar } from '../../../HumaSnackBar'
22
- import { ApproveLenderImg } from '../../../images'
23
- import { LoadingModal } from '../../../LoadingModal'
24
- import { WrapperModal } from '../../../WrapperModal'
17
+ import { useAppDispatch } from '../../../hooks/useRedux'
18
+ import { setError } from '../../../store/widgets.reducers'
19
+ import { HumaSnackBar } from '../../HumaSnackBar'
20
+ import { WrapperModal } from '../../WrapperModal'
21
+ import { ApproveLenderImg } from '../../images'
22
+ import { BottomButton } from '../../BottomButton'
23
+ import { LoadingModal } from '../../LoadingModal'
25
24
 
26
25
  const LoadingCopiesByType: {
27
26
  [key: string]: {
@@ -1,106 +1,43 @@
1
- import {
2
- checkIsDev,
3
- IdentityServiceV2,
4
- SolanaPoolInfo,
5
- } from '@huma-finance/shared'
6
- import { Box, css, useTheme } from '@mui/material'
7
- import { useWallet } from '@solana/wallet-adapter-react'
8
- import React, { useState } from 'react'
1
+ import { CHAIN_TYPE, SolanaPoolInfo, TrancheType } from '@huma-finance/shared'
2
+ import React from 'react'
9
3
 
10
- import { useAppDispatch } from '../../../hooks/useRedux'
11
- import { setError, setStep } from '../../../store/widgets.reducers'
12
- import { WIDGET_STEP } from '../../../store/widgets.store'
13
- import { CustomError } from '../../../utilTypes'
14
- import { BottomButton } from '../../BottomButton'
15
- import { ApproveLenderImg } from '../../images'
16
- import { LoadingModal } from '../../LoadingModal'
17
- import { WrapperModal } from '../../WrapperModal'
4
+ import { PersonaEvaluation } from '../components/PersonaEvaluation'
5
+ import { Campaign } from '../supplyV2'
18
6
 
19
7
  type Props = {
20
8
  poolInfo: SolanaPoolInfo
21
- isUniTranche?: boolean
22
- handleApproveSuccess: () => void
9
+ isUniTranche: boolean
10
+ pointsTestnetExperience: boolean
11
+ campaign?: Campaign
12
+ changeTranche: (tranche: TrancheType) => void
13
+ handleClose: () => void
23
14
  }
24
15
 
25
16
  export function Evaluation({
26
17
  poolInfo,
27
18
  isUniTranche,
28
- handleApproveSuccess,
19
+ pointsTestnetExperience,
20
+ campaign,
21
+ changeTranche,
22
+ handleClose,
29
23
  }: Props): React.ReactElement | null {
30
- const theme = useTheme()
31
- const isDev = checkIsDev()
32
- const dispatch = useAppDispatch()
33
- const { publicKey } = useWallet()
34
- const [loading, setLoading] = useState(false)
35
-
36
- const styles = {
37
- iconWrapper: css`
38
- ${theme.cssMixins.rowCentered};
39
- margin-top: ${theme.spacing(8)};
40
- & > img {
41
- width: 144px;
42
- }
43
- `,
44
- description: css`
45
- ${theme.cssMixins.rowCentered};
46
- margin-top: ${theme.spacing(10)};
47
- padding: ${theme.spacing(0, 2)};
48
- font-weight: 400;
49
- font-size: 16px;
50
- color: ${theme.palette.text.secondary};
51
- `,
52
- }
53
-
54
- const approveLender = async () => {
55
- if (publicKey) {
56
- try {
57
- setLoading(true)
58
- await IdentityServiceV2.approveSolanaLender(
59
- publicKey.toString(),
60
- poolInfo.chainId,
61
- poolInfo.juniorTrancheMint,
62
- isDev,
63
- )
64
- if (!isUniTranche) {
65
- await IdentityServiceV2.approveSolanaLender(
66
- publicKey.toString(),
67
- poolInfo.chainId,
68
- poolInfo.seniorTrancheMint,
69
- isDev,
70
- )
71
- }
72
- handleApproveSuccess()
73
- setLoading(false)
74
- dispatch(setStep(WIDGET_STEP.ChooseTranche))
75
- } catch (e: unknown) {
76
- const error = e as CustomError
77
- setLoading(false)
78
- dispatch(setError({ errorMessage: error.message }))
79
- }
80
- }
81
- }
82
-
83
- if (!loading) {
24
+ if (poolInfo.KYC?.Persona) {
84
25
  return (
85
- <WrapperModal
86
- title='Lender Approval'
87
- subTitle='This pool requires lender approval'
88
- >
89
- <Box css={styles.iconWrapper}>
90
- <img src={ApproveLenderImg} alt='approve-lender' />
91
- </Box>
92
- <Box css={styles.description} />
93
- <BottomButton variant='contained' onClick={approveLender}>
94
- GET APPROVED
95
- </BottomButton>
96
- </WrapperModal>
26
+ <PersonaEvaluation
27
+ poolInfo={{
28
+ KYC: poolInfo.KYC,
29
+ juniorTrancheVault: poolInfo.juniorTrancheMint,
30
+ seniorTrancheVault: poolInfo.seniorTrancheMint,
31
+ }}
32
+ handleClose={handleClose}
33
+ isUniTranche={isUniTranche}
34
+ pointsTestnetExperience={pointsTestnetExperience}
35
+ campaign={campaign}
36
+ chainType={CHAIN_TYPE.SOLANA}
37
+ changeTranche={changeTranche}
38
+ />
97
39
  )
98
40
  }
99
41
 
100
- return (
101
- <LoadingModal
102
- title='Approval Pending'
103
- description='Waiting for approval confirmation...'
104
- />
105
- )
42
+ return null
106
43
  }
@@ -4,7 +4,7 @@ import {
4
4
  useLenderAccounts,
5
5
  useTokenAccount,
6
6
  } from '@huma-finance/web-shared'
7
- import React, { useCallback, useEffect, useState } from 'react'
7
+ import React, { useEffect, useState } from 'react'
8
8
  import { useDispatch } from 'react-redux'
9
9
 
10
10
  import { useAppSelector } from '../../../hooks/useRedux'
@@ -24,12 +24,14 @@ import { Success } from './5-Success'
24
24
  * @typedef {Object} SolanaLendSupplyProps
25
25
  * @property {SolanaPoolInfo} poolInfo The metadata of the pool.
26
26
  * @property {SolanaPoolState} poolState The current state config of the pool.
27
+ * @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
27
28
  * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
28
29
  * @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
29
30
  */
30
31
  export interface SolanaLendSupplyProps {
31
32
  poolInfo: SolanaPoolInfo
32
33
  poolState: SolanaPoolState
34
+ pointsTestnetExperience: boolean
33
35
  handleClose: () => void
34
36
  handleSuccess?: () => void
35
37
  }
@@ -37,6 +39,7 @@ export interface SolanaLendSupplyProps {
37
39
  export function SolanaLendSupply({
38
40
  poolInfo,
39
41
  poolState,
42
+ pointsTestnetExperience,
40
43
  handleClose,
41
44
  handleSuccess,
42
45
  }: SolanaLendSupplyProps): React.ReactElement | null {
@@ -46,7 +49,6 @@ export function SolanaLendSupply({
46
49
  seniorLenderApproved,
47
50
  juniorLenderApproved,
48
51
  loading: isLoadingLenderAccounts,
49
- refresh: refreshLenderAccounts,
50
52
  } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
51
53
  const [tokenAccount, isLoadingTokenAccount] = useTokenAccount(poolInfo)
52
54
  const { step, errorMessage } = useAppSelector(selectWidgetState)
@@ -86,10 +88,6 @@ export function SolanaLendSupply({
86
88
  isLoadingTokenAccount,
87
89
  ])
88
90
 
89
- const handleApproveSuccess = useCallback(() => {
90
- refreshLenderAccounts()
91
- }, [refreshLenderAccounts])
92
-
93
91
  if (isLoadingLenderAccounts || isLoadingTokenAccount) {
94
92
  return (
95
93
  <WidgetWrapper
@@ -112,8 +110,10 @@ export function SolanaLendSupply({
112
110
  {step === WIDGET_STEP.Evaluation && (
113
111
  <Evaluation
114
112
  poolInfo={poolInfo}
115
- isUniTranche={isUniTranche}
116
- handleApproveSuccess={handleApproveSuccess}
113
+ isUniTranche={!!isUniTranche}
114
+ pointsTestnetExperience={pointsTestnetExperience}
115
+ handleClose={handleClose}
116
+ changeTranche={setSelectedTranche}
117
117
  />
118
118
  )}
119
119
  {step === WIDGET_STEP.ChooseTranche && (
@@ -1,9 +1,9 @@
1
- import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
1
+ import { CHAIN_TYPE, PoolInfoV2, TrancheType } from '@huma-finance/shared'
2
2
  import React from 'react'
3
3
 
4
4
  import { Campaign } from '.'
5
- import { PersonaEvaluation } from './components/PersonaEvaluation'
6
- import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
5
+ import { PersonaEvaluation } from '../components/PersonaEvaluation'
6
+ import { SecuritizeEvaluation } from '../components/SecuritizeEvaluation'
7
7
 
8
8
  type Props = {
9
9
  poolInfo: PoolInfoV2
@@ -35,6 +35,7 @@ export function Evaluation({
35
35
  isUniTranche={isUniTranche}
36
36
  pointsTestnetExperience={pointsTestnetExperience}
37
37
  campaign={campaign}
38
+ chainType={CHAIN_TYPE.EVM}
38
39
  changeTranche={changeTranche}
39
40
  />
40
41
  )