@huma-finance/widgets 0.0.48-beta.187 → 0.0.48-beta.188

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.
@@ -30,8 +30,6 @@ var TableCell = require('@mui/material/TableCell');
30
30
  var TableContainer = require('@mui/material/TableContainer');
31
31
  var TableHead = require('@mui/material/TableHead');
32
32
  var TableRow = require('@mui/material/TableRow');
33
- var requestClient_js = require('@requestnetwork/request-client.js');
34
- var paymentProcessor = require('@requestnetwork/payment-processor');
35
33
 
36
34
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
37
35
 
@@ -2348,7 +2346,7 @@ function TxDoneModal(_ref) {
2348
2346
  });
2349
2347
  }
2350
2348
 
2351
- function Success$8(_ref) {
2349
+ function Success$7(_ref) {
2352
2350
  var poolInfo = _ref.poolInfo,
2353
2351
  handleAction = _ref.handleAction;
2354
2352
  var _poolInfo$poolUnderly = poolInfo.poolUnderlyingToken,
@@ -2412,7 +2410,7 @@ function CreditLineApprove(_ref) {
2412
2410
  children: [step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$5, {
2413
2411
  poolInfo: poolInfo,
2414
2412
  amount: amount
2415
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$8, {
2413
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$7, {
2416
2414
  poolInfo: poolInfo,
2417
2415
  handleAction: handleClose
2418
2416
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
@@ -2516,7 +2514,7 @@ function SignIn() {
2516
2514
  }
2517
2515
 
2518
2516
  var _templateObject$b, _templateObject2$9, _templateObject3$7, _templateObject4$6, _templateObject5$3, _templateObject6$2, _templateObject7$2;
2519
- function Evaluation$4(_ref) {
2517
+ function Evaluation$3(_ref) {
2520
2518
  var poolInfo = _ref.poolInfo,
2521
2519
  handleApprove = _ref.handleApprove;
2522
2520
  var theme = material.useTheme();
@@ -2815,7 +2813,7 @@ function ChooseAmountModal(_ref) {
2815
2813
  });
2816
2814
  }
2817
2815
 
2818
- function ChooseAmount$7(_ref) {
2816
+ function ChooseAmount$6(_ref) {
2819
2817
  var poolInfo = _ref.poolInfo,
2820
2818
  accountStats = _ref.accountStats;
2821
2819
  var dispatch = useAppDispatch();
@@ -2922,7 +2920,7 @@ function TxSendModal(_ref) {
2922
2920
  });
2923
2921
  }
2924
2922
 
2925
- function Transfer$7(_ref) {
2923
+ function Transfer$6(_ref) {
2926
2924
  var poolInfo = _ref.poolInfo;
2927
2925
  var dispatch = useAppDispatch();
2928
2926
  var reset = utils.useResetAtom(shared.txAtom);
@@ -2942,7 +2940,7 @@ function Transfer$7(_ref) {
2942
2940
  });
2943
2941
  }
2944
2942
 
2945
- function Success$7(_ref) {
2943
+ function Success$6(_ref) {
2946
2944
  var poolInfo = _ref.poolInfo,
2947
2945
  creditRecord = _ref.creditRecord,
2948
2946
  handleAction = _ref.handleAction,
@@ -3415,17 +3413,17 @@ function CreditLineBorrow(_ref) {
3415
3413
  loadingTitle: "Borrow",
3416
3414
  handleClose: handleClose,
3417
3415
  handleSuccess: handleSuccess,
3418
- children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$4, {
3416
+ children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$3, {
3419
3417
  poolInfo: poolInfo,
3420
3418
  handleApprove: approveCallback
3421
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$7, {
3419
+ }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$6, {
3422
3420
  poolInfo: poolInfo,
3423
3421
  accountStats: accountStats
3424
3422
  }), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$4, {
3425
3423
  poolInfo: poolInfo
3426
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$7, {
3424
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$6, {
3427
3425
  poolInfo: poolInfo
3428
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$7, {
3426
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$6, {
3429
3427
  poolInfo: poolInfo,
3430
3428
  handleAction: setupNotificationsOrClose,
3431
3429
  creditRecord: creditRecord,
@@ -3440,7 +3438,7 @@ function CreditLineBorrow(_ref) {
3440
3438
  });
3441
3439
  }
3442
3440
 
3443
- function ChooseAmount$6(_ref) {
3441
+ function ChooseAmount$5(_ref) {
3444
3442
  var payoffAmount = _ref.payoffAmount,
3445
3443
  totalDueAmount = _ref.totalDueAmount,
3446
3444
  poolInfo = _ref.poolInfo;
@@ -3499,7 +3497,7 @@ function ApproveAllowance$3(_ref) {
3499
3497
  });
3500
3498
  }
3501
3499
 
3502
- function Transfer$6(_ref) {
3500
+ function Transfer$5(_ref) {
3503
3501
  var poolInfo = _ref.poolInfo;
3504
3502
  var dispatch = useAppDispatch();
3505
3503
  var _useWeb3React = core.useWeb3React(),
@@ -3519,7 +3517,7 @@ function Transfer$6(_ref) {
3519
3517
  });
3520
3518
  }
3521
3519
 
3522
- function Success$6(_ref) {
3520
+ function Success$5(_ref) {
3523
3521
  var poolInfo = _ref.poolInfo,
3524
3522
  handleAction = _ref.handleAction;
3525
3523
  var _poolInfo$poolUnderly = poolInfo.poolUnderlyingToken,
@@ -3582,15 +3580,15 @@ function CreditLinePayment(_ref) {
3582
3580
  loadingTitle: "Make Payment",
3583
3581
  handleClose: handleClose,
3584
3582
  handleSuccess: handleSuccess,
3585
- children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$6, {
3583
+ children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$5, {
3586
3584
  poolInfo: poolInfo,
3587
3585
  payoffAmount: payoffAmount,
3588
3586
  totalDueAmount: totalDueAmount
3589
3587
  }), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$3, {
3590
3588
  poolInfo: poolInfo
3591
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$6, {
3589
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$5, {
3592
3590
  poolInfo: poolInfo
3593
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$6, {
3591
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$5, {
3594
3592
  poolInfo: poolInfo,
3595
3593
  handleAction: handleClose
3596
3594
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
@@ -3601,7 +3599,7 @@ function CreditLinePayment(_ref) {
3601
3599
  });
3602
3600
  }
3603
3601
 
3604
- function Evaluation$3(_ref) {
3602
+ function Evaluation$2(_ref) {
3605
3603
  var poolInfo = _ref.poolInfo,
3606
3604
  tokenId = _ref.tokenId;
3607
3605
  var _useEA = useEA(),
@@ -3634,7 +3632,7 @@ function Evaluation$3(_ref) {
3634
3632
  });
3635
3633
  }
3636
3634
 
3637
- function ChooseAmount$5(_ref) {
3635
+ function ChooseAmount$4(_ref) {
3638
3636
  var _receivable;
3639
3637
  var poolInfo = _ref.poolInfo,
3640
3638
  accountStats = _ref.accountStats;
@@ -3770,7 +3768,7 @@ function ConfirmTransferModal(_ref) {
3770
3768
  });
3771
3769
  }
3772
3770
 
3773
- function ConfirmTransfer$2() {
3771
+ function ConfirmTransfer$1() {
3774
3772
  var dispatch = useAppDispatch();
3775
3773
  var _useAppSelector = useAppSelector(selectWidgetState),
3776
3774
  borrowAmountNet = _useAppSelector.borrowAmountNet,
@@ -3796,7 +3794,7 @@ function ConfirmTransfer$2() {
3796
3794
  });
3797
3795
  }
3798
3796
 
3799
- function ApproveNFT$1(_ref) {
3797
+ function ApproveNFT(_ref) {
3800
3798
  var poolInfo = _ref.poolInfo,
3801
3799
  tokenId = _ref.tokenId;
3802
3800
  var dispatch = useAppDispatch();
@@ -3833,7 +3831,7 @@ function ApproveNFT$1(_ref) {
3833
3831
  });
3834
3832
  }
3835
3833
 
3836
- function Transfer$5(_ref) {
3834
+ function Transfer$4(_ref) {
3837
3835
  var poolInfo = _ref.poolInfo,
3838
3836
  tokenId = _ref.tokenId;
3839
3837
  var dispatch = useAppDispatch();
@@ -3853,7 +3851,7 @@ function Transfer$5(_ref) {
3853
3851
  });
3854
3852
  }
3855
3853
 
3856
- function Success$5(_ref) {
3854
+ function Success$4(_ref) {
3857
3855
  var handleAction = _ref.handleAction;
3858
3856
  var _useAppSelector = useAppSelector(selectWidgetState),
3859
3857
  borrowAmountNet = _useAppSelector.borrowAmountNet,
@@ -3894,19 +3892,19 @@ function InvoiceFactoringBorrow(_ref) {
3894
3892
  isOpen: true,
3895
3893
  handleClose: handleClose,
3896
3894
  handleSuccess: handleSuccess,
3897
- children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$3, {
3895
+ children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$2, {
3898
3896
  poolInfo: poolInfo,
3899
3897
  tokenId: tokenId.toString()
3900
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$5, {
3898
+ }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$4, {
3901
3899
  poolInfo: poolInfo,
3902
3900
  accountStats: accountStats
3903
- }), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer$2, {}), step === WIDGET_STEP.ApproveNFT && jsxRuntime.jsx(ApproveNFT$1, {
3901
+ }), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer$1, {}), step === WIDGET_STEP.ApproveNFT && jsxRuntime.jsx(ApproveNFT, {
3904
3902
  poolInfo: poolInfo,
3905
3903
  tokenId: tokenId.toString()
3906
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$5, {
3904
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$4, {
3907
3905
  poolInfo: poolInfo,
3908
3906
  tokenId: tokenId.toString()
3909
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$5, {
3907
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$4, {
3910
3908
  handleAction: handleClose
3911
3909
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
3912
3910
  title: "Invoice Factoring",
@@ -3916,7 +3914,7 @@ function InvoiceFactoringBorrow(_ref) {
3916
3914
  });
3917
3915
  }
3918
3916
 
3919
- function ChooseAmount$4(_ref) {
3917
+ function ChooseAmount$3(_ref) {
3920
3918
  var creditRecord = _ref.creditRecord,
3921
3919
  poolInfo = _ref.poolInfo;
3922
3920
  var dispatch = useAppDispatch();
@@ -3978,7 +3976,7 @@ function ApproveAllowance$2(_ref) {
3978
3976
  });
3979
3977
  }
3980
3978
 
3981
- function Transfer$4(_ref) {
3979
+ function Transfer$3(_ref) {
3982
3980
  var poolInfo = _ref.poolInfo;
3983
3981
  var dispatch = useAppDispatch();
3984
3982
  var _useWeb3React = core.useWeb3React(),
@@ -3998,7 +3996,7 @@ function Transfer$4(_ref) {
3998
3996
  });
3999
3997
  }
4000
3998
 
4001
- function Success$4(_ref) {
3999
+ function Success$3(_ref) {
4002
4000
  var poolInfo = _ref.poolInfo,
4003
4001
  handleAction = _ref.handleAction;
4004
4002
  var symbol = poolInfo.poolUnderlyingToken.symbol;
@@ -4041,14 +4039,14 @@ function InvoiceFactoringPayment(_ref) {
4041
4039
  loadingTitle: "Make Payment",
4042
4040
  handleClose: handleClose,
4043
4041
  handleSuccess: handleSuccess,
4044
- children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$4, {
4042
+ children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$3, {
4045
4043
  creditRecord: creditRecord,
4046
4044
  poolInfo: poolInfo
4047
4045
  }), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$2, {
4048
4046
  poolInfo: poolInfo
4049
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$4, {
4047
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$3, {
4050
4048
  poolInfo: poolInfo
4051
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$4, {
4049
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$3, {
4052
4050
  poolInfo: poolInfo,
4053
4051
  handleAction: handleClose
4054
4052
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
@@ -4532,7 +4530,7 @@ function EvaluationKYC(_ref) {
4532
4530
  });
4533
4531
  }
4534
4532
 
4535
- function Evaluation$2(_ref) {
4533
+ function Evaluation$1(_ref) {
4536
4534
  var _poolInfo$extra;
4537
4535
  var poolInfo = _ref.poolInfo,
4538
4536
  handleClose = _ref.handleClose,
@@ -4551,7 +4549,7 @@ function Evaluation$2(_ref) {
4551
4549
  });
4552
4550
  }
4553
4551
 
4554
- function ChooseAmount$3(_ref) {
4552
+ function ChooseAmount$2(_ref) {
4555
4553
  var allowance = _ref.allowance,
4556
4554
  withdrawlLockoutSeconds = _ref.withdrawlLockoutSeconds,
4557
4555
  underlyingTokenBalance = _ref.underlyingTokenBalance,
@@ -4603,7 +4601,7 @@ function ApproveAllowance$1(_ref) {
4603
4601
  });
4604
4602
  }
4605
4603
 
4606
- function Transfer$3(_ref) {
4604
+ function Transfer$2(_ref) {
4607
4605
  var poolInfo = _ref.poolInfo;
4608
4606
  var dispatch = useAppDispatch();
4609
4607
  var _useAppSelector = useAppSelector(selectWidgetState),
@@ -4621,7 +4619,7 @@ function Transfer$3(_ref) {
4621
4619
  });
4622
4620
  }
4623
4621
 
4624
- function Success$3(_ref) {
4622
+ function Success$2(_ref) {
4625
4623
  var poolInfo = _ref.poolInfo,
4626
4624
  handleAction = _ref.handleAction,
4627
4625
  hasNextStep = _ref.hasNextStep;
@@ -4733,20 +4731,20 @@ function LendSupply(_ref) {
4733
4731
  loadingTitle: "Supply ".concat(poolInfo.poolUnderlyingToken.symbol),
4734
4732
  handleClose: handleClose,
4735
4733
  handleSuccess: handleSupplySuccess,
4736
- children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$2, {
4734
+ children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$1, {
4737
4735
  poolInfo: poolInfo,
4738
4736
  handleClose: handleClose,
4739
4737
  handleApproveSuccess: handleApproveSuccess
4740
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$3, {
4738
+ }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$2, {
4741
4739
  poolInfo: poolInfo,
4742
4740
  allowance: allowance,
4743
4741
  underlyingTokenBalance: balanceWithoutDecimals,
4744
4742
  withdrawlLockoutSeconds: withdrawlLockoutSeconds
4745
4743
  }), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$1, {
4746
4744
  poolInfo: poolInfo
4747
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$3, {
4745
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$2, {
4748
4746
  poolInfo: poolInfo
4749
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$3, {
4747
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$2, {
4750
4748
  poolInfo: poolInfo,
4751
4749
  handleAction: setupNotificationsOrClose,
4752
4750
  hasNextStep: isFirstTimeNotifiUser
@@ -4799,8 +4797,9 @@ function CheckWithdrawable(_ref) {
4799
4797
  });
4800
4798
  }
4801
4799
 
4802
- function ChooseAmount$2(_ref) {
4800
+ function ChooseAmount$1(_ref) {
4803
4801
  var lenderPosition = _ref.lenderPosition,
4802
+ poolBalance = _ref.poolBalance,
4804
4803
  poolInfo = _ref.poolInfo;
4805
4804
  var dispatch = useAppDispatch();
4806
4805
  var poolUnderlyingToken = poolInfo.poolUnderlyingToken;
@@ -4810,7 +4809,9 @@ function ChooseAmount$2(_ref) {
4810
4809
  _useState2 = _slicedToArray(_useState, 2),
4811
4810
  currentAmount = _useState2[0],
4812
4811
  setCurrentAmount = _useState2[1];
4813
- var withdrawableAmount = shared.downScale(lenderPosition, decimals);
4812
+ // Take the minimum of the pool balance or the lender position
4813
+ var withdrawableAmountBN = lenderPosition.lt(poolBalance) ? lenderPosition : poolBalance;
4814
+ var withdrawableAmount = shared.downScale(withdrawableAmountBN, decimals);
4814
4815
  var handleChangeAmount = React.useCallback(function (newAmount) {
4815
4816
  setCurrentAmount(newAmount);
4816
4817
  dispatch(setWithdrawAmount(newAmount));
@@ -4831,7 +4832,7 @@ function ChooseAmount$2(_ref) {
4831
4832
  });
4832
4833
  }
4833
4834
 
4834
- function Transfer$2(_ref) {
4835
+ function Transfer$1(_ref) {
4835
4836
  var poolInfo = _ref.poolInfo;
4836
4837
  var dispatch = useAppDispatch();
4837
4838
  var decimals = poolInfo.poolUnderlyingToken.decimals;
@@ -4849,7 +4850,7 @@ function Transfer$2(_ref) {
4849
4850
  });
4850
4851
  }
4851
4852
 
4852
- function Success$2(_ref) {
4853
+ function Success$1(_ref) {
4853
4854
  var poolInfo = _ref.poolInfo,
4854
4855
  handleAction = _ref.handleAction;
4855
4856
  var _useWeb3React = core.useWeb3React(),
@@ -4906,17 +4907,22 @@ function LendWithdraw(_ref) {
4906
4907
  _useLenderPosition2 = _slicedToArray(_useLenderPosition, 2),
4907
4908
  lenderPosition = _useLenderPosition2[0],
4908
4909
  refreshLenderPosition = _useLenderPosition2[1];
4910
+ var _usePoolBalance = shared.usePoolBalance(poolName, poolType),
4911
+ _usePoolBalance2 = _slicedToArray(_usePoolBalance, 2),
4912
+ poolBalance = _usePoolBalance2[0],
4913
+ refreshPoolBalance = _usePoolBalance2[1];
4909
4914
  React.useEffect(function () {
4910
- if (!step && lenderPosition) {
4915
+ if (!step && lenderPosition && poolBalance) {
4911
4916
  dispatch(setStep(WIDGET_STEP.CheckWithdrawable));
4912
4917
  }
4913
- }, [dispatch, lenderPosition, step]);
4918
+ }, [dispatch, lenderPosition, poolBalance, step]);
4914
4919
  var handleWithdrawSuccess = React.useCallback(function (blockNumber) {
4915
4920
  refreshLenderPosition();
4921
+ refreshPoolBalance();
4916
4922
  if (handleSuccess) {
4917
4923
  handleSuccess(blockNumber);
4918
4924
  }
4919
- }, [handleSuccess, refreshLenderPosition]);
4925
+ }, [handleSuccess, refreshLenderPosition, refreshPoolBalance]);
4920
4926
  if (!poolInfo) {
4921
4927
  return null;
4922
4928
  }
@@ -4927,12 +4933,13 @@ function LendWithdraw(_ref) {
4927
4933
  children: [(!step || step === WIDGET_STEP.CheckWithdrawable) && jsxRuntime.jsx(CheckWithdrawable, {
4928
4934
  poolInfo: poolInfo,
4929
4935
  handleClose: handleClose
4930
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$2, {
4936
+ }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$1, {
4931
4937
  poolInfo: poolInfo,
4932
- lenderPosition: lenderPosition
4933
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$2, {
4938
+ lenderPosition: lenderPosition,
4939
+ poolBalance: poolBalance
4940
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$1, {
4934
4941
  poolInfo: poolInfo
4935
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$2, {
4942
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$1, {
4936
4943
  poolInfo: poolInfo,
4937
4944
  handleAction: handleClose
4938
4945
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
@@ -5225,7 +5232,7 @@ function ApolloWrapper(_ref) {
5225
5232
  });
5226
5233
  }
5227
5234
 
5228
- function Evaluation$1(_ref) {
5235
+ function Evaluation(_ref) {
5229
5236
  var poolInfo = _ref.poolInfo,
5230
5237
  payerAddress = _ref.payerAddress,
5231
5238
  superToken = _ref.superToken;
@@ -5259,7 +5266,7 @@ function Evaluation$1(_ref) {
5259
5266
  });
5260
5267
  }
5261
5268
 
5262
- function ChooseAmount$1(_ref) {
5269
+ function ChooseAmount(_ref) {
5263
5270
  var poolInfo = _ref.poolInfo,
5264
5271
  currentFlowRate = _ref.currentFlowRate;
5265
5272
  var dispatch = useAppDispatch();
@@ -5340,7 +5347,7 @@ function ChooseAmount$1(_ref) {
5340
5347
  });
5341
5348
  }
5342
5349
 
5343
- function ConfirmTransfer$1() {
5350
+ function ConfirmTransfer() {
5344
5351
  var dispatch = useAppDispatch();
5345
5352
  var _useWeb3React = core.useWeb3React(),
5346
5353
  chainId = _useWeb3React.chainId;
@@ -5502,7 +5509,7 @@ function Permit(_ref) {
5502
5509
  });
5503
5510
  }
5504
5511
 
5505
- function Transfer$1(_ref) {
5512
+ function Transfer(_ref) {
5506
5513
  var poolInfo = _ref.poolInfo;
5507
5514
  var dispatch = useAppDispatch();
5508
5515
  var multiSendContract = shared.useMultiSendContract();
@@ -5524,7 +5531,7 @@ function Transfer$1(_ref) {
5524
5531
  });
5525
5532
  }
5526
5533
 
5527
- function Success$1(_ref) {
5534
+ function Success(_ref) {
5528
5535
  var handleAction = _ref.handleAction;
5529
5536
  var _useAppSelector = useAppSelector(selectWidgetState),
5530
5537
  borrowAmount = _useAppSelector.borrowAmount,
@@ -5563,14 +5570,14 @@ function StreamFactoringBorrow(_ref) {
5563
5570
  isOpen: isOpen,
5564
5571
  handleClose: handleClose,
5565
5572
  handleSuccess: handleSuccess,
5566
- children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$1, {
5573
+ children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation, {
5567
5574
  poolInfo: poolInfo,
5568
5575
  payerAddress: payerAddress,
5569
5576
  superToken: superToken
5570
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$1, {
5577
+ }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount, {
5571
5578
  poolInfo: poolInfo,
5572
5579
  currentFlowRate: currentFlowRate
5573
- }), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer$1, {}), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance, {
5580
+ }), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer, {}), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance, {
5574
5581
  poolInfo: poolInfo
5575
5582
  }), step === WIDGET_STEP.Permit && account && chainId && jsxRuntime.jsx(Permit, {
5576
5583
  poolInfo: poolInfo,
@@ -5578,9 +5585,9 @@ function StreamFactoringBorrow(_ref) {
5578
5585
  chainId: chainId,
5579
5586
  borrower: account,
5580
5587
  superToken: superToken
5581
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$1, {
5588
+ }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer, {
5582
5589
  poolInfo: poolInfo
5583
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$1, {
5590
+ }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success, {
5584
5591
  handleAction: handleClose
5585
5592
  }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
5586
5593
  title: "Stream Borrowing",
@@ -6380,315 +6387,6 @@ var themeHuma = material.createTheme(themeBase, {
6380
6387
  components: components(themeBase)
6381
6388
  });
6382
6389
 
6383
- function Evaluation(_ref) {
6384
- var poolInfo = _ref.poolInfo,
6385
- tokenId = _ref.tokenId;
6386
- var _useEA = useEA(),
6387
- checkingEA = _useEA.checkingEA,
6388
- isWalletOwnershipVerificationRequired = _useEA.isWalletOwnershipVerificationRequired,
6389
- isWalletOwnershipVerified = _useEA.isWalletOwnershipVerified;
6390
- var _useWeb3React = core.useWeb3React(),
6391
- account = _useWeb3React.account,
6392
- chainId = _useWeb3React.chainId;
6393
- React.useEffect(function () {
6394
- if (account && chainId) {
6395
- checkingEA({
6396
- poolAddress: poolInfo.pool,
6397
- borrowerWalletAddress: account,
6398
- context: {
6399
- receivable: {
6400
- address: poolInfo.assetAddress,
6401
- param: shared.toBigNumber(tokenId).toHexString()
6402
- }
6403
- }
6404
- }, WIDGET_STEP.ChooseAmount);
6405
- }
6406
- }, [account, chainId, checkingEA, poolInfo.assetAddress, poolInfo.pool, tokenId, isWalletOwnershipVerified]);
6407
- if (isWalletOwnershipVerificationRequired) {
6408
- return jsxRuntime.jsx(SignIn, {});
6409
- }
6410
- return jsxRuntime.jsx(LoadingModal, {
6411
- title: "Checking Invoice",
6412
- description: "Checking if the invoice qualifies for factoring..."
6413
- });
6414
- }
6415
-
6416
- function ChooseAmount(_ref) {
6417
- var _receivable;
6418
- var poolInfo = _ref.poolInfo,
6419
- accountStats = _ref.accountStats;
6420
- var dispatch = useAppDispatch();
6421
- var creditRecord = accountStats.creditRecord;
6422
- var _useState = React.useState(0),
6423
- _useState2 = _slicedToArray(_useState, 2),
6424
- chargedFees = _useState2[0],
6425
- setChargedFees = _useState2[1];
6426
- var _useState3 = React.useState(0),
6427
- _useState4 = _slicedToArray(_useState3, 2),
6428
- currentAmount = _useState4[0],
6429
- setCurrentAmount = _useState4[1];
6430
- var _useAppSelector = useAppSelector(selectWidgetState),
6431
- approval = _useAppSelector.approval;
6432
- var _useFeeManager = shared.useFeeManager(poolInfo.poolName, poolInfo.poolType),
6433
- getFeesCharged = _useFeeManager.getFeesCharged;
6434
- var _useState5 = React.useState((_receivable = approval.receivable) === null || _receivable === void 0 ? void 0 : _receivable.amountFormatted),
6435
- _useState6 = _slicedToArray(_useState5, 2),
6436
- remainder = _useState6[0],
6437
- setRemainder = _useState6[1];
6438
- var getAvailableCreditLimit = function getAvailableCreditLimit() {
6439
- if (approval && creditRecord) {
6440
- var principal = creditRecord.unbilledPrincipal.add(creditRecord.totalDue).sub(creditRecord.feesAndInterestDue).toNumber();
6441
- return Number(approval.terms.creditLimitFormatted) - principal;
6442
- }
6443
- return 0;
6444
- };
6445
- var handleChangeAmount = React.useCallback(function (newAmount) {
6446
- if (approval) {
6447
- setCurrentAmount(newAmount);
6448
- setChargedFees(getFeesCharged(newAmount));
6449
- setRemainder(Number(approval.receivable.amountFormatted) - newAmount);
6450
- }
6451
- }, [approval, getFeesCharged]);
6452
- var handleAction = React.useCallback(function () {
6453
- dispatch(setBorrowInfo({
6454
- borrowAmount: currentAmount,
6455
- borrowAmountBN: shared.upScale(currentAmount, approval === null || approval === void 0 ? void 0 : approval.token.decimal),
6456
- chargedFees: chargedFees,
6457
- remainder: Number(remainder),
6458
- nextStep: WIDGET_STEP.ConfirmTransfer
6459
- }));
6460
- }, [approval === null || approval === void 0 ? void 0 : approval.token.decimal, chargedFees, currentAmount, dispatch, remainder]);
6461
- if (!approval) {
6462
- return null;
6463
- }
6464
- return jsxRuntime.jsx(ChooseAmountModal, {
6465
- title: "Choose Amount",
6466
- description1: "Access up to 80% of your invoice value",
6467
- description2: "The remainder will be sent to your wallet when the invoice is paid",
6468
- sliderMax: getAvailableCreditLimit(),
6469
- currentAmount: currentAmount,
6470
- tokenSymbol: approval.token.symbol,
6471
- topLeft: "Fees",
6472
- topRight: "".concat(chargedFees, " ").concat(approval.token.symbol),
6473
- downLeft: "Remainder",
6474
- downRight: "".concat(remainder, " ").concat(approval.token.symbol),
6475
- handleChangeAmount: handleChangeAmount,
6476
- handleAction: handleAction
6477
- });
6478
- }
6479
-
6480
- function ConfirmTransfer() {
6481
- var dispatch = useAppDispatch();
6482
- var _useAppSelector = useAppSelector(selectWidgetState),
6483
- borrowAmountNet = _useAppSelector.borrowAmountNet,
6484
- approval = _useAppSelector.approval;
6485
- var handleAction = function handleAction() {
6486
- dispatch(setStep(WIDGET_STEP.ApproveNFT));
6487
- };
6488
- if (shared.isEmpty(borrowAmountNet) || shared.isEmpty(approval)) {
6489
- return null;
6490
- }
6491
- return jsxRuntime.jsx(ConfirmTransferModal, {
6492
- title: "Confirm transaction details",
6493
- description: "Huma keeps your Invoice NFT as collateral until it's fully paid.",
6494
- items: [{
6495
- leftText: 'Invoice NFT',
6496
- rightText: 'Huma'
6497
- }, {
6498
- leftText: "".concat(borrowAmountNet, " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol),
6499
- rightText: 'You'
6500
- }],
6501
- actionText: "APPROVE TRANSFER",
6502
- handleAction: handleAction
6503
- });
6504
- }
6505
-
6506
- function ApproveNFT(_ref) {
6507
- var poolInfo = _ref.poolInfo,
6508
- tokenId = _ref.tokenId;
6509
- var dispatch = useAppDispatch();
6510
- var _useWeb3React = core.useWeb3React(),
6511
- provider = _useWeb3React.provider;
6512
- var _useAtom = jotai.useAtom(shared.sendTxAtom),
6513
- _useAtom2 = _slicedToArray(_useAtom, 2),
6514
- _useAtom2$ = _useAtom2[0],
6515
- state = _useAtom2$.state,
6516
- txHash = _useAtom2$.txHash,
6517
- send = _useAtom2[1];
6518
- var reset = utils.useResetAtom(shared.txAtom);
6519
- var invoiceNFTContract = shared.useInvoiceNFTContract(poolInfo.poolName);
6520
- React.useEffect(function () {
6521
- if (state === shared.TxStateType.Success) {
6522
- reset();
6523
- dispatch(setStep(WIDGET_STEP.Transfer));
6524
- }
6525
- }, [dispatch, reset, state]);
6526
- React.useEffect(function () {
6527
- send({
6528
- contract: invoiceNFTContract,
6529
- method: 'approve',
6530
- params: [poolInfo.pool, tokenId],
6531
- provider: provider
6532
- });
6533
- }, [invoiceNFTContract, poolInfo.pool, provider, send, tokenId]);
6534
- return jsxRuntime.jsx(LoadingModal, {
6535
- title: "Approve Invoice Transfer",
6536
- description: "Waiting for approval confirmation...",
6537
- children: jsxRuntime.jsx(ViewOnExplorer, {
6538
- txHash: txHash
6539
- })
6540
- });
6541
- }
6542
-
6543
- function Transfer(_ref) {
6544
- var poolInfo = _ref.poolInfo,
6545
- tokenId = _ref.tokenId;
6546
- var dispatch = useAppDispatch();
6547
- var decimals = poolInfo.poolUnderlyingToken.decimals;
6548
- var _useAppSelector = useAppSelector(selectWidgetState),
6549
- borrowAmount = _useAppSelector.borrowAmount;
6550
- var requestLoanBigNumber = shared.toBigNumber(shared.upScale(borrowAmount, decimals));
6551
- var handleSuccess = React.useCallback(function () {
6552
- dispatch(setStep(WIDGET_STEP.Done));
6553
- }, [dispatch]);
6554
- return jsxRuntime.jsx(TxSendModal, {
6555
- poolInfo: poolInfo,
6556
- title: "Transfer Invoice and Money",
6557
- method: "drawdownWithReceivable",
6558
- params: [requestLoanBigNumber, poolInfo.assetAddress, tokenId],
6559
- handleSuccess: handleSuccess
6560
- });
6561
- }
6562
-
6563
- function Success(_ref) {
6564
- var handleAction = _ref.handleAction;
6565
- var _useAppSelector = useAppSelector(selectWidgetState),
6566
- borrowAmountNet = _useAppSelector.borrowAmountNet,
6567
- remainder = _useAppSelector.remainder,
6568
- approval = _useAppSelector.approval;
6569
- var content = ["".concat(borrowAmountNet, " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol, " is now in your wallet."), "The remaining ".concat(remainder, " ").concat(approval === null || approval === void 0 ? void 0 : approval.token.symbol, " will be sent to your wallet when the invoice is paid.")];
6570
- return jsxRuntime.jsx(TxDoneModal, {
6571
- handleAction: handleAction,
6572
- content: content
6573
- });
6574
- }
6575
-
6576
- function RequestNetworkInvoiceFactoringBorrow(_ref) {
6577
- var poolNameStr = _ref.poolName,
6578
- poolTypeStr = _ref.poolType,
6579
- requestId = _ref.requestId,
6580
- handleClose = _ref.handleClose,
6581
- handleSuccess = _ref.handleSuccess;
6582
- var dispatch = reactRedux.useDispatch();
6583
- var _useWeb3React = core.useWeb3React(),
6584
- account = _useWeb3React.account,
6585
- provider = _useWeb3React.provider;
6586
- var poolName = shared.POOL_NAME[poolNameStr];
6587
- var poolType = shared.POOL_TYPE[poolTypeStr];
6588
- var poolInfo = shared.usePoolInfo(poolName, poolType);
6589
- var _useAppSelector = useAppSelector(selectWidgetState),
6590
- step = _useAppSelector.step,
6591
- errorMessage = _useAppSelector.errorMessage;
6592
- var _useAccountStats = shared.useAccountStats(poolName, poolType, account),
6593
- _useAccountStats2 = _slicedToArray(_useAccountStats, 1),
6594
- accountStats = _useAccountStats2[0];
6595
- var _useState = React.useState(),
6596
- _useState2 = _slicedToArray(_useState, 2),
6597
- tokenId = _useState2[0],
6598
- setTokenId = _useState2[1];
6599
- var _useState3 = React.useState(true),
6600
- _useState4 = _slicedToArray(_useState3, 2),
6601
- isLoading = _useState4[0],
6602
- setIsLoading = _useState4[1];
6603
- React.useEffect(function () {
6604
- dispatch(setStep(WIDGET_STEP.Evaluation));
6605
- }, [dispatch]);
6606
- React.useEffect(function () {
6607
- if (provider == null) {
6608
- return function () {}; // Return empty func to satisty consistent return lint rule
6609
- }
6610
-
6611
- // Refetch every 5 seconds until requestData is non-null
6612
- var interval = setInterval(function () {
6613
- function getInvoice() {
6614
- return _getInvoice.apply(this, arguments);
6615
- }
6616
- function _getInvoice() {
6617
- _getInvoice = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
6618
- var requestNetwork, request, requestData, tokenId;
6619
- return regenerator.wrap(function _callee$(_context) {
6620
- while (1) switch (_context.prev = _context.next) {
6621
- case 0:
6622
- if (!(provider == null)) {
6623
- _context.next = 2;
6624
- break;
6625
- }
6626
- return _context.abrupt("return");
6627
- case 2:
6628
- requestNetwork = new requestClient_js.RequestNetwork({
6629
- nodeConnectionConfig: {
6630
- baseURL: "https://xdai.gateway.request.network/"
6631
- }
6632
- });
6633
- _context.next = 5;
6634
- return requestNetwork.fromRequestId(requestId);
6635
- case 5:
6636
- request = _context.sent;
6637
- requestData = request.getData();
6638
- _context.next = 9;
6639
- return paymentProcessor.getReceivableTokenIdForRequest(requestData, provider);
6640
- case 9:
6641
- tokenId = _context.sent;
6642
- // Check if token ID exists yet for this request
6643
- if (tokenId) {
6644
- setTokenId(tokenId);
6645
- setIsLoading(false);
6646
- clearInterval(interval);
6647
- }
6648
- case 11:
6649
- case "end":
6650
- return _context.stop();
6651
- }
6652
- }, _callee);
6653
- }));
6654
- return _getInvoice.apply(this, arguments);
6655
- }
6656
- getInvoice();
6657
- }, 5000);
6658
- return function () {
6659
- return clearInterval(interval);
6660
- };
6661
- }, [provider, requestId]);
6662
- if (!poolInfo) {
6663
- return null;
6664
- }
6665
- return jsxRuntime.jsxs(WidgetWrapper, {
6666
- isOpen: true,
6667
- isLoading: isLoading,
6668
- handleClose: handleClose,
6669
- handleSuccess: handleSuccess,
6670
- children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation, {
6671
- poolInfo: poolInfo,
6672
- tokenId: tokenId.toString()
6673
- }), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount, {
6674
- poolInfo: poolInfo,
6675
- accountStats: accountStats
6676
- }), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer, {}), step === WIDGET_STEP.ApproveNFT && jsxRuntime.jsx(ApproveNFT, {
6677
- poolInfo: poolInfo,
6678
- tokenId: tokenId.toString()
6679
- }), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer, {
6680
- poolInfo: poolInfo,
6681
- tokenId: tokenId.toString()
6682
- }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success, {
6683
- handleAction: handleClose
6684
- }), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
6685
- title: "Invoice Factoring",
6686
- errorMessage: errorMessage,
6687
- handleOk: handleClose
6688
- })]
6689
- });
6690
- }
6691
-
6692
6390
  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; }
6693
6391
  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; }
6694
6392
  function Widget(props) {
@@ -6714,25 +6412,6 @@ function Widget(props) {
6714
6412
  });
6715
6413
  }
6716
6414
 
6717
- /**
6718
- * Invoice factoring pool borrow widget props
6719
- * @typedef {Object} RequestNetworkInvoiceFactoringBorrowWidgetProps
6720
- * @property {RequestNetworkInvoiceFactoringBorrowProps} RequestNetworkInvoiceFactoringBorrowProps - Invoice factoring pool borrow props.
6721
- * @property {WidgetProps} WidgetProps - Widget general props.
6722
- */
6723
-
6724
- /**
6725
- * Invoice factoring borrow widget
6726
- *
6727
- * @param {RequestNetworkInvoiceFactoringBorrowWidgetProps} props - The invoice factoring pool borrow widget props.
6728
- * @returns Invoice factoring pool borrow widget component
6729
- */
6730
- function RequestNetworkInvoiceFactoringBorrowWidget(props) {
6731
- return jsxRuntime.jsx(Widget, _objectSpread(_objectSpread({}, props), {}, {
6732
- children: jsxRuntime.jsx(RequestNetworkInvoiceFactoringBorrow, _objectSpread({}, props))
6733
- }));
6734
- }
6735
-
6736
6415
  /**
6737
6416
  * Invoice factoring pool borrow widget props
6738
6417
  * @typedef {Object} InvoiceFactoringBorrowWidgetProps
@@ -6886,6 +6565,5 @@ exports.InvoiceFactoringBorrowWidget = InvoiceFactoringBorrowWidget;
6886
6565
  exports.InvoiceFactoringPaymentWidget = InvoiceFactoringPaymentWidget;
6887
6566
  exports.LendSupplyWidget = LendSupplyWidget;
6888
6567
  exports.LendWithdrawWidget = LendWithdrawWidget;
6889
- exports.RequestNetworkInvoiceFactoringBorrowWidget = RequestNetworkInvoiceFactoringBorrowWidget;
6890
6568
  exports.SuperfluidFactoringWidget = SuperfluidFactoringWidget;
6891
6569
  //# sourceMappingURL=index.cjs.map