@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/dist/cjs/index.cjs +61 -82
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +61 -82
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +0 -5
- package/src/components/Lend/supplyV2/8-PointsEarned.tsx +86 -74
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +1 -1
- package/src/components/ViewOnExplorer.tsx +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.61-beta.
|
|
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.
|
|
34
|
-
"@huma-finance/shared": "^0.0.
|
|
35
|
-
"@huma-finance/web-shared": "^0.0.
|
|
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": "
|
|
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 {
|
|
2
|
-
|
|
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
|
|
10
|
+
import { useResetAtom } from 'jotai/utils'
|
|
11
|
+
import React, { useCallback, useEffect, useState } from 'react'
|
|
6
12
|
import { useDispatch } from 'react-redux'
|
|
7
13
|
|
|
8
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
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={
|
|
233
|
+
<BottomButton variant='contained' onClick={handleCloseModal}>
|
|
222
234
|
GREAT
|
|
223
235
|
</BottomButton>
|
|
224
236
|
</Box>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Box
|
|
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
|
-
<
|
|
20
|
+
<BottomButton variant='contained' onClick={() => openInNewTab(link)}>
|
|
20
21
|
<Box component='span'>VIEW ON EXPLORER</Box>
|
|
21
|
-
</
|
|
22
|
+
</BottomButton>
|
|
22
23
|
)
|
|
23
24
|
}
|