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

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
@@ -6251,8 +6251,8 @@ var STATE = /*#__PURE__*/function (STATE) {
6251
6251
  STATE["SignIn"] = "SignIn";
6252
6252
  STATE["Congrats"] = "Congrats";
6253
6253
  return STATE;
6254
- }(STATE || {}); // const ERROR_MESSAGE =
6255
- // 'Failed to update wallet points. Be assured that your points will be added later.'
6254
+ }(STATE || {});
6255
+ const ERROR_MESSAGE = 'Failed to update wallet points. Be assured that your points will be added later.';
6256
6256
  function PointsEarned(_ref) {
6257
6257
  let {
6258
6258
  transactionHash,
@@ -6263,6 +6263,7 @@ function PointsEarned(_ref) {
6263
6263
  const theme = useTheme();
6264
6264
  const isDev = checkIsDev();
6265
6265
  const dispatch = useDispatch();
6266
+ const reset = useResetAtom(txAtom);
6266
6267
  const {
6267
6268
  account,
6268
6269
  chainId
@@ -6271,84 +6272,66 @@ function PointsEarned(_ref) {
6271
6272
  const hasPointsAccumulated = !isEmpty(pointsAccumulated) && pointsAccumulated > 0;
6272
6273
  const lockupMonths = Math.round(lpConfig.withdrawalLockoutPeriodInDays / 30);
6273
6274
  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>()
6275
+ const {
6276
+ errorType,
6277
+ setError: setAuthError,
6278
+ isWalletOwnershipVerified,
6279
+ isWalletOwnershipVerificationRequired
6280
+ } = useAuthErrorHandling(isDev);
6281
+ const [walletOwnership, setWalletOwnership] = useState();
6282
6282
  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
-
6283
+ useEffect(() => {
6284
+ if (isWalletOwnershipVerificationRequired) {
6285
+ setState(STATE.Loading);
6286
+ }
6287
+ }, [isWalletOwnershipVerificationRequired]);
6288
+ useEffect(() => {
6289
+ if (isWalletOwnershipVerified) {
6290
+ setWalletOwnership(true);
6291
+ }
6292
+ }, [isWalletOwnershipVerified]);
6293
+ useEffect(() => {
6294
+ const checkWalletOwnership = async () => {
6295
+ const ownership = await CampaignService.checkWalletOwnership(account, isDev, pointsTestnetExperience);
6296
+ setWalletOwnership(ownership);
6297
+ if (!ownership) {
6298
+ setAuthError('WalletNotSignInException');
6299
+ }
6300
+ };
6301
+ checkWalletOwnership();
6302
+ }, [account, isDev, pointsTestnetExperience, setAuthError]);
6303
+ useEffect(() => {
6304
+ if (errorType === 'NotSignedIn') {
6305
+ setState(STATE.SignIn);
6306
+ } else if (errorType === 'UserRejected') {
6307
+ dispatch(setError({
6308
+ errorMessage: 'User has rejected the transaction.'
6309
+ }));
6310
+ } else if (errorType === 'Other') {
6311
+ dispatch(setError({
6312
+ errorMessage: ERROR_MESSAGE
6313
+ }));
6314
+ }
6315
+ }, [dispatch, errorType]);
6329
6316
  useEffect(() => {
6330
6317
  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);
6318
+ if (walletOwnership) {
6319
+ try {
6320
+ const result = await CampaignService.updateWalletPoints(account, transactionHash, chainId, isDev, pointsTestnetExperience);
6321
+ setPointsAccumulated(result.pointsAccumulated);
6322
+ setState(STATE.Congrats);
6323
+ } catch (error) {
6324
+ console.error('Failed to update wallet points', error);
6325
+ }
6345
6326
  }
6346
- // }
6347
6327
  };
6348
6328
  updateWalletPoints();
6349
- }, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash
6350
- // walletOwnership,
6351
- ]);
6329
+ }, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash, walletOwnership]);
6330
+ const handleCloseModal = useCallback(() => {
6331
+ reset();
6332
+ dispatch(resetState());
6333
+ handleAction();
6334
+ }, [dispatch, handleAction, reset]);
6352
6335
  const styles = {
6353
6336
  wrapper: css(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral(["\n height: 518px;\n position: relative;\n "]))),
6354
6337
  congrats: css(_templateObject2$6 || (_templateObject2$6 = _taggedTemplateLiteral(["\n margin: ", ";\n "])), theme.spacing(-4, -4.5, 0, -4.5)),
@@ -6396,7 +6379,7 @@ function PointsEarned(_ref) {
6396
6379
  }), " for", ' ', monthText, " straight. Plus, If you keep your investment till after", ' ', monthText, ", you\u2019ll gain extra points daily."]
6397
6380
  }), jsx(BottomButton, {
6398
6381
  variant: "contained",
6399
- onClick: handleAction,
6382
+ onClick: handleCloseModal,
6400
6383
  children: "GREAT"
6401
6384
  })]
6402
6385
  });