@huma-finance/widgets 0.0.80 → 0.0.81-beta.1108

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 (68) hide show
  1. package/API.md +0 -11
  2. package/dist/index.js +60790 -64401
  3. package/dist/src/components/Lend/solanaSupply/6-Transfer.d.ts +2 -3
  4. package/dist/src/components/Lend/solanaSupply/7-Success.d.ts +1 -4
  5. package/dist/src/components/Lend/solanaSupply/index.d.ts +1 -7
  6. package/dist/src/components/Lend/stellarSupply/index.d.ts +0 -4
  7. package/dist/src/components/Lend/supply/1-Evaluation.d.ts +8 -0
  8. package/dist/src/components/Lend/supplyV2/6-Transfer.d.ts +2 -5
  9. package/dist/src/components/Lend/supplyV2/7-Success.d.ts +1 -3
  10. package/dist/src/components/Lend/supplyV2/8-Notifications.d.ts +1 -3
  11. package/dist/src/components/Lend/supplyV2/index.d.ts +1 -9
  12. package/dist/src/hooks/useEA.d.ts +0 -2
  13. package/dist/src/store/widgets.reducers.d.ts +1 -2
  14. package/dist/src/store/widgets.store.d.ts +0 -4
  15. package/package.json +6 -6
  16. package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -11
  17. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -10
  18. package/src/components/Lend/solanaSupply/6-Transfer.tsx +4 -34
  19. package/src/components/Lend/solanaSupply/7-Success.tsx +2 -16
  20. package/src/components/Lend/solanaSupply/index.tsx +1 -66
  21. package/src/components/Lend/stellarSupply/index.tsx +0 -5
  22. package/src/components/Lend/supply/{1-Evaluation/EvaluationEA.tsx → 1-Evaluation.tsx} +9 -9
  23. package/src/components/Lend/supply/index.tsx +0 -1
  24. package/src/components/Lend/supplyV2/6-Transfer.tsx +7 -35
  25. package/src/components/Lend/supplyV2/7-Success.tsx +2 -18
  26. package/src/components/Lend/supplyV2/8-Notifications.tsx +3 -26
  27. package/src/components/Lend/supplyV2/index.tsx +15 -72
  28. package/src/components/SolanaTxSendModal.tsx +1 -1
  29. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +1 -10
  30. package/src/hooks/useEA.ts +4 -22
  31. package/src/store/widgets.reducers.ts +0 -7
  32. package/src/store/widgets.store.ts +0 -4
  33. package/vite.config.ts +1 -1
  34. package/dist/src/components/Lend/components/ApproveLenderBase.d.ts +0 -14
  35. package/dist/src/components/Lend/components/PersonaEvaluation.d.ts +0 -17
  36. package/dist/src/components/Lend/components/SecuritizeEvaluation.d.ts +0 -8
  37. package/dist/src/components/Lend/solanaSupply/1-Evaluation.d.ts +0 -12
  38. package/dist/src/components/Lend/solanaSupply/2-ApproveLender.d.ts +0 -10
  39. package/dist/src/components/Lend/solanaSupply/8-PointsEarned.d.ts +0 -11
  40. package/dist/src/components/Lend/supply/1-Evaluation/EvaluationEA.d.ts +0 -8
  41. package/dist/src/components/Lend/supply/1-Evaluation/EvaluationKYC.d.ts +0 -8
  42. package/dist/src/components/Lend/supply/1-Evaluation/index.d.ts +0 -9
  43. package/dist/src/components/Lend/supplyV2/2-Evaluation.d.ts +0 -12
  44. package/dist/src/components/Lend/supplyV2/3-ApproveLender.d.ts +0 -10
  45. package/dist/src/components/PointsEarned.d.ts +0 -10
  46. package/dist/src/components/SignIn.d.ts +0 -6
  47. package/dist/src/cosmos/CreditLineBorrow.fixture.d.ts +0 -2
  48. package/dist/src/cosmos/CreditLinePayment.fixture.d.ts +0 -2
  49. package/dist/src/cosmos/InvoiceFactoringBorrow.fixture.d.ts +0 -2
  50. package/dist/src/cosmos/InvoiceFactoringPayment.fixture.d.ts +0 -2
  51. package/dist/src/cosmos/LendSupply.fixture.d.ts +0 -2
  52. package/dist/src/cosmos/LendWithdraw.fixture.d.ts +0 -2
  53. package/dist/src/cosmos/SDKTesting.fixture.d.ts +0 -2
  54. package/dist/src/cosmos/SuperfluidFactoringBorrow.fixture.d.ts +0 -2
  55. package/dist/src/cosmos/WalletWrapper.d.ts +0 -3
  56. package/dist/src/cosmos/utils/index.d.ts +0 -18
  57. package/src/components/Lend/components/ApproveLenderBase.tsx +0 -128
  58. package/src/components/Lend/components/PersonaEvaluation.tsx +0 -371
  59. package/src/components/Lend/components/SecuritizeEvaluation.tsx +0 -343
  60. package/src/components/Lend/solanaSupply/1-Evaluation.tsx +0 -43
  61. package/src/components/Lend/solanaSupply/2-ApproveLender.tsx +0 -45
  62. package/src/components/Lend/solanaSupply/8-PointsEarned.tsx +0 -189
  63. package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +0 -369
  64. package/src/components/Lend/supply/1-Evaluation/index.tsx +0 -31
  65. package/src/components/Lend/supplyV2/2-Evaluation.tsx +0 -47
  66. package/src/components/Lend/supplyV2/3-ApproveLender.tsx +0 -35
  67. package/src/components/PointsEarned.tsx +0 -135
  68. package/src/components/SignIn.tsx +0 -53
@@ -1,343 +0,0 @@
1
- import {
2
- CHAINS,
3
- configUtil,
4
- DocSignatureStatus,
5
- IdentityService,
6
- KYC_PROVIDER,
7
- KYCCopy,
8
- PoolInfoV2,
9
- timeUtil,
10
- VerificationStatusResult,
11
- } from '@huma-finance/shared'
12
- import {
13
- useAuthErrorHandling,
14
- useParamsSearch,
15
- checkIsDev,
16
- } from '@huma-finance/web-shared'
17
- import { Box, css, useTheme } from '@mui/material'
18
- import { useWeb3React } from '@web3-react/core'
19
- import React, { useCallback, useEffect, useMemo, useState } from 'react'
20
- import { useAppDispatch } from '../../../hooks/useRedux'
21
- import { setError } from '../../../store/widgets.reducers'
22
- import { BottomButton } from '../../BottomButton'
23
- import { HumaSnackBar } from '../../HumaSnackBar'
24
- import { LoadingModal } from '../../LoadingModal'
25
- import { WrapperModal } from '../../WrapperModal'
26
- import { ApproveLenderImg } from '../../images'
27
-
28
- const LoadingCopiesByType: {
29
- [key: string]: {
30
- description: string
31
- }
32
- } = {
33
- verificationStatus: {
34
- description: `Checking your verification status...`,
35
- },
36
- sendDocSignatureLink: {
37
- description: `Sending signature link...`,
38
- },
39
- }
40
-
41
- type Props = {
42
- poolInfo: PoolInfoV2
43
- handleClose: () => void
44
- }
45
-
46
- export function SecuritizeEvaluation({
47
- poolInfo,
48
- handleClose,
49
- }: Props): React.ReactElement | null {
50
- const theme = useTheme()
51
- const isDev = checkIsDev()
52
- const dispatch = useAppDispatch()
53
- const { account, chainId } = useWeb3React()
54
- const { kycProvider, code, kycPool } = useParamsSearch()
55
- const { isWalletOwnershipVerified, setAuthError, authError } =
56
- useAuthErrorHandling(isDev)
57
- const [loadingType, setLoadingType] = useState<
58
- 'verificationStatus' | 'sendDocSignatureLink'
59
- >()
60
- const KYCCopies = poolInfo.KYC!.Securitize!
61
- const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
62
- const [KYCVerifyStatus, setKYCVerifyStatus] =
63
- useState<VerificationStatusResult>()
64
- const [docSignatureStatus, setDocSignatureStatus] =
65
- useState<DocSignatureStatus['status']>()
66
- const docSignatureCompleted = docSignatureStatus === 'completed'
67
- const [openSnackBar, setOpenSnackBar] = useState<boolean>(false)
68
-
69
- const { envelopeKey, envelopeLastQueryTimeKey, envelopeDocuSignStatusKey } =
70
- useMemo(() => {
71
- const envelopeKey = `${poolInfo.pool.toLowerCase()}-${account?.toLowerCase()}`
72
- const envelopeLastQueryTimeKey = `${envelopeKey}-last-query-time`
73
- const envelopeDocuSignStatusKey = `${envelopeKey}-docuSign-status`
74
- return {
75
- envelopeKey,
76
- envelopeLastQueryTimeKey,
77
- envelopeDocuSignStatusKey,
78
- }
79
- }, [account, poolInfo.pool])
80
-
81
- // DocuSign GET requests to any specific URL can be called not more often than once every 15 minutes.
82
- // https://developers.docusign.com/platform/api-guidelines/#:~:text=Polling,not%20once%20every%2010%20minutes
83
- const checkGetDocSignatureStatusIsAvailable = useCallback(() => {
84
- const lastQueryTime = localStorage.getItem(envelopeLastQueryTimeKey)
85
- if (!lastQueryTime) {
86
- return true
87
- }
88
- const lastQueryTimeNumber = Number(lastQueryTime)
89
- const now = timeUtil.getUnixTimestamp()
90
- const diff = now - lastQueryTimeNumber
91
- const fifteenMinutes = 15 * 60
92
- return diff > fifteenMinutes
93
- }, [envelopeLastQueryTimeKey])
94
-
95
- useEffect(() => {
96
- setKYCCopy(KYCCopies.verifyIdentity)
97
- const docuSignStatus = localStorage.getItem(envelopeDocuSignStatusKey)
98
- setDocSignatureStatus(docuSignStatus as DocSignatureStatus['status'])
99
- if (docuSignStatus === 'completed') {
100
- setKYCCopy(KYCCopies.docUnderReview!)
101
- return
102
- }
103
-
104
- const fetchData = async () => {
105
- try {
106
- if (kycProvider && kycPool && account && chainId) {
107
- setLoadingType('verificationStatus')
108
- await IdentityService.onboard(
109
- account,
110
- code as string,
111
- kycPool as string,
112
- chainId,
113
- isDev,
114
- )
115
- }
116
- } catch (e) {
117
- try {
118
- setAuthError(e)
119
- setKYCCopy(KYCCopies.signInRequired)
120
- } catch (e) {
121
- // The repeated call will throw an error of 401, so we can ignore it.
122
- console.log(e)
123
- }
124
- }
125
-
126
- try {
127
- if (account && chainId) {
128
- setLoadingType('verificationStatus')
129
- const verificationStatus =
130
- await IdentityService.getVerificationStatus(
131
- account,
132
- poolInfo.pool,
133
- chainId,
134
- isDev,
135
- )
136
- setKYCVerifyStatus(verificationStatus)
137
- if (verificationStatus.isVerified) {
138
- const envelopeId = localStorage.getItem(envelopeKey)
139
- if (!envelopeId) {
140
- setKYCCopy(KYCCopies.emailSignatureLink!)
141
- } else if (!checkGetDocSignatureStatusIsAvailable()) {
142
- setKYCCopy(KYCCopies.resendSignatureLink!)
143
- } else {
144
- const { status } = await IdentityService.getDocSignatureStatus(
145
- envelopeId,
146
- chainId,
147
- isDev,
148
- )
149
- localStorage.setItem(
150
- envelopeLastQueryTimeKey,
151
- String(timeUtil.getUnixTimestamp()),
152
- )
153
- localStorage.setItem(envelopeDocuSignStatusKey, status)
154
- setDocSignatureStatus(status)
155
- if (status === 'completed') {
156
- setKYCCopy(KYCCopies.docUnderReview!)
157
- // For voided and declined status, we need to send a new link
158
- } else if (['voided', 'declined'].includes(status)) {
159
- localStorage.removeItem(envelopeKey)
160
- localStorage.removeItem(envelopeLastQueryTimeKey)
161
- setKYCCopy(KYCCopies.emailSignatureLink!)
162
- } else {
163
- setKYCCopy(KYCCopies.resendSignatureLink!)
164
- }
165
- }
166
- } else {
167
- setKYCCopy(KYCCopies.verifyIdentity)
168
- }
169
- }
170
- } catch (e: unknown) {
171
- try {
172
- setAuthError(e)
173
- setKYCCopy(KYCCopies.signInRequired)
174
- } catch (e) {
175
- console.error(e)
176
- dispatch(
177
- setError({
178
- errorMessage: 'Something went wrong, please try again later.',
179
- }),
180
- )
181
- }
182
- } finally {
183
- setLoadingType(undefined)
184
- }
185
- }
186
- fetchData()
187
- }, [
188
- KYCCopies.docUnderReview,
189
- KYCCopies.emailSignatureLink,
190
- KYCCopies.resendSignatureLink,
191
- KYCCopies.signInRequired,
192
- KYCCopies.verifyIdentity,
193
- account,
194
- chainId,
195
- checkGetDocSignatureStatusIsAvailable,
196
- code,
197
- dispatch,
198
- envelopeDocuSignStatusKey,
199
- envelopeKey,
200
- envelopeLastQueryTimeKey,
201
- isDev,
202
- kycPool,
203
- kycProvider,
204
- poolInfo.pool,
205
- setAuthError,
206
- isWalletOwnershipVerified,
207
- ])
208
-
209
- useEffect(() => {
210
- if (
211
- authError &&
212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
- [4001, 'ACTION_REJECTED'].includes((authError as any).code)
214
- ) {
215
- dispatch(
216
- setError({
217
- errorMessage: 'User has rejected the transaction.',
218
- }),
219
- )
220
- }
221
- }, [authError, dispatch])
222
-
223
- const approveLender = async () => {
224
- if (docSignatureCompleted) {
225
- handleClose()
226
- return
227
- }
228
-
229
- const { isNotOnboarded, isVerified } = KYCVerifyStatus || {}
230
-
231
- if (!isVerified) {
232
- const issuerId = CHAINS[chainId!].isTestnet
233
- ? '53a66b32-583e-40e7-ba90-baf516d2cadd'
234
- : '5557baf5-d3c2-4c80-b522-c05a11c6e586'
235
- const baseUrl = configUtil.getKYCProviderBaseUrl(
236
- KYC_PROVIDER.Securitize,
237
- chainId!,
238
- )
239
- const originUrl = window.location.href.split('?')[0]
240
- const redirectUrl = `${originUrl}?poolName=${poolInfo.poolName}&kycProvider=${KYC_PROVIDER.Securitize}&kycPool=${poolInfo.pool}`
241
- const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
242
- window.location.href = isNotOnboarded ? providerAuthorizeUrl : baseUrl
243
- } else {
244
- const envelopeId = localStorage.getItem(envelopeKey)
245
- try {
246
- setLoadingType('sendDocSignatureLink')
247
- if (!envelopeId) {
248
- const { envelopeId } = await IdentityService.requestDocSignature(
249
- account!,
250
- chainId!,
251
- isDev,
252
- )
253
- localStorage.setItem(envelopeKey, envelopeId)
254
- localStorage.setItem(
255
- envelopeLastQueryTimeKey,
256
- String(timeUtil.getUnixTimestamp()),
257
- )
258
- setOpenSnackBar(true)
259
- setKYCCopy(KYCCopies.resendSignatureLink)
260
- } else {
261
- await IdentityService.resendDocSignatureLink(
262
- envelopeId,
263
- chainId!,
264
- isDev,
265
- )
266
- setOpenSnackBar(true)
267
- }
268
- } catch (e: unknown) {
269
- try {
270
- const { envelopeId } = await IdentityService.requestDocSignature(
271
- account!,
272
- chainId!,
273
- isDev,
274
- )
275
- localStorage.setItem(envelopeKey, envelopeId)
276
- localStorage.setItem(
277
- envelopeLastQueryTimeKey,
278
- String(timeUtil.getUnixTimestamp()),
279
- )
280
- setOpenSnackBar(true)
281
- setKYCCopy(KYCCopies.resendSignatureLink)
282
- } catch (e) {
283
- setAuthError(e)
284
- setKYCCopy(KYCCopies.signInRequired)
285
- }
286
- } finally {
287
- setLoadingType(undefined)
288
- }
289
- }
290
- }
291
-
292
- const getEmailLinkSentSnackbar = () => (
293
- <HumaSnackBar
294
- open={openSnackBar}
295
- title='Signature Link Sent'
296
- message='The secure signature session link has been sent to you via email.'
297
- severity='success'
298
- onClose={() => setOpenSnackBar(false)}
299
- />
300
- )
301
-
302
- const styles = {
303
- iconWrapper: css`
304
- ${theme.cssMixins.rowCentered};
305
- margin-top: ${theme.spacing(8)};
306
- & > img {
307
- width: 144px;
308
- }
309
- `,
310
- description: css`
311
- ${theme.cssMixins.rowCentered};
312
- margin-top: ${theme.spacing(10)};
313
- padding: ${theme.spacing(0, 2)};
314
- font-weight: 400;
315
- font-size: 16px;
316
- color: ${theme.palette.text.primary};
317
- `,
318
- }
319
-
320
- if (!loadingType) {
321
- return (
322
- <WrapperModal title={kycCopy.title}>
323
- <Box css={styles.iconWrapper}>
324
- <img src={ApproveLenderImg} alt='approve-lender' />
325
- </Box>
326
- <Box css={styles.description}>{kycCopy.description}</Box>
327
- {Boolean(kycCopy.buttonText) && (
328
- <BottomButton variant='contained' onClick={approveLender}>
329
- {kycCopy.buttonText}
330
- </BottomButton>
331
- )}
332
- {getEmailLinkSentSnackbar()}
333
- </WrapperModal>
334
- )
335
- }
336
-
337
- return (
338
- <LoadingModal
339
- title='Lender Approval'
340
- description={LoadingCopiesByType[loadingType].description}
341
- />
342
- )
343
- }
@@ -1,43 +0,0 @@
1
- import { CHAIN_TYPE, NETWORK_TYPE, SolanaPoolInfo } from '@huma-finance/shared'
2
- import React from 'react'
3
-
4
- import { PersonaEvaluation } from '../components/PersonaEvaluation'
5
- import { Campaign } from '../supplyV2'
6
- import useLogOnFirstMount from '../../../hooks/useLogOnFirstMount'
7
-
8
- type Props = {
9
- poolInfo: SolanaPoolInfo
10
- networkType: NETWORK_TYPE
11
- campaign?: Campaign
12
- documentHash: string
13
- handleClose: () => void
14
- }
15
-
16
- export function Evaluation({
17
- poolInfo,
18
- networkType,
19
- campaign,
20
- documentHash,
21
- handleClose,
22
- }: Props): React.ReactElement | null {
23
- useLogOnFirstMount('Evaluation')
24
-
25
- if (poolInfo.KYC?.Persona) {
26
- return (
27
- <PersonaEvaluation
28
- poolInfo={{
29
- KYC: poolInfo.KYC,
30
- juniorTrancheVault: poolInfo.juniorTrancheMint,
31
- seniorTrancheVault: poolInfo.seniorTrancheMint,
32
- }}
33
- handleClose={handleClose}
34
- networkType={networkType}
35
- chainType={CHAIN_TYPE.SOLANA}
36
- campaign={campaign}
37
- documentHash={documentHash}
38
- />
39
- )
40
- }
41
-
42
- return null
43
- }
@@ -1,45 +0,0 @@
1
- import {
2
- CHAIN_TYPE,
3
- getSolanaNetworkType,
4
- SOLANA_CHAIN_INFO,
5
- SolanaPoolInfo,
6
- TrancheType,
7
- } from '@huma-finance/shared'
8
- import React from 'react'
9
-
10
- import { ApproveLenderBase } from '../components/ApproveLenderBase'
11
- import useLogOnFirstMount from '../../../hooks/useLogOnFirstMount'
12
-
13
- type Props = {
14
- poolInfo: SolanaPoolInfo
15
- isUniTranche: boolean
16
- documentHash: string
17
- changeTranche: (tranche: TrancheType) => void
18
- }
19
-
20
- export function ApproveLender({
21
- poolInfo,
22
- isUniTranche,
23
- documentHash,
24
- changeTranche,
25
- }: Props): React.ReactElement | null {
26
- useLogOnFirstMount('ApproveLender')
27
-
28
- const solanaChainInfo = SOLANA_CHAIN_INFO[poolInfo.chainId]
29
-
30
- return (
31
- <ApproveLenderBase
32
- juniorTrancheVault={poolInfo.juniorTrancheMint}
33
- seniorTrancheVault={poolInfo.seniorTrancheMint}
34
- isUniTranche={isUniTranche}
35
- chainType={CHAIN_TYPE.SOLANA}
36
- networkType={getSolanaNetworkType(poolInfo.chainId)}
37
- chainSpecificData={{
38
- huma_program_id: solanaChainInfo.poolProgram,
39
- pool_id: poolInfo.poolId,
40
- }}
41
- documentHash={documentHash}
42
- changeTranche={changeTranche}
43
- />
44
- )
45
- }
@@ -1,189 +0,0 @@
1
- import {
2
- CampaignService,
3
- CHAIN_TYPE,
4
- CloseModalOptions,
5
- FEATHERS_TO_HUMA_RATIO,
6
- formatNumber,
7
- isEmpty,
8
- NETWORK_TYPE,
9
- } from '@huma-finance/shared'
10
- import {
11
- checkIsDev,
12
- SolanaPoolState,
13
- txAtom,
14
- useChainInfo,
15
- } from '@huma-finance/web-shared'
16
- import { Box, css, useTheme } from '@mui/material'
17
- import { useResetAtom } from 'jotai/utils'
18
- import React, { useCallback, useEffect, useState } from 'react'
19
- import { useDispatch } from 'react-redux'
20
-
21
- import useLogOnFirstMount from '../../../hooks/useLogOnFirstMount'
22
- import { resetState } from '../../../store/widgets.reducers'
23
- import { BottomButton } from '../../BottomButton'
24
- import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from '../../icons'
25
- import { LoadingModal } from '../../LoadingModal'
26
- import { SignIn } from '../../SignIn'
27
-
28
- enum STATE {
29
- Loading = 'Loading',
30
- SignIn = 'SignIn',
31
- Congrats = 'Congrats',
32
- }
33
-
34
- type Props = {
35
- transactionHash: string
36
- poolState: SolanaPoolState
37
- networkType: NETWORK_TYPE
38
- handleAction: (options?: CloseModalOptions) => void
39
- }
40
-
41
- export function PointsEarned({
42
- transactionHash,
43
- poolState,
44
- networkType,
45
- handleAction,
46
- }: Props): React.ReactElement {
47
- useLogOnFirstMount('PointsEarned')
48
- const theme = useTheme()
49
- const isDev = checkIsDev()
50
- const dispatch = useDispatch()
51
- const reset = useResetAtom(txAtom)
52
- const { account, chainId } = useChainInfo(isDev, CHAIN_TYPE.SOLANA)
53
- const [pointsAccumulated, setPointsAccumulated] = useState<
54
- number | undefined
55
- >()
56
- const hasPointsAccumulated =
57
- !isEmpty(pointsAccumulated) && pointsAccumulated! > 0
58
- const lockupMonths = Math.round(
59
- (poolState.withdrawalLockupPeriodDays ?? 0) / 30,
60
- )
61
- const monthText =
62
- lockupMonths > 1 ? `${lockupMonths} months` : `${lockupMonths} month`
63
- const [state, setState] = useState<STATE>(STATE.Loading)
64
-
65
- const rewardsAccumulated = pointsAccumulated
66
- ? pointsAccumulated / FEATHERS_TO_HUMA_RATIO
67
- : undefined
68
-
69
- useEffect(() => {
70
- const updateWalletPoints = async () => {
71
- try {
72
- const result = await CampaignService.updateHumaAccountPoints(
73
- account!,
74
- transactionHash,
75
- chainId!,
76
- networkType,
77
- isDev,
78
- )
79
- setPointsAccumulated(result.pointsAccumulated)
80
- setState(STATE.Congrats)
81
- } catch (error) {
82
- console.error('Failed to update wallet rewards', error)
83
- }
84
- }
85
- updateWalletPoints()
86
- }, [account, chainId, isDev, networkType, transactionHash])
87
-
88
- const handleCloseModal = useCallback(() => {
89
- reset()
90
- dispatch(resetState())
91
- handleAction({ isSuccess: true })
92
- }, [dispatch, handleAction, reset])
93
-
94
- const styles = {
95
- wrapper: css`
96
- height: 518px;
97
- position: relative;
98
- `,
99
- congrats: css`
100
- margin: ${theme.spacing(-4, -4.5, 0, -4.5)};
101
- `,
102
- ribbon: css`
103
- position: relative;
104
- ${theme.cssMixins.rowHCentered};
105
- font-weight: 700;
106
- margin-top: ${theme.spacing(-8)};
107
- color: ${theme.palette.text.primary};
108
- font-size: 20px;
109
- line-height: 160%;
110
- letter-spacing: 0.15px;
111
- `,
112
- ribbonContent: css`
113
- ${theme.cssMixins.rowVCentered};
114
- position: absolute;
115
- top: ${theme.spacing(1)};
116
-
117
- svg {
118
- margin-right: ${theme.spacing(1)};
119
- }
120
- `,
121
- entirePoints: css`
122
- color: ${theme.palette.text.tertiary};
123
- text-align: center;
124
- font-weight: 700;
125
- font-size: 20px;
126
- line-height: 160%;
127
- letter-spacing: 0.15px;
128
- margin-top: ${theme.spacing(7)};
129
- `,
130
- entirePointsDetails: css`
131
- color: ${theme.palette.text.tertiary};
132
- text-align: center;
133
- font-weight: 400;
134
- font-size: 16px;
135
- line-height: 150%;
136
- letter-spacing: 0.15px;
137
- margin-top: ${theme.spacing(4)};
138
- `,
139
- everyday: css`
140
- font-weight: 700;
141
- `,
142
- }
143
-
144
- if (state === STATE.SignIn) {
145
- return (
146
- <SignIn description='Please sign in to check the rewards that you earned.' />
147
- )
148
- }
149
-
150
- if (state === STATE.Congrats) {
151
- return (
152
- <Box css={styles.wrapper}>
153
- <Box css={styles.congrats}>
154
- <CongratulationsIcon />
155
- </Box>
156
- <Box css={styles.ribbon}>
157
- <RibbonIcon />
158
- <Box css={styles.ribbonContent}>
159
- <HumaPointsIcon />
160
- <Box>
161
- {hasPointsAccumulated
162
- ? `${formatNumber(rewardsAccumulated)} $HUMA`
163
- : 'Rewards earned'}
164
- </Box>
165
- </Box>
166
- </Box>
167
- <Box css={styles.entirePoints}>
168
- {hasPointsAccumulated ? (
169
- <>
170
- <Box>Congratulations,</Box>
171
- <Box>you've earned {rewardsAccumulated} $HUMA</Box>
172
- </>
173
- ) : (
174
- <Box>Congratulations on joining the Huma Protocol!</Box>
175
- )}
176
- </Box>
177
- <Box css={styles.entirePointsDetails}>
178
- You'll earn rewards <span css={styles.everyday}>everyday</span> for{' '}
179
- {monthText} straight.
180
- </Box>
181
- <BottomButton variant='contained' onClick={handleCloseModal}>
182
- GREAT
183
- </BottomButton>
184
- </Box>
185
- )
186
- }
187
-
188
- return <LoadingModal title='SUPPLY' />
189
- }