Skip to content

Commit

Permalink
Implement ICS 721 (#167)
Browse files Browse the repository at this point in the history
* add nft-transfer

* add serde(default)

* add serde(default) for token_uri and token_data

* rebase for 0.40.0

* fix to add serde for nft

* fix doc

* rebuild with protoc 25.1

* fix fmt

* fix for clippy

* add changelog
  • Loading branch information
yito88 authored Jan 5, 2024
1 parent aecfe0d commit e9efa89
Show file tree
Hide file tree
Showing 9 changed files with 3,505 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/167-ics721-impl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add ICS-721 proto: ([\#167](https://github.com/cosmos/ibc-proto-
rs/issues/167))
29 changes: 29 additions & 0 deletions scripts/sync-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ CACHE_PATH="${XDG_CACHE_HOME:-$HOME/.cache}"
COSMOS_SDK_GIT="${COSMOS_SDK_GIT:-$CACHE_PATH/cosmos/cosmos-sdk.git}"
IBC_GO_GIT="${IBC_GO_GIT:-$CACHE_PATH/ibc-go.git}"
COSMOS_ICS_GIT="${COSMOS_ICS_GIT:-$CACHE_PATH/cosmos/interchain-security.git}"
NFT_TRANSFER_GIT="${NFT_TRANSFER_GIT:-$CACHE_PATH/bianjieai/nft-transfer.git}"

COSMOS_SDK_COMMIT="$(cat src/COSMOS_SDK_COMMIT)"
IBC_GO_COMMIT="$(cat src/IBC_GO_COMMIT)"
INTERCHAIN_SECURITY_COMMIT="$(cat src/INTERCHAIN_SECURITY_COMMIT)"
NFT_TRANSFER_COMMIT="$(cat src/NFT_TRANSFER_COMMIT)"

echo "COSMOS_SDK_COMMIT: $COSMOS_SDK_COMMIT"
echo "IBC_GO_COMMIT: $IBC_GO_COMMIT"
echo "INTERCHAIN_SECURITY_COMMIT: $INTERCHAIN_SECURITY_COMMIT"
echo "NFT_TRANSFER_COMMIT: $NFT_TRANSFER_COMMIT"

# Use either --ics-commit flag for commit ID,
# or --ics-tag for git tag. Because we can't modify
Expand Down Expand Up @@ -89,6 +92,15 @@ else
echo "Using existing ibc-go bare git repository at $IBC_GO_GIT"
fi

if [[ ! -e "$NFT_TRANSFER_GIT" ]]
then
echo "Cloning nft-transfer source code to as bare git repository to $NFT_TRANSFER_GIT"
git clone --mirror https://github.com/bianjieai/nft-transfer.git "$NFT_TRANSFER_GIT"
else
echo "Using existing nft-transfer bare git repository at $NFT_TRANSFER_GIT"
fi


# Update the repositories using git fetch. This is so that
# we keep local copies of the repositories up to sync first.
pushd "$COSMOS_ICS_GIT"
Expand All @@ -103,6 +115,10 @@ pushd "$IBC_GO_GIT"
git fetch
popd

pushd "$NFT_TRANSFER_GIT"
git fetch
popd

# Create a new temporary directory to check out the
# actual source files from the bare git repositories.
# This is so that we do not accidentally use an unclean
Expand Down Expand Up @@ -154,6 +170,17 @@ cd proto
buf export -v -o ../proto-include
popd

NFT_TRANSFER_DIR=$(mktemp -d /tmp/nft-transfer-XXXXXXXX)

pushd "$NFT_TRANSFER_DIR"
git clone "$NFT_TRANSFER_GIT" .
git checkout -b "$NFT_TRANSFER_COMMIT" "$NFT_TRANSFER_COMMIT"

cd proto
buf export -v -o ../proto-include
rm ../proto-include/ibc/core/client/v1/client.proto
popd

# Remove the existing generated protobuf files
# so that the newly generated code does not
# contain removed files.
Expand All @@ -173,6 +200,7 @@ cargo run -- compile \
--ics "$COSMOS_ICS_DIR/proto-include" \
--sdk "$COSMOS_SDK_DIR/proto-include" \
--ibc "$IBC_GO_DIR/proto-include" \
--nft "$NFT_TRANSFER_DIR/proto-include" \
--out ../../src/prost

cd ../..
Expand All @@ -192,3 +220,4 @@ rm -f src/prost/tendermint.abci.rs
rm -rf "$COSMOS_ICS_DIR"
rm -rf "$COSMOS_SDK_DIR"
rm -rf "$IBC_GO_DIR"
rm -rf "$NFT_TRANSFER_DIR"
1 change: 1 addition & 0 deletions src/NFT_TRANSFER_COMMIT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
986de3bb91434c9efc49a82544e3ba0b208e19a7
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub const IBC_GO_COMMIT: &str = include_str!("IBC_GO_COMMIT");
/// The version (commit hash) of Interchain Security used when generating this library.
pub const INTERCHAIN_SECURITY_COMMIT: &str = include_str!("INTERCHAIN_SECURITY_COMMIT");

/// The version (commit hash) of nft-transfer used when generating this library.
pub const NFT_TRANSFER_COMMIT: &str = include_str!("NFT_TRANSFER_COMMIT");

/// File descriptor set of compiled proto.
#[cfg(feature = "proto-descriptor")]
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("prost/proto_descriptor.bin");
Expand Down Expand Up @@ -296,6 +299,13 @@ pub mod ibc {
}
}
}
pub mod nft_transfer {
pub mod v1 {
include_proto!("ibc.applications.nft_transfer.v1.rs");
#[cfg(feature = "serde")]
include_proto!("ibc.applications.nft_transfer.v1.serde.rs");
}
}
}
pub mod core {
pub mod channel {
Expand Down
Loading

0 comments on commit e9efa89

Please sign in to comment.