Skip to content

Commit cbe0b07

Browse files
committed
Update callback types
1 parent 3852424 commit cbe0b07

File tree

6 files changed

+75
-83
lines changed

6 files changed

+75
-83
lines changed

internal/api/bindings.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,29 +597,29 @@ struct UnmanagedVector ibc_packet_timeout(struct cache_t *cache,
597597
struct GasReport *gas_report,
598598
struct UnmanagedVector *error_msg);
599599

600-
struct UnmanagedVector ibc_source_chain_callback(struct cache_t *cache,
601-
struct ByteSliceView checksum,
602-
struct ByteSliceView env,
603-
struct ByteSliceView msg,
604-
struct Db db,
605-
struct GoApi api,
606-
struct GoQuerier querier,
607-
uint64_t gas_limit,
608-
bool print_debug,
609-
struct GasReport *gas_report,
610-
struct UnmanagedVector *error_msg);
611-
612-
struct UnmanagedVector ibc_destination_chain_callback(struct cache_t *cache,
613-
struct ByteSliceView checksum,
614-
struct ByteSliceView env,
615-
struct ByteSliceView msg,
616-
struct Db db,
617-
struct GoApi api,
618-
struct GoQuerier querier,
619-
uint64_t gas_limit,
620-
bool print_debug,
621-
struct GasReport *gas_report,
622-
struct UnmanagedVector *error_msg);
600+
struct UnmanagedVector ibc_source_callback(struct cache_t *cache,
601+
struct ByteSliceView checksum,
602+
struct ByteSliceView env,
603+
struct ByteSliceView msg,
604+
struct Db db,
605+
struct GoApi api,
606+
struct GoQuerier querier,
607+
uint64_t gas_limit,
608+
bool print_debug,
609+
struct GasReport *gas_report,
610+
struct UnmanagedVector *error_msg);
611+
612+
struct UnmanagedVector ibc_destination_callback(struct cache_t *cache,
613+
struct ByteSliceView checksum,
614+
struct ByteSliceView env,
615+
struct ByteSliceView msg,
616+
struct Db db,
617+
struct GoApi api,
618+
struct GoQuerier querier,
619+
uint64_t gas_limit,
620+
bool print_debug,
621+
struct GasReport *gas_report,
622+
struct UnmanagedVector *error_msg);
623623

624624
struct UnmanagedVector new_unmanaged_vector(bool nil, const uint8_t *ptr, uintptr_t length);
625625

internal/api/lib.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ func IBCPacketTimeout(
700700
return copyAndDestroyUnmanagedVector(res), convertGasReport(gasReport), nil
701701
}
702702

703-
func IBCSourceChainCallback(
703+
func IBCSourceCallback(
704704
cache Cache,
705705
checksum []byte,
706706
env []byte,
@@ -734,15 +734,15 @@ func IBCSourceChainCallback(
734734
var gasReport C.GasReport
735735
errmsg := uninitializedUnmanagedVector()
736736

737-
res, err := C.ibc_source_chain_callback(cache.ptr, cs, e, msgBytes, db, a, q, cu64(gasLimit), cbool(printDebug), &gasReport, &errmsg)
737+
res, err := C.ibc_source_callback(cache.ptr, cs, e, msgBytes, db, a, q, cu64(gasLimit), cbool(printDebug), &gasReport, &errmsg)
738738
if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success {
739739
// Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0.
740740
return nil, convertGasReport(gasReport), errorWithMessage(err, errmsg)
741741
}
742742
return copyAndDestroyUnmanagedVector(res), convertGasReport(gasReport), nil
743743
}
744744

745-
func IBCDestinationChainCallback(
745+
func IBCDestinationCallback(
746746
cache Cache,
747747
checksum []byte,
748748
env []byte,
@@ -776,7 +776,7 @@ func IBCDestinationChainCallback(
776776
var gasReport C.GasReport
777777
errmsg := uninitializedUnmanagedVector()
778778

779-
res, err := C.ibc_destination_chain_callback(cache.ptr, cs, e, msgBytes, db, a, q, cu64(gasLimit), cbool(printDebug), &gasReport, &errmsg)
779+
res, err := C.ibc_destination_callback(cache.ptr, cs, e, msgBytes, db, a, q, cu64(gasLimit), cbool(printDebug), &gasReport, &errmsg)
780780
if err != nil && err.(syscall.Errno) != C.ErrnoValue_Success {
781781
// Depending on the nature of the error, `gasUsed` will either have a meaningful value, or just 0.
782782
return nil, convertGasReport(gasReport), errorWithMessage(err, errmsg)

lib_libwasmvm.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,13 @@ func (vm *VM) IBCPacketTimeout(
532532
return &result, gasReport.UsedInternally, nil
533533
}
534534

535-
// IBCSourceChainCallback is available on IBC-enabled contracts with the corresponding entrypoint
535+
// IBCSourceCallback is available on IBC-enabled contracts with the corresponding entrypoint
536536
// and should be called when the response (ack or timeout) for an outgoing callbacks-enabled packet
537537
// (previously sent by this contract) is received.
538-
func (vm *VM) IBCSourceChainCallback(
538+
func (vm *VM) IBCSourceCallback(
539539
checksum Checksum,
540540
env types.Env,
541-
msg types.IBCSourceChainCallbackMsg,
541+
msg types.IBCSourceCallbackMsg,
542542
store KVStore,
543543
goapi GoAPI,
544544
querier Querier,
@@ -554,7 +554,7 @@ func (vm *VM) IBCSourceChainCallback(
554554
if err != nil {
555555
return nil, 0, err
556556
}
557-
data, gasReport, err := api.IBCSourceChainCallback(vm.cache, checksum, envBin, msgBin, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug)
557+
data, gasReport, err := api.IBCSourceCallback(vm.cache, checksum, envBin, msgBin, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug)
558558
if err != nil {
559559
return nil, gasReport.UsedInternally, err
560560
}
@@ -567,12 +567,12 @@ func (vm *VM) IBCSourceChainCallback(
567567
return &result, gasReport.UsedInternally, nil
568568
}
569569

570-
// IBCDestinationChainCallback is available on IBC-enabled contracts with the corresponding entrypoint
570+
// IBCDestinationCallback is available on IBC-enabled contracts with the corresponding entrypoint
571571
// and should be called when an incoming callbacks-enabled IBC packet is received.
572-
func (vm *VM) IBCDestinationChainCallback(
572+
func (vm *VM) IBCDestinationCallback(
573573
checksum Checksum,
574574
env types.Env,
575-
msg types.IBCDestinationChainCallbackMsg,
575+
msg types.IBCDestinationCallbackMsg,
576576
store KVStore,
577577
goapi GoAPI,
578578
querier Querier,
@@ -588,7 +588,7 @@ func (vm *VM) IBCDestinationChainCallback(
588588
if err != nil {
589589
return nil, 0, err
590590
}
591-
data, gasReport, err := api.IBCDestinationChainCallback(vm.cache, checksum, envBin, msgBin, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug)
591+
data, gasReport, err := api.IBCDestinationCallback(vm.cache, checksum, envBin, msgBin, &gasMeter, store, &goapi, &querier, gasLimit, vm.printDebug)
592592
if err != nil {
593593
return nil, gasReport.UsedInternally, err
594594
}

libwasmvm/bindings.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,29 +597,29 @@ struct UnmanagedVector ibc_packet_timeout(struct cache_t *cache,
597597
struct GasReport *gas_report,
598598
struct UnmanagedVector *error_msg);
599599

600-
struct UnmanagedVector ibc_source_chain_callback(struct cache_t *cache,
601-
struct ByteSliceView checksum,
602-
struct ByteSliceView env,
603-
struct ByteSliceView msg,
604-
struct Db db,
605-
struct GoApi api,
606-
struct GoQuerier querier,
607-
uint64_t gas_limit,
608-
bool print_debug,
609-
struct GasReport *gas_report,
610-
struct UnmanagedVector *error_msg);
611-
612-
struct UnmanagedVector ibc_destination_chain_callback(struct cache_t *cache,
613-
struct ByteSliceView checksum,
614-
struct ByteSliceView env,
615-
struct ByteSliceView msg,
616-
struct Db db,
617-
struct GoApi api,
618-
struct GoQuerier querier,
619-
uint64_t gas_limit,
620-
bool print_debug,
621-
struct GasReport *gas_report,
622-
struct UnmanagedVector *error_msg);
600+
struct UnmanagedVector ibc_source_callback(struct cache_t *cache,
601+
struct ByteSliceView checksum,
602+
struct ByteSliceView env,
603+
struct ByteSliceView msg,
604+
struct Db db,
605+
struct GoApi api,
606+
struct GoQuerier querier,
607+
uint64_t gas_limit,
608+
bool print_debug,
609+
struct GasReport *gas_report,
610+
struct UnmanagedVector *error_msg);
611+
612+
struct UnmanagedVector ibc_destination_callback(struct cache_t *cache,
613+
struct ByteSliceView checksum,
614+
struct ByteSliceView env,
615+
struct ByteSliceView msg,
616+
struct Db db,
617+
struct GoApi api,
618+
struct GoQuerier querier,
619+
uint64_t gas_limit,
620+
bool print_debug,
621+
struct GasReport *gas_report,
622+
struct UnmanagedVector *error_msg);
623623

624624
struct UnmanagedVector new_unmanaged_vector(bool nil, const uint8_t *ptr, uintptr_t length);
625625

libwasmvm/src/calls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use time::{format_description::well_known::Rfc3339, OffsetDateTime};
88
use cosmwasm_std::Checksum;
99
use cosmwasm_vm::{
1010
call_execute_raw, call_ibc_channel_close_raw, call_ibc_channel_connect_raw,
11-
call_ibc_channel_open_raw, call_ibc_destination_chain_callback_raw, call_ibc_packet_ack_raw,
12-
call_ibc_packet_receive_raw, call_ibc_packet_timeout_raw, call_ibc_source_chain_callback_raw,
11+
call_ibc_channel_open_raw, call_ibc_destination_callback_raw, call_ibc_packet_ack_raw,
12+
call_ibc_packet_receive_raw, call_ibc_packet_timeout_raw, call_ibc_source_callback_raw,
1313
call_instantiate_raw, call_migrate_raw, call_query_raw, call_reply_raw, call_sudo_raw, Backend,
1414
Cache, Instance, InstanceOptions, VmResult,
1515
};
@@ -397,7 +397,7 @@ pub extern "C" fn ibc_packet_timeout(
397397
}
398398

399399
#[no_mangle]
400-
pub extern "C" fn ibc_source_chain_callback(
400+
pub extern "C" fn ibc_source_callback(
401401
cache: *mut cache_t,
402402
checksum: ByteSliceView,
403403
env: ByteSliceView,
@@ -411,7 +411,7 @@ pub extern "C" fn ibc_source_chain_callback(
411411
error_msg: Option<&mut UnmanagedVector>,
412412
) -> UnmanagedVector {
413413
call_2_args(
414-
call_ibc_source_chain_callback_raw,
414+
call_ibc_source_callback_raw,
415415
cache,
416416
checksum,
417417
env,
@@ -427,7 +427,7 @@ pub extern "C" fn ibc_source_chain_callback(
427427
}
428428

429429
#[no_mangle]
430-
pub extern "C" fn ibc_destination_chain_callback(
430+
pub extern "C" fn ibc_destination_callback(
431431
cache: *mut cache_t,
432432
checksum: ByteSliceView,
433433
env: ByteSliceView,
@@ -441,7 +441,7 @@ pub extern "C" fn ibc_destination_chain_callback(
441441
error_msg: Option<&mut UnmanagedVector>,
442442
) -> UnmanagedVector {
443443
call_2_args(
444-
call_ibc_destination_chain_callback_raw,
444+
call_ibc_destination_callback_raw,
445445
cache,
446446
checksum,
447447
env,

types/ibc.go

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ type IBCPacketTimeoutMsg struct {
148148
Relayer string `json:"relayer"`
149149
}
150150

151-
// The type of IBC source chain callback that is being called.
151+
// The type of IBC source callback that is being called.
152152
//
153-
// IBC source chain callbacks are needed for cases where your contract triggers the sending of an IBC packet through some other message (i.e. not through [`IbcMsg::SendPacket`]) and needs to know whether or not the packet was successfully received on the other chain. A prominent example is the [`IbcMsg::Transfer`] message. Without callbacks, you cannot know whether the transfer was successful or not.
153+
// IBC source callbacks are needed for cases where your contract triggers the sending of an IBC packet through some other message (i.e. not through [`IbcMsg::SendPacket`]) and needs to know whether or not the packet was successfully received on the other chain. A prominent example is the [`IbcMsg::Transfer`] message. Without callbacks, you cannot know whether the transfer was successful or not.
154154
//
155-
// Note that there are some prerequisites that need to be fulfilled to receive source chain callbacks: - The contract must implement the `ibc_source_chain_callback` entrypoint. - The IBC application in the source chain must have support for the callbacks middleware. - You have to add serialized [`IbcCallbackRequest`] to a specific field of the message. For `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded. - The receiver of the callback must also be the sender of the message.
156-
type IBCSourceChainCallbackMsg struct {
155+
// Note that there are some prerequisites that need to be fulfilled to receive source callbacks: - The contract must implement the `ibc_source_callback` entrypoint. - The IBC application in the source chain must have support for the callbacks middleware. - You have to add serialized [`IbcCallbackRequest`] to a specific field of the message. For `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded. - The receiver of the callback must also be the sender of the message.
156+
type IBCSourceCallbackMsg struct {
157157
Acknowledgement *IBCAckCallbackMsg `json:"acknowledgement,omitempty"`
158158
Timeout *IBCTimeoutCallbackMsg `json:"timeout,omitempty"`
159159
}
@@ -169,32 +169,24 @@ type IBCTimeoutCallbackMsg struct {
169169
Relayer string `json:"relayer"`
170170
}
171171

172-
// The message type of the IBC destination chain callback.
172+
// The message type of the IBC destination callback.
173173
//
174-
// The IBC destination chain callback is needed for cases where someone triggers the sending of an
174+
// The IBC destination callback is needed for cases where someone triggers the sending of an
175175
// IBC packet through some other message (i.e. not through [`IbcMsg::SendPacket`]) and
176176
// your contract needs to know that it received this.
177177
// The callback is called after the packet was successfully acknowledged on the destination chain.
178178
// A prominent example is the [`IbcMsg::Transfer`] message. Without callbacks, you cannot know
179179
// that someone sent you IBC coins.
180180
//
181-
// Note that there are some prerequisites that need to be fulfilled to receive source chain callbacks:
182-
// - The contract must implement the `ibc_destination_chain_callback` entrypoint.
181+
// Note that there are some prerequisites that need to be fulfilled to receive source callbacks:
182+
// - The contract must implement the `ibc_destination_callback` entrypoint.
183183
// - The module that receives the packet must be wrapped by an `IBCMiddleware`
184184
// (i.e. the destination chain needs to support callbacks for the message you are being sent).
185185
// - You have to add json-encoded [`IbcCallbackData`] to a specific field of the message.
186186
// For `IbcMsg::Transfer`, this is the `memo` field.
187-
type IBCDestinationChainCallbackMsg struct {
188-
Ack IBCFullAcknowledgement `json:"ack"`
189-
Packet IBCPacket `json:"packet"`
190-
}
191-
192-
// The acknowledgement written by the module on the destination chain. It is different from the [`crate::IbcAcknowledgement`] as it can be unsuccessful.
193-
type IBCFullAcknowledgement struct {
194-
// The acknowledgement data returned by the module.
195-
Data []byte `json:"data"`
196-
// Whether the acknowledgement was successful or not.
197-
Success bool `json:"success"`
187+
type IBCDestinationCallbackMsg struct {
188+
Ack IBCAcknowledgement `json:"ack"`
189+
Packet IBCPacket `json:"packet"`
198190
}
199191

200192
// TODO: test what the sdk Order.String() represents and how to parse back

0 commit comments

Comments
 (0)