@huma-finance/widgets 0.0.6-alpha.0
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/.env.example +3 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +64 -0
- package/.prettierignore +4 -0
- package/.prettierrc.js +16 -0
- package/API.md +331 -0
- package/LICENSE +661 -0
- package/README.md +48 -0
- package/babel.config.js +15 -0
- package/config-overrides.js +9 -0
- package/cosmos.config.json +7 -0
- package/cypress/e2e/01-invoice-factoring-borrow.test.ts +62 -0
- package/cypress/support/e2e.ts +76 -0
- package/cypress/support/ethereum.ts +142 -0
- package/cypress/tsconfig.json +9 -0
- package/cypress/utils/index.ts +54 -0
- package/cypress.config.ts +20 -0
- package/dist/assets/output-15e10f9f.css +44 -0
- package/dist/cjs/assets/output-15e10f9f.css +44 -0
- package/dist/cjs/index.cjs +17576 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +17529 -0
- package/dist/index.js.map +1 -0
- package/jsdoc2md.json +20 -0
- package/package.json +193 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +40 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/rollup.config.js +81 -0
- package/src/components/Activity.tsx +123 -0
- package/src/components/AllowListModal.tsx +113 -0
- package/src/components/ApolloWrapper.tsx +15 -0
- package/src/components/ApproveAllowanceModal.tsx +118 -0
- package/src/components/BottomButton.tsx +31 -0
- package/src/components/ChooseAmountModal.tsx +315 -0
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +159 -0
- package/src/components/CreditLine/borrow/2-AllowList.tsx +34 -0
- package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +74 -0
- package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -0
- package/src/components/CreditLine/borrow/5-Transfer.tsx +30 -0
- package/src/components/CreditLine/borrow/6-Success.tsx +30 -0
- package/src/components/CreditLine/borrow/index.tsx +119 -0
- package/src/components/CreditLine/payment/1-ChooseAmount.tsx +67 -0
- package/src/components/CreditLine/payment/2-ApproveAllowance.tsx +23 -0
- package/src/components/CreditLine/payment/3-Transfer.tsx +34 -0
- package/src/components/CreditLine/payment/4-Success.tsx +39 -0
- package/src/components/CreditLine/payment/index.tsx +94 -0
- package/src/components/ErrorModal.tsx +132 -0
- package/src/components/Factoring/FactoredList.tsx +143 -0
- package/src/components/Factoring/UpcomingList.tsx +90 -0
- package/src/components/Factoring/index.ts +2 -0
- package/src/components/HumaLoading.tsx +68 -0
- package/src/components/HumaTable.tsx +158 -0
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +46 -0
- package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +34 -0
- package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +92 -0
- package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +104 -0
- package/src/components/InvoiceFactoring/borrow/5-ApproveNFT.tsx +55 -0
- package/src/components/InvoiceFactoring/borrow/6-Transfer.tsx +34 -0
- package/src/components/InvoiceFactoring/borrow/7-Success.tsx +20 -0
- package/src/components/InvoiceFactoring/borrow/index.tsx +96 -0
- package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +67 -0
- package/src/components/InvoiceFactoring/payment/2-ApproveAllowance.tsx +23 -0
- package/src/components/InvoiceFactoring/payment/3-Transfer.tsx +34 -0
- package/src/components/InvoiceFactoring/payment/4-Success.tsx +23 -0
- package/src/components/InvoiceFactoring/payment/index.tsx +86 -0
- package/src/components/Lend/supply/1-Evaluation.tsx +86 -0
- package/src/components/Lend/supply/2-ChooseAmount.tsx +70 -0
- package/src/components/Lend/supply/3-ApproveAllowance.tsx +25 -0
- package/src/components/Lend/supply/4-ConfirmTransfer.tsx +104 -0
- package/src/components/Lend/supply/6-Transfer.tsx +32 -0
- package/src/components/Lend/supply/7-Success.tsx +49 -0
- package/src/components/Lend/supply/index.tsx +144 -0
- package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +73 -0
- package/src/components/Lend/withdraw/2-ChooseAmount.tsx +50 -0
- package/src/components/Lend/withdraw/3-Transfer.tsx +32 -0
- package/src/components/Lend/withdraw/4-Success.tsx +49 -0
- package/src/components/Lend/withdraw/index.tsx +101 -0
- package/src/components/LoadingModal.tsx +49 -0
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +57 -0
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +124 -0
- package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +104 -0
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +65 -0
- package/src/components/StreamFactoring/borrow/5-Permit.tsx +144 -0
- package/src/components/StreamFactoring/borrow/6-Transfer.tsx +37 -0
- package/src/components/StreamFactoring/borrow/7-Success.tsx +20 -0
- package/src/components/StreamFactoring/borrow/index.tsx +95 -0
- package/src/components/StreamFactoring/payment/ChooseAmount.tsx +54 -0
- package/src/components/StreamFactoring/payment/Success.tsx +23 -0
- package/src/components/StreamFactoring/payment/Transfer.tsx +34 -0
- package/src/components/StreamFactoring/payment/index.tsx +66 -0
- package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +61 -0
- package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +185 -0
- package/src/components/SuperfluidFactoring/index.tsx +85 -0
- package/src/components/TxDoneModal.tsx +83 -0
- package/src/components/TxSendModal.tsx +59 -0
- package/src/components/ViewOnExplorer.tsx +26 -0
- package/src/components/WidgetWrapper.tsx +74 -0
- package/src/components/WrapperModal.tsx +54 -0
- package/src/components/buttons/TableActionButton.tsx +36 -0
- package/src/components/buttons/index.ts +1 -0
- package/src/components/humaModal/HumaModal.tsx +68 -0
- package/src/components/humaModal/HumaModalHeader.tsx +70 -0
- package/src/components/humaModal/index.tsx +2 -0
- package/src/components/icons/approve-lender.svg +30 -0
- package/src/components/icons/auto-payback.svg +40 -0
- package/src/components/icons/check-circle.svg +3 -0
- package/src/components/icons/check-green.svg +3 -0
- package/src/components/icons/check.svg +10 -0
- package/src/components/icons/donut.svg +904 -0
- package/src/components/icons/ellipse.svg +3 -0
- package/src/components/icons/ethereum.svg +1 -0
- package/src/components/icons/huma-full.svg +22 -0
- package/src/components/icons/huma.svg +15 -0
- package/src/components/icons/index.tsx +93 -0
- package/src/components/icons/loader.svg +229 -0
- package/src/components/icons/metamask.svg +31 -0
- package/src/components/icons/polygon.svg +16 -0
- package/src/components/icons/receipt.svg +3 -0
- package/src/components/icons/separator.svg +3 -0
- package/src/components/icons/sorry.svg +31 -0
- package/src/components/icons/spinner.gif +0 -0
- package/src/components/icons/usdc.svg +5 -0
- package/src/components/icons/wallet-connect.svg +12 -0
- package/src/cosmos/CreditLineBorrow.fixture.tsx +85 -0
- package/src/cosmos/CreditLinePayment.fixture.tsx +49 -0
- package/src/cosmos/InvoiceFactoringBorrow.fixture.tsx +111 -0
- package/src/cosmos/InvoiceFactoringPayment.fixture.tsx +67 -0
- package/src/cosmos/LendSupply.fixture.tsx +75 -0
- package/src/cosmos/LendWithdraw.fixture.tsx +43 -0
- package/src/cosmos/SDKTesting.fixture.tsx +507 -0
- package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +12 -0
- package/src/cosmos/WalletWrapper.tsx +52 -0
- package/src/cosmos/abis/InvoiceNFT.json +644 -0
- package/src/cosmos/abis/ReceivableFactoringPool.json +1529 -0
- package/src/cosmos/utils/index.ts +169 -0
- package/src/fonts/Inter/Inter-Black.ttf +0 -0
- package/src/fonts/Inter/Inter-Bold.ttf +0 -0
- package/src/fonts/Inter/Inter-ExtraBold.ttf +0 -0
- package/src/fonts/Inter/Inter-ExtraLight.ttf +0 -0
- package/src/fonts/Inter/Inter-Light.ttf +0 -0
- package/src/fonts/Inter/Inter-Medium.ttf +0 -0
- package/src/fonts/Inter/Inter-Regular.ttf +0 -0
- package/src/fonts/Inter/Inter-SemiBold.ttf +0 -0
- package/src/fonts/Inter/Inter-Thin.ttf +0 -0
- package/src/fonts/Recoleta/Recoleta-Black.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Bold.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Light.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Medium.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Regular.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-RegularDEMO.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-SemiBold.otf +0 -0
- package/src/fonts/Recoleta/Recoleta-Thin.otf +0 -0
- package/src/fonts/Roboto/LICENSE.txt +202 -0
- package/src/fonts/Roboto/Roboto-Black.ttf +0 -0
- package/src/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Bold.ttf +0 -0
- package/src/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Light.ttf +0 -0
- package/src/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/src/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/src/fonts/Roboto/Roboto-Thin.ttf +0 -0
- package/src/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Black.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Bold.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Book.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Heavy.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Light.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Regular.ttf +0 -0
- package/src/fonts/UniNeue/UniNeue-Thin.ttf +0 -0
- package/src/hooks/useEA.ts +70 -0
- package/src/hooks/useRedux.ts +6 -0
- package/src/index.css +61 -0
- package/src/index.tsx +219 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +6 -0
- package/src/store/index.ts +27 -0
- package/src/store/widgets.reducers.ts +120 -0
- package/src/store/widgets.selectors.ts +3 -0
- package/src/store/widgets.store.ts +55 -0
- package/src/theme/breakpoints.ts +10 -0
- package/src/theme/components.ts +70 -0
- package/src/theme/coreThemeConstants.ts +29 -0
- package/src/theme/cssMixins.ts +92 -0
- package/src/theme/hooks/useGetSizes.ts +34 -0
- package/src/theme/index.ts +24 -0
- package/src/theme/palette.ts +150 -0
- package/src/theme/shape.ts +7 -0
- package/src/theme/theme.types.ts +80 -0
- package/src/theme/typography.ts +117 -0
- package/src/utilTypes.d.ts +29 -0
- package/src/utils/env.ts +9 -0
- package/tsconfig.build.json +7 -0
- package/tsconfig.json +32 -0
- package/webpack.cosmos.js +54 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
3
|
+
import { JsonRpcProvider } from '@ethersproject/providers'
|
|
4
|
+
import { ThemeProvider } from '@mui/material'
|
|
5
|
+
import { Provider as Eip1193Provider } from '@web3-react/types'
|
|
6
|
+
import {
|
|
7
|
+
Provider as Web3Provider,
|
|
8
|
+
ProviderProps as Web3Props,
|
|
9
|
+
} from '@huma-finance/shared'
|
|
10
|
+
import { Provider as AtomProvider } from 'jotai'
|
|
11
|
+
import { Provider as ReduxProvider } from 'react-redux'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
CreditLineBorrow,
|
|
15
|
+
CreditLineBorrowProps,
|
|
16
|
+
} from './components/CreditLine/borrow'
|
|
17
|
+
import {
|
|
18
|
+
CreditLinePayment,
|
|
19
|
+
CreditLinePaymentProps,
|
|
20
|
+
} from './components/CreditLine/payment'
|
|
21
|
+
import {
|
|
22
|
+
InvoiceFactoringBorrow,
|
|
23
|
+
InvoiceFactoringBorrowProps,
|
|
24
|
+
} from './components/InvoiceFactoring/borrow'
|
|
25
|
+
import {
|
|
26
|
+
InvoiceFactoringPayment,
|
|
27
|
+
InvoiceFactoringPaymentProps,
|
|
28
|
+
} from './components/InvoiceFactoring/payment'
|
|
29
|
+
import { LendSupply, LendSupplyProps } from './components/Lend/supply'
|
|
30
|
+
import { LendWithdraw, LendWithdrawProps } from './components/Lend/withdraw'
|
|
31
|
+
import { SuperfluidFactoring } from './components/SuperfluidFactoring'
|
|
32
|
+
import { store } from './store'
|
|
33
|
+
import { themeHuma } from './theme'
|
|
34
|
+
import { WCProps } from './utilTypes'
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Mapping of your JSON-RPC connections indexed by chainId
|
|
38
|
+
* @typedef {Object} JsonRpcConnectionMap
|
|
39
|
+
* @property {Object.<number, string|Array<string>|JsonRpcProvider|Array<JsonRpcProvider>>} chainId Chain id to map the JSON-RPC URL/URLs or JsonRpcProvider/JsonRpcProviders
|
|
40
|
+
*/
|
|
41
|
+
type JsonRpcConnectionMap = {
|
|
42
|
+
[chainId: number]: string | string[] | JsonRpcProvider | JsonRpcProvider[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Object representing the props passed to web3 provider
|
|
47
|
+
* @typedef {Object} WidgetProps
|
|
48
|
+
* @property {JsonRpcConnectionMap|undefined} jsonRpcUrlMap Optional mapping of your JSON-RPC connections indexed by chainId
|
|
49
|
+
* @property {Eip1193Provider|JsonRpcProvider|null|undefined} provider Optional EIP-1193 provider or JsonRpc Provider
|
|
50
|
+
*/
|
|
51
|
+
type WidgetProps = {
|
|
52
|
+
jsonRpcUrlMap?: JsonRpcConnectionMap
|
|
53
|
+
provider?: Eip1193Provider | JsonRpcProvider | null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function Widget(props: WCProps<WidgetProps>) {
|
|
57
|
+
const { children } = props
|
|
58
|
+
return (
|
|
59
|
+
<ThemeProvider theme={themeHuma}>
|
|
60
|
+
<ReduxProvider store={store}>
|
|
61
|
+
<Web3Provider {...(props as Web3Props)}>
|
|
62
|
+
<AtomProvider>{children}</AtomProvider>
|
|
63
|
+
</Web3Provider>
|
|
64
|
+
</ReduxProvider>
|
|
65
|
+
</ThemeProvider>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Invoice factoring pool borrow widget props
|
|
71
|
+
* @typedef {Object} InvoiceFactoringBorrowWidgetProps
|
|
72
|
+
* @property {InvoiceFactoringBorrowProps} InvoiceFactoringBorrowProps - Invoice factoring pool borrow props.
|
|
73
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
74
|
+
*/
|
|
75
|
+
type InvoiceFactoringBorrowWidgetProps = InvoiceFactoringBorrowProps &
|
|
76
|
+
WidgetProps
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Invoice factoring borrow widget
|
|
80
|
+
*
|
|
81
|
+
* @param {InvoiceFactoringBorrowWidgetProps} props - The invoice factoring pool borrow widget props.
|
|
82
|
+
* @returns Invoice factoring pool borrow widget component
|
|
83
|
+
*/
|
|
84
|
+
export function InvoiceFactoringBorrowWidget(
|
|
85
|
+
props: InvoiceFactoringBorrowWidgetProps,
|
|
86
|
+
) {
|
|
87
|
+
return (
|
|
88
|
+
<Widget {...props}>
|
|
89
|
+
<InvoiceFactoringBorrow {...props} />
|
|
90
|
+
</Widget>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Invoice factoring pool payment widget props
|
|
96
|
+
* @typedef {Object} InvoiceFactoringPaymentWidgetProps
|
|
97
|
+
* @property {InvoiceFactoringPaymentProps} InvoiceFactoringPaymentProps - Invoice factoring pool payment props.
|
|
98
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
99
|
+
*/
|
|
100
|
+
type InvoiceFactoringPaymentWidgetProps = InvoiceFactoringPaymentProps &
|
|
101
|
+
WidgetProps
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Invoice factoring payment widget
|
|
105
|
+
*
|
|
106
|
+
* @param {InvoiceFactoringPaymentWidgetProps} props - The invoice factoring pool payment widget props.
|
|
107
|
+
* @returns Invoice factoring pool payment widget component
|
|
108
|
+
*/
|
|
109
|
+
export function InvoiceFactoringPaymentWidget(
|
|
110
|
+
props: InvoiceFactoringPaymentWidgetProps,
|
|
111
|
+
) {
|
|
112
|
+
return (
|
|
113
|
+
<Widget {...props}>
|
|
114
|
+
<InvoiceFactoringPayment {...props} />
|
|
115
|
+
</Widget>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Credit line pool borrow widget props
|
|
121
|
+
* @typedef {Object} CreditLineBorrowWidgetProps
|
|
122
|
+
* @property {CreditLineBorrowProps} CreditLineBorrowProps - Credit line pool borrow props.
|
|
123
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
124
|
+
*/
|
|
125
|
+
type CreditLineBorrowWidgetProps = CreditLineBorrowProps & WidgetProps
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Credit line borrow widget
|
|
129
|
+
*
|
|
130
|
+
* @param {CreditLineBorrowWidgetProps} props - The credit line pool borrow widget props.
|
|
131
|
+
* @returns Credit line pool borrow widget component
|
|
132
|
+
*/
|
|
133
|
+
export function CreditLineBorrowWidget(props: CreditLineBorrowWidgetProps) {
|
|
134
|
+
return (
|
|
135
|
+
<Widget {...props}>
|
|
136
|
+
<CreditLineBorrow {...props} />
|
|
137
|
+
</Widget>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Credit line pool payment widget props
|
|
143
|
+
* @typedef {Object} CreditLinePaymentWidgetProps
|
|
144
|
+
* @property {CreditLinePaymentProps} CreditLinePaymentProps - Credit line pool payment props.
|
|
145
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
146
|
+
*/
|
|
147
|
+
type CreditLinePaymentWidgetProps = CreditLinePaymentProps & WidgetProps
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Credit line payment widget
|
|
151
|
+
*
|
|
152
|
+
* @param {CreditLinePaymentWidgetProps} props - The credit line pool payment widget props.
|
|
153
|
+
* @returns Credit line pool payment widget component
|
|
154
|
+
*/
|
|
155
|
+
export function CreditLinePaymentWidget(props: CreditLinePaymentWidgetProps) {
|
|
156
|
+
return (
|
|
157
|
+
<Widget {...props}>
|
|
158
|
+
<CreditLinePayment {...props} />
|
|
159
|
+
</Widget>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Lend pool supply widget props
|
|
165
|
+
* @typedef {Object} LendSupplyWidgetProps
|
|
166
|
+
* @property {LendSupplyProps} LendSupplyProps - Lend pool supply props.
|
|
167
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
168
|
+
*/
|
|
169
|
+
type LendSupplyWidgetProps = LendSupplyProps & WidgetProps
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Lend supply widget
|
|
173
|
+
*
|
|
174
|
+
* @param {LendSupplyWidgetProps} props - The lend pool supply widget props.
|
|
175
|
+
* @returns Lend pool supply widget component
|
|
176
|
+
*/
|
|
177
|
+
export function LendSupplyWidget(props: LendSupplyWidgetProps) {
|
|
178
|
+
return (
|
|
179
|
+
<Widget {...props}>
|
|
180
|
+
<LendSupply {...props} />
|
|
181
|
+
</Widget>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Lend pool withdraw widget props
|
|
187
|
+
* @typedef {Object} LendWithdrawWidgetProps
|
|
188
|
+
* @property {LendWithdrawProps} LendWithdrawProps - Lend pool withdraw props.
|
|
189
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
190
|
+
*/
|
|
191
|
+
type LendWithdrawWidgetProps = LendWithdrawProps & WidgetProps
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Lend withdraw widget
|
|
195
|
+
*
|
|
196
|
+
* @param {LendWithdrawProps & WidgetProps} props The lend pool withdraw widget props
|
|
197
|
+
* @returns Lend pool withdraw widget component
|
|
198
|
+
*/
|
|
199
|
+
export function LendWithdrawWidget(props: LendWithdrawWidgetProps) {
|
|
200
|
+
return (
|
|
201
|
+
<Widget {...props}>
|
|
202
|
+
<LendWithdraw {...props} />
|
|
203
|
+
</Widget>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Superfluid factoring widget
|
|
209
|
+
*
|
|
210
|
+
* @param {WidgetProps} props - The superfluid factoring widget props.
|
|
211
|
+
* @returns Superfluid factoring widget component
|
|
212
|
+
*/
|
|
213
|
+
export function SuperfluidFactoringWidget(props: WidgetProps) {
|
|
214
|
+
return (
|
|
215
|
+
<Widget {...props}>
|
|
216
|
+
<SuperfluidFactoring />
|
|
217
|
+
</Widget>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReportHandler } from 'web-vitals';
|
|
2
|
+
|
|
3
|
+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
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
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default reportWebVitals;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
3
|
+
// allows you to do things like:
|
|
4
|
+
// expect(element).toHaveTextContent(/react/i)
|
|
5
|
+
// learn more: https://github.com/testing-library/jest-dom
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Action,
|
|
3
|
+
ActionCreator,
|
|
4
|
+
AnyAction,
|
|
5
|
+
configureStore,
|
|
6
|
+
ThunkAction,
|
|
7
|
+
} from '@reduxjs/toolkit'
|
|
8
|
+
|
|
9
|
+
import widgetsReducers from './widgets.reducers'
|
|
10
|
+
|
|
11
|
+
export const store = configureStore({
|
|
12
|
+
reducer: {
|
|
13
|
+
widget: widgetsReducers,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export type AppDispatch = typeof store.dispatch
|
|
18
|
+
export type RootState = ReturnType<typeof store.getState>
|
|
19
|
+
export type AppThunk<ReturnType = void> = ThunkAction<
|
|
20
|
+
ReturnType,
|
|
21
|
+
RootState,
|
|
22
|
+
unknown,
|
|
23
|
+
Action<string>
|
|
24
|
+
>
|
|
25
|
+
export type AppActionThunk<ReturnType = void> = ActionCreator<
|
|
26
|
+
ThunkAction<ReturnType, RootState, unknown, AnyAction>
|
|
27
|
+
>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
|
2
|
+
import { ApproveInfo } from '@huma-finance/shared'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
initialWidgetState,
|
|
6
|
+
MultisendPayload,
|
|
7
|
+
WIDGET_STEP,
|
|
8
|
+
WidgetStream,
|
|
9
|
+
} from './widgets.store'
|
|
10
|
+
|
|
11
|
+
export const widgetSlice = createSlice({
|
|
12
|
+
name: 'widget',
|
|
13
|
+
initialState: initialWidgetState,
|
|
14
|
+
reducers: {
|
|
15
|
+
resetState: (state) => {
|
|
16
|
+
state.errorReason = ''
|
|
17
|
+
state.errorMessage = ''
|
|
18
|
+
state.step = undefined
|
|
19
|
+
state.approveInfo = undefined
|
|
20
|
+
state.borrowAmount = undefined
|
|
21
|
+
state.borrowAmountBN = undefined
|
|
22
|
+
state.chargedFees = undefined
|
|
23
|
+
state.borrowAmountNet = undefined
|
|
24
|
+
state.remainder = undefined
|
|
25
|
+
state.tokenId = undefined
|
|
26
|
+
state.paymentAmount = undefined
|
|
27
|
+
state.remainDueAmount = undefined
|
|
28
|
+
state.stream = undefined
|
|
29
|
+
state.multisend = undefined
|
|
30
|
+
state.supplyAmount = undefined
|
|
31
|
+
state.withdrawAmount = undefined
|
|
32
|
+
},
|
|
33
|
+
setStep: (state, { payload }: PayloadAction<WIDGET_STEP>) => {
|
|
34
|
+
state.step = payload
|
|
35
|
+
},
|
|
36
|
+
setApproveInfo: (
|
|
37
|
+
state,
|
|
38
|
+
{ payload }: PayloadAction<ApproveInfo & { nextStep: WIDGET_STEP }>,
|
|
39
|
+
) => {
|
|
40
|
+
state.approveInfo = payload
|
|
41
|
+
if (Number(payload.creditLimit) > 0) {
|
|
42
|
+
state.step = payload.nextStep
|
|
43
|
+
} else {
|
|
44
|
+
state.errorMessage =
|
|
45
|
+
'Sorry, there was an error with your transaction. Please try submitting again.'
|
|
46
|
+
state.step = WIDGET_STEP.Error
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
setBorrowInfo: (
|
|
50
|
+
state,
|
|
51
|
+
{
|
|
52
|
+
payload,
|
|
53
|
+
}: PayloadAction<{
|
|
54
|
+
borrowAmount: number
|
|
55
|
+
borrowAmountBN: string
|
|
56
|
+
chargedFees: number
|
|
57
|
+
nextStep: WIDGET_STEP
|
|
58
|
+
remainder?: number
|
|
59
|
+
}>,
|
|
60
|
+
) => {
|
|
61
|
+
state.borrowAmount = payload.borrowAmount
|
|
62
|
+
state.borrowAmountBN = payload.borrowAmountBN
|
|
63
|
+
state.remainder = payload.remainder
|
|
64
|
+
state.chargedFees = payload.chargedFees
|
|
65
|
+
state.borrowAmountNet = payload.borrowAmount - payload.chargedFees
|
|
66
|
+
state.step = payload.nextStep
|
|
67
|
+
},
|
|
68
|
+
setTokenId: (state, { payload }: PayloadAction<string>) => {
|
|
69
|
+
state.tokenId = payload
|
|
70
|
+
},
|
|
71
|
+
setPaymentAmount: (
|
|
72
|
+
state,
|
|
73
|
+
{
|
|
74
|
+
payload,
|
|
75
|
+
}: PayloadAction<{ paymentAmount: number; remainDueAmount?: number }>,
|
|
76
|
+
) => {
|
|
77
|
+
state.paymentAmount = payload.paymentAmount
|
|
78
|
+
state.remainDueAmount = payload.remainDueAmount
|
|
79
|
+
},
|
|
80
|
+
setSupplyAmount: (state, { payload }: PayloadAction<number>) => {
|
|
81
|
+
state.supplyAmount = payload
|
|
82
|
+
},
|
|
83
|
+
setWithdrawAmount: (state, { payload }: PayloadAction<number>) => {
|
|
84
|
+
state.withdrawAmount = payload
|
|
85
|
+
},
|
|
86
|
+
setStream: (state, { payload }: PayloadAction<WidgetStream>) => {
|
|
87
|
+
const stream = state.stream ?? {}
|
|
88
|
+
state.stream = { ...stream, ...payload }
|
|
89
|
+
},
|
|
90
|
+
setMultisend: (state, { payload }: PayloadAction<MultisendPayload>) => {
|
|
91
|
+
state.multisend = payload
|
|
92
|
+
},
|
|
93
|
+
setError: (
|
|
94
|
+
state,
|
|
95
|
+
{
|
|
96
|
+
payload,
|
|
97
|
+
}: PayloadAction<{ errorMessage: string; errorReason?: string }>,
|
|
98
|
+
) => {
|
|
99
|
+
state.errorMessage = payload.errorMessage
|
|
100
|
+
state.errorReason = payload.errorReason
|
|
101
|
+
state.step = WIDGET_STEP.Error
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
export const {
|
|
107
|
+
resetState,
|
|
108
|
+
setStep,
|
|
109
|
+
setApproveInfo,
|
|
110
|
+
setBorrowInfo,
|
|
111
|
+
setError,
|
|
112
|
+
setTokenId,
|
|
113
|
+
setPaymentAmount,
|
|
114
|
+
setStream,
|
|
115
|
+
setMultisend,
|
|
116
|
+
setSupplyAmount,
|
|
117
|
+
setWithdrawAmount,
|
|
118
|
+
} = widgetSlice.actions
|
|
119
|
+
|
|
120
|
+
export default widgetSlice.reducer
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ApproveInfo } from '@huma-finance/shared'
|
|
2
|
+
|
|
3
|
+
export enum WIDGET_TYPE {
|
|
4
|
+
BORROW = 'BORROW',
|
|
5
|
+
PAYMENT = 'PAYMENT',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum WIDGET_STEP {
|
|
9
|
+
Evaluation = 'Evaluation',
|
|
10
|
+
AddToAllowList = 'AddToAllowList',
|
|
11
|
+
ChooseAmount = 'ChooseAmount',
|
|
12
|
+
Permit = 'Permit',
|
|
13
|
+
ApproveAllowance = 'ApproveAllowance',
|
|
14
|
+
MintNFT = 'MintNFT',
|
|
15
|
+
ConfirmTransfer = 'ConfirmTransfer',
|
|
16
|
+
ApproveNFT = 'ApproveNFT',
|
|
17
|
+
Transfer = 'Transfer',
|
|
18
|
+
CheckWithdrawable = 'CheckWithdrawable',
|
|
19
|
+
Done = 'Done',
|
|
20
|
+
Error = 'Error',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type WidgetStream = Partial<{
|
|
24
|
+
borrowFlowrate: string
|
|
25
|
+
durationInSeconds: number
|
|
26
|
+
}>
|
|
27
|
+
|
|
28
|
+
export type MultisendPayload = {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
addresses: any[]
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
callData: any[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type WidgetState = {
|
|
36
|
+
step?: WIDGET_STEP
|
|
37
|
+
type?: WIDGET_TYPE
|
|
38
|
+
approveInfo?: ApproveInfo
|
|
39
|
+
borrowAmount?: number
|
|
40
|
+
borrowAmountBN?: string
|
|
41
|
+
chargedFees?: number
|
|
42
|
+
borrowAmountNet?: number
|
|
43
|
+
remainder?: number
|
|
44
|
+
paymentAmount?: number
|
|
45
|
+
remainDueAmount?: number
|
|
46
|
+
supplyAmount?: number
|
|
47
|
+
withdrawAmount?: number
|
|
48
|
+
errorMessage?: string
|
|
49
|
+
errorReason?: string
|
|
50
|
+
tokenId?: string
|
|
51
|
+
stream?: WidgetStream
|
|
52
|
+
multisend?: MultisendPayload
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const initialWidgetState: WidgetState = {}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file can be used to override default props and styles on the various Material components
|
|
3
|
+
* see: https://mui.com/customization/theme-components/
|
|
4
|
+
*/
|
|
5
|
+
import { Theme, ThemeOptions } from '@mui/material'
|
|
6
|
+
|
|
7
|
+
export function components(theme: Theme): ThemeOptions['components'] {
|
|
8
|
+
return {
|
|
9
|
+
MuiButton: {
|
|
10
|
+
defaultProps: {
|
|
11
|
+
disableElevation: true,
|
|
12
|
+
},
|
|
13
|
+
styleOverrides: {
|
|
14
|
+
contained: {
|
|
15
|
+
// align outlined vs contained borders
|
|
16
|
+
border: '1px solid transparent',
|
|
17
|
+
background:
|
|
18
|
+
'linear-gradient(232.71deg, #A363F4 4.17%, #FF6A8A 178.69%)',
|
|
19
|
+
},
|
|
20
|
+
outlined: {
|
|
21
|
+
'.MuiBox-root': {
|
|
22
|
+
background:
|
|
23
|
+
'linear-gradient(232.71deg, #A363F4 4.17%, #FF6A8A 178.69%)',
|
|
24
|
+
backgroundClip: 'text',
|
|
25
|
+
textFillColor: 'transparent',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
root: {
|
|
29
|
+
fontFamily: 'Uni-Neue-Bold',
|
|
30
|
+
fontSize: '15px',
|
|
31
|
+
borderRadius: '32px',
|
|
32
|
+
'&.MuiButton-containedPrimary': {
|
|
33
|
+
'&:hover': {
|
|
34
|
+
backgroundColor: theme.palette.primary.main,
|
|
35
|
+
},
|
|
36
|
+
boxShadow:
|
|
37
|
+
'0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px rgba(0, 0, 0, 0.14), 0px 1px 5px rgba(0, 0, 0, 0.12)',
|
|
38
|
+
},
|
|
39
|
+
'&.MuiButton-outlinedPrimary': {
|
|
40
|
+
'&:hover': {
|
|
41
|
+
backgroundColor: theme.palette.common.white,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
textTransform: 'none',
|
|
45
|
+
'&:disabled': {
|
|
46
|
+
border: 'none',
|
|
47
|
+
background: 'rgba(0, 0, 0, 0.12)',
|
|
48
|
+
boxShadow: 'unset',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
MuiButtonBase: {
|
|
54
|
+
defaultProps: {},
|
|
55
|
+
},
|
|
56
|
+
MuiCssBaseline: {
|
|
57
|
+
styleOverrides: {
|
|
58
|
+
dd: {
|
|
59
|
+
margin: 0,
|
|
60
|
+
},
|
|
61
|
+
dl: {
|
|
62
|
+
margin: 0,
|
|
63
|
+
},
|
|
64
|
+
dt: {
|
|
65
|
+
margin: 0,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const coreThemeConstants = {
|
|
2
|
+
borderRadius: {
|
|
3
|
+
md: 4,
|
|
4
|
+
},
|
|
5
|
+
fontFamily: [
|
|
6
|
+
'Roboto',
|
|
7
|
+
'-apple-system',
|
|
8
|
+
'BlinkMacSystemFont',
|
|
9
|
+
'"Segoe UI"',
|
|
10
|
+
'"Helvetica Neue"',
|
|
11
|
+
'Arial',
|
|
12
|
+
'sans-serif',
|
|
13
|
+
'"Apple Color Emoji"',
|
|
14
|
+
'"Segoe UI Emoji"',
|
|
15
|
+
'"Segoe UI Symbol"',
|
|
16
|
+
].join(','),
|
|
17
|
+
letterSpacing: {
|
|
18
|
+
lg: '2px',
|
|
19
|
+
md: '1px',
|
|
20
|
+
sm: '0.45px',
|
|
21
|
+
xs: '0.25px',
|
|
22
|
+
},
|
|
23
|
+
lineHeight: {
|
|
24
|
+
lg: 1.4, // 22.4px on 16
|
|
25
|
+
md: 1.1875, // 19px on 16, 47.5 on 40
|
|
26
|
+
xl: 1.5, // 24px on 16
|
|
27
|
+
},
|
|
28
|
+
spacingBase: 8, // 8px grid
|
|
29
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { css, SerializedStyles } from '@emotion/react'
|
|
2
|
+
import { createTheme } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
import { coreThemeConstants } from './coreThemeConstants'
|
|
5
|
+
|
|
6
|
+
const theme = createTheme({
|
|
7
|
+
spacing: coreThemeConstants.spacingBase,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
} as any)
|
|
10
|
+
|
|
11
|
+
export const cssMixins = {
|
|
12
|
+
appHeaderHeight: '80px',
|
|
13
|
+
appFooterHeight: '80px',
|
|
14
|
+
colCentered: css`
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
`,
|
|
20
|
+
colHCentered: css`
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
display: flex;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
`,
|
|
25
|
+
colStretch: css`
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
`,
|
|
29
|
+
colVCentered: css`
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
align-items: center;
|
|
32
|
+
display: flex;
|
|
33
|
+
`,
|
|
34
|
+
rowCentered: css`
|
|
35
|
+
align-items: center;
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
`,
|
|
39
|
+
rowHCentered: css`
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
`,
|
|
43
|
+
rowStretch: css`
|
|
44
|
+
display: flex;
|
|
45
|
+
`,
|
|
46
|
+
rowSpaceBetweened: css`
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
`,
|
|
50
|
+
rowFlexEnd: css`
|
|
51
|
+
justify-content: flex-end;
|
|
52
|
+
display: flex;
|
|
53
|
+
`,
|
|
54
|
+
rowVCentered: css`
|
|
55
|
+
align-items: center;
|
|
56
|
+
display: flex;
|
|
57
|
+
`,
|
|
58
|
+
spaceSimpleH: (spacing: number): SerializedStyles => css`
|
|
59
|
+
margin-right: ${theme.spacing(spacing)};
|
|
60
|
+
|
|
61
|
+
&:last-child {
|
|
62
|
+
margin-right: 0;
|
|
63
|
+
}
|
|
64
|
+
`,
|
|
65
|
+
spaceSimpleV: (spacing: number): SerializedStyles => css`
|
|
66
|
+
margin-bottom: ${theme.spacing(spacing)};
|
|
67
|
+
|
|
68
|
+
&:last-child {
|
|
69
|
+
margin-bottom: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
+ & {
|
|
73
|
+
margin-top: ${theme.spacing(spacing)};
|
|
74
|
+
}
|
|
75
|
+
`,
|
|
76
|
+
stretchAll: css`
|
|
77
|
+
top: 0;
|
|
78
|
+
right: 0;
|
|
79
|
+
bottom: 0;
|
|
80
|
+
left: 0;
|
|
81
|
+
`,
|
|
82
|
+
stretchBottom: css`
|
|
83
|
+
right: 0;
|
|
84
|
+
bottom: 0;
|
|
85
|
+
left: 0;
|
|
86
|
+
`,
|
|
87
|
+
stretchTop: css`
|
|
88
|
+
top: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
left: 0;
|
|
91
|
+
`,
|
|
92
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Theme, useMediaQuery } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
type UseGetSizesType = {
|
|
4
|
+
isAboveSm: boolean
|
|
5
|
+
isBelowLgSize: boolean
|
|
6
|
+
isBelowMdSize: boolean
|
|
7
|
+
isBelowXsSize: boolean
|
|
8
|
+
isLgSize: boolean
|
|
9
|
+
isMediumSize: boolean
|
|
10
|
+
isMobileDisplay: boolean
|
|
11
|
+
isXsSize: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useGetSizes(theme: Theme): UseGetSizesType {
|
|
15
|
+
const isMobileDisplay = useMediaQuery(theme.breakpoints.down('md'))
|
|
16
|
+
const isLgSize = useMediaQuery(theme.breakpoints.up('lg'))
|
|
17
|
+
const isBelowLgSize = useMediaQuery(theme.breakpoints.down('lg'))
|
|
18
|
+
const isXsSize = useMediaQuery(theme.breakpoints.down('sm'))
|
|
19
|
+
const isAboveSm = useMediaQuery(theme.breakpoints.up('sm'))
|
|
20
|
+
const isBelowXsSize = useMediaQuery(theme.breakpoints.down('xs'))
|
|
21
|
+
const isBelowMdSize = useMediaQuery(theme.breakpoints.down('md'))
|
|
22
|
+
const isMediumSize = isMobileDisplay && isAboveSm
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
isAboveSm,
|
|
26
|
+
isBelowLgSize,
|
|
27
|
+
isBelowMdSize,
|
|
28
|
+
isBelowXsSize,
|
|
29
|
+
isLgSize,
|
|
30
|
+
isMediumSize,
|
|
31
|
+
isMobileDisplay,
|
|
32
|
+
isXsSize,
|
|
33
|
+
}
|
|
34
|
+
}
|