From 133e139ac2fa2fb5be3ffe972f3f27a973734021 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 5 Jul 2022 16:45:06 -0400 Subject: [PATCH] chore: x/tokenfactory audit (#1962) * updates * updates * updates * updates * Update x/tokenfactory/README.md Co-authored-by: Roman * Update x/tokenfactory/module.go Co-authored-by: Roman * updates * updates Co-authored-by: Roman --- .../tokenfactory/v1beta1/genesis.proto | 5 +- .../osmosis/tokenfactory/v1beta1/params.proto | 2 +- .../osmosis/tokenfactory/v1beta1/query.proto | 17 +++- proto/osmosis/tokenfactory/v1beta1/tx.proto | 44 +++++---- x/tokenfactory/README.md | 99 ++++++++++++------- x/tokenfactory/module.go | 50 +++++----- x/tokenfactory/types/genesis.pb.go | 3 + x/tokenfactory/types/params.pb.go | 2 +- x/tokenfactory/types/query.pb.go | 22 ++++- x/tokenfactory/types/tx.pb.go | 24 +++-- 10 files changed, 170 insertions(+), 98 deletions(-) diff --git a/proto/osmosis/tokenfactory/v1beta1/genesis.proto b/proto/osmosis/tokenfactory/v1beta1/genesis.proto index 6901a494d5d..67f94646700 100644 --- a/proto/osmosis/tokenfactory/v1beta1/genesis.proto +++ b/proto/osmosis/tokenfactory/v1beta1/genesis.proto @@ -18,6 +18,9 @@ message GenesisState { ]; } +// GenesisDenom defines a tokenfactory denom that is defined within genesis +// state. The structure contains DenomAuthorityMetadata which defines the +// denom's admin. message GenesisDenom { option (gogoproto.equal) = true; @@ -26,4 +29,4 @@ message GenesisDenom { (gogoproto.moretags) = "yaml:\"authority_metadata\"", (gogoproto.nullable) = false ]; -} \ No newline at end of file +} diff --git a/proto/osmosis/tokenfactory/v1beta1/params.proto b/proto/osmosis/tokenfactory/v1beta1/params.proto index 6cbe6090fa5..0aafb65ecf4 100644 --- a/proto/osmosis/tokenfactory/v1beta1/params.proto +++ b/proto/osmosis/tokenfactory/v1beta1/params.proto @@ -8,7 +8,7 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; -// Params holds parameters for the tokenfactory module +// Params defines the parameters for the tokenfactory module. message Params { repeated cosmos.base.v1beta1.Coin denom_creation_fee = 1 [ (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", diff --git a/proto/osmosis/tokenfactory/v1beta1/query.proto b/proto/osmosis/tokenfactory/v1beta1/query.proto index c1e3b3717dd..d4811ad9f08 100644 --- a/proto/osmosis/tokenfactory/v1beta1/query.proto +++ b/proto/osmosis/tokenfactory/v1beta1/query.proto @@ -11,17 +11,22 @@ option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; // Query defines the gRPC querier service. service Query { - // Params returns the total set of minting parameters. + // Params defines a gRPC query method that returns the tokenfactory module's + // parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/osmosis/tokenfactory/v1beta1/params"; } + // DenomAuthorityMetadata defines a gRPC query method for fetching + // DenomAuthorityMetadata for a particular denom. rpc DenomAuthorityMetadata(QueryDenomAuthorityMetadataRequest) returns (QueryDenomAuthorityMetadataResponse) { option (google.api.http).get = "/osmosis/tokenfactory/v1beta1/denoms/{denom}/authority_metadata"; } + // DenomsFromCreator defines a gRPC query method for fetching all + // denominations created by a specific admin/creator. rpc DenomsFromCreator(QueryDenomsFromCreatorRequest) returns (QueryDenomsFromCreatorResponse) { option (google.api.http).get = @@ -38,9 +43,14 @@ message QueryParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } +// QueryDenomAuthorityMetadataRequest defines the request structure for the +// DenomAuthorityMetadata gRPC query. message QueryDenomAuthorityMetadataRequest { string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; } + +// QueryDenomAuthorityMetadataResponse defines the response structure for the +// DenomAuthorityMetadata gRPC query. message QueryDenomAuthorityMetadataResponse { DenomAuthorityMetadata authority_metadata = 1 [ (gogoproto.moretags) = "yaml:\"authority_metadata\"", @@ -48,9 +58,14 @@ message QueryDenomAuthorityMetadataResponse { ]; } +// QueryDenomsFromCreatorRequest defines the request structure for the +// DenomsFromCreator gRPC query. message QueryDenomsFromCreatorRequest { string creator = 1 [ (gogoproto.moretags) = "yaml:\"creator\"" ]; } + +// QueryDenomsFromCreatorRequest defines the response structure for the +// DenomsFromCreator gRPC query. message QueryDenomsFromCreatorResponse { repeated string denoms = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ]; } diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index 8d358394592..7391d4dd295 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -6,24 +6,27 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; -// Msg defines the Msg service. +// Msg defines the tokefactory module's gRPC message service. service Msg { rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); rpc Mint(MsgMint) returns (MsgMintResponse); rpc Burn(MsgBurn) returns (MsgBurnResponse); + rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); + // ForceTransfer is deactivated for now because we need to think through edge // cases rpc ForceTransfer(MsgForceTransfer) returns // (MsgForceTransferResponse); - rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); } -// MsgCreateDenom is the sdk.Msg type for allowing an account to create -// a new denom. It requires a sender address and a subdenomination. -// The (sender_address, sub_denomination) pair must be unique and cannot be -// re-used. The resulting denom created is `factory/{creator -// address}/{subdenom}`. The resultant denom's admin is originally set to be the -// creator, but this can be changed later. The token denom does not indicate the -// current admin. +// MsgCreateDenom defines the message structure for the CreateDenom gRPC service +// method. It allows an account to create a new denom. It requires a sender +// address and a sub denomination. The (sender_address, sub_denomination) tuple +// must be unique and cannot be re-used. +// +// The resulting denom created is defined as +// . The resulting denom's admin is +// originally set to be the creator, but this can be changed later. The token +// denom does not indicate the current admin. message MsgCreateDenom { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; // subdenom can be up to 44 "alphanumeric" characters long. @@ -61,7 +64,18 @@ message MsgBurn { message MsgBurnResponse {} -// // ===================== MsgForceTransfer +// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign +// adminship of a denom to a new account +message MsgChangeAdmin { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; + string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; +} + +// MsgChangeAdminResponse defines the response structure for an executed +// MsgChangeAdmin message. +message MsgChangeAdminResponse {} + // message MsgForceTransfer { // string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; // cosmos.base.v1beta1.Coin amount = 2 [ @@ -75,13 +89,3 @@ message MsgBurnResponse {} // } // message MsgForceTransferResponse {} - -// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign -// adminship of a denom to a new account -message MsgChangeAdmin { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; - string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; -} - -message MsgChangeAdminResponse {} \ No newline at end of file diff --git a/x/tokenfactory/README.md b/x/tokenfactory/README.md index c976498431e..4f1f4fea2c4 100644 --- a/x/tokenfactory/README.md +++ b/x/tokenfactory/README.md @@ -11,18 +11,20 @@ created denom. Once a denom is created, the original creator is given - Mint their denom to any account - Burn their denom from any account - Create a transfer of their denom between any two accounts -- Change the admin In the future, more admin capabilities may be - added. Admins can choose to share admin privileges with other - accounts using the authz module. The `ChangeAdmin` functionality, - allows changing the master admin account, or even setting it to - `""`, meaning no account has admin privileges of the asset. - +- Change the admin. In the future, more admin capabilities may be added. Admins + can choose to share admin privileges with other accounts using the authz + module. The `ChangeAdmin` functionality, allows changing the master admin + account, or even setting it to `""`, meaning no account has admin privileges + of the asset. ## Messages ### CreateDenom -- Creates a denom of `factory/{creator address}/{subdenom}` given the denom creator address and the subdenom. Subdenoms can contain `[a-zA-Z0-9./]`. -``` {.go} + +Creates a denom of `factory/{creator address}/{subdenom}` given the denom creator +address and the subdenom. Subdenoms can contain `[a-zA-Z0-9./]`. + +```go message MsgCreateDenom { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; string subdenom = 2 [ (gogoproto.moretags) = "yaml:\"subdenom\"" ]; @@ -30,14 +32,22 @@ message MsgCreateDenom { ``` **State Modifications:** -- Fund community pool with the denom creation fee from the creator address, set in `Params` -- Set `DenomMetaData` via bank keeper -- Set `AuthorityMetadata` for the given denom to store the admin for the created denom `factory/{creator address}/{subdenom}`. Admin is automatically set as the Msg sender -- Add denom to the `CreatorPrefixStore`, where a state of denoms created per creator is kept + +- Fund community pool with the denom creation fee from the creator address, set + in `Params`. +- Set `DenomMetaData` via bank keeper. +- Set `AuthorityMetadata` for the given denom to store the admin for the created + denom `factory/{creator address}/{subdenom}`. Admin is automatically set as the + Msg sender. +- Add denom to the `CreatorPrefixStore`, where a state of denoms created per + creator is kept. ### Mint -- Minting of a specific denom is only allowed for the creator of the denom registered during `CreateDenom` -``` {.go} + +Minting of a specific denom is only allowed for the creator of the denom +registered during `CreateDenom`. + +```go message MsgMint { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; cosmos.base.v1beta1.Coin amount = 2 [ @@ -48,16 +58,18 @@ message MsgMint { ``` **State Modifications:** + - Safety check the following - Check that the denom minting is created via `tokenfactory` module - Check that the sender of the message is the admin of the denom - Mint designated amount of tokens for the denom via `bank` module +### Burn +Burning of a specific denom is only allowed for the creator of the denom +registered during `CreateDenom`. -### Burn -- Burning of a specific denom is only allowed for the creator of the denom registered during `CreateDenom` -``` {.go} +```go message MsgBurn { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; cosmos.base.v1beta1.Coin amount = 2 [ @@ -68,15 +80,18 @@ message MsgBurn { ``` **State Modifications:** + - Saftey check the following - Check that the denom minting is created via `tokenfactory` module - Check that the sender of the message is the admin of the denom - Burn designated amount of tokens for the denom via `bank` module - ### ChangeAdmin -- Burning of a specific denom is only allowed for the creator of the denom registered during `CreateDenom` -``` {.go} + +Burning of a specific denom is only allowed for the creator of the denom +registered during `CreateDenom`. + +```go message MsgChangeAdmin { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; @@ -85,6 +100,7 @@ message MsgChangeAdmin { ``` **State Modifications:** + - Check that sender of the message is the admin of denom - Modify `AuthorityMetadata` state entry to change the admin of the denom @@ -92,26 +108,37 @@ message MsgChangeAdmin { The chain's bech32 prefix for addresses can be at most 16 characters long. -This comes from denoms having a 128 byte maximum length, enforced from the SDK, and us setting longest_subdenom to be 44 bytes. -A token factory token's denom is: -`factory/{creator address}/{subdenom}` +This comes from denoms having a 128 byte maximum length, enforced from the SDK, +and us setting longest_subdenom to be 44 bytes. + +A token factory token's denom is: `factory/{creator address}/{subdenom}` + Splitting up into sub-components, this has: -* `len(factory) = 7` -* `2 * len("/") = 2` -* `len(longest_subdenom)` -* `len(creator_address) = len(bech32(longest_addr_length, chain_addr_prefix))`. -Longest addr length at the moment is `32 bytes`. -Due to SDK error correction settings, this means `len(bech32(32, chain_addr_prefix)) = len(chain_addr_prefix) + 1 + 58`. + +- `len(factory) = 7` +- `2 * len("/") = 2` +- `len(longest_subdenom)` +- `len(creator_address) = len(bech32(longest_addr_length, chain_addr_prefix))`. + +Longest addr length at the moment is `32 bytes`. Due to SDK error correction +settings, this means `len(bech32(32, chain_addr_prefix)) = len(chain_addr_prefix) + 1 + 58`. Adding this all, we have a total length constraint of `128 = 7 + 2 + len(longest_subdenom) + len(longest_chain_addr_prefix) + 1 + 58`. Therefore `len(longest_subdenom) + len(longest_chain_addr_prefix) = 128 - (7 + 2 + 1 + 58) = 60`. -The choice between how we standardized the split these 60 bytes between maxes from longest_subdenom and longest_chain_addr_prefix is somewhat arbitrary. Considerations going into this: -* Per [BIP-0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32) the technically longest HRP for a 32 byte address ('data field') is 31 bytes. (Comes from encode(data) = 59 bytes, and max length = 90 bytes) -* subdenom should be at least 32 bytes so hashes can go into it -* longer subdenoms are very helpful for creating human readable denoms -* chain addresses should prefer being smaller. The longest HRP in cosmos to date is 11 bytes. (`persistence`) +The choice between how we standardized the split these 60 bytes between maxes +from longest_subdenom and longest_chain_addr_prefix is somewhat arbitrary. +Considerations going into this: + +- Per [BIP-0173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32) + the technically longest HRP for a 32 byte address ('data field') is 31 bytes. + (Comes from encode(data) = 59 bytes, and max length = 90 bytes) +- subdenom should be at least 32 bytes so hashes can go into it +- longer subdenoms are very helpful for creating human readable denoms +- chain addresses should prefer being smaller. The longest HRP in cosmos to date is 11 bytes. (`persistence`) For explicitness, its currently set to `len(longest_subdenom) = 44` and `len(longest_chain_addr_prefix) = 16`. -Please note, if the SDK increases the maximum length of a denom from 128 bytes, these caps should increase. -So please don't make code rely on these max lengths for parsing. \ No newline at end of file +Please note, if the SDK increases the maximum length of a denom from 128 bytes, +these caps should increase. + +So please don't make code rely on these max lengths for parsing. diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index c2b7d691e33..68a0207310e 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -5,17 +5,15 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" - - abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/client/cli" "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" @@ -40,7 +38,7 @@ func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { return AppModuleBasic{cdc: cdc} } -// Name returns the capability module's name. +// Name returns the x/tokenfactory module's name. func (AppModuleBasic) Name() string { return types.ModuleName } @@ -54,17 +52,18 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { types.RegisterInterfaces(reg) } -// DefaultGenesis returns the capability module's default genesis state. +// DefaultGenesis returns the x/tokenfactory module's default genesis state. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) } -// ValidateGenesis performs genesis state validation for the capability module. +// ValidateGenesis performs genesis state validation for the x/tokenfactory module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { var genState types.GenesisState if err := cdc.UnmarshalJSON(bz, &genState); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } + return genState.Validate() } @@ -77,12 +76,12 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck } -// GetTxCmd returns the tokenfactory module's root tx command. +// GetTxCmd returns the x/tokenfactory module's root tx command. func (a AppModuleBasic) GetTxCmd() *cobra.Command { return cli.GetTxCmd() } -// GetQueryCmd returns the tokenfactory module's root query command. +// GetQueryCmd returns the x/tokenfactory module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } @@ -100,30 +99,34 @@ type AppModule struct { bankKeeper types.BankKeeper } -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper) AppModule { +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - - accountKeeper: accountKeeper, - bankKeeper: bankKeeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, } } -// Name returns the capability module's name. +// Name returns the x/tokenfactory module's name. func (am AppModule) Name() string { return am.AppModuleBasic.Name() } -// Route returns the capability module's message routing key. +// Route returns the x/tokenfactory module's message routing key. func (am AppModule) Route() sdk.Route { return sdk.Route{} } -// QuerierRoute returns the capability module's query routing key. +// QuerierRoute returns the x/tokenfactory module's query routing key. func (AppModule) QuerierRoute() string { return types.QuerierRoute } -// LegacyQuerierHandler returns the capability module's Querier. +// LegacyQuerierHandler returns the x/tokenfactory module's Querier. func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return nil } @@ -135,11 +138,11 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } -// RegisterInvariants registers the tokenfactory module's invariants. +// RegisterInvariants registers the x/tokenfactory module's invariants. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// InitGenesis performs the tokenfactory module's genesis initialization It returns -// no validator updates. +// InitGenesis performs the x/tokenfactory module's genesis initialization. It +// returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { var genState types.GenesisState cdc.MustUnmarshalJSON(gs, &genState) @@ -149,7 +152,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra return []abci.ValidatorUpdate{} } -// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +// ExportGenesis returns the x/tokenfactory module's exported genesis state as raw +// JSON bytes. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { genState := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(genState) diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go index 666c0d495bd..9e7458096ba 100644 --- a/x/tokenfactory/types/genesis.pb.go +++ b/x/tokenfactory/types/genesis.pb.go @@ -77,6 +77,9 @@ func (m *GenesisState) GetFactoryDenoms() []GenesisDenom { return nil } +// GenesisDenom defines a tokenfactory denom that is defined within genesis +// state. The structure contains DenomAuthorityMetadata which defines the +// denom's admin. type GenesisDenom struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,2,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"` diff --git a/x/tokenfactory/types/params.pb.go b/x/tokenfactory/types/params.pb.go index b8f90a9b98c..6755f175e5e 100644 --- a/x/tokenfactory/types/params.pb.go +++ b/x/tokenfactory/types/params.pb.go @@ -26,7 +26,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Params holds parameters for the tokenfactory module +// Params defines the parameters for the tokenfactory module. type Params struct { DenomCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=denom_creation_fee,json=denomCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"denom_creation_fee" yaml:"denom_creation_fee"` } diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index c71398eb8f4..a8eb09754b1 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -113,6 +113,8 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryDenomAuthorityMetadataRequest defines the request structure for the +// DenomAuthorityMetadata gRPC query. type QueryDenomAuthorityMetadataRequest struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` } @@ -157,6 +159,8 @@ func (m *QueryDenomAuthorityMetadataRequest) GetDenom() string { return "" } +// QueryDenomAuthorityMetadataResponse defines the response structure for the +// DenomAuthorityMetadata gRPC query. type QueryDenomAuthorityMetadataResponse struct { AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,1,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"` } @@ -201,6 +205,8 @@ func (m *QueryDenomAuthorityMetadataResponse) GetAuthorityMetadata() DenomAuthor return DenomAuthorityMetadata{} } +// QueryDenomsFromCreatorRequest defines the request structure for the +// DenomsFromCreator gRPC query. type QueryDenomsFromCreatorRequest struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"` } @@ -245,6 +251,8 @@ func (m *QueryDenomsFromCreatorRequest) GetCreator() string { return "" } +// QueryDenomsFromCreatorRequest defines the response structure for the +// DenomsFromCreator gRPC query. type QueryDenomsFromCreatorResponse struct { Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty" yaml:"denoms"` } @@ -354,9 +362,14 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Params returns the total set of minting parameters. + // Params defines a gRPC query method that returns the tokenfactory module's + // parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // DenomAuthorityMetadata defines a gRPC query method for fetching + // DenomAuthorityMetadata for a particular denom. DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) + // DenomsFromCreator defines a gRPC query method for fetching all + // denominations created by a specific admin/creator. DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) } @@ -397,9 +410,14 @@ func (c *queryClient) DenomsFromCreator(ctx context.Context, in *QueryDenomsFrom // QueryServer is the server API for Query service. type QueryServer interface { - // Params returns the total set of minting parameters. + // Params defines a gRPC query method that returns the tokenfactory module's + // parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // DenomAuthorityMetadata defines a gRPC query method for fetching + // DenomAuthorityMetadata for a particular denom. DenomAuthorityMetadata(context.Context, *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) + // DenomsFromCreator defines a gRPC query method for fetching all + // denominations created by a specific admin/creator. DenomsFromCreator(context.Context, *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) } diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index ead34210afa..e3088cd3959 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -29,13 +29,15 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreateDenom is the sdk.Msg type for allowing an account to create -// a new denom. It requires a sender address and a subdenomination. -// The (sender_address, sub_denomination) pair must be unique and cannot be -// re-used. The resulting denom created is `factory/{creator -// address}/{subdenom}`. The resultant denom's admin is originally set to be the -// creator, but this can be changed later. The token denom does not indicate the -// current admin. +// MsgCreateDenom defines the message structure for the CreateDenom gRPC service +// method. It allows an account to create a new denom. It requires a sender +// address and a sub denomination. The (sender_address, sub_denomination) tuple +// must be unique and cannot be re-used. +// +// The resulting denom created is defined as +// . The resulting denom's admin is +// originally set to be the creator, but this can be changed later. The token +// denom does not indicate the current admin. type MsgCreateDenom struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` // subdenom can be up to 44 "alphanumeric" characters long. @@ -377,6 +379,8 @@ func (m *MsgChangeAdmin) GetNewAdmin() string { return "" } +// MsgChangeAdminResponse defines the response structure for an executed +// MsgChangeAdmin message. type MsgChangeAdminResponse struct { } @@ -480,9 +484,6 @@ type MsgClient interface { CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) - // ForceTransfer is deactivated for now because we need to think through edge - // cases rpc ForceTransfer(MsgForceTransfer) returns - // (MsgForceTransferResponse); ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) } @@ -535,9 +536,6 @@ type MsgServer interface { CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) Mint(context.Context, *MsgMint) (*MsgMintResponse, error) Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) - // ForceTransfer is deactivated for now because we need to think through edge - // cases rpc ForceTransfer(MsgForceTransfer) returns - // (MsgForceTransferResponse); ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error) }