@huma-finance/widgets 0.0.61-beta.546 → 0.0.61-beta.548

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.61-beta.546+8550ae4",
3
+ "version": "0.0.61-beta.548+4ca040c",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,9 +30,9 @@
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.60",
34
- "@huma-finance/shared": "^0.0.60",
35
- "@huma-finance/web-shared": "^0.0.60",
33
+ "@huma-finance/sdk": "^0.0.61-beta.548+4ca040c",
34
+ "@huma-finance/shared": "^0.0.61-beta.548+4ca040c",
35
+ "@huma-finance/web-shared": "^0.0.61-beta.548+4ca040c",
36
36
  "@mui/icons-material": "^5.3.0",
37
37
  "@mui/material": "^5.0.6",
38
38
  "@mui/styles": "^5.0.2",
@@ -195,5 +195,5 @@
195
195
  "optionalDependencies": {
196
196
  "encoding": "^0.1.13"
197
197
  },
198
- "gitHead": "8550ae42c179b2a84d0673184cc4971cd2d30c0d"
198
+ "gitHead": "4ca040c1942ff6df747871456b4103c84571fa7c"
199
199
  }
@@ -45,11 +45,6 @@ export function ChooseAmount({
45
45
  ethers.utils.formatUnits(payoffAmountBN, decimals),
46
46
  )
47
47
 
48
- console.log('totalDueAmountBN', totalDueAmountBN.toString())
49
- console.log('payoffAmountBN', payoffAmountBN.toString())
50
- console.log('payoffAmount', payoffAmount)
51
- console.log('currentAmount', currentAmount)
52
-
53
48
  useEffect(() => {
54
49
  setCurrentAmount(totalDueAmount)
55
50
  }, [totalDueAmount])
@@ -1,11 +1,17 @@
1
- import { checkIsDev, formatNumber, isEmpty } from '@huma-finance/shared'
2
- // import { useAuthErrorHandling } from '@huma-finance/web-shared'
1
+ import {
2
+ CampaignService,
3
+ checkIsDev,
4
+ formatNumber,
5
+ isEmpty,
6
+ } from '@huma-finance/shared'
7
+ import { txAtom, useAuthErrorHandling } from '@huma-finance/web-shared'
3
8
  import { Box, css, useTheme } from '@mui/material'
4
9
  import { useWeb3React } from '@web3-react/core'
5
- import React, { useEffect, useState } from 'react'
10
+ import { useResetAtom } from 'jotai/utils'
11
+ import React, { useCallback, useEffect, useState } from 'react'
6
12
  import { useDispatch } from 'react-redux'
7
13
 
8
- // import { setError } from '../../../store/widgets.reducers'
14
+ import { resetState, setError } from '../../../store/widgets.reducers'
9
15
  import { BottomButton } from '../../BottomButton'
10
16
  import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from '../../icons'
11
17
  import { LoadingModal } from '../../LoadingModal'
@@ -17,8 +23,8 @@ enum STATE {
17
23
  Congrats = 'Congrats',
18
24
  }
19
25
 
20
- // const ERROR_MESSAGE =
21
- // 'Failed to update wallet points. Be assured that your points will be added later.'
26
+ const ERROR_MESSAGE =
27
+ 'Failed to update wallet points. Be assured that your points will be added later.'
22
28
 
23
29
  type Props = {
24
30
  transactionHash: string
@@ -36,6 +42,7 @@ export function PointsEarned({
36
42
  const theme = useTheme()
37
43
  const isDev = checkIsDev()
38
44
  const dispatch = useDispatch()
45
+ const reset = useResetAtom(txAtom)
39
46
  const { account, chainId } = useWeb3React()
40
47
  const [pointsAccumulated, setPointsAccumulated] = useState<
41
48
  number | undefined
@@ -46,78 +53,77 @@ export function PointsEarned({
46
53
  const monthText =
47
54
  lockupMonths > 1 ? `${lockupMonths} months` : `${lockupMonths} month`
48
55
 
49
- // const {
50
- // errorType,
51
- // setError: setAuthError,
52
- // isWalletOwnershipVerified,
53
- // isWalletOwnershipVerificationRequired,
54
- // } = useAuthErrorHandling(isDev)
55
- // const [walletOwnership, setWalletOwnership] = useState<boolean | undefined>()
56
+ const {
57
+ errorType,
58
+ setError: setAuthError,
59
+ isWalletOwnershipVerified,
60
+ isWalletOwnershipVerificationRequired,
61
+ } = useAuthErrorHandling(isDev)
62
+ const [walletOwnership, setWalletOwnership] = useState<boolean | undefined>()
56
63
  const [state, setState] = useState<STATE>(STATE.Loading)
57
64
 
58
- // useEffect(() => {
59
- // if (isWalletOwnershipVerificationRequired) {
60
- // setState(STATE.Loading)
61
- // }
62
- // }, [isWalletOwnershipVerificationRequired])
63
-
64
- // useEffect(() => {
65
- // if (isWalletOwnershipVerified) {
66
- // setWalletOwnership(true)
67
- // }
68
- // }, [isWalletOwnershipVerified])
69
-
70
- // useEffect(() => {
71
- // const checkWalletOwnership = async () => {
72
- // const ownership = await CampaignService.checkWalletOwnership(
73
- // account!,
74
- // isDev,
75
- // pointsTestnetExperience,
76
- // )
77
- // setWalletOwnership(ownership)
78
- // if (!ownership) {
79
- // setAuthError('WalletNotSignInException')
80
- // }
81
- // }
82
- // checkWalletOwnership()
83
- // }, [account, isDev, pointsTestnetExperience, setAuthError])
84
-
85
- // useEffect(() => {
86
- // if (errorType === 'NotSignedIn') {
87
- // setState(STATE.SignIn)
88
- // } else if (errorType === 'UserRejected') {
89
- // dispatch(
90
- // setError({
91
- // errorMessage: 'User has rejected the transaction.',
92
- // }),
93
- // )
94
- // } else if (errorType === 'Other') {
95
- // dispatch(
96
- // setError({
97
- // errorMessage: ERROR_MESSAGE,
98
- // }),
99
- // )
100
- // }
101
- // }, [dispatch, errorType])
65
+ useEffect(() => {
66
+ if (isWalletOwnershipVerificationRequired) {
67
+ setState(STATE.Loading)
68
+ }
69
+ }, [isWalletOwnershipVerificationRequired])
70
+
71
+ useEffect(() => {
72
+ if (isWalletOwnershipVerified) {
73
+ setWalletOwnership(true)
74
+ }
75
+ }, [isWalletOwnershipVerified])
76
+
77
+ useEffect(() => {
78
+ const checkWalletOwnership = async () => {
79
+ const ownership = await CampaignService.checkWalletOwnership(
80
+ account!,
81
+ isDev,
82
+ pointsTestnetExperience,
83
+ )
84
+ setWalletOwnership(ownership)
85
+ if (!ownership) {
86
+ setAuthError('WalletNotSignInException')
87
+ }
88
+ }
89
+ checkWalletOwnership()
90
+ }, [account, isDev, pointsTestnetExperience, setAuthError])
91
+
92
+ useEffect(() => {
93
+ if (errorType === 'NotSignedIn') {
94
+ setState(STATE.SignIn)
95
+ } else if (errorType === 'UserRejected') {
96
+ dispatch(
97
+ setError({
98
+ errorMessage: 'User has rejected the transaction.',
99
+ }),
100
+ )
101
+ } else if (errorType === 'Other') {
102
+ dispatch(
103
+ setError({
104
+ errorMessage: ERROR_MESSAGE,
105
+ }),
106
+ )
107
+ }
108
+ }, [dispatch, errorType])
102
109
 
103
110
  useEffect(() => {
104
111
  const updateWalletPoints = async () => {
105
- // if (walletOwnership) {
106
- try {
107
- // const result = await CampaignService.updateWalletPoints(
108
- // account!,
109
- // transactionHash,
110
- // chainId!,
111
- // isDev,
112
- // pointsTestnetExperience,
113
- // )
114
- // setPointsAccumulated(result.pointsAccumulated)
115
- setPointsAccumulated(5000)
116
- setState(STATE.Congrats)
117
- } catch (error) {
118
- console.error('Failed to update wallet points', error)
112
+ if (walletOwnership) {
113
+ try {
114
+ const result = await CampaignService.updateWalletPoints(
115
+ account!,
116
+ transactionHash,
117
+ chainId!,
118
+ isDev,
119
+ pointsTestnetExperience,
120
+ )
121
+ setPointsAccumulated(result.pointsAccumulated)
122
+ setState(STATE.Congrats)
123
+ } catch (error) {
124
+ console.error('Failed to update wallet points', error)
125
+ }
119
126
  }
120
- // }
121
127
  }
122
128
  updateWalletPoints()
123
129
  }, [
@@ -127,9 +133,15 @@ export function PointsEarned({
127
133
  isDev,
128
134
  pointsTestnetExperience,
129
135
  transactionHash,
130
- // walletOwnership,
136
+ walletOwnership,
131
137
  ])
132
138
 
139
+ const handleCloseModal = useCallback(() => {
140
+ reset()
141
+ dispatch(resetState())
142
+ handleAction()
143
+ }, [dispatch, handleAction, reset])
144
+
133
145
  const styles = {
134
146
  wrapper: css`
135
147
  height: 518px;
@@ -218,7 +230,7 @@ export function PointsEarned({
218
230
  {monthText} straight. Plus, If you keep your investment till after{' '}
219
231
  {monthText}, you’ll gain extra points daily.
220
232
  </Box>
221
- <BottomButton variant='contained' onClick={handleAction}>
233
+ <BottomButton variant='contained' onClick={handleCloseModal}>
222
234
  GREAT
223
235
  </BottomButton>
224
236
  </Box>
@@ -35,7 +35,7 @@ const LoadingCopiesByType: {
35
35
  description: `Checking your verification status...`,
36
36
  },
37
37
  startKYC: {
38
- description: `Starting KYC...`,
38
+ description: `Starting KYC/KYB...`,
39
39
  },
40
40
  approveLender: {
41
41
  description: `Approving as lender...`,
@@ -1,7 +1,8 @@
1
- import { Box, Button } from '@mui/material'
1
+ import { Box } from '@mui/material'
2
2
  import { useWeb3React } from '@web3-react/core'
3
3
  import { getExplorerUrl, openInNewTab } from '@huma-finance/shared'
4
4
  import React from 'react'
5
+ import { BottomButton } from './BottomButton'
5
6
 
6
7
  type Props = {
7
8
  txHash: string
@@ -16,8 +17,8 @@ export function ViewOnExplorer({ txHash }: Props): React.ReactElement | null {
16
17
  }
17
18
 
18
19
  return (
19
- <Button variant='outlined' onClick={() => openInNewTab(link)}>
20
+ <BottomButton variant='contained' onClick={() => openInNewTab(link)}>
20
21
  <Box component='span'>VIEW ON EXPLORER</Box>
21
- </Button>
22
+ </BottomButton>
22
23
  )
23
24
  }