feat(x/nft): add data field in Class type of NFT module (#10501)

## Description

Adds a `data` field in `Class` type of `x/nft`.

Closes: #10494

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
This commit is contained in:
Devashish Dixit 2021-11-10 22:16:46 +08:00 committed by GitHub
parent 4ee10b6bd7
commit 2b95c7ec01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 21 deletions

View File

@ -7295,6 +7295,7 @@ Class defines the class of the nft type.
| `description` | [string](#string) | | description is a brief description of nft classification,optional |
| `uri` | [string](#string) | | uri is a URI may point to a JSON file that conforms to the nft classification Metadata JSON Schema.optional |
| `uri_hash` | [string](#string) | | uri_hash is a hash of the document pointed to uri,optional |
| `data` | [google.protobuf.Any](#google.protobuf.Any) | | data is the metadata of NFT classification,optional |

View File

@ -24,6 +24,9 @@ message Class {
// uri_hash is a hash of the document pointed to uri,optional
string uri_hash = 6;
// data is the metadata of NFT classification,optional
google.protobuf.Any data = 7;
}
// NFT defines the NFT.

View File

@ -37,6 +37,8 @@ type Class struct {
Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"`
// uri_hash is a hash of the document pointed to uri,optional
UriHash string `protobuf:"bytes,6,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"`
// data is the metadata of NFT classification,optional
Data *types.Any `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
}
func (m *Class) Reset() { *m = Class{} }
@ -114,6 +116,13 @@ func (m *Class) GetUriHash() string {
return ""
}
func (m *Class) GetData() *types.Any {
if m != nil {
return m.Data
}
return nil
}
// NFT defines the NFT.
type NFT struct {
// class_id defines the unique identifier of the NFT classification, similar to the contract address of ERC721
@ -204,27 +213,27 @@ func init() {
func init() { proto.RegisterFile("cosmos/nft/v1beta1/nft.proto", fileDescriptor_eb8ebf8e8053172c) }
var fileDescriptor_eb8ebf8e8053172c = []byte{
// 312 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0xc1, 0x4b, 0xfb, 0x30,
0x18, 0x5d, 0xda, 0x6e, 0xfb, 0xfd, 0x32, 0x10, 0x09, 0x22, 0x99, 0x48, 0x18, 0x3b, 0xed, 0x62,
0xc2, 0xf4, 0xea, 0x45, 0x05, 0xd1, 0x8b, 0x87, 0xe1, 0xc9, 0xcb, 0x48, 0x9b, 0x6e, 0x0d, 0xb6,
0xcd, 0x68, 0x52, 0xb1, 0x7f, 0x81, 0x57, 0xf1, 0xaf, 0xf2, 0xb8, 0xa3, 0x47, 0x69, 0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7, 0xa1, 0x17, 0x79, 0xb5, 0x70, 0x8e, 0xcb, 0xf3,
0xf7, 0x9a, 0x80, 0x6d, 0x4d, 0xc0, 0x67, 0x4d, 0xc0, 0x6b, 0x43, 0x7a, 0xdb, 0x86, 0xf4, 0x3e,
0x1a, 0xd2, 0x7b, 0x98, 0xae, 0xa5, 0x49, 0xca, 0x90, 0x46, 0x2a, 0x63, 0xdd, 0x43, 0xda, 0x71,
0xa2, 0xc5, 0x23, 0x7b, 0xb6, 0x1f, 0x09, 0x07, 0x2e, 0xf1, 0xec, 0x2b, 0x00, 0x00, 0xff, 0xff,
0x2e, 0x0d, 0x3c, 0x9b, 0xb2, 0x01, 0x00, 0x00,
// 317 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4a, 0xc3, 0x30,
0x1c, 0xc6, 0x97, 0xb6, 0xdb, 0x34, 0x03, 0x91, 0x20, 0x92, 0x89, 0x84, 0xb1, 0xd3, 0x2e, 0x26,
0x4c, 0xaf, 0x5e, 0x54, 0x10, 0xbd, 0x78, 0x18, 0x9e, 0xbc, 0x8c, 0xb4, 0xe9, 0xd6, 0xe0, 0xda,
0x8c, 0x26, 0x15, 0xfb, 0x04, 0x5e, 0x7d, 0x20, 0x1f, 0xc0, 0xe3, 0x8e, 0x1e, 0xa5, 0x7d, 0x11,
0x49, 0x5a, 0x87, 0x87, 0x81, 0xa7, 0xfc, 0xf3, 0x7d, 0x1f, 0x7f, 0x7e, 0x1f, 0x7f, 0x78, 0x1a,
0x29, 0x9d, 0x2a, 0xcd, 0xb2, 0x85, 0x61, 0x2f, 0xd3, 0x30, 0x36, 0x7c, 0x6a, 0x67, 0xba, 0xce,
0x95, 0x51, 0x08, 0x35, 0x2e, 0xb5, 0x4a, 0xeb, 0x9e, 0x0c, 0x97, 0x4a, 0x2d, 0x57, 0x31, 0x73,
0x89, 0xb0, 0x58, 0x30, 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 0xb7, 0xf1, 0xe2,
0x27, 0x00, 0x00, 0xff, 0xff, 0x94, 0x4b, 0x2c, 0xc3, 0xdc, 0x01, 0x00, 0x00,
}
func (m *Class) Marshal() (dAtA []byte, err error) {
@ -247,6 +256,18 @@ func (m *Class) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.Data != nil {
{
size, err := m.Data.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintNft(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x3a
}
if len(m.UriHash) > 0 {
i -= len(m.UriHash)
copy(dAtA[i:], m.UriHash)
@ -396,6 +417,10 @@ func (m *Class) Size() (n int) {
if l > 0 {
n += 1 + l + sovNft(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovNft(uint64(l))
}
return n
}
@ -655,6 +680,42 @@ func (m *Class) Unmarshal(dAtA []byte) error {
}
m.UriHash = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowNft
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthNft
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthNft
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &types.Any{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipNft(dAtA[iNdEx:])