From 7459e31d065285058a8e2b823301950164b6656c Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Fri, 13 Mar 2026 14:20:10 +0900 Subject: [PATCH 1/5] feat(proto): publish protos on BSR and npmjs --- .github/workflows/proto.yml | 77 +++++++++++++++++++ proto/buf.gen.es.yaml | 7 ++ proto/buf.md | 19 +++++ proto/buf.yaml | 6 +- .../applications/nft_transfer/v1/packet.proto | 2 - proto/initia/abcipp/mempool/v1/query.proto | 35 ++++----- proto/initia/dynamicfee/v1/query.proto | 2 - proto/initia/dynamicfee/v1/types.proto | 1 + proto/initia/reward/v1/tx.proto | 2 +- proto/npm/.gitignore | 13 ++++ proto/npm/package.json | 32 ++++++++ 11 files changed, 170 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/proto.yml create mode 100644 proto/buf.gen.es.yaml create mode 100644 proto/npm/.gitignore create mode 100644 proto/npm/package.json diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml new file mode 100644 index 000000000..0a32b6572 --- /dev/null +++ b/.github/workflows/proto.yml @@ -0,0 +1,77 @@ +name: Protobuf +# Protobuf runs buf (https://buf.build/) fmt, lint and pushes to buf.build +# PR: runs lint and format on proto changes +# Push to main/tags: pushes to BSR + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + paths: + - "proto/**" + +permissions: + contents: write + pull-requests: write + +jobs: + buf-build: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v6 + - uses: bufbuild/buf-action@v1 + with: + input: proto + token: ${{ secrets.BUF_TOKEN }} + breaking: false + + npm-publish: + needs: buf-build + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-node@v6 + with: + node-version: '24' + registry-url: 'https://registry.npmjs.org' + + - uses: bufbuild/buf-setup-action@v1 + + - name: Install protoc-gen-es + run: npm install -g @bufbuild/protoc-gen-es@^2 + + - name: Generate TypeScript from proto + working-directory: proto + run: buf generate . --template buf.gen.es.yaml --include-imports + + - name: Set package version (tag) + if: startsWith(github.ref, 'refs/tags/v') + working-directory: proto/npm + env: + VERSION: ${{ github.ref_name }} + run: npm version "${VERSION#v}" --no-git-tag-version + + - name: Set package version (canary) + if: github.ref == 'refs/heads/main' + working-directory: proto/npm + run: npm version "0.0.0-canary.${GITHUB_SHA::7}" --no-git-tag-version + + - name: Publish (latest) + if: startsWith(github.ref, 'refs/tags/v') + working-directory: proto/npm + run: npm publish --access public + + - name: Publish (canary) + if: github.ref == 'refs/heads/main' + working-directory: proto/npm + run: npm publish --access public --tag canary diff --git a/proto/buf.gen.es.yaml b/proto/buf.gen.es.yaml new file mode 100644 index 000000000..57a139020 --- /dev/null +++ b/proto/buf.gen.es.yaml @@ -0,0 +1,7 @@ +version: v1 +plugins: + - plugin: es + out: npm + opt: + - target=js+dts + - import_extension=js diff --git a/proto/buf.md b/proto/buf.md index 5d63bc5b9..85f6c24c7 100644 --- a/proto/buf.md +++ b/proto/buf.md @@ -1,3 +1,22 @@ # Protobufs This is the public protocol buffers API for the [Initia](https://github.com/initia-labs/initia). + +## npm Package + +TypeScript definitions are published to npm as [`@initia/initia-proto`](https://www.npmjs.com/package/@initia/initia-proto) on every tagged release (`v*`). + +### Installation + +```bash +npm install @initia/initia-proto @bufbuild/protobuf +``` + +### Usage + +```typescript +import { MsgExecuteSchema } from "@initia/initia-proto/initia/move/v1/tx_pb"; +import { MsgDelegateSchema } from "@initia/initia-proto/initia/mstaking/v1/tx_pb"; +``` + +The package requires `@bufbuild/protobuf` v2 as a peer dependency. diff --git a/proto/buf.yaml b/proto/buf.yaml index 9f632374e..0405cff6b 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -13,7 +13,7 @@ breaking: - FILE lint: use: - - DEFAULT + - STANDARD - COMMENTS - FILE_LOWER_SNAKE_CASE except: @@ -24,3 +24,7 @@ lint: - RPC_REQUEST_STANDARD_NAME - ENUM_VALUE_PREFIX - ENUM_ZERO_VALUE_SUFFIX + # excluded to avoid breaking changes on existing fields and RPCs + - FIELD_LOWER_SNAKE_CASE + - RPC_REQUEST_RESPONSE_UNIQUE + - RPC_RESPONSE_STANDARD_NAME diff --git a/proto/ibc/applications/nft_transfer/v1/packet.proto b/proto/ibc/applications/nft_transfer/v1/packet.proto index 9db31fa88..f1c0731e2 100644 --- a/proto/ibc/applications/nft_transfer/v1/packet.proto +++ b/proto/ibc/applications/nft_transfer/v1/packet.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package ibc.applications.nft_transfer.v1; -import "gogoproto/gogo.proto"; - option go_package = "github.com/initia-labs/initia/x/ibc/nft-transfer/types"; // NonFungibleTokenPacketData defines a struct for the packet payload diff --git a/proto/initia/abcipp/mempool/v1/query.proto b/proto/initia/abcipp/mempool/v1/query.proto index 97210d1fd..2b3478ef8 100644 --- a/proto/initia/abcipp/mempool/v1/query.proto +++ b/proto/initia/abcipp/mempool/v1/query.proto @@ -1,26 +1,21 @@ syntax = "proto3"; package initia.abcipp.mempool.v1; -option go_package = "github.com/initia-labs/initia/abcipp/types"; - import "google/api/annotations.proto"; +option go_package = "github.com/initia-labs/initia/abcipp/types"; // Query provides defines the gRPC querier service service Query { - // QueryTxDistribution returns the distribution of transactions in the mempool. - rpc QueryTxDistribution(QueryTxDistributionRequest) returns (QueryTxDistributionResponse) { - option (google.api.http) = { - get: "/initia/abcipp/mempool/v1/distribution" - }; - } - - // QueryTxHash checks if a transaction is in the mempool. - rpc QueryTxHash(QueryTxHashRequest) returns (QueryTxHashResponse) { - option (google.api.http) = { - get: "/initia/abcipp/mempool/v1/{sender}/{sequence}" - }; - } + // QueryTxDistribution returns the distribution of transactions in the mempool. + rpc QueryTxDistribution(QueryTxDistributionRequest) returns (QueryTxDistributionResponse) { + option (google.api.http) = {get: "/initia/abcipp/mempool/v1/distribution"}; + } + + // QueryTxHash checks if a transaction is in the mempool. + rpc QueryTxHash(QueryTxHashRequest) returns (QueryTxHashResponse) { + option (google.api.http) = {get: "/initia/abcipp/mempool/v1/{sender}/{sequence}"}; + } } // QueryTxDistributionRequest is the request type for the Query.QueryTxDistribution @@ -30,19 +25,19 @@ message QueryTxDistributionRequest {} // QueryTxDistributionResponse is the response type for the Query.QueryTxDistribution // RPC method. message QueryTxDistributionResponse { - // Distribution is a map of lane to the number of transactions in the mempool for that lane. - map distribution = 1; + // Distribution is a map of lane to the number of transactions in the mempool for that lane. + map distribution = 1; } // QueryTxHashRequest is the request type for the Query.QueryTxHash // RPC method. message QueryTxHashRequest { - string sender = 1; - string sequence = 2; + string sender = 1; + string sequence = 2; } // QueryTxHashResponse is the response type for the Query.QueryTxHash // RPC method. message QueryTxHashResponse { - string txHash = 1; + string txHash = 1; } diff --git a/proto/initia/dynamicfee/v1/query.proto b/proto/initia/dynamicfee/v1/query.proto index 35833e64e..2b59dca34 100644 --- a/proto/initia/dynamicfee/v1/query.proto +++ b/proto/initia/dynamicfee/v1/query.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package initia.dynamicfee.v1; -import "amino/amino.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "initia/dynamicfee/v1/types.proto"; diff --git a/proto/initia/dynamicfee/v1/types.proto b/proto/initia/dynamicfee/v1/types.proto index 40387017f..147ce32a9 100644 --- a/proto/initia/dynamicfee/v1/types.proto +++ b/proto/initia/dynamicfee/v1/types.proto @@ -9,6 +9,7 @@ option go_package = "github.com/initia-labs/initia/x/dynamic-fee/types"; option (gogoproto.equal_all) = true; option (gogoproto.goproto_getters_all) = false; +// Params defines the parameters for the dynamicfee module. message Params { string base_gas_price = 1 [ (gogoproto.moretags) = "yaml:\"base_gas_price\"", diff --git a/proto/initia/reward/v1/tx.proto b/proto/initia/reward/v1/tx.proto index a824c5a84..4fa06d371 100644 --- a/proto/initia/reward/v1/tx.proto +++ b/proto/initia/reward/v1/tx.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package initia.reward.v1; import "amino/amino.proto"; -import "cosmos/msg/v1/msg.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "initia/reward/v1/types.proto"; diff --git a/proto/npm/.gitignore b/proto/npm/.gitignore new file mode 100644 index 000000000..5db2cc9d9 --- /dev/null +++ b/proto/npm/.gitignore @@ -0,0 +1,13 @@ +node_modules/ +package-lock.json +# protoc-gen-es output (generated by buf generate) +*.js +*.d.ts +amino/ +cosmos/ +cosmos_proto/ +gogoproto/ +google/ +ibc/ +initia/ +tendermint/ diff --git a/proto/npm/package.json b/proto/npm/package.json new file mode 100644 index 000000000..6b7a06c69 --- /dev/null +++ b/proto/npm/package.json @@ -0,0 +1,32 @@ +{ + "name": "@initia/initia-proto", + "version": "0.0.0", + "description": "Protocol Buffers TypeScript definitions for Initia", + "type": "module", + "sideEffects": false, + "files": [ + "initia", + "ibc", + "amino", + "cosmos", + "cosmos_proto", + "gogoproto", + "google", + "tendermint" + ], + "engines": { + "node": ">=22" + }, + "keywords": ["protobuf", "initia", "cosmos"], + "homepage": "https://github.com/initia-labs/initia/tree/main/proto/npm", + "bugs": "https://github.com/initia-labs/initia/issues", + "peerDependencies": { + "@bufbuild/protobuf": "^2.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/initia-labs/initia.git", + "directory": "proto/npm" + }, + "license": "Apache-2.0" +} From 6af9c45c51653d5948abd8611bc54df49936f594 Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Fri, 13 Mar 2026 16:34:02 +0900 Subject: [PATCH 2/5] feat(proto): include full cosmos-sdk and ibc types in npm package --- .github/workflows/proto.yml | 7 ++++++- proto/npm/.gitignore | 1 + proto/npm/package.json | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 0a32b6572..1ea99ef45 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -52,7 +52,12 @@ jobs: - name: Generate TypeScript from proto working-directory: proto - run: buf generate . --template buf.gen.es.yaml --include-imports + run: | + COSMOS_SDK=$(awk '/repository: cosmos-sdk/{getline; print $2}' buf.lock) + IBC=$(awk '/repository: ibc/{getline; print $2}' buf.lock) + buf generate "buf.build/cosmos/cosmos-sdk:${COSMOS_SDK}" --template buf.gen.es.yaml + buf generate "buf.build/cosmos/ibc:${IBC}" --template buf.gen.es.yaml + buf generate . --template buf.gen.es.yaml --include-imports - name: Set package version (tag) if: startsWith(github.ref, 'refs/tags/v') diff --git a/proto/npm/.gitignore b/proto/npm/.gitignore index 5db2cc9d9..146b0c31d 100644 --- a/proto/npm/.gitignore +++ b/proto/npm/.gitignore @@ -4,6 +4,7 @@ package-lock.json *.js *.d.ts amino/ +capability/ cosmos/ cosmos_proto/ gogoproto/ diff --git a/proto/npm/package.json b/proto/npm/package.json index 6b7a06c69..fecb5a107 100644 --- a/proto/npm/package.json +++ b/proto/npm/package.json @@ -7,6 +7,7 @@ "files": [ "initia", "ibc", + "capability", "amino", "cosmos", "cosmos_proto", @@ -17,7 +18,11 @@ "engines": { "node": ">=22" }, - "keywords": ["protobuf", "initia", "cosmos"], + "keywords": [ + "protobuf", + "initia", + "cosmos" + ], "homepage": "https://github.com/initia-labs/initia/tree/main/proto/npm", "bugs": "https://github.com/initia-labs/initia/issues", "peerDependencies": { From 90e49c019266bdfd20838037c8b84b09ec2b5603 Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Fri, 13 Mar 2026 16:51:33 +0900 Subject: [PATCH 3/5] chore fix --- .github/workflows/proto.yml | 1 + proto/buf.md | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 1ea99ef45..219311439 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -12,6 +12,7 @@ on: pull_request: paths: - "proto/**" + - ".github/workflows/proto.yml" permissions: contents: write diff --git a/proto/buf.md b/proto/buf.md index 85f6c24c7..5530d8557 100644 --- a/proto/buf.md +++ b/proto/buf.md @@ -4,7 +4,10 @@ This is the public protocol buffers API for the [Initia](https://github.com/init ## npm Package -TypeScript definitions are published to npm as [`@initia/initia-proto`](https://www.npmjs.com/package/@initia/initia-proto) on every tagged release (`v*`). +TypeScript definitions are published to npm as [`@initia/initia-proto`](https://www.npmjs.com/package/@initia/initia-proto). + +- **Tagged releases** (`v*`) are published as `latest` (e.g. `1.0.0`). +- **Main branch** pushes are published as `canary` (e.g. `0.0.0-canary.`). ### Installation From 03f482e55e7ac96773864e769480067cc7d5bee5 Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Fri, 13 Mar 2026 18:06:22 +0900 Subject: [PATCH 4/5] fix: add missing ics23 on npm publish action --- .github/workflows/proto.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 219311439..8ab8fdb5a 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -56,8 +56,10 @@ jobs: run: | COSMOS_SDK=$(awk '/repository: cosmos-sdk/{getline; print $2}' buf.lock) IBC=$(awk '/repository: ibc/{getline; print $2}' buf.lock) + ICS23=$(awk '/repository: ics23/{getline; print $2}' buf.lock) buf generate "buf.build/cosmos/cosmos-sdk:${COSMOS_SDK}" --template buf.gen.es.yaml buf generate "buf.build/cosmos/ibc:${IBC}" --template buf.gen.es.yaml + buf generate "buf.build/cosmos/ics23:${ICS23}" --template buf.gen.es.yaml buf generate . --template buf.gen.es.yaml --include-imports - name: Set package version (tag) From 64b3a55a6e45448dc10f5e2bd1b313d55df84e5e Mon Sep 17 00:00:00 2001 From: Geoff Lee Date: Mon, 16 Mar 2026 19:06:17 +0900 Subject: [PATCH 5/5] refactor: simplify proto workflow, remove npm publishing --- .github/workflows/proto.yml | 64 ++++--------------------------------- proto/buf.gen.es.yaml | 7 ---- proto/buf.md | 22 ------------- proto/npm/.gitignore | 14 -------- proto/npm/package.json | 37 --------------------- 5 files changed, 6 insertions(+), 138 deletions(-) delete mode 100644 proto/buf.gen.es.yaml delete mode 100644 proto/npm/.gitignore delete mode 100644 proto/npm/package.json diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 8ab8fdb5a..2c82ff47b 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -1,7 +1,8 @@ name: Protobuf -# Protobuf runs buf (https://buf.build/) fmt, lint and pushes to buf.build -# PR: runs lint and format on proto changes +# Runs buf (https://buf.build/) checks and pushes to BSR +# PR: runs lint, format, and breaking change detection # Push to main/tags: pushes to BSR +# Delete branch/tag: archives corresponding BSR labels on: push: @@ -13,9 +14,10 @@ on: paths: - "proto/**" - ".github/workflows/proto.yml" + delete: permissions: - contents: write + contents: read pull-requests: write jobs: @@ -28,58 +30,4 @@ jobs: with: input: proto token: ${{ secrets.BUF_TOKEN }} - breaking: false - - npm-publish: - needs: buf-build - if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - timeout-minutes: 10 - permissions: - contents: read - id-token: write - steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-node@v6 - with: - node-version: '24' - registry-url: 'https://registry.npmjs.org' - - - uses: bufbuild/buf-setup-action@v1 - - - name: Install protoc-gen-es - run: npm install -g @bufbuild/protoc-gen-es@^2 - - - name: Generate TypeScript from proto - working-directory: proto - run: | - COSMOS_SDK=$(awk '/repository: cosmos-sdk/{getline; print $2}' buf.lock) - IBC=$(awk '/repository: ibc/{getline; print $2}' buf.lock) - ICS23=$(awk '/repository: ics23/{getline; print $2}' buf.lock) - buf generate "buf.build/cosmos/cosmos-sdk:${COSMOS_SDK}" --template buf.gen.es.yaml - buf generate "buf.build/cosmos/ibc:${IBC}" --template buf.gen.es.yaml - buf generate "buf.build/cosmos/ics23:${ICS23}" --template buf.gen.es.yaml - buf generate . --template buf.gen.es.yaml --include-imports - - - name: Set package version (tag) - if: startsWith(github.ref, 'refs/tags/v') - working-directory: proto/npm - env: - VERSION: ${{ github.ref_name }} - run: npm version "${VERSION#v}" --no-git-tag-version - - - name: Set package version (canary) - if: github.ref == 'refs/heads/main' - working-directory: proto/npm - run: npm version "0.0.0-canary.${GITHUB_SHA::7}" --no-git-tag-version - - - name: Publish (latest) - if: startsWith(github.ref, 'refs/tags/v') - working-directory: proto/npm - run: npm publish --access public - - - name: Publish (canary) - if: github.ref == 'refs/heads/main' - working-directory: proto/npm - run: npm publish --access public --tag canary + # breaking defaults to PR-only; not set explicitly to avoid running on push events diff --git a/proto/buf.gen.es.yaml b/proto/buf.gen.es.yaml deleted file mode 100644 index 57a139020..000000000 --- a/proto/buf.gen.es.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: v1 -plugins: - - plugin: es - out: npm - opt: - - target=js+dts - - import_extension=js diff --git a/proto/buf.md b/proto/buf.md index 5530d8557..5d63bc5b9 100644 --- a/proto/buf.md +++ b/proto/buf.md @@ -1,25 +1,3 @@ # Protobufs This is the public protocol buffers API for the [Initia](https://github.com/initia-labs/initia). - -## npm Package - -TypeScript definitions are published to npm as [`@initia/initia-proto`](https://www.npmjs.com/package/@initia/initia-proto). - -- **Tagged releases** (`v*`) are published as `latest` (e.g. `1.0.0`). -- **Main branch** pushes are published as `canary` (e.g. `0.0.0-canary.`). - -### Installation - -```bash -npm install @initia/initia-proto @bufbuild/protobuf -``` - -### Usage - -```typescript -import { MsgExecuteSchema } from "@initia/initia-proto/initia/move/v1/tx_pb"; -import { MsgDelegateSchema } from "@initia/initia-proto/initia/mstaking/v1/tx_pb"; -``` - -The package requires `@bufbuild/protobuf` v2 as a peer dependency. diff --git a/proto/npm/.gitignore b/proto/npm/.gitignore deleted file mode 100644 index 146b0c31d..000000000 --- a/proto/npm/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -node_modules/ -package-lock.json -# protoc-gen-es output (generated by buf generate) -*.js -*.d.ts -amino/ -capability/ -cosmos/ -cosmos_proto/ -gogoproto/ -google/ -ibc/ -initia/ -tendermint/ diff --git a/proto/npm/package.json b/proto/npm/package.json deleted file mode 100644 index fecb5a107..000000000 --- a/proto/npm/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@initia/initia-proto", - "version": "0.0.0", - "description": "Protocol Buffers TypeScript definitions for Initia", - "type": "module", - "sideEffects": false, - "files": [ - "initia", - "ibc", - "capability", - "amino", - "cosmos", - "cosmos_proto", - "gogoproto", - "google", - "tendermint" - ], - "engines": { - "node": ">=22" - }, - "keywords": [ - "protobuf", - "initia", - "cosmos" - ], - "homepage": "https://github.com/initia-labs/initia/tree/main/proto/npm", - "bugs": "https://github.com/initia-labs/initia/issues", - "peerDependencies": { - "@bufbuild/protobuf": "^2.0.0" - }, - "repository": { - "type": "git", - "url": "https://github.com/initia-labs/initia.git", - "directory": "proto/npm" - }, - "license": "Apache-2.0" -}