@huma-finance/widgets 0.0.75-beta.977 → 0.0.75-beta.979

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
@@ -1,6 +1,6 @@
1
- var p8 = Object.defineProperty;
2
- var h8 = (ar, or, ur) => or in ar ? p8(ar, or, { enumerable: !0, configurable: !0, writable: !0, value: ur }) : ar[or] = ur;
3
- var Aa = (ar, or, ur) => h8(ar, typeof or != "symbol" ? or + "" : or, ur);
1
+ var dk = Object.defineProperty;
2
+ var pk = (ar, or, ur) => or in ar ? dk(ar, or, { enumerable: !0, configurable: !0, writable: !0, value: ur }) : ar[or] = ur;
3
+ var Aa = (ar, or, ur) => pk(ar, typeof or != "symbol" ? or + "" : or, ur);
4
4
  import * as React from "react";
5
5
  import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useEffect, useRef, createElement, createContext, useReducer, useDebugValue, useCallback, useMemo, useLayoutEffect } from "react";
6
6
  import { txAtom, useMQ, LoggingContextHelper, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, checkIsDev, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useForceRefresh, useHumaProgram, useBorrowerAccounts, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useTrancheMintAccounts, useTrancheTokenAccounts, useLenderAccounts, notEnabledAutoRedeem, getLenderLockupDates, AUTH_ERROR_TYPE, useChainInfo, useTokenAccount, StellarConnectionContext, getClientCommonParams, useStellarLender, useStellarTokenBalance, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, useFactoring, fetchStellarPoolSentinel, useStellarBorrower } from "@huma-finance/web-shared";
@@ -19083,11 +19083,11 @@ See https://reactjs.org/link/refs-must-have-owner for more information.`);
19083
19083
  var Fg = uu(Bv, iu, np, qp.value, Uu);
19084
19084
  Fg !== null && (Or && Fg.alternate !== null && Bv.delete(Fg.key === null ? np : Fg.key), vp = Li(Fg, vp, np), wl === null ? nd = Fg : wl.sibling = Fg, wl = Fg);
19085
19085
  }
19086
- if (Or && Bv.forEach(function(d8) {
19087
- return $r(iu, d8);
19086
+ if (Or && Bv.forEach(function(fk) {
19087
+ return $r(iu, fk);
19088
19088
  }), Yd()) {
19089
- var f8 = np;
19090
- _A(iu, f8);
19089
+ var lk = np;
19090
+ _A(iu, lk);
19091
19091
  }
19092
19092
  return nd;
19093
19093
  }
@@ -19535,9 +19535,9 @@ Incoming: %s`, Tu, "[" + $r.join(", ") + "]", "[" + Or.join(", ") + "]");
19535
19535
  }
19536
19536
  return [Io, Li];
19537
19537
  }
19538
- function y8(Or, $r, ti) {
19538
+ function hk(Or, $r, ti) {
19539
19539
  }
19540
- function g8(Or, $r, ti) {
19540
+ function yk(Or, $r, ti) {
19541
19541
  }
19542
19542
  function US(Or, $r, ti) {
19543
19543
  var di = Fl, Si = Pg(), Li, oo = Yd();
@@ -24947,7 +24947,7 @@ Check the render method of %s.`, Lu(Ro) || "Unknown"));
24947
24947
  }
24948
24948
  return Or == null ? null : Or.nodeType === ol ? Or : D4(Or, "findDOMNode");
24949
24949
  }
24950
- function e8(Or, $r, ti) {
24950
+ function ek(Or, $r, ti) {
24951
24951
  if (dr("ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !xv($r))
24952
24952
  throw new Error("Target container is not a DOM element.");
24953
24953
  {
@@ -24956,7 +24956,7 @@ Check the render method of %s.`, Lu(Ro) || "Unknown"));
24956
24956
  }
24957
24957
  return u2(null, Or, $r, !0, ti);
24958
24958
  }
24959
- function t8(Or, $r, ti) {
24959
+ function tk(Or, $r, ti) {
24960
24960
  if (dr("ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !xv($r))
24961
24961
  throw new Error("Target container is not a DOM element.");
24962
24962
  {
@@ -24965,14 +24965,14 @@ Check the render method of %s.`, Lu(Ro) || "Unknown"));
24965
24965
  }
24966
24966
  return u2(null, Or, $r, !1, ti);
24967
24967
  }
24968
- function r8(Or, $r, ti, di) {
24968
+ function rk(Or, $r, ti, di) {
24969
24969
  if (dr("ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported in React 18. Consider using a portal instead. Until you switch to the createRoot API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !xv(ti))
24970
24970
  throw new Error("Target container is not a DOM element.");
24971
24971
  if (Or == null || !sg(Or))
24972
24972
  throw new Error("parentComponent must be a valid React Component");
24973
24973
  return u2(Or, $r, ti, !1, di);
24974
24974
  }
24975
- function n8(Or) {
24975
+ function nk(Or) {
24976
24976
  if (!xv(Or))
24977
24977
  throw new Error("unmountComponentAtNode(...): Target container is not a DOM element.");
24978
24978
  {
@@ -25000,14 +25000,14 @@ Check the render method of %s.`, Lu(Ro) || "Unknown"));
25000
25000
  hp(L4), fc(F4), aA(U4), um(Ll), cm(iA), (typeof Map != "function" || // $FlowIssue Flow incorrectly thinks Map has no prototype
25001
25001
  Map.prototype == null || typeof Map.prototype.forEach != "function" || typeof Set != "function" || // $FlowIssue Flow incorrectly thinks Set has no prototype
25002
25002
  Set.prototype == null || typeof Set.prototype.clear != "function" || typeof Set.prototype.forEach != "function") && dr("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"), wy(q2), hb(LI, GR, Pm);
25003
- function i8(Or, $r) {
25003
+ function ik(Or, $r) {
25004
25004
  var ti = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
25005
25005
  if (!s2($r))
25006
25006
  throw new Error("Target container is not a DOM element.");
25007
25007
  return N4(Or, $r, null, ti);
25008
25008
  }
25009
- function o8(Or, $r, ti, di) {
25010
- return r8(Or, $r, ti, di);
25009
+ function ok(Or, $r, ti, di) {
25010
+ return rk(Or, $r, ti, di);
25011
25011
  }
25012
25012
  var sT = {
25013
25013
  usingClientEntryPoint: !1,
@@ -25015,27 +25015,27 @@ Check the render method of %s.`, Lu(Ro) || "Unknown"));
25015
25015
  // This is an array for better minification.
25016
25016
  Events: [wu, Iu, ku, sh, $m, LI]
25017
25017
  };
25018
- function a8(Or, $r) {
25018
+ function ak(Or, $r) {
25019
25019
  return sT.usingClientEntryPoint || dr('You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'), G4(Or, $r);
25020
25020
  }
25021
- function s8(Or, $r, ti) {
25021
+ function sk(Or, $r, ti) {
25022
25022
  return sT.usingClientEntryPoint || dr('You are importing hydrateRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'), W4(Or, $r, ti);
25023
25023
  }
25024
- function c8(Or) {
25024
+ function uk(Or) {
25025
25025
  return K3() && dr("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."), Pm(Or);
25026
25026
  }
25027
- var l8 = H4({
25027
+ var ck = H4({
25028
25028
  findFiberByHostInstance: Qs,
25029
25029
  bundleType: 1,
25030
25030
  version: eT,
25031
25031
  rendererPackageName: "react-dom"
25032
25032
  });
25033
- if (!l8 && mi && window.top === window.self && (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Edge") === -1 || navigator.userAgent.indexOf("Firefox") > -1)) {
25033
+ if (!ck && mi && window.top === window.self && (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Edge") === -1 || navigator.userAgent.indexOf("Firefox") > -1)) {
25034
25034
  var Lx = window.location.protocol;
25035
25035
  /^(https?|file):$/.test(Lx) && console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools" + (Lx === "file:" ? `
25036
25036
  You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq` : ""), "font-weight:bold");
25037
25037
  }
25038
- reactDom_development.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = sT, reactDom_development.createPortal = i8, reactDom_development.createRoot = a8, reactDom_development.findDOMNode = X4, reactDom_development.flushSync = c8, reactDom_development.hydrate = e8, reactDom_development.hydrateRoot = s8, reactDom_development.render = t8, reactDom_development.unmountComponentAtNode = n8, reactDom_development.unstable_batchedUpdates = LI, reactDom_development.unstable_renderSubtreeIntoContainer = o8, reactDom_development.version = eT, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
25038
+ reactDom_development.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = sT, reactDom_development.createPortal = ik, reactDom_development.createRoot = ak, reactDom_development.findDOMNode = X4, reactDom_development.flushSync = uk, reactDom_development.hydrate = ek, reactDom_development.hydrateRoot = sk, reactDom_development.render = tk, reactDom_development.unmountComponentAtNode = nk, reactDom_development.unstable_batchedUpdates = LI, reactDom_development.unstable_renderSubtreeIntoContainer = ok, reactDom_development.version = eT, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
25039
25039
  }()), reactDom_development;
25040
25040
  }
25041
25041
  var hasRequiredReactDom;
@@ -182580,32 +182580,33 @@ function Success$8({
182580
182580
  poolInfo: ar,
182581
182581
  poolState: or,
182582
182582
  campaign: ur,
182583
- handleAction: cr
182583
+ isExistingUser: cr,
182584
+ handleAction: fr
182584
182585
  }) {
182585
182586
  useLogOnFirstMount("Success");
182586
- const fr = useDispatch(), { supplyAmount: lr, solanaSignature: dr } = useAppSelector(selectWidgetState), { symbol: pr } = ar.underlyingMint, hr = [
182587
- `You successfully supplied ${formatMoney(lr)} ${pr}.`
182588
- ], Ar = () => {
182589
- const yr = dayjs().add(or.withdrawalLockupPeriodDays ?? 0, "day").date(1), Sr = yr.add(1, "month");
182587
+ const lr = useDispatch(), { supplyAmount: dr, solanaSignature: pr } = useAppSelector(selectWidgetState), { symbol: hr } = ar.underlyingMint, Ar = [
182588
+ `You successfully supplied ${formatMoney(dr)} ${hr}.`
182589
+ ], gr = () => {
182590
+ const Sr = dayjs().add(or.withdrawalLockupPeriodDays ?? 0, "day").date(1), Ir = Sr.add(1, "month");
182590
182591
  return [
182591
182592
  `Redemption request will be automatically submitted on ${timeUtil.timestampToLL(
182592
- yr.unix()
182593
- )}. Your deposit can be redeemed and yield rewards will stop on ${timeUtil.timestampToLL(
182594
182593
  Sr.unix()
182594
+ )}. Your deposit can be redeemed and yield rewards will stop on ${timeUtil.timestampToLL(
182595
+ Ir.unix()
182595
182596
  )}.`
182596
182597
  ];
182597
- }, gr = useCallback(() => {
182598
- ur ? fr(setStep(WIDGET_STEP.PointsEarned)) : cr({ isSuccess: !0 });
182599
- }, [ur, fr, cr]);
182598
+ }, yr = useCallback(() => {
182599
+ ur && !cr ? lr(setStep(WIDGET_STEP.PointsEarned)) : fr({ isSuccess: !0 });
182600
+ }, [ur, lr, fr, cr]);
182600
182601
  return /* @__PURE__ */ jsx(
182601
182602
  SolanaTxDoneModal,
182602
182603
  {
182603
- handleAction: gr,
182604
- content: hr,
182605
- subContent: Ar(),
182604
+ handleAction: yr,
182605
+ content: Ar,
182606
+ subContent: gr(),
182606
182607
  chainId: ar.chainId,
182607
- solanaSignature: dr,
182608
- buttonText: ur ? "VIEW POINTS" : "DONE"
182608
+ solanaSignature: pr,
182609
+ buttonText: ur && !cr ? "VIEW POINTS" : "DONE"
182609
182610
  }
182610
182611
  );
182611
182612
  }
@@ -182616,48 +182617,57 @@ function SolanaLendSupply({
182616
182617
  handleClose: cr,
182617
182618
  handleSuccess: fr
182618
182619
  }) {
182619
- const lr = useDispatch(), { isUniTranche: dr } = or, {
182620
- seniorLenderApproved: pr,
182621
- juniorLenderApproved: hr,
182622
- loading: Ar
182623
- } = useLenderAccounts(ar.chainId, ar.poolName), [gr, yr] = useTokenAccount(ar), { step: Sr, errorMessage: Ir } = useAppSelector(selectWidgetState), xr = useAppSelector(selectWidgetLoggingContext), [Cr, Br] = useState(), Pr = (Mr) => {
182624
- xr.logAction("ExitFlow", {}), cr(Mr);
182620
+ const lr = useDispatch(), dr = checkIsDev(), { isUniTranche: pr } = or, {
182621
+ seniorLenderApproved: hr,
182622
+ juniorLenderApproved: Ar,
182623
+ loading: gr
182624
+ } = useLenderAccounts(ar.chainId, ar.poolName), [yr, Sr] = useTokenAccount(ar), { step: Ir, errorMessage: xr } = useAppSelector(selectWidgetState), Cr = useAppSelector(selectWidgetLoggingContext), [Br, Pr] = useState(), [Mr, Ur] = useState(!1), Qr = (qr) => {
182625
+ Cr.logAction("ExitFlow", {}), cr(qr);
182625
182626
  };
182626
182627
  return useEffect(() => {
182627
- if (!Sr && !Ar && !yr) {
182628
- const Mr = {
182628
+ async function qr() {
182629
+ const Hr = await CampaignService.getHumaAccountPoints(
182630
+ void 0,
182631
+ dr
182632
+ );
182633
+ Hr && (Hr == null ? void 0 : Hr.totalPoints) > 0 && Ur(!0);
182634
+ }
182635
+ qr();
182636
+ }, []), useEffect(() => {
182637
+ if (!Ir && !gr && !Sr) {
182638
+ const qr = {
182629
182639
  flow: "Supply",
182630
182640
  chainId: ar.chainId,
182631
182641
  poolName: ar.poolName,
182632
182642
  poolType: ar.poolType
182633
- }, Ur = new LoggingContextHelper(Mr);
182634
- if (Ur.logAction("StartFlow", {}), lr(setLoggingContext(Mr)), !hr && !pr) {
182635
- Ur.logAction("SetInitialStep", {
182643
+ }, Hr = new LoggingContextHelper(qr);
182644
+ if (Hr.logAction("StartFlow", {}), lr(setLoggingContext(qr)), !Ar && !hr) {
182645
+ Hr.logAction("SetInitialStep", {
182636
182646
  step: WIDGET_STEP.Evaluation
182637
182647
  }), lr(setStep(WIDGET_STEP.Evaluation));
182638
182648
  return;
182639
182649
  }
182640
- if (!dr && (!hr || !pr)) {
182641
- Ur.logAction("SetInitialStep", {
182650
+ if (!pr && (!Ar || !hr)) {
182651
+ Hr.logAction("SetInitialStep", {
182642
182652
  step: WIDGET_STEP.ApproveLender
182643
182653
  }), lr(setStep(WIDGET_STEP.ApproveLender));
182644
182654
  return;
182645
182655
  }
182646
- if (hr && !pr) {
182647
- Ur.logAction("SetInitialStep", {
182656
+ if (Ar && !hr) {
182657
+ Hr.logAction("SetInitialStep", {
182648
182658
  step: WIDGET_STEP.ChooseAmount,
182649
182659
  tranche: "junior"
182650
- }), Br("junior"), lr(setStep(WIDGET_STEP.ChooseAmount));
182660
+ }), Pr("junior"), lr(setStep(WIDGET_STEP.ChooseAmount));
182651
182661
  return;
182652
182662
  }
182653
- if (pr && !hr) {
182654
- Ur.logAction("SetInitialStep", {
182663
+ if (hr && !Ar) {
182664
+ Hr.logAction("SetInitialStep", {
182655
182665
  step: WIDGET_STEP.ChooseAmount,
182656
182666
  tranche: "senior"
182657
- }), Br("senior"), lr(setStep(WIDGET_STEP.ChooseAmount));
182667
+ }), Pr("senior"), lr(setStep(WIDGET_STEP.ChooseAmount));
182658
182668
  return;
182659
182669
  }
182660
- hr && pr && (Ur.logAction("SetInitialStep", {
182670
+ Ar && hr && (Hr.logAction("SetInitialStep", {
182661
182671
  step: WIDGET_STEP.ChooseTranche
182662
182672
  }), lr(setStep(WIDGET_STEP.ChooseTranche)));
182663
182673
  }
@@ -182665,19 +182675,19 @@ function SolanaLendSupply({
182665
182675
  lr,
182666
182676
  cr,
182667
182677
  ar,
182668
- Sr,
182678
+ Ir,
182679
+ gr,
182669
182680
  Ar,
182670
182681
  hr,
182671
- pr,
182672
- yr,
182673
- dr
182674
- ]), Ar || yr ? /* @__PURE__ */ jsx(
182682
+ Sr,
182683
+ pr
182684
+ ]), gr || Sr ? /* @__PURE__ */ jsx(
182675
182685
  WidgetWrapper,
182676
182686
  {
182677
182687
  isOpen: !0,
182678
182688
  isLoading: !0,
182679
182689
  loadingTitle: "Supply",
182680
- handleClose: Pr,
182690
+ handleClose: Qr,
182681
182691
  handleSuccess: fr
182682
182692
  }
182683
182693
  ) : /* @__PURE__ */ jsxs(
@@ -182685,74 +182695,75 @@ function SolanaLendSupply({
182685
182695
  {
182686
182696
  isOpen: !0,
182687
182697
  loadingTitle: `Supply ${ar.underlyingMint.symbol}`,
182688
- handleClose: Pr,
182698
+ handleClose: Qr,
182689
182699
  handleSuccess: fr,
182690
182700
  children: [
182691
- Sr === WIDGET_STEP.Evaluation && /* @__PURE__ */ jsx(
182701
+ Ir === WIDGET_STEP.Evaluation && /* @__PURE__ */ jsx(
182692
182702
  Evaluation$3,
182693
182703
  {
182694
182704
  poolInfo: ar,
182695
182705
  campaign: or.campaign,
182696
182706
  documentHash: ur,
182697
182707
  networkType: getSolanaNetworkType(ar.chainId),
182698
- handleClose: Pr
182708
+ handleClose: Qr
182699
182709
  }
182700
182710
  ),
182701
- Sr === WIDGET_STEP.ApproveLender && /* @__PURE__ */ jsx(
182711
+ Ir === WIDGET_STEP.ApproveLender && /* @__PURE__ */ jsx(
182702
182712
  ApproveLender$1,
182703
182713
  {
182704
182714
  poolInfo: ar,
182705
- isUniTranche: !!dr,
182715
+ isUniTranche: !!pr,
182706
182716
  documentHash: ur,
182707
- changeTranche: Br
182717
+ changeTranche: Pr
182708
182718
  }
182709
182719
  ),
182710
- Sr === WIDGET_STEP.ChooseTranche && /* @__PURE__ */ jsx(
182720
+ Ir === WIDGET_STEP.ChooseTranche && /* @__PURE__ */ jsx(
182711
182721
  ChooseTranche$2,
182712
182722
  {
182713
182723
  poolUnderlyingToken: ar.underlyingMint,
182714
- selectedTranche: Cr,
182715
- changeTranche: Br
182724
+ selectedTranche: Br,
182725
+ changeTranche: Pr
182716
182726
  }
182717
182727
  ),
182718
- Sr === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
182728
+ Ir === WIDGET_STEP.ChooseAmount && /* @__PURE__ */ jsx(
182719
182729
  ChooseAmount$8,
182720
182730
  {
182721
182731
  poolInfo: ar,
182722
182732
  poolState: or,
182723
- tokenAccount: gr,
182724
- selectedTranche: Cr,
182725
- isUniTranche: dr
182733
+ tokenAccount: yr,
182734
+ selectedTranche: Br,
182735
+ isUniTranche: pr
182726
182736
  }
182727
182737
  ),
182728
- Sr === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$6, { poolState: or }),
182729
- Sr === WIDGET_STEP.Transfer && Cr && /* @__PURE__ */ jsx(
182738
+ Ir === WIDGET_STEP.ApproveAllowance && /* @__PURE__ */ jsx(ApproveAllowance$6, { poolState: or }),
182739
+ Ir === WIDGET_STEP.Transfer && Br && /* @__PURE__ */ jsx(
182730
182740
  Transfer$a,
182731
182741
  {
182732
182742
  poolInfo: ar,
182733
182743
  poolState: or,
182734
- selectedTranche: Cr,
182744
+ selectedTranche: Br,
182735
182745
  networkType: getSolanaNetworkType(ar.chainId)
182736
182746
  }
182737
182747
  ),
182738
- Sr === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
182748
+ Ir === WIDGET_STEP.Done && /* @__PURE__ */ jsx(
182739
182749
  Success$8,
182740
182750
  {
182741
182751
  poolInfo: ar,
182742
182752
  poolState: or,
182743
182753
  campaign: or.campaign,
182744
- handleAction: Pr
182754
+ handleAction: Qr,
182755
+ isExistingUser: Mr
182745
182756
  }
182746
182757
  ),
182747
- Sr === WIDGET_STEP.PointsEarned && /* @__PURE__ */ jsx(PointsEarned, { lpConfig: or, handleAction: Pr }),
182748
- Sr === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
182758
+ Ir === WIDGET_STEP.PointsEarned && /* @__PURE__ */ jsx(PointsEarned, { lpConfig: or, handleAction: Qr }),
182759
+ Ir === WIDGET_STEP.Error && /* @__PURE__ */ jsx(
182749
182760
  SolanaErrorModal,
182750
182761
  {
182751
182762
  chainId: ar.chainId,
182752
182763
  title: "Supply",
182753
182764
  errorReason: "Sorry there was an error",
182754
- errorMessage: Ir,
182755
- handleOk: Pr
182765
+ errorMessage: xr,
182766
+ handleOk: Qr
182756
182767
  }
182757
182768
  )
182758
182769
  ]
@@ -6,7 +6,8 @@ type Props = {
6
6
  poolInfo: SolanaPoolInfo;
7
7
  poolState: SolanaPoolState;
8
8
  campaign?: Campaign;
9
+ isExistingUser: boolean;
9
10
  handleAction: (options?: CloseModalOptions) => void;
10
11
  };
11
- export declare function Success({ poolInfo, poolState, campaign, handleAction, }: Props): React.ReactElement;
12
+ export declare function Success({ poolInfo, poolState, campaign, isExistingUser, handleAction, }: Props): React.ReactElement;
12
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.75-beta.977+2650f4a",
3
+ "version": "0.0.75-beta.979+5ab0114",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -22,9 +22,9 @@
22
22
  "@ethersproject/contracts": "^5.7.0",
23
23
  "@ethersproject/experimental": "^5.7.0",
24
24
  "@ethersproject/units": "^5.6.0",
25
- "@huma-finance/sdk": "^0.0.75-beta.977+2650f4a",
26
- "@huma-finance/shared": "^0.0.75-beta.977+2650f4a",
27
- "@huma-finance/web-shared": "^0.0.75-beta.977+2650f4a",
25
+ "@huma-finance/sdk": "^0.0.75-beta.979+5ab0114",
26
+ "@huma-finance/shared": "^0.0.75-beta.979+5ab0114",
27
+ "@huma-finance/web-shared": "^0.0.75-beta.979+5ab0114",
28
28
  "@mui/x-date-pickers": "^5.0.7",
29
29
  "@notifi-network/notifi-frontend-client": "^1.1.2",
30
30
  "@notifi-network/notifi-react": "^1.1.2",
@@ -190,5 +190,5 @@
190
190
  "optionalDependencies": {
191
191
  "encoding": "^0.1.13"
192
192
  },
193
- "gitHead": "2650f4aca79e3fd96f84f7435c2be7e25a0bca34"
193
+ "gitHead": "5ab0114378cfdc5375a211595f3eedc4cc1cc1e0"
194
194
  }
@@ -20,6 +20,7 @@ type Props = {
20
20
  poolInfo: SolanaPoolInfo
21
21
  poolState: SolanaPoolState
22
22
  campaign?: Campaign
23
+ isExistingUser: boolean
23
24
  handleAction: (options?: CloseModalOptions) => void
24
25
  }
25
26
 
@@ -27,6 +28,7 @@ export function Success({
27
28
  poolInfo,
28
29
  poolState,
29
30
  campaign,
31
+ isExistingUser,
30
32
  handleAction,
31
33
  }: Props): React.ReactElement {
32
34
  useLogOnFirstMount('Success')
@@ -53,12 +55,12 @@ export function Success({
53
55
  }
54
56
 
55
57
  const handleUserAction = useCallback(() => {
56
- if (campaign) {
58
+ if (campaign && !isExistingUser) {
57
59
  dispatch(setStep(WIDGET_STEP.PointsEarned))
58
60
  } else {
59
61
  handleAction({ isSuccess: true })
60
62
  }
61
- }, [campaign, dispatch, handleAction])
63
+ }, [campaign, dispatch, handleAction, isExistingUser])
62
64
 
63
65
  return (
64
66
  <SolanaTxDoneModal
@@ -67,7 +69,7 @@ export function Success({
67
69
  subContent={getSubContent()}
68
70
  chainId={poolInfo.chainId}
69
71
  solanaSignature={solanaSignature}
70
- buttonText={campaign ? 'VIEW POINTS' : 'DONE'}
72
+ buttonText={campaign && !isExistingUser ? 'VIEW POINTS' : 'DONE'}
71
73
  />
72
74
  )
73
75
  }
@@ -1,10 +1,12 @@
1
1
  import {
2
+ CampaignService,
2
3
  CloseModalOptions,
3
4
  getSolanaNetworkType,
4
5
  SolanaPoolInfo,
5
6
  TrancheType,
6
7
  } from '@huma-finance/shared'
7
8
  import {
9
+ checkIsDev,
8
10
  LoggingContext,
9
11
  LoggingContextHelper,
10
12
  SolanaPoolState,
@@ -62,6 +64,7 @@ export function SolanaLendSupply({
62
64
  handleSuccess,
63
65
  }: SolanaLendSupplyProps): React.ReactElement | null {
64
66
  const dispatch = useDispatch()
67
+ const isDev = checkIsDev()
65
68
  const { isUniTranche } = poolState
66
69
  const {
67
70
  seniorLenderApproved,
@@ -72,12 +75,28 @@ export function SolanaLendSupply({
72
75
  const { step, errorMessage } = useAppSelector(selectWidgetState)
73
76
  const loggingHelper = useAppSelector(selectWidgetLoggingContext)
74
77
  const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
78
+ const [isExistingUser, setIsExistingUser] = useState<boolean>(false)
75
79
 
76
80
  const handleCloseFlow = (options?: CloseModalOptions) => {
77
81
  loggingHelper.logAction('ExitFlow', {})
78
82
  handleClose(options)
79
83
  }
80
84
 
85
+ useEffect(() => {
86
+ async function fetchPoints() {
87
+ const points = await CampaignService.getHumaAccountPoints(
88
+ import.meta.env.VITE_NETWORK_TYPE,
89
+ isDev,
90
+ )
91
+
92
+ if (points && points?.totalPoints > 0) {
93
+ setIsExistingUser(true)
94
+ }
95
+ }
96
+ fetchPoints()
97
+ // eslint-disable-next-line react-hooks/exhaustive-deps
98
+ }, [])
99
+
81
100
  useEffect(() => {
82
101
  if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccount) {
83
102
  // Set initial logging context
@@ -215,6 +234,7 @@ export function SolanaLendSupply({
215
234
  poolState={poolState}
216
235
  campaign={poolState.campaign}
217
236
  handleAction={handleCloseFlow}
237
+ isExistingUser={isExistingUser}
218
238
  />
219
239
  )}
220
240
  {step === WIDGET_STEP.PointsEarned && (