From 839c8c2002ea77ea8ecfa083a6fcade0f03041fe Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:28:32 -0500 Subject: [PATCH 01/10] feat(app)!: wasm snapshot export is mandatory (#1616) * feat(app)!: wasm snapshot export is mandatory * changelog * refacotr: unindent else block --- CHANGELOG.md | 2 ++ app/app.go | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c680916df..169375f5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1613](https://github.com/NibiruChain/nibiru/pull/1613) - feat(app)!: enforce min commission by changing default and genesis validation * [#1615](https://github.com/NibiruChain/nibiru/pull/1613) - feat(ante)!: Ante handler to add a maximum commission rate of 25% for validators. +* [#1616](https://github.com/NibiruChain/nibiru/pull/1616) - fix(app)!: + Add custom wasm snapshotter for proper state exports ### Improvements diff --git a/app/app.go b/app/app.go index daadec4d8..a6c690b44 100644 --- a/app/app.go +++ b/app/app.go @@ -206,6 +206,19 @@ func NewNibiruApp( app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) + snapshotManager := app.SnapshotManager() + if snapshotManager == nil { + panic("mistakes were made: snapshot manager is nil") + } + if err = snapshotManager.RegisterExtensions( + wasmkeeper.NewWasmSnapshotter( + app.CommitMultiStore(), + &app.WasmKeeper, + ), + ); err != nil { + panic("failed to add wasm snapshot extension.") + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) From ed1a2e4e5ec7619ebb6926c773e83aa1ce713e64 Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Tue, 3 Oct 2023 18:13:38 +0200 Subject: [PATCH 02/10] fix ci not showing errors (#1619) --- contrib/make/test.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/make/test.mk b/contrib/make/test.mk index 08d79f412..0b64c37c6 100644 --- a/contrib/make/test.mk +++ b/contrib/make/test.mk @@ -9,7 +9,7 @@ test-coverage: go test ./... $(PACKAGES_NOSIMULATION) -short \ -coverprofile=coverage.txt \ -covermode=atomic \ - -race | grep -v "no test" | grep -v "no statement" + -race # NOTE: Using the verbose flag breaks the coverage reporting in CI. # Used for CI by Codecov @@ -18,7 +18,7 @@ test-coverage-integration: go test ./... \ -coverprofile=coverage.txt \ -covermode=atomic \ - -race | grep -v "no test" | grep -v "no statement" + -race # Require Python3 .PHONY: test-create-test-cases From c7ae585477680b4dd67e68829e9c211105b3d926 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:01:29 -0500 Subject: [PATCH 03/10] fix(app): non-nil snapshot manager is not guarantted in testapp (#1617) * feat(app)!: wasm snapshot export is mandatory * changelog * refacotr: unindent else block * hotfix(app)!: non-nil snapshot manager is not guaranteed in testapp * changelog --------- Co-authored-by: Jonathan Gimeno --- CHANGELOG.md | 2 ++ app/app.go | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 169375f5f..7ef2b7b1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 handler to add a maximum commission rate of 25% for validators. * [#1616](https://github.com/NibiruChain/nibiru/pull/1616) - fix(app)!: Add custom wasm snapshotter for proper state exports +* [#1617](https://github.com/NibiruChain/nibiru/pull/1617) - fix(app)!: + non-nil snapshot manager is not guarantted in testapp ### Improvements diff --git a/app/app.go b/app/app.go index a6c690b44..4bd5cf1ed 100644 --- a/app/app.go +++ b/app/app.go @@ -206,17 +206,15 @@ func NewNibiruApp( app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) - snapshotManager := app.SnapshotManager() - if snapshotManager == nil { - panic("mistakes were made: snapshot manager is nil") - } - if err = snapshotManager.RegisterExtensions( - wasmkeeper.NewWasmSnapshotter( - app.CommitMultiStore(), - &app.WasmKeeper, - ), - ); err != nil { - panic("failed to add wasm snapshot extension.") + if snapshotManager := app.SnapshotManager(); snapshotManager != nil { + if err = snapshotManager.RegisterExtensions( + wasmkeeper.NewWasmSnapshotter( + app.CommitMultiStore(), + &app.WasmKeeper, + ), + ); err != nil { + panic("failed to add wasm snapshot extension.") + } } if loadLatest { From e054b45ac68268e9315e458c64c116c977c4d3d9 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:18:15 -0500 Subject: [PATCH 04/10] feat(tokenfactory): execute msgs for CreateDenom, ChangeAdmin, UpdateModuleParams (#1607) * (proto): add some txs and events for token factory * #wip msg handlers impl * fix grpc query test * test(tokenfactory): validate basic and msg server tests * test(tokenfactory): update module params * fix(tokenfactory): changelog, linter, put blank CLi commands instead of panic * test(tokenfactory): add case for if the denom is not registered in ChangeAdmin * token factory CLI tests and queries with tests * test(tokenfactory/types): more coverage * combo squashed commit: Resolves strange proto break error test(tokenfactory): more CLI test coverage feat(perp): Add user discounts (#1594) * add discounts * impl genesis * fix test * make test more robust * galaxy brain int encoding fix * test and optimise * lint * CHANGELOG.md * do merge * clarify fee variable names in applyDiscountAndRebate func * refactor dnr_test.go as per PR review * add genesis tests --------- Co-authored-by: unknown unknown Co-authored-by: godismercilex Co-authored-by: Jonathan Gimeno feat(perp): Add user discounts (#1594) * add discounts * impl genesis * fix test * make test more robust * galaxy brain int encoding fix * test and optimise * lint * CHANGELOG.md * do merge * clarify fee variable names in applyDiscountAndRebate func * refactor dnr_test.go as per PR review * add genesis tests --------- Co-authored-by: unknown unknown Co-authored-by: godismercilex Co-authored-by: Jonathan Gimeno * ci(proto-lint): should refer to the PR, not just the last commit * ci(proto-lint): supply with github token in buf setup b/c rate limits --------- Co-authored-by: unknown unknown Co-authored-by: godismercilex Co-authored-by: Jonathan Gimeno Co-authored-by: Matthias <97468149+matthiasmatt@users.noreply.github.com> --- CHANGELOG.md | 2 + proto/nibiru/tokenfactory/v1/event.proto | 16 + proto/nibiru/tokenfactory/v1/query.proto | 32 +- proto/nibiru/tokenfactory/v1/tx.proto | 65 +- x/common/testutil/cli/query.go | 17 +- x/common/testutil/sample.go | 7 + x/devgas/v1/client/cli/tx.go | 18 +- x/sudo/types/msgs.go | 7 +- x/tokenfactory/cli/cli_test.go | 143 +++ x/tokenfactory/cli/query.go | 122 ++ x/tokenfactory/cli/tx.go | 105 ++ x/tokenfactory/keeper/genesis.go | 2 +- x/tokenfactory/keeper/grpc_query.go | 45 + x/tokenfactory/keeper/keeper_test.go | 4 +- x/tokenfactory/keeper/msg_server.go | 97 ++ x/tokenfactory/keeper/msg_server_test.go | 272 +++++ x/tokenfactory/keeper/store.go | 49 +- x/tokenfactory/module.go | 8 +- x/tokenfactory/types/codec.go | 25 +- x/tokenfactory/types/codec_test.go | 12 +- x/tokenfactory/types/errors.go | 14 +- x/tokenfactory/types/event.pb.go | 644 ++++++++++ x/tokenfactory/types/genesis.go | 2 +- x/tokenfactory/types/query.pb.go | 887 +++++++++++++- x/tokenfactory/types/query.pb.gw.go | 202 +++ x/tokenfactory/types/state.go | 12 +- x/tokenfactory/types/state_test.go | 81 ++ x/tokenfactory/types/tx.pb.go | 1421 +++++++++++++++++++++- x/tokenfactory/types/tx_msgs.go | 113 ++ x/tokenfactory/types/tx_msgs_test.go | 169 +++ 30 files changed, 4486 insertions(+), 107 deletions(-) create mode 100644 proto/nibiru/tokenfactory/v1/event.proto create mode 100644 x/tokenfactory/cli/cli_test.go create mode 100644 x/tokenfactory/cli/query.go create mode 100644 x/tokenfactory/cli/tx.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/types/event.pb.go create mode 100644 x/tokenfactory/types/tx_msgs.go create mode 100644 x/tokenfactory/types/tx_msgs_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ef2b7b1d..96df25927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1596](https://github.com/NibiruChain/nibiru/pull/1596) - epic(tokenfactory): State transitions, collections, genesis import and export, and app wiring + * [#1607](https://github.com/NibiruChain/nibiru/pull/1607) - Token factory + transaction messages for CreateDenom, ChangeAdmin, and UpdateModuleParams ### State Machine Breaking diff --git a/proto/nibiru/tokenfactory/v1/event.proto b/proto/nibiru/tokenfactory/v1/event.proto new file mode 100644 index 000000000..584f3920c --- /dev/null +++ b/proto/nibiru/tokenfactory/v1/event.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package nibiru.tokenfactory.v1; + +option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types"; + +message EventCreateDenom { + string denom = 1; + string creator = 2; +} + +message EventChangeAdmin { + string denom = 1; + string old_admin = 3; + string new_admin = 2; +} diff --git a/proto/nibiru/tokenfactory/v1/query.proto b/proto/nibiru/tokenfactory/v1/query.proto index 1ed9e2bf6..2e3150d09 100644 --- a/proto/nibiru/tokenfactory/v1/query.proto +++ b/proto/nibiru/tokenfactory/v1/query.proto @@ -4,6 +4,7 @@ package nibiru.tokenfactory.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos/bank/v1beta1/bank.proto"; import "nibiru/tokenfactory/v1/state.proto"; option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types"; @@ -15,6 +16,16 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/nibiru/tokenfactory/v1/params"; } + + // Denoms retrieves all registered denoms for a given creator + rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { + option (google.api.http).get = "/nibiru/tokenfactory/v1/denoms/{creator}"; + } + + // DenomInfo retrieves the denom metadata and admin info + rpc DenomInfo(QueryDenomInfoRequest) returns (QueryDenomInfoResponse) { + option (google.api.http).get = "/nibiru/tokenfactory/v1/denom-info/{denom}"; + } } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -23,5 +34,24 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // Module parameters stored in state - ModuleParams params = 1 [ (gogoproto.nullable) = false ]; + nibiru.tokenfactory.v1.ModuleParams params = 1 + [ (gogoproto.nullable) = false ]; +} + +// QueryDenomsRequest: gRPC query for all denoms registered for a creator +message QueryDenomsRequest { string creator = 1; } + +// QueryDenomsResponse: All registered denoms for a creator +message QueryDenomsResponse { repeated string denoms = 1; } + +// QueryDenomInfoRequest: gRPC query for the denom admin and x/bank metadata +message QueryDenomInfoRequest { string denom = 1; } + +// QueryDenomInfoResponse: All registered denoms for a creator +message QueryDenomInfoResponse { + // Admin of the token factory denom + string admin = 1; + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. + cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/tokenfactory/v1/tx.proto b/proto/nibiru/tokenfactory/v1/tx.proto index 2fb66f1d2..fa76b3000 100644 --- a/proto/nibiru/tokenfactory/v1/tx.proto +++ b/proto/nibiru/tokenfactory/v1/tx.proto @@ -2,7 +2,70 @@ syntax = "proto3"; package nibiru.tokenfactory.v1; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "nibiru/tokenfactory/v1/state.proto"; + option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types"; // Msg defines the gRPC Msg service for transactions. -service Msg {} +service Msg { + // CreateDenom: registers a token factory denom. + rpc CreateDenom(MsgCreateDenom) returns (MsgCreateDenomResponse); + rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse); + // UpdateModuleParams: A governance operation for updating the x/tokenfactory + // module parameters. + rpc UpdateModuleParams(MsgUpdateModuleParams) + returns (MsgUpdateModuleParamsResponse); + // TODO MsgMint + // TODO MsgBurn + // TODO MsgSetDenomMetadata + // TODO MsgForceTransfer +} + +// MsgCreateDenom: sdk.Msg that registers an a token factory denom. +// A denom has the form "tf/[creatorAddr]/[subdenom]". +// - Denoms become unique x/bank tokens, so the creator-subdenom pair that +// defines a denom cannot be reused. +// - The resulting denom's admin is originally set to be the creator, but the +// admin can be changed later. +message MsgCreateDenom { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + // subdenom can be up to 44 "alphanumeric" characters long. + string subdenom = 2 [ (gogoproto.moretags) = "yaml:\"subdenom\"" ]; +} + +// MsgCreateDenomResponse is the return value of MsgCreateDenom +message MsgCreateDenomResponse { + // NewTokenDenom: identifier for the newly created token factory denom. + string new_token_denom = 1 + [ (gogoproto.moretags) = "yaml:\"new_token_denom\"" ]; +} + +// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to change +// admin of a denom to a new account +message MsgChangeAdmin { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; + string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ]; +} + +// MsgChangeAdminResponse is the gRPC response for the MsgChangeAdmin TxMsg. +message MsgChangeAdminResponse {} + +// MsgUpdateModuleParams: sdk.Msg for updating the x/tokenfactory module params +message MsgUpdateModuleParams { + option (cosmos.msg.v1.signer) = "authority"; + + // Authority: Address of the governance module account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + nibiru.tokenfactory.v1.ModuleParams params = 2 + [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateModuleParamsResponse is the gRPC response for the +// MsgUpdateModuleParams TxMsg. +message MsgUpdateModuleParamsResponse {} diff --git a/x/common/testutil/cli/query.go b/x/common/testutil/cli/query.go index c1062c55e..ef96a2ef2 100644 --- a/x/common/testutil/cli/query.go +++ b/x/common/testutil/cli/query.go @@ -47,8 +47,23 @@ func WithQueryEncodingType(e EncodingType) ExecQueryOption { } } +func (chain Network) ExecQuery( + cmd *cobra.Command, + args []string, + result codec.ProtoMarshaler, + opts ...ExecQueryOption, +) error { + return ExecQuery(chain.Validators[0].ClientCtx, cmd, args, result, opts...) +} + // ExecQuery executes a CLI query onto the provided Network. -func ExecQuery(clientCtx client.Context, cmd *cobra.Command, args []string, result codec.ProtoMarshaler, opts ...ExecQueryOption) error { +func ExecQuery( + clientCtx client.Context, + cmd *cobra.Command, + args []string, + result codec.ProtoMarshaler, + opts ...ExecQueryOption, +) error { var options queryOptions for _, o := range opts { o(&options) diff --git a/x/common/testutil/sample.go b/x/common/testutil/sample.go index 5e9eea478..fc23896f8 100644 --- a/x/common/testutil/sample.go +++ b/x/common/testutil/sample.go @@ -14,6 +14,9 @@ import ( tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) // AccAddress returns a sample address (sdk.AccAddress) created using secp256k1. @@ -77,3 +80,7 @@ func RandLetters(n int) string { } return string(b) } + +func GovModuleAddr() sdk.AccAddress { + return authtypes.NewModuleAddress(govtypes.ModuleName) +} diff --git a/x/devgas/v1/client/cli/tx.go b/x/devgas/v1/client/cli/tx.go index fef2fc23d..e059af0dc 100644 --- a/x/devgas/v1/client/cli/tx.go +++ b/x/devgas/v1/client/cli/tx.go @@ -25,16 +25,16 @@ func NewTxCmd() *cobra.Command { } txCmd.AddCommand( - NewRegisterFeeShare(), - NewCancelFeeShare(), - NewUpdateFeeShare(), + CmdRegisterFeeShare(), + CmdCancelFeeShare(), + CmdUpdateFeeShare(), ) return txCmd } -// NewRegisterFeeShare returns a CLI command handler for registering a +// CmdRegisterFeeShare returns a CLI command handler for registering a // contract for fee distribution -func NewRegisterFeeShare() *cobra.Command { +func CmdRegisterFeeShare() *cobra.Command { cmd := &cobra.Command{ Use: "register [contract_bech32] [withdraw_bech32]", Short: "Register a contract for fee distribution. Only the contract admin can register a contract.", @@ -69,9 +69,9 @@ func NewRegisterFeeShare() *cobra.Command { return cmd } -// NewCancelFeeShare returns a CLI command handler for canceling a +// CmdCancelFeeShare returns a CLI command handler for canceling a // contract for fee distribution -func NewCancelFeeShare() *cobra.Command { +func CmdCancelFeeShare() *cobra.Command { cmd := &cobra.Command{ Use: "cancel [contract_bech32]", Short: "Cancel a contract from feeshare distribution", @@ -104,9 +104,9 @@ func NewCancelFeeShare() *cobra.Command { return cmd } -// NewUpdateFeeShare returns a CLI command handler for updating the withdraw +// CmdUpdateFeeShare returns a CLI command handler for updating the withdraw // address of a contract for fee distribution -func NewUpdateFeeShare() *cobra.Command { +func CmdUpdateFeeShare() *cobra.Command { cmd := &cobra.Command{ Use: "update [contract_bech32] [new_withdraw_bech32]", Short: "Update withdrawer address for a contract registered for feeshare distribution.", diff --git a/x/sudo/types/msgs.go b/x/sudo/types/msgs.go index ed883fc9a..7c8c7d9c4 100644 --- a/x/sudo/types/msgs.go +++ b/x/sudo/types/msgs.go @@ -35,6 +35,7 @@ func (m MsgEditSudoers) ValidateBasic() error { return nil } +// GetSigners implements the sdk.Msg interface. func (m MsgEditSudoers) GetSigners() []sdk.AccAddress { signer, err := sdk.AccAddressFromBech32(m.Sender) if err != nil { @@ -43,13 +44,13 @@ func (m MsgEditSudoers) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -// Route Implements Msg. +// Route implements the sdk.Msg interface. func (msg MsgEditSudoers) Route() string { return ModuleName } -// Type Implements Msg. +// Type implements the sdk.Msg interface. func (msg MsgEditSudoers) Type() string { return "edit_sudoers" } -// GetSignBytes Implements Msg. +// GetSignBytes implements the sdk.Msg interface. func (m MsgEditSudoers) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } diff --git a/x/tokenfactory/cli/cli_test.go b/x/tokenfactory/cli/cli_test.go new file mode 100644 index 000000000..6ce854d03 --- /dev/null +++ b/x/tokenfactory/cli/cli_test.go @@ -0,0 +1,143 @@ +package cli_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/NibiruChain/nibiru/app" + "github.com/NibiruChain/nibiru/x/common/testutil" + testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli" + "github.com/NibiruChain/nibiru/x/common/testutil/genesis" + "github.com/NibiruChain/nibiru/x/common/testutil/testapp" + "github.com/NibiruChain/nibiru/x/tokenfactory/cli" + "github.com/NibiruChain/nibiru/x/tokenfactory/types" +) + +var _ suite.SetupAllSuite = (*IntegrationTestSuite)(nil) + +type IntegrationTestSuite struct { + suite.Suite + + cfg testutilcli.Config + network *testutilcli.Network + val *testutilcli.Validator +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) TestTokenFactory() { + s.T().Run("CreateDenomTest", s.CreateDenomTest) + s.T().Run("ChangeAdminTest", s.ChangeAdminTest) +} + +func (s *IntegrationTestSuite) SetupSuite() { + // Make test skip if -short is not used: + // All tests: `go test ./...` + // Unit tests only: `go test ./... -short` + // Integration tests only: `go test ./... -run Integration` + // See: https://stackoverflow.com/a/41407042/13305627 + if testing.Short() { + s.T().Skip("skipping integration test suite") + } + + s.T().Log("setting up integration test suite") + + testapp.EnsureNibiruPrefix() + encodingConfig := app.MakeEncodingConfigAndRegister() + genState := genesis.NewTestGenesisState(encodingConfig) + cfg := testutilcli.BuildNetworkConfig(genState) + cfg.NumValidators = 1 + network, err := testutilcli.New(s.T(), s.T().TempDir(), cfg) + s.NoError(err) + + s.cfg = cfg + s.network = network + s.val = network.Validators[0] + s.NoError(s.network.WaitForNextBlock()) +} + +func (s *IntegrationTestSuite) CreateDenomTest(t *testing.T) { + creator := s.val.Address + createDenom := func(subdenom string, wantErr bool) { + _, err := s.network.ExecTxCmd( + cli.NewTxCmd(), + creator, []string{"create-denom", subdenom}) + if wantErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + s.NoError(s.network.WaitForNextBlock()) + } + + createDenom("nusd", false) + createDenom("nusd", true) // Can't create the same denom twice. + createDenom("stnibi", false) + createDenom("stnusd", false) + + denomResp := new(types.QueryDenomsResponse) + s.NoError( + s.network.ExecQuery( + cli.CmdQueryDenoms(), []string{creator.String()}, denomResp, + ), + ) + denoms := denomResp.Denoms + wantDenoms := []string{ + types.TFDenom{Creator: creator.String(), Subdenom: "nusd"}.String(), + types.TFDenom{Creator: creator.String(), Subdenom: "stnibi"}.String(), + types.TFDenom{Creator: creator.String(), Subdenom: "stnusd"}.String(), + } + s.ElementsMatch(denoms, wantDenoms) +} + +func (s *IntegrationTestSuite) ChangeAdminTest(t *testing.T) { + creator := s.val.Address + admin := creator + newAdmin := testutil.AccAddress() + denom := types.TFDenom{ + Creator: creator.String(), + Subdenom: "stnibi", + } + + s.T().Log("Verify current admin is creator") + infoResp := new(types.QueryDenomInfoResponse) + s.NoError( + s.network.ExecQuery( + cli.NewQueryCmd(), []string{"denom-info", denom.String()}, infoResp, + ), + ) + s.Equal(infoResp.Admin, admin.String()) + + s.T().Log("Change to a new admin") + _, err := s.network.ExecTxCmd( + cli.NewTxCmd(), + admin, []string{"change-admin", denom.String(), newAdmin.String()}) + s.Require().NoError(err) + + s.T().Log("Verify new admin is in state") + infoResp = new(types.QueryDenomInfoResponse) + s.NoError( + s.network.ExecQuery( + cli.NewQueryCmd(), []string{"denom-info", denom.String()}, infoResp, + ), + ) + s.Equal(infoResp.Admin, newAdmin.String()) +} + +func (s *IntegrationTestSuite) TestQueryModuleParams() { + paramResp := new(types.QueryParamsResponse) + s.NoError( + s.network.ExecQuery( + cli.NewQueryCmd(), []string{"params"}, paramResp, + ), + ) + s.Equal(paramResp.Params, types.DefaultModuleParams()) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} diff --git a/x/tokenfactory/cli/query.go b/x/tokenfactory/cli/query.go new file mode 100644 index 000000000..d67e46154 --- /dev/null +++ b/x/tokenfactory/cli/query.go @@ -0,0 +1,122 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/NibiruChain/nibiru/x/tokenfactory/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +// NewQueryCmd returns the cli query commands for this module +func NewQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Aliases: []string{"tf"}, + Short: fmt.Sprintf("Queries for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdQueryDenoms(), + CmdQueryModuleParams(), + CmdQueryDenomInfo(), + ) + + return cmd +} + +// CmdQueryDenoms: Queries all TF denoms for a given creator. +func CmdQueryDenoms() *cobra.Command { + cmd := &cobra.Command{ + Use: "denoms [creator] [flags]", + Short: "Returns token denoms created by a given 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.Denoms( + cmd.Context(), &types.QueryDenomsRequest{ + Creator: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// CmdQueryModuleParams: Queries module params for x/tokenfactory. +func CmdQueryModuleParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params [flags]", + Short: "Get the params for the x/tokenfactory module", + Args: cobra.ExactArgs(0), + 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.Params( + cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// CmdQueryDenomInfo: Queries the admin and x/bank metadata for a TF denom +func CmdQueryDenomInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "denom-info [denom] [flags]", + Short: "Get the admin and x/bank metadata for a 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.DenomInfo( + cmd.Context(), + &types.QueryDenomInfoRequest{ + Denom: args[0], + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/tokenfactory/cli/tx.go b/x/tokenfactory/cli/tx.go new file mode 100644 index 000000000..2cd154655 --- /dev/null +++ b/x/tokenfactory/cli/tx.go @@ -0,0 +1,105 @@ +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/tx" + + "github.com/NibiruChain/nibiru/x/tokenfactory/types" +) + +// NewTxCmd returns the transaction commands for this module +func NewTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdCreateDenom(), + CmdChangeAdmin(), + // CmdModifyDenomMetadata(), + // CmdMint(), + // CmdMintTo(), + // CmdBurn(), + // CmdBurnFrom(), + // CmdForceTransfer(), + ) + + return cmd +} + +// CmdCreateDenom broadcast MsgCreateDenom +func CmdCreateDenom() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-denom [subdenom] [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, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever( + clientCtx.AccountRetriever) + + msg := &types.MsgCreateDenom{ + Sender: clientCtx.GetFromAddress().String(), + Subdenom: args[0], + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// CmdChangeAdmin broadcast MsgChangeAdmin +func CmdChangeAdmin() *cobra.Command { + cmd := &cobra.Command{ + Use: "change-admin [denom] [new-admin-address] [flags]", + Short: strings.Join([]string{ + "Changes the admin address for a token factory 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, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + msg := &types.MsgChangeAdmin{ + Sender: clientCtx.GetFromAddress().String(), + Denom: args[0], + NewAdmin: args[1], + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go index 5b8f80767..488861333 100644 --- a/x/tokenfactory/keeper/genesis.go +++ b/x/tokenfactory/keeper/genesis.go @@ -22,7 +22,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { for _, genDenom := range genState.GetFactoryDenoms() { // We don't need to validate the struct again here because it's // performed inside of the genState.Validate() execution above. - k.Store.InsertDenomGenesis_NoBankUpdate(ctx, genDenom) + k.Store.unsafeGenesisInsertDenom(ctx, genDenom) } } diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index 9692322f6..af5818e0e 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -24,6 +24,7 @@ func (k Keeper) Querier() Querier { } } +// Params: Returns the module parameters. func (q Querier) Params( goCtx context.Context, _ *types.QueryParamsRequest, @@ -38,3 +39,47 @@ func (q Querier) Params( } return &types.QueryParamsResponse{Params: params}, nil } + +// Denoms: Returns all registered denoms for a given creator. +func (q Querier) Denoms( + goCtx context.Context, + req *types.QueryDenomsRequest, +) (resp *types.QueryDenomsResponse, err error) { + if req == nil { + return resp, errNilMsg + } + if req.Creator == "" { + return resp, types.ErrInvalidCreator.Wrap("empty creator address") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + iter := q.Keeper.Store.Denoms.Indexes.Creator.ExactMatch(ctx, req.Creator) + return &types.QueryDenomsResponse{ + Denoms: iter.PrimaryKeys(), + }, err +} + +// DenomInfo: Returns all registered denoms for a given creator. +func (q Querier) DenomInfo( + goCtx context.Context, + req *types.QueryDenomInfoRequest, +) (resp *types.QueryDenomInfoResponse, err error) { + if req == nil { + return resp, errNilMsg + } + if err := types.DenomStr(req.Denom).Validate(); err != nil { + return resp, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + tfMetadata, err := q.Keeper.Store.denomAdmins.Get(ctx, req.Denom) + if err != nil { + return resp, err + } + + bankMetadata, _ := q.Keeper.bankKeeper.GetDenomMetaData(ctx, req.Denom) + return &types.QueryDenomInfoResponse{ + Admin: tfMetadata.Admin, + Metadata: bankMetadata, + }, err +} diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index d8d5aac85..23498f498 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -42,9 +42,7 @@ func (s *TestSuite) SetupTest() { s.keeper = s.app.TokenFactoryKeeper s.genesis = *tftypes.DefaultGenesis() - s.querier = tfkeeper.Querier{ - Keeper: s.app.TokenFactoryKeeper, - } + s.querier = s.keeper.Querier() } func (s *TestSuite) GoCtx() context.Context { return sdk.WrapSDKContext(s.ctx) } diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go new file mode 100644 index 000000000..1b8b8c46e --- /dev/null +++ b/x/tokenfactory/keeper/msg_server.go @@ -0,0 +1,97 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + grpccodes "google.golang.org/grpc/codes" + grpcstatus "google.golang.org/grpc/status" + + "github.com/NibiruChain/nibiru/x/tokenfactory/types" +) + +var _ types.MsgServer = (*Keeper)(nil) + +var errNilMsg error = grpcstatus.Errorf(grpccodes.InvalidArgument, "nil msg") + +func (k Keeper) CreateDenom( + goCtx context.Context, txMsg *types.MsgCreateDenom, +) (resp *types.MsgCreateDenomResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + ctx := sdk.UnwrapSDKContext(goCtx) + denom := types.TFDenom{ + Creator: txMsg.Sender, + Subdenom: txMsg.Subdenom, + } + err = k.Store.InsertDenom(ctx, denom) + if err != nil { + return resp, err + } + + return &types.MsgCreateDenomResponse{ + NewTokenDenom: denom.String(), + }, err +} + +func (k Keeper) ChangeAdmin( + goCtx context.Context, txMsg *types.MsgChangeAdmin, +) (resp *types.MsgChangeAdminResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + ctx := sdk.UnwrapSDKContext(goCtx) + authData, err := k.Store.GetDenomAuthorityMetadata(ctx, txMsg.Denom) + if err != nil { + return resp, err + } + if txMsg.Sender != authData.Admin { + return resp, types.ErrInvalidSender.Wrapf( + "only the current admin can set a new admin: current admin (%s), sender (%s)", + authData.Admin, txMsg.Sender, + ) + } + + authData.Admin = txMsg.NewAdmin + k.Store.denomAdmins.Insert(ctx, txMsg.Denom, authData) + + return &types.MsgChangeAdminResponse{}, ctx.EventManager().EmitTypedEvent( + &types.EventChangeAdmin{ + Denom: txMsg.Denom, + OldAdmin: txMsg.Sender, + NewAdmin: txMsg.NewAdmin, + }) +} + +func (k Keeper) UpdateModuleParams( + goCtx context.Context, txMsg *types.MsgUpdateModuleParams, +) (resp *types.MsgUpdateModuleParamsResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + if k.authority != txMsg.Authority { + return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.authority, txMsg.Authority) + } + + if err := txMsg.Params.Validate(); err != nil { + return resp, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.Store.ModuleParams.Set(ctx, txMsg.Params) + return &types.MsgUpdateModuleParamsResponse{}, err +} diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go new file mode 100644 index 000000000..a2f763d64 --- /dev/null +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -0,0 +1,272 @@ +package keeper_test + +import ( + "testing" + + "github.com/NibiruChain/collections" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/NibiruChain/nibiru/app" + "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/tokenfactory/types" +) + +func (s *TestSuite) TestCreateDenom() { + _, addrs := testutil.PrivKeyAddressPairs(4) + + testCases := []struct { + name string + txMsg *types.MsgCreateDenom + wantErr string + preHook func(ctx sdk.Context, bapp *app.NibiruApp) + postHook func(ctx sdk.Context, bapp *app.NibiruApp) + }{ + { + name: "happy path", + txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: "nusd"}, + wantErr: "", + preHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + allDenoms := bapp.TokenFactoryKeeper.Store.Denoms. + Iterate(ctx, collections.Range[string]{}).Values() + s.Len(allDenoms, 0) + }, + postHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + allDenoms := bapp.TokenFactoryKeeper.Store.Denoms. + Iterate(ctx, collections.Range[string]{}).Values() + s.Len(allDenoms, 1) + s.Equal(allDenoms[0].Subdenom, "nusd") + }, + }, + { + name: "creating the same denom a second time should fail", + txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: "nusd"}, + wantErr: "attempting to create denom that is already registered", + preHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + allDenoms := bapp.TokenFactoryKeeper.Store.Denoms. + Iterate(ctx, collections.Range[string]{}).Values() + s.Len(allDenoms, 0) + _, err := bapp.TokenFactoryKeeper.CreateDenom( + sdk.WrapSDKContext(s.ctx), &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + ) + s.NoError(err) + }, + postHook: func(ctx sdk.Context, bapp *app.NibiruApp) {}, + }, + + { + name: "sad: nil msg", + txMsg: nil, + wantErr: "nil msg", + }, + + { + name: "sad: sender", + txMsg: &types.MsgCreateDenom{Sender: "sender", Subdenom: "nusd"}, + wantErr: "invalid creator", + }, + + { + name: "sad: denom", + txMsg: &types.MsgCreateDenom{Sender: addrs[0].String(), Subdenom: ""}, + wantErr: "denom format error", + }, + } + + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + s.SetupTest() + if tc.preHook != nil { + tc.preHook(s.ctx, s.app) + } + + resp, err := s.app.TokenFactoryKeeper.CreateDenom( + sdk.WrapSDKContext(s.ctx), tc.txMsg, + ) + + if tc.wantErr != "" { + s.Error(err) + s.ErrorContains(err, tc.wantErr) + return + } + + s.NoError(err) + want := types.TFDenom{ + Creator: tc.txMsg.Sender, + Subdenom: tc.txMsg.Subdenom, + }.String() + s.Equal(want, resp.NewTokenDenom) + + if tc.postHook != nil { + tc.postHook(s.ctx, s.app) + } + }) + } +} + +func (s *TestSuite) TestChangeAdmin() { + sbf := testutil.AccAddress().String() + + testCases := []struct { + name string + txMsg *types.MsgChangeAdmin + wantErr string + preHook func(ctx sdk.Context, bapp *app.NibiruApp) + postHook func(ctx sdk.Context, bapp *app.NibiruApp) + }{ + { + name: "sad: nil msg", + txMsg: nil, + wantErr: "nil msg", + }, + + { + name: "sad: fail validate basic", + txMsg: &types.MsgChangeAdmin{ + Sender: "sender", Denom: "tf/creator/nusd", NewAdmin: "new admin"}, + wantErr: "invalid sender", + }, + + { + name: "sad: non-admin tries to change admin", + txMsg: &types.MsgChangeAdmin{ + Sender: testutil.AccAddress().String(), + Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), + NewAdmin: testutil.AccAddress().String(), + }, + wantErr: "only the current admin can set a new admin", + preHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + _, err := bapp.TokenFactoryKeeper.CreateDenom( + sdk.WrapSDKContext(ctx), &types.MsgCreateDenom{ + Sender: sbf, + Subdenom: "ftt", + }, + ) + s.NoError(err) + }, + }, + + { + name: "happy: SBF changes FTT admin", + txMsg: &types.MsgChangeAdmin{ + Sender: sbf, + Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), + NewAdmin: testutil.AccAddress().String(), + }, + wantErr: "", + preHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + _, err := bapp.TokenFactoryKeeper.CreateDenom( + sdk.WrapSDKContext(ctx), &types.MsgCreateDenom{ + Sender: sbf, + Subdenom: "ftt", + }, + ) + s.NoError(err) + }, + }, + + { + name: "sad: change admin for denom that doesn't exist ", + txMsg: &types.MsgChangeAdmin{ + Sender: sbf, + Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), + NewAdmin: testutil.AccAddress().String()}, + wantErr: collections.ErrNotFound.Error(), + }, + } + + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + s.SetupTest() + if tc.preHook != nil { + tc.preHook(s.ctx, s.app) + } + + _, err := s.app.TokenFactoryKeeper.ChangeAdmin( + sdk.WrapSDKContext(s.ctx), tc.txMsg, + ) + + if tc.wantErr != "" { + s.Error(err) + s.ErrorContains(err, tc.wantErr) + return + } + + s.T().Log("expect new admin to be set in state.") + s.NoError(err) + authData, err := s.app.TokenFactoryKeeper.Store.GetDenomAuthorityMetadata( + s.ctx, tc.txMsg.Denom) + s.NoError(err) + s.Equal(authData.Admin, tc.txMsg.NewAdmin) + + if tc.postHook != nil { + tc.postHook(s.ctx, s.app) + } + }) + } +} + +func (s *TestSuite) TestUpdateModuleParams() { + testCases := []struct { + name string + txMsg *types.MsgUpdateModuleParams + wantErr string + }{ + { + name: "sad: nil msg", + txMsg: nil, + wantErr: "nil msg", + }, + + { + name: "sad: fail validate basic", + txMsg: &types.MsgUpdateModuleParams{ + Authority: "authority", + Params: types.DefaultModuleParams(), + }, + wantErr: "invalid authority", + }, + + { + name: "sad: must be gov proposal form x/gov module account", + txMsg: &types.MsgUpdateModuleParams{ + Authority: testutil.AccAddress().String(), + Params: types.DefaultModuleParams(), + }, + wantErr: "expected gov account as only signer for proposal message", + }, + + { + name: "happy: new params", + txMsg: &types.MsgUpdateModuleParams{ + Authority: testutil.GovModuleAddr().String(), + Params: types.ModuleParams{ + DenomCreationGasConsume: 69_420, + }, + }, + wantErr: "", + }, + } + + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + s.SetupTest() + _, err := s.app.TokenFactoryKeeper.UpdateModuleParams( + sdk.WrapSDKContext(s.ctx), tc.txMsg, + ) + + if tc.wantErr != "" { + s.Error(err) + s.ErrorContains(err, tc.wantErr) + return + } + s.NoError(err) + + params, err := s.app.TokenFactoryKeeper.Store.ModuleParams.Get(s.ctx) + s.Require().NoError(err) + s.Equal(params, tc.txMsg.Params) + }) + } +} diff --git a/x/tokenfactory/keeper/store.go b/x/tokenfactory/keeper/store.go index 7b52f3629..9fa926f8e 100644 --- a/x/tokenfactory/keeper/store.go +++ b/x/tokenfactory/keeper/store.go @@ -33,41 +33,51 @@ func (api StoreAPI) InsertDenom( if err := denom.Validate(); err != nil { return err } - key := denom.String() // The x/bank keeper is the source of truth. + key := denom.String() found := api.HasDenom(ctx, denom) if found { return tftypes.ErrDenomAlreadyRegistered.Wrap(key) } - api.Denoms.Insert(ctx, key, denom) - api.creator.Insert(ctx, denom.Creator) + admin := denom.Creator + api.unsafeInsertDenom(ctx, denom, admin) - // The denom creator is the default admin. The admin can be updated after - // the denom exists using the ChangeAdmin message. Having no admin is also - // allowed. api.bankKeeper.SetDenomMetaData(ctx, denom.DefaultBankMetadata()) api.denomAdmins.Insert(ctx, key, tftypes.DenomAuthorityMetadata{ - Admin: denom.Creator, + Admin: admin, }) return nil } -// InsertDenomGenesis_NoBankUpdate: Populates the x/tokenfactory state without -// making any assumptions about the x/bank state. This function is unsafe and -// should only be used in InitGenesis or upgrades that populate state from an -// exported genesis. -func (api StoreAPI) InsertDenomGenesis_NoBankUpdate( - ctx sdk.Context, genDenom tftypes.GenesisDenom, +// unsafeInsertDenom: Adds a token factory denom to state with the given admin. +// NOTE: unsafe → assumes pre-validated inputs +func (api StoreAPI) unsafeInsertDenom( + ctx sdk.Context, denom tftypes.TFDenom, admin string, ) { - denom := tftypes.DenomStr(genDenom.Denom).MustToStruct() - admin := genDenom.AuthorityMetadata.Admin - key := denom.String() - api.Denoms.Insert(ctx, key, denom) + denomStr := denom.String() + api.Denoms.Insert(ctx, denomStr, denom) api.creator.Insert(ctx, denom.Creator) - api.denomAdmins.Insert(ctx, key, tftypes.DenomAuthorityMetadata{ + api.bankKeeper.SetDenomMetaData(ctx, denom.DefaultBankMetadata()) + api.denomAdmins.Insert(ctx, denomStr, tftypes.DenomAuthorityMetadata{ Admin: admin, }) + _ = ctx.EventManager().EmitTypedEvent(&tftypes.EventCreateDenom{ + Denom: denomStr, + Creator: denom.Creator, + }) +} + +// unsafeGenesisInsertDenom: Populates the x/tokenfactory state without +// making any assumptions about the x/bank state. This function should only be +// used in InitGenesis or upgrades that populate state from an exported genesis. +// NOTE: unsafe → assumes pre-validated inputs +func (api StoreAPI) unsafeGenesisInsertDenom( + ctx sdk.Context, genDenom tftypes.GenesisDenom, +) { + denom := tftypes.DenomStr(genDenom.Denom).MustToStruct() + admin := genDenom.AuthorityMetadata.Admin + api.unsafeInsertDenom(ctx, denom, admin) } // HasDenom: True if the denom has already been registered. @@ -82,7 +92,8 @@ func (api StoreAPI) HasCreator(ctx sdk.Context, creator string) bool { return api.creator.Has(ctx, creator) } -// GetDenomAuthorityMetadata returns the authority metadata for a specific denom +// GetDenomAuthorityMetadata returns the admin (authority metadata) for a +// specific denom. This differs from the x/bank metadata. func (api StoreAPI) GetDenomAuthorityMetadata( ctx sdk.Context, denom string, ) (tftypes.DenomAuthorityMetadata, error) { diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 6e45c08ec..80b41b36c 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -26,7 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - // modulecli "github.com/NibiruChain/nibiru/x/tokenfactory/client/cli" + modulecli "github.com/NibiruChain/nibiru/x/tokenfactory/cli" modulekeeper "github.com/NibiruChain/nibiru/x/tokenfactory/keeper" moduletypes "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) @@ -99,14 +99,12 @@ func (b AppModuleBasic) RegisterGRPCGatewayRoutes( // GetTxCmd returns the root tx command for the fees module. func (AppModuleBasic) GetTxCmd() *cobra.Command { - panic("TODO") - // return modulecli.NewTxCmd() + return modulecli.NewTxCmd() } // GetQueryCmd returns the fees module's root query command. func (AppModuleBasic) GetQueryCmd() *cobra.Command { - panic("TODO") - // return modulecli.GetQueryCmd() + return modulecli.NewQueryCmd() } // ___________________________________________________________________________ diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go index 560aa7a5c..46b6ff55a 100644 --- a/x/tokenfactory/types/codec.go +++ b/x/tokenfactory/types/codec.go @@ -11,7 +11,6 @@ import ( var ( legacyAminoCdc = codec.NewLegacyAmino() ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) - AminoCdc = codec.NewAminoCodec(legacyAminoCdc) ) // NOTE: This is required for the GetSignBytes function @@ -30,15 +29,35 @@ func init() { func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgCreateDenom{}, + &MsgChangeAdmin{}, + &MsgUpdateModuleParams{}, // &MsgTODO{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -// RegisterLegacyAminoCodec registers the necessary x/FeeShare interfaces and +func TX_MSG_TYPE_URLS() []string { + return []string{ + "/nibiru.tokenfactory.v1.MsgCreateDenom", + "/nibiru.tokenfactory.v1.MsgChangeAdmin", + "/nibiru.tokenfactory.v1.MsgUpdateModuleParams", + } +} + +// RegisterLegacyAminoCodec registers the necessary x/tokenfactory interfaces and // concrete types on the provided LegacyAmino codec. These types are used for // Amino JSON serialization and EIP-712 compatibility. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - // cdc.RegisterConcrete(&MsgTODO{}, "prefix/MsgTODO", nil) + for _, ele := range []struct { + MsgType interface{} + Name string + }{ + {&MsgCreateDenom{}, "nibiru/tokenfactory/create-denom"}, + {&MsgChangeAdmin{}, "nibiru/tokenfactory/change-admin"}, + {&MsgUpdateModuleParams{}, "nibiru/tokenfactory/update-module-params"}, + } { + cdc.RegisterConcrete(ele.MsgType, ele.Name, nil) + } } diff --git a/x/tokenfactory/types/codec_test.go b/x/tokenfactory/types/codec_test.go index a9b3b7538..11dcc6dc6 100644 --- a/x/tokenfactory/types/codec_test.go +++ b/x/tokenfactory/types/codec_test.go @@ -1,4 +1,4 @@ -package types +package types_test import ( "testing" @@ -7,6 +7,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) type CodecSuite struct { @@ -20,11 +22,9 @@ func TestCodecSuite(t *testing.T) { func (suite *CodecSuite) TestRegisterInterfaces() { registry := codectypes.NewInterfaceRegistry() registry.RegisterInterface(sdk.MsgInterfaceProtoName, (*sdk.Msg)(nil)) - RegisterInterfaces(registry) + types.RegisterInterfaces(registry) impls := registry.ListImplementations(sdk.MsgInterfaceProtoName) - suite.Require().Equal(0, len(impls)) - suite.Require().ElementsMatch([]string{ - // "/nibiru.tokenfactory.v1.MsgTODO", - }, impls) + suite.Require().Equal(3, len(impls)) + suite.Require().ElementsMatch(types.TX_MSG_TYPE_URLS(), impls) } diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go index e88b82adf..ee80b8e8b 100644 --- a/x/tokenfactory/types/errors.go +++ b/x/tokenfactory/types/errors.go @@ -13,10 +13,12 @@ func registerError(msg string) *sdkerrors.Error { // Module "sentinel" errors var ( - ErrInvalidGenesis = registerError("invalid genesis") - ErrInvalidDenom = registerError("invalid token factory denom") - ErrInvalidCreator = registerError("invalid creator") - ErrInvalidSubdenom = registerError("invalid subdenom") - ErrInvalidAuthorityMetadata = registerError("invalid denom authority metadata") - ErrDenomAlreadyRegistered = registerError("attempting to create denom that is already registered (has bank metadata)") + ErrInvalidGenesis = registerError("invalid genesis") + ErrInvalidDenom = registerError("invalid token factory denom") + ErrInvalidCreator = registerError("invalid creator") + ErrInvalidSubdenom = registerError("invalid subdenom") + ErrInvalidAdmin = registerError("invalid denom admin") + ErrDenomAlreadyRegistered = registerError("attempting to create denom that is already registered (has bank metadata)") + ErrInvalidSender = registerError("invalid msg sender") + ErrInvalidModuleParams = registerError("invalid module params") ) diff --git a/x/tokenfactory/types/event.pb.go b/x/tokenfactory/types/event.pb.go new file mode 100644 index 000000000..9f74b8415 --- /dev/null +++ b/x/tokenfactory/types/event.pb.go @@ -0,0 +1,644 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: nibiru/tokenfactory/v1/event.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/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 EventCreateDenom struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *EventCreateDenom) Reset() { *m = EventCreateDenom{} } +func (m *EventCreateDenom) String() string { return proto.CompactTextString(m) } +func (*EventCreateDenom) ProtoMessage() {} +func (*EventCreateDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_a46c3c7b7d022093, []int{0} +} +func (m *EventCreateDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCreateDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCreateDenom.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 *EventCreateDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCreateDenom.Merge(m, src) +} +func (m *EventCreateDenom) XXX_Size() int { + return m.Size() +} +func (m *EventCreateDenom) XXX_DiscardUnknown() { + xxx_messageInfo_EventCreateDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_EventCreateDenom proto.InternalMessageInfo + +func (m *EventCreateDenom) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *EventCreateDenom) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type EventChangeAdmin struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + OldAdmin string `protobuf:"bytes,3,opt,name=old_admin,json=oldAdmin,proto3" json:"old_admin,omitempty"` + NewAdmin string `protobuf:"bytes,2,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty"` +} + +func (m *EventChangeAdmin) Reset() { *m = EventChangeAdmin{} } +func (m *EventChangeAdmin) String() string { return proto.CompactTextString(m) } +func (*EventChangeAdmin) ProtoMessage() {} +func (*EventChangeAdmin) Descriptor() ([]byte, []int) { + return fileDescriptor_a46c3c7b7d022093, []int{1} +} +func (m *EventChangeAdmin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventChangeAdmin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventChangeAdmin.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 *EventChangeAdmin) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventChangeAdmin.Merge(m, src) +} +func (m *EventChangeAdmin) XXX_Size() int { + return m.Size() +} +func (m *EventChangeAdmin) XXX_DiscardUnknown() { + xxx_messageInfo_EventChangeAdmin.DiscardUnknown(m) +} + +var xxx_messageInfo_EventChangeAdmin proto.InternalMessageInfo + +func (m *EventChangeAdmin) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *EventChangeAdmin) GetOldAdmin() string { + if m != nil { + return m.OldAdmin + } + return "" +} + +func (m *EventChangeAdmin) GetNewAdmin() string { + if m != nil { + return m.NewAdmin + } + return "" +} + +func init() { + proto.RegisterType((*EventCreateDenom)(nil), "nibiru.tokenfactory.v1.EventCreateDenom") + proto.RegisterType((*EventChangeAdmin)(nil), "nibiru.tokenfactory.v1.EventChangeAdmin") +} + +func init() { + proto.RegisterFile("nibiru/tokenfactory/v1/event.proto", fileDescriptor_a46c3c7b7d022093) +} + +var fileDescriptor_a46c3c7b7d022093 = []byte{ + // 237 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xcb, 0x4c, 0xca, + 0x2c, 0x2a, 0xd5, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, + 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x83, 0xa8, 0xd1, 0x43, 0x56, 0xa3, 0x57, 0x66, 0xa8, 0xe4, 0xc4, 0x25, 0xe0, 0x0a, 0x52, 0xe6, + 0x5c, 0x94, 0x9a, 0x58, 0x92, 0xea, 0x92, 0x9a, 0x97, 0x9f, 0x2b, 0x24, 0xc2, 0xc5, 0x9a, 0x02, + 0x62, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x41, 0x38, 0x42, 0x12, 0x5c, 0xec, 0xc9, 0x20, + 0x45, 0xf9, 0x45, 0x12, 0x4c, 0x60, 0x71, 0x18, 0x57, 0x29, 0x09, 0x66, 0x46, 0x46, 0x62, 0x5e, + 0x7a, 0xaa, 0x63, 0x4a, 0x6e, 0x66, 0x1e, 0x0e, 0x33, 0xa4, 0xb9, 0x38, 0xf3, 0x73, 0x52, 0xe2, + 0x13, 0x41, 0x4a, 0x24, 0x98, 0xc1, 0x32, 0x1c, 0xf9, 0x39, 0x29, 0x10, 0x2d, 0xd2, 0x5c, 0x9c, + 0x79, 0xa9, 0xe5, 0x50, 0x49, 0x88, 0x15, 0x1c, 0x79, 0xa9, 0xe5, 0x60, 0x49, 0x27, 0x9f, 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, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, + 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xf7, 0x03, 0x7b, 0xd2, 0x39, 0x23, 0x31, 0x33, 0x4f, 0x1f, 0x1a, + 0x28, 0x15, 0xa8, 0xc1, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x14, 0x63, 0x40, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xb0, 0xbe, 0x29, 0x3a, 0x01, 0x00, 0x00, +} + +func (m *EventCreateDenom) 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 *EventCreateDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCreateDenom) 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 = encodeVarintEvent(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x12 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventChangeAdmin) 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 *EventChangeAdmin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventChangeAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OldAdmin) > 0 { + i -= len(m.OldAdmin) + copy(dAtA[i:], m.OldAdmin) + i = encodeVarintEvent(dAtA, i, uint64(len(m.OldAdmin))) + i-- + dAtA[i] = 0x1a + } + if len(m.NewAdmin) > 0 { + i -= len(m.NewAdmin) + copy(dAtA[i:], m.NewAdmin) + i = encodeVarintEvent(dAtA, i, uint64(len(m.NewAdmin))) + i-- + dAtA[i] = 0x12 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventCreateDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventChangeAdmin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.NewAdmin) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.OldAdmin) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventCreateDenom) 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 ErrIntOverflowEvent + } + 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: EventCreateDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventCreateDenom: 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 ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + 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 Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventChangeAdmin) 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 ErrIntOverflowEvent + } + 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: EventChangeAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventChangeAdmin: 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 ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + 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 NewAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OldAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(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, ErrIntOverflowEvent + } + 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, ErrIntOverflowEvent + } + 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, ErrIntOverflowEvent + } + 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, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go index 9c61c26b7..f6771b81c 100644 --- a/x/tokenfactory/types/genesis.go +++ b/x/tokenfactory/types/genesis.go @@ -38,7 +38,7 @@ func (gs GenesisState) Validate() error { if genesisDenom.AuthorityMetadata.Admin != "" { _, err = sdk.AccAddressFromBech32(genesisDenom.AuthorityMetadata.Admin) if err != nil { - return ErrInvalidAuthorityMetadata.Wrapf("Invalid admin address (%s)", err) + return ErrInvalidAdmin.Wrapf("Invalid admin address (%s)", err) } } } diff --git a/x/tokenfactory/types/query.pb.go b/x/tokenfactory/types/query.pb.go index c3af25340..63b808876 100644 --- a/x/tokenfactory/types/query.pb.go +++ b/x/tokenfactory/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/x/bank/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -112,9 +113,204 @@ func (m *QueryParamsResponse) GetParams() ModuleParams { return ModuleParams{} } +// QueryDenomsRequest: gRPC query for all denoms registered for a creator +type QueryDenomsRequest struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *QueryDenomsRequest) Reset() { *m = QueryDenomsRequest{} } +func (m *QueryDenomsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDenomsRequest) ProtoMessage() {} +func (*QueryDenomsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b7d8bbc34d6c2a91, []int{2} +} +func (m *QueryDenomsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomsRequest.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 *QueryDenomsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomsRequest.Merge(m, src) +} +func (m *QueryDenomsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomsRequest proto.InternalMessageInfo + +func (m *QueryDenomsRequest) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +// QueryDenomsResponse: All registered denoms for a creator +type QueryDenomsResponse struct { + Denoms []string `protobuf:"bytes,1,rep,name=denoms,proto3" json:"denoms,omitempty"` +} + +func (m *QueryDenomsResponse) Reset() { *m = QueryDenomsResponse{} } +func (m *QueryDenomsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDenomsResponse) ProtoMessage() {} +func (*QueryDenomsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7d8bbc34d6c2a91, []int{3} +} +func (m *QueryDenomsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomsResponse.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 *QueryDenomsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomsResponse.Merge(m, src) +} +func (m *QueryDenomsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomsResponse proto.InternalMessageInfo + +func (m *QueryDenomsResponse) GetDenoms() []string { + if m != nil { + return m.Denoms + } + return nil +} + +// QueryDenomInfoRequest: gRPC query for the denom admin and x/bank metadata +type QueryDenomInfoRequest struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *QueryDenomInfoRequest) Reset() { *m = QueryDenomInfoRequest{} } +func (m *QueryDenomInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDenomInfoRequest) ProtoMessage() {} +func (*QueryDenomInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b7d8bbc34d6c2a91, []int{4} +} +func (m *QueryDenomInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomInfoRequest.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 *QueryDenomInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomInfoRequest.Merge(m, src) +} +func (m *QueryDenomInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomInfoRequest proto.InternalMessageInfo + +func (m *QueryDenomInfoRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +// QueryDenomInfoResponse: All registered denoms for a creator +type QueryDenomInfoResponse struct { + // Admin of the token factory denom + Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. + Metadata types.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"` +} + +func (m *QueryDenomInfoResponse) Reset() { *m = QueryDenomInfoResponse{} } +func (m *QueryDenomInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDenomInfoResponse) ProtoMessage() {} +func (*QueryDenomInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b7d8bbc34d6c2a91, []int{5} +} +func (m *QueryDenomInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDenomInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDenomInfoResponse.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 *QueryDenomInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDenomInfoResponse.Merge(m, src) +} +func (m *QueryDenomInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDenomInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDenomInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDenomInfoResponse proto.InternalMessageInfo + +func (m *QueryDenomInfoResponse) GetAdmin() string { + if m != nil { + return m.Admin + } + return "" +} + +func (m *QueryDenomInfoResponse) GetMetadata() types.Metadata { + if m != nil { + return m.Metadata + } + return types.Metadata{} +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "nibiru.tokenfactory.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "nibiru.tokenfactory.v1.QueryParamsResponse") + proto.RegisterType((*QueryDenomsRequest)(nil), "nibiru.tokenfactory.v1.QueryDenomsRequest") + proto.RegisterType((*QueryDenomsResponse)(nil), "nibiru.tokenfactory.v1.QueryDenomsResponse") + proto.RegisterType((*QueryDenomInfoRequest)(nil), "nibiru.tokenfactory.v1.QueryDenomInfoRequest") + proto.RegisterType((*QueryDenomInfoResponse)(nil), "nibiru.tokenfactory.v1.QueryDenomInfoResponse") } func init() { @@ -122,26 +318,38 @@ func init() { } var fileDescriptor_b7d8bbc34d6c2a91 = []byte{ - // 295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xcb, 0x4c, 0xca, - 0x2c, 0x2a, 0xd5, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, - 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, - 0x83, 0xa8, 0xd1, 0x43, 0x56, 0xa3, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, - 0xa2, 0x0f, 0x62, 0x41, 0x54, 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, 0x65, 0x71, - 0xd9, 0x57, 0x5c, 0x92, 0x58, 0x92, 0x0a, 0x51, 0xa3, 0x24, 0xc2, 0x25, 0x14, 0x08, 0xb2, 0x3e, - 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x38, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x29, 0x92, 0x4b, - 0x18, 0x45, 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x89, 0x8b, 0xad, 0x00, 0x2c, 0x22, - 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0xa4, 0xa2, 0x87, 0xdd, 0xb5, 0x7a, 0xbe, 0xf9, 0x29, 0xa5, - 0x39, 0xa9, 0x10, 0xdd, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0x75, 0x1a, 0x4d, 0x66, - 0xe4, 0x62, 0x05, 0x9b, 0x2d, 0xd4, 0xc9, 0xc8, 0xc5, 0x06, 0x51, 0x22, 0xa4, 0x85, 0xcb, 0x20, - 0x4c, 0xb7, 0x49, 0x69, 0x13, 0xa5, 0x16, 0xe2, 0x62, 0x25, 0xb5, 0xa6, 0xcb, 0x4f, 0x26, 0x33, - 0x29, 0x08, 0xc9, 0xe9, 0xe3, 0x08, 0x0b, 0x88, 0xab, 0x9c, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, - 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, - 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, - 0x57, 0xdf, 0x0f, 0x6c, 0x86, 0x73, 0x46, 0x62, 0x66, 0x1e, 0xcc, 0xbc, 0x0a, 0x54, 0x13, 0x4b, - 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x61, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x3b, - 0x5a, 0x49, 0x29, 0xf1, 0x01, 0x00, 0x00, + // 495 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0xe3, 0x96, 0x1c, 0xc4, 0x6c, 0x26, 0x44, 0x51, 0x04, 0x47, 0x64, 0x21, 0x14, 0x05, + 0x62, 0x93, 0xf0, 0x01, 0x90, 0x02, 0x0b, 0x12, 0x45, 0x90, 0x0d, 0x36, 0x5f, 0xe2, 0x5c, 0x4f, + 0xed, 0xf9, 0x5d, 0xcf, 0xbe, 0x88, 0xa8, 0xea, 0xc2, 0xc6, 0x86, 0xd4, 0x9d, 0xcf, 0x53, 0x31, + 0x55, 0x62, 0x61, 0x42, 0x28, 0xe1, 0x83, 0xa0, 0xda, 0xbe, 0xd0, 0x00, 0x21, 0xdd, 0xfc, 0xec, + 0x9f, 0xdf, 0xff, 0xef, 0xf7, 0xbf, 0xc3, 0x54, 0x25, 0x51, 0x92, 0x17, 0xdc, 0xc0, 0x81, 0x54, + 0x53, 0x31, 0x36, 0x90, 0xcf, 0xf9, 0xac, 0xcf, 0x8f, 0x0a, 0x99, 0xcf, 0x59, 0x96, 0x83, 0x01, + 0xd2, 0x70, 0x0c, 0xbb, 0xcc, 0xb0, 0x59, 0xbf, 0x55, 0x8f, 0x21, 0x06, 0x8b, 0xf0, 0x8b, 0x95, + 0xa3, 0x5b, 0x77, 0x62, 0x80, 0xf8, 0x50, 0x72, 0x91, 0x25, 0x5c, 0x28, 0x05, 0x46, 0x98, 0x04, + 0x94, 0xf6, 0xa7, 0xe1, 0x18, 0x74, 0x0a, 0x9a, 0x47, 0x42, 0x1d, 0xf0, 0x59, 0x3f, 0x92, 0x46, + 0xf4, 0x6d, 0xe1, 0xcf, 0x37, 0xf9, 0xd1, 0x46, 0x18, 0xe9, 0x18, 0x5a, 0xc7, 0xe4, 0xcd, 0x85, + 0xbd, 0xd7, 0x22, 0x17, 0xa9, 0x1e, 0xc9, 0xa3, 0x42, 0x6a, 0x43, 0xdf, 0xe2, 0x5b, 0x6b, 0xbb, + 0x3a, 0x03, 0xa5, 0x25, 0x19, 0xe2, 0x20, 0xb3, 0x3b, 0x4d, 0xd4, 0x46, 0x9d, 0x9b, 0x83, 0xfb, + 0xec, 0xdf, 0xaf, 0x61, 0x7b, 0x30, 0x29, 0x0e, 0xa5, 0xbb, 0x3d, 0xbc, 0x76, 0xf6, 0xfd, 0x5e, + 0x65, 0xe4, 0x6f, 0x52, 0xe6, 0x05, 0x9f, 0x4b, 0x05, 0x2b, 0x41, 0xd2, 0xc4, 0xd7, 0xc7, 0xb9, + 0x14, 0x06, 0x72, 0xdb, 0xba, 0x36, 0x2a, 0x4b, 0xda, 0xf3, 0x56, 0x4a, 0xde, 0x5b, 0x69, 0xe0, + 0x60, 0x62, 0x77, 0x9a, 0xa8, 0xbd, 0xdb, 0xa9, 0x8d, 0x7c, 0x45, 0x7b, 0xf8, 0xf6, 0x6f, 0xfc, + 0x85, 0x9a, 0x42, 0xa9, 0x50, 0xc7, 0x55, 0x8b, 0xf8, 0xfe, 0xae, 0xa0, 0x80, 0x1b, 0x7f, 0xe2, + 0x5e, 0xa0, 0x8e, 0xab, 0x62, 0x92, 0x26, 0xaa, 0xe4, 0x6d, 0x41, 0x9e, 0xe2, 0x1b, 0xa9, 0x34, + 0x62, 0x22, 0x8c, 0x68, 0xee, 0xd8, 0x19, 0xdc, 0x65, 0x2e, 0x05, 0x66, 0x07, 0xef, 0x53, 0x60, + 0x7b, 0x1e, 0xf2, 0x8f, 0x5f, 0x5d, 0x1a, 0x7c, 0xd9, 0xc5, 0x55, 0xab, 0x48, 0x3e, 0x22, 0x1c, + 0xb8, 0x09, 0x91, 0xee, 0xa6, 0x39, 0xfe, 0x1d, 0x4d, 0xeb, 0xe1, 0x95, 0x58, 0xf7, 0x08, 0xfa, + 0xe0, 0xc3, 0xd7, 0x9f, 0xa7, 0x3b, 0x6d, 0x12, 0xf2, 0x0d, 0x9f, 0x82, 0x0b, 0x85, 0x9c, 0x22, + 0x1c, 0xb8, 0x01, 0x6f, 0xf1, 0xb2, 0x96, 0xda, 0x16, 0x2f, 0xeb, 0x89, 0xd1, 0xc7, 0xd6, 0x4b, + 0x97, 0x74, 0x36, 0x79, 0x71, 0x09, 0xf2, 0x63, 0x9f, 0xfc, 0x09, 0xf9, 0x8c, 0x70, 0x6d, 0x15, + 0x0c, 0xe9, 0x6d, 0x17, 0xbb, 0x94, 0x77, 0x8b, 0x5d, 0x15, 0xf7, 0xf6, 0x06, 0xd6, 0xde, 0x23, + 0xd2, 0xfd, 0xaf, 0xbd, 0x5e, 0xa2, 0xa6, 0xc0, 0x8f, 0xed, 0xfa, 0x64, 0xf8, 0xf2, 0x6c, 0x11, + 0xa2, 0xf3, 0x45, 0x88, 0x7e, 0x2c, 0x42, 0xf4, 0x69, 0x19, 0x56, 0xce, 0x97, 0x61, 0xe5, 0xdb, + 0x32, 0xac, 0xbc, 0x1b, 0xc4, 0x89, 0xd9, 0x2f, 0x22, 0x36, 0x86, 0x94, 0xbf, 0xb2, 0xfd, 0x9e, + 0xed, 0x8b, 0x44, 0x95, 0xbd, 0xdf, 0xaf, 0x77, 0x37, 0xf3, 0x4c, 0xea, 0x28, 0xb0, 0x7f, 0xe4, + 0x93, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xed, 0x27, 0xd8, 0x56, 0x47, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,6 +366,10 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Params retrieves the module params Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Denoms retrieves all registered denoms for a given creator + Denoms(ctx context.Context, in *QueryDenomsRequest, opts ...grpc.CallOption) (*QueryDenomsResponse, error) + // DenomInfo retrieves the denom metadata and admin info + DenomInfo(ctx context.Context, in *QueryDenomInfoRequest, opts ...grpc.CallOption) (*QueryDenomInfoResponse, error) } type queryClient struct { @@ -177,10 +389,32 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) Denoms(ctx context.Context, in *QueryDenomsRequest, opts ...grpc.CallOption) (*QueryDenomsResponse, error) { + out := new(QueryDenomsResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Query/Denoms", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DenomInfo(ctx context.Context, in *QueryDenomInfoRequest, opts ...grpc.CallOption) (*QueryDenomInfoResponse, error) { + out := new(QueryDenomInfoResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Query/DenomInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params retrieves the module params Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Denoms retrieves all registered denoms for a given creator + Denoms(context.Context, *QueryDenomsRequest) (*QueryDenomsResponse, error) + // DenomInfo retrieves the denom metadata and admin info + DenomInfo(context.Context, *QueryDenomInfoRequest) (*QueryDenomInfoResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -190,6 +424,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) Denoms(ctx context.Context, req *QueryDenomsRequest) (*QueryDenomsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Denoms not implemented") +} +func (*UnimplementedQueryServer) DenomInfo(ctx context.Context, req *QueryDenomInfoRequest) (*QueryDenomInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenomInfo not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -213,6 +453,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_Denoms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDenomsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Denoms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.tokenfactory.v1.Query/Denoms", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Denoms(ctx, req.(*QueryDenomsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DenomInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDenomInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DenomInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.tokenfactory.v1.Query/DenomInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DenomInfo(ctx, req.(*QueryDenomInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.tokenfactory.v1.Query", HandlerType: (*QueryServer)(nil), @@ -221,6 +497,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "Denoms", + Handler: _Query_Denoms_Handler, + }, + { + MethodName: "DenomInfo", + Handler: _Query_DenomInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/tokenfactory/v1/query.proto", @@ -282,6 +566,138 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryDenomsRequest) 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 *QueryDenomsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomsRequest) 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 *QueryDenomsResponse) 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 *QueryDenomsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomsResponse) 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 (m *QueryDenomInfoRequest) 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 *QueryDenomInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomInfoRequest) 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 *QueryDenomInfoResponse) 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 *QueryDenomInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDenomInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Admin) > 0 { + i -= len(m.Admin) + copy(dAtA[i:], m.Admin) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Admin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -313,14 +729,70 @@ func (m *QueryParamsResponse) Size() (n int) { 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 *QueryDenomsRequest) 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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) + +func (m *QueryDenomsResponse) 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 (m *QueryDenomInfoRequest) 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 *QueryDenomInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Admin) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Metadata.Size() + 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 *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx @@ -452,6 +924,367 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryDenomsRequest) 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: QueryDenomsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomsRequest: 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 *QueryDenomsResponse) 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: QueryDenomsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomsResponse: 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 (m *QueryDenomInfoRequest) 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: QueryDenomInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomInfoRequest: 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 *QueryDenomInfoResponse) 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: QueryDenomInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDenomInfoResponse: 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 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.Admin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", 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.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenfactory/types/query.pb.gw.go b/x/tokenfactory/types/query.pb.gw.go index be749518e..47a7f0837 100644 --- a/x/tokenfactory/types/query.pb.gw.go +++ b/x/tokenfactory/types/query.pb.gw.go @@ -51,6 +51,114 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_Denoms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomsRequest + 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.Denoms(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Denoms_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomsRequest + 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.Denoms(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DenomInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomInfoRequest + 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.DenomInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DenomInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDenomInfoRequest + 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.DenomInfo(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. @@ -80,6 +188,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Denoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Denoms_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Denoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DenomInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DenomInfo_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +295,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Denoms_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_Denoms_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_Denoms_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DenomInfo_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_DenomInfo_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_DenomInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "tokenfactory", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "tokenfactory", "v1", "denoms", "creator"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_DenomInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"nibiru", "tokenfactory", "v1", "denom-info", "denom"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Denoms_0 = runtime.ForwardResponseMessage + + forward_Query_DenomInfo_0 = runtime.ForwardResponseMessage ) diff --git a/x/tokenfactory/types/state.go b/x/tokenfactory/types/state.go index c50907d1b..782c7c087 100644 --- a/x/tokenfactory/types/state.go +++ b/x/tokenfactory/types/state.go @@ -18,15 +18,9 @@ func DefaultModuleParams() ModuleParams { } func (params ModuleParams) Validate() error { - return validateDenomCreationGasConsume(params.DenomCreationGasConsume) -} - -func validateDenomCreationGasConsume(i interface{}) error { - _, ok := i.(uint64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) + if params.DenomCreationGasConsume < 1 { + return ErrInvalidModuleParams.Wrap("cannot set gas creation cost to zero") } - return nil } @@ -82,6 +76,8 @@ func (denomStr DenomStr) Validate() error { return err } +func (denomStr DenomStr) String() string { return string(denomStr) } + func (genDenom GenesisDenom) Validate() error { return DenomStr(genDenom.Denom).Validate() } diff --git a/x/tokenfactory/types/state_test.go b/x/tokenfactory/types/state_test.go index 0c174b3c7..1b9a3eacb 100644 --- a/x/tokenfactory/types/state_test.go +++ b/x/tokenfactory/types/state_test.go @@ -1,11 +1,13 @@ package types_test import ( + fmt "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) @@ -38,7 +40,86 @@ func TestDenomStr_Validate(t *testing.T) { assert.NoError(t, tfDenom.Validate()) assert.NotPanics(t, func() { _ = tfDenom.DefaultBankMetadata() + _ = tc.denom.MustToStruct() }) + + assert.NoError(t, types.GenesisDenom{ + Denom: tc.denom.String(), + AuthorityMetadata: types.DenomAuthorityMetadata{}, + }.Validate()) + }) + } +} + +func TestModuleParamsValidate(t *testing.T) { + params := types.DefaultModuleParams() + require.NoError(t, params.Validate()) + + params.DenomCreationGasConsume = 0 + require.Error(t, params.Validate()) +} + +func TestGenesisState(t *testing.T) { + var happyGenDenoms []types.GenesisDenom + for i := 0; i < 5; i++ { + creator := testutil.AccAddress() + lettersIdx := i * 2 + happyGenDenoms = append(happyGenDenoms, types.GenesisDenom{ + Denom: types.TFDenom{ + Creator: creator.String(), + Subdenom: testutil.Latin.Letters[lettersIdx : lettersIdx+4], + }.String(), + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: creator.String(), + }, + }) + } + + for idx, tc := range []struct { + name string + genState types.GenesisState + wantErr string + }{ + {name: "default", wantErr: "", genState: *types.DefaultGenesis()}, + {name: "sad: params", wantErr: types.ErrInvalidModuleParams.Error(), + genState: types.GenesisState{ + Params: types.ModuleParams{ + DenomCreationGasConsume: 0, + }, + FactoryDenoms: happyGenDenoms, + }, + }, + {name: "sad: duplicate", wantErr: "duplicate denom", + genState: types.GenesisState{ + Params: types.DefaultModuleParams(), + FactoryDenoms: []types.GenesisDenom{ + happyGenDenoms[0], happyGenDenoms[0], happyGenDenoms[1], + }, + }, + }, + {name: "sad: invalid admin", wantErr: types.ErrInvalidAdmin.Error(), + genState: types.GenesisState{ + Params: types.DefaultModuleParams(), + FactoryDenoms: []types.GenesisDenom{ + happyGenDenoms[0], + { + Denom: happyGenDenoms[1].Denom, + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: "not_an_address", + }, + }, + }, + }, + }, + } { + t.Run(fmt.Sprintf("%v %s", idx, tc.name), func(t *testing.T) { + err := tc.genState.Validate() + if tc.wantErr != "" { + assert.Error(t, err) + require.Contains(t, err.Error(), tc.wantErr) + return + } + require.NoError(t, err) }) } } diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index 7ec6c4c0d..3f3acddea 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -6,10 +6,18 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/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. @@ -23,19 +31,350 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgCreateDenom: sdk.Msg that registers an a token factory denom. +// A denom has the form "tf/[creatorAddr]/[subdenom]". +// - Denoms become unique x/bank tokens, so the creator-subdenom pair that +// defines a denom cannot be reused. +// - The resulting denom's admin is originally set to be the creator, but the +// admin can be changed later. +type MsgCreateDenom struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + // subdenom can be up to 44 "alphanumeric" characters long. + Subdenom string `protobuf:"bytes,2,opt,name=subdenom,proto3" json:"subdenom,omitempty" yaml:"subdenom"` +} + +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_4c78bacd179e004d, []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) GetSubdenom() string { + if m != nil { + return m.Subdenom + } + return "" +} + +// MsgCreateDenomResponse is the return value of MsgCreateDenom +type MsgCreateDenomResponse struct { + // NewTokenDenom: identifier for the newly created token factory denom. + 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{} } +func (m *MsgCreateDenomResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateDenomResponse) ProtoMessage() {} +func (*MsgCreateDenomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c78bacd179e004d, []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 (m *MsgCreateDenomResponse) GetNewTokenDenom() string { + if m != nil { + return m.NewTokenDenom + } + return "" +} + +// MsgChangeAdmin is the sdk.Msg type for allowing an admin account to change +// admin of a denom to a new account +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=new_admin,json=newAdmin,proto3" json:"new_admin,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_4c78bacd179e004d, []int{2} +} +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 "" +} + +// MsgChangeAdminResponse is the gRPC response for the MsgChangeAdmin TxMsg. +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_4c78bacd179e004d, []int{3} +} +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 + +// MsgUpdateModuleParams: sdk.Msg for updating the x/tokenfactory module params +type MsgUpdateModuleParams struct { + // Authority: Address of the governance module account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Params ModuleParams `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateModuleParams) Reset() { *m = MsgUpdateModuleParams{} } +func (m *MsgUpdateModuleParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateModuleParams) ProtoMessage() {} +func (*MsgUpdateModuleParams) Descriptor() ([]byte, []int) { + return fileDescriptor_4c78bacd179e004d, []int{4} +} +func (m *MsgUpdateModuleParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateModuleParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateModuleParams.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 *MsgUpdateModuleParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateModuleParams.Merge(m, src) +} +func (m *MsgUpdateModuleParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateModuleParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateModuleParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateModuleParams proto.InternalMessageInfo + +func (m *MsgUpdateModuleParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateModuleParams) GetParams() ModuleParams { + if m != nil { + return m.Params + } + return ModuleParams{} +} + +// MsgUpdateModuleParamsResponse is the gRPC response for the +// MsgUpdateModuleParams TxMsg. +type MsgUpdateModuleParamsResponse struct { +} + +func (m *MsgUpdateModuleParamsResponse) Reset() { *m = MsgUpdateModuleParamsResponse{} } +func (m *MsgUpdateModuleParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateModuleParamsResponse) ProtoMessage() {} +func (*MsgUpdateModuleParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c78bacd179e004d, []int{5} +} +func (m *MsgUpdateModuleParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateModuleParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateModuleParamsResponse.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 *MsgUpdateModuleParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateModuleParamsResponse.Merge(m, src) +} +func (m *MsgUpdateModuleParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateModuleParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateModuleParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateModuleParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateDenom)(nil), "nibiru.tokenfactory.v1.MsgCreateDenom") + proto.RegisterType((*MsgCreateDenomResponse)(nil), "nibiru.tokenfactory.v1.MsgCreateDenomResponse") + proto.RegisterType((*MsgChangeAdmin)(nil), "nibiru.tokenfactory.v1.MsgChangeAdmin") + proto.RegisterType((*MsgChangeAdminResponse)(nil), "nibiru.tokenfactory.v1.MsgChangeAdminResponse") + proto.RegisterType((*MsgUpdateModuleParams)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParams") + proto.RegisterType((*MsgUpdateModuleParamsResponse)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParamsResponse") +} + func init() { proto.RegisterFile("nibiru/tokenfactory/v1/tx.proto", fileDescriptor_4c78bacd179e004d) } var fileDescriptor_4c78bacd179e004d = []byte{ - // 139 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0xcb, 0x4c, 0xca, - 0x2c, 0x2a, 0xd5, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, - 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0x28, 0xd0, - 0x43, 0x56, 0xa0, 0x57, 0x66, 0x68, 0xc4, 0xca, 0xc5, 0xec, 0x5b, 0x9c, 0xee, 0xe4, 0x73, 0xe2, - 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, - 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, - 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x7e, 0x60, 0x33, 0x9c, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0xa1, 0x16, - 0x56, 0xa0, 0x5a, 0x59, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xb6, 0xd3, 0x18, 0x10, 0x00, - 0x00, 0xff, 0xff, 0x34, 0xa3, 0x58, 0xbd, 0x96, 0x00, 0x00, 0x00, + // 557 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x4f, 0x6f, 0x12, 0x41, + 0x18, 0xc6, 0xd9, 0x56, 0x49, 0x99, 0xda, 0x3f, 0xae, 0x88, 0x48, 0xe2, 0xae, 0x99, 0x98, 0x46, + 0x4d, 0xba, 0x1b, 0x30, 0x7a, 0xe8, 0xad, 0xd4, 0xa3, 0x18, 0xb3, 0xea, 0xc5, 0x98, 0x90, 0x59, + 0xf6, 0x75, 0xd9, 0xc8, 0xce, 0x90, 0x9d, 0x01, 0x8a, 0x47, 0x3f, 0x81, 0x27, 0xbf, 0x80, 0x5f, + 0xc0, 0x83, 0x1f, 0xa2, 0x37, 0x1b, 0x4f, 0x9e, 0x36, 0x06, 0x0e, 0xde, 0xf9, 0x04, 0x66, 0x67, + 0x86, 0x02, 0x96, 0x92, 0xf6, 0x06, 0xfb, 0xfc, 0xe6, 0x79, 0x9e, 0x37, 0xf3, 0x0e, 0xb2, 0x69, + 0xe4, 0x47, 0x49, 0xcf, 0x15, 0xec, 0x23, 0xd0, 0x0f, 0xa4, 0x25, 0x58, 0x32, 0x74, 0xfb, 0x55, + 0x57, 0x1c, 0x3b, 0xdd, 0x84, 0x09, 0x66, 0x96, 0x14, 0xe0, 0xcc, 0x03, 0x4e, 0xbf, 0x5a, 0x29, + 0x86, 0x2c, 0x64, 0x12, 0x71, 0xb3, 0x5f, 0x8a, 0xae, 0x58, 0x2d, 0xc6, 0x63, 0xc6, 0x5d, 0x9f, + 0x70, 0x70, 0xfb, 0x55, 0x1f, 0x04, 0xa9, 0xba, 0x2d, 0x16, 0x51, 0xad, 0xdf, 0xd1, 0x7a, 0xcc, + 0xc3, 0x2c, 0x25, 0xe6, 0xa1, 0x16, 0xee, 0x2a, 0xa1, 0xa9, 0x1c, 0xd5, 0x1f, 0x2d, 0xe1, 0x0b, + 0x2a, 0x72, 0x41, 0x04, 0x28, 0x06, 0x77, 0xd0, 0x76, 0x83, 0x87, 0x47, 0x09, 0x10, 0x01, 0xcf, + 0x81, 0xb2, 0xd8, 0x7c, 0x84, 0xf2, 0x1c, 0x68, 0x00, 0x49, 0xd9, 0xb8, 0x6f, 0x3c, 0x2c, 0xd4, + 0x6f, 0x4e, 0x52, 0x7b, 0x6b, 0x48, 0xe2, 0xce, 0x01, 0x56, 0xdf, 0xb1, 0xa7, 0x01, 0xd3, 0x45, + 0x1b, 0xbc, 0xe7, 0x07, 0xd9, 0xb1, 0xf2, 0x9a, 0x84, 0x6f, 0x4d, 0x52, 0x7b, 0x47, 0xc3, 0x5a, + 0xc1, 0xde, 0x19, 0x84, 0xdf, 0xa3, 0xd2, 0x62, 0x9a, 0x07, 0xbc, 0xcb, 0x28, 0x07, 0xb3, 0x8e, + 0x76, 0x28, 0x0c, 0x9a, 0xb2, 0x6a, 0x53, 0x39, 0xaa, 0xf8, 0xca, 0x24, 0xb5, 0x4b, 0xca, 0xf1, + 0x3f, 0x00, 0x7b, 0x5b, 0x14, 0x06, 0x6f, 0xb2, 0x0f, 0xd2, 0x0b, 0x7f, 0x35, 0xd4, 0x30, 0x6d, + 0x42, 0x43, 0x38, 0x0c, 0xe2, 0x88, 0x5e, 0x65, 0x98, 0x3d, 0x74, 0x7d, 0x7e, 0x92, 0xdd, 0x49, + 0x6a, 0xdf, 0x50, 0xa4, 0x4e, 0x53, 0xb2, 0x59, 0x45, 0x85, 0xac, 0x08, 0xc9, 0xfc, 0xcb, 0xeb, + 0x92, 0x2d, 0x4e, 0x52, 0x7b, 0x77, 0xd6, 0x51, 0x4a, 0xd8, 0xdb, 0xa0, 0x30, 0x90, 0x2d, 0x70, + 0x59, 0x8d, 0x3d, 0xeb, 0x35, 0x1d, 0x1b, 0x7f, 0x33, 0xd0, 0xed, 0x06, 0x0f, 0xdf, 0x76, 0x03, + 0x22, 0xa0, 0xc1, 0x82, 0x5e, 0x07, 0x5e, 0x91, 0x84, 0xc4, 0xdc, 0x7c, 0x86, 0x0a, 0xa4, 0x27, + 0xda, 0x2c, 0x89, 0xc4, 0x50, 0x97, 0x2f, 0xff, 0xfa, 0xb1, 0x5f, 0xd4, 0x37, 0x7c, 0x18, 0x04, + 0x09, 0x70, 0xfe, 0x5a, 0x24, 0x11, 0x0d, 0xbd, 0x19, 0x6a, 0xd6, 0x51, 0xbe, 0x2b, 0x1d, 0xe4, + 0x1c, 0x9b, 0xb5, 0x07, 0xce, 0xf2, 0x3d, 0x74, 0xe6, 0xd3, 0xea, 0xd7, 0x4e, 0x52, 0x3b, 0xe7, + 0xe9, 0x93, 0x07, 0xdb, 0x9f, 0xff, 0x7e, 0x7f, 0x3c, 0xf3, 0xc4, 0x36, 0xba, 0xb7, 0xb4, 0xe4, + 0x74, 0x8c, 0xda, 0xcf, 0x35, 0xb4, 0xde, 0xe0, 0xa1, 0x09, 0x68, 0x73, 0x7e, 0x95, 0xf6, 0x2e, + 0xcc, 0x5e, 0x58, 0x82, 0x8a, 0x73, 0x39, 0xee, 0x6c, 0x59, 0xb2, 0x98, 0xb9, 0x4b, 0x5e, 0x19, + 0x33, 0xe3, 0x56, 0xc7, 0x9c, 0xbf, 0x1c, 0xf3, 0x13, 0x32, 0x97, 0x5c, 0xcc, 0xfe, 0x0a, 0x97, + 0xf3, 0x78, 0xe5, 0xe9, 0x95, 0xf0, 0x69, 0x76, 0xfd, 0xc5, 0xc9, 0xc8, 0x32, 0x4e, 0x47, 0x96, + 0xf1, 0x67, 0x64, 0x19, 0x5f, 0xc6, 0x56, 0xee, 0x74, 0x6c, 0xe5, 0x7e, 0x8f, 0xad, 0xdc, 0xbb, + 0x5a, 0x18, 0x89, 0x76, 0xcf, 0x77, 0x5a, 0x2c, 0x76, 0x5f, 0x4a, 0xeb, 0xa3, 0x36, 0x89, 0xa8, + 0xab, 0x1f, 0xfb, 0xf1, 0xe2, 0x73, 0x17, 0xc3, 0x2e, 0x70, 0x3f, 0x2f, 0x1f, 0xfb, 0x93, 0x7f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xe6, 0x6f, 0xc2, 0xb5, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -50,6 +389,12 @@ 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: registers a token factory denom. + CreateDenom(ctx context.Context, in *MsgCreateDenom, opts ...grpc.CallOption) (*MsgCreateDenomResponse, error) + ChangeAdmin(ctx context.Context, in *MsgChangeAdmin, opts ...grpc.CallOption) (*MsgChangeAdminResponse, error) + // UpdateModuleParams: A governance operation for updating the x/tokenfactory + // module parameters. + UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleParams, opts ...grpc.CallOption) (*MsgUpdateModuleParamsResponse, error) } type msgClient struct { @@ -60,22 +405,1072 @@ 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, "/nibiru.tokenfactory.v1.Msg/CreateDenom", 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, "/nibiru.tokenfactory.v1.Msg/ChangeAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleParams, opts ...grpc.CallOption) (*MsgUpdateModuleParamsResponse, error) { + out := new(MsgUpdateModuleParamsResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/UpdateModuleParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + // CreateDenom: registers a token factory denom. + CreateDenom(context.Context, *MsgCreateDenom) (*MsgCreateDenomResponse, error) + ChangeAdmin(context.Context, *MsgChangeAdmin) (*MsgChangeAdminResponse, error) + // UpdateModuleParams: A governance operation for updating the x/tokenfactory + // module parameters. + UpdateModuleParams(context.Context, *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, 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) ChangeAdmin(ctx context.Context, req *MsgChangeAdmin) (*MsgChangeAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChangeAdmin not implemented") +} +func (*UnimplementedMsgServer) UpdateModuleParams(ctx context.Context, req *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateModuleParams 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: "/nibiru.tokenfactory.v1.Msg/CreateDenom", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateDenom(ctx, req.(*MsgCreateDenom)) + } + 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: "/nibiru.tokenfactory.v1.Msg/ChangeAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ChangeAdmin(ctx, req.(*MsgChangeAdmin)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateModuleParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateModuleParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateModuleParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.tokenfactory.v1.Msg/UpdateModuleParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateModuleParams(ctx, req.(*MsgUpdateModuleParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.tokenfactory.v1.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "nibiru/tokenfactory/v1/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateDenom", + Handler: _Msg_CreateDenom_Handler, + }, + { + MethodName: "ChangeAdmin", + Handler: _Msg_ChangeAdmin_Handler, + }, + { + MethodName: "UpdateModuleParams", + Handler: _Msg_UpdateModuleParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "nibiru/tokenfactory/v1/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.Subdenom) > 0 { + i -= len(m.Subdenom) + copy(dAtA[i:], m.Subdenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Subdenom))) + 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 + 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 +} + +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 (m *MsgUpdateModuleParams) 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 *MsgUpdateModuleParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateModuleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateModuleParamsResponse) 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 *MsgUpdateModuleParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateModuleParamsResponse) 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.Subdenom) + 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 + l = len(m.NewTokenDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(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 (m *MsgUpdateModuleParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n } + +func (m *MsgUpdateModuleParamsResponse) 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 Subdenom", 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.Subdenom = 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 { + 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:]) + 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 + 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: MsgChangeAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChangeAdmin: 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 Denom", 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.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 + 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 *MsgChangeAdminResponse) 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: MsgChangeAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChangeAdminResponse: 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 *MsgUpdateModuleParams) 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: MsgUpdateModuleParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateModuleParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgUpdateModuleParamsResponse) 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: MsgUpdateModuleParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: 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/tx_msgs.go b/x/tokenfactory/types/tx_msgs.go new file mode 100644 index 000000000..b799b0c0c --- /dev/null +++ b/x/tokenfactory/types/tx_msgs.go @@ -0,0 +1,113 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +) + +// ---------------------------------------------------------------- +// MsgCreateDenom + +var _ sdk.Msg = &MsgCreateDenom{} +var _ legacytx.LegacyMsg = &MsgCreateDenom{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgCreateDenom) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return ErrInvalidCreator.Wrapf("%s: sender address (%s)", err.Error(), m.Sender) + } + + denom := TFDenom{ + Creator: m.Sender, + Subdenom: m.Subdenom, + } + err = denom.Validate() + if err != nil { + return ErrInvalidDenom.Wrap(err.Error()) + } + + return nil +} + +// GetSigners: Impl sdk.Msg. +func (m MsgCreateDenom) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty. +func (m MsgCreateDenom) Route() string { return RouterKey } + +// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, +// intended for utilization within tags +func (m MsgCreateDenom) Type() string { return "create_denom" } + +// GetSignBytes: Get the canonical byte representation of the Msg. Impl +// legacytx.LegacyMsg. +func (m MsgCreateDenom) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// ---------------------------------------------------------------- +// MsgChangeAdmin + +var _ sdk.Msg = &MsgChangeAdmin{} +var _ legacytx.LegacyMsg = &MsgChangeAdmin{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgChangeAdmin) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid sender (%s): %s", m.Sender, err) + } + + _, err = sdk.AccAddressFromBech32(m.NewAdmin) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid new admin (%s): %s", m.NewAdmin, err) + } + + return DenomStr(m.Denom).Validate() +} + +// GetSigners: Impl sdk.Msg. +func (m MsgChangeAdmin) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty. +func (m MsgChangeAdmin) Route() string { return RouterKey } + +// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, +// intended for utilization within tags +func (m MsgChangeAdmin) Type() string { return "create_denom" } + +// GetSignBytes: Get the canonical byte representation of the Msg. Impl +// legacytx.LegacyMsg. +func (m MsgChangeAdmin) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// ---------------------------------------------------------------- +// MsgUpdateModuleParams + +var _ sdk.Msg = &MsgUpdateModuleParams{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgUpdateModuleParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid authority (%s): %s", m.Authority, err) + } + return m.Params.Validate() +} + +// GetSigners: Impl sdk.Msg. +func (m MsgUpdateModuleParams) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{sender} +} diff --git a/x/tokenfactory/types/tx_msgs_test.go b/x/tokenfactory/types/tx_msgs_test.go new file mode 100644 index 000000000..bdc08a776 --- /dev/null +++ b/x/tokenfactory/types/tx_msgs_test.go @@ -0,0 +1,169 @@ +package types_test + +import ( + fmt "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + + "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/tokenfactory/types" +) + +func validateBasicTest(msg sdk.Msg, wantErr string) func(t *testing.T) { + return func(t *testing.T) { + err := msg.ValidateBasic() + if wantErr != "" { + assert.Error(t, err) + require.ErrorContains(t, err, wantErr) + } else { + require.NoError(t, err) + } + } +} + +type ValidateBasicTest struct { + name string + msg sdk.Msg + wantErr string +} + +func TestMsgCreateDenom_ValidateBasic(t *testing.T) { + addr := testutil.AccAddress().String() + for _, tc := range []ValidateBasicTest{ + { + name: "happy", + msg: &types.MsgCreateDenom{ + Sender: addr, + Subdenom: "subdenom", + }, + wantErr: "", + }, + { + name: "sad subdenom", + msg: &types.MsgCreateDenom{ + Sender: addr, + Subdenom: "", + }, + wantErr: "empty subdenom", + }, + { + name: "sad creator", + msg: &types.MsgCreateDenom{ + Sender: "creator", + Subdenom: "subdenom", + }, + wantErr: "invalid creator", + }, + } { + t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + } +} + +func TestMsgChangeAdmin_ValidateBasic(t *testing.T) { + sbf := testutil.AccAddress().String() + validDenom := fmt.Sprintf("tf/%s/ftt", sbf) + for _, tc := range []ValidateBasicTest{ + { + name: "happy", + msg: &types.MsgChangeAdmin{ + Sender: sbf, + Denom: validDenom, + NewAdmin: testutil.AccAddress().String(), + }, + wantErr: "", + }, + { + name: "invalid sender", + msg: &types.MsgChangeAdmin{ + Sender: "sender", + Denom: validDenom, + NewAdmin: testutil.AccAddress().String(), + }, + wantErr: "invalid sender", + }, + { + name: "invalid new admin", + msg: &types.MsgChangeAdmin{ + Sender: sbf, + Denom: validDenom, + NewAdmin: "new-admin", + }, + wantErr: "invalid new admin", + }, + { + name: "invalid denom", + msg: &types.MsgChangeAdmin{ + Sender: sbf, + Denom: "tf/", + NewAdmin: testutil.AccAddress().String(), + }, + wantErr: "denom format error", + }, + } { + t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + } +} + +func TestMsgUpdateModuleParams_ValidateBasic(t *testing.T) { + for _, tc := range []ValidateBasicTest{ + { + name: "happy", + msg: &types.MsgUpdateModuleParams{ + Authority: testutil.AccAddress().String(), + Params: types.DefaultModuleParams(), + }, + wantErr: "", + }, + { + name: "sad authority", + msg: &types.MsgUpdateModuleParams{ + Authority: "authority", + Params: types.DefaultModuleParams(), + }, + wantErr: "invalid authority", + }, + } { + t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + } +} + +func TestTxMsgInterface(t *testing.T) { + creator := testutil.AccAddress().String() + subdenom := testutil.RandLetters(4) + for _, msg := range []legacytx.LegacyMsg{ + &types.MsgCreateDenom{ + Sender: creator, + Subdenom: subdenom, + }, + &types.MsgChangeAdmin{ + Sender: creator, + Denom: fmt.Sprintf("tf/%s/%s", creator, subdenom), + NewAdmin: testutil.AccAddress().String(), + }, + } { + t.Run(msg.Type(), func(t *testing.T) { + require.NotPanics(t, func() { + _ = msg.GetSigners() + _ = msg.Route() + _ = msg.Type() + _ = msg.GetSignBytes() + }) + }) + } + + for _, msg := range []sdk.Msg{ + &types.MsgUpdateModuleParams{ + Authority: testutil.GovModuleAddr().String(), + Params: types.DefaultModuleParams(), + }, + } { + require.NotPanics(t, func() { + _ = msg.GetSigners() + }) + } +} From 9f53504dad8b4e8266939b42fa3d4f661267b2f4 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:58:10 -0500 Subject: [PATCH 05/10] refactor(proto): Use explicit namespacing on proto imports for #1608 (#1614) --- CHANGELOG.md | 5 +- proto/nibiru/devgas/v1/genesis.proto | 5 +- proto/nibiru/devgas/v1/query.proto | 10 ++- proto/nibiru/epochs/v1/genesis.proto | 3 +- proto/nibiru/epochs/v1/query.proto | 5 +- proto/nibiru/inflation/v1/query.proto | 2 +- proto/nibiru/oracle/v1/event.proto | 10 +-- proto/nibiru/oracle/v1/genesis.proto | 18 ++-- proto/nibiru/oracle/v1/query.proto | 15 ++-- proto/nibiru/oracle/v1/tx.proto | 2 +- proto/nibiru/perp/v2/event.proto | 10 +-- proto/nibiru/perp/v2/genesis.proto | 15 ++-- proto/nibiru/perp/v2/query.proto | 22 ++--- proto/nibiru/perp/v2/tx.proto | 8 +- proto/nibiru/spot/v1/event.proto | 10 +-- proto/nibiru/spot/v1/genesis.proto | 4 +- proto/nibiru/spot/v1/pool.proto | 5 +- proto/nibiru/spot/v1/query.proto | 8 +- proto/nibiru/spot/v1/tx.proto | 8 +- proto/nibiru/stablecoin/v1/events.proto | 62 ------------- proto/nibiru/stablecoin/v1/genesis.proto | 17 ---- proto/nibiru/stablecoin/v1/params.proto | 41 --------- proto/nibiru/stablecoin/v1/query.proto | 108 ---------------------- proto/nibiru/stablecoin/v1/tx.proto | 110 ----------------------- proto/nibiru/sudo/v1/event.proto | 2 +- proto/nibiru/sudo/v1/query.proto | 4 +- 26 files changed, 94 insertions(+), 415 deletions(-) delete mode 100644 proto/nibiru/stablecoin/v1/events.proto delete mode 100644 proto/nibiru/stablecoin/v1/genesis.proto delete mode 100644 proto/nibiru/stablecoin/v1/params.proto delete mode 100644 proto/nibiru/stablecoin/v1/query.proto delete mode 100644 proto/nibiru/stablecoin/v1/tx.proto diff --git a/CHANGELOG.md b/CHANGELOG.md index 96df25927..00ea45f92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements -* [#1610](https://github.com/NibiruChain/nibiru/pull/1610) - refactor(app): Simplify app.go with less redundant imports using struct embedding. +* [#1610](https://github.com/NibiruChain/nibiru/pull/1610) - refactor(app): + Simplify app.go with less redundant imports using struct embedding. +* [#1614](https://github.com/NibiruChain/nibiru/pull/1614) - refactor(proto): Use + explicit namespacing on proto imports for #1608 ### Dependencies - Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605)) diff --git a/proto/nibiru/devgas/v1/genesis.proto b/proto/nibiru/devgas/v1/genesis.proto index 7b5dc1983..ed28cb9bd 100644 --- a/proto/nibiru/devgas/v1/genesis.proto +++ b/proto/nibiru/devgas/v1/genesis.proto @@ -8,9 +8,10 @@ option go_package = "github.com/NibiruChain/nibiru/x/devgas/v1/types"; // GenesisState defines the module's genesis state. message GenesisState { // params are the feeshare module parameters - ModuleParams params = 1 [ (gogoproto.nullable) = false ]; + nibiru.devgas.v1.ModuleParams params = 1 [ (gogoproto.nullable) = false ]; // FeeShare is a slice of active registered contracts for fee distribution - repeated FeeShare fee_share = 2 [ (gogoproto.nullable) = false ]; + repeated nibiru.devgas.v1.FeeShare fee_share = 2 + [ (gogoproto.nullable) = false ]; } // ModuleParams defines the params for the devgas module diff --git a/proto/nibiru/devgas/v1/query.proto b/proto/nibiru/devgas/v1/query.proto index 6e995bd14..a7bd65f96 100644 --- a/proto/nibiru/devgas/v1/query.proto +++ b/proto/nibiru/devgas/v1/query.proto @@ -58,7 +58,8 @@ message QueryFeeSharesRequest { // method. message QueryFeeSharesResponse { // FeeShare is the slice of all stored Reveneue for the deployer - repeated FeeShare feeshare = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.devgas.v1.FeeShare feeshare = 1 + [ (gogoproto.nullable) = false ]; } // QueryFeeShareRequest is the request type for the Query/FeeShare RPC method. @@ -70,7 +71,7 @@ message QueryFeeShareRequest { // QueryFeeShareResponse is the response type for the Query/FeeShare RPC method. message QueryFeeShareResponse { // FeeShare is a stored Reveneue for the queried contract - FeeShare feeshare = 1 [ (gogoproto.nullable) = false ]; + nibiru.devgas.v1.FeeShare feeshare = 1 [ (gogoproto.nullable) = false ]; } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -79,7 +80,7 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // params is the returned FeeShare parameter - ModuleParams params = 1 [ (gogoproto.nullable) = false ]; + nibiru.devgas.v1.ModuleParams params = 1 [ (gogoproto.nullable) = false ]; } // QueryFeeSharesByWithdrawerRequest is the request type for the @@ -92,5 +93,6 @@ message QueryFeeSharesByWithdrawerRequest { // QueryFeeSharesByWithdrawerResponse is the response type for the // Query/FeeSharesByWithdrawer RPC method. message QueryFeeSharesByWithdrawerResponse { - repeated FeeShare feeshare = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.devgas.v1.FeeShare feeshare = 1 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/epochs/v1/genesis.proto b/proto/nibiru/epochs/v1/genesis.proto index c431ba555..0ce843e10 100644 --- a/proto/nibiru/epochs/v1/genesis.proto +++ b/proto/nibiru/epochs/v1/genesis.proto @@ -10,5 +10,6 @@ option go_package = "github.com/NibiruChain/nibiru/x/epochs/types"; // GenesisState defines the epochs module's genesis state. message GenesisState { - repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.epochs.v1.EpochInfo epochs = 1 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/epochs/v1/query.proto b/proto/nibiru/epochs/v1/query.proto index ab739f369..b25b4df0f 100644 --- a/proto/nibiru/epochs/v1/query.proto +++ b/proto/nibiru/epochs/v1/query.proto @@ -23,8 +23,9 @@ service Query { message QueryEpochsInfoRequest {} message QueryEpochsInfoResponse { - repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.epochs.v1.EpochInfo epochs = 1 + [ (gogoproto.nullable) = false ]; } message QueryCurrentEpochRequest { string identifier = 1; } -message QueryCurrentEpochResponse { uint64 current_epoch = 1; } \ No newline at end of file +message QueryCurrentEpochResponse { uint64 current_epoch = 1; } diff --git a/proto/nibiru/inflation/v1/query.proto b/proto/nibiru/inflation/v1/query.proto index 726183bb0..e7b6ec57a 100644 --- a/proto/nibiru/inflation/v1/query.proto +++ b/proto/nibiru/inflation/v1/query.proto @@ -115,5 +115,5 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + nibiru.inflation.v1.Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/oracle/v1/event.proto b/proto/nibiru/oracle/v1/event.proto index 73acb862f..f9dda8853 100644 --- a/proto/nibiru/oracle/v1/event.proto +++ b/proto/nibiru/oracle/v1/event.proto @@ -23,7 +23,7 @@ message EventDelegateFeederConsent { // Validator is the Bech32 address that is delegating voting rights. string validator = 1; - // Feeder is the delegate or representative that will be able to send + // Feeder is the delegate or representative that will be able to send // vote and prevote transaction messages. string feeder = 2; } @@ -33,23 +33,23 @@ message EventAggregateVote { // Validator is the Bech32 address to which the vote will be credited. string validator = 1; - // Feeder is the delegate or representative that will send vote and prevote + // Feeder is the delegate or representative that will send vote and prevote // transaction messages on behalf of the voting validator. string feeder = 2; - repeated ExchangeRateTuple prices = 3 [ + repeated nibiru.oracle.v1.ExchangeRateTuple prices = 3 [ (gogoproto.castrepeated) = "ExchangeRateTuples", (gogoproto.nullable) = false ]; } -// Emitted by MsgAggregateExchangePrevote when an aggregate prevote is added +// Emitted by MsgAggregateExchangePrevote when an aggregate prevote is added // to state message EventAggregatePrevote { // Validator is the Bech32 address to which the vote will be credited. string validator = 1; - // Feeder is the delegate or representative that will send vote and prevote + // Feeder is the delegate or representative that will send vote and prevote // transaction messages on behalf of the voting validator. string feeder = 2; } diff --git a/proto/nibiru/oracle/v1/genesis.proto b/proto/nibiru/oracle/v1/genesis.proto index 9643ab331..1ff78bbfb 100644 --- a/proto/nibiru/oracle/v1/genesis.proto +++ b/proto/nibiru/oracle/v1/genesis.proto @@ -9,24 +9,26 @@ option go_package = "github.com/NibiruChain/nibiru/x/oracle/types"; // GenesisState defines the oracle module's genesis state. message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - repeated FeederDelegation feeder_delegations = 2 + nibiru.oracle.v1.Params params = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.oracle.v1.FeederDelegation feeder_delegations = 2 [ (gogoproto.nullable) = false ]; - repeated ExchangeRateTuple exchange_rates = 3 [ + repeated nibiru.oracle.v1.ExchangeRateTuple exchange_rates = 3 [ (gogoproto.castrepeated) = "ExchangeRateTuples", (gogoproto.nullable) = false ]; - repeated MissCounter miss_counters = 4 [ (gogoproto.nullable) = false ]; - repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5 - [ (gogoproto.nullable) = false ]; - repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6 + repeated nibiru.oracle.v1.MissCounter miss_counters = 4 [ (gogoproto.nullable) = false ]; + repeated nibiru.oracle.v1.AggregateExchangeRatePrevote + aggregate_exchange_rate_prevotes = 5 [ (gogoproto.nullable) = false ]; + repeated nibiru.oracle.v1.AggregateExchangeRateVote + aggregate_exchange_rate_votes = 6 [ (gogoproto.nullable) = false ]; repeated string pairs = 7 [ (gogoproto.customtype) = "github.com/NibiruChain/nibiru/x/common/asset.Pair", (gogoproto.nullable) = false ]; - repeated Rewards rewards = 8 [ (gogoproto.nullable) = false ]; + repeated nibiru.oracle.v1.Rewards rewards = 8 + [ (gogoproto.nullable) = false ]; } // FeederDelegation is the address for where oracle feeder authority are diff --git a/proto/nibiru/oracle/v1/query.proto b/proto/nibiru/oracle/v1/query.proto index 53b4cf5f7..993640b40 100644 --- a/proto/nibiru/oracle/v1/query.proto +++ b/proto/nibiru/oracle/v1/query.proto @@ -119,7 +119,7 @@ message QueryExchangeRatesRequest {} message QueryExchangeRatesResponse { // exchange_rates defines a list of the exchange rate for all whitelisted // pairs. - repeated ExchangeRateTuple exchange_rates = 1 [ + repeated nibiru.oracle.v1.ExchangeRateTuple exchange_rates = 1 [ (gogoproto.castrepeated) = "ExchangeRateTuples", (gogoproto.nullable) = false ]; @@ -204,7 +204,7 @@ message QueryAggregatePrevoteRequest { message QueryAggregatePrevoteResponse { // aggregate_prevote defines oracle aggregate prevote submitted by a validator // in the current vote period - AggregateExchangeRatePrevote aggregate_prevote = 1 + nibiru.oracle.v1.AggregateExchangeRatePrevote aggregate_prevote = 1 [ (gogoproto.nullable) = false ]; ; } @@ -218,7 +218,7 @@ message QueryAggregatePrevotesRequest {} message QueryAggregatePrevotesResponse { // aggregate_prevotes defines all oracle aggregate prevotes submitted in the // current vote period - repeated AggregateExchangeRatePrevote aggregate_prevotes = 1 + repeated nibiru.oracle.v1.AggregateExchangeRatePrevote aggregate_prevotes = 1 [ (gogoproto.nullable) = false ]; } @@ -237,7 +237,8 @@ message QueryAggregateVoteRequest { message QueryAggregateVoteResponse { // aggregate_vote defines oracle aggregate vote submitted by a validator in // the current vote period - AggregateExchangeRateVote aggregate_vote = 1 [ (gogoproto.nullable) = false ]; + nibiru.oracle.v1.AggregateExchangeRateVote aggregate_vote = 1 + [ (gogoproto.nullable) = false ]; } // QueryAggregateVotesRequest is the request type for the Query/AggregateVotes @@ -249,7 +250,7 @@ message QueryAggregateVotesRequest {} message QueryAggregateVotesResponse { // aggregate_votes defines all oracle aggregate votes submitted in the current // vote period - repeated AggregateExchangeRateVote aggregate_votes = 1 + repeated nibiru.oracle.v1.AggregateExchangeRateVote aggregate_votes = 1 [ (gogoproto.nullable) = false ]; } @@ -259,5 +260,5 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file + nibiru.oracle.v1.Params params = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/nibiru/oracle/v1/tx.proto b/proto/nibiru/oracle/v1/tx.proto index 7a2135f82..19fd2f833 100644 --- a/proto/nibiru/oracle/v1/tx.proto +++ b/proto/nibiru/oracle/v1/tx.proto @@ -83,4 +83,4 @@ message MsgDelegateFeedConsent { // MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response // type. -message MsgDelegateFeedConsentResponse {} \ No newline at end of file +message MsgDelegateFeedConsentResponse {} diff --git a/proto/nibiru/perp/v2/event.proto b/proto/nibiru/perp/v2/event.proto index e26e46c70..f8a6b7a04 100644 --- a/proto/nibiru/perp/v2/event.proto +++ b/proto/nibiru/perp/v2/event.proto @@ -12,7 +12,7 @@ option go_package = "github.com/NibiruChain/nibiru/x/perp/v2/types"; // Emitted when a position changes. message PositionChangedEvent { - Position final_position = 1 [ (gogoproto.nullable) = false ]; + nibiru.perp.v2.Position final_position = 1 [ (gogoproto.nullable) = false ]; // Position notional (in quote units) after the change. In general, // 'notional = baseAmount * priceQuotePerBase', where size is the baseAmount. @@ -92,7 +92,7 @@ message PositionChangedEvent { // Emitted when a position is liquidated. Wraps a PositionChanged event since a // liquidation causes position changes. message PositionLiquidatedEvent { - PositionChangedEvent position_changed_event = 1 + nibiru.perp.v2.PositionChangedEvent position_changed_event = 1 [ (gogoproto.nullable) = false ]; // Address of the account that executed the tx. @@ -207,7 +207,7 @@ message LiquidationFailedEvent { // - edit depth message AmmUpdatedEvent { // the final state of the AMM - AMM final_amm = 1 [ (gogoproto.nullable) = false ]; + nibiru.perp.v2.AMM final_amm = 1 [ (gogoproto.nullable) = false ]; // The mark price of the pair. string mark_price_twap = 2 [ @@ -232,5 +232,5 @@ message AmmUpdatedEvent { // - bad debt is prepaid by the ecosystem fund message MarketUpdatedEvent { // the final state of the market - Market final_market = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file + nibiru.perp.v2.Market final_market = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/nibiru/perp/v2/genesis.proto b/proto/nibiru/perp/v2/genesis.proto index 136235de8..37634dcf5 100644 --- a/proto/nibiru/perp/v2/genesis.proto +++ b/proto/nibiru/perp/v2/genesis.proto @@ -13,19 +13,18 @@ option go_package = "github.com/NibiruChain/nibiru/x/perp/v2/types"; // Thge genesis state is used not only to start the network but also useful for // exporting and importing state during network upgrades. message GenesisState { - repeated Market markets = 2 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.Market markets = 2 [ (gogoproto.nullable) = false ]; - repeated AMM amms = 3 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.AMM amms = 3 [ (gogoproto.nullable) = false ]; - repeated Position positions = 4 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.Position positions = 4 + [ (gogoproto.nullable) = false ]; - repeated ReserveSnapshot reserve_snapshots = 5 + repeated nibiru.perp.v2.ReserveSnapshot reserve_snapshots = 5 [ (gogoproto.nullable) = false ]; uint64 dnr_epoch = 6; - repeated TraderVolume trader_volumes = 7 [ (gogoproto.nullable) = false ]; - message TraderVolume { string trader = 1; uint64 epoch = 2; @@ -35,6 +34,8 @@ message GenesisState { ]; } + repeated TraderVolume trader_volumes = 7 [ (gogoproto.nullable) = false ]; + message Discount { string fee = 1 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", @@ -55,7 +56,7 @@ message GenesisState { Discount discount = 2; } - repeated GenesisMarketLastVersion market_last_versions = 10 + repeated nibiru.perp.v2.GenesisMarketLastVersion market_last_versions = 10 [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/perp/v2/query.proto b/proto/nibiru/perp/v2/query.proto index e15cb30df..bb69dacdb 100644 --- a/proto/nibiru/perp/v2/query.proto +++ b/proto/nibiru/perp/v2/query.proto @@ -42,7 +42,8 @@ service Query { message QueryPositionsRequest { string trader = 1; } message QueryPositionsResponse { - repeated QueryPositionResponse positions = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.QueryPositionResponse positions = 1 + [ (gogoproto.nullable) = false ]; } message QueryPositionStoreRequest { @@ -52,7 +53,8 @@ message QueryPositionStoreRequest { message QueryPositionStoreResponse { // Position responses: collection of all stored positions (with pagination) - repeated Position positions = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.Position positions = 1 + [ (gogoproto.nullable) = false ]; // pagination defines a paginated response cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -74,7 +76,7 @@ message QueryPositionRequest { message QueryPositionResponse { // The position as it exists in the blockchain state - Position position = 1 [ (gogoproto.nullable) = false ]; + nibiru.perp.v2.Position position = 1 [ (gogoproto.nullable) = false ]; // The position's current notional value, if it were to be entirely closed (in // margin units). @@ -101,7 +103,8 @@ message QueryPositionResponse { message QueryModuleAccountsRequest {} message QueryModuleAccountsResponse { - repeated AccountWithBalance accounts = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.AccountWithBalance accounts = 1 + [ (gogoproto.nullable) = false ]; } message AccountWithBalance { @@ -115,14 +118,13 @@ message AccountWithBalance { } message AmmMarket { - Market market = 1 [ (gogoproto.nullable) = false ]; - AMM amm = 2 [ (gogoproto.nullable) = false ]; + nibiru.perp.v2.Market market = 1 [ (gogoproto.nullable) = false ]; + nibiru.perp.v2.AMM amm = 2 [ (gogoproto.nullable) = false ]; } -message QueryMarketsRequest { - bool versioned = 1; -} +message QueryMarketsRequest { bool versioned = 1; } message QueryMarketsResponse { - repeated AmmMarket amm_markets = 1 [ (gogoproto.nullable) = false ]; + repeated nibiru.perp.v2.AmmMarket amm_markets = 1 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/perp/v2/tx.proto b/proto/nibiru/perp/v2/tx.proto index 23656b499..29bf3a6a2 100644 --- a/proto/nibiru/perp/v2/tx.proto +++ b/proto/nibiru/perp/v2/tx.proto @@ -54,7 +54,7 @@ message MsgRemoveMarginResponse { ]; // The resulting position - Position position = 3; + nibiru.perp.v2.Position position = 3; } // -------------------------- AddMargin -------------------------- @@ -78,7 +78,7 @@ message MsgAddMarginResponse { (gogoproto.nullable) = false ]; - Position position = 2; + nibiru.perp.v2.Position position = 2; } // -------------------------- Liquidation -------------------------- @@ -132,7 +132,7 @@ message MsgMarketOrder { (gogoproto.nullable) = false ]; - Direction side = 3; + nibiru.perp.v2.Direction side = 3; string quote_asset_amount = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -151,7 +151,7 @@ message MsgMarketOrder { } message MsgMarketOrderResponse { - Position position = 1; + nibiru.perp.v2.Position position = 1; // The amount of quote assets exchanged. string exchanged_notional_value = 2 [ diff --git a/proto/nibiru/spot/v1/event.proto b/proto/nibiru/spot/v1/event.proto index b3b3ee865..3e4788d9a 100644 --- a/proto/nibiru/spot/v1/event.proto +++ b/proto/nibiru/spot/v1/event.proto @@ -16,7 +16,7 @@ message EventPoolCreated { repeated cosmos.base.v1beta1.Coin fees = 2 [ (gogoproto.nullable) = false ]; // the final state of the pool - Pool final_pool = 4 [ (gogoproto.nullable) = false ]; + nibiru.spot.v1.Pool final_pool = 4 [ (gogoproto.nullable) = false ]; // the amount of pool shares that the user received cosmos.base.v1beta1.Coin final_user_pool_shares = 5 @@ -39,7 +39,7 @@ message EventPoolJoined { [ (gogoproto.nullable) = false ]; // the final state of the pool - Pool final_pool = 5 [ (gogoproto.nullable) = false ]; + nibiru.spot.v1.Pool final_pool = 5 [ (gogoproto.nullable) = false ]; // the final amount of user pool shares cosmos.base.v1beta1.Coin final_user_pool_shares = 6 @@ -61,7 +61,7 @@ message EventPoolExited { repeated cosmos.base.v1beta1.Coin fees = 4 [ (gogoproto.nullable) = false ]; // the final state of the pool - Pool final_pool = 5 [ (gogoproto.nullable) = false ]; + nibiru.spot.v1.Pool final_pool = 5 [ (gogoproto.nullable) = false ]; // the final amount of user pool shares cosmos.base.v1beta1.Coin final_user_pool_shares = 6 @@ -82,5 +82,5 @@ message EventAssetsSwapped { cosmos.base.v1beta1.Coin fee = 4 [ (gogoproto.nullable) = false ]; // the final state of the pool - Pool final_pool = 5 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file + nibiru.spot.v1.Pool final_pool = 5 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/nibiru/spot/v1/genesis.proto b/proto/nibiru/spot/v1/genesis.proto index 5cbee0393..0d2e222ee 100644 --- a/proto/nibiru/spot/v1/genesis.proto +++ b/proto/nibiru/spot/v1/genesis.proto @@ -11,8 +11,8 @@ option go_package = "github.com/NibiruChain/nibiru/x/spot/types"; // GenesisState defines the spot module's genesis state. message GenesisState { // params defines all the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + nibiru.spot.v1.Params params = 1 [ (gogoproto.nullable) = false ]; // pools defines all the pools of the module. - repeated Pool pools = 2 [ (gogoproto.nullable) = false ]; + repeated nibiru.spot.v1.Pool pools = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/nibiru/spot/v1/pool.proto b/proto/nibiru/spot/v1/pool.proto index 5e113617f..d0e67f52d 100644 --- a/proto/nibiru/spot/v1/pool.proto +++ b/proto/nibiru/spot/v1/pool.proto @@ -33,7 +33,8 @@ message PoolParams { (gogoproto.nullable) = false ]; - PoolType pool_type = 4 [ (gogoproto.moretags) = "yaml:\"pool_type\"" ]; + nibiru.spot.v1.PoolType pool_type = 4 + [ (gogoproto.moretags) = "yaml:\"pool_type\"" ]; } // - `balancer`: Balancer are pools defined by the equation xy=k, extended by @@ -69,7 +70,7 @@ message Pool { string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // Fees and other pool-specific parameters. - PoolParams pool_params = 3 [ + nibiru.spot.v1.PoolParams pool_params = 3 [ (gogoproto.moretags) = "yaml:\"pool_params\"", (gogoproto.nullable) = false ]; diff --git a/proto/nibiru/spot/v1/query.proto b/proto/nibiru/spot/v1/query.proto index a1ef0e143..0bc6ad052 100644 --- a/proto/nibiru/spot/v1/query.proto +++ b/proto/nibiru/spot/v1/query.proto @@ -120,28 +120,28 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { // params holds all the parameters of this module. - Params params = 1 [ (gogoproto.nullable) = false ]; + nibiru.spot.v1.Params params = 1 [ (gogoproto.nullable) = false ]; } message QueryPoolNumberRequest {} message QueryPoolNumberResponse { uint64 pool_id = 1; } message QueryPoolRequest { uint64 pool_id = 1; } -message QueryPoolResponse { Pool pool = 1; } +message QueryPoolResponse { nibiru.spot.v1.Pool pool = 1; } message QueryPoolsRequest { // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 1; } message QueryPoolsResponse { - repeated Pool pools = 1; + repeated nibiru.spot.v1.Pool pools = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryPoolParamsRequest { uint64 pool_id = 1; } -message QueryPoolParamsResponse { PoolParams pool_params = 1; } +message QueryPoolParamsResponse { nibiru.spot.v1.PoolParams pool_params = 1; } message QueryNumPoolsRequest {} message QueryNumPoolsResponse { uint64 num_pools = 1; } diff --git a/proto/nibiru/spot/v1/tx.proto b/proto/nibiru/spot/v1/tx.proto index 3e924f886..8e9a3fc1c 100644 --- a/proto/nibiru/spot/v1/tx.proto +++ b/proto/nibiru/spot/v1/tx.proto @@ -35,9 +35,11 @@ service Msg { message MsgCreatePool { string creator = 1; - PoolParams pool_params = 2 [ (gogoproto.moretags) = "yaml:\"pool_params\"" ]; + nibiru.spot.v1.PoolParams pool_params = 2 + [ (gogoproto.moretags) = "yaml:\"pool_params\"" ]; - repeated PoolAsset pool_assets = 3 [ (gogoproto.nullable) = false ]; + repeated nibiru.spot.v1.PoolAsset pool_assets = 3 + [ (gogoproto.nullable) = false ]; } message MsgCreatePoolResponse { uint64 pool_id = 1; } @@ -63,7 +65,7 @@ Response when a user joins a pool. */ message MsgJoinPoolResponse { // the final state of the pool after a join - Pool pool = 1; + nibiru.spot.v1.Pool pool = 1; // sum of LP tokens minted from the join cosmos.base.v1beta1.Coin num_pool_shares_out = 2 [ diff --git a/proto/nibiru/stablecoin/v1/events.proto b/proto/nibiru/stablecoin/v1/events.proto deleted file mode 100644 index d8d67c526..000000000 --- a/proto/nibiru/stablecoin/v1/events.proto +++ /dev/null @@ -1,62 +0,0 @@ -syntax = "proto3"; - -package nibiru.stablecoin.v1; - -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -option go_package = "github.com/NibiruChain/nibiru/x/stablecoin/types"; - -message EventTransfer { - cosmos.base.v1beta1.Coin coin = 1 [ (gogoproto.nullable) = false ]; - string from = 2; - string to = 3; -} - -message EventMintStable { - string amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message EventBurnStable { - string amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message EventMintNIBI { - string amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message EventBurnNIBI { - string amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message EventRecollateralize { - string caller = 1; - cosmos.base.v1beta1.Coin in_coin = 2 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin out_coin = 3 [ (gogoproto.nullable) = false ]; - string coll_ratio = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message EventBuyback { - string caller = 1; - cosmos.base.v1beta1.Coin in_coin = 2 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin out_coin = 3 [ (gogoproto.nullable) = false ]; - string coll_ratio = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} \ No newline at end of file diff --git a/proto/nibiru/stablecoin/v1/genesis.proto b/proto/nibiru/stablecoin/v1/genesis.proto deleted file mode 100644 index c19181fc5..000000000 --- a/proto/nibiru/stablecoin/v1/genesis.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; -package nibiru.stablecoin.v1; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; -import "nibiru/stablecoin/v1/params.proto"; - -option go_package = "github.com/NibiruChain/nibiru/x/stablecoin/types"; - -// GenesisState defines the stablecoin module's genesis state. -message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin module_account_balance = 2 [ - (gogoproto.moretags) = "yaml:\"module_account_balance\"", - (gogoproto.nullable) = false - ]; -} diff --git a/proto/nibiru/stablecoin/v1/params.proto b/proto/nibiru/stablecoin/v1/params.proto deleted file mode 100644 index 2835fa9d0..000000000 --- a/proto/nibiru/stablecoin/v1/params.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; -package nibiru.stablecoin.v1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/NibiruChain/nibiru/x/stablecoin/types"; - -// Params defines the parameters for the module. -message Params { - // collRatio is the ratio needed as collateral to exchange for stables - int64 coll_ratio = 1; - - // feeRatio is the ratio taken as fees when minting or burning stables - int64 fee_ratio = 2; - // efFeeRatio is the ratio taken from the fees that goes to Ecosystem Fund - int64 ef_fee_ratio = 3; - - /* BonusRateRecoll is the percentage of extra stablecoin value given to the - caller of 'Recollateralize' in units of governance tokens.*/ - int64 bonus_rate_recoll = 4; - - // distr_epoch_identifier defines the frequnecy of update for the collateral - // ratio - string distr_epoch_identifier = 5 - [ (gogoproto.moretags) = "yaml:\"distr_epoch_identifier\"" ]; - - // adjustmentStep is the size of the step taken when updating the collateral - // ratio - int64 adjustment_step = 6; - - // priceLowerBound is the lower bound for the stable coin to trigger a - // collateral ratio update - int64 price_lower_bound = 7; - - // priceUpperBound is the upper bound for the stable coin to trigger a - // collateral ratio update - int64 price_upper_bound = 8; - - // isCollateralRatioValid checks if the collateral ratio is correctly updated - bool is_collateral_ratio_valid = 9; -} diff --git a/proto/nibiru/stablecoin/v1/query.proto b/proto/nibiru/stablecoin/v1/query.proto deleted file mode 100644 index f8ab5a909..000000000 --- a/proto/nibiru/stablecoin/v1/query.proto +++ /dev/null @@ -1,108 +0,0 @@ -syntax = "proto3"; -package nibiru.stablecoin.v1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "nibiru/stablecoin/v1/params.proto"; - -option go_package = "github.com/NibiruChain/nibiru/x/stablecoin/types"; - -// Query defines the gRPC querier service. -service Query { - // Parameters queries the parameters of the x/stablecoin module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/nibiru/stablecoin/v1/params"; - } - - // ModuleAccountBalances queries the account balance of x/stablecoin. - rpc ModuleAccountBalances(QueryModuleAccountBalances) - returns (QueryModuleAccountBalancesResponse) { - option (google.api.http).get = "/nibiru/stablecoin/module_account_balance"; - } - - rpc CirculatingSupplies(QueryCirculatingSupplies) - returns (QueryCirculatingSuppliesResponse) { - option (google.api.http).get = "/nibiru/stablecoin/circulating_supplies"; - } - - rpc LiquidityRatioInfo(QueryLiquidityRatioInfoRequest) - returns (QueryLiquidityRatioInfoResponse) { - option (google.api.http).get = "/nibiru/stablecoin/liquidity_ratio_info"; - } -} - -// ---------------------------------------- Params - -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // params holds all the parameters of this module. - Params params = 1 [ (gogoproto.nullable) = false ]; -} - -// ---------------------------------------- ModuleAccountBalances - -/* QueryModuleAccountBalances is the request type for the balance of the - x/stablecoin module account. */ -message QueryModuleAccountBalances {} - -message QueryModuleAccountBalancesResponse { - // ModuleAccountBalances is the balance of all coins in the x/stablecoin - // module. - repeated cosmos.base.v1beta1.Coin module_account_balances = 1 [ - (gogoproto.moretags) = "yaml:\"coins\"", - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; -} - -// ---------------------------------------- CirculatingSupplies - -/* QueryCirculatingSupplies is the request type for the circulating supply of - both NIBI and NUSD. */ -message QueryCirculatingSupplies {} - -message QueryCirculatingSuppliesResponse { - cosmos.base.v1beta1.Coin nibi = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin nusd = 2 [ (gogoproto.nullable) = false ]; -} - -// ---------------------------------------- GovToMintStable - -// QueryGovToMintStable is the request type for the Query/GovToMintStable RPC -// method -message QueryGovToMintStable { - cosmos.base.v1beta1.Coin collateral = 1 [ (gogoproto.nullable) = false ]; -} - -// QueryGovToMintStableResponse is the response type for 'QueryGovToMintStable' -message QueryGovToMintStableResponse { - cosmos.base.v1beta1.Coin gov = 1 [ (gogoproto.nullable) = false ]; -} - -// ---------------------------------------- Liquidity Ratio Info - -message LiquidityRatioInfo { - string liquidity_ratio = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string upper_band = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string lower_band = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - -message QueryLiquidityRatioInfoRequest {} - -message QueryLiquidityRatioInfoResponse { - LiquidityRatioInfo info = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file diff --git a/proto/nibiru/stablecoin/v1/tx.proto b/proto/nibiru/stablecoin/v1/tx.proto deleted file mode 100644 index 8be25c9aa..000000000 --- a/proto/nibiru/stablecoin/v1/tx.proto +++ /dev/null @@ -1,110 +0,0 @@ -syntax = "proto3"; -package nibiru.stablecoin.v1; - -import "cosmos/base/v1beta1/coin.proto"; -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; - -option go_package = "github.com/NibiruChain/nibiru/x/stablecoin/types"; - -// Msg defines the x/stablecoin Msg service. -service Msg { - /* MintStable defines a method for trading a mixture of GOV and COLL to mint - an equivalent value of stablecoins. */ - rpc MintStable(MsgMintStable) returns (MsgMintStableResponse) { - option (google.api.http).post = "/nibiru/stablecoin/mint-sc"; - } - - /* BurnStable defines a method for redeeming/burning stablecoins to receive an - equivalent value as a mixture of governance and collateral tokens. */ - rpc BurnStable(MsgBurnStable) returns (MsgBurnStableResponse) { - option (google.api.http).post = "/nibiru/stablecoin/burn-sc"; - } - - /* Recollateralize defines a method for manually adding collateral to the - protocol in exchange for an equivalent stablecoin value in governance tokens - plus a small bonus. */ - rpc Recollateralize(MsgRecollateralize) returns (MsgRecollateralizeResponse) { - option (google.api.http).post = "/nibiru/stablecoin/recoll"; - } - - /* Buyback defines a method for manually adding NIBI to the protocol - in exchange for an equivalent stablecoin value in collateral, effectively - executing a share buyback for Nibiru Chain. The NIBI purchased by the protocol - is then burned, distributing value to all NIBI hodlers. */ - rpc Buyback(MsgBuyback) returns (MsgBuybackResponse) { - option (google.api.http).post = "/nibiru/stablecoin/buyback"; - } -} - -/* -MsgMintStable: Msg to mint NUSD. A user deposits NIBI and collateral and gets -NUSD in return. The amount of NUSD received depends on the current price set -by the oracle library and the current collateral ratio for the protocol. -*/ -message MsgMintStable { - string creator = 1; - cosmos.base.v1beta1.Coin stable = 2 [ (gogoproto.nullable) = false ]; -} - -/* MsgMintStableResponse specifies the amount of NUSD token the user will - * receive after their mint transaction*/ -message MsgMintStableResponse { - cosmos.base.v1beta1.Coin stable = 1 [ (gogoproto.nullable) = false ]; - repeated cosmos.base.v1beta1.Coin used_coins = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; - repeated cosmos.base.v1beta1.Coin fees_payed = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; -} - -/* -MsgBurnStable allows users to burn NUSD in exchange for NIBI and collateral. -The amount of NIBI and Collateral received depends on the current price set by -the x/oracle library and the current collateral ratio. -*/ -message MsgBurnStable { - string creator = 1; - cosmos.base.v1beta1.Coin stable = 2 [ (gogoproto.nullable) = false ]; -} - -/* MsgBurnStableResponse specifies the amount of collateral and governance - token the user will receive after their burn transaction. */ -message MsgBurnStableResponse { - cosmos.base.v1beta1.Coin collateral = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin gov = 2 [ (gogoproto.nullable) = false ]; - repeated cosmos.base.v1beta1.Coin fees_payed = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; -} - -/* MsgRecollateralize */ -message MsgRecollateralize { - string creator = 1; - cosmos.base.v1beta1.Coin coll = 2 [ (gogoproto.nullable) = false ]; -} - -/* MsgRecollateralizeResponse is the output of a successful 'Recollateralize' */ -message MsgRecollateralizeResponse { - // Gov (sdk.Coin): Tokens rewarded to the caller in exchange for her - // collateral. - cosmos.base.v1beta1.Coin gov = 1 [ (gogoproto.nullable) = false ]; -} - -/* MsgBuyback */ -message MsgBuyback { - string creator = 1; - /* Gov (sdk.Coin): Tokens the caller wants to sell to the protocol in exchange - for collateral. */ - cosmos.base.v1beta1.Coin gov = 2 [ (gogoproto.nullable) = false ]; -} - -/* MsgBuybackResponse is the output of a successful 'Buyback' */ -message MsgBuybackResponse { - // Coll (sdk.Coin): Tokens sold to the caller in exchange for her collateral. - cosmos.base.v1beta1.Coin coll = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file diff --git a/proto/nibiru/sudo/v1/event.proto b/proto/nibiru/sudo/v1/event.proto index a01d41227..f40344447 100644 --- a/proto/nibiru/sudo/v1/event.proto +++ b/proto/nibiru/sudo/v1/event.proto @@ -9,7 +9,7 @@ import "nibiru/sudo/v1/state.proto"; option go_package = "github.com/NibiruChain/nibiru/x/sudo/types"; message EventUpdateSudoers { - Sudoers sudoers = 1 [ (gogoproto.nullable) = false ]; + nibiru.sudo.v1.Sudoers sudoers = 1 [ (gogoproto.nullable) = false ]; // Action is the type of update that occured to the "sudoers" string action = 2; diff --git a/proto/nibiru/sudo/v1/query.proto b/proto/nibiru/sudo/v1/query.proto index 5729fab52..240f63c4e 100644 --- a/proto/nibiru/sudo/v1/query.proto +++ b/proto/nibiru/sudo/v1/query.proto @@ -20,5 +20,5 @@ message QuerySudoersRequest {} // QuerySudoersResponse indicates the successful execution of MsgEditSudeors. message QuerySudoersResponse { - Sudoers sudoers = 1 [ (gogoproto.nullable) = false ]; -} \ No newline at end of file + nibiru.sudo.v1.Sudoers sudoers = 1 [ (gogoproto.nullable) = false ]; +} From 8f9c4cad3f83c5ba5b0c9fcf61bdfa9430b020c3 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:01:38 -0500 Subject: [PATCH 06/10] docs: Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d289acac0..cf7328079 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nibiru Chain +# Nibiru Chain [![Go Reference](https://pkg.go.dev/badge/github.com/NibiruChain/nibiru.svg)](https://pkg.go.dev/github.com/NibiruChain/nibiru) [![Nibiru Test workflow][badge-go-linter]][workflow-go-linter] @@ -10,11 +10,10 @@ ## Components of Nibiru -- **CosmWasm Smart Contracts**: Rust-based, [WebAssembly (WASM) smart contracts](https://book.cosmwasm.com/) built for the Cosmos Ecosystem. +- **CosmWasm Smart Contracts**: Rust-based, WebAssembly (WASM) smart contracts built for the Cosmos Ecosystem. See our [CosmWasm sandbox monorepo (cw-nibiru)](https://github.com/NibiruChain/cw-nibiru/tree/main) for the protocol's core smart contracts. - **Nibi-Perps**: A perpetual futures exchange where users can take leveraged exposure and trade on a plethora of assets — completely on-chain, completely non-custodially, and with minimal gas fees. - **Oracle Module**: Nibiru accurately prices assets using a native, system of decentralized oracles, and communicates with other Cosmos layer-1 chains using the Inter-Blockchain Communication (IBC) (opens new window)protocol. - **Nibi-Swap**: An automated market maker protocol for multichain assets. This application gives users access to swaps, pools, and bonded liquidity gauges. -- **NUSD Stablecoin**: Nibiru powers a two-token economic model, where NIBI is the staking and utility token for the protocol and NUSD is a capital-efficient, partially collateralized stablecoin for the protocol. ## Modules @@ -22,18 +21,18 @@ | --- | --- | | [common][code-x-common] | Holds helper and utility functions to be utilized by other `x/` modules. | | [epochs][code-x-epochs] | Often in the SDK, we would like to run certain code every-so often. The purpose of `epochs` module is to allow other modules to set that they would like to be signaled once every period. So another module can specify it wants to execute code once a week, starting at UTC-time = x. `epochs` creates a generalized epoch interface to other modules so that they can easily be signalled upon such events. | +| [inflation][code-x-inflation] | Implements the [tokenomics](https://nibiru.fi/docs/learn/tokenomics.html) for Nibiru. | | [oracle][code-x-oracle] | Handles the posting of an up-to-date and accurate feed of exchange rates from the validators. | | [perp][code-x-perp] | Powers the Nibi-Perps exchange. This module enables traders to open long and short leveraged positions and houses all of the PnL calculation and liquidation logic. | | [spot][code-x-spot] | Responsible for creating, joining, and exiting liquidity pools. It also allows users to swap between two assets in an existing pool. It's a fully functional AMM. | -| [stablecoin][code-x-stablecoin] | Responsible for handling mint and redeem transactions with NUSD. | | [wasm][code-x-wasm] | Implements the execution environment for [WebAssembly (WASM) smart contracts](https://book.cosmwasm.com/). | [code-x-common]: https://github.com/NibiruChain/nibiru/tree/master/x/common [code-x-epochs]: https://github.com/NibiruChain/nibiru/tree/master/x/epochs +[code-x-inflation]: https://github.com/NibiruChain/nibiru/tree/master/x/inflation [code-x-oracle]: https://github.com/NibiruChain/nibiru/tree/master/x/oracle [code-x-perp]: https://github.com/NibiruChain/nibiru/tree/master/x/perp [code-x-spot]: https://github.com/NibiruChain/nibiru/tree/master/x/spot -[code-x-stablecoin]: https://github.com/NibiruChain/nibiru/tree/master/x/stablecoin [code-x-wasm]: https://github.com/NibiruChain/nibiru/tree/master/x/wasm Nibiru is built with the [Cosmos-SDK][cosmos-sdk-repo] on [Tendermint Core](https://tendermint.com/core/) consensus, accurately prices assets using a system of decentralized oracles, and communicates with other Cosmos layer-1 chains using the [Inter-Blockchain Communication (IBC)](https://github.com/cosmos/ibc) protocol. @@ -55,7 +54,7 @@ If you have questions or concerns, feel free to connect with a developer or comm

Discord Tweet -Telegram +Telegram

---- From 54ad5f52a672e9227a1acbd6a4401b37fdfd4739 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:51:53 -0500 Subject: [PATCH 07/10] feat(tokenfactory): tx msgs for mint and burn (#1620) --- CHANGELOG.md | 2 + app/keepers.go | 6 +- go.mod | 1 + go.sum | 2 + proto/nibiru/tokenfactory/v1/event.proto | 28 +- proto/nibiru/tokenfactory/v1/tx.proto | 53 +- x/tokenfactory/cli/cli_test.go | 70 +- x/tokenfactory/cli/tx.go | 148 +- x/tokenfactory/keeper/genesis_test.go | 5 +- x/tokenfactory/keeper/grpc_query.go | 11 +- x/tokenfactory/keeper/grpc_query_test.go | 87 ++ x/tokenfactory/keeper/keeper_test.go | 22 +- x/tokenfactory/keeper/msg_server.go | 184 +++ x/tokenfactory/keeper/msg_server_test.go | 391 ++++- x/tokenfactory/keeper/store.go | 22 +- x/tokenfactory/keeper/store_test.go | 10 +- x/tokenfactory/module_test.go | 5 +- x/tokenfactory/types/codec.go | 10 +- x/tokenfactory/types/codec_test.go | 1 - x/tokenfactory/types/errors.go | 6 + x/tokenfactory/types/event.pb.go | 877 ++++++++++- x/tokenfactory/types/genesis.go | 12 +- x/tokenfactory/types/state_test.go | 22 +- x/tokenfactory/types/tx.pb.go | 1724 +++++++++++++++++++--- x/tokenfactory/types/tx_msgs.go | 100 ++ x/tokenfactory/types/tx_msgs_test.go | 218 ++- 26 files changed, 3704 insertions(+), 313 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ea45f92..c39ef8fc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 State transitions, collections, genesis import and export, and app wiring * [#1607](https://github.com/NibiruChain/nibiru/pull/1607) - Token factory transaction messages for CreateDenom, ChangeAdmin, and UpdateModuleParams + * [#1620](https://github.com/NibiruChain/nibiru/pull/1620) - Token factory + transaction messages for Mint and Burn ### State Machine Breaking diff --git a/app/keepers.go b/app/keepers.go index fdba8e1be..af22e3cae 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -277,7 +277,7 @@ func (app *NibiruApp) InitKeepers( appCodec, keys[banktypes.StoreKey], app.AccountKeeper, - blockedAddresses(), + BlockedAddresses(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.stakingKeeper = stakingkeeper.NewKeeper( @@ -679,8 +679,8 @@ func orderedModuleNames() []string { } } -// blockedAddresses returns all the app's blocked account addresses. -func blockedAddresses() map[string]bool { +// BlockedAddresses returns all the app's blocked account addresses. +func BlockedAddresses() map[string]bool { modAccAddrs := make(map[string]bool) for acc := range maccPerms { modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true diff --git a/go.mod b/go.mod index 8d9748905..fad496632 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( cosmossdk.io/math v1.1.2 github.com/CosmWasm/wasmd v0.40.2 github.com/CosmWasm/wasmvm v1.4.0 + github.com/MakeNowJust/heredoc/v2 v2.0.1 github.com/NibiruChain/collections v0.3.0 github.com/armon/go-metrics v0.4.1 github.com/cometbft/cometbft v0.37.2 diff --git a/go.sum b/go.sum index a48280c18..a4aa76865 100644 --- a/go.sum +++ b/go.sum @@ -231,6 +231,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/MakeNowJust/heredoc/v2 v2.0.1 h1:rlCHh70XXXv7toz95ajQWOWQnN4WNLt0TdpZYIR/J6A= +github.com/MakeNowJust/heredoc/v2 v2.0.1/go.mod h1:6/2Abh5s+hc3g9nbWLe9ObDIOhaRrqsyY9MWy+4JdRM= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/NibiruChain/collections v0.3.0 h1:DB2RPzzgcHk35lRXuJ1cPOezweAZ6/c/Guq3bAo4W6w= github.com/NibiruChain/collections v0.3.0/go.mod h1:tKTlBL+Cs1oJnS4tT9MIaFWr7BWsUXrc7KPzP1LxRBo= diff --git a/proto/nibiru/tokenfactory/v1/event.proto b/proto/nibiru/tokenfactory/v1/event.proto index 584f3920c..5364da5db 100644 --- a/proto/nibiru/tokenfactory/v1/event.proto +++ b/proto/nibiru/tokenfactory/v1/event.proto @@ -2,6 +2,10 @@ syntax = "proto3"; package nibiru.tokenfactory.v1; +import "cosmos/bank/v1beta1/bank.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types"; message EventCreateDenom { @@ -11,6 +15,28 @@ message EventCreateDenom { message EventChangeAdmin { string denom = 1; - string old_admin = 3; string new_admin = 2; + string old_admin = 3; +} + +message EventMint { + cosmos.base.v1beta1.Coin coin = 1 + [ (gogoproto.moretags) = "yaml:\"coin\"", (gogoproto.nullable) = false ]; + string to_addr = 2; + string caller = 3; +} + +message EventBurn { + cosmos.base.v1beta1.Coin coin = 1 + [ (gogoproto.moretags) = "yaml:\"coin\"", (gogoproto.nullable) = false ]; + string from_addr = 2; + string caller = 3; +} + +message EventSetDenomMetadata { + string denom = 1; + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. The "metadata.base" is the denom. + cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.nullable) = false ]; + string caller = 3; } diff --git a/proto/nibiru/tokenfactory/v1/tx.proto b/proto/nibiru/tokenfactory/v1/tx.proto index fa76b3000..d62246753 100644 --- a/proto/nibiru/tokenfactory/v1/tx.proto +++ b/proto/nibiru/tokenfactory/v1/tx.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; +import "cosmos/bank/v1beta1/bank.proto"; import "nibiru/tokenfactory/v1/state.proto"; option go_package = "github.com/NibiruChain/nibiru/x/tokenfactory/types"; @@ -19,10 +20,10 @@ service Msg { // module parameters. rpc UpdateModuleParams(MsgUpdateModuleParams) returns (MsgUpdateModuleParamsResponse); - // TODO MsgMint - // TODO MsgBurn - // TODO MsgSetDenomMetadata - // TODO MsgForceTransfer + rpc Mint(MsgMint) returns (MsgMintResponse); + rpc Burn(MsgBurn) returns (MsgBurnResponse); + rpc SetDenomMetadata(MsgSetDenomMetadata) + returns (MsgSetDenomMetadataResponse); } // MsgCreateDenom: sdk.Msg that registers an a token factory denom. @@ -69,3 +70,47 @@ message MsgUpdateModuleParams { // MsgUpdateModuleParamsResponse is the gRPC response for the // MsgUpdateModuleParams TxMsg. message MsgUpdateModuleParamsResponse {} + +// MsgMint: sdk.Msg (TxMsg) where an denom admin mints more of the token. +message MsgMint { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + // coin: The denom identifier and amount to mint. + cosmos.base.v1beta1.Coin coin = 2 + [ (gogoproto.moretags) = "yaml:\"coin\"", (gogoproto.nullable) = false ]; + // mint_to_addr: An address to which tokens will be minted. If blank, + // tokens are minted to the "sender". + string mint_to = 3 [ + (gogoproto.moretags) = "yaml:\"mint_to\"", + (gogoproto.nullable) = true + ]; +} + +message MsgMintResponse { string mint_to = 1; } + +// MsgBurn: sdk.Msg (TxMsg) where a denom admin burns some of the token. +// The reason that the sender isn't automatically the "burn_from" address +// is to support smart contracts (primary use case). In this situation, the +// contract is the message signer and sender, while "burn_from" is based on the +// contract logic. +message MsgBurn { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + // coin: The denom identifier and amount to burn. + cosmos.base.v1beta1.Coin coin = 2 + [ (gogoproto.moretags) = "yaml:\"coin\"", (gogoproto.nullable) = false ]; + // burn_from: The address from which tokens will be burned. + string burn_from = 3 [ (gogoproto.moretags) = "yaml:\"burn_from\"" ]; +} + +message MsgBurnResponse {} + +// MsgSetDenomMetadata: sdk.Msg (TxMsg) enabling the denom admin to change its +// bank metadata. +message MsgSetDenomMetadata { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. The "metadata.base" is the denom. + cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.nullable) = false ]; +} + +message MsgSetDenomMetadataResponse {} diff --git a/x/tokenfactory/cli/cli_test.go b/x/tokenfactory/cli/cli_test.go index 6ce854d03..45d8a70dc 100644 --- a/x/tokenfactory/cli/cli_test.go +++ b/x/tokenfactory/cli/cli_test.go @@ -1,6 +1,7 @@ package cli_test import ( + "fmt" "testing" "github.com/stretchr/testify/suite" @@ -12,6 +13,8 @@ import ( "github.com/NibiruChain/nibiru/x/common/testutil/testapp" "github.com/NibiruChain/nibiru/x/tokenfactory/cli" "github.com/NibiruChain/nibiru/x/tokenfactory/types" + + sdk "github.com/cosmos/cosmos-sdk/types" ) var _ suite.SetupAllSuite = (*IntegrationTestSuite)(nil) @@ -28,9 +31,11 @@ func TestIntegrationTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } +// TestTokenFactory: Runs the test suite with a deterministic order. func (s *IntegrationTestSuite) TestTokenFactory() { - s.T().Run("CreateDenomTest", s.CreateDenomTest) - s.T().Run("ChangeAdminTest", s.ChangeAdminTest) + s.Run("CreateDenomTest", s.CreateDenomTest) + s.Run("MintBurnTest", s.MintBurnTest) + s.Run("ChangeAdminTest", s.ChangeAdminTest) } func (s *IntegrationTestSuite) SetupSuite() { @@ -59,7 +64,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.NoError(s.network.WaitForNextBlock()) } -func (s *IntegrationTestSuite) CreateDenomTest(t *testing.T) { +func (s *IntegrationTestSuite) CreateDenomTest() { creator := s.val.Address createDenom := func(subdenom string, wantErr bool) { _, err := s.network.ExecTxCmd( @@ -93,7 +98,64 @@ func (s *IntegrationTestSuite) CreateDenomTest(t *testing.T) { s.ElementsMatch(denoms, wantDenoms) } -func (s *IntegrationTestSuite) ChangeAdminTest(t *testing.T) { +func (s *IntegrationTestSuite) MintBurnTest() { + creator := s.val.Address + mint := func(coin string, mintTo string, wantErr bool) { + mintToArg := fmt.Sprintf("--mint-to=%s", mintTo) + _, err := s.network.ExecTxCmd( + cli.NewTxCmd(), creator, []string{"mint", coin, mintToArg}) + if wantErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + s.NoError(s.network.WaitForNextBlock()) + } + + burn := func(coin string, burnFrom string, wantErr bool) { + burnFromArg := fmt.Sprintf("--burn-from=%s", burnFrom) + _, err := s.network.ExecTxCmd( + cli.NewTxCmd(), creator, []string{"burn", coin, burnFromArg}) + if wantErr { + s.Require().Error(err) + return + } + s.Require().NoError(err) + s.NoError(s.network.WaitForNextBlock()) + } + + t := s.T() + t.Log("mint successfully") + denom := types.TFDenom{ + Creator: creator.String(), + Subdenom: "nusd", + } + coin := sdk.NewInt64Coin(denom.String(), 420) + wantErr := false + mint(coin.String(), creator.String(), wantErr) // happy + + t.Log("want error: unregistered denom") + coin.Denom = "notadenom" + wantErr = true + mint(coin.String(), creator.String(), wantErr) + burn(coin.String(), creator.String(), wantErr) + + t.Log("want error: invalid coin") + mint("notacoin_231,,", creator.String(), wantErr) + burn("notacoin_231,,", creator.String(), wantErr) + + t.Log(`want error: unable to parse "mint-to" or "burn-from"`) + coin.Denom = denom.String() + mint(coin.String(), "invalidAddr", wantErr) + burn(coin.String(), "invalidAddr", wantErr) + + t.Log("burn successfully") + coin.Denom = denom.String() + wantErr = false + burn(coin.String(), creator.String(), wantErr) // happy +} + +func (s *IntegrationTestSuite) ChangeAdminTest() { creator := s.val.Address admin := creator newAdmin := testutil.AccAddress() diff --git a/x/tokenfactory/cli/tx.go b/x/tokenfactory/cli/tx.go index 2cd154655..5f64f1723 100644 --- a/x/tokenfactory/cli/tx.go +++ b/x/tokenfactory/cli/tx.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strings" "github.com/spf13/cobra" @@ -10,7 +9,11 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/NibiruChain/nibiru/x/tokenfactory/types" + + "github.com/MakeNowJust/heredoc/v2" ) // NewTxCmd returns the transaction commands for this module @@ -18,6 +21,7 @@ func NewTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + Aliases: []string{"tf"}, DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -26,12 +30,9 @@ func NewTxCmd() *cobra.Command { cmd.AddCommand( CmdCreateDenom(), CmdChangeAdmin(), - // CmdModifyDenomMetadata(), - // CmdMint(), - // CmdMintTo(), - // CmdBurn(), - // CmdBurnFrom(), - // CmdForceTransfer(), + CmdMint(), + CmdBurn(), + // CmdModifyDenomMetadata(), // CosmWasm only ) return cmd @@ -41,7 +42,7 @@ func NewTxCmd() *cobra.Command { func CmdCreateDenom() *cobra.Command { cmd := &cobra.Command{ Use: "create-denom [subdenom] [flags]", - Short: "create a new denom from an account", + Short: `Create a denom of the form "tf/{creator}/{subdenom}"`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -49,12 +50,12 @@ func CmdCreateDenom() *cobra.Command { return err } - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) if err != nil { return err } - txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever( + txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever( clientCtx.AccountRetriever) msg := &types.MsgCreateDenom{ @@ -62,7 +63,7 @@ func CmdCreateDenom() *cobra.Command { Subdenom: args[0], } - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg) }, } @@ -70,13 +71,15 @@ func CmdCreateDenom() *cobra.Command { return cmd } -// CmdChangeAdmin broadcast MsgChangeAdmin +// CmdChangeAdmin: Broadcasts MsgChangeAdmin func CmdChangeAdmin() *cobra.Command { cmd := &cobra.Command{ - Use: "change-admin [denom] [new-admin-address] [flags]", - Short: strings.Join([]string{ - "Changes the admin address for a token factory denom.", - "Must have admin authority to do so."}, " "), + Use: "change-admin [denom] [new-admin] [flags]", + Short: "Change the admin address for a token factory denom", + Long: heredoc.Doc(` + Change the admin address for a token factory 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) @@ -84,11 +87,11 @@ func CmdChangeAdmin() *cobra.Command { return err } - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) if err != nil { return err } - txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) msg := &types.MsgChangeAdmin{ Sender: clientCtx.GetFromAddress().String(), @@ -96,10 +99,117 @@ func CmdChangeAdmin() *cobra.Command { NewAdmin: args[1], } - return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// CmdMint: Broadcast MsgMint +func CmdMint() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint [coin] [--mint-to] [flags]", + Short: "Mint a denom to an address.", + Long: heredoc.Doc(` + Mint a denom to an address. + Tx signer must be the denom admin. + If no --mint-to address is provided, it defaults to the sender.`, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + mintTo, err := cmd.Flags().GetString("mint-to") + if err != nil { + return fmt.Errorf( + "Please provide a valid address using the --mint-to flag: %s", err) + } + mintToAddr, err := sdk.AccAddressFromBech32(mintTo) + if err != nil { + return err + } + + msg := &types.MsgMint{ + Sender: clientCtx.GetFromAddress().String(), + Coin: coin, + MintTo: mintToAddr.String(), + } + + txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg) + }, + } + + cmd.Flags().String("mint-to", "", "Address to mint to") + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// CmdBurn: Broadcast MsgBurn +func CmdBurn() *cobra.Command { + cmd := &cobra.Command{ + Use: "burn [coin] [--burn-from] [flags]", + Short: "Burn tokens from an address.", + Long: heredoc.Doc(` + Burn tokens from an address. + Tx signer must be the denom admin. + If no --burn-from address is provided, it defaults to the sender.`, + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txFactory = txFactory.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + coin, err := sdk.ParseCoinNormalized(args[0]) + if err != nil { + return err + } + + burnFrom, err := cmd.Flags().GetString("burn-from") + if err != nil { + return fmt.Errorf( + "Please provide a valid address using the --burn-from flag: %s", err) + } + + burnFromAddr, err := sdk.AccAddressFromBech32(burnFrom) + if err != nil { + return err + } + msg := &types.MsgBurn{ + Sender: clientCtx.GetFromAddress().String(), + Coin: coin, + BurnFrom: burnFromAddr.String(), + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txFactory, msg) }, } + cmd.Flags().String("burn-from", "", "Address to burn from") flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go index cc3ac4e41..7ead2f7e8 100644 --- a/x/tokenfactory/keeper/genesis_test.go +++ b/x/tokenfactory/keeper/genesis_test.go @@ -1,8 +1,6 @@ package keeper_test import ( - "testing" - "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) @@ -53,12 +51,11 @@ func (s *TestSuite) TestGenesis() { } for _, tc := range testCases { - s.T().Run(tc.name, func(t *testing.T) { + s.Run(tc.name, func() { s.SetupTest() // reset if tc.expPanic { s.Require().Panics(func() { - }) } else { s.Require().NotPanics(func() { diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index af5818e0e..e1d16f4e9 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -3,9 +3,6 @@ package keeper import ( "context" - grpccodes "google.golang.org/grpc/codes" - grpcstatus "google.golang.org/grpc/status" - types "github.com/NibiruChain/nibiru/x/tokenfactory/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,13 +27,7 @@ func (q Querier) Params( _ *types.QueryParamsRequest, ) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - params, err := q.Keeper.Store.ModuleParams.Get(ctx) - if err != nil { - return nil, grpcstatus.Errorf( - grpccodes.NotFound, - "failed to query module params", - ) - } + params, _ := q.Keeper.Store.ModuleParams.Get(ctx) return &types.QueryParamsResponse{Params: params}, nil } diff --git a/x/tokenfactory/keeper/grpc_query_test.go b/x/tokenfactory/keeper/grpc_query_test.go index 8e47da052..ad1989018 100644 --- a/x/tokenfactory/keeper/grpc_query_test.go +++ b/x/tokenfactory/keeper/grpc_query_test.go @@ -1,6 +1,9 @@ package keeper_test import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) @@ -9,3 +12,87 @@ func (s *TestSuite) TestQueryModuleParams() { s.NoError(err) s.Equal(res.Params, types.DefaultModuleParams()) } + +func (s *TestSuite) createDenom( + creator sdk.AccAddress, + subdenom string, +) { + msg := &types.MsgCreateDenom{ + Sender: creator.String(), + Subdenom: subdenom, + } + s.NoError(s.HandleMsg(msg)) +} + +func (s *TestSuite) TestQueryDenoms() { + creator := testutil.AccAddress() + denom := types.TFDenom{ + Creator: creator.String(), + Subdenom: "abc", + } + s.createDenom(creator, denom.Subdenom) + s.createDenom(creator, "foobar") + + queryDenoms := func(creator string) ( + resp *types.QueryDenomsResponse, err error, + ) { + return s.querier.Denoms(s.GoCtx(), + &types.QueryDenomsRequest{ + Creator: creator, + }) + } + + denomsResp, err := queryDenoms(denom.Creator) + s.NoError(err) + s.ElementsMatch(denomsResp.Denoms, []string{ + denom.String(), + types.TFDenom{ + Creator: denom.Creator, + Subdenom: "foobar", + }.String(), + }) + + denomsResp, err = queryDenoms("creator") + s.NoError(err) + s.Len(denomsResp.Denoms, 0) + + _, err = queryDenoms("") + s.ErrorContains(err, "empty creator address") + + _, err = s.querier.Denoms(s.GoCtx(), nil) + s.ErrorContains(err, "nil msg") +} + +func (s *TestSuite) TestQueryDenomInfo() { + s.SetupTest() + creator := testutil.AccAddress() + denom := types.TFDenom{ + Creator: creator.String(), + Subdenom: "abc", + } + s.createDenom(creator, denom.Subdenom) + + s.Run("case: nil msg", func() { + _, err := s.querier.DenomInfo(s.GoCtx(), + nil) + s.ErrorContains(err, "nil msg") + }) + + s.Run("case: fail denom validation", func() { + _, err := s.querier.DenomInfo(s.GoCtx(), + &types.QueryDenomInfoRequest{ + Denom: "notadenom", + }) + s.ErrorContains(err, "denom format error") + }) + + s.Run("case: happy", func() { + resp, err := s.querier.DenomInfo(s.GoCtx(), + &types.QueryDenomInfoRequest{ + Denom: denom.String(), + }) + s.NoError(err) + s.Equal(creator.String(), resp.Admin) + s.Equal(denom.DefaultBankMetadata(), resp.Metadata) + }) +} diff --git a/x/tokenfactory/keeper/keeper_test.go b/x/tokenfactory/keeper/keeper_test.go index 23498f498..9300042bb 100644 --- a/x/tokenfactory/keeper/keeper_test.go +++ b/x/tokenfactory/keeper/keeper_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "context" + "fmt" "testing" "github.com/stretchr/testify/suite" @@ -36,13 +37,32 @@ func TestKeeperTestSuite(t *testing.T) { // SetupTest: Runs before each test in the suite. It initializes a fresh app // and ctx. func (s *TestSuite) SetupTest() { + testapp.EnsureNibiruPrefix() nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() s.app = nibiruApp s.ctx = ctx s.keeper = s.app.TokenFactoryKeeper s.genesis = *tftypes.DefaultGenesis() - s.querier = s.keeper.Querier() } +func (s *TestSuite) HandleMsg(txMsg sdk.Msg) (err error) { + goCtx := sdk.WrapSDKContext(s.ctx) + switch txMsg := txMsg.(type) { + case *tftypes.MsgCreateDenom: + _, err = s.app.TokenFactoryKeeper.CreateDenom(goCtx, txMsg) + case *tftypes.MsgMint: + _, err = s.app.TokenFactoryKeeper.Mint(goCtx, txMsg) + case *tftypes.MsgBurn: + _, err = s.app.TokenFactoryKeeper.Burn(goCtx, txMsg) + case *tftypes.MsgChangeAdmin: + _, err = s.app.TokenFactoryKeeper.ChangeAdmin(goCtx, txMsg) + case *tftypes.MsgSetDenomMetadata: + _, err = s.app.TokenFactoryKeeper.SetDenomMetadata(goCtx, txMsg) + default: + err = fmt.Errorf("unknown message type: %t", txMsg) + } + return err +} + func (s *TestSuite) GoCtx() context.Context { return sdk.WrapSDKContext(s.ctx) } diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 1b8b8c46e..527d8bf68 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -73,6 +73,7 @@ func (k Keeper) ChangeAdmin( }) } +// UpdateModuleParams: Message handler for the abci.Msg: MsgUpdateModuleParams func (k Keeper) UpdateModuleParams( goCtx context.Context, txMsg *types.MsgUpdateModuleParams, ) (resp *types.MsgUpdateModuleParamsResponse, err error) { @@ -95,3 +96,186 @@ func (k Keeper) UpdateModuleParams( k.Store.ModuleParams.Set(ctx, txMsg.Params) return &types.MsgUpdateModuleParamsResponse{}, err } + +// Mint: Message handler for the abci.Msg: MsgMint +func (k Keeper) Mint( + goCtx context.Context, txMsg *types.MsgMint, +) (resp *types.MsgMintResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + admin, err := k.Store.GetAdmin(ctx, txMsg.Coin.Denom) + if err != nil { + return nil, err + } + + if txMsg.Sender != admin { + return resp, types.ErrUnauthorized.Wrapf( + "sender (%s), admin (%s)", txMsg.Sender, admin, + ) + } + + if txMsg.MintTo == "" { + txMsg.MintTo = txMsg.Sender + } + + if err := k.mint( + ctx, txMsg.Coin, txMsg.MintTo, txMsg.Sender, + ); err != nil { + return resp, err + } + + return &types.MsgMintResponse{ + MintTo: txMsg.MintTo, + }, ctx.EventManager().EmitTypedEvent( + &types.EventMint{ + Coin: txMsg.Coin, + ToAddr: txMsg.MintTo, + Caller: txMsg.Sender, + }, + ) +} + +func (k Keeper) mint( + ctx sdk.Context, coin sdk.Coin, mintTo string, caller string, +) error { + if err := types.DenomStr(coin.Denom).Validate(); err != nil { + return err + } + + coins := sdk.NewCoins(coin) + err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + if err != nil { + return err + } + + mintToAddr, err := sdk.AccAddressFromBech32(mintTo) + if err != nil { + return err + } + + if k.bankKeeper.BlockedAddr(mintToAddr) { + return types.ErrBlockedAddress.Wrapf( + "failed to mint to %s", mintToAddr) + } + + return k.bankKeeper.SendCoinsFromModuleToAccount( + ctx, types.ModuleName, mintToAddr, coins, + ) +} + +// Burn: Message handler for the abci.Msg: MsgBurn +func (k Keeper) Burn( + goCtx context.Context, txMsg *types.MsgBurn, +) (resp *types.MsgBurnResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + admin, err := k.Store.GetAdmin(ctx, txMsg.Coin.Denom) + if err != nil { + return nil, err + } + + if txMsg.Sender != admin { + return resp, types.ErrUnauthorized.Wrapf( + "sender (%s), admin (%s)", txMsg.Sender, admin, + ) + } + + if txMsg.BurnFrom == "" { + txMsg.BurnFrom = txMsg.Sender + } + + if err := k.burn( + ctx, txMsg.Coin, txMsg.BurnFrom, txMsg.Sender, + ); err != nil { + return resp, err + } + + return &types.MsgBurnResponse{}, ctx.EventManager().EmitTypedEvent( + &types.EventBurn{ + Coin: txMsg.Coin, + FromAddr: txMsg.BurnFrom, + Caller: txMsg.Sender, + }, + ) +} + +func (k Keeper) burn( + ctx sdk.Context, coin sdk.Coin, burnFrom string, caller string, +) error { + if err := types.DenomStr(coin.Denom).Validate(); err != nil { + return err + } + + coins := sdk.NewCoins(coin) + err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + if err != nil { + return err + } + + burnFromAddr, err := sdk.AccAddressFromBech32(burnFrom) + if err != nil { + return err + } + + if k.bankKeeper.BlockedAddr(burnFromAddr) { + return types.ErrBlockedAddress.Wrapf( + "failed to burn from %s", burnFromAddr) + } + + if err = k.bankKeeper.SendCoinsFromAccountToModule( + ctx, burnFromAddr, types.ModuleName, coins, + ); err != nil { + return err + } + + return k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins) +} + +// SetDenomMetadata: Message handler for the abci.Msg: MsgSetDenomMetadata +func (k Keeper) SetDenomMetadata( + goCtx context.Context, txMsg *types.MsgSetDenomMetadata, +) (resp *types.MsgSetDenomMetadataResponse, err error) { + if txMsg == nil { + return resp, errNilMsg + } + if err := txMsg.ValidateBasic(); err != nil { + return resp, err // ValidateBasic needs to be guaranteed for Wasm bindings + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + denom := txMsg.Metadata.Base + admin, err := k.Store.GetAdmin(ctx, denom) + if err != nil { + return nil, err + } + + if txMsg.Sender != admin { + return resp, types.ErrUnauthorized.Wrapf( + "sender (%s), admin (%s)", txMsg.Sender, admin, + ) + } + + k.bankKeeper.SetDenomMetaData(ctx, txMsg.Metadata) + + return &types.MsgSetDenomMetadataResponse{}, ctx.EventManager(). + EmitTypedEvent(&types.EventSetDenomMetadata{ + Denom: denom, + Metadata: txMsg.Metadata, + Caller: txMsg.Sender, + }) +} diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index a2f763d64..9b7b53bcf 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -1,13 +1,15 @@ package keeper_test import ( - "testing" - "github.com/NibiruChain/collections" 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" + "github.com/NibiruChain/nibiru/app" "github.com/NibiruChain/nibiru/x/common/testutil" + oracletypes "github.com/NibiruChain/nibiru/x/oracle/types" "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) @@ -76,7 +78,7 @@ func (s *TestSuite) TestCreateDenom() { } for _, tc := range testCases { - s.T().Run(tc.name, func(t *testing.T) { + s.Run(tc.name, func() { s.SetupTest() if tc.preHook != nil { tc.preHook(s.ctx, s.app) @@ -110,27 +112,28 @@ func (s *TestSuite) TestChangeAdmin() { sbf := testutil.AccAddress().String() testCases := []struct { - name string + Name string txMsg *types.MsgChangeAdmin wantErr string preHook func(ctx sdk.Context, bapp *app.NibiruApp) postHook func(ctx sdk.Context, bapp *app.NibiruApp) }{ { - name: "sad: nil msg", + Name: "sad: nil msg", txMsg: nil, wantErr: "nil msg", }, { - name: "sad: fail validate basic", + Name: "sad: fail validate basic", txMsg: &types.MsgChangeAdmin{ - Sender: "sender", Denom: "tf/creator/nusd", NewAdmin: "new admin"}, + Sender: "sender", Denom: "tf/creator/nusd", NewAdmin: "new admin", + }, wantErr: "invalid sender", }, { - name: "sad: non-admin tries to change admin", + Name: "sad: non-admin tries to change admin", txMsg: &types.MsgChangeAdmin{ Sender: testutil.AccAddress().String(), Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), @@ -149,7 +152,7 @@ func (s *TestSuite) TestChangeAdmin() { }, { - name: "happy: SBF changes FTT admin", + Name: "happy: SBF changes FTT admin", txMsg: &types.MsgChangeAdmin{ Sender: sbf, Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), @@ -168,17 +171,18 @@ func (s *TestSuite) TestChangeAdmin() { }, { - name: "sad: change admin for denom that doesn't exist ", + Name: "sad: change admin for denom that doesn't exist ", txMsg: &types.MsgChangeAdmin{ Sender: sbf, Denom: types.TFDenom{Creator: sbf, Subdenom: "ftt"}.String(), - NewAdmin: testutil.AccAddress().String()}, + NewAdmin: testutil.AccAddress().String(), + }, wantErr: collections.ErrNotFound.Error(), }, } for _, tc := range testCases { - s.T().Run(tc.name, func(t *testing.T) { + s.Run(tc.Name, func() { s.SetupTest() if tc.preHook != nil { tc.preHook(s.ctx, s.app) @@ -251,7 +255,7 @@ func (s *TestSuite) TestUpdateModuleParams() { } for _, tc := range testCases { - s.T().Run(tc.name, func(t *testing.T) { + s.Run(tc.name, func() { s.SetupTest() _, err := s.app.TokenFactoryKeeper.UpdateModuleParams( sdk.WrapSDKContext(s.ctx), tc.txMsg, @@ -270,3 +274,364 @@ func (s *TestSuite) TestUpdateModuleParams() { }) } } + +type TestCaseTx struct { + // Name: identifier for the test case. + Name string + + // SetupMsgs: a list of messages to broadcast in order that should execute + // without error. These can be used to create complex scenarios. + SetupMsgs []sdk.Msg + + // PreHook: an optional hook that runs before TestMsgs + PreHook func(ctx sdk.Context, bapp *app.NibiruApp) + + TestMsgs []TestMsgElem + + // PostHook: an optional hook that runs after TestMsgs + PostHook func(ctx sdk.Context, bapp *app.NibiruApp) +} + +func (tc TestCaseTx) RunTest(s *TestSuite) { + for _, txMsg := range tc.SetupMsgs { + err := s.HandleMsg(txMsg) + s.Require().NoError(err) + } + + if tc.PreHook != nil { + tc.PreHook(s.ctx, s.app) + } + + for _, msgTc := range tc.TestMsgs { + err := s.HandleMsg(msgTc.TestMsg) + if msgTc.WantErr != "" { + s.ErrorContains(err, msgTc.WantErr) + continue + } + s.NoError(err) + } + + if tc.PostHook != nil { + tc.PostHook(s.ctx, s.app) + } +} + +type TestMsgElem struct { + TestMsg sdk.Msg + WantErr string +} + +func (s *TestSuite) TestMintBurn() { + _, addrs := testutil.PrivKeyAddressPairs(4) + tfModuleAddr := authtypes.NewModuleAddress(types.ModuleName) + tfdenom := types.TFDenom{ + Creator: addrs[0].String(), + Subdenom: "nusd", + } + nusd69420 := sdk.Coin{ + Denom: tfdenom.String(), + Amount: sdk.NewInt(69_420), + } + + testCases := []TestCaseTx{ + { + Name: "happy: mint and burn", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + + &types.MsgMint{ + Sender: addrs[0].String(), + Coin: sdk.Coin{ + Denom: types.TFDenom{ + Creator: addrs[0].String(), + Subdenom: "nusd", + }.String(), + Amount: sdk.NewInt(69_420), + }, + MintTo: "", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgBurn{ + Sender: addrs[0].String(), + Coin: sdk.Coin{ + Denom: types.TFDenom{ + Creator: addrs[0].String(), + Subdenom: "nusd", + }.String(), + Amount: sdk.NewInt(1), + }, + BurnFrom: "", + }, + WantErr: "", + }, + }, + PreHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + allDenoms := bapp.TokenFactoryKeeper.Store.Denoms. + Iterate(ctx, collections.Range[string]{}).Values() + s.Len(allDenoms, 1) + }, + PostHook: func(ctx sdk.Context, bapp *app.NibiruApp) { + allDenoms := bapp.TokenFactoryKeeper.Store.Denoms. + Iterate(ctx, collections.Range[string]{}).Values() + + s.T().Log("Minting changes total supply, but burning does not.") + denom := allDenoms[0] + s.Equal( + sdk.NewInt(69_420), s.app.BankKeeper.GetSupply(s.ctx, denom.String()).Amount, + ) + + s.T().Log("We burned 1 token, so it should be in the module account.") + coin := s.app.BankKeeper.GetBalance( + s.ctx, tfModuleAddr, denom.String()) + s.Equal( + sdk.NewInt(1), + coin.Amount, + ) + }, + }, + + { + Name: "sad: denom does not exist", + SetupMsgs: []sdk.Msg{}, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgMint{ + Sender: addrs[0].String(), + Coin: nusd69420, + MintTo: "", + }, + WantErr: collections.ErrNotFound.Error(), + }, + { + TestMsg: &types.MsgBurn{ + Sender: addrs[0].String(), + Coin: nusd69420, + BurnFrom: "", + }, + WantErr: collections.ErrNotFound.Error(), + }, + }, + }, + + { + Name: "sad: sender is not admin", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + + &types.MsgMint{ + Sender: addrs[0].String(), + Coin: nusd69420, + MintTo: "", + }, + + &types.MsgChangeAdmin{ + Sender: addrs[0].String(), + Denom: tfdenom.String(), + NewAdmin: addrs[1].String(), + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgMint{ + Sender: addrs[0].String(), + Coin: nusd69420, + MintTo: "", + }, + WantErr: types.ErrUnauthorized.Error(), + }, + { + TestMsg: &types.MsgBurn{ + Sender: addrs[0].String(), + Coin: nusd69420, + BurnFrom: "", + }, + WantErr: types.ErrUnauthorized.Error(), + }, + }, + }, + + { + Name: "sad: blocked addrs", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + + &types.MsgMint{ + Sender: addrs[0].String(), + Coin: nusd69420, + MintTo: "", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgMint{ + Sender: addrs[0].String(), + Coin: nusd69420, + MintTo: authtypes.NewModuleAddress(oracletypes.ModuleName).String(), + }, + WantErr: types.ErrBlockedAddress.Error(), + }, + { + TestMsg: &types.MsgBurn{ + Sender: addrs[0].String(), + Coin: nusd69420, + BurnFrom: authtypes.NewModuleAddress(oracletypes.ModuleName).String(), + }, + WantErr: types.ErrBlockedAddress.Error(), + }, + }, + }, + } + + for _, tc := range testCases { + s.Run(tc.Name, func() { + s.SetupTest() + tc.RunTest(s) + }) + } +} + +func (s *TestSuite) TestSetDenomMetadata() { + _, addrs := testutil.PrivKeyAddressPairs(4) + tfdenom := types.TFDenom{ + Creator: addrs[0].String(), + Subdenom: "nusd", + } + + testCases := []TestCaseTx{ + { + Name: "happy: set metadata", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgSetDenomMetadata{ + Sender: addrs[0].String(), + Metadata: tfdenom.DefaultBankMetadata(), + }, + WantErr: "", + }, + { + TestMsg: &types.MsgSetDenomMetadata{ + Sender: addrs[0].String(), + Metadata: banktypes.Metadata{ + Description: "US Dollar", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: tfdenom.String(), + Exponent: 0, + Aliases: []string{"unusd"}, + }, + {Denom: "USD", Exponent: 6}, + }, + Base: tfdenom.String(), + Display: "USD", + Name: "USD", + Symbol: "USD", + URI: "https://www.federalreserve.gov/aboutthefed/currency.htm", + }, + }, + WantErr: "", + }, + }, + }, // end case + + { + Name: "sad: sender not admin", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgSetDenomMetadata{ + Sender: addrs[1].String(), + Metadata: tfdenom.DefaultBankMetadata(), + }, + WantErr: types.ErrUnauthorized.Error(), + }, + }, + }, // end case + + { + Name: "sad: invalid sender", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgSetDenomMetadata{ + Sender: "sender", + Metadata: tfdenom.DefaultBankMetadata(), + }, + WantErr: "invalid sender", + }, + }, + }, // end case + + { + Name: "sad: nil msg", + TestMsgs: []TestMsgElem{ + { + TestMsg: (*types.MsgSetDenomMetadata)(nil), + WantErr: "nil msg", + }}, + }, + + { + Name: "sad: metadata.base is not registered", + SetupMsgs: []sdk.Msg{ + &types.MsgCreateDenom{ + Sender: addrs[0].String(), + Subdenom: "nusd", + }, + }, + TestMsgs: []TestMsgElem{ + { + TestMsg: &types.MsgSetDenomMetadata{ + Sender: addrs[0].String(), + Metadata: banktypes.Metadata{ + DenomUnits: []*banktypes.DenomUnit{{ + Denom: "ust", + Exponent: 0, + }}, + Base: "ust", + // The following is necessary for x/bank denom validation + Display: "ust", + Name: "ust", + Symbol: "ust", + }, + }, + WantErr: collections.ErrNotFound.Error(), + }, + }, + }, // end case + + } + + for _, tc := range testCases { + s.Run(tc.Name, func() { + s.SetupTest() + tc.RunTest(s) + }) + } +} diff --git a/x/tokenfactory/keeper/store.go b/x/tokenfactory/keeper/store.go index 9fa926f8e..c0d7db2bf 100644 --- a/x/tokenfactory/keeper/store.go +++ b/x/tokenfactory/keeper/store.go @@ -97,15 +97,31 @@ func (api StoreAPI) HasCreator(ctx sdk.Context, creator string) bool { func (api StoreAPI) GetDenomAuthorityMetadata( ctx sdk.Context, denom string, ) (tftypes.DenomAuthorityMetadata, error) { - return api.denomAdmins.Get(ctx, denom) + metadata, err := api.denomAdmins.Get(ctx, denom) + if err != nil { + return metadata, tftypes.ErrGetAdmin.Wrap(err.Error()) + } + return metadata, nil +} + +func (api StoreAPI) GetAdmin( + ctx sdk.Context, denom string, +) (string, error) { + metadata, err := api.denomAdmins.Get(ctx, denom) + if err != nil { + return "", err + } + return metadata.Admin, nil } // --------------------------------------------- // StoreAPI - Under the hood // --------------------------------------------- -type storePKType = string -type storeVType = tftypes.TFDenom +type ( + storePKType = string + storeVType = tftypes.TFDenom +) // NewTFDenomStore: Creates an indexed map over token facotry denoms indexed // by creator address. diff --git a/x/tokenfactory/keeper/store_test.go b/x/tokenfactory/keeper/store_test.go index 0f024fd60..23c716fc1 100644 --- a/x/tokenfactory/keeper/store_test.go +++ b/x/tokenfactory/keeper/store_test.go @@ -1,9 +1,6 @@ package keeper_test import ( - "fmt" - "testing" - "github.com/NibiruChain/collections" "github.com/NibiruChain/nibiru/x/common/testutil" @@ -28,10 +25,9 @@ func (s *TestSuite) TestStoreWrite() { api := s.keeper.Store - s.T().Run("initial conditions", func(t *testing.T) { + s.Run("initial conditions", func() { for _, tfdenom := range tfdenoms { // created denoms should be valid - fmt.Printf("tfdenom: %v\n", tfdenom) s.NoError(tfdenom.Validate(), tfdenom) // query by denom should fail for all denoms @@ -43,7 +39,7 @@ func (s *TestSuite) TestStoreWrite() { } }) - s.T().Run("insert to state", func(t *testing.T) { + s.Run("insert to state", func() { // inserting should succeed for _, tfdenom := range tfdenoms { s.Require().NoError(api.InsertDenom(s.ctx, tfdenom)) @@ -61,7 +57,7 @@ func (s *TestSuite) TestStoreWrite() { s.False(api.HasCreator(s.ctx, testutil.AccAddress().String())) }) - s.T().Run("inserting invalid denom should fail", func(t *testing.T) { + s.Run("inserting invalid denom should fail", func() { blankDenom := tftypes.TFDenom{} s.Error(blankDenom.Validate()) s.Error(api.InsertDenom(s.ctx, blankDenom)) diff --git a/x/tokenfactory/module_test.go b/x/tokenfactory/module_test.go index 8515b2847..f143c4296 100644 --- a/x/tokenfactory/module_test.go +++ b/x/tokenfactory/module_test.go @@ -46,9 +46,8 @@ func (s *ModuleTestSuite) TestAppModule() { s.NoError(err) s.T().Log("CLI commands") - // TODO - // s.NotNil(appModule.AppModuleBasic.GetTxCmd()) - // s.NotNil(appModule.AppModuleBasic.GetQueryCmd()) + s.NotNil(appModule.AppModuleBasic.GetTxCmd()) + s.NotNil(appModule.AppModuleBasic.GetQueryCmd()) s.NotEmpty(appModule.QuerierRoute()) }) } diff --git a/x/tokenfactory/types/codec.go b/x/tokenfactory/types/codec.go index 46b6ff55a..84be87b73 100644 --- a/x/tokenfactory/types/codec.go +++ b/x/tokenfactory/types/codec.go @@ -32,7 +32,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgCreateDenom{}, &MsgChangeAdmin{}, &MsgUpdateModuleParams{}, - // &MsgTODO{}, + &MsgMint{}, + &MsgBurn{}, + &MsgSetDenomMetadata{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) @@ -43,6 +45,9 @@ func TX_MSG_TYPE_URLS() []string { "/nibiru.tokenfactory.v1.MsgCreateDenom", "/nibiru.tokenfactory.v1.MsgChangeAdmin", "/nibiru.tokenfactory.v1.MsgUpdateModuleParams", + "/nibiru.tokenfactory.v1.MsgMint", + "/nibiru.tokenfactory.v1.MsgBurn", + "/nibiru.tokenfactory.v1.MsgSetDenomMetadata", } } @@ -57,6 +62,9 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { {&MsgCreateDenom{}, "nibiru/tokenfactory/create-denom"}, {&MsgChangeAdmin{}, "nibiru/tokenfactory/change-admin"}, {&MsgUpdateModuleParams{}, "nibiru/tokenfactory/update-module-params"}, + {&MsgMint{}, "nibiru/tokenfactory/mint"}, + {&MsgBurn{}, "nibiru/tokenfactory/burn"}, + {&MsgSetDenomMetadata{}, "nibiru/tokenfactory/set-denom-metadata"}, } { cdc.RegisterConcrete(ele.MsgType, ele.Name, nil) } diff --git a/x/tokenfactory/types/codec_test.go b/x/tokenfactory/types/codec_test.go index 11dcc6dc6..2e0300055 100644 --- a/x/tokenfactory/types/codec_test.go +++ b/x/tokenfactory/types/codec_test.go @@ -25,6 +25,5 @@ func (suite *CodecSuite) TestRegisterInterfaces() { types.RegisterInterfaces(registry) impls := registry.ListImplementations(sdk.MsgInterfaceProtoName) - suite.Require().Equal(3, len(impls)) suite.Require().ElementsMatch(types.TX_MSG_TYPE_URLS(), impls) } diff --git a/x/tokenfactory/types/errors.go b/x/tokenfactory/types/errors.go index ee80b8e8b..aae1ec3b7 100644 --- a/x/tokenfactory/types/errors.go +++ b/x/tokenfactory/types/errors.go @@ -21,4 +21,10 @@ var ( ErrDenomAlreadyRegistered = registerError("attempting to create denom that is already registered (has bank metadata)") ErrInvalidSender = registerError("invalid msg sender") ErrInvalidModuleParams = registerError("invalid module params") + ErrGetAdmin = registerError("failed to find admin for denom") + ErrGetMetadata = registerError("failed to find bank metadata for denom") + ErrUnauthorized = registerError("sender must be admin") + // ErrBlockedAddress: error when the x/bank keeper has an address + // blocked. + ErrBlockedAddress = registerError("blocked address") ) diff --git a/x/tokenfactory/types/event.pb.go b/x/tokenfactory/types/event.pb.go index 9f74b8415..808fb098d 100644 --- a/x/tokenfactory/types/event.pb.go +++ b/x/tokenfactory/types/event.pb.go @@ -5,6 +5,9 @@ package types import ( fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -76,8 +79,8 @@ func (m *EventCreateDenom) GetCreator() string { type EventChangeAdmin struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - OldAdmin string `protobuf:"bytes,3,opt,name=old_admin,json=oldAdmin,proto3" json:"old_admin,omitempty"` NewAdmin string `protobuf:"bytes,2,opt,name=new_admin,json=newAdmin,proto3" json:"new_admin,omitempty"` + OldAdmin string `protobuf:"bytes,3,opt,name=old_admin,json=oldAdmin,proto3" json:"old_admin,omitempty"` } func (m *EventChangeAdmin) Reset() { *m = EventChangeAdmin{} } @@ -120,6 +123,13 @@ func (m *EventChangeAdmin) GetDenom() string { return "" } +func (m *EventChangeAdmin) GetNewAdmin() string { + if m != nil { + return m.NewAdmin + } + return "" +} + func (m *EventChangeAdmin) GetOldAdmin() string { if m != nil { return m.OldAdmin @@ -127,9 +137,184 @@ func (m *EventChangeAdmin) GetOldAdmin() string { return "" } -func (m *EventChangeAdmin) GetNewAdmin() string { +type EventMint struct { + Coin types.Coin `protobuf:"bytes,1,opt,name=coin,proto3" json:"coin" yaml:"coin"` + ToAddr string `protobuf:"bytes,2,opt,name=to_addr,json=toAddr,proto3" json:"to_addr,omitempty"` + Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"` +} + +func (m *EventMint) Reset() { *m = EventMint{} } +func (m *EventMint) String() string { return proto.CompactTextString(m) } +func (*EventMint) ProtoMessage() {} +func (*EventMint) Descriptor() ([]byte, []int) { + return fileDescriptor_a46c3c7b7d022093, []int{2} +} +func (m *EventMint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventMint.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 *EventMint) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventMint.Merge(m, src) +} +func (m *EventMint) XXX_Size() int { + return m.Size() +} +func (m *EventMint) XXX_DiscardUnknown() { + xxx_messageInfo_EventMint.DiscardUnknown(m) +} + +var xxx_messageInfo_EventMint proto.InternalMessageInfo + +func (m *EventMint) GetCoin() types.Coin { if m != nil { - return m.NewAdmin + return m.Coin + } + return types.Coin{} +} + +func (m *EventMint) GetToAddr() string { + if m != nil { + return m.ToAddr + } + return "" +} + +func (m *EventMint) GetCaller() string { + if m != nil { + return m.Caller + } + return "" +} + +type EventBurn struct { + Coin types.Coin `protobuf:"bytes,1,opt,name=coin,proto3" json:"coin" yaml:"coin"` + FromAddr string `protobuf:"bytes,2,opt,name=from_addr,json=fromAddr,proto3" json:"from_addr,omitempty"` + Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"` +} + +func (m *EventBurn) Reset() { *m = EventBurn{} } +func (m *EventBurn) String() string { return proto.CompactTextString(m) } +func (*EventBurn) ProtoMessage() {} +func (*EventBurn) Descriptor() ([]byte, []int) { + return fileDescriptor_a46c3c7b7d022093, []int{3} +} +func (m *EventBurn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBurn.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 *EventBurn) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBurn.Merge(m, src) +} +func (m *EventBurn) XXX_Size() int { + return m.Size() +} +func (m *EventBurn) XXX_DiscardUnknown() { + xxx_messageInfo_EventBurn.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBurn proto.InternalMessageInfo + +func (m *EventBurn) GetCoin() types.Coin { + if m != nil { + return m.Coin + } + return types.Coin{} +} + +func (m *EventBurn) GetFromAddr() string { + if m != nil { + return m.FromAddr + } + return "" +} + +func (m *EventBurn) GetCaller() string { + if m != nil { + return m.Caller + } + return "" +} + +type EventSetDenomMetadata struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. The "metadata.base" is the denom. + Metadata types1.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"` + Caller string `protobuf:"bytes,3,opt,name=caller,proto3" json:"caller,omitempty"` +} + +func (m *EventSetDenomMetadata) Reset() { *m = EventSetDenomMetadata{} } +func (m *EventSetDenomMetadata) String() string { return proto.CompactTextString(m) } +func (*EventSetDenomMetadata) ProtoMessage() {} +func (*EventSetDenomMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_a46c3c7b7d022093, []int{4} +} +func (m *EventSetDenomMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSetDenomMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSetDenomMetadata.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 *EventSetDenomMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSetDenomMetadata.Merge(m, src) +} +func (m *EventSetDenomMetadata) XXX_Size() int { + return m.Size() +} +func (m *EventSetDenomMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_EventSetDenomMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSetDenomMetadata proto.InternalMessageInfo + +func (m *EventSetDenomMetadata) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *EventSetDenomMetadata) GetMetadata() types1.Metadata { + if m != nil { + return m.Metadata + } + return types1.Metadata{} +} + +func (m *EventSetDenomMetadata) GetCaller() string { + if m != nil { + return m.Caller } return "" } @@ -137,6 +322,9 @@ func (m *EventChangeAdmin) GetNewAdmin() string { func init() { proto.RegisterType((*EventCreateDenom)(nil), "nibiru.tokenfactory.v1.EventCreateDenom") proto.RegisterType((*EventChangeAdmin)(nil), "nibiru.tokenfactory.v1.EventChangeAdmin") + proto.RegisterType((*EventMint)(nil), "nibiru.tokenfactory.v1.EventMint") + proto.RegisterType((*EventBurn)(nil), "nibiru.tokenfactory.v1.EventBurn") + proto.RegisterType((*EventSetDenomMetadata)(nil), "nibiru.tokenfactory.v1.EventSetDenomMetadata") } func init() { @@ -144,22 +332,34 @@ func init() { } var fileDescriptor_a46c3c7b7d022093 = []byte{ - // 237 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xcb, 0x4c, 0xca, - 0x2c, 0x2a, 0xd5, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, 0xd4, - 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, - 0x83, 0xa8, 0xd1, 0x43, 0x56, 0xa3, 0x57, 0x66, 0xa8, 0xe4, 0xc4, 0x25, 0xe0, 0x0a, 0x52, 0xe6, - 0x5c, 0x94, 0x9a, 0x58, 0x92, 0xea, 0x92, 0x9a, 0x97, 0x9f, 0x2b, 0x24, 0xc2, 0xc5, 0x9a, 0x02, - 0x62, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x41, 0x38, 0x42, 0x12, 0x5c, 0xec, 0xc9, 0x20, - 0x45, 0xf9, 0x45, 0x12, 0x4c, 0x60, 0x71, 0x18, 0x57, 0x29, 0x09, 0x66, 0x46, 0x46, 0x62, 0x5e, - 0x7a, 0xaa, 0x63, 0x4a, 0x6e, 0x66, 0x1e, 0x0e, 0x33, 0xa4, 0xb9, 0x38, 0xf3, 0x73, 0x52, 0xe2, - 0x13, 0x41, 0x4a, 0x24, 0x98, 0xc1, 0x32, 0x1c, 0xf9, 0x39, 0x29, 0x10, 0x2d, 0xd2, 0x5c, 0x9c, - 0x79, 0xa9, 0xe5, 0x50, 0x49, 0x88, 0x15, 0x1c, 0x79, 0xa9, 0xe5, 0x60, 0x49, 0x27, 0x9f, 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, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xf7, 0x03, 0x7b, 0xd2, 0x39, 0x23, 0x31, 0x33, 0x4f, 0x1f, 0x1a, - 0x28, 0x15, 0xa8, 0xc1, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x14, 0x63, 0x40, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xb0, 0xbe, 0x29, 0x3a, 0x01, 0x00, 0x00, + // 432 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0xbf, 0x92, 0xd3, 0x30, + 0x10, 0xc6, 0x6d, 0x38, 0x72, 0xb1, 0xd2, 0x30, 0xe6, 0x38, 0x02, 0x19, 0x7c, 0x8c, 0x2b, 0x2a, + 0x69, 0x1c, 0x3a, 0x1a, 0xe6, 0x1c, 0xe8, 0x38, 0x8a, 0xd0, 0xd1, 0xdc, 0xc8, 0x96, 0xce, 0xd1, + 0xc4, 0xd6, 0xde, 0xc8, 0x8a, 0x8f, 0x74, 0x14, 0x0c, 0x35, 0x8f, 0x95, 0x32, 0x25, 0x55, 0x86, + 0x49, 0xde, 0x80, 0x27, 0x60, 0x24, 0xcb, 0x21, 0x14, 0xa1, 0xa2, 0xd3, 0xee, 0xb7, 0x7f, 0x7e, + 0x9f, 0xbd, 0x28, 0x96, 0x22, 0x13, 0x6a, 0x41, 0x34, 0xcc, 0xb9, 0xbc, 0xa1, 0xb9, 0x06, 0xb5, + 0x24, 0x4d, 0x42, 0x78, 0xc3, 0xa5, 0xc6, 0xb7, 0x0a, 0x34, 0x84, 0xe7, 0x6d, 0x0d, 0x3e, 0xac, + 0xc1, 0x4d, 0xf2, 0x2c, 0xca, 0xa1, 0xae, 0xa0, 0x26, 0x19, 0x95, 0x73, 0xd2, 0x24, 0x19, 0xd7, + 0x34, 0xb1, 0x41, 0xdb, 0x77, 0xa0, 0xd7, 0x7c, 0xaf, 0xe7, 0x20, 0xa4, 0xd3, 0xcf, 0x0a, 0x28, + 0xc0, 0x3e, 0x89, 0x79, 0xb5, 0xd9, 0x38, 0x45, 0x0f, 0xdf, 0x99, 0xe5, 0x13, 0xc5, 0xa9, 0xe6, + 0x6f, 0xb9, 0x84, 0x2a, 0x3c, 0x43, 0x0f, 0x98, 0x79, 0x0c, 0xfd, 0x17, 0xfe, 0xcb, 0x60, 0xda, + 0x06, 0xe1, 0x10, 0x9d, 0xe6, 0xa6, 0x08, 0xd4, 0xf0, 0x9e, 0xcd, 0x77, 0x61, 0x9c, 0x75, 0x33, + 0x66, 0x54, 0x16, 0xfc, 0x92, 0x55, 0x42, 0x1e, 0x99, 0x31, 0x42, 0x81, 0xe4, 0x77, 0xd7, 0xd4, + 0x94, 0xb8, 0x29, 0x7d, 0xc9, 0xef, 0xda, 0x96, 0x11, 0x0a, 0xa0, 0x64, 0x4e, 0xbc, 0xdf, 0x8a, + 0x50, 0x32, 0x2b, 0xc6, 0x5f, 0x7c, 0x14, 0xd8, 0x25, 0x57, 0x42, 0xea, 0x30, 0x45, 0x27, 0xc6, + 0x99, 0x1d, 0x3e, 0x18, 0x3f, 0xc5, 0xad, 0x75, 0x6c, 0xac, 0x63, 0x67, 0x1d, 0x4f, 0x40, 0xc8, + 0xf4, 0xd1, 0x6a, 0x73, 0xe1, 0xfd, 0xda, 0x5c, 0x0c, 0x96, 0xb4, 0x2a, 0x5f, 0xc7, 0xa6, 0x29, + 0x9e, 0xda, 0xde, 0xf0, 0x09, 0x3a, 0xd5, 0x70, 0x4d, 0x19, 0xeb, 0xfc, 0xf4, 0x34, 0x5c, 0x32, + 0xa6, 0xc2, 0x73, 0xd4, 0xcb, 0x69, 0x59, 0x72, 0xe5, 0x20, 0x5c, 0x14, 0x7f, 0xed, 0x10, 0xd2, + 0x85, 0x92, 0xff, 0x05, 0x61, 0x84, 0x82, 0x1b, 0x05, 0xd5, 0x21, 0x44, 0xdf, 0x24, 0xfe, 0x89, + 0xf1, 0xcd, 0x47, 0x8f, 0x2d, 0xc6, 0x47, 0xae, 0xed, 0xff, 0xba, 0xe2, 0x9a, 0x32, 0xaa, 0xe9, + 0x91, 0x6f, 0xfe, 0x06, 0xf5, 0x2b, 0x57, 0x61, 0x77, 0x0c, 0xc6, 0xcf, 0xff, 0xc0, 0xca, 0xf9, + 0x1e, 0xb6, 0x1b, 0x93, 0x9e, 0x18, 0xe0, 0xe9, 0xbe, 0xe9, 0x18, 0x48, 0xfa, 0x7e, 0xb5, 0x8d, + 0xfc, 0xf5, 0x36, 0xf2, 0x7f, 0x6e, 0x23, 0xff, 0xfb, 0x2e, 0xf2, 0xd6, 0xbb, 0xc8, 0xfb, 0xb1, + 0x8b, 0xbc, 0x4f, 0xe3, 0x42, 0xe8, 0xd9, 0x22, 0xc3, 0x39, 0x54, 0xe4, 0x83, 0xbd, 0xe6, 0xc9, + 0x8c, 0x0a, 0x49, 0xdc, 0xf5, 0x7f, 0xfe, 0xfb, 0xfe, 0xf5, 0xf2, 0x96, 0xd7, 0x59, 0xcf, 0xde, + 0xe3, 0xab, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x91, 0x31, 0x11, 0x4b, 0x23, 0x03, 0x00, 0x00, } func (m *EventCreateDenom) Marshal() (dAtA []byte, err error) { @@ -243,6 +443,147 @@ func (m *EventChangeAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventMint) 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 *EventMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Caller) > 0 { + i -= len(m.Caller) + copy(dAtA[i:], m.Caller) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller))) + i-- + dAtA[i] = 0x1a + } + if len(m.ToAddr) > 0 { + i -= len(m.ToAddr) + copy(dAtA[i:], m.ToAddr) + i = encodeVarintEvent(dAtA, i, uint64(len(m.ToAddr))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EventBurn) 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 *EventBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Caller) > 0 { + i -= len(m.Caller) + copy(dAtA[i:], m.Caller) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller))) + i-- + dAtA[i] = 0x1a + } + if len(m.FromAddr) > 0 { + i -= len(m.FromAddr) + copy(dAtA[i:], m.FromAddr) + i = encodeVarintEvent(dAtA, i, uint64(len(m.FromAddr))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *EventSetDenomMetadata) 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 *EventSetDenomMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSetDenomMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Caller) > 0 { + i -= len(m.Caller) + copy(dAtA[i:], m.Caller) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Caller))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { offset -= sovEvent(v) base := offset @@ -292,6 +633,63 @@ func (m *EventChangeAdmin) Size() (n int) { return n } +func (m *EventMint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Coin.Size() + n += 1 + l + sovEvent(uint64(l)) + l = len(m.ToAddr) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Caller) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventBurn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Coin.Size() + n += 1 + l + sovEvent(uint64(l)) + l = len(m.FromAddr) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = len(m.Caller) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + +func (m *EventSetDenomMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovEvent(uint64(l)) + l = len(m.Caller) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + return n +} + func sovEvent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -558,6 +956,447 @@ func (m *EventChangeAdmin) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventMint) 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 ErrIntOverflowEvent + } + 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: EventMint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventMint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ToAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ToAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Caller = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBurn) 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 ErrIntOverflowEvent + } + 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: EventBurn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBurn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FromAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Caller = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventSetDenomMetadata) 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 ErrIntOverflowEvent + } + 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: EventSetDenomMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSetDenomMetadata: 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 ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + 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 Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Caller", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Caller = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvent(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenfactory/types/genesis.go b/x/tokenfactory/types/genesis.go index f6771b81c..d97990c3a 100644 --- a/x/tokenfactory/types/genesis.go +++ b/x/tokenfactory/types/genesis.go @@ -1,6 +1,8 @@ package types import ( + fmt "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/NibiruChain/nibiru/x/common/set" @@ -32,13 +34,15 @@ func (gs GenesisState) Validate() error { seenDenoms.Add(denom) if err := genesisDenom.Validate(); err != nil { - return err + return ErrInvalidGenesis.Wrap(err.Error()) } - if genesisDenom.AuthorityMetadata.Admin != "" { - _, err = sdk.AccAddressFromBech32(genesisDenom.AuthorityMetadata.Admin) + if admin := genesisDenom.AuthorityMetadata.Admin; admin != "" { + _, err = sdk.AccAddressFromBech32(admin) if err != nil { - return ErrInvalidAdmin.Wrapf("Invalid admin address (%s)", err) + return fmt.Errorf("%w: %s: admin address (%s): %s", + ErrInvalidGenesis, ErrInvalidAdmin, admin, err, + ) } } } diff --git a/x/tokenfactory/types/state_test.go b/x/tokenfactory/types/state_test.go index 1b9a3eacb..9277dc2e1 100644 --- a/x/tokenfactory/types/state_test.go +++ b/x/tokenfactory/types/state_test.go @@ -89,7 +89,8 @@ func TestGenesisState(t *testing.T) { FactoryDenoms: happyGenDenoms, }, }, - {name: "sad: duplicate", wantErr: "duplicate denom", + {name: "sad: duplicate", + wantErr: "duplicate denom", genState: types.GenesisState{ Params: types.DefaultModuleParams(), FactoryDenoms: []types.GenesisDenom{ @@ -97,7 +98,8 @@ func TestGenesisState(t *testing.T) { }, }, }, - {name: "sad: invalid admin", wantErr: types.ErrInvalidAdmin.Error(), + {name: "sad: invalid admin", + wantErr: types.ErrInvalidAdmin.Error(), genState: types.GenesisState{ Params: types.DefaultModuleParams(), FactoryDenoms: []types.GenesisDenom{ @@ -111,6 +113,22 @@ func TestGenesisState(t *testing.T) { }, }, }, + + {name: "sad: invalid genesis denom", + wantErr: types.ErrInvalidGenesis.Error(), + genState: types.GenesisState{ + Params: types.DefaultModuleParams(), + FactoryDenoms: []types.GenesisDenom{ + happyGenDenoms[0], + { + Denom: "sad denom", + AuthorityMetadata: types.DenomAuthorityMetadata{ + Admin: happyGenDenoms[1].AuthorityMetadata.Admin, + }, + }, + }, + }, + }, } { t.Run(fmt.Sprintf("%v %s", idx, tc.name), func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/tokenfactory/types/tx.pb.go b/x/tokenfactory/types/tx.pb.go index 3f3acddea..dbfc272ef 100644 --- a/x/tokenfactory/types/tx.pb.go +++ b/x/tokenfactory/types/tx.pb.go @@ -7,8 +7,9 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" + types1 "github.com/cosmos/cosmos-sdk/x/bank/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -327,6 +328,309 @@ func (m *MsgUpdateModuleParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateModuleParamsResponse proto.InternalMessageInfo +// MsgMint: sdk.Msg (TxMsg) where an denom admin mints more of the token. +type MsgMint struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + // coin: The denom identifier and amount to mint. + Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"` + // mint_to_addr: An address to which tokens will be minted. If blank, + // tokens are minted to the "sender". + MintTo string `protobuf:"bytes,3,opt,name=mint_to,json=mintTo,proto3" json:"mint_to,omitempty" yaml:"mint_to"` +} + +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_4c78bacd179e004d, []int{6} +} +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) GetCoin() types.Coin { + if m != nil { + return m.Coin + } + return types.Coin{} +} + +func (m *MsgMint) GetMintTo() string { + if m != nil { + return m.MintTo + } + return "" +} + +type MsgMintResponse struct { + MintTo string `protobuf:"bytes,1,opt,name=mint_to,json=mintTo,proto3" json:"mint_to,omitempty"` +} + +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_4c78bacd179e004d, []int{7} +} +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 + +func (m *MsgMintResponse) GetMintTo() string { + if m != nil { + return m.MintTo + } + return "" +} + +// MsgBurn: sdk.Msg (TxMsg) where a denom admin burns some of the token. +// The reason that the sender isn't automatically the "burn_from" address +// is to support smart contracts (primary use case). In this situation, the +// contract is the message signer and sender, while "burn_from" is based on the +// contract logic. +type MsgBurn struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + // coin: The denom identifier and amount to burn. + Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"` + // burn_from: The address from which tokens will be burned. + BurnFrom string `protobuf:"bytes,3,opt,name=burn_from,json=burnFrom,proto3" json:"burn_from,omitempty" yaml:"burn_from"` +} + +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_4c78bacd179e004d, []int{8} +} +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) GetCoin() types.Coin { + if m != nil { + return m.Coin + } + return types.Coin{} +} + +func (m *MsgBurn) GetBurnFrom() string { + if m != nil { + return m.BurnFrom + } + 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_4c78bacd179e004d, []int{9} +} +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 + +// MsgSetDenomMetadata: sdk.Msg (TxMsg) enabling the denom admin to change its +// bank metadata. +type MsgSetDenomMetadata struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + // Metadata: Official x/bank metadata for the denom. All token factory denoms + // are standard, native assets. The "metadata.base" is the denom. + Metadata types1.Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata"` +} + +func (m *MsgSetDenomMetadata) Reset() { *m = MsgSetDenomMetadata{} } +func (m *MsgSetDenomMetadata) String() string { return proto.CompactTextString(m) } +func (*MsgSetDenomMetadata) ProtoMessage() {} +func (*MsgSetDenomMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_4c78bacd179e004d, []int{10} +} +func (m *MsgSetDenomMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDenomMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDenomMetadata.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 *MsgSetDenomMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDenomMetadata.Merge(m, src) +} +func (m *MsgSetDenomMetadata) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDenomMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDenomMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDenomMetadata proto.InternalMessageInfo + +func (m *MsgSetDenomMetadata) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSetDenomMetadata) GetMetadata() types1.Metadata { + if m != nil { + return m.Metadata + } + return types1.Metadata{} +} + +type MsgSetDenomMetadataResponse struct { +} + +func (m *MsgSetDenomMetadataResponse) Reset() { *m = MsgSetDenomMetadataResponse{} } +func (m *MsgSetDenomMetadataResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetDenomMetadataResponse) ProtoMessage() {} +func (*MsgSetDenomMetadataResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c78bacd179e004d, []int{11} +} +func (m *MsgSetDenomMetadataResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDenomMetadataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDenomMetadataResponse.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 *MsgSetDenomMetadataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDenomMetadataResponse.Merge(m, src) +} +func (m *MsgSetDenomMetadataResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDenomMetadataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDenomMetadataResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDenomMetadataResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateDenom)(nil), "nibiru.tokenfactory.v1.MsgCreateDenom") proto.RegisterType((*MsgCreateDenomResponse)(nil), "nibiru.tokenfactory.v1.MsgCreateDenomResponse") @@ -334,47 +638,68 @@ func init() { proto.RegisterType((*MsgChangeAdminResponse)(nil), "nibiru.tokenfactory.v1.MsgChangeAdminResponse") proto.RegisterType((*MsgUpdateModuleParams)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParams") proto.RegisterType((*MsgUpdateModuleParamsResponse)(nil), "nibiru.tokenfactory.v1.MsgUpdateModuleParamsResponse") + proto.RegisterType((*MsgMint)(nil), "nibiru.tokenfactory.v1.MsgMint") + proto.RegisterType((*MsgMintResponse)(nil), "nibiru.tokenfactory.v1.MsgMintResponse") + proto.RegisterType((*MsgBurn)(nil), "nibiru.tokenfactory.v1.MsgBurn") + proto.RegisterType((*MsgBurnResponse)(nil), "nibiru.tokenfactory.v1.MsgBurnResponse") + proto.RegisterType((*MsgSetDenomMetadata)(nil), "nibiru.tokenfactory.v1.MsgSetDenomMetadata") + proto.RegisterType((*MsgSetDenomMetadataResponse)(nil), "nibiru.tokenfactory.v1.MsgSetDenomMetadataResponse") } func init() { proto.RegisterFile("nibiru/tokenfactory/v1/tx.proto", fileDescriptor_4c78bacd179e004d) } var fileDescriptor_4c78bacd179e004d = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x4f, 0x6f, 0x12, 0x41, - 0x18, 0xc6, 0xd9, 0x56, 0x49, 0x99, 0xda, 0x3f, 0xae, 0x88, 0x48, 0xe2, 0xae, 0x99, 0x98, 0x46, - 0x4d, 0xba, 0x1b, 0x30, 0x7a, 0xe8, 0xad, 0xd4, 0xa3, 0x18, 0xb3, 0xea, 0xc5, 0x98, 0x90, 0x59, - 0xf6, 0x75, 0xd9, 0xc8, 0xce, 0x90, 0x9d, 0x01, 0x8a, 0x47, 0x3f, 0x81, 0x27, 0xbf, 0x80, 0x5f, - 0xc0, 0x83, 0x1f, 0xa2, 0x37, 0x1b, 0x4f, 0x9e, 0x36, 0x06, 0x0e, 0xde, 0xf9, 0x04, 0x66, 0x67, - 0x86, 0x02, 0x96, 0x92, 0xf6, 0x06, 0xfb, 0xfc, 0xe6, 0x79, 0x9e, 0x37, 0xf3, 0x0e, 0xb2, 0x69, - 0xe4, 0x47, 0x49, 0xcf, 0x15, 0xec, 0x23, 0xd0, 0x0f, 0xa4, 0x25, 0x58, 0x32, 0x74, 0xfb, 0x55, - 0x57, 0x1c, 0x3b, 0xdd, 0x84, 0x09, 0x66, 0x96, 0x14, 0xe0, 0xcc, 0x03, 0x4e, 0xbf, 0x5a, 0x29, - 0x86, 0x2c, 0x64, 0x12, 0x71, 0xb3, 0x5f, 0x8a, 0xae, 0x58, 0x2d, 0xc6, 0x63, 0xc6, 0x5d, 0x9f, - 0x70, 0x70, 0xfb, 0x55, 0x1f, 0x04, 0xa9, 0xba, 0x2d, 0x16, 0x51, 0xad, 0xdf, 0xd1, 0x7a, 0xcc, - 0xc3, 0x2c, 0x25, 0xe6, 0xa1, 0x16, 0xee, 0x2a, 0xa1, 0xa9, 0x1c, 0xd5, 0x1f, 0x2d, 0xe1, 0x0b, - 0x2a, 0x72, 0x41, 0x04, 0x28, 0x06, 0x77, 0xd0, 0x76, 0x83, 0x87, 0x47, 0x09, 0x10, 0x01, 0xcf, - 0x81, 0xb2, 0xd8, 0x7c, 0x84, 0xf2, 0x1c, 0x68, 0x00, 0x49, 0xd9, 0xb8, 0x6f, 0x3c, 0x2c, 0xd4, - 0x6f, 0x4e, 0x52, 0x7b, 0x6b, 0x48, 0xe2, 0xce, 0x01, 0x56, 0xdf, 0xb1, 0xa7, 0x01, 0xd3, 0x45, - 0x1b, 0xbc, 0xe7, 0x07, 0xd9, 0xb1, 0xf2, 0x9a, 0x84, 0x6f, 0x4d, 0x52, 0x7b, 0x47, 0xc3, 0x5a, - 0xc1, 0xde, 0x19, 0x84, 0xdf, 0xa3, 0xd2, 0x62, 0x9a, 0x07, 0xbc, 0xcb, 0x28, 0x07, 0xb3, 0x8e, - 0x76, 0x28, 0x0c, 0x9a, 0xb2, 0x6a, 0x53, 0x39, 0xaa, 0xf8, 0xca, 0x24, 0xb5, 0x4b, 0xca, 0xf1, - 0x3f, 0x00, 0x7b, 0x5b, 0x14, 0x06, 0x6f, 0xb2, 0x0f, 0xd2, 0x0b, 0x7f, 0x35, 0xd4, 0x30, 0x6d, - 0x42, 0x43, 0x38, 0x0c, 0xe2, 0x88, 0x5e, 0x65, 0x98, 0x3d, 0x74, 0x7d, 0x7e, 0x92, 0xdd, 0x49, - 0x6a, 0xdf, 0x50, 0xa4, 0x4e, 0x53, 0xb2, 0x59, 0x45, 0x85, 0xac, 0x08, 0xc9, 0xfc, 0xcb, 0xeb, - 0x92, 0x2d, 0x4e, 0x52, 0x7b, 0x77, 0xd6, 0x51, 0x4a, 0xd8, 0xdb, 0xa0, 0x30, 0x90, 0x2d, 0x70, - 0x59, 0x8d, 0x3d, 0xeb, 0x35, 0x1d, 0x1b, 0x7f, 0x33, 0xd0, 0xed, 0x06, 0x0f, 0xdf, 0x76, 0x03, - 0x22, 0xa0, 0xc1, 0x82, 0x5e, 0x07, 0x5e, 0x91, 0x84, 0xc4, 0xdc, 0x7c, 0x86, 0x0a, 0xa4, 0x27, - 0xda, 0x2c, 0x89, 0xc4, 0x50, 0x97, 0x2f, 0xff, 0xfa, 0xb1, 0x5f, 0xd4, 0x37, 0x7c, 0x18, 0x04, - 0x09, 0x70, 0xfe, 0x5a, 0x24, 0x11, 0x0d, 0xbd, 0x19, 0x6a, 0xd6, 0x51, 0xbe, 0x2b, 0x1d, 0xe4, - 0x1c, 0x9b, 0xb5, 0x07, 0xce, 0xf2, 0x3d, 0x74, 0xe6, 0xd3, 0xea, 0xd7, 0x4e, 0x52, 0x3b, 0xe7, - 0xe9, 0x93, 0x07, 0xdb, 0x9f, 0xff, 0x7e, 0x7f, 0x3c, 0xf3, 0xc4, 0x36, 0xba, 0xb7, 0xb4, 0xe4, - 0x74, 0x8c, 0xda, 0xcf, 0x35, 0xb4, 0xde, 0xe0, 0xa1, 0x09, 0x68, 0x73, 0x7e, 0x95, 0xf6, 0x2e, - 0xcc, 0x5e, 0x58, 0x82, 0x8a, 0x73, 0x39, 0xee, 0x6c, 0x59, 0xb2, 0x98, 0xb9, 0x4b, 0x5e, 0x19, - 0x33, 0xe3, 0x56, 0xc7, 0x9c, 0xbf, 0x1c, 0xf3, 0x13, 0x32, 0x97, 0x5c, 0xcc, 0xfe, 0x0a, 0x97, - 0xf3, 0x78, 0xe5, 0xe9, 0x95, 0xf0, 0x69, 0x76, 0xfd, 0xc5, 0xc9, 0xc8, 0x32, 0x4e, 0x47, 0x96, - 0xf1, 0x67, 0x64, 0x19, 0x5f, 0xc6, 0x56, 0xee, 0x74, 0x6c, 0xe5, 0x7e, 0x8f, 0xad, 0xdc, 0xbb, - 0x5a, 0x18, 0x89, 0x76, 0xcf, 0x77, 0x5a, 0x2c, 0x76, 0x5f, 0x4a, 0xeb, 0xa3, 0x36, 0x89, 0xa8, - 0xab, 0x1f, 0xfb, 0xf1, 0xe2, 0x73, 0x17, 0xc3, 0x2e, 0x70, 0x3f, 0x2f, 0x1f, 0xfb, 0x93, 0x7f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xe6, 0x6f, 0xc2, 0xb5, 0x04, 0x00, 0x00, + // 787 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x4f, 0xe3, 0x46, + 0x18, 0x8e, 0x4b, 0x1a, 0x92, 0xa1, 0x7c, 0x19, 0x1a, 0x42, 0x2a, 0xe2, 0x6a, 0x54, 0xd1, 0x96, + 0x0a, 0x5b, 0x01, 0xb5, 0x07, 0x2e, 0x15, 0xa6, 0xea, 0xa9, 0xae, 0x90, 0xa1, 0x97, 0xaa, 0x52, + 0x34, 0x89, 0x07, 0xc7, 0x02, 0xcf, 0x44, 0x9e, 0x09, 0x90, 0xde, 0xda, 0x5f, 0xd0, 0x53, 0xff, + 0x40, 0x4f, 0xd5, 0x5e, 0xf6, 0xb0, 0x3f, 0x82, 0x23, 0xda, 0xd3, 0x9e, 0xac, 0x15, 0x1c, 0x56, + 0x7b, 0xcd, 0x2f, 0x58, 0xcd, 0x47, 0x9c, 0x40, 0x42, 0x76, 0x73, 0xd9, 0xdb, 0x78, 0xde, 0xe7, + 0x7d, 0xde, 0xe7, 0xf1, 0xbc, 0xef, 0x0c, 0xb0, 0x48, 0xd4, 0x8c, 0x92, 0xae, 0xc3, 0xe9, 0x39, + 0x26, 0x67, 0xa8, 0xc5, 0x69, 0xd2, 0x73, 0x2e, 0xeb, 0x0e, 0xbf, 0xb6, 0x3b, 0x09, 0xe5, 0xd4, + 0x2c, 0x2b, 0x80, 0x3d, 0x0a, 0xb0, 0x2f, 0xeb, 0xd5, 0xf5, 0x90, 0x86, 0x54, 0x42, 0x1c, 0xb1, + 0x52, 0xe8, 0x6a, 0xad, 0x45, 0x59, 0x4c, 0x99, 0xd3, 0x44, 0x0c, 0x3b, 0x97, 0xf5, 0x26, 0xe6, + 0xa8, 0xee, 0xb4, 0x68, 0x44, 0x74, 0x7c, 0x43, 0xc7, 0x63, 0x16, 0x8a, 0x2a, 0x31, 0x0b, 0x75, + 0x60, 0x53, 0x05, 0x1a, 0x8a, 0x51, 0x7d, 0x8c, 0x71, 0x92, 0xf3, 0x8c, 0x53, 0x7c, 0xe8, 0x38, + 0x7c, 0xc2, 0x02, 0xe3, 0x88, 0x63, 0x85, 0x81, 0x17, 0x60, 0xc9, 0x63, 0xe1, 0x51, 0x82, 0x11, + 0xc7, 0x3f, 0x61, 0x42, 0x63, 0xf3, 0x5b, 0x50, 0x60, 0x98, 0x04, 0x38, 0xa9, 0x18, 0x5f, 0x1a, + 0xdf, 0x94, 0xdc, 0xd5, 0x7e, 0x6a, 0x2d, 0xf6, 0x50, 0x7c, 0x71, 0x00, 0xd5, 0x3e, 0xf4, 0x35, + 0xc0, 0x74, 0x40, 0x91, 0x75, 0x9b, 0x81, 0x48, 0xab, 0x7c, 0x22, 0xc1, 0x6b, 0xfd, 0xd4, 0x5a, + 0xd6, 0x60, 0x1d, 0x81, 0x7e, 0x06, 0x82, 0x7f, 0x80, 0xf2, 0xc3, 0x6a, 0x3e, 0x66, 0x1d, 0x4a, + 0x18, 0x36, 0x5d, 0xb0, 0x4c, 0xf0, 0x55, 0x43, 0x4a, 0x6d, 0x28, 0x46, 0x55, 0xbe, 0xda, 0x4f, + 0xad, 0xb2, 0x62, 0x7c, 0x04, 0x80, 0xfe, 0x22, 0xc1, 0x57, 0xa7, 0x62, 0x43, 0x72, 0xc1, 0x7f, + 0x0d, 0x65, 0xa6, 0x8d, 0x48, 0x88, 0x0f, 0x83, 0x38, 0x22, 0xb3, 0x98, 0xd9, 0x06, 0x9f, 0x8e, + 0x3a, 0x59, 0xe9, 0xa7, 0xd6, 0x67, 0x0a, 0xa9, 0xab, 0xa9, 0xb0, 0x59, 0x07, 0x25, 0x21, 0x04, + 0x09, 0xfe, 0xca, 0x9c, 0xc4, 0xae, 0xf7, 0x53, 0x6b, 0x65, 0xa8, 0x51, 0x86, 0xa0, 0x5f, 0x24, + 0xf8, 0x4a, 0xaa, 0x80, 0x15, 0x65, 0x7b, 0xa8, 0x6b, 0x60, 0x1b, 0xfe, 0x67, 0x80, 0xcf, 0x3d, + 0x16, 0xfe, 0xd6, 0x09, 0x10, 0xc7, 0x1e, 0x0d, 0xba, 0x17, 0xf8, 0x18, 0x25, 0x28, 0x66, 0xe6, + 0x0f, 0xa0, 0x84, 0xba, 0xbc, 0x4d, 0x93, 0x88, 0xf7, 0xb4, 0xf8, 0xca, 0xcb, 0x17, 0xbb, 0xeb, + 0xba, 0x03, 0x0e, 0x83, 0x20, 0xc1, 0x8c, 0x9d, 0xf0, 0x24, 0x22, 0xa1, 0x3f, 0x84, 0x9a, 0x2e, + 0x28, 0x74, 0x24, 0x83, 0xf4, 0xb1, 0xb0, 0xf7, 0x95, 0x3d, 0xb9, 0x4f, 0xed, 0xd1, 0x6a, 0x6e, + 0xfe, 0x26, 0xb5, 0x72, 0xbe, 0xce, 0x3c, 0x58, 0xfa, 0xfb, 0xcd, 0xf3, 0x9d, 0x21, 0x27, 0xb4, + 0xc0, 0xd6, 0x44, 0x91, 0x99, 0x8d, 0xff, 0x0d, 0x30, 0xef, 0xb1, 0xd0, 0x8b, 0x08, 0x9f, 0xe5, + 0x97, 0xbb, 0x20, 0x2f, 0x46, 0x40, 0x2b, 0xdd, 0xb4, 0xb5, 0x37, 0x31, 0x23, 0xb6, 0xee, 0x67, + 0xfb, 0x88, 0x46, 0xc4, 0x5d, 0x13, 0xf2, 0xfa, 0xa9, 0xb5, 0xa0, 0x78, 0x44, 0x12, 0xf4, 0x65, + 0xae, 0xe9, 0x80, 0xf9, 0x38, 0x22, 0xbc, 0xc1, 0xa9, 0x3e, 0x8c, 0xf2, 0x4d, 0x6a, 0x19, 0xfd, + 0xd4, 0x5a, 0x52, 0x58, 0x1d, 0x84, 0x7e, 0x41, 0xac, 0x4e, 0x29, 0xdc, 0x01, 0xcb, 0x5a, 0x6a, + 0xd6, 0x7c, 0x1b, 0x43, 0x0e, 0xa9, 0x39, 0xc3, 0x3e, 0x53, 0xbe, 0xdc, 0x6e, 0x42, 0x3e, 0xb6, + 0xaf, 0x3a, 0x28, 0x35, 0xbb, 0x09, 0x69, 0x9c, 0x25, 0x34, 0x1e, 0x6f, 0xb3, 0x2c, 0x04, 0xfd, + 0xa2, 0x58, 0xff, 0x2c, 0x96, 0xab, 0xd2, 0x99, 0x10, 0x9b, 0x1d, 0xcc, 0x5f, 0x06, 0x58, 0xf3, + 0x58, 0x78, 0x82, 0xb9, 0x1c, 0x11, 0x0f, 0x73, 0x14, 0x20, 0x8e, 0x66, 0x31, 0xf3, 0x23, 0x28, + 0xc6, 0x3a, 0x4d, 0x1b, 0xda, 0x1a, 0x1a, 0x22, 0xe7, 0x99, 0xa1, 0x01, 0xb7, 0xee, 0xa5, 0x2c, + 0x09, 0x6e, 0x81, 0x2f, 0x26, 0x48, 0x18, 0x48, 0xdc, 0x7b, 0x9b, 0x07, 0x73, 0x1e, 0x0b, 0x4d, + 0x0c, 0x16, 0x46, 0xaf, 0xa1, 0xed, 0x27, 0xfb, 0xf6, 0xc1, 0x05, 0x52, 0xb5, 0x3f, 0x0c, 0x97, + 0x9d, 0xb5, 0x28, 0x33, 0x72, 0x41, 0x4c, 0x2d, 0x33, 0xc4, 0x4d, 0x2f, 0x33, 0x3e, 0xd8, 0xe6, + 0x9f, 0xc0, 0x9c, 0x30, 0xd4, 0xbb, 0x53, 0x58, 0xc6, 0xe1, 0xd5, 0xef, 0x67, 0x82, 0x67, 0xb5, + 0x8f, 0x41, 0x5e, 0x4e, 0xa2, 0x35, 0x25, 0x5d, 0x00, 0xaa, 0x5f, 0xbf, 0x07, 0x30, 0xca, 0x28, + 0x67, 0x60, 0x1a, 0xa3, 0x00, 0x4c, 0x65, 0x1c, 0x6d, 0x4c, 0x93, 0x83, 0x95, 0xb1, 0xa6, 0xfc, + 0x6e, 0x4a, 0xf2, 0x63, 0x70, 0x75, 0x7f, 0x06, 0xf0, 0xa0, 0xaa, 0xfb, 0xcb, 0xcd, 0x5d, 0xcd, + 0xb8, 0xbd, 0xab, 0x19, 0xaf, 0xef, 0x6a, 0xc6, 0x3f, 0xf7, 0xb5, 0xdc, 0xed, 0x7d, 0x2d, 0xf7, + 0xea, 0xbe, 0x96, 0xfb, 0x7d, 0x2f, 0x8c, 0x78, 0xbb, 0xdb, 0xb4, 0x5b, 0x34, 0x76, 0x7e, 0x95, + 0xc4, 0x47, 0x6d, 0x14, 0x11, 0x47, 0x3f, 0xa1, 0xd7, 0x0f, 0x1f, 0x51, 0xde, 0xeb, 0x60, 0xd6, + 0x2c, 0xc8, 0x27, 0x74, 0xff, 0x5d, 0x00, 0x00, 0x00, 0xff, 0xff, 0x36, 0x8b, 0xd0, 0xb4, 0x2b, + 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -395,6 +720,9 @@ type MsgClient interface { // UpdateModuleParams: A governance operation for updating the x/tokenfactory // module parameters. UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleParams, opts ...grpc.CallOption) (*MsgUpdateModuleParamsResponse, error) + Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) + Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) + SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, error) } type msgClient struct { @@ -432,6 +760,33 @@ func (c *msgClient) UpdateModuleParams(ctx context.Context, in *MsgUpdateModuleP return out, nil } +func (c *msgClient) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) { + out := new(MsgMintResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/Mint", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) { + out := new(MsgBurnResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/Burn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetDenomMetadata(ctx context.Context, in *MsgSetDenomMetadata, opts ...grpc.CallOption) (*MsgSetDenomMetadataResponse, error) { + out := new(MsgSetDenomMetadataResponse) + err := c.cc.Invoke(ctx, "/nibiru.tokenfactory.v1.Msg/SetDenomMetadata", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // CreateDenom: registers a token factory denom. @@ -440,6 +795,9 @@ type MsgServer interface { // UpdateModuleParams: A governance operation for updating the x/tokenfactory // module parameters. UpdateModuleParams(context.Context, *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, error) + Mint(context.Context, *MsgMint) (*MsgMintResponse, error) + Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) + SetDenomMetadata(context.Context, *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -455,6 +813,15 @@ func (*UnimplementedMsgServer) ChangeAdmin(ctx context.Context, req *MsgChangeAd func (*UnimplementedMsgServer) UpdateModuleParams(ctx context.Context, req *MsgUpdateModuleParams) (*MsgUpdateModuleParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateModuleParams 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) SetDenomMetadata(ctx context.Context, req *MsgSetDenomMetadata) (*MsgSetDenomMetadataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetDenomMetadata not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -514,6 +881,60 @@ func _Msg_UpdateModuleParams_Handler(srv interface{}, ctx context.Context, dec f 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: "/nibiru.tokenfactory.v1.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: "/nibiru.tokenfactory.v1.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_SetDenomMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetDenomMetadata) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetDenomMetadata(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.tokenfactory.v1.Msg/SetDenomMetadata", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetDenomMetadata(ctx, req.(*MsgSetDenomMetadata)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.tokenfactory.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -530,6 +951,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateModuleParams", Handler: _Msg_UpdateModuleParams_Handler, }, + { + MethodName: "Mint", + Handler: _Msg_Mint_Handler, + }, + { + MethodName: "Burn", + Handler: _Msg_Burn_Handler, + }, + { + MethodName: "SetDenomMetadata", + Handler: _Msg_SetDenomMetadata_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/tokenfactory/v1/tx.proto", @@ -694,146 +1127,997 @@ func (m *MsgUpdateModuleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { if err != nil { return 0, err } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateModuleParamsResponse) 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 *MsgUpdateModuleParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateModuleParamsResponse) 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.Subdenom) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateModuleParamsResponse) 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 *MsgUpdateModuleParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateModuleParamsResponse) 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.MintTo) > 0 { + i -= len(m.MintTo) + copy(dAtA[i:], m.MintTo) + i = encodeVarintTx(dAtA, i, uint64(len(m.MintTo))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Coin.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 + if len(m.MintTo) > 0 { + i -= len(m.MintTo) + copy(dAtA[i:], m.MintTo) + i = encodeVarintTx(dAtA, i, uint64(len(m.MintTo))) + i-- + dAtA[i] = 0xa + } + 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.BurnFrom) > 0 { + i -= len(m.BurnFrom) + copy(dAtA[i:], m.BurnFrom) + i = encodeVarintTx(dAtA, i, uint64(len(m.BurnFrom))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.Coin.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 *MsgSetDenomMetadata) 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 *MsgSetDenomMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDenomMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Metadata.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 *MsgSetDenomMetadataResponse) 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 *MsgSetDenomMetadataResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDenomMetadataResponse) 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.Subdenom) + 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 + l = len(m.NewTokenDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(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 (m *MsgUpdateModuleParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateModuleParamsResponse) 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.Coin.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.MintTo) + 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 + l = len(m.MintTo) + if l > 0 { + n += 1 + l + sovTx(uint64(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.Coin.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.BurnFrom) + 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 *MsgSetDenomMetadata) 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.Metadata.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetDenomMetadataResponse) 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 Subdenom", 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.Subdenom = 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 { + 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:]) + 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 + 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: MsgChangeAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChangeAdmin: 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 Denom", 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.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 + 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 *MsgChangeAdminResponse) 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: MsgChangeAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgChangeAdminResponse: 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 *MsgUpdateModuleParams) 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: MsgUpdateModuleParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateModuleParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 + } } - return n -} - -func (m *MsgCreateDenomResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.NewTokenDenom) - if l > 0 { - n += 1 + l + sovTx(uint64(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 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } - -func (m *MsgUpdateModuleParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgUpdateModuleParamsResponse) 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: MsgUpdateModuleParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: 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 + } } - l = m.Params.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} -func (m *MsgUpdateModuleParamsResponse) 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 *MsgMint) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -856,10 +2140,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: MsgMint: 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: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -896,7 +2180,40 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subdenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Coin", 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.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintTo", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -924,7 +2241,7 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Subdenom = string(dAtA[iNdEx:postIndex]) + m.MintTo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -947,7 +2264,7 @@ func (m *MsgCreateDenom) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { +func (m *MsgMintResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -970,15 +2287,15 @@ 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: MsgMintResponse: 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: MsgMintResponse: 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) + return fmt.Errorf("proto: wrong wireType = %d for field MintTo", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1006,7 +2323,7 @@ func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NewTokenDenom = string(dAtA[iNdEx:postIndex]) + m.MintTo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1029,7 +2346,7 @@ func (m *MsgCreateDenomResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { +func (m *MsgBurn) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1052,10 +2369,10 @@ func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChangeAdmin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgBurn: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChangeAdmin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1092,9 +2409,9 @@ func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1104,27 +2421,28 @@ func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewAdmin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BurnFrom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1152,7 +2470,7 @@ func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NewAdmin = string(dAtA[iNdEx:postIndex]) + m.BurnFrom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1175,7 +2493,7 @@ func (m *MsgChangeAdmin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error { +func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1198,10 +2516,10 @@ func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChangeAdminResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgBurnResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChangeAdminResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1225,7 +2543,7 @@ func (m *MsgChangeAdminResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error { +func (m *MsgSetDenomMetadata) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1248,15 +2566,15 @@ func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateModuleParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetDenomMetadata: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateModuleParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetDenomMetadata: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1284,11 +2602,11 @@ func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1315,7 +2633,7 @@ func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1340,7 +2658,7 @@ func (m *MsgUpdateModuleParams) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateModuleParamsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSetDenomMetadataResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1363,10 +2681,10 @@ func (m *MsgUpdateModuleParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetDenomMetadataResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateModuleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetDenomMetadataResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/tokenfactory/types/tx_msgs.go b/x/tokenfactory/types/tx_msgs.go index b799b0c0c..7a9ebd861 100644 --- a/x/tokenfactory/types/tx_msgs.go +++ b/x/tokenfactory/types/tx_msgs.go @@ -92,6 +92,85 @@ func (m MsgChangeAdmin) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } +// ---------------------------------------------------------------- +// MsgMint + +var _ sdk.Msg = &MsgMint{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgMint) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid sender (%s): %s", m.Sender, err) + } + + if err := validateCoin(m.Coin); err != nil { + return err + } else if err := DenomStr(m.Coin.Denom).Validate(); err != nil { + return err + } + + if m.MintTo != "" { + _, err = sdk.AccAddressFromBech32(m.MintTo) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid mint_to (%s): %s", m.MintTo, err) + } + } + + return err +} + +// GetSigners: Impl sdk.Msg. +func (m MsgMint) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + +func validateCoin(coin sdk.Coin) error { + if !coin.IsValid() || coin.IsZero() { + return sdkerrors.ErrInvalidCoins.Wrap(coin.String()) + } + return nil +} + +// ---------------------------------------------------------------- +// MsgBurn + +var _ sdk.Msg = &MsgBurn{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgBurn) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid sender (%s): %s", m.Sender, err) + } + + if err := validateCoin(m.Coin); err != nil { + return err + } else if err := DenomStr(m.Coin.Denom).Validate(); err != nil { + return err + } + + if m.BurnFrom != "" { + _, err = sdk.AccAddressFromBech32(m.BurnFrom) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid burn_from (%s): %s", m.BurnFrom, err) + } + } + + return nil +} + +// GetSigners: Impl sdk.Msg. +func (m MsgBurn) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} + // ---------------------------------------------------------------- // MsgUpdateModuleParams @@ -111,3 +190,24 @@ func (m MsgUpdateModuleParams) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Authority) return []sdk.AccAddress{sender} } + +// ---------------------------------------------------------------- +// MsgSetDenomMetadata + +var _ sdk.Msg = &MsgSetDenomMetadata{} + +// ValidateBasic performs stateless validation checks. Impl sdk.Msg. +func (m MsgSetDenomMetadata) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf( + "invalid sender (%s): %s", m.Sender, err) + } + return m.Metadata.Validate() +} + +// GetSigners: Impl sdk.Msg. +func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress { + sender, _ := sdk.AccAddressFromBech32(m.Sender) + return []sdk.AccAddress{sender} +} diff --git a/x/tokenfactory/types/tx_msgs_test.go b/x/tokenfactory/types/tx_msgs_test.go index bdc08a776..ae28bf3d8 100644 --- a/x/tokenfactory/types/tx_msgs_test.go +++ b/x/tokenfactory/types/tx_msgs_test.go @@ -10,11 +10,21 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/tokenfactory/types" ) -func validateBasicTest(msg sdk.Msg, wantErr string) func(t *testing.T) { +type ValidateBasicTest struct { + name string + msg sdk.Msg + wantErr string +} + +func (vbt ValidateBasicTest) test() func(t *testing.T) { + var msg sdk.Msg = vbt.msg + var wantErr string = vbt.wantErr return func(t *testing.T) { err := msg.ValidateBasic() if wantErr != "" { @@ -26,12 +36,7 @@ func validateBasicTest(msg sdk.Msg, wantErr string) func(t *testing.T) { } } -type ValidateBasicTest struct { - name string - msg sdk.Msg - wantErr string -} - +// TestMsgMint_ValidateBasic: Tests if MsgCreateDenom is properly validated. func TestMsgCreateDenom_ValidateBasic(t *testing.T) { addr := testutil.AccAddress().String() for _, tc := range []ValidateBasicTest{ @@ -60,10 +65,11 @@ func TestMsgCreateDenom_ValidateBasic(t *testing.T) { wantErr: "invalid creator", }, } { - t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + t.Run(tc.name, tc.test()) } } +// TestMsgMint_ValidateBasic: Tests if MsgChangeAdmin is properly validated. func TestMsgChangeAdmin_ValidateBasic(t *testing.T) { sbf := testutil.AccAddress().String() validDenom := fmt.Sprintf("tf/%s/ftt", sbf) @@ -105,7 +111,7 @@ func TestMsgChangeAdmin_ValidateBasic(t *testing.T) { wantErr: "denom format error", }, } { - t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + t.Run(tc.name, tc.test()) } } @@ -128,13 +134,14 @@ func TestMsgUpdateModuleParams_ValidateBasic(t *testing.T) { wantErr: "invalid authority", }, } { - t.Run(tc.name, validateBasicTest(tc.msg, tc.wantErr)) + t.Run(tc.name, tc.test()) } } func TestTxMsgInterface(t *testing.T) { creator := testutil.AccAddress().String() subdenom := testutil.RandLetters(4) + denomStr := fmt.Sprintf("tf/%s/%s", creator, subdenom) for _, msg := range []legacytx.LegacyMsg{ &types.MsgCreateDenom{ Sender: creator, @@ -142,7 +149,7 @@ func TestTxMsgInterface(t *testing.T) { }, &types.MsgChangeAdmin{ Sender: creator, - Denom: fmt.Sprintf("tf/%s/%s", creator, subdenom), + Denom: denomStr, NewAdmin: testutil.AccAddress().String(), }, } { @@ -161,9 +168,198 @@ func TestTxMsgInterface(t *testing.T) { Authority: testutil.GovModuleAddr().String(), Params: types.DefaultModuleParams(), }, + &types.MsgMint{ + Sender: creator, + Coin: sdk.NewInt64Coin(denomStr, 420), + MintTo: "", + }, + &types.MsgBurn{ + Sender: creator, + Coin: sdk.NewInt64Coin(denomStr, 420), + BurnFrom: "", + }, } { require.NotPanics(t, func() { _ = msg.GetSigners() }) } } + +// TestMsgMint_ValidateBasic: Tests if tx msgs MsgMint and MsgBurn are properly +// validated. +func TestMsgMint_ValidateBasic(t *testing.T) { + sbf := testutil.AccAddress().String() + validDenom := fmt.Sprintf("tf/%s/ftt", sbf) + validCoin := sdk.NewInt64Coin(validDenom, 420) + for _, tc := range []ValidateBasicTest{ + { + name: "happy", + msg: &types.MsgMint{ + Sender: sbf, + Coin: validCoin, + MintTo: "", + }, + wantErr: "", + }, + { + name: "invalid sender", + msg: &types.MsgMint{ + Sender: "sender", + Coin: validCoin, + MintTo: "", + }, + wantErr: "invalid address", + }, + { + name: "invalid denom", + msg: &types.MsgMint{ + Sender: sbf, + Coin: sdk.Coin{Denom: "tf/", Amount: sdk.NewInt(420)}, + MintTo: "", + }, + wantErr: "denom format error", + }, + { + name: "invalid mint to addr", + msg: &types.MsgMint{ + Sender: sbf, + Coin: validCoin, + MintTo: "mintto", + }, + wantErr: "invalid mint_to", + }, + { + name: "invalid coin", + msg: &types.MsgMint{ + Sender: sbf, + Coin: sdk.Coin{Amount: sdk.NewInt(-420)}, + MintTo: "", + }, + wantErr: "invalid coin", + }, + } { + t.Run(tc.name, tc.test()) + } +} + +func TestMsgBurn_ValidateBasic(t *testing.T) { + sbf := testutil.AccAddress().String() + validDenom := fmt.Sprintf("tf/%s/ftt", sbf) + validCoin := sdk.NewInt64Coin(validDenom, 420) + for _, tc := range []ValidateBasicTest{ + { + name: "happy", + msg: &types.MsgBurn{ + Sender: sbf, + Coin: validCoin, + BurnFrom: "", + }, + wantErr: "", + }, + { + name: "invalid sender", + msg: &types.MsgBurn{ + Sender: "sender", + Coin: validCoin, + BurnFrom: "", + }, + wantErr: "invalid address", + }, + { + name: "invalid denom", + msg: &types.MsgBurn{ + Sender: sbf, + Coin: sdk.Coin{Denom: "tf/", Amount: sdk.NewInt(420)}, + BurnFrom: "", + }, + wantErr: "denom format error", + }, + { + name: "invalid burn from addr", + msg: &types.MsgBurn{ + Sender: sbf, + Coin: validCoin, + BurnFrom: "mintto", + }, + wantErr: "invalid burn_from", + }, + { + name: "invalid coin", + msg: &types.MsgBurn{ + Sender: sbf, + Coin: sdk.Coin{Amount: sdk.NewInt(-420)}, + BurnFrom: "", + }, + wantErr: "invalid coin", + }, + } { + t.Run(tc.name, tc.test()) + } +} + +func TestMsgSetDenomMetadata_ValidateBasic(t *testing.T) { + sbf := testutil.AccAddress().String() + satoshi := testutil.AccAddress().String() + ubtcDenom := fmt.Sprintf("tf/%s/ubtc", satoshi) + for _, tc := range []ValidateBasicTest{ + { + name: "happy: satoshi nakamoto", + msg: &types.MsgSetDenomMetadata{ + Sender: satoshi, + Metadata: banktypes.Metadata{ + Description: "satoshi nakamoto bitcoin", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: ubtcDenom, Exponent: 0}, + {Denom: "btc", Exponent: 6}, + }, + Base: ubtcDenom, + Display: "btc", + Name: "bitcoin", + Symbol: "BTC", + }, + }, + wantErr: "", + }, + + { + name: "happy: SBF", + msg: &types.MsgSetDenomMetadata{ + Sender: sbf, + Metadata: types.DenomStr(fmt.Sprintf("tf/%s/ftt", sbf)). + MustToStruct().DefaultBankMetadata(), + }, + wantErr: "", + }, + + { + name: "invalid sender", + msg: &types.MsgSetDenomMetadata{ + Sender: "notAnAddr", + Metadata: types.TFDenom{Creator: "notAnAddr", Subdenom: "abc"}. + DefaultBankMetadata(), + }, + wantErr: "invalid address", + }, + + { + name: "sad: base denom doesn't match", + msg: &types.MsgSetDenomMetadata{ + Sender: satoshi, + Metadata: banktypes.Metadata{ + Description: "satoshi nakamoto bitcoin", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: ubtcDenom, Exponent: 0}, + {Denom: "wbtc", Exponent: 6}, // must be first + }, + Base: "wbtc", + Display: "wbtc", + Name: "bitcoin", + Symbol: "BTC", + }, + }, + wantErr: "metadata's first denomination unit must be the one with base denom", + }, + } { + t.Run(tc.name, tc.test()) + } +} From a85f30801a29a358f93f9d54b94792be39d51a4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Oct 2023 05:18:34 +0000 Subject: [PATCH 08/10] chore(deps): Bump bufbuild/buf-setup-action from 1.26.1 to 1.27.0 (#1624) * chore(deps): Bump bufbuild/buf-setup-action from 1.26.1 to 1.27.0 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.26.1 to 1.27.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.26.1...v1.27.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Updated changelog - dependabot --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Co-authored-by: Unique-Divine --- .github/workflows/proto-lint.yml | 4 ++-- CHANGELOG.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/proto-lint.yml b/.github/workflows/proto-lint.yml index 62af37839..57cb0c73d 100644 --- a/.github/workflows/proto-lint.yml +++ b/.github/workflows/proto-lint.yml @@ -22,7 +22,7 @@ jobs: # timeout-minutes: 5 # steps: # - uses: actions/checkout@v4 - # - uses: bufbuild/buf-setup-action@v1.26.1 + # - uses: bufbuild/buf-setup-action@v1.27.0 # - uses: bufbuild/buf-lint-action@v1 # with: # input: "proto" @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.26.1 + - uses: bufbuild/buf-setup-action@v1.27.0 with: github_token: ${{ github.token }} - uses: bufbuild/buf-breaking-action@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index c39ef8fc3..24885a885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Dependencies - Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605)) +- Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.27.0 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624)) ## [v0.21.10] @@ -679,4 +680,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Testing * [#695](https://github.com/NibiruChain/nibiru/pull/695) Add `OpenPosition` integration tests. -* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods. +* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods. \ No newline at end of file From 7d1adb023b37cd49761209b1f350e46db9b6a6ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 7 Oct 2023 05:19:44 +0000 Subject: [PATCH 09/10] chore(deps): Bump stefanzweifel/git-auto-commit-action from 4 to 5 (#1625) Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 4 to 5. - [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases) - [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md) - [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4...v5) --- updated-dependencies: - dependency-name: stefanzweifel/git-auto-commit-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> --- .github/workflows/changelog-deps.yml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changelog-deps.yml b/.github/workflows/changelog-deps.yml index 2df19e0d6..b9336196d 100644 --- a/.github/workflows/changelog-deps.yml +++ b/.github/workflows/changelog-deps.yml @@ -22,6 +22,6 @@ jobs: activationLabel: 'dependabot' changelogPath: './CHANGELOG.md' - - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Updated changelog - dependabot" diff --git a/CHANGELOG.md b/CHANGELOG.md index 24885a885..c3590d742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Dependencies - Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605)) - Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.27.0 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624)) +- Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#1625](https://github.com/NibiruChain/nibiru/pull/1625)) ## [v0.21.10] From 40f8e71373333f0c35767aeae6dd31b2c0ddb7d8 Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Sat, 7 Oct 2023 20:55:52 -0500 Subject: [PATCH 10/10] fix(perp): emit MarketUpdatedEvents even in the absence of index price (#1606) --- CHANGELOG.md | 4 ++++ x/perp/v2/module/abci.go | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3590d742..7f3a17466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.27.0 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624)) - Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#1625](https://github.com/NibiruChain/nibiru/pull/1625)) +### Bug Fixes + +* [#1606](https://github.com/NibiruChain/nibiru/pull/1606) - fix(perp): emit `MarketUpdatedEvent` in the absence of index price + ## [v0.21.10] ### Features diff --git a/x/perp/v2/module/abci.go b/x/perp/v2/module/abci.go index 8b9edb281..6326700dc 100644 --- a/x/perp/v2/module/abci.go +++ b/x/perp/v2/module/abci.go @@ -37,18 +37,19 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate { continue } - indexTwap, err := k.OracleKeeper.GetExchangeRateTwap(ctx, amm.Pair) - if err != nil { - k.Logger(ctx).Error("failed to fetch twap index price", "market.Pair", market.Pair, "error", err) - continue - } - if markTwap.IsNil() || markTwap.IsZero() { k.Logger(ctx).Error("mark price is zero", "market.Pair", market.Pair) continue } - if indexTwap.IsNil() || indexTwap.IsZero() { + var indexTwap sdk.Dec + indexTwap, err = k.OracleKeeper.GetExchangeRateTwap(ctx, amm.Pair) + if err != nil { + k.Logger(ctx).Error("failed to fetch twap index price", "market.Pair", market.Pair, "error", err) + indexTwap = sdk.OneDec().Neg() + } + + if indexTwap.IsNil() { k.Logger(ctx).Error("index price is zero", "market.Pair", market.Pair) continue }