@huma-finance/widgets 0.0.65 → 0.0.66-beta.812
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 +0 -2
- package/dist/cjs/index.cjs +100 -114
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +101 -115
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Lend/components/ApproveLenderBase.tsx +5 -1
- package/src/components/Lend/components/PersonaEvaluation.tsx +79 -115
- package/src/components/Lend/solanaSupply/1-Evaluation.tsx +5 -5
- package/src/components/Lend/solanaSupply/2-ApproveLender.tsx +2 -0
- package/src/components/Lend/solanaSupply/6-Transfer.tsx +7 -7
- package/src/components/Lend/solanaSupply/8-PointsEarned.tsx +17 -89
- package/src/components/Lend/solanaSupply/index.tsx +3 -5
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +9 -4
- package/src/components/Lend/supplyV2/3-ApproveLender.tsx +7 -1
- package/src/components/Lend/supplyV2/6-Transfer.tsx +6 -5
- package/src/components/Lend/supplyV2/index.tsx +3 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66-beta.812+dc79163",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
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.
|
|
33
|
-
"@huma-finance/shared": "^0.0.
|
|
34
|
-
"@huma-finance/web-shared": "^0.0.
|
|
32
|
+
"@huma-finance/sdk": "^0.0.66-beta.812+dc79163",
|
|
33
|
+
"@huma-finance/shared": "^0.0.66-beta.812+dc79163",
|
|
34
|
+
"@huma-finance/web-shared": "^0.0.66-beta.812+dc79163",
|
|
35
35
|
"@mui/x-date-pickers": "^5.0.7",
|
|
36
36
|
"@notifi-network/notifi-frontend-client": "^1.1.2",
|
|
37
37
|
"@notifi-network/notifi-react": "^1.1.2",
|
|
@@ -201,5 +201,5 @@
|
|
|
201
201
|
"optionalDependencies": {
|
|
202
202
|
"encoding": "^0.1.13"
|
|
203
203
|
},
|
|
204
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "dc79163e3ea685e1ed7f79755c36761eb48bf913"
|
|
205
205
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
CHAIN_TYPE,
|
|
4
4
|
checkIsDev,
|
|
5
5
|
IdentityServiceV2,
|
|
6
|
+
NETWORK_TYPE,
|
|
6
7
|
timeUtil,
|
|
7
8
|
TrancheType,
|
|
8
9
|
} from '@huma-finance/shared'
|
|
@@ -18,6 +19,7 @@ type Props = {
|
|
|
18
19
|
juniorTrancheVault: string
|
|
19
20
|
seniorTrancheVault: string
|
|
20
21
|
chainType: CHAIN_TYPE
|
|
22
|
+
networkType: NETWORK_TYPE
|
|
21
23
|
isUniTranche: boolean
|
|
22
24
|
chainSpecificData?: Record<string, unknown>
|
|
23
25
|
changeTranche: (tranche: TrancheType) => void
|
|
@@ -28,6 +30,7 @@ export function ApproveLenderBase({
|
|
|
28
30
|
seniorTrancheVault,
|
|
29
31
|
isUniTranche,
|
|
30
32
|
chainType,
|
|
33
|
+
networkType,
|
|
31
34
|
chainSpecificData,
|
|
32
35
|
changeTranche,
|
|
33
36
|
}: Props): React.ReactElement | null {
|
|
@@ -43,6 +46,7 @@ export function ApproveLenderBase({
|
|
|
43
46
|
try {
|
|
44
47
|
tryAttempts -= 1
|
|
45
48
|
await IdentityServiceV2.approveLender(
|
|
49
|
+
networkType,
|
|
46
50
|
account!,
|
|
47
51
|
chainId!,
|
|
48
52
|
trancheVault,
|
|
@@ -64,7 +68,7 @@ export function ApproveLenderBase({
|
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
},
|
|
67
|
-
[account, chainId, chainSpecificData, dispatch, isDev],
|
|
71
|
+
[account, chainId, chainSpecificData, dispatch, isDev, networkType],
|
|
68
72
|
)
|
|
69
73
|
|
|
70
74
|
useEffect(() => {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CAMPAIGN_REFERENCE_CODE,
|
|
3
|
-
CampaignService,
|
|
4
2
|
CHAIN_TYPE,
|
|
5
3
|
checkIsDev,
|
|
6
4
|
CloseModalOptions,
|
|
@@ -8,9 +6,10 @@ import {
|
|
|
8
6
|
IdentityVerificationStatusV2,
|
|
9
7
|
KYCCopy,
|
|
10
8
|
KYCType,
|
|
9
|
+
NETWORK_TYPE,
|
|
11
10
|
VerificationStatusResultV2,
|
|
12
11
|
} from '@huma-finance/shared'
|
|
13
|
-
import { useAuthErrorHandling
|
|
12
|
+
import { useAuthErrorHandling } from '@huma-finance/web-shared'
|
|
14
13
|
import { Box, css, useTheme } from '@mui/material'
|
|
15
14
|
import Persona, { Client } from 'persona'
|
|
16
15
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
@@ -32,8 +31,8 @@ type Props = {
|
|
|
32
31
|
juniorTrancheVault: string
|
|
33
32
|
seniorTrancheVault: string
|
|
34
33
|
}
|
|
34
|
+
networkType: NETWORK_TYPE
|
|
35
35
|
chainType: CHAIN_TYPE
|
|
36
|
-
pointsTestnetExperience: boolean
|
|
37
36
|
campaign?: Campaign
|
|
38
37
|
handleClose: (options?: CloseModalOptions) => void
|
|
39
38
|
}
|
|
@@ -41,14 +40,13 @@ type Props = {
|
|
|
41
40
|
export function PersonaEvaluation({
|
|
42
41
|
poolInfo,
|
|
43
42
|
campaign,
|
|
44
|
-
|
|
43
|
+
networkType,
|
|
45
44
|
chainType,
|
|
46
45
|
handleClose,
|
|
47
46
|
}: Props): React.ReactElement | null {
|
|
48
47
|
const theme = useTheme()
|
|
49
48
|
const isDev = checkIsDev()
|
|
50
49
|
const dispatch = useAppDispatch()
|
|
51
|
-
const { account, chainId } = useChainInfo(isDev, chainType)
|
|
52
50
|
const {
|
|
53
51
|
errorType,
|
|
54
52
|
setError: setAuthError,
|
|
@@ -68,143 +66,109 @@ export function PersonaEvaluation({
|
|
|
68
66
|
const isActionOngoingRef = useRef<boolean>(false)
|
|
69
67
|
const isKYCResumedRef = useRef<boolean>(false)
|
|
70
68
|
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
const createNewWallet = async () => {
|
|
73
|
-
if (isWalletOwnershipVerified && campaign && account) {
|
|
74
|
-
await CampaignService.createNewWallet(
|
|
75
|
-
account,
|
|
76
|
-
localStorage.getItem(CAMPAIGN_REFERENCE_CODE) ?? undefined,
|
|
77
|
-
isDev,
|
|
78
|
-
pointsTestnetExperience,
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
createNewWallet()
|
|
83
|
-
}, [
|
|
84
|
-
account,
|
|
85
|
-
campaign,
|
|
86
|
-
isDev,
|
|
87
|
-
isWalletOwnershipVerified,
|
|
88
|
-
pointsTestnetExperience,
|
|
89
|
-
])
|
|
90
|
-
|
|
91
69
|
const checkVerificationStatus = useCallback(async () => {
|
|
92
70
|
if (isActionOngoingRef.current || isKYCResumedRef.current) {
|
|
93
71
|
return
|
|
94
72
|
}
|
|
95
73
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
chainId,
|
|
103
|
-
isDev,
|
|
104
|
-
)
|
|
105
|
-
setVerificationStatus(verificationStatus)
|
|
106
|
-
setInquiryId(verificationStatus.personaInquiryId)
|
|
107
|
-
|
|
108
|
-
switch (verificationStatus.status) {
|
|
109
|
-
case IdentityVerificationStatusV2.ACCREDITED: {
|
|
110
|
-
const startVerificationResult =
|
|
111
|
-
await IdentityServiceV2.startVerification(account, chainId, isDev)
|
|
112
|
-
setInquiryId(startVerificationResult.personaInquiryId)
|
|
113
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
114
|
-
setLoadingType(undefined)
|
|
115
|
-
if (
|
|
116
|
-
startVerificationResult.status ===
|
|
117
|
-
IdentityVerificationStatusV2.BYPASSED
|
|
118
|
-
) {
|
|
119
|
-
setVerificationStatus(startVerificationResult)
|
|
120
|
-
setKYCCopy(KYCCopies.verificationBypassed)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
break
|
|
124
|
-
}
|
|
74
|
+
isActionOngoingRef.current = true
|
|
75
|
+
setLoadingType('verificationStatus')
|
|
76
|
+
const verificationStatus =
|
|
77
|
+
await IdentityServiceV2.getVerificationStatusV2(networkType, isDev)
|
|
78
|
+
setVerificationStatus(verificationStatus)
|
|
79
|
+
setInquiryId(verificationStatus.personaInquiryId)
|
|
125
80
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
81
|
+
switch (verificationStatus.status) {
|
|
82
|
+
case IdentityVerificationStatusV2.ACCREDITED: {
|
|
83
|
+
const startVerificationResult =
|
|
84
|
+
await IdentityServiceV2.startVerification(networkType, isDev)
|
|
85
|
+
setInquiryId(startVerificationResult.personaInquiryId)
|
|
86
|
+
setKYCCopy(KYCCopies.verifyIdentity)
|
|
87
|
+
setLoadingType(undefined)
|
|
88
|
+
if (
|
|
89
|
+
startVerificationResult.status ===
|
|
90
|
+
IdentityVerificationStatusV2.BYPASSED
|
|
91
|
+
) {
|
|
92
|
+
setVerificationStatus(startVerificationResult)
|
|
93
|
+
setKYCCopy(KYCCopies.verificationBypassed)
|
|
130
94
|
}
|
|
131
95
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
verificationStatus.status = resumeVerificationResult.status
|
|
141
|
-
setVerificationStatus(verificationStatus)
|
|
142
|
-
setSessionToken(resumeVerificationResult.sessionToken)
|
|
143
|
-
setLoadingType(undefined)
|
|
144
|
-
isKYCResumedRef.current = true
|
|
145
|
-
} else {
|
|
146
|
-
setLoadingType('verificationStatus')
|
|
147
|
-
}
|
|
148
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
149
|
-
break
|
|
150
|
-
}
|
|
96
|
+
break
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
case IdentityVerificationStatusV2.CREATED: {
|
|
100
|
+
setKYCCopy(KYCCopies.verifyIdentity)
|
|
101
|
+
setLoadingType(undefined)
|
|
102
|
+
break
|
|
103
|
+
}
|
|
151
104
|
|
|
152
|
-
|
|
105
|
+
case IdentityVerificationStatusV2.PENDING: {
|
|
106
|
+
if (!isKYCCompletedRef.current) {
|
|
153
107
|
const resumeVerificationResult =
|
|
154
|
-
await IdentityServiceV2.resumeVerification(
|
|
155
|
-
account,
|
|
156
|
-
chainId,
|
|
157
|
-
isDev,
|
|
158
|
-
)
|
|
108
|
+
await IdentityServiceV2.resumeVerification(networkType, isDev)
|
|
159
109
|
verificationStatus.status = resumeVerificationResult.status
|
|
160
110
|
setVerificationStatus(verificationStatus)
|
|
161
111
|
setSessionToken(resumeVerificationResult.sessionToken)
|
|
162
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
163
112
|
setLoadingType(undefined)
|
|
164
113
|
isKYCResumedRef.current = true
|
|
165
|
-
|
|
114
|
+
} else {
|
|
115
|
+
setLoadingType('verificationStatus')
|
|
166
116
|
}
|
|
117
|
+
setKYCCopy(KYCCopies.verifyIdentity)
|
|
118
|
+
break
|
|
119
|
+
}
|
|
167
120
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
121
|
+
case IdentityVerificationStatusV2.EXPIRED: {
|
|
122
|
+
const resumeVerificationResult =
|
|
123
|
+
await IdentityServiceV2.resumeVerification(networkType, isDev)
|
|
124
|
+
verificationStatus.status = resumeVerificationResult.status
|
|
125
|
+
setVerificationStatus(verificationStatus)
|
|
126
|
+
setSessionToken(resumeVerificationResult.sessionToken)
|
|
127
|
+
setKYCCopy(KYCCopies.verifyIdentity)
|
|
128
|
+
setLoadingType(undefined)
|
|
129
|
+
isKYCResumedRef.current = true
|
|
130
|
+
break
|
|
131
|
+
}
|
|
171
132
|
|
|
172
|
-
|
|
173
|
-
|
|
133
|
+
case IdentityVerificationStatusV2.BYPASSED: {
|
|
134
|
+
setKYCCopy(KYCCopies.verificationBypassed)
|
|
135
|
+
setLoadingType(undefined)
|
|
174
136
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
setLoadingType(undefined)
|
|
178
|
-
break
|
|
179
|
-
}
|
|
137
|
+
break
|
|
138
|
+
}
|
|
180
139
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
140
|
+
case IdentityVerificationStatusV2.APPROVED: {
|
|
141
|
+
setKYCCopy(KYCCopies.verificationApproved)
|
|
142
|
+
setLoadingType(undefined)
|
|
143
|
+
break
|
|
144
|
+
}
|
|
186
145
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
146
|
+
case IdentityVerificationStatusV2.DECLINED: {
|
|
147
|
+
setKYCCopy(KYCCopies.verificationDeclined)
|
|
148
|
+
setLoadingType(undefined)
|
|
149
|
+
break
|
|
150
|
+
}
|
|
192
151
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
152
|
+
case IdentityVerificationStatusV2.NEEDS_REVIEW: {
|
|
153
|
+
setKYCCopy(KYCCopies.verificationNeedsReview)
|
|
154
|
+
setLoadingType(undefined)
|
|
155
|
+
break
|
|
156
|
+
}
|
|
197
157
|
|
|
198
|
-
|
|
199
|
-
|
|
158
|
+
case IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION: {
|
|
159
|
+
dispatch(setStep(WIDGET_STEP.ApproveLender))
|
|
160
|
+
break
|
|
200
161
|
}
|
|
162
|
+
|
|
163
|
+
default:
|
|
164
|
+
break
|
|
201
165
|
}
|
|
202
166
|
} catch (e: unknown) {
|
|
203
167
|
setAuthError(e)
|
|
204
168
|
} finally {
|
|
205
169
|
isActionOngoingRef.current = false
|
|
206
170
|
}
|
|
207
|
-
}, [KYCCopies,
|
|
171
|
+
}, [KYCCopies, dispatch, isDev, networkType, setAuthError])
|
|
208
172
|
|
|
209
173
|
useEffect(() => {
|
|
210
174
|
checkVerificationStatus()
|
|
@@ -316,7 +280,7 @@ export function PersonaEvaluation({
|
|
|
316
280
|
}
|
|
317
281
|
}, [KYCAutoStarted, startKYC, verificationStatus])
|
|
318
282
|
|
|
319
|
-
const handleAction = () => {
|
|
283
|
+
const handleAction = useCallback(() => {
|
|
320
284
|
if (verificationStatus) {
|
|
321
285
|
switch (verificationStatus.status) {
|
|
322
286
|
case IdentityVerificationStatusV2.ACCREDITED:
|
|
@@ -340,7 +304,7 @@ export function PersonaEvaluation({
|
|
|
340
304
|
break
|
|
341
305
|
}
|
|
342
306
|
}
|
|
343
|
-
}
|
|
307
|
+
}, [handleClose, startKYC, verificationStatus])
|
|
344
308
|
|
|
345
309
|
const styles = {
|
|
346
310
|
iconWrapper: css`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CHAIN_TYPE, SolanaPoolInfo } from '@huma-finance/shared'
|
|
1
|
+
import { CHAIN_TYPE, NETWORK_TYPE, SolanaPoolInfo } from '@huma-finance/shared'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
import { PersonaEvaluation } from '../components/PersonaEvaluation'
|
|
@@ -6,14 +6,14 @@ import { Campaign } from '../supplyV2'
|
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
8
|
poolInfo: SolanaPoolInfo
|
|
9
|
-
|
|
9
|
+
networkType: NETWORK_TYPE
|
|
10
10
|
campaign?: Campaign
|
|
11
11
|
handleClose: () => void
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function Evaluation({
|
|
15
15
|
poolInfo,
|
|
16
|
-
|
|
16
|
+
networkType,
|
|
17
17
|
campaign,
|
|
18
18
|
handleClose,
|
|
19
19
|
}: Props): React.ReactElement | null {
|
|
@@ -26,9 +26,9 @@ export function Evaluation({
|
|
|
26
26
|
seniorTrancheVault: poolInfo.seniorTrancheMint,
|
|
27
27
|
}}
|
|
28
28
|
handleClose={handleClose}
|
|
29
|
-
|
|
30
|
-
campaign={campaign}
|
|
29
|
+
networkType={networkType}
|
|
31
30
|
chainType={CHAIN_TYPE.SOLANA}
|
|
31
|
+
campaign={campaign}
|
|
32
32
|
/>
|
|
33
33
|
)
|
|
34
34
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CHAIN_TYPE,
|
|
3
|
+
getSolanaNetworkType,
|
|
3
4
|
SOLANA_CHAIN_INFO,
|
|
4
5
|
SolanaPoolInfo,
|
|
5
6
|
TrancheType,
|
|
@@ -27,6 +28,7 @@ export function ApproveLender({
|
|
|
27
28
|
seniorTrancheVault={poolInfo.seniorTrancheMint}
|
|
28
29
|
isUniTranche={isUniTranche}
|
|
29
30
|
chainType={CHAIN_TYPE.SOLANA}
|
|
31
|
+
networkType={getSolanaNetworkType(poolInfo.chainId)}
|
|
30
32
|
chainSpecificData={{
|
|
31
33
|
huma_program_id: solanaChainInfo.poolProgram,
|
|
32
34
|
pool_id: poolInfo.poolId,
|
|
@@ -3,12 +3,11 @@ import {
|
|
|
3
3
|
checkIsDev,
|
|
4
4
|
convertToShares,
|
|
5
5
|
getTokenAccounts,
|
|
6
|
+
NETWORK_TYPE,
|
|
6
7
|
SolanaPoolInfo,
|
|
7
8
|
SolanaTokenUtils,
|
|
8
9
|
TrancheType,
|
|
9
10
|
} from '@huma-finance/shared'
|
|
10
|
-
import React, { useCallback, useEffect, useState } from 'react'
|
|
11
|
-
|
|
12
11
|
import {
|
|
13
12
|
SolanaPoolState,
|
|
14
13
|
useHumaProgram,
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
} from '@solana/spl-token'
|
|
23
22
|
import { useWallet } from '@solana/wallet-adapter-react'
|
|
24
23
|
import { PublicKey, Transaction } from '@solana/web3.js'
|
|
24
|
+
import React, { useCallback, useEffect, useState } from 'react'
|
|
25
25
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
26
26
|
import { setPointsAccumulated, setStep } from '../../../store/widgets.reducers'
|
|
27
27
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
@@ -33,14 +33,14 @@ type Props = {
|
|
|
33
33
|
poolInfo: SolanaPoolInfo
|
|
34
34
|
poolState: SolanaPoolState
|
|
35
35
|
selectedTranche: TrancheType
|
|
36
|
-
|
|
36
|
+
networkType: NETWORK_TYPE
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export function Transfer({
|
|
40
40
|
poolInfo,
|
|
41
41
|
poolState,
|
|
42
42
|
selectedTranche,
|
|
43
|
-
|
|
43
|
+
networkType,
|
|
44
44
|
}: Props): React.ReactElement | null {
|
|
45
45
|
const isDev = checkIsDev()
|
|
46
46
|
const dispatch = useAppDispatch()
|
|
@@ -72,12 +72,12 @@ export function Transfer({
|
|
|
72
72
|
async (options?: { signature: string }) => {
|
|
73
73
|
if (publicKey && poolState.campaign && options?.signature) {
|
|
74
74
|
try {
|
|
75
|
-
const result = await CampaignService.
|
|
75
|
+
const result = await CampaignService.updateHumaAccountPoints(
|
|
76
76
|
publicKey.toString(),
|
|
77
77
|
options.signature,
|
|
78
78
|
poolInfo.chainId,
|
|
79
|
+
networkType,
|
|
79
80
|
isDev,
|
|
80
|
-
pointsTestnetExperience,
|
|
81
81
|
)
|
|
82
82
|
dispatch(setPointsAccumulated(result.pointsAccumulated))
|
|
83
83
|
} catch (error) {
|
|
@@ -89,7 +89,7 @@ export function Transfer({
|
|
|
89
89
|
[
|
|
90
90
|
dispatch,
|
|
91
91
|
isDev,
|
|
92
|
-
|
|
92
|
+
networkType,
|
|
93
93
|
poolInfo.chainId,
|
|
94
94
|
poolState.campaign,
|
|
95
95
|
publicKey,
|
|
@@ -5,19 +5,15 @@ import {
|
|
|
5
5
|
CloseModalOptions,
|
|
6
6
|
formatNumber,
|
|
7
7
|
isEmpty,
|
|
8
|
+
NETWORK_TYPE,
|
|
8
9
|
} from '@huma-finance/shared'
|
|
9
|
-
import {
|
|
10
|
-
SolanaPoolState,
|
|
11
|
-
txAtom,
|
|
12
|
-
useAuthErrorHandling,
|
|
13
|
-
useChainInfo,
|
|
14
|
-
} from '@huma-finance/web-shared'
|
|
10
|
+
import { SolanaPoolState, txAtom, useChainInfo } from '@huma-finance/web-shared'
|
|
15
11
|
import { Box, css, useTheme } from '@mui/material'
|
|
16
12
|
import { useResetAtom } from 'jotai/utils'
|
|
17
13
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
18
14
|
import { useDispatch } from 'react-redux'
|
|
19
15
|
|
|
20
|
-
import { resetState
|
|
16
|
+
import { resetState } from '../../../store/widgets.reducers'
|
|
21
17
|
import { BottomButton } from '../../BottomButton'
|
|
22
18
|
import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from '../../icons'
|
|
23
19
|
import { LoadingModal } from '../../LoadingModal'
|
|
@@ -29,20 +25,17 @@ enum STATE {
|
|
|
29
25
|
Congrats = 'Congrats',
|
|
30
26
|
}
|
|
31
27
|
|
|
32
|
-
const ERROR_MESSAGE =
|
|
33
|
-
'Failed to update wallet points. Be assured that your points will be added later.'
|
|
34
|
-
|
|
35
28
|
type Props = {
|
|
36
29
|
transactionHash: string
|
|
37
30
|
poolState: SolanaPoolState
|
|
38
|
-
|
|
31
|
+
networkType: NETWORK_TYPE
|
|
39
32
|
handleAction: (options?: CloseModalOptions) => void
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
export function PointsEarned({
|
|
43
36
|
transactionHash,
|
|
44
37
|
poolState,
|
|
45
|
-
|
|
38
|
+
networkType,
|
|
46
39
|
handleAction,
|
|
47
40
|
}: Props): React.ReactElement {
|
|
48
41
|
const theme = useTheme()
|
|
@@ -60,91 +53,26 @@ export function PointsEarned({
|
|
|
60
53
|
)
|
|
61
54
|
const monthText =
|
|
62
55
|
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
56
|
const [state, setState] = useState<STATE>(STATE.Loading)
|
|
72
57
|
|
|
73
58
|
useEffect(() => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setWalletOwnership(true)
|
|
82
|
-
}
|
|
83
|
-
}, [isWalletOwnershipVerified])
|
|
84
|
-
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
const checkWalletOwnership = async () => {
|
|
87
|
-
if (account) {
|
|
88
|
-
const ownership = await CampaignService.checkWalletOwnership(
|
|
89
|
-
account,
|
|
59
|
+
const updateWalletPoints = async () => {
|
|
60
|
+
try {
|
|
61
|
+
const result = await CampaignService.updateHumaAccountPoints(
|
|
62
|
+
account!,
|
|
63
|
+
transactionHash,
|
|
64
|
+
chainId!,
|
|
65
|
+
networkType,
|
|
90
66
|
isDev,
|
|
91
|
-
pointsTestnetExperience,
|
|
92
67
|
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
}
|
|
68
|
+
setPointsAccumulated(result.pointsAccumulated)
|
|
69
|
+
setState(STATE.Congrats)
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Failed to update wallet points', error)
|
|
136
72
|
}
|
|
137
73
|
}
|
|
138
74
|
updateWalletPoints()
|
|
139
|
-
}, [
|
|
140
|
-
account,
|
|
141
|
-
chainId,
|
|
142
|
-
dispatch,
|
|
143
|
-
isDev,
|
|
144
|
-
pointsTestnetExperience,
|
|
145
|
-
transactionHash,
|
|
146
|
-
walletOwnership,
|
|
147
|
-
])
|
|
75
|
+
}, [account, chainId, isDev, networkType, transactionHash])
|
|
148
76
|
|
|
149
77
|
const handleCloseModal = useCallback(() => {
|
|
150
78
|
reset()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CloseModalOptions,
|
|
3
|
+
getSolanaNetworkType,
|
|
3
4
|
SolanaPoolInfo,
|
|
4
5
|
TrancheType,
|
|
5
6
|
} from '@huma-finance/shared'
|
|
@@ -36,14 +37,12 @@ export interface Campaign {
|
|
|
36
37
|
* @typedef {Object} SolanaLendSupplyProps
|
|
37
38
|
* @property {SolanaPoolInfo} poolInfo The metadata of the pool.
|
|
38
39
|
* @property {SolanaPoolState} poolState The current state config of the pool.
|
|
39
|
-
* @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
|
|
40
40
|
* @property {function((CloseModalOptions|undefined)):void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
41
41
|
* @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
42
42
|
*/
|
|
43
43
|
export interface SolanaLendSupplyProps {
|
|
44
44
|
poolInfo: SolanaPoolInfo
|
|
45
45
|
poolState: SolanaPoolState
|
|
46
|
-
pointsTestnetExperience: boolean
|
|
47
46
|
handleClose: (options?: CloseModalOptions) => void
|
|
48
47
|
handleSuccess?: () => void
|
|
49
48
|
}
|
|
@@ -51,7 +50,6 @@ export interface SolanaLendSupplyProps {
|
|
|
51
50
|
export function SolanaLendSupply({
|
|
52
51
|
poolInfo,
|
|
53
52
|
poolState,
|
|
54
|
-
pointsTestnetExperience,
|
|
55
53
|
handleClose,
|
|
56
54
|
handleSuccess,
|
|
57
55
|
}: SolanaLendSupplyProps): React.ReactElement | null {
|
|
@@ -128,8 +126,8 @@ export function SolanaLendSupply({
|
|
|
128
126
|
{step === WIDGET_STEP.Evaluation && (
|
|
129
127
|
<Evaluation
|
|
130
128
|
poolInfo={poolInfo}
|
|
131
|
-
pointsTestnetExperience={pointsTestnetExperience}
|
|
132
129
|
campaign={poolState.campaign}
|
|
130
|
+
networkType={getSolanaNetworkType(poolInfo.chainId)}
|
|
133
131
|
handleClose={handleClose}
|
|
134
132
|
/>
|
|
135
133
|
)}
|
|
@@ -164,7 +162,7 @@ export function SolanaLendSupply({
|
|
|
164
162
|
poolInfo={poolInfo}
|
|
165
163
|
poolState={poolState}
|
|
166
164
|
selectedTranche={selectedTranche}
|
|
167
|
-
|
|
165
|
+
networkType={getSolanaNetworkType(poolInfo.chainId)}
|
|
168
166
|
/>
|
|
169
167
|
)}
|
|
170
168
|
{step === WIDGET_STEP.Done && (
|