Skip to content

Commit

Permalink
use may_load in howto ICQ contract queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sotnikov-s committed Nov 14, 2024
1 parent 9977666 commit 07d0f1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult<Binary> {
}

pub fn query_account(deps: Deps, addr: String) -> NeutronResult<Binary> {
Ok(to_json_binary(&REMOTE_ACCOUNTS.load(deps.storage, addr)?)?)
Ok(to_json_binary(
&REMOTE_ACCOUNTS
.may_load(deps.storage, addr)
.unwrap_or_default(),
)?)
}

#[entry_point]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult<Binary> {
}

pub fn query_balances(deps: Deps, addr: String) -> NeutronResult<Binary> {
Ok(to_json_binary(&REMOTE_BALANCES.load(deps.storage, addr)?)?)
Ok(to_json_binary(
&REMOTE_BALANCES
.may_load(deps.storage, addr)
.unwrap_or_default(),
)?)
}

#[entry_point]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> NeutronResult<Binary> {
pub fn query_undelegated_amount(deps: Deps, addr: String) -> NeutronResult<Binary> {
Ok(to_json_binary(
&UNDELEGATED_AMOUNTS
.may_load(deps.storage, addr)?
.may_load(deps.storage, addr)
.unwrap_or_default(),
)?)
}
Expand Down

0 comments on commit 07d0f1e

Please sign in to comment.