Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load user info safely #ntrn-240 #84

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions contracts/lockdrop-pcl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,7 @@ pub fn handle_claim_rewards_and_unlock_for_lockup(
// CHECK ::: Is LP Token Pool supported or not ?
let pool_info = ASSET_POOLS.load(deps.storage, pool_type)?;

let mut user_info = USER_INFO
.may_load(deps.storage, &user_address)?
.unwrap_or_default();
let mut user_info = USER_INFO.load(deps.storage, &user_address)?;

// If user's total NTRN rewards == 0 :: We update all of the user's lockup positions to calculate NTRN rewards and for each alongwith their equivalent Astroport LP Shares
if user_info.total_ntrn_rewards == Uint128::zero() {
Expand Down
8 changes: 2 additions & 6 deletions contracts/lockdrop/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,7 @@ pub fn handle_migrate_liquidity_to_pcl_pools(
let config = CONFIG.load(deps.storage)?;
let state = STATE.load(deps.storage)?;

let mut user_info = USER_INFO
.may_load(deps.storage, &user_address)?
.unwrap_or_default();
let mut user_info = USER_INFO.load(deps.storage, &user_address)?;
// If user's total NTRN rewards == 0 :: We update all of the user's lockup positions to
// calculate NTRN rewards and for each alongwith their equivalent Astroport LP Shares
if user_info.total_ntrn_rewards == Uint128::zero() {
Expand Down Expand Up @@ -1190,9 +1188,7 @@ pub fn handle_claim_rewards_and_unlock_for_lockup(
// CHECK ::: Is LP Token Pool supported or not ?
let pool_info = ASSET_POOLS.load(deps.storage, pool_type)?;

let mut user_info = USER_INFO
.may_load(deps.storage, &user_address)?
.unwrap_or_default();
let mut user_info = USER_INFO.load(deps.storage, &user_address)?;

// If user's total NTRN rewards == 0 :: We update all of the user's lockup positions to calculate NTRN rewards and for each alongwith their equivalent Astroport LP Shares
if user_info.total_ntrn_rewards == Uint128::zero() {
Expand Down
Loading