@huma-finance/widgets 0.0.12 → 0.0.13

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.
Files changed (46) hide show
  1. package/API.md +6 -5
  2. package/dist/cjs/index.cjs +5058 -5968
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.d.ts +9 -6
  5. package/dist/index.js +5059 -5969
  6. package/dist/index.js.map +1 -1
  7. package/package.json +16 -16
  8. package/src/components/ApproveAllowanceModal.tsx +5 -2
  9. package/src/components/ChainNotSupportedModal.tsx +31 -0
  10. package/src/components/ChooseAmountModal.tsx +322 -322
  11. package/src/components/ConfirmTransferModal.tsx +153 -0
  12. package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -2
  13. package/src/components/CreditLine/borrow/index.tsx +4 -6
  14. package/src/components/Factoring/FactoredList.tsx +1 -1
  15. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -4
  16. package/src/components/InvoiceFactoring/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +5 -3
  17. package/src/components/InvoiceFactoring/borrow/3-ConfirmTransfer.tsx +37 -0
  18. package/src/components/InvoiceFactoring/borrow/index.tsx +5 -7
  19. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +11 -3
  20. package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +4 -1
  21. package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +18 -80
  22. package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +4 -36
  23. package/src/components/StreamFactoring/borrow/5-Permit.tsx +14 -14
  24. package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +1 -1
  25. package/src/cosmos/CreditLineBorrow.fixture.tsx +1 -0
  26. package/src/cosmos/CreditLinePayment.fixture.tsx +1 -0
  27. package/src/cosmos/SDKTesting.fixture.tsx +615 -615
  28. package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +3 -0
  29. package/src/cosmos/utils/env.ts +6 -0
  30. package/src/hooks/useEA.ts +10 -29
  31. package/src/index.tsx +75 -7
  32. package/src/reportWebVitals.ts +9 -9
  33. package/src/store/widgets.store.ts +0 -1
  34. package/src/utilTypes.d.ts +2 -0
  35. package/webpack.cosmos.js +9 -9
  36. package/src/components/AllowListModal.tsx +0 -113
  37. package/src/components/CreditLine/borrow/2-AllowList.tsx +0 -34
  38. package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +0 -34
  39. package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +0 -104
  40. /package/src/components/CreditLine/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +0 -0
  41. /package/src/components/CreditLine/borrow/{4-Transfer.tsx → 3-Transfer.tsx} +0 -0
  42. /package/src/components/CreditLine/borrow/{5-ApproveAllowance.tsx → 4-ApproveAllowance.tsx} +0 -0
  43. /package/src/components/CreditLine/borrow/{6-Success.tsx → 5-Success.tsx} +0 -0
  44. /package/src/components/InvoiceFactoring/borrow/{5-ApproveNFT.tsx → 4-ApproveNFT.tsx} +0 -0
  45. /package/src/components/InvoiceFactoring/borrow/{6-Transfer.tsx → 5-Transfer.tsx} +0 -0
  46. /package/src/components/InvoiceFactoring/borrow/{7-Success.tsx → 6-Success.tsx} +0 -0
@@ -1,6 +1,9 @@
1
1
  import { SuperfluidFactoringWidget } from '..'
2
+ import { initEnv } from './utils/env'
2
3
  import { WalletWrapper } from './WalletWrapper'
3
4
 
5
+ initEnv()
6
+
4
7
  function Fixture() {
5
8
  return <SuperfluidFactoringWidget />
6
9
  }
@@ -0,0 +1,6 @@
1
+ // @ts-nocheck
2
+
3
+ export const initEnv = () => {
4
+ window.REACT_APP_FORCE_DEV_PREFIX_FOR_URLS =
5
+ process.env.REACT_APP_FORCE_DEV_PREFIX_FOR_URLS
6
+ }
@@ -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, setStep } from '../store/widgets.reducers'
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
- if (addToAllowList) {
48
- dispatch(setStep(WIDGET_STEP.AddToAllowList))
49
- } else {
50
- dispatch(
51
- setError({
52
- errorMessage: EARejectMessage,
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,81 @@ 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, handleClose } = props
64
+ const netWorkVersion =
65
+ // @ts-ignore
66
+ window.ethereum?.networkVersion || window.ethereum?.chainId
67
+ const [currentChainId, setCurrentChainId] = useState<number | undefined>(
68
+ netWorkVersion ? Number(netWorkVersion) : undefined,
69
+ )
70
+ const chainSupported = !!supportedChainId(currentChainId)
71
+
72
+ useEffect(() => {
73
+ const chainChangeListener = (chainId: number) => {
74
+ setCurrentChainId(chainId)
75
+ }
76
+
77
+ if (window.ethereum) {
78
+ // @ts-ignore
79
+ window.ethereum?.on('chainChanged', chainChangeListener)
80
+ }
81
+ return () => {
82
+ if (window.ethereum) {
83
+ // @ts-ignore
84
+ window.ethereum?.removeListener('chainChanged', chainChangeListener)
85
+ }
86
+ }
87
+ }, [])
88
+
89
+ useEffect(() => {
90
+ if (
91
+ window.ethereum &&
92
+ desiredChainId &&
93
+ currentChainId !== desiredChainId
94
+ ) {
95
+ const changeNetwork = async () => {
96
+ try {
97
+ // @ts-ignore
98
+ await window.ethereum.request({
99
+ method: 'wallet_switchEthereumChain',
100
+ params: [{ chainId: `0x${Number(desiredChainId).toString(16)}` }],
101
+ })
102
+ } catch (error) {
103
+ console.error(error)
104
+ }
105
+ }
106
+ changeNetwork()
107
+ }
108
+ }, [currentChainId, desiredChainId])
109
+
110
+ const handleCloseCallback = useCallback(() => {
111
+ if (handleClose) {
112
+ handleClose()
113
+ }
114
+ }, [handleClose])
115
+
116
+ if (!chainSupported) {
117
+ return (
118
+ <ThemeProvider theme={themeHuma}>
119
+ <ReduxProvider store={store}>
120
+ <ChainNotSupportedModal handleClose={handleCloseCallback} />
121
+ </ReduxProvider>
122
+ </ThemeProvider>
123
+ )
124
+ }
125
+
58
126
  return (
59
127
  <ThemeProvider theme={themeHuma}>
60
128
  <ReduxProvider store={store}>
@@ -78,7 +146,7 @@ type InvoiceFactoringBorrowWidgetProps = InvoiceFactoringBorrowProps &
78
146
  /**
79
147
  * Invoice factoring borrow widget
80
148
  *
81
- * @param {InvoiceFactoringBorrowWidgetProps} props - The invoice factoring pool borrow widget props.
149
+ * @param {InvoiceFactoringBorrowProps | WidgetProps} props - The invoice factoring pool borrow widget props.
82
150
  * @returns Invoice factoring pool borrow widget component
83
151
  */
84
152
  export function InvoiceFactoringBorrowWidget(
@@ -103,7 +171,7 @@ type InvoiceFactoringPaymentWidgetProps = InvoiceFactoringPaymentProps &
103
171
  /**
104
172
  * Invoice factoring payment widget
105
173
  *
106
- * @param {InvoiceFactoringPaymentWidgetProps} props - The invoice factoring pool payment widget props.
174
+ * @param {InvoiceFactoringPaymentProps | WidgetProps} props - The invoice factoring pool payment widget props.
107
175
  * @returns Invoice factoring pool payment widget component
108
176
  */
109
177
  export function InvoiceFactoringPaymentWidget(
@@ -127,7 +195,7 @@ type CreditLineBorrowWidgetProps = CreditLineBorrowProps & WidgetProps
127
195
  /**
128
196
  * Credit line borrow widget
129
197
  *
130
- * @param {CreditLineBorrowWidgetProps} props - The credit line pool borrow widget props.
198
+ * @param {CreditLineBorrowProps | WidgetProps} props - The credit line pool borrow widget props.
131
199
  * @returns Credit line pool borrow widget component
132
200
  */
133
201
  export function CreditLineBorrowWidget(props: CreditLineBorrowWidgetProps) {
@@ -149,7 +217,7 @@ type CreditLinePaymentWidgetProps = CreditLinePaymentProps & WidgetProps
149
217
  /**
150
218
  * Credit line payment widget
151
219
  *
152
- * @param {CreditLinePaymentWidgetProps} props - The credit line pool payment widget props.
220
+ * @param {CreditLinePaymentProps | WidgetProps} props - The credit line pool payment widget props.
153
221
  * @returns Credit line pool payment widget component
154
222
  */
155
223
  export function CreditLinePaymentWidget(props: CreditLinePaymentWidgetProps) {
@@ -171,7 +239,7 @@ type LendSupplyWidgetProps = LendSupplyProps & WidgetProps
171
239
  /**
172
240
  * Lend supply widget
173
241
  *
174
- * @param {LendSupplyWidgetProps} props - The lend pool supply widget props.
242
+ * @param {LendSupplyProps | WidgetProps} props - The lend pool supply widget props.
175
243
  * @returns Lend pool supply widget component
176
244
  */
177
245
  export function LendSupplyWidget(props: LendSupplyWidgetProps) {
@@ -193,7 +261,7 @@ type LendWithdrawWidgetProps = LendWithdrawProps & WidgetProps
193
261
  /**
194
262
  * Lend withdraw widget
195
263
  *
196
- * @param {LendWithdrawProps & WidgetProps} props The lend pool withdraw widget props
264
+ * @param {LendWithdrawProps | WidgetProps} props The lend pool withdraw widget props
197
265
  * @returns Lend pool withdraw widget component
198
266
  */
199
267
  export function LendWithdrawWidget(props: LendWithdrawWidgetProps) {
@@ -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
@@ -7,7 +7,6 @@ export enum WIDGET_TYPE {
7
7
 
8
8
  export enum WIDGET_STEP {
9
9
  Evaluation = 'Evaluation',
10
- AddToAllowList = 'AddToAllowList',
11
10
  ChooseAmount = 'ChooseAmount',
12
11
  Permit = 'Permit',
13
12
  ApproveAllowance = 'ApproveAllowance',
@@ -25,5 +25,7 @@ export type CustomError = {
25
25
  declare global {
26
26
  interface Window {
27
27
  REACT_APP_FORCE_DEV_PREFIX_FOR_URLS: string
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ ethereum: any
28
30
  }
29
31
  }
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
- // 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
- // }),
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
- }