-
Notifications
You must be signed in to change notification settings - Fork 30
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
Callbacks #75
Callbacks #75
Conversation
/// status = Ics721Status::Failed - Transfer failed and contract still owns the NFT | ||
#[cw_serde] | ||
pub struct Ics721AckCallbackMsg { | ||
pub status: Ics721Status, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of Ics721Status::Failed
there are 2 cases: error on target chain (e.g. from a contract) or because of IBC timeout. In both cases there is an error string. So we could add an error: Option<String>
here. This field is None in case of success.
This way ack callback knows the reason of fail and may handle both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we can just add the error message to the Error case, Error(String)
, this way if its an error you would get an error.
The Failed case is called for both timeout and failed on the other side, so just a message there should be enough.
This is amazing! |
This PR has internally been reviewed here: arkprotocol#13 |
let msg = to_json_binary(&ReceiverExecuteMsg::Ics721ReceiveCallback( | ||
Ics721ReceiveCallbackMsg { | ||
msg: receive_callback_data, | ||
nft_contract, | ||
original_packet: packet.clone(), | ||
}, | ||
)) | ||
.ok()?; | ||
|
||
Some(WasmMsg::Execute { | ||
contract_addr, | ||
msg, | ||
funds: vec![], | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got feedback from Vlad, TFL: would be great if msg (instead of data) can be passed in memo and being used directly for execution. Use case here would be calling SendNft
on cw721 contract.
Imo, this would be a lot more flexible - without other contracts being adjusted. All we need to make sure is that msg is not called on ICS721.
Callback implementation for ICS721.
There are 2 types of callbacks:
Use cases:
ICS721-tester is a contract used in tests to confirm the data the callback is seeing/getting is the correct data we expect.
It is also a good reference for how a contract would implement accepting callbacks.