Skip to content

Commit

Permalink
add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jun 21, 2024
1 parent b1dc7ff commit 635e110
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [2319](https://github.com/zeta-chain/node/pull/2319) - use `CheckAuthorization` function in all messages
* [2325](https://github.com/zeta-chain/node/pull/2325) - revert telemetry server changes
* [2339](https://github.com/zeta-chain/node/pull/2339) - add binaries related question to syncing issue form
* [2372](https://github.com/zeta-chain/node/pull/2372) - add queries for tss fund migration info

### Refactor

Expand Down
1 change: 1 addition & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30172,6 +30172,7 @@ paths:
- Query
/zeta-chain/observer/get_all_tss_fund_migrators:
get:
summary: Queries all TssFundMigratorInfo
operationId: Query_TssFundsMigratorInfoAll
responses:
"200":
Expand Down
1 change: 1 addition & 0 deletions proto/zetachain/zetacore/observer/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ service Query {
option (google.api.http).get = "/zeta-chain/observer/get_tss_fund_migrator";
}

// Queries all TssFundMigratorInfo
rpc TssFundsMigratorInfoAll(QueryTssFundsMigratorInfoAllRequest)
returns (QueryTssFundsMigratorInfoAllResponse) {
option (google.api.http).get =
Expand Down
11 changes: 9 additions & 2 deletions x/observer/client/cli/query_tss_fund_migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"context"
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -14,12 +15,18 @@ func CmdGetTssFundsMigrator() *cobra.Command {
cmd := &cobra.Command{
Use: "show-tss-funds-migrator [chain-id]",
Short: "show the tss funds migrator for a chain",
RunE: func(cmd *cobra.Command, _ []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryTssFundsMigratorInfoRequest{}
chainId, err := strconv.ParseInt(args[0], 10, 64)

Check warning on line 23 in x/observer/client/cli/query_tss_fund_migrator.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: var chainId should be chainID (revive)

Check warning on line 23 in x/observer/client/cli/query_tss_fund_migrator.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: var chainId should be chainID (revive)
if err != nil {
return err
}
params := &types.QueryTssFundsMigratorInfoRequest{
ChainId: chainId,
}

res, err := queryClient.TssFundsMigratorInfo(context.Background(), params)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions x/observer/keeper/grpc_query_tss_funds_migrator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/x/observer/types"
)

Expand All @@ -21,6 +22,10 @@ func (k Keeper) TssFundsMigratorInfo(

ctx := sdk.UnwrapSDKContext(goCtx)

if chains.GetChainFromChainID(req.ChainId) == nil {
return nil, status.Error(codes.InvalidArgument, "invalid chain id")
}

fm, found := k.GetFundMigrator(ctx, req.ChainId)
if !found {
return nil, status.Error(codes.NotFound, "tss fund migrator not found")
Expand Down
21 changes: 17 additions & 4 deletions x/observer/keeper/grpc_query_tss_funds_migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,29 @@ func TestKeeper_TssFundsMigratorInfo(t *testing.T) {
wctx := sdk.WrapSDKContext(ctx)

res, err := k.TssFundsMigratorInfo(wctx, nil)
require.Error(t, err)
require.ErrorContains(t, err, "invalid request")
require.Nil(t, res)
})

t.Run("should error if chain id is invalid", func(t *testing.T) {
k, ctx, _, _ := keepertest.ObserverKeeper(t)
wctx := sdk.WrapSDKContext(ctx)

res, err := k.TssFundsMigratorInfo(wctx, &types.QueryTssFundsMigratorInfoRequest{
ChainId: 0,
})
require.ErrorContains(t, err, "invalid chain id")
require.Nil(t, res)
})

t.Run("should error if not found", func(t *testing.T) {
k, ctx, _, _ := keepertest.ObserverKeeper(t)
wctx := sdk.WrapSDKContext(ctx)

res, err := k.TssFundsMigratorInfo(wctx, &types.QueryTssFundsMigratorInfoRequest{})
require.Error(t, err)
res, err := k.TssFundsMigratorInfo(wctx, &types.QueryTssFundsMigratorInfoRequest{
ChainId: chains.Ethereum.ChainId,
})
require.ErrorContains(t, err, "tss fund migrator not found")
require.Nil(t, res)
})

Expand Down Expand Up @@ -56,7 +69,7 @@ func TestKeeper_TssFundsMigratorInfoAll(t *testing.T) {
wctx := sdk.WrapSDKContext(ctx)

res, err := k.TssFundsMigratorInfoAll(wctx, nil)
require.Error(t, err)
require.ErrorContains(t, err, "invalid request")
require.Nil(t, res)
})

Expand Down
2 changes: 2 additions & 0 deletions x/observer/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 635e110

Please sign in to comment.