-
Notifications
You must be signed in to change notification settings - Fork 31
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
ICS721 spec seems not matched with example implementation #92
Comments
Even tho the definition of the protobuf is snake case I do believe is working correctly based on these tests It's probably using the protobuf tags in the struct by using ProtoJson marshaling instead of Go's default. |
Hey @jhernandezb, Oh sorry for late response. Hmm not sure what you mean, it is actually not working in testing between cosmos nft-transfer module and wasm nft contract. Currently we fixed this problem by introducing wasm specific conversion in our custom nft module - here and here.
It does not affect when you transfer wasm<>wasm chain, but it will affect when you try to transfer wasm<>cosmosNFT module. |
It should be using it see https://github.com/bianjieai/nft-transfer/blob/c409209538452573978f0aea7a2d70badd2fdf76/types/packet.go#L88-L101 I see that your module deviates from the iris implementation Iris // GetBytes is a helper for serializing
func (nftpd NonFungibleTokenPacketData) GetBytes() []byte {
// Format will reshape tokenUris and tokenData in NonFungibleTokenPacketData:
// 1. if tokenUris/tokenData is ["","",""] or [], then set it to nil.
// 2. if tokenUris/tokenData is ["a","b","c"] or ["a", "", "c"], then keep it.
// NOTE: Only use this before sending pkg.
if requireShape(nftpd.TokenUris) {
nftpd.TokenUris = nil
}
if requireShape(nftpd.TokenData) {
nftpd.TokenData = nil
}
return sdk.MustSortJSON(MustProtoMarshalJSON(&nftpd))
} Initia // GetBytes is a helper for serializing
func (nftpd NonFungibleTokenPacketData) GetBytes(counterpartyPort string) []byte {
var bz []byte
var err error
if isWasmPacket(counterpartyPort) {
bz, err = json.Marshal(nftpd.ToWasmData())
} else {
bz, err = json.Marshal(nftpd)
}
if err != nil {
panic(err)
}
return sdk.MustSortJSON(bz)
} |
I think the proto definitions should be using json tags to avoid the confusion ( like you did with // NonFungibleTokenPacketData defines a struct for the packet payload
// See NonFungibleTokenPacketData spec:
// https://github.com/cosmos/ibc/tree/master/spec/app/ics-721-nft-transfer#data-structures
type NonFungibleTokenPacketData struct {
// the class_id of class to be transferred
ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"`
// the class_uri of class to be transferred
ClassUri string `protobuf:"bytes,2,opt,name=class_uri,json=classUri,proto3" json:"class_uri,omitempty"`
// the class_data of class to be transferred
ClassData string `protobuf:"bytes,3,opt,name=class_data,json=classData,proto3" json:"class_data,omitempty"`
// the non fungible tokens to be transferred
TokenIds []string `protobuf:"bytes,4,rep,name=token_ids,json=tokenIds,proto3" json:"token_ids,omitempty"`
// the non fungible tokens's uri to be transferred
TokenUris []string `protobuf:"bytes,5,rep,name=token_uris,json=tokenUris,proto3" json:"token_uris,omitempty"`
// the non fungible tokens's data to be transferred
TokenData []string `protobuf:"bytes,6,rep,name=token_data,json=tokenData,proto3" json:"token_data,omitempty"`
// the sender address
Sender string `protobuf:"bytes,7,opt,name=sender,proto3" json:"sender,omitempty"`
// the recipient address on the destination chain
Receiver string `protobuf:"bytes,8,opt,name=receiver,proto3" json:"receiver,omitempty"`
// optional memo
Memo string `protobuf:"bytes,9,opt,name=memo,proto3" json:"memo,omitempty"`
} |
Okay, seems official ics721 implementation is doing that. probably good to follow this Proto json format to avoid confusion. |
Problem
Spec seems saying camel case, but all cosmos ibc specs are saying like this but using snake case. Please refer below example.
Cosmos implementation is using snake case
cw-ics721
is using camel casecw-ics721/packages/ics721-types/src/ibc_types.rs
Line 10 in ad8f7b4
Example
ibc-fee spec is saying
but, actual implementation is using snake case
The text was updated successfully, but these errors were encountered: