@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.
- package/dist/cjs/index.cjs +139 -131
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +139 -131
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Activity.tsx +123 -123
- package/src/components/AllowListModal.tsx +113 -113
- package/src/components/ApproveAllowanceModal.tsx +118 -118
- package/src/components/ChooseAmountModal.tsx +315 -315
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +158 -159
- package/src/components/CreditLine/borrow/2-AllowList.tsx +34 -34
- package/src/components/CreditLine/borrow/3-ChooseAmount.tsx +74 -74
- package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -29
- package/src/components/CreditLine/borrow/5-Transfer.tsx +30 -30
- package/src/components/CreditLine/borrow/6-Success.tsx +30 -30
- package/src/components/CreditLine/borrow/index.tsx +119 -119
- package/src/components/CreditLine/payment/1-ChooseAmount.tsx +67 -67
- package/src/components/CreditLine/payment/2-ApproveAllowance.tsx +23 -23
- package/src/components/CreditLine/payment/3-Transfer.tsx +34 -34
- package/src/components/CreditLine/payment/4-Success.tsx +39 -39
- package/src/components/CreditLine/payment/index.tsx +94 -94
- package/src/components/ErrorModal.tsx +132 -132
- package/src/components/Factoring/FactoredList.tsx +143 -143
- package/src/components/Factoring/UpcomingList.tsx +90 -90
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +52 -46
- package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +34 -34
- package/src/components/InvoiceFactoring/borrow/3-ChooseAmount.tsx +86 -92
- package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +104 -104
- package/src/components/InvoiceFactoring/borrow/5-ApproveNFT.tsx +55 -55
- package/src/components/InvoiceFactoring/borrow/6-Transfer.tsx +34 -34
- package/src/components/InvoiceFactoring/borrow/7-Success.tsx +3 -3
- package/src/components/InvoiceFactoring/borrow/index.tsx +96 -96
- package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +67 -67
- package/src/components/InvoiceFactoring/payment/2-ApproveAllowance.tsx +23 -23
- package/src/components/InvoiceFactoring/payment/3-Transfer.tsx +34 -34
- package/src/components/InvoiceFactoring/payment/4-Success.tsx +23 -23
- package/src/components/InvoiceFactoring/payment/index.tsx +86 -86
- package/src/components/Lend/supply/1-Evaluation.tsx +86 -86
- package/src/components/Lend/supply/2-ChooseAmount.tsx +70 -70
- package/src/components/Lend/supply/3-ApproveAllowance.tsx +25 -25
- package/src/components/Lend/supply/4-ConfirmTransfer.tsx +104 -104
- package/src/components/Lend/supply/6-Transfer.tsx +32 -32
- package/src/components/Lend/supply/7-Success.tsx +49 -49
- package/src/components/Lend/supply/index.tsx +144 -144
- package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +73 -73
- package/src/components/Lend/withdraw/2-ChooseAmount.tsx +50 -50
- package/src/components/Lend/withdraw/3-Transfer.tsx +32 -32
- package/src/components/Lend/withdraw/4-Success.tsx +49 -49
- package/src/components/Lend/withdraw/index.tsx +101 -101
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +47 -57
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +124 -124
- package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +104 -104
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +65 -65
- package/src/components/StreamFactoring/borrow/5-Permit.tsx +144 -144
- package/src/components/StreamFactoring/borrow/6-Transfer.tsx +37 -37
- package/src/components/StreamFactoring/borrow/7-Success.tsx +2 -2
- package/src/components/StreamFactoring/borrow/index.tsx +94 -95
- package/src/components/StreamFactoring/payment/ChooseAmount.tsx +54 -54
- package/src/components/StreamFactoring/payment/Success.tsx +23 -23
- package/src/components/StreamFactoring/payment/Transfer.tsx +34 -34
- package/src/components/StreamFactoring/payment/index.tsx +66 -66
- package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +61 -61
- package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +185 -185
- package/src/components/SuperfluidFactoring/index.tsx +85 -85
- package/src/components/TxDoneModal.tsx +83 -83
- package/src/components/TxSendModal.tsx +59 -59
- package/src/components/ViewOnExplorer.tsx +26 -26
- package/src/components/WidgetWrapper.tsx +74 -74
- package/src/components/humaModal/HumaModal.tsx +68 -68
- package/src/cosmos/SDKTesting.fixture.tsx +557 -515
- package/src/hooks/useEA.ts +72 -70
- package/src/index.tsx +219 -219
- package/src/store/widgets.reducers.ts +120 -120
- package/src/store/widgets.store.ts +55 -55
- package/src/theme/components.ts +1 -1
- package/src/theme/hooks/useGetSizes.ts +0 -3
package/src/hooks/useEA.ts
CHANGED
|
@@ -1,70 +1,72 @@
|
|
|
1
|
-
import { useWeb3React } from '@web3-react/core'
|
|
2
|
-
import {
|
|
3
|
-
downScale,
|
|
4
|
-
EAPayload,
|
|
5
|
-
EARejectionError,
|
|
6
|
-
EARejectMessage,
|
|
7
|
-
EARejectReason,
|
|
8
|
-
EAService,
|
|
9
|
-
} from '@huma-finance/shared'
|
|
10
|
-
import { useCallback } from 'react'
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import { WIDGET_STEP } from '../store/widgets.store'
|
|
14
|
-
import { useAppDispatch } from './useRedux'
|
|
15
|
-
import { envUtil } from '../utils/env'
|
|
16
|
-
|
|
17
|
-
const useEA = () => {
|
|
18
|
-
const dispatch = useAppDispatch()
|
|
19
|
-
const { chainId } = useWeb3React()
|
|
20
|
-
|
|
21
|
-
const checkingEA = useCallback(
|
|
22
|
-
async (
|
|
23
|
-
payload: EAPayload,
|
|
24
|
-
nextStep: WIDGET_STEP,
|
|
25
|
-
addToAllowList = false,
|
|
26
|
-
) => {
|
|
27
|
-
try {
|
|
28
|
-
const result = await EAService.approve(
|
|
29
|
-
payload,
|
|
30
|
-
chainId!,
|
|
31
|
-
envUtil.checkIsDev(),
|
|
32
|
-
)
|
|
33
|
-
result.creditLimit = downScale<number>(
|
|
34
|
-
result.creditLimit,
|
|
35
|
-
result.
|
|
36
|
-
)
|
|
37
|
-
result.
|
|
38
|
-
result.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
dispatch(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import { useWeb3React } from '@web3-react/core'
|
|
2
|
+
import {
|
|
3
|
+
downScale,
|
|
4
|
+
EAPayload,
|
|
5
|
+
EARejectionError,
|
|
6
|
+
EARejectMessage,
|
|
7
|
+
EARejectReason,
|
|
8
|
+
EAService,
|
|
9
|
+
} from '@huma-finance/shared'
|
|
10
|
+
import { useCallback } from 'react'
|
|
11
|
+
|
|
12
|
+
import { setApproval, setError, setStep } from '../store/widgets.reducers'
|
|
13
|
+
import { WIDGET_STEP } from '../store/widgets.store'
|
|
14
|
+
import { useAppDispatch } from './useRedux'
|
|
15
|
+
import { envUtil } from '../utils/env'
|
|
16
|
+
|
|
17
|
+
const useEA = () => {
|
|
18
|
+
const dispatch = useAppDispatch()
|
|
19
|
+
const { chainId } = useWeb3React()
|
|
20
|
+
|
|
21
|
+
const checkingEA = useCallback(
|
|
22
|
+
async (
|
|
23
|
+
payload: EAPayload,
|
|
24
|
+
nextStep: WIDGET_STEP,
|
|
25
|
+
addToAllowList = false,
|
|
26
|
+
) => {
|
|
27
|
+
try {
|
|
28
|
+
const result = await EAService.approve(
|
|
29
|
+
payload,
|
|
30
|
+
chainId!,
|
|
31
|
+
envUtil.checkIsDev(),
|
|
32
|
+
)
|
|
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
|
+
dispatch(setApproval({ ...result, nextStep }))
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
} catch (e: any) {
|
|
46
|
+
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
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
dispatch(
|
|
59
|
+
setError({
|
|
60
|
+
errorMessage: e.message,
|
|
61
|
+
}),
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[chainId, dispatch],
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return { checkingEA }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default useEA
|
package/src/index.tsx
CHANGED
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
import './index.css'
|
|
2
|
-
|
|
3
|
-
import { JsonRpcProvider } from '@ethersproject/providers'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '@
|
|
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
|
-
}
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
3
|
+
import { JsonRpcProvider } from '@ethersproject/providers'
|
|
4
|
+
import {
|
|
5
|
+
Provider as Web3Provider,
|
|
6
|
+
ProviderProps as Web3Props,
|
|
7
|
+
} from '@huma-finance/shared'
|
|
8
|
+
import { ThemeProvider } from '@mui/material'
|
|
9
|
+
import { Provider as Eip1193Provider } from '@web3-react/types'
|
|
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
|
+
}
|