diff --git a/contracts/docs/interchainqueries/howto/register_custom_kv_icq/src/contract.rs b/contracts/docs/interchainqueries/howto/register_custom_kv_icq/src/contract.rs index e7a1e9c..ccde5ed 100644 --- a/contracts/docs/interchainqueries/howto/register_custom_kv_icq/src/contract.rs +++ b/contracts/docs/interchainqueries/howto/register_custom_kv_icq/src/contract.rs @@ -112,19 +112,6 @@ pub fn query_account(deps: Deps, addr: String) -> NeutronResult { Ok(to_json_binary(&REMOTE_ACCOUNTS.load(deps.storage, addr)?)?) } -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { - Ok(Response::default()) -} - -#[entry_point] -pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> NeutronResult { - match msg { - SudoMsg::KVQueryResult { query_id } => sudo_kv_query_result(deps, query_id), - _ => Ok(Response::default()), - } -} - #[entry_point] pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> NeutronResult { match msg.id { @@ -152,6 +139,14 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> NeutronResult { } } +#[entry_point] +pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> NeutronResult { + match msg { + SudoMsg::KVQueryResult { query_id } => sudo_kv_query_result(deps, query_id), + _ => Ok(Response::default()), + } +} + /// The contract's callback for KV query results. Note that only the query id is provided, so you /// need to read the query result from the state. pub fn sudo_kv_query_result(deps: DepsMut, query_id: u64) -> NeutronResult { @@ -167,3 +162,8 @@ pub fn sudo_kv_query_result(deps: DepsMut, query_id: u64) -> NeutronResult StdResult { + Ok(Response::default()) +} diff --git a/contracts/docs/interchainqueries/howto/register_kv_icq/src/contract.rs b/contracts/docs/interchainqueries/howto/register_kv_icq/src/contract.rs index f3c0bf0..ad48667 100644 --- a/contracts/docs/interchainqueries/howto/register_kv_icq/src/contract.rs +++ b/contracts/docs/interchainqueries/howto/register_kv_icq/src/contract.rs @@ -97,19 +97,6 @@ pub fn query_balances(deps: Deps, addr: String) -> NeutronResult { Ok(to_json_binary(&REMOTE_BALANCES.load(deps.storage, addr)?)?) } -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { - Ok(Response::default()) -} - -#[entry_point] -pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { - match msg { - SudoMsg::KVQueryResult { query_id } => sudo_kv_query_result(deps, env, query_id), - _ => Ok(Response::default()), - } -} - #[entry_point] pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> NeutronResult { match msg.id { @@ -137,6 +124,14 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> NeutronResult { } } +#[entry_point] +pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { + match msg { + SudoMsg::KVQueryResult { query_id } => sudo_kv_query_result(deps, env, query_id), + _ => Ok(Response::default()), + } +} + /// The contract's callback for KV query results. Note that only the query id is provided, so you /// need to read the query result from the state. pub fn sudo_kv_query_result(deps: DepsMut, env: Env, query_id: u64) -> NeutronResult { @@ -151,3 +146,8 @@ pub fn sudo_kv_query_result(deps: DepsMut, env: Env, query_id: u64) -> NeutronRe Ok(Response::default()) } + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { + Ok(Response::default()) +} diff --git a/contracts/docs/interchainqueries/howto/register_tx_icq/src/contract.rs b/contracts/docs/interchainqueries/howto/register_tx_icq/src/contract.rs index e2c1b8e..64cf630 100644 --- a/contracts/docs/interchainqueries/howto/register_tx_icq/src/contract.rs +++ b/contracts/docs/interchainqueries/howto/register_tx_icq/src/contract.rs @@ -107,8 +107,8 @@ pub fn query_undelegated_amount(deps: Deps, addr: String) -> NeutronResult StdResult { +#[entry_point] +pub fn reply(_deps: DepsMut, _env: Env, _msg: Reply) -> NeutronResult { Ok(Response::default()) } @@ -124,11 +124,6 @@ pub fn sudo(deps: DepsMut, env: Env, msg: SudoMsg) -> NeutronResult { } } -#[entry_point] -pub fn reply(_deps: DepsMut, _env: Env, _msg: Reply) -> NeutronResult { - Ok(Response::default()) -} - /// The contract's callback for TX query results. pub fn sudo_tx_query_result( deps: DepsMut, @@ -154,6 +149,7 @@ pub fn sudo_tx_query_result( } }; + // the contract's side verification of submitted TX Interchain Query results part let mut new_undelegations: Vec = vec![]; for msg in body.messages.iter() { // Narrow down the messages to only MsgUndelegate ones @@ -174,6 +170,8 @@ pub fn sudo_tx_query_result( }); } + // Put your business logic here + // For this example we just preserve the new undelegations in the state if !new_undelegations.is_empty() { let mut undelegations = UNDELEGATED_AMOUNTS .may_load(deps.storage, delegator.clone())? @@ -184,3 +182,8 @@ pub fn sudo_tx_query_result( Ok(Response::default()) } + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult { + Ok(Response::default()) +}