@huma-finance/widgets 0.0.51-beta.227 → 0.0.51-beta.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +454 -0
- package/dist/cjs/index.cjs +6097 -3790
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +280 -2
- package/dist/index.js +6089 -3792
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/ApproveAllowanceModal.tsx +3 -1
- package/src/components/ApproveAllowanceModalV2.tsx +141 -0
- package/src/components/CreditLine/approve/index.tsx +9 -3
- package/src/components/CreditLine/autoPaybackV2/1-ApproveAllowance.tsx +33 -0
- package/src/components/CreditLine/autoPaybackV2/2-Success.tsx +13 -0
- package/src/components/CreditLine/autoPaybackV2/index.tsx +87 -0
- package/src/components/CreditLine/borrow/2-ChooseAmount.tsx +12 -3
- package/src/components/CreditLine/borrow/5-Success.tsx +7 -2
- package/src/components/CreditLine/borrow/index.tsx +4 -2
- package/src/components/CreditLine/borrowV2/1-ChooseAmount.tsx +81 -0
- package/src/components/CreditLine/borrowV2/2-ApproveAllowance.tsx +33 -0
- package/src/components/CreditLine/borrowV2/3-Transfer.tsx +50 -0
- package/src/components/CreditLine/borrowV2/4-Success.tsx +42 -0
- package/src/components/CreditLine/borrowV2/5-Notifications.tsx +10 -0
- package/src/components/CreditLine/borrowV2/index.tsx +140 -0
- package/src/components/CreditLine/payment/1-ChooseAmount.tsx +9 -5
- package/src/components/CreditLine/payment/3-Transfer.tsx +1 -5
- package/src/components/CreditLine/payment/4-Success.tsx +2 -2
- package/src/components/CreditLine/payment/index.tsx +4 -2
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +96 -0
- package/src/components/CreditLine/paymentV2/2-ApproveAllowance.tsx +33 -0
- package/src/components/CreditLine/paymentV2/3-Transfer.tsx +55 -0
- package/src/components/CreditLine/paymentV2/4-Success.tsx +42 -0
- package/src/components/CreditLine/paymentV2/index.tsx +111 -0
- package/src/components/CreditLine/supplyFLC/1-ApproveAllowance.tsx +40 -0
- package/src/components/CreditLine/supplyFLC/2-Transfer.tsx +53 -0
- package/src/components/CreditLine/supplyFLC/3-Success.tsx +26 -0
- package/src/components/CreditLine/supplyFLC/index.tsx +121 -0
- package/src/components/Factoring/FactoredList.tsx +2 -1
- package/src/components/InputAmountModal.tsx +156 -0
- package/src/components/InvoiceFactoring/borrow/2-ChooseAmount.tsx +8 -1
- package/src/components/InvoiceFactoring/borrow/4-ApproveNFT.tsx +6 -2
- package/src/components/InvoiceFactoring/borrow/6-Success.tsx +5 -1
- package/src/components/InvoiceFactoring/borrow/index.tsx +9 -3
- package/src/components/InvoiceFactoring/payment/1-ChooseAmount.tsx +7 -2
- package/src/components/InvoiceFactoring/payment/index.tsx +9 -3
- package/src/components/Lend/addRedemptionV2/1-ChooseTranche.tsx +114 -0
- package/src/components/Lend/addRedemptionV2/2-ChooseAmount.tsx +114 -0
- package/src/components/Lend/addRedemptionV2/3-Transfer.tsx +56 -0
- package/src/components/Lend/addRedemptionV2/4-Done.tsx +20 -0
- package/src/components/Lend/addRedemptionV2/index.tsx +173 -0
- package/src/components/Lend/cancelRedemptionV2 /1-Transfer.tsx +51 -0
- package/src/components/Lend/cancelRedemptionV2 /2-Done.tsx +29 -0
- package/src/components/Lend/cancelRedemptionV2 /index.tsx +120 -0
- package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +19 -2
- package/src/components/Lend/supply/2-ChooseAmount.tsx +1 -0
- package/src/components/Lend/supply/index.tsx +17 -3
- package/src/components/Lend/supplyV2/1-ChooseTranche.tsx +116 -0
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +345 -0
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +87 -0
- package/src/components/Lend/supplyV2/4-ApproveAllowance.tsx +33 -0
- package/src/components/Lend/supplyV2/5-Transfer.tsx +59 -0
- package/src/components/Lend/supplyV2/6-Success.tsx +79 -0
- package/src/components/Lend/supplyV2/7-Notifications.tsx +10 -0
- package/src/components/Lend/supplyV2/index.tsx +175 -0
- package/src/components/Lend/withdraw/1-CheckWithdrawble.tsx +5 -1
- package/src/components/Lend/withdraw/index.tsx +10 -3
- package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +135 -0
- package/src/components/Lend/withdrawV2/2-Transfer.tsx +50 -0
- package/src/components/Lend/withdrawV2/3-Done.tsx +31 -0
- package/src/components/Lend/withdrawV2/index.tsx +177 -0
- package/src/components/Notifi/NotifiSubscriptionModal.tsx +26 -38
- package/src/components/NumericFormatCustom.tsx +33 -0
- package/src/components/ReceivableBackedCreditLine/borrow/1-ChooseAmount.tsx +101 -0
- package/src/components/ReceivableBackedCreditLine/borrow/2-ApproveAllowance.tsx +33 -0
- package/src/components/ReceivableBackedCreditLine/borrow/3-ApproveReceivable.tsx +64 -0
- package/src/components/ReceivableBackedCreditLine/borrow/4-Transfer.tsx +61 -0
- package/src/components/ReceivableBackedCreditLine/borrow/5-Success.tsx +42 -0
- package/src/components/ReceivableBackedCreditLine/borrow/6-Notifications.tsx +10 -0
- package/src/components/ReceivableBackedCreditLine/borrow/index.tsx +148 -0
- package/src/components/ReceivableBackedCreditLine/payment/1-ChoosePaymentType.tsx +115 -0
- package/src/components/ReceivableBackedCreditLine/payment/2-ChooseAmount.tsx +84 -0
- package/src/components/ReceivableBackedCreditLine/payment/3-ApproveAllowance.tsx +41 -0
- package/src/components/ReceivableBackedCreditLine/payment/4-CreateReceivable.tsx +107 -0
- package/src/components/ReceivableBackedCreditLine/payment/5-ApproveReceivable.tsx +64 -0
- package/src/components/ReceivableBackedCreditLine/payment/6-Transfer.tsx +107 -0
- package/src/components/ReceivableBackedCreditLine/payment/7-Success.tsx +49 -0
- package/src/components/ReceivableBackedCreditLine/payment/index.tsx +159 -0
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +8 -1
- package/src/components/StreamFactoring/borrow/6-Transfer.tsx +3 -1
- package/src/components/StreamFactoring/borrow/7-Success.tsx +3 -1
- package/src/components/StreamFactoring/borrow/index.tsx +2 -2
- package/src/components/TxDoneModal.tsx +1 -1
- package/src/components/TxSendModal.tsx +8 -2
- package/src/components/TxSendModalV2.tsx +51 -0
- package/src/hooks/useNotifi.ts +4 -6
- package/src/index.tsx +268 -1
- package/src/store/widgets.reducers.ts +15 -0
- package/src/store/widgets.store.ts +6 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
POOL_NAME,
|
|
3
|
+
useCreditStatsV2,
|
|
4
|
+
usePoolInfoV2,
|
|
5
|
+
usePoolUnderlyingTokenInfoV2,
|
|
6
|
+
useReceivableInfoV2,
|
|
7
|
+
} from '@huma-finance/shared'
|
|
8
|
+
import { useWeb3React } from '@web3-react/core'
|
|
9
|
+
import { BigNumber, ethers } from 'ethers'
|
|
10
|
+
import React, { useEffect, useState } from 'react'
|
|
11
|
+
import { useDispatch } from 'react-redux'
|
|
12
|
+
|
|
13
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
14
|
+
import { setStep } from '../../../store/widgets.reducers'
|
|
15
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
16
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
17
|
+
import { ErrorModal } from '../../ErrorModal'
|
|
18
|
+
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
19
|
+
import { ChoosePaymentType } from './1-ChoosePaymentType'
|
|
20
|
+
import { ChooseAmount } from './2-ChooseAmount'
|
|
21
|
+
import { ApproveAllowance } from './3-ApproveAllowance'
|
|
22
|
+
import { CreateReceivable } from './4-CreateReceivable'
|
|
23
|
+
import { ApproveReceivable } from './5-ApproveReceivable'
|
|
24
|
+
import { Transfer } from './6-Transfer'
|
|
25
|
+
import { Success } from './7-Success'
|
|
26
|
+
|
|
27
|
+
export enum PaymentType {
|
|
28
|
+
PaymentWithReceivable = 1,
|
|
29
|
+
PaymentWithReceivableAndDrawdown = 2,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Credit line pool payment props V2
|
|
34
|
+
* @typedef {Object} CreditLinePaymentPropsV2
|
|
35
|
+
* @property {POOL_NAME} poolName The name of the pool.
|
|
36
|
+
* @property {tokenId} tokenID The receivable token id.
|
|
37
|
+
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
38
|
+
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the credit line pool payment action is successful.
|
|
39
|
+
*/
|
|
40
|
+
export type ReceivableBackedCreditLinePaymentPropsV2 = {
|
|
41
|
+
poolName: keyof typeof POOL_NAME
|
|
42
|
+
tokenId: string
|
|
43
|
+
handleClose: () => void
|
|
44
|
+
handleSuccess?: (blockNumber?: number) => void
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function ReceivableBackedCreditLinePaymentV2({
|
|
48
|
+
poolName: poolNameStr,
|
|
49
|
+
tokenId,
|
|
50
|
+
handleClose,
|
|
51
|
+
handleSuccess,
|
|
52
|
+
}: ReceivableBackedCreditLinePaymentPropsV2): React.ReactElement | null {
|
|
53
|
+
const dispatch = useDispatch()
|
|
54
|
+
const { account, chainId, provider } = useWeb3React()
|
|
55
|
+
const poolName = POOL_NAME[poolNameStr]
|
|
56
|
+
const poolInfo = usePoolInfoV2(poolName, chainId)
|
|
57
|
+
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
58
|
+
const [{ creditRecord }] = useCreditStatsV2(poolName, account, provider)
|
|
59
|
+
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
60
|
+
const [paymentType, setPaymentType] = useState<PaymentType>()
|
|
61
|
+
|
|
62
|
+
const [borrowTokenId, setBorrowTokenId] = useState<string>()
|
|
63
|
+
const paymentReceivableInfo = useReceivableInfoV2(poolName, tokenId, provider)
|
|
64
|
+
const payoffAmount = paymentReceivableInfo
|
|
65
|
+
? BigNumber.from(paymentReceivableInfo.receivableAmount).sub(
|
|
66
|
+
paymentReceivableInfo.paidAmount,
|
|
67
|
+
)
|
|
68
|
+
: BigNumber.from(0)
|
|
69
|
+
const [successTxReceipt, setSuccessTxReceipt] =
|
|
70
|
+
useState<ethers.ContractReceipt>()
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
dispatch(setStep(WIDGET_STEP.ChoosePaymentType))
|
|
74
|
+
}, [dispatch])
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
!poolInfo ||
|
|
78
|
+
!creditRecord ||
|
|
79
|
+
!poolUnderlyingToken ||
|
|
80
|
+
!paymentReceivableInfo
|
|
81
|
+
) {
|
|
82
|
+
return (
|
|
83
|
+
<WidgetWrapper
|
|
84
|
+
isOpen
|
|
85
|
+
isLoading
|
|
86
|
+
loadingTitle='Pay'
|
|
87
|
+
handleClose={handleClose}
|
|
88
|
+
handleSuccess={handleSuccess}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<WidgetWrapper
|
|
95
|
+
isOpen
|
|
96
|
+
isLoading={!creditRecord}
|
|
97
|
+
loadingTitle='Pay'
|
|
98
|
+
handleClose={handleClose}
|
|
99
|
+
handleSuccess={handleSuccess}
|
|
100
|
+
>
|
|
101
|
+
{step === WIDGET_STEP.ChoosePaymentType && (
|
|
102
|
+
<ChoosePaymentType
|
|
103
|
+
paymentType={paymentType}
|
|
104
|
+
changePaymentType={setPaymentType}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
{step === WIDGET_STEP.ChooseAmount && paymentType && (
|
|
108
|
+
<ChooseAmount
|
|
109
|
+
poolInfo={poolInfo}
|
|
110
|
+
poolUnderlyingToken={poolUnderlyingToken}
|
|
111
|
+
payoffAmount={payoffAmount}
|
|
112
|
+
paymentType={paymentType}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
{step === WIDGET_STEP.ApproveAllowance && paymentType && (
|
|
116
|
+
<ApproveAllowance
|
|
117
|
+
poolInfo={poolInfo}
|
|
118
|
+
poolUnderlyingToken={poolUnderlyingToken}
|
|
119
|
+
paymentType={paymentType}
|
|
120
|
+
/>
|
|
121
|
+
)}
|
|
122
|
+
{step === WIDGET_STEP.MintNFT && (
|
|
123
|
+
<CreateReceivable
|
|
124
|
+
poolInfo={poolInfo}
|
|
125
|
+
poolUnderlyingToken={poolUnderlyingToken}
|
|
126
|
+
setTokenId={setBorrowTokenId}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
{step === WIDGET_STEP.ApproveNFT && borrowTokenId && (
|
|
130
|
+
<ApproveReceivable poolInfo={poolInfo} tokenId={borrowTokenId} />
|
|
131
|
+
)}
|
|
132
|
+
{step === WIDGET_STEP.Transfer && paymentType && (
|
|
133
|
+
<Transfer
|
|
134
|
+
poolInfo={poolInfo}
|
|
135
|
+
poolUnderlyingToken={poolUnderlyingToken}
|
|
136
|
+
paymentType={paymentType}
|
|
137
|
+
paymentTokenId={tokenId}
|
|
138
|
+
borrowTokenId={borrowTokenId}
|
|
139
|
+
setSuccessTxReceipt={setSuccessTxReceipt}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
{step === WIDGET_STEP.Done && paymentType && successTxReceipt && (
|
|
143
|
+
<Success
|
|
144
|
+
poolUnderlyingToken={poolUnderlyingToken}
|
|
145
|
+
paymentType={paymentType}
|
|
146
|
+
handleAction={handleClose}
|
|
147
|
+
successTxReceipt={successTxReceipt}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
150
|
+
{step === WIDGET_STEP.Error && (
|
|
151
|
+
<ErrorModal
|
|
152
|
+
title='Pay'
|
|
153
|
+
errorMessage={errorMessage}
|
|
154
|
+
handleOk={handleClose}
|
|
155
|
+
/>
|
|
156
|
+
)}
|
|
157
|
+
</WidgetWrapper>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@huma-finance/shared'
|
|
8
8
|
import React, { useCallback, useState } from 'react'
|
|
9
9
|
|
|
10
|
+
import { useWeb3React } from '@web3-react/core'
|
|
10
11
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
11
12
|
import { setBorrowInfo, setStream } from '../../../store/widgets.reducers'
|
|
12
13
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
@@ -23,8 +24,14 @@ export function ChooseAmount({
|
|
|
23
24
|
currentFlowRate,
|
|
24
25
|
}: Props): React.ReactElement | null {
|
|
25
26
|
const dispatch = useAppDispatch()
|
|
27
|
+
const { chainId, provider } = useWeb3React()
|
|
26
28
|
const { approval } = useAppSelector(selectWidgetState)
|
|
27
|
-
const { getFeesCharged } = useFeeManager(
|
|
29
|
+
const { getFeesCharged } = useFeeManager(
|
|
30
|
+
poolInfo.poolName,
|
|
31
|
+
poolInfo.poolType,
|
|
32
|
+
chainId,
|
|
33
|
+
provider,
|
|
34
|
+
)
|
|
28
35
|
const [chargedFees, setChargedFees] = useState(0)
|
|
29
36
|
const [currentAmount, setCurrentAmount] = useState(0)
|
|
30
37
|
const borrowPeriodInSeconds = approval!.terms.intervalInDays * 24 * 60 * 60
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PoolInfoType, useMultiSendContract } from '@huma-finance/shared'
|
|
2
2
|
import React, { useCallback } from 'react'
|
|
3
3
|
|
|
4
|
+
import { useWeb3React } from '@web3-react/core'
|
|
4
5
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
5
6
|
import { setStep } from '../../../store/widgets.reducers'
|
|
6
7
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
@@ -13,8 +14,9 @@ type Props = {
|
|
|
13
14
|
|
|
14
15
|
export function Transfer({ poolInfo }: Props): React.ReactElement | null {
|
|
15
16
|
const dispatch = useAppDispatch()
|
|
16
|
-
const
|
|
17
|
+
const { chainId, provider } = useWeb3React()
|
|
17
18
|
const { multisend } = useAppSelector(selectWidgetState)
|
|
19
|
+
const multiSendContract = useMultiSendContract(chainId, provider)
|
|
18
20
|
|
|
19
21
|
const handleSuccess = useCallback(() => {
|
|
20
22
|
dispatch(setStep(WIDGET_STEP.Done))
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { formatNumber } from '@huma-finance/shared'
|
|
1
2
|
import React from 'react'
|
|
3
|
+
|
|
2
4
|
import { useAppSelector } from '../../../hooks/useRedux'
|
|
3
5
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
4
6
|
import { TxDoneModal } from '../../TxDoneModal'
|
|
@@ -11,7 +13,7 @@ export function Success({ handleAction }: Props): React.ReactElement {
|
|
|
11
13
|
const { borrowAmount, approval } = useAppSelector(selectWidgetState)
|
|
12
14
|
|
|
13
15
|
const content = [
|
|
14
|
-
`${borrowAmount
|
|
16
|
+
`${formatNumber(borrowAmount)} ${
|
|
15
17
|
approval?.token.symbol
|
|
16
18
|
} is now in your wallet.`,
|
|
17
19
|
]
|
|
@@ -39,8 +39,8 @@ export function StreamFactoringBorrow({
|
|
|
39
39
|
handleSuccess,
|
|
40
40
|
}: StreamFactoringBorrowProps): React.ReactElement | null {
|
|
41
41
|
const dispatch = useDispatch()
|
|
42
|
-
const { account } = useWeb3React()
|
|
43
|
-
const poolInfo = usePoolInfo(poolName, poolType)
|
|
42
|
+
const { account, chainId } = useWeb3React()
|
|
43
|
+
const poolInfo = usePoolInfo(poolName, poolType, chainId)
|
|
44
44
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
45
45
|
|
|
46
46
|
useEffect(() => {
|
|
@@ -32,8 +32,14 @@ export function TxSendModal({
|
|
|
32
32
|
handleSuccess,
|
|
33
33
|
}: Props): React.ReactElement {
|
|
34
34
|
const dispatch = useAppDispatch()
|
|
35
|
-
const { provider } = useWeb3React()
|
|
36
|
-
const poolContract = usePoolContract(
|
|
35
|
+
const { provider, chainId, account } = useWeb3React()
|
|
36
|
+
const poolContract = usePoolContract(
|
|
37
|
+
poolInfo.poolName,
|
|
38
|
+
poolInfo.poolType,
|
|
39
|
+
chainId,
|
|
40
|
+
provider,
|
|
41
|
+
account,
|
|
42
|
+
)
|
|
37
43
|
const [{ state, txHash }, send] = useAtom(sendTxAtom)
|
|
38
44
|
|
|
39
45
|
useEffect(() => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { sendTxAtom, TxStateType, useMount } from '@huma-finance/shared'
|
|
2
|
+
import { useWeb3React } from '@web3-react/core'
|
|
3
|
+
import { Contract } from 'ethers'
|
|
4
|
+
import { useAtom } from 'jotai'
|
|
5
|
+
import React, { useEffect } from 'react'
|
|
6
|
+
|
|
7
|
+
import { useAppDispatch } from '../hooks/useRedux'
|
|
8
|
+
import { LoadingModal } from './LoadingModal'
|
|
9
|
+
import { ViewOnExplorer } from './ViewOnExplorer'
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
method: string
|
|
13
|
+
params: unknown[]
|
|
14
|
+
title?: string
|
|
15
|
+
contract: Contract
|
|
16
|
+
handleSuccess?: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function TxSendModalV2({
|
|
20
|
+
title,
|
|
21
|
+
method,
|
|
22
|
+
params,
|
|
23
|
+
contract,
|
|
24
|
+
handleSuccess,
|
|
25
|
+
}: Props): React.ReactElement {
|
|
26
|
+
const dispatch = useAppDispatch()
|
|
27
|
+
const { provider } = useWeb3React()
|
|
28
|
+
|
|
29
|
+
const [{ state, txHash }, send] = useAtom(sendTxAtom)
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (state === TxStateType.Success) {
|
|
33
|
+
if (handleSuccess) {
|
|
34
|
+
handleSuccess()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, [dispatch, handleSuccess, state])
|
|
38
|
+
|
|
39
|
+
useMount(() => {
|
|
40
|
+
send({ contract, method, params, provider })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<LoadingModal
|
|
45
|
+
title={title ?? 'Transaction Pending'}
|
|
46
|
+
description='Waiting for confirmation...'
|
|
47
|
+
>
|
|
48
|
+
<ViewOnExplorer txHash={txHash} />
|
|
49
|
+
</LoadingModal>
|
|
50
|
+
)
|
|
51
|
+
}
|
package/src/hooks/useNotifi.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
checkIsDev,
|
|
4
4
|
doesChainSupportNotifi,
|
|
5
5
|
getBlockchainConfigFromChain,
|
|
6
|
-
getNotifiDappId,
|
|
7
6
|
} from '@huma-finance/shared'
|
|
8
7
|
import {
|
|
9
8
|
NotifiFrontendClient,
|
|
@@ -34,7 +33,6 @@ export const useDoesChainSupportNotifi = (
|
|
|
34
33
|
export const useNotifiClient = (
|
|
35
34
|
account: string | undefined,
|
|
36
35
|
chainId: number | undefined,
|
|
37
|
-
isDev: boolean,
|
|
38
36
|
) => {
|
|
39
37
|
const [notifiClient, setNotifiClient] = useState<NotifiFrontendClient | null>(
|
|
40
38
|
null,
|
|
@@ -46,8 +44,8 @@ export const useNotifiClient = (
|
|
|
46
44
|
if (account != null && chainId != null && notifiChainSupported) {
|
|
47
45
|
const client = newFrontendClient({
|
|
48
46
|
account: { publicKey: account },
|
|
49
|
-
tenantId:
|
|
50
|
-
env:
|
|
47
|
+
tenantId: 'humafinanceprod',
|
|
48
|
+
env: 'Production',
|
|
51
49
|
walletBlockchain: getBlockchainConfigFromChain(chainId),
|
|
52
50
|
})
|
|
53
51
|
await client.initialize()
|
|
@@ -56,7 +54,7 @@ export const useNotifiClient = (
|
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
createNotifiClient()
|
|
59
|
-
}, [account, chainId,
|
|
57
|
+
}, [account, chainId, notifiChainSupported])
|
|
60
58
|
|
|
61
59
|
return { notifiClient }
|
|
62
60
|
}
|
|
@@ -66,7 +64,7 @@ export const useIsFirstTimeNotifiUser = (
|
|
|
66
64
|
chainId: number | undefined,
|
|
67
65
|
) => {
|
|
68
66
|
const [isFirstTimeNotifiUser, setIsFirstTimeNotifiUser] = useState(false)
|
|
69
|
-
const { notifiClient } = useNotifiClient(account, chainId
|
|
67
|
+
const { notifiClient } = useNotifiClient(account, chainId)
|
|
70
68
|
const { notifiChainSupported } = useDoesChainSupportNotifi(account, chainId)
|
|
71
69
|
|
|
72
70
|
useEffect(() => {
|
package/src/index.tsx
CHANGED
|
@@ -8,22 +8,38 @@ import {
|
|
|
8
8
|
import { ThemeProvider } from '@mui/material'
|
|
9
9
|
import { Provider as Eip1193Provider } from '@web3-react/types'
|
|
10
10
|
import { Provider as AtomProvider } from 'jotai'
|
|
11
|
+
import { useEffect, useState } from 'react'
|
|
11
12
|
import { Provider as ReduxProvider } from 'react-redux'
|
|
12
13
|
|
|
13
|
-
import { useEffect, useState } from 'react'
|
|
14
14
|
import { ChainSupportProvider } from './components/ChainSupportProvider'
|
|
15
15
|
import {
|
|
16
16
|
CreditLineApprove,
|
|
17
17
|
CreditLineApproveProps,
|
|
18
18
|
} from './components/CreditLine/approve'
|
|
19
|
+
import {
|
|
20
|
+
AutoPaybackPropsV2,
|
|
21
|
+
AutoPaybackV2,
|
|
22
|
+
} from './components/CreditLine/autoPaybackV2'
|
|
19
23
|
import {
|
|
20
24
|
CreditLineBorrow,
|
|
21
25
|
CreditLineBorrowProps,
|
|
22
26
|
} from './components/CreditLine/borrow'
|
|
27
|
+
import {
|
|
28
|
+
CreditLineBorrowPropsV2,
|
|
29
|
+
CreditLineBorrowV2,
|
|
30
|
+
} from './components/CreditLine/borrowV2'
|
|
23
31
|
import {
|
|
24
32
|
CreditLinePayment,
|
|
25
33
|
CreditLinePaymentProps,
|
|
26
34
|
} from './components/CreditLine/payment'
|
|
35
|
+
import {
|
|
36
|
+
CreditLinePaymentPropsV2,
|
|
37
|
+
CreditLinePaymentV2,
|
|
38
|
+
} from './components/CreditLine/paymentV2'
|
|
39
|
+
import {
|
|
40
|
+
SupplyFirstLossCover,
|
|
41
|
+
SupplyFirstLossCoverProps,
|
|
42
|
+
} from './components/CreditLine/supplyFLC'
|
|
27
43
|
import {
|
|
28
44
|
InvoiceFactoringBorrow,
|
|
29
45
|
InvoiceFactoringBorrowProps,
|
|
@@ -32,8 +48,29 @@ import {
|
|
|
32
48
|
InvoiceFactoringPayment,
|
|
33
49
|
InvoiceFactoringPaymentProps,
|
|
34
50
|
} from './components/InvoiceFactoring/payment'
|
|
51
|
+
import {
|
|
52
|
+
AddRedemptionPropsV2,
|
|
53
|
+
AddRedemptionV2,
|
|
54
|
+
} from './components/Lend/addRedemptionV2'
|
|
55
|
+
import {
|
|
56
|
+
CancelRedemptionPropsV2,
|
|
57
|
+
CancelRedemptionV2,
|
|
58
|
+
} from './components/Lend/cancelRedemptionV2 '
|
|
35
59
|
import { LendSupply, LendSupplyProps } from './components/Lend/supply'
|
|
60
|
+
import { LendSupplyPropsV2, LendSupplyV2 } from './components/Lend/supplyV2'
|
|
36
61
|
import { LendWithdraw, LendWithdrawProps } from './components/Lend/withdraw'
|
|
62
|
+
import {
|
|
63
|
+
LendWithdrawPropsV2,
|
|
64
|
+
LendWithdrawV2,
|
|
65
|
+
} from './components/Lend/withdrawV2'
|
|
66
|
+
import {
|
|
67
|
+
ReceivableBackedCreditLineBorrowPropsV2,
|
|
68
|
+
ReceivableBackedCreditLineBorrowV2,
|
|
69
|
+
} from './components/ReceivableBackedCreditLine/borrow'
|
|
70
|
+
import {
|
|
71
|
+
ReceivableBackedCreditLinePaymentPropsV2,
|
|
72
|
+
ReceivableBackedCreditLinePaymentV2,
|
|
73
|
+
} from './components/ReceivableBackedCreditLine/payment'
|
|
37
74
|
import { SuperfluidFactoring } from './components/SuperfluidFactoring'
|
|
38
75
|
import { store } from './store'
|
|
39
76
|
import { themeHuma } from './theme'
|
|
@@ -161,6 +198,28 @@ export function CreditLineBorrowWidget(props: CreditLineBorrowWidgetProps) {
|
|
|
161
198
|
)
|
|
162
199
|
}
|
|
163
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Credit line pool borrow widget props V2
|
|
203
|
+
* @typedef {Object} CreditLineBorrowWidgetPropsV2
|
|
204
|
+
* @property {CreditLineBorrowPropsV2} CreditLineBorrowPropsV2 - Credit line pool borrow props V2.
|
|
205
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
206
|
+
*/
|
|
207
|
+
type CreditLineBorrowWidgetPropsV2 = CreditLineBorrowPropsV2 & WidgetProps
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Credit line borrow widget V2
|
|
211
|
+
*
|
|
212
|
+
* @param {CreditLineBorrowWidgetPropsV2} props - The credit line pool borrow widget props V2.
|
|
213
|
+
* @returns Credit line pool borrow widget component V2
|
|
214
|
+
*/
|
|
215
|
+
export function CreditLineBorrowWidgetV2(props: CreditLineBorrowWidgetPropsV2) {
|
|
216
|
+
return (
|
|
217
|
+
<Widget {...props}>
|
|
218
|
+
<CreditLineBorrowV2 {...props} />
|
|
219
|
+
</Widget>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
164
223
|
/**
|
|
165
224
|
* Credit line pool payment widget props
|
|
166
225
|
* @typedef {Object} CreditLinePaymentWidgetProps
|
|
@@ -183,6 +242,30 @@ export function CreditLinePaymentWidget(props: CreditLinePaymentWidgetProps) {
|
|
|
183
242
|
)
|
|
184
243
|
}
|
|
185
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Credit line pool payment widget props V2
|
|
247
|
+
* @typedef {Object} CreditLinePaymentWidgetPropsV2
|
|
248
|
+
* @property {CreditLinePaymentPropsV2} CreditLinePaymentPropsV2 - Credit line pool payment props V2.
|
|
249
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
250
|
+
*/
|
|
251
|
+
type CreditLinePaymentWidgetPropsV2 = CreditLinePaymentPropsV2 & WidgetProps
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Credit line payment widget V2
|
|
255
|
+
*
|
|
256
|
+
* @param {CreditLinePaymentWidgetPropsV2} props - The credit line pool payment widget props V2.
|
|
257
|
+
* @returns Credit line pool payment widget component V2
|
|
258
|
+
*/
|
|
259
|
+
export function CreditLinePaymentWidgetV2(
|
|
260
|
+
props: CreditLinePaymentWidgetPropsV2,
|
|
261
|
+
) {
|
|
262
|
+
return (
|
|
263
|
+
<Widget {...props}>
|
|
264
|
+
<CreditLinePaymentV2 {...props} />
|
|
265
|
+
</Widget>
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
186
269
|
/**
|
|
187
270
|
* Credit line allowance approval widget props
|
|
188
271
|
* @typedef {Object} CreditLinePaymentWidgetProps
|
|
@@ -228,6 +311,28 @@ export function LendSupplyWidget(props: LendSupplyWidgetProps) {
|
|
|
228
311
|
)
|
|
229
312
|
}
|
|
230
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Lend pool supply widget props V2
|
|
316
|
+
* @typedef {Object} LendSupplyWidgetPropsV2
|
|
317
|
+
* @property {LendSupplyPropsV2} LendSupplyPropsV2 - Lend pool supply props V2.
|
|
318
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
319
|
+
*/
|
|
320
|
+
type LendSupplyWidgetPropsV2 = LendSupplyPropsV2 & WidgetProps
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Lend supply widget V2
|
|
324
|
+
*
|
|
325
|
+
* @param {LendSupplyWidgetPropsV2} props - The lend pool supply widget props V2.
|
|
326
|
+
* @returns Lend pool supply widget component V2
|
|
327
|
+
*/
|
|
328
|
+
export function LendSupplyWidgetV2(props: LendSupplyWidgetPropsV2) {
|
|
329
|
+
return (
|
|
330
|
+
<Widget {...props}>
|
|
331
|
+
<LendSupplyV2 {...props} />
|
|
332
|
+
</Widget>
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
231
336
|
/**
|
|
232
337
|
* Lend pool withdraw widget props
|
|
233
338
|
* @typedef {Object} LendWithdrawWidgetProps
|
|
@@ -250,6 +355,96 @@ export function LendWithdrawWidget(props: LendWithdrawWidgetProps) {
|
|
|
250
355
|
)
|
|
251
356
|
}
|
|
252
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Lend pool supply widget props V2
|
|
360
|
+
* @typedef {Object} LendWithdrawWidgetPropsV2
|
|
361
|
+
* @property {LendWithdrawPropsV2} LendSupplyPropsV2 - Lend pool supply props V2.
|
|
362
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
363
|
+
*/
|
|
364
|
+
type LendWithdrawWidgetPropsV2 = LendWithdrawPropsV2 & WidgetProps
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Lend withdraw widget V2
|
|
368
|
+
*
|
|
369
|
+
* @param {LendWithdrawWidgetPropsV2} props - The lend pool supply widget props V2.
|
|
370
|
+
* @returns Lend pool supply widget component V2
|
|
371
|
+
*/
|
|
372
|
+
export function LendWithdrawWidgetV2(props: LendWithdrawWidgetPropsV2) {
|
|
373
|
+
return (
|
|
374
|
+
<Widget {...props}>
|
|
375
|
+
<LendWithdrawV2 {...props} />
|
|
376
|
+
</Widget>
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Lend pool add redemption widget props V2
|
|
382
|
+
* @typedef {Object} AddRedemptionWidgetPropsV2
|
|
383
|
+
* @property {AddRedemptionWidgetPropsV2} AddRedemptionWidgetPropsV2 - Lend pool add redemption props V2.
|
|
384
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
385
|
+
*/
|
|
386
|
+
type AddRedemptionWidgetPropsV2 = AddRedemptionPropsV2 & WidgetProps
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Add redemption widget V2
|
|
390
|
+
*
|
|
391
|
+
* @param {AddRedemptionWidgetPropsV2} props - The lend pool add redemption widget props V2.
|
|
392
|
+
* @returns Lend pool add redemption widget component V2
|
|
393
|
+
*/
|
|
394
|
+
export function AddRedemptionWidgetV2(props: AddRedemptionWidgetPropsV2) {
|
|
395
|
+
return (
|
|
396
|
+
<Widget {...props}>
|
|
397
|
+
<AddRedemptionV2 {...props} />
|
|
398
|
+
</Widget>
|
|
399
|
+
)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Lend pool cancel redemption widget props V2
|
|
404
|
+
* @typedef {Object} CancelRedemptionWidgetPropsV2
|
|
405
|
+
* @property {CancelRedemptionWidgetPropsV2} CancelRedemptionWidgetPropsV2 - Lend pool cancel redemption props V2.
|
|
406
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
407
|
+
*/
|
|
408
|
+
type CancelRedemptionWidgetPropsV2 = CancelRedemptionPropsV2 & WidgetProps
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Cancel redemption widget V2
|
|
412
|
+
*
|
|
413
|
+
* @param {CancelRedemptionWidgetPropsV2} props - The lend pool cancel redemption widget props V2.
|
|
414
|
+
* @returns Lend pool cancel redemption widget component V2
|
|
415
|
+
*/
|
|
416
|
+
export function CancelRedemptionWidgetV2(props: CancelRedemptionWidgetPropsV2) {
|
|
417
|
+
return (
|
|
418
|
+
<Widget {...props}>
|
|
419
|
+
<CancelRedemptionV2 {...props} />
|
|
420
|
+
</Widget>
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Supply first loss cover widget props
|
|
426
|
+
* @typedef {Object} SupplyFirstLossCoverWidgetProps
|
|
427
|
+
* @property {SupplyFirstLossCover} SupplyFirstLossCover - Supply first loss cover props.
|
|
428
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
429
|
+
*/
|
|
430
|
+
type SupplyFirstLossCoverWidgetProps = SupplyFirstLossCoverProps & WidgetProps
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Supply first loss cover widget
|
|
434
|
+
*
|
|
435
|
+
* @param {SupplyFirstLossCoverWidgetProps} props - The supply first loss cover widget props.
|
|
436
|
+
* @returns Supply first loss cover widget component
|
|
437
|
+
*/
|
|
438
|
+
export function SupplyFirstLossCoverWidget(
|
|
439
|
+
props: SupplyFirstLossCoverWidgetProps,
|
|
440
|
+
) {
|
|
441
|
+
return (
|
|
442
|
+
<Widget {...props}>
|
|
443
|
+
<SupplyFirstLossCover {...props} />
|
|
444
|
+
</Widget>
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
|
|
253
448
|
/**
|
|
254
449
|
* Superfluid factoring widget
|
|
255
450
|
*
|
|
@@ -263,3 +458,75 @@ export function SuperfluidFactoringWidget(props: WidgetProps) {
|
|
|
263
458
|
</Widget>
|
|
264
459
|
)
|
|
265
460
|
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Auto payback widget props V2
|
|
464
|
+
* @typedef {Object} AutoPaybackWidgetPropsV2
|
|
465
|
+
* @property {AutoPayback} AutoPayback - Auto payback props V2.
|
|
466
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
467
|
+
*/
|
|
468
|
+
type AutoPaybackWidgetPropsV2 = AutoPaybackPropsV2 & WidgetProps
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Supply first loss cover widget
|
|
472
|
+
*
|
|
473
|
+
* @param {SupplyFirstLossCoverWidgetProps} props - The supply first loss cover widget props.
|
|
474
|
+
* @returns Supply first loss cover widget component
|
|
475
|
+
*/
|
|
476
|
+
export function AutoPaybackWidgetV2(props: AutoPaybackWidgetPropsV2) {
|
|
477
|
+
return (
|
|
478
|
+
<Widget {...props}>
|
|
479
|
+
<AutoPaybackV2 {...props} />
|
|
480
|
+
</Widget>
|
|
481
|
+
)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Receivable backed credit line pool borrow widget props V2
|
|
486
|
+
* @typedef {Object} ReceivableBackedCreditLineBorrowWidgetPropsV2
|
|
487
|
+
* @property {ReceivableBackedCreditLineBorrowPropsV2} ReceivableBackedCreditLineBorrowPropsV2 - Receivable backed credit line pool borrow props V2.
|
|
488
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
489
|
+
*/
|
|
490
|
+
type ReceivableBackedCreditLineBorrowWidgetPropsV2 =
|
|
491
|
+
ReceivableBackedCreditLineBorrowPropsV2 & WidgetProps
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Receivable backed credit line borrow widget V2
|
|
495
|
+
*
|
|
496
|
+
* @param {ReceivableBackedCreditLineBorrowWidgetPropsV2} props - The receivable backed credit line pool borrow widget props V2.
|
|
497
|
+
* @returns Receivable backed credit line pool borrow widget component V2
|
|
498
|
+
*/
|
|
499
|
+
export function ReceivableBackedCreditLineBorrowWidgetV2(
|
|
500
|
+
props: ReceivableBackedCreditLineBorrowWidgetPropsV2,
|
|
501
|
+
) {
|
|
502
|
+
return (
|
|
503
|
+
<Widget {...props}>
|
|
504
|
+
<ReceivableBackedCreditLineBorrowV2 {...props} />
|
|
505
|
+
</Widget>
|
|
506
|
+
)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Receivable backed credit line pool payment widget props V2
|
|
511
|
+
* @typedef {Object} ReceivableBackedCreditLinePaymentWidgetPropsV2
|
|
512
|
+
* @property {ReceivableBackedCreditLinePaymentPropsV2} ReceivableBackedCreditLinePaymentPropsV2 - Receivable backed credit line pool payment props V2.
|
|
513
|
+
* @property {WidgetProps} WidgetProps - Widget general props.
|
|
514
|
+
*/
|
|
515
|
+
type ReceivableBackedCreditLinePaymentWidgetPropsV2 =
|
|
516
|
+
ReceivableBackedCreditLinePaymentPropsV2 & WidgetProps
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Receivable backed credit line payment widget V2
|
|
520
|
+
*
|
|
521
|
+
* @param {ReceivableBackedCreditLinePaymentWidgetPropsV2} props - The receivable backed credit line pool payment widget props V2.
|
|
522
|
+
* @returns Receivable backed credit line pool payment widget component V2
|
|
523
|
+
*/
|
|
524
|
+
export function ReceivableBackedCreditLinePaymentWidgetV2(
|
|
525
|
+
props: ReceivableBackedCreditLinePaymentWidgetPropsV2,
|
|
526
|
+
) {
|
|
527
|
+
return (
|
|
528
|
+
<Widget {...props}>
|
|
529
|
+
<ReceivableBackedCreditLinePaymentV2 {...props} />
|
|
530
|
+
</Widget>
|
|
531
|
+
)
|
|
532
|
+
}
|