Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tokenfactory): execute msgs for CreateDenom, ChangeAdmin, UpdateModuleParams #1607

Merged
merged 18 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#1596](https://github.com/NibiruChain/nibiru/pull/1596) - epic(tokenfactory):
State transitions, collections, genesis import and export, and app wiring
* [#1607](https://github.com/NibiruChain/nibiru/pull/1607) - Token factory
transaction messages for CreateDenom, ChangeAdmin, and UpdateModuleParams

### State Machine Breaking

Expand Down
16 changes: 16 additions & 0 deletions proto/nibiru/tokenfactory/v1/event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

package nibiru.tokenfactory.v1;

option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types";

message EventCreateDenom {
string denom = 1;
string creator = 2;
}

message EventChangeAdmin {
string denom = 1;
string old_admin = 3;
string new_admin = 2;
}
32 changes: 31 additions & 1 deletion proto/nibiru/tokenfactory/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package nibiru.tokenfactory.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "nibiru/tokenfactory/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types";
Expand All @@ -15,6 +16,16 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/nibiru/tokenfactory/v1/params";
}

// Denoms retrieves all registered denoms for a given creator
rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) {
option (google.api.http).get = "/nibiru/tokenfactory/v1/denoms/{creator}";
}

// DenomInfo retrieves the denom metadata and admin info
rpc DenomInfo(QueryDenomInfoRequest) returns (QueryDenomInfoResponse) {
option (google.api.http).get = "/nibiru/tokenfactory/v1/denom-info/{denom}";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
Expand All @@ -23,5 +34,24 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// Module parameters stored in state
ModuleParams params = 1 [ (gogoproto.nullable) = false ];
nibiru.tokenfactory.v1.ModuleParams params = 1
[ (gogoproto.nullable) = false ];
}

// QueryDenomsRequest: gRPC query for all denoms registered for a creator
message QueryDenomsRequest { string creator = 1; }

// QueryDenomsResponse: All registered denoms for a creator
message QueryDenomsResponse { repeated string denoms = 1; }

// QueryDenomInfoRequest: gRPC query for the denom admin and x/bank metadata
message QueryDenomInfoRequest { string denom = 1; }

// QueryDenomInfoResponse: All registered denoms for a creator
message QueryDenomInfoResponse {
// Admin of the token factory denom
string admin = 1;
// Metadata: Official x/bank metadata for the denom. All token factory denoms
// are standard, native assets.
cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.nullable) = false ];
}
65 changes: 64 additions & 1 deletion proto/nibiru/tokenfactory/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,70 @@ syntax = "proto3";

package nibiru.tokenfactory.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "nibiru/tokenfactory/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types";

// Msg defines the gRPC Msg service for transactions.
service Msg {}
service Msg {
// CreateDenom: registers a token factory denom.
rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse);
rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse);
// UpdateModuleParams: A governance operation for updating the x/tokenfactory
// module parameters.
rpc UpdateModuleParams(MsgUpdateModuleParams)
returns (MsgUpdateModuleParamsResponse);
// TODO MsgMint
// TODO MsgBurn
// TODO MsgSetDenomMetadata
// TODO MsgForceTransfer
}

// MsgCreateDenom: sdk.Msg that registers an a token factory denom.
// A denom has the form "tf/[creatorAddr]/[subdenom]".
// - Denoms become unique x/bank tokens, so the creator-subdenom pair that
// defines a denom cannot be reused.
// - The resulting denom's admin is originally set to be the creator, but the
// admin can be changed later.
message MsgCreateDenom {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
// subdenom can be up to 44 "alphanumeric" characters long.
string subdenom = 2 [ (gogoproto.moretags) = "yaml:\"subdenom\"" ];
}

// MsgCreateDenomResponse is the return value of MsgCreateDenom
message MsgCreateDenomResponse {
// NewTokenDenom: identifier for the newly created token factory denom.
string new_token_denom = 1
[ (gogoproto.moretags) = "yaml:\"new_token_denom\"" ];
}

// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to change
// admin 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 is the gRPC response for the MsgChangeAdmin TxMsg.
message MsgChangeAdminResponse {}

// MsgUpdateModuleParams: sdk.Msg for updating the x/tokenfactory module params
message MsgUpdateModuleParams {
option (cosmos.msg.v1.signer) = "authority";

// Authority: Address of the governance module account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

nibiru.tokenfactory.v1.ModuleParams params = 2
[ (gogoproto.nullable) = false ];
}

// MsgUpdateModuleParamsResponse is the gRPC response for the
// MsgUpdateModuleParams TxMsg.
message MsgUpdateModuleParamsResponse {}
17 changes: 16 additions & 1 deletion x/common/testutil/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,23 @@
}
}

func (chain Network) ExecQuery(
cmd *cobra.Command,
args []string,
result codec.ProtoMarshaler,
opts ...ExecQueryOption,
) error {
return ExecQuery(chain.Validators[0].ClientCtx, cmd, args, result, opts...)

Check warning on line 56 in x/common/testutil/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/common/testutil/cli/query.go#L55-L56

Added lines #L55 - L56 were not covered by tests
}

// ExecQuery executes a CLI query onto the provided Network.
func ExecQuery(clientCtx client.Context, cmd *cobra.Command, args []string, result codec.ProtoMarshaler, opts ...ExecQueryOption) error {
func ExecQuery(
clientCtx client.Context,
cmd *cobra.Command,
args []string,
result codec.ProtoMarshaler,
opts ...ExecQueryOption,
) error {
var options queryOptions
for _, o := range opts {
o(&options)
Expand Down
7 changes: 7 additions & 0 deletions x/common/testutil/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

// AccAddress returns a sample address (sdk.AccAddress) created using secp256k1.
Expand Down Expand Up @@ -77,3 +80,7 @@ func RandLetters(n int) string {
}
return string(b)
}

func GovModuleAddr() sdk.AccAddress {
return authtypes.NewModuleAddress(govtypes.ModuleName)
}
18 changes: 9 additions & 9 deletions x/devgas/v1/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ func NewTxCmd() *cobra.Command {
}

txCmd.AddCommand(
NewRegisterFeeShare(),
NewCancelFeeShare(),
NewUpdateFeeShare(),
CmdRegisterFeeShare(),
CmdCancelFeeShare(),
CmdUpdateFeeShare(),
)
return txCmd
}

// NewRegisterFeeShare returns a CLI command handler for registering a
// CmdRegisterFeeShare returns a CLI command handler for registering a
// contract for fee distribution
func NewRegisterFeeShare() *cobra.Command {
func CmdRegisterFeeShare() *cobra.Command {
cmd := &cobra.Command{
Use: "register [contract_bech32] [withdraw_bech32]",
Short: "Register a contract for fee distribution. Only the contract admin can register a contract.",
Expand Down Expand Up @@ -69,9 +69,9 @@ func NewRegisterFeeShare() *cobra.Command {
return cmd
}

// NewCancelFeeShare returns a CLI command handler for canceling a
// CmdCancelFeeShare returns a CLI command handler for canceling a
// contract for fee distribution
func NewCancelFeeShare() *cobra.Command {
func CmdCancelFeeShare() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel [contract_bech32]",
Short: "Cancel a contract from feeshare distribution",
Expand Down Expand Up @@ -104,9 +104,9 @@ func NewCancelFeeShare() *cobra.Command {
return cmd
}

// NewUpdateFeeShare returns a CLI command handler for updating the withdraw
// CmdUpdateFeeShare returns a CLI command handler for updating the withdraw
// address of a contract for fee distribution
func NewUpdateFeeShare() *cobra.Command {
func CmdUpdateFeeShare() *cobra.Command {
cmd := &cobra.Command{
Use: "update [contract_bech32] [new_withdraw_bech32]",
Short: "Update withdrawer address for a contract registered for feeshare distribution.",
Expand Down
7 changes: 4 additions & 3 deletions x/sudo/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (m MsgEditSudoers) ValidateBasic() error {
return nil
}

// GetSigners implements the sdk.Msg interface.
func (m MsgEditSudoers) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
Expand All @@ -43,13 +44,13 @@ func (m MsgEditSudoers) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{signer}
}

// Route Implements Msg.
// Route implements the sdk.Msg interface.
jgimeno marked this conversation as resolved.
Show resolved Hide resolved
func (msg MsgEditSudoers) Route() string { return ModuleName }

// Type Implements Msg.
// Type implements the sdk.Msg interface.
func (msg MsgEditSudoers) Type() string { return "edit_sudoers" }

// GetSignBytes Implements Msg.
// GetSignBytes implements the sdk.Msg interface.
func (m MsgEditSudoers) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
Expand Down
Loading
Loading