@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/dist/cjs/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var providers = require('@ethersproject/providers');
|
|
5
6
|
var shared = require('@huma-finance/shared');
|
|
6
7
|
var material = require('@mui/material');
|
|
7
8
|
var jotai = require('jotai');
|
|
@@ -273,6 +274,7 @@ var widgetSlice = toolkit.createSlice({
|
|
|
273
274
|
},
|
|
274
275
|
setError: function setError(state, _ref10) {
|
|
275
276
|
var payload = _ref10.payload;
|
|
277
|
+
console.trace();
|
|
276
278
|
state.errorMessage = payload.errorMessage;
|
|
277
279
|
state.errorReason = payload.errorReason;
|
|
278
280
|
state.step = WIDGET_STEP.Error;
|
|
@@ -2843,7 +2845,7 @@ function ChooseAmount$6(_ref) {
|
|
|
2843
2845
|
var nextStep = approved ? WIDGET_STEP.Transfer : WIDGET_STEP.ApproveAllowance;
|
|
2844
2846
|
dispatch(setBorrowInfo({
|
|
2845
2847
|
borrowAmount: currentAmount,
|
|
2846
|
-
borrowAmountBN:
|
|
2848
|
+
borrowAmountBN: ethers.BigNumber.from(currentAmount).mul(ethers.BigNumber.from(10).pow(decimals)).toJSON(),
|
|
2847
2849
|
chargedFees: chargedFees,
|
|
2848
2850
|
nextStep: nextStep
|
|
2849
2851
|
}));
|
|
@@ -2923,7 +2925,8 @@ function Transfer$6(_ref) {
|
|
|
2923
2925
|
var dispatch = useAppDispatch();
|
|
2924
2926
|
var reset = utils.useResetAtom(shared.txAtom);
|
|
2925
2927
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
2926
|
-
|
|
2928
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN;
|
|
2929
|
+
var borrowAmountBN = ethers.BigNumber.from(borrowAmountBNJson);
|
|
2927
2930
|
var handleSuccess = React.useCallback(function () {
|
|
2928
2931
|
reset();
|
|
2929
2932
|
var nextStep = WIDGET_STEP.Done;
|
|
@@ -3668,7 +3671,7 @@ function ChooseAmount$4(_ref) {
|
|
|
3668
3671
|
var handleAction = React.useCallback(function () {
|
|
3669
3672
|
dispatch(setBorrowInfo({
|
|
3670
3673
|
borrowAmount: currentAmount,
|
|
3671
|
-
borrowAmountBN:
|
|
3674
|
+
borrowAmountBN: ethers.BigNumber.from(currentAmount).mul(ethers.BigNumber.from(10).pow(ethers.BigNumber.from(approval === null || approval === void 0 ? void 0 : approval.token.decimal))).toJSON(),
|
|
3672
3675
|
chargedFees: chargedFees,
|
|
3673
3676
|
remainder: Number(remainder),
|
|
3674
3677
|
nextStep: WIDGET_STEP.ConfirmTransfer
|
|
@@ -5293,7 +5296,7 @@ function ChooseAmount(_ref) {
|
|
|
5293
5296
|
return {
|
|
5294
5297
|
borrowFlowrate: borrowFlowrate.toString(),
|
|
5295
5298
|
borrowAmount: Number(newBorrowAmount),
|
|
5296
|
-
borrowAmountBN: newBorrowAmountBN
|
|
5299
|
+
borrowAmountBN: newBorrowAmountBN
|
|
5297
5300
|
};
|
|
5298
5301
|
}, [approval, borrowPeriodInSeconds, currentFlowRate]);
|
|
5299
5302
|
var handleChangeAmount = React.useCallback(function (newAmount) {
|
|
@@ -5313,7 +5316,7 @@ function ChooseAmount(_ref) {
|
|
|
5313
5316
|
}));
|
|
5314
5317
|
dispatch(setBorrowInfo({
|
|
5315
5318
|
borrowAmount: borrowAmount,
|
|
5316
|
-
borrowAmountBN: borrowAmountBN,
|
|
5319
|
+
borrowAmountBN: borrowAmountBN.toJSON(),
|
|
5317
5320
|
chargedFees: chargedFees,
|
|
5318
5321
|
nextStep: WIDGET_STEP.ConfirmTransfer
|
|
5319
5322
|
}));
|
|
@@ -5368,7 +5371,8 @@ function ApproveAllowance(_ref) {
|
|
|
5368
5371
|
var poolInfo = _ref.poolInfo;
|
|
5369
5372
|
var dispatch = reactRedux.useDispatch();
|
|
5370
5373
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
5371
|
-
|
|
5374
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN;
|
|
5375
|
+
var borrowAmountBN = ethers.BigNumber.from(borrowAmountBNJson);
|
|
5372
5376
|
var handleSuccess = React.useCallback(function () {
|
|
5373
5377
|
dispatch(setStep(WIDGET_STEP.Permit));
|
|
5374
5378
|
}, [dispatch]);
|
|
@@ -5389,11 +5393,12 @@ function Permit(_ref) {
|
|
|
5389
5393
|
var dispatch = reactRedux.useDispatch();
|
|
5390
5394
|
var tokenAddress = poolInfo.poolUnderlyingToken.address;
|
|
5391
5395
|
var _useAppSelector = useAppSelector(selectWidgetState),
|
|
5392
|
-
|
|
5396
|
+
borrowAmountBNJson = _useAppSelector.borrowAmountBN,
|
|
5393
5397
|
stream = _useAppSelector.stream;
|
|
5394
5398
|
var _useERC2612Permit = shared.useERC2612Permit(),
|
|
5395
5399
|
getERC2612PermitMessage = _useERC2612Permit.getERC2612PermitMessage,
|
|
5396
5400
|
getTradableStreamPermitMessage = _useERC2612Permit.getTradableStreamPermitMessage;
|
|
5401
|
+
var borrowAmountBN = ethers.BigNumber.from(borrowAmountBNJson);
|
|
5397
5402
|
var getApproveAllowanceCallData = /*#__PURE__*/function () {
|
|
5398
5403
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
5399
5404
|
var erc2612PermitResult, tokenContract;
|
|
@@ -5401,11 +5406,11 @@ function Permit(_ref) {
|
|
|
5401
5406
|
while (1) switch (_context.prev = _context.next) {
|
|
5402
5407
|
case 0:
|
|
5403
5408
|
_context.next = 2;
|
|
5404
|
-
return getERC2612PermitMessage(tokenAddress, poolInfo.poolProcessor, borrowAmountBN);
|
|
5409
|
+
return getERC2612PermitMessage(tokenAddress, poolInfo.poolProcessor, borrowAmountBN.toString());
|
|
5405
5410
|
case 2:
|
|
5406
5411
|
erc2612PermitResult = _context.sent;
|
|
5407
5412
|
tokenContract = new ethers.Contract(tokenAddress, shared.ERC2612_ABI);
|
|
5408
|
-
return _context.abrupt("return", tokenContract.interface.encodeFunctionData('permit', [poolInfo.poolProcessor, borrowAmountBN, erc2612PermitResult.nonce, erc2612PermitResult.deadline, erc2612PermitResult.v, erc2612PermitResult.r, erc2612PermitResult.s]));
|
|
5413
|
+
return _context.abrupt("return", tokenContract.interface.encodeFunctionData('permit', [poolInfo.poolProcessor, borrowAmountBN.toString(), erc2612PermitResult.nonce, erc2612PermitResult.deadline, erc2612PermitResult.v, erc2612PermitResult.r, erc2612PermitResult.s]));
|
|
5409
5414
|
case 5:
|
|
5410
5415
|
case "end":
|
|
5411
5416
|
return _context.stop();
|
|
@@ -6376,12 +6381,18 @@ var themeHuma = material.createTheme(themeBase, {
|
|
|
6376
6381
|
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; }
|
|
6377
6382
|
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; }
|
|
6378
6383
|
function Widget(props) {
|
|
6379
|
-
var children = props.children
|
|
6384
|
+
var children = props.children,
|
|
6385
|
+
provider = props.provider;
|
|
6386
|
+
var chainId;
|
|
6387
|
+
if (provider instanceof providers.JsonRpcProvider) {
|
|
6388
|
+
chainId = provider.network.chainId;
|
|
6389
|
+
}
|
|
6380
6390
|
return jsxRuntime.jsx(material.ThemeProvider, {
|
|
6381
6391
|
theme: themeHuma,
|
|
6382
6392
|
children: jsxRuntime.jsx(reactRedux.Provider, {
|
|
6383
6393
|
store: store,
|
|
6384
6394
|
children: jsxRuntime.jsx(shared.Provider, _objectSpread(_objectSpread({}, props), {}, {
|
|
6395
|
+
defaultChainId: chainId,
|
|
6385
6396
|
children: jsxRuntime.jsx(jotai.Provider, {
|
|
6386
6397
|
children: jsxRuntime.jsx(ChainSupportProvider, {
|
|
6387
6398
|
children: children
|