@huma-finance/widgets 0.0.30 → 0.0.32
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/dist/cjs/index.cjs +911 -179
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +913 -182
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/ChooseAmountModal.tsx +322 -322
- package/src/components/CreditLine/borrow/5-Success.tsx +9 -1
- package/src/components/CreditLine/borrow/6-Notifications.tsx +10 -0
- package/src/components/CreditLine/borrow/index.tsx +21 -2
- package/src/components/Factoring/UpcomingList.tsx +1 -1
- package/src/components/HumaSnackBar.tsx +60 -0
- package/src/components/Lend/supply/1-Evaluation/EvaluationEA.tsx +86 -0
- package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +287 -0
- package/src/components/Lend/supply/1-Evaluation/index.tsx +31 -0
- package/src/components/Lend/supply/2-ChooseAmount.tsx +0 -1
- package/src/components/Lend/supply/{7-Success.tsx → 5-Success.tsx} +13 -2
- package/src/components/Lend/supply/6-Notifications.tsx +10 -0
- package/src/components/Lend/supply/index.tsx +29 -6
- package/src/components/Notifi/NotifiSubscriptionModal.tsx +264 -0
- package/src/components/SuperfluidFactoring/index.tsx +85 -85
- package/src/components/TxDoneModal.tsx +3 -1
- package/src/cosmos/SDKTesting.fixture.tsx +616 -615
- package/src/hooks/useNotifi.ts +71 -0
- package/src/store/widgets.store.ts +1 -0
- package/src/components/Lend/supply/1-Evaluation.tsx +0 -171
- package/src/components/Lend/supply/4-ConfirmTransfer.tsx +0 -104
- /package/src/components/Lend/supply/{6-Transfer.tsx → 4-Transfer.tsx} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
doesChainSupportNotifi,
|
|
4
|
+
getBlockchainConfigFromChain,
|
|
5
|
+
} from '@huma-finance/shared'
|
|
6
|
+
import { newFrontendClient } from '@notifi-network/notifi-frontend-client'
|
|
7
|
+
import { envUtil } from '../utils/env'
|
|
8
|
+
|
|
9
|
+
export const useIsFirstTimeNotifiUser = (
|
|
10
|
+
account: string | undefined,
|
|
11
|
+
chainId: number | undefined,
|
|
12
|
+
) => {
|
|
13
|
+
const [isFirstTimeNotifiUser, setIsFirstTimeNotifiUser] = useState(false)
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const checkIsFirstTimeNotifiUser = async () => {
|
|
17
|
+
if (account != null && chainId != null) {
|
|
18
|
+
const client = newFrontendClient({
|
|
19
|
+
account: { publicKey: account },
|
|
20
|
+
tenantId: 'humadapp',
|
|
21
|
+
env: envUtil.checkIsDev() ? 'Development' : 'Production',
|
|
22
|
+
walletBlockchain: getBlockchainConfigFromChain(chainId),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const userState = await client.initialize()
|
|
26
|
+
|
|
27
|
+
// If the user is not authenticated or expired, they are a first time user
|
|
28
|
+
if (
|
|
29
|
+
userState.status !== 'authenticated' &&
|
|
30
|
+
userState.status !== 'expired'
|
|
31
|
+
) {
|
|
32
|
+
setIsFirstTimeNotifiUser(true)
|
|
33
|
+
} else if (userState.status === 'authenticated') {
|
|
34
|
+
// If a user is authenticated, check if they have a target group (AKA email)
|
|
35
|
+
// associated with their wallet. If they do not, show them the notifi onboarding flow.
|
|
36
|
+
const targetGroups = await client.getTargetGroups()
|
|
37
|
+
const emailTargets = targetGroups[0]?.emailTargets?.[0]
|
|
38
|
+
|
|
39
|
+
if (emailTargets == null || emailTargets.emailAddress == null) {
|
|
40
|
+
setIsFirstTimeNotifiUser(true)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
checkIsFirstTimeNotifiUser()
|
|
47
|
+
}, [account, chainId])
|
|
48
|
+
|
|
49
|
+
return { isFirstTimeNotifiUser }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const useDoesChainSupportNotifi = (
|
|
53
|
+
account: string | undefined,
|
|
54
|
+
chainId: number | undefined,
|
|
55
|
+
) => {
|
|
56
|
+
const [notifiChainSupported, setNotifiChainSupported] = useState(false)
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const checkNotifiChainSupported = async () => {
|
|
60
|
+
if (account != null && chainId != null) {
|
|
61
|
+
setNotifiChainSupported(
|
|
62
|
+
doesChainSupportNotifi(chainId, envUtil.checkIsDev(), account),
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
checkNotifiChainSupported()
|
|
68
|
+
}, [account, chainId])
|
|
69
|
+
|
|
70
|
+
return { notifiChainSupported }
|
|
71
|
+
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EAService,
|
|
3
|
-
IdentityService,
|
|
4
|
-
PoolInfoType,
|
|
5
|
-
VerificationStatusResult,
|
|
6
|
-
} from '@huma-finance/shared'
|
|
7
|
-
import { Box, css, useTheme } from '@mui/material'
|
|
8
|
-
import { useWeb3React } from '@web3-react/core'
|
|
9
|
-
import React, { useEffect, useState } from 'react'
|
|
10
|
-
|
|
11
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
12
|
-
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
13
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
14
|
-
import { CustomError } from '../../../utilTypes'
|
|
15
|
-
import { BottomButton } from '../../BottomButton'
|
|
16
|
-
import { ApproveLenderIcon } from '../../icons'
|
|
17
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
18
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
19
|
-
import { envUtil } from '../../../utils/env'
|
|
20
|
-
|
|
21
|
-
type Props = {
|
|
22
|
-
poolInfo: PoolInfoType
|
|
23
|
-
handleApproveSuccess: () => void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function Evaluation({
|
|
27
|
-
poolInfo,
|
|
28
|
-
handleApproveSuccess,
|
|
29
|
-
}: Props): React.ReactElement | null {
|
|
30
|
-
const theme = useTheme()
|
|
31
|
-
const dispatch = useAppDispatch()
|
|
32
|
-
const isDev = envUtil.checkIsDev()
|
|
33
|
-
const { account, chainId } = useWeb3React()
|
|
34
|
-
const [loading, setLoading] = useState(false)
|
|
35
|
-
const [description, setDescription] = useState<string>()
|
|
36
|
-
const [KYCVerifyStatus, setKYCVerifyStatus] =
|
|
37
|
-
useState<VerificationStatusResult>()
|
|
38
|
-
const lenderApprovalProvider = poolInfo.extra?.lenderApprovalProvider
|
|
39
|
-
const isKYC = lenderApprovalProvider?.type === 'KYC'
|
|
40
|
-
const [subTitle, setSubTitle] = useState<string>(
|
|
41
|
-
'This pool requires lender approval',
|
|
42
|
-
)
|
|
43
|
-
const [buttonText, setButtonText] = useState<string>('GET APPROVED')
|
|
44
|
-
|
|
45
|
-
const styles = {
|
|
46
|
-
iconWrapper: css`
|
|
47
|
-
${theme.cssMixins.rowCentered};
|
|
48
|
-
margin-top: 30px;
|
|
49
|
-
`,
|
|
50
|
-
description: css`
|
|
51
|
-
${theme.cssMixins.rowCentered};
|
|
52
|
-
margin-top: 50px;
|
|
53
|
-
font-family: 'Uni-Neue-Regular';
|
|
54
|
-
font-size: 16px;
|
|
55
|
-
color: #a8a1b2;
|
|
56
|
-
`,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (isKYC) {
|
|
61
|
-
setDescription(
|
|
62
|
-
`Approval process is run by ${lenderApprovalProvider.provider}`,
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
}, [lenderApprovalProvider?.provider, isKYC])
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
const fetchData = async () => {
|
|
69
|
-
if (account && chainId && isKYC) {
|
|
70
|
-
try {
|
|
71
|
-
setLoading(true)
|
|
72
|
-
const verificationStatus =
|
|
73
|
-
await IdentityService.getVerificationStatus(
|
|
74
|
-
account,
|
|
75
|
-
poolInfo.pool,
|
|
76
|
-
chainId,
|
|
77
|
-
isDev,
|
|
78
|
-
)
|
|
79
|
-
setKYCVerifyStatus(verificationStatus)
|
|
80
|
-
if (verificationStatus.isVerified) {
|
|
81
|
-
setSubTitle(
|
|
82
|
-
'Approval process in progress. Please contact Pool Owner.',
|
|
83
|
-
)
|
|
84
|
-
setButtonText('CONTACT POOL OWNER')
|
|
85
|
-
}
|
|
86
|
-
} finally {
|
|
87
|
-
setLoading(false)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
fetchData()
|
|
92
|
-
}, [account, chainId, isDev, isKYC, poolInfo.pool])
|
|
93
|
-
|
|
94
|
-
const approveLenderByEA = async () => {
|
|
95
|
-
try {
|
|
96
|
-
setLoading(true)
|
|
97
|
-
const payload = {
|
|
98
|
-
poolAddress: poolInfo.pool,
|
|
99
|
-
lenderWalletAddress: account!,
|
|
100
|
-
}
|
|
101
|
-
await EAService.approveLender(payload, chainId!)
|
|
102
|
-
handleApproveSuccess()
|
|
103
|
-
setLoading(false)
|
|
104
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
105
|
-
} catch (e: unknown) {
|
|
106
|
-
const error = e as CustomError
|
|
107
|
-
setLoading(false)
|
|
108
|
-
dispatch(setError({ errorMessage: error.message }))
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const approveLenderByKYC = () => {
|
|
113
|
-
switch (lenderApprovalProvider?.provider) {
|
|
114
|
-
case 'Securitize':
|
|
115
|
-
{
|
|
116
|
-
const issuerId = '53a66b32-583e-40e7-ba90-baf516d2cadd'
|
|
117
|
-
const baseUrl = `https://id${isDev ? '.sandbox' : ''}.securitize.io`
|
|
118
|
-
const originUrl = window.location.href.split('?')[0]
|
|
119
|
-
const redirectUrl = `${originUrl}?type=KYC&pool=${poolInfo.pool}`
|
|
120
|
-
const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
|
|
121
|
-
const { isNotOnboarded } = KYCVerifyStatus || {}
|
|
122
|
-
const providerUrl = isNotOnboarded ? providerAuthorizeUrl : baseUrl
|
|
123
|
-
window.location.href = providerUrl
|
|
124
|
-
}
|
|
125
|
-
break
|
|
126
|
-
default:
|
|
127
|
-
break
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const approveLender = () => {
|
|
132
|
-
switch (lenderApprovalProvider?.type) {
|
|
133
|
-
case 'EA':
|
|
134
|
-
approveLenderByEA()
|
|
135
|
-
break
|
|
136
|
-
case 'KYC':
|
|
137
|
-
approveLenderByKYC()
|
|
138
|
-
break
|
|
139
|
-
default:
|
|
140
|
-
approveLenderByEA()
|
|
141
|
-
break
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (!loading) {
|
|
146
|
-
return (
|
|
147
|
-
<WrapperModal title='Lender Approval' subTitle={subTitle}>
|
|
148
|
-
<Box css={styles.iconWrapper}>
|
|
149
|
-
<ApproveLenderIcon />
|
|
150
|
-
</Box>
|
|
151
|
-
<Box css={styles.description}>{description}</Box>
|
|
152
|
-
{true && (
|
|
153
|
-
<BottomButton
|
|
154
|
-
variant='contained'
|
|
155
|
-
onClick={approveLender}
|
|
156
|
-
disabled={KYCVerifyStatus?.isVerified}
|
|
157
|
-
>
|
|
158
|
-
{buttonText}
|
|
159
|
-
</BottomButton>
|
|
160
|
-
)}
|
|
161
|
-
</WrapperModal>
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<LoadingModal
|
|
167
|
-
title='Approval Pending'
|
|
168
|
-
description='Waiting for approval confirmation...'
|
|
169
|
-
/>
|
|
170
|
-
)
|
|
171
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
|
|
2
|
-
import { Box, Button, css, Typography, useTheme } from '@mui/material'
|
|
3
|
-
import { isEmpty } from '@huma-finance/shared'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
7
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
8
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
9
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
10
|
-
|
|
11
|
-
export function ConfirmTransfer(): React.ReactElement | null {
|
|
12
|
-
const theme = useTheme()
|
|
13
|
-
const dispatch = useAppDispatch()
|
|
14
|
-
const { borrowAmountNet, approval } = useAppSelector(selectWidgetState)
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
wrapper: css`
|
|
18
|
-
height: 518px;
|
|
19
|
-
position: relative;
|
|
20
|
-
${theme.cssMixins.colStretch};
|
|
21
|
-
`,
|
|
22
|
-
header: css`
|
|
23
|
-
font-family: 'Uni-Neue-Bold';
|
|
24
|
-
${theme.cssMixins.rowHCentered};
|
|
25
|
-
margin-top: -5px;
|
|
26
|
-
`,
|
|
27
|
-
description: css`
|
|
28
|
-
font-family: 'Uni-Neue-Regular';
|
|
29
|
-
font-weight: 500;
|
|
30
|
-
font-size: 16px;
|
|
31
|
-
color: #49505b;
|
|
32
|
-
margin-top: 30px;
|
|
33
|
-
text-align: center;
|
|
34
|
-
`,
|
|
35
|
-
transferWrapper: css`
|
|
36
|
-
margin-top: 75px;
|
|
37
|
-
`,
|
|
38
|
-
transfer: css`
|
|
39
|
-
font-family: 'Uni-Neue-Regular';
|
|
40
|
-
${theme.cssMixins.rowSpaceBetweened}
|
|
41
|
-
${theme.cssMixins.rowVCentered}
|
|
42
|
-
height: 72px;
|
|
43
|
-
background: #f9f8fa;
|
|
44
|
-
border-radius: 4px;
|
|
45
|
-
font-weight: 500;
|
|
46
|
-
font-size: 16px;
|
|
47
|
-
color: #49505b;
|
|
48
|
-
padding: 24px 32px;
|
|
49
|
-
margin-bottom: 9px;
|
|
50
|
-
position: relative;
|
|
51
|
-
box-sizing: border-box;
|
|
52
|
-
`,
|
|
53
|
-
arrow: css`
|
|
54
|
-
color: #d2d0d6;
|
|
55
|
-
position: absolute;
|
|
56
|
-
margin: auto;
|
|
57
|
-
top: 0;
|
|
58
|
-
left: 0;
|
|
59
|
-
bottom: 0;
|
|
60
|
-
right: 0;
|
|
61
|
-
`,
|
|
62
|
-
okButton: css`
|
|
63
|
-
width: 100%;
|
|
64
|
-
position: absolute;
|
|
65
|
-
bottom: 0;
|
|
66
|
-
`,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const handleAction = () => {
|
|
70
|
-
dispatch(setStep(WIDGET_STEP.ApproveNFT))
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (isEmpty(borrowAmountNet) || isEmpty(approval)) {
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Box css={styles.wrapper}>
|
|
79
|
-
<Typography variant='h6' css={styles.header}>
|
|
80
|
-
Confirm transaction details
|
|
81
|
-
</Typography>
|
|
82
|
-
<Box css={styles.description}>
|
|
83
|
-
Huma keeps your Invoice NFT as collateral until it's fully paid.
|
|
84
|
-
</Box>
|
|
85
|
-
<Box css={styles.transferWrapper}>
|
|
86
|
-
<Box css={styles.transfer}>
|
|
87
|
-
<Box>Invoice NFT</Box>
|
|
88
|
-
<ArrowForwardIosIcon css={styles.arrow} />
|
|
89
|
-
<Box>Huma</Box>
|
|
90
|
-
</Box>
|
|
91
|
-
<Box css={styles.transfer}>
|
|
92
|
-
<Box>
|
|
93
|
-
{borrowAmountNet!} {approval?.token.symbol}
|
|
94
|
-
</Box>
|
|
95
|
-
<ArrowForwardIosIcon css={styles.arrow} />
|
|
96
|
-
<Box>You</Box>
|
|
97
|
-
</Box>
|
|
98
|
-
</Box>
|
|
99
|
-
<Button variant='contained' css={styles.okButton} onClick={handleAction}>
|
|
100
|
-
APPROVE TRANSFER
|
|
101
|
-
</Button>
|
|
102
|
-
</Box>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
File without changes
|