-
Notifications
You must be signed in to change notification settings - Fork 70
feat(nft): nft module #296
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
6e4788b
628135e
e834bf6
a658097
ed1caf0
d8a9e7f
9b543d8
466b947
c5ed2f8
dd85dc4
42402ba
4f2e29f
abae283
59b13f5
45df9c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,12 +2,20 @@ name: ictest E2E | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||
| - main | ||||||||||||||||||||||||
| - master | ||||||||||||||||||||||||
| branches-ignore: | ||||||||||||||||||||||||
| - "mvp/**" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||
| tags: | ||||||||||||||||||||||||
| - "**" | ||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||
| - "main" | ||||||||||||||||||||||||
| - "master" | ||||||||||||||||||||||||
| - main | ||||||||||||||||||||||||
| - master | ||||||||||||||||||||||||
| branches-ignore: | ||||||||||||||||||||||||
| - "mvp/**" | ||||||||||||||||||||||||
|
Comment on lines
+15
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid push filters (branches + branches-ignore conflict). Use negative patterns in branches instead of branches-ignore. push:
tags:
- "**"
branches:
- - main
- - master
- branches-ignore:
- - "mvp/**"
+ - main
+ - master
+ - '!mvp/**'📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.7)17-17: both "branches" and "branches-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns (events) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| syntax = "proto3"; | ||
| package bitsong.nft.v1beta1; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buf: missing dependency for gogoproto; build will fail. Add gogoproto to buf deps or vendor third_party/proto/gogoproto/gogo.proto. Add to buf.yaml: version: v2
deps:
- buf.build/cosmos/gogo-protoIf you also rely on google/cosmos imports elsewhere, include:
🧰 Tools🪛 Buf (1.55.1)4-4: import "gogoproto/gogo.proto": file does not exist (COMPILE) 🤖 Prompt for AI Agents |
||
|
|
||
| option go_package = "github.com/bitsongofficial/go-bitsong/x/nft/types"; | ||
|
|
||
| message Collection { | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string denom = 1; | ||
|
|
||
| string symbol = 2; | ||
| string name = 3; | ||
| string description = 4; | ||
| string uri = 5; | ||
|
|
||
| string creator = 6; | ||
| string minter = 7; | ||
| uint64 num_tokens = 8; | ||
| // bool is_mutable | ||
| // update_autority (who can update name, description and uri if is_mutable = true) | ||
| } | ||
|
|
||
| message Nft { | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| string token_id = 2; | ||
|
|
||
| string name = 3; | ||
| string description = 4; | ||
| string uri = 5; | ||
|
|
||
| string owner = 6; | ||
|
|
||
| // TODO: add max_editions | ||
| uint64 editions = 7; // number of printed editions | ||
|
|
||
| // seller_fee_bps | ||
| // payment_address | ||
| // bool is_mutable | ||
| // update_autority (who can update name, description and uri if is_mutable = true) | ||
| } | ||
|
|
||
| message Edition { | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| string token_id = 2; | ||
|
|
||
| uint64 seq = 3; // seq is the edition number | ||
|
|
||
| string owner = 4; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| syntax = "proto3"; | ||
| package bitsong.nft.v1beta1; | ||
|
|
||
| import "gogoproto/gogo.proto"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buf: missing dependency for gogoproto; build will fail. Same as nft.proto: add gogoproto (and likely googleapis/cosmos) to buf deps or vendor the files. Add to buf.yaml: version: v2
deps:
- buf.build/cosmos/gogo-proto
- buf.build/googleapis/googleapis
- buf.build/cosmos/cosmos-proto
- buf.build/cosmos/cosmos-sdk🧰 Tools🪛 Buf (1.55.1)4-4: import "gogoproto/gogo.proto": file does not exist (COMPILE) 🤖 Prompt for AI Agents |
||
| import "google/api/annotations.proto"; | ||
| import "cosmos/query/v1/query.proto"; | ||
| import "cosmos/base/query/v1beta1/pagination.proto"; | ||
| import "bitsong/nft/v1beta1/nft.proto"; | ||
|
Comment on lines
+4
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buf build will fail: missing gogoproto (and likely cosmos/google) deps Add deps to buf.yaml (or vendor). Example buf.yaml: version: v2
deps:
- buf.build/cosmos/gogo-proto
- buf.build/googleapis/googleapis
- buf.build/cosmos/cosmos-proto
- buf.build/cosmos/cosmos-sdkThen:
🧰 Tools🪛 Buf (1.55.1)4-4: import "gogoproto/gogo.proto": file does not exist (COMPILE) 🤖 Prompt for AI Agents |
||
|
|
||
| option go_package = "github.com/bitsongofficial/go-bitsong/x/nft/types"; | ||
|
|
||
| service Query { | ||
| rpc Collection(QueryCollectionRequest) returns (QueryCollectionResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}"; | ||
| } | ||
|
|
||
| // TODO: rpc AllCollections(QueryAllCollectionsRequest) returns (QueryAllCollectionsResponse)..... | ||
|
|
||
| rpc OwnerOf(QueryOwnerOfRequest) returns (QueryOwnerOfResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/{token_id}/owner"; | ||
| } | ||
|
|
||
| rpc NumTokens(QueryNumTokensRequest) returns (QueryNumTokensResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/num_tokens"; | ||
| } | ||
|
|
||
| rpc NftInfo(QueryNftInfoRequest) returns (QueryNftInfoResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/{token_id}"; | ||
| } | ||
|
|
||
| rpc Nfts(QueryNftsRequest) returns (QueryNftsResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/collections/{collection}/nfts"; | ||
| } | ||
|
|
||
| rpc AllNftsByOwner(QueryAllNftsByOwnerRequest) returns (QueryAllNftsByOwnerResponse) { | ||
| option (cosmos.query.v1.module_query_safe) = true; | ||
| option (google.api.http).get = "/bitsong/nft/v1beta1/nfts_by_owner/{owner}"; | ||
| } | ||
| } | ||
|
|
||
| message QueryCollectionRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| } | ||
|
|
||
| message QueryCollectionResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| bitsong.nft.v1beta1.Collection collection = 1; | ||
| } | ||
|
|
||
| message QueryOwnerOfRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| string token_id = 2; | ||
| } | ||
|
|
||
| message QueryOwnerOfResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string owner = 1; | ||
| } | ||
|
|
||
| message QueryNumTokensRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| } | ||
|
|
||
| message QueryNumTokensResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| uint64 count = 1; | ||
| } | ||
|
|
||
| message QueryNftInfoRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
| string token_id = 2; | ||
| } | ||
|
|
||
| message QueryNftInfoResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| bitsong.nft.v1beta1.Nft nft = 1; | ||
| } | ||
|
|
||
| message QueryNftsRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string collection = 1; | ||
|
|
||
| cosmos.base.query.v1beta1.PageRequest pagination = 2; | ||
| } | ||
|
|
||
| message QueryNftsResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| repeated bitsong.nft.v1beta1.Nft nfts = 1 [ | ||
| (gogoproto.nullable) = false | ||
| ]; | ||
|
|
||
| cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
| } | ||
|
|
||
| message QueryAllNftsByOwnerRequest { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| string owner = 1; | ||
|
|
||
| cosmos.base.query.v1beta1.PageRequest pagination = 2; | ||
| } | ||
|
|
||
| message QueryAllNftsByOwnerResponse { | ||
| option (gogoproto.equal) = false; | ||
| option (gogoproto.goproto_getters) = false; | ||
|
|
||
| repeated bitsong.nft.v1beta1.Nft nfts = 1 [ | ||
| (gogoproto.nullable) = false | ||
| ]; | ||
|
|
||
| cosmos.base.query.v1beta1.PageResponse pagination = 2; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package cosmos.query.v1; | ||
|
|
||
| import "google/protobuf/descriptor.proto"; | ||
|
|
||
| // TODO: once we fully migrate to protov2 the go_package needs to be updated. | ||
| // We need this right now because gogoproto codegen needs to import the extension. | ||
| option go_package = "github.com/cosmos/cosmos-sdk/types/query"; | ||
|
|
||
| extend google.protobuf.MethodOptions { | ||
| // module_query_safe is set to true when the query is safe to be called from | ||
| // within the state machine, for example from another module's Keeper, via | ||
| // ADR-033 calls or from CosmWasm contracts. | ||
| // Concretely, it means that the query is: | ||
| // 1. deterministic: given a block height, returns the exact same response | ||
| // upon multiple calls; and doesn't introduce any state-machine-breaking | ||
| // changes across SDK patch version. | ||
| // 2. consumes gas correctly. | ||
| // | ||
| // If you are a module developer and want to add this annotation to one of | ||
| // your own queries, please make sure that the corresponding query: | ||
| // 1. is deterministic and won't introduce state-machine-breaking changes | ||
| // without a coordinated upgrade path, | ||
| // 2. has its gas tracked, to avoid the attack vector where no gas is | ||
| // accounted for on potentially high-computation queries. | ||
| // | ||
| // For queries that potentially consume a large amount of gas (for example | ||
| // those with pagination, if the pagination field is incorrectly set), we | ||
| // also recommend adding Protobuf comments to warn module developers | ||
| // consuming these queries. | ||
| // | ||
| // When set to true, the query can safely be called | ||
| bool module_query_safe = 11110001; | ||
| } |
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.
Fix invalid pull_request filters (branches + branches-ignore are mutually exclusive).
actionlint flags this; GitHub Actions ignores one set unpredictably. Also note: pull_request filters apply to base branch, not head. To exclude PRs from mvp/** heads, drop branches-ignore here and gate jobs with an if condition.
Apply this diff to the trigger:
Then add a job-level guard to skip PRs whose head starts with mvp/ (outside this hunk):
🧰 Tools
🪛 actionlint (1.7.7)
8-8: both "branches" and "branches-ignore" filters cannot be used for the same event "pull_request". note: use '!' to negate patterns
(events)
🤖 Prompt for AI Agents