From e079c6f513b74e5e4ffc20ec73a57a24929697eb Mon Sep 17 00:00:00 2001 From: p0p3yee Date: Thu, 6 Jul 2023 10:43:44 -0400 Subject: [PATCH 1/3] Add allow validator authorize addr to submit key share --- .../keyshare/authorized_address.proto | 11 + proto/fairyring/keyshare/genesis.proto | 6 +- proto/fairyring/keyshare/query.proto | 42 +- proto/fairyring/keyshare/tx.proto | 31 +- x/keyshare/client/cli/query.go | 2 + .../client/cli/query_authorized_address.go | 73 + .../cli/query_authorized_address_test.go | 161 +++ x/keyshare/client/cli/tx.go | 3 + .../client/cli/tx_authorized_address.go | 106 ++ .../client/cli/tx_authorized_address_test.go | 187 +++ x/keyshare/genesis.go | 5 + x/keyshare/genesis_test.go | 9 + x/keyshare/keeper/authorized_address.go | 116 ++ x/keyshare/keeper/authorized_address_test.go | 63 + .../keeper/msg_server_authorized_address.go | 102 ++ .../msg_server_authorized_address_test.go | 142 ++ x/keyshare/keeper/msg_server_send_keyshare.go | 11 +- x/keyshare/keeper/query_authorized_address.go | 57 + .../keeper/query_authorized_address_test.go | 126 ++ x/keyshare/module_simulation.go | 55 + x/keyshare/simulation/authorized_address.go | 147 ++ x/keyshare/types/authorized_address.pb.go | 410 ++++++ x/keyshare/types/codec.go | 8 + x/keyshare/types/errors.go | 37 +- x/keyshare/types/genesis.go | 11 + x/keyshare/types/genesis.pb.go | 112 +- x/keyshare/types/genesis_test.go | 22 + x/keyshare/types/key_authorized_address.go | 37 + .../types/messages_authorized_address.go | 138 ++ .../types/messages_authorized_address_test.go | 102 ++ x/keyshare/types/query.pb.go | 1100 ++++++++++++-- x/keyshare/types/query.pb.gw.go | 184 +++ x/keyshare/types/tx.pb.go | 1260 ++++++++++++++++- 33 files changed, 4660 insertions(+), 216 deletions(-) create mode 100644 proto/fairyring/keyshare/authorized_address.proto create mode 100644 x/keyshare/client/cli/query_authorized_address.go create mode 100644 x/keyshare/client/cli/query_authorized_address_test.go create mode 100644 x/keyshare/client/cli/tx_authorized_address.go create mode 100644 x/keyshare/client/cli/tx_authorized_address_test.go create mode 100644 x/keyshare/keeper/authorized_address.go create mode 100644 x/keyshare/keeper/authorized_address_test.go create mode 100644 x/keyshare/keeper/msg_server_authorized_address.go create mode 100644 x/keyshare/keeper/msg_server_authorized_address_test.go create mode 100644 x/keyshare/keeper/query_authorized_address.go create mode 100644 x/keyshare/keeper/query_authorized_address_test.go create mode 100644 x/keyshare/simulation/authorized_address.go create mode 100644 x/keyshare/types/authorized_address.pb.go create mode 100644 x/keyshare/types/key_authorized_address.go create mode 100644 x/keyshare/types/messages_authorized_address.go create mode 100644 x/keyshare/types/messages_authorized_address_test.go diff --git a/proto/fairyring/keyshare/authorized_address.proto b/proto/fairyring/keyshare/authorized_address.proto new file mode 100644 index 00000000..9a197353 --- /dev/null +++ b/proto/fairyring/keyshare/authorized_address.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package fairyring.keyshare; + +option go_package = "fairyring/x/keyshare/types"; + +message AuthorizedAddress { + string target = 1; + bool isAuthorized = 2; + string authorizedBy = 3; +} + diff --git a/proto/fairyring/keyshare/genesis.proto b/proto/fairyring/keyshare/genesis.proto index 2555ba72..9ce2ed15 100644 --- a/proto/fairyring/keyshare/genesis.proto +++ b/proto/fairyring/keyshare/genesis.proto @@ -8,6 +8,7 @@ import "fairyring/keyshare/validator_set.proto"; import "fairyring/keyshare/key_share.proto"; import "fairyring/keyshare/aggregated_key_share.proto"; import "fairyring/keyshare/pub_key.proto"; +import "fairyring/keyshare/authorized_address.proto"; // this line is used by starport scaffolding # genesis/proto/import @@ -21,7 +22,8 @@ message GenesisState { // this line is used by starport scaffolding # genesis/proto/state repeated AggregatedKeyShare aggregatedKeyShareList = 4 [(gogoproto.nullable) = false]; - ActivePubKey activePubKey = 5 [(gogoproto.nullable) = false]; - QueuedPubKey queuedPubKey = 6 [(gogoproto.nullable) = false]; + ActivePubKey activePubKey = 5 [(gogoproto.nullable) = false]; + QueuedPubKey queuedPubKey = 6 [(gogoproto.nullable) = false]; + repeated AuthorizedAddress authorizedAddressList = 7 [(gogoproto.nullable) = false]; } diff --git a/proto/fairyring/keyshare/query.proto b/proto/fairyring/keyshare/query.proto index dae71087..5d9069af 100644 --- a/proto/fairyring/keyshare/query.proto +++ b/proto/fairyring/keyshare/query.proto @@ -10,6 +10,7 @@ import "fairyring/keyshare/validator_set.proto"; import "fairyring/keyshare/key_share.proto"; import "fairyring/keyshare/aggregated_key_share.proto"; import "fairyring/keyshare/pub_key.proto"; +import "fairyring/keyshare/authorized_address.proto"; // this line is used by starport scaffolding # 1 @@ -21,26 +22,31 @@ service Query { // Parameters queries the parameters of the module. rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/fairyring/keyshare/params"; + } // Queries a ValidatorSet by index. rpc ValidatorSet (QueryGetValidatorSetRequest) returns (QueryGetValidatorSetResponse) { option (google.api.http).get = "/fairyring/keyshare/validator_set/{index}"; + } // Queries a list of ValidatorSet items. rpc ValidatorSetAll (QueryAllValidatorSetRequest) returns (QueryAllValidatorSetResponse) { option (google.api.http).get = "/fairyring/keyshare/validator_set"; + } // Queries a KeyShare by index. rpc KeyShare (QueryGetKeyShareRequest) returns (QueryGetKeyShareResponse) { option (google.api.http).get = "/fairyring/keyshare/key_share/{validator}/{blockHeight}"; + } // Queries a list of KeyShare items. rpc KeyShareAll (QueryAllKeyShareRequest) returns (QueryAllKeyShareResponse) { option (google.api.http).get = "/fairyring/keyshare/key_share"; + } // this line is used by starport scaffolding # 2 @@ -48,14 +54,27 @@ service Query { // Queries a list of AggregatedKeyShare items. rpc AggregatedKeyShare (QueryGetAggregatedKeyShareRequest) returns (QueryGetAggregatedKeyShareResponse) { option (google.api.http).get = "/fairyring/keyshare/aggregated_key_share/{height}"; + } rpc AggregatedKeyShareAll (QueryAllAggregatedKeyShareRequest) returns (QueryAllAggregatedKeyShareResponse) { option (google.api.http).get = "/fairyring/keyshare/aggregated_key_share"; + } - + // Queries the public keys - rpc PubKey (QueryPubKeyRequest) returns (QueryPubKeyResponse) { + rpc PubKey (QueryPubKeyRequest) returns (QueryPubKeyResponse) { option (google.api.http).get = "/fairyring/keyshare/pub_key"; + + } + + // Queries a list of AuthorizedAddress items. + rpc AuthorizedAddress (QueryGetAuthorizedAddressRequest) returns (QueryGetAuthorizedAddressResponse) { + option (google.api.http).get = "/fairyring/keyshare/authorized_address/{target}"; + + } + rpc AuthorizedAddressAll (QueryAllAuthorizedAddressRequest) returns (QueryAllAuthorizedAddressResponse) { + option (google.api.http).get = "/fairyring/keyshare/authorized_address"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -124,7 +143,24 @@ message QueryAllAggregatedKeyShareResponse { message QueryPubKeyRequest {} message QueryPubKeyResponse { - ActivePubKey activePubKey = 1 [(gogoproto.nullable) = false]; + ActivePubKey activePubKey = 1 [(gogoproto.nullable) = false]; QueuedPubKey queuedPubKey = 2 [(gogoproto.nullable) = false]; } +message QueryGetAuthorizedAddressRequest { + string target = 1; +} + +message QueryGetAuthorizedAddressResponse { + AuthorizedAddress authorizedAddress = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllAuthorizedAddressRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllAuthorizedAddressResponse { + repeated AuthorizedAddress authorizedAddress = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + diff --git a/proto/fairyring/keyshare/tx.proto b/proto/fairyring/keyshare/tx.proto index 7e4e1e3d..53253ff5 100644 --- a/proto/fairyring/keyshare/tx.proto +++ b/proto/fairyring/keyshare/tx.proto @@ -10,9 +10,12 @@ option go_package = "fairyring/x/keyshare/types"; service Msg { rpc RegisterValidator (MsgRegisterValidator) returns (MsgRegisterValidatorResponse); rpc SendKeyshare (MsgSendKeyshare ) returns (MsgSendKeyshareResponse ); - + // this line is used by starport scaffolding # proto/tx/rpc - rpc CreateLatestPubKey (MsgCreateLatestPubKey) returns (MsgCreateLatestPubKeyResponse); + rpc CreateLatestPubKey (MsgCreateLatestPubKey ) returns (MsgCreateLatestPubKeyResponse ); + rpc CreateAuthorizedAddress (MsgCreateAuthorizedAddress) returns (MsgCreateAuthorizedAddressResponse); + rpc UpdateAuthorizedAddress (MsgUpdateAuthorizedAddress) returns (MsgUpdateAuthorizedAddressResponse); + rpc DeleteAuthorizedAddress (MsgDeleteAuthorizedAddress) returns (MsgDeleteAuthorizedAddressResponse); } message MsgRegisterValidator { string creator = 1; @@ -39,7 +42,6 @@ message MsgSendKeyshareResponse { uint64 receivedBlockHeight = 6; } - // this line is used by starport scaffolding # proto/tx/message message MsgCreateLatestPubKey { string creator = 1; @@ -47,3 +49,26 @@ message MsgCreateLatestPubKey { } message MsgCreateLatestPubKeyResponse {} + +message MsgCreateAuthorizedAddress { + string target = 1; + string creator = 2; +} + +message MsgCreateAuthorizedAddressResponse {} + +message MsgUpdateAuthorizedAddress { + string target = 1; + bool isAuthorized = 2; + string creator = 3; +} + +message MsgUpdateAuthorizedAddressResponse {} + +message MsgDeleteAuthorizedAddress { + string target = 1; + string creator = 2; +} + +message MsgDeleteAuthorizedAddressResponse {} + diff --git a/x/keyshare/client/cli/query.go b/x/keyshare/client/cli/query.go index a122143a..06b54801 100644 --- a/x/keyshare/client/cli/query.go +++ b/x/keyshare/client/cli/query.go @@ -32,6 +32,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListAggregatedKeyShare()) cmd.AddCommand(CmdShowAggregatedKeyShare()) cmd.AddCommand(CmdShowPubKey()) + cmd.AddCommand(CmdListAuthorizedAddress()) + cmd.AddCommand(CmdShowAuthorizedAddress()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/keyshare/client/cli/query_authorized_address.go b/x/keyshare/client/cli/query_authorized_address.go new file mode 100644 index 00000000..4973d671 --- /dev/null +++ b/x/keyshare/client/cli/query_authorized_address.go @@ -0,0 +1,73 @@ +package cli + +import ( + "context" + + "fairyring/x/keyshare/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdListAuthorizedAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-authorized-address", + Short: "list all authorizedAddress", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllAuthorizedAddressRequest{ + Pagination: pageReq, + } + + res, err := queryClient.AuthorizedAddressAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowAuthorizedAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-authorized-address [target]", + Short: "shows a authorizedAddress", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argTarget := args[0] + + params := &types.QueryGetAuthorizedAddressRequest{ + Target: argTarget, + } + + res, err := queryClient.AuthorizedAddress(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/keyshare/client/cli/query_authorized_address_test.go b/x/keyshare/client/cli/query_authorized_address_test.go new file mode 100644 index 00000000..b350acf5 --- /dev/null +++ b/x/keyshare/client/cli/query_authorized_address_test.go @@ -0,0 +1,161 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "fairyring/testutil/network" + "fairyring/testutil/nullify" + "fairyring/x/keyshare/client/cli" + "fairyring/x/keyshare/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithAuthorizedAddressObjects(t *testing.T, n int) (*network.Network, []types.AuthorizedAddress) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + authorizedAddress := types.AuthorizedAddress{ + Target: strconv.Itoa(i), + } + nullify.Fill(&authorizedAddress) + state.AuthorizedAddressList = append(state.AuthorizedAddressList, authorizedAddress) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.AuthorizedAddressList +} + +func TestShowAuthorizedAddress(t *testing.T) { + net, objs := networkWithAuthorizedAddressObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idTarget string + + args []string + err error + obj types.AuthorizedAddress + }{ + { + desc: "found", + idTarget: objs[0].Target, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idTarget: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idTarget, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowAuthorizedAddress(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetAuthorizedAddressResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.AuthorizedAddress) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.AuthorizedAddress), + ) + } + }) + } +} + +func TestListAuthorizedAddress(t *testing.T) { + net, objs := networkWithAuthorizedAddressObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuthorizedAddress(), args) + require.NoError(t, err) + var resp types.QueryAllAuthorizedAddressResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.AuthorizedAddress), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.AuthorizedAddress), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuthorizedAddress(), args) + require.NoError(t, err) + var resp types.QueryAllAuthorizedAddressResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.AuthorizedAddress), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.AuthorizedAddress), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuthorizedAddress(), args) + require.NoError(t, err) + var resp types.QueryAllAuthorizedAddressResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.AuthorizedAddress), + ) + }) +} diff --git a/x/keyshare/client/cli/tx.go b/x/keyshare/client/cli/tx.go index d6ab8a94..e91fa154 100644 --- a/x/keyshare/client/cli/tx.go +++ b/x/keyshare/client/cli/tx.go @@ -28,6 +28,9 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdRegisterValidator()) cmd.AddCommand(CmdSendKeyshare()) cmd.AddCommand(CmdCreateLatestPubKey()) + cmd.AddCommand(CmdCreateAuthorizedAddress()) + cmd.AddCommand(CmdUpdateAuthorizedAddress()) + cmd.AddCommand(CmdDeleteAuthorizedAddress()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/keyshare/client/cli/tx_authorized_address.go b/x/keyshare/client/cli/tx_authorized_address.go new file mode 100644 index 00000000..ebdbe80f --- /dev/null +++ b/x/keyshare/client/cli/tx_authorized_address.go @@ -0,0 +1,106 @@ +package cli + +import ( + "fairyring/x/keyshare/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cast" + "github.com/spf13/cobra" +) + +func CmdCreateAuthorizedAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-authorized-address [target]", + Short: "Create a new authorizedAddress", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + indexTarget := args[0] + + // Get value arguments + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreateAuthorizedAddress( + clientCtx.GetFromAddress().String(), + indexTarget, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUpdateAuthorizedAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-authorized-address [target] [is-authorized]", + Short: "Update a authorizedAddress", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + indexTarget := args[0] + + isAuthorized := cast.ToBool(args[1]) + + // Get value arguments + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateAuthorizedAddress( + clientCtx.GetFromAddress().String(), + indexTarget, + isAuthorized, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdDeleteAuthorizedAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete-authorized-address [target]", + Short: "Delete a authorizedAddress", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + indexTarget := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDeleteAuthorizedAddress( + clientCtx.GetFromAddress().String(), + indexTarget, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/keyshare/client/cli/tx_authorized_address_test.go b/x/keyshare/client/cli/tx_authorized_address_test.go new file mode 100644 index 00000000..4eb95d49 --- /dev/null +++ b/x/keyshare/client/cli/tx_authorized_address_test.go @@ -0,0 +1,187 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "fairyring/testutil/network" + "fairyring/x/keyshare/client/cli" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestCreateAuthorizedAddress(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{} + for _, tc := range []struct { + desc string + idTarget string + + args []string + err error + code uint32 + }{ + { + idTarget: strconv.Itoa(0), + + desc: "valid", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdkmath.NewInt(10))).String()), + }, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idTarget, + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateAuthorizedAddress(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestUpdateAuthorizedAddress(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{} + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdkmath.NewInt(10))).String()), + } + args := []string{ + "0", + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateAuthorizedAddress(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idTarget string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idTarget: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idTarget: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idTarget, + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateAuthorizedAddress(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestDeleteAuthorizedAddress(t *testing.T) { + net := network.New(t) + + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{} + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdkmath.NewInt(10))).String()), + } + args := []string{ + "0", + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateAuthorizedAddress(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idTarget string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idTarget: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idTarget: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idTarget, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdDeleteAuthorizedAddress(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} diff --git a/x/keyshare/genesis.go b/x/keyshare/genesis.go index 69f89890..ad78cb56 100644 --- a/x/keyshare/genesis.go +++ b/x/keyshare/genesis.go @@ -26,6 +26,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // Set queued public key k.SetQueuedPubKey(ctx, genState.QueuedPubKey) + // Set all the authorizedAddress + for _, elem := range genState.AuthorizedAddressList { + k.SetAuthorizedAddress(ctx, elem) + } // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) } @@ -48,6 +52,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.QueuedPubKey = qkey } + genesis.AuthorizedAddressList = k.GetAllAuthorizedAddress(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/keyshare/genesis_test.go b/x/keyshare/genesis_test.go index 3087488f..1798ba4f 100644 --- a/x/keyshare/genesis_test.go +++ b/x/keyshare/genesis_test.go @@ -41,6 +41,14 @@ func TestGenesis(t *testing.T) { Height: 1, }, }, + AuthorizedAddressList: []types.AuthorizedAddress{ + { + Target: "0", + }, + { + Target: "1", + }, + }, // this line is used by starport scaffolding # genesis/test/state } @@ -55,5 +63,6 @@ func TestGenesis(t *testing.T) { require.ElementsMatch(t, genesisState.ValidatorSetList, got.ValidatorSetList) require.ElementsMatch(t, genesisState.KeyShareList, got.KeyShareList) require.ElementsMatch(t, genesisState.AggregatedKeyShareList, got.AggregatedKeyShareList) + require.ElementsMatch(t, genesisState.AuthorizedAddressList, got.AuthorizedAddressList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/keyshare/keeper/authorized_address.go b/x/keyshare/keeper/authorized_address.go new file mode 100644 index 00000000..2287b8d0 --- /dev/null +++ b/x/keyshare/keeper/authorized_address.go @@ -0,0 +1,116 @@ +package keeper + +import ( + "encoding/binary" + "fairyring/x/keyshare/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetAuthorizedCount( + ctx sdk.Context, + creator string, +) uint64 { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedCountKeyPrefix)) + + b := store.Get(types.AuthorizedCountKey( + creator, + )) + if b == nil { + return 0 + } + + return binary.BigEndian.Uint64(b) +} + +func (k Keeper) IncreaseAuthorizedCount( + ctx sdk.Context, + creator string, +) { + count := k.GetAuthorizedCount(ctx, creator) + + countByte := make([]byte, 8) + + binary.BigEndian.PutUint64(countByte, count+1) + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedCountKeyPrefix)) + + store.Set(types.AuthorizedCountKey(creator), countByte) +} + +func (k Keeper) DecreaseAuthorizedCount( + ctx sdk.Context, + creator string, +) { + count := k.GetAuthorizedCount(ctx, creator) + + var countByte []byte + + var newCount uint64 = 0 + + if count > 0 { + newCount = count - 1 + } + + binary.BigEndian.PutUint64(countByte, newCount) + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedCountKeyPrefix)) + + store.Set(types.AuthorizedCountKey(creator), countByte) +} + +// SetAuthorizedAddress set a specific authorizedAddress in the store from its index +func (k Keeper) SetAuthorizedAddress(ctx sdk.Context, authorizedAddress types.AuthorizedAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedAddressKeyPrefix)) + b := k.cdc.MustMarshal(&authorizedAddress) + store.Set(types.AuthorizedAddressKey( + authorizedAddress.Target, + ), b) +} + +// GetAuthorizedAddress returns a authorizedAddress from its index +func (k Keeper) GetAuthorizedAddress( + ctx sdk.Context, + target string, + +) (val types.AuthorizedAddress, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedAddressKeyPrefix)) + + b := store.Get(types.AuthorizedAddressKey( + target, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveAuthorizedAddress removes a authorizedAddress from the store +func (k Keeper) RemoveAuthorizedAddress( + ctx sdk.Context, + target string, + +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedAddressKeyPrefix)) + store.Delete(types.AuthorizedAddressKey( + target, + )) +} + +// GetAllAuthorizedAddress returns all authorizedAddress +func (k Keeper) GetAllAuthorizedAddress(ctx sdk.Context) (list []types.AuthorizedAddress) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuthorizedAddressKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.AuthorizedAddress + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/keyshare/keeper/authorized_address_test.go b/x/keyshare/keeper/authorized_address_test.go new file mode 100644 index 00000000..a4fc8e49 --- /dev/null +++ b/x/keyshare/keeper/authorized_address_test.go @@ -0,0 +1,63 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "fairyring/testutil/keeper" + "fairyring/testutil/nullify" + "fairyring/x/keyshare/keeper" + "fairyring/x/keyshare/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNAuthorizedAddress(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.AuthorizedAddress { + items := make([]types.AuthorizedAddress, n) + for i := range items { + items[i].Target = strconv.Itoa(i) + + keeper.SetAuthorizedAddress(ctx, items[i]) + } + return items +} + +func TestAuthorizedAddressGet(t *testing.T) { + keeper, ctx := keepertest.KeyshareKeeper(t) + items := createNAuthorizedAddress(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetAuthorizedAddress(ctx, + item.Target, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestAuthorizedAddressRemove(t *testing.T) { + keeper, ctx := keepertest.KeyshareKeeper(t) + items := createNAuthorizedAddress(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveAuthorizedAddress(ctx, + item.Target, + ) + _, found := keeper.GetAuthorizedAddress(ctx, + item.Target, + ) + require.False(t, found) + } +} + +func TestAuthorizedAddressGetAll(t *testing.T) { + keeper, ctx := keepertest.KeyshareKeeper(t) + items := createNAuthorizedAddress(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllAuthorizedAddress(ctx)), + ) +} diff --git a/x/keyshare/keeper/msg_server_authorized_address.go b/x/keyshare/keeper/msg_server_authorized_address.go new file mode 100644 index 00000000..50887388 --- /dev/null +++ b/x/keyshare/keeper/msg_server_authorized_address.go @@ -0,0 +1,102 @@ +package keeper + +import ( + "context" + "fairyring/x/keyshare/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) CreateAuthorizedAddress(goCtx context.Context, msg *types.MsgCreateAuthorizedAddress) (*types.MsgCreateAuthorizedAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + _, isFound := k.GetAuthorizedAddress( + ctx, + msg.Target, + ) + if isFound { + return nil, types.ErrAddressAlreadyAuthorized + } + + if msg.Target == msg.Creator { + return nil, types.ErrAuthorizeSelfAddress + } + + _, found := k.GetValidatorSet(ctx, msg.Creator) + // Only allow registered validator to authorize address + if !found { + return nil, types.ErrOnlyValidatorCanAuthorizeAddr.Wrap(msg.Creator) + } + + if k.GetAuthorizedCount(ctx, msg.Creator) >= 1 { + return nil, types.ErrExceedMaxAuthAddr + } + + var authorizedAddress = types.AuthorizedAddress{ + AuthorizedBy: msg.Creator, + Target: msg.Target, + IsAuthorized: true, + } + + k.SetAuthorizedAddress( + ctx, + authorizedAddress, + ) + k.IncreaseAuthorizedCount(ctx, msg.Creator) + return &types.MsgCreateAuthorizedAddressResponse{}, nil +} + +func (k msgServer) UpdateAuthorizedAddress(goCtx context.Context, msg *types.MsgUpdateAuthorizedAddress) (*types.MsgUpdateAuthorizedAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valFound, isFound := k.GetAuthorizedAddress( + ctx, + msg.Target, + ) + if !isFound { + return nil, types.ErrAuthorizedAddrNotFound + } + + if msg.Creator != valFound.AuthorizedBy { + return nil, types.ErrNotAuthorizedAddrCreator + } + + if msg.Target == msg.Creator { + return nil, types.ErrAuthorizeSelfAddress + } + + var authorizedAddress = types.AuthorizedAddress{ + AuthorizedBy: msg.Creator, + Target: msg.Target, + IsAuthorized: msg.IsAuthorized, + } + + k.SetAuthorizedAddress(ctx, authorizedAddress) + + return &types.MsgUpdateAuthorizedAddressResponse{}, nil +} + +func (k msgServer) DeleteAuthorizedAddress(goCtx context.Context, msg *types.MsgDeleteAuthorizedAddress) (*types.MsgDeleteAuthorizedAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + valFound, isFound := k.GetAuthorizedAddress( + ctx, + msg.Creator, + ) + if !isFound { + return nil, types.ErrAuthorizedAddrNotFound + } + + // Allow the authorized addr creator / target authorized address to remove authorization + if msg.Creator != valFound.AuthorizedBy && msg.Creator != valFound.Target { + return nil, types.ErrNotTargetOrAuthAddrCreator + } + + k.RemoveAuthorizedAddress( + ctx, + msg.Target, + ) + + k.DecreaseAuthorizedCount(ctx, valFound.AuthorizedBy) + + return &types.MsgDeleteAuthorizedAddressResponse{}, nil +} diff --git a/x/keyshare/keeper/msg_server_authorized_address_test.go b/x/keyshare/keeper/msg_server_authorized_address_test.go new file mode 100644 index 00000000..08d53422 --- /dev/null +++ b/x/keyshare/keeper/msg_server_authorized_address_test.go @@ -0,0 +1,142 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + keepertest "fairyring/testutil/keeper" + "fairyring/x/keyshare/keeper" + "fairyring/x/keyshare/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestAuthorizedAddressMsgServerCreate(t *testing.T) { + k, ctx := keepertest.KeyshareKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + creator := "A" + for i := 0; i < 5; i++ { + expected := &types.MsgCreateAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(i), + } + _, err := srv.CreateAuthorizedAddress(wctx, expected) + require.NoError(t, err) + rst, found := k.GetAuthorizedAddress(ctx, + expected.Target, + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.AuthorizedBy) + } +} + +func TestAuthorizedAddressMsgServerUpdate(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgUpdateAuthorizedAddress + err error + }{ + { + desc: "Completed", + request: &types.MsgUpdateAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(0), + }, + }, + { + desc: "Unauthorized", + request: &types.MsgUpdateAuthorizedAddress{Creator: "B", + Target: strconv.Itoa(0), + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgUpdateAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(100000), + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.KeyshareKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + expected := &types.MsgCreateAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(0), + } + _, err := srv.CreateAuthorizedAddress(wctx, expected) + require.NoError(t, err) + + _, err = srv.UpdateAuthorizedAddress(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + rst, found := k.GetAuthorizedAddress(ctx, + expected.Target, + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.AuthorizedBy) + } + }) + } +} + +func TestAuthorizedAddressMsgServerDelete(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgDeleteAuthorizedAddress + err error + }{ + { + desc: "Completed", + request: &types.MsgDeleteAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(0), + }, + }, + { + desc: "Unauthorized", + request: &types.MsgDeleteAuthorizedAddress{Creator: "B", + Target: strconv.Itoa(0), + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgDeleteAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(100000), + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.KeyshareKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + + _, err := srv.CreateAuthorizedAddress(wctx, &types.MsgCreateAuthorizedAddress{Creator: creator, + Target: strconv.Itoa(0), + }) + require.NoError(t, err) + _, err = srv.DeleteAuthorizedAddress(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + _, found := k.GetAuthorizedAddress(ctx, + tc.request.Target, + ) + require.False(t, found) + } + }) + } +} diff --git a/x/keyshare/keeper/msg_server_send_keyshare.go b/x/keyshare/keeper/msg_server_send_keyshare.go index da2d27ec..4bcb8675 100644 --- a/x/keyshare/keeper/msg_server_send_keyshare.go +++ b/x/keyshare/keeper/msg_server_send_keyshare.go @@ -24,7 +24,16 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar validatorInfo, found := k.GetValidatorSet(ctx, msg.Creator) if !found { - return nil, types.ErrValidatorNotRegistered.Wrap(msg.Creator) + authorizedAddrInfo, found := k.GetAuthorizedAddress(ctx, msg.Creator) + if !found || !authorizedAddrInfo.IsAuthorized { + return nil, types.ErrAddrIsNotValidatorOrAuthorized.Wrap(msg.Creator) + } + + authorizedByValInfo, found := k.GetValidatorSet(ctx, authorizedAddrInfo.AuthorizedBy) + if !found { + return nil, types.ErrAuthorizerIsNotValidator.Wrap(authorizedAddrInfo.AuthorizedBy) + } + validatorInfo = authorizedByValInfo } // Setup diff --git a/x/keyshare/keeper/query_authorized_address.go b/x/keyshare/keeper/query_authorized_address.go new file mode 100644 index 00000000..ed173932 --- /dev/null +++ b/x/keyshare/keeper/query_authorized_address.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + "fairyring/x/keyshare/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) AuthorizedAddressAll(goCtx context.Context, req *types.QueryAllAuthorizedAddressRequest) (*types.QueryAllAuthorizedAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var authorizedAddresss []types.AuthorizedAddress + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + authorizedAddressStore := prefix.NewStore(store, types.KeyPrefix(types.AuthorizedAddressKeyPrefix)) + + pageRes, err := query.Paginate(authorizedAddressStore, req.Pagination, func(key []byte, value []byte) error { + var authorizedAddress types.AuthorizedAddress + if err := k.cdc.Unmarshal(value, &authorizedAddress); err != nil { + return err + } + + authorizedAddresss = append(authorizedAddresss, authorizedAddress) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllAuthorizedAddressResponse{AuthorizedAddress: authorizedAddresss, Pagination: pageRes}, nil +} + +func (k Keeper) AuthorizedAddress(goCtx context.Context, req *types.QueryGetAuthorizedAddressRequest) (*types.QueryGetAuthorizedAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + val, found := k.GetAuthorizedAddress( + ctx, + req.Target, + ) + if !found { + return nil, types.ErrAuthorizedAddrNotFound + } + + return &types.QueryGetAuthorizedAddressResponse{AuthorizedAddress: val}, nil +} diff --git a/x/keyshare/keeper/query_authorized_address_test.go b/x/keyshare/keeper/query_authorized_address_test.go new file mode 100644 index 00000000..a20ed27d --- /dev/null +++ b/x/keyshare/keeper/query_authorized_address_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "fairyring/testutil/keeper" + "fairyring/testutil/nullify" + "fairyring/x/keyshare/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestAuthorizedAddressQuerySingle(t *testing.T) { + keeper, ctx := keepertest.KeyshareKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNAuthorizedAddress(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetAuthorizedAddressRequest + response *types.QueryGetAuthorizedAddressResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetAuthorizedAddressRequest{ + Target: msgs[0].Target, + }, + response: &types.QueryGetAuthorizedAddressResponse{AuthorizedAddress: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetAuthorizedAddressRequest{ + Target: msgs[1].Target, + }, + response: &types.QueryGetAuthorizedAddressResponse{AuthorizedAddress: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetAuthorizedAddressRequest{ + Target: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.AuthorizedAddress(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestAuthorizedAddressQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.KeyshareKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNAuthorizedAddress(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllAuthorizedAddressRequest { + return &types.QueryAllAuthorizedAddressRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.AuthorizedAddressAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.AuthorizedAddress), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.AuthorizedAddress), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.AuthorizedAddressAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.AuthorizedAddress), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.AuthorizedAddress), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.AuthorizedAddressAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.AuthorizedAddress), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.AuthorizedAddressAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/keyshare/module_simulation.go b/x/keyshare/module_simulation.go index 0ec374e1..1255e63a 100644 --- a/x/keyshare/module_simulation.go +++ b/x/keyshare/module_simulation.go @@ -34,6 +34,18 @@ const ( opWeightMsgCreateLatestPubKey = "op_weight_msg_latest_pub_key" defaultWeightMsgCreateLatestPubKey int = 100 + opWeightMsgCreateAuthorizedAddress = "op_weight_msg_authorized_address" + // TODO: Determine the simulation weight value + defaultWeightMsgCreateAuthorizedAddress int = 100 + + opWeightMsgUpdateAuthorizedAddress = "op_weight_msg_authorized_address" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateAuthorizedAddress int = 100 + + opWeightMsgDeleteAuthorizedAddress = "op_weight_msg_authorized_address" + // TODO: Determine the simulation weight value + defaultWeightMsgDeleteAuthorizedAddress int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -45,6 +57,16 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } keyshareGenesis := types.GenesisState{ Params: types.DefaultParams(), + AuthorizedAddressList: []types.AuthorizedAddress{ + { + AuthorizedBy: sample.AccAddress(), + Target: "0", + }, + { + AuthorizedBy: sample.AccAddress(), + Target: "1", + }, + }, // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&keyshareGenesis) @@ -101,6 +123,39 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp keysharesimulation.SimulateMsgCreateLatestPubKey(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgCreateAuthorizedAddress int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateAuthorizedAddress, &weightMsgCreateAuthorizedAddress, nil, + func(_ *rand.Rand) { + weightMsgCreateAuthorizedAddress = defaultWeightMsgCreateAuthorizedAddress + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCreateAuthorizedAddress, + keysharesimulation.SimulateMsgCreateAuthorizedAddress(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgUpdateAuthorizedAddress int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateAuthorizedAddress, &weightMsgUpdateAuthorizedAddress, nil, + func(_ *rand.Rand) { + weightMsgUpdateAuthorizedAddress = defaultWeightMsgUpdateAuthorizedAddress + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateAuthorizedAddress, + keysharesimulation.SimulateMsgUpdateAuthorizedAddress(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgDeleteAuthorizedAddress int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteAuthorizedAddress, &weightMsgDeleteAuthorizedAddress, nil, + func(_ *rand.Rand) { + weightMsgDeleteAuthorizedAddress = defaultWeightMsgDeleteAuthorizedAddress + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDeleteAuthorizedAddress, + keysharesimulation.SimulateMsgDeleteAuthorizedAddress(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/keyshare/simulation/authorized_address.go b/x/keyshare/simulation/authorized_address.go new file mode 100644 index 00000000..27329510 --- /dev/null +++ b/x/keyshare/simulation/authorized_address.go @@ -0,0 +1,147 @@ +package simulation + +import ( + "math/rand" + "strconv" + + "fairyring/x/keyshare/keeper" + "fairyring/x/keyshare/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func SimulateMsgCreateAuthorizedAddress( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + + i := r.Int() + msg := &types.MsgCreateAuthorizedAddress{ + Creator: simAccount.Address.String(), + Target: strconv.Itoa(i), + } + + _, found := k.GetAuthorizedAddress(ctx, msg.Target) + if found { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "AuthorizedAddress already exist"), nil, nil + } + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +func SimulateMsgUpdateAuthorizedAddress( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + var ( + simAccount = simtypes.Account{} + authorizedAddress = types.AuthorizedAddress{} + msg = &types.MsgUpdateAuthorizedAddress{} + allAuthorizedAddress = k.GetAllAuthorizedAddress(ctx) + found = false + ) + for _, obj := range allAuthorizedAddress { + simAccount, found = FindAccount(accs, obj.Target) + if found { + authorizedAddress = obj + break + } + } + if !found { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "authorizedAddress creator not found"), nil, nil + } + msg.Creator = simAccount.Address.String() + + msg.Target = authorizedAddress.Target + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +func SimulateMsgDeleteAuthorizedAddress( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + var ( + simAccount = simtypes.Account{} + authorizedAddress = types.AuthorizedAddress{} + msg = &types.MsgUpdateAuthorizedAddress{} + allAuthorizedAddress = k.GetAllAuthorizedAddress(ctx) + found = false + ) + for _, obj := range allAuthorizedAddress { + simAccount, found = FindAccount(accs, obj.Target) + if found { + authorizedAddress = obj + break + } + } + if !found { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "authorizedAddress creator not found"), nil, nil + } + msg.Creator = simAccount.Address.String() + + msg.Target = authorizedAddress.Target + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} diff --git a/x/keyshare/types/authorized_address.pb.go b/x/keyshare/types/authorized_address.pb.go new file mode 100644 index 00000000..e8f962a6 --- /dev/null +++ b/x/keyshare/types/authorized_address.pb.go @@ -0,0 +1,410 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fairyring/keyshare/authorized_address.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AuthorizedAddress struct { + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + IsAuthorized bool `protobuf:"varint,2,opt,name=isAuthorized,proto3" json:"isAuthorized,omitempty"` + AuthorizedBy string `protobuf:"bytes,3,opt,name=authorizedBy,proto3" json:"authorizedBy,omitempty"` +} + +func (m *AuthorizedAddress) Reset() { *m = AuthorizedAddress{} } +func (m *AuthorizedAddress) String() string { return proto.CompactTextString(m) } +func (*AuthorizedAddress) ProtoMessage() {} +func (*AuthorizedAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_7b09dee94c56d60e, []int{0} +} +func (m *AuthorizedAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthorizedAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthorizedAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthorizedAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthorizedAddress.Merge(m, src) +} +func (m *AuthorizedAddress) XXX_Size() int { + return m.Size() +} +func (m *AuthorizedAddress) XXX_DiscardUnknown() { + xxx_messageInfo_AuthorizedAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthorizedAddress proto.InternalMessageInfo + +func (m *AuthorizedAddress) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *AuthorizedAddress) GetIsAuthorized() bool { + if m != nil { + return m.IsAuthorized + } + return false +} + +func (m *AuthorizedAddress) GetAuthorizedBy() string { + if m != nil { + return m.AuthorizedBy + } + return "" +} + +func init() { + proto.RegisterType((*AuthorizedAddress)(nil), "fairyring.keyshare.AuthorizedAddress") +} + +func init() { + proto.RegisterFile("fairyring/keyshare/authorized_address.proto", fileDescriptor_7b09dee94c56d60e) +} + +var fileDescriptor_7b09dee94c56d60e = []byte{ + // 179 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x4b, 0xcc, 0x2c, + 0xaa, 0x2c, 0xca, 0xcc, 0x4b, 0xd7, 0xcf, 0x4e, 0xad, 0x2c, 0xce, 0x48, 0x2c, 0x4a, 0xd5, 0x4f, + 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, 0xac, 0x4a, 0x4d, 0x89, 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, + 0x2e, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x2b, 0xd6, 0x83, 0x29, 0x56, 0x2a, + 0xe6, 0x12, 0x74, 0x84, 0xab, 0x77, 0x84, 0x28, 0x17, 0x12, 0xe3, 0x62, 0x2b, 0x49, 0x2c, 0x4a, + 0x4f, 0x2d, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0xf2, 0x84, 0x94, 0xb8, 0x78, 0x32, + 0x8b, 0x11, 0xca, 0x25, 0x98, 0x14, 0x18, 0x35, 0x38, 0x82, 0x50, 0xc4, 0x40, 0x6a, 0x10, 0x0e, + 0x70, 0xaa, 0x94, 0x60, 0x06, 0x9b, 0x80, 0x22, 0xe6, 0x64, 0x72, 0xe2, 0x91, 0x1c, 0xe3, 0x85, + 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, + 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x52, 0x08, 0xff, 0x54, 0x20, 0x7c, 0x54, 0x52, 0x59, 0x90, 0x5a, + 0x9c, 0xc4, 0x06, 0xf6, 0x85, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x25, 0xfc, 0x33, 0x00, 0xf4, + 0x00, 0x00, 0x00, +} + +func (m *AuthorizedAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthorizedAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthorizedAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AuthorizedBy) > 0 { + i -= len(m.AuthorizedBy) + copy(dAtA[i:], m.AuthorizedBy) + i = encodeVarintAuthorizedAddress(dAtA, i, uint64(len(m.AuthorizedBy))) + i-- + dAtA[i] = 0x1a + } + if m.IsAuthorized { + i-- + if m.IsAuthorized { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintAuthorizedAddress(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAuthorizedAddress(dAtA []byte, offset int, v uint64) int { + offset -= sovAuthorizedAddress(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AuthorizedAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovAuthorizedAddress(uint64(l)) + } + if m.IsAuthorized { + n += 2 + } + l = len(m.AuthorizedBy) + if l > 0 { + n += 1 + l + sovAuthorizedAddress(uint64(l)) + } + return n +} + +func sovAuthorizedAddress(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAuthorizedAddress(x uint64) (n int) { + return sovAuthorizedAddress(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AuthorizedAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthorizedAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthorizedAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthorizedAddress + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorizedAddress + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsAuthorized", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsAuthorized = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedBy", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthorizedAddress + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorizedAddress + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorizedBy = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthorizedAddress(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthorizedAddress + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAuthorizedAddress(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAuthorizedAddress + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAuthorizedAddress + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAuthorizedAddress + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAuthorizedAddress + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAuthorizedAddress = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAuthorizedAddress = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAuthorizedAddress = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/keyshare/types/codec.go b/x/keyshare/types/codec.go index 0ea98e47..b0dc0f0d 100644 --- a/x/keyshare/types/codec.go +++ b/x/keyshare/types/codec.go @@ -11,6 +11,9 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgRegisterValidator{}, "fairyring/RegisterValidator", nil) cdc.RegisterConcrete(&MsgSendKeyshare{}, "fairyring/SendKeyshare", nil) cdc.RegisterConcrete(&MsgCreateLatestPubKey{}, "fairyring/CreateLatestPubKey", nil) + cdc.RegisterConcrete(&MsgCreateAuthorizedAddress{}, "keyshare/CreateAuthorizedAddress", nil) + cdc.RegisterConcrete(&MsgUpdateAuthorizedAddress{}, "keyshare/UpdateAuthorizedAddress", nil) + cdc.RegisterConcrete(&MsgDeleteAuthorizedAddress{}, "keyshare/DeleteAuthorizedAddress", nil) // this line is used by starport scaffolding # 2 } @@ -24,6 +27,11 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateLatestPubKey{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateAuthorizedAddress{}, + &MsgUpdateAuthorizedAddress{}, + &MsgDeleteAuthorizedAddress{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/keyshare/types/errors.go b/x/keyshare/types/errors.go index 78308e0b..77dec9ae 100644 --- a/x/keyshare/types/errors.go +++ b/x/keyshare/types/errors.go @@ -8,18 +8,27 @@ import ( // x/keyshare module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") - ErrValidatorAlreadyRegistered = sdkerrors.Register(ModuleName, 1101, "validator already registered") - ErrValidatorNotRegistered = sdkerrors.Register(ModuleName, 1102, "validator not registered") - ErrInvalidBlockHeight = sdkerrors.Register(ModuleName, 1103, "invalid block height") - ErrDecodingKeyShare = sdkerrors.Register(ModuleName, 1104, "error decoding keyshare") - ErrUnmarshallingKeyShare = sdkerrors.Register(ModuleName, 1105, "error unmarshalling keyshare") - ErrDecodingCommitment = sdkerrors.Register(ModuleName, 1106, "error decoding commitment") - ErrUnmarshallingCommitment = sdkerrors.Register(ModuleName, 1107, "error unmarhsalling commitment") - ErrUnableToVerifyShare = sdkerrors.Register(ModuleName, 1108, "unable to verify share") - ErrInvalidShare = sdkerrors.Register(ModuleName, 1109, "invalid share / commitment") - ErrPubKeyNotFound = sdkerrors.Register(ModuleName, 1110, "Public key does not exists now") - ErrQueuedKeyAlreadyExists = sdkerrors.Register(ModuleName, 1111, "a queued key already exists") - ErrAccountNotStaking = sdkerrors.Register(ModuleName, 1112, "account is not staking") - ErrAddressNotTrusted = sdkerrors.Register(ModuleName, 1113, "address is not trusted") + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrValidatorAlreadyRegistered = sdkerrors.Register(ModuleName, 1101, "validator already registered") + ErrValidatorNotRegistered = sdkerrors.Register(ModuleName, 1102, "validator not registered") + ErrInvalidBlockHeight = sdkerrors.Register(ModuleName, 1103, "invalid block height") + ErrDecodingKeyShare = sdkerrors.Register(ModuleName, 1104, "error decoding keyshare") + ErrUnmarshallingKeyShare = sdkerrors.Register(ModuleName, 1105, "error unmarshalling keyshare") + ErrDecodingCommitment = sdkerrors.Register(ModuleName, 1106, "error decoding commitment") + ErrUnmarshallingCommitment = sdkerrors.Register(ModuleName, 1107, "error unmarhsalling commitment") + ErrUnableToVerifyShare = sdkerrors.Register(ModuleName, 1108, "unable to verify share") + ErrInvalidShare = sdkerrors.Register(ModuleName, 1109, "invalid share / commitment") + ErrPubKeyNotFound = sdkerrors.Register(ModuleName, 1110, "Public key does not exists now") + ErrQueuedKeyAlreadyExists = sdkerrors.Register(ModuleName, 1111, "a queued key already exists") + ErrAccountNotStaking = sdkerrors.Register(ModuleName, 1112, "account is not staking") + ErrAddressNotTrusted = sdkerrors.Register(ModuleName, 1113, "address is not trusted") + ErrAddressAlreadyAuthorized = sdkerrors.Register(ModuleName, 1900, "address is already authorized") + ErrAuthorizedAddrNotFound = sdkerrors.Register(ModuleName, 1901, "target authorized address not found") + ErrNotAuthorizedAddrCreator = sdkerrors.Register(ModuleName, 1902, "sender is not the creator of target authorized address") + ErrNotTargetOrAuthAddrCreator = sdkerrors.Register(ModuleName, 1903, "only the authorized address / the creator can delete authorized address") + ErrAddrIsNotValidatorOrAuthorized = sdkerrors.Register(ModuleName, 1904, "sender is not validator / authorized address to submit key share") + ErrAuthorizerIsNotValidator = sdkerrors.Register(ModuleName, 1905, "address authorized you is not a validator") + ErrOnlyValidatorCanAuthorizeAddr = sdkerrors.Register(ModuleName, 1906, "only validator can authorize address to submit key share") + ErrExceedMaxAuthAddr = sdkerrors.Register(ModuleName, 1907, "each validator can only authorize max 1 address to submit key share") + ErrAuthorizeSelfAddress = sdkerrors.Register(ModuleName, 1908, "unable to authorize sender own address") ) diff --git a/x/keyshare/types/genesis.go b/x/keyshare/types/genesis.go index a37c3189..332edea9 100644 --- a/x/keyshare/types/genesis.go +++ b/x/keyshare/types/genesis.go @@ -13,6 +13,7 @@ func DefaultGenesis() *GenesisState { ValidatorSetList: []ValidatorSet{}, KeyShareList: []KeyShare{}, AggregatedKeyShareList: []AggregatedKeyShare{}, + AuthorizedAddressList: []AuthorizedAddress{}, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -51,6 +52,16 @@ func (gs GenesisState) Validate() error { } aggregatedKeyShareIndexMap[index] = struct{}{} } + // Check for duplicated index in authorizedAddress + authorizedAddressIndexMap := make(map[string]struct{}) + + for _, elem := range gs.AuthorizedAddressList { + index := string(AuthorizedAddressKey(elem.Target)) + if _, ok := authorizedAddressIndexMap[index]; ok { + return fmt.Errorf("duplicated index for authorizedAddress") + } + authorizedAddressIndexMap[index] = struct{}{} + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/keyshare/types/genesis.pb.go b/x/keyshare/types/genesis.pb.go index 072d39fe..d1437dc1 100644 --- a/x/keyshare/types/genesis.pb.go +++ b/x/keyshare/types/genesis.pb.go @@ -32,6 +32,7 @@ type GenesisState struct { AggregatedKeyShareList []AggregatedKeyShare `protobuf:"bytes,4,rep,name=aggregatedKeyShareList,proto3" json:"aggregatedKeyShareList"` ActivePubKey ActivePubKey `protobuf:"bytes,5,opt,name=activePubKey,proto3" json:"activePubKey"` QueuedPubKey QueuedPubKey `protobuf:"bytes,6,opt,name=queuedPubKey,proto3" json:"queuedPubKey"` + AuthorizedAddressList []AuthorizedAddress `protobuf:"bytes,7,rep,name=authorizedAddressList,proto3" json:"authorizedAddressList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -109,6 +110,13 @@ func (m *GenesisState) GetQueuedPubKey() QueuedPubKey { return QueuedPubKey{} } +func (m *GenesisState) GetAuthorizedAddressList() []AuthorizedAddress { + if m != nil { + return m.AuthorizedAddressList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "fairyring.keyshare.GenesisState") } @@ -116,30 +124,32 @@ func init() { func init() { proto.RegisterFile("fairyring/keyshare/genesis.proto", fileDescriptor_6629804056e1ba8d) } var fileDescriptor_6629804056e1ba8d = []byte{ - // 357 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x31, 0x4f, 0xf2, 0x40, - 0x18, 0xc7, 0xdb, 0x17, 0x5e, 0x86, 0x83, 0xc1, 0x5c, 0x8c, 0x21, 0x8d, 0x29, 0x0d, 0x03, 0x61, - 0xb1, 0x24, 0xe8, 0xe0, 0x0a, 0x83, 0x26, 0xe2, 0x80, 0x90, 0x38, 0xb8, 0x90, 0xc3, 0x3e, 0x9e, - 0x0d, 0x4a, 0xeb, 0xf5, 0x4a, 0xbc, 0x6f, 0xe1, 0xc7, 0x62, 0x64, 0x74, 0x32, 0xa6, 0x7c, 0x11, - 0xd3, 0xeb, 0x01, 0xa7, 0x1c, 0xdb, 0x25, 0xf7, 0xfb, 0xff, 0xf2, 0xfc, 0x9f, 0x3c, 0xc8, 0x7b, - 0x22, 0x21, 0x13, 0x2c, 0x9c, 0xd3, 0xce, 0x0c, 0x44, 0xf2, 0x4c, 0x18, 0x74,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d, 0x80, 0xa8, 0xff, 0x97, 0x1b, 0x34, 0xb6, 0xef, 0x69, 0xdc, 0x66, - 0x62, 0x3d, 0x9b, 0xbb, 0xde, 0x52, 0x48, 0x21, 0x50, 0xae, 0xca, 0x61, 0xd7, 0x9d, 0xc6, 0x6d, - 0x5c, 0x7a, 0xb6, 0x7f, 0xb1, 0xcc, 0x5c, 0x7b, 0x95, 0xb9, 0xf6, 0x77, 0xe6, 0xda, 0x1f, 0x6b, - 0xd7, 0x5a, 0xad, 0x5d, 0xeb, 0x73, 0xed, 0x5a, 0x0f, 0xce, 0xee, 0x40, 0xde, 0x77, 0x27, 0xc2, - 0x45, 0x0c, 0xc9, 0xb4, 0x22, 0x2f, 0xe4, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x21, 0x06, - 0xbd, 0x2d, 0x03, 0x00, 0x00, + // 399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6a, 0xea, 0x40, + 0x14, 0x86, 0x93, 0xab, 0xd7, 0x0b, 0xa3, 0x8b, 0xcb, 0x70, 0x6f, 0x91, 0x50, 0x62, 0x10, 0x2a, + 0x42, 0x69, 0x04, 0xdb, 0x45, 0xb7, 0xba, 0x68, 0xa1, 0x76, 0x61, 0x15, 0xba, 0xe8, 0x26, 0x8c, + 0xcd, 0x69, 0x0c, 0xb6, 0x26, 0x9d, 0x99, 0x48, 0xd3, 0xa7, 0xe8, 0x4b, 0x15, 0x5c, 0xba, 0xec, + 0xaa, 0x14, 0x7d, 0x91, 0x92, 0xc9, 0x68, 0x52, 0x1d, 0x77, 0x03, 0xf9, 0xfe, 0x8f, 0xf3, 0x9f, + 0x1c, 0x64, 0x3d, 0x10, 0x9f, 0xc6, 0xd4, 0x9f, 0x7a, 0xad, 0x09, 0xc4, 0x6c, 0x4c, 0x28, 0xb4, + 0x3c, 0x98, 0x02, 0xf3,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e, 0x42, 0xba, 0xf7, 0xb8, 0xf0, 0x15, + 0xaa, 0x90, 0x7b, 0xee, 0xcf, 0xa0, 0x1f, 0x8d, 0x7a, 0x10, 0x57, 0x7f, 0x8b, 0x0d, 0x2a, 0xdb, + 0x77, 0x72, 0xdc, 0x7a, 0xe2, 0x7c, 0x36, 0x71, 0x3d, 0x47, 0x10, 0x81, 0x2b, 0x5d, 0xa5, 0xfd, + 0xae, 0x9b, 0x1c, 0xb7, 0x76, 0xe5, 0xb3, 0x98, 0xa0, 0xff, 0xd9, 0x01, 0x74, 0xd2, 0xff, 0x2f, + 0xca, 0xff, 0x11, 0xe5, 0x8f, 0x94, 0x03, 0x6e, 0x07, 0xa4, 0x59, 0x6d, 0xea, 0x9e, 0xcd, 0x97, + 0xa6, 0xbe, 0x58, 0x9a, 0xfa, 0xd7, 0xd2, 0xd4, 0xdf, 0x56, 0xa6, 0xb6, 0x58, 0x99, 0xda, 0xc7, + 0xca, 0xd4, 0xee, 0x8c, 0xec, 0x1c, 0x5f, 0xb2, 0x83, 0xe4, 0x71, 0x08, 0x6c, 0x54, 0x12, 0x47, + 0x78, 0xfa, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x72, 0x34, 0x24, 0x26, 0xbd, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -162,6 +172,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AuthorizedAddressList) > 0 { + for iNdEx := len(m.AuthorizedAddressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AuthorizedAddressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } { size, err := m.QueuedPubKey.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -278,6 +302,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.QueuedPubKey.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.AuthorizedAddressList) > 0 { + for _, e := range m.AuthorizedAddressList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -517,6 +547,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedAddressList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorizedAddressList = append(m.AuthorizedAddressList, AuthorizedAddress{}) + if err := m.AuthorizedAddressList[len(m.AuthorizedAddressList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/keyshare/types/genesis_test.go b/x/keyshare/types/genesis_test.go index 1627c6e8..3b35086a 100644 --- a/x/keyshare/types/genesis_test.go +++ b/x/keyshare/types/genesis_test.go @@ -49,6 +49,14 @@ func TestGenesisState_Validate(t *testing.T) { Height: 1, }, }, + AuthorizedAddressList: []types.AuthorizedAddress{ + { + Target: "0", + }, + { + Target: "1", + }, + }, // this line is used by starport scaffolding # types/genesis/validField }, valid: true, @@ -97,6 +105,20 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "duplicated authorizedAddress", + genState: &types.GenesisState{ + AuthorizedAddressList: []types.AuthorizedAddress{ + { + Target: "0", + }, + { + Target: "0", + }, + }, + }, + valid: false, + }, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/keyshare/types/key_authorized_address.go b/x/keyshare/types/key_authorized_address.go new file mode 100644 index 00000000..3a78ba34 --- /dev/null +++ b/x/keyshare/types/key_authorized_address.go @@ -0,0 +1,37 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // AuthorizedAddressKeyPrefix is the prefix to retrieve all AuthorizedAddress + AuthorizedAddressKeyPrefix = "AuthorizedAddress/value/" + + AuthorizedCountKeyPrefix = "AuthorizedCount/value/" +) + +// AuthorizedAddressKey returns the store key to retrieve a AuthorizedAddress from the index fields +func AuthorizedAddressKey( + target string, +) []byte { + var key []byte + + targetBytes := []byte(target) + key = append(key, targetBytes...) + key = append(key, []byte("/")...) + + return key +} + +func AuthorizedCountKey( + creator string, +) []byte { + var key []byte + + targetBytes := []byte(creator) + key = append(key, targetBytes...) + key = append(key, []byte("/")...) + + return key +} \ No newline at end of file diff --git a/x/keyshare/types/messages_authorized_address.go b/x/keyshare/types/messages_authorized_address.go new file mode 100644 index 00000000..f3327ad4 --- /dev/null +++ b/x/keyshare/types/messages_authorized_address.go @@ -0,0 +1,138 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeMsgCreateAuthorizedAddress = "create_authorized_address" + TypeMsgUpdateAuthorizedAddress = "update_authorized_address" + TypeMsgDeleteAuthorizedAddress = "delete_authorized_address" +) + +var _ sdk.Msg = &MsgCreateAuthorizedAddress{} + +func NewMsgCreateAuthorizedAddress( + creator string, + target string, + +) *MsgCreateAuthorizedAddress { + return &MsgCreateAuthorizedAddress{ + Creator: creator, + Target: target, + } +} + +func (msg *MsgCreateAuthorizedAddress) Route() string { + return RouterKey +} + +func (msg *MsgCreateAuthorizedAddress) Type() string { + return TypeMsgCreateAuthorizedAddress +} + +func (msg *MsgCreateAuthorizedAddress) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreateAuthorizedAddress) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreateAuthorizedAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +var _ sdk.Msg = &MsgUpdateAuthorizedAddress{} + +func NewMsgUpdateAuthorizedAddress( + creator string, + target string, + isAuthorized bool, +) *MsgUpdateAuthorizedAddress { + return &MsgUpdateAuthorizedAddress{ + Creator: creator, + Target: target, + IsAuthorized: isAuthorized, + } +} + +func (msg *MsgUpdateAuthorizedAddress) Route() string { + return RouterKey +} + +func (msg *MsgUpdateAuthorizedAddress) Type() string { + return TypeMsgUpdateAuthorizedAddress +} + +func (msg *MsgUpdateAuthorizedAddress) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateAuthorizedAddress) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateAuthorizedAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +var _ sdk.Msg = &MsgDeleteAuthorizedAddress{} + +func NewMsgDeleteAuthorizedAddress( + creator string, + target string, + +) *MsgDeleteAuthorizedAddress { + return &MsgDeleteAuthorizedAddress{ + Creator: creator, + Target: target, + } +} +func (msg *MsgDeleteAuthorizedAddress) Route() string { + return RouterKey +} + +func (msg *MsgDeleteAuthorizedAddress) Type() string { + return TypeMsgDeleteAuthorizedAddress +} + +func (msg *MsgDeleteAuthorizedAddress) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDeleteAuthorizedAddress) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDeleteAuthorizedAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/keyshare/types/messages_authorized_address_test.go b/x/keyshare/types/messages_authorized_address_test.go new file mode 100644 index 00000000..4824aab8 --- /dev/null +++ b/x/keyshare/types/messages_authorized_address_test.go @@ -0,0 +1,102 @@ +package types + +import ( + "testing" + + "fairyring/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgCreateAuthorizedAddress_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateAuthorizedAddress + err error + }{ + { + name: "invalid address", + msg: MsgCreateAuthorizedAddress{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgCreateAuthorizedAddress{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateAuthorizedAddress_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateAuthorizedAddress + err error + }{ + { + name: "invalid address", + msg: MsgUpdateAuthorizedAddress{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateAuthorizedAddress{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteAuthorizedAddress_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteAuthorizedAddress + err error + }{ + { + name: "invalid address", + msg: MsgDeleteAuthorizedAddress{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgDeleteAuthorizedAddress{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/keyshare/types/query.pb.go b/x/keyshare/types/query.pb.go index 8716eabf..dc282797 100644 --- a/x/keyshare/types/query.pb.go +++ b/x/keyshare/types/query.pb.go @@ -762,6 +762,190 @@ func (m *QueryPubKeyResponse) GetQueuedPubKey() QueuedPubKey { return QueuedPubKey{} } +type QueryGetAuthorizedAddressRequest struct { + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` +} + +func (m *QueryGetAuthorizedAddressRequest) Reset() { *m = QueryGetAuthorizedAddressRequest{} } +func (m *QueryGetAuthorizedAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetAuthorizedAddressRequest) ProtoMessage() {} +func (*QueryGetAuthorizedAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_572603c2d521bf14, []int{16} +} +func (m *QueryGetAuthorizedAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetAuthorizedAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetAuthorizedAddressRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetAuthorizedAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetAuthorizedAddressRequest.Merge(m, src) +} +func (m *QueryGetAuthorizedAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetAuthorizedAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetAuthorizedAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetAuthorizedAddressRequest proto.InternalMessageInfo + +func (m *QueryGetAuthorizedAddressRequest) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +type QueryGetAuthorizedAddressResponse struct { + AuthorizedAddress AuthorizedAddress `protobuf:"bytes,1,opt,name=authorizedAddress,proto3" json:"authorizedAddress"` +} + +func (m *QueryGetAuthorizedAddressResponse) Reset() { *m = QueryGetAuthorizedAddressResponse{} } +func (m *QueryGetAuthorizedAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetAuthorizedAddressResponse) ProtoMessage() {} +func (*QueryGetAuthorizedAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_572603c2d521bf14, []int{17} +} +func (m *QueryGetAuthorizedAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetAuthorizedAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetAuthorizedAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGetAuthorizedAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetAuthorizedAddressResponse.Merge(m, src) +} +func (m *QueryGetAuthorizedAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetAuthorizedAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetAuthorizedAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetAuthorizedAddressResponse proto.InternalMessageInfo + +func (m *QueryGetAuthorizedAddressResponse) GetAuthorizedAddress() AuthorizedAddress { + if m != nil { + return m.AuthorizedAddress + } + return AuthorizedAddress{} +} + +type QueryAllAuthorizedAddressRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllAuthorizedAddressRequest) Reset() { *m = QueryAllAuthorizedAddressRequest{} } +func (m *QueryAllAuthorizedAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllAuthorizedAddressRequest) ProtoMessage() {} +func (*QueryAllAuthorizedAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_572603c2d521bf14, []int{18} +} +func (m *QueryAllAuthorizedAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllAuthorizedAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllAuthorizedAddressRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllAuthorizedAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllAuthorizedAddressRequest.Merge(m, src) +} +func (m *QueryAllAuthorizedAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllAuthorizedAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllAuthorizedAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllAuthorizedAddressRequest proto.InternalMessageInfo + +func (m *QueryAllAuthorizedAddressRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllAuthorizedAddressResponse struct { + AuthorizedAddress []AuthorizedAddress `protobuf:"bytes,1,rep,name=authorizedAddress,proto3" json:"authorizedAddress"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllAuthorizedAddressResponse) Reset() { *m = QueryAllAuthorizedAddressResponse{} } +func (m *QueryAllAuthorizedAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllAuthorizedAddressResponse) ProtoMessage() {} +func (*QueryAllAuthorizedAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_572603c2d521bf14, []int{19} +} +func (m *QueryAllAuthorizedAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllAuthorizedAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllAuthorizedAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllAuthorizedAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllAuthorizedAddressResponse.Merge(m, src) +} +func (m *QueryAllAuthorizedAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllAuthorizedAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllAuthorizedAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllAuthorizedAddressResponse proto.InternalMessageInfo + +func (m *QueryAllAuthorizedAddressResponse) GetAuthorizedAddress() []AuthorizedAddress { + if m != nil { + return m.AuthorizedAddress + } + return nil +} + +func (m *QueryAllAuthorizedAddressResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "fairyring.keyshare.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "fairyring.keyshare.QueryParamsResponse") @@ -779,68 +963,82 @@ func init() { proto.RegisterType((*QueryAllAggregatedKeyShareResponse)(nil), "fairyring.keyshare.QueryAllAggregatedKeyShareResponse") proto.RegisterType((*QueryPubKeyRequest)(nil), "fairyring.keyshare.QueryPubKeyRequest") proto.RegisterType((*QueryPubKeyResponse)(nil), "fairyring.keyshare.QueryPubKeyResponse") + proto.RegisterType((*QueryGetAuthorizedAddressRequest)(nil), "fairyring.keyshare.QueryGetAuthorizedAddressRequest") + proto.RegisterType((*QueryGetAuthorizedAddressResponse)(nil), "fairyring.keyshare.QueryGetAuthorizedAddressResponse") + proto.RegisterType((*QueryAllAuthorizedAddressRequest)(nil), "fairyring.keyshare.QueryAllAuthorizedAddressRequest") + proto.RegisterType((*QueryAllAuthorizedAddressResponse)(nil), "fairyring.keyshare.QueryAllAuthorizedAddressResponse") } func init() { proto.RegisterFile("fairyring/keyshare/query.proto", fileDescriptor_572603c2d521bf14) } var fileDescriptor_572603c2d521bf14 = []byte{ - // 896 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x4f, 0x03, 0x45, - 0x14, 0xc7, 0x3b, 0xfc, 0x68, 0x60, 0x20, 0x31, 0x19, 0x51, 0xc9, 0x52, 0x4a, 0x19, 0x22, 0x3f, - 0x75, 0x87, 0x82, 0xa8, 0xc4, 0x44, 0x53, 0x0e, 0x62, 0xe4, 0x20, 0x94, 0xc4, 0x44, 0x62, 0x42, - 0xa6, 0x74, 0xdc, 0xae, 0x5d, 0xba, 0x65, 0x77, 0xdb, 0xd0, 0x34, 0xf5, 0xc0, 0xc1, 0xab, 0x26, - 0xfe, 0x01, 0x1e, 0x34, 0xde, 0x3c, 0x79, 0xf1, 0xe4, 0x99, 0xc4, 0x0b, 0x89, 0x17, 0x4f, 0xc6, - 0x80, 0x7f, 0x88, 0xd9, 0xd9, 0xb7, 0xdb, 0x6d, 0xbb, 0xbb, 0x2d, 0xa4, 0xb7, 0xee, 0xcc, 0x7b, - 0x6f, 0x3e, 0xef, 0xfb, 0xa6, 0xef, 0x0d, 0xce, 0x7e, 0xc5, 0x75, 0xab, 0x65, 0xe9, 0x35, 0x8d, - 0x55, 0x45, 0xcb, 0xae, 0x70, 0x4b, 0xb0, 0x9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0x63, 0x16, 0xfd, 0xfb, 0x98, 0x45, 0xdf, 0x3f, 0x65, 0x53, 0x0f, 0x4f, 0xd9, 0xd4, 0xdf, - 0x4f, 0xd9, 0xd4, 0x85, 0xd2, 0xf5, 0xba, 0xed, 0xfa, 0x39, 0xad, 0xba, 0xb0, 0x4b, 0x69, 0xf9, - 0xda, 0xdf, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x83, 0x3d, 0xe8, 0xf7, 0x41, 0x0d, 0x00, 0x00, + // 1054 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xc0, 0x33, 0x49, 0x6b, 0x35, 0x93, 0x48, 0xa8, 0x43, 0x80, 0x6a, 0xeb, 0x3a, 0xee, 0x54, + 0x4d, 0xd3, 0x06, 0x76, 0xea, 0x26, 0xa1, 0x14, 0x24, 0x90, 0x7b, 0xa0, 0x88, 0x1e, 0x68, 0x5d, + 0x09, 0xa9, 0x15, 0x52, 0x34, 0x8e, 0x87, 0xf5, 0xd6, 0x5b, 0xaf, 0xb3, 0xbb, 0x8e, 0x6a, 0x2c, + 0xf7, 0xd0, 0x2f, 0x00, 0x12, 0x1f, 0x80, 0x03, 0x88, 0x1b, 0xa7, 0x5e, 0xe0, 0xc2, 0x95, 0x4a, + 0x5c, 0x2a, 0x71, 0xe1, 0x84, 0x50, 0xc2, 0x87, 0xe0, 0x88, 0x76, 0xf6, 0xed, 0x7a, 0xed, 0x9d, + 0x1d, 0xdb, 0xc1, 0xb7, 0x78, 0xe6, 0xbd, 0x37, 0xbf, 0xf7, 0x27, 0xef, 0xbd, 0xc5, 0xa5, 0x2f, + 0xb9, 0xed, 0xf5, 0x3c, 0xbb, 0x6d, 0xb1, 0x96, 0xe8, 0xf9, 0x4d, 0xee, 0x09, 0x76, 0xd0, 0x15, + 0x5e, 0xcf, 0xec, 0x78,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xd4, 0xdb, + 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x70, 0xe6, 0x11, 0x82, 0xd2, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -870,6 +1068,9 @@ type QueryClient interface { AggregatedKeyShareAll(ctx context.Context, in *QueryAllAggregatedKeyShareRequest, opts ...grpc.CallOption) (*QueryAllAggregatedKeyShareResponse, error) // Queries the public keys PubKey(ctx context.Context, in *QueryPubKeyRequest, opts ...grpc.CallOption) (*QueryPubKeyResponse, error) + // Queries a list of AuthorizedAddress items. + AuthorizedAddress(ctx context.Context, in *QueryGetAuthorizedAddressRequest, opts ...grpc.CallOption) (*QueryGetAuthorizedAddressResponse, error) + AuthorizedAddressAll(ctx context.Context, in *QueryAllAuthorizedAddressRequest, opts ...grpc.CallOption) (*QueryAllAuthorizedAddressResponse, error) } type queryClient struct { @@ -952,6 +1153,24 @@ func (c *queryClient) PubKey(ctx context.Context, in *QueryPubKeyRequest, opts . return out, nil } +func (c *queryClient) AuthorizedAddress(ctx context.Context, in *QueryGetAuthorizedAddressRequest, opts ...grpc.CallOption) (*QueryGetAuthorizedAddressResponse, error) { + out := new(QueryGetAuthorizedAddressResponse) + err := c.cc.Invoke(ctx, "/fairyring.keyshare.Query/AuthorizedAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AuthorizedAddressAll(ctx context.Context, in *QueryAllAuthorizedAddressRequest, opts ...grpc.CallOption) (*QueryAllAuthorizedAddressResponse, error) { + out := new(QueryAllAuthorizedAddressResponse) + err := c.cc.Invoke(ctx, "/fairyring.keyshare.Query/AuthorizedAddressAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -969,6 +1188,9 @@ type QueryServer interface { AggregatedKeyShareAll(context.Context, *QueryAllAggregatedKeyShareRequest) (*QueryAllAggregatedKeyShareResponse, error) // Queries the public keys PubKey(context.Context, *QueryPubKeyRequest) (*QueryPubKeyResponse, error) + // Queries a list of AuthorizedAddress items. + AuthorizedAddress(context.Context, *QueryGetAuthorizedAddressRequest) (*QueryGetAuthorizedAddressResponse, error) + AuthorizedAddressAll(context.Context, *QueryAllAuthorizedAddressRequest) (*QueryAllAuthorizedAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -999,6 +1221,12 @@ func (*UnimplementedQueryServer) AggregatedKeyShareAll(ctx context.Context, req func (*UnimplementedQueryServer) PubKey(ctx context.Context, req *QueryPubKeyRequest) (*QueryPubKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PubKey not implemented") } +func (*UnimplementedQueryServer) AuthorizedAddress(ctx context.Context, req *QueryGetAuthorizedAddressRequest) (*QueryGetAuthorizedAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuthorizedAddress not implemented") +} +func (*UnimplementedQueryServer) AuthorizedAddressAll(ctx context.Context, req *QueryAllAuthorizedAddressRequest) (*QueryAllAuthorizedAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuthorizedAddressAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1148,6 +1376,42 @@ func _Query_PubKey_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_AuthorizedAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetAuthorizedAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AuthorizedAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fairyring.keyshare.Query/AuthorizedAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AuthorizedAddress(ctx, req.(*QueryGetAuthorizedAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AuthorizedAddressAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllAuthorizedAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AuthorizedAddressAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fairyring.keyshare.Query/AuthorizedAddressAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AuthorizedAddressAll(ctx, req.(*QueryAllAuthorizedAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "fairyring.keyshare.Query", HandlerType: (*QueryServer)(nil), @@ -1184,6 +1448,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "PubKey", Handler: _Query_PubKey_Handler, }, + { + MethodName: "AuthorizedAddress", + Handler: _Query_AuthorizedAddress_Handler, + }, + { + MethodName: "AuthorizedAddressAll", + Handler: _Query_AuthorizedAddressAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "fairyring/keyshare/query.proto", @@ -1755,97 +2027,244 @@ func (m *QueryPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetAuthorizedAddressRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *QueryGetAuthorizedAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetValidatorSetRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetAuthorizedAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Index) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryGetValidatorSetResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetAuthorizedAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.ValidatorSet.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil } -func (m *QueryAllValidatorSetRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGetAuthorizedAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllValidatorSetResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetAuthorizedAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.ValidatorSet) > 0 { - for _, e := range m.ValidatorSet { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.AuthorizedAddress.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *QueryGetKeyShareRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryAllAuthorizedAddressRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllAuthorizedAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllAuthorizedAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllAuthorizedAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllAuthorizedAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllAuthorizedAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.AuthorizedAddress) > 0 { + for iNdEx := len(m.AuthorizedAddress) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AuthorizedAddress[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetValidatorSetRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Index) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetValidatorSetResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ValidatorSet.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllValidatorSetRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllValidatorSetResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ValidatorSet) > 0 { + for _, e := range m.ValidatorSet { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetKeyShareRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = len(m.Validator) @@ -1978,6 +2397,62 @@ func (m *QueryPubKeyResponse) Size() (n int) { return n } +func (m *QueryGetAuthorizedAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetAuthorizedAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AuthorizedAddress.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllAuthorizedAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllAuthorizedAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AuthorizedAddress) > 0 { + for _, e := range m.AuthorizedAddress { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3402,6 +3877,377 @@ func (m *QueryPubKeyResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetAuthorizedAddressRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetAuthorizedAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetAuthorizedAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetAuthorizedAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryGetAuthorizedAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetAuthorizedAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedAddress", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AuthorizedAddress.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllAuthorizedAddressRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllAuthorizedAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllAuthorizedAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllAuthorizedAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllAuthorizedAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllAuthorizedAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedAddress", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorizedAddress = append(m.AuthorizedAddress, AuthorizedAddress{}) + if err := m.AuthorizedAddress[len(m.AuthorizedAddress)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/keyshare/types/query.pb.gw.go b/x/keyshare/types/query.pb.gw.go index 599acc5e..cff29d76 100644 --- a/x/keyshare/types/query.pb.gw.go +++ b/x/keyshare/types/query.pb.gw.go @@ -361,6 +361,96 @@ func local_request_Query_PubKey_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_AuthorizedAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetAuthorizedAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target") + } + + protoReq.Target, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target", err) + } + + msg, err := client.AuthorizedAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AuthorizedAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetAuthorizedAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target") + } + + protoReq.Target, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target", err) + } + + msg, err := server.AuthorizedAddress(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AuthorizedAddressAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_AuthorizedAddressAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllAuthorizedAddressRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuthorizedAddressAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AuthorizedAddressAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AuthorizedAddressAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllAuthorizedAddressRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuthorizedAddressAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AuthorizedAddressAll(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -551,6 +641,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_AuthorizedAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AuthorizedAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuthorizedAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuthorizedAddressAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AuthorizedAddressAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuthorizedAddressAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -752,6 +888,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_AuthorizedAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AuthorizedAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuthorizedAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AuthorizedAddressAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AuthorizedAddressAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AuthorizedAddressAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -771,6 +947,10 @@ var ( pattern_Query_AggregatedKeyShareAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"fairyring", "keyshare", "aggregated_key_share"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_PubKey_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"fairyring", "keyshare", "pub_key"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AuthorizedAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"fairyring", "keyshare", "authorized_address", "target"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AuthorizedAddressAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"fairyring", "keyshare", "authorized_address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -789,4 +969,8 @@ var ( forward_Query_AggregatedKeyShareAll_0 = runtime.ForwardResponseMessage forward_Query_PubKey_0 = runtime.ForwardResponseMessage + + forward_Query_AuthorizedAddress_0 = runtime.ForwardResponseMessage + + forward_Query_AuthorizedAddressAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/keyshare/types/tx.pb.go b/x/keyshare/types/tx.pb.go index dd709c24..f8d1a770 100644 --- a/x/keyshare/types/tx.pb.go +++ b/x/keyshare/types/tx.pb.go @@ -364,6 +364,278 @@ func (m *MsgCreateLatestPubKeyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateLatestPubKeyResponse proto.InternalMessageInfo +type MsgCreateAuthorizedAddress struct { + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *MsgCreateAuthorizedAddress) Reset() { *m = MsgCreateAuthorizedAddress{} } +func (m *MsgCreateAuthorizedAddress) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuthorizedAddress) ProtoMessage() {} +func (*MsgCreateAuthorizedAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{6} +} +func (m *MsgCreateAuthorizedAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuthorizedAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuthorizedAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateAuthorizedAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuthorizedAddress.Merge(m, src) +} +func (m *MsgCreateAuthorizedAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuthorizedAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuthorizedAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuthorizedAddress proto.InternalMessageInfo + +func (m *MsgCreateAuthorizedAddress) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *MsgCreateAuthorizedAddress) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type MsgCreateAuthorizedAddressResponse struct { +} + +func (m *MsgCreateAuthorizedAddressResponse) Reset() { *m = MsgCreateAuthorizedAddressResponse{} } +func (m *MsgCreateAuthorizedAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateAuthorizedAddressResponse) ProtoMessage() {} +func (*MsgCreateAuthorizedAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{7} +} +func (m *MsgCreateAuthorizedAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateAuthorizedAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateAuthorizedAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateAuthorizedAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateAuthorizedAddressResponse.Merge(m, src) +} +func (m *MsgCreateAuthorizedAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateAuthorizedAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateAuthorizedAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateAuthorizedAddressResponse proto.InternalMessageInfo + +type MsgUpdateAuthorizedAddress struct { + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + IsAuthorized bool `protobuf:"varint,2,opt,name=isAuthorized,proto3" json:"isAuthorized,omitempty"` + Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *MsgUpdateAuthorizedAddress) Reset() { *m = MsgUpdateAuthorizedAddress{} } +func (m *MsgUpdateAuthorizedAddress) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAuthorizedAddress) ProtoMessage() {} +func (*MsgUpdateAuthorizedAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{8} +} +func (m *MsgUpdateAuthorizedAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAuthorizedAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAuthorizedAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateAuthorizedAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAuthorizedAddress.Merge(m, src) +} +func (m *MsgUpdateAuthorizedAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAuthorizedAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAuthorizedAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAuthorizedAddress proto.InternalMessageInfo + +func (m *MsgUpdateAuthorizedAddress) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *MsgUpdateAuthorizedAddress) GetIsAuthorized() bool { + if m != nil { + return m.IsAuthorized + } + return false +} + +func (m *MsgUpdateAuthorizedAddress) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type MsgUpdateAuthorizedAddressResponse struct { +} + +func (m *MsgUpdateAuthorizedAddressResponse) Reset() { *m = MsgUpdateAuthorizedAddressResponse{} } +func (m *MsgUpdateAuthorizedAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateAuthorizedAddressResponse) ProtoMessage() {} +func (*MsgUpdateAuthorizedAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{9} +} +func (m *MsgUpdateAuthorizedAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateAuthorizedAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateAuthorizedAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateAuthorizedAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateAuthorizedAddressResponse.Merge(m, src) +} +func (m *MsgUpdateAuthorizedAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateAuthorizedAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateAuthorizedAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateAuthorizedAddressResponse proto.InternalMessageInfo + +type MsgDeleteAuthorizedAddress struct { + Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` + Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *MsgDeleteAuthorizedAddress) Reset() { *m = MsgDeleteAuthorizedAddress{} } +func (m *MsgDeleteAuthorizedAddress) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteAuthorizedAddress) ProtoMessage() {} +func (*MsgDeleteAuthorizedAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{10} +} +func (m *MsgDeleteAuthorizedAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteAuthorizedAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteAuthorizedAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeleteAuthorizedAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteAuthorizedAddress.Merge(m, src) +} +func (m *MsgDeleteAuthorizedAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteAuthorizedAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteAuthorizedAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteAuthorizedAddress proto.InternalMessageInfo + +func (m *MsgDeleteAuthorizedAddress) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *MsgDeleteAuthorizedAddress) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type MsgDeleteAuthorizedAddressResponse struct { +} + +func (m *MsgDeleteAuthorizedAddressResponse) Reset() { *m = MsgDeleteAuthorizedAddressResponse{} } +func (m *MsgDeleteAuthorizedAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteAuthorizedAddressResponse) ProtoMessage() {} +func (*MsgDeleteAuthorizedAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1f96ac6a55f1845c, []int{11} +} +func (m *MsgDeleteAuthorizedAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteAuthorizedAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteAuthorizedAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDeleteAuthorizedAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteAuthorizedAddressResponse.Merge(m, src) +} +func (m *MsgDeleteAuthorizedAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteAuthorizedAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteAuthorizedAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDeleteAuthorizedAddressResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgRegisterValidator)(nil), "fairyring.keyshare.MsgRegisterValidator") proto.RegisterType((*MsgRegisterValidatorResponse)(nil), "fairyring.keyshare.MsgRegisterValidatorResponse") @@ -371,39 +643,52 @@ func init() { proto.RegisterType((*MsgSendKeyshareResponse)(nil), "fairyring.keyshare.MsgSendKeyshareResponse") proto.RegisterType((*MsgCreateLatestPubKey)(nil), "fairyring.keyshare.MsgCreateLatestPubKey") proto.RegisterType((*MsgCreateLatestPubKeyResponse)(nil), "fairyring.keyshare.MsgCreateLatestPubKeyResponse") + proto.RegisterType((*MsgCreateAuthorizedAddress)(nil), "fairyring.keyshare.MsgCreateAuthorizedAddress") + proto.RegisterType((*MsgCreateAuthorizedAddressResponse)(nil), "fairyring.keyshare.MsgCreateAuthorizedAddressResponse") + proto.RegisterType((*MsgUpdateAuthorizedAddress)(nil), "fairyring.keyshare.MsgUpdateAuthorizedAddress") + proto.RegisterType((*MsgUpdateAuthorizedAddressResponse)(nil), "fairyring.keyshare.MsgUpdateAuthorizedAddressResponse") + proto.RegisterType((*MsgDeleteAuthorizedAddress)(nil), "fairyring.keyshare.MsgDeleteAuthorizedAddress") + proto.RegisterType((*MsgDeleteAuthorizedAddressResponse)(nil), "fairyring.keyshare.MsgDeleteAuthorizedAddressResponse") } func init() { proto.RegisterFile("fairyring/keyshare/tx.proto", fileDescriptor_1f96ac6a55f1845c) } var fileDescriptor_1f96ac6a55f1845c = []byte{ - // 419 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xbd, 0x8e, 0xd3, 0x40, - 0x10, 0xc7, 0xb3, 0x77, 0xc7, 0xc1, 0x0d, 0x20, 0xc4, 0x02, 0xc2, 0x32, 0x87, 0x89, 0x0c, 0x45, - 0x10, 0x92, 0x13, 0x3e, 0x0a, 0xea, 0xd0, 0x80, 0x82, 0x05, 0x72, 0x24, 0x0a, 0x2a, 0xfc, 0x31, - 0x6c, 0x56, 0x89, 0x3f, 0xb4, 0xbb, 0x41, 0xf1, 0x5b, 0xf0, 0x22, 0xbc, 0x07, 0x05, 0x45, 0x4a, - 0x4a, 0x94, 0x54, 0xbc, 0x05, 0xb2, 0xb1, 0x1d, 0x87, 0x38, 0xc1, 0xd7, 0x79, 0xe6, 0xff, 0xdb, - 0xf9, 0xf2, 0x68, 0xe0, 0xde, 0x67, 0x97, 0x8b, 0x54, 0xf0, 0x88, 0xf5, 0xa7, 0x98, 0xca, 0x89, - 0x2b, 0xb0, 0xaf, 0x16, 0x56, 0x22, 0x62, 0x15, 0x53, 0x5a, 0x89, 0x56, 0x29, 0x9a, 0x03, 0xb8, - 0x6d, 0x4b, 0xe6, 0x20, 0xe3, 0x52, 0xa1, 0xf8, 0xe0, 0xce, 0x78, 0xe0, 0xaa, 0x58, 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x58, 0x4e, 0xf0, 0xd9, 0x8f, 0x23, 0x38, 0xb6, 0x25, 0xa3, 0x31, 0xdc, - 0xdc, 0x5d, 0xbf, 0x9e, 0xb5, 0xbb, 0xab, 0x56, 0xd3, 0xda, 0xe9, 0x83, 0xb6, 0x64, 0xf5, 0xeb, - 0x3e, 0xc1, 0xb5, 0xad, 0x15, 0x7c, 0xb8, 0x27, 0x42, 0x1d, 0xd2, 0x9f, 0xb4, 0x80, 0xaa, 0x0c, - 0x02, 0x68, 0xc3, 0x24, 0x1f, 0xef, 0x09, 0xb1, 0x8b, 0xea, 0x4f, 0x5b, 0xa3, 0x65, 0xce, 0xe1, - 0x8b, 0xef, 0x2b, 0x83, 0x2c, 0x57, 0x06, 0xf9, 0xb5, 0x32, 0xc8, 0xd7, 0xb5, 0xd1, 0x59, 0xae, - 0x8d, 0xce, 0xcf, 0xb5, 0xd1, 0xf9, 0xa8, 0x6f, 0x6e, 0xc2, 0xa2, 0x76, 0x15, 0xd2, 0x04, 0xa5, - 0x77, 0x9a, 0x5f, 0x86, 0xe7, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x78, 0x77, 0x38, 0x51, 0x38, - 0x04, 0x00, 0x00, + // 544 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0xa6, 0x0d, 0xed, 0x50, 0x84, 0x58, 0x3e, 0x6a, 0x99, 0x62, 0x22, 0xd3, 0x43, + 0x10, 0x92, 0x1b, 0x3e, 0x84, 0xb8, 0xb6, 0x70, 0x00, 0x85, 0x00, 0x72, 0x05, 0x07, 0x4e, 0x38, + 0xf6, 0xe0, 0xac, 0x92, 0xd8, 0xd6, 0xee, 0x06, 0xc5, 0xdc, 0x78, 0x03, 0x5e, 0x84, 0xf7, 0xe0, + 0xd8, 0x63, 0x8f, 0x28, 0x39, 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x8f, 0xd6, 0x80, 0x32, 0x05, 0x06, 0xa4, 0x64, 0x9e, 0x1f, 0x4a, 0x4a, 0x2c, 0xa2, 0xda, 0xe3, + 0xb5, 0xd1, 0x4c, 0xf3, 0x87, 0x02, 0x07, 0xb2, 0x91, 0x36, 0x97, 0x96, 0x5b, 0xe0, 0xb5, 0xe7, + 0x9b, 0xf1, 0x05, 0x0f, 0xb2, 0x01, 0x97, 0x79, 0x90, 0xf0, 0x52, 0x0f, 0x2b, 0x86, 0x39, 0xf6, + 0x20, 0x1b, 0x65, 0x99, 0x07, 0x09, 0x2f, 0xf5, 0xb0, 0x62, 0xb4, 0x4f, 0x9f, 0xfd, 0x1e, 0xeb, + 0xca, 0xf9, 0x58, 0x57, 0xfe, 0x8c, 0x75, 0xe5, 0xe7, 0x44, 0xaf, 0x9c, 0x4f, 0xf4, 0xca, 0xc5, + 0x44, 0xaf, 0x7c, 0xd6, 0x66, 0xaf, 0xe4, 0x28, 0xf7, 0x4e, 0x46, 0x21, 0xf2, 0x4e, 0x2d, 0x7e, + 0x2b, 0x9f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x66, 0x91, 0x75, 0x4a, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -422,6 +707,9 @@ type MsgClient interface { SendKeyshare(ctx context.Context, in *MsgSendKeyshare, opts ...grpc.CallOption) (*MsgSendKeyshareResponse, error) // this line is used by starport scaffolding # proto/tx/rpc CreateLatestPubKey(ctx context.Context, in *MsgCreateLatestPubKey, opts ...grpc.CallOption) (*MsgCreateLatestPubKeyResponse, error) + CreateAuthorizedAddress(ctx context.Context, in *MsgCreateAuthorizedAddress, opts ...grpc.CallOption) (*MsgCreateAuthorizedAddressResponse, error) + UpdateAuthorizedAddress(ctx context.Context, in *MsgUpdateAuthorizedAddress, opts ...grpc.CallOption) (*MsgUpdateAuthorizedAddressResponse, error) + DeleteAuthorizedAddress(ctx context.Context, in *MsgDeleteAuthorizedAddress, opts ...grpc.CallOption) (*MsgDeleteAuthorizedAddressResponse, error) } type msgClient struct { @@ -459,12 +747,42 @@ func (c *msgClient) CreateLatestPubKey(ctx context.Context, in *MsgCreateLatestP return out, nil } +func (c *msgClient) CreateAuthorizedAddress(ctx context.Context, in *MsgCreateAuthorizedAddress, opts ...grpc.CallOption) (*MsgCreateAuthorizedAddressResponse, error) { + out := new(MsgCreateAuthorizedAddressResponse) + err := c.cc.Invoke(ctx, "/fairyring.keyshare.Msg/CreateAuthorizedAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateAuthorizedAddress(ctx context.Context, in *MsgUpdateAuthorizedAddress, opts ...grpc.CallOption) (*MsgUpdateAuthorizedAddressResponse, error) { + out := new(MsgUpdateAuthorizedAddressResponse) + err := c.cc.Invoke(ctx, "/fairyring.keyshare.Msg/UpdateAuthorizedAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) DeleteAuthorizedAddress(ctx context.Context, in *MsgDeleteAuthorizedAddress, opts ...grpc.CallOption) (*MsgDeleteAuthorizedAddressResponse, error) { + out := new(MsgDeleteAuthorizedAddressResponse) + err := c.cc.Invoke(ctx, "/fairyring.keyshare.Msg/DeleteAuthorizedAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { RegisterValidator(context.Context, *MsgRegisterValidator) (*MsgRegisterValidatorResponse, error) SendKeyshare(context.Context, *MsgSendKeyshare) (*MsgSendKeyshareResponse, error) // this line is used by starport scaffolding # proto/tx/rpc CreateLatestPubKey(context.Context, *MsgCreateLatestPubKey) (*MsgCreateLatestPubKeyResponse, error) + CreateAuthorizedAddress(context.Context, *MsgCreateAuthorizedAddress) (*MsgCreateAuthorizedAddressResponse, error) + UpdateAuthorizedAddress(context.Context, *MsgUpdateAuthorizedAddress) (*MsgUpdateAuthorizedAddressResponse, error) + DeleteAuthorizedAddress(context.Context, *MsgDeleteAuthorizedAddress) (*MsgDeleteAuthorizedAddressResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -480,6 +798,15 @@ func (*UnimplementedMsgServer) SendKeyshare(ctx context.Context, req *MsgSendKey func (*UnimplementedMsgServer) CreateLatestPubKey(ctx context.Context, req *MsgCreateLatestPubKey) (*MsgCreateLatestPubKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateLatestPubKey not implemented") } +func (*UnimplementedMsgServer) CreateAuthorizedAddress(ctx context.Context, req *MsgCreateAuthorizedAddress) (*MsgCreateAuthorizedAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateAuthorizedAddress not implemented") +} +func (*UnimplementedMsgServer) UpdateAuthorizedAddress(ctx context.Context, req *MsgUpdateAuthorizedAddress) (*MsgUpdateAuthorizedAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateAuthorizedAddress not implemented") +} +func (*UnimplementedMsgServer) DeleteAuthorizedAddress(ctx context.Context, req *MsgDeleteAuthorizedAddress) (*MsgDeleteAuthorizedAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteAuthorizedAddress not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -539,6 +866,60 @@ func _Msg_CreateLatestPubKey_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_CreateAuthorizedAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateAuthorizedAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateAuthorizedAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fairyring.keyshare.Msg/CreateAuthorizedAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateAuthorizedAddress(ctx, req.(*MsgCreateAuthorizedAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateAuthorizedAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateAuthorizedAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateAuthorizedAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fairyring.keyshare.Msg/UpdateAuthorizedAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateAuthorizedAddress(ctx, req.(*MsgUpdateAuthorizedAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_DeleteAuthorizedAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteAuthorizedAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteAuthorizedAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fairyring.keyshare.Msg/DeleteAuthorizedAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteAuthorizedAddress(ctx, req.(*MsgDeleteAuthorizedAddress)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "fairyring.keyshare.Msg", HandlerType: (*MsgServer)(nil), @@ -555,6 +936,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateLatestPubKey", Handler: _Msg_CreateLatestPubKey_Handler, }, + { + MethodName: "CreateAuthorizedAddress", + Handler: _Msg_CreateAuthorizedAddress_Handler, + }, + { + MethodName: "UpdateAuthorizedAddress", + Handler: _Msg_UpdateAuthorizedAddress_Handler, + }, + { + MethodName: "DeleteAuthorizedAddress", + Handler: _Msg_DeleteAuthorizedAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "fairyring/keyshare/tx.proto", @@ -793,24 +1186,214 @@ func (m *MsgCreateLatestPubKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgCreateAuthorizedAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgRegisterValidator) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgCreateAuthorizedAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuthorizedAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Creator) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x12 + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintTx(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateAuthorizedAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateAuthorizedAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateAuthorizedAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateAuthorizedAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateAuthorizedAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAuthorizedAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x1a + } + if m.IsAuthorized { + i-- + if m.IsAuthorized { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintTx(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateAuthorizedAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateAuthorizedAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateAuthorizedAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteAuthorizedAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteAuthorizedAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteAuthorizedAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x12 + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintTx(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteAuthorizedAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteAuthorizedAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteAuthorizedAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -913,6 +1496,87 @@ func (m *MsgCreateLatestPubKeyResponse) Size() (n int) { return n } +func (m *MsgCreateAuthorizedAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateAuthorizedAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateAuthorizedAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsAuthorized { + n += 2 + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateAuthorizedAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteAuthorizedAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Target) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDeleteAuthorizedAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1634,6 +2298,518 @@ func (m *MsgCreateLatestPubKeyResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateAuthorizedAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateAuthorizedAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuthorizedAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateAuthorizedAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateAuthorizedAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateAuthorizedAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateAuthorizedAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateAuthorizedAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAuthorizedAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsAuthorized", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsAuthorized = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateAuthorizedAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateAuthorizedAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateAuthorizedAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteAuthorizedAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteAuthorizedAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteAuthorizedAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteAuthorizedAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteAuthorizedAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteAuthorizedAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 2c784ce2b77a3df46ed5a90ee068e1ad6686651e Mon Sep 17 00:00:00 2001 From: p0p3yee Date: Thu, 6 Jul 2023 10:44:08 -0400 Subject: [PATCH 2/3] Add test authorize address test script --- scripts/tests/keyshare.sh | 42 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/scripts/tests/keyshare.sh b/scripts/tests/keyshare.sh index 3a9fd284..ba41a2cd 100755 --- a/scripts/tests/keyshare.sh +++ b/scripts/tests/keyshare.sh @@ -5,7 +5,9 @@ echo "" echo "######################################################" echo "# Submit Valid & Invalid KeyShare to KeyShare Module #" echo "# Register as a validator in KeyShare Module #" +echo "# Submit KeyShare from Authorized address #" echo "# Submit Public Key to KeyShare Module #" +echo "# Authorize address #" echo "######################################################" echo "" @@ -41,6 +43,16 @@ if [[ "$ERROR_MSG" != *"account is not staking"* ]]; then fi +echo "Non validator account authorizing another address to submit key share on chain fairyring_test_1" +RESULT=$($BINARY tx keyshare create-authorized-address $VALIDATOR_1 --from $WALLET_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) +ERROR_MSG=$(echo "$RESULT" | jq -r '.raw_log') +if [[ "$ERROR_MSG" != *"only validator can authorize address to submit key share"* ]]; then + echo "ERROR: KeyShare module authorize address error. Expected to get account is not validator error, got '$ERROR_MSG'" + echo "$RESULT" + exit 1 +fi + + echo "Registered validator submit invalid key share on chain fairyring_test_1" CURRENT_BLOCK=$($BINARY query block --home $CHAIN_DIR/$CHAINID_1 --node tcp://localhost:16657 | jq -r '.block.header.height') RESULT=$($BINARY tx keyshare send-keyshare 0000 0000 0 $(($CURRENT_BLOCK + 2)) --from $VALIDATOR_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) @@ -55,13 +67,23 @@ fi echo "Not registered account submit key share on chain fairyring_test_1" RESULT=$($BINARY tx keyshare send-keyshare 0000 0000 0 $(($CURRENT_BLOCK + 4)) --from $WALLET_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) ERROR_MSG=$(echo "$RESULT" | jq -r '.raw_log') -if [[ "$ERROR_MSG" != *"validator not registered"* ]]; then - echo "ERROR: KeyShare module submit key share from not registered account error. Expected to get account not registered error, got '$ERROR_MSG'" +if [[ "$ERROR_MSG" != *"sender is not validator / authorized address to submit key share"* ]]; then + echo "ERROR: KeyShare module submit key share from not registered account error. Expected to get account not validator / authorized address error, got '$ERROR_MSG'" echo "$RESULT" exit 1 fi +echo "Registered validator authorize another address to submit key share on chain fairyring_test_1" +RESULT=$($BINARY tx keyshare create-authorized-address $WALLET_1 --from $VALIDATOR_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) +EVENT_ATR=$(echo "$RESULT" | jq -r '.logs[0].events[0].attributes[0].value') +if [ "$EVENT_ATR" != "/fairyring.keyshare.MsgCreateAuthorizedAddress" ]; then + echo "ERROR: KeyShare module registered validator authorize address error. Expected the account to be authorized successfully, got '$EVENT_ATR'" + echo "ERROR MESSAGE: $(echo "$RESULT" | jq -r '.raw_log')" + exit 1 +fi + + GENERATED_RESULT=$($GENERATOR generate 1 1) GENERATED_SHARE=$(echo "$GENERATED_RESULT" | jq -r '.Shares[0].Value') PUB_KEY=$(echo "$GENERATED_RESULT" | jq -r '.MasterPublicKey') @@ -96,7 +118,7 @@ EXTRACTED_COMMITMENT=$(echo "$EXTRACTED_RESULT" | jq -r '.Commitment') RESULT=$($BINARY tx keyshare send-keyshare $EXTRACTED_SHARE $EXTRACTED_COMMITMENT 0 $TARGET_HEIGHT --from $VALIDATOR_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) RESULT_EVENT=$(echo "$RESULT" | jq -r '.logs[0].events[0].type') if [ "$RESULT_EVENT" != "keyshare-aggregated" ]; then - echo "ERROR: KeyShare module submit invalid key share from registered validator error. Expected the key to be aggregated, got '$RESULT_EVENT'" + echo "ERROR: KeyShare module submit valid key share from registered validator error. Expected the key to be aggregated, got '$RESULT_EVENT'" echo "ERROR MESSAGE: $(echo "$RESULT" | jq -r '.raw_log')" exit 1 fi @@ -125,6 +147,20 @@ fi echo "Key Share Successfully aggregated: '$RESULT_DATA'" +echo "Authorized address submit valid key share on chain fairyring_test_1" +TARGET_HEIGHT=$(($CURRENT_BLOCK + 61)) +EXTRACTED_RESULT=$($GENERATOR derive $GENERATED_SHARE 0 $TARGET_HEIGHT) +EXTRACTED_SHARE=$(echo "$EXTRACTED_RESULT" | jq -r '.KeyShare') +EXTRACTED_COMMITMENT=$(echo "$EXTRACTED_RESULT" | jq -r '.Commitment') +RESULT=$($BINARY tx keyshare send-keyshare $EXTRACTED_SHARE $EXTRACTED_COMMITMENT 0 $TARGET_HEIGHT --from $WALLET_1 --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --node tcp://localhost:16657 --broadcast-mode block --keyring-backend test -o json -y) +RESULT_EVENT=$(echo "$RESULT" | jq -r '.logs[0].events[0].type') +if [ "$RESULT_EVENT" != "keyshare-sent" ]; then + echo "ERROR: KeyShare module submit valid key share from authorized address error. Expected the chain received key share without error, got '$RESULT_EVENT'" + echo "ERROR MESSAGE: $(echo "$RESULT" | jq -r '.raw_log')" + exit 1 +fi + + echo "" echo "######################################################" echo "# SUCCESSFULLY TESTED #" From d5863f8fc81e0f4bb7ca8bfe9a95d55d85a71557 Mon Sep 17 00:00:00 2001 From: p0p3yee Date: Fri, 7 Jul 2023 10:37:53 -0400 Subject: [PATCH 3/3] Fix a bug that both the validator and authed addr can submit key share --- x/keyshare/keeper/msg_server_send_keyshare.go | 4 ++++ x/keyshare/types/errors.go | 1 + 2 files changed, 5 insertions(+) diff --git a/x/keyshare/keeper/msg_server_send_keyshare.go b/x/keyshare/keeper/msg_server_send_keyshare.go index 4bcb8675..3bf5607a 100644 --- a/x/keyshare/keeper/msg_server_send_keyshare.go +++ b/x/keyshare/keeper/msg_server_send_keyshare.go @@ -34,6 +34,10 @@ func (k msgServer) SendKeyshare(goCtx context.Context, msg *types.MsgSendKeyshar return nil, types.ErrAuthorizerIsNotValidator.Wrap(authorizedAddrInfo.AuthorizedBy) } validatorInfo = authorizedByValInfo + + // If the sender is in the validator set & authorized another address to submit key share + } else if count := k.GetAuthorizedCount(ctx, msg.Creator); count != 0 { + return nil, types.ErrAuthorizedAnotherAddress } // Setup diff --git a/x/keyshare/types/errors.go b/x/keyshare/types/errors.go index 77dec9ae..7b0fcb08 100644 --- a/x/keyshare/types/errors.go +++ b/x/keyshare/types/errors.go @@ -31,4 +31,5 @@ var ( ErrOnlyValidatorCanAuthorizeAddr = sdkerrors.Register(ModuleName, 1906, "only validator can authorize address to submit key share") ErrExceedMaxAuthAddr = sdkerrors.Register(ModuleName, 1907, "each validator can only authorize max 1 address to submit key share") ErrAuthorizeSelfAddress = sdkerrors.Register(ModuleName, 1908, "unable to authorize sender own address") + ErrAuthorizedAnotherAddress = sdkerrors.Register(ModuleName, 1909, "validator authorized another address to submit key share is not allow to submit key share") )