diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8ac29daa5..6af19e499 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -51,6 +51,24 @@ jobs: version: v1.47 args: --config .github/linters/.golangci.yaml + proto-lint: + name: "Protobuf" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # Install the `buf` CLI + - uses: bufbuild/buf-setup-action@v1.8.0 + + # Lint + - uses: bufbuild/buf-lint-action@v1 + + # Breaking change detection + - uses: bufbuild/buf-breaking-action@v1 + with: + input: 'proto' + against: 'https://github.com/cheqd/cheqd-node.git#branch=develop,ref=HEAD~1,subdir=proto' + super-lint: name: "Super Linter" runs-on: ubuntu-latest @@ -59,7 +77,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Required to fetch version - + - name: Run Super Linter uses: github/super-linter/slim@v4 env: diff --git a/proto/buf.yaml b/proto/buf.yaml index 9020e62f4..7ef72dd47 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -13,11 +13,17 @@ deps: breaking: use: - FILE + ignore: + - cheqd/v1 + - resource/v1 lint: + ignore: + - cheqd/did/v1 + - cheqd/resource/v1 use: - DEFAULT - - COMMENTS except: - SERVICE_SUFFIX - RPC_REQUEST_STANDARD_NAME + - RPC_RESPONSE_STANDARD_NAME diff --git a/proto/cheqd/v1/common.proto b/proto/cheqd/did/v1/common.proto similarity index 100% rename from proto/cheqd/v1/common.proto rename to proto/cheqd/did/v1/common.proto diff --git a/proto/cheqd/v1/did.proto b/proto/cheqd/did/v1/did.proto similarity index 96% rename from proto/cheqd/v1/did.proto rename to proto/cheqd/did/v1/did.proto index bbf3b98ea..b82930958 100644 --- a/proto/cheqd/v1/did.proto +++ b/proto/cheqd/did/v1/did.proto @@ -4,7 +4,7 @@ package cheqdid.cheqdnode.cheqd.v1; option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types"; import "google/protobuf/any.proto"; -import "cheqd/v1/common.proto"; +import "cheqd/did/v1/common.proto"; message Did { repeated string context = 1; // optional diff --git a/proto/cheqd/v1/genesis.proto b/proto/cheqd/did/v1/genesis.proto similarity index 87% rename from proto/cheqd/v1/genesis.proto rename to proto/cheqd/did/v1/genesis.proto index 54981ddf1..4dddc9e8e 100644 --- a/proto/cheqd/v1/genesis.proto +++ b/proto/cheqd/did/v1/genesis.proto @@ -3,7 +3,7 @@ package cheqdid.cheqdnode.cheqd.v1; option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types"; -import "cheqd/v1/stateValue.proto"; +import "cheqd/did/v1/stateValue.proto"; // GenesisState defines the cheqd module's genesis state. message GenesisState { diff --git a/proto/cheqd/v1/query.proto b/proto/cheqd/did/v1/query.proto similarity index 86% rename from proto/cheqd/v1/query.proto rename to proto/cheqd/did/v1/query.proto index 785ba0d17..2af14e720 100644 --- a/proto/cheqd/v1/query.proto +++ b/proto/cheqd/did/v1/query.proto @@ -4,8 +4,8 @@ package cheqdid.cheqdnode.cheqd.v1; option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types"; import "google/api/annotations.proto"; -import "cheqd/v1/did.proto"; -import "cheqd/v1/stateValue.proto"; +import "cheqd/did/v1/did.proto"; +import "cheqd/did/v1/stateValue.proto"; // Query defines the gRPC querier service. diff --git a/proto/cheqd/v1/stateValue.proto b/proto/cheqd/did/v1/stateValue.proto similarity index 100% rename from proto/cheqd/v1/stateValue.proto rename to proto/cheqd/did/v1/stateValue.proto diff --git a/proto/cheqd/v1/tx.proto b/proto/cheqd/did/v1/tx.proto similarity index 96% rename from proto/cheqd/v1/tx.proto rename to proto/cheqd/did/v1/tx.proto index c86fd6759..bf58bd8f5 100644 --- a/proto/cheqd/v1/tx.proto +++ b/proto/cheqd/did/v1/tx.proto @@ -4,8 +4,8 @@ package cheqdid.cheqdnode.cheqd.v1; option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types"; import "google/protobuf/any.proto"; -import "cheqd/v1/did.proto"; -import "cheqd/v1/stateValue.proto"; +import "cheqd/did/v1/did.proto"; +import "cheqd/did/v1/stateValue.proto"; // Msg defines the Msg service. service Msg { diff --git a/proto/cheqd/did/v2/diddoc.proto b/proto/cheqd/did/v2/diddoc.proto new file mode 100644 index 000000000..9acceb7d8 --- /dev/null +++ b/proto/cheqd/did/v2/diddoc.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package cheqd.did.v2; + +option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types/v2"; + +message DidDoc { + repeated string context = 1; + string id = 2; + repeated string controller = 3; + repeated VerificationMethod verification_method = 4; + repeated string authentication = 5; + repeated string assertion_method = 6; + repeated string capability_invocation = 7; + repeated string capability_delegation = 8; + repeated string key_agreement = 9; + repeated Service service = 10; + repeated string also_known_as = 11; +} + +message VerificationMethod { + string id = 1; + string type = 2; + string controller = 3; + string verification_material = 4; +} + +message Service { + string id = 1; + string type = 2; + repeated string service_endpoint = 3; +} + +message DidDocWithMetadata { + DidDoc did_doc = 1; + Metadata metadata = 2; +} + +message Metadata { + string created = 1; + string updated = 2; + bool deactivated = 3; + string version_id = 4; + string next_version_id = 5; + string previous_version_id = 6; +} diff --git a/proto/cheqd/did/v2/fee.proto b/proto/cheqd/did/v2/fee.proto new file mode 100644 index 000000000..fd5622f0d --- /dev/null +++ b/proto/cheqd/did/v2/fee.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package cheqd.did.v2; + +option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types/v2"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; + +// FeeParams defines the parameters for the `did` module fixed fee. +message FeeParams { + // Tx types define the fixed fee each for the `did` module. + map tx_types = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"tx_types\"" + ]; + string burn_factor = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/cheqd/did/v2/genesis.proto b/proto/cheqd/did/v2/genesis.proto new file mode 100644 index 000000000..4886f1f1c --- /dev/null +++ b/proto/cheqd/did/v2/genesis.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package cheqd.did.v2; + +import "cheqd/did/v2/diddoc.proto"; +import "cheqd/did/v2/fee.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types/v2"; + +message GenesisState { + string did_namespace = 1; + repeated DidDocWithMetadata did_docs = 2; + FeeParams fee_params = 3; +} diff --git a/proto/cheqd/did/v2/query.proto b/proto/cheqd/did/v2/query.proto new file mode 100644 index 000000000..e820937f0 --- /dev/null +++ b/proto/cheqd/did/v2/query.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package cheqd.did.v2; + +import "google/api/annotations.proto"; +import "cheqd/did/v2/diddoc.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types/v2"; + +service Query { + rpc DidDoc(QueryGetDidDocRequest) returns (QueryGetDidDocResponse) { + option (google.api.http).get = "/cheqd/did/v2/diddoc/{id}"; + } +} + +message QueryGetDidDocRequest { + string id = 1; +} + +message QueryGetDidDocResponse { + DidDocWithMetadata value = 1; +} diff --git a/proto/cheqd/did/v2/tx.proto b/proto/cheqd/did/v2/tx.proto new file mode 100644 index 000000000..53aa37262 --- /dev/null +++ b/proto/cheqd/did/v2/tx.proto @@ -0,0 +1,78 @@ +syntax = "proto3"; + +package cheqd.did.v2; + +import "cheqd/did/v2/diddoc.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/cheqd/types/v2"; + +service Msg { + rpc CreateDidDoc(MsgCreateDidDoc) returns (MsgCreateDidDocResponse); + rpc UpdateDidDoc(MsgUpdateDidDoc) returns (MsgUpdateDidDocResponse); +} + +message MsgCreateDidDoc { + MsgCreateDidDocPayload payload = 1; + repeated SignInfo signatures = 2; +} + +message MsgUpdateDidDoc { + MsgUpdateDidDocPayload payload = 1; + repeated SignInfo signatures = 2; +} + +message MsgDeactivateDid { + MsgDeactivateDidPayload payload = 1; + repeated SignInfo signatures = 2; +} + +message SignInfo { + string verification_method_id = 1; + bytes signature = 2; +} + +message MsgCreateDidDocPayload { + repeated string context = 1; + string id = 2; + repeated string controller = 3; + repeated VerificationMethod verification_method = 4; + repeated string authentication = 5; + repeated string assertion_method = 6; + repeated string capability_invocation = 7; + repeated string capability_delegation = 8; + repeated string key_agreement = 9; + repeated string also_known_as = 10; + repeated Service service = 11; +} + +message MsgCreateDidDocResponse { + DidDocWithMetadata value = 1; +} + +message MsgUpdateDidDocPayload { + repeated string context = 1; + string id = 2; + repeated string controller = 3; + repeated VerificationMethod verification_method = 4; + repeated string authentication = 5; + repeated string assertion_method = 6; + repeated string capability_invocation = 7; + repeated string capability_delegation = 8; + repeated string key_agreement = 9; + repeated string also_known_as = 10; + repeated Service service = 11; + string version_id = 12; +} + +message MsgUpdateDidDocResponse { + DidDocWithMetadata value = 1; +} + +message MsgDeactivateDidPayload { + string id = 1; + string version_id = 2; +} + +message MsgDeactivateDidResponse { + DidDocWithMetadata value = 1; +} diff --git a/proto/resource/v1/genesis.proto b/proto/cheqd/resource/v1/genesis.proto similarity index 85% rename from proto/resource/v1/genesis.proto rename to proto/cheqd/resource/v1/genesis.proto index 0bb62e1de..08628f2b5 100644 --- a/proto/resource/v1/genesis.proto +++ b/proto/cheqd/resource/v1/genesis.proto @@ -3,7 +3,7 @@ package cheqdid.cheqdnode.resource.v1; option go_package = "github.com/cheqd/cheqd-node/x/resource/types"; -import "resource/v1/resource.proto"; +import "cheqd/resource/v1/resource.proto"; // GenesisState defines the cheqd module's genesis state. message GenesisState { diff --git a/proto/resource/v1/query.proto b/proto/cheqd/resource/v1/query.proto similarity index 96% rename from proto/resource/v1/query.proto rename to proto/cheqd/resource/v1/query.proto index 7e09a7064..64d89207d 100644 --- a/proto/resource/v1/query.proto +++ b/proto/cheqd/resource/v1/query.proto @@ -4,7 +4,7 @@ package cheqdid.cheqdnode.resource.v1; option go_package = "github.com/cheqd/cheqd-node/x/resource/types"; import "google/api/annotations.proto"; -import "resource/v1/resource.proto"; +import "cheqd/resource/v1/resource.proto"; // Query defines the gRPC querier service. diff --git a/proto/resource/v1/resource.proto b/proto/cheqd/resource/v1/resource.proto similarity index 100% rename from proto/resource/v1/resource.proto rename to proto/cheqd/resource/v1/resource.proto diff --git a/proto/resource/v1/tx.proto b/proto/cheqd/resource/v1/tx.proto similarity index 90% rename from proto/resource/v1/tx.proto rename to proto/cheqd/resource/v1/tx.proto index 118c6736b..b39ec7ca9 100644 --- a/proto/resource/v1/tx.proto +++ b/proto/cheqd/resource/v1/tx.proto @@ -3,8 +3,8 @@ package cheqdid.cheqdnode.resource.v1; option go_package = "github.com/cheqd/cheqd-node/x/resource/types"; -import "cheqd/v1/tx.proto"; -import "resource/v1/resource.proto"; +import "cheqd/did/v1/tx.proto"; +import "cheqd/resource/v1/resource.proto"; // Msg defines the Msg service. service Msg { diff --git a/proto/cheqd/resource/v2/fee.proto b/proto/cheqd/resource/v2/fee.proto new file mode 100644 index 000000000..807bdf764 --- /dev/null +++ b/proto/cheqd/resource/v2/fee.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package cheqd.resource.v2; + +option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v2"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; + +// FeeParams defines the parameters for the `resource` module fixed fee. +message FeeParams { + // Media types define the fixed fee each for the `resource` module. + map media_types = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"media_types\"" + ]; + string burn_factor = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/cheqd/resource/v2/genesis.proto b/proto/cheqd/resource/v2/genesis.proto new file mode 100644 index 000000000..7ab05f167 --- /dev/null +++ b/proto/cheqd/resource/v2/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package cheqd.resource.v2; + +import "cheqd/resource/v2/resource.proto"; +import "cheqd/resource/v2/fee.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v2"; + +message GenesisState { + repeated ResourceWithMetadata resources = 1; + FeeParams fee_params = 2; +} diff --git a/proto/cheqd/resource/v2/query.proto b/proto/cheqd/resource/v2/query.proto new file mode 100644 index 000000000..dae8b4549 --- /dev/null +++ b/proto/cheqd/resource/v2/query.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package cheqd.resource.v2; + +import "google/api/annotations.proto"; +import "cheqd/resource/v2/resource.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v2"; + +service Query { + rpc Resource(QueryGetResourceRequest) returns (QueryGetResourceResponse) { + option (google.api.http).get = "/cheqd/resource/v2/collection/{collection_id}/resources/{id}"; + } + rpc ResourceMetadata(QueryGetResourceMetadataRequest) returns (QueryGetResourceMetadataResponse) { + option (google.api.http).get = "/cheqd/resource/v2/collection/{collection_id}/resources/{id}/metadata"; + } + rpc CollectionResources(QueryGetCollectionResourcesRequest) returns (QueryGetCollectionResourcesResponse) { + option (google.api.http).get = "/cheqd/resource/v2/collection/{collection_id}/resources"; + } +} + +message QueryGetResourceRequest { + string collection_id = 1; + string id = 2; +} + +message QueryGetResourceResponse { + ResourceWithMetadata resource = 1; +} + +message QueryGetResourceMetadataRequest { + string collection_id = 1; + string id = 2; +} + +message QueryGetResourceMetadataResponse { + Metadata resource = 1; +} + +message QueryGetCollectionResourcesRequest { + string collection_id = 1; +} + +message QueryGetCollectionResourcesResponse { + repeated Metadata resources = 1; +} diff --git a/proto/cheqd/resource/v2/resource.proto b/proto/cheqd/resource/v2/resource.proto new file mode 100644 index 000000000..5b7510c8d --- /dev/null +++ b/proto/cheqd/resource/v2/resource.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package cheqd.resource.v2; + +option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v2"; + +message Resource { + bytes data = 1; +} + +message ResourceWithMetadata { + Resource resource = 1; + Metadata metadata = 2; +} + +message Metadata { + string collection_id = 1; + string id = 2; + string name = 3; + string version = 4; + string resource_type = 5; + repeated string also_known_as = 6; + + string media_type = 7; + string created = 8; + bytes checksum = 9; + string previous_version_id = 10; + string next_version_id = 11; +} diff --git a/proto/cheqd/resource/v2/tx.proto b/proto/cheqd/resource/v2/tx.proto new file mode 100644 index 000000000..67abcb122 --- /dev/null +++ b/proto/cheqd/resource/v2/tx.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package cheqd.resource.v2; + +import "cheqd/did/v2/tx.proto"; +import "cheqd/resource/v2/resource.proto"; + +option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v2"; + +// Msg defines the Msg service. +service Msg { + rpc CreateResource(MsgCreateResource) returns (MsgCreateResourceResponse); +} + +message MsgCreateResource { + MsgCreateResourcePayload payload = 1; + repeated cheqd.did.v2.SignInfo signatures = 2; +} + +message MsgCreateResourcePayload { + string collection_id = 1; + string id = 2; + string name = 3; + string version = 4; + string resource_type = 5; + repeated string also_known_as = 6; +} + +message MsgCreateResourceResponse { + Metadata resource = 1; +}