@huma-finance/widgets 0.0.51-beta.351 → 0.0.51-beta.363

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/index.js CHANGED
@@ -3324,8 +3324,8 @@ function ChooseAmount$a(_ref) {
3324
3324
  }));
3325
3325
  }, [dispatch]);
3326
3326
  const handleAction = useCallback(() => {
3327
- const payAmount = upScale(currentAmount, decimals);
3328
- const step = toBigNumber(payAmount).gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
3327
+ const payAmount = upScale(toBigNumber(currentAmount), decimals);
3328
+ const step = payAmount.gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
3329
3329
  dispatch(setStep(step));
3330
3330
  }, [allowance, currentAmount, decimals, dispatch]);
3331
3331
  return jsx(ChooseAmountModal, {
@@ -3370,7 +3370,7 @@ function Transfer$d(_ref) {
3370
3370
  const {
3371
3371
  decimals
3372
3372
  } = poolInfo.poolUnderlyingToken;
3373
- const paymentBigNumber = toBigNumber(upScale(paymentAmount, decimals));
3373
+ const paymentBigNumber = upScale(toBigNumber(paymentAmount), decimals);
3374
3374
  const handleSuccess = useCallback(() => {
3375
3375
  dispatch(setStep(WIDGET_STEP.Done));
3376
3376
  }, [dispatch]);
@@ -6036,8 +6036,10 @@ function LendWithdraw(_ref) {
6036
6036
  const [lenderPosition, refreshLenderPosition] = useLenderPosition(poolName, poolType, chainId, account, provider);
6037
6037
  const [poolBalance, refreshPoolBalance] = usePoolBalance(poolName, poolType, chainId, provider);
6038
6038
  useEffect(() => {
6039
- if (!step && lenderPosition && poolBalance) {
6039
+ if (!step && lenderPosition !== null && lenderPosition !== void 0 && lenderPosition.gt(0) && poolBalance !== null && poolBalance !== void 0 && poolBalance.gt(0)) {
6040
6040
  dispatch(setStep(WIDGET_STEP.CheckWithdrawable));
6041
+ } else if (!step && (lenderPosition !== null && lenderPosition !== void 0 && lenderPosition.eq(0) || poolBalance !== null && poolBalance !== void 0 && poolBalance.eq(0))) {
6042
+ dispatch(setStep(WIDGET_STEP.Error));
6041
6043
  }
6042
6044
  }, [dispatch, lenderPosition, poolBalance, step]);
6043
6045
  const handleWithdrawSuccess = useCallback(blockNumber => {
@@ -6054,10 +6056,10 @@ function LendWithdraw(_ref) {
6054
6056
  isOpen: true,
6055
6057
  handleClose: handleClose,
6056
6058
  handleSuccess: handleWithdrawSuccess,
6057
- children: [(!step || step === WIDGET_STEP.CheckWithdrawable) && jsx(CheckWithdrawable, {
6059
+ children: [step === WIDGET_STEP.CheckWithdrawable && jsx(CheckWithdrawable, {
6058
6060
  poolInfo: poolInfo,
6059
6061
  handleClose: handleClose
6060
- }), step === WIDGET_STEP.ChooseAmount && jsx(ChooseAmount$3, {
6062
+ }), step === WIDGET_STEP.ChooseAmount && lenderPosition && poolBalance && jsx(ChooseAmount$3, {
6061
6063
  poolInfo: poolInfo,
6062
6064
  lenderPosition: lenderPosition,
6063
6065
  poolBalance: poolBalance