@huma-finance/widgets 0.0.65 → 0.0.66-beta.812

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/API.md CHANGED
@@ -702,7 +702,6 @@ To be used when re-enabling autopay and other pool actions that require allowanc
702
702
  | --- | --- | --- |
703
703
  | poolInfo | <code>SolanaPoolInfo</code> | <p>The metadata of the pool.</p> |
704
704
  | poolState | <code>SolanaPoolState</code> | <p>The current state config of the pool.</p> |
705
- | pointsTestnetExperience | <code>boolean</code> | <p>If the user is in the testnet experience.</p> |
706
705
  | handleClose | <code>function</code> | <p>Function to notify to close the widget modal when user clicks the 'x' close button.</p> |
707
706
  | handleSuccess | <code>function</code> | <p>Optional function to notify that the lending pool supply action is successful.</p> |
708
707
 
@@ -747,7 +746,6 @@ To be used when re-enabling autopay and other pool actions that require allowanc
747
746
  | Name | Type | Description |
748
747
  | --- | --- | --- |
749
748
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
750
- | pointsTestnetExperience | <code>boolean</code> | <p>If the user is in the testnet experience.</p> |
751
749
  | campaign | <code>Campaign</code> | <p>The campaign info.</p> |
752
750
  | handleClose | <code>function</code> | <p>Function to notify to close the widget modal when user clicks the 'x' close button.</p> |
753
751
  | handleSuccess | <code>function</code> | <p>Optional function to notify that the lending pool supply action is successful.</p> |
@@ -5610,17 +5610,13 @@ function PersonaEvaluation(_ref) {
5610
5610
  let {
5611
5611
  poolInfo,
5612
5612
  campaign,
5613
- pointsTestnetExperience,
5613
+ networkType,
5614
5614
  chainType,
5615
5615
  handleClose
5616
5616
  } = _ref;
5617
5617
  const theme = material.useTheme();
5618
5618
  const isDev = shared.checkIsDev();
5619
5619
  const dispatch = useAppDispatch();
5620
- const {
5621
- account,
5622
- chainId
5623
- } = webShared.useChainInfo(isDev, chainType);
5624
5620
  const {
5625
5621
  errorType,
5626
5622
  setError: setAuthError,
@@ -5638,110 +5634,99 @@ function PersonaEvaluation(_ref) {
5638
5634
  const isKYCCompletedRef = React.useRef(false);
5639
5635
  const isActionOngoingRef = React.useRef(false);
5640
5636
  const isKYCResumedRef = React.useRef(false);
5641
- React.useEffect(() => {
5642
- const createNewWallet = async () => {
5643
- if (isWalletOwnershipVerified && campaign && account) {
5644
- var _localStorage$getItem;
5645
- await shared.CampaignService.createNewWallet(account, (_localStorage$getItem = localStorage.getItem(shared.CAMPAIGN_REFERENCE_CODE)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : undefined, isDev, pointsTestnetExperience);
5646
- }
5647
- };
5648
- createNewWallet();
5649
- }, [account, campaign, isDev, isWalletOwnershipVerified, pointsTestnetExperience]);
5650
5637
  const checkVerificationStatus = React.useCallback(async () => {
5651
5638
  if (isActionOngoingRef.current || isKYCResumedRef.current) {
5652
5639
  return;
5653
5640
  }
5654
5641
  try {
5655
- if (account && chainId) {
5656
- isActionOngoingRef.current = true;
5657
- setLoadingType('verificationStatus');
5658
- const verificationStatus = await shared.IdentityServiceV2.getVerificationStatusV2(account, chainId, isDev);
5659
- setVerificationStatus(verificationStatus);
5660
- setInquiryId(verificationStatus.personaInquiryId);
5661
- switch (verificationStatus.status) {
5662
- case shared.IdentityVerificationStatusV2.ACCREDITED:
5663
- {
5664
- const startVerificationResult = await shared.IdentityServiceV2.startVerification(account, chainId, isDev);
5665
- setInquiryId(startVerificationResult.personaInquiryId);
5666
- setKYCCopy(KYCCopies.verifyIdentity);
5667
- setLoadingType(undefined);
5668
- if (startVerificationResult.status === shared.IdentityVerificationStatusV2.BYPASSED) {
5669
- setVerificationStatus(startVerificationResult);
5670
- setKYCCopy(KYCCopies.verificationBypassed);
5671
- }
5672
- break;
5673
- }
5674
- case shared.IdentityVerificationStatusV2.CREATED:
5675
- {
5676
- setKYCCopy(KYCCopies.verifyIdentity);
5677
- setLoadingType(undefined);
5678
- break;
5679
- }
5680
- case shared.IdentityVerificationStatusV2.PENDING:
5681
- {
5682
- if (!isKYCCompletedRef.current) {
5683
- const resumeVerificationResult = await shared.IdentityServiceV2.resumeVerification(account, chainId, isDev);
5684
- verificationStatus.status = resumeVerificationResult.status;
5685
- setVerificationStatus(verificationStatus);
5686
- setSessionToken(resumeVerificationResult.sessionToken);
5687
- setLoadingType(undefined);
5688
- isKYCResumedRef.current = true;
5689
- } else {
5690
- setLoadingType('verificationStatus');
5691
- }
5692
- setKYCCopy(KYCCopies.verifyIdentity);
5693
- break;
5642
+ isActionOngoingRef.current = true;
5643
+ setLoadingType('verificationStatus');
5644
+ const verificationStatus = await shared.IdentityServiceV2.getVerificationStatusV2(networkType, isDev);
5645
+ setVerificationStatus(verificationStatus);
5646
+ setInquiryId(verificationStatus.personaInquiryId);
5647
+ switch (verificationStatus.status) {
5648
+ case shared.IdentityVerificationStatusV2.ACCREDITED:
5649
+ {
5650
+ const startVerificationResult = await shared.IdentityServiceV2.startVerification(networkType, isDev);
5651
+ setInquiryId(startVerificationResult.personaInquiryId);
5652
+ setKYCCopy(KYCCopies.verifyIdentity);
5653
+ setLoadingType(undefined);
5654
+ if (startVerificationResult.status === shared.IdentityVerificationStatusV2.BYPASSED) {
5655
+ setVerificationStatus(startVerificationResult);
5656
+ setKYCCopy(KYCCopies.verificationBypassed);
5694
5657
  }
5695
- case shared.IdentityVerificationStatusV2.EXPIRED:
5696
- {
5697
- const resumeVerificationResult = await shared.IdentityServiceV2.resumeVerification(account, chainId, isDev);
5658
+ break;
5659
+ }
5660
+ case shared.IdentityVerificationStatusV2.CREATED:
5661
+ {
5662
+ setKYCCopy(KYCCopies.verifyIdentity);
5663
+ setLoadingType(undefined);
5664
+ break;
5665
+ }
5666
+ case shared.IdentityVerificationStatusV2.PENDING:
5667
+ {
5668
+ if (!isKYCCompletedRef.current) {
5669
+ const resumeVerificationResult = await shared.IdentityServiceV2.resumeVerification(networkType, isDev);
5698
5670
  verificationStatus.status = resumeVerificationResult.status;
5699
5671
  setVerificationStatus(verificationStatus);
5700
5672
  setSessionToken(resumeVerificationResult.sessionToken);
5701
- setKYCCopy(KYCCopies.verifyIdentity);
5702
5673
  setLoadingType(undefined);
5703
5674
  isKYCResumedRef.current = true;
5704
- break;
5705
- }
5706
- case shared.IdentityVerificationStatusV2.BYPASSED:
5707
- {
5708
- setKYCCopy(KYCCopies.verificationBypassed);
5709
- setLoadingType(undefined);
5710
- break;
5711
- }
5712
- case shared.IdentityVerificationStatusV2.APPROVED:
5713
- {
5714
- setKYCCopy(KYCCopies.verificationApproved);
5715
- setLoadingType(undefined);
5716
- break;
5717
- }
5718
- case shared.IdentityVerificationStatusV2.DECLINED:
5719
- {
5720
- setKYCCopy(KYCCopies.verificationDeclined);
5721
- setLoadingType(undefined);
5722
- break;
5723
- }
5724
- case shared.IdentityVerificationStatusV2.NEEDS_REVIEW:
5725
- {
5726
- setKYCCopy(KYCCopies.verificationNeedsReview);
5727
- setLoadingType(undefined);
5728
- break;
5729
- }
5730
- case shared.IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION:
5731
- {
5732
- dispatch(setStep(WIDGET_STEP.ApproveLender));
5733
- break;
5675
+ } else {
5676
+ setLoadingType('verificationStatus');
5734
5677
  }
5735
- default:
5678
+ setKYCCopy(KYCCopies.verifyIdentity);
5736
5679
  break;
5737
- }
5680
+ }
5681
+ case shared.IdentityVerificationStatusV2.EXPIRED:
5682
+ {
5683
+ const resumeVerificationResult = await shared.IdentityServiceV2.resumeVerification(networkType, isDev);
5684
+ verificationStatus.status = resumeVerificationResult.status;
5685
+ setVerificationStatus(verificationStatus);
5686
+ setSessionToken(resumeVerificationResult.sessionToken);
5687
+ setKYCCopy(KYCCopies.verifyIdentity);
5688
+ setLoadingType(undefined);
5689
+ isKYCResumedRef.current = true;
5690
+ break;
5691
+ }
5692
+ case shared.IdentityVerificationStatusV2.BYPASSED:
5693
+ {
5694
+ setKYCCopy(KYCCopies.verificationBypassed);
5695
+ setLoadingType(undefined);
5696
+ break;
5697
+ }
5698
+ case shared.IdentityVerificationStatusV2.APPROVED:
5699
+ {
5700
+ setKYCCopy(KYCCopies.verificationApproved);
5701
+ setLoadingType(undefined);
5702
+ break;
5703
+ }
5704
+ case shared.IdentityVerificationStatusV2.DECLINED:
5705
+ {
5706
+ setKYCCopy(KYCCopies.verificationDeclined);
5707
+ setLoadingType(undefined);
5708
+ break;
5709
+ }
5710
+ case shared.IdentityVerificationStatusV2.NEEDS_REVIEW:
5711
+ {
5712
+ setKYCCopy(KYCCopies.verificationNeedsReview);
5713
+ setLoadingType(undefined);
5714
+ break;
5715
+ }
5716
+ case shared.IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION:
5717
+ {
5718
+ dispatch(setStep(WIDGET_STEP.ApproveLender));
5719
+ break;
5720
+ }
5721
+ default:
5722
+ break;
5738
5723
  }
5739
5724
  } catch (e) {
5740
5725
  setAuthError(e);
5741
5726
  } finally {
5742
5727
  isActionOngoingRef.current = false;
5743
5728
  }
5744
- }, [KYCCopies, account, chainId, dispatch, isDev, setAuthError]);
5729
+ }, [KYCCopies, dispatch, isDev, networkType, setAuthError]);
5745
5730
  React.useEffect(() => {
5746
5731
  checkVerificationStatus();
5747
5732
  }, [checkVerificationStatus]);
@@ -5830,7 +5815,7 @@ function PersonaEvaluation(_ref) {
5830
5815
  }
5831
5816
  }
5832
5817
  }, [KYCAutoStarted, startKYC, verificationStatus]);
5833
- const handleAction = () => {
5818
+ const handleAction = React.useCallback(() => {
5834
5819
  if (verificationStatus) {
5835
5820
  switch (verificationStatus.status) {
5836
5821
  case shared.IdentityVerificationStatusV2.ACCREDITED:
@@ -5853,7 +5838,7 @@ function PersonaEvaluation(_ref) {
5853
5838
  break;
5854
5839
  }
5855
5840
  }
5856
- };
5841
+ }, [handleClose, startKYC, verificationStatus]);
5857
5842
  const styles = {
5858
5843
  iconWrapper: material.css(_templateObject$b || (_templateObject$b = _taggedTemplateLiteral(["\n ", ";\n margin-top: ", ";\n & > img {\n width: 144px;\n }\n "])), theme.cssMixins.rowCentered, theme.spacing(8)),
5859
5844
  description: material.css(_templateObject2$b || (_templateObject2$b = _taggedTemplateLiteral(["\n margin-top: ", ";\n padding: ", ";\n font-weight: 400;\n font-size: 16px;\n color: ", ";\n "])), theme.spacing(10), theme.spacing(0, 2), theme.palette.text.primary),
@@ -6127,7 +6112,7 @@ function Evaluation$2(_ref) {
6127
6112
  let {
6128
6113
  poolInfo,
6129
6114
  campaign,
6130
- pointsTestnetExperience,
6115
+ networkType,
6131
6116
  handleClose
6132
6117
  } = _ref;
6133
6118
  if ((_poolInfo$KYC = poolInfo.KYC) !== null && _poolInfo$KYC !== void 0 && _poolInfo$KYC.Securitize) {
@@ -6140,8 +6125,8 @@ function Evaluation$2(_ref) {
6140
6125
  return jsxRuntime.jsx(PersonaEvaluation, {
6141
6126
  poolInfo: poolInfo,
6142
6127
  handleClose: handleClose,
6143
- pointsTestnetExperience: pointsTestnetExperience,
6144
6128
  campaign: campaign,
6129
+ networkType: networkType,
6145
6130
  chainType: shared.CHAIN_TYPE.EVM
6146
6131
  });
6147
6132
  }
@@ -6155,6 +6140,7 @@ function ApproveLenderBase(_ref) {
6155
6140
  seniorTrancheVault,
6156
6141
  isUniTranche,
6157
6142
  chainType,
6143
+ networkType,
6158
6144
  chainSpecificData,
6159
6145
  changeTranche
6160
6146
  } = _ref;
@@ -6169,7 +6155,7 @@ function ApproveLenderBase(_ref) {
6169
6155
  while (tryAttempts > 0) {
6170
6156
  try {
6171
6157
  tryAttempts -= 1;
6172
- await shared.IdentityServiceV2.approveLender(account, chainId, trancheVault, isDev, chainSpecificData);
6158
+ await shared.IdentityServiceV2.approveLender(networkType, account, chainId, trancheVault, isDev, chainSpecificData);
6173
6159
  tryAttempts = 0;
6174
6160
  } catch (e) {
6175
6161
  if (tryAttempts === 0) {
@@ -6182,7 +6168,7 @@ function ApproveLenderBase(_ref) {
6182
6168
  }
6183
6169
  }
6184
6170
  }
6185
- }, [account, chainId, chainSpecificData, dispatch, isDev]);
6171
+ }, [account, chainId, chainSpecificData, dispatch, isDev, networkType]);
6186
6172
  React.useEffect(() => {
6187
6173
  const approveLenderAsync = async () => {
6188
6174
  if (account && chainId) {
@@ -6216,6 +6202,7 @@ function ApproveLender$1(_ref) {
6216
6202
  seniorTrancheVault: poolInfo.seniorTrancheVault,
6217
6203
  isUniTranche: isUniTranche,
6218
6204
  chainType: shared.CHAIN_TYPE.EVM,
6205
+ networkType: shared.getEvmNetworkType(poolInfo.chainId),
6219
6206
  changeTranche: changeTranche
6220
6207
  });
6221
6208
  }
@@ -6325,7 +6312,7 @@ function Transfer$c(_ref) {
6325
6312
  let {
6326
6313
  poolInfo,
6327
6314
  trancheType,
6328
- pointsTestnetExperience,
6315
+ networkType,
6329
6316
  campaign
6330
6317
  } = _ref;
6331
6318
  const isDev = shared.checkIsDev();
@@ -6346,14 +6333,14 @@ function Transfer$c(_ref) {
6346
6333
  const handleSuccess = React.useCallback(async options => {
6347
6334
  if (campaign && options !== null && options !== void 0 && options.txHash) {
6348
6335
  try {
6349
- const result = await shared.CampaignService.updateWalletPoints(account, options.txHash, chainId, isDev, pointsTestnetExperience);
6336
+ const result = await shared.CampaignService.updateHumaAccountPoints(account, options.txHash, chainId, networkType, isDev);
6350
6337
  dispatch(setPointsAccumulated(result.pointsAccumulated));
6351
6338
  } catch (error) {
6352
6339
  console.error('Failed to update wallet points', error);
6353
6340
  }
6354
6341
  }
6355
6342
  dispatch(setStep(WIDGET_STEP.Done));
6356
- }, [account, campaign, chainId, dispatch, isDev, pointsTestnetExperience]);
6343
+ }, [account, campaign, chainId, dispatch, isDev, networkType]);
6357
6344
  if (!trancheVaultContract || !account) {
6358
6345
  return null;
6359
6346
  }
@@ -6461,7 +6448,6 @@ function Notifications$1(_ref) {
6461
6448
  function LendSupplyV2(_ref) {
6462
6449
  let {
6463
6450
  poolName: poolNameStr,
6464
- pointsTestnetExperience,
6465
6451
  campaign,
6466
6452
  handleClose,
6467
6453
  handleSuccess
@@ -6541,8 +6527,8 @@ function LendSupplyV2(_ref) {
6541
6527
  }), step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$2, {
6542
6528
  poolInfo: poolInfo,
6543
6529
  handleClose: handleClose,
6544
- pointsTestnetExperience: pointsTestnetExperience,
6545
- campaign: campaign
6530
+ campaign: campaign,
6531
+ networkType: shared.getEvmNetworkType(poolInfo.chainId)
6546
6532
  }), step === WIDGET_STEP.ApproveLender && jsxRuntime.jsx(ApproveLender$1, {
6547
6533
  poolInfo: poolInfo,
6548
6534
  isUniTranche: isUniTranche,
@@ -6559,8 +6545,8 @@ function LendSupplyV2(_ref) {
6559
6545
  }), step === WIDGET_STEP.Transfer && selectedTranche && jsxRuntime.jsx(Transfer$c, {
6560
6546
  poolInfo: poolInfo,
6561
6547
  trancheType: selectedTranche,
6562
- pointsTestnetExperience: pointsTestnetExperience,
6563
- campaign: campaign
6548
+ campaign: campaign,
6549
+ networkType: shared.getEvmNetworkType(poolInfo.chainId)
6564
6550
  }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$7, {
6565
6551
  poolInfo: poolInfo,
6566
6552
  lpConfig: lpConfig,
@@ -8588,7 +8574,7 @@ function Evaluation(_ref) {
8588
8574
  var _poolInfo$KYC;
8589
8575
  let {
8590
8576
  poolInfo,
8591
- pointsTestnetExperience,
8577
+ networkType,
8592
8578
  campaign,
8593
8579
  handleClose
8594
8580
  } = _ref;
@@ -8600,9 +8586,9 @@ function Evaluation(_ref) {
8600
8586
  seniorTrancheVault: poolInfo.seniorTrancheMint
8601
8587
  },
8602
8588
  handleClose: handleClose,
8603
- pointsTestnetExperience: pointsTestnetExperience,
8604
- campaign: campaign,
8605
- chainType: shared.CHAIN_TYPE.SOLANA
8589
+ networkType: networkType,
8590
+ chainType: shared.CHAIN_TYPE.SOLANA,
8591
+ campaign: campaign
8606
8592
  });
8607
8593
  }
8608
8594
  return null;
@@ -8620,6 +8606,7 @@ function ApproveLender(_ref) {
8620
8606
  seniorTrancheVault: poolInfo.seniorTrancheMint,
8621
8607
  isUniTranche: isUniTranche,
8622
8608
  chainType: shared.CHAIN_TYPE.SOLANA,
8609
+ networkType: shared.getSolanaNetworkType(poolInfo.chainId),
8623
8610
  chainSpecificData: {
8624
8611
  huma_program_id: solanaChainInfo.poolProgram,
8625
8612
  pool_id: poolInfo.poolId
@@ -8905,7 +8892,7 @@ function Transfer$6(_ref) {
8905
8892
  poolInfo,
8906
8893
  poolState,
8907
8894
  selectedTranche,
8908
- pointsTestnetExperience
8895
+ networkType
8909
8896
  } = _ref;
8910
8897
  const isDev = shared.checkIsDev();
8911
8898
  const dispatch = useAppDispatch();
@@ -8938,14 +8925,14 @@ function Transfer$6(_ref) {
8938
8925
  const handleSuccess = React.useCallback(async options => {
8939
8926
  if (publicKey && poolState.campaign && options !== null && options !== void 0 && options.signature) {
8940
8927
  try {
8941
- const result = await shared.CampaignService.updateWalletPoints(publicKey.toString(), options.signature, poolInfo.chainId, isDev, pointsTestnetExperience);
8928
+ const result = await shared.CampaignService.updateHumaAccountPoints(publicKey.toString(), options.signature, poolInfo.chainId, networkType, isDev);
8942
8929
  dispatch(setPointsAccumulated(result.pointsAccumulated));
8943
8930
  } catch (error) {
8944
8931
  console.error('Failed to update wallet points', error);
8945
8932
  }
8946
8933
  }
8947
8934
  dispatch(setStep(WIDGET_STEP.Done));
8948
- }, [dispatch, isDev, pointsTestnetExperience, poolInfo.chainId, poolState.campaign, publicKey]);
8935
+ }, [dispatch, isDev, networkType, poolInfo.chainId, poolState.campaign, publicKey]);
8949
8936
  React.useEffect(() => {
8950
8937
  async function getTx() {
8951
8938
  var _poolState$seniorTran, _poolState$juniorTran, _seniorTrancheMintSup, _juniorTrancheMintSup, _poolState$seniorTran2, _poolState$juniorTran2, _seniorTrancheMintSup2, _juniorTrancheMintSup2, _seniorTokenAccount$a, _juniorTokenAccount$a;
@@ -9123,7 +9110,6 @@ function SolanaLendSupply(_ref) {
9123
9110
  let {
9124
9111
  poolInfo,
9125
9112
  poolState,
9126
- pointsTestnetExperience,
9127
9113
  handleClose,
9128
9114
  handleSuccess
9129
9115
  } = _ref;
@@ -9183,8 +9169,8 @@ function SolanaLendSupply(_ref) {
9183
9169
  handleSuccess: handleSuccess,
9184
9170
  children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation, {
9185
9171
  poolInfo: poolInfo,
9186
- pointsTestnetExperience: pointsTestnetExperience,
9187
9172
  campaign: poolState.campaign,
9173
+ networkType: shared.getSolanaNetworkType(poolInfo.chainId),
9188
9174
  handleClose: handleClose
9189
9175
  }), step === WIDGET_STEP.ApproveLender && jsxRuntime.jsx(ApproveLender, {
9190
9176
  poolInfo: poolInfo,
@@ -9206,7 +9192,7 @@ function SolanaLendSupply(_ref) {
9206
9192
  poolInfo: poolInfo,
9207
9193
  poolState: poolState,
9208
9194
  selectedTranche: selectedTranche,
9209
- pointsTestnetExperience: pointsTestnetExperience
9195
+ networkType: shared.getSolanaNetworkType(poolInfo.chainId)
9210
9196
  }), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$2, {
9211
9197
  poolInfo: poolInfo,
9212
9198
  poolState: poolState,