@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/cjs/index.cjs +58 -75
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +58 -75
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Lend/supplyV2/8-PointsEarned.tsx +86 -74
package/dist/cjs/index.cjs
CHANGED
|
@@ -6291,8 +6291,8 @@ var STATE = /*#__PURE__*/function (STATE) {
|
|
|
6291
6291
|
STATE["SignIn"] = "SignIn";
|
|
6292
6292
|
STATE["Congrats"] = "Congrats";
|
|
6293
6293
|
return STATE;
|
|
6294
|
-
}(STATE || {});
|
|
6295
|
-
|
|
6294
|
+
}(STATE || {});
|
|
6295
|
+
const ERROR_MESSAGE = 'Failed to update wallet points. Be assured that your points will be added later.';
|
|
6296
6296
|
function PointsEarned(_ref) {
|
|
6297
6297
|
let {
|
|
6298
6298
|
transactionHash,
|
|
@@ -6303,6 +6303,7 @@ function PointsEarned(_ref) {
|
|
|
6303
6303
|
const theme = material.useTheme();
|
|
6304
6304
|
const isDev = shared.checkIsDev();
|
|
6305
6305
|
const dispatch = reactRedux.useDispatch();
|
|
6306
|
+
const reset = utils.useResetAtom(webShared.txAtom);
|
|
6306
6307
|
const {
|
|
6307
6308
|
account,
|
|
6308
6309
|
chainId
|
|
@@ -6311,84 +6312,66 @@ function PointsEarned(_ref) {
|
|
|
6311
6312
|
const hasPointsAccumulated = !shared.isEmpty(pointsAccumulated) && pointsAccumulated > 0;
|
|
6312
6313
|
const lockupMonths = Math.round(lpConfig.withdrawalLockoutPeriodInDays / 30);
|
|
6313
6314
|
const monthText = lockupMonths > 1 ? "".concat(lockupMonths, " months") : "".concat(lockupMonths, " month");
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
// const [walletOwnership, setWalletOwnership] = useState<boolean | undefined>()
|
|
6315
|
+
const {
|
|
6316
|
+
errorType,
|
|
6317
|
+
setError: setAuthError,
|
|
6318
|
+
isWalletOwnershipVerified,
|
|
6319
|
+
isWalletOwnershipVerificationRequired
|
|
6320
|
+
} = webShared.useAuthErrorHandling(isDev);
|
|
6321
|
+
const [walletOwnership, setWalletOwnership] = React.useState();
|
|
6322
6322
|
const [state, setState] = React.useState(STATE.Loading);
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
// setError({
|
|
6357
|
-
// errorMessage: 'User has rejected the transaction.',
|
|
6358
|
-
// }),
|
|
6359
|
-
// )
|
|
6360
|
-
// } else if (errorType === 'Other') {
|
|
6361
|
-
// dispatch(
|
|
6362
|
-
// setError({
|
|
6363
|
-
// errorMessage: ERROR_MESSAGE,
|
|
6364
|
-
// }),
|
|
6365
|
-
// )
|
|
6366
|
-
// }
|
|
6367
|
-
// }, [dispatch, errorType])
|
|
6368
|
-
|
|
6323
|
+
React.useEffect(() => {
|
|
6324
|
+
if (isWalletOwnershipVerificationRequired) {
|
|
6325
|
+
setState(STATE.Loading);
|
|
6326
|
+
}
|
|
6327
|
+
}, [isWalletOwnershipVerificationRequired]);
|
|
6328
|
+
React.useEffect(() => {
|
|
6329
|
+
if (isWalletOwnershipVerified) {
|
|
6330
|
+
setWalletOwnership(true);
|
|
6331
|
+
}
|
|
6332
|
+
}, [isWalletOwnershipVerified]);
|
|
6333
|
+
React.useEffect(() => {
|
|
6334
|
+
const checkWalletOwnership = async () => {
|
|
6335
|
+
const ownership = await shared.CampaignService.checkWalletOwnership(account, isDev, pointsTestnetExperience);
|
|
6336
|
+
setWalletOwnership(ownership);
|
|
6337
|
+
if (!ownership) {
|
|
6338
|
+
setAuthError('WalletNotSignInException');
|
|
6339
|
+
}
|
|
6340
|
+
};
|
|
6341
|
+
checkWalletOwnership();
|
|
6342
|
+
}, [account, isDev, pointsTestnetExperience, setAuthError]);
|
|
6343
|
+
React.useEffect(() => {
|
|
6344
|
+
if (errorType === 'NotSignedIn') {
|
|
6345
|
+
setState(STATE.SignIn);
|
|
6346
|
+
} else if (errorType === 'UserRejected') {
|
|
6347
|
+
dispatch(setError({
|
|
6348
|
+
errorMessage: 'User has rejected the transaction.'
|
|
6349
|
+
}));
|
|
6350
|
+
} else if (errorType === 'Other') {
|
|
6351
|
+
dispatch(setError({
|
|
6352
|
+
errorMessage: ERROR_MESSAGE
|
|
6353
|
+
}));
|
|
6354
|
+
}
|
|
6355
|
+
}, [dispatch, errorType]);
|
|
6369
6356
|
React.useEffect(() => {
|
|
6370
6357
|
const updateWalletPoints = async () => {
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
// )
|
|
6380
|
-
// setPointsAccumulated(result.pointsAccumulated)
|
|
6381
|
-
setPointsAccumulated(5000);
|
|
6382
|
-
setState(STATE.Congrats);
|
|
6383
|
-
} catch (error) {
|
|
6384
|
-
console.error('Failed to update wallet points', error);
|
|
6358
|
+
if (walletOwnership) {
|
|
6359
|
+
try {
|
|
6360
|
+
const result = await shared.CampaignService.updateWalletPoints(account, transactionHash, chainId, isDev, pointsTestnetExperience);
|
|
6361
|
+
setPointsAccumulated(result.pointsAccumulated);
|
|
6362
|
+
setState(STATE.Congrats);
|
|
6363
|
+
} catch (error) {
|
|
6364
|
+
console.error('Failed to update wallet points', error);
|
|
6365
|
+
}
|
|
6385
6366
|
}
|
|
6386
|
-
// }
|
|
6387
6367
|
};
|
|
6388
6368
|
updateWalletPoints();
|
|
6389
|
-
}, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash
|
|
6390
|
-
|
|
6391
|
-
|
|
6369
|
+
}, [account, chainId, dispatch, isDev, pointsTestnetExperience, transactionHash, walletOwnership]);
|
|
6370
|
+
const handleCloseModal = React.useCallback(() => {
|
|
6371
|
+
reset();
|
|
6372
|
+
dispatch(resetState());
|
|
6373
|
+
handleAction();
|
|
6374
|
+
}, [dispatch, handleAction, reset]);
|
|
6392
6375
|
const styles = {
|
|
6393
6376
|
wrapper: material.css(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral(["\n height: 518px;\n position: relative;\n "]))),
|
|
6394
6377
|
congrats: material.css(_templateObject2$6 || (_templateObject2$6 = _taggedTemplateLiteral(["\n margin: ", ";\n "])), theme.spacing(-4, -4.5, 0, -4.5)),
|
|
@@ -6436,7 +6419,7 @@ function PointsEarned(_ref) {
|
|
|
6436
6419
|
}), " for", ' ', monthText, " straight. Plus, If you keep your investment till after", ' ', monthText, ", you\u2019ll gain extra points daily."]
|
|
6437
6420
|
}), jsxRuntime.jsx(BottomButton, {
|
|
6438
6421
|
variant: "contained",
|
|
6439
|
-
onClick:
|
|
6422
|
+
onClick: handleCloseModal,
|
|
6440
6423
|
children: "GREAT"
|
|
6441
6424
|
})]
|
|
6442
6425
|
});
|