@huma-finance/widgets 0.0.44-beta.145 → 0.0.44-beta.149
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 +21 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/CreditLine/borrow/2-ChooseAmount.tsx +4 -2
- package/src/components/CreditLine/borrow/4-Transfer.tsx +4 -1
- package/src/components/InvoiceFactoring/borrow/2-ChooseAmount.tsx +5 -7
- package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +2 -2
- package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +4 -1
- package/src/components/StreamFactoring/borrow/5-Permit.tsx +7 -5
- package/src/index.tsx +7 -2
- package/src/store/widgets.reducers.ts +2 -1
- package/src/store/widgets.store.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.44-beta.
|
|
3
|
+
"version": "0.0.44-beta.149+ccd2ced",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@ethersproject/experimental": "^5.7.0",
|
|
31
31
|
"@ethersproject/providers": "^5.6.0",
|
|
32
32
|
"@ethersproject/units": "^5.6.0",
|
|
33
|
-
"@huma-finance/sdk": "^0.0.44-beta.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.44-beta.149+ccd2ced",
|
|
34
34
|
"@huma-finance/shared": "^0.0.43",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
"optionalDependencies": {
|
|
193
193
|
"encoding": "^0.1.13"
|
|
194
194
|
},
|
|
195
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "ccd2cedbc387e09e218950e6ea921c0c5dd9495a"
|
|
196
196
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AccountStats,
|
|
3
3
|
PoolInfoType,
|
|
4
|
-
upScale,
|
|
5
4
|
useCLFeeManager,
|
|
6
5
|
useCLPoolAllowance,
|
|
7
6
|
} from '@huma-finance/shared'
|
|
8
7
|
import { useWeb3React } from '@web3-react/core'
|
|
9
8
|
import React, { useCallback, useState } from 'react'
|
|
9
|
+
import { BigNumber } from 'ethers'
|
|
10
10
|
|
|
11
11
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
12
12
|
import { setBorrowInfo } from '../../../store/widgets.reducers'
|
|
@@ -48,7 +48,9 @@ export function ChooseAmount({
|
|
|
48
48
|
dispatch(
|
|
49
49
|
setBorrowInfo({
|
|
50
50
|
borrowAmount: currentAmount,
|
|
51
|
-
borrowAmountBN:
|
|
51
|
+
borrowAmountBN: BigNumber.from(currentAmount)
|
|
52
|
+
.mul(BigNumber.from(10).pow(decimals))
|
|
53
|
+
.toJSON(),
|
|
52
54
|
chargedFees,
|
|
53
55
|
nextStep,
|
|
54
56
|
}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PoolInfoType, txAtom } from '@huma-finance/shared'
|
|
2
2
|
import { useResetAtom } from 'jotai/utils'
|
|
3
3
|
import React, { useCallback } from 'react'
|
|
4
|
+
import { BigNumber } from 'ethers'
|
|
4
5
|
|
|
5
6
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
6
7
|
import { setStep } from '../../../store/widgets.reducers'
|
|
@@ -15,7 +16,9 @@ type Props = {
|
|
|
15
16
|
export function Transfer({ poolInfo }: Props): React.ReactElement {
|
|
16
17
|
const dispatch = useAppDispatch()
|
|
17
18
|
const reset = useResetAtom(txAtom)
|
|
18
|
-
const { borrowAmountBN } =
|
|
19
|
+
const { borrowAmountBN: borrowAmountBNJson } =
|
|
20
|
+
useAppSelector(selectWidgetState)
|
|
21
|
+
const borrowAmountBN = BigNumber.from(borrowAmountBNJson)
|
|
19
22
|
|
|
20
23
|
const handleSuccess = useCallback(() => {
|
|
21
24
|
reset()
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountStats,
|
|
3
|
-
PoolInfoType,
|
|
4
|
-
upScale,
|
|
5
|
-
useFeeManager,
|
|
6
|
-
} from '@huma-finance/shared'
|
|
1
|
+
import { AccountStats, PoolInfoType, useFeeManager } from '@huma-finance/shared'
|
|
7
2
|
import React, { useCallback, useState } from 'react'
|
|
3
|
+
import { BigNumber } from 'ethers'
|
|
8
4
|
|
|
9
5
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
10
6
|
import { setBorrowInfo } from '../../../store/widgets.reducers'
|
|
@@ -57,7 +53,9 @@ export function ChooseAmount({
|
|
|
57
53
|
dispatch(
|
|
58
54
|
setBorrowInfo({
|
|
59
55
|
borrowAmount: currentAmount,
|
|
60
|
-
borrowAmountBN:
|
|
56
|
+
borrowAmountBN: BigNumber.from(currentAmount)
|
|
57
|
+
.mul(BigNumber.from(10).pow(BigNumber.from(approval?.token.decimal)))
|
|
58
|
+
.toJSON(),
|
|
61
59
|
chargedFees,
|
|
62
60
|
remainder: Number(remainder!),
|
|
63
61
|
nextStep: WIDGET_STEP.ConfirmTransfer,
|
|
@@ -65,7 +65,7 @@ export function ChooseAmount({
|
|
|
65
65
|
return {
|
|
66
66
|
borrowFlowrate: borrowFlowrate.toString(),
|
|
67
67
|
borrowAmount: Number(newBorrowAmount),
|
|
68
|
-
borrowAmountBN: newBorrowAmountBN
|
|
68
|
+
borrowAmountBN: newBorrowAmountBN,
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
[approval, borrowPeriodInSeconds, currentFlowRate],
|
|
@@ -93,7 +93,7 @@ export function ChooseAmount({
|
|
|
93
93
|
dispatch(
|
|
94
94
|
setBorrowInfo({
|
|
95
95
|
borrowAmount,
|
|
96
|
-
borrowAmountBN,
|
|
96
|
+
borrowAmountBN: borrowAmountBN.toJSON(),
|
|
97
97
|
chargedFees,
|
|
98
98
|
nextStep: WIDGET_STEP.ConfirmTransfer,
|
|
99
99
|
}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PoolInfoType } from '@huma-finance/shared'
|
|
2
2
|
import React, { useCallback } from 'react'
|
|
3
3
|
import { useDispatch } from 'react-redux'
|
|
4
|
+
import { BigNumber } from 'ethers'
|
|
4
5
|
|
|
5
6
|
import { useAppSelector } from '../../../hooks/useRedux'
|
|
6
7
|
import { setStep } from '../../../store/widgets.reducers'
|
|
@@ -16,7 +17,9 @@ export function ApproveAllowance({
|
|
|
16
17
|
poolInfo,
|
|
17
18
|
}: Props): React.ReactElement | null {
|
|
18
19
|
const dispatch = useDispatch()
|
|
19
|
-
const { borrowAmountBN } =
|
|
20
|
+
const { borrowAmountBN: borrowAmountBNJson } =
|
|
21
|
+
useAppSelector(selectWidgetState)
|
|
22
|
+
const borrowAmountBN = BigNumber.from(borrowAmountBNJson)
|
|
20
23
|
|
|
21
24
|
const handleSuccess = useCallback(() => {
|
|
22
25
|
dispatch(setStep(WIDGET_STEP.Permit))
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ERC2612_ABI,
|
|
9
9
|
SuperfluidPoolProcessor_ABI,
|
|
10
10
|
} from '@huma-finance/shared'
|
|
11
|
-
import { Contract, ethers } from 'ethers'
|
|
11
|
+
import { BigNumber, Contract, ethers } from 'ethers'
|
|
12
12
|
import React from 'react'
|
|
13
13
|
import { useDispatch } from 'react-redux'
|
|
14
14
|
|
|
@@ -39,20 +39,22 @@ export function Permit({
|
|
|
39
39
|
}: Props): React.ReactElement | null {
|
|
40
40
|
const dispatch = useDispatch()
|
|
41
41
|
const { address: tokenAddress } = poolInfo.poolUnderlyingToken
|
|
42
|
-
const { borrowAmountBN, stream } =
|
|
42
|
+
const { borrowAmountBN: borrowAmountBNJson, stream } =
|
|
43
|
+
useAppSelector(selectWidgetState)
|
|
43
44
|
const { getERC2612PermitMessage, getTradableStreamPermitMessage } =
|
|
44
45
|
useERC2612Permit()
|
|
46
|
+
const borrowAmountBN = BigNumber.from(borrowAmountBNJson)
|
|
45
47
|
|
|
46
48
|
const getApproveAllowanceCallData = async () => {
|
|
47
49
|
const erc2612PermitResult = await getERC2612PermitMessage(
|
|
48
50
|
tokenAddress,
|
|
49
51
|
poolInfo.poolProcessor!,
|
|
50
|
-
borrowAmountBN!,
|
|
52
|
+
borrowAmountBN.toString()!,
|
|
51
53
|
)
|
|
52
54
|
const tokenContract = new Contract(tokenAddress, ERC2612_ABI) as Erc2612
|
|
53
55
|
return tokenContract.interface.encodeFunctionData('permit', [
|
|
54
56
|
poolInfo.poolProcessor!,
|
|
55
|
-
borrowAmountBN!,
|
|
57
|
+
borrowAmountBN.toString()!,
|
|
56
58
|
erc2612PermitResult.nonce,
|
|
57
59
|
erc2612PermitResult.deadline,
|
|
58
60
|
erc2612PermitResult.v,
|
|
@@ -103,7 +105,7 @@ export function Permit({
|
|
|
103
105
|
|
|
104
106
|
return poolProcessorContract.interface.encodeFunctionData(
|
|
105
107
|
'mintAndDrawdown',
|
|
106
|
-
[borrower, borrowAmountBN
|
|
108
|
+
[borrower, borrowAmountBN, poolInfo.assetAddress!, drawdownEncodedData],
|
|
107
109
|
)
|
|
108
110
|
}
|
|
109
111
|
|
package/src/index.tsx
CHANGED
|
@@ -62,12 +62,17 @@ type WidgetProps = {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function Widget(props: WCProps<WidgetProps>) {
|
|
65
|
-
const { children } = props
|
|
65
|
+
const { children, provider } = props
|
|
66
|
+
|
|
67
|
+
let chainId
|
|
68
|
+
if (provider instanceof JsonRpcProvider) {
|
|
69
|
+
chainId = provider.network.chainId
|
|
70
|
+
}
|
|
66
71
|
|
|
67
72
|
return (
|
|
68
73
|
<ThemeProvider theme={themeHuma}>
|
|
69
74
|
<ReduxProvider store={store}>
|
|
70
|
-
<Web3Provider {...(props as Web3Props)}>
|
|
75
|
+
<Web3Provider {...(props as Web3Props)} defaultChainId={chainId}>
|
|
71
76
|
<AtomProvider>
|
|
72
77
|
<ChainSupportProvider>{children}</ChainSupportProvider>
|
|
73
78
|
</AtomProvider>
|
|
@@ -52,7 +52,7 @@ export const widgetSlice = createSlice({
|
|
|
52
52
|
payload,
|
|
53
53
|
}: PayloadAction<{
|
|
54
54
|
borrowAmount: number
|
|
55
|
-
borrowAmountBN:
|
|
55
|
+
borrowAmountBN: JSON
|
|
56
56
|
chargedFees: number
|
|
57
57
|
nextStep: WIDGET_STEP
|
|
58
58
|
remainder?: number
|
|
@@ -96,6 +96,7 @@ export const widgetSlice = createSlice({
|
|
|
96
96
|
payload,
|
|
97
97
|
}: PayloadAction<{ errorMessage: string; errorReason?: string }>,
|
|
98
98
|
) => {
|
|
99
|
+
console.trace()
|
|
99
100
|
state.errorMessage = payload.errorMessage
|
|
100
101
|
state.errorReason = payload.errorReason
|
|
101
102
|
state.step = WIDGET_STEP.Error
|