@huma-finance/widgets 0.0.42-beta.76 → 0.0.42-beta.94
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 +92 -37
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +93 -38
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +11 -1
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +10 -1
- package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +1 -1
- package/src/components/SignIn.tsx +48 -0
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +10 -1
- package/src/hooks/useEA.ts +22 -7
- package/src/store/widgets.store.ts +1 -0
- package/src/utils/env.ts +3 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.42-beta.
|
|
3
|
+
"version": "0.0.42-beta.94+250029f",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,8 +30,8 @@
|
|
|
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.42-beta.
|
|
34
|
-
"@huma-finance/shared": "^0.0.42-beta.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.42-beta.94+250029f",
|
|
34
|
+
"@huma-finance/shared": "^0.0.42-beta.94+250029f",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
37
37
|
"@mui/styles": "^5.0.2",
|
|
@@ -194,5 +194,5 @@
|
|
|
194
194
|
"optionalDependencies": {
|
|
195
195
|
"encoding": "^0.1.13"
|
|
196
196
|
},
|
|
197
|
-
"gitHead": "
|
|
197
|
+
"gitHead": "250029fad7f3f01df9612e4674953c6478193acd"
|
|
198
198
|
}
|
|
@@ -9,6 +9,7 @@ import { setStep } from '../../../store/widgets.reducers'
|
|
|
9
9
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
10
10
|
import { CheckCircleIcon, CheckGreenIcon } from '../../icons'
|
|
11
11
|
import spinner from '../../icons/spinner.gif'
|
|
12
|
+
import { SignIn } from '../../SignIn'
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
14
15
|
poolInfo: PoolInfoType
|
|
@@ -20,7 +21,11 @@ export function Evaluation({
|
|
|
20
21
|
handleApprove,
|
|
21
22
|
}: Props): React.ReactElement {
|
|
22
23
|
const theme = useTheme()
|
|
23
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
checkingEA,
|
|
26
|
+
isWalletOwnershipVerificationRequired,
|
|
27
|
+
isWalletOwnershipVerified,
|
|
28
|
+
} = useEA()
|
|
24
29
|
const dispatch = useAppDispatch()
|
|
25
30
|
const { account, chainId } = useWeb3React()
|
|
26
31
|
const [status, setStatus] = useState<'checking' | 'success'>('checking')
|
|
@@ -47,6 +52,7 @@ export function Evaluation({
|
|
|
47
52
|
handleApprove,
|
|
48
53
|
poolInfo.assetAddress,
|
|
49
54
|
poolInfo.pool,
|
|
55
|
+
isWalletOwnershipVerified,
|
|
50
56
|
])
|
|
51
57
|
|
|
52
58
|
const styles = {
|
|
@@ -115,6 +121,10 @@ export function Evaluation({
|
|
|
115
121
|
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
116
122
|
}
|
|
117
123
|
|
|
124
|
+
if (isWalletOwnershipVerificationRequired) {
|
|
125
|
+
return <SignIn />
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
return (
|
|
119
129
|
<Box css={styles.wrapper}>
|
|
120
130
|
<Typography variant='h6' css={styles.header}>
|
|
@@ -5,6 +5,7 @@ import React, { useEffect } from 'react'
|
|
|
5
5
|
import useEA from '../../../hooks/useEA'
|
|
6
6
|
import { LoadingModal } from '../../LoadingModal'
|
|
7
7
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
8
|
+
import { SignIn } from '../../SignIn'
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
poolInfo: PoolInfoType
|
|
@@ -12,7 +13,11 @@ type Props = {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function Evaluation({ poolInfo, tokenId }: Props): React.ReactElement {
|
|
15
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
checkingEA,
|
|
18
|
+
isWalletOwnershipVerificationRequired,
|
|
19
|
+
isWalletOwnershipVerified,
|
|
20
|
+
} = useEA()
|
|
16
21
|
const { account, chainId } = useWeb3React()
|
|
17
22
|
|
|
18
23
|
useEffect(() => {
|
|
@@ -38,8 +43,12 @@ export function Evaluation({ poolInfo, tokenId }: Props): React.ReactElement {
|
|
|
38
43
|
poolInfo.assetAddress,
|
|
39
44
|
poolInfo.pool,
|
|
40
45
|
tokenId,
|
|
46
|
+
isWalletOwnershipVerified,
|
|
41
47
|
])
|
|
42
48
|
|
|
49
|
+
if (isWalletOwnershipVerificationRequired) {
|
|
50
|
+
return <SignIn />
|
|
51
|
+
}
|
|
43
52
|
return (
|
|
44
53
|
<LoadingModal
|
|
45
54
|
title='Checking Invoice'
|
|
@@ -88,7 +88,7 @@ export function EvaluationKYC({
|
|
|
88
88
|
const { account, chainId } = useWeb3React()
|
|
89
89
|
const { kycProvider, code, kycPool } = useParamsSearch()
|
|
90
90
|
const { isWalletOwnershipVerified, setError: setAuthError } =
|
|
91
|
-
useAuthErrorHandling(
|
|
91
|
+
useAuthErrorHandling(isDev)
|
|
92
92
|
const [loadingType, setLoadingType] = useState<
|
|
93
93
|
'verificationStatus' | 'sendDocSignatureLink'
|
|
94
94
|
>()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Box, css, Typography, useTheme } from '@mui/material'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { ApproveLenderImg } from './images'
|
|
4
|
+
|
|
5
|
+
export function SignIn(): React.ReactElement {
|
|
6
|
+
const theme = useTheme()
|
|
7
|
+
const styles = {
|
|
8
|
+
wrapper: css`
|
|
9
|
+
height: 518px;
|
|
10
|
+
position: relative;
|
|
11
|
+
`,
|
|
12
|
+
header: css`
|
|
13
|
+
${theme.cssMixins.rowHCentered};
|
|
14
|
+
margin-top: -5px;
|
|
15
|
+
`,
|
|
16
|
+
icon: css`
|
|
17
|
+
${theme.cssMixins.rowHCentered};
|
|
18
|
+
margin-top: 100px;
|
|
19
|
+
margin-right: 30px;
|
|
20
|
+
& > img {
|
|
21
|
+
width: 170px;
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
content: css`
|
|
25
|
+
${theme.cssMixins.rowHCentered};
|
|
26
|
+
margin-top: 30px;
|
|
27
|
+
font-family: 'Uni-Neue-Regular';
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
line-height: 24px;
|
|
30
|
+
color: #49505b;
|
|
31
|
+
margin-bottom: 65px;
|
|
32
|
+
`,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Box css={styles.wrapper}>
|
|
37
|
+
<Typography variant='h6' css={styles.header}>
|
|
38
|
+
Sign In
|
|
39
|
+
</Typography>
|
|
40
|
+
<Box css={styles.icon}>
|
|
41
|
+
<img src={ApproveLenderImg} alt='approve-lender' />
|
|
42
|
+
</Box>
|
|
43
|
+
<Box css={styles.content}>
|
|
44
|
+
Please sign in to verify your ownership of the wallet.
|
|
45
|
+
</Box>
|
|
46
|
+
</Box>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -5,6 +5,7 @@ import React, { useEffect } from 'react'
|
|
|
5
5
|
import useEA from '../../../hooks/useEA'
|
|
6
6
|
import { LoadingModal } from '../../LoadingModal'
|
|
7
7
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
8
|
+
import { SignIn } from '../../SignIn'
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
poolInfo: PoolInfoType
|
|
@@ -17,8 +18,12 @@ export function Evaluation({
|
|
|
17
18
|
payerAddress,
|
|
18
19
|
superToken,
|
|
19
20
|
}: Props): React.ReactElement {
|
|
21
|
+
const {
|
|
22
|
+
checkingEA,
|
|
23
|
+
isWalletOwnershipVerificationRequired,
|
|
24
|
+
isWalletOwnershipVerified,
|
|
25
|
+
} = useEA()
|
|
20
26
|
const { account } = useWeb3React()
|
|
21
|
-
const { checkingEA } = useEA()
|
|
22
27
|
|
|
23
28
|
useEffect(() => {
|
|
24
29
|
if (account) {
|
|
@@ -44,8 +49,12 @@ export function Evaluation({
|
|
|
44
49
|
poolInfo.assetAddress,
|
|
45
50
|
poolInfo.pool,
|
|
46
51
|
superToken,
|
|
52
|
+
isWalletOwnershipVerified,
|
|
47
53
|
])
|
|
48
54
|
|
|
55
|
+
if (isWalletOwnershipVerificationRequired) {
|
|
56
|
+
return <SignIn />
|
|
57
|
+
}
|
|
49
58
|
return (
|
|
50
59
|
<LoadingModal
|
|
51
60
|
title='Checking Stream'
|
package/src/hooks/useEA.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
EARejectMessage,
|
|
5
5
|
EARejectReason,
|
|
6
6
|
EAService,
|
|
7
|
+
useAuthErrorHandling,
|
|
7
8
|
} from '@huma-finance/shared'
|
|
8
9
|
import { useWeb3React } from '@web3-react/core'
|
|
9
10
|
import { useCallback } from 'react'
|
|
@@ -16,6 +17,11 @@ import { useAppDispatch } from './useRedux'
|
|
|
16
17
|
const useEA = () => {
|
|
17
18
|
const dispatch = useAppDispatch()
|
|
18
19
|
const { chainId } = useWeb3React()
|
|
20
|
+
const {
|
|
21
|
+
isWalletOwnershipVerificationRequired,
|
|
22
|
+
isWalletOwnershipVerified,
|
|
23
|
+
setError: setAuthError,
|
|
24
|
+
} = useAuthErrorHandling(envUtil.checkIsDev())
|
|
19
25
|
|
|
20
26
|
const checkingEA = useCallback(
|
|
21
27
|
async (payload: EAPayload, nextStep: WIDGET_STEP) => {
|
|
@@ -36,18 +42,27 @@ const useEA = () => {
|
|
|
36
42
|
}),
|
|
37
43
|
)
|
|
38
44
|
} else {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
try {
|
|
46
|
+
setAuthError(e)
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
} catch (e: any) {
|
|
49
|
+
dispatch(
|
|
50
|
+
setError({
|
|
51
|
+
errorMessage: e.message,
|
|
52
|
+
}),
|
|
53
|
+
)
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
},
|
|
47
|
-
[chainId, dispatch],
|
|
58
|
+
[chainId, dispatch, setAuthError],
|
|
48
59
|
)
|
|
49
60
|
|
|
50
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
checkingEA,
|
|
63
|
+
isWalletOwnershipVerificationRequired,
|
|
64
|
+
isWalletOwnershipVerified,
|
|
65
|
+
}
|
|
51
66
|
}
|
|
52
67
|
|
|
53
68
|
export default useEA
|
package/src/utils/env.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const checkIsDev = () =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
process.env.NODE_ENV === 'development'
|
|
6
|
-
)
|
|
2
|
+
window.location.hostname.startsWith('dev') ||
|
|
3
|
+
window.location.hostname.startsWith('deploy-preview') ||
|
|
4
|
+
process.env.NODE_ENV === 'development'
|
|
7
5
|
|
|
8
6
|
export const envUtil = {
|
|
9
7
|
checkIsDev,
|