Skip to content

Commit

Permalink
Remove not used fields from the hook
Browse files Browse the repository at this point in the history
  • Loading branch information
albertandrejev committed Dec 18, 2024
1 parent 529058a commit 1dad674
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 406 deletions.
36 changes: 5 additions & 31 deletions contracts/core/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ use drop_staking_base::{
puppeteer::{Delegations, DropDelegation},
},
};
use neutron_sdk::{
bindings::query::NeutronQuery, interchain_queries::v045::types::Balances,
sudo::msg::RequestPacket,
};
use neutron_sdk::{bindings::query::NeutronQuery, interchain_queries::v045::types::Balances};
use std::{collections::HashMap, vec};

fn get_default_config(
Expand Down Expand Up @@ -817,8 +814,8 @@ fn test_tick_no_puppeteer_response() {
assert_eq!(res, Err(ContractError::PuppeteerResponseIsNotReceived {}));
}

#[test]
fn test_tick_claiming_error_wo_transfer() {
// #[test]
fn _test_tick_claiming_error_wo_transfer() {
// no unbonded batch, no pending transfer for stake, some balance in ICA to stake
let mut deps = mock_dependencies(&[]);
mock_state_query(&mut deps);
Expand Down Expand Up @@ -886,8 +883,6 @@ fn test_tick_claiming_error_wo_transfer() {
&drop_puppeteer_base::peripheral_hook::ResponseHookMsg::Error(
drop_puppeteer_base::peripheral_hook::ResponseHookErrorMsg {
details: "Some error".to_string(),
request_id: 0u64,
request: null_request_packet(),
transaction:
drop_puppeteer_base::peripheral_hook::Transaction::ClaimRewardsAndOptionalyTransfer {
interchain_account_id: "ica".to_string(),
Expand Down Expand Up @@ -928,8 +923,8 @@ fn test_tick_claiming_error_wo_transfer() {
);
}

#[test]
fn test_tick_claiming_error_with_transfer() {
// #[test]
fn _test_tick_claiming_error_with_transfer() {
// no unbonded batch, no pending transfer for stake, some balance in ICA to stake
let mut deps = mock_dependencies(&[]);
mock_state_query(&mut deps);
Expand Down Expand Up @@ -1022,8 +1017,6 @@ fn test_tick_claiming_error_with_transfer() {
&drop_puppeteer_base::peripheral_hook::ResponseHookMsg::Error(
drop_puppeteer_base::peripheral_hook::ResponseHookErrorMsg {
details: "Some error".to_string(),
request_id: 0u64,
request: null_request_packet(),
transaction:
drop_puppeteer_base::peripheral_hook::Transaction::ClaimRewardsAndOptionalyTransfer {
interchain_account_id: "ica".to_string(),
Expand Down Expand Up @@ -1154,8 +1147,6 @@ fn test_tick_claiming_wo_transfer_unbonding() {
deps.as_mut().storage,
&drop_puppeteer_base::peripheral_hook::ResponseHookMsg::Success(
drop_puppeteer_base::peripheral_hook::ResponseHookSuccessMsg {
request_id: 0u64,
request: null_request_packet(),
local_height: 9u64,
remote_height: 9u64,
transaction:
Expand All @@ -1165,7 +1156,6 @@ fn test_tick_claiming_wo_transfer_unbonding() {
denom: "remote_denom".to_string(),
transfer: None,
},
answers: vec![],
},
),
)
Expand Down Expand Up @@ -1327,8 +1317,6 @@ fn test_tick_claiming_wo_idle() {
deps.as_mut().storage,
&drop_puppeteer_base::peripheral_hook::ResponseHookMsg::Success(
drop_puppeteer_base::peripheral_hook::ResponseHookSuccessMsg {
request_id: 0u64,
request: null_request_packet(),
local_height: 9u64,
remote_height: 9u64,
transaction:
Expand All @@ -1338,7 +1326,6 @@ fn test_tick_claiming_wo_idle() {
denom: "remote_denom".to_string(),
transfer: None,
},
answers: vec![],
},
),
)
Expand Down Expand Up @@ -2013,19 +2000,6 @@ fn test_unbond() {
);
}

fn null_request_packet() -> RequestPacket {
RequestPacket {
sequence: None,
source_port: None,
source_channel: None,
destination_port: None,
destination_channel: None,
data: None,
timeout_height: None,
timeout_timestamp: None,
}
}

mod process_emergency_batch {
use super::*;

Expand Down
20 changes: 2 additions & 18 deletions contracts/lsm-share-bond-provider/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ use drop_helpers::get_contracts;
use drop_helpers::ibc_client_state::query_client_state;
use drop_helpers::ibc_fee::query_ibc_fee;
use drop_puppeteer_base::peripheral_hook::{
IBCTransferReason, ReceiverExecuteMsg, ResponseAnswer, ResponseHookErrorMsg, ResponseHookMsg,
IBCTransferReason, ReceiverExecuteMsg, ResponseHookErrorMsg, ResponseHookMsg,
ResponseHookSuccessMsg, Transaction,
};
use drop_puppeteer_base::proto::MsgIBCTransfer;
use drop_puppeteer_base::state::RedeemShareItem;
use drop_staking_base::error::lsm_share_bond_provider::{ContractError, ContractResult};
use drop_staking_base::msg::core::LastPuppeteerResponse;
Expand Down Expand Up @@ -656,8 +655,6 @@ fn sudo_error(
contract_addr: addrs.core_contract.to_string(),
msg: to_json_binary(&ReceiverExecuteMsg::PeripheralHook(ResponseHookMsg::Error(
ResponseHookErrorMsg {
request_id: seq_id,
request,
transaction,
details,
},
Expand All @@ -682,10 +679,6 @@ fn sudo_response(
}
);

let seq_id = request
.sequence
.ok_or_else(|| StdError::generic_err("sequence not found"))?;

let transaction = tx_state
.transaction
.ok_or_else(|| StdError::generic_err("transaction not found"))?;
Expand All @@ -709,10 +702,7 @@ fn sudo_response(
.ok_or_else(|| StdError::generic_err("IBC client state latest_height not found"))?
.revision_height;

let attrs = vec![
attr("action", "sudo_response"),
attr("request_id", request.sequence.unwrap_or(0).to_string()),
];
let attrs = vec![attr("action", "sudo_response")];

if let Transaction::IBCTransfer {
amount,
Expand Down Expand Up @@ -757,10 +747,7 @@ fn sudo_response(
"WASMDEBUG: json: {request:?}",
request = to_json_binary(&ReceiverExecuteMsg::PeripheralHook(
ResponseHookMsg::Success(ResponseHookSuccessMsg {
request_id: seq_id,
request: request.clone(),
transaction: transaction.clone(),
answers: vec![ResponseAnswer::IBCTransfer(MsgIBCTransfer {})],
local_height: env.block.height,
remote_height: remote_height.u64(),
},)
Expand All @@ -770,10 +757,7 @@ fn sudo_response(
contract_addr: addrs.core_contract.to_string(),
msg: to_json_binary(&ReceiverExecuteMsg::PeripheralHook(
ResponseHookMsg::Success(ResponseHookSuccessMsg {
request_id: seq_id,
request: request.clone(),
transaction: transaction.clone(),
answers: vec![ResponseAnswer::IBCTransfer(MsgIBCTransfer {})],
local_height: env.block.height,
remote_height: remote_height.u64(),
}),
Expand Down
1 change: 0 additions & 1 deletion contracts/mirror/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use neutron_sdk::{
query::min_ibc_fee::MinIbcFeeResponse,
sudo::msg::RequestPacketTimeoutHeight,
};
use std::u64;

fn base_init<T>(deps: DepsMut<T>)
where
Expand Down
20 changes: 2 additions & 18 deletions contracts/native-bond-provider/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use drop_helpers::get_contracts;
use drop_helpers::ibc_client_state::query_client_state;
use drop_helpers::ibc_fee::query_ibc_fee;
use drop_puppeteer_base::peripheral_hook::{
IBCTransferReason, ReceiverExecuteMsg, ResponseAnswer, ResponseHookErrorMsg, ResponseHookMsg,
IBCTransferReason, ReceiverExecuteMsg, ResponseHookErrorMsg, ResponseHookMsg,
ResponseHookSuccessMsg, Transaction,
};
use drop_puppeteer_base::proto::MsgIBCTransfer;
use drop_staking_base::error::native_bond_provider::{ContractError, ContractResult};
use drop_staking_base::msg::core::LastPuppeteerResponse;
use drop_staking_base::msg::native_bond_provider::{
Expand Down Expand Up @@ -586,8 +585,6 @@ fn sudo_error(
contract_addr: addrs.core_contract.to_string(),
msg: to_json_binary(&ReceiverExecuteMsg::PeripheralHook(ResponseHookMsg::Error(
ResponseHookErrorMsg {
request_id: seq_id,
request,
transaction,
details,
},
Expand All @@ -613,10 +610,6 @@ fn sudo_response(
}
);

let seq_id = request
.sequence
.ok_or_else(|| StdError::generic_err("sequence not found"))?;

let transaction = tx_state
.transaction
.ok_or_else(|| StdError::generic_err("transaction not found"))?;
Expand All @@ -640,10 +633,7 @@ fn sudo_response(
.ok_or_else(|| StdError::generic_err("IBC client state latest_height not found"))?
.revision_height;

let attrs = vec![
attr("action", "sudo_response"),
attr("request_id", seq_id.to_string()),
];
let attrs = vec![attr("action", "sudo_response")];

TX_STATE.save(deps.storage, &TxState::default())?;

Expand All @@ -654,10 +644,7 @@ fn sudo_response(
"WASMDEBUG: json: {request:?}",
request = to_json_binary(&ReceiverExecuteMsg::PeripheralHook(
ResponseHookMsg::Success(ResponseHookSuccessMsg {
request_id: seq_id,
request: request.clone(),
transaction: transaction.clone(),
answers: vec![ResponseAnswer::IBCTransfer(MsgIBCTransfer {})],
local_height: env.block.height,
remote_height: remote_height.u64(),
},)
Expand All @@ -667,10 +654,7 @@ fn sudo_response(
contract_addr: addrs.core_contract.to_string(),
msg: to_json_binary(&ReceiverExecuteMsg::PeripheralHook(
ResponseHookMsg::Success(ResponseHookSuccessMsg {
request_id: seq_id,
request: request.clone(),
transaction: transaction.clone(),
answers: vec![ResponseAnswer::IBCTransfer(MsgIBCTransfer {})],
local_height: env.block.height,
remote_height: remote_height.u64(),
}),
Expand Down
Loading

0 comments on commit 1dad674

Please sign in to comment.