@huma-finance/widgets 0.0.61-beta.546 → 0.0.61-beta.548

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
@@ -1774,8 +1774,8 @@ function ViewOnExplorer(_ref) {
1774
1774
  if (!link) {
1775
1775
  return null;
1776
1776
  }
1777
- return jsx(Button, {
1778
- variant: "outlined",
1777
+ return jsx(BottomButton, {
1778
+ variant: "contained",
1779
1779
  onClick: () => openInNewTab(link),
1780
1780
  children: jsx(Box, {
1781
1781
  component: "span",
@@ -3606,10 +3606,6 @@ function ChooseAmount$9(_ref) {
3606
3606
  } = usePoolSafeAllowanceV2(poolInfo.poolName, account, provider);
3607
3607
  const totalDueAmount = Number(ethers.utils.formatUnits(totalDueAmountBN, decimals));
3608
3608
  const payoffAmount = Number(ethers.utils.formatUnits(payoffAmountBN, decimals));
3609
- console.log('totalDueAmountBN', totalDueAmountBN.toString());
3610
- console.log('payoffAmountBN', payoffAmountBN.toString());
3611
- console.log('payoffAmount', payoffAmount);
3612
- console.log('currentAmount', currentAmount);
3613
3609
  useEffect(() => {
3614
3610
  setCurrentAmount(totalDueAmount);
3615
3611
  }, [totalDueAmount]);
@@ -5494,7 +5490,7 @@ const LoadingCopiesByType$1 = {
5494
5490
  description: "Checking your verification status..."
5495
5491
  },
5496
5492
  startKYC: {
5497
- description: "Starting KYC..."
5493
+ description: "Starting KYC/KYB..."
5498
5494
  },
5499
5495
  approveLender: {
5500
5496
  description: "Approving as lender..."
@@ -6251,8 +6247,8 @@ var STATE = /*#__PURE__*/function (STATE) {
6251
6247
  STATE["SignIn"] = "SignIn";
6252
6248
  STATE["Congrats"] = "Congrats";
6253
6249
  return STATE;
6254
- }(STATE || {}); // const ERROR_MESSAGE =
6255
- // 'Failed to update wallet points. Be assured that your points will be added later.'
6250
+ }(STATE || {});
6251
+ const ERROR_MESSAGE = 'Failed to update wallet points. Be assured that your points will be added later.';
6256
6252
  function PointsEarned(_ref) {
6257
6253
  let {
6258
6254
  transactionHash,
@@ -6263,6 +6259,7 @@ function PointsEarned(_ref) {
6263
6259
  const theme = useTheme();
6264
6260
  const isDev = checkIsDev();
6265
6261
  const dispatch = useDispatch();
6262
+ const reset = useResetAtom(txAtom);
6266
6263
  const {
6267
6264
  account,
6268
6265
  chainId
@@ -6271,84 +6268,66 @@ function PointsEarned(_ref) {
6271
6268
  const hasPointsAccumulated = !isEmpty(pointsAccumulated) && pointsAccumulated > 0;
6272
6269
  const lockupMonths = Math.round(lpConfig.withdrawalLockoutPeriodInDays / 30);
6273
6270
  const monthText = lockupMonths > 1 ? "".concat(lockupMonths, " months") : "".concat(lockupMonths, " month");
6274
-
6275
- // const {
6276
- // errorType,
6277
- // setError: setAuthError,
6278
- // isWalletOwnershipVerified,
6279
- // isWalletOwnershipVerificationRequired,
6280
- // } = useAuthErrorHandling(isDev)
6281
- // const [walletOwnership, setWalletOwnership] = useState<boolean | undefined>()
6271
+ const {
6272
+ errorType,
6273
+ setError: setAuthError,
6274
+ isWalletOwnershipVerified,
6275
+ isWalletOwnershipVerificationRequired
6276
+ } = useAuthErrorHandling(isDev);
6277
+ const [walletOwnership, setWalletOwnership] = useState();
6282
6278
  const [state, setState] = useState(STATE.Loading);
6283
-
6284
- // useEffect(() => {
6285
- // if (isWalletOwnershipVerificationRequired) {
6286
- // setState(STATE.Loading)
6287
- // }
6288
- // }, [isWalletOwnershipVerificationRequired])
6289
-
6290
- // useEffect(() => {
6291
- // if (isWalletOwnershipVerified) {
6292
- // setWalletOwnership(true)
6293
- // }
6294
- // }, [isWalletOwnershipVerified])
6295
-
6296
- // useEffect(() => {
6297
- // const checkWalletOwnership = async () => {
6298
- // const ownership = await CampaignService.checkWalletOwnership(
6299
- // account!,
6300
- // isDev,
6301
- // pointsTestnetExperience,
6302
- // )
6303
- // setWalletOwnership(ownership)
6304
- // if (!ownership) {
6305
- // setAuthError('WalletNotSignInException')
6306
- // }
6307
- // }
6308
- // checkWalletOwnership()
6309
- // }, [account, isDev, pointsTestnetExperience, setAuthError])
6310
-
6311
- // useEffect(() => {
6312
- // if (errorType === 'NotSignedIn') {
6313
- // setState(STATE.SignIn)
6314
- // } else if (errorType === 'UserRejected') {
6315
- // dispatch(
6316
- // setError({
6317
- // errorMessage: 'User has rejected the transaction.',
6318
- // }),
6319
- // )
6320
- // } else if (errorType === 'Other') {
6321
- // dispatch(
6322
- // setError({
6323
- // errorMessage: ERROR_MESSAGE,
6324
- // }),
6325
- // )
6326
- // }
6327
- // }, [dispatch, errorType])
6328
-
6279
+ useEffect(() => {
6280
+ if (isWalletOwnershipVerificationRequired) {
6281
+ setState(STATE.Loading);
6282
+ }
6283
+ }, [isWalletOwnershipVerificationRequired]);
6284
+ useEffect(() => {
6285
+ if (isWalletOwnershipVerified) {
6286
+ setWalletOwnership(true);
6287
+ }
6288
+ }, [isWalletOwnershipVerified]);
6289
+ useEffect(() => {
6290
+ const checkWalletOwnership = async () => {
6291
+ const ownership = await CampaignService.checkWalletOwnership(account, isDev, pointsTestnetExperience);
6292
+ setWalletOwnership(ownership);
6293
+ if (!ownership) {
6294
+ setAuthError('WalletNotSignInException');
6295
+ }
6296
+ };
6297
+ checkWalletOwnership();
6298
+ }, [account, isDev, pointsTestnetExperience, setAuthError]);
6299
+ useEffect(() => {
6300
+ if (errorType === 'NotSignedIn') {
6301
+ setState(STATE.SignIn);
6302
+ } else if (errorType === 'UserRejected') {
6303
+ dispatch(setError({
6304
+ errorMessage: 'User has rejected the transaction.'
6305
+ }));
6306
+ } else if (errorType === 'Other') {
6307
+ dispatch(setError({
6308
+ errorMessage: ERROR_MESSAGE
6309
+ }));
6310
+ }
6311
+ }, [dispatch, errorType]);
6329
6312
  useEffect(() => {
6330
6313
  const updateWalletPoints = async () => {
6331
- // if (walletOwnership) {
6332
- try {
6333
- // const result = await CampaignService.updateWalletPoints(
6334
- // account!,
6335
- // transactionHash,
6336
- // chainId!,
6337
- // isDev,
6338
- // pointsTestnetExperience,
6339
- // )
6340
- // setPointsAccumulated(result.pointsAccumulated)
6341
- setPointsAccumulated(5000);
6342
- setState(STATE.Congrats);
6343
- } catch (error) {
6344
- console.error('Failed to update wallet points', error);
6314
+ if (walletOwnership) {
6315
+ try {
6316
+ const result = await CampaignService.updateWalletPoints(account, transactionHash, chainId, isDev, pointsTestnetExperience);
6317
+ setPointsAccumulated(result.pointsAccumulated);
6318
+ setState(STATE.Congrats);
6319
+ } catch (error) {
6320
+ console.error('Failed to update wallet points', error);
6321
+ }
6345
6322
  }
6346
- // }
6347
6323
  };
6348
6324
  updateWalletPoints();
6349
- }, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash
6350
- // walletOwnership,
6351
- ]);
6325
+ }, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash, walletOwnership]);
6326
+ const handleCloseModal = useCallback(() => {
6327
+ reset();
6328
+ dispatch(resetState());
6329
+ handleAction();
6330
+ }, [dispatch, handleAction, reset]);
6352
6331
  const styles = {
6353
6332
  wrapper: css(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral(["\n height: 518px;\n position: relative;\n "]))),
6354
6333
  congrats: css(_templateObject2$6 || (_templateObject2$6 = _taggedTemplateLiteral(["\n margin: ", ";\n "])), theme.spacing(-4, -4.5, 0, -4.5)),
@@ -6396,7 +6375,7 @@ function PointsEarned(_ref) {
6396
6375
  }), " for", ' ', monthText, " straight. Plus, If you keep your investment till after", ' ', monthText, ", you\u2019ll gain extra points daily."]
6397
6376
  }), jsx(BottomButton, {
6398
6377
  variant: "contained",
6399
- onClick: handleAction,
6378
+ onClick: handleCloseModal,
6400
6379
  children: "GREAT"
6401
6380
  })]
6402
6381
  });