@huma-finance/widgets 0.0.12 → 0.0.15
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 +6 -5
- package/dist/cjs/index.cjs +5058 -5968
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +5059 -5969
- package/dist/index.js.map +1 -1
- package/package.json +16 -16
- package/src/components/ApproveAllowanceModal.tsx +5 -2
- package/src/components/ChainNotSupportedModal.tsx +33 -0
- package/src/components/ChooseAmountModal.tsx +322 -322
- package/src/components/ConfirmTransferModal.tsx +153 -0
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -2
- package/src/components/CreditLine/borrow/index.tsx +4 -6
- package/src/components/Factoring/FactoredList.tsx +1 -1
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -4
- package/src/components/InvoiceFactoring/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +5 -3
- package/src/components/InvoiceFactoring/borrow/3-ConfirmTransfer.tsx +37 -0
- package/src/components/InvoiceFactoring/borrow/index.tsx +5 -7
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +12 -4
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +4 -1
- package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +18 -80
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +4 -36
- package/src/components/StreamFactoring/borrow/5-Permit.tsx +14 -14
- package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +10 -1
- package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +4 -22
- package/src/cosmos/CreditLineBorrow.fixture.tsx +1 -0
- package/src/cosmos/CreditLinePayment.fixture.tsx +1 -0
- package/src/cosmos/SDKTesting.fixture.tsx +615 -615
- package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +3 -0
- package/src/cosmos/utils/env.ts +6 -0
- package/src/hooks/useEA.ts +10 -29
- package/src/index.tsx +88 -7
- package/src/reportWebVitals.ts +9 -9
- package/src/store/widgets.store.ts +0 -1
- package/src/utilTypes.d.ts +2 -0
- package/webpack.cosmos.js +9 -9
- package/src/components/AllowListModal.tsx +0 -113
- package/src/components/CreditLine/borrow/2-AllowList.tsx +0 -34
- package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +0 -34
- package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +0 -104
- /package/src/components/CreditLine/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +0 -0
- /package/src/components/CreditLine/borrow/{4-Transfer.tsx → 3-Transfer.tsx} +0 -0
- /package/src/components/CreditLine/borrow/{5-ApproveAllowance.tsx → 4-ApproveAllowance.tsx} +0 -0
- /package/src/components/CreditLine/borrow/{6-Success.tsx → 5-Success.tsx} +0 -0
- /package/src/components/InvoiceFactoring/borrow/{5-ApproveNFT.tsx → 4-ApproveNFT.tsx} +0 -0
- /package/src/components/InvoiceFactoring/borrow/{6-Transfer.tsx → 5-Transfer.tsx} +0 -0
- /package/src/components/InvoiceFactoring/borrow/{7-Success.tsx → 6-Success.tsx} +0 -0
package/src/hooks/useEA.ts
CHANGED
|
@@ -1,59 +1,40 @@
|
|
|
1
|
-
import { useWeb3React } from '@web3-react/core'
|
|
2
1
|
import {
|
|
3
|
-
downScale,
|
|
4
2
|
EAPayload,
|
|
5
3
|
EARejectionError,
|
|
6
4
|
EARejectMessage,
|
|
7
5
|
EARejectReason,
|
|
8
6
|
EAService,
|
|
9
7
|
} from '@huma-finance/shared'
|
|
8
|
+
import { useWeb3React } from '@web3-react/core'
|
|
10
9
|
import { useCallback } from 'react'
|
|
11
10
|
|
|
12
|
-
import { setApproval, setError
|
|
11
|
+
import { setApproval, setError } from '../store/widgets.reducers'
|
|
13
12
|
import { WIDGET_STEP } from '../store/widgets.store'
|
|
14
|
-
import { useAppDispatch } from './useRedux'
|
|
15
13
|
import { envUtil } from '../utils/env'
|
|
14
|
+
import { useAppDispatch } from './useRedux'
|
|
16
15
|
|
|
17
16
|
const useEA = () => {
|
|
18
17
|
const dispatch = useAppDispatch()
|
|
19
18
|
const { chainId } = useWeb3React()
|
|
20
19
|
|
|
21
20
|
const checkingEA = useCallback(
|
|
22
|
-
async (
|
|
23
|
-
payload: EAPayload,
|
|
24
|
-
nextStep: WIDGET_STEP,
|
|
25
|
-
addToAllowList = false,
|
|
26
|
-
) => {
|
|
21
|
+
async (payload: EAPayload, nextStep: WIDGET_STEP) => {
|
|
27
22
|
try {
|
|
28
23
|
const result = await EAService.approve(
|
|
29
24
|
payload,
|
|
30
25
|
chainId!,
|
|
31
26
|
envUtil.checkIsDev(),
|
|
32
27
|
)
|
|
33
|
-
result.terms.creditLimit = downScale<number>(
|
|
34
|
-
result.terms.creditLimit,
|
|
35
|
-
result.token.decimal,
|
|
36
|
-
)
|
|
37
|
-
if (result.receivable) {
|
|
38
|
-
result.receivable.amount = downScale<number>(
|
|
39
|
-
result.receivable.amount,
|
|
40
|
-
result.token.decimal,
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
28
|
dispatch(setApproval({ ...result, nextStep }))
|
|
44
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
30
|
} catch (e: any) {
|
|
46
31
|
if (e instanceof EARejectionError) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
errorReason: EARejectReason,
|
|
54
|
-
}),
|
|
55
|
-
)
|
|
56
|
-
}
|
|
32
|
+
dispatch(
|
|
33
|
+
setError({
|
|
34
|
+
errorMessage: EARejectMessage,
|
|
35
|
+
errorReason: EARejectReason,
|
|
36
|
+
}),
|
|
37
|
+
)
|
|
57
38
|
} else {
|
|
58
39
|
dispatch(
|
|
59
40
|
setError({
|
package/src/index.tsx
CHANGED
|
@@ -4,12 +4,15 @@ import { JsonRpcProvider } from '@ethersproject/providers'
|
|
|
4
4
|
import {
|
|
5
5
|
Provider as Web3Provider,
|
|
6
6
|
ProviderProps as Web3Props,
|
|
7
|
+
supportedChainId,
|
|
7
8
|
} from '@huma-finance/shared'
|
|
8
9
|
import { ThemeProvider } from '@mui/material'
|
|
9
10
|
import { Provider as Eip1193Provider } from '@web3-react/types'
|
|
10
11
|
import { Provider as AtomProvider } from 'jotai'
|
|
12
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
11
13
|
import { Provider as ReduxProvider } from 'react-redux'
|
|
12
14
|
|
|
15
|
+
import { ChainNotSupportedModal } from './components/ChainNotSupportedModal'
|
|
13
16
|
import {
|
|
14
17
|
CreditLineBorrow,
|
|
15
18
|
CreditLineBorrowProps,
|
|
@@ -45,16 +48,94 @@ type JsonRpcConnectionMap = {
|
|
|
45
48
|
/**
|
|
46
49
|
* Object representing the props passed to web3 provider
|
|
47
50
|
* @typedef {Object} WidgetProps
|
|
51
|
+
* @property {desiredChainId|undefined} desiredChainId Optional desired chain id, will trigger the switch network action if different from the current chain id
|
|
48
52
|
* @property {JsonRpcConnectionMap|undefined} jsonRpcUrlMap Optional mapping of your JSON-RPC connections indexed by chainId
|
|
49
53
|
* @property {Eip1193Provider|JsonRpcProvider|null|undefined} provider Optional EIP-1193 provider or JsonRpc Provider
|
|
50
54
|
*/
|
|
51
55
|
type WidgetProps = {
|
|
56
|
+
handleClose?: () => void
|
|
57
|
+
desiredChainId?: number
|
|
52
58
|
jsonRpcUrlMap?: JsonRpcConnectionMap
|
|
53
59
|
provider?: Eip1193Provider | JsonRpcProvider | null
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
function Widget(props: WCProps<WidgetProps>) {
|
|
57
|
-
const { children } = props
|
|
63
|
+
const { children, desiredChainId } = props
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
const netWorkVersion = window.ethereum?.networkVersion
|
|
66
|
+
const [currentChainId, setCurrentChainId] = useState<number | undefined>(
|
|
67
|
+
netWorkVersion ? Number(netWorkVersion) : undefined,
|
|
68
|
+
)
|
|
69
|
+
const chainSupported = !!supportedChainId(currentChainId)
|
|
70
|
+
const [chainNotSupportedOpen, setChainNotSupportedOpen] = useState(false)
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setCurrentChainId(netWorkVersion ? Number(netWorkVersion) : undefined)
|
|
74
|
+
}, [netWorkVersion])
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (chainSupported) {
|
|
78
|
+
setChainNotSupportedOpen(false)
|
|
79
|
+
} else {
|
|
80
|
+
setChainNotSupportedOpen(true)
|
|
81
|
+
}
|
|
82
|
+
}, [chainSupported])
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const chainChangeListener = (chainId: number) => {
|
|
86
|
+
setCurrentChainId(chainId)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (window.ethereum) {
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
window.ethereum?.on('chainChanged', chainChangeListener)
|
|
92
|
+
}
|
|
93
|
+
return () => {
|
|
94
|
+
if (window.ethereum) {
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
window.ethereum?.removeListener('chainChanged', chainChangeListener)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, [])
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (
|
|
103
|
+
window.ethereum &&
|
|
104
|
+
desiredChainId &&
|
|
105
|
+
currentChainId !== desiredChainId
|
|
106
|
+
) {
|
|
107
|
+
const changeNetwork = async () => {
|
|
108
|
+
try {
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
await window.ethereum.request({
|
|
111
|
+
method: 'wallet_switchEthereumChain',
|
|
112
|
+
params: [{ chainId: `0x${Number(desiredChainId).toString(16)}` }],
|
|
113
|
+
})
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error(error)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
changeNetwork()
|
|
119
|
+
}
|
|
120
|
+
}, [currentChainId, desiredChainId])
|
|
121
|
+
|
|
122
|
+
const handleCloseCallback = useCallback(() => {
|
|
123
|
+
setChainNotSupportedOpen(false)
|
|
124
|
+
}, [])
|
|
125
|
+
|
|
126
|
+
if (!chainSupported) {
|
|
127
|
+
return (
|
|
128
|
+
<ThemeProvider theme={themeHuma}>
|
|
129
|
+
<ReduxProvider store={store}>
|
|
130
|
+
<ChainNotSupportedModal
|
|
131
|
+
isOpen={chainNotSupportedOpen}
|
|
132
|
+
handleClose={handleCloseCallback}
|
|
133
|
+
/>
|
|
134
|
+
</ReduxProvider>
|
|
135
|
+
</ThemeProvider>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
58
139
|
return (
|
|
59
140
|
<ThemeProvider theme={themeHuma}>
|
|
60
141
|
<ReduxProvider store={store}>
|
|
@@ -78,7 +159,7 @@ type InvoiceFactoringBorrowWidgetProps = InvoiceFactoringBorrowProps &
|
|
|
78
159
|
/**
|
|
79
160
|
* Invoice factoring borrow widget
|
|
80
161
|
*
|
|
81
|
-
* @param {
|
|
162
|
+
* @param {InvoiceFactoringBorrowProps | WidgetProps} props - The invoice factoring pool borrow widget props.
|
|
82
163
|
* @returns Invoice factoring pool borrow widget component
|
|
83
164
|
*/
|
|
84
165
|
export function InvoiceFactoringBorrowWidget(
|
|
@@ -103,7 +184,7 @@ type InvoiceFactoringPaymentWidgetProps = InvoiceFactoringPaymentProps &
|
|
|
103
184
|
/**
|
|
104
185
|
* Invoice factoring payment widget
|
|
105
186
|
*
|
|
106
|
-
* @param {
|
|
187
|
+
* @param {InvoiceFactoringPaymentProps | WidgetProps} props - The invoice factoring pool payment widget props.
|
|
107
188
|
* @returns Invoice factoring pool payment widget component
|
|
108
189
|
*/
|
|
109
190
|
export function InvoiceFactoringPaymentWidget(
|
|
@@ -127,7 +208,7 @@ type CreditLineBorrowWidgetProps = CreditLineBorrowProps & WidgetProps
|
|
|
127
208
|
/**
|
|
128
209
|
* Credit line borrow widget
|
|
129
210
|
*
|
|
130
|
-
* @param {
|
|
211
|
+
* @param {CreditLineBorrowProps | WidgetProps} props - The credit line pool borrow widget props.
|
|
131
212
|
* @returns Credit line pool borrow widget component
|
|
132
213
|
*/
|
|
133
214
|
export function CreditLineBorrowWidget(props: CreditLineBorrowWidgetProps) {
|
|
@@ -149,7 +230,7 @@ type CreditLinePaymentWidgetProps = CreditLinePaymentProps & WidgetProps
|
|
|
149
230
|
/**
|
|
150
231
|
* Credit line payment widget
|
|
151
232
|
*
|
|
152
|
-
* @param {
|
|
233
|
+
* @param {CreditLinePaymentProps | WidgetProps} props - The credit line pool payment widget props.
|
|
153
234
|
* @returns Credit line pool payment widget component
|
|
154
235
|
*/
|
|
155
236
|
export function CreditLinePaymentWidget(props: CreditLinePaymentWidgetProps) {
|
|
@@ -171,7 +252,7 @@ type LendSupplyWidgetProps = LendSupplyProps & WidgetProps
|
|
|
171
252
|
/**
|
|
172
253
|
* Lend supply widget
|
|
173
254
|
*
|
|
174
|
-
* @param {
|
|
255
|
+
* @param {LendSupplyProps | WidgetProps} props - The lend pool supply widget props.
|
|
175
256
|
* @returns Lend pool supply widget component
|
|
176
257
|
*/
|
|
177
258
|
export function LendSupplyWidget(props: LendSupplyWidgetProps) {
|
|
@@ -193,7 +274,7 @@ type LendWithdrawWidgetProps = LendWithdrawProps & WidgetProps
|
|
|
193
274
|
/**
|
|
194
275
|
* Lend withdraw widget
|
|
195
276
|
*
|
|
196
|
-
* @param {LendWithdrawProps
|
|
277
|
+
* @param {LendWithdrawProps | WidgetProps} props The lend pool withdraw widget props
|
|
197
278
|
* @returns Lend pool withdraw widget component
|
|
198
279
|
*/
|
|
199
280
|
export function LendWithdrawWidget(props: LendWithdrawWidgetProps) {
|
package/src/reportWebVitals.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { ReportHandler } from 'web-vitals'
|
|
1
|
+
import { ReportHandler } from 'web-vitals'
|
|
2
2
|
|
|
3
3
|
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
4
|
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
5
|
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
-
getCLS(onPerfEntry)
|
|
7
|
-
getFID(onPerfEntry)
|
|
8
|
-
getFCP(onPerfEntry)
|
|
9
|
-
getLCP(onPerfEntry)
|
|
10
|
-
getTTFB(onPerfEntry)
|
|
11
|
-
})
|
|
6
|
+
getCLS(onPerfEntry)
|
|
7
|
+
getFID(onPerfEntry)
|
|
8
|
+
getFCP(onPerfEntry)
|
|
9
|
+
getLCP(onPerfEntry)
|
|
10
|
+
getTTFB(onPerfEntry)
|
|
11
|
+
})
|
|
12
12
|
}
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
export default reportWebVitals
|
|
15
|
+
export default reportWebVitals
|
package/src/utilTypes.d.ts
CHANGED
package/webpack.cosmos.js
CHANGED
|
@@ -40,15 +40,15 @@ module.exports = (webpackConfig) => {
|
|
|
40
40
|
new webpack.ProvidePlugin({
|
|
41
41
|
Buffer: ['buffer', 'Buffer'],
|
|
42
42
|
}),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
new webpack.DefinePlugin({
|
|
44
|
+
...Object.entries(dotenv.config().parsed).reduce(
|
|
45
|
+
(acc, curr) => ({
|
|
46
|
+
...acc,
|
|
47
|
+
[`process.env.${curr[0]}`]: JSON.stringify(curr[1]),
|
|
48
|
+
}),
|
|
49
|
+
{},
|
|
50
|
+
),
|
|
51
|
+
}),
|
|
52
52
|
],
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Box, Button, css, useTheme } from '@mui/material'
|
|
2
|
-
import { useWeb3React } from '@web3-react/core'
|
|
3
|
-
import {
|
|
4
|
-
EARejectMessageWithAllowList,
|
|
5
|
-
EARejectReason,
|
|
6
|
-
EAService,
|
|
7
|
-
PoolInfoType,
|
|
8
|
-
} from '@huma-finance/shared'
|
|
9
|
-
import React, { useCallback, useState } from 'react'
|
|
10
|
-
|
|
11
|
-
import { CustomError } from '../utilTypes'
|
|
12
|
-
import { ErrorModal } from './ErrorModal'
|
|
13
|
-
import { CheckCircleIcon } from './icons'
|
|
14
|
-
import { LoadingModal } from './LoadingModal'
|
|
15
|
-
import { WrapperModal } from './WrapperModal'
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
poolInfo: PoolInfoType
|
|
19
|
-
handleSuccess: () => void
|
|
20
|
-
handleError: (errorMessage: string) => void
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function AllowListModal({
|
|
24
|
-
poolInfo,
|
|
25
|
-
handleSuccess,
|
|
26
|
-
handleError,
|
|
27
|
-
}: Props): React.ReactElement | null {
|
|
28
|
-
const theme = useTheme()
|
|
29
|
-
const { account } = useWeb3React()
|
|
30
|
-
const [status, setStatus] = useState<
|
|
31
|
-
'notApproved' | 'approving' | 'approved'
|
|
32
|
-
>('notApproved')
|
|
33
|
-
|
|
34
|
-
const styles = {
|
|
35
|
-
congratsWrapper: css`
|
|
36
|
-
font-family: 'Uni-Neue-Regular';
|
|
37
|
-
font-size: 16px;
|
|
38
|
-
padding: 0 16px;
|
|
39
|
-
${theme.cssMixins.rowVCentered}
|
|
40
|
-
margin-top: 60px;
|
|
41
|
-
height: 52px;
|
|
42
|
-
background: linear-gradient(
|
|
43
|
-
0deg,
|
|
44
|
-
rgba(255, 255, 255, 0.9),
|
|
45
|
-
rgba(255, 255, 255, 0.9)
|
|
46
|
-
),
|
|
47
|
-
#2e7d32;
|
|
48
|
-
border-radius: 4px;
|
|
49
|
-
`,
|
|
50
|
-
bottom: css`
|
|
51
|
-
& .MuiButtonBase-root {
|
|
52
|
-
width: 100%;
|
|
53
|
-
position: absolute;
|
|
54
|
-
bottom: 0;
|
|
55
|
-
}
|
|
56
|
-
`,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const addToAllowList = useCallback(async () => {
|
|
60
|
-
try {
|
|
61
|
-
setStatus('approving')
|
|
62
|
-
await EAService.addToAllowList(account!, poolInfo.pool)
|
|
63
|
-
setStatus('approved')
|
|
64
|
-
} catch (e) {
|
|
65
|
-
const error = e as CustomError
|
|
66
|
-
handleError(error.message)
|
|
67
|
-
}
|
|
68
|
-
}, [account, handleError, poolInfo.pool])
|
|
69
|
-
|
|
70
|
-
const continueToBorrow = () => {
|
|
71
|
-
handleSuccess()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (status === 'approving') {
|
|
75
|
-
return (
|
|
76
|
-
<LoadingModal
|
|
77
|
-
title='Add To Allowlist'
|
|
78
|
-
description='Waiting for approval confirmation...'
|
|
79
|
-
/>
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (status === 'approved') {
|
|
84
|
-
return (
|
|
85
|
-
<WrapperModal title='Add To Allowlist'>
|
|
86
|
-
<>
|
|
87
|
-
<Box css={styles.congratsWrapper}>
|
|
88
|
-
<CheckCircleIcon />
|
|
89
|
-
<Box sx={{ marginLeft: '6px' }}>
|
|
90
|
-
Congrats, you have been added to the allowlist
|
|
91
|
-
</Box>
|
|
92
|
-
</Box>
|
|
93
|
-
<Box css={styles.bottom}>
|
|
94
|
-
<Button variant='contained' onClick={continueToBorrow}>
|
|
95
|
-
CONTINUE TO BORROW
|
|
96
|
-
</Button>
|
|
97
|
-
</Box>
|
|
98
|
-
</>
|
|
99
|
-
</WrapperModal>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<ErrorModal
|
|
105
|
-
title='Application Not Approved'
|
|
106
|
-
errorReason={EARejectReason}
|
|
107
|
-
errorMessage={EARejectMessageWithAllowList}
|
|
108
|
-
handleOk={addToAllowList}
|
|
109
|
-
okText='ADD ME TO ALLOWLIST'
|
|
110
|
-
shouldResetState={false}
|
|
111
|
-
/>
|
|
112
|
-
)
|
|
113
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PoolInfoType } from '@huma-finance/shared'
|
|
2
|
-
import React, { useCallback } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
5
|
-
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
6
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
7
|
-
import { AllowListModal } from '../../AllowListModal'
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
poolInfo: PoolInfoType
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function AllowList({ poolInfo }: Props): React.ReactElement | null {
|
|
14
|
-
const dispatch = useAppDispatch()
|
|
15
|
-
|
|
16
|
-
const handleSuccess = useCallback(() => {
|
|
17
|
-
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
18
|
-
}, [dispatch])
|
|
19
|
-
|
|
20
|
-
const handleError = useCallback(
|
|
21
|
-
(errorMessage: string) => {
|
|
22
|
-
dispatch(setError({ errorMessage }))
|
|
23
|
-
},
|
|
24
|
-
[dispatch],
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<AllowListModal
|
|
29
|
-
poolInfo={poolInfo}
|
|
30
|
-
handleSuccess={handleSuccess}
|
|
31
|
-
handleError={handleError}
|
|
32
|
-
/>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PoolInfoType } from '@huma-finance/shared'
|
|
2
|
-
import React, { useCallback } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
5
|
-
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
6
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
7
|
-
import { AllowListModal } from '../../AllowListModal'
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
poolInfo: PoolInfoType
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function AllowList({ poolInfo }: Props): React.ReactElement | null {
|
|
14
|
-
const dispatch = useAppDispatch()
|
|
15
|
-
|
|
16
|
-
const handleSuccess = useCallback(() => {
|
|
17
|
-
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
18
|
-
}, [dispatch])
|
|
19
|
-
|
|
20
|
-
const handleError = useCallback(
|
|
21
|
-
(errorMessage: string) => {
|
|
22
|
-
dispatch(setError({ errorMessage }))
|
|
23
|
-
},
|
|
24
|
-
[dispatch],
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<AllowListModal
|
|
29
|
-
poolInfo={poolInfo}
|
|
30
|
-
handleSuccess={handleSuccess}
|
|
31
|
-
handleError={handleError}
|
|
32
|
-
/>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
|
|
2
|
-
import { Box, Button, css, Typography, useTheme } from '@mui/material'
|
|
3
|
-
import { isEmpty } from '@huma-finance/shared'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
7
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
8
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
9
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
10
|
-
|
|
11
|
-
export function ConfirmTransfer(): React.ReactElement | null {
|
|
12
|
-
const theme = useTheme()
|
|
13
|
-
const dispatch = useAppDispatch()
|
|
14
|
-
const { borrowAmountNet, approval } = useAppSelector(selectWidgetState)
|
|
15
|
-
|
|
16
|
-
const styles = {
|
|
17
|
-
wrapper: css`
|
|
18
|
-
height: 518px;
|
|
19
|
-
position: relative;
|
|
20
|
-
${theme.cssMixins.colStretch};
|
|
21
|
-
`,
|
|
22
|
-
header: css`
|
|
23
|
-
font-family: 'Uni-Neue-Bold';
|
|
24
|
-
${theme.cssMixins.rowHCentered};
|
|
25
|
-
margin-top: -5px;
|
|
26
|
-
`,
|
|
27
|
-
description: css`
|
|
28
|
-
font-family: 'Uni-Neue-Regular';
|
|
29
|
-
font-weight: 500;
|
|
30
|
-
font-size: 16px;
|
|
31
|
-
color: #49505b;
|
|
32
|
-
margin-top: 30px;
|
|
33
|
-
text-align: center;
|
|
34
|
-
`,
|
|
35
|
-
transferWrapper: css`
|
|
36
|
-
margin-top: 75px;
|
|
37
|
-
`,
|
|
38
|
-
transfer: css`
|
|
39
|
-
font-family: 'Uni-Neue-Regular';
|
|
40
|
-
${theme.cssMixins.rowSpaceBetweened}
|
|
41
|
-
${theme.cssMixins.rowVCentered}
|
|
42
|
-
height: 72px;
|
|
43
|
-
background: #f9f8fa;
|
|
44
|
-
border-radius: 4px;
|
|
45
|
-
font-weight: 500;
|
|
46
|
-
font-size: 16px;
|
|
47
|
-
color: #49505b;
|
|
48
|
-
padding: 24px 32px;
|
|
49
|
-
margin-bottom: 9px;
|
|
50
|
-
position: relative;
|
|
51
|
-
box-sizing: border-box;
|
|
52
|
-
`,
|
|
53
|
-
arrow: css`
|
|
54
|
-
color: #d2d0d6;
|
|
55
|
-
position: absolute;
|
|
56
|
-
margin: auto;
|
|
57
|
-
top: 0;
|
|
58
|
-
left: 0;
|
|
59
|
-
bottom: 0;
|
|
60
|
-
right: 0;
|
|
61
|
-
`,
|
|
62
|
-
okButton: css`
|
|
63
|
-
width: 100%;
|
|
64
|
-
position: absolute;
|
|
65
|
-
bottom: 0;
|
|
66
|
-
`,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const handleAction = () => {
|
|
70
|
-
dispatch(setStep(WIDGET_STEP.ApproveNFT))
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (isEmpty(borrowAmountNet) || isEmpty(approval)) {
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Box css={styles.wrapper}>
|
|
79
|
-
<Typography variant='h6' css={styles.header}>
|
|
80
|
-
Confirm transaction details
|
|
81
|
-
</Typography>
|
|
82
|
-
<Box css={styles.description}>
|
|
83
|
-
Huma keeps your Invoice NFT as collateral until it's fully paid.
|
|
84
|
-
</Box>
|
|
85
|
-
<Box css={styles.transferWrapper}>
|
|
86
|
-
<Box css={styles.transfer}>
|
|
87
|
-
<Box>Invoice NFT</Box>
|
|
88
|
-
<ArrowForwardIosIcon css={styles.arrow} />
|
|
89
|
-
<Box>Huma</Box>
|
|
90
|
-
</Box>
|
|
91
|
-
<Box css={styles.transfer}>
|
|
92
|
-
<Box>
|
|
93
|
-
{borrowAmountNet!} {approval?.token.symbol}
|
|
94
|
-
</Box>
|
|
95
|
-
<ArrowForwardIosIcon css={styles.arrow} />
|
|
96
|
-
<Box>You</Box>
|
|
97
|
-
</Box>
|
|
98
|
-
</Box>
|
|
99
|
-
<Button variant='contained' css={styles.okButton} onClick={handleAction}>
|
|
100
|
-
Approve Transfer
|
|
101
|
-
</Button>
|
|
102
|
-
</Box>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|