@huma-finance/widgets 0.0.62-beta.700 → 0.0.62-beta.701
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 +11 -5
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Lend/components/PersonaEvaluation.tsx +4 -3
- package/src/components/Lend/solanaSupply/5-Success.tsx +8 -3
- package/src/components/Lend/solanaSupply/6-PointsEarned.tsx +250 -0
- package/src/components/Lend/solanaSupply/index.tsx +7 -3
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +7 -2
- package/src/components/Lend/supplyV2/index.tsx +3 -3
- package/src/components/SolanaTxDoneModal.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.62-beta.
|
|
3
|
+
"version": "0.0.62-beta.701+5d2620c",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@ethersproject/experimental": "^5.7.0",
|
|
30
30
|
"@ethersproject/providers": "^5.6.0",
|
|
31
31
|
"@ethersproject/units": "^5.6.0",
|
|
32
|
-
"@huma-finance/sdk": "^0.0.62-beta.
|
|
33
|
-
"@huma-finance/shared": "^0.0.62-beta.
|
|
32
|
+
"@huma-finance/sdk": "^0.0.62-beta.701+5d2620c",
|
|
33
|
+
"@huma-finance/shared": "^0.0.62-beta.701+5d2620c",
|
|
34
34
|
"@huma-finance/web-shared": "^0.0.61",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
@@ -203,5 +203,5 @@
|
|
|
203
203
|
"optionalDependencies": {
|
|
204
204
|
"encoding": "^0.1.13"
|
|
205
205
|
},
|
|
206
|
-
"gitHead": "
|
|
206
|
+
"gitHead": "5d2620cc8d54da4495cf4fffcf1bfb4a44860231"
|
|
207
207
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CampaignService,
|
|
4
4
|
CHAIN_TYPE,
|
|
5
5
|
checkIsDev,
|
|
6
|
+
CloseModalOptions,
|
|
6
7
|
IdentityServiceV2,
|
|
7
8
|
IdentityVerificationStatusV2,
|
|
8
9
|
KYCCopy,
|
|
@@ -38,7 +39,7 @@ type Props = {
|
|
|
38
39
|
campaign?: Campaign
|
|
39
40
|
chainSpecificData?: Record<string, unknown>
|
|
40
41
|
changeTranche: (tranche: TrancheType) => void
|
|
41
|
-
handleClose: (
|
|
42
|
+
handleClose: (options?: CloseModalOptions) => void
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export function PersonaEvaluation({
|
|
@@ -377,11 +378,11 @@ export function PersonaEvaluation({
|
|
|
377
378
|
case IdentityVerificationStatusV2.DECLINED:
|
|
378
379
|
case IdentityVerificationStatusV2.NEEDS_REVIEW:
|
|
379
380
|
case IdentityVerificationStatusV2.APPROVED:
|
|
380
|
-
handleClose(verificationStatus.status)
|
|
381
|
+
handleClose({ identityStatus: verificationStatus.status })
|
|
381
382
|
break
|
|
382
383
|
|
|
383
384
|
case IdentityVerificationStatusV2.BYPASSED:
|
|
384
|
-
handleClose(IdentityVerificationStatusV2.APPROVED)
|
|
385
|
+
handleClose({ identityStatus: IdentityVerificationStatusV2.APPROVED })
|
|
385
386
|
break
|
|
386
387
|
|
|
387
388
|
default:
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CloseModalOptions,
|
|
3
|
+
formatMoney,
|
|
4
|
+
SolanaPoolInfo,
|
|
5
|
+
timeUtil,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
2
7
|
import { SolanaPoolState } from '@huma-finance/web-shared'
|
|
3
8
|
import dayjs from 'dayjs'
|
|
4
9
|
import React, { useCallback } from 'react'
|
|
@@ -14,7 +19,7 @@ type Props = {
|
|
|
14
19
|
poolInfo: SolanaPoolInfo
|
|
15
20
|
poolState: SolanaPoolState
|
|
16
21
|
campaign?: Campaign
|
|
17
|
-
handleAction: () => void
|
|
22
|
+
handleAction: (options?: CloseModalOptions) => void
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export function Success({
|
|
@@ -49,7 +54,7 @@ export function Success({
|
|
|
49
54
|
if (campaign) {
|
|
50
55
|
dispatch(setStep(WIDGET_STEP.PointsEarned))
|
|
51
56
|
} else {
|
|
52
|
-
handleAction()
|
|
57
|
+
handleAction({ isSuccess: true })
|
|
53
58
|
}
|
|
54
59
|
}, [campaign, dispatch, handleAction])
|
|
55
60
|
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CampaignService,
|
|
3
|
+
CHAIN_TYPE,
|
|
4
|
+
checkIsDev,
|
|
5
|
+
CloseModalOptions,
|
|
6
|
+
formatNumber,
|
|
7
|
+
isEmpty,
|
|
8
|
+
} from '@huma-finance/shared'
|
|
9
|
+
import {
|
|
10
|
+
SolanaPoolState,
|
|
11
|
+
txAtom,
|
|
12
|
+
useAuthErrorHandling,
|
|
13
|
+
useChainInfo,
|
|
14
|
+
} from '@huma-finance/web-shared'
|
|
15
|
+
import { Box, css, useTheme } from '@mui/material'
|
|
16
|
+
import { useResetAtom } from 'jotai/utils'
|
|
17
|
+
import React, { useCallback, useEffect, useState } from 'react'
|
|
18
|
+
import { useDispatch } from 'react-redux'
|
|
19
|
+
|
|
20
|
+
import { resetState, setError } from '../../../store/widgets.reducers'
|
|
21
|
+
import { BottomButton } from '../../BottomButton'
|
|
22
|
+
import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from '../../icons'
|
|
23
|
+
import { LoadingModal } from '../../LoadingModal'
|
|
24
|
+
import { SignIn } from '../../SignIn'
|
|
25
|
+
|
|
26
|
+
enum STATE {
|
|
27
|
+
Loading = 'Loading',
|
|
28
|
+
SignIn = 'SignIn',
|
|
29
|
+
Congrats = 'Congrats',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const ERROR_MESSAGE =
|
|
33
|
+
'Failed to update wallet points. Be assured that your points will be added later.'
|
|
34
|
+
|
|
35
|
+
type Props = {
|
|
36
|
+
transactionHash: string
|
|
37
|
+
poolState: SolanaPoolState
|
|
38
|
+
pointsTestnetExperience: boolean
|
|
39
|
+
handleAction: (options?: CloseModalOptions) => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function PointsEarned({
|
|
43
|
+
transactionHash,
|
|
44
|
+
poolState,
|
|
45
|
+
pointsTestnetExperience,
|
|
46
|
+
handleAction,
|
|
47
|
+
}: Props): React.ReactElement {
|
|
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
|
+
|
|
64
|
+
const {
|
|
65
|
+
errorType,
|
|
66
|
+
setError: setAuthError,
|
|
67
|
+
isWalletOwnershipVerified,
|
|
68
|
+
isWalletOwnershipVerificationRequired,
|
|
69
|
+
} = useAuthErrorHandling(isDev)
|
|
70
|
+
const [walletOwnership, setWalletOwnership] = useState<boolean | undefined>()
|
|
71
|
+
const [state, setState] = useState<STATE>(STATE.Loading)
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (isWalletOwnershipVerificationRequired) {
|
|
75
|
+
setState(STATE.Loading)
|
|
76
|
+
}
|
|
77
|
+
}, [isWalletOwnershipVerificationRequired])
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (isWalletOwnershipVerified) {
|
|
81
|
+
setWalletOwnership(true)
|
|
82
|
+
}
|
|
83
|
+
}, [isWalletOwnershipVerified])
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const checkWalletOwnership = async () => {
|
|
87
|
+
if (account) {
|
|
88
|
+
const ownership = await CampaignService.checkWalletOwnership(
|
|
89
|
+
account,
|
|
90
|
+
isDev,
|
|
91
|
+
pointsTestnetExperience,
|
|
92
|
+
)
|
|
93
|
+
setWalletOwnership(ownership)
|
|
94
|
+
if (!ownership) {
|
|
95
|
+
setAuthError('WalletNotSignInException')
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
checkWalletOwnership()
|
|
100
|
+
}, [account, isDev, pointsTestnetExperience, setAuthError])
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (errorType === 'NotSignedIn') {
|
|
104
|
+
setState(STATE.SignIn)
|
|
105
|
+
} else if (errorType === 'UserRejected') {
|
|
106
|
+
dispatch(
|
|
107
|
+
setError({
|
|
108
|
+
errorMessage: 'User has rejected the transaction.',
|
|
109
|
+
}),
|
|
110
|
+
)
|
|
111
|
+
} else if (errorType === 'Other') {
|
|
112
|
+
dispatch(
|
|
113
|
+
setError({
|
|
114
|
+
errorMessage: ERROR_MESSAGE,
|
|
115
|
+
}),
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
}, [dispatch, errorType])
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
const updateWalletPoints = async () => {
|
|
122
|
+
if (walletOwnership) {
|
|
123
|
+
try {
|
|
124
|
+
const result = await CampaignService.updateWalletPoints(
|
|
125
|
+
account!,
|
|
126
|
+
transactionHash,
|
|
127
|
+
chainId!,
|
|
128
|
+
isDev,
|
|
129
|
+
pointsTestnetExperience,
|
|
130
|
+
)
|
|
131
|
+
setPointsAccumulated(result.pointsAccumulated)
|
|
132
|
+
setState(STATE.Congrats)
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('Failed to update wallet points', error)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
updateWalletPoints()
|
|
139
|
+
}, [
|
|
140
|
+
account,
|
|
141
|
+
chainId,
|
|
142
|
+
dispatch,
|
|
143
|
+
isDev,
|
|
144
|
+
pointsTestnetExperience,
|
|
145
|
+
transactionHash,
|
|
146
|
+
walletOwnership,
|
|
147
|
+
])
|
|
148
|
+
|
|
149
|
+
const handleCloseModal = useCallback(() => {
|
|
150
|
+
reset()
|
|
151
|
+
dispatch(resetState())
|
|
152
|
+
handleAction({ isSuccess: true })
|
|
153
|
+
}, [dispatch, handleAction, reset])
|
|
154
|
+
|
|
155
|
+
const styles = {
|
|
156
|
+
wrapper: css`
|
|
157
|
+
height: 518px;
|
|
158
|
+
position: relative;
|
|
159
|
+
`,
|
|
160
|
+
congrats: css`
|
|
161
|
+
margin: ${theme.spacing(-4, -4.5, 0, -4.5)};
|
|
162
|
+
`,
|
|
163
|
+
ribbon: css`
|
|
164
|
+
position: relative;
|
|
165
|
+
${theme.cssMixins.rowHCentered};
|
|
166
|
+
font-weight: 700;
|
|
167
|
+
margin-top: ${theme.spacing(-8)};
|
|
168
|
+
color: ${theme.palette.text.primary};
|
|
169
|
+
font-size: 20px;
|
|
170
|
+
line-height: 160%;
|
|
171
|
+
letter-spacing: 0.15px;
|
|
172
|
+
`,
|
|
173
|
+
ribbonContent: css`
|
|
174
|
+
${theme.cssMixins.rowVCentered};
|
|
175
|
+
position: absolute;
|
|
176
|
+
top: ${theme.spacing(1)};
|
|
177
|
+
|
|
178
|
+
svg {
|
|
179
|
+
margin-right: ${theme.spacing(1)};
|
|
180
|
+
}
|
|
181
|
+
`,
|
|
182
|
+
entirePoints: css`
|
|
183
|
+
color: ${theme.palette.text.tertiary};
|
|
184
|
+
text-align: center;
|
|
185
|
+
font-weight: 700;
|
|
186
|
+
font-size: 20px;
|
|
187
|
+
line-height: 160%;
|
|
188
|
+
letter-spacing: 0.15px;
|
|
189
|
+
margin-top: ${theme.spacing(7)};
|
|
190
|
+
`,
|
|
191
|
+
entirePointsDetails: css`
|
|
192
|
+
color: ${theme.palette.text.tertiary};
|
|
193
|
+
text-align: center;
|
|
194
|
+
font-weight: 400;
|
|
195
|
+
font-size: 16px;
|
|
196
|
+
line-height: 150%;
|
|
197
|
+
letter-spacing: 0.15px;
|
|
198
|
+
margin-top: ${theme.spacing(4)};
|
|
199
|
+
`,
|
|
200
|
+
everyday: css`
|
|
201
|
+
font-weight: 700;
|
|
202
|
+
`,
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (state === STATE.SignIn) {
|
|
206
|
+
return (
|
|
207
|
+
<SignIn description='Please sign in to check the points that you earned.' />
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (state === STATE.Congrats) {
|
|
212
|
+
return (
|
|
213
|
+
<Box css={styles.wrapper}>
|
|
214
|
+
<Box css={styles.congrats}>
|
|
215
|
+
<CongratulationsIcon />
|
|
216
|
+
</Box>
|
|
217
|
+
<Box css={styles.ribbon}>
|
|
218
|
+
<RibbonIcon />
|
|
219
|
+
<Box css={styles.ribbonContent}>
|
|
220
|
+
<HumaPointsIcon />
|
|
221
|
+
<Box>
|
|
222
|
+
{hasPointsAccumulated
|
|
223
|
+
? `${formatNumber(pointsAccumulated)} Points`
|
|
224
|
+
: 'Points earned'}
|
|
225
|
+
</Box>
|
|
226
|
+
</Box>
|
|
227
|
+
</Box>
|
|
228
|
+
<Box css={styles.entirePoints}>
|
|
229
|
+
{hasPointsAccumulated ? (
|
|
230
|
+
<>
|
|
231
|
+
<Box>Congratulations,</Box>
|
|
232
|
+
<Box>you've earned {pointsAccumulated} points</Box>
|
|
233
|
+
</>
|
|
234
|
+
) : (
|
|
235
|
+
<Box>Congratulations on joining the Huma Protocol!</Box>
|
|
236
|
+
)}
|
|
237
|
+
</Box>
|
|
238
|
+
<Box css={styles.entirePointsDetails}>
|
|
239
|
+
You'll earn points <span css={styles.everyday}>everyday</span> for{' '}
|
|
240
|
+
{monthText} straight.
|
|
241
|
+
</Box>
|
|
242
|
+
<BottomButton variant='contained' onClick={handleCloseModal}>
|
|
243
|
+
GREAT
|
|
244
|
+
</BottomButton>
|
|
245
|
+
</Box>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return <LoadingModal title='SUPPLY' />
|
|
250
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CloseModalOptions,
|
|
3
|
+
SolanaPoolInfo,
|
|
4
|
+
TrancheType,
|
|
5
|
+
} from '@huma-finance/shared'
|
|
2
6
|
import {
|
|
3
7
|
SolanaPoolState,
|
|
4
8
|
useLenderAccounts,
|
|
@@ -31,14 +35,14 @@ export interface Campaign {
|
|
|
31
35
|
* @property {SolanaPoolInfo} poolInfo The metadata of the pool.
|
|
32
36
|
* @property {SolanaPoolState} poolState The current state config of the pool.
|
|
33
37
|
* @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
|
|
34
|
-
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
38
|
+
* @property {function((CloseModalOptions|undefined)):void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
35
39
|
* @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
36
40
|
*/
|
|
37
41
|
export interface SolanaLendSupplyProps {
|
|
38
42
|
poolInfo: SolanaPoolInfo
|
|
39
43
|
poolState: SolanaPoolState
|
|
40
44
|
pointsTestnetExperience: boolean
|
|
41
|
-
handleClose: () => void
|
|
45
|
+
handleClose: (options?: CloseModalOptions) => void
|
|
42
46
|
handleSuccess?: () => void
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CHAIN_TYPE,
|
|
3
|
+
CloseModalOptions,
|
|
4
|
+
PoolInfoV2,
|
|
5
|
+
TrancheType,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
2
7
|
import React from 'react'
|
|
3
8
|
|
|
4
9
|
import { Campaign } from '.'
|
|
@@ -11,7 +16,7 @@ type Props = {
|
|
|
11
16
|
pointsTestnetExperience: boolean
|
|
12
17
|
campaign?: Campaign
|
|
13
18
|
changeTranche: (tranche: TrancheType) => void
|
|
14
|
-
handleClose: () => void
|
|
19
|
+
handleClose: (options?: CloseModalOptions) => void
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export function Evaluation({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CloseModalOptions,
|
|
3
3
|
openInNewTab,
|
|
4
4
|
POOL_NAME,
|
|
5
5
|
TrancheType,
|
|
@@ -40,14 +40,14 @@ export interface Campaign {
|
|
|
40
40
|
* @property {POOL_NAME} poolName The name of the pool.
|
|
41
41
|
* @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
|
|
42
42
|
* @property {Campaign} campaign The campaign info.
|
|
43
|
-
* @property {function((
|
|
43
|
+
* @property {function((CloseModalOptions|undefined)):void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
44
44
|
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
45
45
|
*/
|
|
46
46
|
export interface LendSupplyPropsV2 {
|
|
47
47
|
poolName: keyof typeof POOL_NAME
|
|
48
48
|
pointsTestnetExperience: boolean
|
|
49
49
|
campaign?: Campaign
|
|
50
|
-
handleClose: (
|
|
50
|
+
handleClose: (options?: CloseModalOptions) => void
|
|
51
51
|
handleSuccess?: (blockNumber?: number) => void
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -19,10 +19,10 @@ type Props = {
|
|
|
19
19
|
export function SolanaTxDoneModal({
|
|
20
20
|
content,
|
|
21
21
|
subContent,
|
|
22
|
-
handleAction,
|
|
23
22
|
solanaSignature,
|
|
24
23
|
chainId,
|
|
25
24
|
buttonText,
|
|
25
|
+
handleAction,
|
|
26
26
|
}: Props): React.ReactElement {
|
|
27
27
|
const theme = useTheme()
|
|
28
28
|
const dispatch = useAppDispatch()
|