Skip to content

Commit

Permalink
refactor: move all module.proto's to the kyve folder
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Apr 10, 2024
1 parent b5e9dd0 commit b6bbe88
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 631 deletions.
51 changes: 35 additions & 16 deletions proto/generate.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/sh

# Cleanup and error
cleanup_and_error() {
rm -rf tmp-gen
rm -rf tmp-gen-pulsar
rm -rf tmp-swagger-gen
exit 1
}
# Find all proto files in the kyve directory except for module.proto's
protos=$(cd proto && find kyve -name '*.proto' -not -name 'module.proto')

# Transform the proto files into a comma separated list
proto_list=$(echo $protos | sed 's/ /,/g')


# Find all module.proto files in the kyve directory
modules=$(cd proto && find kyve -name module.proto)

# Transform the module.proto files into a comma separated list
module_list=$(echo $modules | sed 's/ /,/g')

# Cleanup
cleanup() {
Expand All @@ -15,26 +20,40 @@ cleanup() {
rm -rf tmp-swagger-gen
}

# Generate proto files
generate_proto() {
$(cd proto && buf generate --template buf.gen.gogo.yaml --path kyve) || cleanup_and_error
# Cleanup and error
cleanup_and_error() {
cleanup
exit 1
}

# Generate gogo proto files
generate_gogo_proto() {
# Generate proto files
$(cd proto && buf generate -v --template buf.gen.gogo.yaml --path $proto_list) || cleanup_and_error

# Copy the generated proto files to the x/ directory
cp -r tmp-gen/github.com/KYVENetwork/chain/* ./
}

# Generate module proto files
generate_module_proto() {
$(cd proto && buf generate --template buf.gen.pulsar.yaml --path modules) || cleanup_and_error
cp -r tmp-gen-pulsar/modules/* ./x
generate_pulsar_proto() {
# Generate proto files
$(cd proto && buf generate --template buf.gen.pulsar.yaml --path $module_list) || cleanup_and_error

# Copy the generated proto files to the x/ directory
cp -r tmp-gen-pulsar/kyve/* ./x
}

# Generate openapi docs
generate_docs() {
$(cd proto && buf generate --template buf.gen.swagger.yaml --path kyve) || cleanup_and_error
# Generate swagger files
$(cd proto && buf generate --template buf.gen.swagger.yaml --path $proto_list) || cleanup_and_error

# Combine the swagger files
swagger-combine ./docs/config.json -o ./docs/static/openapi.yml
}

generate_proto
generate_module_proto
generate_gogo_proto
generate_pulsar_proto
generate_docs
cleanup
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.bundles.types;
package kyve.bundles.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.delegation.types;
package kyve.delegation.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.funders.types;
package kyve.funders.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.global.types;
package kyve.global.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.pool.types;
package kyve.pool.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.query.types;
package kyve.query.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.stakers.types;
package kyve.stakers.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package modules.team.types;
package kyve.team.types;

import "cosmos/app/v1alpha1/module.proto";

Expand Down
Loading

0 comments on commit b6bbe88

Please sign in to comment.