From 70c3e250f8b748f7c3e40f9ec87948fab6e6f570 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 11 Nov 2021 21:00:38 +0000 Subject: [PATCH 01/22] init --- go.mod | 1 + go.sum | 3 +- proto/osmosis/tokenfactory/genesis.proto | 11 + proto/osmosis/tokenfactory/query.proto | 15 + proto/osmosis/tokenfactory/tx.proto | 28 ++ testutil/keeper/tokenfactory.go | 39 ++ x/tokenfactory/client/cli/query.go | 30 ++ x/tokenfactory/client/cli/tx.go | 35 ++ x/tokenfactory/genesis.go | 22 + x/tokenfactory/genesis_test.go | 23 + x/tokenfactory/handler.go | 26 + x/tokenfactory/keeper/admins.go | 39 ++ x/tokenfactory/keeper/burners.go | 37 ++ x/tokenfactory/keeper/denommint.go | 39 ++ x/tokenfactory/keeper/grpc_query.go | 7 + x/tokenfactory/keeper/keeper.go | 41 ++ x/tokenfactory/keeper/minters.go | 39 ++ x/tokenfactory/keeper/msg_server.go | 38 ++ x/tokenfactory/keeper/msg_server_test.go | 16 + x/tokenfactory/module.go | 166 +++++++ x/tokenfactory/types/codec.go | 23 + x/tokenfactory/types/errors.go | 12 + x/tokenfactory/types/expected_keepers.go | 20 + x/tokenfactory/types/genesis.go | 23 + x/tokenfactory/types/genesis.pb.go | 266 +++++++++++ x/tokenfactory/types/genesis_test.go | 39 ++ x/tokenfactory/types/keys.go | 28 ++ x/tokenfactory/types/query.pb.go | 87 ++++ x/tokenfactory/types/tx.pb.go | 580 +++++++++++++++++++++++ x/tokenfactory/types/types.go | 1 + 30 files changed, 1733 insertions(+), 1 deletion(-) create mode 100644 proto/osmosis/tokenfactory/genesis.proto create mode 100644 proto/osmosis/tokenfactory/query.proto create mode 100644 proto/osmosis/tokenfactory/tx.proto create mode 100644 testutil/keeper/tokenfactory.go create mode 100644 x/tokenfactory/client/cli/query.go create mode 100644 x/tokenfactory/client/cli/tx.go create mode 100644 x/tokenfactory/genesis.go create mode 100644 x/tokenfactory/genesis_test.go create mode 100644 x/tokenfactory/handler.go create mode 100644 x/tokenfactory/keeper/admins.go create mode 100644 x/tokenfactory/keeper/burners.go create mode 100644 x/tokenfactory/keeper/denommint.go create mode 100644 x/tokenfactory/keeper/grpc_query.go create mode 100644 x/tokenfactory/keeper/keeper.go create mode 100644 x/tokenfactory/keeper/minters.go create mode 100644 x/tokenfactory/keeper/msg_server.go create mode 100644 x/tokenfactory/keeper/msg_server_test.go create mode 100644 x/tokenfactory/module.go create mode 100644 x/tokenfactory/types/codec.go create mode 100644 x/tokenfactory/types/errors.go create mode 100644 x/tokenfactory/types/expected_keepers.go create mode 100644 x/tokenfactory/types/genesis.go create mode 100644 x/tokenfactory/types/genesis.pb.go create mode 100644 x/tokenfactory/types/genesis_test.go create mode 100644 x/tokenfactory/types/keys.go create mode 100644 x/tokenfactory/types/query.pb.go create mode 100644 x/tokenfactory/types/tx.pb.go create mode 100644 x/tokenfactory/types/types.go diff --git a/go.mod b/go.mod index 55d236fbf17..fdf0930bd64 100644 --- a/go.mod +++ b/go.mod @@ -59,6 +59,7 @@ require ( github.com/gogo/gateway v1.1.0 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/google/btree v1.0.0 // indirect + github.com/google/go-cmp v0.5.6 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/go.sum b/go.sum index 51a9aeda300..7443534d026 100644 --- a/go.sum +++ b/go.sum @@ -350,8 +350,9 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= diff --git a/proto/osmosis/tokenfactory/genesis.proto b/proto/osmosis/tokenfactory/genesis.proto new file mode 100644 index 00000000000..852b214390d --- /dev/null +++ b/proto/osmosis/tokenfactory/genesis.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package osmosislabs.osmosis.tokenfactory; + +// this line is used by starport scaffolding # genesis/proto/import + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// GenesisState defines the tokenfactory module's genesis state. +message GenesisState { + // this line is used by starport scaffolding # genesis/proto/state +} diff --git a/proto/osmosis/tokenfactory/query.proto b/proto/osmosis/tokenfactory/query.proto new file mode 100644 index 00000000000..3d6d2480771 --- /dev/null +++ b/proto/osmosis/tokenfactory/query.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package osmosislabs.osmosis.tokenfactory; + +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +// this line is used by starport scaffolding # 1 + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// Query defines the gRPC querier service. +service Query { + // this line is used by starport scaffolding # 2 +} + +// this line is used by starport scaffolding # 3 diff --git a/proto/osmosis/tokenfactory/tx.proto b/proto/osmosis/tokenfactory/tx.proto new file mode 100644 index 00000000000..6f1494ce4d8 --- /dev/null +++ b/proto/osmosis/tokenfactory/tx.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package osmosis.tokenfactory.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// Msg defines the Msg service. +service Msg { + rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); +} + +// ===================== MsgCreateDenom +message MsgCreateDenom { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; +} + +message MsgCreateDenomResponse {} + +// ===================== MsgUpdateMinter +message MsgCreateDenom { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; +} + +message MsgCreateDenomResponse {} \ No newline at end of file diff --git a/testutil/keeper/tokenfactory.go b/testutil/keeper/tokenfactory.go new file mode 100644 index 00000000000..274dc7dd410 --- /dev/null +++ b/testutil/keeper/tokenfactory.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" +) + +func TokenfactoryKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + k := keeper.NewKeeper( + codec.NewProtoCodec(registry), + storeKey, + memStoreKey, + nil, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + return k, ctx +} diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go new file mode 100644 index 00000000000..6e47241d865 --- /dev/null +++ b/x/tokenfactory/client/cli/query.go @@ -0,0 +1,30 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group tokenfactory queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go new file mode 100644 index 00000000000..d2e0a4f8e94 --- /dev/null +++ b/x/tokenfactory/client/cli/tx.go @@ -0,0 +1,35 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/tokenfactory/genesis.go b/x/tokenfactory/genesis.go new file mode 100644 index 00000000000..3f61cc82c73 --- /dev/null +++ b/x/tokenfactory/genesis.go @@ -0,0 +1,22 @@ +package tokenfactory + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init +} + +// ExportGenesis returns the capability module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/tokenfactory/genesis_test.go b/x/tokenfactory/genesis_test.go new file mode 100644 index 00000000000..77a131358b6 --- /dev/null +++ b/x/tokenfactory/genesis_test.go @@ -0,0 +1,23 @@ +package tokenfactory_test + +import ( + "testing" + + keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.TokenfactoryKeeper(t) + tokenfactory.InitGenesis(ctx, *k, genesisState) + got := tokenfactory.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/tokenfactory/handler.go b/x/tokenfactory/handler.go new file mode 100644 index 00000000000..dff81e8cf4f --- /dev/null +++ b/x/tokenfactory/handler.go @@ -0,0 +1,26 @@ +package tokenfactory + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + // this line is used by starport scaffolding # handler/msgServer + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + // this line is used by starport scaffolding # 1 + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/tokenfactory/keeper/admins.go b/x/tokenfactory/keeper/admins.go new file mode 100644 index 00000000000..00e270df301 --- /dev/null +++ b/x/tokenfactory/keeper/admins.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "strings" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (k Keeper) GetAdminsStore(ctx sdk.Context, denom string) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, []byte(strings.Join( + []string{denom, types.DenomAdminsStorePrefix}, "|"))) +} + +// AddAdmins adds admins for a specific denom +func (k Keeper) AddAdmins(ctx sdk.Context, denom string, admins []string) { + + store := k.GetAdminsStore(ctx, denom) + + for _, admin := range admins { + // Turn the value into a bool? + store.Set([]byte(admin), []byte(admin)) + } +} + +// RemoveAdmins removes admins for a specific denom +func (k Keeper) RemoveAdmins(ctx sdk.Context, denom string, admins []string) { + store := k.GetAdminsStore(ctx, denom) + for _, admin := range admins { + store.Delete([]byte(admin)) + } +} + +// IsAdmin returns if a specific address is a admin for a specific denom +func (k Keeper) IsAdmin(ctx sdk.Context, denom string, address string) bool { + return k.GetAdminsStore(ctx, denom).Has([]byte(address)) +} diff --git a/x/tokenfactory/keeper/burners.go b/x/tokenfactory/keeper/burners.go new file mode 100644 index 00000000000..ac6573ec559 --- /dev/null +++ b/x/tokenfactory/keeper/burners.go @@ -0,0 +1,37 @@ +package keeper + +import ( + "strings" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (k Keeper) GetBurnersStore(ctx sdk.Context, denom string) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, []byte(strings.Join( + []string{denom, types.DenomBurnersStorePrefix}, "|"))) +} + +// AddBurners adds burners for a specific denom +func (k Keeper) AddBurners(ctx sdk.Context, denom string, burners []string) { + store := k.GetBurnersStore(ctx, denom) + for _, burner := range burners { + // Turn the value into a bool? + store.Set([]byte(burner), []byte(burner)) + } +} + +// RemoveBurners removes burners for a specific denom +func (k Keeper) RemoveBurners(ctx sdk.Context, denom string, burners []string) { + store := k.GetBurnersStore(ctx, denom) + for _, burner := range burners { + store.Delete([]byte(burner)) + } +} + +// IsBurner returns if a specific address is a burner for a specific denom +func (k Keeper) IsBurner(ctx sdk.Context, denom string, address string) bool { + return k.GetBurnersStore(ctx, denom).Has([]byte(address)) +} diff --git a/x/tokenfactory/keeper/denommint.go b/x/tokenfactory/keeper/denommint.go new file mode 100644 index 00000000000..5d9a7a85bd8 --- /dev/null +++ b/x/tokenfactory/keeper/denommint.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +// ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount +func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce string) error { + + denom := strings.Join([]string{"factory", creatorAddr, denomnonce}, "/") + + err := sdk.ValidateDenom(denom) + if err != nil { + return err + } + + _, found := k.bankKeeper.GetDenomMetaData(ctx, denom) + if found { + return types.ErrDenomExists + } + + baseDenomUnit := banktypes.DenomUnit{ + Denom: denom, + Exponent: 0, + } + + denomMetaData := banktypes.Metadata{ + DenomUnits: []*banktypes.DenomUnit{&baseDenomUnit}, + Base: denom, + } + + k.bankKeeper.SetDenomMetaData(ctx, denomMetaData) + + return nil +} diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go new file mode 100644 index 00000000000..7c6a0eb670c --- /dev/null +++ b/x/tokenfactory/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go new file mode 100644 index 00000000000..c99d531a3cc --- /dev/null +++ b/x/tokenfactory/keeper/keeper.go @@ -0,0 +1,41 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +type ( + Keeper struct { + cdc codec.Marshaler + storeKey sdk.StoreKey + memKey sdk.StoreKey + + bankKeeper types.BankKeeper + } +) + +func NewKeeper( + cdc codec.Marshaler, + storeKey, + memKey sdk.StoreKey, + + bankKeeper types.BankKeeper, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + + bankKeeper: bankKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/tokenfactory/keeper/minters.go b/x/tokenfactory/keeper/minters.go new file mode 100644 index 00000000000..fd393b3ac44 --- /dev/null +++ b/x/tokenfactory/keeper/minters.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "strings" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (k Keeper) GetMintersStore(ctx sdk.Context, denom string) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, []byte(strings.Join( + []string{denom, types.DenomMintersStorePrefix}, "|"))) +} + +// AddMinters adds minters for a specific denom +func (k Keeper) AddMinters(ctx sdk.Context, denom string, minters []string) { + + store := k.GetMintersStore(ctx, denom) + + for _, minter := range minters { + // Turn the value into a bool? + store.Set([]byte(minter), []byte(minter)) + } +} + +// AddMinters removes minters for a specific denom +func (k Keeper) RemoveMinters(ctx sdk.Context, denom string, minters []string) { + store := k.GetMintersStore(ctx, denom) + for _, minter := range minters { + store.Delete([]byte(minter)) + } +} + +// IsMinter returns if a specific address is a minter for a specific denom +func (k Keeper) IsMinter(ctx sdk.Context, denom string, address string) bool { + return k.GetMintersStore(ctx, denom).Has([]byte(address)) +} diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go new file mode 100644 index 00000000000..60ffc6273cb --- /dev/null +++ b/x/tokenfactory/keeper/msg_server.go @@ -0,0 +1,38 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateDenom) (*types.MsgCreateDenomResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := server.Keeper.CreateDenom(ctx, msg.Sender, msg.Nonce) + + if err != nil { + return nil, err + } + + // TODO: events + // ctx.EventManager().EmitEvents(sdk.Events{}) + + return &types.MsgCreateDenomResponse{}, nil +} + +var _ types.MsgServer = msgServer{} diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go new file mode 100644 index 00000000000..8e3afb623bd --- /dev/null +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.TokenfactoryKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go new file mode 100644 index 00000000000..696dc9dfeed --- /dev/null +++ b/x/tokenfactory/module.go @@ -0,0 +1,166 @@ +package tokenfactory + +import ( + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "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/osmosis-labs/osmosis/x/tokenfactory/client/cli" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability 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. +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() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // this line is used by starport scaffolding # 2 +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability 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 + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go new file mode 100644 index 00000000000..133646fd35d --- /dev/null +++ b/x/tokenfactory/types/codec.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go new file mode 100644 index 00000000000..a13d693cdeb --- /dev/null +++ b/x/tokenfactory/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/tokenfactory module sentinel errors +var ( + ErrDenomExists = sdkerrors.Register(ModuleName, 1, "denom already exists") +) diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go new file mode 100644 index 00000000000..d55d26c436d --- /dev/null +++ b/x/tokenfactory/types/expected_keepers.go @@ -0,0 +1,20 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +type BankKeeper interface { + // Methods imported from bank should be defined here + GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) + SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) + + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error +} diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go new file mode 100644 index 00000000000..06921a5995f --- /dev/null +++ b/x/tokenfactory/types/genesis.go @@ -0,0 +1,23 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default capability global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return nil +} diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go new file mode 100644 index 00000000000..2c91f0aa49f --- /dev/null +++ b/x/tokenfactory/types/genesis.pb.go @@ -0,0 +1,266 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/tokenfactory/genesis.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 + +// GenesisState defines the tokenfactory module's genesis state. +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_36277e68a5f011fe, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "osmosislabs.osmosis.tokenfactory.GenesisState") +} + +func init() { + proto.RegisterFile("osmosis/tokenfactory/genesis.proto", fileDescriptor_36277e68a5f011fe) +} + +var fileDescriptor_36277e68a5f011fe = []byte{ + // 148 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, + 0x80, 0xaa, 0xc9, 0x49, 0x4c, 0x2a, 0xd6, 0x83, 0xb2, 0xf5, 0x90, 0xd5, 0x2b, 0xf1, 0x71, 0xf1, + 0xb8, 0x43, 0xb4, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x3a, 0xf9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, + 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, + 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x49, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, + 0x3e, 0xd4, 0x28, 0x5d, 0x90, 0xb9, 0x30, 0x8e, 0x7e, 0x05, 0xaa, 0x4b, 0x4a, 0x2a, 0x0b, 0x52, + 0x8b, 0x93, 0xd8, 0xc0, 0x0e, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3e, 0xc0, 0x4b, 0xa7, + 0xae, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/types/genesis_test.go b/x/tokenfactory/types/genesis_test.go new file mode 100644 index 00000000000..617a4d7a01e --- /dev/null +++ b/x/tokenfactory/types/genesis_test.go @@ -0,0 +1,39 @@ +package types_test + +import ( + "testing" + + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go new file mode 100644 index 00000000000..9aee1a57f70 --- /dev/null +++ b/x/tokenfactory/types/keys.go @@ -0,0 +1,28 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "tokenfactory" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_tokenfactory" +) + +var ( + DenomAdminsStorePrefix = "admins" + DenomMintersStorePrefix = "minters" + DenomBurnersStorePrefix = "burners" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go new file mode 100644 index 00000000000..d91cc870af0 --- /dev/null +++ b/x/tokenfactory/types/query.pb.go @@ -0,0 +1,87 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/tokenfactory/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + math "math" +) + +// 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 + +func init() { proto.RegisterFile("osmosis/tokenfactory/query.proto", fileDescriptor_14a4c72f14d179b4) } + +var fileDescriptor_14a4c72f14d179b4 = []byte{ + // 196 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, + 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x82, 0xa9, 0xc8, + 0x49, 0x4c, 0x2a, 0xd6, 0x83, 0xb2, 0xf5, 0x90, 0x55, 0x4b, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, + 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, + 0x15, 0x43, 0xf4, 0x4b, 0x69, 0x25, 0x83, 0x35, 0xe9, 0x27, 0x25, 0x16, 0xa7, 0x42, 0x0c, 0xd6, + 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x4c, 0xcf, 0xcc, 0x03, 0x2b, 0x86, + 0xa8, 0x35, 0x62, 0xe7, 0x62, 0x0d, 0x04, 0xa9, 0x70, 0xf2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, + 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, + 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, + 0x7d, 0xa8, 0x6b, 0x74, 0x41, 0x4e, 0x83, 0x71, 0xf4, 0x2b, 0x50, 0xbd, 0x52, 0x52, 0x59, 0x90, + 0x5a, 0x9c, 0xc4, 0x06, 0x36, 0xdf, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x03, 0x47, 0xad, + 0xef, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// 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 { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosislabs.osmosis.tokenfactory.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/tokenfactory/query.proto", +} diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go new file mode 100644 index 00000000000..6c9bc6538d3 --- /dev/null +++ b/x/tokenfactory/types/tx.pb.go @@ -0,0 +1,580 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/tokenfactory/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// ===================== MsgCreateDenom +type MsgCreateDenom struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Nonce string `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty" yaml:"nonce"` +} + +func (m *MsgCreateDenom) Reset() { *m = MsgCreateDenom{} } +func (m *MsgCreateDenom) String() string { return proto.CompactTextString(m) } +func (*MsgCreateDenom) ProtoMessage() {} +func (*MsgCreateDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_195ce4708c850bc3, []int{0} +} +func (m *MsgCreateDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateDenom.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 *MsgCreateDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateDenom.Merge(m, src) +} +func (m *MsgCreateDenom) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateDenom) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateDenom proto.InternalMessageInfo + +func (m *MsgCreateDenom) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgCreateDenom) GetNonce() string { + if m != nil { + return m.Nonce + } + return "" +} + +type MsgCreateDenomResponse struct { +} + +func (m *MsgCreateDenomResponse) Reset() { *m = MsgCreateDenomResponse{} } +func (m *MsgCreateDenomResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateDenomResponse) ProtoMessage() {} +func (*MsgCreateDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_195ce4708c850bc3, []int{1} +} +func (m *MsgCreateDenomResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateDenomResponse.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 *MsgCreateDenomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateDenomResponse.Merge(m, src) +} +func (m *MsgCreateDenomResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateDenomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateDenomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateDenomResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateDenom)(nil), "osmosis.tokenfactory.v1beta1.MsgCreateDenom") + proto.RegisterType((*MsgCreateDenomResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse") +} + +func init() { proto.RegisterFile("osmosis/tokenfactory/tx.proto", fileDescriptor_195ce4708c850bc3) } + +var fileDescriptor_195ce4708c850bc3 = []byte{ + // 286 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, + 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x4a, 0xeb, 0x21, 0x4b, + 0xeb, 0x95, 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x15, + 0xea, 0x83, 0x58, 0x10, 0x3d, 0x52, 0x72, 0xc9, 0x60, 0x4d, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, + 0x50, 0xa5, 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0x64, 0x2e, 0x3e, 0xdf, 0xe2, 0x74, + 0xe7, 0xa2, 0xd4, 0xc4, 0x92, 0x54, 0x97, 0xd4, 0xbc, 0xfc, 0x5c, 0x21, 0x4d, 0x2e, 0xb6, 0xe2, + 0xd4, 0xbc, 0x94, 0xd4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xc1, 0x4f, 0xf7, 0xe4, + 0x79, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x20, 0xe2, 0x4a, 0x41, 0x50, 0x05, 0x42, 0x6a, 0x5c, + 0xac, 0x79, 0xf9, 0x79, 0xc9, 0xa9, 0x12, 0x4c, 0x60, 0x95, 0x02, 0x9f, 0xee, 0xc9, 0xf3, 0x40, + 0x54, 0x82, 0x85, 0x95, 0x82, 0x20, 0xd2, 0x4a, 0x12, 0x5c, 0x62, 0xa8, 0x96, 0x04, 0xa5, 0x16, + 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x55, 0x70, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x15, 0x72, 0x71, + 0x23, 0x3b, 0x41, 0x47, 0x0f, 0x9f, 0x4f, 0xf5, 0x50, 0xcd, 0x92, 0x32, 0x21, 0x45, 0x35, 0xcc, + 0x66, 0x27, 0xbf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, + 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x49, 0xcf, + 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0xac, 0x9b, 0x93, 0x98, 0x54, + 0x0c, 0xe3, 0xe8, 0x57, 0xa0, 0xc5, 0x4f, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x3c, 0x8d, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x34, 0xbc, 0x1d, 0x1d, 0xc4, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) { + out := new(MsgCreateDenomResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/CreateDenom", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateDenom(ctx context.Context, req *MsgCreateDenom) (*MsgCreateDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDenom not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateDenom) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateDenom(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/CreateDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateDenom(ctx, req.(*MsgCreateDenom)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.tokenfactory.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateDenom", + Handler: _Msg_CreateDenom_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/tokenfactory/tx.proto", +} + +func (m *MsgCreateDenom) 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 *MsgCreateDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Nonce) > 0 { + i -= len(m.Nonce) + copy(dAtA[i:], m.Nonce) + i = encodeVarintTx(dAtA, i, uint64(len(m.Nonce))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateDenomResponse) 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 *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateDenomResponse) 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 *MsgCreateDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Nonce) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateDenomResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateDenom) 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: MsgCreateDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", 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.Nonce = 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 *MsgCreateDenomResponse) 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: MsgCreateDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDenomResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/types/types.go b/x/tokenfactory/types/types.go new file mode 100644 index 00000000000..ab1254f4c2b --- /dev/null +++ b/x/tokenfactory/types/types.go @@ -0,0 +1 @@ +package types From 196de80b5dc2f6eb9d0db73e6cf3792e586c80e0 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 14 Nov 2021 20:13:52 -0500 Subject: [PATCH 02/22] in progress --- proto/osmosis/tokenfactory/genesis.proto | 11 - proto/osmosis/tokenfactory/query.proto | 15 - proto/osmosis/tokenfactory/tx.proto | 28 - .../v1beta1/authorityMetadata.proto | 13 + .../tokenfactory/v1beta1/genesis.proto | 23 + .../osmosis/tokenfactory/v1beta1/query.proto | 41 + proto/osmosis/tokenfactory/v1beta1/tx.proto | 74 + x/tokenfactory/genesis.go | 30 +- x/tokenfactory/keeper/admins.go | 54 +- x/tokenfactory/keeper/bankactions.go | 33 + x/tokenfactory/keeper/burners.go | 37 - .../keeper/{denommint.go => createdenom.go} | 16 +- x/tokenfactory/keeper/creators.go | 27 + x/tokenfactory/keeper/grpc_query.go | 20 + x/tokenfactory/keeper/keeper.go | 21 + x/tokenfactory/keeper/minters.go | 39 - x/tokenfactory/keeper/msg_server.go | 83 + x/tokenfactory/module.go | 15 +- x/tokenfactory/types/authorityMetadata.pb.go | 347 +++ x/tokenfactory/types/codec.go | 18 +- x/tokenfactory/types/denoms.go | 43 + x/tokenfactory/types/denoms_test.go | 64 + x/tokenfactory/types/errors.go | 6 +- x/tokenfactory/types/expected_keepers.go | 2 + x/tokenfactory/types/genesis.go | 28 +- x/tokenfactory/types/genesis.pb.go | 327 ++- x/tokenfactory/types/genesis_test.go | 105 +- x/tokenfactory/types/keys.go | 27 +- x/tokenfactory/types/msgs.go | 200 ++ x/tokenfactory/types/query.pb.go | 934 +++++++- x/tokenfactory/types/query.pb.gw.go | 282 +++ x/tokenfactory/types/tx.pb.go | 1980 ++++++++++++++++- 32 files changed, 4628 insertions(+), 315 deletions(-) delete mode 100644 proto/osmosis/tokenfactory/genesis.proto delete mode 100644 proto/osmosis/tokenfactory/query.proto delete mode 100644 proto/osmosis/tokenfactory/tx.proto create mode 100644 proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto create mode 100644 proto/osmosis/tokenfactory/v1beta1/genesis.proto create mode 100644 proto/osmosis/tokenfactory/v1beta1/query.proto create mode 100644 proto/osmosis/tokenfactory/v1beta1/tx.proto create mode 100644 x/tokenfactory/keeper/bankactions.go delete mode 100644 x/tokenfactory/keeper/burners.go rename x/tokenfactory/keeper/{denommint.go => createdenom.go} (73%) create mode 100644 x/tokenfactory/keeper/creators.go delete mode 100644 x/tokenfactory/keeper/minters.go create mode 100644 x/tokenfactory/types/authorityMetadata.pb.go create mode 100644 x/tokenfactory/types/denoms.go create mode 100644 x/tokenfactory/types/denoms_test.go create mode 100644 x/tokenfactory/types/msgs.go create mode 100644 x/tokenfactory/types/query.pb.gw.go diff --git a/proto/osmosis/tokenfactory/genesis.proto b/proto/osmosis/tokenfactory/genesis.proto deleted file mode 100644 index 852b214390d..00000000000 --- a/proto/osmosis/tokenfactory/genesis.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package osmosislabs.osmosis.tokenfactory; - -// this line is used by starport scaffolding # genesis/proto/import - -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; - -// GenesisState defines the tokenfactory module's genesis state. -message GenesisState { - // this line is used by starport scaffolding # genesis/proto/state -} diff --git a/proto/osmosis/tokenfactory/query.proto b/proto/osmosis/tokenfactory/query.proto deleted file mode 100644 index 3d6d2480771..00000000000 --- a/proto/osmosis/tokenfactory/query.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package osmosislabs.osmosis.tokenfactory; - -import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -// this line is used by starport scaffolding # 1 - -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; - -// Query defines the gRPC querier service. -service Query { - // this line is used by starport scaffolding # 2 -} - -// this line is used by starport scaffolding # 3 diff --git a/proto/osmosis/tokenfactory/tx.proto b/proto/osmosis/tokenfactory/tx.proto deleted file mode 100644 index 6f1494ce4d8..00000000000 --- a/proto/osmosis/tokenfactory/tx.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; -package osmosis.tokenfactory.v1beta1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; - -// Msg defines the Msg service. -service Msg { - rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); -} - -// ===================== MsgCreateDenom -message MsgCreateDenom { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; -} - -message MsgCreateDenomResponse {} - -// ===================== MsgUpdateMinter -message MsgCreateDenom { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; -} - -message MsgCreateDenomResponse {} \ No newline at end of file diff --git a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto new file mode 100644 index 00000000000..523a9273c02 --- /dev/null +++ b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package osmosis.tokenfactory.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +message DenomAuthorityMetadata { + option (gogoproto.equal) = true; + + string Admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ]; +} \ No newline at end of file diff --git a/proto/osmosis/tokenfactory/v1beta1/genesis.proto b/proto/osmosis/tokenfactory/v1beta1/genesis.proto new file mode 100644 index 00000000000..163010c5c8f --- /dev/null +++ b/proto/osmosis/tokenfactory/v1beta1/genesis.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package osmosis.tokenfactory.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// GenesisState defines the tokenfactory module's genesis state. +message GenesisState { + repeated GenesisDenom factory_denoms = 1 [ + (gogoproto.moretags) = "yaml:\"factory_denoms\"", + (gogoproto.nullable) = false + ]; +} + +message GenesisDenom { + string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; + DenomAuthorityMetadata authority_metadata = 2 [ + (gogoproto.moretags) = "yaml:\"authority_metadata\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/osmosis/tokenfactory/v1beta1/query.proto b/proto/osmosis/tokenfactory/v1beta1/query.proto new file mode 100644 index 00000000000..3c361946922 --- /dev/null +++ b/proto/osmosis/tokenfactory/v1beta1/query.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; +package osmosis.tokenfactory.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// Query defines the gRPC querier service. +service Query { + rpc DenomAuthorityMetadata(QueryDenomAuthorityMetadataRequest) + returns (QueryDenomAuthorityMetadataResponse) { + option (google.api.http).get = + "/osmosis/tokenfactory/v1beta1/denoms/{denom}/authority_metadata"; + } + + rpc DenomsFromCreator(QueryDenomsFromCreatorRequest) + returns (QueryDenomsFromCreatorResponse) { + option (google.api.http).get = + "/osmosis/tokenfactory/v1beta1/denoms_from_creator/{creator}"; + } +} + +message QueryDenomAuthorityMetadataRequest { + string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; +} +message QueryDenomAuthorityMetadataResponse { + DenomAuthorityMetadata authority_metadata = 1 [ + (gogoproto.moretags) = "yaml:\"authority_metadata\"", + (gogoproto.nullable) = false + ]; +} + +message QueryDenomsFromCreatorRequest { + string creator = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ]; +} +message QueryDenomsFromCreatorResponse { + repeated string denoms = 1 [ (gogoproto.moretags) = "yaml:\"denoms\"" ]; +} \ No newline at end of file diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto new file mode 100644 index 00000000000..f1f55b651b7 --- /dev/null +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; +package osmosis.tokenfactory.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; + +// Msg defines the Msg service. +service Msg { + rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); + rpc Mint(MsgMint) returns (MsgMintResponse); + rpc Burn(MsgBurn) returns (MsgBurnResponse); + rpc ForceTransfer(MsgForceTransfer) returns (MsgForceTransferResponse); + rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); +} + +// ===================== MsgCreateDenom +message MsgCreateDenom { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; +} + +message MsgCreateDenomResponse {} + +// ===================== MsgMint +message MsgMint { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.moretags) = "yaml:\"amount\"", + (gogoproto.nullable) = false + ]; + string mintToAddress = 3 + [ (gogoproto.moretags) = "yaml:\"mint_to_address\"" ]; +} + +message MsgMintResponse {} + +// ===================== MsgBurn +message MsgBurn { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.moretags) = "yaml:\"amount\"", + (gogoproto.nullable) = false + ]; + string burnFromAddress = 3 + [ (gogoproto.moretags) = "yaml:\"burn_from_address\"" ]; +} + +message MsgBurnResponse {} + +// ===================== MsgForceTransfer +message MsgForceTransfer { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + cosmos.base.v1beta1.Coin amount = 2 [ + (gogoproto.moretags) = "yaml:\"amount\"", + (gogoproto.nullable) = false + ]; + string transferFromAddress = 3 + [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ]; + string transferToAddress = 4 + [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ]; +} + +message MsgForceTransferResponse {} + +// ===================== MsgChangeAdmin +message MsgChangeAdmin { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; + string newAdmin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; +} + +message MsgChangeAdminResponse {} \ No newline at end of file diff --git a/x/tokenfactory/genesis.go b/x/tokenfactory/genesis.go index 3f61cc82c73..8c11736dadd 100644 --- a/x/tokenfactory/genesis.go +++ b/x/tokenfactory/genesis.go @@ -9,14 +9,36 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init + for _, genDenom := range genState.GetFactoryDenoms() { + creator, nonce, err := types.DeconstructDenom(genDenom.GetDenom()) + if err != nil { + panic(err.Error()) + } + k.CreateDenom(ctx, creator, nonce) + k.SetAuthorityMetadata(ctx, genDenom.GetDenom(), genDenom.GetAuthorityMetadata()) + } } // ExportGenesis returns the capability module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() + genDenoms := []types.GenesisDenom{} + iterator := k.GetAllDenomsIterator(ctx) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + denom := string(iterator.Value()) - // this line is used by starport scaffolding # genesis/module/export + authorityMetadata, err := k.GetAuthorityMetadata(ctx, denom) + if err != nil { + panic(err.Error()) + } - return genesis + genDenoms = append(genDenoms, types.GenesisDenom{ + Denom: denom, + AuthorityMetadata: authorityMetadata, + }) + } + + return &types.GenesisState{ + FactoryDenoms: genDenoms, + } } diff --git a/x/tokenfactory/keeper/admins.go b/x/tokenfactory/keeper/admins.go index 00e270df301..7293adeee84 100644 --- a/x/tokenfactory/keeper/admins.go +++ b/x/tokenfactory/keeper/admins.go @@ -1,39 +1,49 @@ package keeper import ( - "strings" - - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" ) -func (k Keeper) GetAdminsStore(ctx sdk.Context, denom string) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, []byte(strings.Join( - []string{denom, types.DenomAdminsStorePrefix}, "|"))) +// GetAuthorityMetadata returns the authority metadata for a specific denom +func (k Keeper) GetAuthorityMetadata(ctx sdk.Context, denom string) (types.DenomAuthorityMetadata, error) { + bz := k.GetDenomPrefixStore(ctx, denom).Get([]byte(types.DenomAuthorityMetadataKey)) + + metadata := types.DenomAuthorityMetadata{} + err := proto.Unmarshal(bz, &metadata) + if err != nil { + return types.DenomAuthorityMetadata{}, err + } + return metadata, nil } -// AddAdmins adds admins for a specific denom -func (k Keeper) AddAdmins(ctx sdk.Context, denom string, admins []string) { +func (k Keeper) SetAuthorityMetadata(ctx sdk.Context, denom string, metadata types.DenomAuthorityMetadata) error { + if metadata.Admin != "" { + _, err := sdk.AccAddressFromBech32(metadata.Admin) + if err != nil { + return err + } + } - store := k.GetAdminsStore(ctx, denom) + store := k.GetDenomPrefixStore(ctx, denom) - for _, admin := range admins { - // Turn the value into a bool? - store.Set([]byte(admin), []byte(admin)) + bz, err := proto.Marshal(&metadata) + if err != nil { + return err } + + store.Set([]byte(types.DenomAuthorityMetadataKey), bz) + return nil } -// RemoveAdmins removes admins for a specific denom -func (k Keeper) RemoveAdmins(ctx sdk.Context, denom string, admins []string) { - store := k.GetAdminsStore(ctx, denom) - for _, admin := range admins { - store.Delete([]byte(admin)) +func (k Keeper) setAdmin(ctx sdk.Context, denom string, admin string) error { + metadata, err := k.GetAuthorityMetadata(ctx, denom) + if err != nil { + return err } -} -// IsAdmin returns if a specific address is a admin for a specific denom -func (k Keeper) IsAdmin(ctx sdk.Context, denom string, address string) bool { - return k.GetAdminsStore(ctx, denom).Has([]byte(address)) + metadata.Admin = admin + + return k.SetAuthorityMetadata(ctx, denom, metadata) } diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go new file mode 100644 index 00000000000..8a082e1b445 --- /dev/null +++ b/x/tokenfactory/keeper/bankactions.go @@ -0,0 +1,33 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { + err := k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) + if err != nil { + return err + } + + return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, + sdk.AccAddress(mintTo), + sdk.NewCoins(amount)) +} + +func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) error { + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, + sdk.AccAddress(burnFrom), + types.ModuleName, + sdk.NewCoins(amount)) + if err != nil { + return err + } + + return k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) +} + +func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr string, toAddr string) error { + return k.bankKeeper.SendCoins(ctx, sdk.AccAddress(fromAddr), sdk.AccAddress(toAddr), sdk.NewCoins(amount)) +} diff --git a/x/tokenfactory/keeper/burners.go b/x/tokenfactory/keeper/burners.go deleted file mode 100644 index ac6573ec559..00000000000 --- a/x/tokenfactory/keeper/burners.go +++ /dev/null @@ -1,37 +0,0 @@ -package keeper - -import ( - "strings" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" -) - -func (k Keeper) GetBurnersStore(ctx sdk.Context, denom string) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, []byte(strings.Join( - []string{denom, types.DenomBurnersStorePrefix}, "|"))) -} - -// AddBurners adds burners for a specific denom -func (k Keeper) AddBurners(ctx sdk.Context, denom string, burners []string) { - store := k.GetBurnersStore(ctx, denom) - for _, burner := range burners { - // Turn the value into a bool? - store.Set([]byte(burner), []byte(burner)) - } -} - -// RemoveBurners removes burners for a specific denom -func (k Keeper) RemoveBurners(ctx sdk.Context, denom string, burners []string) { - store := k.GetBurnersStore(ctx, denom) - for _, burner := range burners { - store.Delete([]byte(burner)) - } -} - -// IsBurner returns if a specific address is a burner for a specific denom -func (k Keeper) IsBurner(ctx sdk.Context, denom string, address string) bool { - return k.GetBurnersStore(ctx, denom).Has([]byte(address)) -} diff --git a/x/tokenfactory/keeper/denommint.go b/x/tokenfactory/keeper/createdenom.go similarity index 73% rename from x/tokenfactory/keeper/denommint.go rename to x/tokenfactory/keeper/createdenom.go index 5d9a7a85bd8..8cfd8d86e44 100644 --- a/x/tokenfactory/keeper/denommint.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -1,8 +1,6 @@ package keeper import ( - "strings" - sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" @@ -10,10 +8,7 @@ import ( // ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce string) error { - - denom := strings.Join([]string{"factory", creatorAddr, denomnonce}, "/") - - err := sdk.ValidateDenom(denom) + denom, err := types.GetTokenDenom(creatorAddr, denomnonce) if err != nil { return err } @@ -35,5 +30,14 @@ func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce stri k.bankKeeper.SetDenomMetaData(ctx, denomMetaData) + authorityMetadata := types.DenomAuthorityMetadata{ + Admin: creatorAddr, + } + err = k.SetAuthorityMetadata(ctx, denom, authorityMetadata) + if err != nil { + return err + } + + k.addDenomFromCreator(ctx, creatorAddr, denom) return nil } diff --git a/x/tokenfactory/keeper/creators.go b/x/tokenfactory/keeper/creators.go new file mode 100644 index 00000000000..6ce10469a03 --- /dev/null +++ b/x/tokenfactory/keeper/creators.go @@ -0,0 +1,27 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetAuthorityMetadata returns the authority metadata for a specific denom +func (k Keeper) addDenomFromCreator(ctx sdk.Context, creator, denom string) { + store := k.GetCreatorPrefixStore(ctx, creator) + store.Set([]byte(denom), []byte(denom)) +} + +func (k Keeper) getDenomsFromCreator(ctx sdk.Context, creator string) []string { + store := k.GetCreatorPrefixStore(ctx, creator) + + iterator := store.Iterator(nil, nil) + defer iterator.Close() + denoms := []string{} + for ; iterator.Valid(); iterator.Next() { + denoms = append(denoms, string(iterator.Key())) + } + return denoms +} + +func (k Keeper) GetAllDenomsIterator(ctx sdk.Context) sdk.Iterator { + return k.GetCreatorsPrefixStore(ctx).Iterator(nil, nil) +} diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index 7c6a0eb670c..a4bd7166d1e 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -1,7 +1,27 @@ package keeper import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" ) var _ types.QueryServer = Keeper{} + +func (k Keeper) DenomAuthorityMetadata(ctx context.Context, req *types.QueryDenomAuthorityMetadataRequest) (*types.QueryDenomAuthorityMetadataResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + authorityMetadata, err := k.GetAuthorityMetadata(sdkCtx, req.GetDenom()) + if err != nil { + return nil, err + } + + return &types.QueryDenomAuthorityMetadataResponse{AuthorityMetadata: authorityMetadata}, nil +} + +func (k Keeper) DenomsFromCreator(ctx context.Context, req *types.QueryDenomsFromCreatorRequest) (*types.QueryDenomsFromCreatorResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + denoms := k.getDenomsFromCreator(sdkCtx, req.GetCreator()) + return &types.QueryDenomsFromCreatorResponse{Denoms: denoms}, nil +} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index c99d531a3cc..e10dd8cb0ca 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" ) @@ -39,3 +40,23 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func (k Keeper) GetDenomPrefixStore(ctx sdk.Context, denom string) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.GetDenomPrefixStore(denom)) +} + +func (k Keeper) GetCreatorPrefixStore(ctx sdk.Context, creator string) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.GetCreatorPrefix(creator)) +} + +func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) sdk.KVStore { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.GetCreatorsPrefix()) +} + +// func (k Keeper) GetAdminPrefixStore(ctx sdk.Context, admin string) sdk.KVStore { +// store := ctx.KVStore(k.storeKey) +// return prefix.NewStore(store, types.GetAdminPrefix(admin)) +// } diff --git a/x/tokenfactory/keeper/minters.go b/x/tokenfactory/keeper/minters.go deleted file mode 100644 index fd393b3ac44..00000000000 --- a/x/tokenfactory/keeper/minters.go +++ /dev/null @@ -1,39 +0,0 @@ -package keeper - -import ( - "strings" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" -) - -func (k Keeper) GetMintersStore(ctx sdk.Context, denom string) sdk.KVStore { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, []byte(strings.Join( - []string{denom, types.DenomMintersStorePrefix}, "|"))) -} - -// AddMinters adds minters for a specific denom -func (k Keeper) AddMinters(ctx sdk.Context, denom string, minters []string) { - - store := k.GetMintersStore(ctx, denom) - - for _, minter := range minters { - // Turn the value into a bool? - store.Set([]byte(minter), []byte(minter)) - } -} - -// AddMinters removes minters for a specific denom -func (k Keeper) RemoveMinters(ctx sdk.Context, denom string, minters []string) { - store := k.GetMintersStore(ctx, denom) - for _, minter := range minters { - store.Delete([]byte(minter)) - } -} - -// IsMinter returns if a specific address is a minter for a specific denom -func (k Keeper) IsMinter(ctx sdk.Context, denom string, address string) bool { - return k.GetMintersStore(ctx, denom).Has([]byte(address)) -} diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 60ffc6273cb..cae1f3ac39b 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -35,4 +35,87 @@ func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateD return &types.MsgCreateDenomResponse{}, nil } +func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) + if err != nil { + return nil, err + } + + if msg.Sender != authorityMetadata.GetAdmin() { + return nil, types.ErrUnauthorized + } + + server.Keeper.mintTo(ctx, msg.Amount, msg.MintToAddress) + + // TODO: events + // ctx.EventManager().EmitEvents(sdk.Events{}) + + return &types.MsgMintResponse{}, nil +} + +func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) + if err != nil { + return nil, err + } + + if msg.Sender != authorityMetadata.GetAdmin() { + return nil, types.ErrUnauthorized + } + + server.Keeper.burnFrom(ctx, msg.Amount, msg.GetBurnFromAddress()) + + // TODO: events + // ctx.EventManager().EmitEvents(sdk.Events{}) + + return &types.MsgBurnResponse{}, nil +} + +func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForceTransfer) (*types.MsgForceTransferResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) + if err != nil { + return nil, err + } + + if msg.Sender != authorityMetadata.GetAdmin() { + return nil, types.ErrUnauthorized + } + + server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) + + // TODO: events + // ctx.EventManager().EmitEvents(sdk.Events{}) + + return &types.MsgForceTransferResponse{}, nil +} + +func (server msgServer) ChangeAdmin(goCtx context.Context, msg *types.MsgChangeAdmin) (*types.MsgChangeAdminResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Denom) + if err != nil { + return nil, err + } + + if msg.Sender != authorityMetadata.GetAdmin() { + return nil, types.ErrUnauthorized + } + + err = server.Keeper.setAdmin(ctx, msg.Denom, msg.NewAdmin) + if err != nil { + return nil, err + } + + // TODO: events + // ctx.EventManager().EmitEvents(sdk.Events{}) + + return &types.MsgChangeAdminResponse{}, nil +} + var _ types.MsgServer = msgServer{} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 696dc9dfeed..ec6dce30878 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -3,6 +3,7 @@ package tokenfactory import ( "encoding/json" "fmt" + // this line is used by starport scaffolding # 1 "github.com/gorilla/mux" @@ -32,10 +33,10 @@ var ( // AppModuleBasic implements the AppModuleBasic interface for the capability module. type AppModuleBasic struct { - cdc codec.BinaryCodec + cdc codec.Marshaler } -func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { +func NewAppModuleBasic(cdc codec.Marshaler) AppModuleBasic { return AppModuleBasic{cdc: cdc} } @@ -58,12 +59,12 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { } // DefaultGenesis returns the capability module's default genesis state. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) } // ValidateGenesis performs genesis state validation for the capability module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, 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) @@ -101,7 +102,7 @@ type AppModule struct { keeper keeper.Keeper } -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Marshaler, keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, @@ -137,7 +138,7 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // InitGenesis performs the capability module's genesis initialization It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, gs json.RawMessage) []abci.ValidatorUpdate { var genState types.GenesisState // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) @@ -148,7 +149,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra } // ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { genState := ExportGenesis(ctx, am.keeper) return cdc.MustMarshalJSON(genState) } diff --git a/x/tokenfactory/types/authorityMetadata.pb.go b/x/tokenfactory/types/authorityMetadata.pb.go new file mode 100644 index 00000000000..4d285c1c829 --- /dev/null +++ b/x/tokenfactory/types/authorityMetadata.pb.go @@ -0,0 +1,347 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/tokenfactory/v1beta1/authorityMetadata.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + 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 DenomAuthorityMetadata struct { + Admin string `protobuf:"bytes,1,opt,name=Admin,proto3" json:"Admin,omitempty" yaml:"admin"` +} + +func (m *DenomAuthorityMetadata) Reset() { *m = DenomAuthorityMetadata{} } +func (m *DenomAuthorityMetadata) String() string { return proto.CompactTextString(m) } +func (*DenomAuthorityMetadata) ProtoMessage() {} +func (*DenomAuthorityMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_99435de88ae175f7, []int{0} +} +func (m *DenomAuthorityMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DenomAuthorityMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DenomAuthorityMetadata.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 *DenomAuthorityMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_DenomAuthorityMetadata.Merge(m, src) +} +func (m *DenomAuthorityMetadata) XXX_Size() int { + return m.Size() +} +func (m *DenomAuthorityMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_DenomAuthorityMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_DenomAuthorityMetadata proto.InternalMessageInfo + +func (m *DenomAuthorityMetadata) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func init() { + proto.RegisterType((*DenomAuthorityMetadata)(nil), "osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata") +} + +func init() { + proto.RegisterFile("osmosis/tokenfactory/v1beta1/authorityMetadata.proto", fileDescriptor_99435de88ae175f7) +} + +var fileDescriptor_99435de88ae175f7 = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xc9, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, + 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, + 0x2c, 0xa9, 0xf4, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x92, 0x81, 0xea, 0xd2, 0x43, 0xd6, 0xa5, 0x07, 0xd5, 0x25, 0x25, 0x92, 0x9e, 0x9f, 0x9e, + 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, 0xc9, 0x25, 0x83, 0x35, 0xe9, 0x27, 0x25, 0x16, + 0xa7, 0xc2, 0x2d, 0x48, 0xce, 0xcf, 0xcc, 0x83, 0xc8, 0x2b, 0xb9, 0x71, 0x89, 0xb9, 0xa4, 0xe6, + 0xe5, 0xe7, 0x3a, 0xa2, 0xdb, 0x29, 0xa4, 0xc6, 0xc5, 0xea, 0x98, 0x92, 0x9b, 0x99, 0x27, 0xc1, + 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0xf0, 0xe9, 0x9e, 0x3c, 0x4f, 0x65, 0x62, 0x6e, 0x8e, 0x95, + 0x52, 0x22, 0x48, 0x58, 0x29, 0x08, 0x22, 0x6d, 0xc5, 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x93, 0xdf, + 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, + 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa4, 0x67, 0x96, 0x64, 0x94, + 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0xa0, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, + 0x57, 0xa0, 0x86, 0x42, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x79, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x9f, 0xc4, 0x39, 0x6f, 0x2a, 0x01, 0x00, 0x00, +} + +func (this *DenomAuthorityMetadata) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DenomAuthorityMetadata) + if !ok { + that2, ok := that.(DenomAuthorityMetadata) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Admin != that1.Admin { + return false + } + return true +} +func (m *DenomAuthorityMetadata) 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 *DenomAuthorityMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DenomAuthorityMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintAuthorityMetadata(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAuthorityMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovAuthorityMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DenomAuthorityMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovAuthorityMetadata(uint64(l)) + } + return n +} + +func sovAuthorityMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAuthorityMetadata(x uint64) (n int) { + return sovAuthorityMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DenomAuthorityMetadata) 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 ErrIntOverflowAuthorityMetadata + } + 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: DenomAuthorityMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DenomAuthorityMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthorityMetadata + } + 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 ErrInvalidLengthAuthorityMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthorityMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthorityMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthorityMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAuthorityMetadata(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, ErrIntOverflowAuthorityMetadata + } + 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, ErrIntOverflowAuthorityMetadata + } + 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, ErrIntOverflowAuthorityMetadata + } + 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, ErrInvalidLengthAuthorityMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAuthorityMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAuthorityMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAuthorityMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAuthorityMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAuthorityMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go index 133646fd35d..19e53913815 100644 --- a/x/tokenfactory/types/codec.go +++ b/x/tokenfactory/types/codec.go @@ -3,17 +3,29 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + // this line is used by starport scaffolding # 1 "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { - // this line is used by starport scaffolding # 2 + cdc.RegisterConcrete(&MsgCreateDenom{}, "osmosis/tokenfactory/create-denom", nil) + cdc.RegisterConcrete(&MsgMint{}, "osmosis/tokenfactory/mint", nil) + cdc.RegisterConcrete(&MsgBurn{}, "osmosis/tokenfactory/burn", nil) + cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil) + cdc.RegisterConcrete(&MsgChangeAdmin{}, "osmosis/tokenfactory/change-admin", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 - + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgCreateDenom{}, + &MsgMint{}, + &MsgBurn{}, + &MsgForceTransfer{}, + &MsgChangeAdmin{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go new file mode 100644 index 00000000000..c340b2accec --- /dev/null +++ b/x/tokenfactory/types/denoms.go @@ -0,0 +1,43 @@ +package types + +import ( + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + ModuleDenomPrefix = "factory" +) + +func GetTokenDenom(creator, nonce string) (string, error) { + denom := strings.Join([]string{"factory", creator, nonce}, "/") + return denom, sdk.ValidateDenom(denom) +} + +func DeconstructDenom(denom string) (creator string, nonce string, err error) { + err = sdk.ValidateDenom(denom) + if err != nil { + return "", "", err + } + + strParts := strings.Split(denom, "/") + if len(strParts) < 3 { + return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "not enough parts of denom %s", denom) + } + + if strParts[0] != ModuleDenomPrefix { + return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "denom prefix is incorrect. Is: %s. Should be: %s", strParts[0], ModuleDenomPrefix) + } + + creator = strParts[1] + _, err = sdk.AccAddressFromBech32(creator) + if err != nil { + return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "Invalid creator address (%s)", err) + } + + nonce = strings.Join(strParts[2:], "/") + + return creator, nonce, nil +} diff --git a/x/tokenfactory/types/denoms_test.go b/x/tokenfactory/types/denoms_test.go new file mode 100644 index 00000000000..a5d43a69b77 --- /dev/null +++ b/x/tokenfactory/types/denoms_test.go @@ -0,0 +1,64 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + appparams "github.com/osmosis-labs/osmosis/app/params" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func TestDecomposeDenoms(t *testing.T) { + appparams.SetAddressPrefixes() + for _, tc := range []struct { + desc string + denom string + valid bool + }{ + { + desc: "empty is invalid", + denom: "", + valid: false, + }, + { + desc: "normal", + denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + valid: true, + }, + { + desc: "multiple slashes in nonce", + denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin/1", + valid: true, + }, + { + desc: "no nonce", + denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/", + valid: true, + }, + { + desc: "incorrect prefix", + denom: "ibc/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + valid: false, + }, + { + desc: "nonce of only slashes", + denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/////", + valid: true, + }, + { + desc: "too long name", + denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/adsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsfadsf", + valid: false, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + _, _, err := types.DeconstructDenom(tc.denom) + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go index a13d693cdeb..b90cfd92deb 100644 --- a/x/tokenfactory/types/errors.go +++ b/x/tokenfactory/types/errors.go @@ -8,5 +8,9 @@ import ( // x/tokenfactory module sentinel errors var ( - ErrDenomExists = sdkerrors.Register(ModuleName, 1, "denom already exists") + ErrDenomExists = sdkerrors.Register(ModuleName, 1, "denom already exists") + ErrUnauthorized = sdkerrors.Register(ModuleName, 2, "unauthorized account") + ErrInvalidDenom = sdkerrors.Register(ModuleName, 3, "invalid denom") + ErrInvalidAuthorityMetadata = sdkerrors.Register(ModuleName, 4, "invalid authority metadata") + ErrInvalidGenesis = sdkerrors.Register(ModuleName, 5, "invalid genesis") ) diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index d55d26c436d..0e58a42579b 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -17,4 +17,6 @@ type BankKeeper interface { UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error } diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go index 06921a5995f..7c274555415 100644 --- a/x/tokenfactory/types/genesis.go +++ b/x/tokenfactory/types/genesis.go @@ -1,23 +1,45 @@ package types import ( -// this line is used by starport scaffolding # genesis/types/import + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// this line is used by starport scaffolding # genesis/types/import + // DefaultIndex is the default capability global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default + FactoryDenoms: []GenesisDenom{}, } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate + seenDenoms := map[string]bool{} + + for _, denom := range gs.GetFactoryDenoms() { + if seenDenoms[denom.GetDenom()] { + return sdkerrors.Wrapf(ErrInvalidGenesis, "duplicate denom: %s", denom.GetDenom()) + } + seenDenoms[denom.GetDenom()] = true + + _, _, err := DeconstructDenom(denom.GetDenom()) + if err != nil { + return err + } + + if denom.AuthorityMetadata.Admin != "" { + _, err = sdk.AccAddressFromBech32(denom.AuthorityMetadata.Admin) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidAuthorityMetadata, "Invalid admin address (%s)", err) + } + } + } return nil } diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go index 2c91f0aa49f..30c1eb64866 100644 --- a/x/tokenfactory/types/genesis.pb.go +++ b/x/tokenfactory/types/genesis.pb.go @@ -1,10 +1,11 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/tokenfactory/genesis.proto +// source: osmosis/tokenfactory/v1beta1/genesis.proto package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -24,13 +25,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the tokenfactory module's genesis state. type GenesisState struct { + FactoryDenoms []GenesisDenom `protobuf:"bytes,1,rep,name=factory_denoms,json=factoryDenoms,proto3" json:"factory_denoms" yaml:"factory_denoms"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_36277e68a5f011fe, []int{0} + return fileDescriptor_5749c3f71850298b, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -59,26 +61,97 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetFactoryDenoms() []GenesisDenom { + if m != nil { + return m.FactoryDenoms + } + return nil +} + +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"` +} + +func (m *GenesisDenom) Reset() { *m = GenesisDenom{} } +func (m *GenesisDenom) String() string { return proto.CompactTextString(m) } +func (*GenesisDenom) ProtoMessage() {} +func (*GenesisDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_5749c3f71850298b, []int{1} +} +func (m *GenesisDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisDenom.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 *GenesisDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisDenom.Merge(m, src) +} +func (m *GenesisDenom) XXX_Size() int { + return m.Size() +} +func (m *GenesisDenom) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisDenom proto.InternalMessageInfo + +func (m *GenesisDenom) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *GenesisDenom) GetAuthorityMetadata() DenomAuthorityMetadata { + if m != nil { + return m.AuthorityMetadata + } + return DenomAuthorityMetadata{} +} + func init() { - proto.RegisterType((*GenesisState)(nil), "osmosislabs.osmosis.tokenfactory.GenesisState") + proto.RegisterType((*GenesisState)(nil), "osmosis.tokenfactory.v1beta1.GenesisState") + proto.RegisterType((*GenesisDenom)(nil), "osmosis.tokenfactory.v1beta1.GenesisDenom") } func init() { - proto.RegisterFile("osmosis/tokenfactory/genesis.proto", fileDescriptor_36277e68a5f011fe) + proto.RegisterFile("osmosis/tokenfactory/v1beta1/genesis.proto", fileDescriptor_5749c3f71850298b) } -var fileDescriptor_36277e68a5f011fe = []byte{ - // 148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0x2f, 0xce, 0xcd, +var fileDescriptor_5749c3f71850298b = []byte{ + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xca, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, - 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, - 0x80, 0xaa, 0xc9, 0x49, 0x4c, 0x2a, 0xd6, 0x83, 0xb2, 0xf5, 0x90, 0xd5, 0x2b, 0xf1, 0x71, 0xf1, - 0xb8, 0x43, 0xb4, 0x04, 0x97, 0x24, 0x96, 0xa4, 0x3a, 0xf9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, - 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, - 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x49, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, - 0x3e, 0xd4, 0x28, 0x5d, 0x90, 0xb9, 0x30, 0x8e, 0x7e, 0x05, 0xaa, 0x4b, 0x4a, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0x0e, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x3e, 0xc0, 0x4b, 0xa7, - 0xae, 0x00, 0x00, 0x00, + 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0xaa, 0xd5, 0x43, 0x56, 0xab, 0x07, 0x55, + 0x2b, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, 0x99, 0xe0, + 0x35, 0x3f, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0xd2, 0x37, 0xb5, 0x24, 0x31, 0x25, + 0xb1, 0x24, 0x11, 0xa2, 0x4b, 0xa9, 0x81, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x77, 0x70, 0x49, 0x62, + 0x49, 0xaa, 0x50, 0x01, 0x17, 0x1f, 0x54, 0x6f, 0x7c, 0x4a, 0x6a, 0x5e, 0x7e, 0x6e, 0xb1, 0x04, + 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x96, 0x1e, 0x3e, 0x37, 0xe9, 0x41, 0xcd, 0x70, 0x01, 0x69, + 0x71, 0x92, 0x3d, 0x71, 0x4f, 0x9e, 0xe1, 0xd3, 0x3d, 0x79, 0xd1, 0xca, 0xc4, 0xdc, 0x1c, 0x2b, + 0x25, 0x54, 0xf3, 0x94, 0x82, 0x78, 0xa1, 0x02, 0x2e, 0x10, 0xfe, 0x7e, 0x84, 0x13, 0xc0, 0x22, + 0x42, 0x6a, 0x5c, 0xac, 0x60, 0xa5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x02, 0x9f, 0xee, + 0xc9, 0xf3, 0x40, 0x4c, 0x02, 0x0b, 0x2b, 0x05, 0x41, 0xa4, 0x85, 0xda, 0x18, 0xb9, 0x84, 0xe0, + 0xfe, 0x8a, 0xcf, 0x85, 0x7a, 0x4c, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0xc8, 0x04, 0xbf, 0x7b, + 0xc1, 0x36, 0x39, 0xa2, 0x07, 0x8a, 0x93, 0x22, 0xd4, 0xe5, 0x92, 0x10, 0xfb, 0x30, 0x4d, 0x57, + 0x0a, 0x12, 0xc4, 0x08, 0x4a, 0x27, 0xbf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, + 0x88, 0x32, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0xba, 0x47, + 0x37, 0x27, 0x31, 0xa9, 0x18, 0xc6, 0xd1, 0xaf, 0x40, 0x8d, 0xae, 0x92, 0xca, 0x82, 0xd4, 0xe2, + 0x24, 0x36, 0x70, 0xdc, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x94, 0x17, 0x89, 0x33, + 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -101,6 +174,60 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.FactoryDenoms) > 0 { + for iNdEx := len(m.FactoryDenoms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FactoryDenoms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *GenesisDenom) 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 *GenesisDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.AuthorityMetadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -121,6 +248,27 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + if len(m.FactoryDenoms) > 0 { + for _, e := range m.FactoryDenoms { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *GenesisDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.AuthorityMetadata.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -159,6 +307,155 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FactoryDenoms", 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.FactoryDenoms = append(m.FactoryDenoms, GenesisDenom{}) + if err := m.FactoryDenoms[len(m.FactoryDenoms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisDenom) 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 ErrIntOverflowGenesis + } + 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: GenesisDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorityMetadata", 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 + } + if err := m.AuthorityMetadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/tokenfactory/types/genesis_test.go b/x/tokenfactory/types/genesis_test.go index 617a4d7a01e..b4dc50e1768 100644 --- a/x/tokenfactory/types/genesis_test.go +++ b/x/tokenfactory/types/genesis_test.go @@ -19,13 +19,112 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ - // this line is used by starport scaffolding # types/genesis/validField + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44", + }, + }, + }, }, valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase + { + desc: "different admin from creator", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "osmo1ft6e5esdtdegnvcr3djd3ftk4kwpcr6jrx5fj9", + }, + }, + }, + }, + valid: true, + }, + { + desc: "empty admin", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "", + }, + }, + }, + }, + valid: true, + }, + { + desc: "no admin", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + }, + }, + }, + valid: true, + }, + { + desc: "invalid admin", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "moose", + }, + }, + }, + }, + valid: false, + }, + { + desc: "multiple denoms", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "", + }, + }, + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/litecoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "", + }, + }, + }, + }, + valid: true, + }, + { + desc: "duplicate denoms", + genState: &types.GenesisState{ + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "", + }, + }, + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "", + }, + }, + }, + }, + valid: false, + }, } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go index 9aee1a57f70..9a66a9634c4 100644 --- a/x/tokenfactory/types/keys.go +++ b/x/tokenfactory/types/keys.go @@ -1,5 +1,9 @@ package types +import ( + "strings" +) + const ( // ModuleName defines the module name ModuleName = "tokenfactory" @@ -18,11 +22,24 @@ const ( ) var ( - DenomAdminsStorePrefix = "admins" - DenomMintersStorePrefix = "minters" - DenomBurnersStorePrefix = "burners" + DenomAuthorityMetadataKey = "authoritymetadata" + DenomsPrefixKey = "denoms" + CreatorPrefixKey = "creator" + AdminPrefixKey = "admin" ) -func KeyPrefix(p string) []byte { - return []byte(p) +func GetDenomPrefixStore(denom string) []byte { + return []byte(strings.Join([]string{DenomsPrefixKey, denom, ""}, "|")) +} + +func GetCreatorPrefix(creator string) []byte { + return []byte(strings.Join([]string{CreatorPrefixKey, creator, ""}, "|")) } + +func GetCreatorsPrefix() []byte { + return []byte(strings.Join([]string{CreatorPrefixKey, ""}, "|")) +} + +// func GetAdminPrefix(admin string) []byte { +// return []byte(strings.Join([]string{admin, "admin", ""}, "|")) +// } diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go new file mode 100644 index 00000000000..375b0e397e8 --- /dev/null +++ b/x/tokenfactory/types/msgs.go @@ -0,0 +1,200 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// constants +const ( + TypeMsgCreateDenom = "create_denom" + TypeMsgMint = "mint" + TypeMsgBurn = "burn" + TypeMsgForceTransfer = "force_transfer" + TypeMsgChangeAdmin = "change_admin" +) + +var _ sdk.Msg = &MsgCreateDenom{} + +// NewMsgCreateDenom creates a msg to create a new denom +func NewMsgCreateDenom(sender, nonce string) *MsgCreateDenom { + return &MsgCreateDenom{ + Sender: sender, + Nonce: nonce, + } +} + +func (m MsgCreateDenom) Route() string { return RouterKey } +func (m MsgCreateDenom) Type() string { return TypeMsgCreateDenom } +func (m MsgCreateDenom) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + _, err = GetTokenDenom(m.Sender, m.Nonce) + if err != nil { + return sdkerrors.Wrap(ErrInvalidDenom, err.Error()) + } + + return nil +} +func (m MsgCreateDenom) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} +func (m MsgCreateDenom) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgMint{} + +// NewMsgMsgMint creates a message to mint tokens +func NewMsgMsgMint(sender string, amount sdk.Coin, mintTo string) *MsgMint { + return &MsgMint{ + Sender: sender, + Amount: amount, + MintToAddress: mintTo, + } +} + +func (m MsgMint) Route() string { return RouterKey } +func (m MsgMint) Type() string { return TypeMsgMint } +func (m MsgMint) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(m.MintToAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid recipient address (%s)", err) + } + + if !m.Amount.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + return nil +} +func (m MsgMint) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} +func (m MsgMint) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgBurn{} + +// NewMsgMsgBurn creates a message to burn tokens +func NewMsgMsgBurn(sender string, amount sdk.Coin, burnFrom string) *MsgBurn { + return &MsgBurn{ + Sender: sender, + Amount: amount, + BurnFromAddress: burnFrom, + } +} + +func (m MsgBurn) Route() string { return RouterKey } +func (m MsgBurn) Type() string { return TypeMsgBurn } +func (m MsgBurn) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(m.BurnFromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + + if !m.Amount.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + return nil +} +func (m MsgBurn) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} +func (m MsgBurn) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgForceTransfer{} + +// NewMsgForceTransfer creates a transfer funds from one account to another +func NewMsgForceTransfer(sender string, amount sdk.Coin, fromAddr, toAddr string) *MsgForceTransfer { + return &MsgForceTransfer{ + Sender: sender, + Amount: amount, + TransferFromAddress: fromAddr, + TransferToAddress: toAddr, + } +} + +func (m MsgForceTransfer) Route() string { return RouterKey } +func (m MsgForceTransfer) Type() string { return TypeMsgForceTransfer } +func (m MsgForceTransfer) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(m.TransferFromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + _, err = sdk.AccAddressFromBech32(m.TransferToAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + + if !m.Amount.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) + } + + return nil +} +func (m MsgForceTransfer) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} +func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +var _ sdk.Msg = &MsgChangeAdmin{} + +// NewMsgChangeAdmin creates a message to burn tokens +func NewMsgChangeAdmin(sender string, newAdmin string) *MsgChangeAdmin { + return &MsgChangeAdmin{ + Sender: sender, + NewAdmin: newAdmin, + } +} + +func (m MsgChangeAdmin) Route() string { return RouterKey } +func (m MsgChangeAdmin) Type() string { return TypeMsgChangeAdmin } +func (m MsgChangeAdmin) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(m.NewAdmin) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + + return nil +} +func (m MsgChangeAdmin) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} +func (m MsgChangeAdmin) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index d91cc870af0..ae346e07f6a 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/tokenfactory/query.proto +// source: osmosis/tokenfactory/v1beta1/query.proto package types @@ -7,11 +7,16 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -25,23 +30,226 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -func init() { proto.RegisterFile("osmosis/tokenfactory/query.proto", fileDescriptor_14a4c72f14d179b4) } - -var fileDescriptor_14a4c72f14d179b4 = []byte{ - // 196 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, - 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x82, 0xa9, 0xc8, - 0x49, 0x4c, 0x2a, 0xd6, 0x83, 0xb2, 0xf5, 0x90, 0x55, 0x4b, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, - 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, - 0x15, 0x43, 0xf4, 0x4b, 0x69, 0x25, 0x83, 0x35, 0xe9, 0x27, 0x25, 0x16, 0xa7, 0x42, 0x0c, 0xd6, - 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x4c, 0xcf, 0xcc, 0x03, 0x2b, 0x86, - 0xa8, 0x35, 0x62, 0xe7, 0x62, 0x0d, 0x04, 0xa9, 0x70, 0xf2, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, - 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, - 0xc6, 0x63, 0x39, 0x86, 0x28, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, - 0x7d, 0xa8, 0x6b, 0x74, 0x41, 0x4e, 0x83, 0x71, 0xf4, 0x2b, 0x50, 0xbd, 0x52, 0x52, 0x59, 0x90, - 0x5a, 0x9c, 0xc4, 0x06, 0x36, 0xdf, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x03, 0x47, 0xad, - 0xef, 0x00, 0x00, 0x00, +type QueryDenomAuthorityMetadataRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` +} + +func (m *QueryDenomAuthorityMetadataRequest) Reset() { *m = QueryDenomAuthorityMetadataRequest{} } +func (m *QueryDenomAuthorityMetadataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDenomAuthorityMetadataRequest) ProtoMessage() {} +func (*QueryDenomAuthorityMetadataRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{0} +} +func (m *QueryDenomAuthorityMetadataRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomAuthorityMetadataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomAuthorityMetadataRequest.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 *QueryDenomAuthorityMetadataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomAuthorityMetadataRequest.Merge(m, src) +} +func (m *QueryDenomAuthorityMetadataRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomAuthorityMetadataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomAuthorityMetadataRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomAuthorityMetadataRequest proto.InternalMessageInfo + +func (m *QueryDenomAuthorityMetadataRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type QueryDenomAuthorityMetadataResponse struct { + AuthorityMetadata DenomAuthorityMetadata `protobuf:"bytes,1,opt,name=authority_metadata,json=authorityMetadata,proto3" json:"authority_metadata" yaml:"authority_metadata"` +} + +func (m *QueryDenomAuthorityMetadataResponse) Reset() { *m = QueryDenomAuthorityMetadataResponse{} } +func (m *QueryDenomAuthorityMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDenomAuthorityMetadataResponse) ProtoMessage() {} +func (*QueryDenomAuthorityMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{1} +} +func (m *QueryDenomAuthorityMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomAuthorityMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomAuthorityMetadataResponse.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 *QueryDenomAuthorityMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomAuthorityMetadataResponse.Merge(m, src) +} +func (m *QueryDenomAuthorityMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomAuthorityMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomAuthorityMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomAuthorityMetadataResponse proto.InternalMessageInfo + +func (m *QueryDenomAuthorityMetadataResponse) GetAuthorityMetadata() DenomAuthorityMetadata { + if m != nil { + return m.AuthorityMetadata + } + return DenomAuthorityMetadata{} +} + +type QueryDenomsFromCreatorRequest struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty" yaml:"denoms"` +} + +func (m *QueryDenomsFromCreatorRequest) Reset() { *m = QueryDenomsFromCreatorRequest{} } +func (m *QueryDenomsFromCreatorRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDenomsFromCreatorRequest) ProtoMessage() {} +func (*QueryDenomsFromCreatorRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{2} +} +func (m *QueryDenomsFromCreatorRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomsFromCreatorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomsFromCreatorRequest.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 *QueryDenomsFromCreatorRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomsFromCreatorRequest.Merge(m, src) +} +func (m *QueryDenomsFromCreatorRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomsFromCreatorRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomsFromCreatorRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomsFromCreatorRequest proto.InternalMessageInfo + +func (m *QueryDenomsFromCreatorRequest) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type QueryDenomsFromCreatorResponse struct { + Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty" yaml:"denoms"` +} + +func (m *QueryDenomsFromCreatorResponse) Reset() { *m = QueryDenomsFromCreatorResponse{} } +func (m *QueryDenomsFromCreatorResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDenomsFromCreatorResponse) ProtoMessage() {} +func (*QueryDenomsFromCreatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6f22013ad0f72e3f, []int{3} +} +func (m *QueryDenomsFromCreatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomsFromCreatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomsFromCreatorResponse.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 *QueryDenomsFromCreatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomsFromCreatorResponse.Merge(m, src) +} +func (m *QueryDenomsFromCreatorResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomsFromCreatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomsFromCreatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomsFromCreatorResponse proto.InternalMessageInfo + +func (m *QueryDenomsFromCreatorResponse) GetDenoms() []string { + if m != nil { + return m.Denoms + } + return nil +} + +func init() { + proto.RegisterType((*QueryDenomAuthorityMetadataRequest)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest") + proto.RegisterType((*QueryDenomAuthorityMetadataResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse") + proto.RegisterType((*QueryDenomsFromCreatorRequest)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest") + proto.RegisterType((*QueryDenomsFromCreatorResponse)(nil), "osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse") +} + +func init() { + proto.RegisterFile("osmosis/tokenfactory/v1beta1/query.proto", fileDescriptor_6f22013ad0f72e3f) +} + +var fileDescriptor_6f22013ad0f72e3f = []byte{ + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0x33, 0x96, 0x56, 0x1c, 0x15, 0xcc, 0x20, 0x52, 0x43, 0xdd, 0xd4, 0x11, 0xa4, 0x2a, + 0xee, 0xd0, 0x9a, 0x93, 0x55, 0x34, 0xa9, 0xe8, 0xc1, 0x2a, 0x98, 0xa3, 0x97, 0x30, 0x9b, 0x4e, + 0xb7, 0x8b, 0xd9, 0x7d, 0xdb, 0x99, 0x89, 0xb8, 0x94, 0x5e, 0x3c, 0x78, 0x16, 0xfc, 0x1e, 0x7e, + 0x0c, 0xe9, 0xb1, 0xd0, 0x8b, 0xa7, 0x20, 0x89, 0xf8, 0x01, 0xf2, 0x09, 0x24, 0x33, 0x93, 0x58, + 0xdd, 0x75, 0x2d, 0xf6, 0xb4, 0xc3, 0xbc, 0xff, 0xfb, 0xbf, 0xf7, 0x7b, 0x6f, 0x16, 0xaf, 0x80, + 0x8a, 0x41, 0x45, 0x8a, 0x69, 0x78, 0x23, 0x92, 0x6d, 0xde, 0xd5, 0x20, 0x33, 0xf6, 0x76, 0x35, + 0x10, 0x9a, 0xaf, 0xb2, 0xdd, 0xbe, 0x90, 0x99, 0x9f, 0x4a, 0xd0, 0x40, 0x96, 0x9c, 0xd2, 0x3f, + 0xae, 0xf4, 0x9d, 0xb2, 0x76, 0x39, 0x84, 0x10, 0x8c, 0x90, 0x4d, 0x4e, 0x36, 0xa7, 0xb6, 0x14, + 0x02, 0x84, 0x3d, 0xc1, 0x78, 0x1a, 0x31, 0x9e, 0x24, 0xa0, 0xb9, 0x8e, 0x20, 0x51, 0x2e, 0x7a, + 0xbb, 0x6b, 0x2c, 0x59, 0xc0, 0x95, 0xb0, 0xa5, 0x66, 0x85, 0x53, 0x1e, 0x46, 0x89, 0x11, 0x3b, + 0x6d, 0xa3, 0xb4, 0x4f, 0xde, 0xd7, 0x3b, 0x20, 0x23, 0x9d, 0xbd, 0x10, 0x9a, 0x6f, 0x71, 0xcd, + 0x6d, 0x16, 0xdd, 0xc4, 0xf4, 0xd5, 0xc4, 0xf7, 0x89, 0x48, 0x20, 0x6e, 0xfe, 0x29, 0x6a, 0x8b, + 0xdd, 0xbe, 0x50, 0x9a, 0xdc, 0xc4, 0xf3, 0x5b, 0x13, 0xc1, 0x22, 0x5a, 0x46, 0x2b, 0xe7, 0x5a, + 0x97, 0xc6, 0x83, 0xfa, 0x85, 0x8c, 0xc7, 0xbd, 0xfb, 0xd4, 0x5c, 0xd3, 0xb6, 0x0d, 0xd3, 0xcf, + 0x08, 0xdf, 0x28, 0xb5, 0x53, 0x29, 0x24, 0x4a, 0x90, 0x0f, 0x08, 0x93, 0x59, 0x47, 0x9d, 0xd8, + 0x85, 0x8d, 0xfb, 0xf9, 0xb5, 0x86, 0x5f, 0x36, 0x47, 0xbf, 0xd8, 0xba, 0x75, 0xfd, 0x60, 0x50, + 0xaf, 0x8c, 0x07, 0xf5, 0xab, 0xb6, 0xaf, 0xbc, 0x3b, 0x6d, 0x57, 0x73, 0x43, 0xa0, 0x9b, 0xf8, + 0xda, 0xaf, 0x7e, 0xd5, 0x53, 0x09, 0xf1, 0x86, 0x14, 0x5c, 0x83, 0x9c, 0x92, 0xdf, 0xc1, 0x67, + 0xbb, 0xf6, 0xc6, 0xb1, 0x57, 0xc7, 0x83, 0xfa, 0xc5, 0x63, 0xec, 0x8a, 0xb6, 0xa7, 0x0a, 0xfa, + 0x1c, 0x7b, 0x7f, 0x73, 0x73, 0xe0, 0xb7, 0xf0, 0x82, 0xcd, 0x5a, 0x44, 0xcb, 0x73, 0xc5, 0x6e, + 0x4e, 0xb0, 0xf6, 0x65, 0x0e, 0xcf, 0x1b, 0x37, 0xf2, 0x03, 0xe1, 0x2b, 0xc5, 0xd4, 0xe4, 0x71, + 0xf9, 0xac, 0xfe, 0xbd, 0xda, 0x5a, 0xf3, 0x14, 0x0e, 0x16, 0x8a, 0x3e, 0x7b, 0x7f, 0xf4, 0xfd, + 0xd3, 0x99, 0x26, 0x79, 0xc4, 0x4a, 0x9f, 0xa0, 0xe5, 0x62, 0x7b, 0xe6, 0xbb, 0xcf, 0xf2, 0x1b, + 0x22, 0x47, 0x08, 0x57, 0x73, 0xb3, 0x23, 0xeb, 0x27, 0xed, 0xb0, 0x60, 0x7f, 0xb5, 0x07, 0xff, + 0x97, 0xec, 0xc8, 0x36, 0x0c, 0xd9, 0x43, 0xb2, 0x7e, 0x12, 0xb2, 0xce, 0xb6, 0x84, 0xb8, 0xe3, + 0xde, 0x02, 0xdb, 0x73, 0x87, 0xfd, 0xd6, 0xcb, 0x83, 0xa1, 0x87, 0x0e, 0x87, 0x1e, 0xfa, 0x36, + 0xf4, 0xd0, 0xc7, 0x91, 0x57, 0x39, 0x1c, 0x79, 0x95, 0xaf, 0x23, 0xaf, 0xf2, 0xba, 0x11, 0x46, + 0x7a, 0xa7, 0x1f, 0xf8, 0x5d, 0x88, 0xa7, 0x05, 0xee, 0xf6, 0x78, 0xa0, 0x66, 0xd5, 0xde, 0xfd, + 0x5e, 0x4f, 0x67, 0xa9, 0x50, 0xc1, 0x82, 0xf9, 0x73, 0xef, 0xfd, 0x0c, 0x00, 0x00, 0xff, 0xff, + 0x38, 0x95, 0x3d, 0x51, 0x99, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -56,6 +264,8 @@ 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 { + DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) + DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) } type queryClient struct { @@ -66,22 +276,702 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) DenomAuthorityMetadata(ctx context.Context, in *QueryDenomAuthorityMetadataRequest, opts ...grpc.CallOption) (*QueryDenomAuthorityMetadataResponse, error) { + out := new(QueryDenomAuthorityMetadataResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DenomsFromCreator(ctx context.Context, in *QueryDenomsFromCreatorRequest, opts ...grpc.CallOption) (*QueryDenomsFromCreatorResponse, error) { + out := new(QueryDenomsFromCreatorResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { + DenomAuthorityMetadata(context.Context, *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) + DenomsFromCreator(context.Context, *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) DenomAuthorityMetadata(ctx context.Context, req *QueryDenomAuthorityMetadataRequest) (*QueryDenomAuthorityMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenomAuthorityMetadata not implemented") +} +func (*UnimplementedQueryServer) DenomsFromCreator(ctx context.Context, req *QueryDenomsFromCreatorRequest) (*QueryDenomsFromCreatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenomsFromCreator not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_DenomAuthorityMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDenomAuthorityMetadataRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DenomAuthorityMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DenomAuthorityMetadata(ctx, req.(*QueryDenomAuthorityMetadataRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DenomsFromCreator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDenomsFromCreatorRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DenomsFromCreator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DenomsFromCreator(ctx, req.(*QueryDenomsFromCreatorRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosislabs.osmosis.tokenfactory.Query", + ServiceName: "osmosis.tokenfactory.v1beta1.Query", HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/tokenfactory/query.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "DenomAuthorityMetadata", + Handler: _Query_DenomAuthorityMetadata_Handler, + }, + { + MethodName: "DenomsFromCreator", + Handler: _Query_DenomsFromCreator_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/tokenfactory/v1beta1/query.proto", +} + +func (m *QueryDenomAuthorityMetadataRequest) 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 *QueryDenomAuthorityMetadataRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomAuthorityMetadataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDenomAuthorityMetadataResponse) 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 *QueryDenomAuthorityMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomAuthorityMetadataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.AuthorityMetadata.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 *QueryDenomsFromCreatorRequest) 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 *QueryDenomsFromCreatorRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomsFromCreatorRequest) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryDenomsFromCreatorResponse) 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 *QueryDenomsFromCreatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomsFromCreatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denoms) > 0 { + for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denoms[iNdEx]) + copy(dAtA[i:], m.Denoms[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) + 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 *QueryDenomAuthorityMetadataRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDenomAuthorityMetadataResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AuthorityMetadata.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryDenomsFromCreatorRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDenomsFromCreatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Denoms) > 0 { + for _, s := range m.Denoms { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryDenomAuthorityMetadataRequest) 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: QueryDenomAuthorityMetadataRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomAuthorityMetadataRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = 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 *QueryDenomAuthorityMetadataResponse) 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: QueryDenomAuthorityMetadataResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomAuthorityMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorityMetadata", 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.AuthorityMetadata.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 *QueryDenomsFromCreatorRequest) 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: QueryDenomsFromCreatorRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomsFromCreatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.Creator = 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 *QueryDenomsFromCreatorResponse) 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: QueryDenomsFromCreatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomsFromCreatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denoms", 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.Denoms = append(m.Denoms, 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 skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/types/query.pb.gw.go b/x/tokenfactory/types/query.pb.gw.go new file mode 100644 index 00000000000..f3b609e8a15 --- /dev/null +++ b/x/tokenfactory/types/query.pb.gw.go @@ -0,0 +1,282 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/tokenfactory/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_Query_DenomAuthorityMetadata_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomAuthorityMetadataRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.DenomAuthorityMetadata(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DenomAuthorityMetadata_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomAuthorityMetadataRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.DenomAuthorityMetadata(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomsFromCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + msg, err := client.DenomsFromCreator(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DenomsFromCreator_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomsFromCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator") + } + + protoReq.Creator, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator", err) + } + + msg, err := server.DenomsFromCreator(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. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_DenomAuthorityMetadata_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DenomAuthorityMetadata_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomAuthorityMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DenomsFromCreator_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DenomsFromCreator_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomsFromCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_DenomAuthorityMetadata_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_DenomAuthorityMetadata_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_DenomAuthorityMetadata_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DenomsFromCreator_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_DenomsFromCreator_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_DenomsFromCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_DenomAuthorityMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"osmosis", "tokenfactory", "v1beta1", "denoms", "denom", "authority_metadata"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_DenomsFromCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"osmosis", "tokenfactory", "v1beta1", "denoms_from_creator", "creator"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_DenomAuthorityMetadata_0 = runtime.ForwardResponseMessage + + forward_Query_DenomsFromCreator_0 = runtime.ForwardResponseMessage +) diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index 6c9bc6538d3..043bf7dc6d5 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/tokenfactory/tx.proto +// source: osmosis/tokenfactory/v1beta1/tx.proto package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -39,7 +39,7 @@ func (m *MsgCreateDenom) Reset() { *m = MsgCreateDenom{} } func (m *MsgCreateDenom) String() string { return proto.CompactTextString(m) } func (*MsgCreateDenom) ProtoMessage() {} func (*MsgCreateDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_195ce4708c850bc3, []int{0} + return fileDescriptor_283b6c9a90a846b4, []int{0} } func (m *MsgCreateDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -89,7 +89,7 @@ func (m *MsgCreateDenomResponse) Reset() { *m = MsgCreateDenomResponse{} func (m *MsgCreateDenomResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateDenomResponse) ProtoMessage() {} func (*MsgCreateDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_195ce4708c850bc3, []int{1} + return fileDescriptor_283b6c9a90a846b4, []int{1} } func (m *MsgCreateDenomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -118,33 +118,460 @@ func (m *MsgCreateDenomResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateDenomResponse proto.InternalMessageInfo +// ===================== MsgMint +type MsgMint struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` + MintToAddress string `protobuf:"bytes,3,opt,name=mintToAddress,proto3" json:"mintToAddress,omitempty" yaml:"mint_to_address"` +} + +func (m *MsgMint) Reset() { *m = MsgMint{} } +func (m *MsgMint) String() string { return proto.CompactTextString(m) } +func (*MsgMint) ProtoMessage() {} +func (*MsgMint) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{2} +} +func (m *MsgMint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMint.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 *MsgMint) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMint.Merge(m, src) +} +func (m *MsgMint) XXX_Size() int { + return m.Size() +} +func (m *MsgMint) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMint.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMint proto.InternalMessageInfo + +func (m *MsgMint) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMint) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *MsgMint) GetMintToAddress() string { + if m != nil { + return m.MintToAddress + } + return "" +} + +type MsgMintResponse struct { +} + +func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} } +func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintResponse) ProtoMessage() {} +func (*MsgMintResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{3} +} +func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintResponse.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 *MsgMintResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintResponse.Merge(m, src) +} +func (m *MsgMintResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo + +// ===================== MsgBurn +type MsgBurn struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` + BurnFromAddress string `protobuf:"bytes,3,opt,name=burnFromAddress,proto3" json:"burnFromAddress,omitempty" yaml:"burn_from_address"` +} + +func (m *MsgBurn) Reset() { *m = MsgBurn{} } +func (m *MsgBurn) String() string { return proto.CompactTextString(m) } +func (*MsgBurn) ProtoMessage() {} +func (*MsgBurn) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{4} +} +func (m *MsgBurn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurn.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 *MsgBurn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurn.Merge(m, src) +} +func (m *MsgBurn) XXX_Size() int { + return m.Size() +} +func (m *MsgBurn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurn.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurn proto.InternalMessageInfo + +func (m *MsgBurn) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgBurn) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *MsgBurn) GetBurnFromAddress() string { + if m != nil { + return m.BurnFromAddress + } + return "" +} + +type MsgBurnResponse struct { +} + +func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } +func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBurnResponse) ProtoMessage() {} +func (*MsgBurnResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{5} +} +func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnResponse.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 *MsgBurnResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnResponse.Merge(m, src) +} +func (m *MsgBurnResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo + +// ===================== MsgForceTransfer +type MsgForceTransfer struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` + TransferFromAddress string `protobuf:"bytes,3,opt,name=transferFromAddress,proto3" json:"transferFromAddress,omitempty" yaml:"transfer_from_address"` + TransferToAddress string `protobuf:"bytes,4,opt,name=transferToAddress,proto3" json:"transferToAddress,omitempty" yaml:"transfer_to_address"` +} + +func (m *MsgForceTransfer) Reset() { *m = MsgForceTransfer{} } +func (m *MsgForceTransfer) String() string { return proto.CompactTextString(m) } +func (*MsgForceTransfer) ProtoMessage() {} +func (*MsgForceTransfer) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{6} +} +func (m *MsgForceTransfer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgForceTransfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgForceTransfer.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 *MsgForceTransfer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgForceTransfer.Merge(m, src) +} +func (m *MsgForceTransfer) XXX_Size() int { + return m.Size() +} +func (m *MsgForceTransfer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgForceTransfer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgForceTransfer proto.InternalMessageInfo + +func (m *MsgForceTransfer) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgForceTransfer) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func (m *MsgForceTransfer) GetTransferFromAddress() string { + if m != nil { + return m.TransferFromAddress + } + return "" +} + +func (m *MsgForceTransfer) GetTransferToAddress() string { + if m != nil { + return m.TransferToAddress + } + return "" +} + +type MsgForceTransferResponse struct { +} + +func (m *MsgForceTransferResponse) Reset() { *m = MsgForceTransferResponse{} } +func (m *MsgForceTransferResponse) String() string { return proto.CompactTextString(m) } +func (*MsgForceTransferResponse) ProtoMessage() {} +func (*MsgForceTransferResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{7} +} +func (m *MsgForceTransferResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgForceTransferResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgForceTransferResponse.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 *MsgForceTransferResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgForceTransferResponse.Merge(m, src) +} +func (m *MsgForceTransferResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgForceTransferResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgForceTransferResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgForceTransferResponse proto.InternalMessageInfo + +// ===================== MsgChangeAdmin +type MsgChangeAdmin struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + NewAdmin string `protobuf:"bytes,3,opt,name=newAdmin,proto3" json:"newAdmin,omitempty" yaml:"new_admin"` +} + +func (m *MsgChangeAdmin) Reset() { *m = MsgChangeAdmin{} } +func (m *MsgChangeAdmin) String() string { return proto.CompactTextString(m) } +func (*MsgChangeAdmin) ProtoMessage() {} +func (*MsgChangeAdmin) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{8} +} +func (m *MsgChangeAdmin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChangeAdmin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChangeAdmin.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 *MsgChangeAdmin) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChangeAdmin.Merge(m, src) +} +func (m *MsgChangeAdmin) XXX_Size() int { + return m.Size() +} +func (m *MsgChangeAdmin) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChangeAdmin.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChangeAdmin proto.InternalMessageInfo + +func (m *MsgChangeAdmin) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgChangeAdmin) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgChangeAdmin) GetNewAdmin() string { + if m != nil { + return m.NewAdmin + } + return "" +} + +type MsgChangeAdminResponse struct { +} + +func (m *MsgChangeAdminResponse) Reset() { *m = MsgChangeAdminResponse{} } +func (m *MsgChangeAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgChangeAdminResponse) ProtoMessage() {} +func (*MsgChangeAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_283b6c9a90a846b4, []int{9} +} +func (m *MsgChangeAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChangeAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChangeAdminResponse.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 *MsgChangeAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChangeAdminResponse.Merge(m, src) +} +func (m *MsgChangeAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgChangeAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChangeAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgChangeAdminResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateDenom)(nil), "osmosis.tokenfactory.v1beta1.MsgCreateDenom") proto.RegisterType((*MsgCreateDenomResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse") + proto.RegisterType((*MsgMint)(nil), "osmosis.tokenfactory.v1beta1.MsgMint") + proto.RegisterType((*MsgMintResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgMintResponse") + proto.RegisterType((*MsgBurn)(nil), "osmosis.tokenfactory.v1beta1.MsgBurn") + proto.RegisterType((*MsgBurnResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgBurnResponse") + proto.RegisterType((*MsgForceTransfer)(nil), "osmosis.tokenfactory.v1beta1.MsgForceTransfer") + proto.RegisterType((*MsgForceTransferResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgForceTransferResponse") + proto.RegisterType((*MsgChangeAdmin)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdmin") + proto.RegisterType((*MsgChangeAdminResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse") +} + +func init() { + proto.RegisterFile("osmosis/tokenfactory/v1beta1/tx.proto", fileDescriptor_283b6c9a90a846b4) } -func init() { proto.RegisterFile("osmosis/tokenfactory/tx.proto", fileDescriptor_195ce4708c850bc3) } - -var fileDescriptor_195ce4708c850bc3 = []byte{ - // 286 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, - 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x4a, 0xeb, 0x21, 0x4b, - 0xeb, 0x95, 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x15, - 0xea, 0x83, 0x58, 0x10, 0x3d, 0x52, 0x72, 0xc9, 0x60, 0x4d, 0xfa, 0x49, 0x89, 0xc5, 0xa9, 0xfa, - 0x50, 0xa5, 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0x64, 0x2e, 0x3e, 0xdf, 0xe2, 0x74, - 0xe7, 0xa2, 0xd4, 0xc4, 0x92, 0x54, 0x97, 0xd4, 0xbc, 0xfc, 0x5c, 0x21, 0x4d, 0x2e, 0xb6, 0xe2, - 0xd4, 0xbc, 0x94, 0xd4, 0x22, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xc1, 0x4f, 0xf7, 0xe4, - 0x79, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x20, 0xe2, 0x4a, 0x41, 0x50, 0x05, 0x42, 0x6a, 0x5c, - 0xac, 0x79, 0xf9, 0x79, 0xc9, 0xa9, 0x12, 0x4c, 0x60, 0x95, 0x02, 0x9f, 0xee, 0xc9, 0xf3, 0x40, - 0x54, 0x82, 0x85, 0x95, 0x82, 0x20, 0xd2, 0x4a, 0x12, 0x5c, 0x62, 0xa8, 0x96, 0x04, 0xa5, 0x16, - 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x55, 0x70, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x15, 0x72, 0x71, - 0x23, 0x3b, 0x41, 0x47, 0x0f, 0x9f, 0x4f, 0xf5, 0x50, 0xcd, 0x92, 0x32, 0x21, 0x45, 0x35, 0xcc, - 0x66, 0x27, 0xbf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, - 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x49, 0xcf, - 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0xac, 0x9b, 0x93, 0x98, 0x54, - 0x0c, 0xe3, 0xe8, 0x57, 0xa0, 0xc5, 0x4f, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x3c, 0x8d, - 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x34, 0xbc, 0x1d, 0x1d, 0xc4, 0x01, 0x00, 0x00, +var fileDescriptor_283b6c9a90a846b4 = []byte{ + // 622 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xc1, 0x6e, 0xd3, 0x30, + 0x1c, 0xc6, 0x9b, 0x6d, 0x0c, 0xf0, 0x18, 0xdb, 0xc2, 0x98, 0x42, 0x34, 0x25, 0x93, 0xa5, 0x21, + 0x90, 0x58, 0xc2, 0xc6, 0xc4, 0x81, 0x13, 0xeb, 0x50, 0xc5, 0x81, 0x72, 0x88, 0x76, 0x42, 0x48, + 0x55, 0x92, 0xba, 0x59, 0xc4, 0x62, 0x17, 0xdb, 0xa5, 0xeb, 0x5b, 0x70, 0xe1, 0xce, 0x95, 0xb7, + 0xe0, 0x84, 0x76, 0xdc, 0x91, 0x53, 0x84, 0xda, 0x37, 0xc8, 0x13, 0xa0, 0xd8, 0x49, 0x9a, 0xb4, + 0x88, 0xb6, 0xa7, 0xdd, 0x5a, 0xfb, 0xf7, 0xfd, 0xff, 0xfe, 0x6c, 0x7f, 0x0e, 0xd8, 0x27, 0x2c, + 0x22, 0x2c, 0x64, 0x36, 0x27, 0x9f, 0x10, 0xee, 0xb8, 0x3e, 0x27, 0x74, 0x60, 0x7f, 0x39, 0xf4, + 0x10, 0x77, 0x0f, 0x6d, 0x7e, 0x69, 0x75, 0x29, 0xe1, 0x44, 0xdd, 0xcd, 0x30, 0xab, 0x8c, 0x59, + 0x19, 0xa6, 0x6f, 0x07, 0x24, 0x20, 0x02, 0xb4, 0xd3, 0x5f, 0x52, 0xa3, 0x1b, 0xbe, 0x10, 0xd9, + 0x9e, 0xcb, 0x50, 0x51, 0xd1, 0x27, 0x21, 0x96, 0xf3, 0xd0, 0x07, 0xf7, 0x9b, 0x2c, 0x38, 0xa5, + 0xc8, 0xe5, 0xe8, 0x0d, 0xc2, 0x24, 0x52, 0x9f, 0x82, 0x55, 0x86, 0x70, 0x1b, 0x51, 0x4d, 0xd9, + 0x53, 0x9e, 0xdc, 0xad, 0x6f, 0x25, 0xb1, 0xb9, 0x3e, 0x70, 0xa3, 0x8b, 0x57, 0x50, 0x8e, 0x43, + 0x27, 0x03, 0xd4, 0xc7, 0xe0, 0x16, 0x26, 0xd8, 0x47, 0xda, 0x92, 0x20, 0x37, 0x93, 0xd8, 0xbc, + 0x27, 0x49, 0x31, 0x0c, 0x1d, 0x39, 0x0d, 0x35, 0xb0, 0x53, 0x6d, 0xe2, 0x20, 0xd6, 0x25, 0x98, + 0x21, 0xf8, 0x53, 0x01, 0xb7, 0x9b, 0x2c, 0x68, 0x86, 0x98, 0x2f, 0xd2, 0xf8, 0x2d, 0x58, 0x75, + 0x23, 0xd2, 0xc3, 0x5c, 0x74, 0x5e, 0x3b, 0x7a, 0x64, 0x49, 0x9b, 0x56, 0x6a, 0x33, 0xdf, 0x11, + 0xeb, 0x94, 0x84, 0xb8, 0xfe, 0xf0, 0x2a, 0x36, 0x6b, 0xe3, 0x4a, 0x52, 0x06, 0x9d, 0x4c, 0xaf, + 0xbe, 0x06, 0xeb, 0x51, 0x88, 0xf9, 0x19, 0x39, 0x69, 0xb7, 0x29, 0x62, 0x4c, 0x5b, 0x16, 0xbd, + 0xf5, 0x24, 0x36, 0x77, 0xa4, 0x22, 0x9d, 0x6e, 0x71, 0xd2, 0x72, 0x25, 0x00, 0x9d, 0xaa, 0x00, + 0x6e, 0x81, 0x8d, 0xcc, 0x41, 0xe1, 0xea, 0x97, 0x74, 0x55, 0xef, 0x51, 0x7c, 0x33, 0xae, 0x1a, + 0x60, 0xc3, 0xeb, 0x51, 0xdc, 0xa0, 0x24, 0xaa, 0xfa, 0xda, 0x4d, 0x62, 0x53, 0x93, 0x9a, 0x14, + 0x68, 0x75, 0x28, 0x89, 0xc6, 0xce, 0x26, 0x45, 0x99, 0xb7, 0xd4, 0x47, 0xe1, 0xed, 0xc7, 0x12, + 0xd8, 0x6c, 0xb2, 0xa0, 0x41, 0xa8, 0x8f, 0xce, 0xa8, 0x8b, 0x59, 0x07, 0xd1, 0x9b, 0x31, 0xe9, + 0x80, 0x07, 0x3c, 0x5b, 0xc0, 0xb4, 0xd1, 0xbd, 0x24, 0x36, 0x77, 0xa5, 0x2e, 0x87, 0x26, 0xcc, + 0xfe, 0x4b, 0xac, 0xbe, 0x03, 0x5b, 0xf9, 0xf0, 0xf8, 0x4a, 0xac, 0x88, 0x8a, 0x46, 0x12, 0x9b, + 0xfa, 0x44, 0xc5, 0xf2, 0xb5, 0x98, 0x16, 0x42, 0x1d, 0x68, 0x93, 0x5b, 0x55, 0xec, 0xe3, 0x37, + 0x45, 0x26, 0xef, 0xdc, 0xc5, 0x01, 0x3a, 0x69, 0x47, 0x21, 0x5e, 0x30, 0x79, 0xed, 0x34, 0x48, + 0xd3, 0xc9, 0x13, 0xc3, 0xd0, 0x91, 0xd3, 0xea, 0x73, 0x70, 0x07, 0xa3, 0xbe, 0x28, 0x9f, 0x6d, + 0xcc, 0x76, 0x12, 0x9b, 0x9b, 0x59, 0x48, 0x51, 0xbf, 0xe5, 0xa6, 0x53, 0xd0, 0x29, 0xa8, 0x3c, + 0xab, 0xe3, 0x65, 0xe5, 0x2b, 0x3e, 0xfa, 0xbe, 0x02, 0x96, 0x9b, 0x2c, 0x50, 0x3f, 0x83, 0xb5, + 0xf2, 0x7b, 0xf1, 0xcc, 0xfa, 0xdf, 0xb3, 0x64, 0x55, 0x83, 0xaf, 0x1f, 0x2f, 0x42, 0xe7, 0xad, + 0xd5, 0x8f, 0x60, 0x45, 0x3c, 0x11, 0xfb, 0x33, 0xd5, 0x29, 0xa6, 0x1f, 0xcc, 0x85, 0x95, 0xab, + 0x8b, 0xa8, 0xce, 0xae, 0x9e, 0x62, 0x73, 0x54, 0x2f, 0x07, 0x46, 0xed, 0x83, 0xf5, 0x6a, 0x58, + 0xac, 0x99, 0xfa, 0x0a, 0xaf, 0xbf, 0x5c, 0x8c, 0x2f, 0x1a, 0xa7, 0xe7, 0x54, 0xba, 0x5d, 0x73, + 0x9c, 0xd3, 0x98, 0x9e, 0xe7, 0x9c, 0xa6, 0xaf, 0x48, 0xfd, 0xfd, 0xd5, 0xd0, 0x50, 0xae, 0x87, + 0x86, 0xf2, 0x67, 0x68, 0x28, 0x5f, 0x47, 0x46, 0xed, 0x7a, 0x64, 0xd4, 0x7e, 0x8f, 0x8c, 0xda, + 0x87, 0xe3, 0x20, 0xe4, 0xe7, 0x3d, 0xcf, 0xf2, 0x49, 0x64, 0x67, 0x95, 0x0f, 0x2e, 0x5c, 0x8f, + 0xe5, 0x7f, 0xec, 0xcb, 0xea, 0xc7, 0x8f, 0x0f, 0xba, 0x88, 0x79, 0xab, 0xe2, 0x23, 0xf5, 0xe2, + 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0x24, 0x24, 0x31, 0x21, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -160,6 +587,10 @@ 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 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(ctx context.Context, in *MsgForceTransfer, opts ...grpc.CallOption) (*MsgForceTransferResponse, error) + ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) } type msgClient struct { @@ -179,17 +610,69 @@ func (c *msgClient) CreateDenom(ctx context.Context, in *MsgCreateDenom, opts .. return out, nil } -// MsgServer is the server API for Msg service. -type MsgServer interface { - CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) +func (c *msgClient) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) { + out := new(MsgMintResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/Mint", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { +func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) { + out := new(MsgBurnResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/Burn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (*UnimplementedMsgServer) CreateDenom(ctx context.Context, req *MsgCreateDenom) (*MsgCreateDenomResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateDenom not implemented") +func (c *msgClient) ForceTransfer(ctx context.Context, in *MsgForceTransfer, opts ...grpc.CallOption) (*MsgForceTransferResponse, error) { + out := new(MsgForceTransferResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/ForceTransfer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) { + out := new(MsgChangeAdminResponse) + err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/ChangeAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) + Mint(context.Context, *MsgMint) (*MsgMintResponse, error) + Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) + ForceTransfer(context.Context, *MsgForceTransfer) (*MsgForceTransferResponse, error) + ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateDenom(ctx context.Context, req *MsgCreateDenom) (*MsgCreateDenomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDenom not implemented") +} +func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMintResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Mint not implemented") +} +func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") +} +func (*UnimplementedMsgServer) ForceTransfer(ctx context.Context, req *MsgForceTransfer) (*MsgForceTransferResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ForceTransfer not implemented") +} +func (*UnimplementedMsgServer) ChangeAdmin(ctx context.Context, req *MsgChangeAdmin) (*MsgChangeAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChangeAdmin not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -214,6 +697,78 @@ func _Msg_CreateDenom_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Msg_Mint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMint) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Mint(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/Mint", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Mint(ctx, req.(*MsgMint)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBurn) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Burn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/Burn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Burn(ctx, req.(*MsgBurn)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ForceTransfer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgForceTransfer) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ForceTransfer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/ForceTransfer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ForceTransfer(ctx, req.(*MsgForceTransfer)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ChangeAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgChangeAdmin) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ChangeAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/ChangeAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChangeAdmin(ctx, req.(*MsgChangeAdmin)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.tokenfactory.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -222,9 +777,25 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateDenom", Handler: _Msg_CreateDenom_Handler, }, + { + MethodName: "Mint", + Handler: _Msg_Mint_Handler, + }, + { + MethodName: "Burn", + Handler: _Msg_Burn_Handler, + }, + { + MethodName: "ForceTransfer", + Handler: _Msg_ForceTransfer_Handler, + }, + { + MethodName: "ChangeAdmin", + Handler: _Msg_ChangeAdmin_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/tokenfactory/tx.proto", + Metadata: "osmosis/tokenfactory/v1beta1/tx.proto", } func (m *MsgCreateDenom) Marshal() (dAtA []byte, err error) { @@ -271,66 +842,1255 @@ func (m *MsgCreateDenomResponse) Marshal() (dAtA []byte, err error) { if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} + return dAtA[:n], nil +} + +func (m *MsgCreateDenomResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMint) 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 *MsgMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MintToAddress) > 0 { + i -= len(m.MintToAddress) + copy(dAtA[i:], m.MintToAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.MintToAddress))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintResponse) 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 *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBurn) 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 *MsgBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BurnFromAddress) > 0 { + i -= len(m.BurnFromAddress) + copy(dAtA[i:], m.BurnFromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.BurnFromAddress))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnResponse) 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 *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgForceTransfer) 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 *MsgForceTransfer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgForceTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TransferToAddress) > 0 { + i -= len(m.TransferToAddress) + copy(dAtA[i:], m.TransferToAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.TransferToAddress))) + i-- + dAtA[i] = 0x22 + } + if len(m.TransferFromAddress) > 0 { + i -= len(m.TransferFromAddress) + copy(dAtA[i:], m.TransferFromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.TransferFromAddress))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgForceTransferResponse) 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 *MsgForceTransferResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgForceTransferResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgChangeAdmin) 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 *MsgChangeAdmin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChangeAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewAdmin))) + i-- + dAtA[i] = 0x1a + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgChangeAdminResponse) 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 *MsgChangeAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChangeAdminResponse) 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 *MsgCreateDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Nonce) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateDenomResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.MintToAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBurn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.BurnFromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgBurnResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgForceTransfer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.TransferFromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TransferToAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgForceTransferResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgChangeAdmin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgChangeAdminResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateDenom) 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: MsgCreateDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", 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.Nonce = 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 *MsgCreateDenomResponse) 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: MsgCreateDenomResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateDenomResponse: 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 *MsgMint) 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: MsgMint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintToAddress", 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.MintToAddress = 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 *MsgMintResponse) 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: MsgMintResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintResponse: 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 *MsgBurn) 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: MsgBurn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BurnFromAddress", 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.BurnFromAddress = 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 *MsgBurnResponse) 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: MsgBurnResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnResponse: 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 *MsgForceTransfer) 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: MsgForceTransfer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgForceTransfer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferFromAddress", 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.TransferFromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferToAddress", 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.TransferToAddress = 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 + } + } -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++ + if iNdEx > l { + return io.ErrUnexpectedEOF } - dAtA[offset] = uint8(v) - return base + return nil } -func (m *MsgCreateDenom) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Nonce) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgForceTransferResponse) 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: MsgForceTransferResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgForceTransferResponse: 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 + } } - return n -} -func (m *MsgCreateDenomResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { +func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -353,10 +2113,10 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateDenom: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeAdmin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateDenom: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeAdmin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -393,7 +2153,7 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -421,7 +2181,39 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Nonce = string(dAtA[iNdEx:postIndex]) + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", 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.NewAdmin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -444,7 +2236,7 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -467,10 +2259,10 @@ func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateDenomResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeAdminResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 16141bef3ac9e29c25cfba233cf4a91ccc49ecb5 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 14 Nov 2021 23:35:56 -0500 Subject: [PATCH 03/22] cli --- x/tokenfactory/client/cli/tx.go | 172 ++++++++++++++++++++++++++++++-- x/tokenfactory/handler.go | 26 ----- x/tokenfactory/module.go | 2 +- x/tokenfactory/types/msgs.go | 16 ++- 4 files changed, 174 insertions(+), 42 deletions(-) delete mode 100644 x/tokenfactory/handler.go diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index d2e0a4f8e94..bbc34b7e109 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -2,23 +2,18 @@ package cli import ( "fmt" - "time" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" ) -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) - -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" -) - // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ @@ -29,7 +24,164 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - // this line is used by starport scaffolding # 1 + cmd.AddCommand( + NewCreateDenomCmd(), + ) + + return cmd +} + +// NewCreateDenomCmd broadcast MsgCreateDenom +func NewCreateDenomCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-denom [nonce] [flags]", + Short: "create a new denom from an account", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + msg := types.NewMsgCreateDenom( + clientCtx.GetFromAddress().String(), + args[0], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewMintCmd broadcast MsgMint +func NewMintCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint [amount] [mint-to-address] [flags]", + Short: "Mint a denom to an address. Must have admin authority to do so.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + amount, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgMint( + clientCtx.GetFromAddress().String(), + amount, + args[1], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewBurnCmd broadcast MsgBurn +func NewBurnCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn [amount] [burn-from-address] [flags]", + Short: "Burn tokens from an address. Must have admin authority to do so.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + amount, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgBurn( + clientCtx.GetFromAddress().String(), + amount, + args[1], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewForceTransferCmd broadcast MsgForceTransfer +func NewForceTransferCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "force-transfer [amount] [transfer-from-address] [transfer-to-address] [flags]", + Short: "Force transfer tokens from one address to another address. Must have admin authority to do so.", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + amount, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgForceTransfer( + clientCtx.GetFromAddress().String(), + amount, + args[1], + args[2], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewForceTransferCmd broadcast MsgForceTransfer +func NewChangeAdminCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "change-admin [denom] [new-admin-address] [flags]", + Short: "Changes the admin address for a factory-created denom. Must have admin authority to do so.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + msg := types.NewMsgChangeAdmin( + clientCtx.GetFromAddress().String(), + args[0], + args[1], + ) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/tokenfactory/handler.go b/x/tokenfactory/handler.go deleted file mode 100644 index dff81e8cf4f..00000000000 --- a/x/tokenfactory/handler.go +++ /dev/null @@ -1,26 +0,0 @@ -package tokenfactory - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" -) - -// NewHandler ... -func NewHandler(k keeper.Keeper) sdk.Handler { - // this line is used by starport scaffolding # handler/msgServer - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - // this line is used by starport scaffolding # 1 - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index ec6dce30878..b423c029034 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -116,7 +116,7 @@ func (am AppModule) Name() string { // Route returns the capability module's message routing key. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // QuerierRoute returns the capability module's query routing key. diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index 375b0e397e8..06b2e558bea 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -49,8 +49,8 @@ func (m MsgCreateDenom) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgMint{} -// NewMsgMsgMint creates a message to mint tokens -func NewMsgMsgMint(sender string, amount sdk.Coin, mintTo string) *MsgMint { +// NewMsgMint creates a message to mint tokens +func NewMsgMint(sender string, amount sdk.Coin, mintTo string) *MsgMint { return &MsgMint{ Sender: sender, Amount: amount, @@ -87,8 +87,8 @@ func (m MsgMint) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgBurn{} -// NewMsgMsgBurn creates a message to burn tokens -func NewMsgMsgBurn(sender string, amount sdk.Coin, burnFrom string) *MsgBurn { +// NewMsgBurn creates a message to burn tokens +func NewMsgBurn(sender string, amount sdk.Coin, burnFrom string) *MsgBurn { return &MsgBurn{ Sender: sender, Amount: amount, @@ -169,9 +169,10 @@ func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { var _ sdk.Msg = &MsgChangeAdmin{} // NewMsgChangeAdmin creates a message to burn tokens -func NewMsgChangeAdmin(sender string, newAdmin string) *MsgChangeAdmin { +func NewMsgChangeAdmin(sender, denom, newAdmin string) *MsgChangeAdmin { return &MsgChangeAdmin{ Sender: sender, + Denom: denom, NewAdmin: newAdmin, } } @@ -189,6 +190,11 @@ func (m MsgChangeAdmin) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) } + _, _, err = DeconstructDenom(m.Denom) + if err != nil { + return err + } + return nil } func (m MsgChangeAdmin) GetSignBytes() []byte { From d7034c7c4de03b3dd53f65e453195f565d58f536 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Tue, 16 Nov 2021 12:13:39 -0500 Subject: [PATCH 04/22] in progress --- app/app.go | 9 ++ .../tokenfactory/v1beta1/genesis.proto | 4 + proto/osmosis/tokenfactory/v1beta1/tx.proto | 5 +- testutil/keeper/tokenfactory.go | 39 ----- x/tokenfactory/client/cli/query.go | 66 ++++++++- x/tokenfactory/genesis_test.go | 36 +++-- x/tokenfactory/keeper/createdenom.go | 10 +- x/tokenfactory/keeper/keeper.go | 6 +- x/tokenfactory/keeper/msg_server.go | 53 +++++-- x/tokenfactory/keeper/msg_server_test.go | 26 ++-- x/tokenfactory/types/events.go | 15 ++ x/tokenfactory/types/genesis.pb.go | 82 +++++++++-- x/tokenfactory/types/tx.pb.go | 133 ++++++++++++------ x/tokenfactory/types/types.go | 1 - 14 files changed, 345 insertions(+), 140 deletions(-) delete mode 100644 testutil/keeper/tokenfactory.go create mode 100644 x/tokenfactory/types/events.go delete mode 100644 x/tokenfactory/types/types.go diff --git a/app/app.go b/app/app.go index 85e2547a17b..01958bcca91 100644 --- a/app/app.go +++ b/app/app.go @@ -115,6 +115,9 @@ import ( poolincentivesclient "github.com/osmosis-labs/osmosis/x/pool-incentives/client" poolincentiveskeeper "github.com/osmosis-labs/osmosis/x/pool-incentives/keeper" poolincentivestypes "github.com/osmosis-labs/osmosis/x/pool-incentives/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + tokenfactorytypes "github.com/osmosis-labs/osmosis/x/tokenfactory/types" "github.com/osmosis-labs/osmosis/x/txfees" txfeeskeeper "github.com/osmosis-labs/osmosis/x/txfees/keeper" txfeestypes "github.com/osmosis-labs/osmosis/x/txfees/types" @@ -159,6 +162,7 @@ var ( poolincentives.AppModuleBasic{}, epochs.AppModuleBasic{}, claim.AppModuleBasic{}, + tokenfactory.AppModuleBasic{}, ) // module account permissions @@ -177,6 +181,7 @@ var ( lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, poolincentivestypes.ModuleName: nil, txfeestypes.ModuleName: nil, + tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } // module accounts that are allowed to receive tokens @@ -226,6 +231,7 @@ type OsmosisApp struct { EpochsKeeper epochskeeper.Keeper PoolIncentivesKeeper poolincentiveskeeper.Keeper TxFeesKeeper txfeeskeeper.Keeper + TokenFactoryKeeper tokenfactorykeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -272,6 +278,7 @@ func NewOsmosisApp( evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, gammtypes.StoreKey, lockuptypes.StoreKey, claimtypes.StoreKey, incentivestypes.StoreKey, epochstypes.StoreKey, poolincentivestypes.StoreKey, authzkeeper.StoreKey, txfeestypes.StoreKey, + tokenfactorytypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -479,6 +486,8 @@ func NewOsmosisApp( ) poolIncentivesHooks := app.PoolIncentivesKeeper.Hooks() + app.TokenFactoryKeeper = *tokenfactorykeeper.NewKeeper(appCodec, keys[tokenfactorytypes.StoreKey], app.BankKeeper) + // register the proposal types govRouter := govtypes.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). diff --git a/proto/osmosis/tokenfactory/v1beta1/genesis.proto b/proto/osmosis/tokenfactory/v1beta1/genesis.proto index 163010c5c8f..ae79f669b90 100644 --- a/proto/osmosis/tokenfactory/v1beta1/genesis.proto +++ b/proto/osmosis/tokenfactory/v1beta1/genesis.proto @@ -8,6 +8,8 @@ option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; // GenesisState defines the tokenfactory module's genesis state. message GenesisState { + option (gogoproto.equal) = true; + repeated GenesisDenom factory_denoms = 1 [ (gogoproto.moretags) = "yaml:\"factory_denoms\"", (gogoproto.nullable) = false @@ -15,6 +17,8 @@ message GenesisState { } message GenesisDenom { + option (gogoproto.equal) = true; + string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; DenomAuthorityMetadata authority_metadata = 2 [ (gogoproto.moretags) = "yaml:\"authority_metadata\"", diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index f1f55b651b7..aa1bc8aac1f 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -21,7 +21,10 @@ message MsgCreateDenom { string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ]; } -message MsgCreateDenomResponse {} +message MsgCreateDenomResponse { + string new_token_denom = 1 + [ (gogoproto.moretags) = "yaml:\"new_token_denom\"" ]; +} // ===================== MsgMint message MsgMint { diff --git a/testutil/keeper/tokenfactory.go b/testutil/keeper/tokenfactory.go deleted file mode 100644 index 274dc7dd410..00000000000 --- a/testutil/keeper/tokenfactory.go +++ /dev/null @@ -1,39 +0,0 @@ -package keeper - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmdb "github.com/tendermint/tm-db" -) - -func TokenfactoryKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { - storeKey := sdk.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - - db := tmdb.NewMemDB() - stateStore := store.NewCommitMultiStore(db) - stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) - stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - registry := codectypes.NewInterfaceRegistry() - k := keeper.NewKeeper( - codec.NewProtoCodec(registry), - storeKey, - memStoreKey, - nil, - ) - - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - return k, ctx -} diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go index 6e47241d865..2e8b79812e9 100644 --- a/x/tokenfactory/client/cli/query.go +++ b/x/tokenfactory/client/cli/query.go @@ -2,11 +2,14 @@ package cli import ( "fmt" + // "strings" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +27,68 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - // this line is used by starport scaffolding # 1 + cmd.AddCommand( + GetCmdDenomAuthorityMetadata(), + GetCmdDenomsFromCreator(), + ) + + return cmd +} + +// GetCmdDenomAuthorityMetadata returns the authority metadata for a queried denom +func GetCmdDenomAuthorityMetadata() *cobra.Command { + cmd := &cobra.Command{ + Use: "denom-authority-metadata [denom] [flags]", + Short: "Get the authority metadata for a specific denom", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.DenomAuthorityMetadata(cmd.Context(), &types.QueryDenomAuthorityMetadataRequest{ + Denom: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdDenomAuthorityMetadata returns the authority metadata for a queried denom +func GetCmdDenomsFromCreator() *cobra.Command { + cmd := &cobra.Command{ + Use: "denoms-from-creator [creator address] [flags]", + Short: "Returns a list of all tokens created by a specific creator address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.DenomsFromCreator(cmd.Context(), &types.QueryDenomsFromCreatorRequest{ + Creator: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) return cmd } diff --git a/x/tokenfactory/genesis_test.go b/x/tokenfactory/genesis_test.go index 77a131358b6..b000ca90f53 100644 --- a/x/tokenfactory/genesis_test.go +++ b/x/tokenfactory/genesis_test.go @@ -3,21 +3,37 @@ package tokenfactory_test import ( "testing" - keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory" + simapp "github.com/osmosis-labs/osmosis/app" + appparams "github.com/osmosis-labs/osmosis/app/params" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { + appparams.SetAddressPrefixes() + genesisState := types.GenesisState{ - // this line is used by starport scaffolding # genesis/test/state + FactoryDenoms: []types.GenesisDenom{ + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/bitcoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44", + }, + }, + { + Denom: "factory/osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44/litecoin", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44", + }, + }, + }, } + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - k, ctx := keepertest.TokenfactoryKeeper(t) - tokenfactory.InitGenesis(ctx, *k, genesisState) - got := tokenfactory.ExportGenesis(ctx, *k) - require.NotNil(t, got) - - // this line is used by starport scaffolding # genesis/test/assert + // tokenfactory.InitGenesis(ctx, *k, genesisState) + // got := tokenfactory.ExportGenesis(ctx, *k) + // require.NotNil(t, got) + // require.Equal(t, genesisState, got) } diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 8cfd8d86e44..c03b46b36fb 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -7,15 +7,15 @@ import ( ) // ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount -func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce string) error { +func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce string) (newTokenDenom string, err error) { denom, err := types.GetTokenDenom(creatorAddr, denomnonce) if err != nil { - return err + return "", err } _, found := k.bankKeeper.GetDenomMetaData(ctx, denom) if found { - return types.ErrDenomExists + return "", types.ErrDenomExists } baseDenomUnit := banktypes.DenomUnit{ @@ -35,9 +35,9 @@ func (k Keeper) CreateDenom(ctx sdk.Context, creatorAddr string, denomnonce stri } err = k.SetAuthorityMetadata(ctx, denom, authorityMetadata) if err != nil { - return err + return "", err } k.addDenomFromCreator(ctx, creatorAddr, denom) - return nil + return denom, nil } diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index e10dd8cb0ca..660940f9f0c 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -15,7 +15,6 @@ type ( Keeper struct { cdc codec.Marshaler storeKey sdk.StoreKey - memKey sdk.StoreKey bankKeeper types.BankKeeper } @@ -23,15 +22,12 @@ type ( func NewKeeper( cdc codec.Marshaler, - storeKey, - memKey sdk.StoreKey, - + storeKey sdk.StoreKey, bankKeeper types.BankKeeper, ) *Keeper { return &Keeper{ cdc: cdc, storeKey: storeKey, - memKey: memKey, bankKeeper: bankKeeper, } diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index cae1f3ac39b..0eee7d06b5a 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -23,16 +23,23 @@ var _ types.MsgServer = msgServer{} func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateDenom) (*types.MsgCreateDenomResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - err := server.Keeper.CreateDenom(ctx, msg.Sender, msg.Nonce) + denom, err := server.Keeper.CreateDenom(ctx, msg.Sender, msg.Nonce) if err != nil { return nil, err } - // TODO: events - // ctx.EventManager().EmitEvents(sdk.Events{}) - - return &types.MsgCreateDenomResponse{}, nil + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgCreateDenom, + sdk.NewAttribute(types.AttributeCreator, msg.Sender), + sdk.NewAttribute(types.AttributeNewTokenDenom, denom), + ), + }) + + return &types.MsgCreateDenomResponse{ + NewTokenDenom: denom, + }, nil } func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { @@ -49,8 +56,13 @@ func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types. server.Keeper.mintTo(ctx, msg.Amount, msg.MintToAddress) - // TODO: events - // ctx.EventManager().EmitEvents(sdk.Events{}) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgMint, + sdk.NewAttribute(types.AttributeMintToAddress, msg.MintToAddress), + sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), + ), + }) return &types.MsgMintResponse{}, nil } @@ -69,8 +81,13 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types. server.Keeper.burnFrom(ctx, msg.Amount, msg.GetBurnFromAddress()) - // TODO: events - // ctx.EventManager().EmitEvents(sdk.Events{}) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgBurn, + sdk.NewAttribute(types.AttributeBurnFromAddress, msg.BurnFromAddress), + sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), + ), + }) return &types.MsgBurnResponse{}, nil } @@ -89,8 +106,14 @@ func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForce server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) - // TODO: events - // ctx.EventManager().EmitEvents(sdk.Events{}) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgForceTransfer, + sdk.NewAttribute(types.AttributeTransferFromAddress, msg.TransferFromAddress), + sdk.NewAttribute(types.AttributeTransferToAddress, msg.TransferToAddress), + sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), + ), + }) return &types.MsgForceTransferResponse{}, nil } @@ -113,7 +136,13 @@ func (server msgServer) ChangeAdmin(goCtx context.Context, msg *types.MsgChangeA } // TODO: events - // ctx.EventManager().EmitEvents(sdk.Events{}) + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgChangeAdmin, + sdk.NewAttribute(types.AttributeDenom, msg.GetDenom()), + sdk.NewAttribute(types.AttributeNewAdmin, msg.NewAdmin), + ), + }) return &types.MsgChangeAdminResponse{}, nil } diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 8e3afb623bd..846c3dce799 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -1,16 +1,16 @@ -package keeper_test +// package keeper_test -import ( - "context" - "testing" +// import ( +// "context" +// "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" -) +// sdk "github.com/cosmos/cosmos-sdk/types" +// keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" +// "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" +// "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +// ) -func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.TokenfactoryKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) -} +// func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { +// k, ctx := keepertest.TokenfactoryKeeper(t) +// return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +// } diff --git a/x/tokenfactory/types/events.go b/x/tokenfactory/types/events.go new file mode 100644 index 00000000000..24742983950 --- /dev/null +++ b/x/tokenfactory/types/events.go @@ -0,0 +1,15 @@ +package types + +// event types +const ( + AttributeAmount = "amount" + AttributeCreator = "creator" + AttributeNonce = "nonce" + AttributeNewTokenDenom = "new_token_denom" + AttributeMintToAddress = "mint_to_address" + AttributeBurnFromAddress = "burn_from_address" + AttributeTransferFromAddress = "transfer_from_address" + AttributeTransferToAddress = "transfer_to_address" + AttributeDenom = "denom" + AttributeNewAdmin = "new_admin" +) diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go index 30c1eb64866..06df2cfe9c5 100644 --- a/x/tokenfactory/types/genesis.pb.go +++ b/x/tokenfactory/types/genesis.pb.go @@ -130,30 +130,86 @@ func init() { } var fileDescriptor_5749c3f71850298b = []byte{ - // 323 bytes of a gzipped FileDescriptorProto + // 333 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xca, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0xaa, 0xd5, 0x43, 0x56, 0xab, 0x07, 0x55, 0x2b, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, 0x99, 0xe0, 0x35, 0x3f, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0xd2, 0x37, 0xb5, 0x24, 0x31, 0x25, - 0xb1, 0x24, 0x11, 0xa2, 0x4b, 0xa9, 0x81, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x77, 0x70, 0x49, 0x62, + 0xb1, 0x24, 0x11, 0xa2, 0x4b, 0xa9, 0x8d, 0x91, 0x8b, 0xc7, 0x1d, 0x62, 0x77, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x50, 0x01, 0x17, 0x1f, 0x54, 0x6f, 0x7c, 0x4a, 0x6a, 0x5e, 0x7e, 0x6e, 0xb1, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x96, 0x1e, 0x3e, 0x37, 0xe9, 0x41, 0xcd, 0x70, 0x01, 0x69, 0x71, 0x92, 0x3d, 0x71, 0x4f, 0x9e, 0xe1, 0xd3, 0x3d, 0x79, 0xd1, 0xca, 0xc4, 0xdc, 0x1c, 0x2b, - 0x25, 0x54, 0xf3, 0x94, 0x82, 0x78, 0xa1, 0x02, 0x2e, 0x10, 0xfe, 0x7e, 0x84, 0x13, 0xc0, 0x22, - 0x42, 0x6a, 0x5c, 0xac, 0x60, 0xa5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x02, 0x9f, 0xee, - 0xc9, 0xf3, 0x40, 0x4c, 0x02, 0x0b, 0x2b, 0x05, 0x41, 0xa4, 0x85, 0xda, 0x18, 0xb9, 0x84, 0xe0, - 0xfe, 0x8a, 0xcf, 0x85, 0x7a, 0x4c, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0xc8, 0x04, 0xbf, 0x7b, - 0xc1, 0x36, 0x39, 0xa2, 0x07, 0x8a, 0x93, 0x22, 0xd4, 0xe5, 0x92, 0x10, 0xfb, 0x30, 0x4d, 0x57, - 0x0a, 0x12, 0xc4, 0x08, 0x4a, 0x27, 0xbf, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, - 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, - 0x88, 0x32, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0xba, 0x47, - 0x37, 0x27, 0x31, 0xa9, 0x18, 0xc6, 0xd1, 0xaf, 0x40, 0x8d, 0xae, 0x92, 0xca, 0x82, 0xd4, 0xe2, - 0x24, 0x36, 0x70, 0xdc, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x94, 0x17, 0x89, 0x33, - 0x02, 0x00, 0x00, + 0x25, 0x54, 0xf3, 0x94, 0x82, 0x78, 0xa1, 0x02, 0x60, 0xc5, 0xc5, 0x56, 0x2c, 0x2f, 0x16, 0xc8, + 0x33, 0x2a, 0x1d, 0x45, 0x38, 0x04, 0x2c, 0x2e, 0xa4, 0xc6, 0xc5, 0x0a, 0xd6, 0x20, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0xf0, 0xe9, 0x9e, 0x3c, 0x0f, 0xc4, 0x3c, 0xb0, 0xb0, 0x52, 0x10, + 0x44, 0x5a, 0xa8, 0x8d, 0x91, 0x4b, 0x08, 0xee, 0xbb, 0xf8, 0x5c, 0xa8, 0xf7, 0x24, 0x98, 0x14, + 0x18, 0x35, 0xb8, 0x8d, 0x4c, 0xf0, 0xbb, 0x1a, 0x6c, 0x93, 0x23, 0x7a, 0xd0, 0x38, 0x29, 0x42, + 0xdd, 0x2f, 0x09, 0xb1, 0x0f, 0xd3, 0x74, 0xa5, 0x20, 0x41, 0x8c, 0x00, 0x85, 0xf8, 0xc3, 0xc9, + 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0xae, 0xd2, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, + 0xf4, 0x2b, 0x50, 0xa3, 0xae, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x4f, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x96, 0xd9, 0xb1, 0x3f, 0x02, 0x00, 0x00, } +func (this *GenesisState) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GenesisState) + if !ok { + that2, ok := that.(GenesisState) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.FactoryDenoms) != len(that1.FactoryDenoms) { + return false + } + for i := range this.FactoryDenoms { + if !this.FactoryDenoms[i].Equal(&that1.FactoryDenoms[i]) { + return false + } + } + return true +} +func (this *GenesisDenom) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GenesisDenom) + if !ok { + that2, ok := that.(GenesisDenom) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Denom != that1.Denom { + return false + } + if !this.AuthorityMetadata.Equal(&that1.AuthorityMetadata) { + return false + } + return true +} func (m *GenesisState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index 043bf7dc6d5..d5b28f7b21b 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -83,6 +83,7 @@ func (m *MsgCreateDenom) GetNonce() string { } type MsgCreateDenomResponse struct { + NewTokenDenom string `protobuf:"bytes,1,opt,name=new_token_denom,json=newTokenDenom,proto3" json:"new_token_denom,omitempty" yaml:"new_token_denom"` } func (m *MsgCreateDenomResponse) Reset() { *m = MsgCreateDenomResponse{} } @@ -118,6 +119,13 @@ func (m *MsgCreateDenomResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateDenomResponse proto.InternalMessageInfo +func (m *MsgCreateDenomResponse) GetNewTokenDenom() string { + if m != nil { + return m.NewTokenDenom + } + return "" +} + // ===================== MsgMint type MsgMint struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` @@ -532,46 +540,48 @@ func init() { } var fileDescriptor_283b6c9a90a846b4 = []byte{ - // 622 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xc1, 0x6e, 0xd3, 0x30, - 0x1c, 0xc6, 0x9b, 0x6d, 0x0c, 0xf0, 0x18, 0xdb, 0xc2, 0x98, 0x42, 0x34, 0x25, 0x93, 0xa5, 0x21, - 0x90, 0x58, 0xc2, 0xc6, 0xc4, 0x81, 0x13, 0xeb, 0x50, 0xc5, 0x81, 0x72, 0x88, 0x76, 0x42, 0x48, - 0x55, 0x92, 0xba, 0x59, 0xc4, 0x62, 0x17, 0xdb, 0xa5, 0xeb, 0x5b, 0x70, 0xe1, 0xce, 0x95, 0xb7, - 0xe0, 0x84, 0x76, 0xdc, 0x91, 0x53, 0x84, 0xda, 0x37, 0xc8, 0x13, 0xa0, 0xd8, 0x49, 0x9a, 0xb4, - 0x88, 0xb6, 0xa7, 0xdd, 0x5a, 0xfb, 0xf7, 0xfd, 0xff, 0xfe, 0x6c, 0x7f, 0x0e, 0xd8, 0x27, 0x2c, - 0x22, 0x2c, 0x64, 0x36, 0x27, 0x9f, 0x10, 0xee, 0xb8, 0x3e, 0x27, 0x74, 0x60, 0x7f, 0x39, 0xf4, - 0x10, 0x77, 0x0f, 0x6d, 0x7e, 0x69, 0x75, 0x29, 0xe1, 0x44, 0xdd, 0xcd, 0x30, 0xab, 0x8c, 0x59, - 0x19, 0xa6, 0x6f, 0x07, 0x24, 0x20, 0x02, 0xb4, 0xd3, 0x5f, 0x52, 0xa3, 0x1b, 0xbe, 0x10, 0xd9, - 0x9e, 0xcb, 0x50, 0x51, 0xd1, 0x27, 0x21, 0x96, 0xf3, 0xd0, 0x07, 0xf7, 0x9b, 0x2c, 0x38, 0xa5, - 0xc8, 0xe5, 0xe8, 0x0d, 0xc2, 0x24, 0x52, 0x9f, 0x82, 0x55, 0x86, 0x70, 0x1b, 0x51, 0x4d, 0xd9, - 0x53, 0x9e, 0xdc, 0xad, 0x6f, 0x25, 0xb1, 0xb9, 0x3e, 0x70, 0xa3, 0x8b, 0x57, 0x50, 0x8e, 0x43, - 0x27, 0x03, 0xd4, 0xc7, 0xe0, 0x16, 0x26, 0xd8, 0x47, 0xda, 0x92, 0x20, 0x37, 0x93, 0xd8, 0xbc, - 0x27, 0x49, 0x31, 0x0c, 0x1d, 0x39, 0x0d, 0x35, 0xb0, 0x53, 0x6d, 0xe2, 0x20, 0xd6, 0x25, 0x98, - 0x21, 0xf8, 0x53, 0x01, 0xb7, 0x9b, 0x2c, 0x68, 0x86, 0x98, 0x2f, 0xd2, 0xf8, 0x2d, 0x58, 0x75, - 0x23, 0xd2, 0xc3, 0x5c, 0x74, 0x5e, 0x3b, 0x7a, 0x64, 0x49, 0x9b, 0x56, 0x6a, 0x33, 0xdf, 0x11, - 0xeb, 0x94, 0x84, 0xb8, 0xfe, 0xf0, 0x2a, 0x36, 0x6b, 0xe3, 0x4a, 0x52, 0x06, 0x9d, 0x4c, 0xaf, - 0xbe, 0x06, 0xeb, 0x51, 0x88, 0xf9, 0x19, 0x39, 0x69, 0xb7, 0x29, 0x62, 0x4c, 0x5b, 0x16, 0xbd, - 0xf5, 0x24, 0x36, 0x77, 0xa4, 0x22, 0x9d, 0x6e, 0x71, 0xd2, 0x72, 0x25, 0x00, 0x9d, 0xaa, 0x00, - 0x6e, 0x81, 0x8d, 0xcc, 0x41, 0xe1, 0xea, 0x97, 0x74, 0x55, 0xef, 0x51, 0x7c, 0x33, 0xae, 0x1a, - 0x60, 0xc3, 0xeb, 0x51, 0xdc, 0xa0, 0x24, 0xaa, 0xfa, 0xda, 0x4d, 0x62, 0x53, 0x93, 0x9a, 0x14, - 0x68, 0x75, 0x28, 0x89, 0xc6, 0xce, 0x26, 0x45, 0x99, 0xb7, 0xd4, 0x47, 0xe1, 0xed, 0xc7, 0x12, - 0xd8, 0x6c, 0xb2, 0xa0, 0x41, 0xa8, 0x8f, 0xce, 0xa8, 0x8b, 0x59, 0x07, 0xd1, 0x9b, 0x31, 0xe9, - 0x80, 0x07, 0x3c, 0x5b, 0xc0, 0xb4, 0xd1, 0xbd, 0x24, 0x36, 0x77, 0xa5, 0x2e, 0x87, 0x26, 0xcc, - 0xfe, 0x4b, 0xac, 0xbe, 0x03, 0x5b, 0xf9, 0xf0, 0xf8, 0x4a, 0xac, 0x88, 0x8a, 0x46, 0x12, 0x9b, - 0xfa, 0x44, 0xc5, 0xf2, 0xb5, 0x98, 0x16, 0x42, 0x1d, 0x68, 0x93, 0x5b, 0x55, 0xec, 0xe3, 0x37, - 0x45, 0x26, 0xef, 0xdc, 0xc5, 0x01, 0x3a, 0x69, 0x47, 0x21, 0x5e, 0x30, 0x79, 0xed, 0x34, 0x48, - 0xd3, 0xc9, 0x13, 0xc3, 0xd0, 0x91, 0xd3, 0xea, 0x73, 0x70, 0x07, 0xa3, 0xbe, 0x28, 0x9f, 0x6d, - 0xcc, 0x76, 0x12, 0x9b, 0x9b, 0x59, 0x48, 0x51, 0xbf, 0xe5, 0xa6, 0x53, 0xd0, 0x29, 0xa8, 0x3c, - 0xab, 0xe3, 0x65, 0xe5, 0x2b, 0x3e, 0xfa, 0xbe, 0x02, 0x96, 0x9b, 0x2c, 0x50, 0x3f, 0x83, 0xb5, - 0xf2, 0x7b, 0xf1, 0xcc, 0xfa, 0xdf, 0xb3, 0x64, 0x55, 0x83, 0xaf, 0x1f, 0x2f, 0x42, 0xe7, 0xad, - 0xd5, 0x8f, 0x60, 0x45, 0x3c, 0x11, 0xfb, 0x33, 0xd5, 0x29, 0xa6, 0x1f, 0xcc, 0x85, 0x95, 0xab, - 0x8b, 0xa8, 0xce, 0xae, 0x9e, 0x62, 0x73, 0x54, 0x2f, 0x07, 0x46, 0xed, 0x83, 0xf5, 0x6a, 0x58, - 0xac, 0x99, 0xfa, 0x0a, 0xaf, 0xbf, 0x5c, 0x8c, 0x2f, 0x1a, 0xa7, 0xe7, 0x54, 0xba, 0x5d, 0x73, - 0x9c, 0xd3, 0x98, 0x9e, 0xe7, 0x9c, 0xa6, 0xaf, 0x48, 0xfd, 0xfd, 0xd5, 0xd0, 0x50, 0xae, 0x87, - 0x86, 0xf2, 0x67, 0x68, 0x28, 0x5f, 0x47, 0x46, 0xed, 0x7a, 0x64, 0xd4, 0x7e, 0x8f, 0x8c, 0xda, - 0x87, 0xe3, 0x20, 0xe4, 0xe7, 0x3d, 0xcf, 0xf2, 0x49, 0x64, 0x67, 0x95, 0x0f, 0x2e, 0x5c, 0x8f, - 0xe5, 0x7f, 0xec, 0xcb, 0xea, 0xc7, 0x8f, 0x0f, 0xba, 0x88, 0x79, 0xab, 0xe2, 0x23, 0xf5, 0xe2, - 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0x24, 0x24, 0x31, 0x21, 0x07, 0x00, 0x00, + // 646 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4f, 0x4f, 0xd4, 0x4e, + 0x18, 0xde, 0x02, 0x3f, 0x7e, 0x3a, 0xb8, 0x02, 0x15, 0x49, 0x6d, 0x48, 0x4b, 0x26, 0xc1, 0x68, + 0x22, 0xad, 0x20, 0xf1, 0xe0, 0x49, 0x16, 0x43, 0x3c, 0xb8, 0x1e, 0x1a, 0x4e, 0x86, 0x64, 0xd3, + 0x76, 0x87, 0xd2, 0x48, 0x67, 0x70, 0x66, 0xd6, 0x85, 0x6f, 0xe1, 0xc5, 0xbb, 0x57, 0xbf, 0x85, + 0x27, 0xc3, 0x91, 0xa3, 0xa7, 0xc6, 0xc0, 0x37, 0xe8, 0x27, 0x30, 0x9d, 0x99, 0xfe, 0xdb, 0x35, + 0xb2, 0x7b, 0xe2, 0xb6, 0x3b, 0xef, 0xf3, 0x3c, 0x33, 0xcf, 0x3b, 0xf3, 0xbc, 0x05, 0x1b, 0x84, + 0x25, 0x84, 0xc5, 0xcc, 0xe5, 0xe4, 0x23, 0xc2, 0x47, 0x7e, 0xc8, 0x09, 0x3d, 0x77, 0x3f, 0x6f, + 0x05, 0x88, 0xfb, 0x5b, 0x2e, 0x3f, 0x73, 0x4e, 0x29, 0xe1, 0x44, 0x5f, 0x53, 0x30, 0xa7, 0x0e, + 0x73, 0x14, 0xcc, 0x5c, 0x89, 0x48, 0x44, 0x04, 0xd0, 0xcd, 0x7f, 0x49, 0x8e, 0x69, 0x85, 0x82, + 0xe4, 0x06, 0x3e, 0x43, 0xa5, 0x62, 0x48, 0x62, 0x2c, 0xeb, 0x30, 0x04, 0xf7, 0xbb, 0x2c, 0xda, + 0xa3, 0xc8, 0xe7, 0xe8, 0x0d, 0xc2, 0x24, 0xd1, 0x9f, 0x82, 0x79, 0x86, 0x70, 0x1f, 0x51, 0x43, + 0x5b, 0xd7, 0x9e, 0xdc, 0xed, 0x2c, 0x67, 0xa9, 0xdd, 0x3e, 0xf7, 0x93, 0x93, 0x57, 0x50, 0xae, + 0x43, 0x4f, 0x01, 0xf4, 0xc7, 0xe0, 0x3f, 0x4c, 0x70, 0x88, 0x8c, 0x19, 0x81, 0x5c, 0xca, 0x52, + 0xfb, 0x9e, 0x44, 0x8a, 0x65, 0xe8, 0xc9, 0x32, 0x3c, 0x04, 0xab, 0xcd, 0x4d, 0x3c, 0xc4, 0x4e, + 0x09, 0x66, 0x48, 0xef, 0x80, 0x45, 0x8c, 0x86, 0x3d, 0x61, 0xa8, 0xd7, 0xcf, 0x4b, 0x6a, 0x57, + 0x33, 0x4b, 0xed, 0x55, 0xa5, 0xd5, 0x04, 0x40, 0xaf, 0x8d, 0xd1, 0xf0, 0x20, 0x5f, 0x10, 0x5a, + 0xf0, 0x87, 0x06, 0xfe, 0xef, 0xb2, 0xa8, 0x1b, 0x63, 0x3e, 0xcd, 0xe1, 0xdf, 0x82, 0x79, 0x3f, + 0x21, 0x03, 0xcc, 0xc5, 0xe9, 0x17, 0xb6, 0x1f, 0x39, 0xb2, 0x55, 0x4e, 0xde, 0xaa, 0xa2, 0xab, + 0xce, 0x1e, 0x89, 0x71, 0xe7, 0xe1, 0x45, 0x6a, 0xb7, 0x2a, 0x25, 0x49, 0x83, 0x9e, 0xe2, 0xeb, + 0xaf, 0x41, 0x3b, 0x89, 0x31, 0x3f, 0x20, 0xbb, 0xfd, 0x3e, 0x45, 0x8c, 0x19, 0xb3, 0xa3, 0x16, + 0xf2, 0x72, 0x8f, 0x93, 0x9e, 0x2f, 0x01, 0xd0, 0x6b, 0x12, 0xe0, 0x32, 0x58, 0x54, 0x0e, 0x8a, + 0xce, 0xc0, 0x9f, 0xd2, 0x55, 0x67, 0x40, 0xf1, 0xed, 0xb8, 0xda, 0x07, 0x8b, 0xc1, 0x80, 0xe2, + 0x7d, 0x4a, 0x92, 0xa6, 0xaf, 0xb5, 0x2c, 0xb5, 0x0d, 0xc9, 0xc9, 0x01, 0xbd, 0x23, 0x4a, 0x92, + 0xca, 0xd9, 0x28, 0x49, 0x79, 0xcb, 0x7d, 0x94, 0xde, 0xbe, 0xcf, 0x80, 0xa5, 0x2e, 0x8b, 0xf6, + 0x09, 0x0d, 0xd1, 0x01, 0xf5, 0x31, 0x3b, 0x42, 0xf4, 0x76, 0x4c, 0x7a, 0xe0, 0x01, 0x57, 0x07, + 0x18, 0x37, 0xba, 0x9e, 0xa5, 0xf6, 0x9a, 0xe4, 0x15, 0xa0, 0x11, 0xb3, 0x7f, 0x23, 0xeb, 0xef, + 0xc0, 0x72, 0xb1, 0x5c, 0x3d, 0x89, 0x39, 0xa1, 0x68, 0x65, 0xa9, 0x6d, 0x8e, 0x28, 0xd6, 0x9f, + 0xc5, 0x38, 0x11, 0x9a, 0xc0, 0x18, 0x6d, 0x55, 0xd9, 0xc7, 0xaf, 0x9a, 0x4c, 0xef, 0xb1, 0x8f, + 0x23, 0xb4, 0xdb, 0x4f, 0x62, 0x3c, 0x65, 0x7a, 0x65, 0xe2, 0xc6, 0xd2, 0xab, 0x72, 0x26, 0xcb, + 0xfa, 0x73, 0x70, 0x07, 0xa3, 0xa1, 0x90, 0x57, 0x8d, 0x59, 0xc9, 0x52, 0x7b, 0xa9, 0x0a, 0xa7, + 0x9f, 0x97, 0xa0, 0x57, 0xa2, 0xa0, 0x21, 0xf3, 0x5e, 0x1d, 0xab, 0x38, 0xf1, 0xf6, 0xb7, 0x39, + 0x30, 0xdb, 0x65, 0x91, 0xfe, 0x09, 0x2c, 0xd4, 0x67, 0xce, 0x33, 0xe7, 0x5f, 0xa3, 0xcd, 0x69, + 0x0e, 0x0f, 0x73, 0x67, 0x1a, 0x74, 0x39, 0x6a, 0x0e, 0xc1, 0x9c, 0x18, 0x11, 0x1b, 0x37, 0xb2, + 0x73, 0x98, 0xb9, 0x39, 0x11, 0xac, 0xae, 0x2e, 0xa2, 0x7a, 0xb3, 0x7a, 0x0e, 0x9b, 0x40, 0xbd, + 0x1e, 0x18, 0x7d, 0x08, 0xda, 0xcd, 0xb0, 0x38, 0x37, 0xf2, 0x1b, 0x78, 0xf3, 0xe5, 0x74, 0xf8, + 0x72, 0xe3, 0xfc, 0x9e, 0x6a, 0xaf, 0x6b, 0x82, 0x7b, 0xaa, 0xd0, 0x93, 0xdc, 0xd3, 0xf8, 0x13, + 0xe9, 0xbc, 0xbf, 0xb8, 0xb2, 0xb4, 0xcb, 0x2b, 0x4b, 0xfb, 0x7d, 0x65, 0x69, 0x5f, 0xae, 0xad, + 0xd6, 0xe5, 0xb5, 0xd5, 0xfa, 0x75, 0x6d, 0xb5, 0x3e, 0xec, 0x44, 0x31, 0x3f, 0x1e, 0x04, 0x4e, + 0x48, 0x12, 0x57, 0x29, 0x6f, 0x9e, 0xf8, 0x01, 0x2b, 0xfe, 0xb8, 0x67, 0xcd, 0x0f, 0x28, 0x3f, + 0x3f, 0x45, 0x2c, 0x98, 0x17, 0x1f, 0xba, 0x17, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x21, 0x60, + 0x04, 0xa5, 0x65, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -855,6 +865,13 @@ func (m *MsgCreateDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if len(m.NewTokenDenom) > 0 { + i -= len(m.NewTokenDenom) + copy(dAtA[i:], m.NewTokenDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewTokenDenom))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -1176,6 +1193,10 @@ func (m *MsgCreateDenomResponse) Size() (n int) { } var l int _ = l + l = len(m.NewTokenDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1446,6 +1467,38 @@ func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgCreateDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewTokenDenom", 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.NewTokenDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/tokenfactory/types/types.go b/x/tokenfactory/types/types.go deleted file mode 100644 index ab1254f4c2b..00000000000 --- a/x/tokenfactory/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types From e2f0ced35a7db8d22cad79929fbae853c5bc0c55 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 02:30:58 -0500 Subject: [PATCH 05/22] fix sdk v0.44 basics --- x/tokenfactory/genesis_test.go | 10 ++++++---- x/tokenfactory/keeper/keeper.go | 4 ++-- x/tokenfactory/keeper/msg_server_test.go | 2 +- x/tokenfactory/module.go | 14 +++++++------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/x/tokenfactory/genesis_test.go b/x/tokenfactory/genesis_test.go index b000ca90f53..f6e624236ce 100644 --- a/x/tokenfactory/genesis_test.go +++ b/x/tokenfactory/genesis_test.go @@ -5,8 +5,10 @@ import ( simapp "github.com/osmosis-labs/osmosis/app" appparams "github.com/osmosis-labs/osmosis/app/params" + "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" ) @@ -32,8 +34,8 @@ func TestGenesis(t *testing.T) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - // tokenfactory.InitGenesis(ctx, *k, genesisState) - // got := tokenfactory.ExportGenesis(ctx, *k) - // require.NotNil(t, got) - // require.Equal(t, genesisState, got) + tokenfactory.InitGenesis(ctx, app.TokenFactoryKeeper, genesisState) + exportedGenesis := tokenfactory.ExportGenesis(ctx, app.TokenFactoryKeeper) + require.NotNil(t, exportedGenesis) + require.Equal(t, genesisState, *exportedGenesis) } diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 660940f9f0c..0bb224b1414 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -13,7 +13,7 @@ import ( type ( Keeper struct { - cdc codec.Marshaler + cdc codec.Codec storeKey sdk.StoreKey bankKeeper types.BankKeeper @@ -21,7 +21,7 @@ type ( ) func NewKeeper( - cdc codec.Marshaler, + cdc codec.Codec, storeKey sdk.StoreKey, bankKeeper types.BankKeeper, ) *Keeper { diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 846c3dce799..51aa5d9e63e 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -1,4 +1,4 @@ -// package keeper_test +package keeper_test // import ( // "context" diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index b423c029034..210cc28376d 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -33,10 +33,10 @@ var ( // AppModuleBasic implements the AppModuleBasic interface for the capability module. type AppModuleBasic struct { - cdc codec.Marshaler + cdc codec.Codec } -func NewAppModuleBasic(cdc codec.Marshaler) AppModuleBasic { +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { return AppModuleBasic{cdc: cdc} } @@ -59,12 +59,12 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { } // DefaultGenesis returns the capability module's default genesis state. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) } // ValidateGenesis performs genesis state validation for the capability module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config client.TxEncodingConfig, bz json.RawMessage) error { +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) @@ -102,7 +102,7 @@ type AppModule struct { keeper keeper.Keeper } -func NewAppModule(cdc codec.Marshaler, keeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, @@ -138,7 +138,7 @@ func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // InitGenesis performs the capability module's genesis initialization It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, gs json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { var genState types.GenesisState // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) @@ -149,7 +149,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, gs jso } // ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { genState := ExportGenesis(ctx, am.keeper) return cdc.MustMarshalJSON(genState) } From 1b73096d16fa6c00025fb1228e070d713eb1c764 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 04:04:16 -0500 Subject: [PATCH 06/22] add more tests --- app/app.go | 2 +- x/tokenfactory/genesis.go | 2 + x/tokenfactory/keeper/admins_test.go | 66 +++++++++++++++++++++++ x/tokenfactory/keeper/bankactions.go | 28 ++++++++-- x/tokenfactory/keeper/createdenom_test.go | 49 +++++++++++++++++ x/tokenfactory/keeper/keeper.go | 15 +++++- x/tokenfactory/keeper/keeper_test.go | 47 ++++++++++++++++ x/tokenfactory/keeper/msg_server.go | 15 ++++-- x/tokenfactory/keeper/msg_server_test.go | 16 ------ x/tokenfactory/types/expected_keepers.go | 8 +++ 10 files changed, 222 insertions(+), 26 deletions(-) create mode 100644 x/tokenfactory/keeper/admins_test.go create mode 100644 x/tokenfactory/keeper/createdenom_test.go create mode 100644 x/tokenfactory/keeper/keeper_test.go delete mode 100644 x/tokenfactory/keeper/msg_server_test.go diff --git a/app/app.go b/app/app.go index 01958bcca91..93873f70b29 100644 --- a/app/app.go +++ b/app/app.go @@ -486,7 +486,7 @@ func NewOsmosisApp( ) poolIncentivesHooks := app.PoolIncentivesKeeper.Hooks() - app.TokenFactoryKeeper = *tokenfactorykeeper.NewKeeper(appCodec, keys[tokenfactorytypes.StoreKey], app.BankKeeper) + app.TokenFactoryKeeper = *tokenfactorykeeper.NewKeeper(appCodec, keys[tokenfactorytypes.StoreKey], app.AccountKeeper, app.BankKeeper) // register the proposal types govRouter := govtypes.NewRouter() diff --git a/x/tokenfactory/genesis.go b/x/tokenfactory/genesis.go index 8c11736dadd..83f7eeb562a 100644 --- a/x/tokenfactory/genesis.go +++ b/x/tokenfactory/genesis.go @@ -9,6 +9,8 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + k.CreateModuleAccount(ctx) + for _, genDenom := range genState.GetFactoryDenoms() { creator, nonce, err := types.DeconstructDenom(genDenom.GetDenom()) if err != nil { diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go new file mode 100644 index 00000000000..ed026521869 --- /dev/null +++ b/x/tokenfactory/keeper/admins_test.go @@ -0,0 +1,66 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (suite *KeeperTestSuite) TestAdminMsgs() { + suite.SetupTest() + + addr1 := sdk.AccAddress([]byte("addr1---------------")) + addr2 := sdk.AccAddress([]byte("addr2---------------")) + + msgServer := keeper.NewMsgServerImpl(suite.app.TokenFactoryKeeper) + + // Create a denom + res, err := msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "bitcoin")) + suite.Require().NoError(err) + denom := res.GetNewTokenDenom() + + // Make sure that the admin is set correctly + queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ + Denom: res.GetNewTokenDenom(), + }) + suite.Require().NoError(err) + suite.Require().Equal(addr1.String(), queryRes.AuthorityMetadata.Admin) + + // Test minting to admins own account + _, err = msgServer.Mint(sdk.WrapSDKContext(suite.ctx), types.NewMsgMint(addr1.String(), sdk.NewInt64Coin(denom, 10), addr1.String())) + suite.Require().NoError(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 10)), suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom)) + + // Test minting to a separate account + _, err = msgServer.Mint(sdk.WrapSDKContext(suite.ctx), types.NewMsgMint(addr1.String(), sdk.NewInt64Coin(denom, 10), addr2.String())) + suite.Require().NoError(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 10))) + + // Test force transferring + _, err = msgServer.ForceTransfer(sdk.WrapSDKContext(suite.ctx), types.NewMsgForceTransfer(addr1.String(), sdk.NewInt64Coin(denom, 5), addr2.String(), addr1.String())) + suite.Require().NoError(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 15))) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 5))) + + // Test burning + _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 5), addr2.String())) + suite.Require().NoError(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 0))) + + // Test Change Admin + _, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.ctx), types.NewMsgChangeAdmin(addr1.String(), denom, addr2.String())) + queryRes, err = suite.queryClient.DenomAuthorityMetadata(suite.ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ + Denom: res.GetNewTokenDenom(), + }) + suite.Require().NoError(err) + suite.Require().Equal(addr2.String(), queryRes.AuthorityMetadata.Admin) + + // Make sure can no longer do actions + _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 15), addr1.String())) + suite.Require().Error(err) + + // Make sure the new admin works + _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr2.String(), sdk.NewInt64Coin(denom, 15), addr1.String())) + suite.Require().NoError(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 0))) +} diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 8a082e1b445..624d76239af 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -11,14 +11,24 @@ func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { return err } + addr, err := sdk.AccAddressFromBech32(mintTo) + if err != nil { + return err + } + return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, - sdk.AccAddress(mintTo), + addr, sdk.NewCoins(amount)) } func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) error { - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, - sdk.AccAddress(burnFrom), + addr, err := sdk.AccAddressFromBech32(burnFrom) + if err != nil { + return err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, + addr, types.ModuleName, sdk.NewCoins(amount)) if err != nil { @@ -29,5 +39,15 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro } func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr string, toAddr string) error { - return k.bankKeeper.SendCoins(ctx, sdk.AccAddress(fromAddr), sdk.AccAddress(toAddr), sdk.NewCoins(amount)) + fromSdkAddr, err := sdk.AccAddressFromBech32(fromAddr) + if err != nil { + return err + } + + toSdkAddr, err := sdk.AccAddressFromBech32(toAddr) + if err != nil { + return err + } + + return k.bankKeeper.SendCoins(ctx, fromSdkAddr, toSdkAddr, sdk.NewCoins(amount)) } diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go new file mode 100644 index 00000000000..6e49e0ef4b8 --- /dev/null +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -0,0 +1,49 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" +) + +func (suite *KeeperTestSuite) TestMsgCreateDenom() { + suite.SetupTest() + + addr1 := sdk.AccAddress([]byte("addr1---------------")) + + msgServer := keeper.NewMsgServerImpl(suite.app.TokenFactoryKeeper) + + // Creating a denom should work + res, err := msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "bitcoin")) + suite.Require().NoError(err) + suite.Require().NotEmpty(res.GetNewTokenDenom()) + + // Make sure that the admin is set correctly + queryRes, err := suite.queryClient.DenomAuthorityMetadata(suite.ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ + Denom: res.GetNewTokenDenom(), + }) + suite.Require().NoError(err) + suite.Require().Equal(addr1.String(), queryRes.AuthorityMetadata.Admin) + + // Make sure that a second version of the same denom can't be recreated + res, err = msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "bitcoin")) + suite.Require().Error(err) + + // Creating a second denom should work + res, err = msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "litecoin")) + suite.Require().NoError(err) + suite.Require().NotEmpty(res.GetNewTokenDenom()) + + // Try querying all the denoms created by addr1 + queryRes2, err := suite.queryClient.DenomsFromCreator(suite.ctx.Context(), &types.QueryDenomsFromCreatorRequest{ + Creator: addr1.String(), + }) + suite.Require().NoError(err) + suite.Require().Len(queryRes2.Denoms, 2) + + // Make sure that a second account can create a denom with the same nonce + addr2 := sdk.AccAddress([]byte("addr2---------------")) + res, err = msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr2.String(), "bitcoin")) + suite.Require().NoError(err) + suite.Require().NotEmpty(res.GetNewTokenDenom()) +} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 0bb224b1414..cb763ec0983 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -9,6 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) type ( @@ -16,20 +18,23 @@ type ( cdc codec.Codec storeKey sdk.StoreKey - bankKeeper types.BankKeeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper } ) func NewKeeper( cdc codec.Codec, storeKey sdk.StoreKey, + accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ) *Keeper { return &Keeper{ cdc: cdc, storeKey: storeKey, - bankKeeper: bankKeeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, } } @@ -56,3 +61,9 @@ func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) sdk.KVStore { // store := ctx.KVStore(k.storeKey) // return prefix.NewStore(store, types.GetAdminPrefix(admin)) // } + +// CreateModuleAccount creates a module account with minting and burning capabilities +func (k Keeper) CreateModuleAccount(ctx sdk.Context) { + moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner) + k.accountKeeper.SetModuleAccount(ctx, moduleAcc) +} diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go new file mode 100644 index 00000000000..fa626b6bf57 --- /dev/null +++ b/x/tokenfactory/keeper/keeper_test.go @@ -0,0 +1,47 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/app" + "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + querier sdk.Querier + app *app.OsmosisApp + queryClient types.QueryClient + cleanup func() +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.app = app.Setup(false) + suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "osmosis-1", Time: time.Now().UTC()}) + + suite.app.TokenFactoryKeeper.CreateModuleAccount(suite.ctx) + + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.app.TokenFactoryKeeper) + suite.queryClient = types.NewQueryClient(queryHelper) +} + +func (suite *KeeperTestSuite) SetupTestWithLevelDb() { + suite.app, suite.cleanup = app.SetupTestingAppWithLevelDb(false) + suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Height: 1, ChainID: "osmosis-1", Time: time.Now().UTC()}) +} + +func (suite *KeeperTestSuite) Cleanup() { + suite.cleanup() +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 0eee7d06b5a..4550ab8df0e 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -54,7 +54,10 @@ func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types. return nil, types.ErrUnauthorized } - server.Keeper.mintTo(ctx, msg.Amount, msg.MintToAddress) + err = server.Keeper.mintTo(ctx, msg.Amount, msg.MintToAddress) + if err != nil { + return nil, err + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -79,7 +82,10 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types. return nil, types.ErrUnauthorized } - server.Keeper.burnFrom(ctx, msg.Amount, msg.GetBurnFromAddress()) + err = server.Keeper.burnFrom(ctx, msg.Amount, msg.GetBurnFromAddress()) + if err != nil { + return nil, err + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -104,7 +110,10 @@ func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForce return nil, types.ErrUnauthorized } - server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) + err = server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) + if err != nil { + return nil, err + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go deleted file mode 100644 index 51aa5d9e63e..00000000000 --- a/x/tokenfactory/keeper/msg_server_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper_test - -// import ( -// "context" -// "testing" - -// sdk "github.com/cosmos/cosmos-sdk/types" -// keepertest "github.com/osmosis-labs/osmosis/testutil/keeper" -// "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" -// "github.com/osmosis-labs/osmosis/x/tokenfactory/types" -// ) - -// func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { -// k, ctx := keepertest.TokenfactoryKeeper(t) -// return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) -// } diff --git a/x/tokenfactory/types/expected_keepers.go b/x/tokenfactory/types/expected_keepers.go index 0e58a42579b..9ef176f0c73 100644 --- a/x/tokenfactory/types/expected_keepers.go +++ b/x/tokenfactory/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -20,3 +21,10 @@ type BankKeeper interface { SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error } + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + SetModuleAccount(ctx sdk.Context, macc authtypes.ModuleAccountI) + GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI +} From 4e51f3d8147fb801ffbfa1478e98ce0397b9a09a Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 04:54:33 -0500 Subject: [PATCH 07/22] add cli commands --- x/tokenfactory/client/cli/tx.go | 4 ++++ x/tokenfactory/module.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index bbc34b7e109..8eed634396b 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -26,6 +26,10 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand( NewCreateDenomCmd(), + NewMintCmd(), + NewBurnCmd(), + NewForceTransferCmd(), + NewChangeAdminCmd(), ) return cmd diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 210cc28376d..7bac2734807 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -1,6 +1,7 @@ package tokenfactory import ( + "context" "encoding/json" "fmt" @@ -78,7 +79,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // this line is used by starport scaffolding # 2 + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } // GetTxCmd returns the capability module's root tx command. From 5081c1ff7b45aaa37fb20df02e0cb68cfd9b9881 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 05:26:58 -0500 Subject: [PATCH 08/22] register msg server --- app/app.go | 3 +++ x/tokenfactory/module.go | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 93873f70b29..b67a1e733f8 100644 --- a/app/app.go +++ b/app/app.go @@ -586,6 +586,7 @@ func NewOsmosisApp( lockup.NewAppModule(appCodec, app.LockupKeeper, app.AccountKeeper, app.BankKeeper), poolincentives.NewAppModule(appCodec, app.PoolIncentivesKeeper), epochs.NewAppModule(appCodec, app.EpochsKeeper), + tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -624,6 +625,7 @@ func NewOsmosisApp( epochstypes.ModuleName, lockuptypes.ModuleName, authz.ModuleName, + tokenfactorytypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -655,6 +657,7 @@ func NewOsmosisApp( poolincentives.NewAppModule(appCodec, app.PoolIncentivesKeeper), epochs.NewAppModule(appCodec, app.EpochsKeeper), transferModule, + tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper), ) app.sm.RegisterStoreDecoders() diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 7bac2734807..e8cf90f6d9a 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "math/rand" // this line is used by starport scaffolding # 1 @@ -18,6 +19,7 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/osmosis-labs/osmosis/x/tokenfactory/client/cli" "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" "github.com/osmosis-labs/osmosis/x/tokenfactory/types" @@ -131,6 +133,7 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } @@ -156,7 +159,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} @@ -166,3 +169,33 @@ func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the pool-incentives module. +func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { + // gen := types.DefaultGenesis() + // gen.Basedenom = sdk.DefaultBondDenom + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized txfees param changes for the simulator. +func (am AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return nil +} + +// RegisterStoreDecoder registers a decoder for supply module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return nil // TODO +} From 8041b89b5841c2bfcb127548409ae9f148c905a2 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 05:36:20 -0500 Subject: [PATCH 09/22] add README stub --- x/tokenfactory/README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 x/tokenfactory/README.md diff --git a/x/tokenfactory/README.md b/x/tokenfactory/README.md new file mode 100644 index 00000000000..ebd97f0e603 --- /dev/null +++ b/x/tokenfactory/README.md @@ -0,0 +1,40 @@ +# Token Factory + +The tokenfactory module allows any account to create a new token with the name `factory/{creator address}/{nonce} + +Because tokens are namespaced by creator address, this allows token minting to be permissionless, due to not needing to resolve name collisions. +A single account can create multiple denoms, by providing a unique nonce for each created denom. + +Once a denom is created, the original creator is given "admin" privleges over the asset. This allows them to: +- 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 privledges 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 privledges of the asset. + +## State Changes + +TODO: Describe + +## New SDK messages + +TODO: Describe + +## CLI commands + +TODO: Describe + +## Queries + +TODO: Describe + +## Code structure + +TODO: Describe + +## Future directions + +* Want to add in a system to add in general "tx fee credits" for different on-chain usages + * e.g. making 0 fee txs under certain usecases +* If other chains would like to use this, we should brainstorm mechanisms for extending the metadata proto fields From 714567cb561d8d39cd286892f76793187a8f42aa Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 05:38:19 -0500 Subject: [PATCH 10/22] add empty admin test --- x/tokenfactory/keeper/admins_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index ed026521869..48c9dd95c2a 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -63,4 +63,13 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr2.String(), sdk.NewInt64Coin(denom, 15), addr1.String())) suite.Require().NoError(err) suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 0))) + + // Try setting admin to empty + _, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.ctx), types.NewMsgChangeAdmin(addr2.String(), denom, "")) + suite.Require().NoError(err) + queryRes, err = suite.queryClient.DenomAuthorityMetadata(suite.ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ + Denom: res.GetNewTokenDenom(), + }) + suite.Require().NoError(err) + suite.Require().Equal("", queryRes.AuthorityMetadata.Admin) } From c5285f75bc8f3a7dd2d44918b29dc0c23c554868 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sun, 21 Nov 2021 05:38:54 -0500 Subject: [PATCH 11/22] readme stub --- x/tokenfactory/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/tokenfactory/README.md b/x/tokenfactory/README.md index ebd97f0e603..b376cdacdce 100644 --- a/x/tokenfactory/README.md +++ b/x/tokenfactory/README.md @@ -35,6 +35,4 @@ TODO: Describe ## Future directions -* Want to add in a system to add in general "tx fee credits" for different on-chain usages - * e.g. making 0 fee txs under certain usecases -* If other chains would like to use this, we should brainstorm mechanisms for extending the metadata proto fields +TODO: Describe \ No newline at end of file From f81ae6f16cd88152f654cb606fe7cf4bf146baa3 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 27 Nov 2021 18:51:37 -0500 Subject: [PATCH 12/22] fix lint --- x/tokenfactory/genesis.go | 10 ++++++++-- x/tokenfactory/module.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x/tokenfactory/genesis.go b/x/tokenfactory/genesis.go index 83f7eeb562a..21f7964acc2 100644 --- a/x/tokenfactory/genesis.go +++ b/x/tokenfactory/genesis.go @@ -16,8 +16,14 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) if err != nil { panic(err.Error()) } - k.CreateDenom(ctx, creator, nonce) - k.SetAuthorityMetadata(ctx, genDenom.GetDenom(), genDenom.GetAuthorityMetadata()) + _, err = k.CreateDenom(ctx, creator, nonce) + if err != nil { + panic(err.Error()) + } + err = k.SetAuthorityMetadata(ctx, genDenom.GetDenom(), genDenom.GetAuthorityMetadata()) + if err != nil { + panic(err.Error()) + } } } diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index e8cf90f6d9a..23ae4bd02df 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -81,7 +81,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck } // GetTxCmd returns the capability module's root tx command. From 10d223436dc7c2f68122ac1b2d3596ab23f7ab69 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 25 Dec 2021 01:39:36 -0500 Subject: [PATCH 13/22] Update x/tokenfactory/keeper/keeper.go Co-authored-by: Dev Ojha --- x/tokenfactory/keeper/keeper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index cb763ec0983..920dd2c026d 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -63,6 +63,9 @@ func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) sdk.KVStore { // } // CreateModuleAccount creates a module account with minting and burning capabilities +// This account isn't intended to store any coins, +// it purely mints and burns them on behalf of the admin of respective denoms, +// and sends to the relevant address. func (k Keeper) CreateModuleAccount(ctx sdk.Context) { moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner) k.accountKeeper.SetModuleAccount(ctx, moduleAcc) From 40d584a28251946c5480cb09b61550a721f6d7d7 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 25 Dec 2021 01:39:52 -0500 Subject: [PATCH 14/22] Update x/tokenfactory/module.go Co-authored-by: Dev Ojha --- x/tokenfactory/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 23ae4bd02df..4ab7117774d 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -195,7 +195,7 @@ func (am AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { } -// WeightedOperations returns the all the gov module operations with their respective weights. +// WeightedOperations returns simulator module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return nil // TODO } From aa17388d95fca93596a24d1e06be7bd6a3c5da5b Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 25 Dec 2021 11:22:36 -0500 Subject: [PATCH 15/22] move | to a constant --- x/tokenfactory/types/keys.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go index 9a66a9634c4..d4b48670369 100644 --- a/x/tokenfactory/types/keys.go +++ b/x/tokenfactory/types/keys.go @@ -21,6 +21,9 @@ const ( MemStoreKey = "mem_tokenfactory" ) +// KeySeparator is used to combine parts of the keys in the store +const KeySeparator = "|" + var ( DenomAuthorityMetadataKey = "authoritymetadata" DenomsPrefixKey = "denoms" @@ -29,17 +32,17 @@ var ( ) func GetDenomPrefixStore(denom string) []byte { - return []byte(strings.Join([]string{DenomsPrefixKey, denom, ""}, "|")) + return []byte(strings.Join([]string{DenomsPrefixKey, denom, ""}, KeySeparator)) } func GetCreatorPrefix(creator string) []byte { - return []byte(strings.Join([]string{CreatorPrefixKey, creator, ""}, "|")) + return []byte(strings.Join([]string{CreatorPrefixKey, creator, ""}, KeySeparator)) } func GetCreatorsPrefix() []byte { - return []byte(strings.Join([]string{CreatorPrefixKey, ""}, "|")) + return []byte(strings.Join([]string{CreatorPrefixKey, ""}, KeySeparator)) } // func GetAdminPrefix(admin string) []byte { -// return []byte(strings.Join([]string{admin, "admin", ""}, "|")) +// return []byte(strings.Join([]string{admin, "admin", ""}, KeySeparator)) // } From bdfd52f63aa9946098336f399f5e72f242dc058b Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 25 Dec 2021 11:29:22 -0500 Subject: [PATCH 16/22] Apply suggestions from code review Co-authored-by: Dev Ojha --- x/tokenfactory/types/denoms.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go index c340b2accec..3c6f3589db0 100644 --- a/x/tokenfactory/types/denoms.go +++ b/x/tokenfactory/types/denoms.go @@ -12,7 +12,7 @@ const ( ) func GetTokenDenom(creator, nonce string) (string, error) { - denom := strings.Join([]string{"factory", creator, nonce}, "/") + denom := strings.Join([]string{ModuleDenomPrefix, creator, nonce}, "/") return denom, sdk.ValidateDenom(denom) } From 687e781b51603011552c84f7b2d745ab906cd8c7 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Fri, 7 Jan 2022 04:01:13 -0400 Subject: [PATCH 17/22] address @valardragon comments --- proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto | 1 + x/tokenfactory/types/denoms.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto index 523a9273c02..1049c152a6f 100644 --- a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto +++ b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto @@ -9,5 +9,6 @@ option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; message DenomAuthorityMetadata { option (gogoproto.equal) = true; + // Can be empty for no admin, or a valid osmosis address string Admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ]; } \ No newline at end of file diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go index 3c6f3589db0..b4b6eaa50b6 100644 --- a/x/tokenfactory/types/denoms.go +++ b/x/tokenfactory/types/denoms.go @@ -37,6 +37,9 @@ func DeconstructDenom(denom string) (creator string, nonce string, err error) { return "", "", sdkerrors.Wrapf(ErrInvalidDenom, "Invalid creator address (%s)", err) } + // This is to for if there is a denom with a slash in its nonce. For example, + // when we did the split, we'd turn factory/sunnyaddr/atomderivative/sikka into ["factory", "sunnyaddr", "atomderivative", "sikka"] + // So we have to join [2:] with a "/" as the delimiter to get back the correct nonce which should be "atomderivative/sikka" nonce = strings.Join(strParts[2:], "/") return creator, nonce, nil From b9d80b0c8803936d498a62ba2c52926be8cec437 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 21 Apr 2022 10:03:39 -0400 Subject: [PATCH 18/22] fix conflicts --- app/keepers.go | 13 +++++++++++++ app/modules.go | 13 +++++++++++++ go.mod | 4 ---- x/tokenfactory/client/cli/query.go | 2 +- x/tokenfactory/client/cli/tx.go | 2 +- x/tokenfactory/genesis.go | 5 +++-- x/tokenfactory/genesis_test.go | 9 +++++---- x/tokenfactory/keeper/admins.go | 3 ++- x/tokenfactory/keeper/admins_test.go | 7 ++++--- x/tokenfactory/keeper/bankactions.go | 3 ++- x/tokenfactory/keeper/createdenom.go | 3 ++- x/tokenfactory/keeper/createdenom_test.go | 7 ++++--- x/tokenfactory/keeper/grpc_query.go | 3 ++- x/tokenfactory/keeper/keeper.go | 11 ++++++----- x/tokenfactory/keeper/keeper_test.go | 5 +++-- x/tokenfactory/keeper/msg_server.go | 2 +- x/tokenfactory/module.go | 7 ++++--- x/tokenfactory/types/denoms_test.go | 4 ++-- x/tokenfactory/types/genesis_test.go | 3 ++- 19 files changed, 70 insertions(+), 36 deletions(-) diff --git a/app/keepers.go b/app/keepers.go index cca81eed4c5..85664a4350a 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -65,6 +65,8 @@ import ( "github.com/osmosis-labs/osmosis/v7/x/superfluid" superfluidkeeper "github.com/osmosis-labs/osmosis/v7/x/superfluid/keeper" superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" + tokenfactorykeeper "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" "github.com/osmosis-labs/osmosis/v7/x/txfees" txfeeskeeper "github.com/osmosis-labs/osmosis/v7/x/txfees/keeper" txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types" @@ -106,6 +108,7 @@ type appKeepers struct { SuperfluidKeeper *superfluidkeeper.Keeper GovKeeper *govkeeper.Keeper WasmKeeper *wasm.Keeper + TokenFactoryKeeper *tokenfactorykeeper.Keeper } func (app *OsmosisApp) InitSpecialKeepers( @@ -345,6 +348,14 @@ func (app *OsmosisApp) InitNormalKeepers( ) app.TxFeesKeeper = &txFeesKeeper + tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( + appCodec, + keys[tokenfactorytypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + ) + app.TokenFactoryKeeper = &tokenFactoryKeeper + // The last arguments can contain custom message handlers, and custom query handlers, // if we want to allow any custom callbacks supportedFeatures := "iterator,staking,stargate,osmosis" @@ -481,6 +492,7 @@ func (app *OsmosisApp) initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino paramsKeeper.Subspace(superfluidtypes.ModuleName) paramsKeeper.Subspace(gammtypes.ModuleName) paramsKeeper.Subspace(wasm.ModuleName) + paramsKeeper.Subspace(tokenfactorytypes.ModuleName) return paramsKeeper } @@ -511,5 +523,6 @@ func KVStoreKeys() []string { superfluidtypes.StoreKey, bech32ibctypes.StoreKey, wasm.StoreKey, + tokenfactorytypes.StoreKey, } } diff --git a/app/modules.go b/app/modules.go index 29a716c7bc6..cc607d1aad4 100644 --- a/app/modules.go +++ b/app/modules.go @@ -68,6 +68,9 @@ import ( superfluidtypes "github.com/osmosis-labs/osmosis/v7/x/superfluid/types" "github.com/osmosis-labs/osmosis/v7/x/txfees" txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory" + tokenfactorytypes "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // appModuleBasics returns ModuleBasics for the module BasicManager. @@ -112,6 +115,7 @@ var appModuleBasics = []module.AppModuleBasic{ superfluid.AppModuleBasic{}, bech32ibc.AppModuleBasic{}, wasm.AppModuleBasic{}, + tokenfactory.AppModuleBasic{}, } // moduleAccountPermissions defines module account permissions @@ -132,6 +136,7 @@ var moduleAccountPermissions = map[string][]string{ superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, txfeestypes.ModuleName: nil, wasm.ModuleName: {authtypes.Burner}, + tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } // appModules return modules to initialize module manager. @@ -184,6 +189,7 @@ func appModules( app.EpochsKeeper, ), bech32ibc.NewAppModule(appCodec, *app.Bech32IBCKeeper), + tokenfactory.NewAppModule(appCodec, *app.TokenFactoryKeeper), } } @@ -217,6 +223,7 @@ func orderBeginBlockers() []string { lockuptypes.ModuleName, claimtypes.ModuleName, poolincentivestypes.ModuleName, + tokenfactorytypes.ModuleName, // superfluid must come after distribution and epochs superfluidtypes.ModuleName, bech32ibctypes.ModuleName, @@ -254,6 +261,7 @@ var orderEndBlockers = []string{ superfluidtypes.ModuleName, bech32ibctypes.ModuleName, txfeestypes.ModuleName, + tokenfactorytypes.ModuleName, // Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the end epochstypes.ModuleName, wasm.ModuleName, @@ -287,6 +295,7 @@ var modulesOrderInitGenesis = []string{ epochstypes.ModuleName, lockuptypes.ModuleName, authz.ModuleName, + tokenfactorytypes.ModuleName, // wasm after ibc transfer wasm.ModuleName, } @@ -330,6 +339,10 @@ func simulationModules( app.EpochsKeeper, ), app.transferModule, + tokenfactory.NewAppModule( + appCodec, + *app.TokenFactoryKeeper, + ), } } diff --git a/go.mod b/go.mod index e986f026e0d..4469ccc25c2 100644 --- a/go.mod +++ b/go.mod @@ -130,12 +130,8 @@ require ( github.com/golangci/revgrep v0.0.0-20210930125155-c22e5001d4f2 // indirect github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/btree v1.0.0 // indirect -<<<<<<< HEAD - github.com/google/go-cmp v0.5.6 // indirect -======= github.com/google/go-cmp v0.5.7 // indirect github.com/google/gofuzz v1.2.0 // indirect ->>>>>>> main github.com/google/orderedcode v0.0.1 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect diff --git a/x/tokenfactory/client/cli/query.go b/x/tokenfactory/client/cli/query.go index 2e8b79812e9..9da1cdc8c9b 100644 --- a/x/tokenfactory/client/cli/query.go +++ b/x/tokenfactory/client/cli/query.go @@ -13,7 +13,7 @@ import ( // "github.com/cosmos/cosmos-sdk/client/flags" // sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index 8eed634396b..05569796750 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/tokenfactory/genesis.go b/x/tokenfactory/genesis.go index 21f7964acc2..35c3b02c835 100644 --- a/x/tokenfactory/genesis.go +++ b/x/tokenfactory/genesis.go @@ -2,8 +2,9 @@ package tokenfactory import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/tokenfactory/genesis_test.go b/x/tokenfactory/genesis_test.go index f6e624236ce..9b95fced430 100644 --- a/x/tokenfactory/genesis_test.go +++ b/x/tokenfactory/genesis_test.go @@ -3,13 +3,14 @@ package tokenfactory_test import ( "testing" - simapp "github.com/osmosis-labs/osmosis/app" - appparams "github.com/osmosis-labs/osmosis/app/params" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + simapp "github.com/osmosis-labs/osmosis/v7/app" + appparams "github.com/osmosis-labs/osmosis/v7/app/params" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func TestGenesis(t *testing.T) { diff --git a/x/tokenfactory/keeper/admins.go b/x/tokenfactory/keeper/admins.go index 7293adeee84..590490e840d 100644 --- a/x/tokenfactory/keeper/admins.go +++ b/x/tokenfactory/keeper/admins.go @@ -3,7 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // GetAuthorityMetadata returns the authority metadata for a specific denom diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index 48c9dd95c2a..01c46c9a752 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -2,8 +2,9 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func (suite *KeeperTestSuite) TestAdminMsgs() { @@ -12,7 +13,7 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { addr1 := sdk.AccAddress([]byte("addr1---------------")) addr2 := sdk.AccAddress([]byte("addr2---------------")) - msgServer := keeper.NewMsgServerImpl(suite.app.TokenFactoryKeeper) + msgServer := keeper.NewMsgServerImpl(*suite.app.TokenFactoryKeeper) // Create a denom res, err := msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "bitcoin")) diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index 624d76239af..25bde730064 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -2,7 +2,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index c03b46b36fb..a07d3898776 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -3,7 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) // ConvertToBaseToken converts a fee amount in a whitelisted fee token to the base fee token amount diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 6e49e0ef4b8..7d25a9d5d8c 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -2,8 +2,9 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func (suite *KeeperTestSuite) TestMsgCreateDenom() { @@ -11,7 +12,7 @@ func (suite *KeeperTestSuite) TestMsgCreateDenom() { addr1 := sdk.AccAddress([]byte("addr1---------------")) - msgServer := keeper.NewMsgServerImpl(suite.app.TokenFactoryKeeper) + msgServer := keeper.NewMsgServerImpl(*suite.app.TokenFactoryKeeper) // Creating a denom should work res, err := msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr1.String(), "bitcoin")) diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index a4bd7166d1e..23b2278c8bf 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -4,7 +4,8 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 920dd2c026d..50b956df5e4 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -8,7 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -28,8 +29,8 @@ func NewKeeper( storeKey sdk.StoreKey, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, -) *Keeper { - return &Keeper{ +) Keeper { + return Keeper{ cdc: cdc, storeKey: storeKey, @@ -63,8 +64,8 @@ func (k Keeper) GetCreatorsPrefixStore(ctx sdk.Context) sdk.KVStore { // } // CreateModuleAccount creates a module account with minting and burning capabilities -// This account isn't intended to store any coins, -// it purely mints and burns them on behalf of the admin of respective denoms, +// This account isn't intended to store any coins, +// it purely mints and burns them on behalf of the admin of respective denoms, // and sends to the relevant address. func (k Keeper) CreateModuleAccount(ctx sdk.Context) { moduleAcc := authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter, authtypes.Burner) diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index fa626b6bf57..fbafb50943d 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -6,10 +6,11 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/app" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/osmosis-labs/osmosis/v7/app" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) type KeeperTestSuite struct { diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 4550ab8df0e..efb68e0997e 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) type msgServer struct { diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 4ab7117774d..5984f0817ae 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -20,9 +20,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/osmosis-labs/osmosis/x/tokenfactory/client/cli" - "github.com/osmosis-labs/osmosis/x/tokenfactory/keeper" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/client/cli" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/keeper" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) var ( diff --git a/x/tokenfactory/types/denoms_test.go b/x/tokenfactory/types/denoms_test.go index a5d43a69b77..b7f0fc01067 100644 --- a/x/tokenfactory/types/denoms_test.go +++ b/x/tokenfactory/types/denoms_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - appparams "github.com/osmosis-labs/osmosis/app/params" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" + appparams "github.com/osmosis-labs/osmosis/v7/app/params" + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func TestDecomposeDenoms(t *testing.T) { diff --git a/x/tokenfactory/types/genesis_test.go b/x/tokenfactory/types/genesis_test.go index b4dc50e1768..6b6e3bf86f3 100644 --- a/x/tokenfactory/types/genesis_test.go +++ b/x/tokenfactory/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/osmosis-labs/osmosis/x/tokenfactory/types" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) func TestGenesisState_Validate(t *testing.T) { From 086a0eb4d04e66884f04472fbed6ec70eb0389d1 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 21 Apr 2022 10:05:12 -0400 Subject: [PATCH 19/22] lint --- x/tokenfactory/keeper/msg_server.go | 1 - x/tokenfactory/types/msgs.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index efb68e0997e..4592a5bc567 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -24,7 +24,6 @@ func (server msgServer) CreateDenom(goCtx context.Context, msg *types.MsgCreateD ctx := sdk.UnwrapSDKContext(goCtx) denom, err := server.Keeper.CreateDenom(ctx, msg.Sender, msg.Nonce) - if err != nil { return nil, err } diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index 06b2e558bea..cda3d2ff0ac 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -39,9 +39,11 @@ func (m MsgCreateDenom) ValidateBasic() error { return nil } + func (m MsgCreateDenom) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgCreateDenom) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -77,9 +79,11 @@ func (m MsgMint) ValidateBasic() error { return nil } + func (m MsgMint) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgMint) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -115,9 +119,11 @@ func (m MsgBurn) ValidateBasic() error { return nil } + func (m MsgBurn) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgBurn) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -158,9 +164,11 @@ func (m MsgForceTransfer) ValidateBasic() error { return nil } + func (m MsgForceTransfer) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} @@ -197,9 +205,11 @@ func (m MsgChangeAdmin) ValidateBasic() error { return nil } + func (m MsgChangeAdmin) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } + func (m MsgChangeAdmin) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} From 6ee12125cbc0c38f4a40caff87cd1d8e4a592af4 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 21 Apr 2022 10:05:55 -0400 Subject: [PATCH 20/22] fix more conflicts --- x/tokenfactory/genesis_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/tokenfactory/genesis_test.go b/x/tokenfactory/genesis_test.go index 9b95fced430..3749c043ccd 100644 --- a/x/tokenfactory/genesis_test.go +++ b/x/tokenfactory/genesis_test.go @@ -35,8 +35,8 @@ func TestGenesis(t *testing.T) { app := simapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - tokenfactory.InitGenesis(ctx, app.TokenFactoryKeeper, genesisState) - exportedGenesis := tokenfactory.ExportGenesis(ctx, app.TokenFactoryKeeper) + tokenfactory.InitGenesis(ctx, *app.TokenFactoryKeeper, genesisState) + exportedGenesis := tokenfactory.ExportGenesis(ctx, *app.TokenFactoryKeeper) require.NotNil(t, exportedGenesis) require.Equal(t, genesisState, *exportedGenesis) } From 198985db7be79cd2d121e549fc052a80dd788f03 Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Thu, 21 Apr 2022 17:01:35 -0400 Subject: [PATCH 21/22] restrict the token factory module --- docs/core/proto-docs.md | 333 ++++++++++ go.sum | 1 + .../v1beta1/authorityMetadata.proto | 2 +- .../tokenfactory/v1beta1/genesis.proto | 2 +- .../osmosis/tokenfactory/v1beta1/query.proto | 2 +- proto/osmosis/tokenfactory/v1beta1/tx.proto | 32 +- x/tokenfactory/client/cli/tx.go | 68 +-- x/tokenfactory/keeper/admins_test.go | 40 +- x/tokenfactory/keeper/msg_server.go | 69 ++- x/tokenfactory/types/authorityMetadata.pb.go | 11 +- x/tokenfactory/types/codec.go | 4 +- x/tokenfactory/types/genesis.pb.go | 12 +- x/tokenfactory/types/msgs.go | 88 +-- x/tokenfactory/types/query.pb.go | 60 +- x/tokenfactory/types/tx.pb.go | 570 ++---------------- 15 files changed, 587 insertions(+), 707 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 77f18a5972e..1429e8b086f 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -300,6 +300,33 @@ - [Msg](#osmosis.superfluid.Msg) +- [osmosis/tokenfactory/v1beta1/authorityMetadata.proto](#osmosis/tokenfactory/v1beta1/authorityMetadata.proto) + - [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) + +- [osmosis/tokenfactory/v1beta1/genesis.proto](#osmosis/tokenfactory/v1beta1/genesis.proto) + - [GenesisDenom](#osmosis.tokenfactory.v1beta1.GenesisDenom) + - [GenesisState](#osmosis.tokenfactory.v1beta1.GenesisState) + +- [osmosis/tokenfactory/v1beta1/query.proto](#osmosis/tokenfactory/v1beta1/query.proto) + - [QueryDenomAuthorityMetadataRequest](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest) + - [QueryDenomAuthorityMetadataResponse](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse) + - [QueryDenomsFromCreatorRequest](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest) + - [QueryDenomsFromCreatorResponse](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse) + + - [Query](#osmosis.tokenfactory.v1beta1.Query) + +- [osmosis/tokenfactory/v1beta1/tx.proto](#osmosis/tokenfactory/v1beta1/tx.proto) + - [MsgBurn](#osmosis.tokenfactory.v1beta1.MsgBurn) + - [MsgBurnResponse](#osmosis.tokenfactory.v1beta1.MsgBurnResponse) + - [MsgChangeAdmin](#osmosis.tokenfactory.v1beta1.MsgChangeAdmin) + - [MsgChangeAdminResponse](#osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse) + - [MsgCreateDenom](#osmosis.tokenfactory.v1beta1.MsgCreateDenom) + - [MsgCreateDenomResponse](#osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse) + - [MsgMint](#osmosis.tokenfactory.v1beta1.MsgMint) + - [MsgMintResponse](#osmosis.tokenfactory.v1beta1.MsgMintResponse) + + - [Msg](#osmosis.tokenfactory.v1beta1.Msg) + - [osmosis/txfees/v1beta1/feetoken.proto](#osmosis/txfees/v1beta1/feetoken.proto) - [FeeToken](#osmosis.txfees.v1beta1.FeeToken) @@ -4168,6 +4195,312 @@ Execute superfluid redelegation for a lockup rpc SuperfluidRedelegate(MsgSuperfl + +

Top

+ +## osmosis/tokenfactory/v1beta1/authorityMetadata.proto + + + + + +### DenomAuthorityMetadata + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `Admin` | [string](#string) | | Can be empty for no admin, or a valid osmosis address | + + + + + + + + + + + + + + + + +

Top

+ +## osmosis/tokenfactory/v1beta1/genesis.proto + + + + + +### GenesisDenom + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | | +| `authority_metadata` | [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) | | | + + + + + + + + +### GenesisState +GenesisState defines the tokenfactory module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `factory_denoms` | [GenesisDenom](#osmosis.tokenfactory.v1beta1.GenesisDenom) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ +## osmosis/tokenfactory/v1beta1/query.proto + + + + + +### QueryDenomAuthorityMetadataRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | | + + + + + + + + +### QueryDenomAuthorityMetadataResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority_metadata` | [DenomAuthorityMetadata](#osmosis.tokenfactory.v1beta1.DenomAuthorityMetadata) | | | + + + + + + + + +### QueryDenomsFromCreatorRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `creator` | [string](#string) | | | + + + + + + + + +### QueryDenomsFromCreatorResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denoms` | [string](#string) | repeated | | + + + + + + + + + + + + + + +### Query +Query defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `DenomAuthorityMetadata` | [QueryDenomAuthorityMetadataRequest](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataRequest) | [QueryDenomAuthorityMetadataResponse](#osmosis.tokenfactory.v1beta1.QueryDenomAuthorityMetadataResponse) | | GET|/osmosis/tokenfactory/v1beta1/denoms/{denom}/authority_metadata| +| `DenomsFromCreator` | [QueryDenomsFromCreatorRequest](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorRequest) | [QueryDenomsFromCreatorResponse](#osmosis.tokenfactory.v1beta1.QueryDenomsFromCreatorResponse) | | GET|/osmosis/tokenfactory/v1beta1/denoms_from_creator/{creator}| + + + + + + +

Top

+ +## osmosis/tokenfactory/v1beta1/tx.proto + + + + + +### MsgBurn +===================== MsgBurn + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `burnFromAddress` | [string](#string) | | | + + + + + + + + +### MsgBurnResponse + + + + + + + + + +### MsgChangeAdmin +===================== MsgChangeAdmin + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `denom` | [string](#string) | | | +| `newAdmin` | [string](#string) | | | + + + + + + + + +### MsgChangeAdminResponse + + + + + + + + + +### MsgCreateDenom +===================== MsgCreateDenom + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `nonce` | [string](#string) | | | + + + + + + + + +### MsgCreateDenomResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `new_token_denom` | [string](#string) | | | + + + + + + + + +### MsgMint +===================== MsgMint + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sender` | [string](#string) | | | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `mintToAddress` | [string](#string) | | | + + + + + + + + +### MsgMintResponse + + + + + + + + + + + + + + + +### Msg +Msg defines the Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `CreateDenom` | [MsgCreateDenom](#osmosis.tokenfactory.v1beta1.MsgCreateDenom) | [MsgCreateDenomResponse](#osmosis.tokenfactory.v1beta1.MsgCreateDenomResponse) | | | +| `Mint` | [MsgMint](#osmosis.tokenfactory.v1beta1.MsgMint) | [MsgMintResponse](#osmosis.tokenfactory.v1beta1.MsgMintResponse) | | | +| `Burn` | [MsgBurn](#osmosis.tokenfactory.v1beta1.MsgBurn) | [MsgBurnResponse](#osmosis.tokenfactory.v1beta1.MsgBurnResponse) | | | +| `ChangeAdmin` | [MsgChangeAdmin](#osmosis.tokenfactory.v1beta1.MsgChangeAdmin) | [MsgChangeAdminResponse](#osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse) | ForceTransfer is deactivated for now because we need to think through edge cases rpc ForceTransfer(MsgForceTransfer) returns (MsgForceTransferResponse); | | + + + + +

Top

diff --git a/go.sum b/go.sum index c90944affc7..f238a74fcff 100644 --- a/go.sum +++ b/go.sum @@ -1779,6 +1779,7 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto index 1049c152a6f..172acba2fbb 100644 --- a/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto +++ b/proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto @@ -4,7 +4,7 @@ package osmosis.tokenfactory.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; message DenomAuthorityMetadata { option (gogoproto.equal) = true; diff --git a/proto/osmosis/tokenfactory/v1beta1/genesis.proto b/proto/osmosis/tokenfactory/v1beta1/genesis.proto index ae79f669b90..16338e58bf3 100644 --- a/proto/osmosis/tokenfactory/v1beta1/genesis.proto +++ b/proto/osmosis/tokenfactory/v1beta1/genesis.proto @@ -4,7 +4,7 @@ package osmosis.tokenfactory.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; // GenesisState defines the tokenfactory module's genesis state. message GenesisState { diff --git a/proto/osmosis/tokenfactory/v1beta1/query.proto b/proto/osmosis/tokenfactory/v1beta1/query.proto index 3c361946922..48ebf6c6677 100644 --- a/proto/osmosis/tokenfactory/v1beta1/query.proto +++ b/proto/osmosis/tokenfactory/v1beta1/query.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "osmosis/tokenfactory/v1beta1/authorityMetadata.proto"; -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/osmosis/tokenfactory/v1beta1/tx.proto b/proto/osmosis/tokenfactory/v1beta1/tx.proto index aa1bc8aac1f..8c312ec7120 100644 --- a/proto/osmosis/tokenfactory/v1beta1/tx.proto +++ b/proto/osmosis/tokenfactory/v1beta1/tx.proto @@ -4,14 +4,16 @@ package osmosis.tokenfactory.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/osmosis/x/tokenfactory/types"; +option go_package = "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types"; // Msg defines the Msg service. service Msg { rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); rpc Mint(MsgMint) returns (MsgMintResponse); rpc Burn(MsgBurn) returns (MsgBurnResponse); - rpc ForceTransfer(MsgForceTransfer) returns (MsgForceTransferResponse); + // ForceTransfer is deactivated for now because we need to think through edge + // cases rpc ForceTransfer(MsgForceTransfer) returns + // (MsgForceTransferResponse); rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); } @@ -52,20 +54,20 @@ message MsgBurn { message MsgBurnResponse {} -// ===================== MsgForceTransfer -message MsgForceTransfer { - string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; - cosmos.base.v1beta1.Coin amount = 2 [ - (gogoproto.moretags) = "yaml:\"amount\"", - (gogoproto.nullable) = false - ]; - string transferFromAddress = 3 - [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ]; - string transferToAddress = 4 - [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ]; -} +// // ===================== MsgForceTransfer +// message MsgForceTransfer { +// string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; +// cosmos.base.v1beta1.Coin amount = 2 [ +// (gogoproto.moretags) = "yaml:\"amount\"", +// (gogoproto.nullable) = false +// ]; +// string transferFromAddress = 3 +// [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ]; +// string transferToAddress = 4 +// [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ]; +// } -message MsgForceTransferResponse {} +// message MsgForceTransferResponse {} // ===================== MsgChangeAdmin message MsgChangeAdmin { diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index 05569796750..e2f8ce6b1c6 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -28,7 +28,7 @@ func GetTxCmd() *cobra.Command { NewCreateDenomCmd(), NewMintCmd(), NewBurnCmd(), - NewForceTransferCmd(), + // NewForceTransferCmd(), NewChangeAdminCmd(), ) @@ -128,39 +128,39 @@ func NewBurnCmd() *cobra.Command { return cmd } -// NewForceTransferCmd broadcast MsgForceTransfer -func NewForceTransferCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "force-transfer [amount] [transfer-from-address] [transfer-to-address] [flags]", - Short: "Force transfer tokens from one address to another address. Must have admin authority to do so.", - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - - amount, err := sdk.ParseCoinNormalized(args[0]) - if err != nil { - return err - } - - msg := types.NewMsgForceTransfer( - clientCtx.GetFromAddress().String(), - amount, - args[1], - args[2], - ) - - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - return cmd -} +// // NewForceTransferCmd broadcast MsgForceTransfer +// func NewForceTransferCmd() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "force-transfer [amount] [transfer-from-address] [transfer-to-address] [flags]", +// Short: "Force transfer tokens from one address to another address. Must have admin authority to do so.", +// Args: cobra.ExactArgs(3), +// RunE: func(cmd *cobra.Command, args []string) error { +// clientCtx, err := client.GetClientTxContext(cmd) +// if err != nil { +// return err +// } + +// txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + +// amount, err := sdk.ParseCoinNormalized(args[0]) +// if err != nil { +// return err +// } + +// msg := types.NewMsgForceTransfer( +// clientCtx.GetFromAddress().String(), +// amount, +// args[1], +// args[2], +// ) + +// return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) +// }, +// } + +// flags.AddTxFlagsToCmd(cmd) +// return cmd +// } // NewForceTransferCmd broadcast MsgForceTransfer func NewChangeAdminCmd() *cobra.Command { diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index 01c46c9a752..85f7c4e37ee 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -12,6 +12,8 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { addr1 := sdk.AccAddress([]byte("addr1---------------")) addr2 := sdk.AccAddress([]byte("addr2---------------")) + addr1bal := int64(0) + addr2bal := int64(0) msgServer := keeper.NewMsgServerImpl(*suite.app.TokenFactoryKeeper) @@ -29,24 +31,31 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { // Test minting to admins own account _, err = msgServer.Mint(sdk.WrapSDKContext(suite.ctx), types.NewMsgMint(addr1.String(), sdk.NewInt64Coin(denom, 10), addr1.String())) + addr1bal += 10 suite.Require().NoError(err) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 10)), suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom)) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).Amount.Int64() == addr1bal, suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom)) - // Test minting to a separate account + // Test minting to a separate account. Should not work. _, err = msgServer.Mint(sdk.WrapSDKContext(suite.ctx), types.NewMsgMint(addr1.String(), sdk.NewInt64Coin(denom, 10), addr2.String())) - suite.Require().NoError(err) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 10))) + suite.Require().Error(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).Amount.Int64() == addr2bal) + + // // Test force transferring + // _, err = msgServer.ForceTransfer(sdk.WrapSDKContext(suite.ctx), types.NewMsgForceTransfer(addr1.String(), sdk.NewInt64Coin(denom, 5), addr2.String(), addr1.String())) + // suite.Require().NoError(err) + // suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 15))) + // suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 5))) - // Test force transferring - _, err = msgServer.ForceTransfer(sdk.WrapSDKContext(suite.ctx), types.NewMsgForceTransfer(addr1.String(), sdk.NewInt64Coin(denom, 5), addr2.String(), addr1.String())) + // Test burning from own account + _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 5), addr1.String())) + addr1bal -= 5 suite.Require().NoError(err) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 15))) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 5))) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).Amount.Int64() == addr2bal) - // Test burning + // Test burning from a separate account. Should not work. _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 5), addr2.String())) - suite.Require().NoError(err) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).IsEqual(sdk.NewInt64Coin(denom, 0))) + suite.Require().Error(err) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).Amount.Int64() == addr2bal) // Test Change Admin _, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.ctx), types.NewMsgChangeAdmin(addr1.String(), denom, addr2.String())) @@ -56,14 +65,15 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { suite.Require().NoError(err) suite.Require().Equal(addr2.String(), queryRes.AuthorityMetadata.Admin) - // Make sure can no longer do actions - _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 15), addr1.String())) + // Make sure old admin can no longer do actions + _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr1.String(), sdk.NewInt64Coin(denom, 5), addr1.String())) suite.Require().Error(err) // Make sure the new admin works - _, err = msgServer.Burn(sdk.WrapSDKContext(suite.ctx), types.NewMsgBurn(addr2.String(), sdk.NewInt64Coin(denom, 15), addr1.String())) + _, err = msgServer.Mint(sdk.WrapSDKContext(suite.ctx), types.NewMsgMint(addr2.String(), sdk.NewInt64Coin(denom, 5), addr2.String())) + addr2bal += 5 suite.Require().NoError(err) - suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr1, denom).IsEqual(sdk.NewInt64Coin(denom, 0))) + suite.Require().True(suite.app.BankKeeper.GetBalance(suite.ctx, addr2, denom).Amount.Int64() == addr2bal) // Try setting admin to empty _, err = msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.ctx), types.NewMsgChangeAdmin(addr2.String(), denom, "")) diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 4592a5bc567..1e765953558 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/osmosis-labs/osmosis/v7/x/tokenfactory/types" ) @@ -53,6 +54,12 @@ func (server msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types. return nil, types.ErrUnauthorized } + // Temporary additional check that only allows sender to mint coins into their own account. + // This check will be removed in the future once edge cases can be worked out + if msg.Sender != msg.MintToAddress { + return nil, sdkerrors.Wrap(types.ErrUnauthorized, "MintToAddress must be the same as Sender address") + } + err = server.Keeper.mintTo(ctx, msg.Amount, msg.MintToAddress) if err != nil { return nil, err @@ -81,6 +88,12 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types. return nil, types.ErrUnauthorized } + // Temporary additional check that only allows sender to burn coins from their own account. + // This check will be removed in the future once edge cases can be worked out + if msg.Sender != msg.BurnFromAddress { + return nil, sdkerrors.Wrap(types.ErrUnauthorized, "BurnFromAddress must be the same as Sender address") + } + err = server.Keeper.burnFrom(ctx, msg.Amount, msg.GetBurnFromAddress()) if err != nil { return nil, err @@ -97,34 +110,34 @@ func (server msgServer) Burn(goCtx context.Context, msg *types.MsgBurn) (*types. return &types.MsgBurnResponse{}, nil } -func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForceTransfer) (*types.MsgForceTransferResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) - if err != nil { - return nil, err - } - - if msg.Sender != authorityMetadata.GetAdmin() { - return nil, types.ErrUnauthorized - } - - err = server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgForceTransfer, - sdk.NewAttribute(types.AttributeTransferFromAddress, msg.TransferFromAddress), - sdk.NewAttribute(types.AttributeTransferToAddress, msg.TransferToAddress), - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), - ), - }) - - return &types.MsgForceTransferResponse{}, nil -} +// func (server msgServer) ForceTransfer(goCtx context.Context, msg *types.MsgForceTransfer) (*types.MsgForceTransferResponse, error) { +// ctx := sdk.UnwrapSDKContext(goCtx) + +// authorityMetadata, err := server.Keeper.GetAuthorityMetadata(ctx, msg.Amount.GetDenom()) +// if err != nil { +// return nil, err +// } + +// if msg.Sender != authorityMetadata.GetAdmin() { +// return nil, types.ErrUnauthorized +// } + +// err = server.Keeper.forceTransfer(ctx, msg.Amount, msg.TransferFromAddress, msg.TransferToAddress) +// if err != nil { +// return nil, err +// } + +// ctx.EventManager().EmitEvents(sdk.Events{ +// sdk.NewEvent( +// types.TypeMsgForceTransfer, +// sdk.NewAttribute(types.AttributeTransferFromAddress, msg.TransferFromAddress), +// sdk.NewAttribute(types.AttributeTransferToAddress, msg.TransferToAddress), +// sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), +// ), +// }) + +// return &types.MsgForceTransferResponse{}, nil +// } func (server msgServer) ChangeAdmin(goCtx context.Context, msg *types.MsgChangeAdmin) (*types.MsgChangeAdminResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/tokenfactory/types/authorityMetadata.pb.go b/x/tokenfactory/types/authorityMetadata.pb.go index 4d285c1c829..6f45d94a9c3 100644 --- a/x/tokenfactory/types/authorityMetadata.pb.go +++ b/x/tokenfactory/types/authorityMetadata.pb.go @@ -25,6 +25,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type DenomAuthorityMetadata struct { + // Can be empty for no admin, or a valid osmosis address Admin string `protobuf:"bytes,1,opt,name=Admin,proto3" json:"Admin,omitempty" yaml:"admin"` } @@ -77,7 +78,7 @@ func init() { } var fileDescriptor_99435de88ae175f7 = []byte{ - // 236 bytes of a gzipped FileDescriptorProto + // 239 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xc9, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, 0xca, @@ -87,12 +88,12 @@ var fileDescriptor_99435de88ae175f7 = []byte{ 0xa7, 0xc2, 0x2d, 0x48, 0xce, 0xcf, 0xcc, 0x83, 0xc8, 0x2b, 0xb9, 0x71, 0x89, 0xb9, 0xa4, 0xe6, 0xe5, 0xe7, 0x3a, 0xa2, 0xdb, 0x29, 0xa4, 0xc6, 0xc5, 0xea, 0x98, 0x92, 0x9b, 0x99, 0x27, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0xf0, 0xe9, 0x9e, 0x3c, 0x4f, 0x65, 0x62, 0x6e, 0x8e, 0x95, - 0x52, 0x22, 0x48, 0x58, 0x29, 0x08, 0x22, 0x6d, 0xc5, 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x93, 0xdf, + 0x52, 0x22, 0x48, 0x58, 0x29, 0x08, 0x22, 0x6d, 0xc5, 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xe0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, - 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa4, 0x67, 0x96, 0x64, 0x94, + 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0xa0, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, - 0x57, 0xa0, 0x86, 0x42, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x79, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x9f, 0xc4, 0x39, 0x6f, 0x2a, 0x01, 0x00, 0x00, + 0x97, 0x99, 0xeb, 0x57, 0xa0, 0x06, 0x44, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x85, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x06, 0xef, 0xbb, 0x91, 0x2d, 0x01, 0x00, 0x00, } func (this *DenomAuthorityMetadata) Equal(that interface{}) bool { diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go index 19e53913815..6308a36fe5b 100644 --- a/x/tokenfactory/types/codec.go +++ b/x/tokenfactory/types/codec.go @@ -13,7 +13,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateDenom{}, "osmosis/tokenfactory/create-denom", nil) cdc.RegisterConcrete(&MsgMint{}, "osmosis/tokenfactory/mint", nil) cdc.RegisterConcrete(&MsgBurn{}, "osmosis/tokenfactory/burn", nil) - cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil) + // cdc.RegisterConcrete(&MsgForceTransfer{}, "osmosis/tokenfactory/force-transfer", nil) cdc.RegisterConcrete(&MsgChangeAdmin{}, "osmosis/tokenfactory/change-admin", nil) } @@ -23,7 +23,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgCreateDenom{}, &MsgMint{}, &MsgBurn{}, - &MsgForceTransfer{}, + // &MsgForceTransfer{}, &MsgChangeAdmin{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/tokenfactory/types/genesis.pb.go b/x/tokenfactory/types/genesis.pb.go index 06df2cfe9c5..7f7f10e2d1d 100644 --- a/x/tokenfactory/types/genesis.pb.go +++ b/x/tokenfactory/types/genesis.pb.go @@ -130,7 +130,7 @@ func init() { } var fileDescriptor_5749c3f71850298b = []byte{ - // 333 bytes of a gzipped FileDescriptorProto + // 336 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xca, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, @@ -146,12 +146,12 @@ var fileDescriptor_5749c3f71850298b = []byte{ 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0xf0, 0xe9, 0x9e, 0x3c, 0x0f, 0xc4, 0x3c, 0xb0, 0xb0, 0x52, 0x10, 0x44, 0x5a, 0xa8, 0x8d, 0x91, 0x4b, 0x08, 0xee, 0xbb, 0xf8, 0x5c, 0xa8, 0xf7, 0x24, 0x98, 0x14, 0x18, 0x35, 0xb8, 0x8d, 0x4c, 0xf0, 0xbb, 0x1a, 0x6c, 0x93, 0x23, 0x7a, 0xd0, 0x38, 0x29, 0x42, - 0xdd, 0x2f, 0x09, 0xb1, 0x0f, 0xd3, 0x74, 0xa5, 0x20, 0x41, 0x8c, 0x00, 0x85, 0xf8, 0xc3, 0xc9, - 0xef, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, - 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x4c, 0xd2, 0x33, 0x4b, 0x32, + 0xdd, 0x2f, 0x09, 0xb1, 0x0f, 0xd3, 0x74, 0xa5, 0x20, 0x41, 0x8c, 0x00, 0x85, 0xf8, 0xc3, 0x29, + 0xf0, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xcc, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xa1, 0xae, 0xd2, 0xcd, 0x49, 0x4c, 0x2a, 0x86, 0x71, - 0xf4, 0x2b, 0x50, 0xa3, 0xae, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x4f, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x96, 0xd9, 0xb1, 0x3f, 0x02, 0x00, 0x00, + 0xf4, 0xcb, 0xcc, 0xf5, 0x2b, 0x50, 0x63, 0xaf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, + 0x55, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xec, 0xfa, 0xc9, 0x97, 0x42, 0x02, 0x00, 0x00, } func (this *GenesisState) Equal(that interface{}) bool { diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index cda3d2ff0ac..753325e8579 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -129,50 +129,50 @@ func (m MsgBurn) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } -var _ sdk.Msg = &MsgForceTransfer{} - -// NewMsgForceTransfer creates a transfer funds from one account to another -func NewMsgForceTransfer(sender string, amount sdk.Coin, fromAddr, toAddr string) *MsgForceTransfer { - return &MsgForceTransfer{ - Sender: sender, - Amount: amount, - TransferFromAddress: fromAddr, - TransferToAddress: toAddr, - } -} - -func (m MsgForceTransfer) Route() string { return RouterKey } -func (m MsgForceTransfer) Type() string { return TypeMsgForceTransfer } -func (m MsgForceTransfer) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.Sender) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) - } - - _, err = sdk.AccAddressFromBech32(m.TransferFromAddress) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) - } - _, err = sdk.AccAddressFromBech32(m.TransferToAddress) - if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) - } - - if !m.Amount.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) - } - - return nil -} - -func (m MsgForceTransfer) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { - sender, _ := sdk.AccAddressFromBech32(m.Sender) - return []sdk.AccAddress{sender} -} +// var _ sdk.Msg = &MsgForceTransfer{} + +// // NewMsgForceTransfer creates a transfer funds from one account to another +// func NewMsgForceTransfer(sender string, amount sdk.Coin, fromAddr, toAddr string) *MsgForceTransfer { +// return &MsgForceTransfer{ +// Sender: sender, +// Amount: amount, +// TransferFromAddress: fromAddr, +// TransferToAddress: toAddr, +// } +// } + +// func (m MsgForceTransfer) Route() string { return RouterKey } +// func (m MsgForceTransfer) Type() string { return TypeMsgForceTransfer } +// func (m MsgForceTransfer) ValidateBasic() error { +// _, err := sdk.AccAddressFromBech32(m.Sender) +// if err != nil { +// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) +// } + +// _, err = sdk.AccAddressFromBech32(m.TransferFromAddress) +// if err != nil { +// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) +// } +// _, err = sdk.AccAddressFromBech32(m.TransferToAddress) +// if err != nil { +// return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) +// } + +// if !m.Amount.IsValid() { +// return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) +// } + +// return nil +// } + +// func (m MsgForceTransfer) GetSignBytes() []byte { +// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +// } + +// func (m MsgForceTransfer) GetSigners() []sdk.AccAddress { +// sender, _ := sdk.AccAddressFromBech32(m.Sender) +// return []sdk.AccAddress{sender} +// } var _ sdk.Msg = &MsgChangeAdmin{} diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index ae346e07f6a..30a0311d4eb 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -218,38 +218,38 @@ func init() { } var fileDescriptor_6f22013ad0f72e3f = []byte{ - // 488 bytes of a gzipped FileDescriptorProto + // 492 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x41, 0x6b, 0x13, 0x41, 0x14, 0xc7, 0x33, 0x96, 0x56, 0x1c, 0x15, 0xcc, 0x20, 0x52, 0x43, 0xdd, 0xd4, 0x11, 0xa4, 0x2a, - 0xee, 0xd0, 0x9a, 0x93, 0x55, 0x34, 0xa9, 0xe8, 0xc1, 0x2a, 0x98, 0xa3, 0x97, 0x30, 0x9b, 0x4e, - 0xb7, 0x8b, 0xd9, 0x7d, 0xdb, 0x99, 0x89, 0xb8, 0x94, 0x5e, 0x3c, 0x78, 0x16, 0xfc, 0x1e, 0x7e, - 0x0c, 0xe9, 0xb1, 0xd0, 0x8b, 0xa7, 0x20, 0x89, 0xf8, 0x01, 0xf2, 0x09, 0x24, 0x33, 0x93, 0x58, - 0xdd, 0x75, 0x2d, 0xf6, 0xb4, 0xc3, 0xbc, 0xff, 0xfb, 0xbf, 0xf7, 0x7b, 0x6f, 0x16, 0xaf, 0x80, - 0x8a, 0x41, 0x45, 0x8a, 0x69, 0x78, 0x23, 0x92, 0x6d, 0xde, 0xd5, 0x20, 0x33, 0xf6, 0x76, 0x35, - 0x10, 0x9a, 0xaf, 0xb2, 0xdd, 0xbe, 0x90, 0x99, 0x9f, 0x4a, 0xd0, 0x40, 0x96, 0x9c, 0xd2, 0x3f, - 0xae, 0xf4, 0x9d, 0xb2, 0x76, 0x39, 0x84, 0x10, 0x8c, 0x90, 0x4d, 0x4e, 0x36, 0xa7, 0xb6, 0x14, - 0x02, 0x84, 0x3d, 0xc1, 0x78, 0x1a, 0x31, 0x9e, 0x24, 0xa0, 0xb9, 0x8e, 0x20, 0x51, 0x2e, 0x7a, - 0xbb, 0x6b, 0x2c, 0x59, 0xc0, 0x95, 0xb0, 0xa5, 0x66, 0x85, 0x53, 0x1e, 0x46, 0x89, 0x11, 0x3b, - 0x6d, 0xa3, 0xb4, 0x4f, 0xde, 0xd7, 0x3b, 0x20, 0x23, 0x9d, 0xbd, 0x10, 0x9a, 0x6f, 0x71, 0xcd, - 0x6d, 0x16, 0xdd, 0xc4, 0xf4, 0xd5, 0xc4, 0xf7, 0x89, 0x48, 0x20, 0x6e, 0xfe, 0x29, 0x6a, 0x8b, - 0xdd, 0xbe, 0x50, 0x9a, 0xdc, 0xc4, 0xf3, 0x5b, 0x13, 0xc1, 0x22, 0x5a, 0x46, 0x2b, 0xe7, 0x5a, - 0x97, 0xc6, 0x83, 0xfa, 0x85, 0x8c, 0xc7, 0xbd, 0xfb, 0xd4, 0x5c, 0xd3, 0xb6, 0x0d, 0xd3, 0xcf, - 0x08, 0xdf, 0x28, 0xb5, 0x53, 0x29, 0x24, 0x4a, 0x90, 0x0f, 0x08, 0x93, 0x59, 0x47, 0x9d, 0xd8, - 0x85, 0x8d, 0xfb, 0xf9, 0xb5, 0x86, 0x5f, 0x36, 0x47, 0xbf, 0xd8, 0xba, 0x75, 0xfd, 0x60, 0x50, - 0xaf, 0x8c, 0x07, 0xf5, 0xab, 0xb6, 0xaf, 0xbc, 0x3b, 0x6d, 0x57, 0x73, 0x43, 0xa0, 0x9b, 0xf8, - 0xda, 0xaf, 0x7e, 0xd5, 0x53, 0x09, 0xf1, 0x86, 0x14, 0x5c, 0x83, 0x9c, 0x92, 0xdf, 0xc1, 0x67, - 0xbb, 0xf6, 0xc6, 0xb1, 0x57, 0xc7, 0x83, 0xfa, 0xc5, 0x63, 0xec, 0x8a, 0xb6, 0xa7, 0x0a, 0xfa, - 0x1c, 0x7b, 0x7f, 0x73, 0x73, 0xe0, 0xb7, 0xf0, 0x82, 0xcd, 0x5a, 0x44, 0xcb, 0x73, 0xc5, 0x6e, - 0x4e, 0xb0, 0xf6, 0x65, 0x0e, 0xcf, 0x1b, 0x37, 0xf2, 0x03, 0xe1, 0x2b, 0xc5, 0xd4, 0xe4, 0x71, - 0xf9, 0xac, 0xfe, 0xbd, 0xda, 0x5a, 0xf3, 0x14, 0x0e, 0x16, 0x8a, 0x3e, 0x7b, 0x7f, 0xf4, 0xfd, - 0xd3, 0x99, 0x26, 0x79, 0xc4, 0x4a, 0x9f, 0xa0, 0xe5, 0x62, 0x7b, 0xe6, 0xbb, 0xcf, 0xf2, 0x1b, - 0x22, 0x47, 0x08, 0x57, 0x73, 0xb3, 0x23, 0xeb, 0x27, 0xed, 0xb0, 0x60, 0x7f, 0xb5, 0x07, 0xff, - 0x97, 0xec, 0xc8, 0x36, 0x0c, 0xd9, 0x43, 0xb2, 0x7e, 0x12, 0xb2, 0xce, 0xb6, 0x84, 0xb8, 0xe3, - 0xde, 0x02, 0xdb, 0x73, 0x87, 0xfd, 0xd6, 0xcb, 0x83, 0xa1, 0x87, 0x0e, 0x87, 0x1e, 0xfa, 0x36, - 0xf4, 0xd0, 0xc7, 0x91, 0x57, 0x39, 0x1c, 0x79, 0x95, 0xaf, 0x23, 0xaf, 0xf2, 0xba, 0x11, 0x46, - 0x7a, 0xa7, 0x1f, 0xf8, 0x5d, 0x88, 0xa7, 0x05, 0xee, 0xf6, 0x78, 0xa0, 0x66, 0xd5, 0xde, 0xfd, - 0x5e, 0x4f, 0x67, 0xa9, 0x50, 0xc1, 0x82, 0xf9, 0x73, 0xef, 0xfd, 0x0c, 0x00, 0x00, 0xff, 0xff, - 0x38, 0x95, 0x3d, 0x51, 0x99, 0x04, 0x00, 0x00, + 0xee, 0xd0, 0x5a, 0x28, 0x58, 0x45, 0x93, 0x8a, 0x1e, 0xac, 0x87, 0xe6, 0xe8, 0x25, 0xcc, 0xa6, + 0xd3, 0xed, 0x62, 0x76, 0xdf, 0x76, 0x66, 0x52, 0x5c, 0x4a, 0x2f, 0x1e, 0x3c, 0x0b, 0x7e, 0x0f, + 0x3f, 0x86, 0xf4, 0x58, 0xe8, 0xc5, 0x53, 0x90, 0x44, 0xfc, 0x00, 0xf9, 0x04, 0x92, 0x99, 0x49, + 0xac, 0xee, 0xba, 0x16, 0x3d, 0xed, 0x30, 0xef, 0xff, 0xfe, 0xef, 0xfd, 0xde, 0x9b, 0xc5, 0x4b, + 0xa0, 0x62, 0x50, 0x91, 0x62, 0x1a, 0xde, 0x88, 0x64, 0x87, 0x77, 0x34, 0xc8, 0x8c, 0xed, 0x2f, + 0x07, 0x42, 0xf3, 0x65, 0xb6, 0xd7, 0x13, 0x32, 0xf3, 0x53, 0x09, 0x1a, 0xc8, 0x82, 0x53, 0xfa, + 0xa7, 0x95, 0xbe, 0x53, 0xd6, 0xae, 0x86, 0x10, 0x82, 0x11, 0xb2, 0xf1, 0xc9, 0xe6, 0xd4, 0x16, + 0x42, 0x80, 0xb0, 0x2b, 0x18, 0x4f, 0x23, 0xc6, 0x93, 0x04, 0x34, 0xd7, 0x11, 0x24, 0xca, 0x45, + 0xef, 0x76, 0x8c, 0x25, 0x0b, 0xb8, 0x12, 0xb6, 0xd4, 0xb4, 0x70, 0xca, 0xc3, 0x28, 0x31, 0x62, + 0xa7, 0x5d, 0x2d, 0xed, 0x93, 0xf7, 0xf4, 0x2e, 0xc8, 0x48, 0x67, 0xaf, 0x84, 0xe6, 0xdb, 0x5c, + 0x73, 0x9b, 0x45, 0x37, 0x31, 0xdd, 0x1a, 0xfb, 0x3e, 0x13, 0x09, 0xc4, 0x8d, 0xdf, 0x45, 0x2d, + 0xb1, 0xd7, 0x13, 0x4a, 0x93, 0xdb, 0x78, 0x76, 0x7b, 0x2c, 0x98, 0x47, 0x8b, 0x68, 0xe9, 0x42, + 0xf3, 0xca, 0xa8, 0x5f, 0xbf, 0x94, 0xf1, 0xb8, 0xfb, 0x90, 0x9a, 0x6b, 0xda, 0xb2, 0x61, 0xfa, + 0x09, 0xe1, 0x5b, 0xa5, 0x76, 0x2a, 0x85, 0x44, 0x09, 0xf2, 0x1e, 0x61, 0x32, 0xed, 0xa8, 0x1d, + 0xbb, 0xb0, 0x71, 0xbf, 0xb8, 0xb2, 0xea, 0x97, 0xcd, 0xd1, 0x2f, 0xb6, 0x6e, 0xde, 0x3c, 0xea, + 0xd7, 0x2b, 0xa3, 0x7e, 0xfd, 0xba, 0xed, 0x2b, 0xef, 0x4e, 0x5b, 0xd5, 0xdc, 0x10, 0xe8, 0x26, + 0xbe, 0xf1, 0xb3, 0x5f, 0xf5, 0x5c, 0x42, 0xbc, 0x21, 0x05, 0xd7, 0x20, 0x27, 0xe4, 0xf7, 0xf0, + 0xf9, 0x8e, 0xbd, 0x71, 0xec, 0xd5, 0x51, 0xbf, 0x7e, 0xf9, 0x14, 0xbb, 0xa2, 0xad, 0x89, 0x82, + 0xbe, 0xc4, 0xde, 0x9f, 0xdc, 0x1c, 0xf8, 0x1d, 0x3c, 0x67, 0xb3, 0xe6, 0xd1, 0xe2, 0x4c, 0xb1, + 0x9b, 0x13, 0xac, 0x7c, 0x9e, 0xc1, 0xb3, 0xc6, 0x8d, 0x7c, 0x47, 0xf8, 0x5a, 0x31, 0x35, 0x79, + 0x5a, 0x3e, 0xab, 0xbf, 0xaf, 0xb6, 0xd6, 0xf8, 0x0f, 0x07, 0x0b, 0x45, 0x5f, 0xbc, 0x3b, 0xf9, + 0xf6, 0xf1, 0x5c, 0x83, 0x3c, 0x61, 0xa5, 0x4f, 0xd0, 0x72, 0xb1, 0x03, 0xf3, 0x3d, 0x64, 0xf9, + 0x0d, 0x91, 0x13, 0x84, 0xab, 0xb9, 0xd9, 0x91, 0xf5, 0xb3, 0x76, 0x58, 0xb0, 0xbf, 0xda, 0xa3, + 0x7f, 0x4b, 0x76, 0x64, 0x1b, 0x86, 0xec, 0x31, 0x59, 0x3f, 0x0b, 0x59, 0x7b, 0x47, 0x42, 0xdc, + 0x76, 0x6f, 0x81, 0x1d, 0xb8, 0xc3, 0x61, 0x73, 0xeb, 0x68, 0xe0, 0xa1, 0xe3, 0x81, 0x87, 0xbe, + 0x0e, 0x3c, 0xf4, 0x61, 0xe8, 0x55, 0x8e, 0x87, 0x5e, 0xe5, 0xcb, 0xd0, 0xab, 0xbc, 0x5e, 0x0b, + 0x23, 0xbd, 0xdb, 0x0b, 0xfc, 0x0e, 0xc4, 0x93, 0x02, 0xf7, 0xbb, 0x3c, 0x50, 0xd3, 0x6a, 0xfb, + 0x6b, 0xec, 0xed, 0xaf, 0x25, 0x75, 0x96, 0x0a, 0x15, 0xcc, 0x99, 0x9f, 0xf7, 0xc1, 0x8f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xd1, 0x0c, 0x41, 0xe9, 0x9c, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index d5b28f7b21b..5180fd9b254 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -320,111 +320,6 @@ func (m *MsgBurnResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo -// ===================== MsgForceTransfer -type MsgForceTransfer struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount" yaml:"amount"` - TransferFromAddress string `protobuf:"bytes,3,opt,name=transferFromAddress,proto3" json:"transferFromAddress,omitempty" yaml:"transfer_from_address"` - TransferToAddress string `protobuf:"bytes,4,opt,name=transferToAddress,proto3" json:"transferToAddress,omitempty" yaml:"transfer_to_address"` -} - -func (m *MsgForceTransfer) Reset() { *m = MsgForceTransfer{} } -func (m *MsgForceTransfer) String() string { return proto.CompactTextString(m) } -func (*MsgForceTransfer) ProtoMessage() {} -func (*MsgForceTransfer) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{6} -} -func (m *MsgForceTransfer) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgForceTransfer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgForceTransfer.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 *MsgForceTransfer) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgForceTransfer.Merge(m, src) -} -func (m *MsgForceTransfer) XXX_Size() int { - return m.Size() -} -func (m *MsgForceTransfer) XXX_DiscardUnknown() { - xxx_messageInfo_MsgForceTransfer.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgForceTransfer proto.InternalMessageInfo - -func (m *MsgForceTransfer) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgForceTransfer) GetAmount() types.Coin { - if m != nil { - return m.Amount - } - return types.Coin{} -} - -func (m *MsgForceTransfer) GetTransferFromAddress() string { - if m != nil { - return m.TransferFromAddress - } - return "" -} - -func (m *MsgForceTransfer) GetTransferToAddress() string { - if m != nil { - return m.TransferToAddress - } - return "" -} - -type MsgForceTransferResponse struct { -} - -func (m *MsgForceTransferResponse) Reset() { *m = MsgForceTransferResponse{} } -func (m *MsgForceTransferResponse) String() string { return proto.CompactTextString(m) } -func (*MsgForceTransferResponse) ProtoMessage() {} -func (*MsgForceTransferResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{7} -} -func (m *MsgForceTransferResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgForceTransferResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgForceTransferResponse.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 *MsgForceTransferResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgForceTransferResponse.Merge(m, src) -} -func (m *MsgForceTransferResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgForceTransferResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgForceTransferResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgForceTransferResponse proto.InternalMessageInfo - // ===================== MsgChangeAdmin type MsgChangeAdmin struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` @@ -436,7 +331,7 @@ func (m *MsgChangeAdmin) Reset() { *m = MsgChangeAdmin{} } func (m *MsgChangeAdmin) String() string { return proto.CompactTextString(m) } func (*MsgChangeAdmin) ProtoMessage() {} func (*MsgChangeAdmin) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{8} + return fileDescriptor_283b6c9a90a846b4, []int{6} } func (m *MsgChangeAdmin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,7 +388,7 @@ func (m *MsgChangeAdminResponse) Reset() { *m = MsgChangeAdminResponse{} func (m *MsgChangeAdminResponse) String() string { return proto.CompactTextString(m) } func (*MsgChangeAdminResponse) ProtoMessage() {} func (*MsgChangeAdminResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_283b6c9a90a846b4, []int{9} + return fileDescriptor_283b6c9a90a846b4, []int{7} } func (m *MsgChangeAdminResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -529,8 +424,6 @@ func init() { proto.RegisterType((*MsgMintResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgMintResponse") proto.RegisterType((*MsgBurn)(nil), "osmosis.tokenfactory.v1beta1.MsgBurn") proto.RegisterType((*MsgBurnResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgBurnResponse") - proto.RegisterType((*MsgForceTransfer)(nil), "osmosis.tokenfactory.v1beta1.MsgForceTransfer") - proto.RegisterType((*MsgForceTransferResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgForceTransferResponse") proto.RegisterType((*MsgChangeAdmin)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdmin") proto.RegisterType((*MsgChangeAdminResponse)(nil), "osmosis.tokenfactory.v1beta1.MsgChangeAdminResponse") } @@ -540,48 +433,43 @@ func init() { } var fileDescriptor_283b6c9a90a846b4 = []byte{ - // 646 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4f, 0x4f, 0xd4, 0x4e, - 0x18, 0xde, 0x02, 0x3f, 0x7e, 0x3a, 0xb8, 0x02, 0x15, 0x49, 0x6d, 0x48, 0x4b, 0x26, 0xc1, 0x68, - 0x22, 0xad, 0x20, 0xf1, 0xe0, 0x49, 0x16, 0x43, 0x3c, 0xb8, 0x1e, 0x1a, 0x4e, 0x86, 0x64, 0xd3, - 0x76, 0x87, 0xd2, 0x48, 0x67, 0x70, 0x66, 0xd6, 0x85, 0x6f, 0xe1, 0xc5, 0xbb, 0x57, 0xbf, 0x85, - 0x27, 0xc3, 0x91, 0xa3, 0xa7, 0xc6, 0xc0, 0x37, 0xe8, 0x27, 0x30, 0x9d, 0x99, 0xfe, 0xdb, 0x35, - 0xb2, 0x7b, 0xe2, 0xb6, 0x3b, 0xef, 0xf3, 0x3c, 0x33, 0xcf, 0x3b, 0xf3, 0xbc, 0x05, 0x1b, 0x84, - 0x25, 0x84, 0xc5, 0xcc, 0xe5, 0xe4, 0x23, 0xc2, 0x47, 0x7e, 0xc8, 0x09, 0x3d, 0x77, 0x3f, 0x6f, - 0x05, 0x88, 0xfb, 0x5b, 0x2e, 0x3f, 0x73, 0x4e, 0x29, 0xe1, 0x44, 0x5f, 0x53, 0x30, 0xa7, 0x0e, - 0x73, 0x14, 0xcc, 0x5c, 0x89, 0x48, 0x44, 0x04, 0xd0, 0xcd, 0x7f, 0x49, 0x8e, 0x69, 0x85, 0x82, - 0xe4, 0x06, 0x3e, 0x43, 0xa5, 0x62, 0x48, 0x62, 0x2c, 0xeb, 0x30, 0x04, 0xf7, 0xbb, 0x2c, 0xda, - 0xa3, 0xc8, 0xe7, 0xe8, 0x0d, 0xc2, 0x24, 0xd1, 0x9f, 0x82, 0x79, 0x86, 0x70, 0x1f, 0x51, 0x43, - 0x5b, 0xd7, 0x9e, 0xdc, 0xed, 0x2c, 0x67, 0xa9, 0xdd, 0x3e, 0xf7, 0x93, 0x93, 0x57, 0x50, 0xae, - 0x43, 0x4f, 0x01, 0xf4, 0xc7, 0xe0, 0x3f, 0x4c, 0x70, 0x88, 0x8c, 0x19, 0x81, 0x5c, 0xca, 0x52, - 0xfb, 0x9e, 0x44, 0x8a, 0x65, 0xe8, 0xc9, 0x32, 0x3c, 0x04, 0xab, 0xcd, 0x4d, 0x3c, 0xc4, 0x4e, - 0x09, 0x66, 0x48, 0xef, 0x80, 0x45, 0x8c, 0x86, 0x3d, 0x61, 0xa8, 0xd7, 0xcf, 0x4b, 0x6a, 0x57, - 0x33, 0x4b, 0xed, 0x55, 0xa5, 0xd5, 0x04, 0x40, 0xaf, 0x8d, 0xd1, 0xf0, 0x20, 0x5f, 0x10, 0x5a, - 0xf0, 0x87, 0x06, 0xfe, 0xef, 0xb2, 0xa8, 0x1b, 0x63, 0x3e, 0xcd, 0xe1, 0xdf, 0x82, 0x79, 0x3f, - 0x21, 0x03, 0xcc, 0xc5, 0xe9, 0x17, 0xb6, 0x1f, 0x39, 0xb2, 0x55, 0x4e, 0xde, 0xaa, 0xa2, 0xab, - 0xce, 0x1e, 0x89, 0x71, 0xe7, 0xe1, 0x45, 0x6a, 0xb7, 0x2a, 0x25, 0x49, 0x83, 0x9e, 0xe2, 0xeb, - 0xaf, 0x41, 0x3b, 0x89, 0x31, 0x3f, 0x20, 0xbb, 0xfd, 0x3e, 0x45, 0x8c, 0x19, 0xb3, 0xa3, 0x16, - 0xf2, 0x72, 0x8f, 0x93, 0x9e, 0x2f, 0x01, 0xd0, 0x6b, 0x12, 0xe0, 0x32, 0x58, 0x54, 0x0e, 0x8a, - 0xce, 0xc0, 0x9f, 0xd2, 0x55, 0x67, 0x40, 0xf1, 0xed, 0xb8, 0xda, 0x07, 0x8b, 0xc1, 0x80, 0xe2, - 0x7d, 0x4a, 0x92, 0xa6, 0xaf, 0xb5, 0x2c, 0xb5, 0x0d, 0xc9, 0xc9, 0x01, 0xbd, 0x23, 0x4a, 0x92, - 0xca, 0xd9, 0x28, 0x49, 0x79, 0xcb, 0x7d, 0x94, 0xde, 0xbe, 0xcf, 0x80, 0xa5, 0x2e, 0x8b, 0xf6, - 0x09, 0x0d, 0xd1, 0x01, 0xf5, 0x31, 0x3b, 0x42, 0xf4, 0x76, 0x4c, 0x7a, 0xe0, 0x01, 0x57, 0x07, - 0x18, 0x37, 0xba, 0x9e, 0xa5, 0xf6, 0x9a, 0xe4, 0x15, 0xa0, 0x11, 0xb3, 0x7f, 0x23, 0xeb, 0xef, - 0xc0, 0x72, 0xb1, 0x5c, 0x3d, 0x89, 0x39, 0xa1, 0x68, 0x65, 0xa9, 0x6d, 0x8e, 0x28, 0xd6, 0x9f, - 0xc5, 0x38, 0x11, 0x9a, 0xc0, 0x18, 0x6d, 0x55, 0xd9, 0xc7, 0xaf, 0x9a, 0x4c, 0xef, 0xb1, 0x8f, - 0x23, 0xb4, 0xdb, 0x4f, 0x62, 0x3c, 0x65, 0x7a, 0x65, 0xe2, 0xc6, 0xd2, 0xab, 0x72, 0x26, 0xcb, - 0xfa, 0x73, 0x70, 0x07, 0xa3, 0xa1, 0x90, 0x57, 0x8d, 0x59, 0xc9, 0x52, 0x7b, 0xa9, 0x0a, 0xa7, - 0x9f, 0x97, 0xa0, 0x57, 0xa2, 0xa0, 0x21, 0xf3, 0x5e, 0x1d, 0xab, 0x38, 0xf1, 0xf6, 0xb7, 0x39, - 0x30, 0xdb, 0x65, 0x91, 0xfe, 0x09, 0x2c, 0xd4, 0x67, 0xce, 0x33, 0xe7, 0x5f, 0xa3, 0xcd, 0x69, - 0x0e, 0x0f, 0x73, 0x67, 0x1a, 0x74, 0x39, 0x6a, 0x0e, 0xc1, 0x9c, 0x18, 0x11, 0x1b, 0x37, 0xb2, - 0x73, 0x98, 0xb9, 0x39, 0x11, 0xac, 0xae, 0x2e, 0xa2, 0x7a, 0xb3, 0x7a, 0x0e, 0x9b, 0x40, 0xbd, - 0x1e, 0x18, 0x7d, 0x08, 0xda, 0xcd, 0xb0, 0x38, 0x37, 0xf2, 0x1b, 0x78, 0xf3, 0xe5, 0x74, 0xf8, - 0x72, 0xe3, 0xfc, 0x9e, 0x6a, 0xaf, 0x6b, 0x82, 0x7b, 0xaa, 0xd0, 0x93, 0xdc, 0xd3, 0xf8, 0x13, - 0xe9, 0xbc, 0xbf, 0xb8, 0xb2, 0xb4, 0xcb, 0x2b, 0x4b, 0xfb, 0x7d, 0x65, 0x69, 0x5f, 0xae, 0xad, - 0xd6, 0xe5, 0xb5, 0xd5, 0xfa, 0x75, 0x6d, 0xb5, 0x3e, 0xec, 0x44, 0x31, 0x3f, 0x1e, 0x04, 0x4e, - 0x48, 0x12, 0x57, 0x29, 0x6f, 0x9e, 0xf8, 0x01, 0x2b, 0xfe, 0xb8, 0x67, 0xcd, 0x0f, 0x28, 0x3f, - 0x3f, 0x45, 0x2c, 0x98, 0x17, 0x1f, 0xba, 0x17, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x21, 0x60, - 0x04, 0xa5, 0x65, 0x07, 0x00, 0x00, + // 563 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0x6e, 0x28, 0x14, 0xf0, 0x28, 0xdd, 0xa2, 0x31, 0x95, 0x6a, 0x4a, 0x90, 0xa5, 0x21, 0x90, + 0x58, 0xc2, 0x06, 0xd2, 0x24, 0x4e, 0xac, 0x43, 0x13, 0x97, 0x1e, 0x88, 0x76, 0x42, 0x93, 0x2a, + 0x27, 0xf1, 0xb2, 0x88, 0xc5, 0x2e, 0xb1, 0xbb, 0xae, 0x6f, 0xc1, 0x85, 0x67, 0xe0, 0x35, 0x38, + 0xa1, 0x1d, 0x77, 0xe4, 0x14, 0xa1, 0xf6, 0x0d, 0xf2, 0x04, 0xc8, 0x7f, 0xda, 0x24, 0x9b, 0xc4, + 0xda, 0x13, 0xb7, 0xc4, 0xbf, 0xef, 0xfb, 0xfc, 0xfb, 0x7e, 0xfe, 0x6c, 0xb0, 0x45, 0x59, 0x42, + 0x59, 0xcc, 0x5c, 0x4e, 0xbf, 0x60, 0x72, 0x82, 0x02, 0x4e, 0xd3, 0xb1, 0x7b, 0xbe, 0xe3, 0x63, + 0x8e, 0x76, 0x5c, 0x7e, 0xe1, 0x0c, 0x52, 0xca, 0xa9, 0xb9, 0xa9, 0x61, 0x4e, 0x19, 0xe6, 0x68, + 0x58, 0x67, 0x3d, 0xa2, 0x11, 0x95, 0x40, 0x57, 0x7c, 0x29, 0x4e, 0xc7, 0x0a, 0x24, 0xc9, 0xf5, + 0x11, 0xc3, 0x73, 0xc5, 0x80, 0xc6, 0x44, 0xd5, 0x61, 0x00, 0x1e, 0xf7, 0x58, 0x74, 0x90, 0x62, + 0xc4, 0xf1, 0x07, 0x4c, 0x68, 0x62, 0xbe, 0x04, 0x0d, 0x86, 0x49, 0x88, 0xd3, 0xb6, 0xf1, 0xcc, + 0x78, 0xf1, 0xb0, 0xbb, 0x96, 0x67, 0x76, 0x73, 0x8c, 0x92, 0xb3, 0x77, 0x50, 0xad, 0x43, 0x4f, + 0x03, 0xcc, 0xe7, 0xe0, 0x1e, 0xa1, 0x24, 0xc0, 0xed, 0x3b, 0x12, 0xb9, 0x9a, 0x67, 0xf6, 0x23, + 0x85, 0x94, 0xcb, 0xd0, 0x53, 0x65, 0x78, 0x0c, 0x36, 0xaa, 0x9b, 0x78, 0x98, 0x0d, 0x28, 0x61, + 0xd8, 0xec, 0x82, 0x16, 0xc1, 0xa3, 0xbe, 0x34, 0xd4, 0x0f, 0x45, 0x49, 0xef, 0xda, 0xc9, 0x33, + 0x7b, 0x43, 0x6b, 0x55, 0x01, 0xd0, 0x6b, 0x12, 0x3c, 0x3a, 0x12, 0x0b, 0x52, 0x0b, 0xfe, 0x34, + 0xc0, 0xfd, 0x1e, 0x8b, 0x7a, 0x31, 0xe1, 0xcb, 0x34, 0xff, 0x11, 0x34, 0x50, 0x42, 0x87, 0x84, + 0xcb, 0xee, 0x57, 0x76, 0x9f, 0x3a, 0x6a, 0x54, 0x8e, 0x18, 0xd5, 0x6c, 0xaa, 0xce, 0x01, 0x8d, + 0x49, 0xf7, 0xc9, 0x65, 0x66, 0xd7, 0x0a, 0x25, 0x45, 0x83, 0x9e, 0xe6, 0x9b, 0xef, 0x41, 0x33, + 0x89, 0x09, 0x3f, 0xa2, 0xfb, 0x61, 0x98, 0x62, 0xc6, 0xda, 0xf5, 0xeb, 0x16, 0x44, 0xb9, 0xcf, + 0x69, 0x1f, 0x29, 0x00, 0xf4, 0xaa, 0x04, 0xb8, 0x06, 0x5a, 0xda, 0xc1, 0x6c, 0x32, 0xf0, 0x97, + 0x72, 0xd5, 0x1d, 0xa6, 0xe4, 0xff, 0xb8, 0x3a, 0x04, 0x2d, 0x7f, 0x98, 0x92, 0xc3, 0x94, 0x26, + 0x55, 0x5f, 0x9b, 0x79, 0x66, 0xb7, 0x15, 0x47, 0x00, 0xfa, 0x27, 0x29, 0x4d, 0x0a, 0x67, 0xd7, + 0x49, 0xda, 0x9b, 0xf0, 0x31, 0xf7, 0xf6, 0xdd, 0x50, 0xa9, 0x3b, 0x45, 0x24, 0xc2, 0xfb, 0x61, + 0x12, 0x93, 0x25, 0x53, 0xa7, 0x92, 0x72, 0x23, 0x75, 0x3a, 0x1f, 0xaa, 0x6c, 0xbe, 0x06, 0x0f, + 0x08, 0x1e, 0x49, 0x79, 0xdd, 0xf9, 0x7a, 0x9e, 0xd9, 0xab, 0x45, 0xa8, 0x90, 0x28, 0x41, 0x6f, + 0x8e, 0x82, 0x6d, 0x95, 0xd3, 0xa2, 0xad, 0x59, 0xc7, 0xbb, 0x3f, 0xea, 0xa0, 0xde, 0x63, 0x91, + 0xf9, 0x15, 0xac, 0x94, 0xef, 0xca, 0x2b, 0xe7, 0x5f, 0x57, 0xd2, 0xa9, 0x86, 0xbe, 0xf3, 0x76, + 0x19, 0xf4, 0xfc, 0x8a, 0x1c, 0x83, 0xbb, 0x32, 0xda, 0x5b, 0xb7, 0xb2, 0x05, 0xac, 0xb3, 0xbd, + 0x10, 0xac, 0xac, 0x2e, 0x23, 0x76, 0xbb, 0xba, 0x80, 0x2d, 0xa0, 0x5e, 0x3e, 0x68, 0x39, 0xae, + 0xd2, 0x21, 0x2f, 0x30, 0xae, 0x02, 0xbd, 0xc8, 0xb8, 0x6e, 0x9e, 0x54, 0xf7, 0xd3, 0xe5, 0xc4, + 0x32, 0xae, 0x26, 0x96, 0xf1, 0x67, 0x62, 0x19, 0xdf, 0xa6, 0x56, 0xed, 0x6a, 0x6a, 0xd5, 0x7e, + 0x4f, 0xad, 0xda, 0xe7, 0xbd, 0x28, 0xe6, 0xa7, 0x43, 0xdf, 0x09, 0x68, 0xe2, 0x6a, 0xe5, 0xed, + 0x33, 0xe4, 0xb3, 0xd9, 0x8f, 0x7b, 0xbe, 0xe7, 0x5e, 0x54, 0x9f, 0x60, 0x3e, 0x1e, 0x60, 0xe6, + 0x37, 0xe4, 0x53, 0xf9, 0xe6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x4a, 0x5e, 0xb4, 0xa7, + 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -599,7 +487,9 @@ 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(ctx context.Context, in *MsgForceTransfer, opts ...grpc.CallOption) (*MsgForceTransferResponse, 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) } @@ -638,15 +528,6 @@ func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOpti return out, nil } -func (c *msgClient) ForceTransfer(ctx context.Context, in *MsgForceTransfer, opts ...grpc.CallOption) (*MsgForceTransferResponse, error) { - out := new(MsgForceTransferResponse) - err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/ForceTransfer", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *msgClient) ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) { out := new(MsgChangeAdminResponse) err := c.cc.Invoke(ctx, "/osmosis.tokenfactory.v1beta1.Msg/ChangeAdmin", in, out, opts...) @@ -661,7 +542,9 @@ type MsgServer interface { CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) Mint(context.Context, *MsgMint) (*MsgMintResponse, error) Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) - ForceTransfer(context.Context, *MsgForceTransfer) (*MsgForceTransferResponse, 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) } @@ -678,9 +561,6 @@ func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMint func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") } -func (*UnimplementedMsgServer) ForceTransfer(ctx context.Context, req *MsgForceTransfer) (*MsgForceTransferResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ForceTransfer not implemented") -} func (*UnimplementedMsgServer) ChangeAdmin(ctx context.Context, req *MsgChangeAdmin) (*MsgChangeAdminResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChangeAdmin not implemented") } @@ -743,24 +623,6 @@ func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{ return interceptor(ctx, in, info, handler) } -func _Msg_ForceTransfer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgForceTransfer) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ForceTransfer(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.tokenfactory.v1beta1.Msg/ForceTransfer", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ForceTransfer(ctx, req.(*MsgForceTransfer)) - } - return interceptor(ctx, in, info, handler) -} - func _Msg_ChangeAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgChangeAdmin) if err := dec(in); err != nil { @@ -795,10 +657,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Burn", Handler: _Msg_Burn_Handler, }, - { - MethodName: "ForceTransfer", - Handler: _Msg_ForceTransfer_Handler, - }, { MethodName: "ChangeAdmin", Handler: _Msg_ChangeAdmin_Handler, @@ -1015,83 +873,6 @@ func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgForceTransfer) 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 *MsgForceTransfer) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgForceTransfer) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.TransferToAddress) > 0 { - i -= len(m.TransferToAddress) - copy(dAtA[i:], m.TransferToAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.TransferToAddress))) - i-- - dAtA[i] = 0x22 - } - if len(m.TransferFromAddress) > 0 { - i -= len(m.TransferFromAddress) - copy(dAtA[i:], m.TransferFromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.TransferFromAddress))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgForceTransferResponse) 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 *MsgForceTransferResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgForceTransferResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func (m *MsgChangeAdmin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1256,38 +1037,6 @@ func (m *MsgBurnResponse) Size() (n int) { return n } -func (m *MsgForceTransfer) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.TransferFromAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.TransferToAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgForceTransferResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *MsgChangeAdmin) Size() (n int) { if m == nil { return 0 @@ -1914,235 +1663,6 @@ func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgForceTransfer) 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: MsgForceTransfer: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgForceTransfer: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransferFromAddress", 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.TransferFromAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransferToAddress", 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.TransferToAddress = 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 *MsgForceTransferResponse) 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: MsgForceTransferResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgForceTransferResponse: 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 *MsgChangeAdmin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From b119d48cfdd7cdb805b670748b15563489ff81fd Mon Sep 17 00:00:00 2001 From: Sunny Aggarwal Date: Sat, 23 Apr 2022 16:10:47 -0400 Subject: [PATCH 22/22] add check for no slashes in creator address --- x/tokenfactory/keeper/createdenom_test.go | 4 ++++ x/tokenfactory/types/denoms.go | 3 +++ x/tokenfactory/types/errors.go | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 7d25a9d5d8c..a74b8066954 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -47,4 +47,8 @@ func (suite *KeeperTestSuite) TestMsgCreateDenom() { res, err = msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom(addr2.String(), "bitcoin")) suite.Require().NoError(err) suite.Require().NotEmpty(res.GetNewTokenDenom()) + + // Make sure that an address with a "/" in it can't create denoms + res, err = msgServer.CreateDenom(sdk.WrapSDKContext(suite.ctx), types.NewMsgCreateDenom("osmosis.eth/creator", "bitcoin")) + suite.Require().Error(err) } diff --git a/x/tokenfactory/types/denoms.go b/x/tokenfactory/types/denoms.go index b4b6eaa50b6..892122606ae 100644 --- a/x/tokenfactory/types/denoms.go +++ b/x/tokenfactory/types/denoms.go @@ -12,6 +12,9 @@ const ( ) func GetTokenDenom(creator, nonce string) (string, error) { + if strings.Contains(creator, "/") { + return "", ErrInvalidCreator + } denom := strings.Join([]string{ModuleDenomPrefix, creator, nonce}, "/") return denom, sdk.ValidateDenom(denom) } diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go index b90cfd92deb..cb6e7c23d41 100644 --- a/x/tokenfactory/types/errors.go +++ b/x/tokenfactory/types/errors.go @@ -11,6 +11,7 @@ var ( ErrDenomExists = sdkerrors.Register(ModuleName, 1, "denom already exists") ErrUnauthorized = sdkerrors.Register(ModuleName, 2, "unauthorized account") ErrInvalidDenom = sdkerrors.Register(ModuleName, 3, "invalid denom") - ErrInvalidAuthorityMetadata = sdkerrors.Register(ModuleName, 4, "invalid authority metadata") - ErrInvalidGenesis = sdkerrors.Register(ModuleName, 5, "invalid genesis") + ErrInvalidCreator = sdkerrors.Register(ModuleName, 4, "invalid creator") + ErrInvalidAuthorityMetadata = sdkerrors.Register(ModuleName, 5, "invalid authority metadata") + ErrInvalidGenesis = sdkerrors.Register(ModuleName, 6, "invalid genesis") )