@huma-finance/widgets 0.0.44-beta.145 → 0.0.44-beta.147
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 +4 -4
- 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/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
+
import { txAtom, useMQ, supportedChainId, sendTxAtom, isTxFailed, getExplorerUrl, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, useAuthErrorHandling, checkIsDev, EARejectionError, EARejectMessage, EARejectReason, EAService, useCLFeeManager, useCLPoolAllowance, usePoolContract, timeUtil, doesChainSupportNotifi, getNotifiDappId, getBlockchainConfigFromChain, CreditState, upScale, toBigNumber, TRANSFER_ABI, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, useParamsSearch, IdentityService, CHAINS, configUtil, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useLastDepositTime, CreditEventText, useERC2612Permit, ERC2612_ABI, SuperfluidPoolProcessor_ABI, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, timestampToLL, getWalletAddressAbbr, useFactoring, PoolMap, PoolSubgraphMap, CreditEvent, Provider as Provider$1 } from '@huma-finance/shared';
|
|
2
3
|
import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, InputAdornment, Snackbar, Alert, Skeleton, TablePagination, LinearProgress, createTheme, ThemeProvider } from '@mui/material';
|
|
3
4
|
import { useAtom, Provider as Provider$2 } from 'jotai';
|
|
4
5
|
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
@@ -234,6 +235,7 @@ var widgetSlice = createSlice({
|
|
|
234
235
|
},
|
|
235
236
|
setError: function setError(state, _ref10) {
|
|
236
237
|
var payload = _ref10.payload;
|
|
238
|
+
console.trace();
|
|
237
239
|
state.errorMessage = payload.errorMessage;
|
|
238
240
|
state.errorReason = payload.errorReason;
|
|
239
241
|
state.step = WIDGET_STEP.Error;
|
|
@@ -2804,7 +2806,7 @@ function ChooseAmount$6(_ref) {
|
|
|
2804
2806
|
var nextStep = approved ? WIDGET_STEP.Transfer : WIDGET_STEP.ApproveAllowance;
|
|
2805
2807
|
dispatch(setBorrowInfo({
|
|
2806
2808
|
borrowAmount: currentAmount,
|
|
2807
|
-
borrowAmountBN:
|
|
2809
|
+
borrowAmountBN: BigNumber.from(currentAmount).mul(BigNumber.from(10).pow(decimals)).toJSON(),
|
|
2808
2810
|
chargedFees: chargedFees,
|
|
2809
2811
|
nextStep: nextStep
|
|
2810
2812
|
}));
|
|
@@ -2884,7 +2886,8 @@ function Transfer$6(_ref) {
|
|
|
2884
2886
|
var dispatch = useAppDispatch();
|
|
2885
2887
|
var reset = useResetAtom(txAtom);
|
|
2886
2888
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
2887
|
-
|
|
2889
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN;
|
|
2890
|
+
var borrowAmountBN = BigNumber.from(borrowAmountBNJson);
|
|
2888
2891
|
var handleSuccess = useCallback(function () {
|
|
2889
2892
|
reset();
|
|
2890
2893
|
var nextStep = WIDGET_STEP.Done;
|
|
@@ -3629,7 +3632,7 @@ function ChooseAmount$4(_ref) {
|
|
|
3629
3632
|
var handleAction = useCallback(function () {
|
|
3630
3633
|
dispatch(setBorrowInfo({
|
|
3631
3634
|
borrowAmount: currentAmount,
|
|
3632
|
-
borrowAmountBN:
|
|
3635
|
+
borrowAmountBN: BigNumber.from(currentAmount).mul(BigNumber.from(10).pow(BigNumber.from(approval === null || approval === void 0 ? void 0 : approval.token.decimal))).toJSON(),
|
|
3633
3636
|
chargedFees: chargedFees,
|
|
3634
3637
|
remainder: Number(remainder),
|
|
3635
3638
|
nextStep: WIDGET_STEP.ConfirmTransfer
|
|
@@ -5254,7 +5257,7 @@ function ChooseAmount(_ref) {
|
|
|
5254
5257
|
return {
|
|
5255
5258
|
borrowFlowrate: borrowFlowrate.toString(),
|
|
5256
5259
|
borrowAmount: Number(newBorrowAmount),
|
|
5257
|
-
borrowAmountBN: newBorrowAmountBN
|
|
5260
|
+
borrowAmountBN: newBorrowAmountBN
|
|
5258
5261
|
};
|
|
5259
5262
|
}, [approval, borrowPeriodInSeconds, currentFlowRate]);
|
|
5260
5263
|
var handleChangeAmount = useCallback(function (newAmount) {
|
|
@@ -5274,7 +5277,7 @@ function ChooseAmount(_ref) {
|
|
|
5274
5277
|
}));
|
|
5275
5278
|
dispatch(setBorrowInfo({
|
|
5276
5279
|
borrowAmount: borrowAmount,
|
|
5277
|
-
borrowAmountBN: borrowAmountBN,
|
|
5280
|
+
borrowAmountBN: borrowAmountBN.toJSON(),
|
|
5278
5281
|
chargedFees: chargedFees,
|
|
5279
5282
|
nextStep: WIDGET_STEP.ConfirmTransfer
|
|
5280
5283
|
}));
|
|
@@ -5329,7 +5332,8 @@ function ApproveAllowance(_ref) {
|
|
|
5329
5332
|
var poolInfo = _ref.poolInfo;
|
|
5330
5333
|
var dispatch = useDispatch();
|
|
5331
5334
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
5332
|
-
|
|
5335
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN;
|
|
5336
|
+
var borrowAmountBN = BigNumber.from(borrowAmountBNJson);
|
|
5333
5337
|
var handleSuccess = useCallback(function () {
|
|
5334
5338
|
dispatch(setStep(WIDGET_STEP.Permit));
|
|
5335
5339
|
}, [dispatch]);
|
|
@@ -5350,11 +5354,12 @@ function Permit(_ref) {
|
|
|
5350
5354
|
var dispatch = useDispatch();
|
|
5351
5355
|
var tokenAddress = poolInfo.poolUnderlyingToken.address;
|
|
5352
5356
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
5353
|
-
|
|
5357
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN,
|
|
5354
5358
|
stream = _useAppSelector.stream;
|
|
5355
5359
|
var _useERC2612Permit = useERC2612Permit(),
|
|
5356
5360
|
getERC2612PermitMessage = _useERC2612Permit.getERC2612PermitMessage,
|
|
5357
5361
|
getTradableStreamPermitMessage = _useERC2612Permit.getTradableStreamPermitMessage;
|
|
5362
|
+
var borrowAmountBN = BigNumber.from(borrowAmountBNJson);
|
|
5358
5363
|
var getApproveAllowanceCallData = /*#__PURE__*/function () {
|
|
5359
5364
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
5360
5365
|
var erc2612PermitResult, tokenContract;
|
|
@@ -5362,11 +5367,11 @@ function Permit(_ref) {
|
|
|
5362
5367
|
while (1) switch (_context.prev = _context.next) {
|
|
5363
5368
|
case 0:
|
|
5364
5369
|
_context.next = 2;
|
|
5365
|
-
return getERC2612PermitMessage(tokenAddress, poolInfo.poolProcessor, borrowAmountBN);
|
|
5370
|
+
return getERC2612PermitMessage(tokenAddress, poolInfo.poolProcessor, borrowAmountBN.toString());
|
|
5366
5371
|
case 2:
|
|
5367
5372
|
erc2612PermitResult = _context.sent;
|
|
5368
5373
|
tokenContract = new Contract(tokenAddress, ERC2612_ABI);
|
|
5369
|
-
return _context.abrupt("return", tokenContract.interface.encodeFunctionData('permit', [poolInfo.poolProcessor, borrowAmountBN, erc2612PermitResult.nonce, erc2612PermitResult.deadline, erc2612PermitResult.v, erc2612PermitResult.r, erc2612PermitResult.s]));
|
|
5374
|
+
return _context.abrupt("return", tokenContract.interface.encodeFunctionData('permit', [poolInfo.poolProcessor, borrowAmountBN.toString(), erc2612PermitResult.nonce, erc2612PermitResult.deadline, erc2612PermitResult.v, erc2612PermitResult.r, erc2612PermitResult.s]));
|
|
5370
5375
|
case 5:
|
|
5371
5376
|
case "end":
|
|
5372
5377
|
return _context.stop();
|
|
@@ -6337,12 +6342,18 @@ var themeHuma = createTheme(themeBase, {
|
|
|
6337
6342
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6338
6343
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6339
6344
|
function Widget(props) {
|
|
6340
|
-
var children = props.children
|
|
6345
|
+
var children = props.children,
|
|
6346
|
+
provider = props.provider;
|
|
6347
|
+
var chainId;
|
|
6348
|
+
if (provider instanceof JsonRpcProvider) {
|
|
6349
|
+
chainId = provider.network.chainId;
|
|
6350
|
+
}
|
|
6341
6351
|
return jsx(ThemeProvider, {
|
|
6342
6352
|
theme: themeHuma,
|
|
6343
6353
|
children: jsx(Provider, {
|
|
6344
6354
|
store: store,
|
|
6345
6355
|
children: jsx(Provider$1, _objectSpread(_objectSpread({}, props), {}, {
|
|
6356
|
+
defaultChainId: chainId,
|
|
6346
6357
|
children: jsx(Provider$2, {
|
|
6347
6358
|
children: jsx(ChainSupportProvider, {
|
|
6348
6359
|
children: children
|