@huma-finance/widgets 0.0.71 → 0.0.72-beta.886
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 +23 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Lend/components/ApproveLenderBase.tsx +30 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.72-beta.886+47ad69b",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@ethersproject/experimental": "^5.7.0",
|
|
30
30
|
"@ethersproject/providers": "^5.6.0",
|
|
31
31
|
"@ethersproject/units": "^5.6.0",
|
|
32
|
-
"@huma-finance/sdk": "^0.0.
|
|
33
|
-
"@huma-finance/shared": "^0.0.
|
|
34
|
-
"@huma-finance/web-shared": "^0.0.
|
|
32
|
+
"@huma-finance/sdk": "^0.0.72-beta.886+47ad69b",
|
|
33
|
+
"@huma-finance/shared": "^0.0.72-beta.886+47ad69b",
|
|
34
|
+
"@huma-finance/web-shared": "^0.0.72-beta.886+47ad69b",
|
|
35
35
|
"@mui/x-date-pickers": "^5.0.7",
|
|
36
36
|
"@notifi-network/notifi-frontend-client": "^1.1.2",
|
|
37
37
|
"@notifi-network/notifi-react": "^1.1.2",
|
|
@@ -201,5 +201,5 @@
|
|
|
201
201
|
"optionalDependencies": {
|
|
202
202
|
"encoding": "^0.1.13"
|
|
203
203
|
},
|
|
204
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "47ad69bbbf1e48e43ca7856b0c8e9bfe646bc96b"
|
|
205
205
|
}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CHAIN_TYPE,
|
|
4
4
|
checkIsDev,
|
|
5
|
+
COMMON_ERROR_MESSAGE,
|
|
5
6
|
IdentityServiceV2,
|
|
6
7
|
NETWORK_TYPE,
|
|
8
|
+
SOLANA_TRANSACTION_EXPIRED_BLOCKHEIGHT_EXCEEDED_ERROR,
|
|
7
9
|
timeUtil,
|
|
8
10
|
TrancheType,
|
|
9
11
|
} from '@huma-finance/shared'
|
|
10
12
|
import { useChainInfo } from '@huma-finance/web-shared'
|
|
11
13
|
import React, { useCallback, useEffect } from 'react'
|
|
12
|
-
|
|
13
14
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
14
15
|
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
15
16
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
@@ -59,11 +60,7 @@ export function ApproveLenderBase({
|
|
|
59
60
|
tryAttempts = 0
|
|
60
61
|
} catch (e: unknown) {
|
|
61
62
|
if (tryAttempts === 0) {
|
|
62
|
-
|
|
63
|
-
setError({
|
|
64
|
-
errorMessage: 'Something went wrong, please try again later.',
|
|
65
|
-
}),
|
|
66
|
-
)
|
|
63
|
+
throw e
|
|
67
64
|
} else {
|
|
68
65
|
await timeUtil.sleep(3000)
|
|
69
66
|
console.error(e)
|
|
@@ -71,28 +68,38 @@ export function ApproveLenderBase({
|
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
70
|
},
|
|
74
|
-
[
|
|
75
|
-
account,
|
|
76
|
-
chainId,
|
|
77
|
-
chainSpecificData,
|
|
78
|
-
dispatch,
|
|
79
|
-
documentHash,
|
|
80
|
-
isDev,
|
|
81
|
-
networkType,
|
|
82
|
-
],
|
|
71
|
+
[account, chainId, chainSpecificData, documentHash, isDev, networkType],
|
|
83
72
|
)
|
|
84
73
|
|
|
85
74
|
useEffect(() => {
|
|
86
75
|
const approveLenderAsync = async () => {
|
|
87
76
|
if (account && chainId) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
try {
|
|
78
|
+
if (isUniTranche) {
|
|
79
|
+
await approveLender(juniorTrancheVault)
|
|
80
|
+
changeTranche('junior')
|
|
81
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
82
|
+
} else {
|
|
83
|
+
await approveLender(juniorTrancheVault)
|
|
84
|
+
await approveLender(seniorTrancheVault)
|
|
85
|
+
dispatch(setStep(WIDGET_STEP.ChooseTranche))
|
|
86
|
+
}
|
|
87
|
+
} catch (e: unknown) {
|
|
88
|
+
console.error(e)
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
let errorMessage = e.message ?? COMMON_ERROR_MESSAGE
|
|
91
|
+
if (
|
|
92
|
+
errorMessage.indexOf(
|
|
93
|
+
SOLANA_TRANSACTION_EXPIRED_BLOCKHEIGHT_EXCEEDED_ERROR,
|
|
94
|
+
) >= 0
|
|
95
|
+
) {
|
|
96
|
+
errorMessage = `Transaction failed due to blockchain congestion. Please try again.`
|
|
97
|
+
}
|
|
98
|
+
dispatch(
|
|
99
|
+
setError({
|
|
100
|
+
errorMessage,
|
|
101
|
+
}),
|
|
102
|
+
)
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
105
|
}
|