@huma-finance/widgets 0.0.59-beta.494 → 0.0.59-beta.495
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/API.md +2 -0
- package/dist/cjs/index.cjs +967 -191
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +968 -193
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/components/ChooseAmountModal.tsx +2 -3
- package/src/components/ConfirmTransferModal.tsx +2 -2
- package/src/components/ErrorModal.tsx +1 -1
- package/src/components/InputAmountModal.tsx +2 -2
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +31 -329
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +58 -9
- package/src/components/Lend/supplyV2/6-Success.tsx +49 -6
- package/src/components/Lend/supplyV2/7-Notifications.tsx +22 -3
- package/src/components/Lend/supplyV2/8-PointsEarned.tsx +231 -0
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +442 -0
- package/src/components/Lend/supplyV2/components/SecuritizeEvaluation.tsx +345 -0
- package/src/components/Lend/supplyV2/index.tsx +67 -5
- package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +1 -1
- package/src/components/SignIn.tsx +7 -2
- package/src/components/TxDoneModal.tsx +21 -2
- package/src/components/humaModal/HumaModal.tsx +1 -0
- package/src/components/humaModal/HumaModalHeader.tsx +1 -0
- package/src/components/icons/congratulations.svg +54 -0
- package/src/components/icons/huma-points.svg +15 -0
- package/src/components/icons/index.tsx +15 -0
- package/src/components/icons/ribbon.svg +9 -0
- package/src/store/widgets.reducers.ts +0 -1
- package/src/store/widgets.store.ts +1 -0
- package/src/theme/palette.ts +1 -1
|
@@ -0,0 +1,345 @@
|
|
|
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-weight: 400;
|
|
317
|
+
font-size: 16px;
|
|
318
|
+
color: ${theme.palette.text.primary};
|
|
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
|
+
}
|
|
@@ -2,8 +2,10 @@ import {
|
|
|
2
2
|
POOL_NAME,
|
|
3
3
|
TrancheType,
|
|
4
4
|
openInNewTab,
|
|
5
|
+
useLPConfigV2,
|
|
5
6
|
useLenderApprovedV2,
|
|
6
7
|
usePoolInfoV2,
|
|
8
|
+
usePoolSettingsV2,
|
|
7
9
|
usePoolUnderlyingTokenInfoV2,
|
|
8
10
|
} from '@huma-finance/shared'
|
|
9
11
|
import { useWeb3React } from '@web3-react/core'
|
|
@@ -23,22 +25,34 @@ import { ApproveAllowance } from './4-ApproveAllowance'
|
|
|
23
25
|
import { Transfer } from './5-Transfer'
|
|
24
26
|
import { Success } from './6-Success'
|
|
25
27
|
import { Notifications } from './7-Notifications'
|
|
28
|
+
import { PointsEarned } from './8-PointsEarned'
|
|
29
|
+
|
|
30
|
+
export interface Campaign {
|
|
31
|
+
id: string
|
|
32
|
+
campaignGroupId: string
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
36
|
* Lend pool supply props
|
|
29
37
|
* @typedef {Object} LendSupplyPropsV2
|
|
30
38
|
* @property {POOL_NAME} poolName The name of the pool.
|
|
39
|
+
* @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
|
|
40
|
+
* @property {Campaign} campaign The campaign info.
|
|
31
41
|
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
32
42
|
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
33
43
|
*/
|
|
34
44
|
export interface LendSupplyPropsV2 {
|
|
35
45
|
poolName: keyof typeof POOL_NAME
|
|
46
|
+
pointsTestnetExperience: boolean
|
|
47
|
+
campaign?: Campaign
|
|
36
48
|
handleClose: () => void
|
|
37
49
|
handleSuccess?: (blockNumber?: number) => void
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
export function LendSupplyV2({
|
|
41
53
|
poolName: poolNameStr,
|
|
54
|
+
pointsTestnetExperience,
|
|
55
|
+
campaign,
|
|
42
56
|
handleClose,
|
|
43
57
|
handleSuccess,
|
|
44
58
|
}: LendSupplyPropsV2): React.ReactElement | null {
|
|
@@ -48,8 +62,11 @@ export function LendSupplyV2({
|
|
|
48
62
|
const poolInfo = usePoolInfoV2(poolName, chainId)
|
|
49
63
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
50
64
|
const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
|
|
65
|
+
const [transactionHash, setTransactionHash] = useState<string | undefined>()
|
|
51
66
|
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
52
|
-
|
|
67
|
+
const poolSettings = usePoolSettingsV2(poolName, provider)
|
|
68
|
+
const lpConfig = useLPConfigV2(poolName, provider)
|
|
69
|
+
const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
|
|
53
70
|
const [lenderApprovedSenior] = useLenderApprovedV2(
|
|
54
71
|
poolName,
|
|
55
72
|
'senior',
|
|
@@ -67,7 +84,21 @@ export function LendSupplyV2({
|
|
|
67
84
|
lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined
|
|
68
85
|
|
|
69
86
|
useEffect(() => {
|
|
70
|
-
if (!step && poolInfo && lenderApproveStatusFetched) {
|
|
87
|
+
if (!step && poolInfo && lenderApproveStatusFetched && lpConfig) {
|
|
88
|
+
if (
|
|
89
|
+
campaign &&
|
|
90
|
+
!isUniTranche &&
|
|
91
|
+
(!lenderApprovedJunior || !lenderApprovedSenior)
|
|
92
|
+
) {
|
|
93
|
+
if (poolInfo.KYC) {
|
|
94
|
+
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
95
|
+
} else if (poolInfo.supplyLink) {
|
|
96
|
+
openInNewTab(poolInfo.supplyLink)
|
|
97
|
+
handleClose()
|
|
98
|
+
}
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
71
102
|
if (lenderApprovedJunior && !lenderApprovedSenior) {
|
|
72
103
|
setSelectedTranche('junior')
|
|
73
104
|
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
@@ -98,14 +129,23 @@ export function LendSupplyV2({
|
|
|
98
129
|
}, [
|
|
99
130
|
dispatch,
|
|
100
131
|
handleClose,
|
|
132
|
+
isUniTranche,
|
|
101
133
|
lenderApproveStatusFetched,
|
|
102
134
|
lenderApprovedJunior,
|
|
103
135
|
lenderApprovedSenior,
|
|
136
|
+
lpConfig,
|
|
104
137
|
poolInfo,
|
|
138
|
+
campaign,
|
|
105
139
|
step,
|
|
106
140
|
])
|
|
107
141
|
|
|
108
|
-
if (
|
|
142
|
+
if (
|
|
143
|
+
!poolInfo ||
|
|
144
|
+
!poolUnderlyingToken ||
|
|
145
|
+
!lenderApproveStatusFetched ||
|
|
146
|
+
!lpConfig ||
|
|
147
|
+
!poolSettings
|
|
148
|
+
) {
|
|
109
149
|
return (
|
|
110
150
|
<WidgetWrapper
|
|
111
151
|
isOpen
|
|
@@ -132,13 +172,24 @@ export function LendSupplyV2({
|
|
|
132
172
|
/>
|
|
133
173
|
)}
|
|
134
174
|
{step === WIDGET_STEP.Evaluation && (
|
|
135
|
-
<Evaluation
|
|
175
|
+
<Evaluation
|
|
176
|
+
poolInfo={poolInfo}
|
|
177
|
+
handleClose={handleClose}
|
|
178
|
+
isUniTranche={isUniTranche}
|
|
179
|
+
changeTranche={setSelectedTranche}
|
|
180
|
+
pointsTestnetExperience={pointsTestnetExperience}
|
|
181
|
+
campaign={campaign}
|
|
182
|
+
minDepositAmount={poolSettings.minDepositAmount}
|
|
183
|
+
/>
|
|
136
184
|
)}
|
|
137
185
|
{step === WIDGET_STEP.ChooseAmount && (
|
|
138
186
|
<ChooseAmount
|
|
139
187
|
poolInfo={poolInfo}
|
|
140
188
|
poolUnderlyingToken={poolUnderlyingToken}
|
|
141
189
|
selectedTranche={selectedTranche}
|
|
190
|
+
isUniTranche={isUniTranche}
|
|
191
|
+
pointsTestnetExperience={pointsTestnetExperience}
|
|
192
|
+
campaign={campaign}
|
|
142
193
|
/>
|
|
143
194
|
)}
|
|
144
195
|
{step === WIDGET_STEP.ApproveAllowance && (
|
|
@@ -158,11 +209,22 @@ export function LendSupplyV2({
|
|
|
158
209
|
<Success
|
|
159
210
|
poolInfo={poolInfo}
|
|
160
211
|
poolUnderlyingToken={poolUnderlyingToken}
|
|
212
|
+
lpConfig={lpConfig}
|
|
213
|
+
campaign={campaign}
|
|
214
|
+
updateTransactionHash={setTransactionHash}
|
|
161
215
|
handleAction={handleClose}
|
|
162
216
|
/>
|
|
163
217
|
)}
|
|
164
218
|
{step === WIDGET_STEP.Notifications && (
|
|
165
|
-
<Notifications handleAction={handleClose} />
|
|
219
|
+
<Notifications campaign={campaign} handleAction={handleClose} />
|
|
220
|
+
)}
|
|
221
|
+
{step === WIDGET_STEP.PointsEarned && transactionHash && (
|
|
222
|
+
<PointsEarned
|
|
223
|
+
transactionHash={transactionHash}
|
|
224
|
+
lpConfig={lpConfig}
|
|
225
|
+
pointsTestnetExperience={pointsTestnetExperience}
|
|
226
|
+
handleAction={handleClose}
|
|
227
|
+
/>
|
|
166
228
|
)}
|
|
167
229
|
{step === WIDGET_STEP.Error && (
|
|
168
230
|
<ErrorModal
|
|
@@ -2,7 +2,11 @@ import { Box, css, Typography, useTheme } from '@mui/material'
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { ApproveLenderImg } from './images'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type Props = {
|
|
6
|
+
description?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function SignIn({ description }: Props): React.ReactElement {
|
|
6
10
|
const theme = useTheme()
|
|
7
11
|
const styles = {
|
|
8
12
|
wrapper: css`
|
|
@@ -41,7 +45,8 @@ export function SignIn(): React.ReactElement {
|
|
|
41
45
|
<img src={ApproveLenderImg} alt='approve-lender' />
|
|
42
46
|
</Box>
|
|
43
47
|
<Box css={styles.content}>
|
|
44
|
-
|
|
48
|
+
{description ??
|
|
49
|
+
'Please sign in to verify your ownership of the wallet.'}
|
|
45
50
|
</Box>
|
|
46
51
|
</Box>
|
|
47
52
|
)
|
|
@@ -9,12 +9,14 @@ import { CheckIcon } from './icons'
|
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
11
|
content: string[]
|
|
12
|
-
|
|
12
|
+
subContent?: string[]
|
|
13
13
|
buttonText?: string
|
|
14
|
+
handleAction: () => void
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export function TxDoneModal({
|
|
17
18
|
content,
|
|
19
|
+
subContent,
|
|
18
20
|
handleAction,
|
|
19
21
|
buttonText,
|
|
20
22
|
}: Props): React.ReactElement {
|
|
@@ -33,12 +35,20 @@ export function TxDoneModal({
|
|
|
33
35
|
`,
|
|
34
36
|
content: css`
|
|
35
37
|
${theme.cssMixins.colVCentered};
|
|
36
|
-
font-weight: 400;
|
|
38
|
+
font-weight: ${subContent ? 700 : 400};
|
|
37
39
|
font-size: 18px;
|
|
38
40
|
color: ${theme.palette.text.secondary};
|
|
39
41
|
margin-top: ${theme.spacing(8)};
|
|
40
42
|
text-align: center;
|
|
41
43
|
`,
|
|
44
|
+
subContent: css`
|
|
45
|
+
${theme.cssMixins.colVCentered};
|
|
46
|
+
font-weight: 400;
|
|
47
|
+
font-size: 18px;
|
|
48
|
+
color: ${theme.palette.text.primary};
|
|
49
|
+
margin-top: ${theme.spacing(2)};
|
|
50
|
+
text-align: center;
|
|
51
|
+
`,
|
|
42
52
|
check: css`
|
|
43
53
|
width: 100%;
|
|
44
54
|
${theme.cssMixins.rowHCentered};
|
|
@@ -72,6 +82,15 @@ export function TxDoneModal({
|
|
|
72
82
|
</Box>
|
|
73
83
|
))}
|
|
74
84
|
</Box>
|
|
85
|
+
{subContent && (
|
|
86
|
+
<Box css={styles.subContent}>
|
|
87
|
+
{subContent.map((item) => (
|
|
88
|
+
<Box sx={{ marginTop: theme.spacing(1) }} key={item}>
|
|
89
|
+
{item}
|
|
90
|
+
</Box>
|
|
91
|
+
))}
|
|
92
|
+
</Box>
|
|
93
|
+
)}
|
|
75
94
|
<Button
|
|
76
95
|
className='transaction-done-modal-close-btn'
|
|
77
96
|
variant='contained'
|