@huma-finance/widgets 0.0.61-beta.542 → 0.0.61-beta.544

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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import { JsonRpcProvider } from '@ethersproject/providers';
3
3
  import { Provider } from '@web3-react/types';
4
- import { POOL_NAME, POOL_TYPE, TrancheType } from '@huma-finance/shared';
4
+ import { POOL_NAME, POOL_TYPE, TrancheType, IdentityVerificationStatusV2 } from '@huma-finance/shared';
5
5
  import { BigNumberish, BigNumber } from 'ethers';
6
6
 
7
7
  /**
@@ -190,14 +190,14 @@ interface Campaign {
190
190
  * @property {POOL_NAME} poolName The name of the pool.
191
191
  * @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
192
192
  * @property {Campaign} campaign The campaign info.
193
- * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
193
+ * @property {function((IdentityVerificationStatusV2|undefined)):void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
194
194
  * @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
195
195
  */
196
196
  interface LendSupplyPropsV2 {
197
197
  poolName: keyof typeof POOL_NAME;
198
198
  pointsTestnetExperience: boolean;
199
199
  campaign?: Campaign;
200
- handleClose: () => void;
200
+ handleClose: (identityStatus?: IdentityVerificationStatusV2) => void;
201
201
  handleSuccess?: (blockNumber?: number) => void;
202
202
  }
203
203
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JsonRpcProvider } from '@ethersproject/providers';
2
- import { txAtom, useMQ, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useDebouncedValue, usePoolUnderlyingTokenBalanceV2, usePoolSettingsV2, useLenderApprovedV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, useFactoring, Provider as Provider$1 } from '@huma-finance/web-shared';
2
+ import { txAtom, useMQ, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useDebouncedValue, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, useFactoring, Provider as Provider$1 } from '@huma-finance/web-shared';
3
3
  import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, TextField, FormControl, FormLabel, RadioGroup, FormControlLabel, Radio, Snackbar, Alert, Skeleton, TablePagination, LinearProgress, createTheme, ThemeProvider } from '@mui/material';
4
4
  import { useAtom, Provider as Provider$2 } from 'jotai';
5
5
  import * as React from 'react';
@@ -5504,7 +5504,6 @@ function PersonaEvaluation(_ref) {
5504
5504
  let {
5505
5505
  poolInfo,
5506
5506
  isUniTranche,
5507
- minDepositAmount: minDepositAmountBN,
5508
5507
  campaign,
5509
5508
  pointsTestnetExperience,
5510
5509
  changeTranche,
@@ -5530,7 +5529,6 @@ function PersonaEvaluation(_ref) {
5530
5529
  const [sessionToken, setSessionToken] = useState();
5531
5530
  const [verificationStatus, setVerificationStatus] = useState();
5532
5531
  const [showPersonaClient, setShowPersonaClient] = useState(false);
5533
- const [campaignBasePoints, setCampaignBasePoints] = useState(0);
5534
5532
  const isKYCCompletedRef = useRef(false);
5535
5533
  const isActionOngoingRef = useRef(false);
5536
5534
  const isKYCResumedRef = useRef(false);
@@ -5543,26 +5541,6 @@ function PersonaEvaluation(_ref) {
5543
5541
  };
5544
5542
  createNewWallet();
5545
5543
  }, [account, campaign, isDev, isWalletOwnershipVerified, pointsTestnetExperience]);
5546
- useEffect(() => {
5547
- const getBasePoints = async () => {
5548
- if (campaign) {
5549
- const estimatedPoints = await CampaignService.getEstimatedPoints(campaign.campaignGroupId, minDepositAmountBN.toString(), isDev, pointsTestnetExperience);
5550
- const campaignPoints = estimatedPoints.find(item => item.campaignId === campaign.id);
5551
- if (campaignPoints) {
5552
- const {
5553
- juniorTranchePoints,
5554
- seniorTranchePoints
5555
- } = campaignPoints;
5556
- if (isUniTranche) {
5557
- setCampaignBasePoints(juniorTranchePoints !== null && juniorTranchePoints !== void 0 ? juniorTranchePoints : 0);
5558
- } else {
5559
- setCampaignBasePoints(juniorTranchePoints < seniorTranchePoints ? juniorTranchePoints : seniorTranchePoints);
5560
- }
5561
- }
5562
- }
5563
- };
5564
- getBasePoints();
5565
- }, [campaign, isDev, isUniTranche, minDepositAmountBN, pointsTestnetExperience]);
5566
5544
  const approveLender = useCallback(async () => {
5567
5545
  try {
5568
5546
  isActionOngoingRef.current = true;
@@ -5636,7 +5614,8 @@ function PersonaEvaluation(_ref) {
5636
5614
  }
5637
5615
  case IdentityVerificationStatusV2.APPROVED:
5638
5616
  {
5639
- await approveLender();
5617
+ setKYCCopy(KYCCopies.verificationApproved);
5618
+ setLoadingType(undefined);
5640
5619
  break;
5641
5620
  }
5642
5621
  case IdentityVerificationStatusV2.DECLINED:
@@ -5651,6 +5630,11 @@ function PersonaEvaluation(_ref) {
5651
5630
  setLoadingType(undefined);
5652
5631
  break;
5653
5632
  }
5633
+ case IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION:
5634
+ {
5635
+ await approveLender();
5636
+ break;
5637
+ }
5654
5638
  default:
5655
5639
  break;
5656
5640
  }
@@ -5705,6 +5689,7 @@ function PersonaEvaluation(_ref) {
5705
5689
  const client = new Persona.Client({
5706
5690
  inquiryId,
5707
5691
  sessionToken,
5692
+ frameWidth: '480px',
5708
5693
  onReady: () => {
5709
5694
  client.open();
5710
5695
  setShowPersonaClient(true);
@@ -5738,7 +5723,8 @@ function PersonaEvaluation(_ref) {
5738
5723
  break;
5739
5724
  case IdentityVerificationStatusV2.DECLINED:
5740
5725
  case IdentityVerificationStatusV2.NEEDS_REVIEW:
5741
- handleClose();
5726
+ case IdentityVerificationStatusV2.APPROVED:
5727
+ handleClose(verificationStatus.status);
5742
5728
  break;
5743
5729
  }
5744
5730
  }
@@ -5757,16 +5743,11 @@ function PersonaEvaluation(_ref) {
5757
5743
  src: ApproveLenderImg,
5758
5744
  alt: "approve-lender"
5759
5745
  })
5760
- }), campaign && kycCopy === KYCCopies.verifyIdentity ? jsxs(Box, {
5746
+ }), campaign && kycCopy === KYCCopies.verifyIdentity ? jsx(Box, {
5761
5747
  css: styles.description,
5762
- children: [jsx("span", {
5763
- children: "You'll be rewarded with a minimum of"
5764
- }), jsxs("span", {
5765
- css: styles.points,
5766
- children: [' ', formatNumber(campaignBasePoints), " Huma points", ' ']
5767
- }), jsx("span", {
5768
- children: "after completing KYC and your first investment."
5769
- })]
5748
+ children: jsx("span", {
5749
+ children: "You'll be rewarded with Huma points after completing KYC/KYB and your first investment."
5750
+ })
5770
5751
  }) : jsx(Box, {
5771
5752
  css: styles.description,
5772
5753
  children: kycCopy.description
@@ -6021,7 +6002,6 @@ function Evaluation$1(_ref) {
6021
6002
  let {
6022
6003
  poolInfo,
6023
6004
  isUniTranche,
6024
- minDepositAmount,
6025
6005
  campaign,
6026
6006
  pointsTestnetExperience,
6027
6007
  changeTranche,
@@ -6040,7 +6020,6 @@ function Evaluation$1(_ref) {
6040
6020
  isUniTranche: isUniTranche,
6041
6021
  pointsTestnetExperience: pointsTestnetExperience,
6042
6022
  campaign: campaign,
6043
- minDepositAmount: minDepositAmount,
6044
6023
  changeTranche: changeTranche
6045
6024
  });
6046
6025
  }
@@ -6289,6 +6268,7 @@ function PointsEarned(_ref) {
6289
6268
  chainId
6290
6269
  } = useWeb3React();
6291
6270
  const [pointsAccumulated, setPointsAccumulated] = useState();
6271
+ const hasPointsAccumulated = !isEmpty(pointsAccumulated) && pointsAccumulated > 0;
6292
6272
  const lockupMonths = Math.round(lpConfig.withdrawalLockoutPeriodInDays / 30);
6293
6273
  const monthText = lockupMonths > 1 ? "".concat(lockupMonths, " months") : "".concat(lockupMonths, " month");
6294
6274
  const {
@@ -6337,17 +6317,10 @@ function PointsEarned(_ref) {
6337
6317
  if (walletOwnership) {
6338
6318
  try {
6339
6319
  const result = await CampaignService.updateWalletPoints(account, transactionHash, chainId, isDev, pointsTestnetExperience);
6340
- if (!result.pointsAccumulated) {
6341
- dispatch(setError({
6342
- errorMessage: ERROR_MESSAGE
6343
- }));
6344
- }
6345
6320
  setPointsAccumulated(result.pointsAccumulated);
6346
6321
  setState(STATE.Congrats);
6347
6322
  } catch (error) {
6348
- dispatch(setError({
6349
- errorMessage: ERROR_MESSAGE
6350
- }));
6323
+ console.error('Failed to update wallet points', error);
6351
6324
  }
6352
6325
  }
6353
6326
  };
@@ -6377,17 +6350,21 @@ function PointsEarned(_ref) {
6377
6350
  css: styles.ribbon,
6378
6351
  children: [jsx(RibbonIcon, {}), jsxs(Box, {
6379
6352
  css: styles.ribbonContent,
6380
- children: [jsx(HumaPointsIcon, {}), jsxs(Box, {
6381
- children: [formatNumber(pointsAccumulated), " Points"]
6353
+ children: [jsx(HumaPointsIcon, {}), jsx(Box, {
6354
+ children: hasPointsAccumulated ? "".concat(formatNumber(pointsAccumulated), " Points") : 'Points earned'
6382
6355
  })]
6383
6356
  })]
6384
- }), jsxs(Box, {
6357
+ }), jsx(Box, {
6385
6358
  css: styles.entirePoints,
6386
- children: [jsx(Box, {
6387
- children: "Congratulations,"
6388
- }), jsxs(Box, {
6389
- children: ["you've earned ", pointsAccumulated, " points"]
6390
- })]
6359
+ children: hasPointsAccumulated ? jsxs(Fragment, {
6360
+ children: [jsx(Box, {
6361
+ children: "Congratulations,"
6362
+ }), jsxs(Box, {
6363
+ children: ["you've earned ", pointsAccumulated, " points"]
6364
+ })]
6365
+ }) : jsx(Box, {
6366
+ children: "Congratulations on joining the Huma Protocol!"
6367
+ })
6391
6368
  }), jsxs(Box, {
6392
6369
  css: styles.entirePointsDetails,
6393
6370
  children: ["You'll earn points ", jsx("span", {
@@ -6429,7 +6406,6 @@ function LendSupplyV2(_ref) {
6429
6406
  const [selectedTranche, setSelectedTranche] = useState();
6430
6407
  const [transactionHash, setTransactionHash] = useState();
6431
6408
  const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider);
6432
- const poolSettings = usePoolSettingsV2(poolName, provider);
6433
6409
  const lpConfig = useLPConfigV2(poolName, provider);
6434
6410
  const isUniTranche = (lpConfig === null || lpConfig === void 0 ? void 0 : lpConfig.maxSeniorJuniorRatio) === 0;
6435
6411
  const [lenderApprovedSenior] = useLenderApprovedV2(poolName, 'senior', account, provider);
@@ -6470,7 +6446,7 @@ function LendSupplyV2(_ref) {
6470
6446
  }
6471
6447
  }
6472
6448
  }, [dispatch, handleClose, isUniTranche, lenderApproveStatusFetched, lenderApprovedJunior, lenderApprovedSenior, lpConfig, poolInfo, campaign, step]);
6473
- if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched || !lpConfig || !poolSettings) {
6449
+ if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched || !lpConfig) {
6474
6450
  return jsx(WidgetWrapper, {
6475
6451
  isOpen: true,
6476
6452
  isLoading: true,
@@ -6494,8 +6470,7 @@ function LendSupplyV2(_ref) {
6494
6470
  isUniTranche: isUniTranche,
6495
6471
  changeTranche: setSelectedTranche,
6496
6472
  pointsTestnetExperience: pointsTestnetExperience,
6497
- campaign: campaign,
6498
- minDepositAmount: poolSettings.minDepositAmount
6473
+ campaign: campaign
6499
6474
  }), step === WIDGET_STEP.ChooseAmount && jsx(ChooseAmount$4, {
6500
6475
  poolInfo: poolInfo,
6501
6476
  poolUnderlyingToken: poolUnderlyingToken,