@huma-finance/widgets 0.0.29 → 0.0.31
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 +2 -2
- package/.eslintignore +2 -2
- package/.eslintrc.js +64 -64
- package/.prettierignore +4 -4
- package/.prettierrc.js +16 -16
- package/API.md +332 -332
- package/LICENSE +660 -660
- package/README.md +48 -48
- package/babel.config.js +15 -15
- package/config-overrides.js +9 -9
- package/cosmos.config.json +7 -7
- package/cypress/e2e/01-invoice-factoring-borrow.test.ts +62 -62
- package/cypress/support/e2e.ts +76 -76
- package/cypress/support/ethereum.ts +142 -142
- package/cypress/tsconfig.json +9 -9
- package/cypress/utils/index.ts +54 -54
- package/cypress.config.ts +20 -20
- package/dist/cjs/index.cjs +144 -142
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +193 -193
- package/dist/index.js +145 -143
- package/dist/index.js.map +1 -1
- package/jsdoc2md.json +20 -20
- package/package.json +5 -4
- package/public/index.html +40 -40
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/rollup.config.js +81 -81
- package/src/components/Activity.tsx +132 -132
- package/src/components/ApolloWrapper.tsx +15 -15
- package/src/components/ApproveAllowanceModal.tsx +121 -121
- package/src/components/BottomButton.tsx +33 -33
- package/src/components/ChainNotSupportedModal.tsx +33 -33
- package/src/components/ConfirmTransferModal.tsx +153 -153
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +157 -157
- package/src/components/CreditLine/borrow/2-ChooseAmount.tsx +68 -68
- package/src/components/CreditLine/borrow/3-Transfer.tsx +44 -44
- package/src/components/CreditLine/borrow/4-ApproveAllowance.tsx +29 -29
- package/src/components/CreditLine/borrow/5-Success.tsx +30 -30
- package/src/components/CreditLine/borrow/index.tsx +117 -117
- 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/Factoring/index.ts +2 -2
- package/src/components/HumaLoading.tsx +68 -68
- package/src/components/HumaTable.tsx +158 -158
- package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +49 -49
- package/src/components/InvoiceFactoring/borrow/2-ChooseAmount.tsx +88 -88
- package/src/components/InvoiceFactoring/borrow/3-ConfirmTransfer.tsx +37 -37
- package/src/components/InvoiceFactoring/borrow/4-ApproveNFT.tsx +55 -55
- package/src/components/InvoiceFactoring/borrow/5-Transfer.tsx +34 -34
- package/src/components/InvoiceFactoring/borrow/6-Success.tsx +20 -20
- package/src/components/InvoiceFactoring/borrow/index.tsx +94 -94
- 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 +175 -171
- 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/LoadingModal.tsx +49 -49
- package/src/components/NotifiSubscriptionModal.tsx +84 -0
- package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +55 -55
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +127 -127
- package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +42 -42
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +33 -33
- 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 +20 -20
- package/src/components/StreamFactoring/borrow/index.tsx +94 -94
- 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 +70 -70
- package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +167 -167
- 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/WrapperModal.tsx +54 -54
- package/src/components/buttons/TableActionButton.tsx +36 -36
- package/src/components/buttons/index.ts +1 -1
- package/src/components/humaModal/HumaModal.tsx +68 -68
- package/src/components/humaModal/HumaModalHeader.tsx +70 -70
- package/src/components/humaModal/index.tsx +2 -2
- package/src/components/icons/approve-lender.svg +30 -30
- package/src/components/icons/auto-payback.svg +40 -40
- package/src/components/icons/check-circle.svg +3 -3
- package/src/components/icons/check-green.svg +3 -3
- package/src/components/icons/check.svg +10 -10
- package/src/components/icons/donut.svg +904 -904
- package/src/components/icons/ellipse.svg +3 -3
- package/src/components/icons/huma-full.svg +22 -22
- package/src/components/icons/huma.svg +15 -15
- package/src/components/icons/index.tsx +93 -93
- package/src/components/icons/loader.svg +229 -229
- package/src/components/icons/metamask.svg +31 -31
- package/src/components/icons/polygon.svg +16 -16
- package/src/components/icons/receipt.svg +3 -3
- package/src/components/icons/separator.svg +3 -3
- package/src/components/icons/sorry.svg +31 -31
- package/src/components/icons/usdc.svg +5 -5
- package/src/components/icons/wallet-connect.svg +11 -11
- package/src/cosmos/CreditLineBorrow.fixture.tsx +86 -86
- package/src/cosmos/CreditLinePayment.fixture.tsx +50 -50
- package/src/cosmos/InvoiceFactoringBorrow.fixture.tsx +111 -111
- package/src/cosmos/InvoiceFactoringPayment.fixture.tsx +67 -67
- package/src/cosmos/LendSupply.fixture.tsx +75 -75
- package/src/cosmos/LendWithdraw.fixture.tsx +43 -43
- package/src/cosmos/SDKTesting.fixture.tsx +4 -3
- package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +15 -15
- package/src/cosmos/WalletWrapper.tsx +52 -52
- package/src/cosmos/abis/InvoiceNFT.json +644 -644
- package/src/cosmos/abis/ReceivableFactoringPool.json +1529 -1529
- package/src/cosmos/utils/env.ts +6 -6
- package/src/cosmos/utils/index.ts +169 -169
- 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/hooks/useEA.ts +53 -53
- package/src/hooks/useRedux.ts +6 -6
- package/src/index.css +61 -61
- package/src/index.tsx +301 -301
- package/src/react-app-env.d.ts +1 -1
- package/src/reportWebVitals.ts +15 -15
- package/src/setupTests.ts +6 -6
- package/src/store/index.ts +27 -27
- package/src/store/widgets.reducers.ts +120 -120
- package/src/store/widgets.selectors.ts +3 -3
- package/src/store/widgets.store.ts +54 -54
- package/src/theme/breakpoints.ts +10 -10
- package/src/theme/components.ts +70 -70
- package/src/theme/coreThemeConstants.ts +29 -29
- package/src/theme/cssMixins.ts +92 -92
- package/src/theme/hooks/useGetSizes.ts +31 -31
- package/src/theme/index.ts +24 -24
- package/src/theme/palette.ts +150 -150
- package/src/theme/shape.ts +7 -7
- package/src/theme/theme.types.ts +80 -80
- package/src/theme/typography.ts +117 -117
- package/src/utilTypes.d.ts +31 -31
- package/src/utils/env.ts +10 -10
- package/tsconfig.build.json +7 -7
- package/tsconfig.json +32 -32
- package/webpack.cosmos.js +54 -54
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHAINS,
|
|
3
|
-
Erc2612,
|
|
4
|
-
PoolInfoType,
|
|
5
|
-
SuperfluidPoolProcessor,
|
|
6
|
-
useERC2612Permit,
|
|
7
|
-
useMount,
|
|
8
|
-
} from '@huma-finance/shared'
|
|
9
|
-
import ERC2612Abi from '@huma-finance/shared/dist/abis/erc2612.json'
|
|
10
|
-
import PoolProcessorAbi from '@huma-finance/shared/dist/abis/SuperfluidPoolProcessor.json'
|
|
11
|
-
import { Contract, ethers } from 'ethers'
|
|
12
|
-
import React from 'react'
|
|
13
|
-
import { useDispatch } from 'react-redux'
|
|
14
|
-
|
|
15
|
-
import { useAppSelector } from '../../../hooks/useRedux'
|
|
16
|
-
import {
|
|
17
|
-
setError,
|
|
18
|
-
setMultisend,
|
|
19
|
-
setStep,
|
|
20
|
-
} from '../../../store/widgets.reducers'
|
|
21
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
22
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
23
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
24
|
-
|
|
25
|
-
type Props = {
|
|
26
|
-
poolInfo: PoolInfoType
|
|
27
|
-
payerAddress: string
|
|
28
|
-
chainId: number
|
|
29
|
-
borrower: string
|
|
30
|
-
superToken: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function Permit({
|
|
34
|
-
poolInfo,
|
|
35
|
-
payerAddress,
|
|
36
|
-
chainId,
|
|
37
|
-
borrower,
|
|
38
|
-
superToken,
|
|
39
|
-
}: Props): React.ReactElement | null {
|
|
40
|
-
const dispatch = useDispatch()
|
|
41
|
-
const { address: tokenAddress } = poolInfo.poolUnderlyingToken
|
|
42
|
-
const { borrowAmountBN, stream } = useAppSelector(selectWidgetState)
|
|
43
|
-
const { getERC2612PermitMessage, getTradableStreamPermitMessage } =
|
|
44
|
-
useERC2612Permit()
|
|
45
|
-
|
|
46
|
-
const getApproveAllowanceCallData = async () => {
|
|
47
|
-
const erc2612PermitResult = await getERC2612PermitMessage(
|
|
48
|
-
tokenAddress,
|
|
49
|
-
poolInfo.poolProcessor!,
|
|
50
|
-
borrowAmountBN!,
|
|
51
|
-
)
|
|
52
|
-
const tokenContract = new Contract(tokenAddress, ERC2612Abi) as Erc2612
|
|
53
|
-
return tokenContract.interface.encodeFunctionData('permit', [
|
|
54
|
-
poolInfo.poolProcessor!,
|
|
55
|
-
borrowAmountBN!,
|
|
56
|
-
erc2612PermitResult.nonce,
|
|
57
|
-
erc2612PermitResult.deadline,
|
|
58
|
-
erc2612PermitResult.v,
|
|
59
|
-
erc2612PermitResult.r,
|
|
60
|
-
erc2612PermitResult.s,
|
|
61
|
-
])
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const getDrawdownCallData = async () => {
|
|
65
|
-
const NFTPermitResult = await getTradableStreamPermitMessage(
|
|
66
|
-
poolInfo.assetAddress!,
|
|
67
|
-
borrower,
|
|
68
|
-
superToken,
|
|
69
|
-
payerAddress,
|
|
70
|
-
poolInfo.poolProcessor!,
|
|
71
|
-
stream!.borrowFlowrate!,
|
|
72
|
-
stream!.durationInSeconds!,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
const drawdownEncodedData = ethers.utils.defaultAbiCoder.encode(
|
|
76
|
-
[
|
|
77
|
-
'address',
|
|
78
|
-
'address',
|
|
79
|
-
'address',
|
|
80
|
-
'int96',
|
|
81
|
-
'uint256',
|
|
82
|
-
'uint256',
|
|
83
|
-
'uint8',
|
|
84
|
-
'bytes32',
|
|
85
|
-
'bytes32',
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
borrower,
|
|
89
|
-
superToken,
|
|
90
|
-
payerAddress,
|
|
91
|
-
stream?.borrowFlowrate,
|
|
92
|
-
stream?.durationInSeconds,
|
|
93
|
-
NFTPermitResult.expiry,
|
|
94
|
-
NFTPermitResult.v,
|
|
95
|
-
NFTPermitResult.r,
|
|
96
|
-
NFTPermitResult.s,
|
|
97
|
-
],
|
|
98
|
-
)
|
|
99
|
-
const poolProcessorContract = new Contract(
|
|
100
|
-
poolInfo.poolProcessor!,
|
|
101
|
-
PoolProcessorAbi,
|
|
102
|
-
) as SuperfluidPoolProcessor
|
|
103
|
-
|
|
104
|
-
return poolProcessorContract.interface.encodeFunctionData(
|
|
105
|
-
'mintAndDrawdown',
|
|
106
|
-
[borrower, borrowAmountBN!, poolInfo.assetAddress!, drawdownEncodedData],
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
useMount(async () => {
|
|
111
|
-
try {
|
|
112
|
-
const callData = []
|
|
113
|
-
const addresses: string[] = []
|
|
114
|
-
|
|
115
|
-
// The token in Goerli hasn't integrated ERC-2612
|
|
116
|
-
if (!CHAINS[chainId].isTestnet) {
|
|
117
|
-
const approveAllowanceCallData = await getApproveAllowanceCallData()
|
|
118
|
-
addresses.push(tokenAddress)
|
|
119
|
-
callData.push(approveAllowanceCallData)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const drawdownCalldata = await getDrawdownCallData()
|
|
123
|
-
addresses.push(poolInfo.poolProcessor!)
|
|
124
|
-
callData.push(drawdownCalldata)
|
|
125
|
-
|
|
126
|
-
dispatch(setMultisend({ addresses, callData }))
|
|
127
|
-
dispatch(setStep(WIDGET_STEP.Transfer))
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
-
} catch (e: any) {
|
|
130
|
-
let errorMessage = e.reason || `Sign permit failed`
|
|
131
|
-
if (e.code === 4001 || e.code === 'ACTION_REJECTED') {
|
|
132
|
-
errorMessage = 'User has rejected the permit sign'
|
|
133
|
-
}
|
|
134
|
-
dispatch(setError({ errorMessage, errorReason: errorMessage }))
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<LoadingModal
|
|
140
|
-
title='Sign Token and NFT'
|
|
141
|
-
description='Waiting for signing...'
|
|
142
|
-
/>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
CHAINS,
|
|
3
|
+
Erc2612,
|
|
4
|
+
PoolInfoType,
|
|
5
|
+
SuperfluidPoolProcessor,
|
|
6
|
+
useERC2612Permit,
|
|
7
|
+
useMount,
|
|
8
|
+
} from '@huma-finance/shared'
|
|
9
|
+
import ERC2612Abi from '@huma-finance/shared/dist/abis/erc2612.json'
|
|
10
|
+
import PoolProcessorAbi from '@huma-finance/shared/dist/abis/SuperfluidPoolProcessor.json'
|
|
11
|
+
import { Contract, ethers } from 'ethers'
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import { useDispatch } from 'react-redux'
|
|
14
|
+
|
|
15
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
16
|
+
import {
|
|
17
|
+
setError,
|
|
18
|
+
setMultisend,
|
|
19
|
+
setStep,
|
|
20
|
+
} from '../../../store/widgets.reducers'
|
|
21
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
22
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
23
|
+
import { LoadingModal } from '../../LoadingModal'
|
|
24
|
+
|
|
25
|
+
type Props = {
|
|
26
|
+
poolInfo: PoolInfoType
|
|
27
|
+
payerAddress: string
|
|
28
|
+
chainId: number
|
|
29
|
+
borrower: string
|
|
30
|
+
superToken: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function Permit({
|
|
34
|
+
poolInfo,
|
|
35
|
+
payerAddress,
|
|
36
|
+
chainId,
|
|
37
|
+
borrower,
|
|
38
|
+
superToken,
|
|
39
|
+
}: Props): React.ReactElement | null {
|
|
40
|
+
const dispatch = useDispatch()
|
|
41
|
+
const { address: tokenAddress } = poolInfo.poolUnderlyingToken
|
|
42
|
+
const { borrowAmountBN, stream } = useAppSelector(selectWidgetState)
|
|
43
|
+
const { getERC2612PermitMessage, getTradableStreamPermitMessage } =
|
|
44
|
+
useERC2612Permit()
|
|
45
|
+
|
|
46
|
+
const getApproveAllowanceCallData = async () => {
|
|
47
|
+
const erc2612PermitResult = await getERC2612PermitMessage(
|
|
48
|
+
tokenAddress,
|
|
49
|
+
poolInfo.poolProcessor!,
|
|
50
|
+
borrowAmountBN!,
|
|
51
|
+
)
|
|
52
|
+
const tokenContract = new Contract(tokenAddress, ERC2612Abi) as Erc2612
|
|
53
|
+
return tokenContract.interface.encodeFunctionData('permit', [
|
|
54
|
+
poolInfo.poolProcessor!,
|
|
55
|
+
borrowAmountBN!,
|
|
56
|
+
erc2612PermitResult.nonce,
|
|
57
|
+
erc2612PermitResult.deadline,
|
|
58
|
+
erc2612PermitResult.v,
|
|
59
|
+
erc2612PermitResult.r,
|
|
60
|
+
erc2612PermitResult.s,
|
|
61
|
+
])
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const getDrawdownCallData = async () => {
|
|
65
|
+
const NFTPermitResult = await getTradableStreamPermitMessage(
|
|
66
|
+
poolInfo.assetAddress!,
|
|
67
|
+
borrower,
|
|
68
|
+
superToken,
|
|
69
|
+
payerAddress,
|
|
70
|
+
poolInfo.poolProcessor!,
|
|
71
|
+
stream!.borrowFlowrate!,
|
|
72
|
+
stream!.durationInSeconds!,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const drawdownEncodedData = ethers.utils.defaultAbiCoder.encode(
|
|
76
|
+
[
|
|
77
|
+
'address',
|
|
78
|
+
'address',
|
|
79
|
+
'address',
|
|
80
|
+
'int96',
|
|
81
|
+
'uint256',
|
|
82
|
+
'uint256',
|
|
83
|
+
'uint8',
|
|
84
|
+
'bytes32',
|
|
85
|
+
'bytes32',
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
borrower,
|
|
89
|
+
superToken,
|
|
90
|
+
payerAddress,
|
|
91
|
+
stream?.borrowFlowrate,
|
|
92
|
+
stream?.durationInSeconds,
|
|
93
|
+
NFTPermitResult.expiry,
|
|
94
|
+
NFTPermitResult.v,
|
|
95
|
+
NFTPermitResult.r,
|
|
96
|
+
NFTPermitResult.s,
|
|
97
|
+
],
|
|
98
|
+
)
|
|
99
|
+
const poolProcessorContract = new Contract(
|
|
100
|
+
poolInfo.poolProcessor!,
|
|
101
|
+
PoolProcessorAbi,
|
|
102
|
+
) as SuperfluidPoolProcessor
|
|
103
|
+
|
|
104
|
+
return poolProcessorContract.interface.encodeFunctionData(
|
|
105
|
+
'mintAndDrawdown',
|
|
106
|
+
[borrower, borrowAmountBN!, poolInfo.assetAddress!, drawdownEncodedData],
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
useMount(async () => {
|
|
111
|
+
try {
|
|
112
|
+
const callData = []
|
|
113
|
+
const addresses: string[] = []
|
|
114
|
+
|
|
115
|
+
// The token in Goerli hasn't integrated ERC-2612
|
|
116
|
+
if (!CHAINS[chainId].isTestnet) {
|
|
117
|
+
const approveAllowanceCallData = await getApproveAllowanceCallData()
|
|
118
|
+
addresses.push(tokenAddress)
|
|
119
|
+
callData.push(approveAllowanceCallData)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const drawdownCalldata = await getDrawdownCallData()
|
|
123
|
+
addresses.push(poolInfo.poolProcessor!)
|
|
124
|
+
callData.push(drawdownCalldata)
|
|
125
|
+
|
|
126
|
+
dispatch(setMultisend({ addresses, callData }))
|
|
127
|
+
dispatch(setStep(WIDGET_STEP.Transfer))
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
} catch (e: any) {
|
|
130
|
+
let errorMessage = e.reason || `Sign permit failed`
|
|
131
|
+
if (e.code === 4001 || e.code === 'ACTION_REJECTED') {
|
|
132
|
+
errorMessage = 'User has rejected the permit sign'
|
|
133
|
+
}
|
|
134
|
+
dispatch(setError({ errorMessage, errorReason: errorMessage }))
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<LoadingModal
|
|
140
|
+
title='Sign Token and NFT'
|
|
141
|
+
description='Waiting for signing...'
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { PoolInfoType, useMultiSendContract } from '@huma-finance/shared'
|
|
2
|
-
import React, { useCallback } from 'react'
|
|
3
|
-
|
|
4
|
-
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
5
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
6
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
7
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
8
|
-
import { TxSendModal } from '../../TxSendModal'
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
poolInfo: PoolInfoType
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Transfer({ poolInfo }: Props): React.ReactElement | null {
|
|
15
|
-
const dispatch = useAppDispatch()
|
|
16
|
-
const multiSendContract = useMultiSendContract()
|
|
17
|
-
const { multisend } = useAppSelector(selectWidgetState)
|
|
18
|
-
|
|
19
|
-
const handleSuccess = useCallback(() => {
|
|
20
|
-
dispatch(setStep(WIDGET_STEP.Done))
|
|
21
|
-
}, [dispatch])
|
|
22
|
-
|
|
23
|
-
if (!multisend || !multiSendContract) {
|
|
24
|
-
return null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<TxSendModal
|
|
29
|
-
poolInfo={poolInfo}
|
|
30
|
-
contract={multiSendContract}
|
|
31
|
-
title='Transfer Tradable Stream and Money'
|
|
32
|
-
method='multisend'
|
|
33
|
-
params={[multisend.addresses, multisend.callData]}
|
|
34
|
-
handleSuccess={handleSuccess}
|
|
35
|
-
/>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
1
|
+
import { PoolInfoType, useMultiSendContract } from '@huma-finance/shared'
|
|
2
|
+
import React, { useCallback } from 'react'
|
|
3
|
+
|
|
4
|
+
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
5
|
+
import { setStep } from '../../../store/widgets.reducers'
|
|
6
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
7
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
8
|
+
import { TxSendModal } from '../../TxSendModal'
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
poolInfo: PoolInfoType
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function Transfer({ poolInfo }: Props): React.ReactElement | null {
|
|
15
|
+
const dispatch = useAppDispatch()
|
|
16
|
+
const multiSendContract = useMultiSendContract()
|
|
17
|
+
const { multisend } = useAppSelector(selectWidgetState)
|
|
18
|
+
|
|
19
|
+
const handleSuccess = useCallback(() => {
|
|
20
|
+
dispatch(setStep(WIDGET_STEP.Done))
|
|
21
|
+
}, [dispatch])
|
|
22
|
+
|
|
23
|
+
if (!multisend || !multiSendContract) {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<TxSendModal
|
|
29
|
+
poolInfo={poolInfo}
|
|
30
|
+
contract={multiSendContract}
|
|
31
|
+
title='Transfer Tradable Stream and Money'
|
|
32
|
+
method='multisend'
|
|
33
|
+
params={[multisend.addresses, multisend.callData]}
|
|
34
|
+
handleSuccess={handleSuccess}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { useAppSelector } from '../../../hooks/useRedux'
|
|
3
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
4
|
-
import { TxDoneModal } from '../../TxDoneModal'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
handleAction: () => void
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function Success({ handleAction }: Props): React.ReactElement {
|
|
11
|
-
const { borrowAmount, approval } = useAppSelector(selectWidgetState)
|
|
12
|
-
|
|
13
|
-
const content = [
|
|
14
|
-
`${borrowAmount?.toFixed(2)} ${
|
|
15
|
-
approval?.token.symbol
|
|
16
|
-
} is now in your wallet.`,
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
return <TxDoneModal handleAction={handleAction} content={content} />
|
|
20
|
-
}
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
3
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
4
|
+
import { TxDoneModal } from '../../TxDoneModal'
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
handleAction: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function Success({ handleAction }: Props): React.ReactElement {
|
|
11
|
+
const { borrowAmount, approval } = useAppSelector(selectWidgetState)
|
|
12
|
+
|
|
13
|
+
const content = [
|
|
14
|
+
`${borrowAmount?.toFixed(2)} ${
|
|
15
|
+
approval?.token.symbol
|
|
16
|
+
} is now in your wallet.`,
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
return <TxDoneModal handleAction={handleAction} content={content} />
|
|
20
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { useWeb3React } from '@web3-react/core'
|
|
2
|
-
import { POOL_NAME, POOL_TYPE, usePoolInfo } from '@huma-finance/shared'
|
|
3
|
-
import React, { useEffect } from 'react'
|
|
4
|
-
import { useDispatch } from 'react-redux'
|
|
5
|
-
|
|
6
|
-
import { useAppSelector } from '../../../hooks/useRedux'
|
|
7
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
8
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
9
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
10
|
-
import { ErrorModal } from '../../ErrorModal'
|
|
11
|
-
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
12
|
-
import { Evaluation } from './1-Evaluation'
|
|
13
|
-
import { ChooseAmount } from './2-ChooseAmount'
|
|
14
|
-
import { ConfirmTransfer } from './3-ConfirmTransfer'
|
|
15
|
-
import { ApproveAllowance } from './4-ApproveAllowance'
|
|
16
|
-
import { Permit } from './5-Permit'
|
|
17
|
-
import { Transfer } from './6-Transfer'
|
|
18
|
-
import { Success } from './7-Success'
|
|
19
|
-
|
|
20
|
-
export type StreamFactoringBorrowProps = {
|
|
21
|
-
poolName: POOL_NAME
|
|
22
|
-
poolType: POOL_TYPE
|
|
23
|
-
payerAddress: string
|
|
24
|
-
superToken: string
|
|
25
|
-
currentFlowRate: string
|
|
26
|
-
isOpen: boolean
|
|
27
|
-
handleClose: () => void
|
|
28
|
-
handleSuccess: (blockNumber: number) => void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function StreamFactoringBorrow({
|
|
32
|
-
poolName,
|
|
33
|
-
poolType,
|
|
34
|
-
payerAddress,
|
|
35
|
-
superToken,
|
|
36
|
-
currentFlowRate,
|
|
37
|
-
isOpen,
|
|
38
|
-
handleClose,
|
|
39
|
-
handleSuccess,
|
|
40
|
-
}: StreamFactoringBorrowProps): React.ReactElement | null {
|
|
41
|
-
const dispatch = useDispatch()
|
|
42
|
-
const { account, chainId } = useWeb3React()
|
|
43
|
-
const poolInfo = usePoolInfo(poolName, poolType)
|
|
44
|
-
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
48
|
-
}, [dispatch])
|
|
49
|
-
|
|
50
|
-
if (!poolInfo) {
|
|
51
|
-
return null
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<WidgetWrapper
|
|
56
|
-
isOpen={isOpen}
|
|
57
|
-
handleClose={handleClose}
|
|
58
|
-
handleSuccess={handleSuccess}
|
|
59
|
-
>
|
|
60
|
-
{step === WIDGET_STEP.Evaluation && (
|
|
61
|
-
<Evaluation
|
|
62
|
-
poolInfo={poolInfo}
|
|
63
|
-
payerAddress={payerAddress}
|
|
64
|
-
superToken={superToken}
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
67
|
-
{step === WIDGET_STEP.ChooseAmount && (
|
|
68
|
-
<ChooseAmount poolInfo={poolInfo} currentFlowRate={currentFlowRate} />
|
|
69
|
-
)}
|
|
70
|
-
{step === WIDGET_STEP.ConfirmTransfer && <ConfirmTransfer />}
|
|
71
|
-
{step === WIDGET_STEP.ApproveAllowance && (
|
|
72
|
-
<ApproveAllowance poolInfo={poolInfo} />
|
|
73
|
-
)}
|
|
74
|
-
{step === WIDGET_STEP.Permit && account && chainId && (
|
|
75
|
-
<Permit
|
|
76
|
-
poolInfo={poolInfo}
|
|
77
|
-
payerAddress={payerAddress}
|
|
78
|
-
chainId={chainId}
|
|
79
|
-
borrower={account}
|
|
80
|
-
superToken={superToken}
|
|
81
|
-
/>
|
|
82
|
-
)}
|
|
83
|
-
{step === WIDGET_STEP.Transfer && <Transfer poolInfo={poolInfo} />}
|
|
84
|
-
{step === WIDGET_STEP.Done && <Success handleAction={handleClose} />}
|
|
85
|
-
{step === WIDGET_STEP.Error && (
|
|
86
|
-
<ErrorModal
|
|
87
|
-
title='Stream Borrowing'
|
|
88
|
-
errorMessage={errorMessage}
|
|
89
|
-
handleOk={handleClose}
|
|
90
|
-
/>
|
|
91
|
-
)}
|
|
92
|
-
</WidgetWrapper>
|
|
93
|
-
)
|
|
94
|
-
}
|
|
1
|
+
import { useWeb3React } from '@web3-react/core'
|
|
2
|
+
import { POOL_NAME, POOL_TYPE, usePoolInfo } from '@huma-finance/shared'
|
|
3
|
+
import React, { useEffect } from 'react'
|
|
4
|
+
import { useDispatch } from 'react-redux'
|
|
5
|
+
|
|
6
|
+
import { useAppSelector } from '../../../hooks/useRedux'
|
|
7
|
+
import { setStep } from '../../../store/widgets.reducers'
|
|
8
|
+
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
9
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
10
|
+
import { ErrorModal } from '../../ErrorModal'
|
|
11
|
+
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
12
|
+
import { Evaluation } from './1-Evaluation'
|
|
13
|
+
import { ChooseAmount } from './2-ChooseAmount'
|
|
14
|
+
import { ConfirmTransfer } from './3-ConfirmTransfer'
|
|
15
|
+
import { ApproveAllowance } from './4-ApproveAllowance'
|
|
16
|
+
import { Permit } from './5-Permit'
|
|
17
|
+
import { Transfer } from './6-Transfer'
|
|
18
|
+
import { Success } from './7-Success'
|
|
19
|
+
|
|
20
|
+
export type StreamFactoringBorrowProps = {
|
|
21
|
+
poolName: POOL_NAME
|
|
22
|
+
poolType: POOL_TYPE
|
|
23
|
+
payerAddress: string
|
|
24
|
+
superToken: string
|
|
25
|
+
currentFlowRate: string
|
|
26
|
+
isOpen: boolean
|
|
27
|
+
handleClose: () => void
|
|
28
|
+
handleSuccess: (blockNumber: number) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function StreamFactoringBorrow({
|
|
32
|
+
poolName,
|
|
33
|
+
poolType,
|
|
34
|
+
payerAddress,
|
|
35
|
+
superToken,
|
|
36
|
+
currentFlowRate,
|
|
37
|
+
isOpen,
|
|
38
|
+
handleClose,
|
|
39
|
+
handleSuccess,
|
|
40
|
+
}: StreamFactoringBorrowProps): React.ReactElement | null {
|
|
41
|
+
const dispatch = useDispatch()
|
|
42
|
+
const { account, chainId } = useWeb3React()
|
|
43
|
+
const poolInfo = usePoolInfo(poolName, poolType)
|
|
44
|
+
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
48
|
+
}, [dispatch])
|
|
49
|
+
|
|
50
|
+
if (!poolInfo) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<WidgetWrapper
|
|
56
|
+
isOpen={isOpen}
|
|
57
|
+
handleClose={handleClose}
|
|
58
|
+
handleSuccess={handleSuccess}
|
|
59
|
+
>
|
|
60
|
+
{step === WIDGET_STEP.Evaluation && (
|
|
61
|
+
<Evaluation
|
|
62
|
+
poolInfo={poolInfo}
|
|
63
|
+
payerAddress={payerAddress}
|
|
64
|
+
superToken={superToken}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
{step === WIDGET_STEP.ChooseAmount && (
|
|
68
|
+
<ChooseAmount poolInfo={poolInfo} currentFlowRate={currentFlowRate} />
|
|
69
|
+
)}
|
|
70
|
+
{step === WIDGET_STEP.ConfirmTransfer && <ConfirmTransfer />}
|
|
71
|
+
{step === WIDGET_STEP.ApproveAllowance && (
|
|
72
|
+
<ApproveAllowance poolInfo={poolInfo} />
|
|
73
|
+
)}
|
|
74
|
+
{step === WIDGET_STEP.Permit && account && chainId && (
|
|
75
|
+
<Permit
|
|
76
|
+
poolInfo={poolInfo}
|
|
77
|
+
payerAddress={payerAddress}
|
|
78
|
+
chainId={chainId}
|
|
79
|
+
borrower={account}
|
|
80
|
+
superToken={superToken}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
{step === WIDGET_STEP.Transfer && <Transfer poolInfo={poolInfo} />}
|
|
84
|
+
{step === WIDGET_STEP.Done && <Success handleAction={handleClose} />}
|
|
85
|
+
{step === WIDGET_STEP.Error && (
|
|
86
|
+
<ErrorModal
|
|
87
|
+
title='Stream Borrowing'
|
|
88
|
+
errorMessage={errorMessage}
|
|
89
|
+
handleOk={handleClose}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
</WidgetWrapper>
|
|
93
|
+
)
|
|
94
|
+
}
|