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 ibc-hooks (and its tests) #6752

Merged
merged 3 commits into from
Oct 24, 2023
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
Binary file modified tests/ibc-hooks/bytecode/counter.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/ibc-hooks/testutils/contracts/counter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ pub fn instantiate(
total_funds: vec![],
owner: info.sender.clone(),
};
deps.api.debug(&format!("initial_counter: {:?}", initial_counter));
COUNTERS.save(deps.storage, info.sender.clone(), &initial_counter)?;
deps.api.debug(&format!("instantiate saved. Initial msg: {:?}", msg));

Ok(Response::new()
.add_attribute("method", "instantiate")
Expand Down Expand Up @@ -77,6 +79,7 @@ pub fn execute(
info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
deps.api.debug(&format!("execute {msg:?}"));
match msg {
ExecuteMsg::Increment {} => execute::increment(deps, info),
ExecuteMsg::Reset { count } => execute::reset(deps, info, count),
Expand All @@ -87,6 +90,7 @@ pub mod execute {
use super::*;

pub fn increment(deps: DepsMut, info: MessageInfo) -> Result<Response, ContractError> {
deps.api.debug(&format!("increment"));
utils::update_counter(
deps,
info.sender,
Expand Down Expand Up @@ -216,6 +220,7 @@ fn coin_addition() {

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
deps.api.debug(&format!("query {msg:?}"));
match msg {
QueryMsg::GetCount { addr } => to_binary(&query::count(deps, addr)?),
QueryMsg::GetTotalFunds { addr } => to_binary(&query::total_funds(deps, addr)?),
Expand Down
2 changes: 1 addition & 1 deletion x/ibc-hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type OnTimeoutPacketAfterHooks interface {

// SendPacket Hooks
type SendPacketOverrideHooks interface {
SendPacketOverride(ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, sourceChannel string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte) (uint64, error)
SendPacketOverride(i ICS4Middleware, ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, sourceChannel string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte) (uint64, error)
}
type SendPacketBeforeHooks interface {
SendPacketBeforeHook(ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, sourceChannel string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte)
Expand Down
2 changes: 1 addition & 1 deletion x/ibc-hooks/ics4_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (i ICS4Middleware) SendPacket(
data []byte,
) (sequence uint64, err error) {
if hook, ok := i.Hooks.(SendPacketOverrideHooks); ok {
return hook.SendPacketOverride(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
return hook.SendPacketOverride(i, ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
}

if hook, ok := i.Hooks.(SendPacketBeforeHooks); ok {
Expand Down
2 changes: 1 addition & 1 deletion x/ibc-hooks/wasm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (h WasmHooks) SendPacketOverride(i ICS4Middleware, ctx sdk.Context, chanCap
} else {
ics20data.Memo = stringMetadata
}
dataBytes, err := json.Marshal(data)
dataBytes, err := json.Marshal(ics20data)
if err != nil {
return 0, errorsmod.Wrap(err, "Send packet with callback error")
}
Expand Down