Skip to content

Commit

Permalink
chore: Add deprecation mark (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikthebird authored Sep 12, 2024
1 parent 9f623aa commit 66c3370
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/burner/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn instantiate(
#[entry_point]
pub fn migrate(deps: DepsMut, env: Env, msg: MigrateMsg) -> StdResult<Response> {
// get balance and send all to recipient
#[allow(deprecated)]
let balance = deps.querier.query_all_balances(env.contract.address)?;
let send = BankMsg::Send {
to_address: msg.payout.clone(),
Expand Down
2 changes: 2 additions & 0 deletions contracts/hackatom/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn do_release(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Response, Ha

if info.sender == state.verifier {
let to_addr = state.beneficiary;
#[allow(deprecated)]
let balance = deps.querier.query_all_balances(env.contract.address)?;

let resp = Response::new()
Expand Down Expand Up @@ -268,6 +269,7 @@ fn query_verifier(deps: Deps) -> StdResult<VerifierResponse> {
})
}

#[allow(deprecated)]
fn query_other_balance(deps: Deps, address: String) -> StdResult<AllBalanceResponse> {
deps.querier
.query(&BankQuery::AllBalances { address }.into())
Expand Down
3 changes: 3 additions & 0 deletions contracts/ibc-reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ pub fn ibc_channel_close(
remove_account(deps.storage, channel_id);

// transfer current balance if any (steal the money)
#[allow(deprecated)]
let amount = deps.querier.query_all_balances(&reflect_addr)?;
let messages: Vec<SubMsg<Empty>> = if !amount.is_empty() {
let bank_msg = BankMsg::Send {
Expand Down Expand Up @@ -303,6 +304,7 @@ fn receive_who_am_i(deps: DepsMut, caller: String) -> StdResult<IbcReceiveRespon
// processes PacketMsg::Balances variant
fn receive_balances(deps: DepsMut, caller: String) -> StdResult<IbcReceiveResponse> {
let account = load_account(deps.storage, &caller)?;
#[allow(deprecated)]
let balances = deps.querier.query_all_balances(&account)?;
let response = BalancesResponse {
account: account.into(),
Expand Down Expand Up @@ -656,6 +658,7 @@ mod tests {
let raw = query(deps.as_ref(), mock_env(), QueryMsg::ListAccounts {}).unwrap();
let res: ListAccountsResponse = from_json(raw).unwrap();
assert_eq!(1, res.accounts.len());
#[allow(deprecated)]
let balance = deps.as_ref().querier.query_all_balances(&account).unwrap();
assert_eq!(funds, balance);

Expand Down
2 changes: 2 additions & 0 deletions contracts/reflect/schema/raw/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
},
{
"description": "This calls into the native bank module for all denominations. Note that this may be much more expensive than Balance and should be avoided if possible. Return value is AllBalanceResponse.",
"deprecated": true,
"type": "object",
"required": [
"all_balances"
Expand Down Expand Up @@ -375,6 +376,7 @@
},
{
"description": "Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.",
"deprecated": true,
"type": "object",
"required": [
"list_channels"
Expand Down
2 changes: 2 additions & 0 deletions contracts/reflect/schema/reflect.json
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@
},
{
"description": "This calls into the native bank module for all denominations. Note that this may be much more expensive than Balance and should be avoided if possible. Return value is AllBalanceResponse.",
"deprecated": true,
"type": "object",
"required": [
"all_balances"
Expand Down Expand Up @@ -1635,6 +1636,7 @@
},
{
"description": "Lists all channels that are bound to a given port. If `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.",
"deprecated": true,
"type": "object",
"required": [
"list_channels"
Expand Down
1 change: 1 addition & 0 deletions contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ mod tests {
let deps = mock_dependencies_with_custom_querier(&coins(123, "ucosm"));

// with bank query
#[allow(deprecated)]
let msg = QueryMsg::Chain {
request: BankQuery::AllBalances {
address: MOCK_CONTRACT_ADDR.to_string(),
Expand Down
1 change: 1 addition & 0 deletions packages/std/src/query/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum BankQuery {
/// This calls into the native bank module for all denominations.
/// Note that this may be much more expensive than Balance and should be avoided if possible.
/// Return value is AllBalanceResponse.
#[deprecated = "Returns a potentially unbound number of results. If you think you have a valid usecase, please open an issue."]
AllBalances { address: String },
/// This calls into the native bank module for querying metadata for a specific bank token.
/// Return value is DenomMetadataResponse
Expand Down
1 change: 1 addition & 0 deletions packages/std/src/query/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum IbcQuery {
/// If `port_id` is omitted, this list all channels bound to the contract's port.
///
/// Returns a `ListChannelsResponse`.
#[deprecated = "Returns a potentially unbound number of results. If you think you have a valid usecase, please open an issue."]
ListChannels { port_id: Option<String> },
/// Lists all information for a (portID, channelID) pair.
/// If port_id is omitted, it will default to the contract's own channel.
Expand Down
6 changes: 6 additions & 0 deletions packages/std/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ impl BankQuerier {
};
to_json_binary(&bank_res).into()
}
#[allow(deprecated)]
BankQuery::AllBalances { address } => {
// proper error on not found, serialize result on found
let bank_res = AllBalanceResponse {
Expand Down Expand Up @@ -936,6 +937,7 @@ impl IbcQuerier {
let res = ChannelResponse { channel };
to_json_binary(&res).into()
}
#[allow(deprecated)]
IbcQuery::ListChannels { port_id } => {
let channels = self
.channels
Expand Down Expand Up @@ -1868,6 +1870,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn bank_querier_all_balances() {
let addr = String::from("foobar");
let balance = vec![coin(123, "ELF"), coin(777, "FLY")];
Expand Down Expand Up @@ -1911,6 +1914,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn bank_querier_missing_account() {
let addr = String::from("foobar");
let balance = vec![coin(123, "ELF"), coin(777, "FLY")];
Expand Down Expand Up @@ -2217,6 +2221,7 @@ mod tests {

#[cfg(feature = "stargate")]
#[test]
#[allow(deprecated)]
fn ibc_querier_channels_matching() {
let chan1 = mock_ibc_channel("channel-0", IbcOrder::Ordered, "ibc");
let chan2 = mock_ibc_channel("channel-1", IbcOrder::Ordered, "ibc");
Expand All @@ -2234,6 +2239,7 @@ mod tests {

#[cfg(feature = "stargate")]
#[test]
#[allow(deprecated)]
fn ibc_querier_channels_no_matching() {
let chan1 = mock_ibc_channel("channel-0", IbcOrder::Ordered, "ibc");
let chan2 = mock_ibc_channel("channel-1", IbcOrder::Ordered, "ibc");
Expand Down
3 changes: 3 additions & 0 deletions packages/std/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> {
Ok(res.amount)
}

#[deprecated]
pub fn query_all_balances(&self, address: impl Into<String>) -> StdResult<Vec<Coin>> {
#[allow(deprecated)]
let request = BankQuery::AllBalances {
address: address.into(),
}
Expand Down Expand Up @@ -706,6 +708,7 @@ mod tests {
let balance = wrapper.query_balance("foo", "ELF").unwrap();
assert_eq!(balance, coin(123, "ELF"));

#[allow(deprecated)]
let all_balances = wrapper.query_all_balances("foo").unwrap();
assert_eq!(all_balances, vec![coin(123, "ELF"), coin(777, "FLY")]);
}
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn with_querier_from_context_works() {
let (env, _store, _instance) = make_instance(TESTING_GAS_LIMIT);
leave_default_data(&env);
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn do_query_chain_works() {
let api = MockApi::default();
let (fe, mut store, _instance) = make_instance(api);
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn with_querier_works_readonly() {
let rich_addr = String::from("foobar");
let rich_balance = vec![coin(10000, "gold"), coin(8000, "silver")];
Expand Down
2 changes: 2 additions & 0 deletions packages/vm/src/testing/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn bank_querier_all_balances() {
let addr = String::from("foobar");
let balance = vec![coin(123, "ELF"), coin(777, "FLY")];
Expand Down Expand Up @@ -193,6 +194,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn bank_querier_missing_account() {
let addr = String::from("foobar");
let balance = vec![coin(123, "ELF"), coin(777, "FLY")];
Expand Down

0 comments on commit 66c3370

Please sign in to comment.