@huma-finance/widgets 0.0.8 → 0.0.11

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 (76) hide show
  1. package/dist/cjs/index.cjs +139 -131
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/index.js +139 -131
  4. package/dist/index.js.map +1 -1
  5. package/package.json +4 -4
  6. package/src/components/Activity.tsx +123 -123
  7. package/src/components/AllowListModal.tsx +113 -113
  8. package/src/components/ApproveAllowanceModal.tsx +118 -118
  9. package/src/components/ChooseAmountModal.tsx +315 -315
  10. package/src/components/CreditLine/borrow/1-Evaluation.tsx +158 -159
  11. package/src/components/CreditLine/borrow/2-AllowList.tsx +34 -34
  12. package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +74 -74
  13. package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -29
  14. package/src/components/CreditLine/borrow/5-Transfer.tsx +30 -30
  15. package/src/components/CreditLine/borrow/6-Success.tsx +30 -30
  16. package/src/components/CreditLine/borrow/index.tsx +119 -119
  17. package/src/components/CreditLine/payment/1-ChooseAmount.tsx +67 -67
  18. package/src/components/CreditLine/payment/2-ApproveAllowance.tsx +23 -23
  19. package/src/components/CreditLine/payment/3-Transfer.tsx +34 -34
  20. package/src/components/CreditLine/payment/4-Success.tsx +39 -39
  21. package/src/components/CreditLine/payment/index.tsx +94 -94
  22. package/src/components/ErrorModal.tsx +132 -132
  23. package/src/components/Factoring/FactoredList.tsx +143 -143
  24. package/src/components/Factoring/UpcomingList.tsx +90 -90
  25. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +52 -46
  26. package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +34 -34
  27. package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +86 -92
  28. package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +104 -104
  29. package/src/components/InvoiceFactoring/borrow/5-ApproveNFT.tsx +55 -55
  30. package/src/components/InvoiceFactoring/borrow/6-Transfer.tsx +34 -34
  31. package/src/components/InvoiceFactoring/borrow/7-Success.tsx +3 -3
  32. package/src/components/InvoiceFactoring/borrow/index.tsx +96 -96
  33. package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +67 -67
  34. package/src/components/InvoiceFactoring/payment/2-ApproveAllowance.tsx +23 -23
  35. package/src/components/InvoiceFactoring/payment/3-Transfer.tsx +34 -34
  36. package/src/components/InvoiceFactoring/payment/4-Success.tsx +23 -23
  37. package/src/components/InvoiceFactoring/payment/index.tsx +86 -86
  38. package/src/components/Lend/supply/1-Evaluation.tsx +86 -86
  39. package/src/components/Lend/supply/2-ChooseAmount.tsx +70 -70
  40. package/src/components/Lend/supply/3-ApproveAllowance.tsx +25 -25
  41. package/src/components/Lend/supply/4-ConfirmTransfer.tsx +104 -104
  42. package/src/components/Lend/supply/6-Transfer.tsx +32 -32
  43. package/src/components/Lend/supply/7-Success.tsx +49 -49
  44. package/src/components/Lend/supply/index.tsx +144 -144
  45. package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +73 -73
  46. package/src/components/Lend/withdraw/2-ChooseAmount.tsx +50 -50
  47. package/src/components/Lend/withdraw/3-Transfer.tsx +32 -32
  48. package/src/components/Lend/withdraw/4-Success.tsx +49 -49
  49. package/src/components/Lend/withdraw/index.tsx +101 -101
  50. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +47 -57
  51. package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +124 -124
  52. package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +104 -104
  53. package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +65 -65
  54. package/src/components/StreamFactoring/borrow/5-Permit.tsx +144 -144
  55. package/src/components/StreamFactoring/borrow/6-Transfer.tsx +37 -37
  56. package/src/components/StreamFactoring/borrow/7-Success.tsx +2 -2
  57. package/src/components/StreamFactoring/borrow/index.tsx +94 -95
  58. package/src/components/StreamFactoring/payment/ChooseAmount.tsx +54 -54
  59. package/src/components/StreamFactoring/payment/Success.tsx +23 -23
  60. package/src/components/StreamFactoring/payment/Transfer.tsx +34 -34
  61. package/src/components/StreamFactoring/payment/index.tsx +66 -66
  62. package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +61 -61
  63. package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +185 -185
  64. package/src/components/SuperfluidFactoring/index.tsx +85 -85
  65. package/src/components/TxDoneModal.tsx +83 -83
  66. package/src/components/TxSendModal.tsx +59 -59
  67. package/src/components/ViewOnExplorer.tsx +26 -26
  68. package/src/components/WidgetWrapper.tsx +74 -74
  69. package/src/components/humaModal/HumaModal.tsx +68 -68
  70. package/src/cosmos/SDKTesting.fixture.tsx +557 -515
  71. package/src/hooks/useEA.ts +72 -70
  72. package/src/index.tsx +219 -219
  73. package/src/store/widgets.reducers.ts +120 -120
  74. package/src/store/widgets.store.ts +55 -55
  75. package/src/theme/components.ts +1 -1
  76. package/src/theme/hooks/useGetSizes.ts +0 -3
@@ -1,118 +1,118 @@
1
- import { MaxUint256 } from '@ethersproject/constants'
2
- import { Box, css, useTheme } from '@mui/material'
3
- import { useWeb3React } from '@web3-react/core'
4
- import { BigNumber } from 'ethers'
5
- import {
6
- PoolInfoType,
7
- sendTxAtom,
8
- txAtom,
9
- TxStateType,
10
- useMount,
11
- usePoolUnderlyingTokenContract,
12
- } from '@huma-finance/shared'
13
- import { useAtom } from 'jotai'
14
- import { useResetAtom } from 'jotai/utils'
15
- import React, { useCallback, useEffect } from 'react'
16
-
17
- import { BottomButton } from './BottomButton'
18
- import { AutoPaybackIcon } from './icons'
19
- import { LoadingModal } from './LoadingModal'
20
- import { ViewOnExplorer } from './ViewOnExplorer'
21
- import { WrapperModal } from './WrapperModal'
22
-
23
- type Props = {
24
- poolInfo: PoolInfoType
25
- showAutoPayback?: boolean
26
- allowanceAmount?: BigNumber
27
- handleSuccess: () => void
28
- }
29
-
30
- export function ApproveAllowanceModal({
31
- poolInfo,
32
- showAutoPayback = false,
33
- allowanceAmount,
34
- handleSuccess,
35
- }: Props): React.ReactElement | null {
36
- const theme = useTheme()
37
- const { provider } = useWeb3React()
38
- const { poolUnderlyingToken } = poolInfo
39
- const { symbol } = poolUnderlyingToken
40
- const poolUnderlyingTokenContract = usePoolUnderlyingTokenContract(
41
- poolInfo.poolName,
42
- poolInfo.poolType,
43
- )
44
- const reset = useResetAtom(txAtom)
45
- const [{ state, txHash }, send] = useAtom(sendTxAtom)
46
- const waitingForAccept = state === TxStateType.New
47
-
48
- useEffect(() => {
49
- if (state === TxStateType.Success) {
50
- reset()
51
- handleSuccess()
52
- }
53
- }, [handleSuccess, reset, state, symbol])
54
-
55
- const styles = {
56
- iconWrapper: css`
57
- ${theme.cssMixins.rowCentered};
58
- margin-top: 30px;
59
- `,
60
- description: css`
61
- margin-top: 14px;
62
- font-family: 'Uni-Neue-Regular';
63
- font-size: 16px;
64
- color: #a8a1b2;
65
- padding: 0 12px;
66
- `,
67
- }
68
-
69
- const sendApprove = useCallback(() => {
70
- send({
71
- contract: poolUnderlyingTokenContract!,
72
- method: 'approve',
73
- params: [poolInfo.pool, allowanceAmount ?? MaxUint256],
74
- provider,
75
- })
76
- }, [
77
- allowanceAmount,
78
- poolInfo.pool,
79
- poolUnderlyingTokenContract,
80
- provider,
81
- send,
82
- ])
83
-
84
- useMount(() => {
85
- if (!showAutoPayback) {
86
- sendApprove()
87
- }
88
- })
89
-
90
- if (showAutoPayback && waitingForAccept) {
91
- return (
92
- <WrapperModal
93
- title='Auto Payback'
94
- subTitle='Enable auto payback and never miss payments. You only need to do it once.'
95
- >
96
- <Box css={styles.iconWrapper}>
97
- <AutoPaybackIcon />
98
- </Box>
99
- <Box css={styles.description}>
100
- This allowance transaction removes the need to confirm follow up{' '}
101
- {symbol} transactions. Gas is on us.
102
- </Box>
103
- <BottomButton variant='contained' onClick={sendApprove}>
104
- APPROVE {symbol} PAYMENTS
105
- </BottomButton>
106
- </WrapperModal>
107
- )
108
- }
109
-
110
- return (
111
- <LoadingModal
112
- title={`Approve ${symbol}`}
113
- description='Waiting for approval confirmation...'
114
- >
115
- <ViewOnExplorer txHash={txHash} />
116
- </LoadingModal>
117
- )
118
- }
1
+ import { MaxUint256 } from '@ethersproject/constants'
2
+ import { Box, css, useTheme } from '@mui/material'
3
+ import { useWeb3React } from '@web3-react/core'
4
+ import { BigNumber } from 'ethers'
5
+ import {
6
+ PoolInfoType,
7
+ sendTxAtom,
8
+ txAtom,
9
+ TxStateType,
10
+ useMount,
11
+ usePoolUnderlyingTokenContract,
12
+ } from '@huma-finance/shared'
13
+ import { useAtom } from 'jotai'
14
+ import { useResetAtom } from 'jotai/utils'
15
+ import React, { useCallback, useEffect } from 'react'
16
+
17
+ import { BottomButton } from './BottomButton'
18
+ import { AutoPaybackIcon } from './icons'
19
+ import { LoadingModal } from './LoadingModal'
20
+ import { ViewOnExplorer } from './ViewOnExplorer'
21
+ import { WrapperModal } from './WrapperModal'
22
+
23
+ type Props = {
24
+ poolInfo: PoolInfoType
25
+ showAutoPayback?: boolean
26
+ allowanceAmount?: BigNumber
27
+ handleSuccess: () => void
28
+ }
29
+
30
+ export function ApproveAllowanceModal({
31
+ poolInfo,
32
+ showAutoPayback = false,
33
+ allowanceAmount,
34
+ handleSuccess,
35
+ }: Props): React.ReactElement | null {
36
+ const theme = useTheme()
37
+ const { provider } = useWeb3React()
38
+ const { poolUnderlyingToken } = poolInfo
39
+ const { symbol } = poolUnderlyingToken
40
+ const poolUnderlyingTokenContract = usePoolUnderlyingTokenContract(
41
+ poolInfo.poolName,
42
+ poolInfo.poolType,
43
+ )
44
+ const reset = useResetAtom(txAtom)
45
+ const [{ state, txHash }, send] = useAtom(sendTxAtom)
46
+ const waitingForAccept = state === TxStateType.New
47
+
48
+ useEffect(() => {
49
+ if (state === TxStateType.Success) {
50
+ reset()
51
+ handleSuccess()
52
+ }
53
+ }, [handleSuccess, reset, state, symbol])
54
+
55
+ const styles = {
56
+ iconWrapper: css`
57
+ ${theme.cssMixins.rowCentered};
58
+ margin-top: 30px;
59
+ `,
60
+ description: css`
61
+ margin-top: 14px;
62
+ font-family: 'Uni-Neue-Regular';
63
+ font-size: 16px;
64
+ color: #a8a1b2;
65
+ padding: 0 12px;
66
+ `,
67
+ }
68
+
69
+ const sendApprove = useCallback(() => {
70
+ send({
71
+ contract: poolUnderlyingTokenContract!,
72
+ method: 'approve',
73
+ params: [poolInfo.pool, allowanceAmount ?? MaxUint256],
74
+ provider,
75
+ })
76
+ }, [
77
+ allowanceAmount,
78
+ poolInfo.pool,
79
+ poolUnderlyingTokenContract,
80
+ provider,
81
+ send,
82
+ ])
83
+
84
+ useMount(() => {
85
+ if (!showAutoPayback) {
86
+ sendApprove()
87
+ }
88
+ })
89
+
90
+ if (showAutoPayback && waitingForAccept) {
91
+ return (
92
+ <WrapperModal
93
+ title='Auto Payback'
94
+ subTitle='Enable auto payback and never miss payments. You only need to do it once.'
95
+ >
96
+ <Box css={styles.iconWrapper}>
97
+ <AutoPaybackIcon />
98
+ </Box>
99
+ <Box css={styles.description}>
100
+ This allowance transaction removes the need to confirm follow up{' '}
101
+ {symbol} transactions. Gas is on us.
102
+ </Box>
103
+ <BottomButton variant='contained' onClick={sendApprove}>
104
+ APPROVE {symbol} PAYMENTS
105
+ </BottomButton>
106
+ </WrapperModal>
107
+ )
108
+ }
109
+
110
+ return (
111
+ <LoadingModal
112
+ title={`Approve ${symbol}`}
113
+ description='Waiting for approval confirmation...'
114
+ >
115
+ <ViewOnExplorer txHash={txHash} />
116
+ </LoadingModal>
117
+ )
118
+ }